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

View file

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