diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-26 22:20:03 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-26 22:20:03 (GMT) |
commit | 83f0b4ecbd83e83b5404afd5cead7a08966495bf (patch) | |
tree | ff887fca701fe27221a04bf2c304e3ecb4cbf7cc /src/bindings | |
parent | 405c805f249cacb07f8861d5550abda8f6694d0c (diff) | |
download | uscxml-83f0b4ecbd83e83b5404afd5cead7a08966495bf.zip uscxml-83f0b4ecbd83e83b5404afd5cead7a08966495bf.tar.gz uscxml-83f0b4ecbd83e83b5404afd5cead7a08966495bf.tar.bz2 |
Implemented ParentQueues for PHP
Diffstat (limited to 'src/bindings')
-rw-r--r-- | src/bindings/swig/php/test.php | 16 | ||||
-rw-r--r-- | src/bindings/swig/php/uscxml.i | 6 | ||||
-rw-r--r-- | src/bindings/swig/php/uscxmlNativePHP.php | 91 |
3 files changed, 71 insertions, 42 deletions
diff --git a/src/bindings/swig/php/test.php b/src/bindings/swig/php/test.php index 3ac64eb..6a15429 100644 --- a/src/bindings/swig/php/test.php +++ b/src/bindings/swig/php/test.php @@ -45,10 +45,16 @@ $interpreter = Interpreter::fromURI('https://raw.github.com/tklab-tud/uscxml/mas $interpreter->addMonitor($monitor); $interpreter->interpret(); -// $interpreter = Interpreter::fromURI('https://raw.github.com/tklab-tud/uscxml/master/test/samples/uscxml/test-invoked.scxml'); -// $parentQueue = -// $interpreter->setParentQueue($parentQueue); -// $interpreter->addMonitor($monitor); -// $interpreter->interpret(); +$interpreter = Interpreter::fromURI('https://raw.github.com/tklab-tud/uscxml/master/test/samples/uscxml/test-invoked.scxml'); +$parentQueue = new ParentQueue(); +$interpreter->setParentQueue($parentQueue); +$interpreter->interpret(); +//$interpreter->start(); + +#while($interpreter->isRunning()) { + $event = $parentQueue->pop(); + print_r($event); + print(Event_name_get($event) . "\n"); +#} ?>
\ No newline at end of file diff --git a/src/bindings/swig/php/uscxml.i b/src/bindings/swig/php/uscxml.i index edf51e0..54e9f27 100644 --- a/src/bindings/swig/php/uscxml.i +++ b/src/bindings/swig/php/uscxml.i @@ -16,6 +16,7 @@ %{ #include "../../../uscxml/Message.h" #include "../../../uscxml/Interpreter.h" +#include "../../../uscxml/concurrency/BlockingQueue.h" using namespace uscxml; @@ -29,9 +30,14 @@ void*** tsrm_ls; %feature("director") uscxml::InterpreterMonitor; +%ignore uscxml::NumAttr; + //*********************************************** // Parse the header file to generate wrappers //*********************************************** %include "../../../uscxml/Message.h" %include "../../../uscxml/Interpreter.h" +%include "../../../uscxml/concurrency/BlockingQueue.h" + +%template(ParentQueue) uscxml::concurrency::BlockingQueue<uscxml::Event>; diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php index 6bab7af..91f6b21 100644 --- a/src/bindings/swig/php/uscxmlNativePHP.php +++ b/src/bindings/swig/php/uscxmlNativePHP.php @@ -26,10 +26,6 @@ if (!extension_loaded('uscxmlNativePHP')) { -abstract class uscxmlNativePHP { - const ZTS = ZTS; -} - /* PHP Proxy Classes */ class Data { public $_cPtr=null; @@ -336,39 +332,6 @@ class InterpreterMonitor { } } -class NumAttr { - public $_cPtr=null; - protected $_pData=array(); - - function __set($var,$value) { - if ($var === 'value') return NumAttr_value_set($this->_cPtr,$value); - if ($var === 'unit') return NumAttr_unit_set($this->_cPtr,$value); - if ($var === 'thisown') return swig_uscxmlNativePHP_alter_newobject($this->_cPtr,$value); - $this->_pData[$var] = $value; - } - - function __isset($var) { - if (function_exists('NumAttr_'.$var.'_set')) return true; - if ($var === 'thisown') return true; - return array_key_exists($var, $this->_pData); - } - - function __get($var) { - if ($var === 'value') return NumAttr_value_get($this->_cPtr); - if ($var === 'unit') return NumAttr_unit_get($this->_cPtr); - if ($var === 'thisown') return swig_uscxmlNativePHP_get_newobject($this->_cPtr); - return $this->_pData[$var]; - } - - function __construct($str) { - if (is_resource($str) && get_resource_type($str) === '_p_uscxml__NumAttr') { - $this->_cPtr=$str; - return; - } - $this->_cPtr=new_NumAttr($str); - } -} - class Interpreter { public $_cPtr=null; protected $_pData=array(); @@ -457,6 +420,10 @@ class Interpreter { Interpreter_join($this->_cPtr); } + function isRunning() { + return Interpreter_isRunning($this->_cPtr); + } + function interpret() { Interpreter_interpret($this->_cPtr); } @@ -654,5 +621,55 @@ class Interpreter { } } +class ParentQueue { + public $_cPtr=null; + protected $_pData=array(); + + function __set($var,$value) { + if ($var === 'thisown') return swig_uscxmlNativePHP_alter_newobject($this->_cPtr,$value); + $this->_pData[$var] = $value; + } + + function __isset($var) { + if ($var === 'thisown') return true; + return array_key_exists($var, $this->_pData); + } + + function __get($var) { + if ($var === 'thisown') return swig_uscxmlNativePHP_get_newobject($this->_cPtr); + return $this->_pData[$var]; + } + + function __construct($res=null) { + if (is_resource($res) && get_resource_type($res) === '_p_uscxml__concurrency__BlockingQueueT_uscxml__Event_t') { + $this->_cPtr=$res; + return; + } + $this->_cPtr=new_ParentQueue(); + } + + function push($elem) { + ParentQueue_push($this->_cPtr,$elem); + } + + function push_front($elem) { + ParentQueue_push_front($this->_cPtr,$elem); + } + + function pop() { + $r=ParentQueue_pop($this->_cPtr); + 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 Event($r); + } + return $r; + } + + function isEmpty() { + return ParentQueue_isEmpty($this->_cPtr); + } +} + ?> |