summaryrefslogtreecommitdiff
path: root/Source/Modules/python.cxx
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-11-18 19:44:00 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-11-18 19:44:00 +0000
commit29bc7492a2ec300997eaf670bf24f1556fef08cd (patch)
tree816e01c4a5513d2491f40694f62f375c564dbdf3 /Source/Modules/python.cxx
parent4729cf2b1f44e57f46d13758009b10cec5af47b6 (diff)
downloadswig-29bc7492a2ec300997eaf670bf24f1556fef08cd.tar.gz
SwigType * handling corrections - Python builtin mangling
Further corrections to pass SwigType * to methods expecting types instead of passing readable type strings. Swig_string_mangle() takes a generic String *, but it was calling functions that require SwigType *. Swig_string_mangle_type() is now provided for SwigType *. The previous commit is a pre-requisite in order to prevent duplicate symbols from being generated in the C++ wrappers.
Diffstat (limited to 'Source/Modules/python.cxx')
-rw-r--r--Source/Modules/python.cxx46
1 files changed, 27 insertions, 19 deletions
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 6f30c1faa..b613b2bd0 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -1898,16 +1898,20 @@ public:
String *str = Getattr(n, "feature:docstring");
if (!str || Len(str) == 0) {
if (builtin) {
- String *name = Getattr(n, "name");
- String *rname = add_explicit_scope(SwigType_namestr(name));
+ SwigType *name = Getattr(n, "name");
+ SwigType *sname = add_explicit_scope(name);
+ String *rname = SwigType_namestr(sname);
Printf(doc, "%s", rname);
+ Delete(sname);
Delete(rname);
} else {
+ String *classname_str = SwigType_namestr(real_classname);
if (CPlusPlus) {
- Printf(doc, "Proxy of C++ %s class.", SwigType_namestr(real_classname));
+ Printf(doc, "Proxy of C++ %s class.", classname_str);
} else {
- Printf(doc, "Proxy of C %s struct.", SwigType_namestr(real_classname));
+ Printf(doc, "Proxy of C %s struct.", classname_str);
}
+ Delete(classname_str);
}
}
}
@@ -3922,35 +3926,36 @@ public:
* classHandler()
* ------------------------------------------------------------ */
- String *add_explicit_scope(String *s) {
+ SwigType *add_explicit_scope(SwigType *s) {
if (!Strstr(s, "::")) {
- String *ss = NewStringf("::%s", s);
- Delete(s);
- s = ss;
+ return NewStringf("::%s", s);
}
- return s;
+ return Copy(s);
}
void builtin_pre_decl(Node *n) {
- String *name = Getattr(n, "name");
- String *rname = add_explicit_scope(SwigType_namestr(name));
- String *mname = SwigType_manglestr(rname);
+ SwigType *name = Getattr(n, "name");
+ SwigType *sname = add_explicit_scope(name);
+ String *rname = SwigType_namestr(sname);
+ String *mname = SwigType_manglestr(sname);
Printf(f_init, "\n/* type '%s' */\n", rname);
Printf(f_init, " builtin_pytype = (PyTypeObject *)&SwigPyBuiltin_%s_type;\n", mname);
Printf(f_init, " builtin_pytype->tp_dict = d = PyDict_New();\n");
+ Delete(sname);
Delete(rname);
Delete(mname);
}
void builtin_post_decl(File *f, Node *n) {
- String *name = Getattr(n, "name");
- String *pname = Copy(name);
+ SwigType *name = Getattr(n, "name");
+ SwigType *pname = Copy(name);
SwigType_add_pointer(pname);
String *symname = Getattr(n, "sym:name");
- String *rname = add_explicit_scope(SwigType_namestr(name));
- String *mname = SwigType_manglestr(rname);
+ SwigType *sname = add_explicit_scope(name);
+ String *rname = SwigType_namestr(sname);
+ String *mname = SwigType_manglestr(sname);
String *pmname = SwigType_manglestr(pname);
String *templ = NewStringf("SwigPyBuiltin_%s", mname);
int funpack = fastunpack;
@@ -4381,9 +4386,10 @@ public:
Delete(clientdata);
Delete(smart);
+ Delete(sname);
Delete(rname);
- Delete(pname);
Delete(mname);
+ Delete(pname);
Delete(pmname);
Delete(templ);
Delete(tp_flags);
@@ -4480,9 +4486,11 @@ public:
Setattr(n, "feature:python:tp_doc", ds);
Delete(ds);
} else {
- String *name = Getattr(n, "name");
- String *rname = add_explicit_scope(SwigType_namestr(name));
+ SwigType *name = Getattr(n, "name");
+ SwigType *sname = add_explicit_scope(name);
+ String *rname = SwigType_namestr(sname);
Setattr(n, "feature:python:tp_doc", rname);
+ Delete(sname);
Delete(rname);
}
} else {