mirror of https://github.com/swig/swig
ensure %apply with char*, unsigned char* and signed char* works
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9072 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
468ad3c74b
commit
2d24918a97
|
@ -0,0 +1,16 @@
|
|||
|
||||
using System;
|
||||
using apply_stringsNamespace;
|
||||
|
||||
public class apply_strings_runme {
|
||||
|
||||
private static string TEST_MESSAGE = "A message from target language to the C++ world and back again.";
|
||||
|
||||
public static void Main() {
|
||||
if (apply_strings.UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed");
|
||||
if (apply_strings.SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed");
|
||||
SWIGTYPE_p_char pChar = apply_strings.CharFunction(null);
|
||||
if (pChar != null) throw new Exception("CharFunction failed");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
import apply_strings.*;
|
||||
|
||||
public class apply_strings_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("apply_strings");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static String TEST_MESSAGE = "A message from target language to the C++ world and back again.";
|
||||
|
||||
public static void main(String argv[]) {
|
||||
if (!apply_strings.UCharFunction(TEST_MESSAGE).equals(TEST_MESSAGE)) throw new RuntimeException("UCharFunction failed");
|
||||
if (!apply_strings.SCharFunction(TEST_MESSAGE).equals(TEST_MESSAGE)) throw new RuntimeException("SCharFunction failed");
|
||||
SWIGTYPE_p_char pChar = apply_strings.CharFunction(null);
|
||||
if (pChar != null) throw new RuntimeException("CharFunction failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
use apply_strings;
|
||||
|
||||
my $TEST_MESSAGE = "A message from target language to the C++ world and back again.";
|
||||
|
||||
if (apply_strings::UCharFunction($TEST_MESSAGE) ne $TEST_MESSAGE) {
|
||||
die "UCharFunction failed";
|
||||
}
|
||||
if (apply_strings::SCharFunction($TEST_MESSAGE) ne $TEST_MESSAGE) {
|
||||
die "SCharFunction failed";
|
||||
}
|
|
@ -126,8 +126,8 @@
|
|||
%typemap(out) double %{ $result = $1; %}
|
||||
|
||||
/* char * - treat as String */
|
||||
%typemap(in) char * %{ $1 = $input; %}
|
||||
%typemap(out) char * %{ $result = SWIG_csharp_string_callback($1); %}
|
||||
%typemap(in) char * %{ $1 = ($1_type)$input; %}
|
||||
%typemap(out) char * %{ $result = SWIG_csharp_string_callback((const char *)$1); %}
|
||||
|
||||
%typemap(out, null="") void ""
|
||||
|
||||
|
|
|
@ -289,11 +289,11 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
|||
/* Strings */
|
||||
|
||||
%typemap (in, doc="$NAME is a string") char *(int must_free = 0) {
|
||||
$1 = SWIG_scm2str($input);
|
||||
$1 = ($1_type)SWIG_scm2str($input);
|
||||
must_free = 1;
|
||||
}
|
||||
%typemap (varin, doc="NEW-VALUE is a string") char * {$1 = SWIG_scm2str($input);}
|
||||
%typemap (out, doc="<string>") char * {$result = gh_str02scm($1);}
|
||||
%typemap (out, doc="<string>") char * {$result = gh_str02scm((const char *)$1);}
|
||||
%typemap (varout, doc="<string>") char * {$result = gh_str02scm($1);}
|
||||
%typemap (in, doc="$NAME is a string") char * *INPUT(char * temp, int must_free = 0) {
|
||||
temp = (char *) SWIG_scm2str($input); $1 = &temp;
|
||||
|
|
|
@ -358,13 +358,13 @@
|
|||
%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * {
|
||||
$input = 0;
|
||||
if ($1) {
|
||||
$input = JCALL1(NewStringUTF, jenv, $1);
|
||||
$input = JCALL1(NewStringUTF, jenv, (const char *)$1);
|
||||
if (!$input) return $null;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); }
|
||||
%typemap(out, noblock=1) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); }
|
||||
%typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
|
||||
%typemap(out, noblock=1) char * { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
|
||||
%typemap(javadirectorin) char * "$jniinput"
|
||||
%typemap(javadirectorout) char * "$javacall"
|
||||
|
||||
|
@ -629,14 +629,14 @@
|
|||
%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char[ANY], char[] {
|
||||
$input = 0;
|
||||
if ($1) {
|
||||
$input = JCALL1(NewStringUTF, jenv, $1);
|
||||
$input = JCALL1(NewStringUTF, jenv, (const char *)$1);
|
||||
if (!$input) return $null;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(argout) char[ANY], char[] ""
|
||||
%typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); }
|
||||
%typemap(out, noblock=1) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, $1); }
|
||||
%typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
|
||||
%typemap(out, noblock=1) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
|
||||
%typemap(javadirectorin) char[ANY], char[] "$jniinput"
|
||||
%typemap(javadirectorout) char[ANY], char[] "$javacall"
|
||||
|
||||
|
|
|
@ -67,10 +67,16 @@
|
|||
%{ lua_pushboolean(L,(int)*$1); SWIG_arg++;%}
|
||||
|
||||
// strings (char* and char[])
|
||||
%typemap(in,checkfn="lua_isstring") const char*, char*, const char[ANY], char[ANY]
|
||||
%typemap(in,checkfn="lua_isstring") const char*, char*
|
||||
%{$1 = ($1_type)lua_tostring(L, $input);%}
|
||||
|
||||
%typemap(in,checkfn="lua_isstring") const char[ANY], char[ANY]
|
||||
%{$1 = (char*)lua_tostring(L, $input);%}
|
||||
|
||||
%typemap(out) const char*, char*, const char[ANY], char[ANY]
|
||||
%typemap(out) const char*, char*
|
||||
%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%}
|
||||
|
||||
%typemap(out) const char[ANY], char[ANY]
|
||||
%{ lua_pushstring(L,$1); SWIG_arg++;%}
|
||||
|
||||
// char's
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res,"$type",$symname, $argnum);
|
||||
}
|
||||
$1 = buf;
|
||||
$1 = ($1_type)buf;
|
||||
}
|
||||
%typemap(freearg,noblock=1,match="in") Char *, const Char * {
|
||||
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||
|
@ -55,7 +55,7 @@
|
|||
/* out */
|
||||
|
||||
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char* {
|
||||
%set_output(SWIG_FromCharPtr($1));
|
||||
%set_output(SWIG_FromCharPtr((const Char *)$1));
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,7 +102,7 @@
|
|||
%set_varoutput(SWIG_FromCharPtr($1));
|
||||
}
|
||||
|
||||
/* meberin */
|
||||
/* memberin */
|
||||
|
||||
%typemap(memberin,noblock=1) Char * {
|
||||
if ($1) %delete_array($1);
|
||||
|
@ -159,7 +159,7 @@
|
|||
%typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtr)
|
||||
Char *, Char const*, Char *const, Char const *const,
|
||||
Char const *&, Char *const &, Char const *const & {
|
||||
$input = SWIG_FromCharPtr($1_name);
|
||||
$input = SWIG_FromCharPtr((const Char *)$1_name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,7 +174,7 @@
|
|||
if (alloc == SWIG_NEWOBJ) {
|
||||
swig_acquire_ownership_array(buf);
|
||||
}
|
||||
$result = buf;
|
||||
$result = ($1_type)buf;
|
||||
}
|
||||
%typemap(directorfree,noblock=1) Char *
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue