From: <wsf...@us...> - 2012-03-25 19:10:39
|
Revision: 12953 http://swig.svn.sourceforge.net/swig/?rev=12953&view=rev Author: wsfulton Date: 2012-03-25 19:10:33 +0000 (Sun, 25 Mar 2012) Log Message: ----------- Revert 12776, 12777 - %shared_ptr fixes with typedef. It breaks li_boost_shared_ptr testcase in Python. To resolve at a later date. Modified Paths: -------------- trunk/CHANGES.current trunk/Examples/test-suite/common.mk trunk/Source/Modules/typepass.cxx Modified: trunk/CHANGES.current =================================================================== --- trunk/CHANGES.current 2012-03-25 16:56:09 UTC (rev 12952) +++ trunk/CHANGES.current 2012-03-25 19:10:33 UTC (rev 12953) @@ -310,12 +310,6 @@ the module table into the global namespace. Require call also returns the module table instead of a string. -2011-08-12: wsfulton - SF bug # 3333549 - %shared_ptr fixes when the type is a template using template parameters - that are typedef'd to another type. - - Also fixed %shared_ptr when template parameters have default values. - 2011-08-09: xavier98 Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) Modified: trunk/Examples/test-suite/common.mk =================================================================== --- trunk/Examples/test-suite/common.mk 2012-03-25 16:56:09 UTC (rev 12952) +++ trunk/Examples/test-suite/common.mk 2012-03-25 19:10:33 UTC (rev 12953) @@ -83,6 +83,7 @@ exception_partial_info \ extend_variable \ li_std_vector_ptr \ + li_boost_shared_ptr_template \ overload_complicated \ template_default_pointer \ template_expr Modified: trunk/Source/Modules/typepass.cxx =================================================================== --- trunk/Source/Modules/typepass.cxx 2012-03-25 16:56:09 UTC (rev 12952) +++ trunk/Source/Modules/typepass.cxx 2012-03-25 19:10:33 UTC (rev 12953) @@ -227,64 +227,51 @@ for (i = 0; i < len; i++) { Node *n = Getitem(ilist, i); String *bname = Getattr(n, "name"); - Node *bclass = n; + Node *bclass = n; /* Getattr(n,"class"); */ Hash *scopes = Getattr(bclass, "typescope"); SwigType_inherit(clsname, bname, cast, 0); - if (!importmode) { - String *btype = Copy(bname); - SwigType_add_pointer(btype); - SwigType_remember(btype); - Delete(btype); - } - String *smartptr = Getattr(first, "feature:smartptr"); - String *base_smartptr = Getattr(bclass, "feature:smartptr"); if (smartptr) { + SwigType *smart = 0; SwigType *spt = Swig_cparse_type(smartptr); if (spt) { - if (base_smartptr) { - SwigType *base_spt = Swig_cparse_type(base_smartptr); - if (base_spt) { - /* Record a (fake) inheritance relationship between smart pointer - and smart pointer to base class, so that smart pointer upcasts - are automatically generated. */ - SwigType *smart = SwigType_typedef_resolve_all(spt); - SwigType *bsmart = SwigType_typedef_resolve_all(base_spt); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); - - /* Construct casting code */ - String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr); - - /* Setup inheritance relationship between smart pointers */ - SwigType_inherit(smart, bsmart, 0, convcode); - if (!importmode) { - String *btype = Copy(bsmart); - SwigType_add_pointer(btype); - SwigType_remember(btype); - Delete(btype); - } - Delete(convcode); - Delete(bsmartnamestr); - Delete(smartnamestr); - Delete(bsmart); - Delete(smart); - Delete(base_spt); - } else { - Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(base_smartptr), SwigType_namestr(bname)); - } - Delete(spt); - } else { + smart = SwigType_typedef_resolve_all(spt); + Delete(spt); + /* Record a (fake) inheritance relationship between smart pointer + and smart pointer to base class, so that smart pointer upcasts + are automatically generated. */ + SwigType *bsmart = Copy(smart); + SwigType *rclsname = SwigType_typedef_resolve_all(clsname); + SwigType *rbname = SwigType_typedef_resolve_all(bname); + Replaceall(bsmart, rclsname, rbname); + Delete(rclsname); + Delete(rbname); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(bsmart); + /* construct casting code */ + String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr); + Delete(bsmartnamestr); + Delete(smartnamestr); + /* setup inheritance relationship between smart pointer templates */ + SwigType_inherit(smart, bsmart, 0, convcode); + if (!GetFlag(bclass, "feature:smartptr")) Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name"))); - } + Delete(convcode); + Delete(bsmart); + Delete(smart); } else { Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname)); } } else { - if (base_smartptr) + if (GetFlag(bclass, "feature:smartptr")) Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name"))); } - + if (!importmode) { + String *btype = Copy(bname); + SwigType_add_pointer(btype); + SwigType_remember(btype); + Delete(btype); + } if (scopes) { SwigType_inherit_scope(scopes); } @@ -442,10 +429,6 @@ } } else { Swig_symbol_cadd(fname, n); - /* needed? - if (template_default_expanded) - Swig_symbol_cadd(template_default_expanded, n); - */ SwigType_typedef_class(fname); scopename = Copy(fname); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |