std::string typemap modifications so they can be used with %apply for other string classes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13120 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
49b6c39d98
commit
12a9671440
13 changed files with 37 additions and 33 deletions
|
|
@ -4,6 +4,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
|
||||
Version 2.0.7 (in progress)
|
||||
===========================
|
||||
2012-05-26: wsfulton
|
||||
std::string typemap modifications so they can be used with %apply for other string
|
||||
classes.
|
||||
|
||||
2012-05-25: wsfulton
|
||||
[Lua] Fixes for -external-runtime to work again.
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ namespace std {
|
|||
// SWIG_exception(SWIG_TypeError, "string expected");
|
||||
// }
|
||||
|
||||
// %typemap(in) const string & (std::string temp) {
|
||||
// %typemap(in) const string & ($*1_ltype temp) {
|
||||
// if (caml_ptr_check($input)) {
|
||||
// temp.assign((char *)caml_ptr_val($input,0),
|
||||
// caml_string_len($input));
|
||||
|
|
@ -131,7 +131,7 @@ namespace std {
|
|||
// }
|
||||
// }
|
||||
|
||||
// %typemap(in) string & (std::string temp) {
|
||||
// %typemap(in) string & ($*1_ltype temp) {
|
||||
// if (caml_ptr_check($input)) {
|
||||
// temp.assign((char *)caml_ptr_val($input,0),
|
||||
// caml_string_len($input));
|
||||
|
|
@ -141,9 +141,9 @@ namespace std {
|
|||
// }
|
||||
// }
|
||||
|
||||
// %typemap(in) string * (std::string *temp) {
|
||||
// %typemap(in) string * ($*1_ltype *temp) {
|
||||
// if (caml_ptr_check($input)) {
|
||||
// temp = new std::string((char *)caml_ptr_val($input,0),
|
||||
// temp = new $*1_ltype((char *)caml_ptr_val($input,0),
|
||||
// caml_string_len($input));
|
||||
// $1 = temp;
|
||||
// } else {
|
||||
|
|
@ -151,7 +151,7 @@ namespace std {
|
|||
// }
|
||||
// }
|
||||
|
||||
// %typemap(free) string * (std::string *temp) {
|
||||
// %typemap(free) string * ($*1_ltype *temp) {
|
||||
// delete temp;
|
||||
// }
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) const string& (std::string temp, char *tempptr) {
|
||||
%typemap(in) const string& ($*1_ltype temp, char *tempptr) {
|
||||
|
||||
if ($input == C_SCHEME_FALSE) {
|
||||
temp.resize(0);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class string;
|
|||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
|
||||
return $null;
|
||||
}
|
||||
std::string $1_str($input);
|
||||
$*1_ltype $1_str($input);
|
||||
$1 = &$1_str; %}
|
||||
%typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class string;
|
|||
return $null;
|
||||
}
|
||||
/* possible thread/reentrant code problem */
|
||||
static std::string $1_str;
|
||||
static $*1_ltype $1_str;
|
||||
$1_str = $input;
|
||||
$result = &$1_str; %}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class string;
|
|||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
return $null;
|
||||
}
|
||||
std::string $1_str($input);
|
||||
$*1_ltype $1_str($input);
|
||||
$1 = &$1_str; %}
|
||||
|
||||
%typemap(out) string %{ $result = SWIG_d_string_callback($1.c_str()); %}
|
||||
|
|
@ -63,7 +63,7 @@ class string;
|
|||
return $null;
|
||||
}
|
||||
/* possible thread/reentrant code problem */
|
||||
static std::string $1_str;
|
||||
static $*1_ltype $1_str;
|
||||
$1_str = $input;
|
||||
$result = &$1_str; %}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,13 @@ class string;
|
|||
|
||||
%typemap(in) const string &
|
||||
%{
|
||||
std::string $1_str($input.p, $input.n);
|
||||
$*1_ltype $1_str($input.p, $input.n);
|
||||
$1 = &$1_str;
|
||||
%}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{
|
||||
static std::string $1_str;
|
||||
static $*1_ltype $1_str;
|
||||
$1_str.assign($input.p, $input.n);
|
||||
$result = &$1_str;
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp, char *tempptr) {
|
||||
%typemap(in) const string & ($*1_ltype temp, char *tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
temp.assign(tempptr);
|
||||
|
|
@ -50,7 +50,7 @@ namespace std {
|
|||
%typemap(in) string * (char *tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
$1 = new std::string(tempptr);
|
||||
$1 = new $*1_ltype(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class string;
|
|||
|
||||
%typemap(in) string
|
||||
%{ if(!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return $null;
|
||||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
|
|
@ -38,7 +38,7 @@ class string;
|
|||
|
||||
%typemap(directorout) string
|
||||
%{ if(!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return $null;
|
||||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
|
|
@ -73,24 +73,24 @@ class string;
|
|||
|
||||
%typemap(in) const string &
|
||||
%{ if(!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return $null;
|
||||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
if (!$1_pstr) return $null;
|
||||
std::string $1_str($1_pstr);
|
||||
$*1_ltype $1_str($1_pstr);
|
||||
$1 = &$1_str;
|
||||
jenv->ReleaseStringUTFChars($input, $1_pstr); %}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{ if(!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return $null;
|
||||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
if (!$1_pstr) return $null;
|
||||
/* possible thread/reentrant code problem */
|
||||
static std::string $1_str;
|
||||
static $*1_ltype $1_str;
|
||||
$1_str = $1_pstr;
|
||||
$result = &$1_str;
|
||||
jenv->ReleaseStringUTFChars($input, $1_pstr); %}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ Not using: lua_tolstring() as this is only found in Lua 5.1 & not 5.0.2
|
|||
%typemap(out) std::string
|
||||
%{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_arg++;%}
|
||||
|
||||
%typemap(in,checkfn="lua_isstring") const std::string& (std::string temp)
|
||||
%typemap(in,checkfn="lua_isstring") const std::string& ($*1_ltype temp)
|
||||
%{temp.assign(lua_tostring(L,$input),lua_rawlen(L,$input)); $1=&temp;%}
|
||||
|
||||
%typemap(out) const std::string&
|
||||
|
|
@ -84,7 +84,7 @@ typemaps to tell SWIG what to do.
|
|||
*/
|
||||
|
||||
%typemap(in) std::string &INPUT=const std::string &;
|
||||
%typemap(in, numinputs=0) std::string &OUTPUT (std::string temp)
|
||||
%typemap(in, numinputs=0) std::string &OUTPUT ($*1_ltype temp)
|
||||
%{ $1 = &temp; %}
|
||||
%typemap(argout) std::string &OUTPUT
|
||||
%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace std {
|
|||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp) {
|
||||
%typemap(in) const string & ($*1_ltype temp) {
|
||||
if (SCHEME_STRINGP($input)) {
|
||||
temp.assign(SCHEME_STR_VAL($input));
|
||||
$1 = &temp;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class wstring;
|
|||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp) {
|
||||
%typemap(in) const string & ($*1_ltype temp) {
|
||||
/* %typemap(in) const string & */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
|
|
@ -46,7 +46,7 @@ class wstring;
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) string & (std::string temp) {
|
||||
%typemap(in) string & ($*1_ltype temp) {
|
||||
/* %typemap(in) string & */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
|
|
@ -56,17 +56,17 @@ class wstring;
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) string * (std::string *temp) {
|
||||
%typemap(in) string * ($*1_ltype *temp) {
|
||||
/* %typemap(in) string * */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp = new std::string((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
temp = new $*1_ltype((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
$1 = temp;
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(free) string * (std::string *temp) {
|
||||
%typemap(free) string * ($*1_ltype *temp) {
|
||||
delete temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,15 +56,15 @@ namespace std {
|
|||
|
||||
/* These next two handle a function which takes a non-const reference to
|
||||
* a std::string and modifies the string. */
|
||||
%typemap(in) string & (std::string temp) %{
|
||||
%typemap(in) string & ($*1_ltype temp) %{
|
||||
convert_to_string_ex($input);
|
||||
temp.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
$1 = &temp;
|
||||
%}
|
||||
|
||||
%typemap(directorout) string & (std::string *temp) %{
|
||||
%typemap(directorout) string & ($*1_ltype *temp) %{
|
||||
convert_to_string_ex($input);
|
||||
temp = new std::string(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
temp = new $*1_ltype(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
swig_acquire_ownership(temp);
|
||||
$result = temp;
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace std {
|
|||
$1.assign(STR0($input.u.string));
|
||||
}
|
||||
|
||||
%typemap(in, pikedesc="tStr") const string & (std::string temp) {
|
||||
%typemap(in, pikedesc="tStr") const string & ($*1_ltype temp) {
|
||||
if ($input.type != T_STRING)
|
||||
Pike_error("Bad argument: Expected a string.\n");
|
||||
temp.assign(STR0($input.u.string));
|
||||
|
|
@ -47,7 +47,7 @@ namespace std {
|
|||
throw Swig::DirectorTypeMismatchException("string expected");
|
||||
}
|
||||
|
||||
%typemap(directorout) const string & (std::string temp) {
|
||||
%typemap(directorout) const string & ($*1_ltype temp) {
|
||||
if ($input.type == T_STRING) {
|
||||
temp.assign(STR0($input.u.string));
|
||||
$result = &temp;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue