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