Add names to c function params

This commit is contained in:
Joey Yakimowich-Payne 2023-02-17 18:55:32 -07:00
commit 83ae863d4a
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
3 changed files with 18 additions and 6 deletions

View file

@ -869,7 +869,7 @@ public:
// We want to use readable parameter names in our wrappers instead of the autogenerated arg$N if possible, so do it, and do it before calling
// Swig_typemap_attach_parms(), as this uses the parameter names for typemap expansion.
for (Parm* p2 = p; p2; p2 = nextSibling(p2)) {
String* name = Getattr(p, "name");
String* name = Getattr(p2, "name");
if (!name) {
// Can't do anything for unnamed parameters.
continue;
@ -2411,10 +2411,21 @@ public:
String *lname = 0;
for (p = (Parm*)parms, index = 1; p; (p = nextSibling(p)), index++) {
if(!(lname = Getattr(p, "lname"))) {
lname = NewStringf("arg%d", index);
Setattr(p, "lname", lname);
String* name = Getattr(p, "name");
if (!name) {
// Can't do anything for unnamed parameters.
if(!(lname = Getattr(p, "lname"))) {
lname = NewStringf("arg%d", index);
Setattr(p, "lname", lname);
}
continue;
}
scoped_dohptr name_ptr;
if (Strstr(name, "::")) {
name_ptr = Swig_scopename_last(name);
name = name_ptr.get();
}
Setattr(p, "lname", name);
}
// C++ function wrapper

View file

@ -58,7 +58,8 @@ const char *Swig_cresult_name(void) {
String *Swig_cparm_name(Parm *p, int i) {
String *name = NewStringf("arg%d", i + 1);
if (p) {
Setattr(p, "lname", name);
String *lname = Getattr(p, "lname");
if (!lname) Setattr(p, "lname", name);
}
return name;

View file

@ -1834,7 +1834,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
for (i = 0; i < nmatch; i++) {
SwigType *type = Getattr(p, "type");
String *pname = Getattr(p, "name");
String *lname = Getattr(p, "lname");
String *lname = Swig_cparm_name(p, argnum-1);
SwigType *mtype = Getattr(p, "tmap:match");
SwigType *matchtype = mtype ? mtype : type;