char *& typemaps added
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10295 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c99fe90574
commit
2cf3cb3dc9
6 changed files with 82 additions and 12 deletions
|
|
@ -1,6 +1,12 @@
|
||||||
Version 1.3.35 (in progress)
|
Version 1.3.35 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
03/04/2008: wsfulton
|
||||||
|
[Java, C#] Add char *& typemaps.
|
||||||
|
|
||||||
|
03/04/2008: wsfulton
|
||||||
|
Fix occasional seg fault when attempting to report overloaded methods as being ignored.
|
||||||
|
|
||||||
02/29/2008: wsfulton
|
02/29/2008: wsfulton
|
||||||
[Perl] Fix #1904537 Swig causes a Perl warning "x used only once" in Perl 5.10
|
[Perl] Fix #1904537 Swig causes a Perl warning "x used only once" in Perl 5.10
|
||||||
reported by Ari Jolma
|
reported by Ari Jolma
|
||||||
|
|
|
||||||
|
|
@ -137,3 +137,22 @@ const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
|
||||||
|
// char *& tests
|
||||||
|
const char *&GetConstCharPointerRef() {
|
||||||
|
static const char str[] = CPLUSPLUS_MSG;
|
||||||
|
static const char *ptr = str;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetConstCharPointerRef(const char *&str, unsigned int number) {
|
||||||
|
static char static_str[] = CPLUSPLUS_MSG;
|
||||||
|
strcpy(static_str, str);
|
||||||
|
return check(static_str, number);
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,18 @@ public class char_strings_runme {
|
||||||
if (char_strings.global_const_char_array2 != CPLUSPLUS_MSG)
|
if (char_strings.global_const_char_array2 != CPLUSPLUS_MSG)
|
||||||
throw new Exception("Test variables 6 failed, iteration " + i);
|
throw new Exception("Test variables 6 failed, iteration " + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// char *& tests
|
||||||
|
for (i=0; i<count; i++) {
|
||||||
|
String str = char_strings.GetConstCharPointerRef();
|
||||||
|
if (str != CPLUSPLUS_MSG)
|
||||||
|
throw new Exception("Test char pointer ref get failed, iteration " + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<count; i++) {
|
||||||
|
if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
|
||||||
|
throw new Exception("Test char pointer ref set failed, iteration " + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,18 @@ public class char_strings_runme {
|
||||||
if (!char_strings.getGlobal_const_char_array2().equals(CPLUSPLUS_MSG))
|
if (!char_strings.getGlobal_const_char_array2().equals(CPLUSPLUS_MSG))
|
||||||
throw new RuntimeException("Test variables 6 failed, iteration " + i);
|
throw new RuntimeException("Test variables 6 failed, iteration " + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// char *& tests
|
||||||
|
for (i=0; i<count; i++) {
|
||||||
|
String str = char_strings.GetConstCharPointerRef();
|
||||||
|
if (!str.equals(CPLUSPLUS_MSG))
|
||||||
|
throw new RuntimeException("Test char pointer ref get failed, iteration " + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<count; i++) {
|
||||||
|
if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
|
||||||
|
throw new RuntimeException("Test char pointer ref set failed, iteration " + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,9 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
%typemap(cstype) double, const double & "double"
|
%typemap(cstype) double, const double & "double"
|
||||||
%typemap(cstype) void "void"
|
%typemap(cstype) void "void"
|
||||||
|
|
||||||
%typemap(ctype) char *, char[ANY], char[] "char *"
|
%typemap(ctype) char *, char *&, char[ANY], char[] "char *"
|
||||||
%typemap(imtype) char *, char[ANY], char[] "string"
|
%typemap(imtype) char *, char *&, char[ANY], char[] "string"
|
||||||
%typemap(cstype) char *, char[ANY], char[] "string"
|
%typemap(cstype) char *, char *&, char[ANY], char[] "string"
|
||||||
|
|
||||||
/* Non primitive types */
|
/* Non primitive types */
|
||||||
%typemap(ctype) SWIGTYPE "void *"
|
%typemap(ctype) SWIGTYPE "void *"
|
||||||
|
|
@ -243,6 +243,13 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
%typemap(csdirectorin) char * "$iminput"
|
%typemap(csdirectorin) char * "$iminput"
|
||||||
%typemap(csdirectorout) char * "$cscall"
|
%typemap(csdirectorout) char * "$cscall"
|
||||||
|
|
||||||
|
/* char *& - treat as String */
|
||||||
|
%typemap(in) char *& ($*1_ltype temp = 0) %{
|
||||||
|
temp = ($*1_ltype)$input;
|
||||||
|
$1 = &temp;
|
||||||
|
%}
|
||||||
|
%typemap(out) char *& %{ if ($1) $result = SWIG_csharp_string_callback((const char *)*$1); %}
|
||||||
|
|
||||||
%typemap(out, null="") void ""
|
%typemap(out, null="") void ""
|
||||||
%typemap(csdirectorin) void "$iminput"
|
%typemap(csdirectorin) void "$iminput"
|
||||||
%typemap(csdirectorout) void "$cscall"
|
%typemap(csdirectorout) void "$cscall"
|
||||||
|
|
@ -508,6 +515,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
|
|
||||||
%typecheck(SWIG_TYPECHECK_STRING)
|
%typecheck(SWIG_TYPECHECK_STRING)
|
||||||
char *,
|
char *,
|
||||||
|
char *&,
|
||||||
char[ANY],
|
char[ANY],
|
||||||
char[]
|
char[]
|
||||||
""
|
""
|
||||||
|
|
@ -562,7 +570,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
float, const float &,
|
float, const float &,
|
||||||
double, const double &
|
double, const double &
|
||||||
"$csinput"
|
"$csinput"
|
||||||
%typemap(csin) char *, char[ANY], char[] "$csinput"
|
%typemap(csin) char *, char *&, char[ANY], char[] "$csinput"
|
||||||
%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)"
|
%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)"
|
||||||
%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
|
%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
|
||||||
%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)"
|
%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)"
|
||||||
|
|
@ -632,7 +640,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
double ret = $imcall;$excode
|
double ret = $imcall;$excode
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
%typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] {
|
%typemap(csout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] {
|
||||||
string ret = $imcall;$excode
|
string ret = $imcall;$excode
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -665,7 +673,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
$imcall;$excode
|
$imcall;$excode
|
||||||
} %}
|
} %}
|
||||||
|
|
||||||
%typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{
|
%typemap(csvarin, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{
|
||||||
set {
|
set {
|
||||||
$imcall;$excode
|
$imcall;$excode
|
||||||
} %}
|
} %}
|
||||||
|
|
@ -742,7 +750,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
} %}
|
} %}
|
||||||
|
|
||||||
|
|
||||||
%typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{
|
%typemap(csvarout, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{
|
||||||
get {
|
get {
|
||||||
string ret = $imcall;$excode
|
string ret = $imcall;$excode
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,9 @@
|
||||||
%typemap(jstype) double, const double & "double"
|
%typemap(jstype) double, const double & "double"
|
||||||
%typemap(jstype) void "void"
|
%typemap(jstype) void "void"
|
||||||
|
|
||||||
%typemap(jni) char *, char[ANY], char[] "jstring"
|
%typemap(jni) char *, char *&, char[ANY], char[] "jstring"
|
||||||
%typemap(jtype) char *, char[ANY], char[] "String"
|
%typemap(jtype) char *, char *&, char[ANY], char[] "String"
|
||||||
%typemap(jstype) char *, char[ANY], char[] "String"
|
%typemap(jstype) char *, char *&, char[ANY], char[] "String"
|
||||||
|
|
||||||
/* JNI types */
|
/* JNI types */
|
||||||
%typemap(jni) jboolean "jboolean"
|
%typemap(jni) jboolean "jboolean"
|
||||||
|
|
@ -368,6 +368,18 @@
|
||||||
%typemap(javadirectorin) char * "$jniinput"
|
%typemap(javadirectorin) char * "$jniinput"
|
||||||
%typemap(javadirectorout) char * "$javacall"
|
%typemap(javadirectorout) char * "$javacall"
|
||||||
|
|
||||||
|
/* char *& - treat as String */
|
||||||
|
%typemap(in, noblock=1) char *& ($*1_ltype temp = 0) {
|
||||||
|
$1 = 0;
|
||||||
|
if ($input) {
|
||||||
|
temp = ($*1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
|
||||||
|
if (!temp) return $null;
|
||||||
|
}
|
||||||
|
$1 = &temp;
|
||||||
|
}
|
||||||
|
%typemap(freearg, noblock=1) char *& { if ($1 && *$1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)*$1); }
|
||||||
|
%typemap(out, noblock=1) char *& { if(*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); }
|
||||||
|
|
||||||
%typemap(out) void ""
|
%typemap(out) void ""
|
||||||
%typemap(javadirectorin) void "$jniinput"
|
%typemap(javadirectorin) void "$jniinput"
|
||||||
%typemap(javadirectorout) void "$javacall"
|
%typemap(javadirectorout) void "$javacall"
|
||||||
|
|
@ -842,6 +854,7 @@
|
||||||
%typecheck(SWIG_TYPECHECK_STRING) /* Java String */
|
%typecheck(SWIG_TYPECHECK_STRING) /* Java String */
|
||||||
jstring,
|
jstring,
|
||||||
char *,
|
char *,
|
||||||
|
char *&,
|
||||||
char[ANY],
|
char[ANY],
|
||||||
char []
|
char []
|
||||||
""
|
""
|
||||||
|
|
@ -933,7 +946,7 @@
|
||||||
float, const float &,
|
float, const float &,
|
||||||
double, const double &
|
double, const double &
|
||||||
"$javainput"
|
"$javainput"
|
||||||
%typemap(javain) char *, char[ANY], char[] "$javainput"
|
%typemap(javain) char *, char *&, char[ANY], char[] "$javainput"
|
||||||
%typemap(javain) jboolean,
|
%typemap(javain) jboolean,
|
||||||
jchar,
|
jchar,
|
||||||
jbyte,
|
jbyte,
|
||||||
|
|
@ -975,7 +988,7 @@
|
||||||
double, const double & {
|
double, const double & {
|
||||||
return $jnicall;
|
return $jnicall;
|
||||||
}
|
}
|
||||||
%typemap(javaout) char *, char[ANY], char[] {
|
%typemap(javaout) char *, char *&, char[ANY], char[] {
|
||||||
return $jnicall;
|
return $jnicall;
|
||||||
}
|
}
|
||||||
%typemap(javaout) jboolean,
|
%typemap(javaout) jboolean,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue