From 3dd0ebdde9db434e79fbe17607224ea1e4b96c9e Mon Sep 17 00:00:00 2001 From: Simon Marchetto Date: Wed, 17 Jul 2013 16:31:34 +0200 Subject: [PATCH] Scilab: wrap SWIG_Init() function to initialize module SWIG types (needed for STL support) --- Lib/scilab/sciruntime.swg | 35 +++++++++++++++++++++++++++++------ Source/Modules/scilab.cxx | 8 +++++--- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Lib/scilab/sciruntime.swg b/Lib/scilab/sciruntime.swg index 9b9d9b3d2..67b7bb8f9 100644 --- a/Lib/scilab/sciruntime.swg +++ b/Lib/scilab/sciruntime.swg @@ -230,11 +230,34 @@ SwigScilabRaise(const char *type) { %} -//%insert(init) "swiginit.swg" -%init %{ -/* -----------------------------------------------------------------------------* - * Partial Init method - * -----------------------------------------------------------------------------*/ +%insert("init") +%{ + +#define SWIG_GetModule(clientdata) SWIG_Scilab_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Scilab_SetModule(pointer) + +SWIGRUNTIME swig_module_info* +SWIG_Scilab_GetModule(void) +{ + return NULL; +} + +SWIGRUNTIME void +SWIG_Scilab_SetModule(swig_module_info *swig_module) +{ +} -SWIGEXPORT int SWIG_init(void) { +%} + +%insert(init) "swiginit.swg" + +%init %{ +#ifdef __cplusplus +extern "C" { +int SWIG_Init(char *fname, unsigned long fname_len) { + SWIG_InitializeModule(NULL); + return 0; +} +} +#endif %} diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx index 6ece54dd5..7602365f3 100644 --- a/Source/Modules/scilab.cxx +++ b/Source/Modules/scilab.cxx @@ -22,6 +22,8 @@ Scilab Options (available with -scilab)\n\ -addcflag - Additionnal path to includes for builder.sce file (Ex: -I/usr/includes/)\n\ -addldlag - Additionnal library flag for builder.sce file (Ex: -lm)\n\n"; +const char* SWIG_INIT_FUNCTION_NAME = "SWIG_Init"; + class SCILAB : public Language { protected: /* General objects used for holding the strings */ @@ -174,6 +176,9 @@ public: Printf(builderCode, "table = ["); + /* Add initialization function to builder table */ + Printf(builderCode, "\"%s\",\"%s\";", SWIG_INIT_FUNCTION_NAME, SWIG_INIT_FUNCTION_NAME); + /* Emit code for children */ if (CPlusPlus) { Printf(wrappersSection, "extern \"C\" {\n"); @@ -201,9 +206,6 @@ public: Close(builderFile); Delete(builderFile); - /* Close the init function and quit (opened in sciruntime.swg) */ - Printf(initSection, "return 0;\n}\n"); - /* Write all to the wrapper file */ SwigType_emit_type_table(runtimeSection, wrappersSection); // Declare pointer types, ... (Ex: SWIGTYPE_p_p_double) Dump(runtimeSection, beginSection);