smart-pointer const fix
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4551 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7681f43d47
commit
6f1e04f7bb
2 changed files with 35 additions and 6 deletions
|
|
@ -229,7 +229,7 @@ class Allocate : public Dispatcher {
|
||||||
|
|
||||||
/* Grab methods used by smart pointers */
|
/* 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) {
|
if (!methods) {
|
||||||
methods = NewList();
|
methods = NewList();
|
||||||
}
|
}
|
||||||
|
|
@ -273,7 +273,23 @@ class Allocate : public Dispatcher {
|
||||||
if (!match) {
|
if (!match) {
|
||||||
Node *cc = c;
|
Node *cc = c;
|
||||||
while (cc) {
|
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");
|
cc = Getattr(cc,"sym:nextSibling");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -294,7 +310,7 @@ class Allocate : public Dispatcher {
|
||||||
Node *bases = Getattr(cls,"bases");
|
Node *bases = Getattr(cls,"bases");
|
||||||
int k;
|
int k;
|
||||||
for (k = 0; k < Len(bases); 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 */
|
/* Remove protected/private members */
|
||||||
|
|
@ -496,7 +512,14 @@ public:
|
||||||
Node *sc = Swig_symbol_clookup(base, 0);
|
Node *sc = Swig_symbol_clookup(base, 0);
|
||||||
if ((sc) && (Strcmp(nodeType(sc),"class") == 0)) {
|
if ((sc) && (Strcmp(nodeType(sc),"class") == 0)) {
|
||||||
if (SwigType_check_decl(type,"p.")) {
|
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);
|
Setattr(inclass,"allocate:smartpointer",methods);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1058,7 +1058,7 @@ int
|
||||||
Language::membervariableHandler(Node *n) {
|
Language::membervariableHandler(Node *n) {
|
||||||
|
|
||||||
Swig_require("membervariableHandler",n,"*name","*sym:name","*type",NIL);
|
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 *name = Getattr(n,"name");
|
||||||
String *symname = Getattr(n,"sym:name");
|
String *symname = Getattr(n,"sym:name");
|
||||||
|
|
@ -1073,6 +1073,13 @@ Language::membervariableHandler(Node *n) {
|
||||||
Delattr(n,"feature:except");
|
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) {
|
if (!AttributeFunctionGet) {
|
||||||
|
|
||||||
String *mrename_get, *mrename_set;
|
String *mrename_get, *mrename_set;
|
||||||
|
|
@ -1672,7 +1679,6 @@ int Language::classHandler(Node *n) {
|
||||||
SmartPointer = CWRAP_SMART_POINTER;
|
SmartPointer = CWRAP_SMART_POINTER;
|
||||||
Node *c;
|
Node *c;
|
||||||
for (c = Firstitem(methods); c; c= Nextitem(methods)) {
|
for (c = Firstitem(methods); c; c= Nextitem(methods)) {
|
||||||
/* Swig_print_node(c); */
|
|
||||||
emit_one(c);
|
emit_one(c);
|
||||||
}
|
}
|
||||||
SmartPointer = 0;
|
SmartPointer = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue