summaryrefslogtreecommitdiffstats
path: root/src/bindings/swig/csharp/uscxml.i
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/swig/csharp/uscxml.i')
-rw-r--r--src/bindings/swig/csharp/uscxml.i180
1 files changed, 83 insertions, 97 deletions
diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i
index 07604c4..e7b7d62 100644
--- a/src/bindings/swig/csharp/uscxml.i
+++ b/src/bindings/swig/csharp/uscxml.i
@@ -20,9 +20,15 @@ typedef uscxml::Event Event;
typedef uscxml::InvokeRequest InvokeRequest;
typedef uscxml::SendRequest SendRequest;
+%feature("director") uscxml::WrappedInvoker;
+%feature("director") uscxml::WrappedDataModel;
+%feature("director") uscxml::WrappedIOProcessor;
+%feature("director") uscxml::WrappedExecutableContent;
+
// disable warning related to unknown base class
#pragma SWIG nowarn=401
-//%ignore boost::enable_shared_from_this;
+// do not warn when we override symbols via extend
+#pragma SWIG nowarn=302
%csconst(1);
@@ -31,14 +37,6 @@ typedef uscxml::SendRequest SendRequest;
%rename(equals) operator==;
%rename(isValid) operator bool;
-%ignore operator!=;
-%ignore operator<;
-%ignore operator=;
-%ignore operator[];
-%ignore operator std::list<Data>;
-%ignore operator std::string;
-%ignore operator std::map<std::string,Data>;
-%ignore operator<<;
//**************************************************
@@ -49,6 +47,7 @@ typedef uscxml::SendRequest SendRequest;
#include "../../../uscxml/Message.h"
#include "../../../uscxml/Factory.h"
+#include "../../../uscxml/concurrency/BlockingQueue.h"
#include "../../../uscxml/Interpreter.h"
//#include <DOM/Document.hpp>
@@ -59,104 +58,89 @@ typedef uscxml::SendRequest SendRequest;
#include "../wrapped/WrappedInvoker.h"
#include "../wrapped/WrappedDataModel.h"
+#include "../wrapped/WrappedExecutableContent.h"
+#include "../wrapped/WrappedIOProcessor.h"
using namespace uscxml;
using namespace Arabica::DOM;
#include "../wrapped/WrappedInvoker.cpp"
#include "../wrapped/WrappedDataModel.cpp"
+#include "../wrapped/WrappedExecutableContent.cpp"
+#include "../wrapped/WrappedIOProcessor.cpp"
%}
-%ignore uscxml::NumAttr;
-%ignore uscxml::SCXMLParser;
-%ignore uscxml::InterpreterImpl;
+// see http://binf.gmu.edu/software/SWIG/CSharp.html#csharp_exceptions
+%insert(runtime) %{
+ // Code to handle throwing of C# CustomApplicationException from C/C++ code.
+ // The equivalent delegate to the callback, CSharpExceptionCallback_t, is CustomExceptionDelegate
+ // and the equivalent customExceptionCallback instance is customDelegate
+ typedef void (SWIGSTDCALL* CSharpExceptionCallback_t)(const char *);
+ CSharpExceptionCallback_t customExceptionCallback = NULL;
+
+ extern "C" SWIGEXPORT
+ void SWIGSTDCALL CustomExceptionRegisterCallback(CSharpExceptionCallback_t customCallback) {
+ customExceptionCallback = customCallback;
+ }
+
+ // Note that SWIG detects any method calls named starting with
+ // SWIG_CSharpSetPendingException for warning 845
+ static void SWIG_CSharpSetPendingExceptionCustom(const char *msg) {
+ customExceptionCallback(msg);
+ }
+%}
-%ignore create();
+%pragma(csharp) imclasscode=%{
+ class CustomExceptionHelper {
+ // C# delegate for the C/C++ customExceptionCallback
+ public delegate void CustomExceptionDelegate(string message);
+ static CustomExceptionDelegate customDelegate =
+ new CustomExceptionDelegate(SetPendingCustomException);
+
+ [System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="CustomExceptionRegisterCallback")]
+ public static extern
+ void CustomExceptionRegisterCallback(CustomExceptionDelegate customCallback);
+
+ static void SetPendingCustomException(string message) {
+ SWIGPendingException.Set(new org.uscxml.InterpreterException(message));
+ }
+
+ static CustomExceptionHelper() {
+ CustomExceptionRegisterCallback(customDelegate);
+ }
+ }
+ static CustomExceptionHelper exceptionHelper = new CustomExceptionHelper();
+%}
-%ignore uscxml::Interpreter::getDelayQueue();
-%ignore uscxml::WrappedInvoker::create(InterpreterImpl*);
+%define WRAP_THROW_EXCEPTION( MATCH )
+%exception MATCH %{
+try {
+ $action
+} catch (uscxml::Event& e) {
+ std::stringstream ss;
+ ss << std::endl << e;
+ SWIG_CSharpSetPendingExceptionCustom(ss.str().c_str());
+}
+%}
+%enddef
-%ignore uscxml::WrappedDataModel::create(InterpreterImpl*);
-%ignore uscxml::WrappedDataModel::init(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&);
-%ignore uscxml::WrappedDataModel::init(const std::string&, const Data&);
-%ignore uscxml::WrappedDataModel::assign(const Arabica::DOM::Element<std::string>&, const Arabica::DOM::Document<std::string>&, const std::string&);
-%ignore uscxml::WrappedDataModel::assign(const std::string&, const Data&);
-%ignore uscxml::WrappedDataModel::eval(const Arabica::DOM::Element<std::string>&, const std::string&);
+WRAP_THROW_EXCEPTION(uscxml::Interpreter::fromXML);
+WRAP_THROW_EXCEPTION(uscxml::Interpreter::fromURI);
+WRAP_THROW_EXCEPTION(uscxml::Interpreter::step);
+WRAP_THROW_EXCEPTION(uscxml::Interpreter::interpret);
-%ignore uscxml::Event::Event(const Arabica::DOM::Node<std::string>&);
-%ignore uscxml::Event::getStrippedDOM;
-%ignore uscxml::Event::getFirstDOMElement;
-%ignore uscxml::Event::getDOM();
-%ignore uscxml::Event::setDOM(const Arabica::DOM::Document<std::string>&);
-%ignore uscxml::Event::toDocument();
-%template(DataList) std::list<uscxml::Data>;
-%template(DataMap) std::map<std::string, uscxml::Data>;
-%template(StringSet) std::set<std::string>;
-%template(StringVector) std::vector<std::string>;
-%template(ParamPair) std::pair<std::string, uscxml::Data>;
-%template(ParamPairVector) std::vector<std::pair<std::string, uscxml::Data> >;
-%template(IOProcMap) std::map<std::string, uscxml::IOProcessor>;
-%template(InvokerMap) std::map<std::string, uscxml::Invoker>;
+%include "../uscxml_ignores.i"
%rename Data DataNative;
-%feature("director") uscxml::WrappedInvoker;
-%feature("director") uscxml::WrappedDataModel;
-
// translate param multimap to Map<String, List<Data> >
%rename(getParamsNative) uscxml::Event::getParams();
%csmethodmodifiers uscxml::Event::getParams() "private";
-%extend uscxml::Event {
- std::vector<std::pair<std::string, Data> > getParamPairs() {
- std::vector<std::pair<std::string, Data> > pairs;
- std::multimap<std::string, Data>::iterator paramPairIter = self->getParams().begin();
- while(paramPairIter != self->getParams().end()) {
- pairs.push_back(*paramPairIter);
- paramPairIter++;
- }
- return pairs;
- }
-};
-
-%extend uscxml::Interpreter {
- std::vector<std::string> getIOProcessorKeys() {
- std::vector<std::string> keys;
- std::map<std::string, IOProcessor>::const_iterator iter = self->getIOProcessors().begin();
- while(iter != self->getIOProcessors().end()) {
- keys.push_back(iter->first);
- iter++;
- }
- return keys;
- }
-
- std::vector<std::string> getInvokerKeys() {
- std::vector<std::string> keys;
- std::map<std::string, Invoker>::const_iterator iter = self->getInvokers().begin();
- while(iter != self->getInvokers().end()) {
- keys.push_back(iter->first);
- iter++;
- }
- return keys;
- }
-
-};
-
-%extend uscxml::Data {
- std::vector<std::string> getCompundKeys() {
- std::vector<std::string> keys;
- std::map<std::string, Data>::const_iterator iter = self->compound.begin();
- while(iter != self->compound.end()) {
- keys.push_back(iter->first);
- iter++;
- }
- return keys;
- }
-};
-
+%include "../uscxml_beautify.i"
//***********************************************
@@ -167,19 +151,21 @@ using namespace Arabica::DOM;
%include "../../../uscxml/Factory.h"
%include "../../../uscxml/Message.h"
%include "../../../uscxml/Interpreter.h"
-#include "../../../uscxml/DOMUtils.h"
-
-# %include <DOM/Document.hpp>
-# %include <DOM/Node.hpp>
-# %include <DOM/Element.hpp>
-# %include <DOM/Attr.hpp>
-# %include <DOM/Text.hpp>
+%include "../../../uscxml/concurrency/BlockingQueue.h"
%include "../wrapped/WrappedInvoker.h"
%include "../wrapped/WrappedDataModel.h"
+%include "../wrapped/WrappedExecutableContent.h"
+%include "../wrapped/WrappedIOProcessor.h"
+
-# %template(XMLDocument) Arabica::DOM::Document<std::string>;
-# %template(XMLNode) Arabica::DOM::Node<std::string>;
-# %template(XMLElement) Arabica::DOM::Element<std::string>;
-# %template(XMLAttr) Arabica::DOM::Attr<std::string>;
-# %template(XMLText) Arabica::DOM::Text<std::string>;
+%template(DataList) std::list<uscxml::Data>;
+%template(DataMap) std::map<std::string, uscxml::Data>;
+%template(StringSet) std::set<std::string>;
+%template(StringVector) std::vector<std::string>;
+%template(StringList) std::list<std::string>;
+%template(ParamPair) std::pair<std::string, uscxml::Data>;
+%template(ParamPairVector) std::vector<std::pair<std::string, uscxml::Data> >;
+%template(IOProcMap) std::map<std::string, uscxml::IOProcessor>;
+%template(InvokerMap) std::map<std::string, uscxml::Invoker>;
+%template(ParentQueue) uscxml::concurrency::BlockingQueue<uscxml::SendRequest>;