src/cpp/getEnvId.cpp \
src/cpp/ScilabOptionsSetter.cpp \
src/cpp/ScilabAutoCleaner.cpp \
- src/cpp/ExternalObjectsFunction.cpp
+ src/cpp/ExternalObjectsFunction.cpp \
+ src/cpp/wrapInFloat.cpp
GATEWAY_C_SOURCES = sci_gateway/c/gw_external_objects.c
libsciexternal_objects_algo_la-getEnvId.lo \
libsciexternal_objects_algo_la-ScilabOptionsSetter.lo \
libsciexternal_objects_algo_la-ScilabAutoCleaner.lo \
- libsciexternal_objects_algo_la-ExternalObjectsFunction.lo
+ libsciexternal_objects_algo_la-ExternalObjectsFunction.lo \
+ libsciexternal_objects_algo_la-wrapInFloat.lo
am_libsciexternal_objects_algo_la_OBJECTS = $(am__objects_1) \
$(am__objects_1) $(am__objects_2)
libsciexternal_objects_algo_la_OBJECTS = \
src/cpp/getEnvId.cpp \
src/cpp/ScilabOptionsSetter.cpp \
src/cpp/ScilabAutoCleaner.cpp \
- src/cpp/ExternalObjectsFunction.cpp
+ src/cpp/ExternalObjectsFunction.cpp \
+ src/cpp/wrapInFloat.cpp
GATEWAY_C_SOURCES = sci_gateway/c/gw_external_objects.c
GATEWAY_CPP_SOURCES = sci_gateway/cpp/sci_percent_EObj_e.cpp \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_algo_la-unwrapremove.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_algo_la-wrap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_algo_la-wrapAsRef.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_algo_la-wrapInFloat.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_la-gw_external_objects.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_la-sci_doubleExclam_invoke_.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_la-sci_invoke_lu.Plo@am__quote@
@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_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libsciexternal_objects_algo_la-ExternalObjectsFunction.lo `test -f 'src/cpp/ExternalObjectsFunction.cpp' || echo '$(srcdir)/'`src/cpp/ExternalObjectsFunction.cpp
+libsciexternal_objects_algo_la-wrapInFloat.lo: src/cpp/wrapInFloat.cpp
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libsciexternal_objects_algo_la-wrapInFloat.lo -MD -MP -MF $(DEPDIR)/libsciexternal_objects_algo_la-wrapInFloat.Tpo -c -o libsciexternal_objects_algo_la-wrapInFloat.lo `test -f 'src/cpp/wrapInFloat.cpp' || echo '$(srcdir)/'`src/cpp/wrapInFloat.cpp
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libsciexternal_objects_algo_la-wrapInFloat.Tpo $(DEPDIR)/libsciexternal_objects_algo_la-wrapInFloat.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/cpp/wrapInFloat.cpp' object='libsciexternal_objects_algo_la-wrapInFloat.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_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libsciexternal_objects_algo_la-wrapInFloat.lo `test -f 'src/cpp/wrapInFloat.cpp' || echo '$(srcdir)/'`src/cpp/wrapInFloat.cpp
+
libsciexternal_objects_la-sci_percent_EObj_e.lo: sci_gateway/cpp/sci_percent_EObj_e.cpp
@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libsciexternal_objects_la-sci_percent_EObj_e.lo -MD -MP -MF $(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_e.Tpo -c -o libsciexternal_objects_la-sci_percent_EObj_e.lo `test -f 'sci_gateway/cpp/sci_percent_EObj_e.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_EObj_e.cpp
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_e.Tpo $(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_e.Plo
virtual int wrap(char ** x, int xSize, int xSizeCol, const bool isRef) const = 0;
- virtual int wrap(float * x, const bool isRef) const = 0;
+ virtual int wrapFloat(double * x, const bool isRef) const = 0;
- virtual int wrap(float * x, int xSize, const bool isRef) const = 0;
+ virtual int wrapFloat(double * x, int xSize, const bool isRef) const = 0;
- virtual int wrap(float * x, int xSize, int xSizeCol, const bool isRef) const = 0;
+ virtual int wrapFloat(double * x, int xSize, int xSizeCol, const bool isRef) const = 0;
virtual int wrapBool(int * x, const bool isRef) const = 0;
#include "ScilabAbstractEnvironmentWrapper.hxx"
#include "ScilabAbstractEnvironmentException.hxx"
+#include <iostream>
+
extern "C"
{
#include "api_scilab.h"
inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, float * ptr)
{
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot create a matrix of floats");
+ double * _ptr = alloc(pvApiCtx, position, rows, cols, (double *)0);
+ for (int i = 0; i < rows * cols; i++)
+ {
+ _ptr[i] = static_cast<double>(ptr[i]);
+ }
}
inline static float * alloc(void * pvApiCtx, const int position, const int rows, const int cols, float * ptr)
{
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot allocate a matrix of floats");
+ return (float *)alloc(pvApiCtx, position, rows, cols, (double *)0);
}
inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, double * re, double * im)
inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, long long * ptr)
{
- int * dataPtr = 0;
- alloc(pvApiCtx, position, rows, cols, dataPtr);
+ int * dataPtr = alloc(pvApiCtx, position, rows, cols, (int *)0);
for (int i = 0; i < rows * cols; i++)
{
dataPtr[i] = static_cast<int>(ptr[i]);
inline static long long * alloc(void * pvApiCtx, const int position, const int rows, const int cols, long long * ptr)
{
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot allocate a matrix of Integer64");
+ return (long long *)alloc(pvApiCtx, position, rows, cols, (int *)0);
}
inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, unsigned long long * ptr)
{
- unsigned int * dataPtr = 0;
- alloc(pvApiCtx, position, rows, cols, dataPtr);
+ unsigned int * dataPtr = alloc(pvApiCtx, position, rows, cols, (unsigned int *)0);
for (int i = 0; i < rows * cols; i++)
{
dataPtr[i] = static_cast<unsigned int>(ptr[i]);
inline static unsigned long long * alloc(void * pvApiCtx, const int position, const int rows, const int cols, unsigned long long * ptr)
{
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot allocate a matrix of UInteger64");
+ return (unsigned long long *)alloc(pvApiCtx, position, rows, cols, (unsigned int *)0);
}
#endif
}
template <typename T>
- int * allocate(const int rows, const int cols, T * dataPtr)
+ int * allocate(const int rows, const int cols, T * dataPtr) const
{
if (!rows || !cols)
{
static int wrapAsRef(char * fname, const int envId, void * pvApiCtx);
- //static int wrapInFloat(char * fname, const int envId, void * pvApiCtx);
+ static int wrapInFloat(char * fname, const int envId, void * pvApiCtx);
};
}
return wrapper.wrapBool(data, row, col, isRef);
}
+ inline static int wrapFloat(const int row, const int col, double * data, const ScilabAbstractEnvironmentWrapper & wrapper, const bool isRef)
+ {
+ if (row == 0 || col == 0)
+ {
+ return 0;
+ }
+ else if (row == 1 && col == 1)
+ {
+ return wrapper.wrapFloat(data, isRef);
+ }
+ else if (row == 1)
+ {
+ return wrapper.wrapFloat(data, col, isRef);
+ }
+
+ return wrapper.wrapFloat(data, row, col, isRef);
+ }
+
inline static int wrap(const int row, const int col, double * real, double * imag, const ScilabAbstractEnvironmentWrapper & wrapper, const bool isRef)
{
if (row == 0 || col == 0)
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET
+ *
+ * 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 "ScilabGateway.hxx"
+
+namespace org_modules_external_objects
+{
+
+int ScilabGateway::wrapInFloat(char * fname, const int envId, void * pvApiCtx)
+{
+ SciErr err;
+ int * addr = 0;
+ int idObj;
+ int type = 0;
+ double * data = 0;
+ int row, col;
+
+ if (Rhs == 0)
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong number of arguments : more than 1 argument expected."));
+ }
+
+ ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
+ ScilabGatewayOptions & options = env.getGatewayOptions();
+ OptionsHelper::setCopyOccurred(false);
+ ScilabObjects::initialization(env, pvApiCtx);
+ options.setIsNew(false);
+ const ScilabAbstractEnvironmentWrapper & wrapper = ScilabEnvironments::getEnvironment(envId).getWrapper();
+
+ CheckOutputArgument(pvApiCtx, Rhs, Rhs);
+
+ for (int i = 1; i < Rhs + 1; i++)
+ {
+ err = getVarAddressFromPosition(pvApiCtx, i, &addr);
+ if (err.iErr)
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+ }
+
+ err = getVarType(pvApiCtx, addr, &type);
+ if (err.iErr)
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data type"));
+ }
+
+ if (type != sci_matrix || isVarComplex(pvApiCtx, addr))
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("%s: Wrong argument type at position %i: Double expected\n"), fname, i);
+ }
+
+ err = getMatrixOfDouble(pvApiCtx, addr, &row, &col, &data);
+ if (err.iErr)
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+ }
+
+ idObj = ScilabObjects::wrapFloat(row, col, data, wrapper, false);
+
+ ScilabObjects::createEnvironmentObjectAtPos(EXTERNAL_OBJECT, Rhs + i, idObj, envId, pvApiCtx);
+
+ LhsVar(i) = Rhs + i;
+ }
+
+ PutLhsVar();
+
+ return 0;
+}
+}
sci_gateway/cpp/sci_jvoid.cpp \
sci_gateway/cpp/sci_jarray.cpp \
sci_gateway/cpp/sci_jcast.cpp \
-sci_gateway/cpp/sci_jallowClassReloading.cpp
+sci_gateway/cpp/sci_jallowClassReloading.cpp \
+sci_gateway/cpp/sci_jwrapinfloat.cpp
GIWS_WRAPPERS = src/jni/ScilabObjects.giws.xml
libsciexternal_objects_java_la-sci_jvoid.lo \
libsciexternal_objects_java_la-sci_jarray.lo \
libsciexternal_objects_java_la-sci_jcast.lo \
- libsciexternal_objects_java_la-sci_jallowClassReloading.lo
+ libsciexternal_objects_java_la-sci_jallowClassReloading.lo \
+ libsciexternal_objects_java_la-sci_jwrapinfloat.lo
am_libsciexternal_objects_java_la_OBJECTS = $(am__objects_3) \
$(am__objects_1)
libsciexternal_objects_java_la_OBJECTS = \
sci_gateway/cpp/sci_jvoid.cpp \
sci_gateway/cpp/sci_jarray.cpp \
sci_gateway/cpp/sci_jcast.cpp \
-sci_gateway/cpp/sci_jallowClassReloading.cpp
+sci_gateway/cpp/sci_jallowClassReloading.cpp \
+sci_gateway/cpp/sci_jwrapinfloat.cpp
GIWS_WRAPPERS = src/jni/ScilabObjects.giws.xml
@GIWS_TRUE@BUILT_SOURCES = giws
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_junwraprem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jvoid.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jwrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciexternal_objects_java_la-sci_jwrapinfloat.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@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_jallowClassReloading.lo `test -f 'sci_gateway/cpp/sci_jallowClassReloading.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_jallowClassReloading.cpp
+libsciexternal_objects_java_la-sci_jwrapinfloat.lo: sci_gateway/cpp/sci_jwrapinfloat.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_jwrapinfloat.lo -MD -MP -MF $(DEPDIR)/libsciexternal_objects_java_la-sci_jwrapinfloat.Tpo -c -o libsciexternal_objects_java_la-sci_jwrapinfloat.lo `test -f 'sci_gateway/cpp/sci_jwrapinfloat.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_jwrapinfloat.cpp
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libsciexternal_objects_java_la-sci_jwrapinfloat.Tpo $(DEPDIR)/libsciexternal_objects_java_la-sci_jwrapinfloat.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='sci_gateway/cpp/sci_jwrapinfloat.cpp' object='libsciexternal_objects_java_la-sci_jwrapinfloat.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_jwrapinfloat.lo `test -f 'sci_gateway/cpp/sci_jwrapinfloat.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_jwrapinfloat.cpp
+
mostlyclean-libtool:
-rm -f *.lo
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABGATEWAY_HXX__
-#define __SCILABGATEWAY_HXX__
-
-#include <sstream>
-
-#include "ScilabObjects.hxx"
-#include "ScilabAbstractInvoker.hxx"
-#include "ScilabAbstractMemoryAllocator.hxx"
-#include "ScilabAbstractOptionsSetter.hxx"
-#include "ScilabStream.hxx"
-#include "dynlib_external_objects_java_scilab.h"
-
-extern "C" {
-#include "MALLOC.h"
-}
-
-namespace org_modules_external_objects
-{
-
-qclass EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP ScilabGateway
-{
-
-public:
-
- static int getEnvId(char * fname, const int envId, void * pvApiCtx);
-
- static int getsetOptions(char * fname, const int envId, ScilabAbstractOptionsSetter & setter, void * pvApiCtx);
-
- static int addToClasspath(char * fname, const int envId, void * pvApiCtx);
-
- static int getClasspath(char * fname, const int envId, void * pvApiCtx);
-
- static int addNamedVariable(char * fname, const int envId, void * pvApiCtx);
-
- static int getNamedVariable(char * fname, const int envId, void * pvApiCtx);
-
- static int evalString(char * fname, const int envId, void * pvApiCtx);
-
- static int array(char * fname, const int envId, void * pvApiCtx);
-
- static int cast(char * fname, const int envId, void * pvApiCtx);
-
- static int compile(char * fname, const int envId, void * pvApiCtx);
-
- static int convMatrixMethod(char * fname, const int envId, void * pvApiCtx);
-
- static int deff(char * fname, const int envId, void * pvApiCtx);
-
- static int display(char * fname, const int envId, void * pvApiCtx);
-
- static int doubleExclam_invoke(char * fname, const int envId, void * pvApiCtx);
-
- static int classExtract(char * fname, const int envId, void * pvApiCtx);
-
- static int objectExtract(char * fname, const int envId, void * pvApiCtx);
-
- static int objectInsert(char * fname, const int envId, void * pvApiCtx);
-
- static int objectPrint(char * fname, const int envId, void * pvApiCtx);
-
- static int exists(char * fname, const int envId, void * pvApiCtx);
-
- static int getClassName(char * fname, const int envId, void * pvApiCtx);
-
- static int getEnvironmentName(char * fname, const int envId, void * pvApiCtx);
-
- static int getEnvironmentInfos(char * fname, const int envId, void * pvApiCtx);
-
- static int getField(char * fname, const int envId, void * pvApiCtx);
-
- static int getFields(char * fname, const int envId, void * pvApiCtx);
-
- static int getMethods(char * fname, const int envId, void * pvApiCtx);
-
- static int getRepresentation(char * fname, const int envId, void * pvApiCtx);
-
- static int import(char * fname, const int envId, void * pvApiCtx);
-
- static int operation(char * fname, const int envId, const OperatorsType type, void * pvApiCtx);
-
- static int invoke(char * fname, const int envId, void * pvApiCtx);
-
- static int invoke(char * fname, const int envId, ScilabAbstractInvoker & invoker, void * pvApiCtx);
-
- static int invoke_lu(char * fname, const int envId, void * pvApiCtx);
-
- static int trace(char * fname, const int envId, void * pvApiCtx);
-
- static int newInstance(char * fname, const int envId, void * pvApiCtx);
-
- static int remove(char * fname, const int envId, void * pvApiCtx);
-
- static int setField(char * fname, const int envId, void * pvApiCtx);
-
- static int unwrap(char * fname, const int envId, void * pvApiCtx);
-
- static int unwrapremove(char * fname, const int envId, void * pvApiCtx);
-
- //static int unwrapAndRemove(char * fname, const int envId, void * pvApiCtx);
-
- static int wrap(char * fname, const int envId, void * pvApiCtx);
-
- static int wrapAsRef(char * fname, const int envId, void * pvApiCtx);
-
- //static int wrapInFloat(char * fname, const int envId, void * pvApiCtx);
-};
-}
-
-#endif // __SCILABGATEWAY_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __EXTERNALOBJECTS_H__
-#define __EXTERNALOBJECTS_H__
-
-#define __USE_DEPRECATED_STACK_FUNCTIONS__
-
-//#define EODEBUG
-
-#define FIELDS_LENGTH 3
-
-#define VOID_OBJECT -1
-
-#define EXTERNAL_INVALID -1
-#define EXTERNAL_OBJECT 0
-#define EXTERNAL_CLASS 1
-#define EXTERNAL_VOID 2
-
-#define EXTERNAL_ENV_ID_POSITION 2
-#define EXTERNAL_OBJ_ID_POSITION 3
-
-#define SAE_NOTHING 0
-#define SAE_NULL 1
-#define SAE_SINGLE_DOUBLE 2
-#define SAE_ROW_DOUBLE 3
-#define SAE_MAT_DOUBLE 4
-#define SAE_SINGLE_STRING 5
-#define SAE_ROW_STRING 6
-#define SAE_MAT_STRING 7
-#define SAE_SINGLE_BOOLEAN 8
-#define SAE_ROW_BOOLEAN 9
-#define SAE_MAT_BOOLEAN 10
-#define SAE_SINGLE_CHAR 11
-#define SAE_ROW_CHAR 12
-#define SAE_MAT_CHAR 13
-#define SAE_SINGLE_UCHAR 14
-#define SAE_ROW_UCHAR 15
-#define SAE_MAT_UCHAR 16
-#define SAE_SINGLE_SHORT 17
-#define SAE_ROW_SHORT 18
-#define SAE_MAT_SHORT 19
-#define SAE_SINGLE_USHORT 20
-#define SAE_ROW_USHORT 21
-#define SAE_MAT_USHORT 22
-#define SAE_SINGLE_INT 23
-#define SAE_ROW_INT 24
-#define SAE_MAT_INT 25
-#define SAE_SINGLE_UINT 26
-#define SAE_ROW_UINT 27
-#define SAE_MAT_UINT 28
-#define SAE_SINGLE_LONG 29
-#define SAE_ROW_LONG 30
-#define SAE_MAT_LONG 31
-#define SAE_SINGLE_ULONG 32
-#define SAE_ROW_ULONG 33
-#define SAE_MAT_ULONG 34
-#define SAE_SINGLE_FLOAT 35
-#define SAE_ROW_FLOAT 36
-#define SAE_MAT_FLOAT 37
-#define SAE_SINGLE_COMPLEX 38
-#define SAE_ROW_COMPLEX 39
-#define SAE_MAT_COMPLEX 40
-
-typedef enum { Nothing = SAE_NOTHING, Null = SAE_NULL,
- SingleDouble = SAE_SINGLE_DOUBLE, RowDouble = SAE_ROW_DOUBLE, MatDouble = SAE_MAT_DOUBLE,
- SingleString = SAE_SINGLE_STRING, RowString = SAE_ROW_STRING, MatString = SAE_MAT_STRING,
- SingleBoolean = SAE_SINGLE_BOOLEAN, RowBoolean = SAE_ROW_BOOLEAN, MatBoolean = SAE_MAT_BOOLEAN,
- SingleChar = SAE_SINGLE_CHAR, RowChar = SAE_ROW_CHAR, MatChar = SAE_MAT_CHAR,
- SingleUChar = SAE_SINGLE_UCHAR, RowUChar = SAE_ROW_UCHAR, MatUChar = SAE_MAT_UCHAR,
- SingleShort = SAE_SINGLE_SHORT, RowShort = SAE_ROW_SHORT, MatShort = SAE_MAT_SHORT,
- SingleUShort = SAE_SINGLE_USHORT, RowUShort = SAE_ROW_USHORT, MatUShort = SAE_MAT_USHORT,
- SingleInt = SAE_SINGLE_INT, RowInt = SAE_ROW_INT, MatInt = SAE_MAT_INT,
- SingleUInt = SAE_SINGLE_UINT, RowUInt = SAE_ROW_UINT, MatUInt = SAE_MAT_UINT,
- SingleLong = SAE_SINGLE_LONG, RowLong = SAE_ROW_LONG, MatLong = SAE_MAT_LONG,
- SingleULong = SAE_SINGLE_ULONG, RowULong = SAE_ROW_ULONG, MatULong = SAE_MAT_ULONG,
- SingleFloat = SAE_SINGLE_FLOAT, RowFloat = SAE_ROW_FLOAT, MatFloat = SAE_MAT_FLOAT,
- SingleComplex = SAE_SINGLE_COMPLEX, RowComplex = SAE_ROW_COMPLEX, MatComplex = SAE_MAT_COMPLEX
- } VariableType;
-
-#define SAE_TRANSP 0
-#define SAE_ADD 1
-#define SAE_SUB 2
-#define SAE_MUL 3
-#define SAE_DIV 4
-#define SAE_BACKSLASH 5
-#define SAE_POW 6
-#define SAE_DOT_MUL 7
-#define SAE_DOT_DIV 8
-#define SAE_DOT_BACKSLASH 9
-#define SAE_DOT_MUL_DOT 10
-#define SAE_DOT_DIV_DOT 11
-#define SAE_DOT_BACKSLASH_DOT 12
-#define SAE_EQ 13
-#define SAE_NEQ 14
-#define SAE_OR 15
-#define SAE_AND 16
-#define SAE_DOT_POW 17
-#define SAE_NOT 18
-#define SAE_DOT_TRANSP 19
-#define SAE_LT 20
-#define SAE_GT 21
-#define SAE_LEQ 22
-#define SAE_GEQ 23
-
-typedef enum { Transp = SAE_TRANSP, Add = SAE_ADD, Sub = SAE_SUB, Mul = SAE_MUL, Div = SAE_DIV, Backslash = SAE_BACKSLASH,
- Pow = SAE_POW, DotMul = SAE_DOT_MUL, DotDiv = SAE_DOT_DIV, DotBackslash = SAE_DOT_BACKSLASH,
- DotMulDot = SAE_DOT_MUL_DOT, DotDivDot = SAE_DOT_DIV_DOT, DotBackslashDot = SAE_DOT_BACKSLASH_DOT, Eq = SAE_EQ,
- Neq = SAE_NEQ, Or = SAE_OR, And = SAE_AND, DotPow = SAE_DOT_POW, Not = SAE_NOT, DotTransp = SAE_DOT_TRANSP,
- Lt = SAE_LT, Gt = SAE_GT, Leq = SAE_LEQ, Geq = SAE_GEQ
- } OperatorsType;
-
-#endif //__EXTERNALOBJECTS_H__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __EXTERNALOBJECTSFUNCTION_H__
-#define __EXTERNALOBJECTSFUNCTION_H__
-
-#include "dynlib_external_objects_java_scilab.h"
-
-EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP void ExternalObjects_goDown();
-
-#endif // __EXTERNALOBJECTSFUNCTION_H__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2011 - Igor GRIDCHYN
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABABSTRACTINVOKER_HXX__
-#define __SCILABABSTRACTINVOKER_HXX__
-
-namespace org_modules_external_objects
-{
-class ScilabAbstractInvoker
-{
-
-public:
-
- virtual int invoke(int * args, int argsSize) = 0;
-};
-
-}
-
-#endif // __SCILABABSTRACTINVOKER_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABABSTRACTMEMORYALLOCATOR_H__
-#define __SCILABABSTRACTMEMORYALLOCATOR_H__
-
-#include "ScilabAbstractEnvironmentWrapper.hxx"
-#include "ScilabAbstractEnvironmentException.hxx"
-
-namespace org_modules_external_objects
-{
-
-class ComplexDataPointers
-{
-public:
-
- ComplexDataPointers(double * _realPtr, double * _imagPtr) : realPtr(_realPtr), imagPtr(_imagPtr) { }
- ComplexDataPointers() : realPtr(0), imagPtr(0) { }
- ~ComplexDataPointers() { }
-
- double * const realPtr;
- double * const imagPtr;
-};
-
-class ScilabStackAllocator
-{
-
-public:
-
- ScilabStackAllocator(void * _pvApiCtx, int _position) : pvApiCtx(_pvApiCtx), position(_position) { }
-
- ~ScilabStackAllocator() { }
-
-protected:
-
- int position;
- void * pvApiCtx;
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, double * ptr)
- {
- SciErr err = createMatrixOfDouble(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static double * alloc(void * pvApiCtx, const int position, const int rows, const int cols, double * ptr)
- {
- double * _ptr = 0;
- SciErr err = allocMatrixOfDouble(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, float * ptr)
- {
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot create a matrix of floats");
- }
-
- inline static float * alloc(void * pvApiCtx, const int position, const int rows, const int cols, float * ptr)
- {
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot allocate a matrix of floats");
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, double * re, double * im)
- {
- SciErr err = createComplexMatrixOfDouble(pvApiCtx, position, rows, cols, re, im);
- checkError(err);
- }
-
- inline static ComplexDataPointers alloc(void * pvApiCtx, const int position, const int rows, const int cols, double * re, double * im)
- {
- double * _re = 0, * _im = 0;
- SciErr err = allocComplexMatrixOfDouble(pvApiCtx, position, rows, cols, &_re, &_im);
- checkError(err);
-
- return ComplexDataPointers(_re, _im);
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, char * ptr)
- {
- SciErr err = createMatrixOfInteger8(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static char * alloc(void * pvApiCtx, const int position, const int rows, const int cols, char * ptr)
- {
- char * _ptr = 0;
- SciErr err = allocMatrixOfInteger8(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, unsigned char * ptr)
- {
- SciErr err = createMatrixOfUnsignedInteger8(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static unsigned char * alloc(void * pvApiCtx, const int position, const int rows, const int cols, unsigned char * ptr)
- {
- unsigned char * _ptr = 0;
- SciErr err = allocMatrixOfUnsignedInteger8(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, short * ptr)
- {
- SciErr err = createMatrixOfInteger16(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static short * alloc(void * pvApiCtx, const int position, const int rows, const int cols, short * ptr)
- {
- short * _ptr = 0;
- SciErr err = allocMatrixOfInteger16(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, unsigned short * ptr)
- {
- SciErr err = createMatrixOfUnsignedInteger16(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static unsigned short * alloc(void * pvApiCtx, const int position, const int rows, const int cols, unsigned short * ptr)
- {
- unsigned short * _ptr = 0;
- SciErr err = allocMatrixOfUnsignedInteger16(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, int * ptr)
- {
- SciErr err = createMatrixOfInteger32(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static int * alloc(void * pvApiCtx, const int position, const int rows, const int cols, int * ptr)
- {
- int * _ptr = 0;
- SciErr err = allocMatrixOfInteger32(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, unsigned int * ptr)
- {
- SciErr err = createMatrixOfUnsignedInteger32(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static unsigned int * alloc(void * pvApiCtx, const int position, const int rows, const int cols, unsigned int * ptr)
- {
- unsigned int * _ptr = 0;
- SciErr err = allocMatrixOfUnsignedInteger32(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
-#ifdef __SCILAB_INT64__
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, long long * ptr)
- {
- SciErr err = createMatrixOfInteger64(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static long long * alloc(void * pvApiCtx, const int position, const int rows, const int cols, long long * ptr)
- {
- long long * _ptr = 0;
- SciErr err = allocMatrixOfInteger64(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, unsigned long long * ptr)
- {
- SciErr err = createMatrixOfUnsignedIntege64(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static unsigned long long * alloc(void * pvApiCtx, const int position, const int rows, const int cols, unsigned long long * ptr)
- {
- unsigned long long * _ptr = 0;
- SciErr err = allocMatrixOfUnsignedInteger64(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return_ ptr;
- }
-
-#else
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, long long * ptr)
- {
- int * dataPtr = 0;
- alloc(pvApiCtx, position, rows, cols, dataPtr);
- for (int i = 0; i < rows * cols; i++)
- {
- dataPtr[i] = static_cast<int>(ptr[i]);
- }
- }
-
- inline static long long * alloc(void * pvApiCtx, const int position, const int rows, const int cols, long long * ptr)
- {
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot allocate a matrix of Integer64");
- }
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, unsigned long long * ptr)
- {
- unsigned int * dataPtr = 0;
- alloc(pvApiCtx, position, rows, cols, dataPtr);
- for (int i = 0; i < rows * cols; i++)
- {
- dataPtr[i] = static_cast<unsigned int>(ptr[i]);
- }
- }
-
- inline static unsigned long long * alloc(void * pvApiCtx, const int position, const int rows, const int cols, unsigned long long * ptr)
- {
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot allocate a matrix of UInteger64");
- }
-
-#endif
-
- inline static void create(void * pvApiCtx, const int position, const int rows, const int cols, char ** ptr)
- {
- SciErr err = createMatrixOfString(pvApiCtx, position, rows, cols, const_cast<const char * const *>(ptr));
- checkError(err);
- }
-
- inline static char ** alloc(void * pvApiCtx, const int position, const int rows, const int cols, char ** ptr)
- {
- throw ScilabAbstractEnvironmentException("Invalid operation: cannot allocate a matrix of String");
- }
-
- inline static void createBool(void * pvApiCtx, const int position, const int rows, const int cols, int * ptr)
- {
- SciErr err = createMatrixOfBoolean(pvApiCtx, position, rows, cols, ptr);
- checkError(err);
- }
-
- inline static int * allocBool(void * pvApiCtx, const int position, const int rows, const int cols, int * ptr)
- {
- int * _ptr = 0;
- SciErr err = allocMatrixOfBoolean(pvApiCtx, position, rows, cols, &_ptr);
- checkError(err);
-
- return _ptr;
- }
-
-
-private:
-
- inline static void checkError(const SciErr & err)
- {
- if (err.iErr)
- {
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Cannot allocate memory");
- }
- }
-
-};
-
-template <typename T>
-class ScilabSingleTypeStackAllocator : public ScilabStackAllocator
-{
-
-public:
-
- ScilabSingleTypeStackAllocator(void * _pvApiCtx, int _position) : ScilabStackAllocator(_pvApiCtx, _position) { }
-
- ~ScilabSingleTypeStackAllocator() { }
-
- virtual T * allocate(const int rows, const int cols, T * dataPtr) const
- {
- if (!rows || !cols)
- {
- createEmptyMatrix(pvApiCtx, position);
- return 0;
- }
-
- if (dataPtr)
- {
- create(pvApiCtx, position, rows, cols, dataPtr);
- return 0;
- }
- else
- {
- return alloc(pvApiCtx, position, rows, cols, dataPtr);
- }
- }
-};
-
-typedef ScilabSingleTypeStackAllocator<double> ScilabDoubleStackAllocator;
-typedef ScilabSingleTypeStackAllocator<char *> ScilabStringStackAllocator;
-typedef ScilabSingleTypeStackAllocator<char> ScilabCharStackAllocator;
-typedef ScilabSingleTypeStackAllocator<unsigned char> ScilabUCharStackAllocator;
-typedef ScilabSingleTypeStackAllocator<short> ScilabShortStackAllocator;
-typedef ScilabSingleTypeStackAllocator<unsigned short> ScilabUShortStackAllocator;
-typedef ScilabSingleTypeStackAllocator<int> ScilabIntStackAllocator;
-typedef ScilabSingleTypeStackAllocator<unsigned int> ScilabUIntStackAllocator;
-typedef ScilabSingleTypeStackAllocator<long long> ScilabLongStackAllocator;
-typedef ScilabSingleTypeStackAllocator<unsigned long long> ScilabULongStackAllocator;
-typedef ScilabSingleTypeStackAllocator<float> ScilabFloatStackAllocator;
-
-class ScilabComplexStackAllocator : public ScilabStackAllocator
-{
-
-public:
-
- ScilabComplexStackAllocator(void * _pvApiCtx, int _position) : ScilabStackAllocator(_pvApiCtx, _position) { }
-
- ~ScilabComplexStackAllocator() { }
-
- ComplexDataPointers allocate(const int rows, const int cols, double * realPtr, double * imagPtr) const
- {
- if (!rows || !cols)
- {
- createEmptyMatrix(pvApiCtx, position);
- return ComplexDataPointers();
- }
-
- if (realPtr && imagPtr)
- {
- create(pvApiCtx, position, rows, cols, realPtr, imagPtr);
- return ComplexDataPointers();
- }
- else
- {
- return alloc(pvApiCtx, position, rows, cols, realPtr, imagPtr);
- }
- }
-};
-
-class ScilabBooleanStackAllocator : public ScilabSingleTypeStackAllocator<int>
-{
-
-public:
-
- ScilabBooleanStackAllocator(void * _pvApiCtx, int _position) : ScilabSingleTypeStackAllocator<int>(_pvApiCtx, _position) { }
-
- ~ScilabBooleanStackAllocator() { }
-
- int * allocate(const int rows, const int cols, int * dataPtr) const
- {
- if (!rows || !cols)
- {
- createEmptyMatrix(pvApiCtx, position);
- return 0;
- }
-
- if (dataPtr)
- {
- createBool(pvApiCtx, position, rows, cols, dataPtr);
- return 0;
- }
- else
- {
- return allocBool(pvApiCtx, position, rows, cols, dataPtr);
- }
- }
-
- template <typename T>
- int * allocate(const int rows, const int cols, T * dataPtr)
- {
- if (!rows || !cols)
- {
- createEmptyMatrix(pvApiCtx, position);
- return 0;
- }
-
- if (dataPtr)
- {
- int * ptr = 0;
- allocBool(pvApiCtx, position, rows, cols, ptr);
- for (int i = 0; i < rows * cols; i++)
- {
- ptr[i] = static_cast<int>(dataPtr[i]);
- }
-
- return 0;
- }
- else
- {
- throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, "Invalid operation: cannot allocate a matrix of Boolean");
- }
- }
-};
-
-}
-
-#endif // __SCILABABSTRACTMEMORYALLOCATOR_H__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABABSTRACTOPTIONSSETTER_HXX__
-#define __SCILABABSTRACTOPTIONSSETTER_HXX__
-
-namespace org_modules_external_objects
-{
-
-class ScilabAbstractOptionsSetter
-{
-
-public:
-
- virtual void set(const bool state) = 0;
-
- virtual bool get() const = 0;
-
-};
-}
-
-#endif //__SCILABABSTRACTOPTIONSSETTER_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABAUTOCLEANER_HXX__
-#define __SCILABAUTOCLEANER_HXX__
-
-#include <algorithm>
-#include <set>
-#include <stack>
-#include <map>
-
-#include "ScilabEnvironments.hxx"
-#include "ScilabAbstractEnvironment.hxx"
-#include "ScilabObjects.hxx"
-#include "dynlib_external_objects_java_scilab.h"
-
-extern "C" {
-#include "api_scilab.h"
-#include "stack-c.h"
-}
-
-namespace org_modules_external_objects
-{
-
-typedef std::map<int, std::set<int> > _MapIds;
-
-class EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP ScilabAutoCleaner
-{
- static std::stack< _MapIds > stack;
-
-public:
- static void goDown();
- static void registerVariable(const int envId, const int varId);
- static void unregisterVariable(const int envId, const int varId);
-
-private:
- static _MapIds getAllObjectsAtCurrentLevel(void * pvApiCtx);
- static void removeUnusedObjects(const _MapIds & current, const _MapIds & previous, void * pvApiCtx);
-};
-}
-
-#endif // __SCILABAUTOCLEANER_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABENVIRONMENTS_HXX__
-#define __SCILABENVIRONMENTS_HXX__
-
-#pragma warning(disable: 4251)
-
-#include <vector>
-
-#include "ScilabAbstractEnvironmentException.hxx"
-#include "ScilabAbstractEnvironment.hxx"
-#include "dynlib_external_objects_java_scilab.h"
-
-extern "C" {
-#include "localization.h"
-}
-
-namespace org_modules_external_objects
-{
-
-class EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP ScilabEnvironments
-{
- static std::vector<ScilabAbstractEnvironment*> environments;
-
-public:
-
- static int registerScilabEnvironment(ScilabAbstractEnvironment * env);
-
- static void unregisterScilabEnvironment(const int id);
-
- static ScilabAbstractEnvironment & getEnvironment(const int id);
-};
-
-}
-
-#endif // __SCILABENVIRONMENTS_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABGATEWAY_HXX__
-#define __SCILABGATEWAY_HXX__
-
-#include <sstream>
-
-#include "ScilabObjects.hxx"
-#include "ScilabAbstractInvoker.hxx"
-#include "ScilabAbstractMemoryAllocator.hxx"
-#include "ScilabAbstractOptionsSetter.hxx"
-#include "ScilabStream.hxx"
-#include "dynlib_external_objects_java_scilab.h"
-
-extern "C" {
-#include "MALLOC.h"
-}
-
-namespace org_modules_external_objects
-{
-
-class EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP ScilabGateway
-{
-
-public:
-
- static int getEnvId(char * fname, const int envId, void * pvApiCtx);
-
- static int getsetOptions(char * fname, const int envId, ScilabAbstractOptionsSetter & setter, void * pvApiCtx);
-
- static int addToClasspath(char * fname, const int envId, void * pvApiCtx);
-
- static int getClasspath(char * fname, const int envId, void * pvApiCtx);
-
- static int addNamedVariable(char * fname, const int envId, void * pvApiCtx);
-
- static int getNamedVariable(char * fname, const int envId, void * pvApiCtx);
-
- static int evalString(char * fname, const int envId, void * pvApiCtx);
-
- static int array(char * fname, const int envId, void * pvApiCtx);
-
- static int cast(char * fname, const int envId, void * pvApiCtx);
-
- static int compile(char * fname, const int envId, void * pvApiCtx);
-
- static int convMatrixMethod(char * fname, const int envId, void * pvApiCtx);
-
- static int deff(char * fname, const int envId, void * pvApiCtx);
-
- static int display(char * fname, const int envId, void * pvApiCtx);
-
- static int doubleExclam_invoke(char * fname, const int envId, void * pvApiCtx);
-
- static int classExtract(char * fname, const int envId, void * pvApiCtx);
-
- static int objectExtract(char * fname, const int envId, void * pvApiCtx);
-
- static int objectInsert(char * fname, const int envId, void * pvApiCtx);
-
- static int objectPrint(char * fname, const int envId, void * pvApiCtx);
-
- static int exists(char * fname, const int envId, void * pvApiCtx);
-
- static int getClassName(char * fname, const int envId, void * pvApiCtx);
-
- static int getEnvironmentName(char * fname, const int envId, void * pvApiCtx);
-
- static int getEnvironmentInfos(char * fname, const int envId, void * pvApiCtx);
-
- static int getField(char * fname, const int envId, void * pvApiCtx);
-
- static int getFields(char * fname, const int envId, void * pvApiCtx);
-
- static int getMethods(char * fname, const int envId, void * pvApiCtx);
-
- static int getRepresentation(char * fname, const int envId, void * pvApiCtx);
-
- static int import(char * fname, const int envId, void * pvApiCtx);
-
- static int operation(char * fname, const int envId, const OperatorsType type, void * pvApiCtx);
-
- static int invoke(char * fname, const int envId, void * pvApiCtx);
-
- static int invoke(char * fname, const int envId, ScilabAbstractInvoker & invoker, void * pvApiCtx);
-
- static int invoke_lu(char * fname, const int envId, void * pvApiCtx);
-
- static int trace(char * fname, const int envId, void * pvApiCtx);
-
- static int newInstance(char * fname, const int envId, void * pvApiCtx);
-
- static int remove(char * fname, const int envId, void * pvApiCtx);
-
- static int setField(char * fname, const int envId, void * pvApiCtx);
-
- static int unwrap(char * fname, const int envId, void * pvApiCtx);
-
- static int unwrapremove(char * fname, const int envId, void * pvApiCtx);
-
- //static int unwrapAndRemove(char * fname, const int envId, void * pvApiCtx);
-
- static int wrap(char * fname, const int envId, void * pvApiCtx);
-
- static int wrapAsRef(char * fname, const int envId, void * pvApiCtx);
-
- //static int wrapInFloat(char * fname, const int envId, void * pvApiCtx);
-};
-}
-
-#endif // __SCILABGATEWAY_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABGATEWAYOPTIONS_HXX__
-#define __SCILABGATEWAYOPTIONS_HXX__
-
-namespace org_modules_external_objects
-{
-
-class ScilabGatewayOptions
-{
-
- int objId;
- bool isNew;
- const char * methodName;
-
-public:
-
- ScilabGatewayOptions() : objId(0), isNew(false), methodName(0) { }
-
- ~ScilabGatewayOptions() { }
-
- void setObjId(const int _objId)
- {
- objId = _objId;
- }
-
- int getObjId() const
- {
- return objId;
- }
-
- void setIsNew(const bool _isNew)
- {
- isNew = _isNew;
- }
-
- bool getIsNew() const
- {
- return isNew;
- }
-
- void setMethodName(const char * _methodName)
- {
- if (methodName)
- {
- freeAllocatedSingleString(const_cast<char *>(methodName));
- }
- methodName = _methodName;
- }
-
- const char * getMethodName() const
- {
- return methodName;
- }
-
-};
-}
-
-#endif // __SCILABGATEWAYOPTIONS_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABOBJECTS_HXX__
-#define __SCILABOBJECTS_HXX__
-
-#include <string.h>
-
-#include "ExternalObjects.h"
-#include "ScilabAbstractEnvironment.hxx"
-#include "ScilabEnvironments.hxx"
-#include "OptionsHelper.hxx"
-#include "dynlib_external_objects_java_scilab.h"
-
-namespace org_modules_external_objects
-{
-class EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP ScilabObjects
-{
- static bool isInit;
- static const char * _EOBJ[];
- static const char * _ECLASS[];
- static const char * _EVOID[];
- static const char * _INVOKE_;
-
-public:
-
- static void initialization(ScilabAbstractEnvironment & env, void * pvApiCtx);
-
- static int createNamedEnvironmentObject(int type, const char * name, int id, const int envId, void * pvApiCtx);
-
- static void createEnvironmentObjectAtPos(int type, int pos, int id, const int envId, void * pvApiCtx);
-
- static void copyInvocationMacroToStack(int pos, ScilabAbstractEnvironment & env, void * pvApiCtx);
-
- static void removeTemporaryVars(const int envId, int * tmpvar);
-
- static void removeVar(int * addr, void * pvApiCtx);
-
- static bool unwrap(int idObj, int pos, const int envId, void * pvApiCtx);
-
- static int getMListType(int * mlist, void * pvApiCtx);
-
- static bool isValidExternal(int * mlist, void * pvApiCtx);
-
- static bool isExternalObj(int * mlist, void * pvApiCtx);
-
- static bool isExternalClass(int * mlist, void * pvApiCtx);
-
- static bool isExternalVoid(int * mlist, void * pvApiCtx);
-
- static bool isExternalObjOrClass(int * mlist, void * pvApiCtx);
-
- static char * getSingleString(int pos, void * pvApiCtx);
-
- static int isPositiveIntegerAtAddress(int * addr, void * pvApiCtx);
-
- static int getEnvironmentId(int * addr, void * pvApiCtx);
-
- static int getExternalId(int * addr, void * pvApiCtx);
-
- static int getArgumentId(int * addr, int * tmpvars, const bool isRef, const bool isClass, const int envId, void * pvApiCtx);
-
- template <typename T>
- inline static int wrap(const int row, const int col, T * data, const ScilabAbstractEnvironmentWrapper & wrapper, const bool isRef)
- {
- if (row == 0 || col == 0)
- {
- return 0;
- }
- else if (row == 1 && col == 1)
- {
- return wrapper.wrap(data, isRef);
- }
- else if (row == 1)
- {
- return wrapper.wrap(data, col, isRef);
- }
-
- return wrapper.wrap(data, row, col, isRef);
- }
-
- inline static int wrapBool(const int row, const int col, int * data, const ScilabAbstractEnvironmentWrapper & wrapper, const bool isRef)
- {
- if (row == 0 || col == 0)
- {
- return 0;
- }
- else if (row == 1 && col == 1)
- {
- return wrapper.wrapBool(data, isRef);
- }
- else if (row == 1)
- {
- return wrapper.wrapBool(data, col, isRef);
- }
-
- return wrapper.wrapBool(data, row, col, isRef);
- }
-
- inline static int wrap(const int row, const int col, double * real, double * imag, const ScilabAbstractEnvironmentWrapper & wrapper, const bool isRef)
- {
- if (row == 0 || col == 0)
- {
- return 0;
- }
- else if (row == 1 && col == 1)
- {
- return wrapper.wrap(real, imag, isRef);
- }
- else if (row == 1)
- {
- return wrapper.wrap(real, imag, col, isRef);
- }
-
- return wrapper.wrap(real, imag, row, col, isRef);
- }
-};
-}
-
-#endif // __SCILABOBJECTS_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABOPTIONSSETTER_HXX__
-#define __SCILABOPTIONSSETTER_HXX__
-
-#include "ScilabAbstractOptionsSetter.hxx"
-#include "dynlib_external_objects_java_scilab.h"
-
-#define LAST_OPTION_INDEX 4
-
-namespace org_modules_external_objects
-{
-
-class OptionsHelper;
-
-class EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP ScilabOptionsSetter : public ScilabAbstractOptionsSetter
-{
-
-protected:
-
- OptionsHelper & helper;
- unsigned int type;
-
-public:
-
- static const unsigned int METHODOFCONV;
- static const unsigned int ALLOWRELOAD;
- static const unsigned int AUTOUNWRAP;
- static const unsigned int USECOPY;
- static const unsigned int USESCILABINDEX;
-
- ScilabOptionsSetter(OptionsHelper & _helper, unsigned int _type) : helper(_helper), type(_type) { }
- ~ScilabOptionsSetter() { }
-
- virtual void set(const bool state);
-
- virtual bool get() const;
-};
-}
-
-#endif //__SCILABOPTIONSSETTER_HXX__
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
- *
- * 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 __SCILABSTREAM_HXX__
-#define __SCILABSTREAM_HXX__
-
-extern "C" {
-#include "sciprint.h"
-}
-
-#include <sstream>
-
-namespace org_modules_external_objects
-{
-
-class ScilabStream : virtual public std::ostream
-{
-
- class MyStringBuf : public std::stringbuf
- {
-
- public:
-
- MyStringBuf() { }
- virtual ~MyStringBuf() { }
-
- virtual int sync()
- {
- int ret = std::stringbuf::sync();
- if (!ret && str().size() != 0)
- {
- sciprint("%s", str().c_str());
- str("");
- }
-
- return ret;
- }
- };
-
-public:
- ScilabStream() : std::ostream(new MyStringBuf()) { }
- virtual ~ScilabStream()
- {
- flush();
- }
-};
-}
-
-#endif //__SCILABSTREAM_HXX__
EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jarray(char *fname, unsigned long fname_len);
EXTERNAL_OBJECTS_JAVA_SCILAB_IMPEXP int sci_jcast(char *fname, unsigned long fname_len);
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);
/*--------------------------------------------------------------------------*/
#endif /* __GW_EXTERNAL_OBJECTS_H__ */
/*--------------------------------------------------------------------------*/
{sci_jvoid, "jvoid"},
{sci_jarray, "jarray"},
{sci_jcast, "jcast"},
- {sci_jallowClassReloading, "jallowClassReloading"}
+ {sci_jallowClassReloading, "jallowClassReloading"},
+ {sci_jwrapinfloat, "jwrapinfloat"}
};
/*--------------------------------------------------------------------------*/
--- /dev/null
+/*
+ * PIMS ( http://forge.scilab.org/index.php/p/pims ) - This file is part of PIMS
+ * Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET
+ *
+ * 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_jwrapinfloat(char * fname, unsigned long fname_len)
+{
+ try
+ {
+ const int envId = ScilabJavaEnvironment::start();
+ return ScilabGateway::wrapInFloat(fname, envId, pvApiCtx);
+ }
+ catch (std::exception & e)
+ {
+ Scierror(999, "%s: An error occured: %s", fname, e.what());
+ return 0;
+ }
+}
<PRIMITIVE gatewayId="72" primitiveId="17" primitiveName="jarray" />
<PRIMITIVE gatewayId="72" primitiveId="18" primitiveName="jcast" />
<PRIMITIVE gatewayId="72" primitiveId="19" primitiveName="jallowClassReloading" />
+ <PRIMITIVE gatewayId="72" primitiveId="20" primitiveName="jwrapinfloat" />
</GATEWAY>
#endif
#include "ScilabJavaEnvironmentWrapper.hxx"
-#include "ScilabJavaObject.hxx"
extern "C" {
#include "getScilabJavaVM.h"
VariableType ScilabJavaEnvironmentWrapper::isunwrappable(int id) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
int type = ScilabJavaObject::isUnwrappable(vm, id);
+
return (VariableType)type;
}
-// template <class T>
-// int ScilabJavaEnvironmentWrapper::wrap(T* x, const bool isRef) const
-// {
-// JavaVM *vm = getScilabJavaVM ();
-// return ScilabJavaObject::wrapDouble(vm, x, isRef);
-// }
-
-
int ScilabJavaEnvironmentWrapper::wrap(double * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapDouble(vm, *x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x);
}
int ScilabJavaEnvironmentWrapper::wrap(double * x, int xSize, const bool isRef) const
{
- // return wrapData<double>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(double * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<double>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x, xSize, xSizeCol);
}
int ScilabJavaEnvironmentWrapper::wrap(double * re, double * im, const bool isRef) const
int ScilabJavaEnvironmentWrapper::wrap(char * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapChar(vm, *x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap<char>(vm, x);
}
int ScilabJavaEnvironmentWrapper::wrap(char * x, int xSize, const bool isRef) const
{
- // return wrapData<char>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (byte *)x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(char * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<char>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (byte *)x, xSize, xSizeCol);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned char * x, const bool isRef) const
{
- // return wrapData<unsigned char>(x, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (byte *)x);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned char * x, int xSize, const bool isRef) const
{
- // return wrapData<unsigned char>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (byte *)x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned char * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<unsigned char>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (byte *)x, xSize, xSizeCol);
}
int ScilabJavaEnvironmentWrapper::wrap(short * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapShort(vm, *x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x);
}
int ScilabJavaEnvironmentWrapper::wrap(short * x, int xSize, const bool isRef) const
{
- // return wrapData<short>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(short * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<short>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x, xSize, xSizeCol);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned short * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapUShort(vm, *x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (short *)x);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned short * x, int xSize, const bool isRef) const
{
- // return wrapData<unsigned short>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (short *)x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned short * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<unsigned short>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (short *)x, xSize, xSizeCol);
}
int ScilabJavaEnvironmentWrapper::wrap(int * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapInt(vm, *x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x);
}
int ScilabJavaEnvironmentWrapper::wrap(int * x, int xSize, const bool isRef) const
{
- // return wrapData<int>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(int * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<int>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x, xSize, xSizeCol);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned int * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapUInt(vm, *x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (int *)x);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned int * x, int xSize, const bool isRef) const
{
- // return wrapData<unsigned int>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (int *)x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned int * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<unsigned int>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (int *)x, xSize, xSizeCol);
}
#ifdef __SCILAB_INT64__
int ScilabJavaEnvironmentWrapper::wrap(long long * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapLong(vm, *x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x);
}
int ScilabJavaEnvironmentWrapper::wrap(long long * x, int xSize, const bool isRef) const
{
- // return wrapData<long>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(long long * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<long>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, x, xSize, xSizeCol);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned long long * x, const bool isRef) const
{
- // return wrapData<unsigned long>(x, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (long long *)x);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned long long * x, int xSize, const bool isRef) const
{
- // return wrapData<unsigned long>(x, xSize, isRef);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (long long *)x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(unsigned long long * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<unsigned long>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (long long *)x, xSize, xSizeCol);
}
#endif
int ScilabJavaEnvironmentWrapper::wrap(char ** x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapString(vm, (char const*) * x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (char const**)x);
}
int ScilabJavaEnvironmentWrapper::wrap(char ** x, int xSize, const bool isRef) const
{
- // return wrapData(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (char const**)x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrap(char ** x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap(vm, (char const**)x, xSize, xSizeCol);
}
int ScilabJavaEnvironmentWrapper::wrapBool(int * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapBoolean(vm, *x != 0);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap<int, bool>(vm, x);
}
int ScilabJavaEnvironmentWrapper::wrapBool(int * x, int xSize, const bool isRef) const
{
- // return wrapData<int, bool, npy_bool>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap<int, bool>(vm, x, xSize);
}
int ScilabJavaEnvironmentWrapper::wrapBool(int * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<int, bool, npy_bool>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap<int, bool>(vm, x, xSize, xSizeCol);
}
-int ScilabJavaEnvironmentWrapper::wrap(float * x, const bool isRef) const
+int ScilabJavaEnvironmentWrapper::wrapFloat(double * x, const bool isRef) const
{
- JavaVM *vm = getScilabJavaVM ();
- return ScilabJavaObject::wrapFloat(vm, *x);
+ JavaVM * vm = getScilabJavaVM();
+ return wrap<double, float>(vm, x);
}
-int ScilabJavaEnvironmentWrapper::wrap(float * x, int xSize, const bool isRef) const
+int ScilabJavaEnvironmentWrapper::wrapFloat(double * x, int xSize, const bool isRef) const
{
- // return wrapData<float>(x, xSize, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap<double, float>(vm, x, xSize);
}
-int ScilabJavaEnvironmentWrapper::wrap(float * x, int xSize, int xSizeCol, const bool isRef) const
+int ScilabJavaEnvironmentWrapper::wrapFloat(double * x, int xSize, int xSizeCol, const bool isRef) const
{
- // return wrapData<float>(x, xSize, xSizeCol, isRef);
- return 0;
+ JavaVM * vm = getScilabJavaVM();
+ return wrap<double, float>(vm, x, xSize, xSizeCol);
}
void ScilabJavaEnvironmentWrapper::unwrapdouble(int id, const ScilabDoubleStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapSingle<jdouble, double>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwraprowdouble(int id, const ScilabDoubleStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapRow<jdouble, double>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapmatdouble(int id, const ScilabDoubleStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapMat<jdouble, double>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapchar(int id, const ScilabCharStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapSingle<jbyte, char>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwraprowchar(int id, const ScilabCharStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapRow<jbyte, char>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapmatchar(int id, const ScilabCharStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapMat<jbyte, char>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapuchar(int id, const ScilabUCharStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapSingle<jbyte, unsigned char>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwraprowuchar(int id, const ScilabUCharStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapRow<jbyte, unsigned char>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwrapmatuchar(int id, const ScilabUCharStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapMat<jbyte, unsigned char>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwrapshort(int id, const ScilabShortStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapSingle<jshort, short>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwraprowshort(int id, const ScilabShortStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapRow<jshort, short>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapmatshort(int id, const ScilabShortStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapMat<jshort, short>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapushort(int id, const ScilabUShortStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapSingle<jshort, unsigned short>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwraprowushort(int id, const ScilabUShortStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapRow<jshort, unsigned short>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwrapmatushort(int id, const ScilabUShortStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapMat<jshort, unsigned short>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwrapint(int id, const ScilabIntStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapSingle<jint, int>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwraprowint(int id, const ScilabIntStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapRow<jint, int>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapmatint(int id, const ScilabIntStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapMat<jint, int>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapuint(int id, const ScilabUIntStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapSingle<jint, unsigned int>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwraprowuint(int id, const ScilabUIntStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapRow<jint, unsigned int>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwrapmatuint(int id, const ScilabUIntStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- unwrapMat<jint, unsigned int>(vm, id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwraplong(int id, const ScilabLongStackAllocator & allocator) const
{
- // pyUnwrapSingle<long long>(id, allocator);
+ JavaVM * vm = getScilabJavaVM();
+ unwrapSingle<jlong, long long, long long>(vm, id, allocator, false);
}
void ScilabJavaEnvironmentWrapper::unwraprowlong(int id, const ScilabLongStackAllocator & allocator) const
{
- // pyUnwrapRow<long long>(id, allocator);
+ JavaVM * vm = getScilabJavaVM();
+ unwrapRow<jlong, long long, long long>(vm, id, allocator, false);
}
void ScilabJavaEnvironmentWrapper::unwrapmatlong(int id, const ScilabLongStackAllocator & allocator) const
{
- // pyUnwrapMat<long long>(id, allocator);
+ JavaVM * vm = getScilabJavaVM();
+ unwrapMat<jlong, int, long long>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapulong(int id, const ScilabULongStackAllocator & allocator) const
{
- // pyUnwrapSingle<unsigned long long>(id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwraprowulong(int id, const ScilabULongStackAllocator & allocator) const
{
- // pyUnwrapRow<unsigned long long>(id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwrapmatulong(int id, const ScilabULongStackAllocator & allocator) const
{
- // pyUnwrapMat<unsigned long long>(id, allocator);
+ // Not called
}
void ScilabJavaEnvironmentWrapper::unwrapboolean(int id, const ScilabBooleanStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapSingle<jboolean, int, bool>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwraprowboolean(int id, const ScilabBooleanStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapRow<jboolean, int, bool>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapmatboolean(int id, const ScilabBooleanStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
+ JavaVM * vm = getScilabJavaVM();
unwrapMat<jboolean, int, bool>(vm, id, allocator);
}
void ScilabJavaEnvironmentWrapper::unwrapstring(int id, const ScilabStringStackAllocator & allocator) const
{
- JavaVM *vm = getScilabJavaVM ();
- char * data = ScilabJavaObject::unwrapString(vm, id);
- allocator.allocate(1, 1, &data);
+ JNIEnv * curEnv = NULL;
+ JavaVM * vm = getScilabJavaVM();
+ vm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+
+ jstring res = static_cast<jstring>(curEnv->CallStaticObjectMethod(ScilabJavaObjectClass_, unwrapStringID_ , id));
+ char * addr = const_cast<char *>(curEnv->GetStringUTFChars(res, 0));
+
+ allocator.allocate(1, 1, &addr);
+
+ curEnv->ReleaseStringUTFChars(res, addr);
+ curEnv->DeleteLocalRef(res);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
}
void ScilabJavaEnvironmentWrapper::unwraprowstring(int id, const ScilabStringStackAllocator & allocator) const
{
- /* PyObject * obj = scope.getObject(id);
+ JNIEnv * curEnv = NULL;
+ JavaVM * vm = getScilabJavaVM();
+ vm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
- if (PyList_Check(obj))
- {
- // List case
- int col = PyList_Size(obj);
- char ** data = new char*[col];
- for (int i = 0; i < col; i++)
- {
- PyObject * item = PyList_GET_ITEM(obj, i);
- data[i] = PyString_AsString(item);
- }
+ jobjectArray res = static_cast<jobjectArray>(curEnv->CallStaticObjectMethod(ScilabJavaObjectClass_, unwrapRowStringID_ , id));
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
- allocator.allocate(1, col, data);
- delete[] data;
- }
- else
- {
- // Numpy array case
- PyArrayObject * arr = reinterpret_cast<PyArrayObject *>(obj);
- npy_intp * dims = PyArray_DIMS(arr);
- npy_intp * strides = PyArray_STRIDES(arr);
- char * pyData = reinterpret_cast<char *>(PyArray_DATA(arr));
- char ** data = new char*[dims[0]];
-
- for (int i = 0; i < dims[0]; i++)
- {
- data[i] = pyData + i * strides[0];
- }
+ jint lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+ char ** addr = new char*[lenRow];
+ jstring * resString = new jstring[lenRow];
- allocator.allocate(1, dims[0], data);
- delete[] data;
- }
- */
+ for (jsize i = 0; i < lenRow; i++)
+ {
+ resString[i] = reinterpret_cast<jstring>(curEnv->GetObjectArrayElement(res, i));
+ addr[i] = const_cast<char *>(curEnv->GetStringUTFChars(resString[i], &isCopy));
+ }
+
+ allocator.allocate(1, lenRow, addr);
+
+ for (jsize i = 0; i < lenRow; i++)
+ {
+ curEnv->ReleaseStringUTFChars(resString[i], addr[i]);
+ curEnv->DeleteLocalRef(resString[i]);
+ }
+ delete[] addr;
+ delete[] resString;
+
+ curEnv->DeleteLocalRef(res);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
}
void ScilabJavaEnvironmentWrapper::unwrapmatstring(int id, const ScilabStringStackAllocator & allocator) const
{
- /* PyObject * obj = scope.getObject(id);
-
- if (PyList_Check(obj))
+ JNIEnv * curEnv = NULL;
+ JavaVM * vm = getScilabJavaVM();
+ vm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+
+ jobjectArray res = static_cast<jobjectArray>(curEnv->CallStaticObjectMethod(ScilabJavaObjectClass_, unwrapMatStringID_, id));
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ jint lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ jobjectArray oneDim = reinterpret_cast<jobjectArray>(curEnv->GetObjectArrayElement(res, 0));
+ jint lenCol = curEnv->GetArrayLength(oneDim);
+ char ** addr = new char*[lenRow * lenCol];
+ jstring * resString = new jstring[lenRow * lenCol];
+
+ for (int i = 0; i < lenRow; i++)
+ {
+ oneDim = reinterpret_cast<jobjectArray>(curEnv->GetObjectArrayElement(res, i));
+ if (helper.getMethodOfConv())
{
- // List case
- int row = PyList_Size(obj);
- if (row > 0)
+ for (int j = 0; j < lenCol; j++)
{
- PyObject * f = PyList_GET_ITEM(obj, 0);
- int col = PyList_Size(f);
- char ** data = new char*[row * col];
- for (int i = 0; i < row; i++)
- {
- PyObject * sublist = PyList_GetItem(obj, i);
- for (int j = 0; j < col; j++)
- {
- PyObject * item = PyList_GET_ITEM(sublist, j);
- data[i + row * j] = PyString_AsString(item);
- }
- }
-
- allocator.allocate(row, col, data);
- delete[] data;
+ resString[j * lenRow + i] = reinterpret_cast<jstring>(curEnv->GetObjectArrayElement(oneDim, j));
+ addr[j * lenRow + i] = const_cast<char *>(curEnv->GetStringUTFChars(resString[j * lenRow + i], &isCopy));
}
}
else
{
- // Numpy array case
- PyArrayObject * arr = reinterpret_cast<PyArrayObject *>(obj);
- npy_intp * dims = PyArray_DIMS(arr);
- npy_intp * strides = PyArray_STRIDES(arr);
- char * pyData = reinterpret_cast<char *>(PyArray_DATA(arr));
- char ** data = new char*[dims[0] * dims[1]];
-
- for (int i = 0; i < dims[0]; i++)
+ for (int j = 0; j < lenCol; j++)
{
- for (int j = 0; j < dims[1]; j++)
- {
- data[i + dims[0] * j] = pyData + i * strides[0] + j * strides[1];
- }
+ resString[i * lenCol + j] = reinterpret_cast<jstring>(curEnv->GetObjectArrayElement(oneDim, j));
+ addr[i * lenCol + j] = const_cast<char *>(curEnv->GetStringUTFChars(resString[i * lenCol + j], &isCopy));
}
-
- allocator.allocate(dims[0], dims[1], data);
- delete[] data;
}
- */
+ curEnv->DeleteLocalRef(oneDim);
+ }
+
+ if (helper.getMethodOfConv())
+ {
+ allocator.allocate(lenRow, lenCol, addr);
+ }
+ else
+ {
+ allocator.allocate(lenCol, lenRow, addr);
+ }
+
+ for (int i = 0; i < lenRow * lenCol; i++)
+ {
+ curEnv->ReleaseStringUTFChars(resString[i], addr[i]);
+ curEnv->DeleteLocalRef(resString[i]);
+ }
+ delete[] addr;
+ delete[] resString;
+
+ curEnv->DeleteLocalRef(res);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
}
void ScilabJavaEnvironmentWrapper::unwrapcomplex(int id, const ScilabComplexStackAllocator & allocator) const
{
- /* PyObject * obj = scope.getObject(id);
- ComplexDataPointers cdp = allocator.allocate(1, 1, static_cast<double *>(0), static_cast<double *>(0));
- pyUnwrap(*cdp.realPtr, *cdp.imagPtr, obj);*/
+ // never called
}
void ScilabJavaEnvironmentWrapper::unwraprowcomplex(int id, const ScilabComplexStackAllocator & allocator) const
{
- /* PyObject * obj = scope.getObject(id);
-
- if (PyList_Check(obj))
- {
- // List case
- int col = PyList_Size(obj);
- ComplexDataPointers cdp = allocator.allocate(1, col, static_cast<double *>(0), static_cast<double *>(0));
- for (int i = 0; i < col; i++)
- {
- PyObject * item = PyList_GET_ITEM(obj, i);
- pyUnwrap(cdp.realPtr[i], cdp.imagPtr[i], obj);
- }
- }
- else
- {
- // Numpy array case
- PyArrayObject * arr = reinterpret_cast<PyArrayObject *>(obj);
- npy_intp * dims = PyArray_DIMS(arr);
- npy_intp * strides = PyArray_STRIDES(arr);
-
- ComplexDataPointers cdp = allocator.allocate(1, static_cast<int>(dims[0]), static_cast<double *>(0), static_cast<double *>(0));
- char * pyData = reinterpret_cast<char *>(PyArray_DATA(arr));
- for (int i = 0; i < dims[0]; i++)
- {
- complex c = *reinterpret_cast<complex *>(pyData + i * strides[0]);
- cdp.realPtr[i] = c.re;
- cdp.imagPtr[i] = c.im;
- }
- }
- */
+ // never called
}
void ScilabJavaEnvironmentWrapper::unwrapmatcomplex(int id, const ScilabComplexStackAllocator & allocator) const
{
- /* PyObject * obj = scope.getObject(id);
- if (PyList_Check(obj))
- {
- // List case
- int row = PyList_Size(obj);
- if (row > 0)
- {
- PyObject * f = PyList_GET_ITEM(obj, 0);
- int col = PyList_Size(f);
- ComplexDataPointers cdp = allocator.allocate(row, col, static_cast<double *>(0), static_cast<double *>(0));
- for (int i = 0; i < row; i++)
- {
- PyObject * sublist = PyList_GET_ITEM(obj, i);
- for (int j = 0; j < col; j++)
- {
- PyObject * item = PyList_GET_ITEM(sublist, j);
- pyUnwrap(cdp.realPtr[i + row * j], cdp.imagPtr[i + row * j], item);
- }
- }
- }
- }
- else
- {
- // Numpy array case
- PyArrayObject * arr = reinterpret_cast<PyArrayObject *>(obj);
- npy_intp * dims = PyArray_DIMS(arr);
- npy_intp * strides = PyArray_STRIDES(arr);
-
- ComplexDataPointers cdp = allocator.allocate(static_cast<int>(dims[0]), static_cast<int>(dims[1]), static_cast<double *>(0), static_cast<double *>(0));
- char * pyData = reinterpret_cast<char*>(PyArray_DATA(arr));
-
- for (int i = 0; i < dims[0]; i++)
- {
- for (int j = 0; j < dims[1]; j++)
- {
- complex c = *reinterpret_cast<complex *>(pyData + i * strides[0] + j * strides[1]);
- cdp.realPtr[i + dims[0] * j] = c.re;
- cdp.imagPtr[i + dims[0] * j] = c.im;
- }
- }
- }*/
+ // never called
}
-void ScilabJavaEnvironmentWrapper::unwrapfloat(int id, const ScilabFloatStackAllocator & allocator) const { }
+void ScilabJavaEnvironmentWrapper::unwrapfloat(int id, const ScilabFloatStackAllocator & allocator) const
+{
+ JavaVM * vm = getScilabJavaVM();
+ unwrapSingle<jfloat, float, float>(vm, id, allocator, false);
+}
-void ScilabJavaEnvironmentWrapper::unwraprowfloat(int id, const ScilabFloatStackAllocator & allocator) const { }
+void ScilabJavaEnvironmentWrapper::unwraprowfloat(int id, const ScilabFloatStackAllocator & allocator) const
+{
+ JavaVM * vm = getScilabJavaVM();
+ unwrapRow<jfloat, float, float>(vm, id, allocator, false);
+}
-void ScilabJavaEnvironmentWrapper::unwrapmatfloat(int id, const ScilabFloatStackAllocator & allocator) const { }
+void ScilabJavaEnvironmentWrapper::unwrapmatfloat(int id, const ScilabFloatStackAllocator & allocator) const
+{
+ JavaVM * vm = getScilabJavaVM();
+ unwrapMat<jfloat, double, float>(vm, id, allocator);
+}
}
#include "ScilabAbstractEnvironmentWrapper.hxx"
#include "ScilabJavaException.hxx"
+#include "ScilabJavaObject.hxx"
+
#include "GiwsException.hxx"
extern "C" {
JavaOptionsHelper & helper;
jclass ScilabJavaObjectClass_;
+ jmethodID unwrapStringID_;
+ jmethodID unwrapRowStringID_;
+ jmethodID unwrapMatStringID_;
+
jmethodID unwrapBooleanID_;
jmethodID unwrapRowBooleanID_;
jmethodID unwrapMatBooleanID_;
jmethodID unwrapRowDoubleID_;
jmethodID unwrapMatDoubleID_;
+ jmethodID unwrapFloatID_;
+ jmethodID unwrapRowFloatID_;
+ jmethodID unwrapMatFloatID_;
+
public:
ScilabJavaEnvironmentWrapper(JavaOptionsHelper & _helper) : helper(_helper)
vm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
ScilabJavaObjectClass_ = curEnv->FindClass(SCILABJAVAOBJECT);
+ unwrapStringID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapString", "(I)Ljava/lang/String;");
+ unwrapRowStringID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapRowString", "(I)[Ljava/lang/String;");
+ unwrapMatStringID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapMatString", "(I)[[Ljava/lang/String;");
+
unwrapBooleanID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapBoolean", "(I)Z");
unwrapRowBooleanID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapRowBoolean", "(I)[Z");
unwrapMatBooleanID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapMatBoolean", "(I)[[Z");
unwrapDoubleID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapDouble", "(I)D");
unwrapRowDoubleID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapRowDouble", "(I)[D");
unwrapMatDoubleID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapMatDouble", "(I)[[D");
+
+ unwrapFloatID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapFloat", "(I)F");
+ unwrapRowFloatID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapRowFloat", "(I)[F");
+ unwrapMatFloatID_ = curEnv->GetStaticMethodID(ScilabJavaObjectClass_, "unwrapMatFloat", "(I)[[F");
}
~ScilabJavaEnvironmentWrapper() { }
int wrap(char ** x, int xSize, int xSizeCol, const bool isRef) const;
- int wrap(float * x, const bool isRef) const;
+ int wrapFloat(double * x, const bool isRef) const;
- int wrap(float * x, int xSize, const bool isRef) const;
+ int wrapFloat(double * x, int xSize, const bool isRef) const;
- int wrap(float * x, int xSize, int xSizeCol, const bool isRef) const;
+ int wrapFloat(double * x, int xSize, int xSizeCol, const bool isRef) const;
int wrapBool(int * x, const bool isRef) const;
private:
- inline const jmethodID getSingleMethod(const char x) const
+ template<typename T>
+ inline int wrap(JavaVM * vm, T * x) const
{
- return unwrapByteID_;
+ return ScilabJavaObject::wrap(vm, *x);
+ }
+
+ template<typename T, typename U>
+ inline int wrap(JavaVM * vm, T * x) const
+ {
+ return ScilabJavaObject::wrap(vm, (U) * x);
+ }
+
+ template<typename T>
+ inline int wrap(JavaVM * vm, T * x, const int len) const
+ {
+ return ScilabJavaObject::wrap(vm, x, len);
}
- inline const jmethodID getSingleMethod(const unsigned char x) const
+
+ template<typename T, typename U>
+ inline int wrap(JavaVM * vm, T * x, const int len) const
+ {
+ U * xx = new U[len];
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ xx[i] = (U)x[i];
+ }
+
+ i = ScilabJavaObject::wrap(vm, xx, len);
+ delete[] xx;
+
+ return i;
+ }
+
+ template<typename T>
+ inline int wrap(JavaVM * vm, T * x, const int r, const int c) const
+ {
+ if (helper.getMethodOfConv())
+ {
+ T ** xx = new T*[r];
+ int i, j;
+ for (i = 0; i < r; i++)
+ {
+ xx[i] = new T[c];
+ for (j = 0; j < c; j++)
+ {
+ xx[i][j] = x[j * r + i];
+ }
+ }
+ j = ScilabJavaObject::wrap(vm, xx, r, c);
+ for (i = 0; i < r; delete[] xx[i++]);
+ delete[] xx;
+ return j;
+ }
+ else
+ {
+ T ** xx = new T*[c];
+ int i;
+ xx[0] = x;
+ for (i = 1; i < c; xx[i] = xx[i++ - 1] + r);
+ i = ScilabJavaObject::wrap(vm, xx, c, r);
+ delete[] xx;
+ return i;
+ }
+ }
+
+ template<typename T, typename U>
+ inline int wrap(JavaVM * vm, T * x, const int r, const int c) const
+ {
+ if (helper.getMethodOfConv())
+ {
+ U ** xx = new U*[r];
+ int i, j;
+ for (i = 0; i < r; i++)
+ {
+ xx[i] = new U[c];
+ for (j = 0; j < c; j++)
+ {
+ xx[i][j] = (U)(x[j * r + i]);
+ }
+ }
+ j = ScilabJavaObject::wrap(vm, xx, r, c);
+ for (i = 0; i < r; delete[] xx[i++]);
+ delete[] xx;
+ return j;
+ }
+ else
+ {
+ U ** xx = new U*[c];
+ int i, j;
+ for (i = 0; i < c; i++)
+ {
+ xx[i] = new U[r];
+ for (j = 0; j < r; j++)
+ {
+ xx[i][j] = (U)(x[i * r + j]);
+ }
+ }
+ j = ScilabJavaObject::wrap(vm, xx, c, r);
+ for (i = 0; i < c; delete[] xx[i++]);
+ delete[] xx;
+ return j;
+ }
+ }
+
+ inline const jmethodID getSingleMethod(const char x) const
{
return unwrapByteID_;
}
{
return unwrapIntID_;
}
- inline const jmethodID getSingleMethod(const unsigned int x) const
- {
- return unwrapIntID_;
- }
- inline const jmethodID getSingleMethod(const long x) const
- {
- return unwrapLongID_;
- }
- inline const jmethodID getSingleMethod(const unsigned long x) const
+ inline const jmethodID getSingleMethod(const long long x) const
{
return unwrapLongID_;
}
{
return unwrapBooleanID_;
}
-
- inline const jmethodID getRowMethod(const char x) const
+ inline const jmethodID getSingleMethod(const float x) const
{
- return unwrapRowByteID_;
+ return unwrapFloatID_;
}
- inline const jmethodID getRowMethod(const unsigned char x) const
+
+ inline const jmethodID getRowMethod(const char x) const
{
return unwrapRowByteID_;
}
{
return unwrapRowIntID_;
}
- inline const jmethodID getRowMethod(const unsigned int x) const
- {
- return unwrapRowIntID_;
- }
- inline const jmethodID getRowMethod(const long x) const
- {
- return unwrapRowLongID_;
- }
- inline const jmethodID getRowMethod(const unsigned long x) const
+ inline const jmethodID getRowMethod(const long long x) const
{
return unwrapRowLongID_;
}
{
return unwrapRowBooleanID_;
}
-
- inline const jmethodID getMatMethod(const char x) const
+ inline const jmethodID getRowMethod(const float x) const
{
- return unwrapMatByteID_;
+ return unwrapRowFloatID_;
}
- inline const jmethodID getMatMethod(const unsigned char x) const
+
+ inline const jmethodID getMatMethod(const char x) const
{
return unwrapMatByteID_;
}
{
return unwrapMatIntID_;
}
- inline const jmethodID getMatMethod(const unsigned int x) const
- {
- return unwrapMatIntID_;
- }
- inline const jmethodID getMatMethod(const long x) const
- {
- return unwrapMatLongID_;
- }
- inline const jmethodID getMatMethod(const unsigned long x) const
+ inline const jmethodID getMatMethod(const long long x) const
{
return unwrapMatLongID_;
}
{
return unwrapMatBooleanID_;
}
-
- template <typename T>
- inline T CallStatic(JNIEnv * env_, const char x, int javaID) const
+ inline const jmethodID getMatMethod(const float x) const
{
- return static_cast<T>(env_->CallStaticByteMethod(ScilabJavaObjectClass_, getSingleMethod(x), javaID));
+ return unwrapMatFloatID_;
}
template <typename T>
- inline T CallStatic(JNIEnv * env_, const unsigned char x, int javaID) const
+ inline T CallStatic(JNIEnv * env_, const char x, int javaID) const
{
return static_cast<T>(env_->CallStaticByteMethod(ScilabJavaObjectClass_, getSingleMethod(x), javaID));
}
}
template <typename T>
- inline T CallStatic(JNIEnv * env_, const unsigned int x, int javaID) const
- {
- return static_cast<T>(env_->CallStaticIntMethod(ScilabJavaObjectClass_, getSingleMethod(x), javaID));
- }
-
- template <typename T>
- inline T CallStatic(JNIEnv * env_, const long x, int javaID) const
- {
- return static_cast<T>(env_->CallStaticLongMethod(ScilabJavaObjectClass_, getSingleMethod(x), javaID));
- }
-
- template <typename T>
- inline T CallStatic(JNIEnv * env_, const unsigned long x, int javaID) const
+ inline T CallStatic(JNIEnv * env_, const long long x, int javaID) const
{
return static_cast<T>(env_->CallStaticLongMethod(ScilabJavaObjectClass_, getSingleMethod(x), javaID));
}
return static_cast<T>(env_->CallStaticBooleanMethod(ScilabJavaObjectClass_, getSingleMethod(x), javaID));
}
+ template <typename T>
+ inline T CallStatic(JNIEnv * env_, const float x, int javaID) const
+ {
+ return static_cast<T>(env_->CallStaticFloatMethod(ScilabJavaObjectClass_, getSingleMethod(x), javaID));
+ }
+
template <typename T, typename U, class V>
inline void unwrapSingle(JavaVM * jvm_, const int javaID, const V & allocator) const
{
}
template <typename T, typename U, typename V, class W>
- inline void unwrapSingle(JavaVM * jvm_, const int javaID, const W & allocator) const
+ inline void unwrapSingle(JavaVM * jvm_, const int javaID, const W & allocator, const bool mustAlloc = true) const
{
JNIEnv * curEnv = NULL;
U * addr = NULL;
throw GiwsException::JniCallMethodException(curEnv);
}
- addr = allocator.allocate(1, 1, 0);
- *addr = static_cast<U>(res);
+ if (mustAlloc)
+ {
+ addr = allocator.allocate(1, 1, 0);
+ *addr = static_cast<U>(res);
+ }
+ else
+ {
+ allocator.allocate(1, 1, reinterpret_cast<U *>(&res));
+ }
}
template <typename T, typename U, class V>
}
template <typename T, typename U, typename V, class W>
- inline void unwrapRow(JavaVM * jvm_, const int javaID, const W & allocator) const
+ inline void unwrapRow(JavaVM * jvm_, const int javaID, const W & allocator, const bool mustAlloc = true) const
{
jint lenRow;
jboolean isCopy = JNI_FALSE;
lenRow = curEnv->GetArrayLength(res);
- try
- {
- addr = allocator.allocate(1, lenRow, 0);
- }
- catch (const ScilabAbstractEnvironmentException & e)
+ if (mustAlloc)
{
- curEnv->DeleteLocalRef(res);
- throw;
+ try
+ {
+ addr = allocator.allocate(1, lenRow, 0);
+ }
+ catch (const ScilabAbstractEnvironmentException & e)
+ {
+ curEnv->DeleteLocalRef(res);
+ throw;
+ }
}
T * resultsArray = static_cast<T *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
- for (int i = 0; i < lenRow; i++)
+
+ if (mustAlloc)
{
- addr[i] = static_cast<U>(resultsArray[i]);
+ for (int i = 0; i < lenRow; i++)
+ {
+ addr[i] = static_cast<U>(resultsArray[i]);
+ }
+ }
+ else
+ {
+ try
+ {
+ allocator.allocate(1, lenRow, reinterpret_cast<U *>(resultsArray));
+ }
+ catch (const ScilabAbstractEnvironmentException & e)
+ {
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+ curEnv->DeleteLocalRef(res);
+ throw;
+ }
}
curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
{
if (helper.getMethodOfConv())
{
- addr = allocator.allocate(lenRow, lenCol, 0);
+ addr = (U *)allocator.allocate(lenRow, lenCol, 0);
}
else
{
- addr = allocator.allocate(lenCol, lenRow, 0);
+ addr = (U *)allocator.allocate(lenCol, lenRow, 0);
}
}
catch (const ScilabAbstractEnvironmentException & e)
throw GiwsException::JniCallMethodException(curEnv);
}
}
-
-
- /*
- inline static PyObject * pyWrap(double x)
- {
- return PyFloat_FromDouble(x);
- }
- inline static PyObject * pyWrap(float x)
- {
- return PyFloat_FromDouble((double)x);
- }
- inline static PyObject * pyWrap(bool x)
- {
- return PyBool_FromLong((long)x);
- }
- inline static PyObject * pyWrap(char x)
- {
- return PyInt_FromLong((long)x);
- }
- inline static PyObject * pyWrap(unsigned char x)
- {
- return PyInt_FromLong((long)x);
- }
- inline static PyObject * pyWrap(short x)
- {
- return PyInt_FromLong((long)x);
- }
- inline static PyObject * pyWrap(unsigned short x)
- {
- return PyInt_FromLong((long)x);
- }
- inline static PyObject * pyWrap(int x)
- {
- return PyInt_FromLong((long)x);
- }
- inline static PyObject * pyWrap(unsigned int x)
- {
- return PyInt_FromLong((long)x);
- }
- inline static PyObject * pyWrap(long long x)
- {
- return PyInt_FromLong(x);
- }
- inline static PyObject * pyWrap(unsigned long long x)
- {
- return PyInt_FromLong((long)x);
- }
- inline static PyObject * pyWrap(char * x)
- {
- return PyString_FromString(const_cast<const char *>(x));
- }
- inline static PyObject * pyWrap(double r, double i)
- {
- return PyComplex_FromDoubles(r, i);
- }
-
- inline static void pyUnwrap(double & x, PyObject * obj)
- {
- x = PyFloat_AS_DOUBLE(obj);
- }
- inline static void pyUnwrap(double & re, double & im, PyObject * obj)
- {
- re = PyComplex_RealAsDouble(obj);
- im = PyComplex_ImagAsDouble(obj);
- }
- inline static void pyUnwrap(float & x, PyObject * obj)
- {
- x = (float)PyFloat_AS_DOUBLE(obj);
- }
- inline static void pyUnWrap(bool & x, PyObject * obj)
- {
- x = (bool)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(char & x, PyObject * obj)
- {
- x = (char)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(unsigned char & x, PyObject * obj)
- {
- x = (unsigned char)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(short & x, PyObject * obj)
- {
- x = (short)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(unsigned short & x, PyObject * obj)
- {
- x = (unsigned short)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(int & x, PyObject * obj)
- {
- x = (int)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(unsigned int & x, PyObject * obj)
- {
- x = (unsigned int)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(long long & x, PyObject * obj)
- {
- x = (long long)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(unsigned long long & x, PyObject * obj)
- {
- x = (unsigned long long)PyInt_AS_LONG(obj);
- }
- inline static void pyUnwrap(char* & x, PyObject * obj)
- {
- x = PyString_AS_STRING(obj);
- }
-
- inline static PyArray_Descr * pyGetDescr(double x)
- {
- return PyArray_DescrFromType(PyArray_DOUBLE);
- }
- inline static PyArray_Descr * pyGetDescr(float x)
- {
- return PyArray_DescrFromType(PyArray_FLOAT);
- }
- inline static PyArray_Descr * pyGetDescr(char x)
- {
- return PyArray_DescrFromType(PyArray_BYTE);
- }
- inline static PyArray_Descr * pyGetDescr(unsigned char x)
- {
- return PyArray_DescrFromType(PyArray_UBYTE);
- }
- inline static PyArray_Descr * pyGetDescr(short x)
- {
- return PyArray_DescrFromType(PyArray_SHORT);
- }
- inline static PyArray_Descr * pyGetDescr(unsigned short x)
- {
- return PyArray_DescrFromType(PyArray_USHORT);
- }
- inline static PyArray_Descr * pyGetDescr(int x)
- {
- return PyArray_DescrFromType(PyArray_INT);
- }
- inline static PyArray_Descr * pyGetDescr(unsigned int x)
- {
- return PyArray_DescrFromType(PyArray_UINT);
- }
- inline static PyArray_Descr * pyGetDescr(long long x)
- {
- return PyArray_DescrFromType(PyArray_LONG);
- }
- inline static PyArray_Descr * pyGetDescr(unsigned long long x)
- {
- return PyArray_DescrFromType(PyArray_ULONG);
- }
- inline static PyArray_Descr * pyGetDescr(char * x)
- {
- return PyArray_DescrFromType(PyArray_STRING);
- }
- inline static PyArray_Descr * pyGetDescr(bool x)
- {
- return PyArray_DescrFromType(PyArray_BOOL);
- }
-
- template <typename T>
- inline void pyUnwrapSingle(int id, const ScilabSingleTypeStackAllocator<T> & allocator) const
- {
- PyObject * obj = scope.getObject(id);
- T * data = allocator.allocate(1, 1, static_cast<T *>(0));
- pyUnwrap(*data, obj);
- }
-
- template <typename T>
- inline void pyUnwrapRow(int id, const ScilabSingleTypeStackAllocator<T> & allocator) const
- {
- PyObject * obj = scope.getObject(id);
- if (PyList_Check(obj))
- {
- // List case
- int col = PyList_Size(obj);
- T * data = allocator.allocate(1, col, static_cast<T *>(0));
- for (int i = 0; i < col; i++)
- {
- PyObject * item = PyList_GET_ITEM(obj, i);
- pyUnwrap(data[i], item);
- }
- }
- else
- {
- // Numpy array case
- PyArrayObject * arr = (PyArrayObject *)obj;
- npy_intp * dims = PyArray_DIMS(arr);
- npy_intp * strides = PyArray_STRIDES(arr);
-
- if (strides[0] == sizeof(T))
- {
- allocator.allocate(1, static_cast<int>(dims[0]), reinterpret_cast<T*>(PyArray_DATA(arr)));
- }
- else
- {
- T * data = allocator.allocate(1, static_cast<int>(dims[0]), static_cast<T *>(0));
- char * pyData = (char *)PyArray_DATA(arr);
- for (int i = 0; i < dims[0]; i++)
- {
- data[i] = *(T*)(pyData + i * strides[0]);
- }
- }
- }
- }
-
- template <typename T>
- inline void pyUnwrapMat(int id, const ScilabSingleTypeStackAllocator<T> & allocator) const
- {
- PyObject * obj = scope.getObject(id);
- if (PyList_Check(obj))
- {
- // List case
- int row = PyList_Size(obj);
- if (row > 0)
- {
- PyObject * f = PyList_GET_ITEM(obj, 0);
- int col = PyList_Size(f);
- T * data = allocator.allocate(row, col, static_cast<T *>(0));
- for (int i = 0; i < row; i++)
- {
- PyObject * sublist = PyList_GET_ITEM(obj, i);
- for (int j = 0; j < col; j++)
- {
- PyObject * item = PyList_GET_ITEM(sublist, j);
- pyUnwrap(data[i + row * j], item);
- }
- }
- }
- }
- else
- {
- // Numpy array case
- PyArrayObject * arr = (PyArrayObject *)obj;
- npy_intp * dims = PyArray_DIMS(arr);
- npy_intp * strides = PyArray_STRIDES(arr);
-
- if (PyArray_ISFORTRAN(arr) && strides[0] == sizeof(T) && strides[1] == sizeof(T) * dims[0])
- {
- // the allocator use a memcpy (it is faster than two loops)
- allocator.allocate(static_cast<int>(dims[0]), static_cast<int>(dims[1]), (T*)PyArray_DATA(arr));
- }
- else
- {
- T * data = allocator.allocate(static_cast<int>(dims[0]), static_cast<int>(dims[1]), static_cast<T*>(0));
- char * pyData = (char*)PyArray_DATA(arr);
- for (int i = 0; i < dims[0]; i++)
- {
- for (int j = 0; j < dims[1]; j++)
- {
- data[i + dims[0] * j] = *(T*)(pyData + i * strides[0] + j * strides[1]);
- }
- }
- }
- }
- }
-
-
- template <typename T>
- inline int wrapData(T * x, const bool isRef) const
- {
- if (helper.getWrapSingleWithNumpy())
- {
- return wrapData<T, T, T>(x, 1, isRef);
- }
- else
- {
- return wrapData<T, T>(x, isRef);
- }
- }
-
- template <typename T>
- inline int wrapData(T * x, int xSize, const bool isRef) const
- {
- return wrapData<T, T, T>(x, xSize, isRef);
- }
-
- template <typename T>
- inline int wrapData(T * x, int xSize, int xSizeCol, const bool isRef) const
- {
- return wrapData<T, T, T>(x, xSize, xSizeCol, isRef);
- }
-
- template <typename T, typename U>
- inline int wrapData(T * x, const bool isRef) const
- {
- PyObject * obj = pyWrap(static_cast<U>(*x));
- return scope.addObject(obj);
- }
-
- template <typename T, typename U, typename V>
- inline int wrapData(T * x, int xSize, const bool isRef) const
- {
- if (helper.getUseNumpy())
- {
- PyObject * array;
- V * matnp = 0;
- npy_intp dim[] = { xSize };
- npy_intp strides[] = { 0 };
- npy_intp * stridesAddr = strides;
-
- if (helper.getUseCopy() && !isRef)
- {
- matnp = new V[xSize];
- for (int i = 0; i < xSize; i++)
- {
- matnp[i] = static_cast<V>(x[i]);
- }
- stridesAddr = 0;
- }
- else
- {
- if (sizeof(T) < sizeof(V))
- {
- throw ScilabJavaException(__LINE__, __FILE__, gettext("Cannot pass the data by reference"));
- }
-
- matnp = (V*)x;
- strides[0] = static_cast<npy_intp>(sizeof(T));
- }
-
- array = PyArray_NewFromDescr(&PyArray_Type, pyGetDescr(static_cast<U>(*x)), 1, dim, stridesAddr, reinterpret_cast<void *>(matnp), NPY_OWNDATA | NPY_FARRAY, 0);
- if (helper.getUseCopy() && !isRef)
- {
- NumpyDeallocator::attach_deallocator(array, reinterpret_cast<void *>(matnp));
- }
-
- return scope.addObject(array);
- }
- else
- {
- PyObject * list = PyList_New(xSize);
- for (int i = 0; i < xSize; i++)
- {
- PyList_SetItem(list, i, pyWrap(static_cast<U>(x[i])));
- }
-
- return scope.addObject(list);
- }
- }
-
- template <typename T, typename U, typename V>
- inline int wrapData(T * x, int xSize, int xSizeCol, const bool isRef) const
- {
- if (helper.getUseNumpy())
- {
- PyObject * array;
- V * matnp = 0;
- npy_intp dim[] = { xSize, xSizeCol };
- npy_intp strides[] = { 0, 0 };
- npy_intp * stridesAddr = strides;
-
- if (helper.getUseCopy() && !isRef)
- {
- matnp = new V[xSize * xSizeCol];
- for (int i = 0; i < xSize * xSizeCol; i++)
- {
- matnp[i] = static_cast<V>(x[i]);
- }
- stridesAddr = 0;
- }
- else
- {
- if (sizeof(T) < sizeof(V))
- {
- throw ScilabJavaException(__LINE__, __FILE__, gettext("Cannot pass the data by reference"));
- }
-
- matnp = (V*)x;
- strides[0] = static_cast<npy_intp>(sizeof(T));
- strides[1] = static_cast<npy_intp>(sizeof(T) * xSize);
- }
-
- array = PyArray_NewFromDescr(&PyArray_Type, pyGetDescr(static_cast<U>(*x)), 2, dim, stridesAddr, reinterpret_cast<void *>(matnp), NPY_OWNDATA | NPY_FARRAY, 0);
- if (helper.getUseCopy() && !isRef)
- {
- NumpyDeallocator::attach_deallocator(array, reinterpret_cast<void *>(matnp));
- }
-
- return scope.addObject(array);
- }
- else
- {
- PyObject * list = PyList_New(xSize);
- for (int i = 0; i < xSize; i++)
- {
- PyObject * sublist = PyList_New(xSizeCol);
- PyList_SetItem(list, i, sublist);
- for (int j = 0; j < xSizeCol; j++)
- {
- PyList_SetItem(sublist, j, pyWrap(static_cast<U>(x[i + j * xSize])));
- }
- }
-
- return scope.addObject(list);
- }
- }
-
- inline int wrapData(char ** x, int xSize, const bool isRef) const
- {
- if (helper.getUseNumpy())
- {
- PyObject * array;
- npy_intp dim[] = { xSize };
- npy_intp strides[] = { 0 };
- char * matnp = 0;
- int maxlen = 0;
-
- if (helper.getUseCopy() && !isRef)
- {
- int * lens = new int[xSize];
- for (int i = 0; i < xSize; i++)
- {
- lens[i] = strlen(x[i]);
- if (lens[i] > maxlen)
- {
- maxlen = lens[i];
- }
- }
- maxlen++;
-
- matnp = new char[xSize * maxlen];
- memset(matnp, 0, xSize * maxlen);
- for (int i = 0; i < xSize; i++)
- {
- memcpy(matnp + i * maxlen, x[i], lens[i]);
- }
- delete[] lens;
-
- strides[0] = static_cast<npy_intp>(maxlen);
- }
- else
- {
- throw ScilabJavaException(__LINE__, __FILE__, gettext("Cannot pass Scilab strings by reference"));
- }
-
- PyArray_Descr * descr = pyGetDescr(*x);
- descr->elsize = maxlen - 1;
- array = PyArray_NewFromDescr(&PyArray_Type, descr, 1, dim, strides, reinterpret_cast<void *>(matnp), NPY_OWNDATA | NPY_FARRAY, 0);
- NumpyDeallocator::attach_deallocator(array, reinterpret_cast<void *>(matnp));
-
- return scope.addObject(array);
- }
- else
- {
- PyObject * list = PyList_New(xSize);
- for (int i = 0; i < xSize; i++)
- {
- PyList_SetItem(list, i, pyWrap(x[i]));
- }
-
- return scope.addObject(list);
- }
- }
-
- inline int wrapData(char ** x, int xSize, int xSizeCol, const bool isRef) const
- {
- if (helper.getUseNumpy())
- {
- PyObject * array;
- char * matnp = 0;
- npy_intp dim[] = { xSize, xSizeCol };
- npy_intp strides[] = { 0, 0 };
- int maxlen = 0;
-
- if (helper.getUseCopy() && !isRef)
- {
- int * lens = new int[xSize * xSizeCol];
- for (int i = 0; i < xSize * xSizeCol; i++)
- {
- lens[i] = strlen(x[i]);
- if (lens[i] > maxlen)
- {
- maxlen = lens[i];
- }
- }
-
- matnp = new char[xSize * xSizeCol * maxlen];
- memset(matnp, 0, xSize * xSizeCol * maxlen);
- for (int i = 0; i < xSize * xSizeCol; i++)
- {
- memcpy(matnp + i * maxlen, x[i], lens[i]);
- }
- delete[] lens;
-
- strides[0] = static_cast<npy_intp>(maxlen);
- strides[1] = static_cast<npy_intp>(xSize * maxlen);
- }
- else
- {
- throw ScilabJavaException(__LINE__, __FILE__, gettext("Cannot pass Scilab strings by reference"));
- }
-
-
- PyArray_Descr * descr = pyGetDescr(*x);
- descr->elsize = maxlen;
-
- array = PyArray_NewFromDescr(&PyArray_Type, pyGetDescr(*x), 2, dim, strides, reinterpret_cast<void *>(matnp), NPY_OWNDATA | NPY_FARRAY, 0);
- NumpyDeallocator::attach_deallocator(array, reinterpret_cast<void *>(matnp));
-
- return scope.addObject(array);
- }
- else
- {
- PyObject * list = PyList_New(xSize);
- for (int i = 0; i < xSize; i++)
- {
- PyObject * sublist = PyList_New(xSizeCol);
- PyList_SetItem(list, i, sublist);
- for (int j = 0; j < xSizeCol; j++)
- {
- PyList_SetItem(sublist, j, pyWrap(x[i + j * xSize]));
- }
- }
-
- return scope.addObject(list);
- }
- }
-
- inline int wrapData(double * re, double * im, const bool isRef) const
- {
- PyObject * obj = pyWrap(*re, *im);
- return scope.addObject(obj);
- }
-
- inline int wrapData(double * re, double * im, int xSize, const bool isRef) const
- {
- if (helper.getUseNumpy())
- {
- PyObject * array;
- npy_intp dim[] = { xSize };
- double * matnp = 0;
-
- if (helper.getUseCopy() && !isRef)
- {
- matnp = new double[2 * xSize];
- for (int i = 0; i < xSize; i++)
- {
- matnp[2 * i] = re[i];
- matnp[2 * i + 1] = im[i];
- }
- }
- else
- {
- throw ScilabJavaException(__LINE__, __FILE__, gettext("Cannot pass Scilab Complex by reference"));
- }
-
- array = PyArray_NewFromDescr(&PyArray_Type, PyArray_DescrFromType(PyArray_CDOUBLE), 1, dim, 0, reinterpret_cast<void *>(matnp), NPY_OWNDATA | NPY_FARRAY, 0);
- NumpyDeallocator::attach_deallocator(array, reinterpret_cast<void *>(matnp));
-
- return scope.addObject(array);
- }
- else
- {
- PyObject * list = PyList_New(xSize);
- for (int i = 0; i < xSize; i++)
- {
- PyList_SetItem(list, i, pyWrap(re[i], im[i]));
- }
-
- return scope.addObject(list);
- }
- }
-
- inline int wrapData(double * re, double * im, int xSize, int xSizeCol, const bool isRef) const
- {
- if (helper.getUseNumpy())
- {
- PyObject * array;
- double * matnp = 0;
- npy_intp dim[] = { xSize, xSizeCol };
-
- if (helper.getUseCopy() && !isRef)
- {
- matnp = new double[2 * xSize * xSizeCol];
- for (int i = 0; i < xSize * xSizeCol; i++)
- {
- matnp[2 * i] = re[i];
- matnp[2 * i + 1] = im[i];
- }
- }
- else
- {
- throw ScilabJavaException(__LINE__, __FILE__, gettext("Cannot pass Scilab Complex by reference"));
- }
-
-
- array = PyArray_NewFromDescr(&PyArray_Type, PyArray_DescrFromType(PyArray_CDOUBLE), 2, dim, 0, reinterpret_cast<void *>(matnp), NPY_OWNDATA | NPY_FARRAY, 0);
- NumpyDeallocator::attach_deallocator(array, reinterpret_cast<void *>(matnp));
-
- return scope.addObject(array);
- }
- else
- {
- PyObject * list = PyList_New(xSize);
- for (int i = 0; i < xSize; i++)
- {
- PyObject * sublist = PyList_New(xSizeCol);
- PyList_SetItem(list, i, sublist);
- for (int j = 0; j < xSizeCol; j++)
- {
- PyList_SetItem(sublist, j, pyWrap(re[i + j * xSize], im[i + j * xSize]));
- }
- }
-
- return scope.addObject(list);
- }
- }
- */
};
}
unwrappableType.put(String.class, 5);
unwrappableType.put(String[].class, 6);
unwrappableType.put(String[][].class, 7);
- unwrappableType.put(int.class, 23);
- unwrappableType.put(int[].class, 24);
- unwrappableType.put(int[][].class, 25);
unwrappableType.put(boolean.class, 8);
unwrappableType.put(boolean[].class, 9);
unwrappableType.put(boolean[][].class, 10);
unwrappableType.put(char.class, 20);
unwrappableType.put(char[].class, 21);
unwrappableType.put(char[][].class, 22);
- unwrappableType.put(float.class, 23);
- unwrappableType.put(float[].class, 35);
- unwrappableType.put(float[][].class, 36);
- unwrappableType.put(long.class, 37);
+ unwrappableType.put(int.class, 23);
+ unwrappableType.put(int[].class, 24);
+ unwrappableType.put(int[][].class, 25);
+ unwrappableType.put(long.class, 29);
unwrappableType.put(long[].class, 30);
unwrappableType.put(long[][].class, 31);
- unwrappableType.put(Double.class, 29);
- unwrappableType.put(Integer.class, 30);
- unwrappableType.put(Long.class, 31);
- unwrappableType.put(Byte.class, 32);
- unwrappableType.put(Character.class, 34);
- unwrappableType.put(Boolean.class, 35);
- unwrappableType.put(Float.class, 36);
- unwrappableType.put(Short.class, 37);
+ unwrappableType.put(float.class, 35);
+ unwrappableType.put(float[].class, 36);
+ unwrappableType.put(float[][].class, 37);
+ unwrappableType.put(Double.class, 2);
+ unwrappableType.put(Integer.class, 23);
+ unwrappableType.put(Long.class, 29);
+ unwrappableType.put(Byte.class, 11);
+ unwrappableType.put(Character.class, 20);
+ unwrappableType.put(Boolean.class, 8);
+ unwrappableType.put(Float.class, 35);
+ unwrappableType.put(Short.class, 17);
arraySJO[0] = new ScilabJavaObject(null, null);
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapDouble(final double x) {
+ public static int wrap(final double x) {
return new ScilabJavaObject(x, double.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapDouble(final double[] x) {
+ public static int wrap(final double[] x) {
return new ScilabJavaObject(x, double[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapDouble(final double[][] x) {
+ public static int wrap(final double[][] x) {
return new ScilabJavaObject(x, double[][].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapInt(final int x) {
+ public static int wrap(final int x) {
return new ScilabJavaObject(x, int.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapInt(final int[] x) {
+ public static int wrap(final int[] x) {
return new ScilabJavaObject(x, int[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapInt(final int[][] x) {
+ public static int wrap(final int[][] x) {
return new ScilabJavaObject(x, int[][].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapUInt(final long x) {
+ public static int wrap(final long x) {
return new ScilabJavaObject(x, long.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapUInt(final long[] x) {
+ public static int wrap(final long[] x) {
return new ScilabJavaObject(x, long[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapUInt(final long[][] x) {
+ public static int wrap(final long[][] x) {
return new ScilabJavaObject(x, long[][].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapByte(final byte x) {
+ public static int wrap(final byte x) {
return new ScilabJavaObject(x, byte.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapByte(final byte[] x) {
+ public static int wrap(final byte[] x) {
return new ScilabJavaObject(x, byte[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapByte(final byte[][] x) {
+ public static int wrap(final byte[][] x) {
return new ScilabJavaObject(x, byte[][].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapShort(final short x) {
+ public static int wrap(final short x) {
return new ScilabJavaObject(x, short.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapShort(final short[] x) {
+ public static int wrap(final short[] x) {
return new ScilabJavaObject(x, short[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapShort(final short[][] x) {
+ public static int wrap(final short[][] x) {
return new ScilabJavaObject(x, short[][].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapUShort(final int x) {
- return new ScilabJavaObject(x, int.class).id;
- }
-
- /**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapUShort(final int[] x) {
- return new ScilabJavaObject(x, int[].class).id;
- }
-
- /**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapUShort(final int[][] x) {
- return new ScilabJavaObject(x, int[][].class).id;
- }
-
- /**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapUByte(final short x) {
- return new ScilabJavaObject(x, short.class).id;
- }
-
- /**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapUByte(final short[] x) {
- return new ScilabJavaObject(x, short[].class).id;
- }
-
- /**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapUByte(final short[][] x) {
- return new ScilabJavaObject(x, short[][].class).id;
- }
-
- /**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapString(final String x) {
+ public static int wrap(final String x) {
return new ScilabJavaObject(x, String.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapString(final String[] x) {
+ public static int wrap(final String[] x) {
return new ScilabJavaObject(x, String[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapString(final String[][] x) {
+ public static int wrap(final String[][] x) {
return new ScilabJavaObject(x, String[][].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapBoolean(final boolean x) {
+ public static int wrap(final boolean x) {
return new ScilabJavaObject(x, boolean.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapBoolean(final boolean[] x) {
+ public static int wrap(final boolean[] x) {
return new ScilabJavaObject(x, boolean[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapBoolean(final boolean[][] x) {
+ public static int wrap(final boolean[][] x) {
return new ScilabJavaObject(x, boolean[][].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapChar(final char x) {
+ public static int wrap(final char x) {
return new ScilabJavaObject(x, char.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapChar(final char[] x) {
+ public static int wrap(final char[] x) {
return new ScilabJavaObject(x, char[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapChar(final char[][] x) {
+ public static int wrap(final char[][] x) {
return new ScilabJavaObject(x, char[][].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapFloat(final float x) {
+ public static int wrap(final float x) {
return new ScilabJavaObject(x, float.class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapFloat(final float[] x) {
+ public static int wrap(final float[] x) {
return new ScilabJavaObject(x, float[].class).id;
}
* @param x the variable to wrap into a Java Object
* @return the corresponding id
*/
- public static int wrapFloat(final float[][] x) {
+ public static int wrap(final float[][] x) {
return new ScilabJavaObject(x, float[][].class).id;
}
/**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapLong(final long x) {
- return new ScilabJavaObject(x, long.class).id;
- }
-
- /**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapLong(final long[] x) {
- return new ScilabJavaObject(x, long[].class).id;
- }
-
- /**
- * @param x the variable to wrap into a Java Object
- * @return the corresponding id
- */
- public static int wrapLong(final long[][] x) {
- return new ScilabJavaObject(x, long[][].class).id;
- }
-
- /**
* @param id the Java Object id
* @return the resulting unwrapping
*/
#include "ScilabClassLoader.hxx"
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
knowledge of the CeCILL-B license and that you accept its terms.
*/
-namespace org_scilab_modules_external_objects_java {
+namespace org_scilab_modules_external_objects_java
+{
+
+// Static declarations (if any)
- // Static declarations (if any)
-
// Returns the current env
-JNIEnv * ScilabClassLoader::getCurrentEnv() {
-JNIEnv * curEnv = NULL;
-jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-if (res != JNI_OK) {
-throw GiwsException::JniException(getCurrentEnv());
-}
-return curEnv;
+JNIEnv * ScilabClassLoader::getCurrentEnv()
+{
+ JNIEnv * curEnv = NULL;
+ jint res = this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ if (res != JNI_OK)
+ {
+ throw GiwsException::JniException(getCurrentEnv());
+ }
+ return curEnv;
}
// Destructor
-ScilabClassLoader::~ScilabClassLoader() {
-JNIEnv * curEnv = NULL;
-this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-curEnv->DeleteGlobalRef(this->instance);
-curEnv->DeleteGlobalRef(this->instanceClass);
+ScilabClassLoader::~ScilabClassLoader()
+{
+ JNIEnv * curEnv = NULL;
+ this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ curEnv->DeleteGlobalRef(this->instance);
+ curEnv->DeleteGlobalRef(this->instanceClass);
}
// Constructors
-ScilabClassLoader::ScilabClassLoader(JavaVM * jvm_) {
-jmethodID constructObject = NULL ;
-jobject localInstance ;
-jclass localClass ;
+ScilabClassLoader::ScilabClassLoader(JavaVM * jvm_)
+{
+ jmethodID constructObject = NULL ;
+ jobject localInstance ;
+ jclass localClass ;
-const std::string construct="<init>";
-const std::string param="()V";
-jvm=jvm_;
+ const std::string construct = "<init>";
+ const std::string param = "()V";
+ jvm = jvm_;
-JNIEnv * curEnv = getCurrentEnv();
+ JNIEnv * curEnv = getCurrentEnv();
-localClass = curEnv->FindClass( this->className().c_str() ) ;
-if (localClass == NULL) {
- throw GiwsException::JniClassNotFoundException(curEnv, this->className());
-}
+ localClass = curEnv->FindClass( this->className().c_str() ) ;
+ if (localClass == NULL)
+ {
+ throw GiwsException::JniClassNotFoundException(curEnv, this->className());
+ }
-this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
-/* localClass is not needed anymore */
-curEnv->DeleteLocalRef(localClass);
+ /* localClass is not needed anymore */
+ curEnv->DeleteLocalRef(localClass);
-if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
-constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
-if(constructObject == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
+ constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
+ if (constructObject == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
-localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
-if(localInstance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-
-this->instance = curEnv->NewGlobalRef(localInstance) ;
-if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-/* localInstance not needed anymore */
-curEnv->DeleteLocalRef(localInstance);
+ localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
+ if (localInstance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+
+ this->instance = curEnv->NewGlobalRef(localInstance) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* localInstance not needed anymore */
+ curEnv->DeleteLocalRef(localInstance);
- /* Methods ID set to NULL */
-jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID=NULL;
+ /* Methods ID set to NULL */
+ jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID = NULL;
}
-ScilabClassLoader::ScilabClassLoader(JavaVM * jvm_, jobject JObj) {
- jvm=jvm_;
+ScilabClassLoader::ScilabClassLoader(JavaVM * jvm_, jobject JObj)
+{
+ jvm = jvm_;
- JNIEnv * curEnv = getCurrentEnv();
+ JNIEnv * curEnv = getCurrentEnv();
-jclass localClass = curEnv->GetObjectClass(JObj);
- this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
- curEnv->DeleteLocalRef(localClass);
+ jclass localClass = curEnv->GetObjectClass(JObj);
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ curEnv->DeleteLocalRef(localClass);
- if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
- this->instance = curEnv->NewGlobalRef(JObj) ;
- if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
- /* Methods ID set to NULL */
- jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID=NULL;
+ this->instance = curEnv->NewGlobalRef(JObj) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* Methods ID set to NULL */
+ jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID = NULL;
}
// Generic methods
-void ScilabClassLoader::synchronize() {
-if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabClassLoader");
-}
+void ScilabClassLoader::synchronize()
+{
+ if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabClassLoader");
+ }
}
-void ScilabClassLoader::endSynchronize() {
-if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabClassLoader");
-}
+void ScilabClassLoader::endSynchronize()
+{
+ if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabClassLoader");
+ }
}
// Method(s)
-int ScilabClassLoader::loadJavaClass (JavaVM * jvm_, char const* name, bool allowReload){
-
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-
-jmethodID jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "loadJavaClass", "(Ljava/lang/String;Z)I" ) ;
-if (jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "loadJavaClass");
-}
-
-jstring name_ = curEnv->NewStringUTF( name );
-if (name != NULL && name_ == NULL)
+int ScilabClassLoader::loadJavaClass (JavaVM * jvm_, char const* name, bool allowReload)
{
-throw GiwsException::JniBadAllocException(curEnv);
-}
-
-jboolean allowReload_ = (static_cast<bool>(allowReload) ? JNI_TRUE : JNI_FALSE);
-
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID ,name_, allowReload_));
- curEnv->DeleteLocalRef(name_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "loadJavaClass", "(Ljava/lang/String;Z)I" ) ;
+ if (jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "loadJavaClass");
+ }
+
+ jstring name_ = curEnv->NewStringUTF( name );
+ if (name != NULL && name_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+
+ jboolean allowReload_ = (static_cast<bool>(allowReload) ? JNI_TRUE : JNI_FALSE);
+
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID , name_, allowReload_));
+ curEnv->DeleteLocalRef(name_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
#include "GiwsException.hxx"
- #if defined(_MSC_VER) /* Defined anyway with Visual */
- #include <Windows.h>
- #else
- typedef signed char byte;
- #endif
+#if defined(_MSC_VER) /* Defined anyway with Visual */
+#include <Windows.h>
+#else
+typedef signed char byte;
+#endif
#ifndef GIWSEXPORT
# endif
#endif
-namespace org_scilab_modules_external_objects_java {
-class GIWSEXPORT ScilabClassLoader {
+namespace org_scilab_modules_external_objects_java
+{
+class GIWSEXPORT ScilabClassLoader
+{
private:
-JavaVM * jvm;
+ JavaVM * jvm;
protected:
-jmethodID jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID; // cache method id
+ jmethodID jintloadJavaClassjstringjava_lang_StringjbooleanbooleanID; // cache method id
-jobject instance;
-jclass instanceClass; // cache class
+ jobject instance;
+ jclass instanceClass; // cache class
-
-// Caching (if any)
+ // Caching (if any)
-/**
-* Get the environment matching to the current thread.
-*/
-virtual JNIEnv * getCurrentEnv();
+
+ /**
+ * Get the environment matching to the current thread.
+ */
+ virtual JNIEnv * getCurrentEnv();
public:
-// Constructor
-/**
-* Create a wrapping of the object from a JNIEnv.
-* It will call the default constructor
-* @param JEnv_ the Java Env
-*/
-ScilabClassLoader(JavaVM * jvm_);
+ // Constructor
+ /**
+ * Create a wrapping of the object from a JNIEnv.
+ * It will call the default constructor
+ * @param JEnv_ the Java Env
+ */
+ ScilabClassLoader(JavaVM * jvm_);
+
+ /**
+ * Create a wrapping of an already existing object from a JNIEnv.
+ * The object must have already been instantiated
+ * @param JEnv_ the Java Env
+ * @param JObj the object
+ */
+ ScilabClassLoader(JavaVM * jvm_, jobject JObj);
+
+
+ /**
+ * This is a fake constructor to avoid the constructor
+ * chaining when dealing with extended giws classes
+ */
+#ifdef FAKEGIWSDATATYPE
+ ScilabClassLoader(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
+#endif
-/**
-* Create a wrapping of an already existing object from a JNIEnv.
-* The object must have already been instantiated
-* @param JEnv_ the Java Env
-* @param JObj the object
-*/
-ScilabClassLoader(JavaVM * jvm_, jobject JObj);
+ // Destructor
+ ~ScilabClassLoader();
+ // Generic method
+ // Synchronization methods
+ /**
+ * Enter monitor associated with the object.
+ * Equivalent of creating a "synchronized(obj)" scope in Java.
+ */
+ void synchronize();
-/**
-* This is a fake constructor to avoid the constructor
-* chaining when dealing with extended giws classes
-*/
-#ifdef FAKEGIWSDATATYPE
-ScilabClassLoader(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
-#endif
+ /**
+ * Exit monitor associated with the object.
+ * Equivalent of ending a "synchronized(obj)" scope.
+ */
+ void endSynchronize();
-// Destructor
-~ScilabClassLoader();
+ // Methods
+ static int loadJavaClass(JavaVM * jvm_, char const* name, bool allowReload);
-// Generic method
-// Synchronization methods
-/**
-* Enter monitor associated with the object.
-* Equivalent of creating a "synchronized(obj)" scope in Java.
-*/
-void synchronize();
-/**
-* Exit monitor associated with the object.
-* Equivalent of ending a "synchronized(obj)" scope.
-*/
-void endSynchronize();
-
-// Methods
-static int loadJavaClass(JavaVM * jvm_, char const* name, bool allowReload);
-
-
- /**
- * Get class name to use for static methods
- * @return class name to use for static methods
- */
-
- static const std::string className()
- {
- return "org/scilab/modules/external_objects_java/ScilabClassLoader";
- }
-
+ /**
+ * Get class name to use for static methods
+ * @return class name to use for static methods
+ */
+
+ static const std::string className()
+ {
+ return "org/scilab/modules/external_objects_java/ScilabClassLoader";
+ }
+
};
#include "ScilabJavaArray.hxx"
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
knowledge of the CeCILL-B license and that you accept its terms.
*/
-namespace org_scilab_modules_external_objects_java {
+namespace org_scilab_modules_external_objects_java
+{
+
+// Static declarations (if any)
- // Static declarations (if any)
-
// Returns the current env
-JNIEnv * ScilabJavaArray::getCurrentEnv() {
-JNIEnv * curEnv = NULL;
-jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-if (res != JNI_OK) {
-throw GiwsException::JniException(getCurrentEnv());
-}
-return curEnv;
+JNIEnv * ScilabJavaArray::getCurrentEnv()
+{
+ JNIEnv * curEnv = NULL;
+ jint res = this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ if (res != JNI_OK)
+ {
+ throw GiwsException::JniException(getCurrentEnv());
+ }
+ return curEnv;
}
// Destructor
-ScilabJavaArray::~ScilabJavaArray() {
-JNIEnv * curEnv = NULL;
-this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-curEnv->DeleteGlobalRef(this->instance);
-curEnv->DeleteGlobalRef(this->instanceClass);
+ScilabJavaArray::~ScilabJavaArray()
+{
+ JNIEnv * curEnv = NULL;
+ this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ curEnv->DeleteGlobalRef(this->instance);
+ curEnv->DeleteGlobalRef(this->instanceClass);
}
// Constructors
-ScilabJavaArray::ScilabJavaArray(JavaVM * jvm_) {
-jmethodID constructObject = NULL ;
-jobject localInstance ;
-jclass localClass ;
+ScilabJavaArray::ScilabJavaArray(JavaVM * jvm_)
+{
+ jmethodID constructObject = NULL ;
+ jobject localInstance ;
+ jclass localClass ;
-const std::string construct="<init>";
-const std::string param="()V";
-jvm=jvm_;
+ const std::string construct = "<init>";
+ const std::string param = "()V";
+ jvm = jvm_;
-JNIEnv * curEnv = getCurrentEnv();
+ JNIEnv * curEnv = getCurrentEnv();
-localClass = curEnv->FindClass( this->className().c_str() ) ;
-if (localClass == NULL) {
- throw GiwsException::JniClassNotFoundException(curEnv, this->className());
-}
+ localClass = curEnv->FindClass( this->className().c_str() ) ;
+ if (localClass == NULL)
+ {
+ throw GiwsException::JniClassNotFoundException(curEnv, this->className());
+ }
-this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
-/* localClass is not needed anymore */
-curEnv->DeleteLocalRef(localClass);
+ /* localClass is not needed anymore */
+ curEnv->DeleteLocalRef(localClass);
-if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
-constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
-if(constructObject == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
+ constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
+ if (constructObject == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
-localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
-if(localInstance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-
-this->instance = curEnv->NewGlobalRef(localInstance) ;
-if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-/* localInstance not needed anymore */
-curEnv->DeleteLocalRef(localInstance);
+ localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
+ if (localInstance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+
+ this->instance = curEnv->NewGlobalRef(localInstance) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* localInstance not needed anymore */
+ curEnv->DeleteLocalRef(localInstance);
- /* Methods ID set to NULL */
-jintnewInstancejstringjava_lang_StringjintArray_intintID=NULL;
+ /* Methods ID set to NULL */
+ jintnewInstancejstringjava_lang_StringjintArray_intintID = NULL;
}
-ScilabJavaArray::ScilabJavaArray(JavaVM * jvm_, jobject JObj) {
- jvm=jvm_;
+ScilabJavaArray::ScilabJavaArray(JavaVM * jvm_, jobject JObj)
+{
+ jvm = jvm_;
- JNIEnv * curEnv = getCurrentEnv();
+ JNIEnv * curEnv = getCurrentEnv();
-jclass localClass = curEnv->GetObjectClass(JObj);
- this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
- curEnv->DeleteLocalRef(localClass);
+ jclass localClass = curEnv->GetObjectClass(JObj);
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ curEnv->DeleteLocalRef(localClass);
- if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
- this->instance = curEnv->NewGlobalRef(JObj) ;
- if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
- /* Methods ID set to NULL */
- jintnewInstancejstringjava_lang_StringjintArray_intintID=NULL;
+ this->instance = curEnv->NewGlobalRef(JObj) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* Methods ID set to NULL */
+ jintnewInstancejstringjava_lang_StringjintArray_intintID = NULL;
}
// Generic methods
-void ScilabJavaArray::synchronize() {
-if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaArray");
-}
-}
-
-void ScilabJavaArray::endSynchronize() {
-if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaArray");
-}
-}
-// Method(s)
-
-int ScilabJavaArray::newInstance (JavaVM * jvm_, char const* name, int const* args, int argsSize){
-
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-
-jmethodID jintnewInstancejstringjava_lang_StringjintArray_intintID = curEnv->GetStaticMethodID(cls, "newInstance", "(Ljava/lang/String;[I)I" ) ;
-if (jintnewInstancejstringjava_lang_StringjintArray_intintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "newInstance");
-}
-
-jstring name_ = curEnv->NewStringUTF( name );
-if (name != NULL && name_ == NULL)
+void ScilabJavaArray::synchronize()
{
-throw GiwsException::JniBadAllocException(curEnv);
+ if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaArray");
+ }
}
-
-jintArray args_ = curEnv->NewIntArray( argsSize ) ;
-
-if (args_ == NULL)
+void ScilabJavaArray::endSynchronize()
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
+ if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaArray");
+ }
}
+// Method(s)
-curEnv->SetIntArrayRegion( args_, 0, argsSize, (jint*)(args) ) ;
-
+int ScilabJavaArray::newInstance (JavaVM * jvm_, char const* name, int const* args, int argsSize)
+{
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintnewInstancejstringjava_lang_StringjintArray_intintID ,name_, args_));
- curEnv->DeleteLocalRef(name_);
-curEnv->DeleteLocalRef(args_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintnewInstancejstringjava_lang_StringjintArray_intintID = curEnv->GetStaticMethodID(cls, "newInstance", "(Ljava/lang/String;[I)I" ) ;
+ if (jintnewInstancejstringjava_lang_StringjintArray_intintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "newInstance");
+ }
+
+ jstring name_ = curEnv->NewStringUTF( name );
+ if (name != NULL && name_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+
+ jintArray args_ = curEnv->NewIntArray( argsSize ) ;
+
+ if (args_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ curEnv->SetIntArrayRegion( args_, 0, argsSize, (jint*)(args) ) ;
+
+
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintnewInstancejstringjava_lang_StringjintArray_intintID , name_, args_));
+ curEnv->DeleteLocalRef(name_);
+ curEnv->DeleteLocalRef(args_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
#include "GiwsException.hxx"
- #if defined(_MSC_VER) /* Defined anyway with Visual */
- #include <Windows.h>
- #else
- typedef signed char byte;
- #endif
+#if defined(_MSC_VER) /* Defined anyway with Visual */
+#include <Windows.h>
+#else
+typedef signed char byte;
+#endif
#ifndef GIWSEXPORT
# endif
#endif
-namespace org_scilab_modules_external_objects_java {
-class GIWSEXPORT ScilabJavaArray {
+namespace org_scilab_modules_external_objects_java
+{
+class GIWSEXPORT ScilabJavaArray
+{
private:
-JavaVM * jvm;
+ JavaVM * jvm;
protected:
-jmethodID jintnewInstancejstringjava_lang_StringjintArray_intintID; // cache method id
+ jmethodID jintnewInstancejstringjava_lang_StringjintArray_intintID; // cache method id
-jobject instance;
-jclass instanceClass; // cache class
+ jobject instance;
+ jclass instanceClass; // cache class
-
-// Caching (if any)
+ // Caching (if any)
-/**
-* Get the environment matching to the current thread.
-*/
-virtual JNIEnv * getCurrentEnv();
+
+ /**
+ * Get the environment matching to the current thread.
+ */
+ virtual JNIEnv * getCurrentEnv();
public:
-// Constructor
-/**
-* Create a wrapping of the object from a JNIEnv.
-* It will call the default constructor
-* @param JEnv_ the Java Env
-*/
-ScilabJavaArray(JavaVM * jvm_);
+ // Constructor
+ /**
+ * Create a wrapping of the object from a JNIEnv.
+ * It will call the default constructor
+ * @param JEnv_ the Java Env
+ */
+ ScilabJavaArray(JavaVM * jvm_);
+
+ /**
+ * Create a wrapping of an already existing object from a JNIEnv.
+ * The object must have already been instantiated
+ * @param JEnv_ the Java Env
+ * @param JObj the object
+ */
+ ScilabJavaArray(JavaVM * jvm_, jobject JObj);
+
+
+ /**
+ * This is a fake constructor to avoid the constructor
+ * chaining when dealing with extended giws classes
+ */
+#ifdef FAKEGIWSDATATYPE
+ ScilabJavaArray(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
+#endif
-/**
-* Create a wrapping of an already existing object from a JNIEnv.
-* The object must have already been instantiated
-* @param JEnv_ the Java Env
-* @param JObj the object
-*/
-ScilabJavaArray(JavaVM * jvm_, jobject JObj);
+ // Destructor
+ ~ScilabJavaArray();
+ // Generic method
+ // Synchronization methods
+ /**
+ * Enter monitor associated with the object.
+ * Equivalent of creating a "synchronized(obj)" scope in Java.
+ */
+ void synchronize();
-/**
-* This is a fake constructor to avoid the constructor
-* chaining when dealing with extended giws classes
-*/
-#ifdef FAKEGIWSDATATYPE
-ScilabJavaArray(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
-#endif
+ /**
+ * Exit monitor associated with the object.
+ * Equivalent of ending a "synchronized(obj)" scope.
+ */
+ void endSynchronize();
-// Destructor
-~ScilabJavaArray();
+ // Methods
+ static int newInstance(JavaVM * jvm_, char const* name, int const* args, int argsSize);
-// Generic method
-// Synchronization methods
-/**
-* Enter monitor associated with the object.
-* Equivalent of creating a "synchronized(obj)" scope in Java.
-*/
-void synchronize();
-/**
-* Exit monitor associated with the object.
-* Equivalent of ending a "synchronized(obj)" scope.
-*/
-void endSynchronize();
-
-// Methods
-static int newInstance(JavaVM * jvm_, char const* name, int const* args, int argsSize);
-
-
- /**
- * Get class name to use for static methods
- * @return class name to use for static methods
- */
-
- static const std::string className()
- {
- return "org/scilab/modules/external_objects_java/ScilabJavaArray";
- }
-
+ /**
+ * Get class name to use for static methods
+ * @return class name to use for static methods
+ */
+
+ static const std::string className()
+ {
+ return "org/scilab/modules/external_objects_java/ScilabJavaArray";
+ }
+
};
#include "ScilabJavaClass.hxx"
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
knowledge of the CeCILL-B license and that you accept its terms.
*/
-namespace org_scilab_modules_external_objects_java {
+namespace org_scilab_modules_external_objects_java
+{
+
+// Static declarations (if any)
- // Static declarations (if any)
-
// Returns the current env
-JNIEnv * ScilabJavaClass::getCurrentEnv() {
-JNIEnv * curEnv = NULL;
-jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-if (res != JNI_OK) {
-throw GiwsException::JniException(getCurrentEnv());
-}
-return curEnv;
+JNIEnv * ScilabJavaClass::getCurrentEnv()
+{
+ JNIEnv * curEnv = NULL;
+ jint res = this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ if (res != JNI_OK)
+ {
+ throw GiwsException::JniException(getCurrentEnv());
+ }
+ return curEnv;
}
// Destructor
-ScilabJavaClass::~ScilabJavaClass() {
-JNIEnv * curEnv = NULL;
-this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-curEnv->DeleteGlobalRef(this->instance);
-curEnv->DeleteGlobalRef(this->instanceClass);
+ScilabJavaClass::~ScilabJavaClass()
+{
+ JNIEnv * curEnv = NULL;
+ this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ curEnv->DeleteGlobalRef(this->instance);
+ curEnv->DeleteGlobalRef(this->instanceClass);
}
// Constructors
-ScilabJavaClass::ScilabJavaClass(JavaVM * jvm_) {
-jmethodID constructObject = NULL ;
-jobject localInstance ;
-jclass localClass ;
+ScilabJavaClass::ScilabJavaClass(JavaVM * jvm_)
+{
+ jmethodID constructObject = NULL ;
+ jobject localInstance ;
+ jclass localClass ;
-const std::string construct="<init>";
-const std::string param="()V";
-jvm=jvm_;
+ const std::string construct = "<init>";
+ const std::string param = "()V";
+ jvm = jvm_;
-JNIEnv * curEnv = getCurrentEnv();
+ JNIEnv * curEnv = getCurrentEnv();
-localClass = curEnv->FindClass( this->className().c_str() ) ;
-if (localClass == NULL) {
- throw GiwsException::JniClassNotFoundException(curEnv, this->className());
-}
+ localClass = curEnv->FindClass( this->className().c_str() ) ;
+ if (localClass == NULL)
+ {
+ throw GiwsException::JniClassNotFoundException(curEnv, this->className());
+ }
-this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
-/* localClass is not needed anymore */
-curEnv->DeleteLocalRef(localClass);
+ /* localClass is not needed anymore */
+ curEnv->DeleteLocalRef(localClass);
-if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
-constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
-if(constructObject == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
+ constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
+ if (constructObject == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
-localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
-if(localInstance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-
-this->instance = curEnv->NewGlobalRef(localInstance) ;
-if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-/* localInstance not needed anymore */
-curEnv->DeleteLocalRef(localInstance);
+ localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
+ if (localInstance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
- /* Methods ID set to NULL */
-jintnewInstancejintintjintArray_intintID=NULL;
+ this->instance = curEnv->NewGlobalRef(localInstance) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* localInstance not needed anymore */
+ curEnv->DeleteLocalRef(localInstance);
+
+ /* Methods ID set to NULL */
+ jintnewInstancejintintjintArray_intintID = NULL;
}
-ScilabJavaClass::ScilabJavaClass(JavaVM * jvm_, jobject JObj) {
- jvm=jvm_;
+ScilabJavaClass::ScilabJavaClass(JavaVM * jvm_, jobject JObj)
+{
+ jvm = jvm_;
- JNIEnv * curEnv = getCurrentEnv();
+ JNIEnv * curEnv = getCurrentEnv();
-jclass localClass = curEnv->GetObjectClass(JObj);
- this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
- curEnv->DeleteLocalRef(localClass);
+ jclass localClass = curEnv->GetObjectClass(JObj);
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ curEnv->DeleteLocalRef(localClass);
- if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
- this->instance = curEnv->NewGlobalRef(JObj) ;
- if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
- /* Methods ID set to NULL */
- jintnewInstancejintintjintArray_intintID=NULL;
+ this->instance = curEnv->NewGlobalRef(JObj) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* Methods ID set to NULL */
+ jintnewInstancejintintjintArray_intintID = NULL;
}
// Generic methods
-void ScilabJavaClass::synchronize() {
-if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaClass");
-}
+void ScilabJavaClass::synchronize()
+{
+ if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaClass");
+ }
}
-void ScilabJavaClass::endSynchronize() {
-if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaClass");
-}
+void ScilabJavaClass::endSynchronize()
+{
+ if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaClass");
+ }
}
// Method(s)
-int ScilabJavaClass::newInstance (JavaVM * jvm_, int id, int const* args, int argsSize){
-
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-
-jmethodID jintnewInstancejintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "newInstance", "(I[I)I" ) ;
-if (jintnewInstancejintintjintArray_intintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "newInstance");
-}
-
-jintArray args_ = curEnv->NewIntArray( argsSize ) ;
-
-if (args_ == NULL)
+int ScilabJavaClass::newInstance (JavaVM * jvm_, int id, int const* args, int argsSize)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetIntArrayRegion( args_, 0, argsSize, (jint*)(args) ) ;
-
-
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintnewInstancejintintjintArray_intintID ,id, args_));
- curEnv->DeleteLocalRef(args_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintnewInstancejintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "newInstance", "(I[I)I" ) ;
+ if (jintnewInstancejintintjintArray_intintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "newInstance");
+ }
+
+ jintArray args_ = curEnv->NewIntArray( argsSize ) ;
+
+ if (args_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ curEnv->SetIntArrayRegion( args_, 0, argsSize, (jint*)(args) ) ;
+
+
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintnewInstancejintintjintArray_intintID , id, args_));
+ curEnv->DeleteLocalRef(args_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
#include "GiwsException.hxx"
- #if defined(_MSC_VER) /* Defined anyway with Visual */
- #include <Windows.h>
- #else
- typedef signed char byte;
- #endif
+#if defined(_MSC_VER) /* Defined anyway with Visual */
+#include <Windows.h>
+#else
+typedef signed char byte;
+#endif
#ifndef GIWSEXPORT
# endif
#endif
-namespace org_scilab_modules_external_objects_java {
-class GIWSEXPORT ScilabJavaClass {
+namespace org_scilab_modules_external_objects_java
+{
+class GIWSEXPORT ScilabJavaClass
+{
private:
-JavaVM * jvm;
+ JavaVM * jvm;
protected:
-jmethodID jintnewInstancejintintjintArray_intintID; // cache method id
+ jmethodID jintnewInstancejintintjintArray_intintID; // cache method id
-jobject instance;
-jclass instanceClass; // cache class
+ jobject instance;
+ jclass instanceClass; // cache class
-
-// Caching (if any)
+ // Caching (if any)
-/**
-* Get the environment matching to the current thread.
-*/
-virtual JNIEnv * getCurrentEnv();
+
+ /**
+ * Get the environment matching to the current thread.
+ */
+ virtual JNIEnv * getCurrentEnv();
public:
-// Constructor
-/**
-* Create a wrapping of the object from a JNIEnv.
-* It will call the default constructor
-* @param JEnv_ the Java Env
-*/
-ScilabJavaClass(JavaVM * jvm_);
+ // Constructor
+ /**
+ * Create a wrapping of the object from a JNIEnv.
+ * It will call the default constructor
+ * @param JEnv_ the Java Env
+ */
+ ScilabJavaClass(JavaVM * jvm_);
+
+ /**
+ * Create a wrapping of an already existing object from a JNIEnv.
+ * The object must have already been instantiated
+ * @param JEnv_ the Java Env
+ * @param JObj the object
+ */
+ ScilabJavaClass(JavaVM * jvm_, jobject JObj);
+
+
+ /**
+ * This is a fake constructor to avoid the constructor
+ * chaining when dealing with extended giws classes
+ */
+#ifdef FAKEGIWSDATATYPE
+ ScilabJavaClass(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
+#endif
-/**
-* Create a wrapping of an already existing object from a JNIEnv.
-* The object must have already been instantiated
-* @param JEnv_ the Java Env
-* @param JObj the object
-*/
-ScilabJavaClass(JavaVM * jvm_, jobject JObj);
+ // Destructor
+ ~ScilabJavaClass();
+ // Generic method
+ // Synchronization methods
+ /**
+ * Enter monitor associated with the object.
+ * Equivalent of creating a "synchronized(obj)" scope in Java.
+ */
+ void synchronize();
-/**
-* This is a fake constructor to avoid the constructor
-* chaining when dealing with extended giws classes
-*/
-#ifdef FAKEGIWSDATATYPE
-ScilabJavaClass(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
-#endif
+ /**
+ * Exit monitor associated with the object.
+ * Equivalent of ending a "synchronized(obj)" scope.
+ */
+ void endSynchronize();
-// Destructor
-~ScilabJavaClass();
+ // Methods
+ static int newInstance(JavaVM * jvm_, int id, int const* args, int argsSize);
-// Generic method
-// Synchronization methods
-/**
-* Enter monitor associated with the object.
-* Equivalent of creating a "synchronized(obj)" scope in Java.
-*/
-void synchronize();
-/**
-* Exit monitor associated with the object.
-* Equivalent of ending a "synchronized(obj)" scope.
-*/
-void endSynchronize();
-
-// Methods
-static int newInstance(JavaVM * jvm_, int id, int const* args, int argsSize);
-
-
- /**
- * Get class name to use for static methods
- * @return class name to use for static methods
- */
-
- static const std::string className()
- {
- return "org/scilab/modules/external_objects_java/ScilabJavaClass";
- }
-
+ /**
+ * Get class name to use for static methods
+ * @return class name to use for static methods
+ */
+
+ static const std::string className()
+ {
+ return "org/scilab/modules/external_objects_java/ScilabJavaClass";
+ }
+
};
#include "ScilabJavaCompiler.hxx"
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
knowledge of the CeCILL-B license and that you accept its terms.
*/
-namespace org_scilab_modules_external_objects_java {
+namespace org_scilab_modules_external_objects_java
+{
+
+// Static declarations (if any)
- // Static declarations (if any)
-
// Returns the current env
-JNIEnv * ScilabJavaCompiler::getCurrentEnv() {
-JNIEnv * curEnv = NULL;
-jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-if (res != JNI_OK) {
-throw GiwsException::JniException(getCurrentEnv());
-}
-return curEnv;
+JNIEnv * ScilabJavaCompiler::getCurrentEnv()
+{
+ JNIEnv * curEnv = NULL;
+ jint res = this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ if (res != JNI_OK)
+ {
+ throw GiwsException::JniException(getCurrentEnv());
+ }
+ return curEnv;
}
// Destructor
-ScilabJavaCompiler::~ScilabJavaCompiler() {
-JNIEnv * curEnv = NULL;
-this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-curEnv->DeleteGlobalRef(this->instance);
-curEnv->DeleteGlobalRef(this->instanceClass);
-curEnv->DeleteGlobalRef(this->stringArrayClass);}
+ScilabJavaCompiler::~ScilabJavaCompiler()
+{
+ JNIEnv * curEnv = NULL;
+ this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ curEnv->DeleteGlobalRef(this->instance);
+ curEnv->DeleteGlobalRef(this->instanceClass);
+ curEnv->DeleteGlobalRef(this->stringArrayClass);
+}
// Constructors
-ScilabJavaCompiler::ScilabJavaCompiler(JavaVM * jvm_) {
-jmethodID constructObject = NULL ;
-jobject localInstance ;
-jclass localClass ;
+ScilabJavaCompiler::ScilabJavaCompiler(JavaVM * jvm_)
+{
+ jmethodID constructObject = NULL ;
+ jobject localInstance ;
+ jclass localClass ;
-const std::string construct="<init>";
-const std::string param="()V";
-jvm=jvm_;
+ const std::string construct = "<init>";
+ const std::string param = "()V";
+ jvm = jvm_;
-JNIEnv * curEnv = getCurrentEnv();
+ JNIEnv * curEnv = getCurrentEnv();
-localClass = curEnv->FindClass( this->className().c_str() ) ;
-if (localClass == NULL) {
- throw GiwsException::JniClassNotFoundException(curEnv, this->className());
-}
+ localClass = curEnv->FindClass( this->className().c_str() ) ;
+ if (localClass == NULL)
+ {
+ throw GiwsException::JniClassNotFoundException(curEnv, this->className());
+ }
-this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
-/* localClass is not needed anymore */
-curEnv->DeleteLocalRef(localClass);
+ /* localClass is not needed anymore */
+ curEnv->DeleteLocalRef(localClass);
-if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
-constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
-if(constructObject == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
+ constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
+ if (constructObject == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
-localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
-if(localInstance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-
-this->instance = curEnv->NewGlobalRef(localInstance) ;
-if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-/* localInstance not needed anymore */
-curEnv->DeleteLocalRef(localInstance);
+ localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
+ if (localInstance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
- /* Methods ID set to NULL */
-jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
+ this->instance = curEnv->NewGlobalRef(localInstance) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* localInstance not needed anymore */
+ curEnv->DeleteLocalRef(localInstance);
+
+ /* Methods ID set to NULL */
+ jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID = NULL;
}
-ScilabJavaCompiler::ScilabJavaCompiler(JavaVM * jvm_, jobject JObj) {
- jvm=jvm_;
+ScilabJavaCompiler::ScilabJavaCompiler(JavaVM * jvm_, jobject JObj)
+{
+ jvm = jvm_;
- JNIEnv * curEnv = getCurrentEnv();
+ JNIEnv * curEnv = getCurrentEnv();
-jclass localClass = curEnv->GetObjectClass(JObj);
- this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
- curEnv->DeleteLocalRef(localClass);
+ jclass localClass = curEnv->GetObjectClass(JObj);
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ curEnv->DeleteLocalRef(localClass);
- if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
- this->instance = curEnv->NewGlobalRef(JObj) ;
- if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
- /* Methods ID set to NULL */
- jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
+ this->instance = curEnv->NewGlobalRef(JObj) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* Methods ID set to NULL */
+ jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID = NULL;
}
// Generic methods
-void ScilabJavaCompiler::synchronize() {
-if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaCompiler");
-}
-}
-
-void ScilabJavaCompiler::endSynchronize() {
-if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaCompiler");
-}
-}
-// Method(s)
-
-int ScilabJavaCompiler::compileCode (JavaVM * jvm_, char const* classname, char const* const* code, int codeSize){
-
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-
-jmethodID jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "compileCode", "(Ljava/lang/String;[Ljava/lang/String;)I" ) ;
-if (jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "compileCode");
-}
-
-jstring classname_ = curEnv->NewStringUTF( classname );
-if (classname != NULL && classname_ == NULL)
+void ScilabJavaCompiler::synchronize()
{
-throw GiwsException::JniBadAllocException(curEnv);
+ if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaCompiler");
+ }
}
-jclass stringArrayClass = curEnv->FindClass("java/lang/String");
-
-// create java array of strings.
-jobjectArray code_ = curEnv->NewObjectArray( codeSize, stringArrayClass, NULL);
-if (code_ == NULL)
+void ScilabJavaCompiler::endSynchronize()
{
-throw GiwsException::JniBadAllocException(curEnv);
+ if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaCompiler");
+ }
}
+// Method(s)
-// convert each char * to java strings and fill the java array.
-for ( int i = 0; i < codeSize; i++)
-{
-jstring TempString = curEnv->NewStringUTF( code[i] );
-if (TempString == NULL)
+int ScilabJavaCompiler::compileCode (JavaVM * jvm_, char const* classname, char const* const* code, int codeSize)
{
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetObjectArrayElement( code_, i, TempString);
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "compileCode", "(Ljava/lang/String;[Ljava/lang/String;)I" ) ;
+ if (jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "compileCode");
+ }
+
+ jstring classname_ = curEnv->NewStringUTF( classname );
+ if (classname != NULL && classname_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ jclass stringArrayClass = curEnv->FindClass("java/lang/String");
+
+ // create java array of strings.
+ jobjectArray code_ = curEnv->NewObjectArray( codeSize, stringArrayClass, NULL);
+ if (code_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ // convert each char * to java strings and fill the java array.
+ for ( int i = 0; i < codeSize; i++)
+ {
+ jstring TempString = curEnv->NewStringUTF( code[i] );
+ if (TempString == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-// avoid keeping reference on to many strings
-curEnv->DeleteLocalRef(TempString);
-}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID ,classname_, code_));
- curEnv->DeleteLocalRef(stringArrayClass);
-curEnv->DeleteLocalRef(classname_);
-curEnv->DeleteLocalRef(code_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ curEnv->SetObjectArrayElement( code_, i, TempString);
+
+ // avoid keeping reference on too many strings
+ curEnv->DeleteLocalRef(TempString);
+ }
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID , classname_, code_));
+ curEnv->DeleteLocalRef(stringArrayClass);
+ curEnv->DeleteLocalRef(classname_);
+ curEnv->DeleteLocalRef(code_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
#include "GiwsException.hxx"
- #if defined(_MSC_VER) /* Defined anyway with Visual */
- #include <Windows.h>
- #else
- typedef signed char byte;
- #endif
+#if defined(_MSC_VER) /* Defined anyway with Visual */
+#include <Windows.h>
+#else
+typedef signed char byte;
+#endif
#ifndef GIWSEXPORT
# endif
#endif
-namespace org_scilab_modules_external_objects_java {
-class GIWSEXPORT ScilabJavaCompiler {
+namespace org_scilab_modules_external_objects_java
+{
+class GIWSEXPORT ScilabJavaCompiler
+{
private:
-JavaVM * jvm;
+ JavaVM * jvm;
protected:
-jmethodID jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID; // cache method id
-jclass stringArrayClass;
+ jmethodID jintcompileCodejstringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringID; // cache method id
+ jclass stringArrayClass;
-jobject instance;
-jclass instanceClass; // cache class
+ jobject instance;
+ jclass instanceClass; // cache class
-
-// Caching (if any)
+ // Caching (if any)
-/**
-* Get the environment matching to the current thread.
-*/
-virtual JNIEnv * getCurrentEnv();
+
+ /**
+ * Get the environment matching to the current thread.
+ */
+ virtual JNIEnv * getCurrentEnv();
public:
-// Constructor
-/**
-* Create a wrapping of the object from a JNIEnv.
-* It will call the default constructor
-* @param JEnv_ the Java Env
-*/
-ScilabJavaCompiler(JavaVM * jvm_);
+ // Constructor
+ /**
+ * Create a wrapping of the object from a JNIEnv.
+ * It will call the default constructor
+ * @param JEnv_ the Java Env
+ */
+ ScilabJavaCompiler(JavaVM * jvm_);
+
+ /**
+ * Create a wrapping of an already existing object from a JNIEnv.
+ * The object must have already been instantiated
+ * @param JEnv_ the Java Env
+ * @param JObj the object
+ */
+ ScilabJavaCompiler(JavaVM * jvm_, jobject JObj);
+
+
+ /**
+ * This is a fake constructor to avoid the constructor
+ * chaining when dealing with extended giws classes
+ */
+#ifdef FAKEGIWSDATATYPE
+ ScilabJavaCompiler(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
+#endif
-/**
-* Create a wrapping of an already existing object from a JNIEnv.
-* The object must have already been instantiated
-* @param JEnv_ the Java Env
-* @param JObj the object
-*/
-ScilabJavaCompiler(JavaVM * jvm_, jobject JObj);
+ // Destructor
+ ~ScilabJavaCompiler();
+ // Generic method
+ // Synchronization methods
+ /**
+ * Enter monitor associated with the object.
+ * Equivalent of creating a "synchronized(obj)" scope in Java.
+ */
+ void synchronize();
-/**
-* This is a fake constructor to avoid the constructor
-* chaining when dealing with extended giws classes
-*/
-#ifdef FAKEGIWSDATATYPE
-ScilabJavaCompiler(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
-#endif
+ /**
+ * Exit monitor associated with the object.
+ * Equivalent of ending a "synchronized(obj)" scope.
+ */
+ void endSynchronize();
-// Destructor
-~ScilabJavaCompiler();
+ // Methods
+ static int compileCode(JavaVM * jvm_, char const* classname, char const* const* code, int codeSize);
-// Generic method
-// Synchronization methods
-/**
-* Enter monitor associated with the object.
-* Equivalent of creating a "synchronized(obj)" scope in Java.
-*/
-void synchronize();
-/**
-* Exit monitor associated with the object.
-* Equivalent of ending a "synchronized(obj)" scope.
-*/
-void endSynchronize();
-
-// Methods
-static int compileCode(JavaVM * jvm_, char const* classname, char const* const* code, int codeSize);
-
-
- /**
- * Get class name to use for static methods
- * @return class name to use for static methods
- */
-
- static const std::string className()
- {
- return "org/scilab/modules/external_objects_java/ScilabJavaCompiler";
- }
-
+ /**
+ * Get class name to use for static methods
+ * @return class name to use for static methods
+ */
+
+ static const std::string className()
+ {
+ return "org/scilab/modules/external_objects_java/ScilabJavaCompiler";
+ }
+
};
#include "ScilabJavaObject.hxx"
/* Generated by GIWS (version 2.0.2) with command:
-giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
+giws -e -r -f ScilabObjects.giws.xml
*/
/*
knowledge of the CeCILL-B license and that you accept its terms.
*/
-namespace org_scilab_modules_external_objects_java {
+namespace org_scilab_modules_external_objects_java
+{
+
+// Static declarations (if any)
- // Static declarations (if any)
-
// Returns the current env
-JNIEnv * ScilabJavaObject::getCurrentEnv() {
-JNIEnv * curEnv = NULL;
-jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-if (res != JNI_OK) {
-throw GiwsException::JniException(getCurrentEnv());
-}
-return curEnv;
+JNIEnv * ScilabJavaObject::getCurrentEnv()
+{
+ JNIEnv * curEnv = NULL;
+ jint res = this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ if (res != JNI_OK)
+ {
+ throw GiwsException::JniException(getCurrentEnv());
+ }
+ return curEnv;
}
// Destructor
-ScilabJavaObject::~ScilabJavaObject() {
-JNIEnv * curEnv = NULL;
-this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-curEnv->DeleteGlobalRef(this->instance);
-curEnv->DeleteGlobalRef(this->instanceClass);
-curEnv->DeleteGlobalRef(this->stringArrayClass);}
+ScilabJavaObject::~ScilabJavaObject()
+{
+ JNIEnv * curEnv = NULL;
+ this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ curEnv->DeleteGlobalRef(this->instance);
+ curEnv->DeleteGlobalRef(this->instanceClass);
+ curEnv->DeleteGlobalRef(this->stringArrayClass);
+}
// Constructors
-ScilabJavaObject::ScilabJavaObject(JavaVM * jvm_) {
-jmethodID constructObject = NULL ;
-jobject localInstance ;
-jclass localClass ;
-
-const std::string construct="<init>";
-const std::string param="()V";
-jvm=jvm_;
-
-JNIEnv * curEnv = getCurrentEnv();
-
-localClass = curEnv->FindClass( this->className().c_str() ) ;
-if (localClass == NULL) {
- throw GiwsException::JniClassNotFoundException(curEnv, this->className());
-}
-
-this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
-
-/* localClass is not needed anymore */
-curEnv->DeleteLocalRef(localClass);
-
-if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-
-
-constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
-if(constructObject == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-
-localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
-if(localInstance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-
-this->instance = curEnv->NewGlobalRef(localInstance) ;
-if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
-}
-/* localInstance not needed anymore */
-curEnv->DeleteLocalRef(localInstance);
-
- /* Methods ID set to NULL */
-jintinvokejintintjstringjava_lang_StringjintArray_intintID=NULL;
-voidinitScilabJavaObjectID=NULL;
-voidgarbageCollectID=NULL;
-jstringgetRepresentationjintintID=NULL;
-jbooleanisValidJavaObjectjintintID=NULL;
-voidenableTracejstringjava_lang_StringID=NULL;
-voiddisableTraceID=NULL;
-voidsetFieldjintintjstringjava_lang_StringjintintID=NULL;
-jintgetFieldjintintjstringjava_lang_StringID=NULL;
-jintgetFieldTypejintintjstringjava_lang_StringID=NULL;
-jintjavaCastjintintjstringjava_lang_StringID=NULL;
-jintjavaCastjintintjintintID=NULL;
-jstringgetClassNamejintintID=NULL;
-jintgetArrayElementjintintjintArray_intintID=NULL;
-voidsetArrayElementjintintjintArray_intintjintintID=NULL;
-voidremoveScilabJavaObjectjintintID=NULL;
-voidlimitDirectBufferjintintID=NULL;
-jintisUnwrappablejintintID=NULL;
-jintwrapDoublejdoubledoubleID=NULL;
-jintwrapDoublejdoubleArray_doubledoubleID=NULL;
-jintwrapDoublejobjectArray__doubledoubleID=NULL;
-jintwrapIntjintintID=NULL;
-jintwrapIntjintArray_intintID=NULL;
-jintwrapIntjobjectArray__intintID=NULL;
-jintwrapUIntjlonglongID=NULL;
-jintwrapUIntjlongArray_longlongID=NULL;
-jintwrapUIntjobjectArray__longlongID=NULL;
-jintwrapBytejbytebyteID=NULL;
-jintwrapBytejbyteArray_bytebyteID=NULL;
-jintwrapBytejobjectArray__bytebyteID=NULL;
-jintwrapUBytejshortshortID=NULL;
-jintwrapUBytejshortArray_shortshortID=NULL;
-jintwrapUBytejobjectArray__shortshortID=NULL;
-jintwrapShortjshortshortID=NULL;
-jintwrapShortjshortArray_shortshortID=NULL;
-jintwrapShortjobjectArray__shortshortID=NULL;
-jintwrapUShortjintintID=NULL;
-jintwrapUShortjintArray_intintID=NULL;
-jintwrapUShortjobjectArray__intintID=NULL;
-jintwrapStringjstringjava_lang_StringID=NULL;
-jintwrapStringjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
-jintwrapStringjobjectArray__java_lang_Stringjava_lang_StringID=NULL;
-jintwrapBooleanjbooleanbooleanID=NULL;
-jintwrapBooleanjbooleanArray_booleanbooleanID=NULL;
-jintwrapBooleanjobjectArray__booleanbooleanID=NULL;
-jintwrapCharjcharcharID=NULL;
-jintwrapCharjcharArray_charcharID=NULL;
-jintwrapCharjobjectArray__charcharID=NULL;
-jintwrapFloatjfloatfloatID=NULL;
-jintwrapFloatjfloatArray_floatfloatID=NULL;
-jintwrapFloatjobjectArray__floatfloatID=NULL;
-jintwrapLongjlonglongID=NULL;
-jintwrapLongjlongArray_longlongID=NULL;
-jintwrapLongjobjectArray__longlongID=NULL;
-jdoubleunwrapDoublejintintID=NULL;
-jdoubleArray_unwrapRowDoublejintintID=NULL;
-jobjectArray__unwrapMatDoublejintintID=NULL;
-jintunwrapIntjintintID=NULL;
-jintArray_unwrapRowIntjintintID=NULL;
-jobjectArray__unwrapMatIntjintintID=NULL;
-jlongunwrapUIntjintintID=NULL;
-jlongArray_unwrapRowUIntjintintID=NULL;
-jobjectArray__unwrapMatUIntjintintID=NULL;
-jbyteunwrapBytejintintID=NULL;
-jbyteArray_unwrapRowBytejintintID=NULL;
-jobjectArray__unwrapMatBytejintintID=NULL;
-jshortunwrapUBytejintintID=NULL;
-jshortArray_unwrapRowUBytejintintID=NULL;
-jobjectArray__unwrapMatUBytejintintID=NULL;
-jshortunwrapShortjintintID=NULL;
-jshortArray_unwrapRowShortjintintID=NULL;
-jobjectArray__unwrapMatShortjintintID=NULL;
-jintunwrapUShortjintintID=NULL;
-jintArray_unwrapRowUShortjintintID=NULL;
-jobjectArray__unwrapMatUShortjintintID=NULL;
-jstringunwrapStringjintintID=NULL;
-jobjectArray_unwrapRowStringjintintID=NULL;
-jobjectArray__unwrapMatStringjintintID=NULL;
-jbooleanunwrapBooleanjintintID=NULL;
-jbooleanArray_unwrapRowBooleanjintintID=NULL;
-jobjectArray__unwrapMatBooleanjintintID=NULL;
-jcharunwrapCharjintintID=NULL;
-jcharArray_unwrapRowCharjintintID=NULL;
-jobjectArray__unwrapMatCharjintintID=NULL;
-jfloatunwrapFloatjintintID=NULL;
-jfloatArray_unwrapRowFloatjintintID=NULL;
-jobjectArray__unwrapMatFloatjintintID=NULL;
-jlongunwrapLongjintintID=NULL;
-jlongArray_unwrapRowLongjintintID=NULL;
-jobjectArray__unwrapMatLongjintintID=NULL;
-
-
-}
-
-ScilabJavaObject::ScilabJavaObject(JavaVM * jvm_, jobject JObj) {
- jvm=jvm_;
-
- JNIEnv * curEnv = getCurrentEnv();
-
-jclass localClass = curEnv->GetObjectClass(JObj);
- this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
- curEnv->DeleteLocalRef(localClass);
-
- if (this->instanceClass == NULL) {
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
-
- this->instance = curEnv->NewGlobalRef(JObj) ;
- if(this->instance == NULL){
-throw GiwsException::JniObjectCreationException(curEnv, this->className());
- }
- /* Methods ID set to NULL */
- jintinvokejintintjstringjava_lang_StringjintArray_intintID=NULL;
-voidinitScilabJavaObjectID=NULL;
-voidgarbageCollectID=NULL;
-jstringgetRepresentationjintintID=NULL;
-jbooleanisValidJavaObjectjintintID=NULL;
-voidenableTracejstringjava_lang_StringID=NULL;
-voiddisableTraceID=NULL;
-voidsetFieldjintintjstringjava_lang_StringjintintID=NULL;
-jintgetFieldjintintjstringjava_lang_StringID=NULL;
-jintgetFieldTypejintintjstringjava_lang_StringID=NULL;
-jintjavaCastjintintjstringjava_lang_StringID=NULL;
-jintjavaCastjintintjintintID=NULL;
-jstringgetClassNamejintintID=NULL;
-jintgetArrayElementjintintjintArray_intintID=NULL;
-voidsetArrayElementjintintjintArray_intintjintintID=NULL;
-voidremoveScilabJavaObjectjintintID=NULL;
-voidlimitDirectBufferjintintID=NULL;
-jintisUnwrappablejintintID=NULL;
-jintwrapDoublejdoubledoubleID=NULL;
-jintwrapDoublejdoubleArray_doubledoubleID=NULL;
-jintwrapDoublejobjectArray__doubledoubleID=NULL;
-jintwrapIntjintintID=NULL;
-jintwrapIntjintArray_intintID=NULL;
-jintwrapIntjobjectArray__intintID=NULL;
-jintwrapUIntjlonglongID=NULL;
-jintwrapUIntjlongArray_longlongID=NULL;
-jintwrapUIntjobjectArray__longlongID=NULL;
-jintwrapBytejbytebyteID=NULL;
-jintwrapBytejbyteArray_bytebyteID=NULL;
-jintwrapBytejobjectArray__bytebyteID=NULL;
-jintwrapUBytejshortshortID=NULL;
-jintwrapUBytejshortArray_shortshortID=NULL;
-jintwrapUBytejobjectArray__shortshortID=NULL;
-jintwrapShortjshortshortID=NULL;
-jintwrapShortjshortArray_shortshortID=NULL;
-jintwrapShortjobjectArray__shortshortID=NULL;
-jintwrapUShortjintintID=NULL;
-jintwrapUShortjintArray_intintID=NULL;
-jintwrapUShortjobjectArray__intintID=NULL;
-jintwrapStringjstringjava_lang_StringID=NULL;
-jintwrapStringjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
-jintwrapStringjobjectArray__java_lang_Stringjava_lang_StringID=NULL;
-jintwrapBooleanjbooleanbooleanID=NULL;
-jintwrapBooleanjbooleanArray_booleanbooleanID=NULL;
-jintwrapBooleanjobjectArray__booleanbooleanID=NULL;
-jintwrapCharjcharcharID=NULL;
-jintwrapCharjcharArray_charcharID=NULL;
-jintwrapCharjobjectArray__charcharID=NULL;
-jintwrapFloatjfloatfloatID=NULL;
-jintwrapFloatjfloatArray_floatfloatID=NULL;
-jintwrapFloatjobjectArray__floatfloatID=NULL;
-jintwrapLongjlonglongID=NULL;
-jintwrapLongjlongArray_longlongID=NULL;
-jintwrapLongjobjectArray__longlongID=NULL;
-jdoubleunwrapDoublejintintID=NULL;
-jdoubleArray_unwrapRowDoublejintintID=NULL;
-jobjectArray__unwrapMatDoublejintintID=NULL;
-jintunwrapIntjintintID=NULL;
-jintArray_unwrapRowIntjintintID=NULL;
-jobjectArray__unwrapMatIntjintintID=NULL;
-jlongunwrapUIntjintintID=NULL;
-jlongArray_unwrapRowUIntjintintID=NULL;
-jobjectArray__unwrapMatUIntjintintID=NULL;
-jbyteunwrapBytejintintID=NULL;
-jbyteArray_unwrapRowBytejintintID=NULL;
-jobjectArray__unwrapMatBytejintintID=NULL;
-jshortunwrapUBytejintintID=NULL;
-jshortArray_unwrapRowUBytejintintID=NULL;
-jobjectArray__unwrapMatUBytejintintID=NULL;
-jshortunwrapShortjintintID=NULL;
-jshortArray_unwrapRowShortjintintID=NULL;
-jobjectArray__unwrapMatShortjintintID=NULL;
-jintunwrapUShortjintintID=NULL;
-jintArray_unwrapRowUShortjintintID=NULL;
-jobjectArray__unwrapMatUShortjintintID=NULL;
-jstringunwrapStringjintintID=NULL;
-jobjectArray_unwrapRowStringjintintID=NULL;
-jobjectArray__unwrapMatStringjintintID=NULL;
-jbooleanunwrapBooleanjintintID=NULL;
-jbooleanArray_unwrapRowBooleanjintintID=NULL;
-jobjectArray__unwrapMatBooleanjintintID=NULL;
-jcharunwrapCharjintintID=NULL;
-jcharArray_unwrapRowCharjintintID=NULL;
-jobjectArray__unwrapMatCharjintintID=NULL;
-jfloatunwrapFloatjintintID=NULL;
-jfloatArray_unwrapRowFloatjintintID=NULL;
-jobjectArray__unwrapMatFloatjintintID=NULL;
-jlongunwrapLongjintintID=NULL;
-jlongArray_unwrapRowLongjintintID=NULL;
-jobjectArray__unwrapMatLongjintintID=NULL;
+ScilabJavaObject::ScilabJavaObject(JavaVM * jvm_)
+{
+ jmethodID constructObject = NULL ;
+ jobject localInstance ;
+ jclass localClass ;
+
+ const std::string construct = "<init>";
+ const std::string param = "()V";
+ jvm = jvm_;
+
+ JNIEnv * curEnv = getCurrentEnv();
+
+ localClass = curEnv->FindClass( this->className().c_str() ) ;
+ if (localClass == NULL)
+ {
+ throw GiwsException::JniClassNotFoundException(curEnv, this->className());
+ }
+
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+
+ /* localClass is not needed anymore */
+ curEnv->DeleteLocalRef(localClass);
+
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+
+
+ constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
+ if (constructObject == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+
+ localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
+ if (localInstance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+
+ this->instance = curEnv->NewGlobalRef(localInstance) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* localInstance not needed anymore */
+ curEnv->DeleteLocalRef(localInstance);
+
+ /* Methods ID set to NULL */
+ jintinvokejintintjstringjava_lang_StringjintArray_intintID = NULL;
+ voidinitScilabJavaObjectID = NULL;
+ voidgarbageCollectID = NULL;
+ jstringgetRepresentationjintintID = NULL;
+ jbooleanisValidJavaObjectjintintID = NULL;
+ voidenableTracejstringjava_lang_StringID = NULL;
+ voiddisableTraceID = NULL;
+ voidsetFieldjintintjstringjava_lang_StringjintintID = NULL;
+ jintgetFieldjintintjstringjava_lang_StringID = NULL;
+ jintgetFieldTypejintintjstringjava_lang_StringID = NULL;
+ jintjavaCastjintintjstringjava_lang_StringID = NULL;
+ jintjavaCastjintintjintintID = NULL;
+ jstringgetClassNamejintintID = NULL;
+ jintgetArrayElementjintintjintArray_intintID = NULL;
+ voidsetArrayElementjintintjintArray_intintjintintID = NULL;
+ voidremoveScilabJavaObjectjintintID = NULL;
+ voidlimitDirectBufferjintintID = NULL;
+ jintisUnwrappablejintintID = NULL;
+ jintwrapjdoubledoubleID = NULL;
+ jintwrapjdoubleArray_doubledoubleID = NULL;
+ jintwrapjobjectArray__doubledoubleID = NULL;
+ jintwrapjintintID = NULL;
+ jintwrapjintArray_intintID = NULL;
+ jintwrapjobjectArray__intintID = NULL;
+ jintwrapjbytebyteID = NULL;
+ jintwrapjbyteArray_bytebyteID = NULL;
+ jintwrapjobjectArray__bytebyteID = NULL;
+ jintwrapjshortshortID = NULL;
+ jintwrapjshortArray_shortshortID = NULL;
+ jintwrapjobjectArray__shortshortID = NULL;
+ jintwrapjstringjava_lang_StringID = NULL;
+ jintwrapjobjectArray_java_lang_Stringjava_lang_StringID = NULL;
+ jintwrapjobjectArray__java_lang_Stringjava_lang_StringID = NULL;
+ jintwrapjbooleanbooleanID = NULL;
+ jintwrapjbooleanArray_booleanbooleanID = NULL;
+ jintwrapjobjectArray__booleanbooleanID = NULL;
+ jintwrapjcharcharID = NULL;
+ jintwrapjcharArray_charcharID = NULL;
+ jintwrapjobjectArray__charcharID = NULL;
+ jintwrapjfloatfloatID = NULL;
+ jintwrapjfloatArray_floatfloatID = NULL;
+ jintwrapjobjectArray__floatfloatID = NULL;
+ jintwrapjlonglongID = NULL;
+ jintwrapjlongArray_longlongID = NULL;
+ jintwrapjobjectArray__longlongID = NULL;
+ jdoubleunwrapDoublejintintID = NULL;
+ jdoubleArray_unwrapRowDoublejintintID = NULL;
+ jobjectArray__unwrapMatDoublejintintID = NULL;
+ jintunwrapIntjintintID = NULL;
+ jintArray_unwrapRowIntjintintID = NULL;
+ jobjectArray__unwrapMatIntjintintID = NULL;
+ jlongunwrapUIntjintintID = NULL;
+ jlongArray_unwrapRowUIntjintintID = NULL;
+ jobjectArray__unwrapMatUIntjintintID = NULL;
+ jbyteunwrapBytejintintID = NULL;
+ jbyteArray_unwrapRowBytejintintID = NULL;
+ jobjectArray__unwrapMatBytejintintID = NULL;
+ jshortunwrapUBytejintintID = NULL;
+ jshortArray_unwrapRowUBytejintintID = NULL;
+ jobjectArray__unwrapMatUBytejintintID = NULL;
+ jshortunwrapShortjintintID = NULL;
+ jshortArray_unwrapRowShortjintintID = NULL;
+ jobjectArray__unwrapMatShortjintintID = NULL;
+ jintunwrapUShortjintintID = NULL;
+ jintArray_unwrapRowUShortjintintID = NULL;
+ jobjectArray__unwrapMatUShortjintintID = NULL;
+ jstringunwrapStringjintintID = NULL;
+ jobjectArray_unwrapRowStringjintintID = NULL;
+ jobjectArray__unwrapMatStringjintintID = NULL;
+ jbooleanunwrapBooleanjintintID = NULL;
+ jbooleanArray_unwrapRowBooleanjintintID = NULL;
+ jobjectArray__unwrapMatBooleanjintintID = NULL;
+ jcharunwrapCharjintintID = NULL;
+ jcharArray_unwrapRowCharjintintID = NULL;
+ jobjectArray__unwrapMatCharjintintID = NULL;
+ jfloatunwrapFloatjintintID = NULL;
+ jfloatArray_unwrapRowFloatjintintID = NULL;
+ jobjectArray__unwrapMatFloatjintintID = NULL;
+ jlongunwrapLongjintintID = NULL;
+ jlongArray_unwrapRowLongjintintID = NULL;
+ jobjectArray__unwrapMatLongjintintID = NULL;
+
+
+}
+
+ScilabJavaObject::ScilabJavaObject(JavaVM * jvm_, jobject JObj)
+{
+ jvm = jvm_;
+
+ JNIEnv * curEnv = getCurrentEnv();
+
+ jclass localClass = curEnv->GetObjectClass(JObj);
+ this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+ curEnv->DeleteLocalRef(localClass);
+
+ if (this->instanceClass == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+
+ this->instance = curEnv->NewGlobalRef(JObj) ;
+ if (this->instance == NULL)
+ {
+ throw GiwsException::JniObjectCreationException(curEnv, this->className());
+ }
+ /* Methods ID set to NULL */
+ jintinvokejintintjstringjava_lang_StringjintArray_intintID = NULL;
+ voidinitScilabJavaObjectID = NULL;
+ voidgarbageCollectID = NULL;
+ jstringgetRepresentationjintintID = NULL;
+ jbooleanisValidJavaObjectjintintID = NULL;
+ voidenableTracejstringjava_lang_StringID = NULL;
+ voiddisableTraceID = NULL;
+ voidsetFieldjintintjstringjava_lang_StringjintintID = NULL;
+ jintgetFieldjintintjstringjava_lang_StringID = NULL;
+ jintgetFieldTypejintintjstringjava_lang_StringID = NULL;
+ jintjavaCastjintintjstringjava_lang_StringID = NULL;
+ jintjavaCastjintintjintintID = NULL;
+ jstringgetClassNamejintintID = NULL;
+ jintgetArrayElementjintintjintArray_intintID = NULL;
+ voidsetArrayElementjintintjintArray_intintjintintID = NULL;
+ voidremoveScilabJavaObjectjintintID = NULL;
+ voidlimitDirectBufferjintintID = NULL;
+ jintisUnwrappablejintintID = NULL;
+ jintwrapjdoubledoubleID = NULL;
+ jintwrapjdoubleArray_doubledoubleID = NULL;
+ jintwrapjobjectArray__doubledoubleID = NULL;
+ jintwrapjintintID = NULL;
+ jintwrapjintArray_intintID = NULL;
+ jintwrapjobjectArray__intintID = NULL;
+ jintwrapjbytebyteID = NULL;
+ jintwrapjbyteArray_bytebyteID = NULL;
+ jintwrapjobjectArray__bytebyteID = NULL;
+ jintwrapjshortshortID = NULL;
+ jintwrapjshortArray_shortshortID = NULL;
+ jintwrapjobjectArray__shortshortID = NULL;
+ jintwrapjstringjava_lang_StringID = NULL;
+ jintwrapjobjectArray_java_lang_Stringjava_lang_StringID = NULL;
+ jintwrapjobjectArray__java_lang_Stringjava_lang_StringID = NULL;
+ jintwrapjbooleanbooleanID = NULL;
+ jintwrapjbooleanArray_booleanbooleanID = NULL;
+ jintwrapjobjectArray__booleanbooleanID = NULL;
+ jintwrapjcharcharID = NULL;
+ jintwrapjcharArray_charcharID = NULL;
+ jintwrapjobjectArray__charcharID = NULL;
+ jintwrapjfloatfloatID = NULL;
+ jintwrapjfloatArray_floatfloatID = NULL;
+ jintwrapjobjectArray__floatfloatID = NULL;
+ jintwrapjlonglongID = NULL;
+ jintwrapjlongArray_longlongID = NULL;
+ jintwrapjobjectArray__longlongID = NULL;
+ jdoubleunwrapDoublejintintID = NULL;
+ jdoubleArray_unwrapRowDoublejintintID = NULL;
+ jobjectArray__unwrapMatDoublejintintID = NULL;
+ jintunwrapIntjintintID = NULL;
+ jintArray_unwrapRowIntjintintID = NULL;
+ jobjectArray__unwrapMatIntjintintID = NULL;
+ jlongunwrapUIntjintintID = NULL;
+ jlongArray_unwrapRowUIntjintintID = NULL;
+ jobjectArray__unwrapMatUIntjintintID = NULL;
+ jbyteunwrapBytejintintID = NULL;
+ jbyteArray_unwrapRowBytejintintID = NULL;
+ jobjectArray__unwrapMatBytejintintID = NULL;
+ jshortunwrapUBytejintintID = NULL;
+ jshortArray_unwrapRowUBytejintintID = NULL;
+ jobjectArray__unwrapMatUBytejintintID = NULL;
+ jshortunwrapShortjintintID = NULL;
+ jshortArray_unwrapRowShortjintintID = NULL;
+ jobjectArray__unwrapMatShortjintintID = NULL;
+ jintunwrapUShortjintintID = NULL;
+ jintArray_unwrapRowUShortjintintID = NULL;
+ jobjectArray__unwrapMatUShortjintintID = NULL;
+ jstringunwrapStringjintintID = NULL;
+ jobjectArray_unwrapRowStringjintintID = NULL;
+ jobjectArray__unwrapMatStringjintintID = NULL;
+ jbooleanunwrapBooleanjintintID = NULL;
+ jbooleanArray_unwrapRowBooleanjintintID = NULL;
+ jobjectArray__unwrapMatBooleanjintintID = NULL;
+ jcharunwrapCharjintintID = NULL;
+ jcharArray_unwrapRowCharjintintID = NULL;
+ jobjectArray__unwrapMatCharjintintID = NULL;
+ jfloatunwrapFloatjintintID = NULL;
+ jfloatArray_unwrapRowFloatjintintID = NULL;
+ jobjectArray__unwrapMatFloatjintintID = NULL;
+ jlongunwrapLongjintintID = NULL;
+ jlongArray_unwrapRowLongjintintID = NULL;
+ jobjectArray__unwrapMatLongjintintID = NULL;
}
// Generic methods
-void ScilabJavaObject::synchronize() {
-if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaObject");
-}
+void ScilabJavaObject::synchronize()
+{
+ if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaObject");
+ }
}
-void ScilabJavaObject::endSynchronize() {
-if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
-throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaObject");
-}
+void ScilabJavaObject::endSynchronize()
+{
+ if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK)
+ {
+ throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaObject");
+ }
}
// Method(s)
-int ScilabJavaObject::invoke (JavaVM * jvm_, int id, char const* methodName, int const* args, int argsSize){
+int ScilabJavaObject::invoke (JavaVM * jvm_, int id, char const* methodName, int const* args, int argsSize)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID jintinvokejintintjstringjava_lang_StringjintArray_intintID = curEnv->GetStaticMethodID(cls, "invoke", "(ILjava/lang/String;[I)I" ) ;
-if (jintinvokejintintjstringjava_lang_StringjintArray_intintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "invoke");
-}
+ jmethodID jintinvokejintintjstringjava_lang_StringjintArray_intintID = curEnv->GetStaticMethodID(cls, "invoke", "(ILjava/lang/String;[I)I" ) ;
+ if (jintinvokejintintjstringjava_lang_StringjintArray_intintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "invoke");
+ }
-jstring methodName_ = curEnv->NewStringUTF( methodName );
-if (methodName != NULL && methodName_ == NULL)
-{
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ jstring methodName_ = curEnv->NewStringUTF( methodName );
+ if (methodName != NULL && methodName_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-jintArray args_ = curEnv->NewIntArray( argsSize ) ;
+ jintArray args_ = curEnv->NewIntArray( argsSize ) ;
-if (args_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ if (args_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-curEnv->SetIntArrayRegion( args_, 0, argsSize, (jint*)(args) ) ;
+ curEnv->SetIntArrayRegion( args_, 0, argsSize, (jint*)(args) ) ;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintinvokejintintjstringjava_lang_StringjintArray_intintID ,id, methodName_, args_));
- curEnv->DeleteLocalRef(methodName_);
-curEnv->DeleteLocalRef(args_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintinvokejintintjstringjava_lang_StringjintArray_intintID , id, methodName_, args_));
+ curEnv->DeleteLocalRef(methodName_);
+ curEnv->DeleteLocalRef(args_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-void ScilabJavaObject::initScilabJavaObject (JavaVM * jvm_){
+void ScilabJavaObject::initScilabJavaObject (JavaVM * jvm_)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID voidinitScilabJavaObjectID = curEnv->GetStaticMethodID(cls, "initScilabJavaObject", "()V" ) ;
+ if (voidinitScilabJavaObjectID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "initScilabJavaObject");
+ }
+
+ curEnv->CallStaticVoidMethod(cls, voidinitScilabJavaObjectID );
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+}
+
+void ScilabJavaObject::garbageCollect (JavaVM * jvm_)
+{
-jmethodID voidinitScilabJavaObjectID = curEnv->GetStaticMethodID(cls, "initScilabJavaObject", "()V" ) ;
-if (voidinitScilabJavaObjectID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "initScilabJavaObject");
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID voidgarbageCollectID = curEnv->GetStaticMethodID(cls, "garbageCollect", "()V" ) ;
+ if (voidgarbageCollectID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "garbageCollect");
+ }
+
+ curEnv->CallStaticVoidMethod(cls, voidgarbageCollectID );
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+}
+
+char* ScilabJavaObject::getRepresentation (JavaVM * jvm_, int id)
+{
- curEnv->CallStaticVoidMethod(cls, voidinitScilabJavaObjectID );
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jstringgetRepresentationjintintID = curEnv->GetStaticMethodID(cls, "getRepresentation", "(I)Ljava/lang/String;" ) ;
+ if (jstringgetRepresentationjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "getRepresentation");
+ }
+
+ jstring res = static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringgetRepresentationjintintID , id));
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ if (res != NULL)
+ {
+
+ const char *tempString = curEnv->GetStringUTFChars(res, 0);
+ char * myStringBuffer = new char[strlen(tempString) + 1];
+ strcpy(myStringBuffer, tempString);
+ curEnv->ReleaseStringUTFChars(res, tempString);
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myStringBuffer;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myStringBuffer;
+ }
+ else
+ {
+ curEnv->DeleteLocalRef(res);
+ return NULL;
+ }
}
-void ScilabJavaObject::garbageCollect (JavaVM * jvm_){
+bool ScilabJavaObject::isValidJavaObject (JavaVM * jvm_, int id)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID voidgarbageCollectID = curEnv->GetStaticMethodID(cls, "garbageCollect", "()V" ) ;
-if (voidgarbageCollectID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "garbageCollect");
-}
+ jmethodID jbooleanisValidJavaObjectjintintID = curEnv->GetStaticMethodID(cls, "isValidJavaObject", "(I)Z" ) ;
+ if (jbooleanisValidJavaObjectjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "isValidJavaObject");
+ }
+
+ jboolean res = static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanisValidJavaObjectjintintID , id));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return (res == JNI_TRUE);
- curEnv->CallStaticVoidMethod(cls, voidgarbageCollectID );
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
}
-char* ScilabJavaObject::getRepresentation (JavaVM * jvm_, int id){
+void ScilabJavaObject::enableTrace (JavaVM * jvm_, char const* filename)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID voidenableTracejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "enableTrace", "(Ljava/lang/String;)V" ) ;
+ if (voidenableTracejstringjava_lang_StringID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "enableTrace");
+ }
+
+ jstring filename_ = curEnv->NewStringUTF( filename );
+ if (filename != NULL && filename_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+
+ curEnv->CallStaticVoidMethod(cls, voidenableTracejstringjava_lang_StringID , filename_);
+ curEnv->DeleteLocalRef(filename_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+}
+
+void ScilabJavaObject::disableTrace (JavaVM * jvm_)
+{
-jmethodID jstringgetRepresentationjintintID = curEnv->GetStaticMethodID(cls, "getRepresentation", "(I)Ljava/lang/String;" ) ;
-if (jstringgetRepresentationjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "getRepresentation");
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID voiddisableTraceID = curEnv->GetStaticMethodID(cls, "disableTrace", "()V" ) ;
+ if (voiddisableTraceID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "disableTrace");
+ }
+
+ curEnv->CallStaticVoidMethod(cls, voiddisableTraceID );
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+}
+
+void ScilabJavaObject::setField (JavaVM * jvm_, int id, char const* fieldName, int idarg)
+{
- jstring res = static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringgetRepresentationjintintID ,id));
- if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}if (res != NULL) {
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID voidsetFieldjintintjstringjava_lang_StringjintintID = curEnv->GetStaticMethodID(cls, "setField", "(ILjava/lang/String;I)V" ) ;
+ if (voidsetFieldjintintjstringjava_lang_StringjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "setField");
+ }
+
+ jstring fieldName_ = curEnv->NewStringUTF( fieldName );
+ if (fieldName != NULL && fieldName_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+
+ curEnv->CallStaticVoidMethod(cls, voidsetFieldjintintjstringjava_lang_StringjintintID , id, fieldName_, idarg);
+ curEnv->DeleteLocalRef(fieldName_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+}
+
+int ScilabJavaObject::getField (JavaVM * jvm_, int id, char const* fieldName)
+{
-const char *tempString = curEnv->GetStringUTFChars(res, 0);
-char * myStringBuffer = new char[strlen(tempString) + 1];
-strcpy(myStringBuffer, tempString);
-curEnv->ReleaseStringUTFChars(res, tempString);
-curEnv->DeleteLocalRef(res);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-delete[] myStringBuffer;
- throw GiwsException::JniCallMethodException(curEnv);
-}
-return myStringBuffer;
- } else {
-curEnv->DeleteLocalRef(res);
-return NULL;
-}
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-bool ScilabJavaObject::isValidJavaObject (JavaVM * jvm_, int id){
+ jmethodID jintgetFieldjintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "getField", "(ILjava/lang/String;)I" ) ;
+ if (jintgetFieldjintintjstringjava_lang_StringID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "getField");
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jstring fieldName_ = curEnv->NewStringUTF( fieldName );
+ if (fieldName != NULL && fieldName_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-jmethodID jbooleanisValidJavaObjectjintintID = curEnv->GetStaticMethodID(cls, "isValidJavaObject", "(I)Z" ) ;
-if (jbooleanisValidJavaObjectjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "isValidJavaObject");
-}
- jboolean res = static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanisValidJavaObjectjintintID ,id));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return (res == JNI_TRUE);
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetFieldjintintjstringjava_lang_StringID , id, fieldName_));
+ curEnv->DeleteLocalRef(fieldName_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-void ScilabJavaObject::enableTrace (JavaVM * jvm_, char const* filename){
+int ScilabJavaObject::getFieldType (JavaVM * jvm_, int id, char const* fieldName)
+{
+
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jmethodID jintgetFieldTypejintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "getFieldType", "(ILjava/lang/String;)I" ) ;
+ if (jintgetFieldTypejintintjstringjava_lang_StringID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "getFieldType");
+ }
-jmethodID voidenableTracejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "enableTrace", "(Ljava/lang/String;)V" ) ;
-if (voidenableTracejstringjava_lang_StringID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "enableTrace");
-}
+ jstring fieldName_ = curEnv->NewStringUTF( fieldName );
+ if (fieldName != NULL && fieldName_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-jstring filename_ = curEnv->NewStringUTF( filename );
-if (filename != NULL && filename_ == NULL)
-{
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetFieldTypejintintjstringjava_lang_StringID , id, fieldName_));
+ curEnv->DeleteLocalRef(fieldName_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
- curEnv->CallStaticVoidMethod(cls, voidenableTracejstringjava_lang_StringID ,filename_);
- curEnv->DeleteLocalRef(filename_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
}
-void ScilabJavaObject::disableTrace (JavaVM * jvm_){
+int ScilabJavaObject::javaCast (JavaVM * jvm_, int id, char const* objName)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID voiddisableTraceID = curEnv->GetStaticMethodID(cls, "disableTrace", "()V" ) ;
-if (voiddisableTraceID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "disableTrace");
-}
+ jmethodID jintjavaCastjintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "javaCast", "(ILjava/lang/String;)I" ) ;
+ if (jintjavaCastjintintjstringjava_lang_StringID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "javaCast");
+ }
- curEnv->CallStaticVoidMethod(cls, voiddisableTraceID );
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-}
+ jstring objName_ = curEnv->NewStringUTF( objName );
+ if (objName != NULL && objName_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-void ScilabJavaObject::setField (JavaVM * jvm_, int id, char const* fieldName, int idarg){
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintjavaCastjintintjstringjava_lang_StringID , id, objName_));
+ curEnv->DeleteLocalRef(objName_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID voidsetFieldjintintjstringjava_lang_StringjintintID = curEnv->GetStaticMethodID(cls, "setField", "(ILjava/lang/String;I)V" ) ;
-if (voidsetFieldjintintjstringjava_lang_StringjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "setField");
}
-jstring fieldName_ = curEnv->NewStringUTF( fieldName );
-if (fieldName != NULL && fieldName_ == NULL)
+int ScilabJavaObject::javaCast (JavaVM * jvm_, int id, int classId)
{
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
- curEnv->CallStaticVoidMethod(cls, voidsetFieldjintintjstringjava_lang_StringjintintID ,id, fieldName_, idarg);
- curEnv->DeleteLocalRef(fieldName_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-}
+ jmethodID jintjavaCastjintintjintintID = curEnv->GetStaticMethodID(cls, "javaCast", "(II)I" ) ;
+ if (jintjavaCastjintintjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "javaCast");
+ }
-int ScilabJavaObject::getField (JavaVM * jvm_, int id, char const* fieldName){
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintjavaCastjintintjintintID , id, classId));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
}
-jmethodID jintgetFieldjintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "getField", "(ILjava/lang/String;)I" ) ;
-if (jintgetFieldjintintjstringjava_lang_StringID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "getField");
+char* ScilabJavaObject::getClassName (JavaVM * jvm_, int id)
+{
+
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jstringgetClassNamejintintID = curEnv->GetStaticMethodID(cls, "getClassName", "(I)Ljava/lang/String;" ) ;
+ if (jstringgetClassNamejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "getClassName");
+ }
+
+ jstring res = static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringgetClassNamejintintID , id));
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ if (res != NULL)
+ {
+
+ const char *tempString = curEnv->GetStringUTFChars(res, 0);
+ char * myStringBuffer = new char[strlen(tempString) + 1];
+ strcpy(myStringBuffer, tempString);
+ curEnv->ReleaseStringUTFChars(res, tempString);
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myStringBuffer;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myStringBuffer;
+ }
+ else
+ {
+ curEnv->DeleteLocalRef(res);
+ return NULL;
+ }
}
-jstring fieldName_ = curEnv->NewStringUTF( fieldName );
-if (fieldName != NULL && fieldName_ == NULL)
+int ScilabJavaObject::getArrayElement (JavaVM * jvm_, int id, int const* index, int indexSize)
{
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetFieldjintintjstringjava_lang_StringID ,id, fieldName_));
- curEnv->DeleteLocalRef(fieldName_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jmethodID jintgetArrayElementjintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "getArrayElement", "(I[I)I" ) ;
+ if (jintgetArrayElementjintintjintArray_intintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "getArrayElement");
+ }
-}
+ jintArray index_ = curEnv->NewIntArray( indexSize ) ;
-int ScilabJavaObject::getFieldType (JavaVM * jvm_, int id, char const* fieldName){
+ if (index_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ curEnv->SetIntArrayRegion( index_, 0, indexSize, (jint*)(index) ) ;
+
+
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetArrayElementjintintjintArray_intintID , id, index_));
+ curEnv->DeleteLocalRef(index_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintgetFieldTypejintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "getFieldType", "(ILjava/lang/String;)I" ) ;
-if (jintgetFieldTypejintintjstringjava_lang_StringID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "getFieldType");
}
-jstring fieldName_ = curEnv->NewStringUTF( fieldName );
-if (fieldName != NULL && fieldName_ == NULL)
+void ScilabJavaObject::setArrayElement (JavaVM * jvm_, int id, int const* index, int indexSize, int idArg)
{
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetFieldTypejintintjstringjava_lang_StringID ,id, fieldName_));
- curEnv->DeleteLocalRef(fieldName_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jmethodID voidsetArrayElementjintintjintArray_intintjintintID = curEnv->GetStaticMethodID(cls, "setArrayElement", "(I[II)V" ) ;
+ if (voidsetArrayElementjintintjintArray_intintjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "setArrayElement");
+ }
-}
+ jintArray index_ = curEnv->NewIntArray( indexSize ) ;
-int ScilabJavaObject::javaCast (JavaVM * jvm_, int id, char const* objName){
+ if (index_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ curEnv->SetIntArrayRegion( index_, 0, indexSize, (jint*)(index) ) ;
-jmethodID jintjavaCastjintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "javaCast", "(ILjava/lang/String;)I" ) ;
-if (jintjavaCastjintintjstringjava_lang_StringID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "javaCast");
+
+ curEnv->CallStaticVoidMethod(cls, voidsetArrayElementjintintjintArray_intintjintintID , id, index_, idArg);
+ curEnv->DeleteLocalRef(index_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
}
-jstring objName_ = curEnv->NewStringUTF( objName );
-if (objName != NULL && objName_ == NULL)
+void ScilabJavaObject::removeScilabJavaObject (JavaVM * jvm_, int id)
{
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID voidremoveScilabJavaObjectjintintID = curEnv->GetStaticMethodID(cls, "removeScilabJavaObject", "(I)V" ) ;
+ if (voidremoveScilabJavaObjectjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "removeScilabJavaObject");
+ }
+
+ curEnv->CallStaticVoidMethod(cls, voidremoveScilabJavaObjectjintintID , id);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+}
+
+void ScilabJavaObject::limitDirectBuffer (JavaVM * jvm_, int id)
+{
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintjavaCastjintintjstringjava_lang_StringID ,id, objName_));
- curEnv->DeleteLocalRef(objName_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID voidlimitDirectBufferjintintID = curEnv->GetStaticMethodID(cls, "limitDirectBuffer", "(I)V" ) ;
+ if (voidlimitDirectBufferjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "limitDirectBuffer");
+ }
+
+ curEnv->CallStaticVoidMethod(cls, voidlimitDirectBufferjintintID , id);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+}
+
+int ScilabJavaObject::isUnwrappable (JavaVM * jvm_, int id)
+{
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-int ScilabJavaObject::javaCast (JavaVM * jvm_, int id, int classId){
+ jmethodID jintisUnwrappablejintintID = curEnv->GetStaticMethodID(cls, "isUnwrappable", "(I)I" ) ;
+ if (jintisUnwrappablejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "isUnwrappable");
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintisUnwrappablejintintID , id));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintjavaCastjintintjintintID = curEnv->GetStaticMethodID(cls, "javaCast", "(II)I" ) ;
-if (jintjavaCastjintintjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "javaCast");
}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintjavaCastjintintjintintID ,id, classId));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+int ScilabJavaObject::wrap (JavaVM * jvm_, double x)
+{
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-char* ScilabJavaObject::getClassName (JavaVM * jvm_, int id){
+ jmethodID jintwrapjdoubledoubleID = curEnv->GetStaticMethodID(cls, "wrap", "(D)I" ) ;
+ if (jintwrapjdoubledoubleID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjdoubledoubleID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jstringgetClassNamejintintID = curEnv->GetStaticMethodID(cls, "getClassName", "(I)Ljava/lang/String;" ) ;
-if (jstringgetClassNamejintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "getClassName");
}
- jstring res = static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringgetClassNamejintintID ,id));
- if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}if (res != NULL) {
-
-const char *tempString = curEnv->GetStringUTFChars(res, 0);
-char * myStringBuffer = new char[strlen(tempString) + 1];
-strcpy(myStringBuffer, tempString);
-curEnv->ReleaseStringUTFChars(res, tempString);
-curEnv->DeleteLocalRef(res);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-delete[] myStringBuffer;
- throw GiwsException::JniCallMethodException(curEnv);
-}
-return myStringBuffer;
- } else {
-curEnv->DeleteLocalRef(res);
-return NULL;
-}
-}
+int ScilabJavaObject::wrap (JavaVM * jvm_, double const* x, int xSize)
+{
-int ScilabJavaObject::getArrayElement (JavaVM * jvm_, int id, int const* index, int indexSize){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jmethodID jintwrapjdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "wrap", "([D)I" ) ;
+ if (jintwrapjdoubleArray_doubledoubleID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-jmethodID jintgetArrayElementjintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "getArrayElement", "(I[I)I" ) ;
-if (jintgetArrayElementjintintjintArray_intintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "getArrayElement");
-}
+ jdoubleArray x_ = curEnv->NewDoubleArray( xSize ) ;
-jintArray index_ = curEnv->NewIntArray( indexSize ) ;
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-if (index_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ curEnv->SetDoubleArrayRegion( x_, 0, xSize, (jdouble*)(x) ) ;
-curEnv->SetIntArrayRegion( index_, 0, indexSize, (jint*)(index) ) ;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjdoubleArray_doubledoubleID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetArrayElementjintintjintArray_intintID ,id, index_));
- curEnv->DeleteLocalRef(index_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
}
-return res;
-}
+int ScilabJavaObject::wrap (JavaVM * jvm_, double const* const* x, int xSize, int xSizeCol)
+{
-void ScilabJavaObject::setArrayElement (JavaVM * jvm_, int id, int const* index, int indexSize, int idArg){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__doubledoubleID = curEnv->GetStaticMethodID(cls, "wrap", "([[D)I" ) ;
+ if (jintwrapjobjectArray__doubledoubleID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[D"), NULL);
+
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ for (int i = 0; i < xSize; i++)
+ {
+
+ jdoubleArray xLocal = curEnv->NewDoubleArray( xSizeCol ) ;
+
+ if (xLocal == NULL)
+ {
+ // check that allocation succeed
+ curEnv->DeleteLocalRef(x_);
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ curEnv->SetDoubleArrayRegion( xLocal, 0, xSizeCol, (jdouble*)(x[i]) ) ;
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
+ }
-jmethodID voidsetArrayElementjintintjintArray_intintjintintID = curEnv->GetStaticMethodID(cls, "setArrayElement", "(I[II)V" ) ;
-if (voidsetArrayElementjintintjintArray_intintjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "setArrayElement");
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__doubledoubleID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jintArray index_ = curEnv->NewIntArray( indexSize ) ;
+}
-if (index_ == NULL)
+int ScilabJavaObject::wrap (JavaVM * jvm_, int x)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetIntArrayRegion( index_, 0, indexSize, (jint*)(index) ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ jmethodID jintwrapjintintID = curEnv->GetStaticMethodID(cls, "wrap", "(I)I" ) ;
+ if (jintwrapjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjintintID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
- curEnv->CallStaticVoidMethod(cls, voidsetArrayElementjintintjintArray_intintjintintID ,id, index_, idArg);
- curEnv->DeleteLocalRef(index_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
}
-void ScilabJavaObject::removeScilabJavaObject (JavaVM * jvm_, int id){
+int ScilabJavaObject::wrap (JavaVM * jvm_, int const* x, int xSize)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID voidremoveScilabJavaObjectjintintID = curEnv->GetStaticMethodID(cls, "removeScilabJavaObject", "(I)V" ) ;
-if (voidremoveScilabJavaObjectjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "removeScilabJavaObject");
-}
+ jmethodID jintwrapjintArray_intintID = curEnv->GetStaticMethodID(cls, "wrap", "([I)I" ) ;
+ if (jintwrapjintArray_intintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
- curEnv->CallStaticVoidMethod(cls, voidremoveScilabJavaObjectjintintID ,id);
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-}
+ jintArray x_ = curEnv->NewIntArray( xSize ) ;
-void ScilabJavaObject::limitDirectBuffer (JavaVM * jvm_, int id){
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ curEnv->SetIntArrayRegion( x_, 0, xSize, (jint*)(x) ) ;
-jmethodID voidlimitDirectBufferjintintID = curEnv->GetStaticMethodID(cls, "limitDirectBuffer", "(I)V" ) ;
-if (voidlimitDirectBufferjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "limitDirectBuffer");
-}
- curEnv->CallStaticVoidMethod(cls, voidlimitDirectBufferjintintID ,id);
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjintArray_intintID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
+
}
-int ScilabJavaObject::isUnwrappable (JavaVM * jvm_, int id){
+int ScilabJavaObject::wrap (JavaVM * jvm_, int const* const* x, int xSize, int xSizeCol)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__intintID = curEnv->GetStaticMethodID(cls, "wrap", "([[I)I" ) ;
+ if (jintwrapjobjectArray__intintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[I"), NULL);
+
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ for (int i = 0; i < xSize; i++)
+ {
+
+ jintArray xLocal = curEnv->NewIntArray( xSizeCol ) ;
+
+ if (xLocal == NULL)
+ {
+ // check that allocation succeed
+ curEnv->DeleteLocalRef(x_);
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-jmethodID jintisUnwrappablejintintID = curEnv->GetStaticMethodID(cls, "isUnwrappable", "(I)I" ) ;
-if (jintisUnwrappablejintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "isUnwrappable");
-}
+ curEnv->SetIntArrayRegion( xLocal, 0, xSizeCol, (jint*)(x[i]) ) ;
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintisUnwrappablejintintID ,id));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__intintID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-int ScilabJavaObject::wrapDouble (JavaVM * jvm_, double x){
+int ScilabJavaObject::wrap (JavaVM * jvm_, byte x)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID jintwrapDoublejdoubledoubleID = curEnv->GetStaticMethodID(cls, "wrapDouble", "(D)I" ) ;
-if (jintwrapDoublejdoubledoubleID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapDouble");
-}
+ jmethodID jintwrapjbytebyteID = curEnv->GetStaticMethodID(cls, "wrap", "(B)I" ) ;
+ if (jintwrapjbytebyteID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapDoublejdoubledoubleID ,x));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjbytebyteID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-int ScilabJavaObject::wrapDouble (JavaVM * jvm_, double const* x, int xSize){
+int ScilabJavaObject::wrap (JavaVM * jvm_, byte const* x, int xSize)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID jintwrapDoublejdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "wrapDouble", "([D)I" ) ;
-if (jintwrapDoublejdoubleArray_doubledoubleID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapDouble");
-}
+ jmethodID jintwrapjbyteArray_bytebyteID = curEnv->GetStaticMethodID(cls, "wrap", "([B)I" ) ;
+ if (jintwrapjbyteArray_bytebyteID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-jdoubleArray x_ = curEnv->NewDoubleArray( xSize ) ;
+ jbyteArray x_ = curEnv->NewByteArray( xSize ) ;
-if (x_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-curEnv->SetDoubleArrayRegion( x_, 0, xSize, (jdouble*)(x) ) ;
+ curEnv->SetByteArrayRegion( x_, 0, xSize, (jbyte*)(x) ) ;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapDoublejdoubleArray_doubledoubleID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjbyteArray_bytebyteID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-int ScilabJavaObject::wrapDouble (JavaVM * jvm_, double const* const* x, int xSize, int xSizeCol){
+int ScilabJavaObject::wrap (JavaVM * jvm_, byte const* const* x, int xSize, int xSizeCol)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__bytebyteID = curEnv->GetStaticMethodID(cls, "wrap", "([[B)I" ) ;
+ if (jintwrapjobjectArray__bytebyteID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[B"), NULL);
+
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ for (int i = 0; i < xSize; i++)
+ {
+
+ jbyteArray xLocal = curEnv->NewByteArray( xSizeCol ) ;
+
+ if (xLocal == NULL)
+ {
+ // check that allocation succeed
+ curEnv->DeleteLocalRef(x_);
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-jmethodID jintwrapDoublejobjectArray__doubledoubleID = curEnv->GetStaticMethodID(cls, "wrapDouble", "([[D)I" ) ;
-if (jintwrapDoublejobjectArray__doubledoubleID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapDouble");
-}
+ curEnv->SetByteArrayRegion( xLocal, 0, xSizeCol, (jbyte*)(x[i]) ) ;
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
+ }
- jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[D"),NULL);
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__bytebyteID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-if (x_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
}
- for (int i=0; i<xSize; i++){
+int ScilabJavaObject::wrap (JavaVM * jvm_, short x)
+{
-jdoubleArray xLocal = curEnv->NewDoubleArray( xSizeCol ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-if (xLocal == NULL)
-{
-// check that allocation succeed
-curEnv->DeleteLocalRef(x_);
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ jmethodID jintwrapjshortshortID = curEnv->GetStaticMethodID(cls, "wrap", "(S)I" ) ;
+ if (jintwrapjshortshortID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-curEnv->SetDoubleArrayRegion( xLocal, 0, xSizeCol, (jdouble*)(x[i]) ) ;
-curEnv->SetObjectArrayElement(x_, i, xLocal);
-curEnv->DeleteLocalRef(xLocal);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjshortshortID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapDoublejobjectArray__doubledoubleID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
}
-return res;
-}
+int ScilabJavaObject::wrap (JavaVM * jvm_, short const* x, int xSize)
+{
-int ScilabJavaObject::wrapInt (JavaVM * jvm_, int x){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jmethodID jintwrapjshortArray_shortshortID = curEnv->GetStaticMethodID(cls, "wrap", "([S)I" ) ;
+ if (jintwrapjshortArray_shortshortID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-jmethodID jintwrapIntjintintID = curEnv->GetStaticMethodID(cls, "wrapInt", "(I)I" ) ;
-if (jintwrapIntjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapInt");
-}
+ jshortArray x_ = curEnv->NewShortArray( xSize ) ;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapIntjintintID ,x));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-}
+ curEnv->SetShortArrayRegion( x_, 0, xSize, (jshort*)(x) ) ;
-int ScilabJavaObject::wrapInt (JavaVM * jvm_, int const* x, int xSize){
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjshortArray_shortshortID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapIntjintArray_intintID = curEnv->GetStaticMethodID(cls, "wrapInt", "([I)I" ) ;
-if (jintwrapIntjintArray_intintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapInt");
}
-jintArray x_ = curEnv->NewIntArray( xSize ) ;
-
-if (x_ == NULL)
+int ScilabJavaObject::wrap (JavaVM * jvm_, short const* const* x, int xSize, int xSizeCol)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetIntArrayRegion( x_, 0, xSize, (jint*)(x) ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__shortshortID = curEnv->GetStaticMethodID(cls, "wrap", "([[S)I" ) ;
+ if (jintwrapjobjectArray__shortshortID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[S"), NULL);
+
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ for (int i = 0; i < xSize; i++)
+ {
+
+ jshortArray xLocal = curEnv->NewShortArray( xSizeCol ) ;
+
+ if (xLocal == NULL)
+ {
+ // check that allocation succeed
+ curEnv->DeleteLocalRef(x_);
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+ curEnv->SetShortArrayRegion( xLocal, 0, xSizeCol, (jshort*)(x[i]) ) ;
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapIntjintArray_intintID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__shortshortID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-int ScilabJavaObject::wrapInt (JavaVM * jvm_, int const* const* x, int xSize, int xSizeCol){
+int ScilabJavaObject::wrap (JavaVM * jvm_, char const* x)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID jintwrapIntjobjectArray__intintID = curEnv->GetStaticMethodID(cls, "wrapInt", "([[I)I" ) ;
-if (jintwrapIntjobjectArray__intintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapInt");
-}
+ jmethodID jintwrapjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrap", "(Ljava/lang/String;)I" ) ;
+ if (jintwrapjstringjava_lang_StringID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
- jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[I"),NULL);
+ jstring x_ = curEnv->NewStringUTF( x );
+ if (x != NULL && x_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-if (x_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
- for (int i=0; i<xSize; i++){
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjstringjava_lang_StringID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jintArray xLocal = curEnv->NewIntArray( xSizeCol ) ;
+}
-if (xLocal == NULL)
+int ScilabJavaObject::wrap (JavaVM * jvm_, char const* const* x, int xSize)
{
-// check that allocation succeed
-curEnv->DeleteLocalRef(x_);
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetIntArrayRegion( xLocal, 0, xSizeCol, (jint*)(x[i]) ) ;
-curEnv->SetObjectArrayElement(x_, i, xLocal);
-curEnv->DeleteLocalRef(xLocal);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrap", "([Ljava/lang/String;)I" ) ;
+ if (jintwrapjobjectArray_java_lang_Stringjava_lang_StringID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+ jclass stringArrayClass = curEnv->FindClass("java/lang/String");
+
+ // create java array of strings.
+ jobjectArray x_ = curEnv->NewObjectArray( xSize, stringArrayClass, NULL);
+ if (x_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ // convert each char * to java strings and fill the java array.
+ for ( int i = 0; i < xSize; i++)
+ {
+ jstring TempString = curEnv->NewStringUTF( x[i] );
+ if (TempString == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapIntjobjectArray__intintID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ curEnv->SetObjectArrayElement( x_, i, TempString);
+
+ // avoid keeping reference on too many strings
+ curEnv->DeleteLocalRef(TempString);
+ }
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray_java_lang_Stringjava_lang_StringID , x_));
+ curEnv->DeleteLocalRef(stringArrayClass);
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-int ScilabJavaObject::wrapUInt (JavaVM * jvm_, long long x){
+int ScilabJavaObject::wrap (JavaVM * jvm_, char const* const* const* x, int xSize, int xSizeCol)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrap", "([[Ljava/lang/String;)I" ) ;
+ if (jintwrapjobjectArray__java_lang_Stringjava_lang_StringID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+ jclass stringArrayClass = curEnv->FindClass("java/lang/String");
+ // create java array of array of strings.
+ jobjectArray x_ = curEnv->NewObjectArray( xSize, curEnv->FindClass("[Ljava/lang/String;"), NULL);
+ if (x_ == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ for ( int i = 0; i < xSize; i++)
+ {
+ jobjectArray xLocal = curEnv->NewObjectArray( xSizeCol, stringArrayClass, NULL);
+ // convert each char * to java strings and fill the java array.
+ for ( int j = 0; j < xSizeCol; j++)
+ {
+ jstring TempString = curEnv->NewStringUTF( x[i][j] );
+
+ if (TempString == NULL)
+ {
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ curEnv->SetObjectArrayElement( xLocal, j, TempString);
+
+ // avoid keeping reference on too many strings
+ curEnv->DeleteLocalRef(TempString);
+ }
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
-jmethodID jintwrapUIntjlonglongID = curEnv->GetStaticMethodID(cls, "wrapUInt", "(J)I" ) ;
-if (jintwrapUIntjlonglongID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUInt");
-}
+ }
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__java_lang_Stringjava_lang_StringID , x_));
+ curEnv->DeleteLocalRef(stringArrayClass);
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUIntjlonglongID ,x));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
}
-return res;
-}
+int ScilabJavaObject::wrap (JavaVM * jvm_, bool x)
+{
-int ScilabJavaObject::wrapUInt (JavaVM * jvm_, long long const* x, int xSize){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jmethodID jintwrapjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "wrap", "(Z)I" ) ;
+ if (jintwrapjbooleanbooleanID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-jmethodID jintwrapUIntjlongArray_longlongID = curEnv->GetStaticMethodID(cls, "wrapUInt", "([J)I" ) ;
-if (jintwrapUIntjlongArray_longlongID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUInt");
-}
+ jboolean x_ = (static_cast<bool>(x) ? JNI_TRUE : JNI_FALSE);
-jlongArray x_ = curEnv->NewLongArray( xSize ) ;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjbooleanbooleanID , x_));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-if (x_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
}
-curEnv->SetLongArrayRegion( x_, 0, xSize, (jlong*)(x) ) ;
-
+int ScilabJavaObject::wrap (JavaVM * jvm_, bool const* x, int xSize)
+{
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUIntjlongArray_longlongID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-}
+ jmethodID jintwrapjbooleanArray_booleanbooleanID = curEnv->GetStaticMethodID(cls, "wrap", "([Z)I" ) ;
+ if (jintwrapjbooleanArray_booleanbooleanID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-int ScilabJavaObject::wrapUInt (JavaVM * jvm_, long long const* const* x, int xSize, int xSizeCol){
+ jbooleanArray x_ = curEnv->NewBooleanArray( xSize ) ;
+ curEnv->SetBooleanArrayRegion( x_, 0, xSize, (jboolean*)x ) ;
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjbooleanArray_booleanbooleanID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapUIntjobjectArray__longlongID = curEnv->GetStaticMethodID(cls, "wrapUInt", "([[J)I" ) ;
-if (jintwrapUIntjobjectArray__longlongID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUInt");
}
- jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[J"),NULL);
-
-if (x_ == NULL)
+int ScilabJavaObject::wrap (JavaVM * jvm_, bool const* const* x, int xSize, int xSizeCol)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
- for (int i=0; i<xSize; i++){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__booleanbooleanID = curEnv->GetStaticMethodID(cls, "wrap", "([[Z)I" ) ;
+ if (jintwrapjobjectArray__booleanbooleanID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[Z"), NULL);
+ for (int i = 0; i < xSize; i++)
+ {
+ jbooleanArray xLocal = curEnv->NewBooleanArray( xSizeCol ) ;
+ curEnv->SetBooleanArrayRegion( xLocal, 0, xSizeCol, (jboolean*)(x[i]) ) ;
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
+ }
+
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__booleanbooleanID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
+
+}
+
+int ScilabJavaObject::wrap (JavaVM * jvm_, unsigned short x)
+{
-jlongArray xLocal = curEnv->NewLongArray( xSizeCol ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-if (xLocal == NULL)
-{
-// check that allocation succeed
-curEnv->DeleteLocalRef(x_);
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ jmethodID jintwrapjcharcharID = curEnv->GetStaticMethodID(cls, "wrap", "(C)I" ) ;
+ if (jintwrapjcharcharID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-curEnv->SetLongArrayRegion( xLocal, 0, xSizeCol, (jlong*)(x[i]) ) ;
-curEnv->SetObjectArrayElement(x_, i, xLocal);
-curEnv->DeleteLocalRef(xLocal);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjcharcharID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUIntjobjectArray__longlongID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
}
-return res;
-}
+int ScilabJavaObject::wrap (JavaVM * jvm_, unsigned short const* x, int xSize)
+{
-int ScilabJavaObject::wrapByte (JavaVM * jvm_, byte x){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jmethodID jintwrapjcharArray_charcharID = curEnv->GetStaticMethodID(cls, "wrap", "([C)I" ) ;
+ if (jintwrapjcharArray_charcharID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-jmethodID jintwrapBytejbytebyteID = curEnv->GetStaticMethodID(cls, "wrapByte", "(B)I" ) ;
-if (jintwrapBytejbytebyteID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapByte");
-}
+ jcharArray x_ = curEnv->NewCharArray( xSize ) ;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapBytejbytebyteID ,x));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-}
+ curEnv->SetCharArrayRegion( x_, 0, xSize, (jchar*)(x) ) ;
-int ScilabJavaObject::wrapByte (JavaVM * jvm_, byte const* x, int xSize){
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjcharArray_charcharID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapBytejbyteArray_bytebyteID = curEnv->GetStaticMethodID(cls, "wrapByte", "([B)I" ) ;
-if (jintwrapBytejbyteArray_bytebyteID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapByte");
}
-jbyteArray x_ = curEnv->NewByteArray( xSize ) ;
-
-if (x_ == NULL)
+int ScilabJavaObject::wrap (JavaVM * jvm_, unsigned short const* const* x, int xSize, int xSizeCol)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetByteArrayRegion( x_, 0, xSize, (jbyte*)(x) ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__charcharID = curEnv->GetStaticMethodID(cls, "wrap", "([[C)I" ) ;
+ if (jintwrapjobjectArray__charcharID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[C"), NULL);
+
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ for (int i = 0; i < xSize; i++)
+ {
+
+ jcharArray xLocal = curEnv->NewCharArray( xSizeCol ) ;
+
+ if (xLocal == NULL)
+ {
+ // check that allocation succeed
+ curEnv->DeleteLocalRef(x_);
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+ curEnv->SetCharArrayRegion( xLocal, 0, xSizeCol, (jchar*)(x[i]) ) ;
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapBytejbyteArray_bytebyteID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__charcharID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-int ScilabJavaObject::wrapByte (JavaVM * jvm_, byte const* const* x, int xSize, int xSizeCol){
+int ScilabJavaObject::wrap (JavaVM * jvm_, float x)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID jintwrapBytejobjectArray__bytebyteID = curEnv->GetStaticMethodID(cls, "wrapByte", "([[B)I" ) ;
-if (jintwrapBytejobjectArray__bytebyteID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapByte");
-}
+ jmethodID jintwrapjfloatfloatID = curEnv->GetStaticMethodID(cls, "wrap", "(F)I" ) ;
+ if (jintwrapjfloatfloatID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
- jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[B"),NULL);
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjfloatfloatID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-if (x_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
}
- for (int i=0; i<xSize; i++){
+int ScilabJavaObject::wrap (JavaVM * jvm_, float const* x, int xSize)
+{
-jbyteArray xLocal = curEnv->NewByteArray( xSizeCol ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-if (xLocal == NULL)
-{
-// check that allocation succeed
-curEnv->DeleteLocalRef(x_);
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ jmethodID jintwrapjfloatArray_floatfloatID = curEnv->GetStaticMethodID(cls, "wrap", "([F)I" ) ;
+ if (jintwrapjfloatArray_floatfloatID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
-curEnv->SetByteArrayRegion( xLocal, 0, xSizeCol, (jbyte*)(x[i]) ) ;
-curEnv->SetObjectArrayElement(x_, i, xLocal);
-curEnv->DeleteLocalRef(xLocal);
-}
+ jfloatArray x_ = curEnv->NewFloatArray( xSize ) ;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapBytejobjectArray__bytebyteID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-}
+ curEnv->SetFloatArrayRegion( x_, 0, xSize, (jfloat*)(x) ) ;
-int ScilabJavaObject::wrapUByte (JavaVM * jvm_, short x){
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjfloatArray_floatfloatID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapUBytejshortshortID = curEnv->GetStaticMethodID(cls, "wrapUByte", "(S)I" ) ;
-if (jintwrapUBytejshortshortID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUByte");
}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUBytejshortshortID ,x));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+int ScilabJavaObject::wrap (JavaVM * jvm_, float const* const* x, int xSize, int xSizeCol)
+{
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__floatfloatID = curEnv->GetStaticMethodID(cls, "wrap", "([[F)I" ) ;
+ if (jintwrapjobjectArray__floatfloatID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[F"), NULL);
+
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ for (int i = 0; i < xSize; i++)
+ {
+
+ jfloatArray xLocal = curEnv->NewFloatArray( xSizeCol ) ;
+
+ if (xLocal == NULL)
+ {
+ // check that allocation succeed
+ curEnv->DeleteLocalRef(x_);
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-int ScilabJavaObject::wrapUByte (JavaVM * jvm_, short const* x, int xSize){
+ curEnv->SetFloatArrayRegion( xLocal, 0, xSizeCol, (jfloat*)(x[i]) ) ;
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__floatfloatID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapUBytejshortArray_shortshortID = curEnv->GetStaticMethodID(cls, "wrapUByte", "([S)I" ) ;
-if (jintwrapUBytejshortArray_shortshortID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUByte");
}
-jshortArray x_ = curEnv->NewShortArray( xSize ) ;
-
-if (x_ == NULL)
+int ScilabJavaObject::wrap (JavaVM * jvm_, long long x)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetShortArrayRegion( x_, 0, xSize, (jshort*)(x) ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ jmethodID jintwrapjlonglongID = curEnv->GetStaticMethodID(cls, "wrap", "(J)I" ) ;
+ if (jintwrapjlonglongID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUBytejshortArray_shortshortID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjlonglongID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-int ScilabJavaObject::wrapUByte (JavaVM * jvm_, short const* const* x, int xSize, int xSizeCol){
+int ScilabJavaObject::wrap (JavaVM * jvm_, long long const* x, int xSize)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-jmethodID jintwrapUBytejobjectArray__shortshortID = curEnv->GetStaticMethodID(cls, "wrapUByte", "([[S)I" ) ;
-if (jintwrapUBytejobjectArray__shortshortID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUByte");
-}
+ jmethodID jintwrapjlongArray_longlongID = curEnv->GetStaticMethodID(cls, "wrap", "([J)I" ) ;
+ if (jintwrapjlongArray_longlongID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
- jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[S"),NULL);
+ jlongArray x_ = curEnv->NewLongArray( xSize ) ;
-if (x_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
- for (int i=0; i<xSize; i++){
+ curEnv->SetLongArrayRegion( x_, 0, xSize, (jlong*)(x) ) ;
-jshortArray xLocal = curEnv->NewShortArray( xSizeCol ) ;
-if (xLocal == NULL)
-{
-// check that allocation succeed
-curEnv->DeleteLocalRef(x_);
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjlongArray_longlongID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-curEnv->SetShortArrayRegion( xLocal, 0, xSizeCol, (jshort*)(x[i]) ) ;
-curEnv->SetObjectArrayElement(x_, i, xLocal);
-curEnv->DeleteLocalRef(xLocal);
}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUBytejobjectArray__shortshortID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+int ScilabJavaObject::wrap (JavaVM * jvm_, long long const* const* x, int xSize, int xSizeCol)
+{
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintwrapjobjectArray__longlongID = curEnv->GetStaticMethodID(cls, "wrap", "([[J)I" ) ;
+ if (jintwrapjobjectArray__longlongID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
+ }
+
+ jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[J"), NULL);
+
+ if (x_ == NULL)
+ {
+ // check that allocation succeed
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
+
+ for (int i = 0; i < xSize; i++)
+ {
+
+ jlongArray xLocal = curEnv->NewLongArray( xSizeCol ) ;
+
+ if (xLocal == NULL)
+ {
+ // check that allocation succeed
+ curEnv->DeleteLocalRef(x_);
+ throw GiwsException::JniBadAllocException(curEnv);
+ }
-int ScilabJavaObject::wrapShort (JavaVM * jvm_, short x){
+ curEnv->SetLongArrayRegion( xLocal, 0, xSizeCol, (jlong*)(x[i]) ) ;
+ curEnv->SetObjectArrayElement(x_, i, xLocal);
+ curEnv->DeleteLocalRef(xLocal);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__longlongID , x_));
+ curEnv->DeleteLocalRef(x_);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapShortjshortshortID = curEnv->GetStaticMethodID(cls, "wrapShort", "(S)I" ) ;
-if (jintwrapShortjshortshortID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapShort");
}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapShortjshortshortID ,x));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+double ScilabJavaObject::unwrapDouble (JavaVM * jvm_, int x)
+{
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-int ScilabJavaObject::wrapShort (JavaVM * jvm_, short const* x, int xSize){
+ jmethodID jdoubleunwrapDoublejintintID = curEnv->GetStaticMethodID(cls, "unwrapDouble", "(I)D" ) ;
+ if (jdoubleunwrapDoublejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapDouble");
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jdouble res = static_cast<jdouble>( curEnv->CallStaticDoubleMethod(cls, jdoubleunwrapDoublejintintID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapShortjshortArray_shortshortID = curEnv->GetStaticMethodID(cls, "wrapShort", "([S)I" ) ;
-if (jintwrapShortjshortArray_shortshortID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapShort");
}
-jshortArray x_ = curEnv->NewShortArray( xSize ) ;
+double* ScilabJavaObject::unwrapRowDouble (JavaVM * jvm_, int x)
+{
-if (x_ == NULL)
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jdoubleArray_unwrapRowDoublejintintID = curEnv->GetStaticMethodID(cls, "unwrapRowDouble", "(I)[D" ) ;
+ if (jdoubleArray_unwrapRowDoublejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapRowDouble");
+ }
+
+ jdoubleArray res = static_cast<jdoubleArray>( curEnv->CallStaticObjectMethod(cls, jdoubleArray_unwrapRowDoublejintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
+ jdouble *resultsArray = static_cast<jdouble *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
+ double* myArray = new double[ lenRow];
+
+ for (jsize i = 0; i < lenRow; i++)
+ {
+ myArray[i] = resultsArray[i];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
+
+}
+
+double** ScilabJavaObject::unwrapMatDouble (JavaVM * jvm_, int x)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetShortArrayRegion( x_, 0, xSize, (jshort*)(x) ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jobjectArray__unwrapMatDoublejintintID = curEnv->GetStaticMethodID(cls, "unwrapMatDouble", "(I)[[D" ) ;
+ if (jobjectArray__unwrapMatDoublejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapMatDouble");
+ }
+
+ jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray__unwrapMatDoublejintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenCol;
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ double ** myArray = new double*[ lenRow];
+ for (int i = 0; i < lenRow; i++)
+ {
+ jdoubleArray oneDim = (jdoubleArray)curEnv->GetObjectArrayElement(res, i);
+ lenCol = curEnv->GetArrayLength(oneDim);
+ double *resultsArray = static_cast<double *>(curEnv->GetPrimitiveArrayCritical(oneDim, &isCopy));
+ myArray[i] = new double[ lenCol];
+ for (int j = 0; j < lenCol; j++)
+ {
+ myArray[i][j] = resultsArray[j];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+ }
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapShortjshortArray_shortshortID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
}
-return res;
-}
+int ScilabJavaObject::unwrapInt (JavaVM * jvm_, int x)
+{
-int ScilabJavaObject::wrapShort (JavaVM * jvm_, short const* const* x, int xSize, int xSizeCol){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jmethodID jintunwrapIntjintintID = curEnv->GetStaticMethodID(cls, "unwrapInt", "(I)I" ) ;
+ if (jintunwrapIntjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapInt");
+ }
-jmethodID jintwrapShortjobjectArray__shortshortID = curEnv->GetStaticMethodID(cls, "wrapShort", "([[S)I" ) ;
-if (jintwrapShortjobjectArray__shortshortID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapShort");
-}
+ jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintunwrapIntjintintID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
- jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[S"),NULL);
+}
-if (x_ == NULL)
+int* ScilabJavaObject::unwrapRowInt (JavaVM * jvm_, int x)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
- for (int i=0; i<xSize; i++){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jintArray_unwrapRowIntjintintID = curEnv->GetStaticMethodID(cls, "unwrapRowInt", "(I)[I" ) ;
+ if (jintArray_unwrapRowIntjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapRowInt");
+ }
+
+ jintArray res = static_cast<jintArray>( curEnv->CallStaticObjectMethod(cls, jintArray_unwrapRowIntjintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
+ jint *resultsArray = static_cast<jint *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
+ int* myArray = new int[ lenRow];
+
+ for (jsize i = 0; i < lenRow; i++)
+ {
+ myArray[i] = resultsArray[i];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
+
+}
+
+int** ScilabJavaObject::unwrapMatInt (JavaVM * jvm_, int x)
+{
-jshortArray xLocal = curEnv->NewShortArray( xSizeCol ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jobjectArray__unwrapMatIntjintintID = curEnv->GetStaticMethodID(cls, "unwrapMatInt", "(I)[[I" ) ;
+ if (jobjectArray__unwrapMatIntjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapMatInt");
+ }
+
+ jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray__unwrapMatIntjintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenCol;
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ int ** myArray = new int*[ lenRow];
+ for (int i = 0; i < lenRow; i++)
+ {
+ jintArray oneDim = (jintArray)curEnv->GetObjectArrayElement(res, i);
+ lenCol = curEnv->GetArrayLength(oneDim);
+ int *resultsArray = static_cast<int *>(curEnv->GetPrimitiveArrayCritical(oneDim, &isCopy));
+ myArray[i] = new int[ lenCol];
+ for (int j = 0; j < lenCol; j++)
+ {
+ myArray[i][j] = resultsArray[j];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+ }
-if (xLocal == NULL)
-{
-// check that allocation succeed
-curEnv->DeleteLocalRef(x_);
-throw GiwsException::JniBadAllocException(curEnv);
-}
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
-curEnv->SetShortArrayRegion( xLocal, 0, xSizeCol, (jshort*)(x[i]) ) ;
-curEnv->SetObjectArrayElement(x_, i, xLocal);
-curEnv->DeleteLocalRef(xLocal);
}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapShortjobjectArray__shortshortID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+long long ScilabJavaObject::unwrapUInt (JavaVM * jvm_, int x)
+{
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-int ScilabJavaObject::wrapUShort (JavaVM * jvm_, int x){
+ jmethodID jlongunwrapUIntjintintID = curEnv->GetStaticMethodID(cls, "unwrapUInt", "(I)J" ) ;
+ if (jlongunwrapUIntjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapUInt");
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jlong res = static_cast<jlong>( curEnv->CallStaticLongMethod(cls, jlongunwrapUIntjintintID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapUShortjintintID = curEnv->GetStaticMethodID(cls, "wrapUShort", "(I)I" ) ;
-if (jintwrapUShortjintintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUShort");
}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUShortjintintID ,x));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+long long* ScilabJavaObject::unwrapRowUInt (JavaVM * jvm_, int x)
+{
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jlongArray_unwrapRowUIntjintintID = curEnv->GetStaticMethodID(cls, "unwrapRowUInt", "(I)[J" ) ;
+ if (jlongArray_unwrapRowUIntjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapRowUInt");
+ }
+
+ jlongArray res = static_cast<jlongArray>( curEnv->CallStaticObjectMethod(cls, jlongArray_unwrapRowUIntjintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
+ jlong *resultsArray = static_cast<jlong *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
+ long long* myArray = new long long[ lenRow];
+
+ for (jsize i = 0; i < lenRow; i++)
+ {
+ myArray[i] = resultsArray[i];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
+
+}
+
+long long** ScilabJavaObject::unwrapMatUInt (JavaVM * jvm_, int x)
+{
-int ScilabJavaObject::wrapUShort (JavaVM * jvm_, int const* x, int xSize){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jobjectArray__unwrapMatUIntjintintID = curEnv->GetStaticMethodID(cls, "unwrapMatUInt", "(I)[[J" ) ;
+ if (jobjectArray__unwrapMatUIntjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapMatUInt");
+ }
+
+ jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray__unwrapMatUIntjintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenCol;
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ long long ** myArray = new long long*[ lenRow];
+ for (int i = 0; i < lenRow; i++)
+ {
+ jlongArray oneDim = (jlongArray)curEnv->GetObjectArrayElement(res, i);
+ lenCol = curEnv->GetArrayLength(oneDim);
+ long long *resultsArray = static_cast<long long *>(curEnv->GetPrimitiveArrayCritical(oneDim, &isCopy));
+ myArray[i] = new long long[ lenCol];
+ for (int j = 0; j < lenCol; j++)
+ {
+ myArray[i][j] = resultsArray[j];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
-jmethodID jintwrapUShortjintArray_intintID = curEnv->GetStaticMethodID(cls, "wrapUShort", "([I)I" ) ;
-if (jintwrapUShortjintArray_intintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUShort");
}
-jintArray x_ = curEnv->NewIntArray( xSize ) ;
-
-if (x_ == NULL)
+byte ScilabJavaObject::unwrapByte (JavaVM * jvm_, int x)
{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetIntArrayRegion( x_, 0, xSize, (jint*)(x) ) ;
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ jmethodID jbyteunwrapBytejintintID = curEnv->GetStaticMethodID(cls, "unwrapByte", "(I)B" ) ;
+ if (jbyteunwrapBytejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapByte");
+ }
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUShortjintArray_intintID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
+ jbyte res = static_cast<jbyte>( curEnv->CallStaticByteMethod(cls, jbyteunwrapBytejintintID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
}
-int ScilabJavaObject::wrapUShort (JavaVM * jvm_, int const* const* x, int xSize, int xSizeCol){
+byte* ScilabJavaObject::unwrapRowByte (JavaVM * jvm_, int x)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jbyteArray_unwrapRowBytejintintID = curEnv->GetStaticMethodID(cls, "unwrapRowByte", "(I)[B" ) ;
+ if (jbyteArray_unwrapRowBytejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapRowByte");
+ }
+
+ jbyteArray res = static_cast<jbyteArray>( curEnv->CallStaticObjectMethod(cls, jbyteArray_unwrapRowBytejintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
+ jbyte *resultsArray = static_cast<jbyte *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
+ byte* myArray = new byte[ lenRow];
+
+ for (jsize i = 0; i < lenRow; i++)
+ {
+ myArray[i] = resultsArray[i];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
+
+}
+
+byte** ScilabJavaObject::unwrapMatByte (JavaVM * jvm_, int x)
+{
-jmethodID jintwrapUShortjobjectArray__intintID = curEnv->GetStaticMethodID(cls, "wrapUShort", "([[I)I" ) ;
-if (jintwrapUShortjobjectArray__intintID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapUShort");
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jobjectArray__unwrapMatBytejintintID = curEnv->GetStaticMethodID(cls, "unwrapMatByte", "(I)[[B" ) ;
+ if (jobjectArray__unwrapMatBytejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapMatByte");
+ }
+
+ jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray__unwrapMatBytejintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenCol;
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ byte ** myArray = new byte*[ lenRow];
+ for (int i = 0; i < lenRow; i++)
+ {
+ jbyteArray oneDim = (jbyteArray)curEnv->GetObjectArrayElement(res, i);
+ lenCol = curEnv->GetArrayLength(oneDim);
+ byte *resultsArray = static_cast<byte *>(curEnv->GetPrimitiveArrayCritical(oneDim, &isCopy));
+ myArray[i] = new byte[ lenCol];
+ for (int j = 0; j < lenCol; j++)
+ {
+ myArray[i][j] = resultsArray[j];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+ }
- jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[I"),NULL);
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
-if (x_ == NULL)
-{
-// check that allocation succeed
-throw GiwsException::JniBadAllocException(curEnv);
}
- for (int i=0; i<xSize; i++){
-
-jintArray xLocal = curEnv->NewIntArray( xSizeCol ) ;
-
-if (xLocal == NULL)
+short ScilabJavaObject::unwrapUByte (JavaVM * jvm_, int x)
{
-// check that allocation succeed
-curEnv->DeleteLocalRef(x_);
-throw GiwsException::JniBadAllocException(curEnv);
-}
-
-curEnv->SetIntArrayRegion( xLocal, 0, xSizeCol, (jint*)(x[i]) ) ;
-curEnv->SetObjectArrayElement(x_, i, xLocal);
-curEnv->DeleteLocalRef(xLocal);
-}
-
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapUShortjobjectArray__intintID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-int ScilabJavaObject::wrapString (JavaVM * jvm_, char const* x){
+ jmethodID jshortunwrapUBytejintintID = curEnv->GetStaticMethodID(cls, "unwrapUByte", "(I)S" ) ;
+ if (jshortunwrapUBytejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapUByte");
+ }
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ jshort res = static_cast<jshort>( curEnv->CallStaticShortMethod(cls, jshortunwrapUBytejintintID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-jmethodID jintwrapStringjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrapString", "(Ljava/lang/String;)I" ) ;
-if (jintwrapStringjstringjava_lang_StringID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapString");
}
-jstring x_ = curEnv->NewStringUTF( x );
-if (x != NULL && x_ == NULL)
+short* ScilabJavaObject::unwrapRowUByte (JavaVM * jvm_, int x)
{
-throw GiwsException::JniBadAllocException(curEnv);
-}
-
-
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapStringjstringjava_lang_StringID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
-
-}
-int ScilabJavaObject::wrapString (JavaVM * jvm_, char const* const* x, int xSize){
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jshortArray_unwrapRowUBytejintintID = curEnv->GetStaticMethodID(cls, "unwrapRowUByte", "(I)[S" ) ;
+ if (jshortArray_unwrapRowUBytejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapRowUByte");
+ }
+
+ jshortArray res = static_cast<jshortArray>( curEnv->CallStaticObjectMethod(cls, jshortArray_unwrapRowUBytejintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
+ jshort *resultsArray = static_cast<jshort *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
+ short* myArray = new short[ lenRow];
+
+ for (jsize i = 0; i < lenRow; i++)
+ {
+ myArray[i] = resultsArray[i];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
+
+}
+
+short** ScilabJavaObject::unwrapMatUByte (JavaVM * jvm_, int x)
+{
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jobjectArray__unwrapMatUBytejintintID = curEnv->GetStaticMethodID(cls, "unwrapMatUByte", "(I)[[S" ) ;
+ if (jobjectArray__unwrapMatUBytejintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapMatUByte");
+ }
+
+ jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray__unwrapMatUBytejintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenCol;
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ short ** myArray = new short*[ lenRow];
+ for (int i = 0; i < lenRow; i++)
+ {
+ jshortArray oneDim = (jshortArray)curEnv->GetObjectArrayElement(res, i);
+ lenCol = curEnv->GetArrayLength(oneDim);
+ short *resultsArray = static_cast<short *>(curEnv->GetPrimitiveArrayCritical(oneDim, &isCopy));
+ myArray[i] = new short[ lenCol];
+ for (int j = 0; j < lenCol; j++)
+ {
+ myArray[i][j] = resultsArray[j];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+ }
-jmethodID jintwrapStringjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrapString", "([Ljava/lang/String;)I" ) ;
-if (jintwrapStringjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapString");
-}
-jclass stringArrayClass = curEnv->FindClass("java/lang/String");
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
-// create java array of strings.
-jobjectArray x_ = curEnv->NewObjectArray( xSize, stringArrayClass, NULL);
-if (x_ == NULL)
-{
-throw GiwsException::JniBadAllocException(curEnv);
}
-// convert each char * to java strings and fill the java array.
-for ( int i = 0; i < xSize; i++)
+short ScilabJavaObject::unwrapShort (JavaVM * jvm_, int x)
{
-jstring TempString = curEnv->NewStringUTF( x[i] );
-if (TempString == NULL)
-{
-throw GiwsException::JniBadAllocException(curEnv);
-}
-curEnv->SetObjectArrayElement( x_, i, TempString);
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
-// avoid keeping reference on to many strings
-curEnv->DeleteLocalRef(TempString);
-}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapStringjobjectArray_java_lang_Stringjava_lang_StringID ,x_));
- curEnv->DeleteLocalRef(stringArrayClass);
-curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
-
-}
+ jmethodID jshortunwrapShortjintintID = curEnv->GetStaticMethodID(cls, "unwrapShort", "(I)S" ) ;
+ if (jshortunwrapShortjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapShort");
+ }
-int ScilabJavaObject::wrapString (JavaVM * jvm_, char const* const* const* x, int xSize, int xSizeCol){
+ jshort res = static_cast<jshort>( curEnv->CallStaticShortMethod(cls, jshortunwrapShortjintintID , x));
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return res;
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-
-jmethodID jintwrapStringjobjectArray__java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrapString", "([[Ljava/lang/String;)I" ) ;
-if (jintwrapStringjobjectArray__java_lang_Stringjava_lang_StringID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapString");
-}
-jclass stringArrayClass = curEnv->FindClass("java/lang/String");
-// create java array of array of strings.
-jobjectArray x_ = curEnv->NewObjectArray( xSize, curEnv->FindClass("[Ljava/lang/String;"), NULL);
-if (x_ == NULL)
-{
-throw GiwsException::JniBadAllocException(curEnv);
}
-for ( int i = 0; i < xSize; i++)
+short* ScilabJavaObject::unwrapRowShort (JavaVM * jvm_, int x)
{
-jobjectArray xLocal = curEnv->NewObjectArray( xSizeCol, stringArrayClass, NULL);
-// convert each char * to java strings and fill the java array.
-for ( int j = 0; j < xSizeCol; j++) {
-jstring TempString = curEnv->NewStringUTF( x[i][j] );
-if (TempString == NULL)
+ JNIEnv * curEnv = NULL;
+ jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+ jclass cls = curEnv->FindClass( className().c_str() );
+ if ( cls == NULL)
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+
+ jmethodID jshortArray_unwrapRowShortjintintID = curEnv->GetStaticMethodID(cls, "unwrapRowShort", "(I)[S" ) ;
+ if (jshortArray_unwrapRowShortjintintID == NULL)
+ {
+ throw GiwsException::JniMethodNotFoundException(curEnv, "unwrapRowShort");
+ }
+
+ jshortArray res = static_cast<jshortArray>( curEnv->CallStaticObjectMethod(cls, jshortArray_unwrapRowShortjintintID , x));
+ if (res == NULL)
+ {
+ return NULL;
+ }
+ if (curEnv->ExceptionCheck())
+ {
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ int lenRow;
+ lenRow = curEnv->GetArrayLength(res);
+ jboolean isCopy = JNI_FALSE;
+
+ /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
+ jshort *resultsArray = static_cast<jshort *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
+ short* myArray = new short[ lenRow];
+
+ for (jsize i = 0; i < lenRow; i++)
+ {
+ myArray[i] = resultsArray[i];
+ }
+ curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
+
+ curEnv->DeleteLocalRef(res);
+ curEnv->DeleteLocalRef(cls);
+ if (curEnv->ExceptionCheck())
+ {
+ delete[] myArray;
+ throw GiwsException::JniCallMethodException(curEnv);
+ }
+ return myArray;
+
+}
+
+short** ScilabJavaObject::unwrapMatShort (JavaVM * jvm_, int x)
{
-throw GiwsException::JniBadAllocException(curEnv);
-}
-
-curEnv->SetObjectArrayElement( xLocal, j, TempString);
-
-// avoid keeping reference on to many strings
-curEnv->DeleteLocalRef(TempString);
-}
-curEnv->SetObjectArrayElement(x_, i, xLocal);
-curEnv->DeleteLocalRef(xLocal);
-
-}
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapStringjobjectArray__java_lang_Stringjava_lang_StringID ,x_));
- curEnv->DeleteLocalRef(stringArrayClass);
-curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
-
-}
-
-int ScilabJavaObject::wrapBoolean (JavaVM * jvm_, bool x){
-
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-
-jmethodID jintwrapBooleanjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "wrapBoolean", "(Z)I" ) ;
-if (jintwrapBooleanjbooleanbooleanID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapBoolean");
-}
-
-jboolean x_ = (static_cast<bool>(x) ? JNI_TRUE : JNI_FALSE);
-
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapBooleanjbooleanbooleanID ,x_));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
-
-}
-
-int ScilabJavaObject::wrapBoolean (JavaVM * jvm_, bool const* x, int xSize){
-
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-
-jmethodID jintwrapBooleanjbooleanArray_booleanbooleanID = curEnv->GetStaticMethodID(cls, "wrapBoolean", "([Z)I" ) ;
-if (jintwrapBooleanjbooleanArray_booleanbooleanID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapBoolean");
-}
-
-jbooleanArray x_ = curEnv->NewBooleanArray( xSize ) ;
-curEnv->SetBooleanArrayRegion( x_, 0, xSize, (jboolean*)x ) ;
-
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapBooleanjbooleanArray_booleanbooleanID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
-
-}
-
-int ScilabJavaObject::wrapBoolean (JavaVM * jvm_, bool const* const* x, int xSize, int xSizeCol){
-
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-jmethodID jintwrapBooleanjobjectArray__booleanbooleanID = curEnv->GetStaticMethodID(cls, "wrapBoolean", "([[Z)I" ) ;
-if (jintwrapBooleanjobjectArray__booleanbooleanID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapBoolean");
-}
-
-jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[Z"),NULL);
-for (int i=0; i<xSize; i++){
- jbooleanArray xLocal = curEnv->NewBooleanArray( xSizeCol ) ;
- curEnv->SetBooleanArrayRegion( xLocal, 0, xSizeCol, (jboolean*)(x[i]) ) ;
- curEnv->SetObjectArrayElement(x_, i, xLocal);
- curEnv->DeleteLocalRef(xLocal);
- }
-
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapBooleanjobjectArray__booleanbooleanID ,x_));
- curEnv->DeleteLocalRef(x_);
-curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-return res;
-
-}
-
-int ScilabJavaObject::wrapChar (JavaVM * jvm_, unsigned short x){
-
-JNIEnv * curEnv = NULL;
-jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
-jclass cls = curEnv->FindClass( className().c_str() );
-if ( cls == NULL) {
-throw GiwsException::JniCallMethodException(curEnv);
-}
-
-jmethodID jintwrapCharjcharcharID = curEnv->GetStaticMethodID(cls, "wrapChar", "(C)I" ) ;
-if (jintwrapCharjcharcharID == NULL) {
-throw GiwsException::JniMethodNotFoundException(curEnv, "wrapChar");
-}
-
- jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapCharjcharcharID ,x));
- curEnv->DeleteLocalRef(cls);
-if (curEnv->ExceptionCheck()) {
-throw GiwsException::JniCallMethodException