Templated smart pointers overloaded with both const and non const operator-> generated uncompilable code when the pointee was a class with either public member variables or static methods.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12512 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-03-02 22:30:05 +00:00
commit 28af783d18
4 changed files with 51 additions and 4 deletions

View file

@ -794,14 +794,16 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
/* If smart pointer without const overload or mutable method, change self dereferencing */
if (flags & CWRAP_SMART_POINTER) {
if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
if (qualifier && strncmp(Char(qualifier), "q(const)", 8) == 0) {
self = NewString("(*(this))->");
is_smart_pointer_overload = 1;
}
else if (Cmp(Getattr(n, "storage"), "static") == 0) {
self = NewStringf("(*(%s const *)this)->", cname);
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
String *ctname = SwigType_namestr(cname);
self = NewStringf("(*(%s const *)this)->", ctname);
is_smart_pointer_overload = 1;
Delete(ctname);
}
else {
self = NewString("(*this)->");
@ -940,7 +942,9 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
String *ctname = SwigType_namestr(cname);
String *fadd = 0;
if (is_smart_pointer_overload) {
fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, classname, pname);
String *nclassname = SwigType_namestr(classname);
fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, nclassname, pname);
Delete(nclassname);
}
else {
fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
@ -1333,7 +1337,9 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
String *base = Getattr(sn, "name");
self = NewStringf("%s::", base);
} else if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
self = NewStringf("(*(%s const *)this)->", classname);
String *nclassname = SwigType_namestr(classname);
self = NewStringf("(*(%s const *)this)->", nclassname);
Delete(nclassname);
} else {
self = NewString("(*this)->");
}