From: Doug Coleman Date: Tue, 23 Jan 2024 19:12:19 +0000 (-0600) Subject: libclang: add word to get an array from an array of ptrs X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=54a1bd4bd51ce20859b5c0619d335324b2fa80e2 libclang: add word to get an array from an array of ptrs --- diff --git a/extra/libclang/libclang.factor b/extra/libclang/libclang.factor index 9db16988d6..fad2a12853 100644 --- a/extra/libclang/libclang.factor +++ b/extra/libclang/libclang.factor @@ -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 ] [ ] bi* + [ + * swap + ] 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 - CXToken heap-size :> bytesize - quot - '[ - bytesize * swap @ - ] 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