Fix member pointers on 64 bit platforms for Java
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12031 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d324633cfa
commit
9df4479a08
2 changed files with 95 additions and 9 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
Version 2.0.0 (in progress)
|
Version 2.0.0 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2010-05-18: wsfulton
|
||||||
|
[Java] Fix member pointers on 64 bit platforms.
|
||||||
|
|
||||||
2010-05-14: wsfulton
|
2010-05-14: wsfulton
|
||||||
Fix wrapping of C++ enum boolean values reported by Torsten Landschoff:
|
Fix wrapping of C++ enum boolean values reported by Torsten Landschoff:
|
||||||
typedef enum { PLAY = true, STOP = false } play_state;
|
typedef enum { PLAY = true, STOP = false } play_state;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,49 @@
|
||||||
* The jtype typemap contains the Java type used in the JNI intermediary class.
|
* The jtype typemap contains the Java type used in the JNI intermediary class.
|
||||||
* The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */
|
* The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */
|
||||||
|
|
||||||
|
/* Fragments */
|
||||||
|
%fragment("SWIG_PackData", "header") {
|
||||||
|
/* Pack binary data into a string */
|
||||||
|
SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
|
||||||
|
static const char hex[17] = "0123456789abcdef";
|
||||||
|
register const unsigned char *u = (unsigned char *) ptr;
|
||||||
|
register const unsigned char *eu = u + sz;
|
||||||
|
for (; u != eu; ++u) {
|
||||||
|
register unsigned char uu = *u;
|
||||||
|
*(c++) = hex[(uu & 0xf0) >> 4];
|
||||||
|
*(c++) = hex[uu & 0xf];
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%fragment("SWIG_UnPackData", "header") {
|
||||||
|
/* Unpack binary data from a string */
|
||||||
|
SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
|
register unsigned char *u = (unsigned char *) ptr;
|
||||||
|
register const unsigned char *eu = u + sz;
|
||||||
|
for (; u != eu; ++u) {
|
||||||
|
register char d = *(c++);
|
||||||
|
register unsigned char uu;
|
||||||
|
if ((d >= '0') && (d <= '9'))
|
||||||
|
uu = ((d - '0') << 4);
|
||||||
|
else if ((d >= 'a') && (d <= 'f'))
|
||||||
|
uu = ((d - ('a'-10)) << 4);
|
||||||
|
else
|
||||||
|
return (char *) 0;
|
||||||
|
d = *(c++);
|
||||||
|
if ((d >= '0') && (d <= '9'))
|
||||||
|
uu |= (d - '0');
|
||||||
|
else if ((d >= 'a') && (d <= 'f'))
|
||||||
|
uu |= (d - ('a'-10));
|
||||||
|
else
|
||||||
|
return (char *) 0;
|
||||||
|
*u = uu;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Primitive types */
|
/* Primitive types */
|
||||||
%typemap(jni) bool, const bool & "jboolean"
|
%typemap(jni) bool, const bool & "jboolean"
|
||||||
%typemap(jni) char, const char & "jchar"
|
%typemap(jni) char, const char & "jchar"
|
||||||
|
|
@ -143,8 +186,8 @@
|
||||||
%typemap(jstype) SWIGTYPE & "$javaclassname"
|
%typemap(jstype) SWIGTYPE & "$javaclassname"
|
||||||
|
|
||||||
/* pointer to a class member */
|
/* pointer to a class member */
|
||||||
%typemap(jni) SWIGTYPE (CLASS::*) "jlong"
|
%typemap(jni) SWIGTYPE (CLASS::*) "jstring"
|
||||||
%typemap(jtype) SWIGTYPE (CLASS::*) "long"
|
%typemap(jtype) SWIGTYPE (CLASS::*) "String"
|
||||||
%typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname"
|
%typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname"
|
||||||
|
|
||||||
/* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */
|
/* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */
|
||||||
|
|
@ -592,20 +635,39 @@
|
||||||
%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
|
%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
|
||||||
|
|
||||||
/* Generic pointers and references */
|
/* Generic pointers and references */
|
||||||
%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
|
%typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %}
|
||||||
|
%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) {
|
||||||
|
const char *temp = 0;
|
||||||
|
if ($input) {
|
||||||
|
temp = JCALL2(GetStringUTFChars, jenv, $input, 0);
|
||||||
|
if (!temp) return $null;
|
||||||
|
}
|
||||||
|
SWIG_UnpackData(temp, (void *)&$1, sizeof($1));
|
||||||
|
}
|
||||||
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
|
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
|
||||||
if (!$1) {
|
if (!$1) {
|
||||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
||||||
return $null;
|
return $null;
|
||||||
} %}
|
} %}
|
||||||
%typemap(out) SWIGTYPE *, SWIGTYPE (CLASS::*)
|
%typemap(out) SWIGTYPE *
|
||||||
%{ *($&1_ltype)&$result = $1; %}
|
%{ *($&1_ltype)&$result = $1; %}
|
||||||
|
%typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) {
|
||||||
|
char buf[128];
|
||||||
|
char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
|
||||||
|
*data = '\0';
|
||||||
|
$result = JCALL1(NewStringUTF, jenv, buf);
|
||||||
|
}
|
||||||
%typemap(out) SWIGTYPE &
|
%typemap(out) SWIGTYPE &
|
||||||
%{ *($&1_ltype)&$result = $1; %}
|
%{ *($&1_ltype)&$result = $1; %}
|
||||||
|
|
||||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *, SWIGTYPE (CLASS::*)
|
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
|
||||||
%{ $result = *($&1_ltype)&$input; %}
|
%{ $result = *($&1_ltype)&$input; %}
|
||||||
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *, SWIGTYPE (CLASS::*)
|
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
|
||||||
|
%{ $result = *($&1_ltype)&$input; %}
|
||||||
|
|
||||||
|
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *
|
||||||
|
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
|
||||||
|
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE (CLASS::*)
|
||||||
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
|
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
|
||||||
|
|
||||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
|
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
|
||||||
|
|
@ -967,7 +1029,8 @@
|
||||||
jobjectArray
|
jobjectArray
|
||||||
"$javainput"
|
"$javainput"
|
||||||
%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
|
%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
|
||||||
%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$javaclassname.getCPtr($javainput)"
|
%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
|
||||||
|
%typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)"
|
||||||
|
|
||||||
/* The javaout typemap is used for converting function return types from the return type
|
/* The javaout typemap is used for converting function return types from the return type
|
||||||
* used in the JNI class to the type returned by the proxy, module or type wrapper class. */
|
* used in the JNI class to the type returned by the proxy, module or type wrapper class. */
|
||||||
|
|
@ -1020,10 +1083,14 @@
|
||||||
%typemap(javaout) SWIGTYPE & {
|
%typemap(javaout) SWIGTYPE & {
|
||||||
return new $javaclassname($jnicall, $owner);
|
return new $javaclassname($jnicall, $owner);
|
||||||
}
|
}
|
||||||
%typemap(javaout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) {
|
%typemap(javaout) SWIGTYPE *, SWIGTYPE [] {
|
||||||
long cPtr = $jnicall;
|
long cPtr = $jnicall;
|
||||||
return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner);
|
return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner);
|
||||||
}
|
}
|
||||||
|
%typemap(javaout) SWIGTYPE (CLASS::*) {
|
||||||
|
String cMemberPtr = $jnicall;
|
||||||
|
return (cMemberPtr == null) ? null : new $javaclassname(cMemberPtr, $owner);
|
||||||
|
}
|
||||||
|
|
||||||
/* Pointer reference typemaps */
|
/* Pointer reference typemaps */
|
||||||
%typemap(jni) SWIGTYPE *const& "jlong"
|
%typemap(jni) SWIGTYPE *const& "jlong"
|
||||||
|
|
@ -1086,7 +1153,7 @@
|
||||||
SWIG_JAVABODY_METHODS(public, public, SWIGTYPE)
|
SWIG_JAVABODY_METHODS(public, public, SWIGTYPE)
|
||||||
|
|
||||||
// Typewrapper classes
|
// Typewrapper classes
|
||||||
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
|
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{
|
||||||
private long swigCPtr;
|
private long swigCPtr;
|
||||||
|
|
||||||
protected $javaclassname(long cPtr, boolean futureUse) {
|
protected $javaclassname(long cPtr, boolean futureUse) {
|
||||||
|
|
@ -1102,6 +1169,22 @@ SWIG_JAVABODY_METHODS(public, public, SWIGTYPE)
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%typemap(javabody) SWIGTYPE (CLASS::*) %{
|
||||||
|
private String swigCMemberPtr;
|
||||||
|
|
||||||
|
protected $javaclassname(String cMemberPtr, boolean futureUse) {
|
||||||
|
swigCMemberPtr = cMemberPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $javaclassname() {
|
||||||
|
swigCMemberPtr = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static String getCMemberPtr($javaclassname obj) {
|
||||||
|
return obj.swigCMemberPtr;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
%typemap(javafinalize) SWIGTYPE %{
|
%typemap(javafinalize) SWIGTYPE %{
|
||||||
protected void finalize() {
|
protected void finalize() {
|
||||||
delete();
|
delete();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue