dynamic module can write Initialize and finalize function that call by kernel @ first... 88/14788/4
Antoine ELIAS [Wed, 2 Jul 2014 12:24:07 +0000 (14:24 +0200)]
Change-Id: I0e5b530d666f7bcfe6bbd8a5dcd78f5a38265ada

41 files changed:
scilab/modules/console/src/c/console.vcxproj
scilab/modules/dynamic_link/includes/dynamic_link.h
scilab/modules/dynamic_link/sci_gateway/cpp/sci_ulink.cpp
scilab/modules/dynamic_link/src/cpp/dynamic_link.cpp
scilab/modules/functions_manager/includes/dynamic_modules.hxx
scilab/modules/functions_manager/includes/funcmanager.hxx
scilab/modules/functions_manager/src/cpp/funcmanager.cpp
scilab/modules/hdf5/Makefile.am
scilab/modules/hdf5/Makefile.in
scilab/modules/hdf5/includes/gw_hdf5.h
scilab/modules/hdf5/sci_gateway/cpp/hdf5_gw.cpp [moved from scilab/modules/hdf5/sci_gateway/c/gw_hdf5.c with 62% similarity]
scilab/modules/hdf5/src/c/hdf5.vcxproj
scilab/modules/hdf5/src/c/hdf5.vcxproj.filters
scilab/modules/hdf5/src/cpp/H5Object.cpp
scilab/modules/hdf5/src/cpp/H5Object.hxx
scilab/modules/hdf5/src/cpp/H5Type.cpp
scilab/modules/hdf5/src/cpp/H5Type.hxx
scilab/modules/hdf5/src/cpp/H5VariableScope.cpp
scilab/modules/hdf5/src/cpp/H5VariableScope.hxx
scilab/modules/output_stream/src/c/output_stream.vcxproj
scilab/modules/scicos/includes/scicos.h
scilab/modules/scicos/sci_gateway/c/sci_model2blk.c
scilab/modules/scicos/src/c/scicos.c
scilab/modules/system_env/Makefile.am
scilab/modules/system_env/Makefile.in
scilab/modules/system_env/includes/configvariable.hxx
scilab/modules/system_env/includes/dynamic_module.h [new file with mode: 0644]
scilab/modules/system_env/src/cpp/configvariable.cpp
scilab/modules/system_env/src/cpp/dynamic_module.cpp [new file with mode: 0644]
scilab/modules/system_env/system_env.vcxproj
scilab/modules/system_env/system_env.vcxproj.filters
scilab/modules/types/includes/function.hxx
scilab/modules/types/src/cpp/function.cpp
scilab/modules/types/system_env_Import.def
scilab/modules/xml/src/cpp/XMLDocument.cpp
scilab/modules/xml/src/cpp/XMLDocument.hxx
scilab/modules/xml/src/cpp/XMLValidation.cpp
scilab/modules/xml/src/cpp/XMLValidation.hxx
scilab/modules/xml/src/cpp/XMLValidationDTD.cpp
scilab/modules/xml/src/cpp/XMLValidationRelaxNG.cpp
scilab/modules/xml/src/cpp/XMLValidationSchema.cpp

index f08f02d..2835ba1 100644 (file)
@@ -85,7 +85,7 @@
     <ClCompile>
       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../../localization/includes;../../../string/includes;../../../system_env/includes;../../../fileio/includes;../../../history_manager/includes;../../../api_scilab/includes;../../../completion/includes;../../../output_stream/includes;../../../operations/includes;../../../threads/includes;../../../windows_tools/includes;../../../ui_data/includes;../../../windows_tools/src/c/scilab_windows;../../../types/includes;../../../ast/includes;../../../commons/src/jni;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;../../../dynamic_link/includes;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../../localization/includes;../../../string/includes;../../../system_env/includes;../../../fileio/includes;../../../history_manager/includes;../../../api_scilab/includes;../../../completion/includes;../../../output_stream/includes;../../../operations/includes;../../../threads/includes;../../../windows_tools/includes;../../../ui_data/includes;../../../windows_tools/src/c/scilab_windows;../../../types/includes;../../../ast/includes;../../../commons/src/jni;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;CONSOLE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../../localization/includes;../../../string/includes;../../../system_env/includes;../../../fileio/includes;../../../history_manager/includes;../../../api_scilab/includes;../../../completion/includes;../../../output_stream/includes;../../../operations/includes;../../../threads/includes;../../../windows_tools/includes;../../../ui_data/includes;../../../windows_tools/src/c/scilab_windows;../../../types/includes;../../../ast/includes;../../../commons/src/jni;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;../../../dynamic_link/includes;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../../localization/includes;../../../string/includes;../../../system_env/includes;../../../fileio/includes;../../../history_manager/includes;../../../api_scilab/includes;../../../completion/includes;../../../output_stream/includes;../../../operations/includes;../../../threads/includes;../../../windows_tools/includes;../../../ui_data/includes;../../../windows_tools/src/c/scilab_windows;../../../types/includes;../../../ast/includes;../../../commons/src/jni;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;CONSOLE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../../localization/includes;../../../string/includes;../../../system_env/includes;../../../fileio/includes;../../../history_manager/includes;../../../api_scilab/includes;../../../completion/includes;../../../output_stream/includes;../../../operations/includes;../../../threads/includes;../../../windows_tools/includes;../../../ui_data/includes;../../../windows_tools/src/c/scilab_windows;../../../types/includes;../../../ast/includes;../../../commons/src/jni;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;../../../dynamic_link/includes;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../../localization/includes;../../../string/includes;../../../system_env/includes;../../../fileio/includes;../../../history_manager/includes;../../../api_scilab/includes;../../../completion/includes;../../../output_stream/includes;../../../operations/includes;../../../threads/includes;../../../windows_tools/includes;../../../ui_data/includes;../../../windows_tools/src/c/scilab_windows;../../../types/includes;../../../ast/includes;../../../commons/src/jni;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;CONSOLE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../../localization/includes;../../../string/includes;../../../system_env/includes;../../../fileio/includes;../../../history_manager/includes;../../../api_scilab/includes;../../../completion/includes;../../../output_stream/includes;../../../operations/includes;../../../threads/includes;../../../windows_tools/includes;../../../ui_data/includes;../../../windows_tools/src/c/scilab_windows;../../../types/includes;../../../ast/includes;../../../commons/src/jni;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;../../../dynamic_link/includes;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../../localization/includes;../../../string/includes;../../../system_env/includes;../../../fileio/includes;../../../history_manager/includes;../../../api_scilab/includes;../../../completion/includes;../../../output_stream/includes;../../../operations/includes;../../../threads/includes;../../../windows_tools/includes;../../../ui_data/includes;../../../windows_tools/src/c/scilab_windows;../../../types/includes;../../../ast/includes;../../../commons/src/jni;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;CONSOLE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
index 755f812..d52b945 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <wchar.h> /* wchar_t */
 #include "dynlib_dynamic_link.h"
+#include "dynamiclibrary.h"
 #include "BOOL.h"
 
 /**
@@ -32,7 +33,7 @@ DYNAMIC_LINK_IMPEXP int Sci_dlopen(wchar_t* _pwstDynLibPath);
 * return value is == 0 if the FreeDynLibrary failed
 * @param loaded_file
 */
-DYNAMIC_LINK_IMPEXP int Sci_dlclose(unsigned long long _hLib);
+DYNAMIC_LINK_IMPEXP int Sci_dlclose(DynLibHandle _hLib);
 
 /**
 * This routine load the entryname ename
index 9634bb5..46f8c98 100644 (file)
@@ -78,7 +78,7 @@ void unLink(int _iLib)
     ConfigVariable::DynamicLibraryStr* pStr = ConfigVariable::getDynamicLibrary(_iLib);
     if (pStr)
     {
-        unsigned long long iLib = ConfigVariable::getDynamicLibrary(_iLib)->hLib;
+        DynLibHandle iLib = ConfigVariable::getDynamicLibrary(_iLib)->hLib;
         ConfigVariable::removeDynamicLibrary(_iLib);
         Sci_dlclose(iLib);
     }
index a6bb106..3efb762 100644 (file)
@@ -21,7 +21,6 @@ extern "C"
 #include <stdio.h>
 #include <stdlib.h>
 #include "dynamic_link.h"
-#include "dynamiclibrary.h"
 #include "men_Sutils.h"
 #include "sci_malloc.h" /* MALLOC */
 #include "warningmode.h"
@@ -162,9 +161,9 @@ static void Underscores(BOOL _bFortran, wchar_t* _pwstEntryPointName, wchar_t* _
     return;
 }
 /*---------------------------------------------------------------------------*/
-int Sci_dlclose(unsigned long long _hLib)
+int Sci_dlclose(DynLibHandle _hLib)
 {
-    return FreeDynLibrary((DynLibHandle)_hLib);
+    return FreeDynLibrary(_hLib);
 }
 /*---------------------------------------------------------------------------*/
 int Sci_dlopen(wchar_t* _pwstDynLibPath)
@@ -191,7 +190,7 @@ int Sci_dlopen(wchar_t* _pwstDynLibPath)
 
     ConfigVariable::DynamicLibraryStr* pDL = ConfigVariable::getNewDynamicLibraryStr();
     ConfigVariable::setLibraryName(pDL, _pwstDynLibPath);
-    pDL->hLib = (unsigned long long)hLib;
+    pDL->hLib = hLib;
 
 
     return ConfigVariable::addDynamicLibrary(pDL);
index 49524b9..d9b6823 100644 (file)
@@ -32,8 +32,6 @@ struct GatewayStr
 
 typedef std::vector<GatewayStr> vectGateway;
 
-vectGateway loadGatewaysName(std::wstring _wstModuleName);
-
 class GenericModule
 {
 protected :
index f48512b..d729318 100644 (file)
@@ -42,6 +42,7 @@ using namespace std;
 
 //Gateway function pointer
 typedef int (*GW_MOD)(void);
+typedef int (*FINALIZE_MODULE)(void);
 
 class EXTERN_FUNC_MAN FuncManager
 {
index 85ba0cc..db055e2 100644 (file)
@@ -459,6 +459,22 @@ bool FuncManager::UnloadModules(bool _bNoStart)
 
     //protected all variables after scilab start
     symbol::Context::getInstance()->scope_begin();
+
+    //call finalize function on dynamic modules
+    int iCount = ConfigVariable::getDynModuleCount();
+    DynLibHandle* libs = ConfigVariable::getAllDynModule();
+    for (int i = 0 ; i < iCount ; i++)
+    {
+        FINALIZE_MODULE pFinalize = (FINALIZE_MODULE)GetDynLibFuncPtr(libs[i], "Finalize");
+        if (pFinalize)
+        {
+            pFinalize();
+        }
+        FreeDynLibrary(libs[i]);
+    }
+
+    ConfigVariable::cleanDynModule();
+    delete[] libs;
     return bRet;
 }
 
index d63257d..d11ba14 100644 (file)
@@ -45,9 +45,9 @@ HDF5_CXX_SOURCES = src/cpp/H5Attribute.cpp \
                   src/cpp/H5VlenData.cpp \
                   src/cpp/H5Options.cpp
 
-GATEWAY_C_SOURCES = sci_gateway/c/gw_hdf5.c
-
-GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_export_to_hdf5.cpp \
+GATEWAY_CXX_SOURCES = \
+sci_gateway/cpp/hdf5_gw.cpp \
+sci_gateway/cpp/sci_export_to_hdf5.cpp \
 sci_gateway/cpp/sci_import_from_hdf5.cpp \
 sci_gateway/cpp/sci_is_hdf5_file.cpp \
 sci_gateway/cpp/sci_listvar_in_hdf5.cpp \
@@ -125,7 +125,7 @@ noinst_LTLIBRARIES += libscihdf5-algo.la
 libscihdf5_la_LDFLAGS = $(AM_LDFLAGS)
 
 libscihdf5_algo_la_SOURCES = $(HDF5_SOURCES) $(HDF5_CXX_SOURCES)
-libscihdf5_la_SOURCES = $(GATEWAY_CXX_SOURCES) $(GATEWAY_C_SOURCES)
+libscihdf5_la_SOURCES = $(GATEWAY_CXX_SOURCES)  
 libscihdf5_algo_la_CPPFLAGS = $(libscihdf5_la_CPPFLAGS)
 
 # For the code check (splint)
index a781c03..28a79ab 100644 (file)
@@ -204,7 +204,8 @@ am__v_lt_0 = --silent
 am__v_lt_1 = 
 am__DEPENDENCIES_1 =
 libscihdf5_la_DEPENDENCIES = libscihdf5-algo.la $(am__DEPENDENCIES_1)
-am__objects_3 = sci_gateway/cpp/libscihdf5_la-sci_export_to_hdf5.lo \
+am__objects_3 = sci_gateway/cpp/libscihdf5_la-hdf5_gw.lo \
+       sci_gateway/cpp/libscihdf5_la-sci_export_to_hdf5.lo \
        sci_gateway/cpp/libscihdf5_la-sci_import_from_hdf5.lo \
        sci_gateway/cpp/libscihdf5_la-sci_is_hdf5_file.lo \
        sci_gateway/cpp/libscihdf5_la-sci_listvar_in_hdf5.lo \
@@ -232,8 +233,7 @@ am__objects_3 = sci_gateway/cpp/libscihdf5_la-sci_export_to_hdf5.lo \
        sci_gateway/cpp/libscihdf5_la-sci_h5label.lo \
        sci_gateway/cpp/libscihdf5_la-sci_h5exists.lo \
        sci_gateway/cpp/libscihdf5_la-sci_percent_H5Object_fieldnames.lo
-am__objects_4 = sci_gateway/c/libscihdf5_la-gw_hdf5.lo
-am_libscihdf5_la_OBJECTS = $(am__objects_3) $(am__objects_4)
+am_libscihdf5_la_OBJECTS = $(am__objects_3)
 libscihdf5_la_OBJECTS = $(am_libscihdf5_la_OBJECTS)
 libscihdf5_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
        $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -637,8 +637,9 @@ HDF5_CXX_SOURCES = src/cpp/H5Attribute.cpp \
                   src/cpp/H5VlenData.cpp \
                   src/cpp/H5Options.cpp
 
-GATEWAY_C_SOURCES = sci_gateway/c/gw_hdf5.c
-GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_export_to_hdf5.cpp \
+GATEWAY_CXX_SOURCES = \
+sci_gateway/cpp/hdf5_gw.cpp \
+sci_gateway/cpp/sci_export_to_hdf5.cpp \
 sci_gateway/cpp/sci_import_from_hdf5.cpp \
 sci_gateway/cpp/sci_is_hdf5_file.cpp \
 sci_gateway/cpp/sci_listvar_in_hdf5.cpp \
@@ -706,7 +707,7 @@ noinst_LTLIBRARIES = libscihdf5-algo.la
 # When Scilab is built with HDF5, we need some libraries for a workaround
 libscihdf5_la_LDFLAGS = $(AM_LDFLAGS)
 libscihdf5_algo_la_SOURCES = $(HDF5_SOURCES) $(HDF5_CXX_SOURCES)
-libscihdf5_la_SOURCES = $(GATEWAY_CXX_SOURCES) $(GATEWAY_C_SOURCES)
+libscihdf5_la_SOURCES = $(GATEWAY_CXX_SOURCES)  
 libscihdf5_algo_la_CPPFLAGS = $(libscihdf5_la_CPPFLAGS)
 
 # For the code check (splint)
@@ -1016,6 +1017,9 @@ sci_gateway/cpp/$(am__dirstamp):
 sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp):
        @$(MKDIR_P) sci_gateway/cpp/$(DEPDIR)
        @: > sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscihdf5_la-hdf5_gw.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/cpp/libscihdf5_la-sci_export_to_hdf5.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
@@ -1100,22 +1104,12 @@ sci_gateway/cpp/libscihdf5_la-sci_h5exists.lo:  \
 sci_gateway/cpp/libscihdf5_la-sci_percent_H5Object_fieldnames.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
-sci_gateway/c/$(am__dirstamp):
-       @$(MKDIR_P) sci_gateway/c
-       @: > sci_gateway/c/$(am__dirstamp)
-sci_gateway/c/$(DEPDIR)/$(am__dirstamp):
-       @$(MKDIR_P) sci_gateway/c/$(DEPDIR)
-       @: > sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
-sci_gateway/c/libscihdf5_la-gw_hdf5.lo: sci_gateway/c/$(am__dirstamp) \
-       sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
 
 libscihdf5.la: $(libscihdf5_la_OBJECTS) $(libscihdf5_la_DEPENDENCIES) $(EXTRA_libscihdf5_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(libscihdf5_la_LINK) -rpath $(pkglibdir) $(libscihdf5_la_OBJECTS) $(libscihdf5_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
        -rm -f *.$(OBJEXT)
-       -rm -f sci_gateway/c/*.$(OBJEXT)
-       -rm -f sci_gateway/c/*.lo
        -rm -f sci_gateway/cpp/*.$(OBJEXT)
        -rm -f sci_gateway/cpp/*.lo
        -rm -f src/c/*.$(OBJEXT)
@@ -1126,7 +1120,7 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscihdf5_la-gw_hdf5.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-hdf5_gw.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-sci_h5attr.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-sci_h5close.Plo@am__quote@
@@ -1236,13 +1230,6 @@ src/c/libscihdf5_algo_la-h5_readDataFromFile_v1.lo: src/c/h5_readDataFromFile_v1
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscihdf5_algo_la-h5_readDataFromFile_v1.lo `test -f 'src/c/h5_readDataFromFile_v1.c' || echo '$(srcdir)/'`src/c/h5_readDataFromFile_v1.c
 
-sci_gateway/c/libscihdf5_la-gw_hdf5.lo: sci_gateway/c/gw_hdf5.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscihdf5_la-gw_hdf5.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscihdf5_la-gw_hdf5.Tpo -c -o sci_gateway/c/libscihdf5_la-gw_hdf5.lo `test -f 'sci_gateway/c/gw_hdf5.c' || echo '$(srcdir)/'`sci_gateway/c/gw_hdf5.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscihdf5_la-gw_hdf5.Tpo sci_gateway/c/$(DEPDIR)/libscihdf5_la-gw_hdf5.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/gw_hdf5.c' object='sci_gateway/c/libscihdf5_la-gw_hdf5.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscihdf5_la-gw_hdf5.lo `test -f 'sci_gateway/c/gw_hdf5.c' || echo '$(srcdir)/'`sci_gateway/c/gw_hdf5.c
-
 .cpp.o:
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@@ -1435,6 +1422,13 @@ src/cpp/libscihdf5_algo_la-H5Options.lo: src/cpp/H5Options.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscihdf5_algo_la-H5Options.lo `test -f 'src/cpp/H5Options.cpp' || echo '$(srcdir)/'`src/cpp/H5Options.cpp
 
+sci_gateway/cpp/libscihdf5_la-hdf5_gw.lo: sci_gateway/cpp/hdf5_gw.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscihdf5_la-hdf5_gw.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-hdf5_gw.Tpo -c -o sci_gateway/cpp/libscihdf5_la-hdf5_gw.lo `test -f 'sci_gateway/cpp/hdf5_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/hdf5_gw.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-hdf5_gw.Tpo sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-hdf5_gw.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/hdf5_gw.cpp' object='sci_gateway/cpp/libscihdf5_la-hdf5_gw.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscihdf5_la-hdf5_gw.lo `test -f 'sci_gateway/cpp/hdf5_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/hdf5_gw.cpp
+
 sci_gateway/cpp/libscihdf5_la-sci_export_to_hdf5.lo: sci_gateway/cpp/sci_export_to_hdf5.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscihdf5_la-sci_export_to_hdf5.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Tpo -c -o sci_gateway/cpp/libscihdf5_la-sci_export_to_hdf5.lo `test -f 'sci_gateway/cpp/sci_export_to_hdf5.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_export_to_hdf5.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Tpo sci_gateway/cpp/$(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Plo
@@ -1636,7 +1630,6 @@ mostlyclean-libtool:
 
 clean-libtool:
        -rm -rf .libs _libs
-       -rm -rf sci_gateway/c/.libs sci_gateway/c/_libs
        -rm -rf sci_gateway/cpp/.libs sci_gateway/cpp/_libs
        -rm -rf src/c/.libs src/c/_libs
        -rm -rf src/cpp/.libs src/cpp/_libs
@@ -1843,8 +1836,6 @@ clean-generic:
 distclean-generic:
        -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
        -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-       -rm -f sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
-       -rm -f sci_gateway/c/$(am__dirstamp)
        -rm -f sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
        -rm -f sci_gateway/cpp/$(am__dirstamp)
        -rm -f src/c/$(DEPDIR)/$(am__dirstamp)
@@ -1862,7 +1853,7 @@ clean-am: clean-generic clean-libtool clean-local \
        clean-noinstLTLIBRARIES clean-pkglibLTLIBRARIES mostlyclean-am
 
 distclean: distclean-am
-       -rm -rf sci_gateway/c/$(DEPDIR) sci_gateway/cpp/$(DEPDIR) src/c/$(DEPDIR) src/cpp/$(DEPDIR)
+       -rm -rf sci_gateway/cpp/$(DEPDIR) src/c/$(DEPDIR) src/cpp/$(DEPDIR)
        -rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
        distclean-local distclean-tags
@@ -1911,7 +1902,7 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-       -rm -rf sci_gateway/c/$(DEPDIR) sci_gateway/cpp/$(DEPDIR) src/c/$(DEPDIR) src/cpp/$(DEPDIR)
+       -rm -rf sci_gateway/cpp/$(DEPDIR) src/c/$(DEPDIR) src/cpp/$(DEPDIR)
        -rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
index 9f3c035..8810262 100644 (file)
@@ -15,7 +15,8 @@
 /*--------------------------------------------------------------------------*/
 #include "dynlib_hdf5_scilab.h"
 /*--------------------------------------------------------------------------*/
-HDF5_SCILAB_IMPEXP int gw_hdf5(void);
+HDF5_SCILAB_IMPEXP int Initialize(void);
+HDF5_SCILAB_IMPEXP int Finalize(void);
 /*--------------------------------------------------------------------------*/
 HDF5_SCILAB_IMPEXP int sci_export_to_hdf5(char *fname, int* pvApiCtx);
 HDF5_SCILAB_IMPEXP int sci_import_from_hdf5(char *fname, int* pvApiCtx);
  *
  */
 /*--------------------------------------------------------------------------*/
+
+#include "H5Type.hxx"
+#include "H5VariableScope.hxx"
+#include "H5Object.hxx"
+
+extern "C"
+{
 #include "gw_hdf5.h"
 #include "callFunctionFromGateway.h"
 #include "api_scilab.h"
 #include "sci_malloc.h"
+}
 /*--------------------------------------------------------------------------*/
-int gw_hdf5(void)
+int Initialize(void)
 {
+    org_modules_hdf5::H5Type::initMap();
+    org_modules_hdf5::H5VariableScope::initScope();
+    org_modules_hdf5::H5Object::initRoot();
     return 0;
 }
 /*--------------------------------------------------------------------------*/
+int Finalize(void)
+{
+    org_modules_hdf5::H5Type::cleanMap();
+    //org_modules_hdf5::H5VariableScope::clearScope();
+    org_modules_hdf5::H5Object::clearRoot();
+    return 0;
+}
+/*--------------------------------------------------------------------------*/
+
 
index ddc9a7f..7cb44a9 100644 (file)
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="..\..\sci_gateway\cpp\hdf5_gw.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_h5attr.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_h5close.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_h5cp.cpp" />
     <ClCompile Include="..\cpp\import_from_hdf5_v1.cpp" />
     <ClCompile Include="..\cpp\listvar_in_hdf5_v1.cpp" />
     <ClCompile Include="DllmainHdf5.c" />
-    <ClCompile Include="..\..\sci_gateway\c\gw_hdf5.c" />
     <ClCompile Include="h5_fileManagement.c" />
     <ClCompile Include="h5_readDataFromFile.c" />
     <ClCompile Include="h5_readDataFromFile_v1.c" />
index 4beb601..8b0e00e 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <Filter Include="Source Files">
@@ -26,9 +26,6 @@
     <ClCompile Include="DllmainHdf5.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\sci_gateway\c\gw_hdf5.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="h5_fileManagement.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\..\sci_gateway\cpp\sci_h5readattr.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\sci_gateway\cpp\hdf5_gw.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\dynlib_hdf5_scilab.h">
index 3cf1ef6..f56f526 100644 (file)
@@ -21,7 +21,7 @@
 namespace org_modules_hdf5
 {
 
-H5Object & H5Object::root = *new H5Object();
+H5Object* H5Object::root = NULL;
 
 H5Object::H5Object(H5Object & _parent, const std::string & _name) : parent(_parent), children(std::set<H5Object *>()), locked(false), scilabId(-1), name(_name)
 {
@@ -97,7 +97,7 @@ H5File & H5Object::getFile() const
 {
     const H5Object * sobj = this;
     const H5Object * obj = &parent;
-    while (obj != &root)
+    while (obj != root)
     {
         sobj = obj;
         obj = &(obj->parent);
@@ -711,3 +711,4 @@ herr_t H5Object::filterSoftLinkIterator(hid_t g_id, const char * name, const H5L
     return (herr_t)0;
 }
 }
+
index 6e74465..388bb5b 100644 (file)
@@ -49,7 +49,7 @@ class H5File;
 
 class H5Object
 {
-    static H5Object & root;
+    static H5Object* root;
 
     bool locked;
     H5Object & parent;
@@ -67,6 +67,16 @@ public :
     H5Object(H5Object & _parent, const std::string & _name);
     virtual ~H5Object();
 
+    static void clearRoot()
+    {
+        delete root;
+    }
+
+    static void initRoot()
+    {
+        root = new H5Object();
+    }
+
     virtual void cleanup();
 
     virtual hid_t getH5Id() const;
@@ -273,7 +283,7 @@ public :
 
     bool isRoot() const
     {
-        return this == &root;
+        return this == root;
     }
 
     void unregisterChild(H5Object * child)
@@ -291,18 +301,18 @@ public :
 
     static H5Object & getRoot()
     {
-        return root;
+        return *root;
     }
 
     static void cleanAll()
     {
-        root.locked = true;
-        for (std::set<H5Object *>::iterator it = root.children.begin(); it != root.children.end(); it++)
+        root->locked = true;
+        for (std::set<H5Object *>::iterator it = root->children.begin(); it != root->children.end(); it++)
         {
             delete *it;
         }
-        root.children.clear();
-        root.locked = false;
+        root->children.clear();
+        root->locked = false;
         H5VariableScope::clearScope();
     }
 
@@ -427,3 +437,4 @@ private :
 #undef __H5_LS_LENGTH__
 
 #endif // __H5OBJECT_HXX__
+
index 17387b5..8486b23 100644 (file)
@@ -15,7 +15,7 @@
 namespace org_modules_hdf5
 {
 
-std::map<std::string, hid_t> H5Type::nameToType = initMap();
+std::map<std::string, hid_t> H5Type::nameToType;
 
 void H5Type::init()
 {
index cfd5d99..7db1a27 100644 (file)
@@ -138,14 +138,8 @@ public:
         return (hid_t) - 1;
     }
 
-private:
-
-    void init();
-
-    static std::map<std::string, hid_t> initMap()
+    static void initMap()
     {
-        std::map<std::string, hid_t> nameToType;
-
         nameToType.insert(std::pair<std::string, hid_t>("H5T_STD_I8BE", H5T_STD_I8BE));
         nameToType.insert(std::pair<std::string, hid_t>("H5T_STD_I8LE", H5T_STD_I8LE));
         nameToType.insert(std::pair<std::string, hid_t>("H5T_STD_I16BE", H5T_STD_I16BE));
@@ -268,20 +262,27 @@ private:
         nameToType.insert(std::pair<std::string, hid_t>("H5T_MIPS_B64", H5T_MIPS_B64));
         nameToType.insert(std::pair<std::string, hid_t>("H5T_STD_REF_OBJ", H5T_STD_REF_OBJ));
         /*
-                        nameToType.insert(std::pair<std::string, hid_t>("H5T_UNIX_D32BE", H5T_UNIX_D32BE));
-                        nameToType.insert(std::pair<std::string, hid_t>("H5T_UNIX_D32LE", H5T_UNIX_D32LE));
-                        nameToType.insert(std::pair<std::string, hid_t>("H5T_UNIX_D64BE", H5T_UNIX_D64BE));
-                        nameToType.insert(std::pair<std::string, hid_t>("H5T_UNIX_D64LE", H5T_UNIX_D64LE));
-                       nameToType.insert(std::pair<std::string, hid_t>("H5T_STRING", H5T_STRING));
-                       nameToType.insert(std::pair<std::string, hid_t>("H5T_OPAQUE", H5T_OPAQUE));
-                       nameToType.insert(std::pair<std::string, hid_t>("H5T_COMPOUND", H5T_COMPOUND));
-                       nameToType.insert(std::pair<std::string, hid_t>("H5T_ENUM", H5T_ENUM));
-                       nameToType.insert(std::pair<std::string, hid_t>("H5T_VLEN", H5T_VLEN));
-                       nameToType.insert(std::pair<std::string, hid_t>("H5T_ARRAY", H5T_ARRAY));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_UNIX_D32BE", H5T_UNIX_D32BE));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_UNIX_D32LE", H5T_UNIX_D32LE));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_UNIX_D64BE", H5T_UNIX_D64BE));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_UNIX_D64LE", H5T_UNIX_D64LE));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_STRING", H5T_STRING));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_OPAQUE", H5T_OPAQUE));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_COMPOUND", H5T_COMPOUND));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_ENUM", H5T_ENUM));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_VLEN", H5T_VLEN));
+        nameToType.insert(std::pair<std::string, hid_t>("H5T_ARRAY", H5T_ARRAY));
         */
+    }
 
-        return nameToType;
+    static void cleanMap()
+    {
+        nameToType.clear();
     }
+
+
+private:
+    void init();
 };
 }
 
index 9d8ac78..b84dabf 100644 (file)
 
 namespace org_modules_hdf5
 {
-std::vector<H5Object *> & H5VariableScope::scope = *initScope();
-std::stack<int> & H5VariableScope::freePlaces = *new std::stack<int>();
+std::vector<H5Object *> H5VariableScope::scope;
+std::stack<int> H5VariableScope::freePlaces;
+
+void H5VariableScope::initScope()
+{
+    scope.reserve(1024);
+}
 
 void H5VariableScope::clearScope()
 {
@@ -24,12 +29,6 @@ void H5VariableScope::clearScope()
     {
         delete scope[i];
     }
-
-    delete &scope;
-    scope = *initScope();
-
-    delete &freePlaces;
-    freePlaces = *new std::stack<int>();
 }
 
 int H5VariableScope::getVariableId(H5Object & obj)
@@ -82,3 +81,4 @@ void H5VariableScope::removeId(const int id)
 }
 }
 
+
index 7e7ee36..511d480 100644 (file)
@@ -24,8 +24,8 @@ class H5Object;
 class H5VariableScope
 {
 
-    static std::vector<H5Object *> & scope;
-    static std::stack<int> & freePlaces;
+    static std::vector<H5Object *> scope;
+    static std::stack<int> freePlaces;
 
 public:
 
@@ -34,17 +34,9 @@ public:
     static void removeId(const int id);
     static void removeIdAndDelete(const int id);
     static void clearScope();
-
-private :
-
-    static std::vector<H5Object *> * initScope()
-    {
-        std::vector<H5Object *> * _scope = new std::vector<H5Object *>();
-        _scope->reserve(1024);
-
-        return _scope;
-    }
+    static void initScope();
 };
 }
 
 #endif // __H5VARIABLESCOPE_HXX__
+
index 5198e72..d8ee10e 100644 (file)
@@ -80,7 +80,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../core/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes;../../../system_env/includes;../../../operations/includes;../../../types/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../core/includes;;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes;../../../system_env/includes;../../../operations/includes;../../../types/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -119,7 +119,7 @@ lib /DEF:"$(ProjectDir)core_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../core/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes;../../../system_env/includes;../../../operations/includes;../../../types/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../core/includes;;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes;../../../system_env/includes;../../../operations/includes;../../../types/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -156,7 +156,7 @@ lib /DEF:"$(ProjectDir)core_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClCompile>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../core/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes;../../../system_env/includes;../../../operations/includes;../../../types/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../core/includes;;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes;../../../system_env/includes;../../../operations/includes;../../../types/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -200,7 +200,7 @@ lib /DEF:"$(ProjectDir)core_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClCompile>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../core/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes;../../../system_env/includes;../../../operations/includes;../../../types/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../core/includes;;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes;../../../system_env/includes;../../../operations/includes;../../../types/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes;../../../ast/includes/exps;../../../../libs/Eigen/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
index 18fb28b..00b41f3 100644 (file)
@@ -22,7 +22,6 @@
 #define __SCICOS_H
 
 #include "machine.h"
-#include "scicos_block4.h"
 #include "import.h"
 
 /* maximum value for sum of number of inputs and outputs ports of a given
index 25fac6d..23e77d0 100644 (file)
@@ -31,7 +31,6 @@
 #include "sciblk4.h"
 #include "sciblk2.h"
 #include "MlistGetFieldNumber.h"
-#include "dynamic_link.h"
 #include "createblklist.h"
 #include "scicos.h"
 /*--------------------------------------------------------------------------*/
index 1b7e26b..e1aece0 100644 (file)
@@ -57,7 +57,6 @@
 #include "ida_impl.h"
 
 #include "machine.h" /* C2F */
-#include "dynamic_link.h"
 #include "scicos-def.h"
 #include "stack-def.h"
 #include "sciprint.h"
@@ -3624,9 +3623,9 @@ void callf(double *t, scicos_block *block, scicos_flag *flag)
     //sciprint("callf type=%d flag=%d\n",block->type,flagi);
     switch (block->type)
     {
-        /*******************/
-        /* function type 0 */
-        /*******************/
+            /*******************/
+            /* function type 0 */
+            /*******************/
         case 0 :
         {
             /* This is for compatibility */
index d589a41..147a67a 100644 (file)
@@ -24,7 +24,8 @@ SYSTEM_ENV_CPP_SOURCES = \
        src/cpp/formatmode.cpp \
        src/cpp/sci_ieee.cpp \
        src/cpp/sci_simpMode.cpp \
-       src/cpp/reference_modules.cpp
+       src/cpp/reference_modules.cpp \
+       src/cpp/dynamic_module.cpp
 
 pkglib_LTLIBRARIES = libscisystem_env.la
 
index fba57e3..4a17d88 100644 (file)
@@ -153,7 +153,8 @@ am__objects_1 = src/cpp/libscisystem_env_la-setenvvar.lo \
        src/cpp/libscisystem_env_la-formatmode.lo \
        src/cpp/libscisystem_env_la-sci_ieee.lo \
        src/cpp/libscisystem_env_la-sci_simpMode.lo \
-       src/cpp/libscisystem_env_la-reference_modules.lo
+       src/cpp/libscisystem_env_la-reference_modules.lo \
+       src/cpp/libscisystem_env_la-dynamic_module.lo
 am_libscisystem_env_la_OBJECTS = $(am__objects_1)
 libscisystem_env_la_OBJECTS = $(am_libscisystem_env_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -519,7 +520,8 @@ SYSTEM_ENV_CPP_SOURCES = \
        src/cpp/formatmode.cpp \
        src/cpp/sci_ieee.cpp \
        src/cpp/sci_simpMode.cpp \
-       src/cpp/reference_modules.cpp
+       src/cpp/reference_modules.cpp \
+       src/cpp/dynamic_module.cpp
 
 pkglib_LTLIBRARIES = libscisystem_env.la
 libscisystem_env_la_SOURCES = $(SYSTEM_ENV_CPP_SOURCES)
@@ -668,6 +670,8 @@ src/cpp/libscisystem_env_la-sci_simpMode.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscisystem_env_la-reference_modules.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscisystem_env_la-dynamic_module.lo:  \
+       src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscisystem_env.la: $(libscisystem_env_la_OBJECTS) $(libscisystem_env_la_DEPENDENCIES) $(EXTRA_libscisystem_env_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libscisystem_env_la_OBJECTS) $(libscisystem_env_la_LIBADD) $(LIBS)
@@ -681,6 +685,7 @@ distclean-compile:
        -rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisystem_env_la-configvariable.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisystem_env_la-dynamic_module.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisystem_env_la-formatmode.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisystem_env_la-home.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscisystem_env_la-lasterror.Plo@am__quote@
@@ -817,6 +822,13 @@ src/cpp/libscisystem_env_la-reference_modules.lo: src/cpp/reference_modules.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisystem_env_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscisystem_env_la-reference_modules.lo `test -f 'src/cpp/reference_modules.cpp' || echo '$(srcdir)/'`src/cpp/reference_modules.cpp
 
+src/cpp/libscisystem_env_la-dynamic_module.lo: src/cpp/dynamic_module.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisystem_env_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscisystem_env_la-dynamic_module.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscisystem_env_la-dynamic_module.Tpo -c -o src/cpp/libscisystem_env_la-dynamic_module.lo `test -f 'src/cpp/dynamic_module.cpp' || echo '$(srcdir)/'`src/cpp/dynamic_module.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscisystem_env_la-dynamic_module.Tpo src/cpp/$(DEPDIR)/libscisystem_env_la-dynamic_module.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/dynamic_module.cpp' object='src/cpp/libscisystem_env_la-dynamic_module.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisystem_env_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscisystem_env_la-dynamic_module.lo `test -f 'src/cpp/dynamic_module.cpp' || echo '$(srcdir)/'`src/cpp/dynamic_module.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index 3731295..bf42608 100644 (file)
@@ -29,6 +29,7 @@ extern "C"
 {
 #include "dynlib_system_env.h"
 #include "Thread_Wrapper.h"
+#include "dynamiclibrary.h"
 }
 
 class EXTERN_SYSTEM_ENV ConfigVariable
@@ -249,7 +250,7 @@ public :
     typedef struct
     {
         wchar_t* pwstLibraryName;   /** name of dynamic library **/
-        unsigned long long hLib;        /** handle of the library **/
+        DynLibHandle hLib;        /** handle of the library **/
     } DynamicLibraryStr;
 
     typedef struct
@@ -287,6 +288,17 @@ public :
     static EntryPointStr* getEntryPoint(wchar_t* _pwstEntryPointName, int _iDynamicLibraryIndex = -1);
     static std::vector<std::wstring> getEntryPointNameList();
 
+    //dynamic modules
+private :
+    static std::map<std::wstring, DynLibHandle> m_DynModules;
+public :
+    static void addDynModule(std::wstring _name, DynLibHandle _lib);
+    static void removeDynModule(std::wstring _name);
+    static DynLibHandle getDynModule(std::wstring _name);
+    static int getDynModuleCount();
+    static DynLibHandle* getAllDynModule();
+    static void cleanDynModule();
+
     // Command Line Arguments
 private :
     static std::vector<std::wstring> m_Args;
diff --git a/scilab/modules/system_env/includes/dynamic_module.h b/scilab/modules/system_env/includes/dynamic_module.h
new file mode 100644 (file)
index 0000000..abb9db6
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) - 2014 - Scilab Enteprises - Antoine ELIAS
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+#ifndef __DYNAMIC_MODULE_H__
+#define __DYNAMIC_MODULE_H__
+
+#include "dynlib_system_env.h"
+#include "dynamiclibrary.h"
+
+EXTERN_SYSTEM_ENV void addDynModule(const wchar_t* _pwstName, DynLibHandle _lib);
+EXTERN_SYSTEM_ENV void removeDynModule(const wchar_t* _pwstName);
+EXTERN_SYSTEM_ENV DynLibHandle getDynModule(const wchar_t* _pwstName);
+EXTERN_SYSTEM_ENV int getDynModuleCount();
+EXTERN_SYSTEM_ENV DynLibHandle* getAllDynModule();
+EXTERN_SYSTEM_ENV void cleanDynModule();
+
+#endif /* !__DYNAMIC_MODULE_H__ */
\ No newline at end of file
index 92b0e63..684a06b 100644 (file)
@@ -757,6 +757,53 @@ std::list<ConfigVariable::EntryPointStr*>* ConfigVariable::getEntryPointList()
     return &m_EntryPointList;
 }
 
+//dynamic modules
+std::map<std::wstring, DynLibHandle> ConfigVariable::m_DynModules;
+
+void ConfigVariable::addDynModule(std::wstring _name, DynLibHandle _lib)
+{
+    m_DynModules[_name] = _lib;
+}
+
+void ConfigVariable::removeDynModule(std::wstring _name)
+{
+    m_DynModules.erase(_name);
+}
+
+DynLibHandle ConfigVariable::getDynModule(std::wstring _name)
+{
+    std::map<std::wstring, DynLibHandle>::iterator it;
+    it = m_DynModules.find(_name);
+    if (it != m_DynModules.end())
+    {
+        return it->second;
+    }
+
+    return (DynLibHandle) - 1;
+}
+
+int ConfigVariable::getDynModuleCount()
+{
+    return (int)m_DynModules.size();
+}
+
+DynLibHandle* ConfigVariable::getAllDynModule()
+{
+    DynLibHandle* moduleList = new DynLibHandle[m_DynModules.size()];
+    std::map<std::wstring, DynLibHandle>::iterator it = m_DynModules.begin();
+    std::map<std::wstring, DynLibHandle>::iterator itEnd = m_DynModules.end();
+    for (int i = 0; it != itEnd ; ++it, ++i)
+    {
+        moduleList[i] = it->second;
+    }
+
+    return moduleList;
+}
+
+void ConfigVariable::cleanDynModule()
+{
+    m_DynModules.clear();
+}
 
 // Command Line Arguments
 std::vector<std::wstring> ConfigVariable::m_Args;
diff --git a/scilab/modules/system_env/src/cpp/dynamic_module.cpp b/scilab/modules/system_env/src/cpp/dynamic_module.cpp
new file mode 100644 (file)
index 0000000..93e9764
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) - 2014 - Scilab Enteprises - Antoine ELIAS
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+#include "configvariable.hxx"
+extern "C"
+{
+#include "dynamic_module.h"
+}
+
+void addDynModule(const wchar_t* _pwstName, DynLibHandle _lib)
+{
+    ConfigVariable::addDynModule(_pwstName, _lib);
+}
+
+void removeDynModule(const wchar_t* _pwstName)
+{
+    ConfigVariable::removeDynModule(_pwstName);
+}
+
+DynLibHandle getDynModule(const wchar_t* _pwstName)
+{
+    return ConfigVariable::getDynModule(_pwstName);
+}
+
+int getDynModuleCount()
+{
+    return ConfigVariable::getDynModuleCount();
+}
+
+DynLibHandle* getAllDynModule()
+{
+    return ConfigVariable::getAllDynModule();
+}
+
+void cleanDynModule()
+{
+    ConfigVariable::cleanDynModule();
+}
index 604a986..834c5c4 100644 (file)
   <ItemGroup>
     <ClCompile Include="src\cpp\configvariable.cpp" />
     <ClCompile Include="src\cpp\context_get.cpp" />
+    <ClCompile Include="src\cpp\dynamic_module.cpp" />
     <ClCompile Include="src\cpp\formatmode.cpp" />
     <ClCompile Include="src\cpp\home.cpp" />
     <ClCompile Include="src\cpp\lasterror.cpp" />
   <ItemGroup>
     <ClInclude Include="includes\configvariable.hxx" />
     <ClInclude Include="includes\context_get.h" />
+    <ClInclude Include="includes\dynamic_module.h" />
     <ClInclude Include="includes\dynlib_system_env.h" />
     <ClInclude Include="includes\formatmode.h" />
     <ClInclude Include="includes\home.h" />
index d321644..e8a0dea 100644 (file)
@@ -60,6 +60,9 @@
     <ClCompile Include="src\cpp\reference_modules.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\dynamic_module.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\configvariable.hxx">
     <ClInclude Include="includes\reference_modules.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="includes\dynamic_module.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Library Include="..\..\bin\blasplus.lib" />
index e7c4f91..0933478 100644 (file)
@@ -46,6 +46,7 @@ public :
     };
 
     typedef void (*LOAD_DEPS)(void);
+    typedef int (*INIT_MODULE)(void);
     typedef ReturnValue (*GW_FUNC)(typed_list &in, int _iRetCount, typed_list &out);
     typedef ReturnValue (*GW_FUNC_OPT)(typed_list &in, optional_list &opt, int _iRetCount, typed_list &out);
 
@@ -189,14 +190,12 @@ private :
     std::wstring            m_wstEntryPoint;
     std::wstring            m_wstLoadDepsName;
     bool                    m_bCloseLibAfterCall;
-    bool                    m_bLoaded;
     FunctionType            m_iType;
     GW_FUNC                 m_pFunc;
     GW_FUNC_OPT             m_pOptFunc;
     OLDGW_FUNC              m_pOldFunc;
     MEXGW_FUNC              m_pMexFunc;
     Function*               m_pFunction;
-    DynLibHandle            m_hLib;
 };
 
 }
index e263159..05e7d3a 100644 (file)
@@ -29,6 +29,7 @@ extern "C"
 #include "os_swprintf.h"
 #include "lasterror.h"
 #include "reference_modules.h"
+#include "dynamic_module.h"
 }
 
 namespace types
@@ -365,14 +366,12 @@ DynamicFunction::DynamicFunction(std::wstring _wstName, std::wstring _wstEntryPo
     m_wstLoadDepsName       = _wstLoadDepsName;
     m_pLoadDeps             = NULL;
     m_bCloseLibAfterCall    = _bCloseLibAfterCall;
-    m_bLoaded               = false;
     m_iType                 = _iType;
     m_pFunc                 = NULL;
     m_pOptFunc              = NULL;
     m_pOldFunc              = NULL;
     m_pMexFunc              = NULL;
     m_pFunction             = NULL;
-    m_hLib                  = NULL;
 }
 
 DynamicFunction::DynamicFunction(std::wstring _wstName, std::wstring _wstEntryPointName, std::wstring _wstLibName, FunctionType _iType, LOAD_DEPS _pLoadDeps, std::wstring _wstModule, bool _bCloseLibAfterCall)
@@ -384,30 +383,26 @@ DynamicFunction::DynamicFunction(std::wstring _wstName, std::wstring _wstEntryPo
     m_pLoadDeps             = _pLoadDeps;
     m_wstLoadDepsName       = L"";
     m_bCloseLibAfterCall    = _bCloseLibAfterCall;
-    m_bLoaded               = false;
     m_iType                 = _iType;
     m_pFunc                 = NULL;
     m_pOptFunc              = NULL;
     m_pOldFunc              = NULL;
     m_pMexFunc              = NULL;
     m_pFunction             = NULL;
-    m_hLib                  = NULL;
 }
 
 Function::ReturnValue DynamicFunction::call(typed_list &in, optional_list &opt, int _iRetCount, typed_list &out, ast::ConstVisitor* execFunc)
 {
     ReturnValue ret = OK;
-    if (m_bLoaded == false)
+    if (m_pFunction == NULL)
     {
         if (Init() != OK)
         {
             return Error;
         }
-        /*Create function object*/
-        m_bLoaded = true;
     }
-    /*call function*/
 
+    /*call function*/
     if (m_pFunction->call(in, opt, _iRetCount, out, execFunc) != OK)
     {
         return Error;
@@ -417,7 +412,6 @@ Function::ReturnValue DynamicFunction::call(typed_list &in, optional_list &opt,
     if (m_bCloseLibAfterCall)
     {
         Clear();
-        m_bLoaded = false;
     }
 
     return OK;
@@ -433,57 +427,71 @@ Callable::ReturnValue DynamicFunction::Init()
         return Error;
     }
 
-    char* pstLibName = wide_string_to_UTF8(m_wstLibName.c_str());
-    m_hLib = LoadDynLibrary(pstLibName);
-    FREE(pstLibName);
-    if (m_hLib == NULL)
+    DynLibHandle hLib = getDynModule(m_wstLibName.c_str());
+    if (hLib == (DynLibHandle) - 1)
     {
-        //2nd chance for linux !
-#ifndef _MSC_VER
-        char* pstError = GetLastDynLibError();
-
-        /* Haven't been able to find the lib with dlopen...
-         * This can happen for two reasons:
-         * - the lib must be dynamically linked
-         * - Some silly issues under Suse (see bug #2875)
-         * Note that we are handling only the "source tree build"
-         * because libraries are split (they are in the same directory
-         * in the binary)
-         */
-        wchar_t* pwstScilabPath = getSCIW();
-        wchar_t pwstModulesPath[] = L"/modules/";
-        wchar_t pwstLTDir[] =  L".libs/";
-
-        /* Build the full path to the library */
-        int iPathToLibLen = (wcslen(pwstScilabPath) + wcslen(pwstModulesPath) + wcslen(m_wstModule.c_str()) + wcslen(L"/") + wcslen(pwstLTDir) + wcslen(m_wstLibName.c_str()) + 1);
-        wchar_t* pwstPathToLib = (wchar_t*)MALLOC(iPathToLibLen * sizeof(wchar_t));
-        os_swprintf(pwstPathToLib, iPathToLibLen, L"%ls%ls%ls/%ls%ls", pwstScilabPath, pwstModulesPath, m_wstModule.c_str(), pwstLTDir, m_wstLibName.c_str());
-        char* pstPathToLib = wide_string_to_UTF8(pwstPathToLib);
-        m_hLib = LoadDynLibrary(pstPathToLib);
-
-        FREE(pwstPathToLib);
-
-        if (m_hLib == NULL)
+        char* pstLibName = wide_string_to_UTF8(m_wstLibName.c_str());
+        hLib = LoadDynLibrary(pstLibName);
+        FREE(pstLibName);
+
+        if (hLib == (DynLibHandle) - 1)
         {
-            if (pstError != NULL)
+            //2nd chance for linux !
+#ifndef _MSC_VER
+            char* pstError = GetLastDynLibError();
+
+            /* Haven't been able to find the lib with dlopen...
+            * This can happen for two reasons:
+            * - the lib must be dynamically linked
+            * - Some silly issues under Suse (see bug #2875)
+            * Note that we are handling only the "source tree build"
+            * because libraries are split (they are in the same directory
+            * in the binary)
+            */
+            wchar_t* pwstScilabPath = getSCIW();
+            wchar_t pwstModulesPath[] = L"/modules/";
+            wchar_t pwstLTDir[] =  L".libs/";
+
+            /* Build the full path to the library */
+            int iPathToLibLen = (wcslen(pwstScilabPath) + wcslen(pwstModulesPath) + wcslen(m_wstModule.c_str()) + wcslen(L"/") + wcslen(pwstLTDir) + wcslen(m_wstLibName.c_str()) + 1);
+            wchar_t* pwstPathToLib = (wchar_t*)MALLOC(iPathToLibLen * sizeof(wchar_t));
+            os_swprintf(pwstPathToLib, iPathToLibLen, L"%ls%ls%ls/%ls%ls", pwstScilabPath, pwstModulesPath, m_wstModule.c_str(), pwstLTDir, m_wstLibName.c_str());
+            char* pstPathToLib = wide_string_to_UTF8(pwstPathToLib);
+            hLib = LoadDynLibrary(pstPathToLib);
+
+            FREE(pwstPathToLib);
+
+            if (hLib == (DynLibHandle) - 1)
             {
-                Scierror(999, _("A error has been detected while loading %s: %s\n"), pstLibName, pstError);
+                if (pstError != NULL)
+                {
+                    Scierror(999, _("A error has been detected while loading %s: %s\n"), pstLibName, pstError);
+                }
+                return Error;
             }
-            return Error;
-        }
 #else
-        char* pstError = wide_string_to_UTF8(m_wstLibName.c_str());
-        Scierror(999, _("Impossible to load %s library\n"), pstError);
-        FREE(pstError);
-        return Error;
+            char* pstError = wide_string_to_UTF8(m_wstLibName.c_str());
+            Scierror(999, _("Impossible to load %s library\n"), pstError);
+            FREE(pstError);
+            return Error;
 #endif
-    }
+        }
+        addDynModule(m_wstLibName.c_str(), hLib);
+
+        //call init module function
+        INIT_MODULE pInit = (INIT_MODULE)GetDynLibFuncPtr(hLib, "Initialize");
+        if (pInit)
+        {
+            pInit();
+        }
+
+        /*Load deps*/
+        if (m_wstLoadDepsName.empty() == false && m_pLoadDeps == NULL)
+        {
+            char* pstLoadDepsName = wide_string_to_UTF8(m_wstLoadDepsName.c_str());
+            m_pLoadDeps = (LOAD_DEPS)GetDynLibFuncPtr(hLib, pstLoadDepsName);
+        }
 
-    /*Load deps*/
-    if (m_wstLoadDepsName.empty() == false && m_pLoadDeps == NULL)
-    {
-        char* pstLoadDepsName = wide_string_to_UTF8(m_wstLoadDepsName.c_str());
-        m_pLoadDeps = (LOAD_DEPS)GetDynLibFuncPtr(m_hLib, pstLoadDepsName);
     }
 
     /*Load gateway*/
@@ -493,16 +501,16 @@ Callable::ReturnValue DynamicFunction::Init()
         switch (m_iType)
         {
             case EntryPointCPPOpt :
-                m_pOptFunc = (GW_FUNC_OPT)GetDynLibFuncPtr(m_hLib, pstEntryPoint);
+                m_pOptFunc = (GW_FUNC_OPT)GetDynLibFuncPtr(hLib, pstEntryPoint);
                 break;
             case EntryPointCPP :
-                m_pFunc = (GW_FUNC)GetDynLibFuncPtr(m_hLib, pstEntryPoint);
+                m_pFunc = (GW_FUNC)GetDynLibFuncPtr(hLib, pstEntryPoint);
                 break;
             case EntryPointC :
-                m_pOldFunc = (OLDGW_FUNC)GetDynLibFuncPtr(m_hLib, pstEntryPoint);
+                m_pOldFunc = (OLDGW_FUNC)GetDynLibFuncPtr(hLib, pstEntryPoint);
                 break;
             case EntryPointMex :
-                m_pMexFunc = (MEXGW_FUNC)GetDynLibFuncPtr(m_hLib, pstEntryPoint);
+                m_pMexFunc = (MEXGW_FUNC)GetDynLibFuncPtr(hLib, pstEntryPoint);
                 break;
         }
 
@@ -544,12 +552,6 @@ Callable::ReturnValue DynamicFunction::Init()
 
 void DynamicFunction::Clear()
 {
-    if (m_hLib)
-    {
-        FreeDynLibrary(m_hLib);
-        m_hLib = NULL;
-    }
-
     m_pFunc     = NULL;
     m_pOldFunc  = NULL;
     m_pMexFunc  = NULL;
index c819ff8..fccacba 100644 (file)
@@ -11,3 +11,6 @@ SetError
 isError
 resetError
 checkReferenceModule
+addDynModule
+removeDynModule
+getDynModule
index 42271a6..2775ca6 100644 (file)
@@ -32,9 +32,9 @@ extern "C"
 namespace org_modules_xml
 {
 
-    std::string * XMLDocument::errorBuffer = 0;
-    std::string * XMLDocument::errorXPathBuffer = 0;
-    std::list < XMLDocument * >&XMLDocument::openDocs = *new std::list < XMLDocument * >();
+    std::string XMLDocument::errorBuffer;
+    std::string XMLDocument::errorXPathBuffer;
+    std::list < XMLDocument *> XMLDocument::openDocs;
 
     XMLDocument::XMLDocument(const char *path, bool validate, std::string * error, const char * encoding, const bool html): XMLObject()
     {
@@ -126,16 +126,6 @@ namespace org_modules_xml
             }
             xmlFreeDoc(document);
         }
-        if (errorBuffer)
-        {
-            delete errorBuffer;
-            errorBuffer = 0;
-        }
-        if (errorXPathBuffer)
-        {
-            delete errorXPathBuffer;
-            errorXPathBuffer = 0;
-        }
     }
 
     void *XMLDocument::getRealXMLPointer() const
@@ -145,18 +135,14 @@ namespace org_modules_xml
 
     const XMLXPath *XMLDocument::makeXPathQuery(const char *query, char **namespaces, int length, const XMLElement * e, std::string * error)
     {
-        if (errorXPathBuffer)
-        {
-            delete errorXPathBuffer;
-        }
-        errorXPathBuffer = new std::string();
+        errorXPathBuffer.clear();
 
         xmlXPathContext *ctxt = xmlXPathNewContext(document);
 
         if (!ctxt)
         {
-            errorXPathBuffer->append(gettext("Cannot create a parser context"));
-            *error = *errorXPathBuffer;
+            errorXPathBuffer.append(gettext("Cannot create a parser context"));
+            *error = errorXPathBuffer;
             return 0;
         }
 
@@ -180,7 +166,7 @@ namespace org_modules_xml
         {
             xmlSetStructuredErrorFunc(ctxt, 0);
             xmlXPathFreeContext(ctxt);
-            *error = *errorXPathBuffer;
+            *error = errorXPathBuffer;
             return 0;
         }
 
@@ -191,7 +177,7 @@ namespace org_modules_xml
         xmlXPathFreeCompExpr(expr);
         if (!xpath)
         {
-            *error = *errorXPathBuffer;
+            *error = errorXPathBuffer;
             return 0;
         }
 
@@ -356,7 +342,7 @@ namespace org_modules_xml
         doc = xmlCtxtReadFile(ctxt, filename, encoding, options);
         if (!doc || !ctxt->valid)
         {
-            *error = *errorBuffer;
+            *error = errorBuffer;
         }
 
         xmlSetGenericErrorFunc(0, errorFunctionWithoutOutput);
@@ -380,7 +366,7 @@ namespace org_modules_xml
         doc = htmlCtxtReadFile(ctxt, filename, encoding, options);
         if (!doc || !ctxt->valid)
         {
-            *error = *errorBuffer;
+            *error = errorBuffer;
         }
 
         xmlSetGenericErrorFunc(0, errorFunctionWithoutOutput);
@@ -409,7 +395,7 @@ namespace org_modules_xml
         doc = xmlCtxtReadDoc(ctxt, (const xmlChar *)xmlCode.c_str(), 0, encoding, options);
         if (!doc || !ctxt->valid)
         {
-            *error = *errorBuffer;
+            *error = errorBuffer;
         }
 
         xmlSetGenericErrorFunc(0, errorFunctionWithoutOutput);
@@ -433,7 +419,7 @@ namespace org_modules_xml
         doc = htmlCtxtReadDoc(ctxt, (const xmlChar *)htmlCode.c_str(), 0, encoding, options);
         if (!doc || !ctxt->valid)
         {
-            *error = *errorBuffer;
+            *error = errorBuffer;
         }
 
         xmlSetGenericErrorFunc(0, errorFunctionWithoutOutput);
@@ -470,17 +456,13 @@ namespace org_modules_xml
     {
         xmlParserCtxt *ctxt;
 
-        if (errorBuffer)
-        {
-            delete errorBuffer;
-        }
-        errorBuffer = new std::string();
+        errorBuffer.clear();
 
         ctxt = xmlNewParserCtxt();
         if (!ctxt)
         {
-            errorBuffer->append(gettext("Cannot create a parser context"));
-            *error = *errorBuffer;
+            errorBuffer.append(gettext("Cannot create a parser context"));
+            *error = errorBuffer;
             return 0;
         }
 
@@ -498,17 +480,13 @@ namespace org_modules_xml
     {
         htmlParserCtxt *ctxt;
 
-        if (errorBuffer)
-        {
-            delete errorBuffer;
-        }
-        errorBuffer = new std::string();
+        errorBuffer.clear();
 
         ctxt = htmlNewParserCtxt();
         if (!ctxt)
         {
-            errorBuffer->append(gettext("Cannot create a parser context"));
-            *error = *errorBuffer;
+            errorBuffer.append(gettext("Cannot create a parser context"));
+            *error = errorBuffer;
             return 0;
         }
 
@@ -525,11 +503,12 @@ namespace org_modules_xml
         va_start(args, msg);
         vsnprintf(str, BUFFER_SIZE, msg, args);
         va_end(args);
-        errorBuffer->append(str);
+        errorBuffer.append(str);
     }
 
     void XMLDocument::errorXPathFunction(void *ctx, xmlError * error)
     {
-        errorXPathBuffer->append(error->message);
+        errorXPathBuffer.append(error->message);
     }
 }
+
index efab974..4f0395d 100644 (file)
@@ -46,7 +46,7 @@ class XMLValidation;
  */
 class XML_SCILAB_IMPEXP XMLDocument: public XMLObject
 {
-    static std::list < XMLDocument * >&openDocs;
+    static std::list < XMLDocument * > openDocs;
     xmlDoc *document;
 
 public:
@@ -227,9 +227,10 @@ private:
      */
     static htmlParserCtxt *initHTMLContext(std::string * error);
 
-    static std::string * errorBuffer;
-    static std::string * errorXPathBuffer;
+    static std::string errorBuffer;
+    static std::string errorXPathBuffer;
 };
 }
 
 #endif
+
index bb4b8c9..463debf 100644 (file)
@@ -25,8 +25,8 @@ extern "C"
 namespace org_modules_xml
 {
 
-std::string * XMLValidation::errorBuffer = 0;
-std::list<XMLValidation *>& XMLValidation::openValidationFiles = *new std::list < XMLValidation * >();
+std::string XMLValidation::errorBuffer;
+std::list<XMLValidation *> XMLValidation::openValidationFiles;
 
 XMLValidation::XMLValidation(): XMLObject(), validationFile(0)
 {
@@ -45,7 +45,7 @@ void XMLValidation::errorFunction(void *ctx, const char *msg, ...)
     vsnprintf(str, BUFFER_SIZE, msg, args);
 #endif
     va_end(args);
-    errorBuffer->append(str);
+    errorBuffer.append(str);
 }
 
 void XMLValidation::errorReaderFunction(void * arg, const char * msg, xmlParserSeverities severity, xmlTextReaderLocatorPtr locator)
@@ -56,7 +56,7 @@ void XMLValidation::errorReaderFunction(void * arg, const char * msg, xmlParserS
         << xmlTextReaderLocatorLineNumber(locator) << std::endl
         << msg << std::endl;
 
-    errorBuffer->append(oss.str());
+    errorBuffer.append(oss.str());
 }
 
 
@@ -127,3 +127,4 @@ void XMLValidation::closeAllValidationFiles()
     delete[]arr;
 }
 }
+
index b09d78f..3a6ce3d 100644 (file)
@@ -87,8 +87,8 @@ public:
     }
 
 protected:
-    static std::string * errorBuffer;
-    static std::list < XMLValidation * >&openValidationFiles;
+    static std::string errorBuffer;
+    static std::list<XMLValidation *> openValidationFiles;
 
     /**
      * Error function for the XML parser
@@ -103,3 +103,4 @@ protected:
 }
 
 #endif
+
index 9539b2c..61b970a 100644 (file)
@@ -36,13 +36,9 @@ XMLValidationDTD::XMLValidationDTD(const char *path, std::string * error): XMLVa
         FREE(expandedPath);
         if (!validationFile)
         {
-            if (errorBuffer)
-            {
-                delete errorBuffer;
-            }
-            errorBuffer = new std::string(gettext("Cannot parse the DTD"));
-
-            *error = *errorBuffer;
+            errorBuffer.clear();
+            errorBuffer.append(gettext("Cannot parse the DTD"));
+            *error = errorBuffer;
         }
         else
         {
@@ -84,13 +80,8 @@ XMLValidationDTD::~XMLValidationDTD()
             resetScope();
         }
     }
-
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-
-        errorBuffer = 0;
-    }
+    
+    errorBuffer.clear();
 }
 
 bool XMLValidationDTD::validate(const XMLDocument & doc, std::string * error) const
@@ -98,16 +89,12 @@ bool XMLValidationDTD::validate(const XMLDocument & doc, std::string * error) co
     bool ret;
     xmlValidCtxt *vctxt = xmlNewValidCtxt();
 
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-    }
-    errorBuffer = new std::string("");
+    errorBuffer.clear();
 
     if (!vctxt)
     {
-        errorBuffer->append(gettext("Cannot create a valid context"));
-        *error = *errorBuffer;
+        errorBuffer.append(gettext("Cannot create a valid context"));
+        *error = errorBuffer;
         return false;
     }
 
@@ -120,7 +107,7 @@ bool XMLValidationDTD::validate(const XMLDocument & doc, std::string * error) co
 
     if (!ret)
     {
-        *error = *errorBuffer;
+        *error = errorBuffer;
     }
 
     return ret;
@@ -131,16 +118,12 @@ bool XMLValidationDTD::validate(xmlTextReader * reader, std::string * error) con
     int last;
     int valid;
 
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-    }
-    errorBuffer = new std::string("");
+    errorBuffer.clear();
 
     if (!internalValidate)
     {
-        errorBuffer->append(gettext("Due to a libxml2 limitation, it is not possible to validate a document against an external DTD\nPlease see help xmlValidate.\n"));
-        *error = *errorBuffer;
+        errorBuffer.append(gettext("Due to a libxml2 limitation, it is not possible to validate a document against an external DTD\nPlease see help xmlValidate.\n"));
+        *error = errorBuffer;
         return false;
     }
 
@@ -157,7 +140,7 @@ bool XMLValidationDTD::validate(xmlTextReader * reader, std::string * error) con
 
     if (last == -1 || valid != 1)
     {
-        *error = *errorBuffer;
+        *error = errorBuffer;
         return false;
     }
 
@@ -177,3 +160,4 @@ const std::string XMLValidationDTD::toString() const
     return oss.str();
 }
 }
+
index 919d0a2..d48ee66 100644 (file)
@@ -36,12 +36,9 @@ XMLValidationRelaxNG::XMLValidationRelaxNG(const char *path, std::string * error
         FREE(expandedPath);
         if (!pctxt)
         {
-            if (errorBuffer)
-            {
-                delete errorBuffer;
-            }
-            errorBuffer = new std::string(gettext("Cannot create a validation context"));
-            *error = *errorBuffer;
+            errorBuffer.clear();
+            errorBuffer.append(gettext("Cannot create a validation context"));
+            *error = errorBuffer;
         }
         else
         {
@@ -49,12 +46,9 @@ XMLValidationRelaxNG::XMLValidationRelaxNG(const char *path, std::string * error
             xmlRelaxNGFreeParserCtxt(pctxt);
             if (!validationFile)
             {
-                if (errorBuffer)
-                {
-                    delete errorBuffer;
-                }
-                errorBuffer = new std::string(gettext("Cannot parse the Relax NG grammar"));
-                *error = *errorBuffer;
+                errorBuffer.clear();
+                errorBuffer.append(gettext("Cannot parse the Relax NG grammar"));
+                *error = errorBuffer;
             }
             else
             {
@@ -85,12 +79,7 @@ XMLValidationRelaxNG::~XMLValidationRelaxNG()
         }
     }
 
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-
-        errorBuffer = 0;
-    }
+    errorBuffer.clear();
 }
 
 bool XMLValidationRelaxNG::validate(const XMLDocument & doc, std::string * error) const
@@ -98,16 +87,12 @@ bool XMLValidationRelaxNG::validate(const XMLDocument & doc, std::string * error
     bool ret;
     xmlRelaxNGValidCtxt *vctxt = xmlRelaxNGNewValidCtxt((xmlRelaxNG *) validationFile);
 
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-    }
-    errorBuffer = new std::string("");
+    errorBuffer.clear();
 
     if (!vctxt)
     {
-        errorBuffer->append(gettext("Cannot create a validation context"));
-        *error = *errorBuffer;
+        errorBuffer.append(gettext("Cannot create a validation context"));
+        *error = errorBuffer;
         return false;
     }
 
@@ -120,7 +105,7 @@ bool XMLValidationRelaxNG::validate(const XMLDocument & doc, std::string * error
 
     if (ret)
     {
-        *error = *errorBuffer;
+        *error = errorBuffer;
     }
 
     return ret == 0;
@@ -131,11 +116,7 @@ bool XMLValidationRelaxNG::validate(xmlTextReader * reader, std::string * error)
     int last;
     int valid;
 
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-    }
-    errorBuffer = new std::string();
+    errorBuffer.clear();
 
     xmlTextReaderSetErrorHandler(reader, (xmlTextReaderErrorFunc) XMLValidation::errorReaderFunction, 0);
     xmlTextReaderRelaxNGSetSchema(reader, getValidationFile < xmlRelaxNG > ());
@@ -151,7 +132,7 @@ bool XMLValidationRelaxNG::validate(xmlTextReader * reader, std::string * error)
 
     if (last == -1 || valid != 1)
     {
-        *error = *errorBuffer;
+        *error = errorBuffer;
         return false;
     }
 
@@ -163,3 +144,4 @@ const std::string XMLValidationRelaxNG::toString() const
     return std::string("XML Relax NG\nNo public information");
 }
 }
+
index cbb0d09..e46b741 100644 (file)
@@ -36,12 +36,9 @@ XMLValidationSchema::XMLValidationSchema(const char *path, std::string * error):
         FREE(expandedPath);
         if (!pctxt)
         {
-            if (errorBuffer)
-            {
-                delete errorBuffer;
-            }
-            errorBuffer = new std::string(gettext("Cannot create a validation context"));
-            *error = *errorBuffer;
+            errorBuffer.clear();
+            errorBuffer.append(gettext("Cannot create a validation context"));
+            *error = errorBuffer;
         }
         else
         {
@@ -49,12 +46,9 @@ XMLValidationSchema::XMLValidationSchema(const char *path, std::string * error):
             xmlSchemaFreeParserCtxt(pctxt);
             if (!validationFile)
             {
-                if (errorBuffer)
-                {
-                    delete errorBuffer;
-                }
-                errorBuffer = new std::string(gettext("Cannot parse the schema"));
-                *error = *errorBuffer;
+                errorBuffer.clear();
+                errorBuffer.append(gettext("Cannot parse the schema"));
+                *error = errorBuffer;
             }
             else
             {
@@ -84,12 +78,7 @@ XMLValidationSchema::~XMLValidationSchema()
         }
     }
 
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-
-        errorBuffer = 0;
-    }
+    errorBuffer.clear();
 }
 
 bool XMLValidationSchema::validate(const XMLDocument & doc, std::string * error) const
@@ -97,16 +86,12 @@ bool XMLValidationSchema::validate(const XMLDocument & doc, std::string * error)
     bool ret;
     xmlSchemaValidCtxt *vctxt = xmlSchemaNewValidCtxt((xmlSchema *) validationFile);
 
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-    }
-    errorBuffer = new std::string("");
+    errorBuffer.clear();
 
     if (!vctxt)
     {
-        errorBuffer->append(gettext("Cannot create a validation context"));
-        *error = *errorBuffer;
+        errorBuffer.append(gettext("Cannot create a validation context"));
+        *error = errorBuffer;
         return false;
     }
 
@@ -119,7 +104,7 @@ bool XMLValidationSchema::validate(const XMLDocument & doc, std::string * error)
 
     if (ret)
     {
-        *error = *errorBuffer;
+        *error = errorBuffer;
     }
 
     return ret == 0;
@@ -131,24 +116,20 @@ bool XMLValidationSchema::validate(xmlTextReader * reader, std::string * error)
     int last;
     int valid;
 
-    if (errorBuffer)
-    {
-        delete errorBuffer;
-    }
-    errorBuffer = new std::string();
+    errorBuffer.clear();
 
     if (!reader)
     {
-        errorBuffer->append(gettext("Cannot read the stream"));
-        *error = *errorBuffer;
+        errorBuffer.append(gettext("Cannot read the stream"));
+        *error = errorBuffer;
         return false;
     }
 
     vctxt = xmlSchemaNewValidCtxt(getValidationFile < xmlSchema > ());
     if (!vctxt)
     {
-        errorBuffer->append(gettext("Cannot create a validation context"));
-        *error = *errorBuffer;
+        errorBuffer.append(gettext("Cannot create a validation context"));
+        *error = errorBuffer;
         return false;
     }
 
@@ -169,7 +150,7 @@ bool XMLValidationSchema::validate(xmlTextReader * reader, std::string * error)
 
     if (last == -1 || valid != 1)
     {
-        *error = *errorBuffer;
+        *error = errorBuffer;
         return false;
     }
 
@@ -190,3 +171,4 @@ const std::string XMLValidationSchema::toString() const
 }
 
 }
+