scilab: support of Scilab 6: gateway signatures

This commit is contained in:
Simon Marchetto 2014-05-22 09:40:32 +02:00
commit a74874f288
3 changed files with 21 additions and 12 deletions

View file

@ -32,6 +32,15 @@ extern "C" {
#undef Max #undef Max
#undef Min #undef Min
/* Gateway signature */
#if SWIG_SCILAB_VERSION_MIN(6, 0, 0)
#define SWIG_GatewayParameters char* fname, void *pvApiCtx
#define SWIG_GatewayArguments fname, pvApiCtx
#else
#define SWIG_GatewayParameters char* fname, unsigned long fname_len
#define SWIG_GatewayArguments fname, fname_len
#endif
/* Function name management functions */ /* Function name management functions */
@ -256,12 +265,12 @@ SWIG_Scilab_Raise(const int obj, const char *type, swig_type_info *descriptor) {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
int swig_this(char *fname, unsigned long fname_len) { 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);
return SWIG_Scilab_SetOutput(pvApiCtx, return SWIG_Scilab_SetOutput(pvApiCtx,
createScalarDouble(pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + 1, createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + 1,
(double) (unsigned long) ptrValue)); (double) (unsigned long) ptrValue));
} }
else { else {
@ -273,7 +282,7 @@ int swig_this(char *fname, unsigned long fname_len) {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
int swig_ptr(char *fname, unsigned long fname_len) { int swig_ptr(SWIG_GatewayParameters) {
double dValue = 0; double dValue = 0;
int *piAddr; int *piAddr;
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);

View file

@ -27,7 +27,7 @@ SWIG_Scilab_SetModule(swig_module_info *swig_module)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
int <module>_Init(char *fname, unsigned long fname_len) { int <module>_Init(SWIG_GatewayParameters) {
SWIG_InitializeModule(NULL); SWIG_InitializeModule(NULL);
SWIG_CreateScilabVariables(); SWIG_CreateScilabVariables();
%} %}

View file

@ -325,7 +325,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, "(char *fname, unsigned long fname_len) {", NIL); Printv(wrapper->def, "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;
@ -512,10 +512,10 @@ public:
int maxargs = 0; int maxargs = 0;
/* Generate the dispatch function */ /* Generate the dispatch function */
String *dispatch = Swig_overload_dispatch(node, "return %s(fname, fname_len);", &maxargs); String *dispatch = Swig_overload_dispatch(node, "return %s(SWIG_GatewayArguments);", &maxargs);
String *tmp = NewString(""); String *tmp = NewString("");
Printv(wrapper->def, "int ", wrapperName, " (char *fname, unsigned long fname_len) {\n", NIL); Printv(wrapper->def, "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)");
@ -555,7 +555,7 @@ public:
String *getFunctionName = Swig_name_get(NSPACE_TODO, variableName); String *getFunctionName = Swig_name_get(NSPACE_TODO, variableName);
Setattr(node, "wrap:name", getFunctionName); Setattr(node, "wrap:name", getFunctionName);
Printv(getFunctionWrapper->def, "int ", getFunctionName, "(char *fname, unsigned long fname_len) {\n", NIL); Printv(getFunctionWrapper->def, "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");
@ -582,7 +582,7 @@ public:
String *setFunctionName = Swig_name_set(NSPACE_TODO, variableName); String *setFunctionName = Swig_name_set(NSPACE_TODO, variableName);
Setattr(node, "wrap:name", setFunctionName); Setattr(node, "wrap:name", setFunctionName);
Printv(setFunctionWrapper->def, "int ", setFunctionName, "(char *fname, unsigned long fname_len) {\n", NIL); Printv(setFunctionWrapper->def, "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");
@ -657,7 +657,7 @@ public:
Wrapper *getFunctionWrapper = NewWrapper(); Wrapper *getFunctionWrapper = NewWrapper();
String *getFunctionName = Swig_name_get(NSPACE_TODO, constantName); String *getFunctionName = Swig_name_get(NSPACE_TODO, constantName);
Setattr(node, "wrap:name", getFunctionName); Setattr(node, "wrap:name", getFunctionName);
Printv(getFunctionWrapper->def, "int ", getFunctionName, "(char *fname, unsigned long fname_len) {\n", NIL); Printv(getFunctionWrapper->def, "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");
@ -835,10 +835,10 @@ public:
Printf(builderCode, " ilib_build('%s', table, files, libs, [], ldflags, cflags);\n", libraryName); Printf(builderCode, " ilib_build('%s', table, files, libs, [], ldflags, cflags);\n", libraryName);
Printf(builderCode, " libfilename = 'lib%s' + getdynlibext();\n", libraryName); Printf(builderCode, " libfilename = 'lib%s' + getdynlibext();\n", libraryName);
Printf(builderCode, " if ~isfile(libfilename) then\n"); Printf(builderCode, " if ~isfile(libfilename) then\n");
Printf(builderCode, " err_msg = 'Error while building library ' + libfilename ' + '.');\n"); Printf(builderCode, " err_msg = 'Error while building library ' + libfilename;\n");
Printf(builderCode, " end\n"); Printf(builderCode, " end\n");
Printf(builderCode, " if ~isfile('loader.sce') then\n"); Printf(builderCode, " if ~isfile('loader.sce') then\n");
Printf(builderCode, " err_msg = 'Error while generating loader script loader.sce.');\n"); Printf(builderCode, " err_msg = 'Error while generating loader script loader.sce.';\n");
Printf(builderCode, " end\n"); Printf(builderCode, " end\n");
Printf(builderCode, "end\n"); Printf(builderCode, "end\n");
Printf(builderCode, "cd(originaldir);\n"); Printf(builderCode, "cd(originaldir);\n");