Code style fixes.

Output after running 'make beautify-file' on scilab file
This commit is contained in:
William S Fulton 2013-08-30 19:32:38 +01:00
commit d4df5fb07b
2 changed files with 105 additions and 109 deletions

View file

@ -16,16 +16,16 @@
/*#define SWIG_DEBUG*/ /*#define SWIG_DEBUG*/
static const char *usage = (char*) "\ static const char *usage = (char *) "\
Scilab options\n\ Scilab options\n\
-addsrc <source files> additionnal source files (separated by space) to include in build script (ex: myfile.cxx myfile2.cxx)\n\ -addsrc <source files> additionnal source files (separated by space) to include in build script (ex: myfile.cxx myfile2.cxx)\n\
-addcflag -I<path> additionnal include path to include in build script (ex: -I/usr/includes/)\n\ -addcflag -I<path> additionnal include path to include in build script (ex: -I/usr/includes/)\n\
-addldlag <flag> additionnal link flag to include in build script (ex: -lm)\n\ -addldlag <flag> additionnal link flag to include in build script (ex: -lm)\n\
-vbl <level> sets the build verbose level (default 0)\n\n"; -vbl <level> sets the build verbose level (default 0)\n\n";
const char* SWIG_INIT_FUNCTION_NAME = "SWIG_Init"; const char *SWIG_INIT_FUNCTION_NAME = "SWIG_Init";
class SCILAB : public Language { class SCILAB:public Language {
protected: protected:
/* General objects used for holding the strings */ /* General objects used for holding the strings */
File *beginSection; File *beginSection;
@ -42,13 +42,13 @@ protected:
String *cflag; String *cflag;
String *ldflag; String *ldflag;
String* verboseBuildLevel; String *verboseBuildLevel;
public: public:
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
* main() * main()
* ----------------------------------------------------------------------*/ * ----------------------------------------------------------------------*/
virtual void main(int argc, char* argv[]) { virtual void main(int argc, char *argv[]) {
sourceFileList = NewList(); sourceFileList = NewList();
ldflag = NULL; ldflag = NULL;
@ -64,32 +64,31 @@ public:
/* Indicate arg as valid */ /* Indicate arg as valid */
Swig_mark_arg(argIndex); Swig_mark_arg(argIndex);
} else if (strcmp(argv[argIndex], "-addsrc") == 0) { } else if (strcmp(argv[argIndex], "-addsrc") == 0) {
if (argv[argIndex+1] != NULL) { if (argv[argIndex + 1] != NULL) {
Swig_mark_arg(argIndex); Swig_mark_arg(argIndex);
char *sourceFile = strtok(argv[argIndex+1], " "); char *sourceFile = strtok(argv[argIndex + 1], " ");
while (sourceFile != NULL) while (sourceFile != NULL) {
{
DohInsertitem(sourceFileList, Len(sourceFileList), sourceFile); DohInsertitem(sourceFileList, Len(sourceFileList), sourceFile);
sourceFile = strtok(NULL, " "); sourceFile = strtok(NULL, " ");
} }
Swig_mark_arg(argIndex+1); Swig_mark_arg(argIndex + 1);
} }
} else if (strcmp(argv[argIndex], "-addcflag") == 0) { } else if (strcmp(argv[argIndex], "-addcflag") == 0) {
Swig_mark_arg(argIndex); Swig_mark_arg(argIndex);
if (argv[argIndex+1] != NULL) { if (argv[argIndex + 1] != NULL) {
cflag = NewString(argv[argIndex+1]); cflag = NewString(argv[argIndex + 1]);
Swig_mark_arg(argIndex+1); Swig_mark_arg(argIndex + 1);
} }
} else if (strcmp(argv[argIndex], "-addldflag") == 0) { } else if (strcmp(argv[argIndex], "-addldflag") == 0) {
Swig_mark_arg(argIndex); Swig_mark_arg(argIndex);
if (argv[argIndex+1] != NULL) { if (argv[argIndex + 1] != NULL) {
ldflag = NewString(argv[argIndex+1]); ldflag = NewString(argv[argIndex + 1]);
Swig_mark_arg(argIndex+1); Swig_mark_arg(argIndex + 1);
} }
} else if (strcmp(argv[argIndex], "-vbl") == 0) { } else if (strcmp(argv[argIndex], "-vbl") == 0) {
Swig_mark_arg(argIndex); Swig_mark_arg(argIndex);
verboseBuildLevel = NewString(argv[argIndex+1]); verboseBuildLevel = NewString(argv[argIndex + 1]);
Swig_mark_arg(argIndex+1); Swig_mark_arg(argIndex + 1);
} }
} }
} }
@ -119,10 +118,10 @@ public:
virtual int top(Node *node) { virtual int top(Node *node) {
/* Get the module name */ /* Get the module name */
String* moduleName = Getattr(node, "name"); String *moduleName = Getattr(node, "name");
/* Get the output file name */ /* Get the output file name */
String* outputFilename = Getattr(node, "outfile"); String *outputFilename = Getattr(node, "outfile");
/* Initialize I/O */ /* Initialize I/O */
beginSection = NewFile(NewStringf("%s%s", SWIG_output_directory(), outputFilename), "w", SWIG_output_files()); beginSection = NewFile(NewStringf("%s%s", SWIG_output_directory(), outputFilename), "w", SWIG_output_files());
@ -170,15 +169,11 @@ public:
} }
DohInsertitem(sourceFileList, 0, outputFilename); DohInsertitem(sourceFileList, 0, outputFilename);
for (int i=0; i<Len(sourceFileList); i++) for (int i = 0; i < Len(sourceFileList); i++) {
{ String *sourceFile = Getitem(sourceFileList, i);
String* sourceFile = Getitem(sourceFileList, i); if (i == 0) {
if (i==0)
{
Printf(builderCode, "files = \"%s\";\n", sourceFile); Printf(builderCode, "files = \"%s\";\n", sourceFile);
} } else {
else
{
Printf(builderCode, "files($ + 1) = \"%s\";\n", sourceFile); Printf(builderCode, "files($ + 1) = \"%s\";\n", sourceFile);
} }
} }
@ -364,7 +359,8 @@ public:
Delete(functionReturnTypemap); Delete(functionReturnTypemap);
} else { } else {
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(functionReturnType, 0), functionName); Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(functionReturnType, 0),
functionName);
} }
/* Write typemaps(out) */ /* Write typemaps(out) */
@ -374,7 +370,7 @@ public:
minOutputArguments++; minOutputArguments++;
maxOutputArguments++; maxOutputArguments++;
Printf(wrapper->code, "SWIG_Scilab_SetOutputPosition(%d); /* paramTypemap */ \n", minOutputArguments); Printf(wrapper->code, "SWIG_Scilab_SetOutputPosition(%d); /* paramTypemap */ \n", minOutputArguments);
char result[64] = {}; char result[64] = { };
sprintf(result, "%d", minOutputArguments); sprintf(result, "%d", minOutputArguments);
Replaceall(paramTypemap, "$result", result); Replaceall(paramTypemap, "$result", result);
Printf(wrapper->code, "%s\n", paramTypemap); Printf(wrapper->code, "%s\n", paramTypemap);
@ -392,7 +388,7 @@ public:
Replaceall(tm, "$source", Getattr(param, "lname")); Replaceall(tm, "$source", Getattr(param, "lname"));
Printf(wrapper->code, "%s\n", tm); Printf(wrapper->code, "%s\n", tm);
} }
param= Getattr(param, "tmap:freearg:next"); param = Getattr(param, "tmap:freearg:next");
} else { } else {
param = nextSibling(param); param = nextSibling(param);
} }
@ -414,7 +410,7 @@ public:
if (minOutputArguments == 0) { if (minOutputArguments == 0) {
maxOutputArguments = 1; maxOutputArguments = 1;
} }
char argnumber[64] = {}; char argnumber[64] = { };
sprintf(argnumber, "%d", minInputArguments); sprintf(argnumber, "%d", minInputArguments);
Replaceall(wrapper->code, "$mininputarguments", argnumber); Replaceall(wrapper->code, "$mininputarguments", argnumber);
sprintf(argnumber, "%d", maxInputArguments); sprintf(argnumber, "%d", maxInputArguments);
@ -623,6 +619,6 @@ public:
} }
}; };
extern "C" Language* swig_scilab(void) { extern "C" Language *swig_scilab(void) {
return new SCILAB(); return new SCILAB();
} }

View file

@ -88,7 +88,7 @@ static swig_module modules[] = {
{"-python", swig_python, "Python"}, {"-python", swig_python, "Python"},
{"-r", swig_r, "R (aka GNU S)"}, {"-r", swig_r, "R (aka GNU S)"},
{"-ruby", swig_ruby, "Ruby"}, {"-ruby", swig_ruby, "Ruby"},
{"-scilab",swig_scilab,"Scilab"}, {"-scilab", swig_scilab, "Scilab"},
{"-sexp", swig_sexp, "Lisp S-Expressions"}, {"-sexp", swig_sexp, "Lisp S-Expressions"},
{"-tcl", swig_tcl, "Tcl"}, {"-tcl", swig_tcl, "Tcl"},
{"-tcl8", swig_tcl, 0}, {"-tcl8", swig_tcl, 0},