Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move _cxstring_to_string out of cursor.jl. #423

Merged
merged 1 commit into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Clang.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ foreach(names(@__MODULE__; all=true)) do s
end
end

include("string.jl")

include("index.jl")
export Index

Expand Down
9 changes: 0 additions & 9 deletions src/cursor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/string.jl
Original file line number Diff line number Diff line change
@@ -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