R does not like variables with leading underscores
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10391 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fd6be0ba40
commit
ade41d0a72
1 changed files with 30 additions and 16 deletions
|
|
@ -16,6 +16,18 @@ char cvsroot_r_cxx[] = "$Id$";
|
||||||
static const double DEFAULT_NUMBER = .0000123456712312312323;
|
static const double DEFAULT_NUMBER = .0000123456712312312323;
|
||||||
static const int MAX_OVERLOAD_ARGS = 5;
|
static const int MAX_OVERLOAD_ARGS = 5;
|
||||||
|
|
||||||
|
static String* replaceInitialDash(const String *name)
|
||||||
|
{
|
||||||
|
String *retval;
|
||||||
|
if (!Strncmp(name, "_", 1)) {
|
||||||
|
retval = Copy(name);
|
||||||
|
Insert(retval, 0, "s");
|
||||||
|
} else {
|
||||||
|
retval = Copy(name);
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
static String * getRTypeName(SwigType *t, int *outCount = NULL) {
|
static String * getRTypeName(SwigType *t, int *outCount = NULL) {
|
||||||
String *b = SwigType_base(t);
|
String *b = SwigType_base(t);
|
||||||
List *els = SwigType_split(t);
|
List *els = SwigType_split(t);
|
||||||
|
|
@ -572,10 +584,12 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
||||||
// ParmList *parms = Getattr(n, "parms");
|
// ParmList *parms = Getattr(n, "parms");
|
||||||
// memory leak
|
// memory leak
|
||||||
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)));
|
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)));
|
||||||
if (debugMode) {
|
|
||||||
|
|
||||||
|
// if (debugMode) {
|
||||||
Printf(stderr, "Type: %s\n", t);
|
Printf(stderr, "Type: %s\n", t);
|
||||||
Printf(stderr, "Return type: %s\n", SwigType_base(t));
|
Printf(stderr, "Return type: %s\n", SwigType_base(t));
|
||||||
}
|
//}
|
||||||
|
|
||||||
bool isVoidType = Strcmp(rettype, "void") == 0;
|
bool isVoidType = Strcmp(rettype, "void") == 0;
|
||||||
if (debugMode)
|
if (debugMode)
|
||||||
|
|
@ -1835,10 +1849,7 @@ int R::functionWrapper(Node *n) {
|
||||||
if (Len(name) == 0)
|
if (Len(name) == 0)
|
||||||
name = NewStringf("s_arg%d", i+1);
|
name = NewStringf("s_arg%d", i+1);
|
||||||
|
|
||||||
if (!Strncmp(name, "_", 1)) {
|
name = replaceInitialDash(name);
|
||||||
name = Copy(name);
|
|
||||||
Insert(name, 0, "s");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Strncmp(name, "arg", 3)) {
|
if (!Strncmp(name, "arg", 3)) {
|
||||||
name = Copy(name);
|
name = Copy(name);
|
||||||
|
|
@ -2493,6 +2504,7 @@ int R::classDeclaration(Node *n) {
|
||||||
String *tp;
|
String *tp;
|
||||||
|
|
||||||
elName = Getattr(c, "name");
|
elName = Getattr(c, "name");
|
||||||
|
|
||||||
String *elKind = Getattr(c, "kind");
|
String *elKind = Getattr(c, "kind");
|
||||||
if (Strcmp(elKind, "variable") != 0) {
|
if (Strcmp(elKind, "variable") != 0) {
|
||||||
c = nextSibling(c);
|
c = nextSibling(c);
|
||||||
|
|
@ -2532,10 +2544,11 @@ int R::classDeclaration(Node *n) {
|
||||||
// Printf(stderr, "<classDeclaration> elType %p\n", elType);
|
// Printf(stderr, "<classDeclaration> elType %p\n", elType);
|
||||||
// tp = getRClassNameCopyStruct(Getattr(c, "type"), 1);
|
// tp = getRClassNameCopyStruct(Getattr(c, "type"), 1);
|
||||||
#endif
|
#endif
|
||||||
|
String *elNameT = replaceInitialDash(elName);
|
||||||
Printf(def, "%s%s = \"%s\"", tab8, elName, tp);
|
Printf(def, "%s%s = \"%s\"", tab8, elNameT, tp);
|
||||||
firstItem = false;
|
firstItem = false;
|
||||||
Delete(tp);
|
Delete(tp);
|
||||||
|
Delete(elNameT);
|
||||||
c = nextSibling(c);
|
c = nextSibling(c);
|
||||||
}
|
}
|
||||||
Printf(def, "),\n%scontains = \"RSWIGStruct\")\n", tab8);
|
Printf(def, "),\n%scontains = \"RSWIGStruct\")\n", tab8);
|
||||||
|
|
@ -2662,12 +2675,11 @@ int R::generateCopyRoutinesObsolete(Node *n) {
|
||||||
SwigType_push(elTT, decl);
|
SwigType_push(elTT, decl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
String *elNameT = replaceInitialDash(elName);
|
||||||
Printf(copyToR->code, "obj@%s = %s(value)\n", elName, get);
|
Printf(copyToR->code, "obj@%s = %s(value)\n", elNameT, get);
|
||||||
Printf(copyToC->code, "%s(obj, value@%s)\n", set, elName);
|
Printf(copyToC->code, "%s(obj, value@%s)\n", set, elNameT);
|
||||||
|
String *field = NewStringf("value->%s", elNameT);
|
||||||
|
Delete(elNameT);
|
||||||
String *field = NewStringf("value->%s", elName);
|
|
||||||
SwigType *elType = Getattr(c, "type");
|
SwigType *elType = Getattr(c, "type");
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2828,8 +2840,10 @@ int R::generateCopyRoutines(Node *n) {
|
||||||
|
|
||||||
|
|
||||||
/* The S functions to get and set the member value. */
|
/* The S functions to get and set the member value. */
|
||||||
Printf(copyToR->code, "obj@%s = value$%s\n", elName, elName);
|
String *elNameT = replaceInitialDash(elName);
|
||||||
Printf(copyToC->code, "obj$%s = value@%s\n", elName, elName);
|
Printf(copyToR->code, "obj@%s = value$%s\n", elNameT, elNameT);
|
||||||
|
Printf(copyToC->code, "obj$%s = value@%s\n", elNameT, elNameT);
|
||||||
|
Delete(elNameT);
|
||||||
}
|
}
|
||||||
Printf(copyToR->code, "obj\n}\n\n");
|
Printf(copyToR->code, "obj\n}\n\n");
|
||||||
String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref.
|
String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue