diff options
Diffstat (limited to 'src/bindings/swig')
-rw-r--r-- | src/bindings/swig/csharp/uscxml.i | 35 | ||||
-rw-r--r-- | src/bindings/swig/java/uscxml.i | 26 | ||||
-rw-r--r-- | src/bindings/swig/uscxml_ignores.i | 8 |
3 files changed, 69 insertions, 0 deletions
diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i index 2a1ac07..bd8c669 100644 --- a/src/bindings/swig/csharp/uscxml.i +++ b/src/bindings/swig/csharp/uscxml.i @@ -157,6 +157,41 @@ WRAP_TO_STRING(uscxml::InvokeRequest); // Beautify important classes //*********************************************** + +// byte[] signature for Blob get/setData +// see http://permalink.gmane.org/gmane.comp.programming.swig/5804 + +%csmethodmodifiers uscxml::Blob::Blob(const char* data, size_t size, const std::string& mimeType) "private"; +%typemap(cscode) uscxml::Blob %{ + public Blob(byte[] data, string mimeType) : this(uscxmlNativeCSharpPINVOKE.new_Blob(data, (uint)data.Length, mimeType), true) { + if (uscxmlNativeCSharpPINVOKE.SWIGPendingException.Pending) throw uscxmlNativeCSharpPINVOKE.SWIGPendingException.Retrieve(); + } +%} + +%typemap(imtype, out="System.IntPtr") const char *data "byte[]" +%typemap(cstype) const char *data "byte[]" +%typemap(in) const char *data %{ $1 = ($1_ltype)$input; %} +%typemap(csin) const char *data "$csinput" + +%typemap(imtype, out="System.IntPtr") char* getData "byte[]" +%typemap(cstype) char* getData "byte[]" + +%typemap(csout) char* getData %{ + { + byte[] ret = new byte[this.getSize()]; + System.IntPtr data = $imcall; + System.Runtime.InteropServices.Marshal.Copy(data, ret, 0, (int)this.getSize()); + return ret; + } +%} + +// make sure we do not get the default with SWIG_csharp_string_callback +%typemap(out) char* getData { + $result = (char *)result; +} + + + %csmethodmodifiers uscxml::Event::getParamMap() "private"; %csmethodmodifiers uscxml::Event::getParamMapKeys() "private"; %csmethodmodifiers uscxml::Event::setParamMap(const std::map<std::string, std::list<uscxml::Data> >&) "private"; diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i index ee95eb0..9610e77 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -112,6 +112,7 @@ WRAP_TO_STRING(uscxml::InvokeRequest); %include "../uscxml_ignores.i" +#if 0 // see http://swig.org/Doc2.0/Java.html#Java_date_marshalling %define BEAUTIFY_NATIVE( MATCH, WRAPPER, NATIVE ) @@ -164,6 +165,24 @@ BEAUTIFY_NATIVE(uscxml::Event, Event, EventNative); BEAUTIFY_NATIVE(uscxml::SendRequest, SendRequest, SendRequestNative); BEAUTIFY_NATIVE(uscxml::InvokeRequest, InvokeRequest, InvokeRequestNative); */ +#endif + +// bytearray for Blob::data +// see: http://stackoverflow.com/questions/9934059/swig-technique-to-wrap-unsigned-binary-data + +%apply (char *STRING, size_t LENGTH) { (const char* data, size_t size) }; + +%typemap(jni) char* getData "jbyteArray" +%typemap(jtype) char* getData "byte[]" +%typemap(jstype) char* getData "byte[]" +%typemap(javaout) char* getData { + return $jnicall; +} + +%typemap(out) char* getData { + $result = JCALL1(NewByteArray, jenv, ((uscxml::Blob const *)arg1)->getSize()); + JCALL4(SetByteArrayRegion, jenv, $result, 0, ((uscxml::Blob const *)arg1)->getSize(), (jbyte *)$1); +} //*********************************************** @@ -180,6 +199,9 @@ BEAUTIFY_NATIVE(uscxml::InvokeRequest, InvokeRequest, InvokeRequestNative); %javamethodmodifiers uscxml::Interpreter::getIOProcessors() "private"; %javamethodmodifiers uscxml::Data::getCompoundKeys() "private"; +%javamethodmodifiers uscxml::Blob::setData(const char* data, size_t length) "private"; +%javamethodmodifiers uscxml::Blob::setMimeType(const std::string& mimeType) "private"; + %include "../uscxml_beautify.i" @@ -231,6 +253,10 @@ import java.util.LinkedList; %} %typemap(javacode) uscxml::Data %{ + public Data(byte[] data, String mimeType) { + + } + public Data(Map<String, Data> compound) { this(uscxmlNativeJavaJNI.new_Data__SWIG_0(), true); setCompound(compound); diff --git a/src/bindings/swig/uscxml_ignores.i b/src/bindings/swig/uscxml_ignores.i index d54dae2..5e99416 100644 --- a/src/bindings/swig/uscxml_ignores.i +++ b/src/bindings/swig/uscxml_ignores.i @@ -189,6 +189,14 @@ %ignore uscxml::Data::toDocument; %ignore uscxml::Data::Data(const Arabica::DOM::Node<std::string>&); +%ignore uscxml::Data::Data(const char* data, size_t size, const std::string& mimeType, bool adopt); +%ignore uscxml::Data::Data(const char* data, size_t size, const std::string& mimeType); + +// Blob + +%ignore uscxml::Blob::Blob(size_t size); +%ignore uscxml::Blob::Blob(const char* data, size_t size, const std::string& mimeType, bool adopt); + %ignore operator!=; %ignore operator<; |