From 30faff1fce99676356b8ddb3d4966abde6e63781 Mon Sep 17 00:00:00 2001 From: Simon Marchetto Date: Tue, 21 Oct 2014 14:39:18 +0200 Subject: [PATCH] scilab: remove outputlibrary option + renaming module to gateway --- Doc/Manual/Scilab.html | 6 --- Source/Modules/scilab.cxx | 110 +++++++++++++------------------------- 2 files changed, 37 insertions(+), 79 deletions(-) diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index cdb63a815..84c42600b 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -290,12 +290,6 @@ The following table lists the Scilab specific command line options in addition t Generate the gateway XML with the given <gateway_id> - --outputlibrary <name> -Set name of the output library - - -

diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx index 36eb9ef04..011ac459a 100644 --- a/Source/Modules/scilab.cxx +++ b/Source/Modules/scilab.cxx @@ -27,8 +27,7 @@ Scilab options (available with -scilab)\n\ -buildflags - Use the Scilab script to set build flags\n\ -buildverbositylevel - Set the build verbosity (default 0)\n\ -gatewayxml - Generate gateway xml with the given \n\ - -nobuilder - Do not generate builder script\n\ - -outputlibrary - Set name of the output library to \n\n"; + -nobuilder - Do not generate builder script\n\n"; class SCILAB:public Language { protected: @@ -67,8 +66,6 @@ protected: bool createLoader; File *loaderFile; String* loaderScript; - - String *libraryName; public: /* ------------------------------------------------------------------------ @@ -98,8 +95,6 @@ public: loaderFile = NULL; loaderScript = NULL; - libraryName = NULL; - /* Manage command line arguments */ for (int argIndex = 1; argIndex < argc; argIndex++) { if (argv[argIndex] != NULL) { @@ -145,10 +140,6 @@ public: createGatewayXML = true; gatewayID = NewString(argv[argIndex + 1]); Swig_mark_arg(argIndex + 1); - } else if (strcmp(argv[argIndex], "-outputlibrary") == 0) { - Swig_mark_arg(argIndex); - libraryName = NewString(argv[argIndex + 1]); - Swig_mark_arg(argIndex + 1); } } } @@ -179,12 +170,11 @@ public: virtual int top(Node *node) { /* Get the module name */ - String *moduleName = Getattr(node, "name"); + String *gatewayName = Getattr(node, "name"); - /* Set the library name if not specified */ - if (libraryName == NULL) { - libraryName = moduleName; - } + // Set gateway source and library name + String* gatewaySourceName = NewStringf("gw_%s", gatewayName); + String* gatewayLibraryName = NewStringf("lib%s", gatewayName); /* Get the output file name */ String *outputFilename = Getattr(node, "outfile"); @@ -212,31 +202,29 @@ public: // Create builder file if required if (generateBuilder) { - createBuilderFile(); - startBuilderCode(outputFilename); + createBuilderFile(outputFilename); } // Create gateway source if required if (createGatewaySource) { - createGatewaySourceFile(moduleName); + createGatewaySourceFile(gatewaySourceName); } // Create gateway XML if required if (createGatewayXML) { - createGatewayXMLFile(moduleName); + createGatewayXMLFile(gatewayName); } // Create loader script if required if (createLoader) { - createLoaderFile(moduleName); + createLoaderFile(gatewayLibraryName); } // Module initialization function - String *moduleInitFunctionName = NewString(""); - Printf(moduleInitFunctionName, "%s_Init", moduleName); + String *gatewayInitFunctionName = NewStringf("%s_Init", gatewayName); /* Add initialization function to builder table */ - addFunctionToScilab(moduleInitFunctionName, moduleInitFunctionName); + addFunctionToScilab(gatewayInitFunctionName, gatewayInitFunctionName); // Add helper functions to builder table addHelperFunctions(); @@ -260,13 +248,12 @@ public: // Add Builder footer code and save if (generateBuilder) { - terminateBuilderCode(); - saveBuilderFile(); + saveBuilderFile(gatewayLibraryName); } /* Close the init function and rename with module name */ Printf(initSection, "return 0;\n}\n"); - Replaceall(initSection, "", moduleName); + Replaceall(initSection, "", gatewayName); /* Write all to the wrapper file */ SwigType_emit_type_table(runtimeSection, wrappersSection); // Declare pointer types, ... (Ex: SWIGTYPE_p_p_double) @@ -278,7 +265,7 @@ public: Wrapper_pretty_print(initSection, beginSection); if (createGatewaySource) { - saveGatewaySourceFile(moduleName); + saveGatewaySourceFile(gatewaySourceName); } if (createGatewayXML) { @@ -286,7 +273,7 @@ public: } if (createLoader) { - saveLoaderFile(moduleName); + saveLoaderFile(gatewaySourceName, gatewayLibraryName); } /* Cleanup files */ @@ -876,7 +863,7 @@ public: * createBuilderCode() * ----------------------------------------------------------------------- */ - void createBuilderFile() { + void createBuilderFile(String *outputFilename) { String *builderFilename = NewStringf("builder.sce"); builderFile = NewFile(builderFilename, "w", SWIG_output_files()); if (!builderFile) { @@ -884,13 +871,7 @@ public: SWIG_exit(EXIT_FAILURE); } emitBanner(builderFile); - } - /* ----------------------------------------------------------------------- - * startBuilderCode() - * ----------------------------------------------------------------------- */ - - void startBuilderCode(String *outputFilename) { builderFunctionCount = 0; builderCode = NewString(""); Printf(builderCode, "mode(-1);\n"); @@ -903,8 +884,6 @@ public: Printf(builderCode, "ilib_verbose(%s);\n", verboseBuildLevel); - Printf(builderCode, "lib_name = \"%s\";\n", libraryName); - Printf(builderCode, "libs = [];\n"); // Flags from command line arguments @@ -960,15 +939,15 @@ public: } /* ----------------------------------------------------------------------- - * terminateBuilderCode() + * saveBuilderFile() * ----------------------------------------------------------------------- */ - void terminateBuilderCode() { + void saveBuilderFile(String *gatewayLibraryName) { Printf(builderCode, "];\n"); Printf(builderCode, "ierr = 0;\n"); Printf(builderCode, "if ~isempty(table) then\n"); - Printf(builderCode, " libfilename = 'lib%s' + getdynlibext();\n", libraryName); - Printf(builderCode, " ierr = execstr(\"ilib_build(''%s'', table, files, libs, [], ldflags, cflags);\", 'errcatch');\n", libraryName); + Printf(builderCode, " libfilename = '%s' + getdynlibext();\n", gatewayLibraryName); + Printf(builderCode, " ierr = execstr(\"ilib_build(''%s'', table, files, libs, [], ldflags, cflags);\", 'errcatch');\n", gatewayLibraryName); Printf(builderCode, " if ierr <> 0 then\n"); Printf(builderCode, " err_msg = lasterror();\n"); Printf(builderCode, " elseif ~isfile(libfilename) then\n"); @@ -983,13 +962,6 @@ public: Printf(builderCode, "if ierr <> 0 then\n"); Printf(builderCode, " error(ierr, err_msg);\n"); Printf(builderCode, "end\n"); - } - - /* ----------------------------------------------------------------------- - * saveBuilderCode() - * ----------------------------------------------------------------------- */ - - void saveBuilderFile() { Printv(builderFile, builderCode, NIL); Delete(builderFile); } @@ -999,17 +971,17 @@ public: * This XML file is used by Scilab in the context of internal modules * ----------------------------------------------------------------------- */ - void createGatewayXMLFile(String *moduleName) { - String *gatewayXMLFilename = NewStringf("%s_gateway.xml", moduleName); + void createGatewayXMLFile(String *gatewayName) { + String *gatewayXMLFilename = NewStringf("%s_gateway.xml", gatewayName); gatewayXMLFile = NewFile(gatewayXMLFilename, "w", SWIG_output_files()); if (!gatewayXMLFile) { FileErrorDisplay(gatewayXMLFilename); SWIG_exit(EXIT_FAILURE); } - + gatewayXML = NewString(""); Printf(gatewayXML, "\n"); - Printf(gatewayXML, "\n", moduleName); + Printf(gatewayXML, "\n", gatewayName); Printf(gatewayXML, "