]> gitweb.factorcode.org Git - factor.git/commitdiff
libclang: add word to get an array from an array of ptrs
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 23 Jan 2024 19:12:19 +0000 (13:12 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 23 Jan 2024 19:12:19 +0000 (13:12 -0600)
extra/libclang/libclang.factor

index 9db16988d6d343bf40e7894cbc8e1376f21ed9e1..fad2a12853d67f421d0eb6f492989e886b5a215e 100644 (file)
@@ -342,15 +342,18 @@ M: object def>out-form
     [ drop ] [ clang-get-file-max-range ] 2bi
     clang-tokenize ;
 
-:: with-cursor-tokens ( cursor quot: ( tu token -- obj ) -- )
+: ptr-array>array ( ptr c-type n -- array )
+    [ heap-size ] [ <iota> ] bi*
+    [
+        * swap <displaced-alien>
+    ] with with { } map-as ;
+
+:: with-cursor-tokens ( cursor quot: ( tu token -- obj ) -- seq )
     cursor clang_Cursor_getTranslationUnit :> tu
     tu cursor clang_getCursorExtent clang-tokenize :> ( tokens ntokens )
-    tu tokens ntokens <iota>
-    CXToken heap-size :> bytesize
-    quot
-    '[
-        bytesize * swap <displaced-alien> @
-    ] with with { } map-as
+    tu
+    tokens CXToken ntokens ptr-array>array
+    [ clang_getTokenSpelling clang-get-cstring ] with map
     tu tokens ntokens clang_disposeTokens ; inline
 
 DEFER: cursor>c-struct