Merge pull request #839 from richardbeare/RsetMethods

Corrected generation of "set" methods for R.
This commit is contained in:
Joseph Wang 2016-12-21 21:52:27 +08:00 • committed by GitHub
commit 14a5f9e11d

View file

@ -974,7 +974,9 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
String *key;
int i, n = Len(keys);
/* Loop over all the <Class>_set and <Class>_get entries in the table. */
/* This function checks for names ending in _set - perhaps it should */
/* use attributes of some other form, as it potentially clashes with */
/* methods ending in _set */
if(n && outputNamespaceInfo) {
Printf(s_namespace, "exportClasses(");
}
@ -984,9 +986,13 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
String *className = Getitem(el, 0);
char *ptr = Char(key);
ptr = &ptr[Len(key) - 3];
int isSet = strcmp(ptr, "set") == 0;
int klen = Len(key);
int isSet = 0;
if (klen > 4) {
ptr = &ptr[klen - 4];
isSet = strcmp(ptr, "_set") == 0;
}
// OutputArrayMethod(className, el, out);
OutputMemberReferenceMethod(className, isSet, el, out);
@ -1273,7 +1279,9 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
if(isSet < 0) {
int n = Len(name);
char *ptr = Char(name);
isSet = Strcmp(NewString(&ptr[n-3]), "set") == 0;
if (n>4) {
isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0;
}
}
List *l = isSet ? class_member_set_functions : class_member_functions;
@ -1753,7 +1761,8 @@ int R::functionWrapper(Node *n) {
int n = Len(iname);
char *ptr = Char(iname);
bool isSet(Strcmp(NewString(&ptr[n-3]), "set") == 0);
bool isSet(0);
if (n > 4) isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0;
String *tmp = NewString("");