@@ -46,7 +46,7 @@ resolve_headers(headers::Vector{String}, include_paths::Vector{String})::Vector{
4646 resolve_header .(headers, Ref (include_paths))
4747
4848function get_full_name (cursor, funcargs:: Bool = true , buf= " " )
49- parent = Clang. getCursorLexicalParent (cursor)
49+ parent = Clang. getCursorSemanticParent (cursor)
5050 parent_kind = spelling (kind (parent))
5151 cursor_name = name (cursor)
5252 if ! funcargs
@@ -111,6 +111,36 @@ function get_julia_name(cursor::CLCursor)
111111 replace (vname, " ::" => " " )
112112end
113113
114+ nns (x:: Clang.CLInvalidFile ) = " "
115+ nns (x:: Clang.CLTranslationUnit ) = " "
116+ function nns (x:: CLCursor )
117+ pn = nns (Clang. getCursorSemanticParent (x))
118+ if isempty (pn)
119+ return spelling (x)
120+ else
121+ return pn * " ::" * spelling (x)
122+ end
123+ end
124+ get_qualified_name (x:: CLCursor ) = isempty (spelling (x)) ? " " : nns (x)
125+
126+ get_qualified_basename (x:: CLCursor ) = " "
127+ function get_qualified_basename (x:: CLTypeRef )
128+ n = spelling (x)
129+ startswith (n, " class " ) && return split (n, " class " )[2 ]
130+ startswith (n, " struct " ) && return split (n, " struct " )[2 ]
131+ startswith (n, " Union " ) && return split (n, " Union " )[2 ]
132+ return " "
133+ end
134+ get_qualified_basename (x:: CLCXXBaseSpecifier ) = get_qualified_basename (children (x)[1 ])
135+ function get_qualified_basename (x:: Union{CLClassDecl,CLStructDecl,CLUnionDecl} )
136+ bn = get_qualified_basename (children (x)[1 ])
137+ if isempty (bn)
138+ return spelling (x)
139+ else
140+ return bn * " ::" * spelling (x)
141+ end
142+ end
143+
114144function object_decl_handler (ctx:: BindgenContext , classdecl:: CLCursor ):: Tuple{Union{Nothing, String}, Union{Nothing, String}}
115145 full_name = get_full_name (classdecl)
116146 length (children (classdecl)) == 0 && return nothing , " skip_empty_classdecl"
@@ -125,7 +155,7 @@ function object_decl_handler(ctx::BindgenContext, classdecl::CLCursor)::Tuple{Un
125155 # handle simple inheritance
126156 subnodes = children (classdecl)
127157 if length (subnodes) > 1 && kind (subnodes[1 ]) == Clang. CXCursor_CXXBaseSpecifier
128- base_class = get_full_name (subnodes[1 ])
158+ base_class = get_qualified_basename (subnodes[1 ])
129159 if ! isempty (base_class)
130160
131161 ctx. outputSupertypes *= " template<> struct SuperType<$full_name > { typedef $base_class type; };\n "
0 commit comments