summaryrefslogtreecommitdiff
path: root/Lib/java/java.swg
diff options
context:
space:
mode:
authorAndrew Galante <drew@perfectco.com>2017-07-26 13:59:08 -0700
committerAndrew Galante <drew@perfectco.com>2017-07-26 13:59:08 -0700
commit36b3c56a062b700f1a13f98fe52419f3f5fd498c (patch)
treebdc428bcc5ebce10b4a32fbd136041ff393d1f0e /Lib/java/java.swg
parent7ac21f3799ce5bd8eec629132c2ddaa170db948f (diff)
downloadswig-36b3c56a062b700f1a13f98fe52419f3f5fd498c.tar.gz
Prevent writeback of a const char* array through a director when using the byte[] %typemap.
Diffstat (limited to 'Lib/java/java.swg')
-rw-r--r--Lib/java/java.swg19
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index b49826ba0..56516439d 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -1366,12 +1366,12 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* String & length */
-%typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray"
-%typemap(jtype) (char *STRING, size_t LENGTH) "byte[]"
-%typemap(jstype) (char *STRING, size_t LENGTH) "byte[]"
-%typemap(javain) (char *STRING, size_t LENGTH) "$javainput"
-%typemap(freearg) (char *STRING, size_t LENGTH) ""
-%typemap(in) (char *STRING, size_t LENGTH) {
+%typemap(jni) (const char *STRING, size_t LENGTH) "jbyteArray"
+%typemap(jtype) (const char *STRING, size_t LENGTH) "byte[]"
+%typemap(jstype) (const char *STRING, size_t LENGTH) "byte[]"
+%typemap(javain) (const char *STRING, size_t LENGTH) "$javainput"
+%typemap(freearg) (const char *STRING, size_t LENGTH) ""
+%typemap(in) (const char *STRING, size_t LENGTH) {
if ($input) {
$1 = ($1_ltype) JCALL2(GetByteArrayElements, jenv, $input, 0);
$2 = ($2_type) JCALL1(GetArrayLength, jenv, $input);
@@ -1380,10 +1380,10 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
$2 = 0;
}
}
-%typemap(argout) (char *STRING, size_t LENGTH) {
+%typemap(argout) (const char *STRING, size_t LENGTH) {
if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
-%typemap(directorin, descriptor="[B", noblock=1) (char *STRING, size_t LENGTH) {
+%typemap(directorin, descriptor="[B", noblock=1) (const char *STRING, size_t LENGTH) {
$input = 0;
if ($1) {
$input = JCALL1(NewByteArray, jenv, (jsize)$2);
@@ -1392,9 +1392,10 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
}
Swig::LocalRefGuard $1_refguard(jenv, $input);
}
+%typemap(javadirectorin, descriptor="[B") (const char *STRING, size_t LENGTH) "$jniinput"
+%apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) }
%typemap(directorargout, noblock=1) (char *STRING, size_t LENGTH)
{ if ($input && $1) JCALL4(GetByteArrayRegion, jenv, $input, 0, (jsize)$2, (jbyte *)$1); }
-%typemap(javadirectorin, descriptor="[B") (char *STRING, size_t LENGTH) "$jniinput"
%apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) }
/* java keywords */