Enable Perl automatic stringification (see 2004/05/13 post from J.Slade)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5909 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
410af41cae
commit
f1970a552b
1 changed files with 9 additions and 11 deletions
|
|
@ -28,24 +28,22 @@ namespace std {
|
|||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string {
|
||||
if (!SvPOK((SV*) $input)) {
|
||||
SWIG_croak("Type error in argument $argnum of $symname. "
|
||||
"Expected a string");
|
||||
STRLEN len;
|
||||
const char *ptr = SvPV($input, len);
|
||||
if (!ptr) {
|
||||
SWIG_croak("Undefined variable in argument $argnum of $symname.");
|
||||
} else {
|
||||
STRLEN len;
|
||||
const char *ptr = SvPV($input, len);
|
||||
$1.assign(ptr, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in) string *INPUT(std::string temp),
|
||||
const string & (std::string temp) {
|
||||
if (!SvPOK((SV*) $input)) {
|
||||
SWIG_croak("Type error in argument $argnum of $symname. "
|
||||
"Expected a string");
|
||||
STRLEN len;
|
||||
const char *ptr = SvPV($input, len);
|
||||
if (!ptr) {
|
||||
SWIG_croak("Undefined variable in argument $argnum of $symname.");
|
||||
} else {
|
||||
STRLEN len;
|
||||
const char *ptr = SvPV($input, len);
|
||||
temp.assign(ptr, len);
|
||||
$1 = &temp;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue