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:
Luigi Ballabio 2004-05-17 12:49:42 +00:00
commit f1970a552b

View file

@ -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;
}