smart-pointer classes deriving from parent smart-pointers
white-space cleanup
This commit is contained in:
parent
e6a1a7dbd1
commit
1df744e0c3
1 changed files with 397 additions and 394 deletions
|
|
@ -58,11 +58,11 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(count)
|
if(count)
|
||||||
return(b);
|
return(b);
|
||||||
|
|
||||||
Delete(b);
|
Delete(b);
|
||||||
return(NewString(""));
|
return(NewString(""));
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
|
||||||
#ifdef R_SWIG_VERBOSE
|
#ifdef R_SWIG_VERBOSE
|
||||||
if (debugMode)
|
if (debugMode)
|
||||||
Printf(stdout, "SwigType_split return an empty list for %s\n",
|
Printf(stdout, "SwigType_split return an empty list for %s\n",
|
||||||
retType);
|
retType);
|
||||||
#endif
|
#endif
|
||||||
return(tmp);
|
return(tmp);
|
||||||
}
|
}
|
||||||
|
|
@ -107,8 +107,8 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
|
||||||
if(addRef) {
|
if(addRef) {
|
||||||
for(int i = 0; i < n; i++) {
|
for(int i = 0; i < n; i++) {
|
||||||
if(Strcmp(Getitem(l, i), "p.") == 0 ||
|
if(Strcmp(Getitem(l, i), "p.") == 0 ||
|
||||||
Strncmp(Getitem(l, i), "a(", 2) == 0)
|
Strncmp(Getitem(l, i), "a(", 2) == 0)
|
||||||
Printf(tmp, "Ref");
|
Printf(tmp, "Ref");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,14 +212,14 @@ R Options (available with -r)\n\
|
||||||
-cppcast - Enable C++ casting operators (default) \n\
|
-cppcast - Enable C++ casting operators (default) \n\
|
||||||
-debug - Output debug\n\
|
-debug - Output debug\n\
|
||||||
-dll <name> - Name of the DLL (without the .dll or .so suffix).\n\
|
-dll <name> - Name of the DLL (without the .dll or .so suffix).\n\
|
||||||
Default is the module name.\n\
|
Default is the module name.\n\
|
||||||
-gc - Aggressive garbage collection\n\
|
-gc - Aggressive garbage collection\n\
|
||||||
-memoryprof - Add memory profile\n\
|
-memoryprof - Add memory profile\n\
|
||||||
-namespace - Output NAMESPACE file\n\
|
-namespace - Output NAMESPACE file\n\
|
||||||
-no-init-code - Turn off the generation of the R_init_<pkgname> code\n\
|
-no-init-code - Turn off the generation of the R_init_<pkgname> code\n\
|
||||||
(registration information still generated)\n\
|
(registration information still generated)\n\
|
||||||
-package <name> - Package name for the PACKAGE argument of the R .Call()\n\
|
-package <name> - Package name for the PACKAGE argument of the R .Call()\n\
|
||||||
invocations. Default is the module name.\n\
|
invocations. Default is the module name.\n\
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -292,7 +292,7 @@ public:
|
||||||
|
|
||||||
int typedefHandler(Node *n);
|
int typedefHandler(Node *n);
|
||||||
static List *Swig_overload_rank(Node *n,
|
static List *Swig_overload_rank(Node *n,
|
||||||
bool script_lang_wrapping);
|
bool script_lang_wrapping);
|
||||||
|
|
||||||
int memberfunctionHandler(Node *n) {
|
int memberfunctionHandler(Node *n) {
|
||||||
if (debugMode)
|
if (debugMode)
|
||||||
|
|
@ -534,7 +534,7 @@ void R::addSMethodInfo(String *name, String *argType, int nargs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns the name of the new routine.
|
Returns the name of the new routine.
|
||||||
*/
|
*/
|
||||||
String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
||||||
String *funName = SwigType_manglestr(t);
|
String *funName = SwigType_manglestr(t);
|
||||||
|
|
@ -590,7 +590,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
||||||
|
|
||||||
emit_parameter_variables(parms, f);
|
emit_parameter_variables(parms, f);
|
||||||
emit_return_variable(n, rettype, f);
|
emit_return_variable(n, rettype, f);
|
||||||
// emit_attach_parmmaps(parms,f);
|
// emit_attach_parmmaps(parms,f);
|
||||||
|
|
||||||
/* Using weird name and struct to avoid potential conflicts. */
|
/* Using weird name and struct to avoid potential conflicts. */
|
||||||
Wrapper_add_local(f, "r_swig_cb_data", "RCallbackFunctionData *r_swig_cb_data = R_SWIG_getCallbackFunctionData()");
|
Wrapper_add_local(f, "r_swig_cb_data", "RCallbackFunctionData *r_swig_cb_data = R_SWIG_getCallbackFunctionData()");
|
||||||
|
|
@ -987,6 +987,7 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
|
||||||
/* This function checks for names ending in _set - perhaps it should */
|
/* This function checks for names ending in _set - perhaps it should */
|
||||||
/* use attributes of some other form, as it potentially clashes with */
|
/* use attributes of some other form, as it potentially clashes with */
|
||||||
/* methods ending in _set */
|
/* methods ending in _set */
|
||||||
|
|
||||||
if(n && outputNamespaceInfo) {
|
if(n && outputNamespaceInfo) {
|
||||||
Printf(s_namespace, "exportClasses(");
|
Printf(s_namespace, "exportClasses(");
|
||||||
}
|
}
|
||||||
|
|
@ -1021,7 +1022,7 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
|
||||||
struct or union (or class).
|
struct or union (or class).
|
||||||
className - the name of the struct or union (e.g. Bar for struct Bar)
|
className - the name of the struct or union (e.g. Bar for struct Bar)
|
||||||
isSet - a logical value indicating whether the method is for
|
isSet - a logical value indicating whether the method is for
|
||||||
modifying ($<-) or accessing ($) the member field.
|
modifying ($<-) or accessing ($) the member field.
|
||||||
el - a list of length 2 * # accessible member elements + 1.
|
el - a list of length 2 * # accessible member elements + 1.
|
||||||
The first element is the name of the class.
|
The first element is the name of the class.
|
||||||
The other pairs are member name and the name of the R function to access it.
|
The other pairs are member name and the name of the R function to access it.
|
||||||
|
|
@ -1326,7 +1327,7 @@ struct Overloaded {
|
||||||
|
|
||||||
|
|
||||||
List * R::Swig_overload_rank(Node *n,
|
List * R::Swig_overload_rank(Node *n,
|
||||||
bool script_lang_wrapping) {
|
bool script_lang_wrapping) {
|
||||||
Overloaded nodes[MAX_OVERLOAD];
|
Overloaded nodes[MAX_OVERLOAD];
|
||||||
int nnodes = 0;
|
int nnodes = 0;
|
||||||
Node *o = Getattr(n,"sym:overloaded");
|
Node *o = Getattr(n,"sym:overloaded");
|
||||||
|
|
@ -1444,7 +1445,7 @@ List * R::Swig_overload_rank(Node *n,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need subtype check here. If t2 is a subtype of t1, then we need to change the
|
/* Need subtype check here. If t2 is a subtype of t1, then we need to change the
|
||||||
order */
|
order */
|
||||||
|
|
||||||
if (SwigType_issubtype(t2,t1)) {
|
if (SwigType_issubtype(t2,t1)) {
|
||||||
Overloaded t = nodes[i];
|
Overloaded t = nodes[i];
|
||||||
|
|
@ -1560,7 +1561,7 @@ List * R::Swig_overload_rank(Node *n,
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < nnodes; i++) {
|
for (i = 0; i < nnodes; i++) {
|
||||||
if (nodes[i].error)
|
if (nodes[i].error)
|
||||||
Setattr(nodes[i].n, "overload:ignore", "1");
|
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||||
Append(result,nodes[i].n);
|
Append(result,nodes[i].n);
|
||||||
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
||||||
// Swig_print_node(nodes[i].n);
|
// Swig_print_node(nodes[i].n);
|
||||||
|
|
@ -1649,29 +1650,29 @@ void R::dispatchFunction(Node *n) {
|
||||||
if (tm) {
|
if (tm) {
|
||||||
if (Strcmp(tm,"numeric")==0) {
|
if (Strcmp(tm,"numeric")==0) {
|
||||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||||
j == 0 ? "" : " && ",
|
j == 0 ? "" : " && ",
|
||||||
j+1);
|
j+1);
|
||||||
}
|
}
|
||||||
else if (Strcmp(tm,"integer")==0) {
|
else if (Strcmp(tm,"integer")==0) {
|
||||||
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
|
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
|
||||||
j == 0 ? "" : " && ",
|
j == 0 ? "" : " && ",
|
||||||
j+1, j+1);
|
j+1, j+1);
|
||||||
}
|
}
|
||||||
else if (Strcmp(tm,"character")==0) {
|
else if (Strcmp(tm,"character")==0) {
|
||||||
Printf(f->code, "%sis.character(argv[[%d]])",
|
Printf(f->code, "%sis.character(argv[[%d]])",
|
||||||
j == 0 ? "" : " && ",
|
j == 0 ? "" : " && ",
|
||||||
j+1);
|
j+1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
||||||
j == 0 ? "" : " && ",
|
j == 0 ? "" : " && ",
|
||||||
j+1,
|
j+1,
|
||||||
tm);
|
tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!SwigType_ispointer(Getattr(p, "type"))) {
|
if (!SwigType_ispointer(Getattr(p, "type"))) {
|
||||||
Printf(f->code, " && length(argv[[%d]]) == 1",
|
Printf(f->code, " && length(argv[[%d]]) == 1",
|
||||||
j+1);
|
j+1);
|
||||||
}
|
}
|
||||||
p = Getattr(p, "tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
}
|
}
|
||||||
|
|
@ -1828,14 +1829,14 @@ int R::functionWrapper(Node *n) {
|
||||||
Printv(sfun->def, "\n`", sfname, "` = function(", NIL);
|
Printv(sfun->def, "\n`", sfname, "` = function(", NIL);
|
||||||
|
|
||||||
if(outputNamespaceInfo) {//XXX Need to be a little more discriminating
|
if(outputNamespaceInfo) {//XXX Need to be a little more discriminating
|
||||||
if (constructor) {
|
if (constructor) {
|
||||||
String *niname = Copy(iname);
|
String *niname = Copy(iname);
|
||||||
Replace(niname, "new_", "", DOH_REPLACE_FIRST);
|
Replace(niname, "new_", "", DOH_REPLACE_FIRST);
|
||||||
addNamespaceFunction(niname);
|
addNamespaceFunction(niname);
|
||||||
Delete(niname);
|
Delete(niname);
|
||||||
} else {
|
} else {
|
||||||
addNamespaceFunction(iname);
|
addNamespaceFunction(iname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Swig_typemap_attach_parms("scoercein", l, f);
|
Swig_typemap_attach_parms("scoercein", l, f);
|
||||||
|
|
@ -2138,13 +2139,13 @@ int R::functionWrapper(Node *n) {
|
||||||
Replaceall(tm,"$source","ans");
|
Replaceall(tm,"$source","ans");
|
||||||
Replaceall(tm,"$result","ans");
|
Replaceall(tm,"$result","ans");
|
||||||
if (constructor) {
|
if (constructor) {
|
||||||
Node * parent = Getattr(n, "parentNode");
|
Node * parent = Getattr(n, "parentNode");
|
||||||
String * smartname = Getattr(parent, "feature:smartptr");
|
String * smartname = Getattr(parent, "feature:smartptr");
|
||||||
if (smartname) {
|
if (smartname) {
|
||||||
smartname = getRClassName(smartname, 1, 1);
|
smartname = getRClassName(smartname, 1, 1);
|
||||||
Replaceall(tm, "$R_class", smartname);
|
Replaceall(tm, "$R_class", smartname);
|
||||||
Delete(smartname);
|
Delete(smartname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
replaceRClass(tm, Getattr(n, "type"));
|
replaceRClass(tm, Getattr(n, "type"));
|
||||||
Chop(tm);
|
Chop(tm);
|
||||||
|
|
@ -2289,7 +2290,7 @@ int R::outputRegistrationRoutines(File *out) {
|
||||||
if (inCPlusMode)
|
if (inCPlusMode)
|
||||||
Printv(out, "extern \"C\" ", NIL);
|
Printv(out, "extern \"C\" ", NIL);
|
||||||
{ /* R allows pckage names to have '.' in the name, which is not allowed in C++ var names
|
{ /* R allows pckage names to have '.' in the name, which is not allowed in C++ var names
|
||||||
we simply replace all occurrences of '.' with '_' to construct the var name */
|
we simply replace all occurrences of '.' with '_' to construct the var name */
|
||||||
String * Rpackage_sane = Copy(Rpackage);
|
String * Rpackage_sane = Copy(Rpackage);
|
||||||
Replace(Rpackage_sane, ".", "_", DOH_REPLACE_ANY);
|
Replace(Rpackage_sane, ".", "_", DOH_REPLACE_ANY);
|
||||||
Printf(out, "SWIGEXPORT void R_init_%s(DllInfo *dll) {\n", Rpackage_sane);
|
Printf(out, "SWIGEXPORT void R_init_%s(DllInfo *dll) {\n", Rpackage_sane);
|
||||||
|
|
@ -2348,13 +2349,28 @@ void R::registerClass(Node *n) {
|
||||||
Delete(base);
|
Delete(base);
|
||||||
String *smartptr = Getattr(n, "feature:smartptr");
|
String *smartptr = Getattr(n, "feature:smartptr");
|
||||||
if (smartptr) {
|
if (smartptr) {
|
||||||
SwigType *spt = Swig_cparse_type(smartptr);
|
List *l = Getattr(n, "bases");
|
||||||
String *smart = SwigType_typedef_resolve_all(spt);
|
SwigType *spt = Swig_cparse_type(smartptr);
|
||||||
String *smart_rname = SwigType_manglestr(smart);
|
String *smart = SwigType_typedef_resolve_all(spt);
|
||||||
Printf(s_classes, "setClass('_p%s', contains = c('%s'))\n", smart_rname, sname);
|
String *smart_rname = SwigType_manglestr(smart);
|
||||||
Delete(spt);
|
Printf(s_classes, "setClass('_p%s', contains = c('%s'", smart_rname, sname);
|
||||||
Delete(smart);
|
Delete(spt);
|
||||||
Delete(smart_rname);
|
Delete(smart);
|
||||||
|
Delete(smart_rname);
|
||||||
|
for(int i = 0; i < Len(l); i++) {
|
||||||
|
Node * b = Getitem(l, i);
|
||||||
|
smartptr = Getattr(b, "feature:smartptr");
|
||||||
|
if (smartptr) {
|
||||||
|
spt = Swig_cparse_type(smartptr);
|
||||||
|
smart = SwigType_typedef_resolve_all(spt);
|
||||||
|
smart_rname = SwigType_manglestr(smart);
|
||||||
|
Printf(s_classes, ", '_p%s'", smart_rname);
|
||||||
|
Delete(spt);
|
||||||
|
Delete(smart);
|
||||||
|
Delete(smart_rname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Printf(s_classes, "))\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2826,17 +2842,4 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue