Skip to content

Commit 8f30ca2

Browse files
committed
Add docstrings for module support
1 parent 94b0d5f commit 8f30ca2

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/module.jl

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct CLModule
1+
struct CLModule
22
mod::CXModule
33
end
44

@@ -8,36 +8,65 @@ Base.unsafe_convert(::Type{CXModule}, x::CLModule) = x.mod
88

99
Base.show(io::IO, x::CLModule) = print(io, "CLModule ($(full_name(x)))")
1010

11-
11+
"""
12+
get_module(tu::TranslationUnit, file::CLFile) -> CLModule
13+
Given a CLFile header file, return the module that contains it, if one exists.
14+
"""
1215
function get_module(tu::TranslationUnit, file::CLFile)::CLModule
1316
return Clang.clang_getModuleForFile(tu, file)
1417
end
1518

19+
"""
20+
ast_file(mod::CLModule) -> CLFile
21+
Given a module, return the module file where the provided module object came from.
22+
"""
1623
function ast_file(mod::CLModule)::CLFile
1724
return Clang.clang_Module_getASTFile(mod)
1825
end
1926

27+
"""
28+
parent_module(mod::CLModule) -> CLModule
29+
Given a module, return the parent of a sub-module or NULL if the given module is top-level,
30+
e.g. for 'std.vector' it will return the 'std' module.
31+
"""
2032
function parent_module(mod::CLModule)::CLModule
2133
return Clang.clang_Module_getParent(mod)
2234
end
2335

36+
"""
37+
name(mod::CLModule)
38+
Given a module, return the name of the module,
39+
e.g. for the 'std.vector' sub-module it will return "vector".
40+
"""
2441
function name(mod::CLModule)
2542
return Clang.clang_Module_getName(mod) |> _cxstring_to_string
2643
end
2744

45+
"""
46+
full_name(mod::CLModule)
47+
Given a module, return the full name of the module, e.g. "std.vector".
48+
"""
2849
function full_name(mod::CLModule)
2950
return Clang.clang_Module_getFullName(mod) |> _cxstring_to_string
3051
end
3152

53+
"""
54+
is_system(mod::CLModule)
55+
Given a module, return whether it is a system one.
56+
"""
3257
function is_system(mod::CLModule)
3358
return Bool(Clang.clang_Module_isSystem(mod))
3459
end
3560

61+
"""
62+
toplevel_headers(tu::TranslationUnit, mod::CLModule)
63+
Given a module, return all top level headers associated with the module.
64+
"""
3665
function toplevel_headers(tu::TranslationUnit, mod::CLModule)
3766
num = Clang.clang_Module_getNumTopLevelHeaders(tu, mod)
3867
headers = Vector{CLFile}(undef, num)
3968
for i=1:num
40-
headers[i] = Clang.clang_Module_getTopLevelHeader(tu, mod, i-1)
69+
headers[i] = Clang.clang_Module_getTopLevelHeader(tu, mod, i-1)
4170
end
4271
return headers
4372
end

0 commit comments

Comments
 (0)