fix #697 - miscounting comma in member lists

fix method for counting comma in member list
This commit is contained in:
Joseph C Wang 2016-11-12 00:23:41 +08:00
parent 6310cdb28a
commit bff182d556
3 changed files with 19 additions and 4 deletions

View File

@ -19,7 +19,8 @@ C_TEST_CASES += \
CPP_TEST_CASES += \
r_double_delete \
r_overload_array \
r_sexp
r_sexp \
r_overload_comma
include $(srcdir)/../common.mk

View File

@ -0,0 +1,14 @@
%module r_overload_comma
%inline %{
class r_overload_comma
{
public:
int getMember1()const {return _member1;}
void setMember1ThatEndsWithWord_get(int arg) { _member1=arg; }
void setMember1ThatEndsWithWord_get(char* arg) {_member1=atoi(arg);}
private:
int _member1;
};
%}

View File

@ -1064,7 +1064,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
if (!isSet && varaccessor > 0) {
Printf(f->code, "%svaccessors = c(", tab8);
int vcount = 0;
int first = 1;
for(j = 0; j < numMems; j+=3) {
String *item = Getitem(el, j);
String *dup = Getitem(el, j + 1);
@ -1072,8 +1072,8 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
ptr = &ptr[Len(dup) - 3];
if (!strcmp(ptr, "get")) {
vcount++;
Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : "");
Printf(f->code, "%s'%s'", first ? "" : ", ", item);
first = 0;
}
}
Printf(f->code, ");\n");