[scilab] Fix to work on Windows

* Change the builder filename to match the loader filename

* Mark extern functions with SWIGEXPORT

* Fix bug: builder.sce not generated if with  '-scilab -builder'  option

Fixes #1853
This commit is contained in:
YungLee 2022-03-15 10:06:17 +08:00 committed by GitHub
commit 31f7b437f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 13 deletions

View file

@ -434,7 +434,7 @@ SWIG_Scilab_NewMemberObj(void *pvApiCtx, int iVarOut, void *ptr, int sz, swig_ty
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
int SWIG_this(SWIG_GatewayParameters) { SWIGEXPORT int SWIG_this(SWIG_GatewayParameters) {
void *ptrValue = NULL; void *ptrValue = NULL;
if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) { if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) {
SWIG_Scilab_SetOutputPosition(1); SWIG_Scilab_SetOutputPosition(1);
@ -451,7 +451,7 @@ int SWIG_this(SWIG_GatewayParameters) {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
int SWIG_ptr(SWIG_GatewayParameters) { SWIGEXPORT int SWIG_ptr(SWIG_GatewayParameters) {
if (SWIG_NbInputArgument(pvApiCtx) > 0) { if (SWIG_NbInputArgument(pvApiCtx) > 0) {
SciErr sciErr; SciErr sciErr;
int *piAddrVar1 = NULL; int *piAddrVar1 = NULL;

View file

@ -40,7 +40,7 @@ SWIG_Scilab_TypeQuery(const char *name) {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
int SWIG_<module>_Init(SWIG_GatewayParameters) { SWIGEXPORT int SWIG_<module>_Init(SWIG_GatewayParameters) {
SWIG_InitializeModule(NULL); SWIG_InitializeModule(NULL);
SWIG_CreateScilabVariables(pvApiCtx); SWIG_CreateScilabVariables(pvApiCtx);
swig_module_initialized = 1; swig_module_initialized = 1;

View file

@ -252,7 +252,7 @@ public:
// Add Builder footer code and save // Add Builder footer code and save
if (generateBuilder) { if (generateBuilder) {
saveBuilderFile(gatewayName); saveBuilderFile(gatewayLibraryName);
} }
/* Close the init function and rename with module name */ /* Close the init function and rename with module name */
@ -345,7 +345,7 @@ public:
} }
/* Write the wrapper function definition (standard Scilab gateway function prototype) */ /* Write the wrapper function definition (standard Scilab gateway function prototype) */
Printv(wrapper->def, "int ", overloadedName, "(SWIG_GatewayParameters) {", NIL); Printv(wrapper->def, "SWIGEXPORT int ", overloadedName, "(SWIG_GatewayParameters) {", NIL);
/* Emit all of the local variables for holding arguments */ /* Emit all of the local variables for holding arguments */
// E.g.: double arg1; // E.g.: double arg1;
@ -556,7 +556,7 @@ public:
String *dispatch = Swig_overload_dispatch(node, "return %s(SWIG_GatewayArguments);", &maxargs); String *dispatch = Swig_overload_dispatch(node, "return %s(SWIG_GatewayArguments);", &maxargs);
String *tmp = NewString(""); String *tmp = NewString("");
Printv(wrapper->def, "int ", wrapperName, "(SWIG_GatewayParameters) {\n", NIL); Printv(wrapper->def, "SWIGEXPORT int ", wrapperName, "(SWIG_GatewayParameters) {\n", NIL);
/* Get the number of the parameters */ /* Get the number of the parameters */
Wrapper_add_local(wrapper, "argc", "int argc = SWIG_NbInputArgument(pvApiCtx)"); Wrapper_add_local(wrapper, "argc", "int argc = SWIG_NbInputArgument(pvApiCtx)");
@ -600,7 +600,7 @@ public:
String *scilabGetSmallFunctionName = Swig_name_get(NSPACE_TODO, smallVariableName); String *scilabGetSmallFunctionName = Swig_name_get(NSPACE_TODO, smallVariableName);
Setattr(node, "wrap:name", getFunctionName); Setattr(node, "wrap:name", getFunctionName);
Printv(getFunctionWrapper->def, "int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL); Printv(getFunctionWrapper->def, "SWIGEXPORT int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
/* Check the number of input and output */ /* Check the number of input and output */
Printf(getFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 0, 0);\n"); Printf(getFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 0, 0);\n");
@ -630,7 +630,7 @@ public:
String *scilabSetSmallFunctionName = Swig_name_set(NSPACE_TODO, smallVariableName); String *scilabSetSmallFunctionName = Swig_name_set(NSPACE_TODO, smallVariableName);
Setattr(node, "wrap:name", setFunctionName); Setattr(node, "wrap:name", setFunctionName);
Printv(setFunctionWrapper->def, "int ", setFunctionName, "(SWIG_GatewayParameters) {\n", NIL); Printv(setFunctionWrapper->def, "SWIGEXPORT int ", setFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
/* Check the number of input and output */ /* Check the number of input and output */
Printf(setFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 1, 1);\n"); Printf(setFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 1, 1);\n");
@ -714,7 +714,7 @@ public:
String *scilabGetSmallFunctionName = Swig_name_get(NSPACE_TODO, smallConstantName); String *scilabGetSmallFunctionName = Swig_name_get(NSPACE_TODO, smallConstantName);
Setattr(node, "wrap:name", getFunctionName); Setattr(node, "wrap:name", getFunctionName);
Setattr(node, "wrap:name", getFunctionName); Setattr(node, "wrap:name", getFunctionName);
Printv(getFunctionWrapper->def, "int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL); Printv(getFunctionWrapper->def, "SWIGEXPORT int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
/* Check the number of input and output */ /* Check the number of input and output */
Printf(getFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 0, 0);\n"); Printf(getFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 0, 0);\n");
@ -830,6 +830,8 @@ public:
builderFunctionCount = 0; builderFunctionCount = 0;
builderCode = NewString(""); builderCode = NewString("");
builderCode5 = NewString("");
builderCode6 = NewString("");
Printf(builderCode, "mode(-1);\n"); Printf(builderCode, "mode(-1);\n");
Printf(builderCode, "lines(0);\n"); /* Useful for automatic tests */ Printf(builderCode, "lines(0);\n"); /* Useful for automatic tests */
@ -933,8 +935,8 @@ public:
Printf(builderCode, "if ierr <> 0 then\n"); Printf(builderCode, "if ierr <> 0 then\n");
Printf(builderCode, " error(ierr, err_msg);\n"); Printf(builderCode, " error(ierr, err_msg);\n");
Printf(builderCode, "end\n"); Printf(builderCode, "end\n");
Write(builderFile, builderCode, Len(builderCode)); Printv(builderFile, builderCode, NIL);
Delete(builderCode); Delete(builderCode);
Delete(builderFile); Delete(builderFile);
} }
@ -998,7 +1000,7 @@ public:
Printf(gatewayHeaderV6, "#ifdef __cplusplus\n"); Printf(gatewayHeaderV6, "#ifdef __cplusplus\n");
Printf(gatewayHeaderV6, "extern \"C\"\n"); Printf(gatewayHeaderV6, "extern \"C\"\n");
Printf(gatewayHeaderV6, "#endif\n"); Printf(gatewayHeaderV6, "#endif\n");
Printf(gatewayHeaderV6, "int %s(wchar_t *pwstFuncName) {\n", gatewayLibraryName); Printf(gatewayHeaderV6, "SWIGEXPORT int %s(wchar_t *pwstFuncName) {\n", gatewayLibraryName);
Printf(gatewayHeaderV6, "\n"); Printf(gatewayHeaderV6, "\n");
} }
@ -1029,7 +1031,7 @@ public:
Printf(gatewayHeaderV5, "#ifdef __cplusplus\n"); Printf(gatewayHeaderV5, "#ifdef __cplusplus\n");
Printf(gatewayHeaderV5, "extern \"C\" {\n"); Printf(gatewayHeaderV5, "extern \"C\" {\n");
Printf(gatewayHeaderV5, "#endif\n"); Printf(gatewayHeaderV5, "#endif\n");
Printf(gatewayHeaderV5, "int C2F(%s)() {\n", gatewayLibraryName); Printf(gatewayHeaderV5, "SWIGEXPORT int C2F(%s)() {\n", gatewayLibraryName);
Printf(gatewayHeaderV5, " Rhs = Max(0, Rhs);\n"); Printf(gatewayHeaderV5, " Rhs = Max(0, Rhs);\n");
Printf(gatewayHeaderV5, " if (*(Tab[Fin-1].f) != NULL) {\n"); Printf(gatewayHeaderV5, " if (*(Tab[Fin-1].f) != NULL) {\n");
Printf(gatewayHeaderV5, " if(pvApiCtx == NULL) {\n"); Printf(gatewayHeaderV5, " if(pvApiCtx == NULL) {\n");