Fix dealing with class typedefs in do_resolve_type()

We must use the string for the resolved type, i.e. after replacing
typedefs with their expansions, as otherwise typedefs could leak into
the generated header.

In principle it might be possible to actually use the original typedefs
in the C++ part of the wrappers, but then we'd need to propagate the
typedef definitions there too and we don't do it currently.
This commit is contained in:
Vadim Zeitlin 2021-12-07 16:51:53 +01:00
commit 730384834d

View file

@ -715,12 +715,12 @@ private:
} else {
String* classname;
if (Node* const class_node = Language::instance()->classLookup(type)) {
typestr = SwigType_str(type, 0);
typestr = SwigType_str(resolved_type, 0);
classname = Getattr(class_node, "sym:name");
// We don't use namespaces, but the type may contain them, so get rid of them by replacing the base type name, which is fully qualified, with just the
// class name, which is not.
scoped_dohptr basetype(SwigType_base(type));
scoped_dohptr basetype(SwigType_base(resolved_type));
scoped_dohptr basetypestr(SwigType_str(basetype, 0));
if (Cmp(basetypestr, classname) != 0) {
Replaceall(typestr, basetypestr, classname);