add methods call and deref for functor and dereferencing operators
add hash to make sure that each method only appears once git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9257 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a8451e7c69
commit
de8b9eaea4
1 changed files with 21 additions and 2 deletions
|
|
@ -1003,8 +1003,12 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
||||||
Printf(f->code, "{\n");
|
Printf(f->code, "{\n");
|
||||||
Printf(f->code, "%saccessorFuns = list(", tab8);
|
Printf(f->code, "%saccessorFuns = list(", tab8);
|
||||||
|
|
||||||
|
Node *itemList = NewHash();
|
||||||
for(j = 0; j < numMems; j+=3) {
|
for(j = 0; j < numMems; j+=3) {
|
||||||
String *item = Getitem(el, j);
|
String *item = Getitem(el, j);
|
||||||
|
if (Getattr(itemList, item))
|
||||||
|
continue;
|
||||||
|
Setattr(itemList, item, "1");
|
||||||
if (!Strcmp(item, "__getitem__")) has_getitem = 1;
|
if (!Strcmp(item, "__getitem__")) has_getitem = 1;
|
||||||
if (!Strcmp(item, "__setitem__")) has_setitem = 1;
|
if (!Strcmp(item, "__setitem__")) has_setitem = 1;
|
||||||
if (!Strcmp(item, "__str__")) has_str = 1;
|
if (!Strcmp(item, "__str__")) has_str = 1;
|
||||||
|
|
@ -1015,8 +1019,23 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
||||||
|
|
||||||
if (!strcmp(ptr, "get"))
|
if (!strcmp(ptr, "get"))
|
||||||
varaccessor++;
|
varaccessor++;
|
||||||
Printf(f->code, "'%s' = %s%s", item, dup, j < numMems - 3 ? ", " : "");
|
|
||||||
|
String *pitem;
|
||||||
|
if (!Strcmp(item, "operator ()")) {
|
||||||
|
pitem = NewString("call");
|
||||||
|
} else if (!Strcmp(item, "operator ->")) {
|
||||||
|
pitem = NewString("deref");
|
||||||
|
} else if (!Strcmp(item, "operator +")) {
|
||||||
|
pitem = NewString("add");
|
||||||
|
} else if (!Strcmp(item, "operator -")) {
|
||||||
|
pitem = NewString("sub");
|
||||||
|
} else {
|
||||||
|
pitem = Copy(item);
|
||||||
|
}
|
||||||
|
Printf(f->code, "'%s' = %s%s", pitem, dup, j < numMems - 3 ? ", " : "");
|
||||||
|
Delete(pitem);
|
||||||
}
|
}
|
||||||
|
Delete(itemList);
|
||||||
Printf(f->code, ")\n");
|
Printf(f->code, ")\n");
|
||||||
|
|
||||||
if (!isSet && varaccessor > 0) {
|
if (!isSet && varaccessor > 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue