smart-pointer const fix
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4551 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3a75cd354e
commit
64354c5b3b
2 changed files with 35 additions and 6 deletions
|
|
@ -229,7 +229,7 @@ class Allocate : public Dispatcher {
|
|||
|
||||
/* Grab methods used by smart pointers */
|
||||
|
||||
List *smart_pointer_methods(Node *cls, List *methods) {
|
||||
List *smart_pointer_methods(Node *cls, List *methods, int isconst) {
|
||||
if (!methods) {
|
||||
methods = NewList();
|
||||
}
|
||||
|
|
@ -273,7 +273,23 @@ class Allocate : public Dispatcher {
|
|||
if (!match) {
|
||||
Node *cc = c;
|
||||
while (cc) {
|
||||
Append(methods,cc);
|
||||
/* If constant, we have to be careful */
|
||||
if (isconst) {
|
||||
SwigType *decl = Getattr(cc,"decl");
|
||||
if (decl) {
|
||||
if (SwigType_isfunction(decl)) { /* If method, we only add if it's a const method */
|
||||
if (SwigType_isconst(decl)) {
|
||||
Append(methods,cc);
|
||||
}
|
||||
} else {
|
||||
Append(methods,cc);
|
||||
}
|
||||
} else {
|
||||
Append(methods,cc);
|
||||
}
|
||||
} else {
|
||||
Append(methods,cc);
|
||||
}
|
||||
cc = Getattr(cc,"sym:nextSibling");
|
||||
}
|
||||
}
|
||||
|
|
@ -294,7 +310,7 @@ class Allocate : public Dispatcher {
|
|||
Node *bases = Getattr(cls,"bases");
|
||||
int k;
|
||||
for (k = 0; k < Len(bases); k++) {
|
||||
smart_pointer_methods(Getitem(bases,k),methods);
|
||||
smart_pointer_methods(Getitem(bases,k),methods,isconst);
|
||||
}
|
||||
}
|
||||
/* Remove protected/private members */
|
||||
|
|
@ -496,7 +512,14 @@ public:
|
|||
Node *sc = Swig_symbol_clookup(base, 0);
|
||||
if ((sc) && (Strcmp(nodeType(sc),"class") == 0)) {
|
||||
if (SwigType_check_decl(type,"p.")) {
|
||||
List *methods = smart_pointer_methods(sc,0);
|
||||
/* Need to check if type is a const pointer */
|
||||
int isconst = 0;
|
||||
SwigType_pop(type);
|
||||
if (SwigType_isconst(type)) {
|
||||
isconst = 1;
|
||||
Setattr(inclass,"allocate:smartpointerconst","1");
|
||||
}
|
||||
List *methods = smart_pointer_methods(sc,0,isconst);
|
||||
Setattr(inclass,"allocate:smartpointer",methods);
|
||||
break;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1058,7 +1058,7 @@ int
|
|||
Language::membervariableHandler(Node *n) {
|
||||
|
||||
Swig_require("membervariableHandler",n,"*name","*sym:name","*type",NIL);
|
||||
Swig_save("membervariableHandler",n,"parms",NIL);
|
||||
Swig_save("membervariableHandler",n,"parms","feature:immutable",NIL);
|
||||
|
||||
String *name = Getattr(n,"name");
|
||||
String *symname = Getattr(n,"sym:name");
|
||||
|
|
@ -1073,6 +1073,13 @@ Language::membervariableHandler(Node *n) {
|
|||
Delattr(n,"feature:except");
|
||||
}
|
||||
|
||||
/* If a smart-pointer and it's a constant access, we have to set immutable */
|
||||
if (SmartPointer) {
|
||||
if (Getattr(CurrentClass,"allocate:smartpointerconst")) {
|
||||
Setattr(n,"feature:immutable","1");
|
||||
}
|
||||
}
|
||||
|
||||
if (!AttributeFunctionGet) {
|
||||
|
||||
String *mrename_get, *mrename_set;
|
||||
|
|
@ -1672,7 +1679,6 @@ int Language::classHandler(Node *n) {
|
|||
SmartPointer = CWRAP_SMART_POINTER;
|
||||
Node *c;
|
||||
for (c = Firstitem(methods); c; c= Nextitem(methods)) {
|
||||
/* Swig_print_node(c); */
|
||||
emit_one(c);
|
||||
}
|
||||
SmartPointer = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue