Xcos: introduce a new XML based format (using XMI) 12/18412/9
Clément DAVID [Tue, 5 Jul 2016 09:21:50 +0000 (11:21 +0200)]
* A new XML file format based on [XML Metadata Interchange (XMI)](http://www.omg.org/spec/XMI/) has been introduced to allow interchange using [Eclipse Modeling Framework (EMF)](https://eclipse.org/modeling/emf/).

Change-Id: I947ff520f3ef569fc92d2e70acb24e04919800c0

38 files changed:
scilab/CHANGES.md
scilab/modules/io/tests/nonreg_tests/lib [deleted file]
scilab/modules/scicos/Makefile.am
scilab/modules/scicos/Makefile.in
scilab/modules/scicos/includes/XMIResource.hxx [new file with mode: 0644]
scilab/modules/scicos/includes/gw_scicos.hxx
scilab/modules/scicos/includes/model/BaseObject.hxx
scilab/modules/scicos/sci_gateway/cpp/sci_scicosDiagramToScilab.cpp [new file with mode: 0644]
scilab/modules/scicos/sci_gateway/scicos_gateway.xml
scilab/modules/scicos/src/c/DllmainScicos.c
scilab/modules/scicos/src/c/cli/DllmainScicos-cli.c
scilab/modules/scicos/src/c/cli/scicos-cli.vcxproj
scilab/modules/scicos/src/c/cli/scicos-cli.vcxproj.filters
scilab/modules/scicos/src/c/scicos.vcxproj
scilab/modules/scicos/src/c/scicos.vcxproj.filters
scilab/modules/scicos/src/cpp/Model_getObjectProperties.cpp
scilab/modules/scicos/src/cpp/Model_setObjectProperties.cpp
scilab/modules/scicos/src/cpp/XMIResource.cpp [new file with mode: 0644]
scilab/modules/scicos/src/cpp/XMIResource_load.cpp [new file with mode: 0644]
scilab/modules/scicos/src/cpp/XMIResource_save.cpp [new file with mode: 0644]
scilab/modules/scicos/src/cpp/base64.hxx [new file with mode: 0644]
scilab/modules/xcos/Makefile.am
scilab/modules/xcos/Makefile.in
scilab/modules/xcos/model/Xcos.genmodel [new file with mode: 0644]
scilab/modules/xcos/model/Xcos.xcore [new file with mode: 0644]
scilab/modules/xcos/model/xcos.ecore [new file with mode: 0644]
scilab/modules/xcos/src/c/xcos.vcxproj
scilab/modules/xcos/src/c/xcos.vcxproj.filters
scilab/modules/xcos/src/java/org/scilab/modules/xcos/JavaXMIResource.java [new file with mode: 0644]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/JavaXMIResourceJNI.java [new file with mode: 0644]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/PortKind.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/UpdateStatus.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/XcosFileType.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/XcosMessages.java
scilab/modules/xcos/src/jni/JavaXMIResource.i [new file with mode: 0644]
scilab/modules/xcos/src/jni/JavaXMIResource_wrap.cxx [new file with mode: 0644]
scilab/modules/xcos/src/jni/JavaXMIResource_wrap.h [new file with mode: 0644]

index 47ecd86..30e0b68 100644 (file)
@@ -13,7 +13,7 @@ This file is intended for the specific needs of advanced users, and describes:
 - Bug fixes.
 
 This changelog is most likely incomplete, as an enormous amount of code has changed between 5.5.2 and 6.
-Please report any thing we could have missed, on the [mailing lists][1] or on the [bug tracker][2], 
+Please report any thing we could have missed, on the [mailing lists][1] or on the [bug tracker][2],
 and we will correct it before the final Scilab 6.0.0 release.
 
 [1]: http://mailinglists.scilab.org
@@ -23,8 +23,8 @@ and we will correct it before the final Scilab 6.0.0 release.
 Main new features
 -----------------
 
-For high-level description of the main new features of this release, please 
-consult the [embedded help](modules/helptools/data/pages/homepage-en_US.html). It is also available 
+For high-level description of the main new features of this release, please
+consult the [embedded help](modules/helptools/data/pages/homepage-en_US.html). It is also available
 as the "What's new" page of the help, by simply typing `help` in Scilab console.
 
 In summary, the main new features are:
@@ -100,7 +100,7 @@ Language changes
 
 Some small changes have been done to the language syntax, aiming at more clarity and less
 ambiguity. Some changes are not compatible with 5.5; code written for Scilab 5.x
-has to be modified in order to work in Scilab 6.0. 
+has to be modified in order to work in Scilab 6.0.
 
 See [the wiki page on porting code from 5.5 to 6.0](https://wiki.scilab.org/FromScilab5ToScilab6)
 for details and examples.
@@ -111,10 +111,10 @@ for details and examples.
 * Declaring strings using non-homogenous delimiters ("string' or 'string") is no longer allowed.
 * `(a=b)` executed as `a == b` is now deprecated and returns an error.
 * Function definitions can finish with `end` instead of `endfunction`.
-* `{}` and `[]` are now distinct operators. Matrices can no longer be defined usind `{}` operators. 
+* `{}` and `[]` are now distinct operators. Matrices can no longer be defined usind `{}` operators.
 These are reserved for cell definition.
 * Shortcut and element-wise boolean operators are now distinct. `&&` and `||` are new shortcut boolean AND and OR,
-while `&` and `|` are element-wise operations and will not shortcut one of the operand. 
+while `&` and `|` are element-wise operations and will not shortcut one of the operand.
 Both shortcut and element-wise operators are evaluated from left to right.
 * Syntax `%i:10` is now deprecated (only real scalars can be used).
 * `while ... else ... end` control instruction is not supported anymore.
@@ -150,12 +150,12 @@ Feature changes and additions
 * `sign` can now handle a sparse matrix.
 * `sleep(..,'s')` allows now to specify the duration in seconds.
 * `real`, `imag`, `conj` and `isreal` now accept rational fractions.
-* A call stack limit has been introduced. Default maximum depth is setup to 1000 
+* A call stack limit has been introduced. Default maximum depth is setup to 1000
 and can be changed by `recursionlimit` or through the Preferences interface.
-* The floating point exception mode `ieee` is now set to `2` by default: floating 
+* The floating point exception mode `ieee` is now set to `2` by default: floating
 point exceptions now produce `Inf` or `Nan`, and do not cause any error.
 The previous behavior can be recalled by simply calling: `ieee(0)`.
-* The graphics entity "Datatip" has its property `z_component = 'on|off'` changed to 
+* The graphics entity "Datatip" has its property `z_component = 'on|off'` changed to
 `display_components = 'xyz'`; it is now possible to choose which components to display,
 and in which order. Loading old `*.scg` files containing datatips with "z_component"
 property may not display the z component.
@@ -163,7 +163,7 @@ property may not display the z component.
 * `amell` now:
   - checks if its parameters are real numbers,
   - throws an error if the second parameter is not a scalar.
-* The use of I/O console is now allowed with the following functions: `mget`, 
+* The use of I/O console is now allowed with the following functions: `mget`,
 `mgetl`, `mgetstr`, `mput`, `mputl` and `mputstr`.
 * `mclearerr` now returns a flag indicating the file identifier validity.
 * `fileinfo` can now take a row vector as input.
@@ -192,9 +192,9 @@ input and output arguments.
    - `bitxor` is now vectorized and fast.
 * The zoom rubber box now can start/finish from points lying outside the axes bounds.
 * The zoom rubber box now can select multiple and overlying axes at once. Changed behavior of scroll zoom,
-scrolling over overlying axes will zoom all of them together, using the CTRL key while scrolling 
+scrolling over overlying axes will zoom all of them together, using the CTRL key while scrolling
 will zoom all axes in the current figure.
-* The graphics entity "Datatip" has a new property `detached_position` which accepts `[]` 
+* The graphics entity "Datatip" has a new property `detached_position` which accepts `[]`
 or a 3-components vector to set the position in axes coordinates to draw the datatip text box.
 * `MPI_Create_comm` create a new communicator from MPI_COMM_WORLD using MPI world ranks.
 
@@ -235,22 +235,23 @@ Xcos
 
 * Major rewrite of the data structures, huge models should load and save faster.
 The memory usage on diagram edition is also slightly reduced.
-* ZCOS and XCOS file formats have evolved to reduce the duplicated information. 
+* ZCOS and XCOS file formats have evolved to reduce the duplicated information.
 Scilab 5.5.2 is able to open the newly saved files, but the ports have to be repositioned manually.
-* Implicit fixed-size step ODE solver added: Crank-Nicolson 2(3). 
+* A new XML file format based on [XML Metadata Interchange (XMI)](http://www.omg.org/spec/XMI/) has been introduced to allow interchange using [Eclipse Modeling Framework (EMF)](https://eclipse.org/modeling/emf/).
+* Implicit fixed-size step ODE solver added: Crank-Nicolson 2(3).
 Added to the CVode package, it also benefits from the CVode rootfinding feature.
 
 
 API modification
 ----------------
 
-A new set of C APIs to write C or C++ extensions (toolboxes) to Scilab. 
+A new set of C APIs to write C or C++ extensions (toolboxes) to Scilab.
 It allows defining native functions (commonly called "gateways"), getting input parameters
 for such functions, setting return parameters, accessing local variables, using common helper
-functions for accessing environment information (such as warning level), generate errors... 
+functions for accessing environment information (such as warning level), generate errors...
 
 It also includes ways to overload existing Scilab functions to support additional parameter
-types (see `help scilab_overload`). Finally, you can call back Scilab functions 
+types (see `help scilab_overload`). Finally, you can call back Scilab functions
 (macros and built-in functions) from your gateway (see `help scilab_call`).
 
 User-defined functions written in C or C++ (gateways) must now use a `void* pvApiCtx` name
@@ -299,7 +300,7 @@ Known issues
 
 * Scilab 6 is still in a beta stage and likely to contain a number of known or unknown bugs.
 Do not hesitate to [report](https://bugzilla.scilab.org) them.
-* Toolboxes rebuild is in progress. Do not hesitate to submit patch or feature upgrade to 
+* Toolboxes rebuild is in progress. Do not hesitate to submit patch or feature upgrade to
 the [development mailing list](dev@lists.scilab.org) for a particular toolbox.
 
 
diff --git a/scilab/modules/io/tests/nonreg_tests/lib b/scilab/modules/io/tests/nonreg_tests/lib
deleted file mode 100644 (file)
index c211999..0000000
Binary files a/scilab/modules/io/tests/nonreg_tests/lib and /dev/null differ
index 3055584..c52caba 100644 (file)
@@ -21,6 +21,9 @@ src/cpp/il_state.cpp \
 src/cpp/il_sim.cpp \
 src/cpp/var2vec.cpp \
 src/cpp/vec2var.cpp \
+src/cpp/XMIResource.cpp \
+src/cpp/XMIResource_load.cpp \
+src/cpp/XMIResource_save.cpp \
 src/cpp/Controller.cpp \
 src/cpp/controller_helpers.cpp \
 src/cpp/LoggerView.cpp \
@@ -95,7 +98,8 @@ sci_gateway/cpp/sci_validvar.cpp \
 sci_gateway/cpp/sci_var2vec.cpp \
 sci_gateway/cpp/sci_vec2var.cpp \
 sci_gateway/cpp/sci_callblk.cpp \
-sci_gateway/cpp/sci_model2blk.cpp
+sci_gateway/cpp/sci_model2blk.cpp \
+sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
 
 GATEWAY_C_SOURCES = \
 sci_gateway/c/sci_ftree2.c \
@@ -149,11 +153,13 @@ libsciscicos_algo_la_CPPFLAGS= -I$(srcdir)/includes/ \
                        -I$(top_srcdir)/modules/threads/includes/ \
                        -I$(top_srcdir)/modules/console/includes/ \
                        -I$(top_srcdir)/modules/differential_equations/includes/ \
+                       $(XML_FLAGS) \
                        $(AM_CPPFLAGS)
 else
 libsciscicos_algo_la_CPPFLAGS= -I$(top_srcdir)/modules/output_stream/includes/ \
                        -I$(top_srcdir)/modules/api_scilab/includes/ \
                        -I$(top_srcdir)/modules/scicos/includes/ \
+                       $(XML_FLAGS) \
                        $(AM_CPPFLAGS)
 endif
 libsciscicos_cli_la_CPPFLAGS = $(libsciscicos_algo_la_CPPFLAGS)
@@ -169,7 +175,9 @@ libsciscicos_cli_la_SOURCES =
 libsciscicos_la_SOURCES =
 endif
 
-libsciscicos_algo_la_LIBADD =
+libsciscicos_algo_la_LIBADD =  \
+               $(RT_LIB) \
+               $(LIBXML_LIBS)
 libsciscicos_cli_la_LIBADD = libsciscicos-algo.la
 libsciscicos_la_LIBADD = libsciscicos-algo.la
 if XCOS
@@ -181,11 +189,6 @@ libsciscicos_la_LIBADD += libscisundials.la \
 endif
 endif
 
-libsciscicos_algo_la_LIBADD += $(RT_LIB)
-libsciscicos_cli_la_LIBADD += $(RT_LIB)
-libsciscicos_la_LIBADD += $(RT_LIB)
-
-
 # For the code check (splint)
 CHECK_SRC= $(SCICOS_C_SOURCES) $(GATEWAY_C_SOURCES)
 INCLUDE_FLAGS = $(libsciscicos_la_CFLAGS)
index bb39dd0..71ddc9b 100644 (file)
@@ -220,9 +220,11 @@ am__DEPENDENCIES_1 =
 libsciscicos_algo_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
 am__libsciscicos_algo_la_SOURCES_DIST = src/c/noscicos/noscicos.c \
        src/cpp/il_state.cpp src/cpp/il_sim.cpp src/cpp/var2vec.cpp \
-       src/cpp/vec2var.cpp src/cpp/Controller.cpp \
-       src/cpp/controller_helpers.cpp src/cpp/LoggerView.cpp \
-       src/cpp/Model.cpp src/cpp/Model_getObjectProperties.cpp \
+       src/cpp/vec2var.cpp src/cpp/XMIResource.cpp \
+       src/cpp/XMIResource_load.cpp src/cpp/XMIResource_save.cpp \
+       src/cpp/Controller.cpp src/cpp/controller_helpers.cpp \
+       src/cpp/LoggerView.cpp src/cpp/Model.cpp \
+       src/cpp/Model_getObjectProperties.cpp \
        src/cpp/Model_setObjectProperties.cpp \
        src/cpp/view_scilab/Adapters.cpp \
        src/cpp/view_scilab/BlockAdapter.cpp \
@@ -248,6 +250,9 @@ am__objects_2 = src/cpp/libsciscicos_algo_la-il_state.lo \
        src/cpp/libsciscicos_algo_la-il_sim.lo \
        src/cpp/libsciscicos_algo_la-var2vec.lo \
        src/cpp/libsciscicos_algo_la-vec2var.lo \
+       src/cpp/libsciscicos_algo_la-XMIResource.lo \
+       src/cpp/libsciscicos_algo_la-XMIResource_load.lo \
+       src/cpp/libsciscicos_algo_la-XMIResource_save.lo \
        src/cpp/libsciscicos_algo_la-Controller.lo \
        src/cpp/libsciscicos_algo_la-controller_helpers.lo \
        src/cpp/libsciscicos_algo_la-LoggerView.lo \
@@ -296,7 +301,7 @@ libsciscicos_algo_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
        $(AM_CXXFLAGS) $(CXXFLAGS) $(libsciscicos_algo_la_LDFLAGS) \
        $(LDFLAGS) -o $@
 libsciscicos_cli_la_DEPENDENCIES = libsciscicos-algo.la \
-       $(am__append_2) $(am__DEPENDENCIES_1)
+       $(am__append_2)
 am__libsciscicos_cli_la_SOURCES_DIST =  \
        sci_gateway/cpp/sci_scicos_debug.cpp \
        sci_gateway/cpp/sci_scicos_debug_count.cpp \
@@ -325,10 +330,11 @@ am__libsciscicos_cli_la_SOURCES_DIST =  \
        sci_gateway/cpp/sci_var2vec.cpp \
        sci_gateway/cpp/sci_vec2var.cpp \
        sci_gateway/cpp/sci_callblk.cpp \
-       sci_gateway/cpp/sci_model2blk.cpp sci_gateway/c/sci_ftree2.c \
-       sci_gateway/c/sci_ftree3.c sci_gateway/c/sci_ftree4.c \
-       sci_gateway/c/sci_loadScicos.c sci_gateway/c/sci_sctree.c \
-       sci_gateway/fortran/sci_f_tree2.f \
+       sci_gateway/cpp/sci_model2blk.cpp \
+       sci_gateway/cpp/sci_scicosDiagramToScilab.cpp \
+       sci_gateway/c/sci_ftree2.c sci_gateway/c/sci_ftree3.c \
+       sci_gateway/c/sci_ftree4.c sci_gateway/c/sci_loadScicos.c \
+       sci_gateway/c/sci_sctree.c sci_gateway/fortran/sci_f_tree2.f \
        sci_gateway/fortran/sci_f_tree3.f \
        sci_gateway/fortran/sci_f_tree4.f
 am__objects_5 =  \
@@ -360,7 +366,8 @@ am__objects_5 =  \
        sci_gateway/cpp/libsciscicos_cli_la-sci_var2vec.lo \
        sci_gateway/cpp/libsciscicos_cli_la-sci_vec2var.lo \
        sci_gateway/cpp/libsciscicos_cli_la-sci_callblk.lo \
-       sci_gateway/cpp/libsciscicos_cli_la-sci_model2blk.lo
+       sci_gateway/cpp/libsciscicos_cli_la-sci_model2blk.lo \
+       sci_gateway/cpp/libsciscicos_cli_la-sci_scicosDiagramToScilab.lo
 am__objects_6 = sci_gateway/c/libsciscicos_cli_la-sci_ftree2.lo \
        sci_gateway/c/libsciscicos_cli_la-sci_ftree3.lo \
        sci_gateway/c/libsciscicos_cli_la-sci_ftree4.lo \
@@ -377,8 +384,7 @@ libsciscicos_cli_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
        $(AM_CXXFLAGS) $(CXXFLAGS) $(libsciscicos_cli_la_LDFLAGS) \
        $(LDFLAGS) -o $@
 @XCOS_TRUE@am_libsciscicos_cli_la_rpath = -rpath $(pkglibdir)
-libsciscicos_la_DEPENDENCIES = libsciscicos-algo.la $(am__append_3) \
-       $(am__DEPENDENCIES_1)
+libsciscicos_la_DEPENDENCIES = libsciscicos-algo.la $(am__append_3)
 am__libsciscicos_la_SOURCES_DIST =  \
        sci_gateway/cpp/sci_scicos_debug.cpp \
        sci_gateway/cpp/sci_scicos_debug_count.cpp \
@@ -407,10 +413,11 @@ am__libsciscicos_la_SOURCES_DIST =  \
        sci_gateway/cpp/sci_var2vec.cpp \
        sci_gateway/cpp/sci_vec2var.cpp \
        sci_gateway/cpp/sci_callblk.cpp \
-       sci_gateway/cpp/sci_model2blk.cpp sci_gateway/c/sci_ftree2.c \
-       sci_gateway/c/sci_ftree3.c sci_gateway/c/sci_ftree4.c \
-       sci_gateway/c/sci_loadScicos.c sci_gateway/c/sci_sctree.c \
-       sci_gateway/fortran/sci_f_tree2.f \
+       sci_gateway/cpp/sci_model2blk.cpp \
+       sci_gateway/cpp/sci_scicosDiagramToScilab.cpp \
+       sci_gateway/c/sci_ftree2.c sci_gateway/c/sci_ftree3.c \
+       sci_gateway/c/sci_ftree4.c sci_gateway/c/sci_loadScicos.c \
+       sci_gateway/c/sci_sctree.c sci_gateway/fortran/sci_f_tree2.f \
        sci_gateway/fortran/sci_f_tree3.f \
        sci_gateway/fortran/sci_f_tree4.f
 am__objects_8 = sci_gateway/cpp/libsciscicos_la-sci_scicos_debug.lo \
@@ -441,7 +448,8 @@ am__objects_8 = sci_gateway/cpp/libsciscicos_la-sci_scicos_debug.lo \
        sci_gateway/cpp/libsciscicos_la-sci_var2vec.lo \
        sci_gateway/cpp/libsciscicos_la-sci_vec2var.lo \
        sci_gateway/cpp/libsciscicos_la-sci_callblk.lo \
-       sci_gateway/cpp/libsciscicos_la-sci_model2blk.lo
+       sci_gateway/cpp/libsciscicos_la-sci_model2blk.lo \
+       sci_gateway/cpp/libsciscicos_la-sci_scicosDiagramToScilab.lo
 am__objects_9 = sci_gateway/c/libsciscicos_la-sci_ftree2.lo \
        sci_gateway/c/libsciscicos_la-sci_ftree3.lo \
        sci_gateway/c/libsciscicos_la-sci_ftree4.lo \
@@ -947,6 +955,9 @@ src/cpp/il_state.cpp \
 src/cpp/il_sim.cpp \
 src/cpp/var2vec.cpp \
 src/cpp/vec2var.cpp \
+src/cpp/XMIResource.cpp \
+src/cpp/XMIResource_load.cpp \
+src/cpp/XMIResource_save.cpp \
 src/cpp/Controller.cpp \
 src/cpp/controller_helpers.cpp \
 src/cpp/LoggerView.cpp \
@@ -1019,7 +1030,8 @@ sci_gateway/cpp/sci_validvar.cpp \
 sci_gateway/cpp/sci_var2vec.cpp \
 sci_gateway/cpp/sci_vec2var.cpp \
 sci_gateway/cpp/sci_callblk.cpp \
-sci_gateway/cpp/sci_model2blk.cpp
+sci_gateway/cpp/sci_model2blk.cpp \
+sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
 
 GATEWAY_C_SOURCES = \
 sci_gateway/c/sci_ftree2.c \
@@ -1044,6 +1056,7 @@ libsciscicos_la_LDFLAGS = $(AM_LDFLAGS)
 @XCOS_FALSE@libsciscicos_algo_la_CPPFLAGS = -I$(top_srcdir)/modules/output_stream/includes/ \
 @XCOS_FALSE@                   -I$(top_srcdir)/modules/api_scilab/includes/ \
 @XCOS_FALSE@                   -I$(top_srcdir)/modules/scicos/includes/ \
+@XCOS_FALSE@                   $(XML_FLAGS) \
 @XCOS_FALSE@                   $(AM_CPPFLAGS)
 
 @XCOS_TRUE@libsciscicos_algo_la_CPPFLAGS = -I$(srcdir)/includes/ \
@@ -1070,6 +1083,7 @@ libsciscicos_la_LDFLAGS = $(AM_LDFLAGS)
 @XCOS_TRUE@                    -I$(top_srcdir)/modules/threads/includes/ \
 @XCOS_TRUE@                    -I$(top_srcdir)/modules/console/includes/ \
 @XCOS_TRUE@                    -I$(top_srcdir)/modules/differential_equations/includes/ \
+@XCOS_TRUE@                    $(XML_FLAGS) \
 @XCOS_TRUE@                    $(AM_CPPFLAGS)
 
 libsciscicos_cli_la_CPPFLAGS = $(libsciscicos_algo_la_CPPFLAGS)
@@ -1080,11 +1094,12 @@ libsciscicos_la_CPPFLAGS = $(libsciscicos_algo_la_CPPFLAGS)
 @XCOS_TRUE@libsciscicos_cli_la_SOURCES = $(GATEWAY_CXX_SOURCES) $(GATEWAY_C_SOURCES) $(GATEWAY_FORTRAN_SOURCES)
 @XCOS_FALSE@libsciscicos_la_SOURCES = 
 @XCOS_TRUE@libsciscicos_la_SOURCES = $(GATEWAY_CXX_SOURCES) $(GATEWAY_C_SOURCES) $(GATEWAY_FORTRAN_SOURCES)
-libsciscicos_algo_la_LIBADD = $(RT_LIB)
-libsciscicos_cli_la_LIBADD = libsciscicos-algo.la $(am__append_2) \
-       $(RT_LIB)
-libsciscicos_la_LIBADD = libsciscicos-algo.la $(am__append_3) \
-       $(RT_LIB)
+libsciscicos_algo_la_LIBADD = \
+               $(RT_LIB) \
+               $(LIBXML_LIBS)
+
+libsciscicos_cli_la_LIBADD = libsciscicos-algo.la $(am__append_2)
+libsciscicos_la_LIBADD = libsciscicos-algo.la $(am__append_3)
 
 # For the code check (splint)
 CHECK_SRC = $(SCICOS_C_SOURCES) $(GATEWAY_C_SOURCES)
@@ -1463,6 +1478,12 @@ src/cpp/libsciscicos_algo_la-var2vec.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libsciscicos_algo_la-vec2var.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libsciscicos_algo_la-XMIResource.lo: src/cpp/$(am__dirstamp) \
+       src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libsciscicos_algo_la-XMIResource_load.lo:  \
+       src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libsciscicos_algo_la-XMIResource_save.lo:  \
+       src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libsciscicos_algo_la-Controller.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libsciscicos_algo_la-controller_helpers.lo:  \
@@ -1662,6 +1683,9 @@ sci_gateway/cpp/libsciscicos_cli_la-sci_callblk.lo:  \
 sci_gateway/cpp/libsciscicos_cli_la-sci_model2blk.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libsciscicos_cli_la-sci_scicosDiagramToScilab.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/c/$(am__dirstamp):
        @$(MKDIR_P) sci_gateway/c
        @: > sci_gateway/c/$(am__dirstamp)
@@ -1788,6 +1812,9 @@ sci_gateway/cpp/libsciscicos_la-sci_callblk.lo:  \
 sci_gateway/cpp/libsciscicos_la-sci_model2blk.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libsciscicos_la-sci_scicosDiagramToScilab.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/c/libsciscicos_la-sci_ftree2.lo:  \
        sci_gateway/c/$(am__dirstamp) \
        sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
@@ -2028,6 +2055,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_model2blk.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_phase_simulation.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_pointer_xproperty.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_scicosDiagramToScilab.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_scicos_debug.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_scicos_debug_count.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_scicos_log.Plo@am__quote@
@@ -2057,6 +2085,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_model2blk.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_phase_simulation.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_pointer_xproperty.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicosDiagramToScilab.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicos_debug.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicos_debug_count.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicos_log.Plo@am__quote@
@@ -2087,6 +2116,9 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-Model.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-Model_getObjectProperties.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-Model_setObjectProperties.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource_load.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource_save.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-controller_helpers.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-createblklist.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciscicos_algo_la-extractblklist.Plo@am__quote@
@@ -2490,6 +2522,27 @@ src/cpp/libsciscicos_algo_la-vec2var.lo: src/cpp/vec2var.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciscicos_algo_la-vec2var.lo `test -f 'src/cpp/vec2var.cpp' || echo '$(srcdir)/'`src/cpp/vec2var.cpp
 
+src/cpp/libsciscicos_algo_la-XMIResource.lo: src/cpp/XMIResource.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciscicos_algo_la-XMIResource.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource.Tpo -c -o src/cpp/libsciscicos_algo_la-XMIResource.lo `test -f 'src/cpp/XMIResource.cpp' || echo '$(srcdir)/'`src/cpp/XMIResource.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource.Tpo src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/XMIResource.cpp' object='src/cpp/libsciscicos_algo_la-XMIResource.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciscicos_algo_la-XMIResource.lo `test -f 'src/cpp/XMIResource.cpp' || echo '$(srcdir)/'`src/cpp/XMIResource.cpp
+
+src/cpp/libsciscicos_algo_la-XMIResource_load.lo: src/cpp/XMIResource_load.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciscicos_algo_la-XMIResource_load.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource_load.Tpo -c -o src/cpp/libsciscicos_algo_la-XMIResource_load.lo `test -f 'src/cpp/XMIResource_load.cpp' || echo '$(srcdir)/'`src/cpp/XMIResource_load.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource_load.Tpo src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource_load.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/XMIResource_load.cpp' object='src/cpp/libsciscicos_algo_la-XMIResource_load.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciscicos_algo_la-XMIResource_load.lo `test -f 'src/cpp/XMIResource_load.cpp' || echo '$(srcdir)/'`src/cpp/XMIResource_load.cpp
+
+src/cpp/libsciscicos_algo_la-XMIResource_save.lo: src/cpp/XMIResource_save.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciscicos_algo_la-XMIResource_save.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource_save.Tpo -c -o src/cpp/libsciscicos_algo_la-XMIResource_save.lo `test -f 'src/cpp/XMIResource_save.cpp' || echo '$(srcdir)/'`src/cpp/XMIResource_save.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource_save.Tpo src/cpp/$(DEPDIR)/libsciscicos_algo_la-XMIResource_save.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/XMIResource_save.cpp' object='src/cpp/libsciscicos_algo_la-XMIResource_save.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciscicos_algo_la-XMIResource_save.lo `test -f 'src/cpp/XMIResource_save.cpp' || echo '$(srcdir)/'`src/cpp/XMIResource_save.cpp
+
 src/cpp/libsciscicos_algo_la-Controller.lo: src/cpp/Controller.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciscicos_algo_la-Controller.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciscicos_algo_la-Controller.Tpo -c -o src/cpp/libsciscicos_algo_la-Controller.lo `test -f 'src/cpp/Controller.cpp' || echo '$(srcdir)/'`src/cpp/Controller.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciscicos_algo_la-Controller.Tpo src/cpp/$(DEPDIR)/libsciscicos_algo_la-Controller.Plo
@@ -2840,6 +2893,13 @@ sci_gateway/cpp/libsciscicos_cli_la-sci_model2blk.lo: sci_gateway/cpp/sci_model2
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_cli_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libsciscicos_cli_la-sci_model2blk.lo `test -f 'sci_gateway/cpp/sci_model2blk.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_model2blk.cpp
 
+sci_gateway/cpp/libsciscicos_cli_la-sci_scicosDiagramToScilab.lo: sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_cli_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libsciscicos_cli_la-sci_scicosDiagramToScilab.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_scicosDiagramToScilab.Tpo -c -o sci_gateway/cpp/libsciscicos_cli_la-sci_scicosDiagramToScilab.lo `test -f 'sci_gateway/cpp/sci_scicosDiagramToScilab.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_scicosDiagramToScilab.Tpo sci_gateway/cpp/$(DEPDIR)/libsciscicos_cli_la-sci_scicosDiagramToScilab.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_scicosDiagramToScilab.cpp' object='sci_gateway/cpp/libsciscicos_cli_la-sci_scicosDiagramToScilab.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_cli_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libsciscicos_cli_la-sci_scicosDiagramToScilab.lo `test -f 'sci_gateway/cpp/sci_scicosDiagramToScilab.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
+
 sci_gateway/cpp/libsciscicos_la-sci_scicos_debug.lo: sci_gateway/cpp/sci_scicos_debug.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libsciscicos_la-sci_scicos_debug.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicos_debug.Tpo -c -o sci_gateway/cpp/libsciscicos_la-sci_scicos_debug.lo `test -f 'sci_gateway/cpp/sci_scicos_debug.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_scicos_debug.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicos_debug.Tpo sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicos_debug.Plo
@@ -3043,6 +3103,13 @@ sci_gateway/cpp/libsciscicos_la-sci_model2blk.lo: sci_gateway/cpp/sci_model2blk.
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libsciscicos_la-sci_model2blk.lo `test -f 'sci_gateway/cpp/sci_model2blk.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_model2blk.cpp
 
+sci_gateway/cpp/libsciscicos_la-sci_scicosDiagramToScilab.lo: sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libsciscicos_la-sci_scicosDiagramToScilab.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicosDiagramToScilab.Tpo -c -o sci_gateway/cpp/libsciscicos_la-sci_scicosDiagramToScilab.lo `test -f 'sci_gateway/cpp/sci_scicosDiagramToScilab.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicosDiagramToScilab.Tpo sci_gateway/cpp/$(DEPDIR)/libsciscicos_la-sci_scicosDiagramToScilab.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_scicosDiagramToScilab.cpp' object='sci_gateway/cpp/libsciscicos_la-sci_scicosDiagramToScilab.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libsciscicos_la-sci_scicosDiagramToScilab.lo `test -f 'sci_gateway/cpp/sci_scicosDiagramToScilab.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
+
 .f.o:
        $(AM_V_F77)$(F77COMPILE) -c -o $@ $<
 
diff --git a/scilab/modules/scicos/includes/XMIResource.hxx b/scilab/modules/scicos/includes/XMIResource.hxx
new file mode 100644 (file)
index 0000000..2e53cec
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2016-2016 - Scilab Enterprises - Clement DAVID
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ */
+
+#include "utilities.hxx"
+#include "Controller.hxx"
+#include "model/BaseObject.hxx"
+
+#include "dynlib_scicos.h"
+
+#include <map>
+#include <array>
+#include <string>
+#include <vector>
+
+extern "C" {
+#include <libxml/xmlwriter.h>
+#include <libxml/xmlreader.h>
+}
+
+namespace org_scilab_modules_scicos
+{
+
+class SCICOS_IMPEXP XMIResource
+{
+
+public:
+    XMIResource(ScicosID id);
+    ~XMIResource();
+
+    int save(const char* uri);
+    int load(const char* uri);
+
+private:
+    /*
+     * Save helpers
+     */
+
+    int writePoint(xmlTextWriterPtr writer, double x, double y);
+    int writeGeometry(xmlTextWriterPtr writer, ScicosID id, kind_t kind);
+    int writeAbstractLayer(xmlTextWriterPtr writer, ScicosID id, kind_t kind);
+    int writeAbstractBaseObject(xmlTextWriterPtr writer, ScicosID id, kind_t kind);
+    int writeDiagram(xmlTextWriterPtr writer);
+    int writeSimulationConfig(xmlTextWriterPtr writer, ScicosID id);
+    int writeBlock(xmlTextWriterPtr writer, ScicosID id);
+    int writePort(xmlTextWriterPtr writer, enum object_properties_t container, ScicosID id);
+    int writeLink(xmlTextWriterPtr writer, ScicosID id);
+    int writeAnnotation(xmlTextWriterPtr writer, ScicosID id);
+
+    /*
+     * Load helpers
+     */
+    int loadDoubleArray(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o);
+    int loadIntArray(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o);
+    int loadStringArray(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o);
+    int loadBase64(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o);
+    int loadPoint(xmlTextReaderPtr reader, const model::BaseObject& o);
+    int loadGeometry(xmlTextReaderPtr reader, const model::BaseObject& o);
+    int loadAbstractBaseObject(xmlTextReaderPtr reader, const model::BaseObject& o);
+    int loadDiagram(xmlTextReaderPtr reader, const model::BaseObject& o);
+    int loadSimulationConfig(xmlTextReaderPtr reader, const model::BaseObject& o);
+    int loadBlock(xmlTextReaderPtr reader, const model::BaseObject& o);
+    int loadPort(xmlTextReaderPtr reader, const model::BaseObject& o);
+    int loadLink(xmlTextReaderPtr reader, const model::BaseObject& o);
+    int loadAnnotation(xmlTextReaderPtr reader, const model::BaseObject& o);
+
+    int processNode(xmlTextReaderPtr reader);
+    int processElement(xmlTextReaderPtr reader);
+    int processText(xmlTextReaderPtr reader);
+    int processEndElement(xmlTextReaderPtr reader);
+
+private:
+    /* shared controller */
+    Controller controller;
+    /* id of the diagram */
+    ScicosID root;
+
+    /*
+     * load shared variables
+     */
+
+    /* interned string indexes */
+    enum xcosNames
+    {
+        e_Annotation,
+        e_BaseObject,
+        e_Block,
+        e_CompiledRepresentation,
+        e_Diagram,
+        e_Geometry,
+        e_Layer,
+        e_Link,
+        e_Point,
+        e_Port,
+        e_PortKind,
+        e_SimulationConfig,
+        e_absoluteTolerance,
+        e_base64,
+        e_blocktype,
+        e_child,
+        e_color,
+        e_connectedSignal,
+        e_context,
+        e_controlPoint,
+        e_datatype,
+        e_debugLevel,
+        e_deltaH,
+        e_deltaT,
+        e_dependsOnT,
+        e_dependsOnU,
+        e_description,
+        e_destinationPort,
+        e_dstate,
+        e_ein,
+        e_eout,
+        e_equations,
+        e_expression,
+        e_exprs,
+        e_finalTime,
+        e_firing,
+        e_font,
+        e_fontSize,
+        e_functionAPI,
+        e_functionName,
+        e_geometry,
+        e_height,
+        e_implicit,
+        e_in,
+        e_interfaceFunction,
+        e_ipar,
+        e_kind,
+        e_label,
+        e_lineHeight,
+        e_lineWidth,
+        e_nmode,
+        e_nzcross,
+        e_odstate,
+        e_opar,
+        e_out,
+        e_parent,
+        e_parentDiagram,
+        e_path,
+        e_properties,
+        e_realtimeScale,
+        e_relativeTolerance,
+        e_rpar,
+        e_solver,
+        e_sourceBlock,
+        e_sourcePort,
+        e_state,
+        e_style,
+        e_timeTolerance,
+        e_title,
+        e_type,
+        e_uid,
+        e_version,
+        e_width,
+        e_x,
+        e_xcos,
+        e_y,
+        NB_XCOS_NAMES
+    };
+    /* temporary interned string content (owned by a reader) */
+    std::array<const xmlChar*, NB_XCOS_NAMES> constXcosNames;
+    /* temporary interned xcos namespace (owned by a reader) */
+    const xmlChar* xcosNamespaceUri;
+    /* temporary interned xsi namespace (owned by a reader) */
+    const xmlChar* xsiNamespaceUri;
+
+    /* stack uid / kind used */
+    std::vector<model::BaseObject> processed;
+
+    /* store the parent of a text node */
+    enum xcosNames parent;
+
+    /* uid string - ScicosID  map */
+    std::map<std::string, ScicosID> references;
+    /* reference to resolve after loading the whole file */
+    struct unresolvedReference
+    {
+        unresolvedReference(ScicosID id, kind_t kind, enum object_properties_t prop, std::string uid)
+            : m_id(id), m_kind(kind), m_prop(prop), m_uid(uid) {}
+        ScicosID m_id;
+        kind_t m_kind;
+        enum object_properties_t m_prop;
+        std::string m_uid;
+    };
+    /* temporary unresolved references */
+    std::vector<unresolvedReference> unresolved;
+};
+
+}
+
index fe4b818..a3d609b 100644 (file)
@@ -48,5 +48,6 @@ CPP_GATEWAY_PROTOTYPE_EXPORT(sci_var2vec, SCICOS_IMPEXP);
 CPP_GATEWAY_PROTOTYPE_EXPORT(sci_vec2var, SCICOS_IMPEXP);
 CPP_GATEWAY_PROTOTYPE_EXPORT(sci_model2blk, SCICOS_IMPEXP);
 CPP_GATEWAY_PROTOTYPE_EXPORT(sci_callblk, SCICOS_IMPEXP);
+CPP_GATEWAY_PROTOTYPE_EXPORT(sci_scicosDiagramToScilab, SCICOS_IMPEXP);
 
 #endif /* GW_SCICOS_HXX_ */
index ef04b4a..54077bf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- *  Copyright (C) 2014-2014 - Scilab Enterprises - Clement DAVID
+ *  Copyright (C) 2014-2016 - Scilab Enterprises - Clement DAVID
  *
  * Copyright (C) 2012 - 2016 - Scilab Enterprises
  *
@@ -29,7 +29,7 @@ namespace model
 class BaseObject
 {
 public:
-    BaseObject(kind_t k) :
+    explicit BaseObject(kind_t k) :
         m_kind(k)
         // Not initializing m_id on purpose: the ID is given by the model constructor
     {
@@ -38,6 +38,10 @@ public:
         m_id(b.m_id), m_kind(b.m_kind)
     {
     }
+    BaseObject(BaseObject&& b) :
+        m_id(b.m_id), m_kind(b.m_kind)
+    {
+    }
     BaseObject(ScicosID id, kind_t k) :
         m_id(id), m_kind(k)
     {
@@ -45,6 +49,12 @@ public:
 
     ~BaseObject() = default;
 
+    inline BaseObject& operator=(BaseObject&& o)
+    {
+        m_id = o.m_id;
+        m_kind = o.m_kind;
+        return *this;
+    }
     inline bool operator<(BaseObject o) const
     {
         return m_id < o.m_id;
@@ -77,7 +87,7 @@ private:
     /**
      * Kind of the Object
      */
-    const kind_t m_kind;
+    kind_t m_kind;
 };
 
 /** @defgroup utilities Shared utility classes
diff --git a/scilab/modules/scicos/sci_gateway/cpp/sci_scicosDiagramToScilab.cpp b/scilab/modules/scicos/sci_gateway/cpp/sci_scicosDiagramToScilab.cpp
new file mode 100644 (file)
index 0000000..8019225
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) Scilab Enterprises - 2016-2016 - Clément DAVID
+ *
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ */
+/*--------------------------------------------------------------------------*/
+#include "Controller.hxx"
+#include "view_scilab/Adapters.hxx"
+#include "XMIResource.hxx"
+
+#include "types.hxx"
+#include "function.hxx"
+#include "string.hxx"
+#include "user.hxx"
+#include "int.hxx"
+
+#include "gw_scicos.hxx"
+
+extern "C"
+{
+#include "sci_malloc.h"
+#include "localization.h"
+#include "Scierror.h"
+}
+/*--------------------------------------------------------------------------*/
+using namespace org_scilab_modules_scicos;
+/*--------------------------------------------------------------------------*/
+static char funname[] = "scicosDiagramToScilab";
+types::InternalType* importFile(char const* file);
+bool exportFile(int index, char const* file, types::InternalType* uid);
+/*--------------------------------------------------------------------------*/
+types::Function::ReturnValue sci_scicosDiagramToScilab(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    /*
+     * to import some files
+     * scs_m = scicosDiagramToScilab("/path/to/a/file")
+     * [scs_m1, scs_m2] = scicosDiagramToScilab(["/path/to/a/file", "/path/to/files"])
+     *
+     * to export a file
+     * scicosDiagramToScilab("/path/to/a/file", scs_m)
+     * scicosDiagramToScilab(["/path/to/a/file", "/path/to/files"], scs_m1, scs_m2)
+     */
+
+    if (in.size() < 1)
+    {
+        Scierror(77, _("%s: Wrong number of input arguments: at least %d expected.\n"), funname, 1);
+        return types::Function::Error;
+    }
+
+    if (!in[0]->isString())
+    {
+        Scierror(77, _("%s: Wrong type for input argument #%d: string expected.\n"), funname, 1);
+        return types::Function::Error;
+    }
+
+    types::String* files = in[0]->getAs<types::String>();
+    if (in.size() == 1 && files->getSize() == _iRetCount)
+    {
+        // the user asked to import
+        out.resize(_iRetCount);
+        for (int i = 0; i < _iRetCount; i++)
+        {
+            char* f = wide_string_to_UTF8(files->get(i));
+            out[i] = importFile(f);
+            FREE(f);
+            if (out[i] == nullptr)
+            {
+                return types::Function::Error;
+            }
+        }
+    }
+    else if (in.size() == 1 + static_cast<size_t>(files->getSize()) && _iRetCount <= 1)
+    {
+        // the user asked to export
+        for (int i = 0; i < _iRetCount; i++)
+        {
+            if (!in[1 + i]->isUserType())
+            {
+                Scierror(77, _("%s: Wrong type for input argument #%d: ""%s"" expected.\n"), funname, "diagram");
+                return types::Function::Error;
+            }
+        }
+        for (int i = 0; i < _iRetCount; i++)
+        {
+            char* f = wide_string_to_UTF8(files->get(i));
+            bool success = exportFile(1 + i, f, in[1 + i]);
+            FREE(f);
+            if (!success)
+            {
+                return types::Function::Error;
+            }
+        }
+    }
+    else
+    {
+        // report a comprehensible error message
+        if (in.size() == 1)
+        {
+            Scierror(77, _("%s: Wrong number of output arguments: %d expected.\n"), funname, files->getSize());
+        }
+        else if (in.size() == 1 + static_cast<size_t>(files->getSize()))
+        {
+            Scierror(77, _("%s: Wrong number of output arguments: %d expected.\n"), funname, 0);
+        }
+        else
+        {
+            Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), funname, 1);
+        }
+        return types::Function::Error;
+    }
+
+    return types::Function::OK;
+}
+/*--------------------------------------------------------------------------*/
+types::InternalType* importFile(char const* file)
+{
+    // create a diagram
+    org_scilab_modules_scicos::Controller controller;
+    ScicosID uid = controller.createObject(DIAGRAM);
+
+    // load it
+    if (XMIResource(uid).load(file) != 0)
+    {
+        Scierror(999, _("%s: Unable to load \"%s\" .\n"), funname, file);
+        return nullptr;
+    }
+
+    return view_scilab::Adapters::instance().allocate_view(uid, DIAGRAM);
+}
+/*--------------------------------------------------------------------------*/
+bool exportFile(int index, char const* file, types::InternalType* type)
+{
+    // check that the passed argument is a diagram
+    const model::BaseObject* o = view_scilab::Adapters::instance().descriptor(type);
+    if (o == nullptr || o->kind() != DIAGRAM)
+    {
+        Scierror(77, _("%s: Wrong type for input argument #%d: ""%s"" expected.\n"), funname, index, "diagram");
+        return false;
+    }
+
+    if (XMIResource(o->id()).save(file) < 0)
+    {
+        Scierror(999, _("%s: Unable to save \"%s\" .\n"), funname, file);
+        return false;
+
+    }
+
+    return true;
+}
+/*--------------------------------------------------------------------------*/
index 5148ba9..73c6fca 100644 (file)
@@ -58,4 +58,7 @@
     <gateway type="1" name="sci_vec2var" function="vec2var"/>
     <gateway type="1" name="sci_model2blk" function="model2blk"/>
     <gateway type="1" name="sci_callblk" function="callblk"/>
+    <!-- provide a simple native implementation (without Java) ; the xcosDiagramToScilab gateway superseed it -->
+    <gateway type="1" name="sci_scicosDiagramToScilab" function="scicosDiagramToScilab" />
 </module>
+
index e71c683..f903cca 100644 (file)
@@ -10,6 +10,9 @@
 #include <vld.h>
 #endif
 /*--------------------------------------------------------------------------*/
+#pragma comment(lib,"../../../../bin/libxml2.lib")
+#pragma comment(lib,"../../../../bin/libintl.lib")
+/*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
 {
     switch (reason)
index e71c683..9911a09 100644 (file)
@@ -10,6 +10,9 @@
 #include <vld.h>
 #endif
 /*--------------------------------------------------------------------------*/
+#pragma comment(lib,"../../../../../bin/libxml2.lib")
+#pragma comment(lib,"../../../../../bin/libintl.lib")
+/*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
 {
     switch (reason)
index 45b9f8e..b55e6f0 100644 (file)
@@ -82,7 +82,7 @@
     </PreBuildEvent>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>../;../../../src/cpp;../../../includes;../../../../../libs/intl;../../../../core/includes;../../../../time/includes;../../../../api_scilab/includes;../../../../output_stream/includes;../../../../scicos_blocks/includes;../../../../windows_tools/includes;../../../../localization/includes;../../../../string/includes;../../../../dynamic_link/includes;../../scicos_sundials/include;../../scicos_sundials/include/sundials;../../scicos_sundials/src/ida;../../../../action_binding/includes;../../../../ast/includes/types;../../../../ast/includes/ast;../../../../ast/includes/analysis;../../../../ast/includes/exps;../../../../ast/includes/operations;../../../../ast/includes/symbol;../../../../ast/includes/system_env;../../../../ast/includes/parse;../../../../threads/includes;../../../../console/includes;../../../../differential_equations/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../;../../../src/cpp;../../../includes;../../../../../libs/intl;../../../../core/includes;../../../../time/includes;../../../../api_scilab/includes;../../../../output_stream/includes;../../../../scicos_blocks/includes;../../../../windows_tools/includes;../../../../localization/includes;../../../../string/includes;../../../../dynamic_link/includes;../../scicos_sundials/include;../../scicos_sundials/include/sundials;../../scicos_sundials/src/ida;../../../../action_binding/includes;../../../../ast/includes/types;../../../../ast/includes/ast;../../../../ast/includes/analysis;../../../../ast/includes/exps;../../../../ast/includes/operations;../../../../ast/includes/symbol;../../../../ast/includes/system_env;../../../../ast/includes/parse;../../../../threads/includes;../../../../console/includes;../../../../differential_equations/includes;../../../../../libs/libxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;SCICOS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -119,7 +119,7 @@ lib /DEF:"$(ProjectDir)../differential_equations_f_Import.def" /SUBSYSTEM:WINDOW
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>../;../../../src/cpp;../../../includes;../../../../../libs/intl;../../../../core/includes;../../../../time/includes;../../../../api_scilab/includes;../../../../output_stream/includes;../../../../scicos_blocks/includes;../../../../windows_tools/includes;../../../../localization/includes;../../../../string/includes;../../../../dynamic_link/includes;../../scicos_sundials/include;../../scicos_sundials/include/sundials;../../scicos_sundials/src/ida;../../../../action_binding/includes;../../../../ast/includes/types;../../../../ast/includes/ast;../../../../ast/includes/analysis;../../../../ast/includes/exps;../../../../ast/includes/operations;../../../../ast/includes/symbol;../../../../ast/includes/system_env;../../../../ast/includes/parse;../../../../threads/includes;../../../../console/includes;../../../../differential_equations/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>../;../../../src/cpp;../../../includes;../../../../../libs/intl;../../../../core/includes;../../../../time/includes;../../../../api_scilab/includes;../../../../output_stream/includes;../../../../scicos_blocks/includes;../../../../windows_tools/includes;../../../../localization/includes;../../../../string/includes;../../../../dynamic_link/includes;../../scicos_sundials/include;../../scicos_sundials/include/sundials;../../scicos_sundials/src/ida;../../../../action_binding/includes;../../../../ast/includes/types;../../../../ast/includes/ast;../../../../ast/includes/analysis;../../../../ast/includes/exps;../../../../ast/includes/operations;../../../../ast/includes/symbol;../../../../ast/includes/system_env;../../../../ast/includes/parse;../../../../threads/includes;../../../../console/includes;../../../../differential_equations/includes;../../../../../libs/libxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;SCICOS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -258,6 +258,7 @@ lib /DEF:"$(ProjectDir)../differential_equations_f_Import.def" /SUBSYSTEM:WINDOW
     <ClCompile Include="..\..\..\sci_gateway\cpp\sci_sig2data.cpp" />
     <ClCompile Include="..\..\..\sci_gateway\cpp\sci_var2vec.cpp" />
     <ClCompile Include="..\..\..\sci_gateway\cpp\sci_vec2var.cpp" />
+    <ClCompile Include="..\..\..\sci_gateway\cpp\sci_scicosDiagramToScilab.cpp" />
     <ClCompile Include="..\..\..\sci_gateway\c\sci_loadScicos.c" />
     <ClCompile Include="..\..\..\sci_gateway\cpp\sci_validvar.cpp" />
     <ClCompile Include="..\..\cpp\Controller.cpp" />
@@ -285,6 +286,9 @@ lib /DEF:"$(ProjectDir)../differential_equations_f_Import.def" /SUBSYSTEM:WINDOW
     <ClCompile Include="..\..\cpp\view_scilab\ScsAdapter.cpp" />
     <ClCompile Include="..\..\cpp\view_scilab\StateAdapter.cpp" />
     <ClCompile Include="..\..\cpp\view_scilab\TextAdapter.cpp" />
+    <ClCompile Include="..\..\cpp\XMIResource.cpp" />
+    <ClCompile Include="..\..\cpp\XMIResource_load.cpp" />
+    <ClCompile Include="..\..\cpp\XMIResource_save.cpp" />
     <ClCompile Include="..\ddaskr.c" />
     <ClCompile Include="..\ezxml.c" />
     <ClCompile Include="..\import.c" />
@@ -307,8 +311,10 @@ lib /DEF:"$(ProjectDir)../differential_equations_f_Import.def" /SUBSYSTEM:WINDOW
     <ClInclude Include="..\..\..\includes\Model.hxx" />
     <ClInclude Include="..\..\..\includes\model\BaseObject.hxx" />
     <ClInclude Include="..\..\..\includes\View.hxx" />
+    <ClInclude Include="..\..\..\includes\XMIResource.hxx" />
     <ClInclude Include="..\..\..\includes\view_scilab\Adapters.hxx" />
     <ClInclude Include="..\..\cpp\controller_helpers.hxx" />
+    <ClInclude Include="..\..\cpp\base64.hxx" />
     <ClInclude Include="..\..\cpp\createblklist.hxx" />
     <ClInclude Include="..\..\cpp\extractblklist.hxx" />
     <ClInclude Include="..\..\cpp\LoggerView.hxx" />
index 2cf66e7..4a57746 100644 (file)
     <ClCompile Include="..\..\..\sci_gateway\cpp\sci_vec2var.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\sci_gateway\cpp\sci_scicosDiagramToScilab.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="..\..\..\sci_gateway\cpp\sci_coserror.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\..\cpp\Model_setObjectProperties.cpp">
       <Filter>Source Files\MVC</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\cpp\XMIResource.cpp">
+      <Filter>Source Files\MVC</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\cpp\XMIResource_load.cpp">
+      <Filter>Source Files\MVC</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\cpp\XMIResource_save.cpp">
+      <Filter>Source Files\MVC</Filter>
+    </ClCompile>
     <ClCompile Include="..\..\cpp\vec2var.cpp">
       <Filter>Source Files\MVC</Filter>
     </ClCompile>
     <ClInclude Include="..\..\cpp\model\Port.hxx">
       <Filter>Header Files\MVC\model</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\cpp\base64.hxx">
+      <Filter>Header Files\MVC\model</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\cpp\view_scilab\BaseAdapter.hxx">
       <Filter>Header Files\MVC\view_scilab</Filter>
     </ClInclude>
     <ClInclude Include="..\..\..\includes\view_scilab\Adapters.hxx">
       <Filter>Header Files\MVC\view_scilab</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\includes\XMIResource.hxx">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\core_import.def">
index ea2884b..087d77d 100644 (file)
@@ -120,7 +120,7 @@ lib /DEF:"$(ProjectDir)Scicos_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfo
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../cpp/;../cpp/model;../cpp/view_scilab;../scicos_sundials/include;../scicos_sundials/src/ida;../scicos_sundials/include/sundials;../../../../libs/intl;../../../core/includes;../../../time/includes;../../../api_scilab/includes;../../../output_stream/includes;../../../scicos_blocks/includes;../../../windows_tools/includes;../../../graphics/includes;../../../localization/includes;../../../string/includes;../../../dynamic_link/includes;../../../action_binding/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../ast/includes/parse;../../../threads/includes;../../../console/includes;../../../differential_equations/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../cpp/;../cpp/model;../cpp/view_scilab;../scicos_sundials/include;../scicos_sundials/src/ida;../scicos_sundials/include/sundials;../../../../libs/intl;../../../core/includes;../../../time/includes;../../../api_scilab/includes;../../../output_stream/includes;../../../scicos_blocks/includes;../../../windows_tools/includes;../../../graphics/includes;../../../localization/includes;../../../string/includes;../../../dynamic_link/includes;../../../action_binding/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../ast/includes/parse;../../../threads/includes;../../../console/includes;../../../differential_equations/includes;../../../../libs/libxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;SCICOS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -156,7 +156,7 @@ lib /DEF:"$(ProjectDir)Scicos_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfo
     <ClCompile>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../cpp/;../cpp/model;../cpp/view_scilab;../scicos_sundials/include;../scicos_sundials/src/ida;../scicos_sundials/include/sundials;../../../../libs/intl;../../../core/includes;../../../time/includes;../../../api_scilab/includes;../../../output_stream/includes;../../../scicos_blocks/includes;../../../windows_tools/includes;../../../graphics/includes;../../../localization/includes;../../../string/includes;../../../dynamic_link/includes;../../../action_binding/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../ast/includes/parse;../../../threads/includes;../../../console/includes;../../../differential_equations/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../cpp/;../cpp/model;../cpp/view_scilab;../scicos_sundials/include;../scicos_sundials/src/ida;../scicos_sundials/include/sundials;../../../../libs/intl;../../../core/includes;../../../time/includes;../../../api_scilab/includes;../../../output_stream/includes;../../../scicos_blocks/includes;../../../windows_tools/includes;../../../graphics/includes;../../../localization/includes;../../../string/includes;../../../dynamic_link/includes;../../../action_binding/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../ast/includes/parse;../../../threads/includes;../../../console/includes;../../../differential_equations/includes;../../../../libs/libxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;SCICOS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -262,6 +262,7 @@ lib /DEF:"$(ProjectDir)Scicos_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfo
     <ClCompile Include="..\..\sci_gateway\cpp\sci_validvar.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_var2vec.cpp" />
     <ClCompile Include="..\..\sci_gateway\cpp\sci_vec2var.cpp" />
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_scicosDiagramToScilab.cpp" />
     <ClCompile Include="..\cpp\createblklist.cpp" />
     <ClCompile Include="..\cpp\extractblklist.cpp" />
     <ClCompile Include="..\cpp\sciblk2.cpp" />
@@ -287,6 +288,9 @@ lib /DEF:"$(ProjectDir)Scicos_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfo
     <ClCompile Include="..\cpp\view_scilab\ScsAdapter.cpp" />
     <ClCompile Include="..\cpp\view_scilab\StateAdapter.cpp" />
     <ClCompile Include="..\cpp\view_scilab\TextAdapter.cpp" />
+    <ClCompile Include="..\cpp\XMIResource.cpp" />
+    <ClCompile Include="..\cpp\XMIResource_load.cpp" />
+    <ClCompile Include="..\cpp\XMIResource_save.cpp" />
     <ClCompile Include="DllmainScicos.c" />
     <ClCompile Include="ezxml.c" />
     <ClCompile Include="import.c" />
@@ -311,6 +315,7 @@ lib /DEF:"$(ProjectDir)Scicos_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfo
     <ClInclude Include="..\..\includes\model\BaseObject.hxx" />
     <ClInclude Include="..\..\includes\view_scilab\Adapters.hxx" />
     <ClInclude Include="..\..\includes\View.hxx" />
+    <ClInclude Include="..\..\includes\XMIResource.hxx" />
     <ClInclude Include="..\cpp\createblklist.hxx" />
     <ClInclude Include="..\cpp\extractblklist.hxx" />
     <ClInclude Include="..\cpp\il_sim.hxx" />
@@ -319,6 +324,7 @@ lib /DEF:"$(ProjectDir)Scicos_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfo
     <ClInclude Include="..\cpp\var2vec.hxx" />
     <ClInclude Include="..\cpp\vec2var.hxx" />
     <ClInclude Include="..\cpp\controller_helpers.hxx" />
+    <ClInclude Include="..\cpp\base64.hxx" />
     <ClInclude Include="..\cpp\model\Annotation.hxx" />
     <ClInclude Include="..\cpp\model\Block.hxx" />
     <ClInclude Include="..\cpp\model\Diagram.hxx" />
index eddd8f2..1c61f7a 100644 (file)
     <ClCompile Include="..\cpp\Model_setObjectProperties.cpp">
       <Filter>Source Files\MVC</Filter>
     </ClCompile>
+    <ClCompile Include="..\cpp\XMIResource.cpp">
+      <Filter>Source Files\MVC</Filter>
+    </ClCompile>
+    <ClCompile Include="..\cpp\XMIResource_load.cpp">
+      <Filter>Source Files\MVC</Filter>
+    </ClCompile>
+    <ClCompile Include="..\cpp\XMIResource_save.cpp">
+      <Filter>Source Files\MVC</Filter>
+    </ClCompile>
     <ClCompile Include="..\cpp\view_scilab\CprAdapter.cpp">
       <Filter>Source Files\MVC\view_scilab</Filter>
     </ClCompile>
     <ClCompile Include="..\..\sci_gateway\cpp\sci_vec2var.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\sci_gateway\cpp\sci_scicosDiagramToScilab.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="..\cpp\il_sim.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClInclude Include="..\..\includes\model\BaseObject.hxx">
       <Filter>Header Files\MVC\model</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\includes\XMIResource.hxx">
+      <Filter>Header Files</Filter>
+    </ClInclude>
     <ClInclude Include="..\cpp\model\Annotation.hxx">
       <Filter>Header Files\MVC\model</Filter>
     </ClInclude>
     <ClInclude Include="..\cpp\model\Port.hxx">
       <Filter>Header Files\MVC\model</Filter>
     </ClInclude>
+    <ClInclude Include="..\cpp\base64.hxx">
+      <Filter>Header Files</Filter>
+    </ClInclude>
     <ClInclude Include="..\cpp\il_sim.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
index b344ac6..2d515f3 100644 (file)
 #include "model/Link.hxx"
 #include "model/Port.hxx"
 
+extern "C" {
+#include "sci_types.h"
+}
+
 namespace org_scilab_modules_scicos
 {
 
+/* helper function to decode simple string EXPRS */
+static std::vector<std::string> decode_string_vector(const std::vector<double>& v)
+{
+    std::vector<std::string> ret;
+    std::vector<double>::const_iterator it = v.begin();
+
+    int strHeader = *it++;
+    if (strHeader != sci_strings)
+    {
+        return ret;
+    }
+    unsigned int iDims = *it++;
+
+    // manage multi-dimensionnal arrays (will be serialized as a vector)
+    unsigned int iElements = 1;
+    for (unsigned int i = 0; i < iDims; ++i)
+    {
+        iElements *= static_cast<unsigned int>(*it++);
+    }
+
+    // retrieve the length of each encoded string, stored as a stack
+    std::vector<unsigned int> stringsLength;
+    stringsLength.reserve(iElements + 1);
+    stringsLength.push_back(0);
+    for (unsigned int i = 0; i < iElements; ++i)
+    {
+        stringsLength.push_back(*it++);
+    }
+
+    // Retrieving the pointers (already UTF-8 encoded char*) and store them as strings
+    ret.reserve(iElements);
+    const double* strData = &(*it);
+    for (unsigned int i = 0; i < iElements; ++i)
+    {
+        // push the data
+        ret.push_back((char*) (strData + stringsLength[i]));
+    }
+
+    return ret;
+}
+
+
 bool Model::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, double& v)  const
 {
     model::BaseObject* baseObject = getObject(uid);
@@ -656,6 +702,14 @@ bool Model::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std
             case DIAGRAM_CONTEXT:
                 o->getContext(v);
                 return true;
+            case EXPRS:
+            {
+                std::vector<double> data;
+                o->getExprs(data);
+
+                v = decode_string_vector(data);
+                return true;
+            }
             default:
                 break;
         }
index be91ff9..c881e02 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- *  Copyright (C) 2014-2014 - Scilab Enterprises - Clement DAVID
+ *  Copyright (C) 2014-2016 - Scilab Enterprises - Clement DAVID
  *
  * Copyright (C) 2012 - 2016 - Scilab Enterprises
  *
@@ -15,6 +15,7 @@
 
 #include <string>
 #include <vector>
+#include <cstring> // for memcpy
 
 #include "Model.hxx"
 #include "utilities.hxx"
 #include "model/Link.hxx"
 #include "model/Port.hxx"
 
+extern "C" {
+#include "sci_types.h"
+}
+
 namespace org_scilab_modules_scicos
 {
 
+/* helper function to encode simple string EXPRS */
+static std::vector<double> encode_string_vector(const std::vector<std::string>& v)
+{
+    std::vector<double> ret;
+
+    // header
+    ret.push_back(sci_strings);
+
+    // serialize as a Scilab vector
+    ret.push_back(2); // MxN
+    ret.push_back(v.size()); // M
+    ret.push_back(1); // N
+
+    // reserve some space to store the length of each string (including the null terminating character)
+    ret.resize(ret.size() + v.size());
+
+    // store the index and the null terminated UTF-8 strings
+    size_t stringOffset = 0;
+    for (size_t i = 0; i < v.size(); ++i)
+    {
+        const std::string& str = v[i];
+        // length as a 64bit index (as we store on a double vector)
+        size_t len = ((str.size() + 1) * sizeof(char) + sizeof(double) - 1) / sizeof(double);
+
+        // insert the offset
+        auto it = ret.begin() + 4 + i;
+        stringOffset += len;
+        *it = stringOffset;
+
+        // reserve some space for the string
+        size_t size = ret.size();
+        ret.resize(size + len);
+
+        // copy the UTF-8 encoded values
+        std::memcpy(ret.data() + size, str.data(), str.size());
+    }
+
+    return ret;
+}
+
 update_status_t Model::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, double v)
 {
     model::BaseObject* baseObject = getObject(uid);
@@ -598,6 +643,8 @@ update_status_t Model::setObjectProperty(ScicosID uid, kind_t k, object_properti
         {
             case DIAGRAM_CONTEXT:
                 return o->setContext(v);
+            case EXPRS:
+                return o->setExprs(encode_string_vector(v));
             default:
                 break;
         }
diff --git a/scilab/modules/scicos/src/cpp/XMIResource.cpp b/scilab/modules/scicos/src/cpp/XMIResource.cpp
new file mode 100644 (file)
index 0000000..0c8ff82
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2016-2016 - Scilab Enterprises - Clement DAVID
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ */
+
+#include "XMIResource.hxx"
+
+extern "C" {
+#include <libxml/xmlversion.h>
+}
+
+namespace org_scilab_modules_scicos
+{
+
+XMIResource::XMIResource(ScicosID id) : controller(), root(id), processed(), parent(NB_XCOS_NAMES), references()
+{
+    references.insert(std::make_pair("/", id));
+
+    LIBXML_TEST_VERSION;
+}
+
+XMIResource::~XMIResource()
+{
+}
+
+}
diff --git a/scilab/modules/scicos/src/cpp/XMIResource_load.cpp b/scilab/modules/scicos/src/cpp/XMIResource_load.cpp
new file mode 100644 (file)
index 0000000..2760824
--- /dev/null
@@ -0,0 +1,1162 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2016-2016 - Scilab Enterprises - Clement DAVID
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ */
+
+#include "XMIResource.hxx"
+#include "base64.hxx"
+
+#include <cassert>
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <cstdlib> // for atoi and atof
+#include <cstring> // for strcmp and strchr
+
+extern "C"
+{
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/xmlerror.h>
+#include <libxml/xmlreader.h>
+
+#include "sciprint.h"
+}
+
+namespace org_scilab_modules_scicos
+{
+
+/**
+ * Display on the Scilab console
+ */
+void console_print(void *, const char *msg, ...) LIBXML_ATTR_FORMAT(2, 3);
+void console_print(void *, const char *msg, ...)
+{
+    //print the message
+    va_list ap;
+    va_start(ap, msg);
+    scivprint(msg, ap);
+    va_end(ap);
+}
+
+/**
+ * Helper class to set / reset the XML parser state
+ */
+struct LibXML2State
+{
+    LibXML2State()
+    {
+        xmlGenericErrorFunc f = &console_print;
+        initGenericErrorDefaultFunc(&f);
+    }
+    ~LibXML2State()
+    {
+        initGenericErrorDefaultFunc(nullptr);
+    }
+};
+
+int XMIResource::load(const char* uri)
+{
+    int ret;
+
+    LibXML2State state;
+
+    /*
+     * Allocate the reader object, this API is used as it is simpler to use than SAX2 :
+     *  * we have direct access to a node object
+     *  * Strings are interned by libxml2
+     *  * partial SAX2 callbacks are not supported by libxml2
+     */
+    xmlTextReaderPtr reader;
+    /* resolve xinclude and intern strings */
+    reader = xmlReaderForFile(uri, NULL, XML_PARSE_XINCLUDE | XML_PARSE_COMPACT);
+
+    /*
+     * Intern strings to speedup comparaison, this table can be generated using XPath on xcos.ecore .
+     */
+    constXcosNames[e_Annotation] = xmlTextReaderConstString(reader, BAD_CAST ("Annotation"));
+    constXcosNames[e_BaseObject] = xmlTextReaderConstString(reader, BAD_CAST ("BaseObject"));
+    constXcosNames[e_Block] = xmlTextReaderConstString(reader, BAD_CAST ("Block"));
+    constXcosNames[e_CompiledRepresentation] = xmlTextReaderConstString(reader, BAD_CAST ("CompiledRepresentation"));
+    constXcosNames[e_Diagram] = xmlTextReaderConstString(reader, BAD_CAST ("Diagram"));
+    constXcosNames[e_Geometry] = xmlTextReaderConstString(reader, BAD_CAST ("Geometry"));
+    constXcosNames[e_Layer] = xmlTextReaderConstString(reader, BAD_CAST ("Layer"));
+    constXcosNames[e_Link] = xmlTextReaderConstString(reader, BAD_CAST ("Link"));
+    constXcosNames[e_Point] = xmlTextReaderConstString(reader, BAD_CAST ("Point"));
+    constXcosNames[e_Port] = xmlTextReaderConstString(reader, BAD_CAST ("Port"));
+    constXcosNames[e_PortKind] = xmlTextReaderConstString(reader, BAD_CAST ("PortKind"));
+    constXcosNames[e_SimulationConfig] = xmlTextReaderConstString(reader, BAD_CAST ("SimulationConfig"));
+    constXcosNames[e_absoluteTolerance] = xmlTextReaderConstString(reader, BAD_CAST ("absoluteTolerance"));
+    constXcosNames[e_base64] = xmlTextReaderConstString(reader, BAD_CAST ("base64"));
+    constXcosNames[e_blocktype] = xmlTextReaderConstString(reader, BAD_CAST ("blocktype"));
+    constXcosNames[e_child] = xmlTextReaderConstString(reader, BAD_CAST ("child"));
+    constXcosNames[e_color] = xmlTextReaderConstString(reader, BAD_CAST ("color"));
+    constXcosNames[e_connectedSignal] = xmlTextReaderConstString(reader, BAD_CAST ("connectedSignal"));
+    constXcosNames[e_context] = xmlTextReaderConstString(reader, BAD_CAST ("context"));
+    constXcosNames[e_controlPoint] = xmlTextReaderConstString(reader, BAD_CAST ("controlPoint"));
+    constXcosNames[e_datatype] = xmlTextReaderConstString(reader, BAD_CAST ("datatype"));
+    constXcosNames[e_debugLevel] = xmlTextReaderConstString(reader, BAD_CAST ("debugLevel"));
+    constXcosNames[e_deltaH] = xmlTextReaderConstString(reader, BAD_CAST ("deltaH"));
+    constXcosNames[e_deltaT] = xmlTextReaderConstString(reader, BAD_CAST ("deltaT"));
+    constXcosNames[e_dependsOnT] = xmlTextReaderConstString(reader, BAD_CAST ("dependsOnT"));
+    constXcosNames[e_dependsOnU] = xmlTextReaderConstString(reader, BAD_CAST ("dependsOnU"));
+    constXcosNames[e_description] = xmlTextReaderConstString(reader, BAD_CAST ("description"));
+    constXcosNames[e_destinationPort] = xmlTextReaderConstString(reader, BAD_CAST ("destinationPort"));
+    constXcosNames[e_dstate] = xmlTextReaderConstString(reader, BAD_CAST ("dstate"));
+    constXcosNames[e_ein] = xmlTextReaderConstString(reader, BAD_CAST ("ein"));
+    constXcosNames[e_eout] = xmlTextReaderConstString(reader, BAD_CAST ("eout"));
+    constXcosNames[e_equations] = xmlTextReaderConstString(reader, BAD_CAST ("equations"));
+    constXcosNames[e_expression] = xmlTextReaderConstString(reader, BAD_CAST ("expression"));
+    constXcosNames[e_exprs] = xmlTextReaderConstString(reader, BAD_CAST ("exprs"));
+    constXcosNames[e_finalTime] = xmlTextReaderConstString(reader, BAD_CAST ("finalTime"));
+    constXcosNames[e_firing] = xmlTextReaderConstString(reader, BAD_CAST ("firing"));
+    constXcosNames[e_font] = xmlTextReaderConstString(reader, BAD_CAST ("font"));
+    constXcosNames[e_fontSize] = xmlTextReaderConstString(reader, BAD_CAST ("fontSize"));
+    constXcosNames[e_functionAPI] = xmlTextReaderConstString(reader, BAD_CAST ("functionAPI"));
+    constXcosNames[e_functionName] = xmlTextReaderConstString(reader, BAD_CAST ("functionName"));
+    constXcosNames[e_geometry] = xmlTextReaderConstString(reader, BAD_CAST ("geometry"));
+    constXcosNames[e_height] = xmlTextReaderConstString(reader, BAD_CAST ("height"));
+    constXcosNames[e_implicit] = xmlTextReaderConstString(reader, BAD_CAST ("implicit"));
+    constXcosNames[e_in] = xmlTextReaderConstString(reader, BAD_CAST ("in"));
+    constXcosNames[e_interfaceFunction] = xmlTextReaderConstString(reader, BAD_CAST ("interfaceFunction"));
+    constXcosNames[e_ipar] = xmlTextReaderConstString(reader, BAD_CAST ("ipar"));
+    constXcosNames[e_kind] = xmlTextReaderConstString(reader, BAD_CAST ("kind"));
+    constXcosNames[e_label] = xmlTextReaderConstString(reader, BAD_CAST ("label"));
+    constXcosNames[e_lineHeight] = xmlTextReaderConstString(reader, BAD_CAST ("lineHeight"));
+    constXcosNames[e_lineWidth] = xmlTextReaderConstString(reader, BAD_CAST ("lineWidth"));
+    constXcosNames[e_nmode] = xmlTextReaderConstString(reader, BAD_CAST ("nmode"));
+    constXcosNames[e_nzcross] = xmlTextReaderConstString(reader, BAD_CAST ("nzcross"));
+    constXcosNames[e_odstate] = xmlTextReaderConstString(reader, BAD_CAST ("odstate"));
+    constXcosNames[e_opar] = xmlTextReaderConstString(reader, BAD_CAST ("opar"));
+    constXcosNames[e_out] = xmlTextReaderConstString(reader, BAD_CAST ("out"));
+    constXcosNames[e_parent] = xmlTextReaderConstString(reader, BAD_CAST ("parent"));
+    constXcosNames[e_parentDiagram] = xmlTextReaderConstString(reader, BAD_CAST ("parentDiagram"));
+    constXcosNames[e_path] = xmlTextReaderConstString(reader, BAD_CAST ("path"));
+    constXcosNames[e_properties] = xmlTextReaderConstString(reader, BAD_CAST ("properties"));
+    constXcosNames[e_realtimeScale] = xmlTextReaderConstString(reader, BAD_CAST ("realtimeScale"));
+    constXcosNames[e_relativeTolerance] = xmlTextReaderConstString(reader, BAD_CAST ("relativeTolerance"));
+    constXcosNames[e_rpar] = xmlTextReaderConstString(reader, BAD_CAST ("rpar"));
+    constXcosNames[e_solver] = xmlTextReaderConstString(reader, BAD_CAST ("solver"));
+    constXcosNames[e_sourceBlock] = xmlTextReaderConstString(reader, BAD_CAST ("sourceBlock"));
+    constXcosNames[e_sourcePort] = xmlTextReaderConstString(reader, BAD_CAST ("sourcePort"));
+    constXcosNames[e_state] = xmlTextReaderConstString(reader, BAD_CAST ("state"));
+    constXcosNames[e_style] = xmlTextReaderConstString(reader, BAD_CAST ("style"));
+    constXcosNames[e_timeTolerance] = xmlTextReaderConstString(reader, BAD_CAST ("timeTolerance"));
+    constXcosNames[e_title] = xmlTextReaderConstString(reader, BAD_CAST ("title"));
+    constXcosNames[e_type] = xmlTextReaderConstString(reader, BAD_CAST ("type"));
+    constXcosNames[e_uid] = xmlTextReaderConstString(reader, BAD_CAST ("uid"));
+    constXcosNames[e_version] = xmlTextReaderConstString(reader, BAD_CAST ("version"));
+    constXcosNames[e_width] = xmlTextReaderConstString(reader, BAD_CAST ("width"));
+    constXcosNames[e_x] = xmlTextReaderConstString(reader, BAD_CAST ("x"));
+    constXcosNames[e_xcos] = xmlTextReaderConstString(reader, BAD_CAST ("xcos"));
+    constXcosNames[e_y] = xmlTextReaderConstString(reader, BAD_CAST ("y"));
+
+    xcosNamespaceUri = xmlTextReaderConstString(reader, BAD_CAST ("org.scilab.modules.xcos"));
+    xsiNamespaceUri = xmlTextReaderConstString(reader, BAD_CAST ("http://www.w3.org/2001/XMLSchema-instance"));
+
+    unresolved.clear();
+
+    /*
+     * Process the document
+     */
+    if (reader != NULL)
+    {
+        ret = xmlTextReaderRead(reader);
+        while (ret == 1)
+        {
+            ret = processNode(reader);
+            if (ret == 1)
+            {
+                ret = xmlTextReaderRead(reader);
+            }
+        }
+        /*
+         * Once the document has been fully parsed check the validation results
+         */
+        if (xmlTextReaderIsValid(reader) < 0)
+        {
+            sciprint("Document %s does not validate\n", uri);
+        }
+        xmlFreeTextReader(reader);
+        if (ret < 0)
+        {
+            sciprint("%s : failed to parse\n", uri);
+            return ret;
+        }
+    }
+    else
+    {
+        sciprint("Unable to open %s\n", uri);
+        return -1;
+    }
+
+    /*
+     * After loading the XML file, resolve all references
+     */
+    for (const unresolvedReference& ref : unresolved)
+    {
+        auto it = references.find(ref.m_uid);
+        if (it != references.end())
+        {
+            controller.setObjectProperty(ref.m_id, ref.m_kind, ref.m_prop, it->second);
+        }
+        else
+        {
+            sciprint("Unable to resolve %s\n", ref.m_uid.c_str());
+            return -1;
+        }
+    }
+
+    return ret;
+}
+
+/*
+ * Convert an XML UTF-8 string to a model string
+ */
+std::string to_string(const xmlChar* xmlStr)
+{
+    if (xmlStr == nullptr)
+    {
+        return "";
+    }
+
+    // the strings in the model are stored as UTF-8 as in libxml2
+    return std::string((const char*) xmlStr);
+}
+
+/*
+ * Convert an XML UTF-8 string to a model int
+ */
+int to_int(const xmlChar* xmlStr)
+{
+    if (xmlStr == nullptr)
+    {
+        return 0;
+    }
+
+    return std::atoi((const char*) xmlStr);
+}
+
+/*
+ * Convert an XML UTF-8 string to a model double
+ */
+double to_double(const xmlChar* xmlStr)
+{
+    if (xmlStr == nullptr)
+    {
+        return 0.0;
+    }
+
+    return std::atof((const char*) xmlStr);
+}
+
+int XMIResource::loadDoubleArray(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o)
+{
+    std::vector<double> v;
+    controller.getObjectProperty(o.id(), o.kind(), property, v);
+
+    v.push_back(to_double(xmlTextReaderConstValue(reader)));
+
+    controller.setObjectProperty(o.id(), o.kind(), property, v);
+    return 1;
+}
+
+int XMIResource::loadIntArray(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o)
+{
+    std::vector<int> v;
+    controller.getObjectProperty(o.id(), o.kind(), property, v);
+
+    v.push_back(to_int(xmlTextReaderConstValue(reader)));
+
+    controller.setObjectProperty(o.id(), o.kind(), property, v);
+    return 1;
+}
+
+int XMIResource::loadStringArray(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o)
+{
+    std::vector<std::string> v;
+    controller.getObjectProperty(o.id(), o.kind(), property, v);
+
+    v.push_back(to_string(xmlTextReaderConstValue(reader)));
+
+    controller.setObjectProperty(o.id(), o.kind(), property, v);
+    return 1;
+}
+
+int XMIResource::loadBase64(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o)
+{
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+
+        switch (current)
+        {
+            case e_base64:
+            {
+                const xmlChar* base64 = xmlTextReaderConstValue(reader);
+                std::vector<double> v = base64::decode<std::vector<double> >(to_string(base64));
+                controller.setObjectProperty(o.id(), o.kind(), property, v);
+                break;
+            }
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    return 1;
+}
+
+int XMIResource::loadPoint(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == LINK);
+
+    std::vector<double> points;
+    controller.getObjectProperty(o.id(), o.kind(), CONTROL_POINTS, points);
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_x:
+                points.push_back(to_double(xmlTextReaderConstValue(reader)));
+                break;
+            case e_y:
+                points.push_back(to_double(xmlTextReaderConstValue(reader)));
+                break;
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    controller.setObjectProperty(o.id(), o.kind(), CONTROL_POINTS, points);
+    return 1;
+}
+
+int XMIResource::loadGeometry(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == BLOCK || o.kind() == ANNOTATION || o.kind() == LINK);
+
+    std::vector<double> geom;
+    controller.getObjectProperty(o.id(), o.kind(), GEOMETRY, geom);
+    geom.resize(4);
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_x:
+                geom[0] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_y:
+                geom[1] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_width:
+                geom[2] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_height:
+                geom[3] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    controller.setObjectProperty(o.id(), o.kind(), GEOMETRY, geom);
+    return 1;
+}
+
+int XMIResource::loadAbstractBaseObject(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == BLOCK || o.kind() == ANNOTATION || o.kind() == LINK);
+
+    // abstract Layer is not decoded there as it has no attribute
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_uid:
+            {
+                std::string uid = to_string(xmlTextReaderConstValue(reader));
+                controller.setObjectProperty(o.id(), o.kind(), UID, uid);
+                references.insert(std::make_pair(uid, o.id()));
+                break;
+            }
+            case e_parentDiagram:
+            {
+                // not lookup needed ; only one diagram is serialized at a time
+                controller.setObjectProperty(o.id(), o.kind(), PARENT_DIAGRAM, root);
+                break;
+            }
+            case e_parent:
+            {
+                // not lookup needed thanks to the XML hierarchy
+                const model::BaseObject& parent = *(processed.end() - 2);
+                controller.setObjectProperty(o.id(), o.kind(), PARENT_BLOCK, parent.id());
+                break;
+            }
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    return 1;
+}
+
+int XMIResource::loadDiagram(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == DIAGRAM);
+
+    // abstract Layer is not decoded there as it has no attribute
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_title:
+                controller.setObjectProperty(o.id(), o.kind(), TITLE, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_path:
+                controller.setObjectProperty(o.id(), o.kind(), PATH, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_debugLevel:
+                controller.setObjectProperty(o.id(), o.kind(), DEBUG_LEVEL, to_int(xmlTextReaderConstValue(reader)));
+                break;
+            case e_version:
+                controller.setObjectProperty(o.id(), o.kind(), VERSION_NUMBER, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    return 1;
+}
+
+int XMIResource::loadSimulationConfig(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == DIAGRAM);
+
+    std::vector<double> properties;
+    controller.getObjectProperty(o.id(), o.kind(), PROPERTIES, properties);
+    properties.resize(8);
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_finalTime:
+                properties[0] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_absoluteTolerance:
+                properties[1] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_relativeTolerance:
+                properties[2] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_timeTolerance:
+                properties[3] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_deltaT:
+                properties[4] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_realtimeScale:
+                properties[5] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_solver:
+                properties[6] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            case e_deltaH:
+                properties[7] = to_double(xmlTextReaderConstValue(reader));
+                break;
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    controller.setObjectProperty(o.id(), o.kind(), PROPERTIES, properties);
+    return 1;
+}
+
+int XMIResource::loadBlock(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == BLOCK);
+
+    // load the base class
+    int ret = loadAbstractBaseObject(reader, o);
+    if (ret != 1)
+    {
+        return ret;
+    }
+
+    // Layer has no attribute so there is no need to decode it there
+    // Geometry is handled as an element
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_description:
+                controller.setObjectProperty(o.id(), o.kind(), DESCRIPTION, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_label:
+                controller.setObjectProperty(o.id(), o.kind(), LABEL, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_style:
+                controller.setObjectProperty(o.id(), o.kind(), STYLE, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_interfaceFunction:
+                controller.setObjectProperty(o.id(), o.kind(), INTERFACE_FUNCTION, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_functionName:
+                controller.setObjectProperty(o.id(), o.kind(), SIM_FUNCTION_NAME, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_functionAPI:
+                controller.setObjectProperty(o.id(), o.kind(), SIM_FUNCTION_API, to_int(xmlTextReaderConstValue(reader)));
+                break;
+            case e_dependsOnT:
+            {
+                std::vector<int> dep_ut;
+                controller.getObjectProperty(o.id(), o.kind(), SIM_DEP_UT, dep_ut);
+                dep_ut.resize(2);
+
+                dep_ut[1] = to_int(xmlTextReaderConstValue(reader));
+                controller.setObjectProperty(o.id(), o.kind(), SIM_DEP_UT, dep_ut);
+                break;
+            }
+            case e_dependsOnU:
+            {
+                std::vector<int> dep_ut;
+                controller.getObjectProperty(o.id(), o.kind(), SIM_DEP_UT, dep_ut);
+                dep_ut.resize(2);
+
+                dep_ut[0] = to_int(xmlTextReaderConstValue(reader));
+                controller.setObjectProperty(o.id(), o.kind(), SIM_DEP_UT, dep_ut);
+                break;
+            }
+            case e_blocktype:
+                controller.setObjectProperty(o.id(), o.kind(), SIM_BLOCKTYPE, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    /*
+     * Reset some properties loaded as array and initialized with non-empty value
+     */
+    std::vector<int> empty_int_array;
+    controller.setObjectProperty(o.id(), o.kind(), NZCROSS, empty_int_array);
+    controller.setObjectProperty(o.id(), o.kind(), NMODE, empty_int_array);
+
+    return 1;
+}
+
+int XMIResource::loadPort(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == PORT);
+
+    // ignore datatype as it is managed as an XML node
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_uid:
+            {
+                std::string uid = to_string(xmlTextReaderConstValue(reader));
+                controller.setObjectProperty(o.id(), o.kind(), UID, uid);
+                references.insert(std::make_pair(uid, o.id()));
+                break;
+            }
+            case e_firing:
+                controller.setObjectProperty(o.id(), o.kind(), FIRING, to_double(xmlTextReaderConstValue(reader)));
+                break;
+            case e_sourceBlock:
+            {
+                // not lookup needed thanks to the XML hierarchy
+                const model::BaseObject& parent = processed.back();
+                controller.setObjectProperty(o.id(), o.kind(), SOURCE_BLOCK, parent.id());
+                break;
+            }
+            case e_kind:
+            {
+                std::string portKindStr = to_string(xmlTextReaderConstValue(reader));
+                int k;
+                if ("in" == portKindStr)
+                {
+                    k = PORT_IN;
+                }
+                else if ("out" == portKindStr)
+                {
+                    k = PORT_OUT;
+                }
+                else if ("ein" == portKindStr)
+                {
+                    k = PORT_EIN;
+                }
+                else if ("eout" == portKindStr)
+                {
+                    k = PORT_EOUT;
+                }
+                else
+                {
+                    k = PORT_UNDEF;
+                }
+                controller.setObjectProperty(o.id(), o.kind(), PORT_KIND, k);
+                break;
+            }
+            case e_implicit:
+                controller.setObjectProperty(o.id(), o.kind(), IMPLICIT, to_int(xmlTextReaderConstValue(reader)));
+                break;
+            case e_connectedSignal:
+                // will be resolved later
+                unresolved.push_back(
+                    unresolvedReference(o.id(), o.kind(), CONNECTED_SIGNALS,
+                                        to_string(xmlTextReaderConstValue(reader))));
+                break;
+            case e_style:
+                controller.setObjectProperty(o.id(), o.kind(), STYLE, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_label:
+                controller.setObjectProperty(o.id(), o.kind(), LABEL, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    return 1;
+}
+
+int XMIResource::loadLink(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == LINK);
+
+    // load the base class
+    int ret = loadAbstractBaseObject(reader, o);
+    if (ret != 1)
+    {
+        return ret;
+    }
+
+    // geometry is handled as in independent node
+    // controlPoint is handled as in independent node
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_uid:
+            {
+                std::string uid = to_string(xmlTextReaderConstValue(reader));
+                controller.setObjectProperty(o.id(), o.kind(), UID, uid);
+                references.insert(std::make_pair(uid, o.id()));
+                break;
+            }
+            case e_sourcePort:
+                // will be resolved later
+                unresolved.push_back(
+                    unresolvedReference(o.id(), o.kind(), SOURCE_PORT, to_string(xmlTextReaderConstValue(reader))));
+                break;
+            case e_destinationPort:
+                // will be resolved later
+                unresolved.push_back(
+                    unresolvedReference(o.id(), o.kind(), DESTINATION_PORT,
+                                        to_string(xmlTextReaderConstValue(reader))));
+                break;
+            case e_style:
+                controller.setObjectProperty(o.id(), o.kind(), STYLE, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_label:
+                controller.setObjectProperty(o.id(), o.kind(), LABEL, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_lineWidth:
+            {
+                std::vector<double> thick;
+                controller.getObjectProperty(o.id(), o.kind(), THICK, thick);
+                thick[0] = to_double(xmlTextReaderConstValue(reader));
+                controller.setObjectProperty(o.id(), o.kind(), THICK, thick);
+                break;
+            }
+            case e_lineHeight:
+            {
+                std::vector<double> thick;
+                controller.getObjectProperty(o.id(), o.kind(), THICK, thick);
+                thick[1] = to_double(xmlTextReaderConstValue(reader));
+                controller.setObjectProperty(o.id(), o.kind(), THICK, thick);
+                break;
+            }
+            case e_color:
+                controller.setObjectProperty(o.id(), o.kind(), COLOR, to_int(xmlTextReaderConstValue(reader)));
+                break;
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    return ret;
+}
+
+int XMIResource::loadAnnotation(xmlTextReaderPtr reader, const model::BaseObject& o)
+{
+    assert(o.kind() == ANNOTATION);
+
+    // load the base class
+    int ret = loadAbstractBaseObject(reader, o);
+    if (ret != 1)
+    {
+        return ret;
+    }
+
+    // geometry is handled as a node
+
+    // iterate on attributes
+    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+    {
+        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));
+        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+        switch (current)
+        {
+            case e_description:
+                controller.setObjectProperty(o.id(), o.kind(), DESCRIPTION, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_font:
+                controller.setObjectProperty(o.id(), o.kind(), FONT, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_fontSize:
+                controller.setObjectProperty(o.id(), o.kind(), FONT_SIZE, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            case e_style:
+                controller.setObjectProperty(o.id(), o.kind(), STYLE, to_string(xmlTextReaderConstValue(reader)));
+                break;
+            default:
+                // ignore other parameters
+                // TODO: Does other metamodels might be managed there ?
+                break;
+        }
+    }
+
+    return ret;
+}
+
+int XMIResource::processNode(xmlTextReaderPtr reader)
+{
+    // manage only xcos related XML nodes
+    const xmlChar* nsURI = xmlTextReaderConstNamespaceUri(reader);
+    if (nsURI == xcosNamespaceUri || nsURI == nullptr)
+    {
+        xmlReaderTypes nodeType = (xmlReaderTypes) xmlTextReaderNodeType(reader);
+        switch (nodeType)
+        {
+            case XML_READER_TYPE_NONE:
+                return 1;
+            case XML_READER_TYPE_ELEMENT:
+                return processElement(reader);
+            case XML_READER_TYPE_ATTRIBUTE:
+                sciprint("xmlReader attributes node not supported\n");
+                return -1;
+            case XML_READER_TYPE_TEXT:
+                return processText(reader);
+            case XML_READER_TYPE_CDATA:
+                return processText(reader);
+            case XML_READER_TYPE_ENTITY_REFERENCE:
+                sciprint("xmlReader entity reference not supported\n");
+                return -1;
+            case XML_READER_TYPE_ENTITY:
+                sciprint("xmlReader entity not supported\n");
+                return -1;
+            case XML_READER_TYPE_PROCESSING_INSTRUCTION:
+                sciprint("xmlReader processing instruction not supported\n");
+                return -1;
+            case XML_READER_TYPE_COMMENT:
+                return 1;
+            case XML_READER_TYPE_DOCUMENT:
+                return 1;
+            case XML_READER_TYPE_DOCUMENT_TYPE:
+                sciprint("xmlReader document type not supported\n");
+                return -1;
+            case XML_READER_TYPE_DOCUMENT_FRAGMENT:
+                sciprint("xmlReader document fragment not supported\n");
+                return -1;
+            case XML_READER_TYPE_NOTATION:
+                sciprint("xmlReader notation not supported\n");
+                return -1;
+            case XML_READER_TYPE_WHITESPACE:
+                sciprint("xmlReader whitespace not supported\n");
+                return -1;
+            case XML_READER_TYPE_SIGNIFICANT_WHITESPACE:
+                return 1; // ignore indent or end-of-line
+            case XML_READER_TYPE_END_ELEMENT:
+                return processEndElement(reader);
+            case XML_READER_TYPE_END_ENTITY:
+                sciprint("xmlReader end entity not supported\n");
+                return -1;
+            case XML_READER_TYPE_XML_DECLARATION:
+                sciprint("xmlReader XML declaration not supported\n");
+                return -1;
+        }
+    }
+    else
+    {
+        // TODO mixed model should be preserved in some way and restored back on XMIResource_save.cpp .
+    }
+    sciprint("unable to process node\n");
+    return -1;
+}
+
+int XMIResource::processElement(xmlTextReaderPtr reader)
+{
+    const xmlChar *name = xmlTextReaderConstLocalName(reader);
+    parent = NB_XCOS_NAMES;
+
+    // lookup for known node names
+    // thanks to the string intern-ing, the pointer comparison could be used
+    auto found = std::find(constXcosNames.begin(), constXcosNames.end(), name);
+    enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+    switch (current)
+    {
+        case e_Diagram:
+        {
+            // the root diagram should be decoded
+            model::BaseObject o(root, DIAGRAM);
+
+            processed.push_back(o);
+            return loadDiagram(reader, o);
+        }
+        case e_child:
+        {
+            // this is a child of a diagram, resolve the type and call the loaders
+            // iterate on attributes to lookup for EMF type
+
+            // iterate on attributes
+            for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))
+            {
+                const xmlChar* nsURI  = xmlTextReaderConstNamespaceUri(reader);
+                if (nsURI != xsiNamespaceUri)
+                {
+                    continue;
+                }
+
+                auto foundName = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstLocalName(reader));
+                enum xcosNames currentName = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), foundName));
+                if (currentName != e_type)
+                {
+                    continue;
+                }
+
+                const xmlChar* value = xmlTextReaderConstValue(reader);
+                const xmlChar* valueWithoutPrefix = BAD_CAST(std::strchr((const char*) value, ':'));
+                if (valueWithoutPrefix == nullptr)
+                {
+                    valueWithoutPrefix = value;
+                }
+                else
+                {
+                    // remove the leading ':'
+                    valueWithoutPrefix = valueWithoutPrefix + 1;
+                }
+                const xmlChar* interned = xmlTextReaderConstString(reader, valueWithoutPrefix);
+
+                auto found = std::find(constXcosNames.begin(), constXcosNames.end(), interned);
+                enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));
+                switch (current)
+                {
+                    case e_Block:
+                    {
+                        ScicosID o = controller.createObject(BLOCK);
+
+                        // assign the child
+                        model::BaseObject parent = processed.back();
+                        std::vector<ScicosID> children;
+                        controller.getObjectProperty(parent.id(), parent.kind(), CHILDREN, children);
+                        children.push_back(o);
+                        controller.setObjectProperty(parent.id(), parent.kind(), CHILDREN, children);
+
+                        model::BaseObject child(o, BLOCK);
+                        processed.push_back(child);
+                        return loadBlock(reader, child);
+                    }
+                    case e_Link:
+                    {
+                        ScicosID o = controller.createObject(LINK);
+
+                        // assign the child
+                        model::BaseObject parent = processed.back();
+                        std::vector<ScicosID> children;
+                        controller.getObjectProperty(parent.id(), parent.kind(), CHILDREN, children);
+                        children.push_back(o);
+                        controller.setObjectProperty(parent.id(), parent.kind(), CHILDREN, children);
+
+                        model::BaseObject child(o, LINK);
+                        processed.push_back(child);
+                        return loadLink(reader, child);
+                    }
+                    case e_Annotation:
+                    {
+                        ScicosID o = controller.createObject(ANNOTATION);
+
+                        // assign the child
+                        model::BaseObject parent = processed.back();
+                        std::vector<ScicosID> children;
+                        controller.getObjectProperty(parent.id(), parent.kind(), CHILDREN, children);
+                        children.push_back(o);
+                        controller.setObjectProperty(parent.id(), parent.kind(), CHILDREN, children);
+
+                        model::BaseObject child(o, ANNOTATION);
+                        return loadAnnotation(reader, child);
+                    }
+                    default:
+                        sciprint("Not handled child type=%s at line %d\n", *found,
+                                 xmlTextReaderGetParserLineNumber(reader) - 1);
+                        return -1;
+                }
+            }
+            break;
+        }
+        case e_in: // no break on purpose
+        case e_out: // no break on purpose
+        case e_ein: // no break on purpose
+        case e_eout:
+        {
+            ScicosID o = controller.createObject(PORT);
+
+            enum object_properties_t p;
+            switch (current)
+            {
+                case e_in:
+                    p = INPUTS;
+                    break;
+                case e_out:
+                    p = OUTPUTS;
+                    break;
+                case e_ein:
+                    p = EVENT_INPUTS;
+                    break;
+                case e_eout:
+                    p = EVENT_OUTPUTS;
+                    break;
+                default:
+                    return -1;
+            }
+
+            model::BaseObject parent = processed.back();
+            // add the port them to the parent
+            std::vector<ScicosID> ports;
+            controller.getObjectProperty(parent.id(), parent.kind(), p, ports);
+            ports.push_back(o);
+            controller.setObjectProperty(parent.id(), parent.kind(), p, ports);
+
+            // decode content
+            model::BaseObject child(o, PORT);
+            return loadPort(reader, child);
+        }
+        case e_geometry:
+            // geometry is used for rectangle coordinates of its parent
+            return loadGeometry(reader, processed.back());
+        case e_nzcross:
+            // nzcross is a Block property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        case e_nmode:
+            // nmode is a Block property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        case e_rpar:
+            // rpar is a Block property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        case e_ipar:
+            // ipar is a Block property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        case e_opar:
+            // ipar is a Block property
+            return loadBase64(reader, OPAR, processed.back());
+        case e_state:
+            // state is a Block property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        case e_dstate:
+            // dstate is a Block property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        case e_odstate:
+            // odstate is a Block property
+            return loadBase64(reader, ODSTATE, processed.back());
+        case e_equations:
+            // equation is a Block property
+            return loadBase64(reader, EQUATIONS, processed.back());
+        case e_expression:
+            // expression is a Block property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        case e_exprs:
+            // exprs is a Block property
+            return loadBase64(reader, EXPRS, processed.back());
+        case e_controlPoint:
+            // controlPoint is a link property
+            return loadPoint(reader, processed.back());
+        case e_context:
+            // context is a Layer property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        case e_properties:
+            // properties is a Diagram property
+            return loadSimulationConfig(reader, processed.back());
+        case e_datatype:
+            // datatype is a Port property
+            if (!xmlTextReaderIsEmptyElement(reader))
+            {
+                parent = current;
+            }
+            return 1;
+        default:
+            sciprint("Unknown \"%s\" element name at line %d\n", name, xmlTextReaderGetParserLineNumber(reader) - 1);
+            return -1;
+    }
+
+    return 1;
+}
+
+int XMIResource::processText(xmlTextReaderPtr reader)
+{
+    int ret;
+
+    switch (parent)
+    {
+        case e_nzcross:
+            // nzcross is a Block property
+            ret = loadIntArray(reader, NZCROSS, processed.back());
+            break;
+        case e_nmode:
+            // nmode is a Block property
+            ret = loadIntArray(reader, NMODE, processed.back());
+            break;
+        case e_rpar:
+            // rpar is a Block property
+            ret = loadDoubleArray(reader, RPAR, processed.back());
+            break;
+        case e_ipar:
+            // ipar is a Block property
+            ret = loadIntArray(reader, IPAR, processed.back());
+            break;
+        case e_state:
+            // state is a Block property
+            ret = loadDoubleArray(reader, RPAR, processed.back());
+            break;
+        case e_dstate:
+            // dstate is a Block property
+            ret = loadDoubleArray(reader, RPAR, processed.back());
+            break;
+        case e_expression:
+            // expression is a Block property
+            ret = loadStringArray(reader, EXPRS, processed.back());
+            break;
+        case e_context:
+            // context is a Layer property
+            ret = loadStringArray(reader, DIAGRAM_CONTEXT, processed.back());
+            break;
+        case e_datatype:
+            // datatype is a port property
+            ret = loadIntArray(reader, DATATYPE, processed.back());
+            break;
+        default:
+            sciprint("Unable to decode text value at line %d\n", xmlTextReaderGetParserLineNumber(reader) - 1);
+            ret = -1;
+            break;
+    }
+
+    return ret;
+}
+
+int XMIResource::processEndElement(xmlTextReaderPtr)
+{
+    if (parent == NB_XCOS_NAMES)
+    {
+        processed.pop_back();
+    }
+    else
+    {
+        parent = NB_XCOS_NAMES;
+    }
+
+    return 1;
+}
+
+} /* namespace org_scilab_modules_xcos */
diff --git a/scilab/modules/scicos/src/cpp/XMIResource_save.cpp b/scilab/modules/scicos/src/cpp/XMIResource_save.cpp
new file mode 100644 (file)
index 0000000..215ea60
--- /dev/null
@@ -0,0 +1,1083 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2016-2016 - Scilab Enterprises - Clement DAVID
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ */
+
+#include "XMIResource.hxx"
+#include "base64.hxx"
+
+#include <string>
+#include <sstream>
+#include <vector>
+#include <cstdio>
+
+extern "C" {
+#include "sci_types.h"
+
+#include <libxml/xmlwriter.h>
+}
+
+namespace org_scilab_modules_scicos
+{
+
+int XMIResource::save(const char* uri)
+{
+    int status;
+
+    xmlTextWriterPtr writer = xmlNewTextWriterFilename(uri, 0);
+    if (writer == NULL)
+    {
+        return -1;
+    }
+
+    status = xmlTextWriterSetIndent(writer, 1);
+    if (status == -1)
+    {
+        xmlFreeTextWriter(writer);
+        return status;
+    }
+
+    status = xmlTextWriterStartDocument(writer, "1.0", "UTF-8", NULL);
+    if (status == -1)
+    {
+        xmlFreeTextWriter(writer);
+        return status;
+    }
+
+    status = writeDiagram(writer);
+    if (status == -1)
+    {
+        xmlFreeTextWriter(writer);
+        return status;
+    }
+
+    status = xmlTextWriterEndDocument(writer);
+    xmlFreeTextWriter(writer);
+    return status;
+}
+
+static bool is_empty_matrix(const std::vector<double>& v)
+{
+    // v == {1, 2, 0, 0, 0}
+    return v.size() == 5 && v[0] == sci_matrix && v[1] == 2. && v[2] == 0. && v[3] == 0. && v[4] == 0.;
+}
+
+static bool is_empty_list(const std::vector<double>& v)
+{
+    // v == {15, 0}
+    return v.size() == 2 && v[0] == sci_list && v[1] == 0.;
+}
+
+static bool is_string_vector(const std::vector<double>& v)
+{
+    return v.size() > 2 && v[0] == sci_strings && v[1] != 0;
+}
+
+static std::string to_string(int v)
+{
+    return std::to_string(v);
+}
+
+static std::string to_string(double v)
+{
+    if (std::trunc(v) == v)
+    {
+        return to_string((int) v);
+    }
+
+    std::string str(15, '\0');
+       // std::snprintf(const_cast<char*>(str.data()), str.size(), "%.6E", v);
+    std::sprintf(const_cast<char*>(str.data()), "%.6E", v);
+    return str;
+}
+
+static int writeBase64(xmlTextWriterPtr writer, const char* name, const std::vector<double>& v)
+{
+    int status;
+
+    // convert values as big endian (network endianess)
+    // convert the big endian value to Base64
+    std::string content = base64::encode(v);
+
+    // write the XML data
+    status = xmlTextWriterStartElement(writer, BAD_CAST(name));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("base64"), BAD_CAST(content.data()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    return status;
+}
+
+
+int XMIResource::writePoint(xmlTextWriterPtr writer, double x, double y)
+{
+    int status;
+
+
+    status = xmlTextWriterStartElement(writer, BAD_CAST("controlPoint"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("x"), BAD_CAST(to_string(x).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("y"), BAD_CAST(to_string(y).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    return status;
+}
+
+int XMIResource::writeGeometry(xmlTextWriterPtr writer, ScicosID id, kind_t kind)
+{
+    int status;
+
+    status = xmlTextWriterStartElement(writer, BAD_CAST("geometry"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::vector<double> doubleArrayValue;
+    controller.getObjectProperty(id, kind, GEOMETRY, doubleArrayValue);
+    unsigned int i = 0;
+    if (doubleArrayValue.size() > i && doubleArrayValue[i])
+    {
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("x"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    i++;
+    if (doubleArrayValue.size() > i && doubleArrayValue[i])
+    {
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("y"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    i++;
+    if (doubleArrayValue.size() > i && doubleArrayValue[i])
+    {
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("width"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    i++;
+    if (doubleArrayValue.size() > i && doubleArrayValue[i])
+    {
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("height"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    return status;
+}
+
+int XMIResource::writeAbstractLayer(xmlTextWriterPtr writer, ScicosID id, kind_t kind)
+{
+    int status = 1;
+
+    std::vector<std::string> context;
+    controller.getObjectProperty(id, kind, DIAGRAM_CONTEXT, context);
+    for (const std::string& c : context)
+    {
+        status = xmlTextWriterStartElement(writer, BAD_CAST("context"));
+        if (status == -1)
+        {
+            return status;
+        }
+
+        if (!c.empty())
+        {
+            status = xmlTextWriterWriteCDATA(writer, BAD_CAST(c.c_str()));
+            if (status == -1)
+            {
+                return status;
+            }
+        }
+
+        status = xmlTextWriterEndElement(writer);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    std::vector<ScicosID> children;
+    controller.getObjectProperty(id, kind, CHILDREN, children);
+    for (ScicosID child : children)
+    {
+        kind_t kind = controller.getKind(child);
+        switch (kind)
+        {
+            case BLOCK:
+                status = writeBlock(writer, child);
+                break;
+            case LINK:
+                status = writeLink(writer, child);
+                break;
+            case ANNOTATION:
+                status = writeAnnotation(writer, child);
+                break;
+            default:
+                status =  -1;
+                break;
+        }
+
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    return status;
+}
+
+int XMIResource::writeAbstractBaseObject(xmlTextWriterPtr writer, ScicosID id, kind_t kind)
+{
+    int status;
+
+    std::string uid;
+    controller.getObjectProperty(id, kind, UID, uid);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("uid"), BAD_CAST(uid.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("parentDiagram"), BAD_CAST("/"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    /* parent / child relation is not serialized as this relation is the XML tree */
+    return status;
+}
+
+int XMIResource::writeDiagram(xmlTextWriterPtr writer)
+{
+    int status;
+
+    status = xmlTextWriterStartElementNS(writer, BAD_CAST("xcos"), BAD_CAST("Diagram"), BAD_CAST("org.scilab.modules.xcos"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    /*
+     * Write default xmlns
+     */
+    status = xmlTextWriterWriteAttributeNS(writer, BAD_CAST("xmi"), BAD_CAST("version"), BAD_CAST("http://www.omg.org/XMI"), BAD_CAST("2.0"));
+    if (status == -1)
+    {
+        return status;
+    }
+    status = xmlTextWriterWriteAttributeNS(writer, BAD_CAST("xsi"), BAD_CAST("schemaLocation"), BAD_CAST("http://www.w3.org/2001/XMLSchema-instance"), BAD_CAST("org.scilab.modules.xcos Xcos.xcore#/EPackage"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    /*
+     * Diagram values
+     */
+    std::string strValue;
+    controller.getObjectProperty(root, DIAGRAM, TITLE, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("title"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(root, DIAGRAM, PATH, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("path"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    int intValue;
+    controller.getObjectProperty(root, DIAGRAM, DEBUG_LEVEL, intValue);
+    strValue = to_string(intValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("debugLevel"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(root, DIAGRAM, VERSION_NUMBER, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("version"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = writeAbstractLayer(writer, root, DIAGRAM);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = writeSimulationConfig(writer, root);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    return status;
+}
+
+int XMIResource::writeSimulationConfig(xmlTextWriterPtr writer, ScicosID id)
+{
+    int status;
+
+    status = xmlTextWriterStartElement(writer, BAD_CAST("properties"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::vector<double> doubleArrayValue;
+    controller.getObjectProperty(id, DIAGRAM, PROPERTIES, doubleArrayValue);
+    unsigned int i = 0;
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("finalTime"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    i++;
+    if (i >= doubleArrayValue.size())
+    {
+        return -1;
+    }
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("absoluteTime"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    i++;
+    if (i >= doubleArrayValue.size())
+    {
+        return -1;
+    }
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("relativeTolerance"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    i++;
+    if (i >= doubleArrayValue.size())
+    {
+        return -1;
+    }
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("absoluteTolerance"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    i++;
+    if (i >= doubleArrayValue.size())
+    {
+        return -1;
+    }
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("deltaT"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    i++;
+    if (i >= doubleArrayValue.size())
+    {
+        return -1;
+    }
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("realtimeScale"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    i++;
+    if (i >= doubleArrayValue.size())
+    {
+        return -1;
+    }
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("solver"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    i++;
+    if (i >= doubleArrayValue.size())
+    {
+        return -1;
+    }
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("deltaH"), BAD_CAST(to_string(doubleArrayValue[i]).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    return status;
+}
+
+int XMIResource::writeBlock(xmlTextWriterPtr writer, ScicosID id)
+{
+    int status;
+
+    status = xmlTextWriterStartElement(writer, BAD_CAST("child"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("xsi:type"), BAD_CAST("xcos:Block"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = writeAbstractBaseObject(writer, id, BLOCK);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::string strValue;
+    controller.getObjectProperty(id, BLOCK, DESCRIPTION, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("description"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, BLOCK, LABEL, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("label"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, BLOCK, STYLE, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("style"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, BLOCK, INTERFACE_FUNCTION, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("interfaceFunction"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, BLOCK, SIM_FUNCTION_NAME, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("functionName"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    int intValue;
+    controller.getObjectProperty(id, BLOCK, SIM_FUNCTION_API, intValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("functionAPI"), BAD_CAST(to_string(intValue).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::vector<int> intArrayValue;
+    controller.getObjectProperty(id, BLOCK, SIM_DEP_UT, intArrayValue);
+    unsigned int i = 0;
+    if (intArrayValue.size() > i && intArrayValue[i])
+    {
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("dependsOnU"), BAD_CAST(to_string(intArrayValue[i]).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+    i++;
+    if (intArrayValue.size() > i && intArrayValue[i])
+    {
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("dependsOnT"), BAD_CAST(to_string(intArrayValue[i]).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, BLOCK, SIM_BLOCKTYPE, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("blocktype"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = writeAbstractLayer(writer, id, BLOCK);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = writeGeometry(writer, id, BLOCK);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::vector<double> doubleArrayValue;
+    controller.getObjectProperty(id, BLOCK, EXPRS, doubleArrayValue);
+    if (is_empty_matrix(doubleArrayValue))
+    {
+        // we do not serialize the default value
+    }
+    else if (is_string_vector(doubleArrayValue))
+    {
+        // if this is a string the expression is used
+        std::vector<std::string> values;
+        controller.getObjectProperty(id, BLOCK, EXPRS, values);
+
+        for (const std::string& s : values)
+        {
+            status = xmlTextWriterStartElement(writer, BAD_CAST("expression"));
+            if (status == -1)
+            {
+                return status;
+            }
+            status = xmlTextWriterWriteCDATA(writer, BAD_CAST(s.c_str()));
+            if (status == -1)
+            {
+                return status;
+            }
+
+            status = xmlTextWriterEndElement(writer);
+            if (status == -1)
+            {
+                return status;
+            }
+        }
+    }
+    else
+    {
+        // encode the value as base64 binary
+        status = writeBase64(writer, "exprs", doubleArrayValue);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    intArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, NZCROSS, intArrayValue);
+    for (int i : intArrayValue)
+    {
+        status = xmlTextWriterWriteElement(writer, BAD_CAST("nzcross"), BAD_CAST(to_string(i).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    intArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, NMODE, intArrayValue);
+    for (int i : intArrayValue)
+    {
+        status = xmlTextWriterWriteElement(writer, BAD_CAST("nmode"), BAD_CAST(to_string(i).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    doubleArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, EQUATIONS, doubleArrayValue);
+    if (!doubleArrayValue.empty() && !is_empty_list(doubleArrayValue))
+    {
+        status = writeBase64(writer, "equations", doubleArrayValue);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    std::vector<ScicosID> scicosIDArrayValue;
+    controller.getObjectProperty(id, BLOCK, INPUTS, scicosIDArrayValue);
+    for (ScicosID p : scicosIDArrayValue)
+    {
+        status = writePort(writer, INPUTS, p);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    scicosIDArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, OUTPUTS, scicosIDArrayValue);
+    for (ScicosID p : scicosIDArrayValue)
+    {
+        status = writePort(writer, OUTPUTS, p);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    controller.getObjectProperty(id, BLOCK, EVENT_INPUTS, scicosIDArrayValue);
+    for (ScicosID p : scicosIDArrayValue)
+    {
+        status = writePort(writer, EVENT_INPUTS, p);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    controller.getObjectProperty(id, BLOCK, EVENT_OUTPUTS, scicosIDArrayValue);
+    for (ScicosID p : scicosIDArrayValue)
+    {
+        status = writePort(writer, EVENT_OUTPUTS, p);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    doubleArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, RPAR, doubleArrayValue);
+    for (double d : doubleArrayValue)
+    {
+        status = xmlTextWriterWriteElement(writer, BAD_CAST("rpar"), BAD_CAST(to_string(d).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    intArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, IPAR, intArrayValue);
+    for (int i : intArrayValue)
+    {
+        status = xmlTextWriterWriteElement(writer, BAD_CAST("ipar"), BAD_CAST(to_string(i).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    doubleArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, OPAR, doubleArrayValue);
+    if (!is_empty_list(doubleArrayValue))
+    {
+        status = writeBase64(writer, "opar", doubleArrayValue);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    doubleArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, STATE, doubleArrayValue);
+    for (double d : doubleArrayValue)
+    {
+        status = xmlTextWriterWriteElement(writer, BAD_CAST("state"), BAD_CAST(to_string(d).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    doubleArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, DSTATE, doubleArrayValue);
+    for (double d : doubleArrayValue)
+    {
+        status = xmlTextWriterWriteElement(writer, BAD_CAST("dstate"), BAD_CAST(to_string(d).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    doubleArrayValue.clear();
+    controller.getObjectProperty(id, BLOCK, ODSTATE, doubleArrayValue);
+    if (!is_empty_list(doubleArrayValue))
+    {
+        status = writeBase64(writer, "odstate", doubleArrayValue);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    return status;
+}
+
+int XMIResource::writePort(xmlTextWriterPtr writer, enum object_properties_t container, ScicosID id)
+{
+    int status;
+
+    std::string element;
+    switch (container)
+    {
+        case INPUTS:
+            element = "in";
+            break;
+        case OUTPUTS:
+            element = "out";
+            break;
+        case EVENT_INPUTS:
+            element = "ein";
+            break;
+        case EVENT_OUTPUTS:
+            element = "eout";
+            break;
+        default:
+            return -1;
+    }
+
+    status = xmlTextWriterStartElement(writer, BAD_CAST(element.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::string strValue;
+    controller.getObjectProperty(id, PORT, UID, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("uid"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    ScicosID idValue;
+    controller.getObjectProperty(id, PORT, SOURCE_BLOCK, idValue);
+    controller.getObjectProperty(idValue, BLOCK, UID, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("sourceBlock"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    const std::vector<std::string> elementName = {"portUndefined", "in", "out", "ein", "eout"};
+    int portKind;
+    controller.getObjectProperty(id, PORT, PORT_KIND, portKind);
+    if (portKind < 0 && elementName.size() <= (unsigned int) portKind)
+    {
+        return -1;
+    }
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("kind"), BAD_CAST(elementName[portKind].c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    controller.getObjectProperty(id, PORT, CONNECTED_SIGNALS, idValue);
+    if (idValue != 0)
+    {
+        strValue.clear();
+        controller.getObjectProperty(idValue, LINK, UID, strValue);
+
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("connectedSignal"), BAD_CAST(strValue.c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, PORT, STYLE, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("style"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, PORT, LABEL, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("label"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::vector<double> doubleArrayValue;
+    controller.getObjectProperty(id, BLOCK, DATATYPE, doubleArrayValue);
+    for (double d : doubleArrayValue)
+    {
+        status = xmlTextWriterWriteElement(writer, BAD_CAST("datatype"), BAD_CAST(to_string(d).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    return status;
+}
+
+int XMIResource::writeLink(xmlTextWriterPtr writer, ScicosID id)
+{
+    int status;
+
+    status = xmlTextWriterStartElement(writer, BAD_CAST("child"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("xsi:type"), BAD_CAST("xcos:Link"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = writeAbstractBaseObject(writer, id, LINK);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    ScicosID idValue;
+    std::string strValue;
+    controller.getObjectProperty(id, LINK, SOURCE_PORT, idValue);
+    if (idValue != 0)
+    {
+        strValue.clear();
+        controller.getObjectProperty(idValue, PORT, UID, strValue);
+
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("sourcePort"), BAD_CAST(strValue.c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    controller.getObjectProperty(id, LINK, DESTINATION_PORT, idValue);
+    if (idValue != 0)
+    {
+        strValue.clear();
+        controller.getObjectProperty(idValue, PORT, UID, strValue);
+
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("destinationPort"), BAD_CAST(strValue.c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, LINK, STYLE, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("style"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, LINK, LABEL, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("label"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    int intValue;
+    controller.getObjectProperty(id, LINK, COLOR, intValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("color"), BAD_CAST(to_string(intValue).c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::vector<int> intArrayValue;
+    controller.getObjectProperty(id, LINK, THICK, intArrayValue);
+    unsigned int i = 0;
+    if (i < intArrayValue.size())
+    {
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("lineWidth"), BAD_CAST(to_string(intArrayValue[i]).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+    i++;
+    if (i < intArrayValue.size())
+    {
+        status = xmlTextWriterWriteAttribute(writer, BAD_CAST("lineHeight"), BAD_CAST(to_string(intArrayValue[i]).c_str()));
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    status = writeGeometry(writer, id, LINK);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::vector<double> dblArrayValue;
+    controller.getObjectProperty(id, LINK, CONTROL_POINTS, dblArrayValue);
+    for (unsigned int i = 0; i < dblArrayValue.size(); i += 2)
+    {
+        status = writePoint(writer, dblArrayValue[i], dblArrayValue[i + 1]);
+        if (status == -1)
+        {
+            return status;
+        }
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    return status;
+}
+
+int XMIResource::writeAnnotation(xmlTextWriterPtr writer, ScicosID id)
+{
+    int status;
+
+    status = xmlTextWriterStartElement(writer, BAD_CAST("child"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("xsi:type"), BAD_CAST("xcos:Annotation"));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = writeAbstractBaseObject(writer, id, ANNOTATION);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    std::string strValue;
+    controller.getObjectProperty(id, ANNOTATION, DESCRIPTION, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("description"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, ANNOTATION, FONT, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("font"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, ANNOTATION, FONT_SIZE, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("fontSize"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    strValue.clear();
+    controller.getObjectProperty(id, ANNOTATION, STYLE, strValue);
+    status = xmlTextWriterWriteAttribute(writer, BAD_CAST("style"), BAD_CAST(strValue.c_str()));
+    if (status == -1)
+    {
+        return status;
+    }
+
+    status = xmlTextWriterEndElement(writer);
+    if (status == -1)
+    {
+        return status;
+    }
+
+    return status;
+}
+
+} /* namespace org_scilab_modules_xcos */
diff --git a/scilab/modules/scicos/src/cpp/base64.hxx b/scilab/modules/scicos/src/cpp/base64.hxx
new file mode 100644 (file)
index 0000000..a768d0e
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+*  Copyright (C) 2016 - Scilab Enterprises - Clement DAVID
+*
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+*
+*/
+
+#ifndef MODULES_SCICOS_SRC_CPP_BASE64_HXX_
+#define MODULES_SCICOS_SRC_CPP_BASE64_HXX_
+
+#include <array>
+#include <vector>
+#include <sstream>
+#include <string>
+#include <limits>
+#include <cmath> // for std::trunc
+
+namespace org_scilab_modules_scicos
+{
+
+/*
+ * Encode a string to a base64 encoded string.
+ *
+ * This implement the RFC 2045 Base64 variant. See https://tools.ietf.org/html/rfc2045
+ */
+struct base64
+{
+    template<typename T> static std::string encode(const T& v);
+    template<typename T> static T decode(const std::string& content);
+};
+template<> inline std::string base64::encode(const std::string& v);
+template<> inline std::string base64::decode(const std::string& content);
+
+
+template<> std::string base64::encode<std::string>(const std::string& strValue)
+{
+    const std::string Base64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+    const char Base64Pad = '=';
+
+    // tips given by :
+    //  * http://www.adp-gmbh.ch/cpp/common/base64.html
+    //  * http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c
+    std::string content;
+
+    int val = 0;
+    int val_byte = -6;
+    for (unsigned char c : strValue)
+    {
+        val = (val << 8) + c;
+        val_byte += 8;
+
+        while (val_byte >= 0)
+        {
+            content.push_back(Base64Alphabet[(val >> val_byte) & 0x3F]);
+            val_byte -= 6;
+        }
+    }
+    // the trailing part is left in val_byte
+    if (val_byte > -6)
+    {
+        content.push_back(Base64Alphabet[((val << 8) >> (val_byte + 8)) & 0x3F]);
+    }
+    // add padding if needed
+    while (content.size() % 4)
+    {
+        content.push_back(Base64Pad);
+    }
+
+    return content;
+}
+
+template<> std::string base64::decode<std::string>(const std::string& content)
+{
+    const std::string Base64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+    // inverse table (might be const or constexpr)
+    std::array<char, 255> T;
+    T.fill(255);
+    for (size_t i = 0; i < Base64Alphabet.length(); i++)
+    {
+        T[Base64Alphabet[i]] = i;
+    }
+
+    // decoding loop
+    std::string strValue;
+
+    int val = 0;
+    int val_byte = -8;
+    for (char c : content)
+    {
+        if (T[c] == std::numeric_limits<unsigned char>::max()) // not in the table, stop decoding
+        {
+            break;
+        }
+
+        val = (val << 6) + T[c];
+        val_byte += 6;
+        if (val_byte >= 0)
+        {
+            strValue.push_back((val >> val_byte) & 0xFF);
+            val_byte -= 8;
+        }
+    }
+
+    return strValue;
+}
+
+
+template<typename T>
+std::string base64::encode(const T& v)
+{
+    // convert to string components and compress using int conversion
+    std::string strValue;
+    for (auto it = v.begin(); it != v.end(); it++)
+    {
+        typename T::value_type d = *it;
+
+        if (std::trunc(d) == d)
+        {
+            strValue.append(std::to_string((int) d));
+        }
+        else
+        {
+            strValue.append(std::to_string(d));
+        }
+
+        if (it + 1 != v.end())
+        {
+            strValue.push_back(' ');
+        }
+    }
+
+    return encode<std::string>(strValue);
+}
+
+template<typename T>
+T base64::decode(const std::string& content)
+{
+    std::string strValue = decode<std::string>(content);
+
+    T vector;
+    std::istringstream ss(strValue);
+    while (ss)
+    {
+        typename T::value_type v;
+        ss >> v;
+        vector.push_back(v);
+    }
+
+    return vector;
+}
+
+} /* namespace org_scilab_modules_xcos */
+
+#endif /* MODULES_SCICOS_SRC_CPP_BASE64_HXX_ */
index c27cfc2..c87789e 100644 (file)
@@ -48,8 +48,8 @@ XCOS_CXX_SOURCES =    \
     src/jni/Modelica.hxx \
     src/jni/JavaController_wrap.cxx \
     src/cpp/xcosUtilities.cpp \
-    src/cpp/loadStatus.cpp
-
+    src/cpp/loadStatus.cpp \
+    src/jni/JavaXMIResource_wrap.cxx
 
 GIWS_WRAPPERS = \
     src/jni/Xcos.giws.xml \
@@ -57,7 +57,9 @@ GIWS_WRAPPERS = \
     src/jni/Palette.giws.xml \
     src/jni/Modelica.giws.xml
 SWIG_WRAPPERS = \
-    src/jni/JavaController.i
+    src/jni/JavaController.i \
+    src/jni/JavaXMIResource.i
+    
 # FORCE directors due to a bug into swig
 SWIG_OPTIONS=-c++ -directors
 BUILT_SOURCES=
@@ -116,6 +118,7 @@ libscixcos_la_CPPFLAGS = \
     -I$(top_srcdir)/modules/localization/includes/ \
     -I$(top_srcdir)/modules/fileio/includes/ \
     -I$(top_srcdir)/modules/api_scilab/includes/ \
+    $(XML_FLAGS) \
     $(JAVA_JNI_INCLUDE) \
     $(AM_CPPFLAGS)
 
@@ -131,6 +134,7 @@ libscixcos_disable_la_CPPFLAGS = \
     -I$(top_srcdir)/modules/ast/includes/types/ \
     -I$(top_srcdir)/modules/localization/includes/ \
     -I$(top_srcdir)/modules/output_stream/includes \
+    $(XML_FLAGS) \
     $(AM_CPPFLAGS)
 
 XCOS_DISABLE_C_SOURCES = src/noxcos/noxcos.c
@@ -159,7 +163,8 @@ INCLUDE_FLAGS = $(libscixcos_la_CPPFLAGS)
 libscixcos_la_LIBADD = libscixcos-algo.la \
                $(top_builddir)/modules/scicos/libsciscicos.la \
                $(top_builddir)/modules/commons/libscicommons.la \
-               $(top_builddir)/modules/jvm/libscijvm.la
+               $(top_builddir)/modules/jvm/libscijvm.la \
+               $(LIBXML_LIBS)
 
 #### xcos : gateway declaration ####
 libscixcos_la_sci_gatewaydir = $(mydatadir)/sci_gateway
index dc51598..1628e57 100644 (file)
@@ -195,7 +195,8 @@ am__objects_1 = src/jni/libscixcos_algo_la-Xcos.lo \
        src/jni/libscixcos_algo_la-Modelica.lo \
        src/jni/libscixcos_algo_la-JavaController_wrap.lo \
        src/cpp/libscixcos_algo_la-xcosUtilities.lo \
-       src/cpp/libscixcos_algo_la-loadStatus.lo
+       src/cpp/libscixcos_algo_la-loadStatus.lo \
+       src/jni/libscixcos_algo_la-JavaXMIResource_wrap.lo
 am_libscixcos_algo_la_OBJECTS = $(am__objects_1)
 libscixcos_algo_la_OBJECTS = $(am_libscixcos_algo_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -641,7 +642,8 @@ XCOS_CXX_SOURCES = \
     src/jni/Modelica.hxx \
     src/jni/JavaController_wrap.cxx \
     src/cpp/xcosUtilities.cpp \
-    src/cpp/loadStatus.cpp
+    src/cpp/loadStatus.cpp \
+    src/jni/JavaXMIResource_wrap.cxx
 
 GIWS_WRAPPERS = \
     src/jni/Xcos.giws.xml \
@@ -650,7 +652,9 @@ GIWS_WRAPPERS = \
     src/jni/Modelica.giws.xml
 
 SWIG_WRAPPERS = \
-    src/jni/JavaController.i
+    src/jni/JavaController.i \
+    src/jni/JavaXMIResource.i
+
 
 # FORCE directors due to a bug into swig
 SWIG_OPTIONS = -c++ -directors
@@ -701,6 +705,7 @@ libscixcos_la_CPPFLAGS = \
     -I$(top_srcdir)/modules/localization/includes/ \
     -I$(top_srcdir)/modules/fileio/includes/ \
     -I$(top_srcdir)/modules/api_scilab/includes/ \
+    $(XML_FLAGS) \
     $(JAVA_JNI_INCLUDE) \
     $(AM_CPPFLAGS)
 
@@ -717,6 +722,7 @@ libscixcos_disable_la_CPPFLAGS = \
     -I$(top_srcdir)/modules/ast/includes/types/ \
     -I$(top_srcdir)/modules/localization/includes/ \
     -I$(top_srcdir)/modules/output_stream/includes \
+    $(XML_FLAGS) \
     $(AM_CPPFLAGS)
 
 XCOS_DISABLE_C_SOURCES = src/noxcos/noxcos.c
@@ -733,7 +739,8 @@ INCLUDE_FLAGS = $(libscixcos_la_CPPFLAGS)
 libscixcos_la_LIBADD = libscixcos-algo.la \
                $(top_builddir)/modules/scicos/libsciscicos.la \
                $(top_builddir)/modules/commons/libscicommons.la \
-               $(top_builddir)/modules/jvm/libscijvm.la
+               $(top_builddir)/modules/jvm/libscijvm.la \
+               $(LIBXML_LIBS)
 
 
 #### xcos : gateway declaration ####
@@ -1221,6 +1228,8 @@ src/cpp/libscixcos_algo_la-xcosUtilities.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscixcos_algo_la-loadStatus.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/jni/libscixcos_algo_la-JavaXMIResource_wrap.lo:  \
+       src/jni/$(am__dirstamp) src/jni/$(DEPDIR)/$(am__dirstamp)
 
 libscixcos-algo.la: $(libscixcos_algo_la_OBJECTS) $(libscixcos_algo_la_DEPENDENCIES) $(EXTRA_libscixcos_algo_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(CXXLINK) $(am_libscixcos_algo_la_rpath) $(libscixcos_algo_la_OBJECTS) $(libscixcos_algo_la_LIBADD) $(LIBS)
@@ -1331,6 +1340,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscixcos_algo_la-loadStatus.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscixcos_algo_la-xcosUtilities.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscixcos_algo_la-JavaController_wrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscixcos_algo_la-JavaXMIResource_wrap.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscixcos_algo_la-Modelica.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscixcos_algo_la-Palette.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscixcos_algo_la-Xcos.Plo@am__quote@
@@ -1441,6 +1451,13 @@ src/cpp/libscixcos_algo_la-loadStatus.lo: src/cpp/loadStatus.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscixcos_algo_la-loadStatus.lo `test -f 'src/cpp/loadStatus.cpp' || echo '$(srcdir)/'`src/cpp/loadStatus.cpp
 
+src/jni/libscixcos_algo_la-JavaXMIResource_wrap.lo: src/jni/JavaXMIResource_wrap.cxx
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/jni/libscixcos_algo_la-JavaXMIResource_wrap.lo -MD -MP -MF src/jni/$(DEPDIR)/libscixcos_algo_la-JavaXMIResource_wrap.Tpo -c -o src/jni/libscixcos_algo_la-JavaXMIResource_wrap.lo `test -f 'src/jni/JavaXMIResource_wrap.cxx' || echo '$(srcdir)/'`src/jni/JavaXMIResource_wrap.cxx
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/jni/$(DEPDIR)/libscixcos_algo_la-JavaXMIResource_wrap.Tpo src/jni/$(DEPDIR)/libscixcos_algo_la-JavaXMIResource_wrap.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/jni/JavaXMIResource_wrap.cxx' object='src/jni/libscixcos_algo_la-JavaXMIResource_wrap.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/jni/libscixcos_algo_la-JavaXMIResource_wrap.lo `test -f 'src/jni/JavaXMIResource_wrap.cxx' || echo '$(srcdir)/'`src/jni/JavaXMIResource_wrap.cxx
+
 sci_gateway/cpp/libscixcos_la-sci_Xcos.lo: sci_gateway/cpp/sci_Xcos.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscixcos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscixcos_la-sci_Xcos.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscixcos_la-sci_Xcos.Tpo -c -o sci_gateway/cpp/libscixcos_la-sci_Xcos.lo `test -f 'sci_gateway/cpp/sci_Xcos.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_Xcos.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscixcos_la-sci_Xcos.Tpo sci_gateway/cpp/$(DEPDIR)/libscixcos_la-sci_Xcos.Plo
diff --git a/scilab/modules/xcos/model/Xcos.genmodel b/scilab/modules/xcos/model/Xcos.genmodel
new file mode 100644 (file)
index 0000000..2370b76
--- /dev/null
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+    xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/xcos/src" modelPluginID="xcos" runtimeJar="true"
+    modelName="Xcos" updateClasspath="false" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
+    testsDirectory="" booleanFlagsField="eFlags" booleanFlagsReservedBits="8" importerID="org.eclipse.emf.ecore.xcore.importer"
+    containmentProxies="true" complianceLevel="8.0" language="en" usedGenPackages="../../../org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore"
+    operationReflection="true" importOrganizing="true" decoration="Live" oSGiCompatible="true">
+  <genAnnotations source="http://www.eclipse.org/emf/2002/GenModel/exporter/org.eclipse.xsd.ecore.exporter">
+    <genAnnotations source="selectedPackages">
+      <details key="http://www.eclipse.org/emf/2002/Ecore" value="Ecore.xsd"/>
+    </genAnnotations>
+    <details key="directoryURI" value="."/>
+  </genAnnotations>
+  <genAnnotations source="http://www.eclipse.org/emf/2002/GenModel/exporter/org.eclipse.xsd.ecore.exporter.xmi">
+    <genAnnotations source="selectedPackages">
+      <details key="http://www.eclipse.org/emf/2002/Ecore" value="EcoreXMI.xsd"/>
+    </genAnnotations>
+    <details key="directoryURI" value="."/>
+  </genAnnotations>
+  <foreignModel>Xcos.xcore</foreignModel>
+  <modelPluginVariables>org.eclipse.xtext.xbase.lib</modelPluginVariables>
+  <modelPluginVariables>org.eclipse.emf.ecore.xcore.lib</modelPluginVariables>
+  <genPackages prefix="Xcos" basePackage="org.scilab.modules" disposableProviderFactory="true"
+      ecorePackage="xcos.ecore#/">
+    <genEnums typeSafeEnumCompatible="false" ecoreEnum="xcos.ecore#//PortKind">
+      <genEnumLiterals ecoreEnumLiteral="xcos.ecore#//PortKind/in"/>
+      <genEnumLiterals ecoreEnumLiteral="xcos.ecore#//PortKind/out"/>
+      <genEnumLiterals ecoreEnumLiteral="xcos.ecore#//PortKind/ein"/>
+      <genEnumLiterals ecoreEnumLiteral="xcos.ecore#//PortKind/eout"/>
+    </genEnums>
+    <genClasses ecoreClass="xcos.ecore#//Binary">
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Binary/base64"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//Point">
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Point/x"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Point/y"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//Geometry">
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Geometry/x"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Geometry/y"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Geometry/height"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Geometry/width"/>
+    </genClasses>
+    <genClasses image="false" ecoreClass="xcos.ecore#//Layer">
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Layer/context"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Layer/child"/>
+    </genClasses>
+    <genClasses image="false" ecoreClass="xcos.ecore#//BaseObject">
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//BaseObject/uid"/>
+      <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference xcos.ecore#//BaseObject/parentDiagram"/>
+      <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference xcos.ecore#//BaseObject/parent"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//Diagram">
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Diagram/title"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Diagram/path"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Diagram/properties"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Diagram/debugLevel"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Diagram/version"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//SimulationConfig">
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//SimulationConfig/finalTime"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//SimulationConfig/absoluteTolerance"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//SimulationConfig/relativeTolerance"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//SimulationConfig/timeTolerance"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//SimulationConfig/deltaT"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//SimulationConfig/realtimeScale"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//SimulationConfig/solver"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//SimulationConfig/deltaH"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//Block">
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/geometry"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/description"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/label"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/style"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/interfaceFunction"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/expression"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/exprs"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/nzcross"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/nmode"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/equations"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/functionName"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/functionAPI"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/dependsOnU"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/dependsOnT"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/blocktype"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/in"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/out"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/ein"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/eout"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/rpar"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/ipar"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/opar"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/state"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Block/dstate"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Block/odstate"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//Port">
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Port/uid"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Port/datatype"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Port/firing"/>
+      <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference xcos.ecore#//Port/sourceBlock"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Port/kind"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Port/implicit"/>
+      <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference xcos.ecore#//Port/connectedSignal"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Port/style"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Port/label"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//Link">
+      <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference xcos.ecore#//Link/sourcePort"/>
+      <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference xcos.ecore#//Link/destinationPort"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Link/geometry"/>
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Link/controlPoint"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Link/style"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Link/label"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Link/lineWidth"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Link/lineHeight"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Link/color"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//Annotation">
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference xcos.ecore#//Annotation/geometry"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Annotation/description"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Annotation/font"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Annotation/fontSize"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute xcos.ecore#//Annotation/style"/>
+    </genClasses>
+    <genClasses ecoreClass="xcos.ecore#//CompiledRepresentation"/>
+  </genPackages>
+</genmodel:GenModel>
diff --git a/scilab/modules/xcos/model/Xcos.xcore b/scilab/modules/xcos/model/Xcos.xcore
new file mode 100644 (file)
index 0000000..14bc452
--- /dev/null
@@ -0,0 +1,176 @@
+package org.scilab.modules.xcos
+
+/* Encoded Scilab values */
+class Binary
+{
+       /* RFC 2045 Base64 encoded double[] values (space separated) */
+       String base64
+}
+
+/* A point is a position on the diagram */
+class Point
+{
+       /* X coordinate */
+       double x
+       /* Y coordinate */
+       double y
+}
+
+/* Rectangular coordinates of the object */
+class Geometry
+{
+       /* X coordinate */
+       double x
+       /* Y coordinate */
+       double y
+       /* Height of the object */
+       double height
+       /* Width of the object */
+       double width
+}
+
+/* The kind of a port */
+enum PortKind
+{
+       in, out, ein, eout
+}
+
+/* Shared definition for both a Diagram and a SuperBlock (eg. a Block) */
+abstract class Layer
+{
+       /* Scilab scripts added at current layer */
+       String[] context
+       /* contained objects */
+       contains BaseObject[] child opposite parent
+}
+
+/* Shared definition for an object contained in a Layer */
+abstract class BaseObject {
+       /* Unique IDentifier : usually on the universally unique identifier (UUID) form */
+       id String uid
+       
+       /* The diagram (to ease in memory representation) */
+       refers Diagram[1..1] parentDiagram
+       /* parent Layer to navigate back */
+       container Layer[1..1] parent opposite child
+}
+
+/* A diagram is the top-level object of a model. It contains simulation parameters and the hierarchical data-flow and event-flow graphs. */
+class Diagram extends Layer
+{
+       /* title of a diagram */
+       String title
+       /* Latest saved path */
+       String path
+       
+       /* Simulation settings */
+       contains SimulationConfig properties
+       /* Simulation debug level */
+       int debugLevel
+       
+       /* Version of the diagram */
+       String version
+}
+
+/* Simulation settings */
+class SimulationConfig
+{
+       /* Simulation final time (starting at 0) */
+       double finalTime
+       double absoluteTolerance
+       double relativeTolerance
+       double timeTolerance
+       double deltaT
+       double realtimeScale
+       double solver
+       double deltaH
+}
+
+/*  */
+class Block extends BaseObject, Layer
+{      
+       contains Geometry geometry
+       String description
+       String label
+       String style
+       
+       String interfaceFunction
+       String[] expression
+       contains Binary exprs
+       
+       int[] nzcross
+       int[] nmode
+       contains Binary equations
+       
+       String functionName
+       int functionAPI
+       boolean dependsOnU
+       boolean dependsOnT
+       char blocktype
+       
+       contains Port[] in
+       contains Port[] out
+       contains Port[] ein
+       contains Port[] eout
+       
+       double[] rpar
+       int[] ipar
+       contains Binary opar
+       
+       double[] state
+       double[] dstate
+       contains Binary odstate
+}
+
+class Port
+{      
+       id String uid
+       
+       int[] datatype
+       double firing
+       
+       refers Block sourceBlock
+       PortKind kind
+       boolean implicit
+       refers Link connectedSignal
+       
+       String style
+       String label
+}
+
+class Link extends BaseObject
+{      
+       refers Port sourcePort
+       refers Port destinationPort
+       
+       contains Geometry geometry
+       contains Point[] controlPoint
+       
+       String style
+       String label
+       double lineWidth
+       double lineHeight
+       int color
+}
+
+class Annotation extends BaseObject
+{
+       contains Geometry geometry
+       String description
+       String font
+       String fontSize
+       String style
+}
+
+/****************************************************************************************
+ * An executable representation can be exported only if the diagram has been "compiled" *
+ ****************************************************************************************/
+/*
+ * 
+ */
+class CompiledRepresentation
+{
+       
+}
+
diff --git a/scilab/modules/xcos/model/xcos.ecore b/scilab/modules/xcos/model/xcos.ecore
new file mode 100644 (file)
index 0000000..96571a6
--- /dev/null
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="xcos" nsURI="org.scilab.modules.xcos" nsPrefix="xcos">
+  <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+    <details key="basePackage" value="org.scilab.modules"/>
+  </eAnnotations>
+  <eClassifiers xsi:type="ecore:EClass" name="Binary">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value=" Encoded Scilab values"/>
+    </eAnnotations>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="base64" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" RFC 2045 Base64 encoded double[] values (space separated)"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="Point">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value=" A point is a position on the diagram"/>
+    </eAnnotations>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="x" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" X coordinate"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="y" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Y coordinate"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="Geometry">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value=" Rectangular coordinates of the object"/>
+    </eAnnotations>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="x" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" X coordinate"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="y" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Y coordinate"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="height" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Height of the object"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="width" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Width of the object"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EEnum" name="PortKind">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value=" The kind of a port"/>
+    </eAnnotations>
+    <eLiterals name="in"/>
+    <eLiterals name="out"/>
+    <eLiterals name="ein"/>
+    <eLiterals name="eout"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="Layer" abstract="true">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value=" Shared definition for both a Diagram and a SuperBlock (eg. a Block)"/>
+    </eAnnotations>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="context" unique="false"
+        upperBound="-1" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Scilab scripts added at current layer"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="child" upperBound="-1"
+        eType="#//BaseObject" containment="true" resolveProxies="false" eOpposite="#//BaseObject/parent">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" contained objects"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="BaseObject" abstract="true">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value=" Shared definition for an object contained in a Layer"/>
+    </eAnnotations>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="uid" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"
+        iD="true">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Unique IDentifier : usually on the universally unique identifier (UUID) form"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="parentDiagram" lowerBound="1"
+        eType="#//Diagram">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" The diagram (to ease in memory representation)"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="parent" lowerBound="1"
+        eType="#//Layer" eOpposite="#//Layer/child">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" parent Layer to navigate back"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="Diagram" eSuperTypes="#//Layer">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value=" A diagram is the top-level object of a model. It contains simulation parameters and the hierarchical data-flow and event-flow graphs."/>
+    </eAnnotations>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="title" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" title of a diagram"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="path" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Latest saved path"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="properties" eType="#//SimulationConfig"
+        containment="true" resolveProxies="false">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Simulation settings"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="debugLevel" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Simulation debug level"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="version" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Version of the diagram"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="SimulationConfig">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value=" Simulation settings"/>
+    </eAnnotations>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="finalTime" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value=" Simulation final time (starting at 0)"/>
+      </eAnnotations>
+    </eStructuralFeatures>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="absoluteTolerance" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="relativeTolerance" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="timeTolerance" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="deltaT" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="realtimeScale" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="solver" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="deltaH" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="Block" eSuperTypes="#//BaseObject #//Layer">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="geometry" eType="#//Geometry"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="label" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="style" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="interfaceFunction" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="expression" unique="false"
+        upperBound="-1" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="exprs" eType="#//Binary"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="nzcross" unique="false"
+        upperBound="-1" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="nmode" unique="false" upperBound="-1"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="equations" eType="#//Binary"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="functionName" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="functionAPI" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="dependsOnU" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="dependsOnT" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="blocktype" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EChar"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="in" upperBound="-1" eType="#//Port"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="out" upperBound="-1" eType="#//Port"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="ein" upperBound="-1" eType="#//Port"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="eout" upperBound="-1" eType="#//Port"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="rpar" unique="false" upperBound="-1"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="ipar" unique="false" upperBound="-1"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="opar" eType="#//Binary"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="state" unique="false" upperBound="-1"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="dstate" unique="false"
+        upperBound="-1" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="odstate" eType="#//Binary"
+        containment="true" resolveProxies="false"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="Port">
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="uid" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"
+        iD="true"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="datatype" unique="false"
+        upperBound="-1" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="firing" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="sourceBlock" eType="#//Block"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="kind" unique="false" eType="#//PortKind"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="implicit" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="connectedSignal" eType="#//Link"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="style" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="label" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="Link" eSuperTypes="#//BaseObject">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="sourcePort" eType="#//Port"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="destinationPort" eType="#//Port"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="geometry" eType="#//Geometry"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="controlPoint" upperBound="-1"
+        eType="#//Point" containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="style" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="label" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="lineWidth" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="lineHeight" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EDouble"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="color" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="Annotation" eSuperTypes="#//BaseObject">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="geometry" eType="#//Geometry"
+        containment="true" resolveProxies="false"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="font" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="fontSize" unique="false"
+        eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="style" unique="false" eType="ecore:EDataType ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="CompiledRepresentation">
+    <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+      <details key="documentation" value="***************************************************************************************&#xA;An executable representation can be exported only if the diagram has been &quot;compiled&quot; *&#xA;**************************************************************************************"/>
+    </eAnnotations>
+  </eClassifiers>
+</ecore:EPackage>
index 8f12511..455786a 100644 (file)
@@ -93,7 +93,7 @@
     <ClCompile>
       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../cpp;../jni;../../includes;$(SCILAB_JDK32)/include;$(SCILAB_JDK32)/include/win32;../../../../libs/intl;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../fileio/includes;../../../output_stream/includes;../../../commons/src/jni;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../scicos/includes;../../../dynamic_link/includes;../../../string/includes;../../../threads/includes;../../../console/includes;../../../scicos_blocks/includes;../../../scicos_blocks/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../cpp;../jni;../../includes;$(SCILAB_JDK32)/include;$(SCILAB_JDK32)/include/win32;../../../../libs/intl;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../fileio/includes;../../../output_stream/includes;../../../commons/src/jni;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../scicos/includes;../../../dynamic_link/includes;../../../string/includes;../../../threads/includes;../../../console/includes;../../../scicos_blocks/includes;../../../scicos_blocks/src/jni;../../../../libs/libxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;XCOS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../cpp;../jni;../../includes;$(SCILAB_JDK64)/include;$(SCILAB_JDK64)/include/win32;../../../../libs/intl;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../fileio/includes;../../../output_stream/includes;../../../commons/src/jni;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../scicos/includes;../../../dynamic_link/includes;../../../string/includes;../../../threads/includes;../../../console/includes;../../../scicos_blocks/includes;../../../scicos_blocks/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../cpp;../jni;../../includes;$(SCILAB_JDK64)/include;$(SCILAB_JDK64)/include/win32;../../../../libs/intl;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../fileio/includes;../../../output_stream/includes;../../../commons/src/jni;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../scicos/includes;../../../dynamic_link/includes;../../../string/includes;../../../threads/includes;../../../console/includes;../../../scicos_blocks/includes;../../../scicos_blocks/src/jni;../../../../libs/libxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;XCOS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../cpp;../jni;../../includes;$(SCILAB_JDK32)/include;$(SCILAB_JDK32)/include/win32;../../../../libs/intl;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../fileio/includes;../../../output_stream/includes;../../../commons/src/jni;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../scicos/includes;../../../dynamic_link/includes;../../../string/includes;../../../threads/includes;../../../console/includes;../../../scicos_blocks/includes;../../../scicos_blocks/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../cpp;../jni;../../includes;$(SCILAB_JDK32)/include;$(SCILAB_JDK32)/include/win32;../../../../libs/intl;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../fileio/includes;../../../output_stream/includes;../../../commons/src/jni;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../scicos/includes;../../../dynamic_link/includes;../../../string/includes;../../../threads/includes;../../../console/includes;../../../scicos_blocks/includes;../../../scicos_blocks/src/jni;../../../../libs/libxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;XCOS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../cpp;../jni;../../includes;$(SCILAB_JDK64)/include;$(SCILAB_JDK64)/include/win32;../../../../libs/intl;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../fileio/includes;../../../output_stream/includes;../../../commons/src/jni;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../scicos/includes;../../../dynamic_link/includes;../../../string/includes;../../../threads/includes;../../../console/includes;../../../scicos_blocks/includes;../../../scicos_blocks/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../cpp;../jni;../../includes;$(SCILAB_JDK64)/include;$(SCILAB_JDK64)/include/win32;../../../../libs/intl;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../fileio/includes;../../../output_stream/includes;../../../commons/src/jni;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../scicos/includes;../../../dynamic_link/includes;../../../string/includes;../../../threads/includes;../../../console/includes;../../../scicos_blocks/includes;../../../scicos_blocks/src/jni;../../../../libs/libxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;XCOS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
     <ClCompile Include="..\..\sci_gateway\cpp\sci_xcosDiagramToScilab.cpp" />
     <ClCompile Include="..\cpp\loadStatus.cpp" />
     <ClCompile Include="..\jni\JavaController_wrap.cxx" />
+    <ClCompile Include="..\jni\JavaXMIResource_wrap.cxx" />
     <ClCompile Include="..\jni\XcosCellFactory.cpp" />
     <ClCompile Include="DllmainXCOS.c" />
     <ClCompile Include="..\jni\Modelica.cpp" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index dcca62c..558bcc7 100644 (file)
@@ -89,6 +89,9 @@
     <ClCompile Include="..\jni\JavaController_wrap.cxx">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\jni\JavaXMIResource_wrap.cxx">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="..\jni\XcosCellFactory.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
       <Filter>Resource Files</Filter>
     </ResourceCompile>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/JavaXMIResource.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/JavaXMIResource.java
new file mode 100644 (file)
index 0000000..75bab25
--- /dev/null
@@ -0,0 +1,20 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 3.0.8
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.scilab.modules.xcos;
+
+public class JavaXMIResource {
+    public static int save(String uri, long id) {
+        return JavaXMIResourceJNI.save(uri, id);
+    }
+
+    public static int load(String uri, long id) {
+        return JavaXMIResourceJNI.load(uri, id);
+    }
+
+}
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/JavaXMIResourceJNI.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/JavaXMIResourceJNI.java
new file mode 100644 (file)
index 0000000..15859b1
--- /dev/null
@@ -0,0 +1,14 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 3.0.8
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.scilab.modules.xcos;
+
+public class JavaXMIResourceJNI {
+    public final static native int save(String jarg1, long jarg2);
+    public final static native int load(String jarg1, long jarg2);
+}
index 8391c02..d505d95 100644 (file)
@@ -9,10 +9,10 @@
 package org.scilab.modules.xcos;
 
 public enum PortKind {
-  PORT_UNDEF,
-  PORT_IN,
-  PORT_OUT,
-  PORT_EIN,
-  PORT_EOUT;
+    PORT_UNDEF,
+    PORT_IN,
+    PORT_OUT,
+    PORT_EIN,
+    PORT_EOUT;
 }
 
index c2d6061..9d4b8b6 100644 (file)
@@ -9,8 +9,8 @@
 package org.scilab.modules.xcos;
 
 public enum UpdateStatus {
-  SUCCESS,
-  NO_CHANGES,
-  FAIL;
+    SUCCESS,
+    NO_CHANGES,
+    FAIL;
 }
 
index a08c082..72765fe 100644 (file)
@@ -880,17 +880,14 @@ public final class Xcos {
             throw new IllegalArgumentException("not handled filetype");
         }
 
-        switch (filetype) {
-            case XCOS:
-            case ZCOS:
-                if (export) {
-                    filetype.save(file, new XcosDiagram(new JavaController(), diagramId, Kind.DIAGRAM, ""));
-                } else {
-                    filetype.load(file, new XcosDiagram(new JavaController(), diagramId, Kind.DIAGRAM, ""));
-                }
-                break;
-            case COSF:
-                throw new IllegalArgumentException("not handled filetype");
+        if (XcosFileType.getAvailableSaveFormats().contains(filetype)) {
+            if (export) {
+                filetype.save(file, new XcosDiagram(new JavaController(), diagramId, Kind.DIAGRAM, ""));
+            } else {
+                filetype.load(file, new XcosDiagram(new JavaController(), diagramId, Kind.DIAGRAM, ""));
+            }
+        } else {
+            throw new IllegalArgumentException("not handled filetype");
         }
     }
 
index 1db78cd..e7fe653 100644 (file)
@@ -37,6 +37,7 @@ import javax.xml.transform.TransformerException;
 
 import org.scilab.modules.commons.xml.ScilabXMLOutputFactory;
 import org.scilab.modules.xcos.JavaController;
+import org.scilab.modules.xcos.JavaXMIResource;
 import org.scilab.modules.xcos.View;
 import org.scilab.modules.xcos.Xcos;
 import org.scilab.modules.xcos.graph.XcosDiagram;
@@ -136,6 +137,21 @@ public enum XcosFileType {
         }
     },
     /**
+     * Represent an XMI (compatible with Eclipse EMF) serialization of the model
+     */
+    XMI("xmi", XcosMessages.FILE_XMI) {
+
+        @Override
+        public void load(String file, XcosDiagram into) throws Exception {
+            JavaXMIResource.load(file, into.getUID());
+        }
+
+        @Override
+        public void save(String file, XcosDiagram from) throws Exception {
+            JavaXMIResource.save(file, from.getUID());
+        }
+    },
+    /**
      * Represent the old Scicos text format.
      */
     COSF("cosf", XcosMessages.FILE_COSF) {
@@ -425,6 +441,7 @@ public enum XcosFileType {
         final Set<XcosFileType> values = EnumSet.noneOf(XcosFileType.class);
         values.add(XcosFileType.XCOS);
         values.add(XcosFileType.ZCOS);
+        values.add(XcosFileType.XMI);
         return values;
     }
 }
index c1069d5..5b46466 100644 (file)
@@ -255,6 +255,7 @@ public final class XcosMessages {
     public static final String FILE_COS = FILE_COSF;
     public static final String FILE_XCOS = Messages.gettext("Xcos file");
     public static final String FILE_ZCOS = Messages.gettext("Xcos (zip) file");
+    public static final String FILE_XMI = Messages.gettext("XMI (Eclipse EMF) file");
     public static final String FILE_SOD = Messages.gettext("Scilab Open Data file");
 
     /* Superblock mask editor */
diff --git a/scilab/modules/xcos/src/jni/JavaXMIResource.i b/scilab/modules/xcos/src/jni/JavaXMIResource.i
new file mode 100644 (file)
index 0000000..2756441
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2016 - Scilab Enterprises - Clement DAVID
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ */
+
+/*
+ * swig -java -c++ -directors -package org.scilab.modules.xcos -outdir src/java/org/scilab/modules/xcos/ src/jni/JavaXMIResource.i
+ * or make swig
+ */
+
+%module(director="0") JavaXMIResource;
+
+%{
+#include "utilities.hxx"
+#include "XMIResource.hxx"
+
+using namespace org_scilab_modules_scicos;
+%}
+typedef long long ScicosID;
+#define SCICOS_IMPEXP
+
+%inline %{
+inline int save(const char* uri, ScicosID id) {
+    return XMIResource(id).save(uri);
+}
+
+inline int load(const char* uri, ScicosID id) {
+    return XMIResource(id).load(uri);
+}
+%}
+
diff --git a/scilab/modules/xcos/src/jni/JavaXMIResource_wrap.cxx b/scilab/modules/xcos/src/jni/JavaXMIResource_wrap.cxx
new file mode 100644 (file)
index 0000000..aa81aae
--- /dev/null
@@ -0,0 +1,732 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 3.0.8
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+
+#ifndef SWIGJAVA
+#define SWIGJAVA
+#endif
+
+#define SWIG_DIRECTORS
+
+
+#ifdef __cplusplus
+/* SwigValueWrapper is described in swig.swg */
+template<typename T> class SwigValueWrapper {
+  struct SwigMovePointer {
+    T *ptr;
+    SwigMovePointer(T *p) : ptr(p) { }
+    ~SwigMovePointer() { delete ptr; }
+    SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+  } pointer;
+  SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+  SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+public:
+  SwigValueWrapper() : pointer(0) { }
+  SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
+  operator T&() const { return *pointer.ptr; }
+  T *operator&() { return pointer.ptr; }
+};
+
+template <typename T> T SwigValueInit() {
+  return T();
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ *  This section contains generic SWIG labels for method/variable
+ *  declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+#  define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#   define SWIGINLINE inline
+# else
+#   define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define SWIGUNUSED __attribute__ ((__unused__))
+#   else
+#     define SWIGUNUSED
+#   endif
+# elif defined(__ICC)
+#   define SWIGUNUSED __attribute__ ((__unused__))
+# else
+#   define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+#   define SWIGUNUSEDPARM(p)
+# else
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  ifndef GCC_HASCLASSVISIBILITY
+#    define GCC_HASCLASSVISIBILITY
+#  endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   if defined(STATIC_LINKED)
+#     define SWIGEXPORT
+#   else
+#     define SWIGEXPORT __declspec(dllexport)
+#   endif
+# else
+#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+#     define SWIGEXPORT __attribute__ ((visibility("default")))
+#   else
+#     define SWIGEXPORT
+#   endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   define SWIGSTDCALL __stdcall
+# else
+#   define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
+#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
+# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
+#endif
+
+/* Intel's compiler complains if a variable which was never initialised is
+ * cast to void, which is a common idiom which we use to indicate that we
+ * are aware a variable isn't used.  So we just silence that warning.
+ * See: https://github.com/swig/swig/issues/192 for more discussion.
+ */
+#ifdef __INTEL_COMPILER
+# pragma warning disable 592
+#endif
+
+
+/* Fix for jlong on some versions of gcc on Windows */
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+  typedef long long __int64;
+#endif
+
+/* Fix for jlong on 64-bit x86 Solaris */
+#if defined(__x86_64)
+# ifdef _LP64
+#   undef _LP64
+# endif
+#endif
+
+#include <jni.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Support for throwing Java exceptions */
+typedef enum {
+  SWIG_JavaOutOfMemoryError = 1, 
+  SWIG_JavaIOException, 
+  SWIG_JavaRuntimeException, 
+  SWIG_JavaIndexOutOfBoundsException,
+  SWIG_JavaArithmeticException,
+  SWIG_JavaIllegalArgumentException,
+  SWIG_JavaNullPointerException,
+  SWIG_JavaDirectorPureVirtual,
+  SWIG_JavaUnknownError
+} SWIG_JavaExceptionCodes;
+
+typedef struct {
+  SWIG_JavaExceptionCodes code;
+  const char *java_exception;
+} SWIG_JavaExceptions_t;
+
+
+static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
+  jclass excep;
+  static const SWIG_JavaExceptions_t java_exceptions[] = {
+    { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
+    { SWIG_JavaIOException, "java/io/IOException" },
+    { SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
+    { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
+    { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
+    { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
+    { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
+    { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
+    { SWIG_JavaUnknownError,  "java/lang/UnknownError" },
+    { (SWIG_JavaExceptionCodes)0,  "java/lang/UnknownError" }
+  };
+  const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
+
+  while (except_ptr->code != code && except_ptr->code)
+    except_ptr++;
+
+  jenv->ExceptionClear();
+  excep = jenv->FindClass(except_ptr->java_exception);
+  if (excep)
+    jenv->ThrowNew(excep, msg);
+}
+
+
+/* Contract support */
+
+#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else
+
+/* -----------------------------------------------------------------------------
+ * director_common.swg
+ *
+ * This file contains support for director classes which is common between
+ * languages.
+ * ----------------------------------------------------------------------------- */
+
+/*
+  Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the
+  'Swig' namespace. This could be useful for multi-modules projects.
+*/
+#ifdef SWIG_DIRECTOR_STATIC
+/* Force anonymous (static) namespace */
+#define Swig
+#endif
+/* -----------------------------------------------------------------------------
+ * director.swg
+ *
+ * This file contains support for director classes so that Java proxy
+ * methods can be called from C++.
+ * ----------------------------------------------------------------------------- */
+
+#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION)
+#include <iostream>
+#endif
+
+#include <exception>
+
+namespace Swig {
+
+  /* Java object wrapper */
+  class JObjectWrapper {
+  public:
+    JObjectWrapper() : jthis_(NULL), weak_global_(true) {
+    }
+
+    ~JObjectWrapper() {
+      jthis_ = NULL;
+      weak_global_ = true;
+    }
+
+    bool set(JNIEnv *jenv, jobject jobj, bool mem_own, bool weak_global) {
+      if (!jthis_) {
+        weak_global_ = weak_global || !mem_own; // hold as weak global if explicitly requested or not owned
+        if (jobj)
+          jthis_ = weak_global_ ? jenv->NewWeakGlobalRef(jobj) : jenv->NewGlobalRef(jobj);
+#if defined(DEBUG_DIRECTOR_OWNED)
+        std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> " << jthis_ << std::endl;
+#endif
+        return true;
+      } else {
+#if defined(DEBUG_DIRECTOR_OWNED)
+        std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> already set" << std::endl;
+#endif
+        return false;
+      }
+    }
+
+    jobject get(JNIEnv *jenv) const {
+#if defined(DEBUG_DIRECTOR_OWNED)
+      std::cout << "JObjectWrapper::get(";
+      if (jthis_)
+        std::cout << jthis_;
+      else
+        std::cout << "null";
+      std::cout << ") -> return new local ref" << std::endl;
+#endif
+      return (jthis_ ? jenv->NewLocalRef(jthis_) : jthis_);
+    }
+
+    void release(JNIEnv *jenv) {
+#if defined(DEBUG_DIRECTOR_OWNED)
+      std::cout << "JObjectWrapper::release(" << jthis_ << "): " << (weak_global_ ? "weak global ref" : "global ref") << std::endl;
+#endif
+      if (jthis_) {
+        if (weak_global_) {
+          if (jenv->IsSameObject(jthis_, NULL) == JNI_FALSE)
+            jenv->DeleteWeakGlobalRef((jweak)jthis_);
+        } else
+          jenv->DeleteGlobalRef(jthis_);
+      }
+
+      jthis_ = NULL;
+      weak_global_ = true;
+    }
+
+    /* Only call peek if you know what you are doing wrt to weak/global references */
+    jobject peek() {
+      return jthis_;
+    }
+
+    /* Java proxy releases ownership of C++ object, C++ object is now
+       responsible for destruction (creates NewGlobalRef to pin Java proxy) */
+    void java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) {
+      if (take_or_release) {  /* Java takes ownership of C++ object's lifetime. */
+        if (!weak_global_) {
+          jenv->DeleteGlobalRef(jthis_);
+          jthis_ = jenv->NewWeakGlobalRef(jself);
+          weak_global_ = true;
+        }
+      } else {
+       /* Java releases ownership of C++ object's lifetime */
+        if (weak_global_) {
+          jenv->DeleteWeakGlobalRef((jweak)jthis_);
+          jthis_ = jenv->NewGlobalRef(jself);
+          weak_global_ = false;
+        }
+      }
+    }
+
+  private:
+    /* pointer to Java object */
+    jobject jthis_;
+    /* Local or global reference flag */
+    bool weak_global_;
+  };
+
+  /* Local JNI reference deleter */
+  class LocalRefGuard {
+    JNIEnv *jenv_;
+    jobject jobj_;
+
+    // non-copyable
+    LocalRefGuard(const LocalRefGuard &);
+    LocalRefGuard &operator=(const LocalRefGuard &);
+  public:
+    LocalRefGuard(JNIEnv *jenv, jobject jobj): jenv_(jenv), jobj_(jobj) {}
+    ~LocalRefGuard() {
+      if (jobj_)
+        jenv_->DeleteLocalRef(jobj_);
+    }
+  };
+
+  /* director base class */
+  class Director {
+    /* pointer to Java virtual machine */
+    JavaVM *swig_jvm_;
+
+  protected:
+#if defined (_MSC_VER) && (_MSC_VER<1300)
+    class JNIEnvWrapper;
+    friend class JNIEnvWrapper;
+#endif
+    /* Utility class for managing the JNI environment */
+    class JNIEnvWrapper {
+      const Director *director_;
+      JNIEnv *jenv_;
+      int env_status;
+    public:
+      JNIEnvWrapper(const Director *director) : director_(director), jenv_(0), env_status(0) {
+#if defined(__ANDROID__)
+        JNIEnv **jenv = &jenv_;
+#else
+        void **jenv = (void **)&jenv_;
+#endif
+        env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2);
+#if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON)
+        // Attach a daemon thread to the JVM. Useful when the JVM should not wait for
+        // the thread to exit upon shutdown. Only for jdk-1.4 and later.
+        director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL);
+#else
+        director_->swig_jvm_->AttachCurrentThread(jenv, NULL);
+#endif
+      }
+      ~JNIEnvWrapper() {
+#if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD)
+        // Some JVMs, eg jdk-1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call.
+        // However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak.
+        if (env_status == JNI_EDETACHED)
+          director_->swig_jvm_->DetachCurrentThread();
+#endif
+      }
+      JNIEnv *getJNIEnv() const {
+        return jenv_;
+      }
+    };
+
+    /* Java object wrapper */
+    JObjectWrapper swig_self_;
+
+    /* Disconnect director from Java object */
+    void swig_disconnect_director_self(const char *disconn_method) {
+      JNIEnvWrapper jnienv(this) ;
+      JNIEnv *jenv = jnienv.getJNIEnv() ;
+      jobject jobj = swig_self_.get(jenv);
+      LocalRefGuard ref_deleter(jenv, jobj);
+#if defined(DEBUG_DIRECTOR_OWNED)
+      std::cout << "Swig::Director::disconnect_director_self(" << jobj << ")" << std::endl;
+#endif
+      if (jobj && jenv->IsSameObject(jobj, NULL) == JNI_FALSE) {
+        jmethodID disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(jobj), disconn_method, "()V");
+        if (disconn_meth) {
+#if defined(DEBUG_DIRECTOR_OWNED)
+          std::cout << "Swig::Director::disconnect_director_self upcall to " << disconn_method << std::endl;
+#endif
+          jenv->CallVoidMethod(jobj, disconn_meth);
+        }
+      }
+    }
+
+  public:
+    Director(JNIEnv *jenv) : swig_jvm_((JavaVM *) NULL), swig_self_() {
+      /* Acquire the Java VM pointer */
+      jenv->GetJavaVM(&swig_jvm_);
+    }
+
+    virtual ~Director() {
+      JNIEnvWrapper jnienv(this) ;
+      JNIEnv *jenv = jnienv.getJNIEnv() ;
+      swig_self_.release(jenv);
+    }
+
+    bool swig_set_self(JNIEnv *jenv, jobject jself, bool mem_own, bool weak_global) {
+      return swig_self_.set(jenv, jself, mem_own, weak_global);
+    }
+
+    jobject swig_get_self(JNIEnv *jenv) const {
+      return swig_self_.get(jenv);
+    }
+
+    // Change C++ object's ownership, relative to Java
+    void swig_java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) {
+      swig_self_.java_change_ownership(jenv, jself, take_or_release);
+    }
+  };
+
+  // Zero initialized bool array
+  template<size_t N> class BoolArray {
+    bool array_[N];
+  public:
+    BoolArray() {
+      memset(array_, 0, sizeof(array_));
+    }
+    bool& operator[](size_t n) {
+      return array_[n];
+    }
+    bool operator[](size_t n) const {
+      return array_[n];
+    }
+  };
+
+  // Utility classes and functions for exception handling.
+
+  // Simple holder for a Java string during exception handling, providing access to a c-style string
+  class JavaString {
+  public:
+    JavaString(JNIEnv *jenv, jstring jstr) : jenv_(jenv), jstr_(jstr), cstr_(0) {
+      if (jenv_ && jstr_)
+       cstr_ = (const char *) jenv_->GetStringUTFChars(jstr_, NULL);
+    }
+
+    ~JavaString() {
+      if (jenv_ && jstr_ && cstr_)
+       jenv_->ReleaseStringUTFChars(jstr_, cstr_);
+    }
+
+    const char *c_str(const char *null_string = "null JavaString") const {
+      return cstr_ ? cstr_ : null_string;
+    }
+
+  private:
+    // non-copyable
+    JavaString(const JavaString &);
+    JavaString &operator=(const JavaString &);
+
+    JNIEnv *jenv_;
+    jstring jstr_;
+    const char *cstr_;
+  };
+
+  // Helper class to extract the exception message from a Java throwable
+  class JavaExceptionMessage {
+  public:
+    JavaExceptionMessage(JNIEnv *jenv, jthrowable throwable) : message_(jenv, exceptionMessageFromThrowable(jenv, throwable)) {
+    }
+
+    const char *message() const {
+      return message_.c_str("Could not get exception message in JavaExceptionMessage");
+    }
+
+  private:
+    // non-copyable
+    JavaExceptionMessage(const JavaExceptionMessage &);
+    JavaExceptionMessage &operator=(const JavaExceptionMessage &);
+
+    // Get exception message by calling Java method Throwable.getMessage()
+    static jstring exceptionMessageFromThrowable(JNIEnv *jenv, jthrowable throwable) {
+      jstring jmsg = NULL;
+      if (jenv && throwable) {
+       jenv->ExceptionClear(); // Cannot invoke methods with any pending exceptions
+       jclass throwclz = jenv->GetObjectClass(throwable);
+       if (throwclz) {
+         // All Throwable classes have a getMessage() method, so call it to extract the exception message
+         jmethodID getMessageMethodID = jenv->GetMethodID(throwclz, "getMessage", "()Ljava/lang/String;");
+         if (getMessageMethodID)
+           jmsg = (jstring)jenv->CallObjectMethod(throwable, getMessageMethodID);
+       }
+       if (jmsg == NULL && jenv->ExceptionCheck())
+         jenv->ExceptionClear();
+      }
+      return jmsg;
+    }
+
+    JavaString message_;
+  };
+
+  // C++ Exception class for handling Java exceptions thrown during a director method Java upcall
+  class DirectorException : public std::exception {
+  public:
+
+    // Construct exception from a Java throwable
+    DirectorException(JNIEnv *jenv, jthrowable throwable) : classname_(0), msg_(0) {
+
+      // Call Java method Object.getClass().getName() to obtain the throwable's class name (delimited by '/')
+      if (throwable) {
+       jclass throwclz = jenv->GetObjectClass(throwable);
+       if (throwclz) {
+         jclass clzclz = jenv->GetObjectClass(throwclz);
+         if (clzclz) {
+           jmethodID getNameMethodID = jenv->GetMethodID(clzclz, "getName", "()Ljava/lang/String;");
+           if (getNameMethodID) {
+             jstring jstr_classname = (jstring)(jenv->CallObjectMethod(throwclz, getNameMethodID));
+              // Copy strings, since there is no guarantee that jenv will be active when handled
+              if (jstr_classname) {
+                JavaString jsclassname(jenv, jstr_classname);
+                const char *classname = jsclassname.c_str(0);
+                if (classname)
+                  classname_ = copypath(classname);
+              }
+           }
+         }
+       }
+      }
+
+      JavaExceptionMessage exceptionmsg(jenv, throwable);
+      msg_ = copystr(exceptionmsg.message());
+    }
+
+    // More general constructor for handling as a java.lang.RuntimeException
+    DirectorException(const char *msg) : classname_(0), msg_(copystr(msg ? msg : "Unspecified DirectorException message")) {
+    }
+
+    ~DirectorException() throw() {
+      delete[] classname_;
+      delete[] msg_;
+    }
+
+    const char *what() const throw() {
+      return msg_;
+    }
+
+    // Reconstruct and raise/throw the Java Exception that caused the DirectorException
+    // Note that any error in the JNI exception handling results in a Java RuntimeException
+    void raiseJavaException(JNIEnv *jenv) const {
+      if (jenv) {
+       jenv->ExceptionClear();
+
+       jmethodID ctorMethodID = 0;
+       jclass throwableclass = 0;
+        if (classname_) {
+          throwableclass = jenv->FindClass(classname_);
+          if (throwableclass)
+            ctorMethodID = jenv->GetMethodID(throwableclass, "<init>", "(Ljava/lang/String;)V");
+       }
+
+       if (ctorMethodID) {
+         jenv->ThrowNew(throwableclass, what());
+       } else {
+         SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, what());
+       }
+      }
+    }
+
+  private:
+    static char *copypath(const char *srcmsg) {
+      char *target = copystr(srcmsg);
+      for (char *c=target; *c; ++c) {
+        if ('.' == *c)
+          *c = '/';
+      }
+      return target;
+    }
+
+    static char *copystr(const char *srcmsg) {
+      char *target = 0;
+      if (srcmsg) {
+       size_t msglen = strlen(srcmsg) + 1;
+       target = new char[msglen];
+       strncpy(target, srcmsg, msglen);
+      }
+      return target;
+    }
+
+    const char *classname_;
+    const char *msg_;
+  };
+
+  // Helper method to determine if a Java throwable matches a particular Java class type
+  SWIGINTERN bool ExceptionMatches(JNIEnv *jenv, jthrowable throwable, const char *classname) {
+    bool matches = false;
+
+    if (throwable && jenv && classname) {
+      // Exceptions need to be cleared for correct behavior.
+      // The caller of ExceptionMatches should restore pending exceptions if desired -
+      // the caller already has the throwable.
+      jenv->ExceptionClear();
+
+      jclass clz = jenv->FindClass(classname);
+      if (clz) {
+       jclass classclz = jenv->GetObjectClass(clz);
+       jmethodID isInstanceMethodID = jenv->GetMethodID(classclz, "isInstance", "(Ljava/lang/Object;)Z");
+       if (isInstanceMethodID) {
+         matches = jenv->CallBooleanMethod(clz, isInstanceMethodID, throwable) != 0;
+       }
+      }
+
+#if defined(DEBUG_DIRECTOR_EXCEPTION)
+      if (jenv->ExceptionCheck()) {
+        // Typically occurs when an invalid classname argument is passed resulting in a ClassNotFoundException
+        JavaExceptionMessage exc(jenv, jenv->ExceptionOccurred());
+        std::cout << "Error: ExceptionMatches: class '" << classname << "' : " << exc.message() << std::endl;
+      }
+#endif
+    }
+    return matches;
+  }
+}
+
+
+#include "utilities.hxx"
+#include "XMIResource.hxx"
+
+using namespace org_scilab_modules_scicos;
+
+
+inline int save(const char* uri, ScicosID id) {
+    return XMIResource(id).save(uri);
+}
+
+inline int load(const char* uri, ScicosID id) {
+    return XMIResource(id).load(uri);
+}
+
+
+
+/* ---------------------------------------------------
+ * C++ director class methods
+ * --------------------------------------------------- */
+
+#include "JavaXMIResource_wrap.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SWIGEXPORT jint JNICALL Java_org_scilab_modules_xcos_JavaXMIResourceJNI_save(JNIEnv *jenv, jclass jcls, jstring jarg1, jlong jarg2) {
+  jint jresult = 0 ;
+  char *arg1 = (char *) 0 ;
+  ScicosID arg2 ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
+    if (!arg1) return 0;
+  }
+  arg2 = (ScicosID)jarg2; 
+  result = (int)save((char const *)arg1,arg2);
+  jresult = (jint)result; 
+  if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_scilab_modules_xcos_JavaXMIResourceJNI_load(JNIEnv *jenv, jclass jcls, jstring jarg1, jlong jarg2) {
+  jint jresult = 0 ;
+  char *arg1 = (char *) 0 ;
+  ScicosID arg2 ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
+    if (!arg1) return 0;
+  }
+  arg2 = (ScicosID)jarg2; 
+  result = (int)load((char const *)arg1,arg2);
+  jresult = (jint)result; 
+  if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
+  return jresult;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/scilab/modules/xcos/src/jni/JavaXMIResource_wrap.h b/scilab/modules/xcos/src/jni/JavaXMIResource_wrap.h
new file mode 100644 (file)
index 0000000..9a5bd77
--- /dev/null
@@ -0,0 +1,15 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 3.0.8
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#ifndef SWIG_JavaXMIResource_WRAP_H_
+#define SWIG_JavaXMIResource_WRAP_H_
+
+
+#endif