Expand special variables in cxxcode typemap

This makes the typemap much more useful, as it can now reference the
name of the class it is being expanded for and the type of the C pointer
used by it (in principle, the latter could be recovered by using
decltype(), but this results in rather verbose code inside static
methods where a dummy pointer to the type must be constructed first, so
using another special variable seems like a simpler solution).
This commit is contained in:
Vadim Zeitlin 2021-12-06 20:22:49 +01:00
commit 8d9f3e88b2
2 changed files with 5 additions and 2 deletions

View file

@ -543,8 +543,11 @@ public:
scoped_dohptr cxxcode(Swig_typemap_lookup("cxxcode", dummy, "", NULL));
if (!cxxcode || *Char(cxxcode) != '\n')
Append(cxx_wrappers_.sect_decls, "\n");
if (cxxcode)
if (cxxcode) {
Replaceall(cxxcode, "$cxxclassname", classname);
Replaceall(cxxcode, "$cclassptrname", get_c_class_ptr(n));
Append(cxx_wrappers_.sect_decls, cxxcode);
}
class_node_ = n;
dtor_wname_ = NULL;