diff options
author | Olly Betts <olly@survex.com> | 2010-05-26 00:19:08 +0000 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2010-05-26 00:19:08 +0000 |
commit | ed98187e3bd3f2e23e1cce128bace99d36ba5c3a (patch) | |
tree | bacd142f6a7d2fe12d9d38cfe785156d7baf9e8b /Lib/php | |
parent | 9207a2fe37be54d53c03871e6ee7dc2dd4649440 (diff) | |
download | swig-ed98187e3bd3f2e23e1cce128bace99d36ba5c3a.tar.gz |
Tidy up typemaps, combining variants with the same code.
Use const_cast to remove const-ness from const char * for stupid PHP API in
%throws typemap.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12054 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/php')
-rw-r--r-- | Lib/php/std_string.i | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index 6eb8ac22a..de4e15c4e 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -23,8 +23,8 @@ namespace std { class string; - %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string %{ - $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; + %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string, const string& %{ + $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; %} %typemap(in) string %{ @@ -37,15 +37,11 @@ namespace std { $result.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); %} - %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) const string& %{ - $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; - %} - %typemap(out) string %{ ZVAL_STRINGL($result, const_cast<char*>($1.data()), $1.size(), 1); %} - %typemap(directorin) string %{ + %typemap(directorin) string, const string& %{ ZVAL_STRINGL($input, const_cast<char*>($1_name.data()), $1_name.size(), 1); %} @@ -53,16 +49,8 @@ namespace std { ZVAL_STRINGL($result, const_cast<char*>($1->data()), $1->size(), 1); %} - %typemap(directorin) const string & %{ - ZVAL_STRINGL($input, const_cast<char*>($1_name.data()), $1_name.size(), 1); - %} - - %typemap(throws) string %{ - SWIG_PHP_Error(E_ERROR, (char *)$1.c_str()); - %} - - %typemap(throws) const string& %{ - SWIG_PHP_Error(E_ERROR, (char *)$1.c_str()); + %typemap(throws) string, const string& %{ + SWIG_PHP_Error(E_ERROR, const_cast<char*>($1.c_str())); %} /* These next two handle a function which takes a non-const reference to |