From de8b9eaea4c528280ebb7234fdc20372df40e041 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Mon, 21 Aug 2006 22:48:58 +0000 Subject: [PATCH] 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 --- SWIG/Source/Modules/r.cxx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/SWIG/Source/Modules/r.cxx b/SWIG/Source/Modules/r.cxx index c259de55f..e9993e9ea 100644 --- a/SWIG/Source/Modules/r.cxx +++ b/SWIG/Source/Modules/r.cxx @@ -1002,9 +1002,13 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, Printf(f->code, "{\n"); Printf(f->code, "%saccessorFuns = list(", tab8); - + + Node *itemList = NewHash(); for(j = 0; j < numMems; j+=3) { String *item = Getitem(el, j); + if (Getattr(itemList, item)) + continue; + Setattr(itemList, item, "1"); if (!Strcmp(item, "__getitem__")) has_getitem = 1; if (!Strcmp(item, "__setitem__")) has_setitem = 1; if (!Strcmp(item, "__str__")) has_str = 1; @@ -1015,8 +1019,23 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, if (!strcmp(ptr, "get")) 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"); if (!isSet && varaccessor > 0) {