From 5cdc1f8ec070fc3b8d03bde36a1854e7291790a2 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Sat, 30 Mar 2013 18:31:50 +0100 Subject: Interpreter cannot be abstract for PHP wrappers to work --- src/bindings/swig/php/uscxmlNativePHP.php | 58 ++++++++++++++++------------ src/uscxml/Interpreter.cpp | 11 +----- src/uscxml/Interpreter.h | 2 +- src/uscxml/interpreter/InterpreterDraft7.cpp | 9 ++++- 4 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php index 85cef6c..7a1b9f8 100644 --- a/src/bindings/swig/php/uscxmlNativePHP.php +++ b/src/bindings/swig/php/uscxmlNativePHP.php @@ -210,6 +210,14 @@ class Event { Event_setDOM($this->_cPtr,$dom); } + function getContent() { + return Event_getContent($this->_cPtr); + } + + function setContent($content) { + Event_setContent($this->_cPtr,$content); + } + function getSendId() { return Event_getSendId($this->_cPtr); } @@ -310,14 +318,6 @@ class InvokeRequest extends Event { InvokeRequest_setSource($this->_cPtr,$src); } - function getContent() { - return InvokeRequest_getContent($this->_cPtr); - } - - function setContent($content) { - InvokeRequest_setContent($this->_cPtr,$content); - } - function isAutoForwarded() { return InvokeRequest_isAutoForwarded($this->_cPtr); } @@ -444,14 +444,6 @@ class SendRequest extends Event { SendRequest_setDelayMs($this->_cPtr,$delayMs); } - function getContent() { - return SendRequest_getContent($this->_cPtr); - } - - function setContent($content) { - SendRequest_setContent($this->_cPtr,$content); - } - function getNameList() { $r=SendRequest_getNameList($this->_cPtr); if (is_resource($r)) { @@ -580,7 +572,7 @@ class InterpreterMonitor { } } -abstract class Interpreter { +class Interpreter { public $_cPtr=null; protected $_pData=array(); @@ -614,26 +606,42 @@ abstract class Interpreter { static function fromDOM($node) { $r=Interpreter_fromDOM($node); - $this->_cPtr = $r; - return $this; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new Interpreter($r); + } + return $r; } static function fromXML($xml) { $r=Interpreter_fromXML($xml); - $this->_cPtr = $r; - return $this; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new Interpreter($r); + } + return $r; } static function fromURI($uri) { $r=Interpreter_fromURI($uri); - $this->_cPtr = $r; - return $this; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new Interpreter($r); + } + return $r; } static function fromInputSource($source) { $r=Interpreter_fromInputSource($source); - $this->_cPtr = $r; - return $this; + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new Interpreter($r); + } + return $r; } function start() { diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 089406d..37f2b77 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -573,15 +573,8 @@ void Interpreter::send(const Arabica::DOM::Node& element) { // use the whole dom Arabica::DOM::DOMImplementation domFactory = Arabica::SimpleDOM::DOMImplementation::getDOMImplementation(); sendReq.dom = domFactory.createDocument(contents[0].getNamespaceURI(), "", 0); - for (int i = 0; i < contentChilds.getLength(); i++) { - try { - Node newNode = sendReq.dom.importNode(contentChilds.item(i), true); - sendReq.dom.appendChild(newNode); - } catch (...) { - - } - } - std::cout << sendReq.dom << std::endl; + Node newNode = sendReq.dom.importNode(contents[0], true); + sendReq.dom.appendChild(newNode); } else { Node textChild = contents[0].getFirstChild(); while(textChild && textChild.getNodeType() != Node_base::TEXT_NODE) { diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index 5d45e4c..7a0301c 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -107,7 +107,7 @@ public: return _running || !_done; } - virtual void interpret() = 0; + virtual void interpret() {}; void addMonitor(InterpreterMonitor* monitor) { _monitors.insert(monitor); diff --git a/src/uscxml/interpreter/InterpreterDraft7.cpp b/src/uscxml/interpreter/InterpreterDraft7.cpp index 7af2d39..5f07cfc 100644 --- a/src/uscxml/interpreter/InterpreterDraft7.cpp +++ b/src/uscxml/interpreter/InterpreterDraft7.cpp @@ -253,6 +253,7 @@ function selectEventlessTransitions(): return enabledTransitions */ Arabica::XPath::NodeSet InterpreterDraft7::selectEventlessTransitions() { + return Arabica::XPath::NodeSet(); } /** @@ -269,6 +270,7 @@ function selectTransitions(event): return enabledTransitions */ Arabica::XPath::NodeSet InterpreterDraft7::selectTransitions(const std::string& event) { + return Arabica::XPath::NodeSet(); } /** @@ -335,6 +337,7 @@ function computeExitSet(transitions) */ Arabica::XPath::NodeSet InterpreterDraft7::computeExitSet(const Arabica::XPath::NodeSet& enabledTransitions, const Arabica::XPath::NodeSet& statesToExit) { + return Arabica::XPath::NodeSet(); } /** @@ -351,6 +354,7 @@ Arabica::XPath::NodeSet InterpreterDraft7::computeExitSet(const Ara Arabica::XPath::NodeSet InterpreterDraft7::computeEntrySet(const Arabica::XPath::NodeSet& transitions, const Arabica::XPath::NodeSet& statesToEnter, const Arabica::XPath::NodeSet& statesForDefaultEntry) { + return Arabica::XPath::NodeSet(); } /** @@ -375,6 +379,7 @@ function removeConflictingTransitions(enabledTransitions): return filteredTransitions */ Arabica::XPath::NodeSet InterpreterDraft7::removeConflictingTransitions(const Arabica::XPath::NodeSet& enabledTransitions) { + return Arabica::XPath::NodeSet(); } /** @@ -388,6 +393,7 @@ Arabica::XPath::NodeSet InterpreterDraft7::removeConflictingTransit return findLCCA([t.source].append(tstates)) */ Arabica::DOM::Node InterpreterDraft7::getTransitionDomain(const Arabica::DOM::Node& transition) { + return Arabica::DOM::Node(); } /** @@ -418,6 +424,7 @@ Arabica::DOM::Node InterpreterDraft7::getTransitionDomain(const Ara Arabica::XPath::NodeSet InterpreterDraft7::addDescendentStatesToEnter(const Arabica::DOM::Node& state, const Arabica::XPath::NodeSet& statesToEnter, const Arabica::XPath::NodeSet& statesForDefaultEntry) { + return Arabica::XPath::NodeSet(); } /** @@ -433,7 +440,7 @@ Arabica::XPath::NodeSet InterpreterDraft7::addAncestorsStatesToEnte const Arabica::DOM::Node& ancestor, const Arabica::XPath::NodeSet& statesToEnter, const Arabica::XPath::NodeSet& statesForDefaultEntry) { + return Arabica::XPath::NodeSet(); } - } \ No newline at end of file -- cgit v0.12