align implementation of smartname to r class name

This commit is contained in:
AndLLA 2022-10-16 20:49:00 +02:00 • committed by William S Fulton
commit 0fec14ba34

View file

@ -2091,21 +2091,16 @@ int R::functionWrapper(Node *n) {
if (constructor) { if (constructor) {
Node * parent = Getattr(n, "parentNode"); Node * parent = Getattr(n, "parentNode");
String * smartname = Getattr(parent, "feature:smartptr"); String * smartname = Getattr(parent, "feature:smartptr");
if (smartname) { if (smartname) { // SmartName handling - has to be aligned to the other implementation in this file
String * classtypeobj = Getattr(parent, "classtypeobj"); // this is the correct name, e.g. ClassName(int) SwigType *spt = Swig_cparse_type(smartname);
String * classtype = NewString(Getattr(parent, "classtype")); // this is the "wrong" name e.g. ClassName<int> String *smart = SwigType_typedef_resolve_all(spt);
String *smart_rname = SwigType_manglestr(smart);
// we replace inside smartname ClassName<int> with ClassName(int) String *smart_rname_p = NewStringf("_p%s", smart_rname);
String * smartname_fixed = NewString(smartname); Replaceall(tm, "$R_class", smart_rname_p);
Replaceall(classtype, " ", ""); // classtype actually has spaces inside so we remove them Delete(spt);
Replaceall(smartname_fixed, classtype, classtypeobj); Delete(smart);
Delete(smart_rname);
String * smartname_fixed_rclass = getRClassName(smartname_fixed, 1, 1); Delete(smart_rname_p);
Replaceall(tm, "$R_class", smartname_fixed_rclass);
Delete(classtype);
Delete(smartname_fixed);
Delete(smartname_fixed_rclass);
} }
} }
if (debugMode) { if (debugMode) {
@ -2334,7 +2329,7 @@ void R::registerClass(Node *n) {
Printf(s_classes, "setClass('%s', contains = %s)\n", sname, base); Printf(s_classes, "setClass('%s', contains = %s)\n", sname, base);
Delete(base); Delete(base);
String *smartptr = Getattr(n, "feature:smartptr"); String *smartptr = Getattr(n, "feature:smartptr");
if (smartptr) { if (smartptr) {// SmartName handling - has to be aligned to the other implementation in this file
List *l = Getattr(n, "bases"); List *l = Getattr(n, "bases");
SwigType *spt = Swig_cparse_type(smartptr); SwigType *spt = Swig_cparse_type(smartptr);
String *smart = SwigType_typedef_resolve_all(spt); String *smart = SwigType_typedef_resolve_all(spt);