From fde4a016f5ac5fe81287e7f32a30a8fd2b060fb8 Mon Sep 17 00:00:00 2001 From: Nehal Patel Date: Fri, 17 Mar 2023 15:49:40 -0400 Subject: [PATCH] Move `_cxstring_to_string` out of `cursor.jl`. --- src/Clang.jl | 2 ++ src/cursor.jl | 9 --------- src/string.jl | 8 ++++++++ 3 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 src/string.jl diff --git a/src/Clang.jl b/src/Clang.jl index db9d40c3..177cb862 100644 --- a/src/Clang.jl +++ b/src/Clang.jl @@ -24,6 +24,8 @@ foreach(names(@__MODULE__; all=true)) do s end end +include("string.jl") + include("index.jl") export Index diff --git a/src/cursor.jl b/src/cursor.jl index ee20825f..ad89d81e 100644 --- a/src/cursor.jl +++ b/src/cursor.jl @@ -18,15 +18,6 @@ Base.hash(x::CLCursor) = hash(x.cursor) Base.:(==)(c1::CLCursor, c2::CXCursor) = c1.cursor == c2 Base.:(==)(c1::CXCursor, c2::CLCursor) = c1 == c2.cursor -"Free and convert a CXString to String. Note this function will free the given CXString so ensure it is not called twice." -function _cxstring_to_string(cxstr::CXString) - ptr = clang_getCString(cxstr) - ptr == C_NULL && return "" - s = unsafe_string(ptr) - clang_disposeString(cxstr) - return s -end - """ kind(c::CXCursor) -> CXCursorKind Return the kind of the given cursor. diff --git a/src/string.jl b/src/string.jl new file mode 100644 index 00000000..68cfee90 --- /dev/null +++ b/src/string.jl @@ -0,0 +1,8 @@ +"Free and convert a CXString to String. Note this function will free the given CXString so ensure it is not called twice." +function _cxstring_to_string(cxstr::CXString) + ptr = clang_getCString(cxstr) + ptr == C_NULL && return "" + s = unsafe_string(ptr) + clang_disposeString(cxstr) + return s +end