jautoUnwrap plugged 34/11934/2
Sylvestre Ledru [Thu, 4 Jul 2013 12:49:13 +0000 (14:49 +0200)]
Change-Id: I27a692b12a8dee89bb745a4b22b8da653015efce

scilab/modules/external_objects_java/Makefile.am
scilab/modules/external_objects_java/Makefile.in
scilab/modules/external_objects_java/TODO
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_jautoUnwrap.cpp [new file with mode: 0644]
scilab/modules/external_objects_java/sci_gateway/external_objects_java_gateway.xml
scilab/modules/external_objects_java/tests/unit_tests/jautoUnwrap.dia.ref [new file with mode: 0644]
scilab/modules/external_objects_java/tests/unit_tests/jautoUnwrap.tst [new file with mode: 0644]

index 5791bac..4b3251d 100644 (file)
@@ -53,6 +53,7 @@ sci_gateway/cpp/sci_jnewInstance.cpp \
 sci_gateway/cpp/sci_jremove.cpp \
 sci_gateway/cpp/sci_jexists.cpp \
 sci_gateway/cpp/sci_junwrap.cpp \
+sci_gateway/cpp/sci_jautoUnwrap.cpp \
 sci_gateway/cpp/sci_junwraprem.cpp \
 sci_gateway/cpp/sci_jenableTrace.cpp \
 sci_gateway/cpp/sci_jdisableTrace.cpp \
index f8f9aab..fd18f66 100644 (file)
@@ -175,6 +175,7 @@ am__objects_3 =  \
        libsciexternal_objects_java_la-sci_jremove.lo \
        libsciexternal_objects_java_la-sci_jexists.lo \
        libsciexternal_objects_java_la-sci_junwrap.lo \
+       libsciexternal_objects_java_la-sci_jautoUnwrap.lo \
        libsciexternal_objects_java_la-sci_junwraprem.lo \
        libsciexternal_objects_java_la-sci_jenableTrace.lo \
        libsciexternal_objects_java_la-sci_jdisableTrace.lo \
@@ -602,6 +603,7 @@ sci_gateway/cpp/sci_jnewInstance.cpp \
 sci_gateway/cpp/sci_jremove.cpp \
 sci_gateway/cpp/sci_jexists.cpp \
 sci_gateway/cpp/sci_junwrap.cpp \
+sci_gateway/cpp/sci_jautoUnwrap.cpp \
 sci_gateway/cpp/sci_junwraprem.cpp \
 sci_gateway/cpp/sci_jenableTrace.cpp \
 sci_gateway/cpp/sci_jdisableTrace.cpp \
@@ -761,6 +763,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-gw_external_objects_java.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jallowClassReloading.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jarray.Plo@am__quote@
+@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_jdeff.Plo@am__quote@
@@ -970,6 +973,13 @@ libsciexternal_objects_java_la-sci_junwrap.lo: sci_gateway/cpp/sci_junwrap.cpp
 @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_junwrap.lo `test -f 'sci_gateway/cpp/sci_junwrap.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_junwrap.cpp
 
+libsciexternal_objects_java_la-sci_jautoUnwrap.lo: sci_gateway/cpp/sci_jautoUnwrap.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_jautoUnwrap.lo -MD -MP -MF $(DEPDIR)/libsciexternal_objects_java_la-sci_jautoUnwrap.Tpo -c -o libsciexternal_objects_java_la-sci_jautoUnwrap.lo `test -f 'sci_gateway/cpp/sci_jautoUnwrap.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_jautoUnwrap.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libsciexternal_objects_java_la-sci_jautoUnwrap.Tpo $(DEPDIR)/libsciexternal_objects_java_la-sci_jautoUnwrap.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_jautoUnwrap.cpp' object='libsciexternal_objects_java_la-sci_jautoUnwrap.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_jautoUnwrap.lo `test -f 'sci_gateway/cpp/sci_jautoUnwrap.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_jautoUnwrap.cpp
+
 libsciexternal_objects_java_la-sci_junwraprem.lo: sci_gateway/cpp/sci_junwraprem.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_junwraprem.lo -MD -MP -MF $(DEPDIR)/libsciexternal_objects_java_la-sci_junwraprem.Tpo -c -o libsciexternal_objects_java_la-sci_junwraprem.lo `test -f 'sci_gateway/cpp/sci_junwraprem.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_junwraprem.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libsciexternal_objects_java_la-sci_junwraprem.Tpo $(DEPDIR)/libsciexternal_objects_java_la-sci_junwraprem.Plo
index 4b0055b..9fb59d9 100644 (file)
@@ -1,15 +1,16 @@
 jallowClassReloading
 jarray                   - Tests are failing
-jautoUnwrap
-jcast
 jconvMatrixMethod
 jinvoke_db
 jnull
-jsetfield
 junwraprem
 junwrap
 jvoid
 jwrapinchar
 jwrapinfloat
-jwrap                    - Other types should be managed
+jwrap
 new
+
+In the help pages, add the matching types <=> java
+
+what is long / float / char wrap  ? 
index 9e7f50a..654f4c8 100644 (file)
@@ -38,6 +38,7 @@ EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jcast(char *fname, unsigned long fna
 EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jallowClassReloading(char *fname, unsigned long fname_len);
 EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jwrapinfloat(char *fname, unsigned long fname_len);
 EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jsetfield(char *fname, unsigned long fname_len);
+EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jautoUnwrap(char *fname, unsigned long fname_len);
 /*--------------------------------------------------------------------------*/
 #endif /* __GW_EXTERNAL_OBJECTS_H__ */
 /*--------------------------------------------------------------------------*/
index 32e0055..60ea6f8 100644 (file)
@@ -39,7 +39,8 @@ static gw_generic_table Tab[] =
     {sci_jcast, "jcast"},
     {sci_jallowClassReloading, "jallowClassReloading"},
     {sci_jwrapinfloat, "jwrapinfloat"},
-    {sci_jsetfield, "jsetfield"}
+    {sci_jsetfield, "jsetfield"},
+    {sci_jautoUnwrap, "jautoUnwrap"}
 };
 
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/external_objects_java/sci_gateway/cpp/sci_jautoUnwrap.cpp b/scilab/modules/external_objects_java/sci_gateway/cpp/sci_jautoUnwrap.cpp
new file mode 100644 (file)
index 0000000..977b9c6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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_jautoUnwrap(char * fname, unsigned long fname_len)
+{
+    try
+    {
+        const int envId = ScilabJavaEnvironment::start();
+        JavaOptionsSetter setter = ScilabJavaEnvironment::getInstance().getOptionsHelper().getSetter(JavaOptionsSetter::AUTOUNWRAP);
+        return ScilabGateway::getsetOptions(fname, envId, setter, pvApiCtx);
+    }
+    catch (std::exception & e)
+    {
+        Scierror(999, "%s: An error occured: %s", fname, e.what());
+        return 0;
+    }
+}
index bb183f0..57563a7 100644 (file)
@@ -50,4 +50,5 @@
     <PRIMITIVE gatewayId="72" primitiveId="19" primitiveName="jallowClassReloading" />
     <PRIMITIVE gatewayId="72" primitiveId="20" primitiveName="jwrapinfloat" />
     <PRIMITIVE gatewayId="72" primitiveId="21" primitiveName="jsetfield" />
+    <PRIMITIVE gatewayId="72" primitiveId="22" primitiveName="jautoUnwrap" />
 </GATEWAY>
diff --git a/scilab/modules/external_objects_java/tests/unit_tests/jautoUnwrap.dia.ref b/scilab/modules/external_objects_java/tests/unit_tests/jautoUnwrap.dia.ref
new file mode 100644 (file)
index 0000000..4de8129
--- /dev/null
@@ -0,0 +1,15 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+jautoUnwrap(%t)
+assert_checktrue(jautoUnwrap());
+jautoUnwrap(%f)
+assert_checkfalse(jautoUnwrap());
+c = jcompile("Test", ["public class Test {";"public static double foo(double d) { return d; }";"}"]);
+jautoUnwrap(%f);
+assert_checkequal(typeof(c.foo(12)), "_EObj");
+jautoUnwrap(%t);
+assert_checkequal(typeof(c.foo(12)), "constant");
diff --git a/scilab/modules/external_objects_java/tests/unit_tests/jautoUnwrap.tst b/scilab/modules/external_objects_java/tests/unit_tests/jautoUnwrap.tst
new file mode 100644 (file)
index 0000000..db47b90
--- /dev/null
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+jautoUnwrap(%t)
+assert_checktrue(jautoUnwrap());
+jautoUnwrap(%f)
+assert_checkfalse(jautoUnwrap());
+
+c = jcompile("Test", ["public class Test {";"public static double foo(double d) { return d; }";"}"]);
+jautoUnwrap(%f);
+assert_checkequal(typeof(c.foo(12)), "_EObj");
+
+jautoUnwrap(%t);
+assert_checkequal(typeof(c.foo(12)), "constant");
\ No newline at end of file