Allow for strings with embedded zeros

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5005 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Luigi Ballabio 2003-08-17 12:00:17 +00:00
commit c48f73d7aa

View file

@ -29,14 +29,16 @@ namespace std {
%typemap(in) string {
if (PyString_Check($input))
$1 = std::string(PyString_AsString($input));
$1 = std::string(PyString_AsString($input),
PyString_Size($input));
else
SWIG_exception(SWIG_TypeError, "string expected");
}
%typemap(in) const string & (std::string temp) {
if (PyString_Check($input)) {
temp = std::string(PyString_AsString($input));
temp = std::string(PyString_AsString($input),
PyString_Size($input));
$1 = &temp;
} else {
SWIG_exception(SWIG_TypeError, "string expected");
@ -57,14 +59,16 @@ namespace std {
%typemap(outv) string {
if (PyString_Check($input))
$result = std::string(PyString_AsString($input));
$result = std::string(PyString_AsString($input),
PyString_Size($input));
else
throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");
}
%typemap(outv) const string & (std::string temp) {
if (PyString_Check($input)) {
temp = std::string(PyString_AsString($input));
temp = std::string(PyString_AsString($input),
PyString_Size($input));
$result = &temp;
} else {
throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");