diff --git a/CHANGES.current b/CHANGES.current index 5fd6d6135..a30b026dc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.6 (in progress) =========================== +2015-05-10: wsfulton + [Java] Fix multi-argument typemaps (char *STRING, size_t LENGTH) + so that they can be applied to a wider range of types. Fixes #385. + 2015-05-07: olly [Python] Deal with an integer as the default value of a bool parameter in the C++ prototype. Fixes github #327, reported by diff --git a/Examples/test-suite/director_binary_string.i b/Examples/test-suite/director_binary_string.i index f842dc2c7..17bdc1b64 100644 --- a/Examples/test-suite/director_binary_string.i +++ b/Examples/test-suite/director_binary_string.i @@ -4,6 +4,7 @@ %apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) }; %apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) }; +%apply (char* STRING, size_t LENGTH) { (const void* data, size_t datalen) }; %inline %{ #include @@ -20,6 +21,7 @@ public: if (dataBufferBB) memset(dataBufferBB, -1, sizeBB); } + virtual void writeData(const void* data, size_t datalen) = 0; }; class Caller { @@ -50,6 +52,17 @@ public: void call_null() { _callback->run(NULL, 0, NULL, 0); } + int callWriteData() { + int sum = 0; + if (_callback) { + char* aa = (char*)malloc(BUFFER_SIZE_AA); + memset(aa, 9, BUFFER_SIZE_AA); + _callback->writeData(aa, BUFFER_SIZE_AA); + for (int i = 0; i < BUFFER_SIZE_AA; i++) + sum += aa[i]; + } + return sum; + } }; %} diff --git a/Examples/test-suite/java/director_binary_string_runme.java b/Examples/test-suite/java/director_binary_string_runme.java index 962073367..14982efc2 100644 --- a/Examples/test-suite/java/director_binary_string_runme.java +++ b/Examples/test-suite/java/director_binary_string_runme.java @@ -17,11 +17,15 @@ public class director_binary_string_runme { Callback callback = new DirectorBinaryStringCallback(); caller.setCallback(callback); int sum = caller.call(); + int sumData = caller.callWriteData(); caller.delCallback(); if (sum != 9*2*8 + 13*3*5) throw new RuntimeException("Unexpected sum: " + sum); + if (sumData != 9*2*8) + throw new RuntimeException("Unexpected sum: " + sum); + new Callback().run(null, null); callback = new DirectorBinaryStringCallback(); caller.setCallback(callback); @@ -45,5 +49,13 @@ class DirectorBinaryStringCallback extends Callback { for (int i = 0; i < dataBufferBB.length; i++) dataBufferBB[i] = (byte)(dataBufferBB[i] * 3); } + + @Override + public void writeData(byte[] dataBufferAA) + { + if (dataBufferAA != null) + for (int i = 0; i < dataBufferAA.length; i++) + dataBufferAA[i] = (byte)(dataBufferAA[i] * 2); + } } diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 9374f5783..37b3fa940 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1348,6 +1348,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %typemap(directorargout) (char *STRING, size_t LENGTH) %{(jenv)->GetByteArrayRegion($input, 0, $2, (jbyte *)$1); (jenv)->DeleteLocalRef($input);%} +%typemap(javadirectorin, descriptor="[B") (char *STRING, size_t LENGTH) "$jniinput" %apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) } /* java keywords */