From aa635ecc06213bfb7f4f6c62cbb8e99832d99d48 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Tue, 30 Apr 2013 19:48:25 +0200 Subject: Started to offer state predicates for php --- CMakeLists.txt | 4 ++-- src/bindings/swig/php/uscxml.i | 12 ++++++++++++ src/bindings/swig/php/uscxmlNativePHP.php | 20 ++++++++++++++------ test/samples/uscxml/test-prolog2.scxml | 18 ++++++++++-------- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bdd2f45..68b196a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -325,11 +325,11 @@ if (NOT WIN32) include_directories(${LIBXML2_INCLUDE_DIR}) list (APPEND USCXML_CORE_LIBS ${LIBXML2_LIBRARIES}) set(XML_LIBRARIES ${LIBXML2_LIBRARIES}) - list (APPEND USCXML_CORE_LIBS "dl") - list (APPEND USCXML_CORE_LIBS "pthread") if (NOT APPLE) list (APPEND USCXML_CORE_LIBS "rt") endif() + list (APPEND USCXML_CORE_LIBS "dl") + list (APPEND USCXML_CORE_LIBS "pthread") elseif(WIN32) list (APPEND XML_LIBRARIES "Ws2_32") list (APPEND XML_LIBRARIES "Winmm") diff --git a/src/bindings/swig/php/uscxml.i b/src/bindings/swig/php/uscxml.i index 5f0b930..5dd59b9 100644 --- a/src/bindings/swig/php/uscxml.i +++ b/src/bindings/swig/php/uscxml.i @@ -42,6 +42,18 @@ void*** tsrm_ls; %ignore uscxml::InterpreterImpl; //*********************************************** +// Beautify interpreter class +//*********************************************** + +%ignore uscxml::Interpreter::isAtomic(Arabica::DOM::Node); +%extend uscxml::Interpreter { + bool isAtomic(const std::string stateId) { + Arabica::DOM::Node state = self->getState(stateId); + return self->isAtomic(state); + } +} + +//*********************************************** // Parse the header file to generate wrappers //*********************************************** diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php index e7ef93d..61e7c2e 100644 --- a/src/bindings/swig/php/uscxmlNativePHP.php +++ b/src/bindings/swig/php/uscxmlNativePHP.php @@ -274,8 +274,12 @@ class Event { return $r; } - function setData($invokeId) { - Event_setData($this->_cPtr,$invokeId); + function setData($data) { + Event_setData($this->_cPtr,$data); + } + + function initContent($content) { + Event_initContent($this->_cPtr,$content); } static function fromXML($xmlString) { @@ -747,10 +751,6 @@ class Interpreter { return Interpreter_isTargetless($transition); } - static function isAtomic($state) { - return Interpreter_isAtomic($state); - } - static function isFinal($state) { return Interpreter_isFinal($state); } @@ -832,6 +832,14 @@ class Interpreter { static function getUUID() { return Interpreter_getUUID(); } + + function isAtomic($stateId=null) { + switch (func_num_args()) { + case 0: $r=Interpreter_isAtomic($this->_cPtr); break; + default: $r=Interpreter_isAtomic($this->_cPtr,$stateId); + } + return $r; + } } class InterpreterMonitor { diff --git a/test/samples/uscxml/test-prolog2.scxml b/test/samples/uscxml/test-prolog2.scxml index f697b89..50dd1b3 100644 --- a/test/samples/uscxml/test-prolog2.scxml +++ b/test/samples/uscxml/test-prolog2.scxml @@ -1,12 +1,14 @@ - - bob, jim. - bob, john. - - - mother(martha, jim). - mother(martha, john). - + + + bob, jim. + bob, john. + + + mother(martha, jim). + mother(martha, john). + +