From f6a474cafa5475c1503b738d9d1c482ac958cda9 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 17 May 2004 12:49:42 +0000 Subject: [PATCH] Enable Perl automatic stringification (see 2004/05/13 post from J.Slade) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5909 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/std_string.i | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Lib/perl5/std_string.i b/Lib/perl5/std_string.i index e16ee012e..2754cbbbe 100644 --- a/Lib/perl5/std_string.i +++ b/Lib/perl5/std_string.i @@ -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; }