Add inv and outv Ruby typemaps for std::string.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4714 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f60b413181
commit
c0a9e0d223
2 changed files with 186 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ namespace std {
|
|||
%rename(String) string;
|
||||
class string;
|
||||
|
||||
/* Overloading check */
|
||||
%typemap(typecheck) string = char *;
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
|
|
@ -53,4 +54,24 @@ namespace std {
|
|||
$result = rb_str_new2($1->c_str());
|
||||
}
|
||||
|
||||
%typemap(inv) string, const string &, string & "$1_name.c_str()";
|
||||
|
||||
%typemap(inv) string *, const string * "$1_name->c_str()";
|
||||
|
||||
%typemap(outv) string {
|
||||
if (TYPE($input) == T_STRING)
|
||||
$result = std::string(StringValuePtr($input));
|
||||
else
|
||||
throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");
|
||||
}
|
||||
|
||||
%typemap(outv) const string & (std::string temp) {
|
||||
if (TYPE($input) == T_STRING) {
|
||||
temp = std::string(StringValuePtr($input));
|
||||
$result = &temp;
|
||||
} else {
|
||||
throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue