Reindent Scilab sources

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12277 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Sylvestre Ledru 2010-10-14 15:59:20 +00:00
commit 8d0ceb287d

View file

@ -17,7 +17,7 @@ char cvsroot_scilab_cxx[] = "$Id$";
static const char *usage = (char *) "\ static const char *usage = (char *) "\
Scilab Options (available with -scilab)\n\ Scilab Options (available with -scilab)\n\
(none yet)\n\n"; (none yet)\n\n";
class SCILAB:public Language { class SCILAB:public Language {
@ -46,9 +46,9 @@ public:
virtual void main(int argc, char *argv[]) { virtual void main(int argc, char *argv[]) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (argv[i]) { if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) { if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stderr); fputs(usage, stderr);
} }
} }
} }
@ -86,7 +86,7 @@ public:
if (!f_begin) { if (!f_begin) {
FileErrorDisplay(outfile); FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} }
f_runtime = NewString(""); f_runtime = NewString("");
f_header = NewString(""); f_header = NewString("");
f_wrappers = NewString(""); f_wrappers = NewString("");
@ -217,44 +217,45 @@ public:
/* Walk the function parameter list and generate code to get arguments */ /* Walk the function parameter list and generate code to get arguments */
for (j = 0, p = l; j < num_arguments; ++j) { for (j = 0, p = l; j < num_arguments; ++j) {
while (checkAttribute(p, "tmap:in:numinputs", "0")) { while (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next"); p = Getattr(p, "tmap:in:next");
} }
SwigType *pt = Getattr(p, "type"); SwigType *pt = Getattr(p, "type");
if ( Equal(SwigType_base(pt), "long long") || Equal(SwigType_base(pt), "unsigned long long")) if ( Equal(SwigType_base(pt), "long long") || Equal(SwigType_base(pt), "unsigned long long")) {
Printv(f->code, " #ifdef __SCILAB_INT64__\n", NIL); Printv(f->code, " #ifdef __SCILAB_INT64__\n", NIL);
}
/* Get typemap for this argument */ /* Get typemap for this argument */
String *tm = Getattr(p, "tmap:in"); String *tm = Getattr(p, "tmap:in");
if (tm) { if (tm) {
if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) { if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) {
p = nextSibling(p); p = nextSibling(p);
continue; continue;
} }
char source[64]; char source[64];
sprintf(source, "%d", j + 1); sprintf(source, "%d", j + 1);
Setattr(p, "emit:input", source); Setattr(p, "emit:input", source);
Replaceall(tm, "$input", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input"));
String *getargs = NewString(""); String *getargs = NewString("");
/* The paremeter is variable */ /* The paremeter is variable */
if (j >= num_required) if (j >= num_required)
Printf(getargs, "if (Rhs > %d) {\n%s\n}", j, tm); Printf(getargs, "if (Rhs > %d) {\n%s\n}", j, tm);
else else
Printv(getargs, tm, NIL); Printv(getargs, tm, NIL);
Printv(f->code, getargs, "\n", NIL); Printv(f->code, getargs, "\n", NIL);
if ( Equal(SwigType_base(pt), "long long") || Equal(SwigType_base(pt), "unsigned long long")) if ( Equal(SwigType_base(pt), "long long") || Equal(SwigType_base(pt), "unsigned long long"))
Printv(f->code, "#endif\n", NIL); Printv(f->code, "#endif\n", NIL);
Delete(getargs); Delete(getargs);
p = Getattr(p, "tmap:in:next"); p = Getattr(p, "tmap:in:next");
continue; continue;
} }
else { else {
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
break; break;
} }
} }
@ -272,7 +273,7 @@ public:
/* There are more than one output */ /* There are more than one output */
if (out_required > 0) { if (out_required > 0) {
Printf(f->code, "LhsVar(iOutNum) = iVarOut;\n"); Printf(f->code, "LhsVar(iOutNum) = iVarOut;\n");
Printf(f->code, "iOutNum ++;\niVarOut ++;\n"); Printf(f->code, "iOutNum ++;\niVarOut ++;\n");
} }
Printf(f->code, "%s\n", tm); Printf(f->code, "%s\n", tm);
@ -280,22 +281,22 @@ public:
out_required ++; out_required ++;
} }
else { else {
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), iname); Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), iname);
} }
/* Insert argument output code */ /* Insert argument output code */
String *outarg = NewString(""); String *outarg = NewString("");
for (p = l; p;) { for (p = l; p;) {
if ((tm = Getattr(p, "tmap:argout"))) { if ((tm = Getattr(p, "tmap:argout"))) {
//if (out_required > 0) { //if (out_required > 0) {
// Printf(f->code, "LhsVar(iOutNum) = iVarOut;\n"); // Printf(f->code, "LhsVar(iOutNum) = iVarOut;\n");
// Printf(f->code,"iOutNum ++;\niVarOut ++;\n"); // Printf(f->code,"iOutNum ++;\niVarOut ++;\n");
//} //}
Printv(outarg, tm, "\n", NIL); Printv(outarg, tm, "\n", NIL);
p = Getattr(p, "tmap:argout:next"); p = Getattr(p, "tmap:argout:next");
out_required ++; out_required ++;
} else { } else {
p = nextSibling(p); p = nextSibling(p);
} }
} }
Printv(f->code, outarg, NIL); Printv(f->code, outarg, NIL);
@ -303,10 +304,10 @@ public:
/* Insert constraint checking code */ /* Insert constraint checking code */
for (p = l; p;) { for (p = l; p;) {
if ((tm = Getattr(p, "tmap:check"))) { if ((tm = Getattr(p, "tmap:check"))) {
Printv(f->code, tm, "\n", NIL); Printv(f->code, tm, "\n", NIL);
p = Getattr(p, "tmap:check:next"); p = Getattr(p, "tmap:check:next");
} else { } else {
p = nextSibling(p); p = nextSibling(p);
} }
} }
@ -314,12 +315,12 @@ public:
String *cleanup = NewString(""); String *cleanup = NewString("");
for (p = l; p;) { for (p = l; p;) {
if ((tm = Getattr(p, "tmap:freearg"))) { if ((tm = Getattr(p, "tmap:freearg"))) {
if (tm && (Len(tm) != 0)) { if (tm && (Len(tm) != 0)) {
Printv(cleanup, tm, "\n", NIL); Printv(cleanup, tm, "\n", NIL);
} }
p = Getattr(p, "tmap:freearg:next"); p = Getattr(p, "tmap:freearg:next");
} else { } else {
p = nextSibling(p); p = nextSibling(p);
} }
} }
@ -353,7 +354,7 @@ public:
/* Finish the the code for the function */ /* Finish the the code for the function */
//if (flag) //if (flag)
Printf(f->code, "//PutLhsVar();\n"); Printf(f->code, "//PutLhsVar();\n");
Printf(f->code, "return 0;\n"); Printf(f->code, "return 0;\n");
Printf(f->code, "}\n"); Printf(f->code, "}\n");
@ -407,8 +408,9 @@ public:
Wrapper_add_local(f, "iOutNum", "int iOutNum = 1"); Wrapper_add_local(f, "iOutNum", "int iOutNum = 1");
Wrapper_add_local(f, "iVarOut", "int iVarOut = Rhs + 1"); Wrapper_add_local(f, "iVarOut", "int iVarOut = Rhs + 1");
Printf(tmp, "int argv[%d]={", maxargs); Printf(tmp, "int argv[%d]={", maxargs);
for (int j = 0; j < maxargs; ++j) for (int j = 0; j < maxargs; ++j) {
Printf(tmp, "%s%d", j ? "," : " ", j + 1); Printf(tmp, "%s%d", j ? "," : " ", j + 1);
}
Printf(tmp, "}"); Printf(tmp, "}");
Wrapper_add_local(f, "argv", tmp); Wrapper_add_local(f, "argv", tmp);
/* Dump the dispatch function */ /* Dump the dispatch function */
@ -460,12 +462,14 @@ public:
Printf(globalVar, "int %s = 1;\n", rowname); Printf(globalVar, "int %s = 1;\n", rowname);
Printf(globalVar, "int %s = 1;\n", colname); Printf(globalVar, "int %s = 1;\n", colname);
if(!Strcmp(t, "p.double")) if(!Strcmp(t, "p.double")) {
Printf(globalVar, "int %s = 0;\n\n", iscomplexname); Printf(globalVar, "int %s = 0;\n\n", iscomplexname);
else } else {
Printf(globalVar, "\n"); Printf(globalVar, "\n");
if ( Equal(SwigType_base(t), "long long") || Equal(SwigType_base(t), "unsigned long long")) }
if ( Equal(SwigType_base(t), "long long") || Equal(SwigType_base(t), "unsigned long long")) {
Printv(setf->def, "#ifdef __SCILAB_INT64__\n", NIL); Printv(setf->def, "#ifdef __SCILAB_INT64__\n", NIL);
}
Printv(setf->def, "int ", setname, " (char *fname, unsigned long fname_len) {\n", NIL); Printv(setf->def, "int ", setname, " (char *fname, unsigned long fname_len) {\n", NIL);
/* Check the number of input and output */ /* Check the number of input and output */
@ -483,26 +487,26 @@ public:
if (Getattr(n, "unnamedinstance")) if (Getattr(n, "unnamedinstance"))
Setattr(n, "type", "int"); Setattr(n, "type", "int");
if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
Replaceall(tm, "$argnum", "1"); Replaceall(tm, "$argnum", "1");
Replaceall(tm, "iRows", rowname); Replaceall(tm, "iRows", rowname);
Replaceall(tm, "iCols", colname); Replaceall(tm, "iCols", colname);
Replaceall(tm, "isComplex", iscomplexname); Replaceall(tm, "isComplex", iscomplexname);
Replaceall(tm, "$input", "1"); Replaceall(tm, "$input", "1");
emit_action_code(n, setf->code, tm); emit_action_code(n, setf->code, tm);
Delete(tm); Delete(tm);
} else { } else {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
} }
} }
else { else {
Append(setf->code, "SWIG_Error(999, \"attempt to set immutable member variable\");"); Append(setf->code, "SWIG_Error(999, \"attempt to set immutable member variable\");");
} }
Append(setf->code, "}\n"); Append(setf->code, "}\n");
if ( Equal(SwigType_base(t), "long long") || Equal(SwigType_base(t), "unsigned long long")) if ( Equal(SwigType_base(t), "long long") || Equal(SwigType_base(t), "unsigned long long"))
Printv(setf->def, "#endif\n", NIL); Printv(setf->def, "#endif\n", NIL);
Wrapper_print(setf, f_wrappers); Wrapper_print(setf, f_wrappers);
if (++ function_count % 10 == 0) { if (++ function_count % 10 == 0) {
Printf(f_builder_code, "];\n\ntable = [table;"); Printf(f_builder_code, "];\n\ntable = [table;");
} }
Printf(f_builder_code, "\"%s\",\"%s\";", setname, setname); Printf(f_builder_code, "\"%s\",\"%s\";", setname, setname);
@ -542,12 +546,12 @@ public:
/* Dump the wrapper function */ /* Dump the wrapper function */
Printf(getf->code, "LhsVar(iOutNum) = iVarOut;\n"); Printf(getf->code, "LhsVar(iOutNum) = iVarOut;\n");
Append(getf->code, "}\n"); Append(getf->code, "}\n");
if ( Equal(SwigType_base(t), "long long") || Equal(SwigType_base(t), "unsigned long long")) if ( Equal(SwigType_base(t), "long long") || Equal(SwigType_base(t), "unsigned long long"))
Printv(getf->def, " #endif\n", NIL); Printv(getf->def, " #endif\n", NIL);
Wrapper_print(getf, f_wrappers); Wrapper_print(getf, f_wrappers);
Printf(f_header,"%s", globalVar); Printf(f_header,"%s", globalVar);
if (++ function_count % 10 == 0) { if (++ function_count % 10 == 0) {
Printf(f_builder_code, "];\n\ntable = [table;"); Printf(f_builder_code, "];\n\ntable = [table;");
} }
Printf(f_builder_code, "\"%s\",\"%s\";", getname, getname); Printf(f_builder_code, "\"%s\",\"%s\";", getname, getname);
@ -612,7 +616,7 @@ public:
Append(getf->code, "}\n"); Append(getf->code, "}\n");
Wrapper_print(getf, f_wrappers); Wrapper_print(getf, f_wrappers);
if (++ function_count % 10 == 0) { if (++ function_count % 10 == 0) {
Printf(f_builder_code, "];\n\ntable = [table;"); Printf(f_builder_code, "];\n\ntable = [table;");
} }
Printf(f_builder_code, "\"%s\",\"%s\";", getname, getname); Printf(f_builder_code, "\"%s\",\"%s\";", getname, getname);