From b542369263782dc8b85893e218119ed070efa7b3 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Thu, 3 Jul 2014 03:10:03 +0200 Subject: Got ready for cmake3 and some minor fixes --- CMakeLists.txt | 14 +-- README.md | 19 ++- contrib/cmake/FindCURLPP.cmake | 20 --- docs/BUILDING.md | 136 ++++++++++++++++++--- docs/CentOS.md | 47 ------- docs/CentOS.txt | 47 +++++++ docs/Ubuntu-LTS.md | 44 ------- docs/Ubuntu-LTS.txt | 44 +++++++ embedding/csharp/uSCXMLEmbedding.suo | Bin 30208 -> 37376 bytes .../uSCXMLEmbedding/Extensions/CustomDataModel.cs | 4 +- .../Extensions/CustomExecutableContent.cs | 4 +- .../uSCXMLEmbedding/Extensions/CustomIOProc.cs | 36 +++++- .../uSCXMLEmbedding/Extensions/CustomInvoker.cs | 20 +-- embedding/csharp/uSCXMLEmbedding/RunTests.cs | 39 +++--- .../datamodel/ecmascript/ECMAScriptDataModel.java | 21 ++-- .../tests/execContent/TestCustomExecContent.java | 4 +- .../uscxml/tests/invoker/TestCustomInvoker.java | 5 +- .../uscxml/tests/ioprocessor/TestCustomIOProc.java | 3 +- src/bindings/CMakeLists.txt | 5 + src/bindings/swig/csharp/CMakeLists.txt | 3 +- src/bindings/swig/csharp/uscxml.i | 57 +++++++++ src/bindings/swig/java/uscxml.i | 57 +++++++++ src/bindings/swig/uscxml_beautify.i | 52 +------- src/bindings/swig/wrapped/WrappedIOProcessor.h | 2 +- src/uscxml/Factory.cpp | 2 +- src/uscxml/Interpreter.cpp | 25 ++-- src/uscxml/Interpreter.h | 2 +- src/uscxml/interpreter/InterpreterDraft6.cpp | 6 +- src/uscxml/messages/SendRequest.h | 2 +- .../plugins/datamodel/xpath/XPathDataModel.cpp | 2 +- test/src/test-lifecycle.cpp | 114 ++++++++--------- test/w3c/confEcma.xsl | 17 ++- test/w3c/confXPath.xsl | 17 ++- test/w3c/ecma/test252.scxml | 4 +- test/w3c/ecma/test343.scxml | 2 +- test/w3c/ecma/test354.scxml | 4 +- test/w3c/ecma/test487.scxml | 3 +- test/w3c/ecma/test553.scxml | 4 +- test/w3c/ecma/test554.scxml | 4 +- test/w3c/txml/test252.txml | 4 +- test/w3c/txml/test343.txml | 2 +- test/w3c/txml/test354.txml | 4 +- test/w3c/txml/test487.txml | 3 +- test/w3c/txml/test553.txml | 4 +- test/w3c/txml/test554.txml | 4 +- test/w3c/xpath/test252.scxml | 4 +- test/w3c/xpath/test343.scxml | 2 +- test/w3c/xpath/test354.scxml | 4 +- test/w3c/xpath/test487.scxml | 3 +- test/w3c/xpath/test553.scxml | 4 +- test/w3c/xpath/test554.scxml | 4 +- 51 files changed, 593 insertions(+), 340 deletions(-) delete mode 100644 contrib/cmake/FindCURLPP.cmake delete mode 100644 docs/CentOS.md create mode 100644 docs/CentOS.txt delete mode 100644 docs/Ubuntu-LTS.md create mode 100644 docs/Ubuntu-LTS.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a26928..2de5bee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,8 +149,8 @@ if(CMAKE_CROSSCOMPILING) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "BOTH") SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "BOTH") SET(USCXML_PREBUILT_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/contrib/prebuilt/android/${ANDROID_ABI}") - LIST(APPEND CMAKE_FIND_ROOT_PATH "/usr/local/bin") # this is needed to find swig - LIST(APPEND CMAKE_FIND_ROOT_PATH "/opt/local/bin") # this is needed to find protoc + LIST(APPEND CMAKE_PREFIX_PATH "/usr/local/bin") # this is needed to find swig + LIST(APPEND CMAKE_PREFIX_PATH "/opt/local/bin") # this is needed to find protoc endif () else () # SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "BOTH") @@ -265,19 +265,20 @@ endif() if (CMAKE_CROSSCOMPILING) # always prefer prebuilt libraries for cross-compiling OPTION(BUILD_PREFER_PREBUILT_LIBS "Search libraries in contrib/prebuilt first" ON) - SET(CMAKE_FIND_ROOT_PATH "${USCXML_PREBUILT_LIBRARY_PATH};${USCXML_PREBUILT_HEADER_PATH};${CMAKE_FIND_ROOT_PATH}") + SET(CMAKE_PREFIX_PATH "${USCXML_PREBUILT_LIBRARY_PATH};${USCXML_PREBUILT_HEADER_PATH};${CMAKE_PREFIX_PATH}") else() OPTION(BUILD_PREFER_PREBUILT_LIBS "Search libraries in contrib/prebuilt first" ON) if (BUILD_PREFER_PREBUILT_LIBS) # for everything, we start our search in contrib/prebuilt - SET(CMAKE_FIND_ROOT_PATH "${USCXML_PREBUILT_LIBRARY_PATH};${USCXML_PREBUILT_HEADER_PATH};${CMAKE_FIND_ROOT_PATH}") + SET(CMAKE_PREFIX_PATH "${USCXML_PREBUILT_LIBRARY_PATH};${USCXML_PREBUILT_HEADER_PATH};${CMAKE_PREFIX_PATH}") else() # using this trick, we search paths from find_* before CMAKE_FIND_ROOT_PATH as '/' is prepended first - SET(CMAKE_FIND_ROOT_PATH "/;${CMAKE_FIND_ROOT_PATH};${USCXML_PREBUILT_LIBRARY_PATH};${USCXML_PREBUILT_HEADER_PATH}") + SET(CMAKE_PREFIX_PATH "/;${CMAKE_PREFIX_PATH};${USCXML_PREBUILT_LIBRARY_PATH};${USCXML_PREBUILT_HEADER_PATH}") endif() endif() include_directories(${USCXML_PREBUILT_LIBRARY_PATH}/include) +#set(CMAKE_PREFIX_PATH ${CMAKE_FIND_ROOT_PATH}) #message(STATUS "Searching for prebuilt libraries in: ${CMAKE_FIND_ROOT_PATH}") if (WIN32) @@ -351,6 +352,7 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") add_definitions(-Wall) # add_definitions(-Wno-parentheses-equality) add_definitions(-Wno-attributes) + add_definitions(-Wno-unused-variable) # we cannot tread warning as error with the "narrowing problem" # add_definitions(-Werror) @@ -358,8 +360,6 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") if(GCC_VERSION VERSION_EQUAL 4.7 OR GCC_VERSION VERSION_GREATER 4.7) # when compiling as C++11, narrowing is a warning but older compilers complain about the option add_definitions(-Wno-narrowing) - # recent gcc started to complain about unused globals - add_definitions(-Wno-unused-variable) endif() if(GCC_VERSION VERSION_EQUAL 4.8 OR GCC_VERSION VERSION_GREATER 4.8) diff --git a/README.md b/README.md index 1e18c5f..f0a9ea2 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,18 @@ uSCXML still fails the following ecmascript tests: + + + + + + + + + + + + @@ -128,7 +140,12 @@ internal phase is reached. ## Embedding uSCXML -There are bindings for Java and C# with some examples in the embedding directory. +There are bindings for Java and C# with some examples in the embedding directory. The bindings consist of +two parts each (i) the C++ uscxml interpreter compiled as a loadable module for the target language and (ii) a target +language specific module (uscxml.jar / uscxmlCSharp.dll) with the wrapper classes. The first one is loaded by the +target language (System.loadLibrary / SetDLLDirectory) while the second is to be included in your actual project. +Have a look at the examples in embedding and adapt the paths to reflect your setup. See the [build +instructions](https://github.com/tklab-tud/uscxml/blob/master/docs/BUILDING.md) for details on how to build these. ## Extending uSCXML diff --git a/contrib/cmake/FindCURLPP.cmake b/contrib/cmake/FindCURLPP.cmake deleted file mode 100644 index 853265d..0000000 --- a/contrib/cmake/FindCURLPP.cmake +++ /dev/null @@ -1,20 +0,0 @@ -FIND_PATH(CURLPP_INCLUDE_DIR curlpp/cURLpp.hpp - PATH_SUFFIXES include - PATHS - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - HINTS $ENV{CURLPP_SRC} -) - -FIND_LIBRARY(CURLPP_LIBRARY - NAMES curlpp - HINTS $ENV{CURLPP_SRC}/.libs/ -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURLPP DEFAULT_MSG CURLPP_LIBRARY CURLPP_INCLUDE_DIR) -MARK_AS_ADVANCED(CURLPP_LIBRARY CURLPP_INCLUDE_DIR) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 01a52d7..fb87943 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -12,19 +12,27 @@ essentially the same on every platform: in <USCXML_SRC>/build/. 4. Run cmake (or ccmake / CMake-GUI) to create the files required by your actual build-system. 5. Use your actual build-system or development environment to build uscxml. -6. Read the SCXML draft and have a look at the tests to get started. +6. Optionally build the [language bindings](#language-bindings) to embed the SCXML interpreter in another language. +7. Read the SCXML draft and have a look at the tests to get started. If you want to build for another IDE or build-system, just create a new -*out-of-source* build directory and start over with cmake. To get an idea of +*out-of-source* build directory and start over with CMake. To get an idea of supported IDEs and build-environments on your platform, type cmake --help or run the CMake-GUI and look for the *Generators* section at the end of the output. Default on Unices is Makefiles. +Note: If you plan to use Eclipse CDT, you cannot have a build directory anywhere under +the source directory - just create the build directory anywhere else. This only applies to the Eclipse CDT +project generator. + +Note: You cannot build the language bindings with the Visual Studio project as it croaks when calling SWIG, +just have another build directory with the "NMake Makefiles" project generator. + # Build Dependencies Overview of the uscxml dependencies. See the [Platform Notes](#platform-notes) for details. -Note: We download pre-compiled versions of most dependencies at cmake configure-time. If you want +Note: We download pre-compiled versions of most dependencies at CMake configure-time. If you want to provide you own libraries, remove them from <USCXML_SRC>/contrib/prebuilt/ and provide your own. @@ -36,11 +44,15 @@ your own. + + + + - + @@ -110,7 +122,7 @@ This section will detail the preparation of the respective platforms to ultimate ## Mac OSX -You will have to install cmake via Macports: +You will have to install CMake via Macports: sudo port install cmake @@ -126,9 +138,9 @@ Just download the source and invoke CMake to create Makefiles or a Xcode project -- Build files have been written to: .../build/cli $ make -You can test whether everything works by starting the mmi-browser with a test.scxml file: +You can test whether everything works by starting the uscxml-browser with a test.scxml file: - $ ./bin/mmi-browser ../../test/samples/uscxml/test-ecmascript.scxml + $ ./bin/uscxml-browser ../../test/uscxml/test-ecmascript.scxml ### Xcode @@ -157,7 +169,7 @@ This would be all distributions based on Debian, like Ubuntu, Linux Mint and the $ sudo apt-get install libxml2-dev libcurl4-openssl-dev There may still be packages missing due to the set of dependencies among packages -in the various distributons. Try to run cmake and resolve dependencies until you +in the various distributons. Try to run CMake and resolve dependencies until you are satisfied. ### Preparing *yum based* distributions @@ -214,34 +226,28 @@ Instructions are a literal copy of building uscxml for MacOSX on the console fro -- Build files have been written to: .../build/cli $ make -You can test whether everything works by starting the mmi-browser with a test.scxml file: +You can test whether everything works by starting the uscxml-browser with a test.scxml file: - $ ./bin/mmi-browser ../../test/samples/uscxml/test-ecmascript.scxml + $ ./bin/uscxml-browser ../../test/uscxml/test-ecmascript.scxml ### Eclipse CDT Note: Eclipse does not like the project to be a subdirectory in the source. You have to choose your build directory with the generated project accordingly. - $ mkdir -p build/uscxml/eclipse && cd build/uscxml/eclipse + $ mkdir -p ~/Desktop/build/uscxml/eclipse && cd ~/Desktop/build/uscxml/eclipse $ cmake -G "Eclipse CDT4 - Unix Makefiles" [...] -- Build files have been written to: .../build/uscxml/eclipse Now open Eclipse CDT and import the out-of-source directory as an existing project into workspace, leaving the "Copy projects into workspace" checkbox unchecked. There are some more [detailed instruction](http://www.cmake.org/Wiki/Eclipse_CDT4_Generator) available -in the cmake wiki as well. - -### Compiling Dependencies - -If the packages in your distribution are too old, you will have to compile current -binaries. This applies especially for SWI and CMake as they *need* to be rather -current. Have a look at the build dependencies above for minimum versions. +in the CMake wiki as well. ## Windows -Building from source on windows is somewhat more involved and instructions are necessarily in prose form. These instructions were -created using Windows 7 and MS Visual Studio 2010. +Building from source on windows is somewhat more involved and instructions are necessarily in prose form. These +instructions were created using Windows 7 and MS Visual Studio 2010. ### Prepare compilation @@ -262,3 +268,93 @@ Just open it up to continue in your IDE. Note: We only tested with the MSVC compiler. You can try to compile with MinGW but you would have to build all the dependent libraries as well. +Note: We do no provide prebuilt dependencies for MSVC18.x (Visual Studio 2012 / 2013). +You can still use the bindings for C#, but not the native C++ libraries. + +## Language Bindings + +In order to build any language bindings, you will need to have SWIG and the development kit of your target language +installed. The set of available language bindings is printed at the end of the CMake invocation: + + $ cmake + ... + -- Available custom elements ...... : respond file postpone fetch + -- Available language bindings .... : csharp java + -- General information: + ... + +### Java + +We are relying on CMake's [FindJNI.CMake](http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:FindJNI) module +to find the JNI headers and respective libraries. On unices, it's easiest to check whether jni.h is available +in JAVA_HOME: + + $ find $JAVA_HOME -name jni.h + /usr/lib/jvm/java-7-openjdk-i386/include/jni.h + +In addition, you will need apache's ant in the path or in $ENV{ANT_HOME}/bin: + + $ ant -version + Apache Ant(TM) version 1.8.2 compiled on September 22 2011 + +If both of these are given, you ought to get java as an available language binding and a new target called +java for your build system. If you used plain Makefiles (default on unices), you will get everything you need via: + + $ make && make java + $ ls lib/*.jnilib lib/*.jar + lib/libuscxmlNativeJava64.jnilib lib/uscxml.jar + +The uscxml.jar is to be added to your project's classpath, while the libuscxmlNativeJava64.jnilib +(or .so, .dll) needs to be loaded once via System.load() before you can use native objects. + +### CSharp + +For the CSharp bindings, we need to find either csc.exe from the Microsoft.NET framework or dmcs +from the mono project. We search the following places for these: + + $ENV{CSC_HOME}; $ENV{DMCS_HOME} + "C:/Windows/Microsoft.NET/Framework/v3.5" + "C:/Windows/Microsoft.NET/Framework/v4.0.30319" + +If we find one of those binaries (and SWIG obviously), we will enable the language bindings. + + $ which dmcs + /opt/local/bin/dmcs + +Again, if you used plain Makefiles, you will get everything you need via: + + $ make && make csharp + $ $ find lib -type f -iname *csharp* + lib/csharp/libuscxmlNativeCSharp.so + lib/uscxmlCSharp.dll + +The libuscxmlNativeCSharp.so has to be available to your C# runtime, either by installing it in +/usr/local/lib or (preferred) by using LD_PRELOAD or SetDllDirectory. See the +embedding examples. The uscxmlCSharp.dll contains the managed code portion and needs to be added +to your C# project as a reference. + +Note: You cannot use uSCXML with Xamarin Studio / Mono on Mac out of the box, as they still +have no 64Bit support. The last Macintosh without 64Bit support was the (late 2006) Mac Mini with an Intel Core Duo. + +### Important Note for Windows + +You cannot use CMake projects generated for Visual Studio to build the target language specific part of the +various bindings - you have to use nmake at a command prompt. Open a Visual Studio [x64 Win64] +Command Prompt (2010) and type: + + > cd c:\path\to\build\dir + > cmake -G"NMake Makefiles" c:\path\to\uscxml\source + ... + > nmake && nmake csharp && nmake java + ... + +## About 32/64Bit Support + +We do support both, 32 and 64Bit for Linux and Windows. On Macintosh, most prebuilt dependencies are compiled as +universal binaries with 32/64Bit but we build 64Bit binaries exclusively. The reason is that e.g. curl +cannot be compiled as a universal binary as its header files make assumptions about the bit-depth of an int. +Furthermore, most libraries used by invokers and provided by brew or Macports will be 64Bit only and fail to link. + +If you feel adventurous, you can uncomment set(CMAKE_OSX_ARCHITECTURES "i386;x86_64") in the topmost +CMakeLists.txt and fight your way through the linker errors. + \ No newline at end of file diff --git a/docs/CentOS.md b/docs/CentOS.md deleted file mode 100644 index 8a3424e..0000000 --- a/docs/CentOS.md +++ /dev/null @@ -1,47 +0,0 @@ -Install CentOS -Minimal Profile -sudo yum install wget -sudo yum groupinstall "Development tools" - - -$ wget http://sourceforge.net/projects/boost/files/latest/download -$ tar xvjf boost* -$ cd boost* -$ ./bootstrap.sh -$ sudo ./b2 --layout=tagged install - -sudo yum install libtool-ltdl-devel libxml2-devel libpng-devel libjpeg-devel libtiff-devel libcurl-devel mesa-libGL-devel pcre-devel -sudo yum remove swig - -$ wget http://sourceforge.net/projects/openvrml/files/latest/download -$ tar xvjf openvrml* -$ cd openvrml* -$ ./configure --disable-render-text-node --disable-script-node-javascript --disable-script-node-java --disable-gl-renderer --disable-xembed --disable-player --disable-examples --disable-mozilla-plugin -$ sudo make install - -$ wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz -$ tar xvzf cmake-2.8.10.2.tar.gz -$ cd cmake-2.8.10 -$ ./configure -$ make install - -$ svn co http://www.openscenegraph.org/svn/osg/OpenSceneGraph/tags/OpenSceneGraph-3.1.5 OpenSceneGraph -$ cd OpenSceneGraph -$ mkdir build && cd build -$ cmake .. -$ make -j4 -$ sudo make install - -$ wget http://sourceforge.net/projects/swig/files/latest/download -$ tar xvjf swig* -$ cd swig* -$ ./configure -$ make -$ make install - -$ git clone git://github.com/tklab-tud/uscxml.git -$ cd uscxml -$ mkdir build && cd build -$ cmake .. -$ make - diff --git a/docs/CentOS.txt b/docs/CentOS.txt new file mode 100644 index 0000000..8a3424e --- /dev/null +++ b/docs/CentOS.txt @@ -0,0 +1,47 @@ +Install CentOS +Minimal Profile +sudo yum install wget +sudo yum groupinstall "Development tools" + + +$ wget http://sourceforge.net/projects/boost/files/latest/download +$ tar xvjf boost* +$ cd boost* +$ ./bootstrap.sh +$ sudo ./b2 --layout=tagged install + +sudo yum install libtool-ltdl-devel libxml2-devel libpng-devel libjpeg-devel libtiff-devel libcurl-devel mesa-libGL-devel pcre-devel +sudo yum remove swig + +$ wget http://sourceforge.net/projects/openvrml/files/latest/download +$ tar xvjf openvrml* +$ cd openvrml* +$ ./configure --disable-render-text-node --disable-script-node-javascript --disable-script-node-java --disable-gl-renderer --disable-xembed --disable-player --disable-examples --disable-mozilla-plugin +$ sudo make install + +$ wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz +$ tar xvzf cmake-2.8.10.2.tar.gz +$ cd cmake-2.8.10 +$ ./configure +$ make install + +$ svn co http://www.openscenegraph.org/svn/osg/OpenSceneGraph/tags/OpenSceneGraph-3.1.5 OpenSceneGraph +$ cd OpenSceneGraph +$ mkdir build && cd build +$ cmake .. +$ make -j4 +$ sudo make install + +$ wget http://sourceforge.net/projects/swig/files/latest/download +$ tar xvjf swig* +$ cd swig* +$ ./configure +$ make +$ make install + +$ git clone git://github.com/tklab-tud/uscxml.git +$ cd uscxml +$ mkdir build && cd build +$ cmake .. +$ make + diff --git a/docs/Ubuntu-LTS.md b/docs/Ubuntu-LTS.md deleted file mode 100644 index df687ab..0000000 --- a/docs/Ubuntu-LTS.md +++ /dev/null @@ -1,44 +0,0 @@ -Install Ubuntu LTS 12 - -For core functionality without fancy plugins: - -$ sudo apt-get install cmake build-essential libxml2-dev libcurl4-openssl-dev - -For OpenSceneGraph invoker (version in repositories lacks vrml plugin): - -$ sudo apt-get install libpng12-dev libjpeg-dev libboost-all-dev libltdl-dev -$ sudo apt-get install libopenscenegraph-dev # just for the dependencies -$ sudo apt-get remove libopenscenegraph-dev - -$ wget http://sourceforge.net/projects/openvrml/files/latest/download -$ tar xvjf openvrml* -$ cd openvrml* -$ ./configure --disable-render-text-node --disable-script-node-javascript --disable-script-node-java --disable-gl-renderer --disable-xembed --disable-player --disable-examples --disable-mozilla-plugin -$ sudo make install -$ cd .. - -for mavericks: -PNG_CFLAGS="-I/opt/local/include" PNG_LIBS="-L/opt/local/lib" XML_CFLAGS="-I`xcrun --show-sdk-path`/usr/include/libxml2" XML_LIBS="-L`xcrun --show-sdk-path`/usr/lib" CPPFLAGS="--sysroot=`xcrun --show-sdk-path` -I/opt/local/include -I`xcrun --show-sdk-path`/usr/include/libxml2" LDFLAGS="--sysroot=`xcrun --show-sdk-path` -L/opt/local/lib -lboost_system-mt -lxml2 -lpng" ./configure --disable-render-text-node --disable-script-node-javascript --disable-script-node-java --disable-gl-renderer --disable-xembed --disable-player --disable-examples --disable-mozilla-plugin - - -$ sudo apt-get install git -$ git clone https://github.com/openscenegraph/osg -$ cd osg -$ nano src/osgPlugins/vrml/IndexedFaceSet.cpp # Edit line 207 and remove the else block - -$ mkdir build && cd build -$ cmake .. -$ make -j4 -$ sudo make install - -For ffmpeg invoker: - -Follow http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide for a version of recent version of ffmpeg -on ubuntu. The various libav* packages that come with the distribution are inadequate. - -Install uscxml: -$ git clone https://github.com/tklab-tud/uscxml.git -$ cd uscxml -$ mkdir build && cd build -$ cmake .. -$ make \ No newline at end of file diff --git a/docs/Ubuntu-LTS.txt b/docs/Ubuntu-LTS.txt new file mode 100644 index 0000000..df687ab --- /dev/null +++ b/docs/Ubuntu-LTS.txt @@ -0,0 +1,44 @@ +Install Ubuntu LTS 12 + +For core functionality without fancy plugins: + +$ sudo apt-get install cmake build-essential libxml2-dev libcurl4-openssl-dev + +For OpenSceneGraph invoker (version in repositories lacks vrml plugin): + +$ sudo apt-get install libpng12-dev libjpeg-dev libboost-all-dev libltdl-dev +$ sudo apt-get install libopenscenegraph-dev # just for the dependencies +$ sudo apt-get remove libopenscenegraph-dev + +$ wget http://sourceforge.net/projects/openvrml/files/latest/download +$ tar xvjf openvrml* +$ cd openvrml* +$ ./configure --disable-render-text-node --disable-script-node-javascript --disable-script-node-java --disable-gl-renderer --disable-xembed --disable-player --disable-examples --disable-mozilla-plugin +$ sudo make install +$ cd .. + +for mavericks: +PNG_CFLAGS="-I/opt/local/include" PNG_LIBS="-L/opt/local/lib" XML_CFLAGS="-I`xcrun --show-sdk-path`/usr/include/libxml2" XML_LIBS="-L`xcrun --show-sdk-path`/usr/lib" CPPFLAGS="--sysroot=`xcrun --show-sdk-path` -I/opt/local/include -I`xcrun --show-sdk-path`/usr/include/libxml2" LDFLAGS="--sysroot=`xcrun --show-sdk-path` -L/opt/local/lib -lboost_system-mt -lxml2 -lpng" ./configure --disable-render-text-node --disable-script-node-javascript --disable-script-node-java --disable-gl-renderer --disable-xembed --disable-player --disable-examples --disable-mozilla-plugin + + +$ sudo apt-get install git +$ git clone https://github.com/openscenegraph/osg +$ cd osg +$ nano src/osgPlugins/vrml/IndexedFaceSet.cpp # Edit line 207 and remove the else block + +$ mkdir build && cd build +$ cmake .. +$ make -j4 +$ sudo make install + +For ffmpeg invoker: + +Follow http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide for a version of recent version of ffmpeg +on ubuntu. The various libav* packages that come with the distribution are inadequate. + +Install uscxml: +$ git clone https://github.com/tklab-tud/uscxml.git +$ cd uscxml +$ mkdir build && cd build +$ cmake .. +$ make \ No newline at end of file diff --git a/embedding/csharp/uSCXMLEmbedding.suo b/embedding/csharp/uSCXMLEmbedding.suo index 9bacedf..823eecc 100644 Binary files a/embedding/csharp/uSCXMLEmbedding.suo and b/embedding/csharp/uSCXMLEmbedding.suo differ diff --git a/embedding/csharp/uSCXMLEmbedding/Extensions/CustomDataModel.cs b/embedding/csharp/uSCXMLEmbedding/Extensions/CustomDataModel.cs index b2ee1de..65e517a 100644 --- a/embedding/csharp/uSCXMLEmbedding/Extensions/CustomDataModel.cs +++ b/embedding/csharp/uSCXMLEmbedding/Extensions/CustomDataModel.cs @@ -10,7 +10,9 @@ namespace embedding { public override DataModel create(Interpreter interpreter) { - return new CustomDataModel(); + CustomDataModel dm = new CustomDataModel(); + dm.swigCMemOwn = false; + return dm; } public override void eval(string scriptElem, string expr) diff --git a/embedding/csharp/uSCXMLEmbedding/Extensions/CustomExecutableContent.cs b/embedding/csharp/uSCXMLEmbedding/Extensions/CustomExecutableContent.cs index 94cf111..ac79065 100644 --- a/embedding/csharp/uSCXMLEmbedding/Extensions/CustomExecutableContent.cs +++ b/embedding/csharp/uSCXMLEmbedding/Extensions/CustomExecutableContent.cs @@ -25,7 +25,9 @@ namespace embedding public override ExecutableContent create(Interpreter interpreter) { - return new CustomExecutableContent(); + CustomExecutableContent execContent = new CustomExecutableContent(); + execContent.swigCMemOwn = false; + return execContent; } diff --git a/embedding/csharp/uSCXMLEmbedding/Extensions/CustomIOProc.cs b/embedding/csharp/uSCXMLEmbedding/Extensions/CustomIOProc.cs index 0480a34..866c148 100644 --- a/embedding/csharp/uSCXMLEmbedding/Extensions/CustomIOProc.cs +++ b/embedding/csharp/uSCXMLEmbedding/Extensions/CustomIOProc.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using org.uscxml; +using System.Xml; +using System.Xml.XPath; +using System.IO; namespace embedding { @@ -10,7 +13,9 @@ namespace embedding { public override IOProcessor create(Interpreter interpreter) { - return new CustomIOProc(); + CustomIOProc ioProc = new CustomIOProc(); + ioProc.swigCMemOwn = false; + return ioProc; } public override Data getDataModelVariables() @@ -22,12 +27,39 @@ namespace embedding public override StringList getNames() { StringList names = new StringList(); - names.add("simple"); + names.add("custom"); return names; } public override void send(SendRequest req) { + Console.WriteLine(req); + // send in s1.onentry + if ("This is some content!" == req.getContent()) + { + returnEvent(new Event("received1")); + return; + } + // send in s2.onentry + if (req.getParams().ContainsKey("foo") + && "bar" == (req.getParams()["foo"][0].getAtom())) + { + returnEvent(new Event("received2")); + return; + } + // send in s3 + if (req.getXML().Length > 0) + { + XmlReaderSettings set = new XmlReaderSettings(); + set.ConformanceLevel = ConformanceLevel.Fragment; + XPathDocument doc = new XPathDocument(XmlReader.Create(new StringReader(req.getXML()), set)); + XPathNavigator nav = doc.CreateNavigator(); + + Console.WriteLine("Root element :" + nav.SelectSingleNode("/").Value); + returnEvent(new Event("received3")); + return; + } + } } } diff --git a/embedding/csharp/uSCXMLEmbedding/Extensions/CustomInvoker.cs b/embedding/csharp/uSCXMLEmbedding/Extensions/CustomInvoker.cs index da941b0..7c174ed 100644 --- a/embedding/csharp/uSCXMLEmbedding/Extensions/CustomInvoker.cs +++ b/embedding/csharp/uSCXMLEmbedding/Extensions/CustomInvoker.cs @@ -13,7 +13,9 @@ namespace embedding { public override Invoker create(Interpreter interpreter) { - return new CustomInvoker(); + CustomInvoker invoker = new CustomInvoker(); + invoker.swigCMemOwn = false; + return invoker; } public override Data getDataModelVariables() @@ -31,20 +33,20 @@ namespace embedding public override void invoke(InvokeRequest req) { - } - - public override void send(SendRequest req) - { Console.WriteLine(req); // send in s1.onentry - if ("This is some content!" == req.getContent()) + if ("Some string content" == req.getContent()) { - returnEvent(new Event("received1")); + returnEvent(new Event("received1"), true); return; } + } + + public override void send(SendRequest req) + { + Console.WriteLine(req); // send in s2.onentry - if (req.getParams().ContainsKey("foo") - && "bar" == (req.getParams()["foo"][0].getAtom())) + if (req.getName() == "foo") { returnEvent(new Event("received2")); return; diff --git a/embedding/csharp/uSCXMLEmbedding/RunTests.cs b/embedding/csharp/uSCXMLEmbedding/RunTests.cs index d98bca1..38e3736 100644 --- a/embedding/csharp/uSCXMLEmbedding/RunTests.cs +++ b/embedding/csharp/uSCXMLEmbedding/RunTests.cs @@ -29,14 +29,19 @@ namespace embedding SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\uscxml\\lib\\csharp"); } - testLifeCycle(); - testExecutableContent(); - testIOProcessor(); - testInvoker(); + int i = 1; + while (i-- > 0) + { + testLifeCycle(); + testExecutableContent(); + testIOProcessor(); + testInvoker(); + } Console.ReadKey(); } public static void testInvoker() { + Console.WriteLine("testInvoker"); CustomInvoker invoker = new CustomInvoker(); // just register prototype at global factory Factory.getInstance().registerInvoker(invoker); @@ -47,13 +52,15 @@ namespace embedding " " + " Some string content" + " " + - " " + + " " + " " + - " " + + " " + + " " + " " + " " + " " + " " + + " " + " " + " " + " " + @@ -69,6 +76,7 @@ namespace embedding public static void testIOProcessor() { + Console.WriteLine("testIOProcessor"); CustomIOProc ioproc = new CustomIOProc(); // just register prototype at global factory Factory.getInstance().registerIOProcessor(ioproc); @@ -77,7 +85,7 @@ namespace embedding "" + " " + " " + - " " + + " " + " This is some content!" + " " + " " + @@ -85,7 +93,7 @@ namespace embedding " " + " " + " " + - " " + + " " + " " + " " + " " + @@ -93,7 +101,7 @@ namespace embedding " " + " " + " " + - " " + + " " + " " + " " + " " + @@ -112,6 +120,7 @@ namespace embedding public static void testExecutableContent() { + Console.WriteLine("testExecutableContent"); CustomExecutableContent execContent = new CustomExecutableContent(); Factory.getInstance().registerExecutableContent(execContent); @@ -119,12 +128,12 @@ namespace embedding "\n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " " + " \n" + @@ -132,10 +141,12 @@ namespace embedding "\n" ); interpreter.interpret(); + interpreter.Dispose(); } public static void testLifeCycle() { + Console.WriteLine("testLifeCycle"); // syntactic xml parse error -> throws try { @@ -145,7 +156,7 @@ namespace embedding } catch (InterpreterException e) { - Console.WriteLine(e); +// Console.WriteLine(e); } // semantic xml parse error -> throws @@ -159,7 +170,7 @@ namespace embedding } catch (InterpreterException e) { - Console.WriteLine(e); +// Console.WriteLine(e); } // request unknown datamodel @@ -179,7 +190,7 @@ namespace embedding } catch (InterpreterException e) { - Console.WriteLine(e); +// Console.WriteLine(e); } diff --git a/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java index 0b2b576..679581d 100644 --- a/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java +++ b/embedding/java/src/org/uscxml/datamodel/ecmascript/ECMAScriptDataModel.java @@ -1,6 +1,7 @@ package org.uscxml.datamodel.ecmascript; import java.lang.reflect.Method; +import java.util.Map; import org.mozilla.javascript.Callable; import org.mozilla.javascript.Context; @@ -14,8 +15,9 @@ import org.uscxml.Data; import org.uscxml.DataModel; import org.uscxml.Event; import org.uscxml.Interpreter; +import org.uscxml.NativeIOProcessor; +import org.uscxml.NativeInvoker; import org.uscxml.StringList; -import org.uscxml.StringVector; public class ECMAScriptDataModel extends DataModel { @@ -84,6 +86,7 @@ public class ECMAScriptDataModel extends DataModel { */ ECMAScriptDataModel newDM = new ECMAScriptDataModel(); + newDM.swigReleaseOwnership(); newDM.interpreter = interpreter; newDM.ctx = Context.enter(); @@ -99,11 +102,9 @@ public class ECMAScriptDataModel extends DataModel { // ioProcessors { Data ioProcs = new Data(); - StringVector keys = interpreter.getIOProcessorKeys(); - for (int i = 0; i < keys.size(); i++) { - ioProcs.put(keys.get(i), interpreter - .getIOProcessors().get(keys.get(i)) - .getDataModelVariables()); + Map ioProcNatives = interpreter.getIOProcessors(); + for (String key : ioProcNatives.keySet()) { + ioProcs.put(key, ioProcNatives.get(key).getDataModelVariables()); } newDM.scope .put("_ioprocessors", newDM.scope, new ECMAData(ioProcs)); @@ -112,11 +113,9 @@ public class ECMAScriptDataModel extends DataModel { // invokers { Data invokers = new Data(); - StringVector keys = interpreter.getInvokerKeys(); - for (int i = 0; i < keys.size(); i++) { - invokers.put(keys.get(i), interpreter - .getInvokers().get(keys.get(i)) - .getDataModelVariables()); + Map invokersNatives = interpreter.getInvokers(); + for (String key : invokersNatives.keySet()) { + invokers.put(key, invokersNatives.get(key).getDataModelVariables()); } newDM.scope .put("_ioprocessors", newDM.scope, new ECMAData(invokers)); diff --git a/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java b/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java index 7a97ab4..805e6f7 100644 --- a/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java +++ b/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java @@ -42,7 +42,9 @@ public class TestCustomExecContent extends ExecutableContent { @Override public ExecutableContent create(Interpreter interpreter) { - return new TestCustomExecContent(); + TestCustomExecContent execContent = new TestCustomExecContent(); + execContent.swigReleaseOwnership(); + return execContent; } /** diff --git a/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java b/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java index 25420ed..ecbff9b 100644 --- a/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java +++ b/embedding/java/src/org/uscxml/tests/invoker/TestCustomInvoker.java @@ -47,7 +47,9 @@ public class TestCustomInvoker extends Invoker { @Override public Invoker create(Interpreter interpreter) { - return new TestCustomInvoker(); + TestCustomInvoker invoker = new TestCustomInvoker(); + invoker.swigReleaseOwnership(); + return invoker; } /** @@ -73,6 +75,7 @@ public class TestCustomInvoker extends Invoker { " " + " " + " " + + " " + " " + " " + " " + diff --git a/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java b/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java index 277c505..8a72abe 100644 --- a/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java +++ b/embedding/java/src/org/uscxml/tests/ioprocessor/TestCustomIOProc.java @@ -89,6 +89,7 @@ public class TestCustomIOProc extends IOProcessor { public IOProcessor create(Interpreter interpreter) { TestCustomIOProc ioProc = new TestCustomIOProc(); ioProc.interpreter = interpreter; + ioProc.swigReleaseOwnership(); return ioProc; } @@ -102,7 +103,7 @@ public class TestCustomIOProc extends IOProcessor { TestCustomIOProc ioproc = new TestCustomIOProc(); // just register prototype at global factory Factory.getInstance().registerIOProcessor(ioproc); - + String xml = "" + " " + diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt index ca5b774..25c11a1 100644 --- a/src/bindings/CMakeLists.txt +++ b/src/bindings/CMakeLists.txt @@ -12,6 +12,8 @@ if (WIN32) endif() LIST(APPEND CMAKE_PROGRAM_PATH "C:/Program Files/swig") # swig.exe + LIST(APPEND CMAKE_PROGRAM_PATH "C:/Program Files (x86)/swig") # swig.exe + endif() LIST(APPEND CMAKE_PROGRAM_PATH $ENV{SWIG_DIR}) @@ -23,6 +25,9 @@ if (SWIG_FOUND) INCLUDE(${SWIG_USE_FILE}) add_subdirectory(swig/java) add_subdirectory(swig/csharp) + if(SWIG_VERSION VERSION_LESS 3.0.0) + message(STATUS "SWIG version > 3.0 is recommended, found ${SWIG_VERSION}") + endif() else() message(STATUS "SWIG version 2.0.5 is required, found ${SWIG_VERSION} - skipping java wrapper generation") endif() diff --git a/src/bindings/swig/csharp/CMakeLists.txt b/src/bindings/swig/csharp/CMakeLists.txt index 80d093e..ee37bf7 100644 --- a/src/bindings/swig/csharp/CMakeLists.txt +++ b/src/bindings/swig/csharp/CMakeLists.txt @@ -2,9 +2,8 @@ # Make from within Eclipse fails miserably with the whole thing if (WIN32) - LIST(APPEND CMAKE_PROGRAM_PATH "C:/Program Files (x86)/swig") # swig.exe - #LIST(APPEND CMAKE_PROGRAM_PATH "C:/Windows/Microsoft.NET/Framework/v4.0.30319") # CSharp compiler LIST(APPEND CMAKE_PROGRAM_PATH "C:/Windows/Microsoft.NET/Framework/v3.5") # CSharp compiler + LIST(APPEND CMAKE_PROGRAM_PATH "C:/Windows/Microsoft.NET/Framework/v4.0.30319") # CSharp compiler endif() FIND_PROGRAM(DMCS_EXECUTABLE dmcs PATHS $ENV{DMCS_HOME} ENV PATH ) # Mono compiler diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i index 8e9a297..2a1ac07 100644 --- a/src/bindings/swig/csharp/uscxml.i +++ b/src/bindings/swig/csharp/uscxml.i @@ -36,6 +36,8 @@ typedef uscxml::ExecutableContentImpl ExecutableContentImpl; #pragma SWIG nowarn=401 // do not warn when we override symbols via extend #pragma SWIG nowarn=302 +// do not warn when ignoring overrided method +#pragma SWIG nowarn=516 %csconst(1); @@ -133,14 +135,69 @@ WRAP_THROW_EXCEPTION(uscxml::Interpreter::step); WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret); +%define WRAP_TO_STRING( CLASSNAME ) +%csmethodmodifiers CLASSNAME::ToString() "public override"; +%extend CLASSNAME { + virtual std::string ToString() { + std::stringstream ss; + ss << *self; + return ss.str(); + } +}; +%enddef + +WRAP_TO_STRING(uscxml::Event); +WRAP_TO_STRING(uscxml::Data); +WRAP_TO_STRING(uscxml::SendRequest); +WRAP_TO_STRING(uscxml::InvokeRequest); + %include "../uscxml_ignores.i" //*********************************************** // Beautify important classes //*********************************************** +%csmethodmodifiers uscxml::Event::getParamMap() "private"; +%csmethodmodifiers uscxml::Event::getParamMapKeys() "private"; +%csmethodmodifiers uscxml::Event::setParamMap(const std::map >&) "private"; +%csmethodmodifiers uscxml::Event::getNameListKeys() "private"; +%csmethodmodifiers uscxml::Interpreter::getIOProcessorKeys() "private"; +%csmethodmodifiers uscxml::Interpreter::getInvokerKeys() "private"; +%csmethodmodifiers uscxml::Interpreter::getInvokers() "private"; +%csmethodmodifiers uscxml::Interpreter::getIOProcessors() "private"; +%csmethodmodifiers uscxml::Data::getCompoundKeys() "private"; + %include "../uscxml_beautify.i" +%typemap(csimports) uscxml::Interpreter %{ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +%} + +%typemap(cscode) uscxml::Interpreter %{ + public Dictionary getIOProcessors() { + Dictionary ioProcs = new Dictionary(); + StringVector keys = getIOProcessorKeys(); + IOProcMap ioProcMap = getIOProcessorsNative(); + for (int i = 0; i < keys.Count; i++) { + ioProcs[keys[i]] = ioProcMap[keys[i]]; + } + return ioProcs; + } + + public Dictionary getInvokers() { + Dictionary invokers = new Dictionary(); + StringVector keys = getInvokerKeys(); + InvokerMap invokerMap = getInvokersNative(); + for (int i = 0; i < keys.Count; i++) { + invokers[keys[i]] = invokerMap[keys[i]]; + } + return invokers; + } + +%} + %rename(getCompoundNative) uscxml::Data::getCompound(); %rename(getArrayNative) uscxml::Data::getArray(); diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i index cb760e4..ee95eb0 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -36,6 +36,8 @@ typedef uscxml::ExecutableContentImpl ExecutableContentImpl; #pragma SWIG nowarn=401 // do not warn when we override symbols via extend #pragma SWIG nowarn=302 +// do not warn when ignoring overrided method +#pragma SWIG nowarn=516 %javaconst(1); @@ -93,6 +95,21 @@ WRAP_THROW_EXCEPTION(uscxml::Interpreter::step); WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret); +%define WRAP_TO_STRING( CLASSNAME ) +%extend CLASSNAME { + virtual std::string toString() { + std::stringstream ss; + ss << *self; + return ss.str(); + } +}; +%enddef + +WRAP_TO_STRING(uscxml::Event); +WRAP_TO_STRING(uscxml::Data); +WRAP_TO_STRING(uscxml::SendRequest); +WRAP_TO_STRING(uscxml::InvokeRequest); + %include "../uscxml_ignores.i" // see http://swig.org/Doc2.0/Java.html#Java_date_marshalling @@ -153,9 +170,49 @@ BEAUTIFY_NATIVE(uscxml::InvokeRequest, InvokeRequest, InvokeRequestNative); // Beautify important classes //*********************************************** +%javamethodmodifiers uscxml::Event::getParamMap() "private"; +%javamethodmodifiers uscxml::Event::getParamMapKeys() "private"; +%javamethodmodifiers uscxml::Event::setParamMap(const std::map >&) "private"; +%javamethodmodifiers uscxml::Event::getNameListKeys() "private"; +%javamethodmodifiers uscxml::Interpreter::getIOProcessorKeys() "private"; +%javamethodmodifiers uscxml::Interpreter::getInvokerKeys() "private"; +%javamethodmodifiers uscxml::Interpreter::getInvokers() "private"; +%javamethodmodifiers uscxml::Interpreter::getIOProcessors() "private"; +%javamethodmodifiers uscxml::Data::getCompoundKeys() "private"; + %include "../uscxml_beautify.i" +%typemap(javaimports) uscxml::Interpreter %{ +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.LinkedList; +%} + +%typemap(javacode) uscxml::Interpreter %{ + public Map getIOProcessors() { + Map ioProcs = new HashMap(); + StringVector keys = getIOProcessorKeys(); + IOProcMap ioProcMap = getIOProcessorsNative(); + for (int i = 0; i < keys.size(); i++) { + ioProcs.put(keys.get(i), ioProcMap.get(keys.get(i))); + } + return ioProcs; + } + + public Map getInvokers() { + Map invokers = new HashMap(); + StringVector keys = getInvokerKeys(); + InvokerMap invokerMap = getInvokersNative(); + for (int i = 0; i < keys.size(); i++) { + invokers.put(keys.get(i), invokerMap.get(keys.get(i))); + } + return invokers; + } + +%} + %rename(getCompoundNative) uscxml::Data::getCompound(); %rename(getArrayNative) uscxml::Data::getArray(); %rename(setCompoundNative) uscxml::Data::setCompound(const std::map&); diff --git a/src/bindings/swig/uscxml_beautify.i b/src/bindings/swig/uscxml_beautify.i index ac3ed44..6daba77 100644 --- a/src/bindings/swig/uscxml_beautify.i +++ b/src/bindings/swig/uscxml_beautify.i @@ -9,34 +9,10 @@ %rename(NativeInterpreterMonitor) InterpreterMonitor; %rename(InterpreterMonitor) WrappedInterpreterMonitor; -%extend uscxml::Event { -/* std::vector > getParamPairs() { - std::vector > pairs; - std::multimap::iterator paramPairIter = self->getParams().begin(); - while(paramPairIter != self->getParams().end()) { - pairs.push_back(*paramPairIter); - paramPairIter++; - } - return pairs; - } +%rename(getInvokersNative) uscxml::Interpreter::getInvokers(); +%rename(getIOProcessorsNative) uscxml::Interpreter::getIOProcessors(); - void setParamPairs(const std::vector >& pairs) { - std::multimap params; - std::vector >::const_iterator pairIter = pairs.begin(); - while(pairIter != pairs.end()) { - params.insert(std::make_pair(pairIter->first, pairIter->second)); - pairIter++; - } - self->setParams(params); - } -*/ - - std::string toString() { - std::stringstream ss; - ss << *self; - return ss.str(); - } - +%extend uscxml::Event { std::map > getParamMap() { std::map > paramMap; std::multimap::const_iterator paramPairIter = self->getParams().begin(); @@ -127,12 +103,6 @@ }; %extend uscxml::Data { - std::string toString() { - std::stringstream ss; - ss << *self; - return ss.str(); - } - std::vector getCompoundKeys() { std::vector keys; std::map::const_iterator iter = self->compound.begin(); @@ -143,19 +113,3 @@ return keys; } }; - -%extend uscxml::SendRequest { - std::string toString() { - std::stringstream ss; - ss << *self; - return ss.str(); - } -}; - -%extend uscxml::InvokeRequest { - std::string toString() { - std::stringstream ss; - ss << *self; - return ss.str(); - } -}; \ No newline at end of file diff --git a/src/bindings/swig/wrapped/WrappedIOProcessor.h b/src/bindings/swig/wrapped/WrappedIOProcessor.h index b4e4938..0b5cfe8 100644 --- a/src/bindings/swig/wrapped/WrappedIOProcessor.h +++ b/src/bindings/swig/wrapped/WrappedIOProcessor.h @@ -47,7 +47,7 @@ public: _interpreter = interpreter->shared_from_this(); return boost::shared_ptr(create(_interpreter)); } - + virtual std::list getNames() { return std::list(); }; diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp index 22482e6..0f3e8c9 100644 --- a/src/uscxml/Factory.cpp +++ b/src/uscxml/Factory.cpp @@ -672,7 +672,7 @@ void EventHandlerImpl::returnEvent(Event& event, bool external) { event.origin = "#_" + _invokeId; if (event.origintype.length() == 0) event.origintype = _type; - + if (external) { _interpreter->receive(event); } else { diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 47a6182..5b0db2d 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -97,15 +97,15 @@ #define VALID_FROM_FINISHED(newState) ( \ newState == USCXML_DESTROYED || \ newState == USCXML_INSTANTIATED \ -) +) /// macro to catch exceptions in executeContent #define CATCH_AND_DISTRIBUTE(msg) \ catch (Event e) {\ - LOG(ERROR) << msg << std::endl << e << std::endl;\ if (rethrow) {\ throw(e);\ } else {\ + LOG(ERROR) << msg << std::endl << e << std::endl;\ e.name = "error.execution";\ e.data.compound["cause"] = uscxml::Data(msg, uscxml::Data::VERBATIM); \ e.eventType = Event::PLATFORM;\ @@ -116,10 +116,10 @@ catch (Event e) {\ #define CATCH_AND_DISTRIBUTE2(msg, node) \ catch (Event e) {\ std::string xpathPos = DOMUtils::xPathForNode(node); \ - LOG(ERROR) << msg << " " << xpathPos << ":" << std::endl << e << std::endl;\ if (rethrow) {\ throw(e);\ } else {\ + LOG(ERROR) << msg << " " << xpathPos << ":" << std::endl << e << std::endl;\ e.name = "error.execution";\ e.data.compound["cause"] = uscxml::Data(msg, uscxml::Data::VERBATIM); \ e.data.compound["xpath"] = uscxml::Data(xpathPos, uscxml::Data::VERBATIM); \ @@ -684,7 +684,7 @@ void InterpreterImpl::reset() { _topLevelFinalReached = false; _isInitialized = false; _stable = false; - + setInterpreterState(USCXML_INSTANTIATED); } @@ -1162,15 +1162,16 @@ void InterpreterImpl::send(const Arabica::DOM::Node& element) { try { // namelist if (HAS_ATTR(element, "namelist")) { - if (_dataModel) { - std::list names = tokenizeIdRefs(ATTR(element, "namelist")); - for (std::list::const_iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) { - Data namelistValue = _dataModel.getStringAsData(*nameIter); - sendReq.namelist[*nameIter] = namelistValue; - sendReq.data.compound[*nameIter] = namelistValue; + std::list names = tokenizeIdRefs(ATTR(element, "namelist")); + for (std::list::const_iterator nameIter = names.begin(); nameIter != names.end(); nameIter++) { + if (!_dataModel.isDeclared(*nameIter)) { + LOG(ERROR) << "Error in send element " << DOMUtils::xPathForNode(element) << " namelist:" << std::endl << "'" << *nameIter << "' is not declared" << std::endl; + ERROR_EXECUTION2(err, "Location expression '" + *nameIter + "' in namelist is invalid", element); + return; } - } else { - LOG(ERROR) << "Namelist attribute at send requires datamodel to be defined"; + Data namelistValue = _dataModel.getStringAsData(*nameIter); + sendReq.namelist[*nameIter] = namelistValue; + sendReq.data.compound[*nameIter] = namelistValue; } } } catch (Event e) { diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index cf281b5..2ad1039 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -51,7 +51,7 @@ e.name = "error.platform"; \ e.data.compound["cause"] = Data(msg, Data::VERBATIM); \ throw e; \ - + #define USCXML_MONITOR_CATCH(callback) \ catch (Event e) { \ diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index 048adf9..fdbd21b 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -151,7 +151,7 @@ InterpreterState InterpreterDraft6::step(int waitForMS = 0) { } _stable = true; } - + // test415 if (_topLevelFinalReached) goto EXIT_INTERPRETER; @@ -185,7 +185,7 @@ InterpreterState InterpreterDraft6::step(int waitForMS = 0) { if (_state != USCXML_MACROSTEPPED && _state != USCXML_IDLE) USCXML_MONITOR_CALLBACK(onStableConfiguration) - setInterpreterState(USCXML_MACROSTEPPED); + setInterpreterState(USCXML_MACROSTEPPED); if (_topLevelFinalReached) goto EXIT_INTERPRETER; @@ -232,7 +232,7 @@ InterpreterState InterpreterDraft6::step(int waitForMS = 0) { _currEvent = _externalQueue.pop(); _currEvent.eventType = Event::EXTERNAL; // make sure it is set to external _stable = false; - + if (_topLevelFinalReached) goto EXIT_INTERPRETER; diff --git a/src/uscxml/messages/SendRequest.h b/src/uscxml/messages/SendRequest.h index 6bc3d91..f43b856 100644 --- a/src/uscxml/messages/SendRequest.h +++ b/src/uscxml/messages/SendRequest.h @@ -26,7 +26,7 @@ namespace uscxml { class USCXML_API SendRequest : public Event { public: - SendRequest() {} + SendRequest() : delayMs(0) {} SendRequest(Event event) : Event(event) {} std::string getTarget() { diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp index 5800f98..3b28547 100644 --- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp +++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp @@ -663,7 +663,7 @@ void XPathDataModel::assign(const NodeSet& key, // addattribute: Add an attribute with the name specified by 'attr' // and value specified by 'expr' to the node specified by 'location'. if (!HAS_ATTR(assignElem, "attr")) - ERROR_EXECUTION_THROW("Assign element is missing 'attr'") + ERROR_EXECUTION_THROW("Assign element is missing 'attr'"); element.setAttribute(ATTR(assignElem, "attr"), value); } else { /// test 547 diff --git a/test/src/test-lifecycle.cpp b/test/src/test-lifecycle.cpp index c0fb55c..7cbb68b 100644 --- a/test/src/test-lifecycle.cpp +++ b/test/src/test-lifecycle.cpp @@ -129,7 +129,7 @@ class SequenceCheckingMonitor : public InterpreterMonitor { virtual void beforeMicroStep(Interpreter interpreter) { CHECK_CALLBACK_TYPE(USCXML_BEFOREMICROSTEP); } - + virtual void beforeExitingState(Interpreter interpreter, const Arabica::DOM::Element& state, bool moreComing) { if (!moreComing) CHECK_CALLBACK_TYPE(USCXML_BEFOREEXITINGSTATE); @@ -138,21 +138,21 @@ class SequenceCheckingMonitor : public InterpreterMonitor { if (!moreComing) CHECK_CALLBACK_TYPE(USCXML_AFTEREXITINGSTATE); } - + virtual void beforeExecutingContent(Interpreter interpreter, const Arabica::DOM::Element& element) { CHECK_CALLBACK_TYPE(USCXML_BEFOREEXECUTINGCONTENT); } virtual void afterExecutingContent(Interpreter interpreter, const Arabica::DOM::Element& element) { CHECK_CALLBACK_TYPE(USCXML_AFTEREXECUTINGCONTENT); } - + virtual void beforeUninvoking(Interpreter interpreter, const Arabica::DOM::Element& invokeElem, const std::string& invokeid) { CHECK_CALLBACK_TYPE(USCXML_BEFOREUNINVOKING); } virtual void afterUninvoking(Interpreter interpreter, const Arabica::DOM::Element& invokeElem, const std::string& invokeid) { CHECK_CALLBACK_TYPE(USCXML_AFTERUNINVOKING); } - + virtual void beforeTakingTransition(Interpreter interpreter, const Arabica::DOM::Element& transition, bool moreComing) { if (!moreComing) CHECK_CALLBACK_TYPE(USCXML_BEFORETAKINGTRANSITION); @@ -161,7 +161,7 @@ class SequenceCheckingMonitor : public InterpreterMonitor { if (!moreComing) CHECK_CALLBACK_TYPE(USCXML_AFTERTAKINGTRANSITION); } - + virtual void beforeEnteringState(Interpreter interpreter, const Arabica::DOM::Element& state, bool moreComing) { if (!moreComing) CHECK_CALLBACK_TYPE(USCXML_BEFOREENTERINGSTATE); @@ -170,22 +170,22 @@ class SequenceCheckingMonitor : public InterpreterMonitor { if (!moreComing) CHECK_CALLBACK_TYPE(USCXML_AFTERENTERINGSTATE); } - + virtual void beforeInvoking(Interpreter interpreter, const Arabica::DOM::Element& invokeElem, const std::string& invokeid) { CHECK_CALLBACK_TYPE(USCXML_BEFOREINVOKING); } virtual void afterInvoking(Interpreter interpreter, const Arabica::DOM::Element& invokeElem, const std::string& invokeid) { CHECK_CALLBACK_TYPE(USCXML_AFTERINVOKING); } - + virtual void afterMicroStep(Interpreter interpreter) { CHECK_CALLBACK_TYPE(USCXML_AFTERMICROSTEP); } - + virtual void onStableConfiguration(Interpreter interpreter) { CHECK_CALLBACK_TYPE(USCXML_ONSTABLECONFIGURATION); } - + virtual void beforeCompletion(Interpreter interpreter) { CHECK_CALLBACK_TYPE(USCXML_BEFORECOMPLETION); } @@ -208,7 +208,7 @@ int main(int argc, char** argv) { google::LogToStderr(); SequenceCheckingMonitor* mon = new SequenceCheckingMonitor(); - + int iterations = 1; while(iterations--) { @@ -241,12 +241,12 @@ int main(int argc, char** argv) { // request unknown datamodel try { const char* xml = - "" - " " - " " - " " - " " - ""; + "" + " " + " " + " " + " " + ""; Interpreter interpreter = Interpreter::fromXML(xml); interpreter.addMonitor(mon); assert(interpreter.getState() == USCXML_INSTANTIATED); @@ -260,22 +260,22 @@ int main(int argc, char** argv) { if (1) { // two microsteps const char* xml = - "" - " " - " " - " " - " " - " " - " " - " " - ""; - + "" + " " + " " + " " + " " + " " + " " + " " + ""; + Interpreter interpreter = Interpreter::fromXML(xml); interpreter.addMonitor(mon); callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE); callBackSeq.push_back(USCXML_AFTERENTERINGSTATE); - + callBackSeq.push_back(USCXML_BEFOREMICROSTEP); callBackSeq.push_back(USCXML_BEFOREEXITINGSTATE); callBackSeq.push_back(USCXML_AFTEREXITINGSTATE); @@ -295,31 +295,31 @@ int main(int argc, char** argv) { callBackSeq.push_back(USCXML_AFTERMICROSTEP); callBackSeq.push_back(USCXML_BEFORECOMPLETION); - callBackSeq.push_back(USCXML_AFTERCOMPLETION); - + callBackSeq.push_back(USCXML_AFTERCOMPLETION); + assert(interpreter.getState() == USCXML_INSTANTIATED); assert(interpreter.step() == USCXML_MICROSTEPPED); assert(interpreter.step() == USCXML_MICROSTEPPED); assert(interpreter.step() == USCXML_FINISHED); assert(callBackSeq.empty()); } - + if (1) { // single macrostep, multiple runs const char* xml = - "" - " " - " " - " " - " " - ""; - + "" + " " + " " + " " + " " + ""; + Interpreter interpreter = Interpreter::fromXML(xml); interpreter.addMonitor(mon); callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE); callBackSeq.push_back(USCXML_AFTERENTERINGSTATE); - + callBackSeq.push_back(USCXML_BEFOREMICROSTEP); callBackSeq.push_back(USCXML_BEFOREEXITINGSTATE); callBackSeq.push_back(USCXML_AFTEREXITINGSTATE); @@ -328,10 +328,10 @@ int main(int argc, char** argv) { callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE); callBackSeq.push_back(USCXML_AFTERENTERINGSTATE); callBackSeq.push_back(USCXML_AFTERMICROSTEP); - + callBackSeq.push_back(USCXML_BEFORECOMPLETION); callBackSeq.push_back(USCXML_AFTERCOMPLETION); - + assert(interpreter.getState() == USCXML_INSTANTIATED); assert(interpreter.step() == USCXML_MICROSTEPPED); assert(interpreter.step() == USCXML_FINISHED); @@ -339,7 +339,7 @@ int main(int argc, char** argv) { callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE); callBackSeq.push_back(USCXML_AFTERENTERINGSTATE); - + callBackSeq.push_back(USCXML_BEFOREMICROSTEP); callBackSeq.push_back(USCXML_BEFOREEXITINGSTATE); callBackSeq.push_back(USCXML_AFTEREXITINGSTATE); @@ -348,7 +348,7 @@ int main(int argc, char** argv) { callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE); callBackSeq.push_back(USCXML_AFTERENTERINGSTATE); callBackSeq.push_back(USCXML_AFTERMICROSTEP); - + callBackSeq.push_back(USCXML_BEFORECOMPLETION); callBackSeq.push_back(USCXML_AFTERCOMPLETION); @@ -356,23 +356,23 @@ int main(int argc, char** argv) { assert(interpreter.step() == USCXML_MICROSTEPPED); assert(interpreter.step() == USCXML_FINISHED); } - + if (1) { // macrostep in between const char* xml = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - ""; - + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; + Interpreter interpreter = Interpreter::fromXML(xml); interpreter.addMonitor(mon); @@ -410,7 +410,7 @@ int main(int argc, char** argv) { assert(interpreter.step() == USCXML_MICROSTEPPED); assert(interpreter.step() == USCXML_FINISHED); } - + #if 0 diff --git a/test/w3c/confEcma.xsl b/test/w3c/confEcma.xsl index ffc922d..a77d552 100644 --- a/test/w3c/confEcma.xsl +++ b/test/w3c/confEcma.xsl @@ -165,7 +165,7 @@ foo - +123 @@ -273,6 +273,12 @@ events which cause the test to fail. The default value provided here is pretty Var + + + "foo" + + + @@ -380,6 +386,10 @@ events which cause the test to fail. The default value provided here is pretty + + + Var == 123 + @@ -428,6 +438,11 @@ is the second argument --> _event.data == + + + _event.data == 123 + + typeof _event.data === 'undefined' diff --git a/test/w3c/confXPath.xsl b/test/w3c/confXPath.xsl index 71286ce..bb65375 100644 --- a/test/w3c/confXPath.xsl +++ b/test/w3c/confXPath.xsl @@ -204,7 +204,7 @@ is of the same type as array123 --> foo - +123 @@ -270,6 +270,11 @@ events which cause the test to fail. The default value provided here is pretty $Var + + + "foo" + + @@ -419,6 +424,11 @@ know if we can make this strong in XPath 1.0 --> + + + Var = 123 + + @@ -513,6 +523,11 @@ is the second argument --> $_event/data = + + + _event.data = 123 + + not($_event/data/*) diff --git a/test/w3c/ecma/test252.scxml b/test/w3c/ecma/test252.scxml index 14c6686..b33342b 100644 --- a/test/w3c/ecma/test252.scxml +++ b/test/w3c/ecma/test252.scxml @@ -5,7 +5,7 @@ timeout indicates success. --> - + @@ -22,7 +22,7 @@ timeout indicates success. --> - + diff --git a/test/w3c/ecma/test343.scxml b/test/w3c/ecma/test343.scxml index 7f15cf0..a1455d9 100644 --- a/test/w3c/ecma/test343.scxml +++ b/test/w3c/ecma/test343.scxml @@ -14,7 +14,7 @@ - + diff --git a/test/w3c/ecma/test354.scxml b/test/w3c/ecma/test354.scxml index ef55794..6c544a4 100644 --- a/test/w3c/ecma/test354.scxml +++ b/test/w3c/ecma/test354.scxml @@ -37,10 +37,10 @@ and that correct values are used --> - foo + 123 - + diff --git a/test/w3c/ecma/test487.scxml b/test/w3c/ecma/test487.scxml index 30a50eb..5baacbe 100644 --- a/test/w3c/ecma/test487.scxml +++ b/test/w3c/ecma/test487.scxml @@ -1,10 +1,11 @@ - + + diff --git a/test/w3c/ecma/test553.scxml b/test/w3c/ecma/test553.scxml index 0beddea..0df3c3e 100644 --- a/test/w3c/ecma/test553.scxml +++ b/test/w3c/ecma/test553.scxml @@ -6,8 +6,8 @@ of 's args causes an error.. --> - - + + - - + + diff --git a/test/w3c/txml/test252.txml b/test/w3c/txml/test252.txml index 40c36cb..ba43543 100644 --- a/test/w3c/txml/test252.txml +++ b/test/w3c/txml/test252.txml @@ -9,7 +9,7 @@ timeout indicates success. --> - + @@ -26,7 +26,7 @@ timeout indicates success. --> - + diff --git a/test/w3c/txml/test343.txml b/test/w3c/txml/test343.txml index 1d13da6..f0aba04 100644 --- a/test/w3c/txml/test343.txml +++ b/test/w3c/txml/test343.txml @@ -17,7 +17,7 @@ - + diff --git a/test/w3c/txml/test354.txml b/test/w3c/txml/test354.txml index 0f1f6c5..890b6ef 100644 --- a/test/w3c/txml/test354.txml +++ b/test/w3c/txml/test354.txml @@ -41,10 +41,10 @@ and that correct values are used --> - foo + - + diff --git a/test/w3c/txml/test487.txml b/test/w3c/txml/test487.txml index 7210c2b..fe7423c 100644 --- a/test/w3c/txml/test487.txml +++ b/test/w3c/txml/test487.txml @@ -4,11 +4,12 @@ - + + diff --git a/test/w3c/txml/test553.txml b/test/w3c/txml/test553.txml index 0c6a622..b9dfece 100644 --- a/test/w3c/txml/test553.txml +++ b/test/w3c/txml/test553.txml @@ -10,8 +10,8 @@ of 's args causes an error.. --> - - + + - - + + diff --git a/test/w3c/xpath/test252.scxml b/test/w3c/xpath/test252.scxml index 1f92127..f8d93a5 100644 --- a/test/w3c/xpath/test252.scxml +++ b/test/w3c/xpath/test252.scxml @@ -5,7 +5,7 @@ timeout indicates success. --> - + @@ -22,7 +22,7 @@ timeout indicates success. --> - + diff --git a/test/w3c/xpath/test343.scxml b/test/w3c/xpath/test343.scxml index bae14de..e3dbf53 100644 --- a/test/w3c/xpath/test343.scxml +++ b/test/w3c/xpath/test343.scxml @@ -14,7 +14,7 @@ - + diff --git a/test/w3c/xpath/test354.scxml b/test/w3c/xpath/test354.scxml index 499b568..e75d382 100644 --- a/test/w3c/xpath/test354.scxml +++ b/test/w3c/xpath/test354.scxml @@ -37,10 +37,10 @@ and that correct values are used --> - foo + 123 - + diff --git a/test/w3c/xpath/test487.scxml b/test/w3c/xpath/test487.scxml index 9e6c441..cec2f64 100644 --- a/test/w3c/xpath/test487.scxml +++ b/test/w3c/xpath/test487.scxml @@ -1,10 +1,11 @@ - + + diff --git a/test/w3c/xpath/test553.scxml b/test/w3c/xpath/test553.scxml index 00bd1e8..90cd97c 100644 --- a/test/w3c/xpath/test553.scxml +++ b/test/w3c/xpath/test553.scxml @@ -6,8 +6,8 @@ of 's args causes an error.. --> - - + + - - + + -- cgit v0.12
Test#StatusDescriptionComment
553Failed"test that the processor does not dispatch the event if evaluation of <send>'s args causes an error."We cannot correctly identify location expressions (valid LHS) for ecmascript. Send is performed anyway.
554Failed"test that if the evaluation of <invoke>'s args causes an error, the invocation is cancelled."We cannot correctly identify location expressions (valid LHS) for ecmascript. Invoke is performed anyway.
579 Failed "Before the parent state has been visited for the first time, if a transition is executed that takes the history state as its target, the SCXML processor MUST execute any executable content in the transition after the parent state's onentry content and any content in a possible initial transition.">= 2.8.6 The build-system used for uscxml.
SWIG
optional
>= 2.0.6Generates language bindings to embed uSCXML in other target languages.
libevent
pre-compiled
>= 2.1.x Event queues with callbacks and the HTTP server.
curl
required
curl
pre-compiled / required
>= 7.29.0 URL downloads.