diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2012-03-25 19:10:33 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2012-03-25 19:10:33 +0000 |
commit | 36ab437443cbfd138185931db08e5f31c0762c3a (patch) | |
tree | 1ea10f26489a12ada3f3cf273b9c3dea8c2b1186 /Source | |
parent | c7895b43d50a26e391452f1df4bed1352c125fc8 (diff) | |
download | swig-36ab437443cbfd138185931db08e5f31c0762c3a.tar.gz |
Revert 12776, 12777 - %shared_ptr fixes with typedef. It breaks li_boost_shared_ptr testcase in Python. To resolve at a later date.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12953 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Modules/typepass.cxx | 81 |
1 files changed, 32 insertions, 49 deletions
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 575b8e6b2..15768f203 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -227,64 +227,51 @@ class TypePass:private Dispatcher { 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 @@ class TypePass:private Dispatcher { } } 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); } |