Finalize JVM module for Scilab 6. 04/15904/4
Vincent COUVERT [Tue, 3 Feb 2015 14:18:49 +0000 (15:18 +0100)]
To test: test_run jvm

Change-Id: I3da5d6f925c9b5e4c5d3cf282443cfbb8cf59ea3

18 files changed:
scilab/modules/jvm/Makefile.am
scilab/modules/jvm/Makefile.in
scilab/modules/jvm/includes/gw_jvm.h
scilab/modules/jvm/includes/jvm_gw.hxx
scilab/modules/jvm/libjvm.vcxproj
scilab/modules/jvm/libjvm.vcxproj.filters
scilab/modules/jvm/sci_gateway/c/sci_javaclasspath.c
scilab/modules/jvm/sci_gateway/c/sci_javalibrarypath.c
scilab/modules/jvm/sci_gateway/c/sci_system_setproperty.c [deleted file]
scilab/modules/jvm/sci_gateway/cpp/jvm_gw.cpp
scilab/modules/jvm/sci_gateway/cpp/libjvm_gw.vcxproj
scilab/modules/jvm/sci_gateway/cpp/libjvm_gw.vcxproj.filters
scilab/modules/jvm/sci_gateway/cpp/sci_system_getproperty.cpp
scilab/modules/jvm/sci_gateway/cpp/sci_system_setproperty.cpp [new file with mode: 0644]
scilab/modules/jvm/tests/unit_tests/javalibrarypath.dia.ref
scilab/modules/jvm/tests/unit_tests/javalibrarypath.tst
scilab/modules/jvm/tests/unit_tests/system_setproperty.dia.ref
scilab/modules/jvm/tests/unit_tests/system_setproperty.tst

index 858d4f2..2c61964 100644 (file)
@@ -89,13 +89,13 @@ libscijvm_la_include_HEADERS = \
     includes/getScilabObject.h
 
 GATEWAY_C_SOURCES = \
-    sci_gateway/c/sci_system_setproperty.c \
     sci_gateway/c/sci_javaclasspath.c \
     sci_gateway/c/gw_jvm.c \
     sci_gateway/c/sci_javalibrarypath.c
 
 GATEWAY_CPP_SOURCES = \
     sci_gateway/cpp/sci_system_getproperty.cpp \
+    sci_gateway/cpp/sci_system_setproperty.cpp \
     sci_gateway/cpp/jvm_gw.cpp
 
 JVM_C_SOURCES = \
index 1432893..7ab1045 100644 (file)
@@ -211,12 +211,12 @@ libscijvm_disable_la_OBJECTS = $(am_libscijvm_disable_la_OBJECTS)
 am__DEPENDENCIES_1 =
 libscijvm_la_DEPENDENCIES = libscijvm-algo.la $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1)
-am__objects_4 = sci_gateway/c/libscijvm_la-sci_system_setproperty.lo \
-       sci_gateway/c/libscijvm_la-sci_javaclasspath.lo \
+am__objects_4 = sci_gateway/c/libscijvm_la-sci_javaclasspath.lo \
        sci_gateway/c/libscijvm_la-gw_jvm.lo \
        sci_gateway/c/libscijvm_la-sci_javalibrarypath.lo
 am__objects_5 =  \
        sci_gateway/cpp/libscijvm_la-sci_system_getproperty.lo \
+       sci_gateway/cpp/libscijvm_la-sci_system_setproperty.lo \
        sci_gateway/cpp/libscijvm_la-jvm_gw.lo
 am_libscijvm_la_OBJECTS = $(am__objects_4) $(am__objects_5)
 libscijvm_la_OBJECTS = $(am_libscijvm_la_OBJECTS)
@@ -658,13 +658,13 @@ libscijvm_la_include_HEADERS = \
     includes/getScilabObject.h
 
 GATEWAY_C_SOURCES = \
-    sci_gateway/c/sci_system_setproperty.c \
     sci_gateway/c/sci_javaclasspath.c \
     sci_gateway/c/gw_jvm.c \
     sci_gateway/c/sci_javalibrarypath.c
 
 GATEWAY_CPP_SOURCES = \
     sci_gateway/cpp/sci_system_getproperty.cpp \
+    sci_gateway/cpp/sci_system_setproperty.cpp \
     sci_gateway/cpp/jvm_gw.cpp
 
 JVM_C_SOURCES = \
@@ -930,9 +930,6 @@ 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/libscijvm_la-sci_system_setproperty.lo:  \
-       sci_gateway/c/$(am__dirstamp) \
-       sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/c/libscijvm_la-sci_javaclasspath.lo:  \
        sci_gateway/c/$(am__dirstamp) \
        sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
@@ -950,6 +947,9 @@ sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp):
 sci_gateway/cpp/libscijvm_la-sci_system_getproperty.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscijvm_la-sci_system_setproperty.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/cpp/libscijvm_la-jvm_gw.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
@@ -974,9 +974,9 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscijvm_la-gw_jvm.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_javaclasspath.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_javalibrarypath.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_system_setproperty.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscijvm_la-jvm_gw.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscijvm_la-sci_system_getproperty.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscijvm_la-sci_system_setproperty.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscijvm_algo_la-InitializeJVM.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscijvm_algo_la-JVM.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscijvm_algo_la-JVM_Unix.Plo@am__quote@
@@ -1155,13 +1155,6 @@ src/nojvm/libscijvm_disable_la-nojvm.lo: src/nojvm/nojvm.c
 @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) $(libscijvm_disable_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/nojvm/libscijvm_disable_la-nojvm.lo `test -f 'src/nojvm/nojvm.c' || echo '$(srcdir)/'`src/nojvm/nojvm.c
 
-sci_gateway/c/libscijvm_la-sci_system_setproperty.lo: sci_gateway/c/sci_system_setproperty.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijvm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscijvm_la-sci_system_setproperty.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_system_setproperty.Tpo -c -o sci_gateway/c/libscijvm_la-sci_system_setproperty.lo `test -f 'sci_gateway/c/sci_system_setproperty.c' || echo '$(srcdir)/'`sci_gateway/c/sci_system_setproperty.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_system_setproperty.Tpo sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_system_setproperty.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/sci_system_setproperty.c' object='sci_gateway/c/libscijvm_la-sci_system_setproperty.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) $(libscijvm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscijvm_la-sci_system_setproperty.lo `test -f 'sci_gateway/c/sci_system_setproperty.c' || echo '$(srcdir)/'`sci_gateway/c/sci_system_setproperty.c
-
 sci_gateway/c/libscijvm_la-sci_javaclasspath.lo: sci_gateway/c/sci_javaclasspath.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijvm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscijvm_la-sci_javaclasspath.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_javaclasspath.Tpo -c -o sci_gateway/c/libscijvm_la-sci_javaclasspath.lo `test -f 'sci_gateway/c/sci_javaclasspath.c' || echo '$(srcdir)/'`sci_gateway/c/sci_javaclasspath.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_javaclasspath.Tpo sci_gateway/c/$(DEPDIR)/libscijvm_la-sci_javaclasspath.Plo
@@ -1221,6 +1214,13 @@ sci_gateway/cpp/libscijvm_la-sci_system_getproperty.lo: sci_gateway/cpp/sci_syst
 @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) $(libscijvm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscijvm_la-sci_system_getproperty.lo `test -f 'sci_gateway/cpp/sci_system_getproperty.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_system_getproperty.cpp
 
+sci_gateway/cpp/libscijvm_la-sci_system_setproperty.lo: sci_gateway/cpp/sci_system_setproperty.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijvm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscijvm_la-sci_system_setproperty.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscijvm_la-sci_system_setproperty.Tpo -c -o sci_gateway/cpp/libscijvm_la-sci_system_setproperty.lo `test -f 'sci_gateway/cpp/sci_system_setproperty.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_system_setproperty.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscijvm_la-sci_system_setproperty.Tpo sci_gateway/cpp/$(DEPDIR)/libscijvm_la-sci_system_setproperty.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_system_setproperty.cpp' object='sci_gateway/cpp/libscijvm_la-sci_system_setproperty.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) $(libscijvm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscijvm_la-sci_system_setproperty.lo `test -f 'sci_gateway/cpp/sci_system_setproperty.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_system_setproperty.cpp
+
 sci_gateway/cpp/libscijvm_la-jvm_gw.lo: sci_gateway/cpp/jvm_gw.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijvm_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscijvm_la-jvm_gw.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscijvm_la-jvm_gw.Tpo -c -o sci_gateway/cpp/libscijvm_la-jvm_gw.lo `test -f 'sci_gateway/cpp/jvm_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/jvm_gw.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscijvm_la-jvm_gw.Tpo sci_gateway/cpp/$(DEPDIR)/libscijvm_la-jvm_gw.Plo
index d477e04..eed0ae9 100644 (file)
 /*--------------------------------------------------------------------------*/
 int gw_jvm(void);
 /*--------------------------------------------------------------------------*/
-/* Declaration of all the profile function declared and */
-/* used in sci_gateway */
-//JVM_GW_IMPEXP int sci_with_embedded_jre(char *fname, unsigned long fname_len);
-//JVM_GW_IMPEXP int sci_system_setproperty(char *fname, unsigned long fname_len);
-//JVM_GW_IMPEXP int sci_javalibrarypath(char *fname, unsigned long fname_len);
-//YaSp
+/* Declaration of all the profile function declared and used in sci_gateway */
 JVM_GW_IMPEXP int sci_javaclasspath(char *fname, void* pvApiCtx);
+JVM_GW_IMPEXP int sci_javalibrarypath(char *fname, void* pvApiCtx);
 /*--------------------------------------------------------------------------*/
 #endif /*  __GW_JVM_H__ */
 
index c33ec2f..3787829 100644 (file)
@@ -34,5 +34,6 @@ public :
     }
 };
 CPP_GATEWAY_PROTOTYPE(sci_system_getproperty);
+CPP_GATEWAY_PROTOTYPE(sci_system_setproperty);
 
 #endif /* !__JVM_GW_HXX__ */
index d35d362..80ad1c6 100644 (file)
@@ -237,7 +237,6 @@ lib /DEF:"$(ProjectDir)preferences_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Pla
     <ClCompile Include="src\c\loadClasspath.c" />
     <ClCompile Include="src\c\loadLibrarypath.c" />
     <ClCompile Include="src\c\loadOnUseClassPath.c" />
-    <ClCompile Include="sci_gateway\c\sci_system_setproperty.c" />
     <ClCompile Include="src\c\system_getproperty.c" />
     <ClCompile Include="src\c\system_setproperty.c" />
     <ClCompile Include="src\c\TerminateJVM.c" />
index 2d24cc2..a055cb9 100644 (file)
@@ -78,9 +78,6 @@
     <ClCompile Include="src\c\loadOnUseClassPath.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="sci_gateway\c\sci_system_setproperty.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\c\system_getproperty.c">
       <Filter>Source Files</Filter>
     </ClCompile>
       <Filter>localization</Filter>
     </None>
     <None Include="Scilab_Windows_Import.def">
-      <Filter>Source Files</Filter>
+      <Filter>Libraries Dependencies\Imports</Filter>
     </None>
   </ItemGroup>
 </Project>
\ No newline at end of file
index e08e1eb..5d71d7e 100644 (file)
@@ -27,22 +27,21 @@ int sci_javaclasspath(char *fname, void* pvApiCtx)
     int iType = 0;
     SciErr sciErr;
 
-    //Rhs = Max(Rhs,0);
     CheckRhs(0, 1);
     CheckLhs(0, 1);
 
     if (Rhs == 0)
     {
-        int nbRow = 0;
-        int nbCol = 1;
-        char **Strings = NULL;
+        int iRows = 0;
+        int iCols = 1;
+        char **pstClasspath = NULL;
 
-        Strings = getClasspath(&nbRow);
-        createMatrixOfString(pvApiCtx, Rhs + 1, nbRow, nbCol, Strings);
+        pstClasspath = getClasspath(&iRows);
+        createMatrixOfString(pvApiCtx, Rhs + 1, iRows, iCols, pstClasspath);
 
         LhsVar(1) = Rhs + 1;
         PutLhsVar();
-        freeArrayOfString(Strings, nbRow * nbCol);
+        freeArrayOfString(pstClasspath, iRows * iCols);
     }
     else
     {
@@ -65,83 +64,26 @@ int sci_javaclasspath(char *fname, void* pvApiCtx)
         if ( iType == sci_strings )
         {
             char **pStVarOne = NULL;
-            int *lenStVarOne = NULL;
-            static int n1 = 0, m1 = 0;
+            static int iCols = 0, iRows = 0;
             int i = 0;
 
-            /* get dimensions */
-            sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
-            if (sciErr.iErr)
+            if (getAllocatedMatrixOfString(pvApiCtx, piAddressVarOne, &iRows, &iCols, &pStVarOne))
             {
-                printError(&sciErr, 0);
                 Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
                 return 0;
             }
-
-            lenStVarOne = (int*)MALLOC(sizeof(int) * (m1 * n1));
-            if (lenStVarOne == NULL)
-            {
-                Scierror(999, _("%s: No more memory.\n"), fname);
-                return 0;
-            }
-
-            /* get lengths */
-            sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
-            if (sciErr.iErr)
-            {
-                if (lenStVarOne)
-                {
-                    FREE(lenStVarOne);
-                    lenStVarOne = NULL;
-                }
-                printError(&sciErr, 0);
-                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
-                return 0;
-            }
-
-            pStVarOne = (char **)MALLOC(sizeof(char*) * (m1 * n1));
-            if (pStVarOne == NULL)
-            {
-                if (lenStVarOne)
-                {
-                    FREE(lenStVarOne);
-                    lenStVarOne = NULL;
-                }
-                Scierror(999, _("%s: No more memory.\n"), fname);
-                return 0;
-            }
-            for (i = 0; i < m1 * n1; i++)
-            {
-                pStVarOne[i] = (char*)MALLOC(sizeof(char*) * (lenStVarOne[i] + 1));
-            }
-
-            /* get strings */
-            sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
-            if (sciErr.iErr)
-            {
-                freeArrayOfString(pStVarOne, m1 * n1);
-                if (lenStVarOne)
-                {
-                    FREE(lenStVarOne);
-                    lenStVarOne = NULL;
-                }
-                printError(&sciErr, 0);
-                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
-                return 0;
-            }
-
-            for (i = 0; i < m1 * n1 ; i++)
+            for (i = 0; i < iRows * iCols ; i++)
             {
                 if (!addToClasspath(pStVarOne[i], STARTUP))
                 {
                     Scierror(999, _("%s: Could not add URL to system classloader : %s.\n"), fname, pStVarOne[i]);
-                    freeArrayOfString(pStVarOne, m1 * n1);
+                    freeArrayOfString(pStVarOne, iRows * iCols);
                     return 0;
                 }
             }
             LhsVar(1) = 0;
             PutLhsVar();
-            freeArrayOfString(pStVarOne, m1 * n1);
+            freeArrayOfString(pStVarOne, iRows * iCols);
         }
         else
         {
index efd2878..51a4917 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) INRIA - Allan CORNET
+ * Copyright (C) Scilab Enterprises - 2015 - Vincent COUVERT
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
 /*--------------------------------------------------------------------------*/
 #include "gw_jvm.h"
 #include "sci_malloc.h"
-#include "stack-c.h"
 #include "Scierror.h"
 #include "addToLibrarypath.h"
 #include "getLibrarypath.h"
 #include "localization.h"
 #include "freeArrayOfString.h"
+#include "api_scilab.h"
 /*--------------------------------------------------------------------------*/
-int sci_javalibrarypath(char *fname, unsigned long fname_len)
+int sci_javalibrarypath(char *fname, void* pvApiCtx)
 {
-    //Rhs = Max(Rhs, 0);
-    //CheckRhs(0, 1);
-    //CheckLhs(0, 1);
+    int *piAddressVarOne = NULL;
+    int iType = 0;
+    SciErr sciErr;
 
-    //if (Rhs == 0)
-    //{
-    //    int nbRow = 0;
-    //    int nbCol = 1;
-    //    char **Strings = NULL;
+    CheckRhs(0, 1);
+    CheckLhs(0, 1);
 
-    //    Strings = getLibrarypath(&nbRow);
-    //    CreateVarFromPtr( Rhs + 1, MATRIX_OF_STRING_DATATYPE, &nbRow, &nbCol, Strings );
+    if (Rhs == 0)
+    {
+        int iRows = 0;
+        int iCols = 1;
+        char **pstLibrarypath = NULL;
 
-    //    LhsVar(1) = Rhs + 1;
-    //    freeArrayOfString(Strings, nbRow * nbCol);
-    //    PutLhsVar();
-    //}
-    //else
-    //{
-    //    if ( GetType(1) == sci_strings )
-    //    {
-    //        static int n1 = 0, m1 = 0;
-    //        int i = 0;
-    //        BOOL bOK = FALSE;
-    //        char **libraryPaths = NULL;
+        pstLibrarypath = getLibrarypath(&iRows);
+        createMatrixOfString(pvApiCtx, Rhs + 1, iRows, iCols, pstLibrarypath);
 
-    //        GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &m1, &n1, &libraryPaths);
+        LhsVar(1) = Rhs + 1;
+        PutLhsVar();
+        freeArrayOfString(pstLibrarypath, iRows * iCols);
+    }
+    else
+    {
+        sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
+        if (sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+            return 0;
+        }
+
+        sciErr = getVarType(pvApiCtx, piAddressVarOne, &iType);
+        if (sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+            return 0;
+        }
+
+        if ( iType == sci_strings )
+        {
+            char **pStVarOne = NULL;
+            static int iCols = 0, iRows = 0;
+            int i = 0;
+
+            if (getAllocatedMatrixOfString(pvApiCtx, piAddressVarOne, &iRows, &iCols, &pStVarOne))
+            {
+                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+                return 0;
+            }
+            for (i = 0; i < iRows * iCols ; i++)
+            {
+                if (!addToLibrarypath(pStVarOne[i]))
+                {
+                    Scierror(999, _("%s: Could not add path to java.library.path: %s.\n"), fname, pStVarOne[i]);;
+                    freeArrayOfString(pStVarOne, iRows * iCols);
+                    return 0;
+                }
+            }
+            LhsVar(1) = 0;
+            PutLhsVar();
+            freeArrayOfString(pStVarOne, iRows * iCols);
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
+        }
+    }
 
-    //        for (i = 0; i < m1 * n1 ; i++)
-    //        {
-    //            bOK = addToLibrarypath(libraryPaths[i]);
-    //            if (!bOK)
-    //            {
-    //                Scierror(999, _("%s: Could not add path to java.library.path: %s.\n"), fname, libraryPaths[i]);
-    //                freeArrayOfString(libraryPaths, m1 * n1);
-    //                return 0;
-    //            }
-    //        }
-    //        LhsVar(1) = 0;
-    //        freeArrayOfString(libraryPaths, m1 * n1);
-    //        PutLhsVar();
-    //    }
-    //    else
-    //    {
-    //        Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
-    //    }
-    //}
     return 0;
 }
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/jvm/sci_gateway/c/sci_system_setproperty.c b/scilab/modules/jvm/sci_gateway/c/sci_system_setproperty.c
deleted file mode 100644 (file)
index f1bbfca..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) INRIA - Allan CORNET
- *
- * 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.1-en.txt
- *
- */
-
-/*--------------------------------------------------------------------------*/
-#include <string.h>
-#include "gw_jvm.h"
-#include "sci_malloc.h"
-#include "stack-c.h"
-#include "system_setproperty.h"
-#include "Scierror.h"
-#include "localization.h"
-/*--------------------------------------------------------------------------*/
-int sci_system_setproperty(char *fname, unsigned long fname_len)
-{
-    //Rhs = Max(Rhs, 0);
-    //CheckRhs(2, 2);
-    //CheckLhs(1, 1);
-
-    //if ( (GetType(1) == sci_strings) && (GetType(2) == sci_strings) )
-    //{
-    //    static int m1, n1 = 0, l1 = 0;
-    //    static int m2, n2 = 0, l2 = 0;
-    //    char *propertyName = NULL;
-    //    char *propertyValue = NULL;
-    //    char *previousValue = NULL;
-
-    //    GetRhsVar(1, STRING_DATATYPE, &m1, &n1, &l1);
-    //    propertyName = cstk(l1);
-
-    //    GetRhsVar(2, STRING_DATATYPE, &m2, &n2, &l2);
-    //    propertyValue = cstk(l2);
-
-    //    previousValue = system_setproperty(propertyName, propertyValue);
-
-    //    if (previousValue)
-    //    {
-    //        n1 = 1;
-    //        m1 = (int)strlen(propertyValue);
-    //        CreateVarFromPtr(Rhs + 1, STRING_DATATYPE, &m1, &n1, &previousValue);
-    //    }
-    //    else
-    //    {
-    //        n1 = 0;
-    //        m1 = 0;
-    //        l1 = 0;
-    //        CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE, &n1, &m1, &l1);
-    //    }
-    //    LhsVar(1) = Rhs + 1;
-    //    if (previousValue)
-    //    {
-    //        FREE(previousValue);
-    //        previousValue = NULL;
-    //    }
-    //    PutLhsVar();
-    //}
-    //else
-    //{
-    //    Scierror(999, _("%s: Wrong type for input argument #%d or #%d: String expected.\n"), fname, 1, 2);
-    //}
-    return 0;
-}
-/*--------------------------------------------------------------------------*/
index 49f2020..3c210cc 100644 (file)
@@ -25,6 +25,8 @@ extern "C"
 int JvmModule::Load()
 {
     symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"system_getproperty", &sci_system_getproperty, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"system_setproperty", &sci_system_setproperty, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"javaclasspath", &sci_javaclasspath, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"javalibrarypath", &sci_javaclasspath, MODULE_NAME));
     return 1;
 }
index 2f230a1..9ff6777 100644 (file)
   <ItemGroup>
     <ClCompile Include="..\c\sci_javaclasspath.c" />
     <ClCompile Include="..\c\sci_javalibrarypath.c" />
-    <ClCompile Include="..\c\sci_system_setproperty.c" />
     <ClCompile Include="jvm_gw.cpp" />
     <ClCompile Include="sci_system_getproperty.cpp" />
+    <ClCompile Include="sci_system_setproperty.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\dynlib_jvm_gw.h" />
index 578a0a9..ef5459c 100644 (file)
@@ -27,7 +27,7 @@
     <ClCompile Include="..\c\sci_javalibrarypath.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\c\sci_system_setproperty.c">
+    <ClCompile Include="sci_system_setproperty.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
index 27d686b..3829d4e 100644 (file)
@@ -32,19 +32,19 @@ Function::ReturnValue sci_system_getproperty(typed_list &in, int _piRetCount, ty
 {
     if (in.size() != 1)
     {
-        Scierror(999, _("%s: Wrong number of input arguments: at least %d expected.\n"), "system_getproperty", 1);
+        Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), "system_getproperty", 1);
         return Function::Error;
     }
 
-    if (in[0]->isString() == false || in[0]->getAs<types::String>()->getSize() != 1)
+    if (_piRetCount != 1)
     {
-        Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), "system_getproperty" , 1);
+        Scierror(999, _("%s: Wrong number of output arguments: %d expected.\n"), "system_getproperty", 1);
         return Function::Error;
     }
 
-    if (getScilabMode() == SCILAB_NWNI)
+    if (in[0]->isString() == false || in[0]->getAs<types::String>()->getSize() != 1)
     {
-        Scierror(999, _("JVM interface disabled in -nogui or -nwni modes.\n"));
+        Scierror(999, _("%s: Wrong type for input argument #%d: A String expected.\n"), "system_getproperty" , 1);
         return Function::Error;
     }
 
@@ -53,33 +53,10 @@ Function::ReturnValue sci_system_getproperty(typed_list &in, int _piRetCount, ty
     String* pS          = new String(pstValue);
     out.push_back(pS);
 
-    return Function::OK;
-    //Rhs = std::max(Rhs,0);
-    //CheckRhs(1,1);
-    //CheckLhs(0,1);
-
-    //if ( GetType(1) == sci_strings )
-    //{
-    // static int m1,n1=0,l1=0;
-    // char *propertyName = NULL;
-    // char *propertyValue = NULL;
-
-    // GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
-    // propertyName=cstk(l1);
-    // propertyValue=system_getproperty(propertyName,"unknown");
+    FREE(pstProperty);
+    FREE(pstValue);
 
-    // n1=1;
-    // CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m1=(int)strlen(propertyValue), &m1),&n1,&propertyValue);
-    // LhsVar(1)=Rhs+1;
-    // C2F(putlhsvar)();
-    // if (propertyValue) {FREE(propertyValue);propertyValue=NULL;}
-    //}
-    //else
-    //{
-    // Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"),fname, 1);
-    // return 0;
-    //}
-    //return 0;
+    return Function::OK;
 }
 
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/jvm/sci_gateway/cpp/sci_system_setproperty.cpp b/scilab/modules/jvm/sci_gateway/cpp/sci_system_setproperty.cpp
new file mode 100644 (file)
index 0000000..a1d038f
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA - Allan CORNET
+ * Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+ *
+ * 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.1-en.txt
+ *
+ */
+
+/*--------------------------------------------------------------------------*/
+#include "funcmanager.hxx"
+#include "jvm_gw.hxx"
+#include "function.hxx"
+#include "string.hxx"
+#include "double.hxx"
+
+extern "C"
+{
+#include <string.h>
+#include "system_setproperty.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "configvariable_interface.h"
+
+}
+/*--------------------------------------------------------------------------*/
+
+using namespace types;
+
+Function::ReturnValue sci_system_setproperty(typed_list &in, int _piRetCount, typed_list &out)
+{
+    if (in.size() != 2)
+    {
+        Scierror(999, _("%s: Wrong number of input arguments: at %d expected.\n"), "system_setproperty", 2);
+        return Function::Error;
+    }
+
+    if (_piRetCount != 1)
+    {
+        Scierror(999, _("%s: Wrong number of output arguments: %d expected.\n"), "system_setproperty", 1);
+        return Function::Error;
+    }
+
+    if (in[0]->isString() == false || in[0]->getAs<types::String>()->getSize() != 1)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A String expected.\n"), "system_setproperty" , 1);
+        return Function::Error;
+    }
+
+    if (in[1]->isString() == false || in[1]->getAs<types::String>()->getSize() != 1)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A String expected.\n"), "system_setproperty" , 2);
+        return Function::Error;
+    }
+
+    char* pstProperty        = wide_string_to_UTF8(in[0]->getAs<types::String>()->get(0));
+    char* pstValue           = wide_string_to_UTF8(in[1]->getAs<types::String>()->get(0));
+    char* pstPreviousValue   = system_setproperty(pstProperty, pstValue);
+
+    FREE(pstProperty);
+    FREE(pstValue);
+
+    if (pstPreviousValue)
+    {
+        String* pSPreviousValue = new String(pstPreviousValue);
+        out.push_back(pSPreviousValue);
+        FREE(pstPreviousValue);
+    }
+    else
+    {
+        Double* pDPreviousValue = Double::Empty();
+        out.push_back(pDPreviousValue);
+    }
+    return Function::OK;
+
+}
+/*--------------------------------------------------------------------------*/
index e5cb6c2..4e7cb1f 100644 (file)
@@ -4,10 +4,8 @@
 //
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
-ierr = execstr('a = javalibrarypath(2);','errcatch');
-if ierr <> 999 then bugmes();quit;end
+assert_checktrue(execstr("a = javalibrarypath(2);","errcatch")==999);
 result = javalibrarypath();
-if size(result,"*") < 1 then bugmes();quit;end
+assert_checktrue(size(result,"*") > 1);
 // Does not return anything
-ierr = execstr('javalibrarypath(TMPDIR);;','errcatch');
-if ierr <> 0 then bugmes();quit;end
+assert_checktrue(execstr("javalibrarypath(TMPDIR);","errcatch")==0);
index b2ad5c1..9cc9ce0 100644 (file)
@@ -5,12 +5,11 @@
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
 
-ierr = execstr('a = javalibrarypath(2);','errcatch');
-if ierr <> 999 then pause,end
+assert_checktrue(execstr("a = javalibrarypath(2);","errcatch")==999);
 
 result = javalibrarypath();
-if size(result,"*") < 1 then pause, end
+assert_checktrue(size(result,"*") > 1);
 
 // Does not return anything
-ierr = execstr('javalibrarypath(TMPDIR);;','errcatch');
-if ierr <> 0 then pause,end
+assert_checktrue(execstr("javalibrarypath(TMPDIR);","errcatch")==0);
+
index 34ff319..7edb878 100644 (file)
@@ -4,21 +4,16 @@
 //
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
-ierr = execstr('system_setproperty();','errcatch');
-if ierr <> 77 then bugmes();quit;end
-ierr = execstr('system_getproperty();','errcatch');
-if ierr <> 77 then bugmes();quit;end
-ierr = execstr('a = system_setproperty(''TOTO'',2);','errcatch');
-if ierr <> 999 then bugmes();quit;end
-r = system_getproperty('TOTO');
-if r <> 'unknown' then bugmes();quit;end
-ierr = execstr('a = system_setproperty(''TOTO'',''TATA'');','errcatch');
-if ierr <> 0 then bugmes();quit;end
-if a <> [] then bugmes();quit;end
-r = system_getproperty('TOTO');
-if r <> 'TATA' then bugmes();quit;end
-ierr = execstr('a = system_setproperty(''TOTO'',''TITI'');','errcatch');
-if ierr <> 0 then bugmes();quit;end
-if a <> 'TATA' then bugmes();quit;end
-r = system_getproperty('TOTO');
-if r <> 'TITI' then bugmes();quit;end
+assert_checktrue(execstr("system_setproperty();","errcatch")==999);
+assert_checktrue(execstr("system_getproperty();","errcatch")==999);
+assert_checktrue(execstr("a = system_setproperty(""TOTO"",2);","errcatch")==999);
+r = system_getproperty("TOTO");
+assert_checkequal(r, "unknown");
+assert_checktrue(execstr("a = system_setproperty(""TOTO"",""TATA"");","errcatch")==0);
+assert_checkequal(a, []);
+r = system_getproperty("TOTO");
+assert_checkequal(r, "TATA");
+assert_checktrue(execstr("a = system_setproperty(""TOTO"",""TITI"");","errcatch")==0);
+assert_checkequal(a, "TATA");
+r = system_getproperty("TOTO");
+assert_checkequal(r, "TITI");
index 5efc15e..0302ace 100644 (file)
@@ -5,27 +5,21 @@
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
 
-ierr = execstr('system_setproperty();','errcatch');
-if ierr <> 77 then pause,end
+assert_checktrue(execstr("system_setproperty();","errcatch")==999);
 
-ierr = execstr('system_getproperty();','errcatch');
-if ierr <> 77 then pause,end
+assert_checktrue(execstr("system_getproperty();","errcatch")==999);
 
-ierr = execstr('a = system_setproperty(''TOTO'',2);','errcatch');
-if ierr <> 999 then pause,end
+assert_checktrue(execstr("a = system_setproperty(""TOTO"",2);","errcatch")==999);
 
-r = system_getproperty('TOTO');
-if r <> 'unknown' then pause,end
+r = system_getproperty("TOTO");
+assert_checkequal(r, "unknown");
 
-ierr = execstr('a = system_setproperty(''TOTO'',''TATA'');','errcatch');
-if ierr <> 0 then pause,end
-if a <> [] then pause,end
-r = system_getproperty('TOTO');
-if r <> 'TATA' then pause,end
+assert_checktrue(execstr("a = system_setproperty(""TOTO"",""TATA"");","errcatch")==0);
+assert_checkequal(a, []);
+r = system_getproperty("TOTO");
+assert_checkequal(r, "TATA");
 
-
-ierr = execstr('a = system_setproperty(''TOTO'',''TITI'');','errcatch');
-if ierr <> 0 then pause,end
-if a <> 'TATA' then pause,end
-r = system_getproperty('TOTO');
-if r <> 'TITI' then pause,end
+assert_checktrue(execstr("a = system_setproperty(""TOTO"",""TITI"");","errcatch")==0);
+assert_checkequal(a, "TATA");
+r = system_getproperty("TOTO");
+assert_checkequal(r, "TITI");