|
| 1 | +struct CLModule |
| 2 | + mod::CXModule |
| 3 | +end |
| 4 | + |
| 5 | +Base.convert(::Type{CLModule}, x::CXModule) = CLModule(x) |
| 6 | +Base.cconvert(::Type{CXModule}, x::CLModule) = x |
| 7 | +Base.unsafe_convert(::Type{CXModule}, x::CLModule) = x.mod |
| 8 | + |
| 9 | +Base.show(io::IO, x::CLModule) = print(io, "CLModule ($(full_name(x)))") |
| 10 | + |
| 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 | +""" |
| 15 | +function get_module(tu::TranslationUnit, file::CLFile)::CLModule |
| 16 | + return Clang.clang_getModuleForFile(tu, file) |
| 17 | +end |
| 18 | + |
| 19 | +""" |
| 20 | + ast_file(mod::CLModule) -> CLFile |
| 21 | +Given a module, return the module file where the provided module object came from. |
| 22 | +""" |
| 23 | +function ast_file(mod::CLModule)::CLFile |
| 24 | + return Clang.clang_Module_getASTFile(mod) |
| 25 | +end |
| 26 | + |
| 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 | +""" |
| 32 | +function parent_module(mod::CLModule)::CLModule |
| 33 | + return Clang.clang_Module_getParent(mod) |
| 34 | +end |
| 35 | + |
| 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 | +""" |
| 41 | +function name(mod::CLModule) |
| 42 | + return Clang.clang_Module_getName(mod) |> _cxstring_to_string |
| 43 | +end |
| 44 | + |
| 45 | +""" |
| 46 | + full_name(mod::CLModule) |
| 47 | +Given a module, return the full name of the module, e.g. "std.vector". |
| 48 | +""" |
| 49 | +function full_name(mod::CLModule) |
| 50 | + return Clang.clang_Module_getFullName(mod) |> _cxstring_to_string |
| 51 | +end |
| 52 | + |
| 53 | +""" |
| 54 | + is_system(mod::CLModule) |
| 55 | +Given a module, return whether it is a system one. |
| 56 | +""" |
| 57 | +function is_system(mod::CLModule) |
| 58 | + return Bool(Clang.clang_Module_isSystem(mod)) |
| 59 | +end |
| 60 | + |
| 61 | +""" |
| 62 | + toplevel_headers(tu::TranslationUnit, mod::CLModule) |
| 63 | +Given a module, return all top level headers associated with the module. |
| 64 | +""" |
| 65 | +function toplevel_headers(tu::TranslationUnit, mod::CLModule) |
| 66 | + num = Clang.clang_Module_getNumTopLevelHeaders(tu, mod) |
| 67 | + headers = Vector{CLFile}(undef, num) |
| 68 | + for i=1:num |
| 69 | + headers[i] = Clang.clang_Module_getTopLevelHeader(tu, mod, i-1) |
| 70 | + end |
| 71 | + return headers |
| 72 | +end |
0 commit comments