Add support for const references to pointers

They're used in some unit tests and we can support them by handling them
just as pointers in C++ wrappers (this was already the case for C
wrappers).
This commit is contained in:
Vadim Zeitlin 2021-12-08 03:26:44 +01:00
commit 1fd4c647b8
3 changed files with 11 additions and 4 deletions

View file

@ -719,7 +719,16 @@ private:
} else {
String* classname;
if (Node* const class_node = Language::instance()->classLookup(type)) {
typestr = SwigType_str(resolved_type, 0);
// Special case: if this is a pointer passed by (const) reference, we return just the pointer directly because we don't have any pointer-valued variable
// to give out a reference to.
if (typeKind == Type_Ptr && strncmp(Char(resolved_type), "r.q(const).", 11) == 0) {
scoped_dohptr deref_type(Copy(resolved_type));
Delslice(deref_type, 0, 11);
typestr = SwigType_str(deref_type, 0);
} else {
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