Skip to content

Commit b0ce226

Browse files
committed
Remove redundant code from r.cxx
1 parent f0c9229 commit b0ce226

File tree

1 file changed

+2
-115
lines changed

1 file changed

+2
-115
lines changed

Source/Modules/r.cxx

Lines changed: 2 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ static String *getRClassName(String *retType, int deRef=0, int upRef=0) {
8989
static String * getRClassNameCopyStruct(String *retType, int addRef) {
9090
String *tmp = NewString("");
9191

92-
#if 1
9392
List *l = SwigType_split(retType);
9493
int n = Len(l);
9594
if(!l || n == 0) {
@@ -115,24 +114,6 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) {
115114
}
116115
}
117116

118-
#else
119-
char *retName = Char(SwigType_manglestr(retType));
120-
if(!retName)
121-
return(tmp);
122-
123-
if(addRef) {
124-
while(retName && strlen(retName) > 1 &&
125-
strncmp(retName, "_p", 2) == 0) {
126-
retName += 2;
127-
Printf(tmp, "Ref");
128-
}
129-
}
130-
131-
if(retName[0] == '_')
132-
retName ++;
133-
Insert(tmp, 0, retName);
134-
#endif
135-
136117
return tmp;
137118
}
138119

@@ -273,17 +254,7 @@ class R : public Language {
273254
int generateCopyRoutines(Node *n);
274255
int DumpCode(Node *n);
275256

276-
int OutputMemberReferenceMethod(String *className, int isSet,
277-
List *memberList, List *nameList,
278-
List *typeList, File *out);
279-
#if 0
280-
// not used
281-
int OutputArrayMethod(String *className, List *el, File *out);
282-
int OutputClassMemberTable(Hash *tb, File *out);
283-
int OutputClassMethodsTable(File *out);
284-
int OutputClassAccessInfo(Hash *tb, File *out);
285-
#endif
286-
257+
int OutputMemberReferenceMethod(String *className, int isSet, List *memberList, List *nameList, List *typeList, File *out);
287258
int defineArrayAccessors(SwigType *type);
288259

289260
void addNamespaceFunction(String *name) {
@@ -369,8 +340,6 @@ class R : public Language {
369340
String *R_MEMBER_GET;
370341

371342
int processing_class_member_function;
372-
// List *class_member_functions;
373-
// List *class_member_set_functions;
374343
// Spread out the lists so that they are simpler to process
375344
// by storing the type of the method (i.e. set, get or nothing)
376345
// and having separate lists for name, membername and wrapper
@@ -731,18 +700,6 @@ void R::init() {
731700
}
732701

733702

734-
735-
#if 0
736-
int R::cDeclaration(Node *n) {
737-
SwigType *t = Getattr(n, "type");
738-
SwigType *name = Getattr(n, "name");
739-
if (debugMode)
740-
Printf(stdout, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
741-
return Language::cDeclaration(n);
742-
}
743-
#endif
744-
745-
746703
/* -------------------------------------------------------------
747704
* Method from Language that is called to start the entire
748705
* processing off, i.e. the generation of the code.
@@ -1152,49 +1109,6 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
11521109
return SWIG_OK;
11531110
}
11541111

1155-
#if 0
1156-
// not used
1157-
/* -------------------------------------------------------------
1158-
* Write the methods for [ or [<- for accessing a member field in an
1159-
* struct or union (or class).
1160-
* className - the name of the struct or union (e.g. Bar for struct Bar)
1161-
* el - a list of length 2 * # accessible member elements + 1.
1162-
* The first element is the name of the class.
1163-
* The other pairs are member name and the name of the R function to access it.
1164-
* out - the stream where we write the code.
1165-
* --------------------------------------------------------------*/
1166-
1167-
int R::OutputArrayMethod(String *className, List *el, File *out) {
1168-
int numMems = Len(el), j;
1169-
1170-
if(!el || numMems == 0)
1171-
return(0);
1172-
1173-
Printf(out, "# start of array methods for %s\n", className);
1174-
for(j = 0; j < numMems; j+=3) {
1175-
String *item = Getitem(el, j);
1176-
String *dup = Getitem(el, j + 1);
1177-
if (!Strcmp(item, "__getitem__")) {
1178-
Printf(out,
1179-
"setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ",
1180-
getRClassName(className));
1181-
Printf(out, " sapply(i, function (n) %s(x, as.integer(n-1))))\n\n", dup);
1182-
}
1183-
if (!Strcmp(item, "__setitem__")) {
1184-
Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)",
1185-
getRClassName(className));
1186-
Printf(out, " sapply(1:length(i), function(n) %s(x, as.integer(i[n]-1), value[n])))\n\n", dup);
1187-
}
1188-
1189-
}
1190-
1191-
Printf(out, "# end of array methods for %s\n", className);
1192-
1193-
return SWIG_OK;
1194-
}
1195-
1196-
#endif
1197-
11981112
/* -------------------------------------------------------------
11991113
* Called when a enumeration is to be processed.
12001114
* We want to call the R function defineEnumeration().
@@ -2118,18 +2032,7 @@ int R::functionWrapper(Node *n) {
21182032
Replaceall(tm,"$owner", "0");
21192033
}
21202034

2121-
#if 0
2122-
if(addCopyParam) {
2123-
Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n");
2124-
Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n");
2125-
Printf(f->code, "}\n else {\n");
2126-
}
2127-
#endif
21282035
Printf(f->code, "%s\n", tm);
2129-
#if 0
2130-
if(addCopyParam)
2131-
Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */
2132-
#endif
21332036

21342037
} else {
21352038
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number,
@@ -2467,14 +2370,6 @@ int R::classDeclaration(Node *n) {
24672370
opaqueClassDeclaration = NULL;
24682371

24692372

2470-
// OutputArrayMethod(name, class_member_functions, sfile);
2471-
#if 0
2472-
// RJB - this bit will need to change
2473-
if (class_member_functions)
2474-
OutputMemberReferenceMethod(name, 0, class_member_functions, sfile);
2475-
if (class_member_set_functions)
2476-
OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile);
2477-
#else
24782373
if (class_member_function_types) {
24792374

24802375
// collect the "set" methods
@@ -2507,7 +2402,6 @@ int R::classDeclaration(Node *n) {
25072402
Delete(class_other_functionnames);
25082403
Delete(class_other_functiontypes);
25092404
}
2510-
#endif
25112405

25122406
if (class_member_function_types) {
25132407
Delete(class_member_function_types);
@@ -2544,9 +2438,6 @@ int R::classDeclaration(Node *n) {
25442438
c = nextSibling(c);
25452439
continue;
25462440
}
2547-
#if 0
2548-
tp = getRType(c);
2549-
#else
25502441
tp = Swig_typemap_lookup("rtype", c, "", 0);
25512442
if(!tp) {
25522443
c = nextSibling(c);
@@ -2573,7 +2464,7 @@ int R::classDeclaration(Node *n) {
25732464
// returns "" tp = processType(elType, c, NULL);
25742465
// Printf(stdout, "<classDeclaration> elType %p\n", elType);
25752466
// tp = getRClassNameCopyStruct(Getattr(c, "type"), 1);
2576-
#endif
2467+
25772468
String *elNameT = replaceInitialDash(elName);
25782469
Printf(def, "%s%s = \"%s\"", tab8, elNameT, tp);
25792470
firstItem = false;
@@ -2934,10 +2825,6 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
29342825
return tmp;
29352826
}
29362827

2937-
#if 0
2938-
SwigType_isfunction(t) && SwigType_ispointer(t)
2939-
#endif
2940-
29412828
return NULL;
29422829
}
29432830

0 commit comments

Comments
 (0)