From c90239bce6164a771e07183f208e53d692c2e70f Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Wed, 23 Nov 2016 17:13:27 +1100 Subject: [PATCH] Corrected generation of "set" methods for R. The function "OutputClassMemberTable" tags methods generated for a class so that R wrapper code supporting syntax like: WrappedClass$VarName <- value The comments in the function indicate that it is looking for method names ending in "_set", but in fact it was searching for methods ending in just "set", This was resulting in class methods ending in set (names like GetOffset, SetOffset etc) being placed in the wrong accessor functions and thus not being available in the normal way. There is probably a more appropriate way to tag the _set functions when they are being created, which is a future step. This patch makes the behaviour conform to the original intention. --- Source/Modules/r.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index bd1b9107e..edad26e53 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -974,7 +974,9 @@ int R::OutputClassMemberTable(Hash *tb, File *out) { String *key; int i, n = Len(keys); /* Loop over all the _set and _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,12 @@ 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[Len(key) - 4]; + isSet = strcmp(ptr, "_set") == 0; + } // OutputArrayMethod(className, el, out); OutputMemberReferenceMethod(className, isSet, el, out);