JIMS: add jconvMatrixMethod 73/11973/2
Calixte DENIZET [Mon, 8 Jul 2013 16:35:15 +0000 (18:35 +0200)]
Change-Id: If979124cfba9c0948fe1ad48877f37b4caa48bce

scilab/modules/external_objects/includes/ScilabOptionsSetter.hxx
scilab/modules/external_objects_java/Makefile.am
scilab/modules/external_objects_java/Makefile.in
scilab/modules/external_objects_java/includes/gw_external_objects_java.h
scilab/modules/external_objects_java/sci_gateway/c/gw_external_objects_java.c
scilab/modules/external_objects_java/sci_gateway/cpp/sci_jconvMatrixMethod.cpp [new file with mode: 0644]
scilab/modules/external_objects_java/sci_gateway/external_objects_java_gateway.xml
scilab/modules/external_objects_java/src/cpp/JavaOptionsSetter.cpp
scilab/modules/external_objects_java/src/cpp/JavaOptionsSetter.hxx

index 3286718..3feebf4 100644 (file)
@@ -42,6 +42,9 @@ public:
     static const unsigned int USESCILABINDEX;
 
     ScilabOptionsSetter(OptionsHelper & _helper, unsigned int _type) : helper(_helper), type(_type) { }
+
+    ScilabOptionsSetter(const ScilabOptionsSetter & setter) : helper(setter.helper), type(setter.type) { }
+
     ~ScilabOptionsSetter() { }
 
     virtual void set(const bool state);
index d205424..a0a516f 100644 (file)
@@ -64,7 +64,8 @@ sci_gateway/cpp/sci_jcast.cpp \
 sci_gateway/cpp/sci_jallowClassReloading.cpp \
 sci_gateway/cpp/sci_jwrapinfloat.cpp \
 sci_gateway/cpp/sci_jsetfield.cpp \
-sci_gateway/cpp/sci_jautoTranspose.cpp
+sci_gateway/cpp/sci_jautoTranspose.cpp \
+sci_gateway/cpp/sci_jconvMatrixMethod.cpp
 
 GIWS_WRAPPERS = src/jni/ScilabObjects.giws.xml
 
index ad9765d..e4dbd4e 100644 (file)
@@ -186,7 +186,8 @@ am__objects_3 =  \
        libsciexternal_objects_java_la-sci_jallowClassReloading.lo \
        libsciexternal_objects_java_la-sci_jwrapinfloat.lo \
        libsciexternal_objects_java_la-sci_jsetfield.lo \
-       libsciexternal_objects_java_la-sci_jautoTranspose.lo
+       libsciexternal_objects_java_la-sci_jautoTranspose.lo \
+       libsciexternal_objects_java_la-sci_jconvMatrixMethod.lo
 am_libsciexternal_objects_java_la_OBJECTS = $(am__objects_3) \
        $(am__objects_1)
 libsciexternal_objects_java_la_OBJECTS =  \
@@ -616,7 +617,8 @@ sci_gateway/cpp/sci_jcast.cpp \
 sci_gateway/cpp/sci_jallowClassReloading.cpp \
 sci_gateway/cpp/sci_jwrapinfloat.cpp \
 sci_gateway/cpp/sci_jsetfield.cpp \
-sci_gateway/cpp/sci_jautoTranspose.cpp
+sci_gateway/cpp/sci_jautoTranspose.cpp \
+sci_gateway/cpp/sci_jconvMatrixMethod.cpp
 
 GIWS_WRAPPERS = src/jni/ScilabObjects.giws.xml
 @GIWS_TRUE@BUILT_SOURCES = giws
@@ -774,6 +776,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jautoUnwrap.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jcast.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jcompile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jconvMatrixMethod.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jdeff.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jdisableTrace.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jenableTrace.Plo@am__quote@
@@ -1072,6 +1075,13 @@ libsciexternal_objects_java_la-sci_jautoTranspose.lo: sci_gateway/cpp/sci_jautoT
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_java_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libsciexternal_objects_java_la-sci_jautoTranspose.lo `test -f 'sci_gateway/cpp/sci_jautoTranspose.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_jautoTranspose.cpp
 
+libsciexternal_objects_java_la-sci_jconvMatrixMethod.lo: sci_gateway/cpp/sci_jconvMatrixMethod.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_java_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libsciexternal_objects_java_la-sci_jconvMatrixMethod.lo -MD -MP -MF $(DEPDIR)/libsciexternal_objects_java_la-sci_jconvMatrixMethod.Tpo -c -o libsciexternal_objects_java_la-sci_jconvMatrixMethod.lo `test -f 'sci_gateway/cpp/sci_jconvMatrixMethod.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_jconvMatrixMethod.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libsciexternal_objects_java_la-sci_jconvMatrixMethod.Tpo $(DEPDIR)/libsciexternal_objects_java_la-sci_jconvMatrixMethod.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_jconvMatrixMethod.cpp' object='libsciexternal_objects_java_la-sci_jconvMatrixMethod.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_java_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libsciexternal_objects_java_la-sci_jconvMatrixMethod.lo `test -f 'sci_gateway/cpp/sci_jconvMatrixMethod.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_jconvMatrixMethod.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index 00e6fb2..dfdbcf9 100644 (file)
@@ -40,6 +40,7 @@ EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jsetfield(char *fname, unsigned long
 EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jautoUnwrap(char *fname, unsigned long fname_len);
 EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jautoTranspose(char *fname, unsigned long fname_len);
 EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jinvoke(char *fname, unsigned long fname_len);
+EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jconvMatrixMethod(char *fname, unsigned long fname_len);
 /*--------------------------------------------------------------------------*/
 #endif /* __GW_EXTERNAL_OBJECTS_H__ */
 /*--------------------------------------------------------------------------*/
index f50afef..c204ee4 100644 (file)
@@ -41,7 +41,8 @@ static gw_generic_table Tab[] =
     {sci_jsetfield, "jsetfield"},
     {sci_jautoUnwrap, "jautoUnwrap"},
     {sci_jautoTranspose, "jautoTranspose"},
-    {sci_jinvoke, "jinvoke"}
+    {sci_jinvoke, "jinvoke"},
+    {sci_jconvMatrixMethod, "jconvMatrixMethod"}
 };
 
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/external_objects_java/sci_gateway/cpp/sci_jconvMatrixMethod.cpp b/scilab/modules/external_objects_java/sci_gateway/cpp/sci_jconvMatrixMethod.cpp
new file mode 100644 (file)
index 0000000..b2e759c
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * PIMS ( http://forge.scilab.org/index.php/p/pims ) - This file is part of PIMS
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ * Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
+ *
+ * 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 "ScilabJavaEnvironment.hxx"
+#include "ScilabGateway.hxx"
+
+extern "C" {
+#include "Scierror.h"
+#include "gw_external_objects_java.h"
+}
+
+using namespace org_scilab_modules_external_objects_java;
+using namespace org_modules_external_objects;
+
+int sci_jconvMatrixMethod(char * fname, unsigned long fname_len)
+{
+    SciErr sciErr;
+    int * addr = 0;
+    int val = 0;
+    int envId;
+    char * type = 0;
+
+    CheckInputArgument(pvApiCtx, 0, 1);
+    CheckOutputArgument(pvApiCtx, 1, 1);
+
+    envId = ScilabJavaEnvironment::start();
+    JavaOptionsSetter setter = ScilabJavaEnvironment::getInstance().getOptionsHelper().getSetter(JavaOptionsSetter::METHODOFCONV);
+    ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
+    ScilabGatewayOptions & options = env.getGatewayOptions();
+    OptionsHelper::setCopyOccurred(false);
+    ScilabObjects::initialization(env, pvApiCtx);
+    options.setIsNew(false);
+
+    if (Rhs == 0)
+    {
+        const char * order = setter.get() ? "rc" : "cr";
+        createMatrixOfString(pvApiCtx, Rhs + 1, 1, 1, &order);
+
+        LhsVar(1) = 1;
+        PutLhsVar();
+
+        return 0;
+    }
+
+    try
+    {
+        type = ScilabObjects::getSingleString(Rhs, pvApiCtx);
+    }
+    catch (const std::exception & e)
+    {
+        Scierror(999, "%s: String \"rc\" or \"cr\" expected.", fname);
+        return 0;
+    }
+
+    if (!strcmp(type, "rc"))
+    {
+        setter.set(true);
+    }
+    else if (!strcmp(type, "cr"))
+    {
+        setter.set(false);
+    }
+    else
+    {
+        Scierror(999, "%s: Invalid string: \"rc\" or \"cr\" expected.", fname);
+        return 0;
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+
+    return 0;
+}
index 7dafa3d..d2fadac 100644 (file)
@@ -52,4 +52,5 @@
     <PRIMITIVE gatewayId="72" primitiveId="21" primitiveName="jautoUnwrap" />
     <PRIMITIVE gatewayId="72" primitiveId="22" primitiveName="jautoTranspose" />
     <PRIMITIVE gatewayId="72" primitiveId="23" primitiveName="jinvoke" />
+    <PRIMITIVE gatewayId="72" primitiveId="24" primitiveName="jconvMatrixMethod" />
 </GATEWAY>
index 28d85b1..7dd18e0 100644 (file)
@@ -21,6 +21,8 @@ const unsigned int JavaOptionsSetter::SHOWPRIVATE = LAST_OPTION_INDEX + 2;
 
 JavaOptionsSetter::JavaOptionsSetter(JavaOptionsHelper & _helper, unsigned int _type) : ScilabOptionsSetter(_helper, _type) { }
 
+JavaOptionsSetter::JavaOptionsSetter(const JavaOptionsSetter & setter) : ScilabOptionsSetter(setter) { }
+
 void JavaOptionsSetter::set(const bool state)
 {
     switch (type)
index 001ee49..542eb5b 100644 (file)
@@ -33,6 +33,9 @@ public:
     static const unsigned int SHOWPRIVATE;
 
     JavaOptionsSetter(JavaOptionsHelper & _helper, unsigned int _type);
+
+    JavaOptionsSetter(const JavaOptionsSetter & setter);
+
     ~JavaOptionsSetter() { }
 
     void set(const bool state);