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:
parent
10138e60b9
commit
c48f73d7aa
1 changed files with 8 additions and 4 deletions
|
|
@ -29,14 +29,16 @@ namespace std {
|
||||||
|
|
||||||
%typemap(in) string {
|
%typemap(in) string {
|
||||||
if (PyString_Check($input))
|
if (PyString_Check($input))
|
||||||
$1 = std::string(PyString_AsString($input));
|
$1 = std::string(PyString_AsString($input),
|
||||||
|
PyString_Size($input));
|
||||||
else
|
else
|
||||||
SWIG_exception(SWIG_TypeError, "string expected");
|
SWIG_exception(SWIG_TypeError, "string expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(in) const string & (std::string temp) {
|
%typemap(in) const string & (std::string temp) {
|
||||||
if (PyString_Check($input)) {
|
if (PyString_Check($input)) {
|
||||||
temp = std::string(PyString_AsString($input));
|
temp = std::string(PyString_AsString($input),
|
||||||
|
PyString_Size($input));
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
} else {
|
} else {
|
||||||
SWIG_exception(SWIG_TypeError, "string expected");
|
SWIG_exception(SWIG_TypeError, "string expected");
|
||||||
|
|
@ -57,14 +59,16 @@ namespace std {
|
||||||
|
|
||||||
%typemap(outv) string {
|
%typemap(outv) string {
|
||||||
if (PyString_Check($input))
|
if (PyString_Check($input))
|
||||||
$result = std::string(PyString_AsString($input));
|
$result = std::string(PyString_AsString($input),
|
||||||
|
PyString_Size($input));
|
||||||
else
|
else
|
||||||
throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");
|
throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(outv) const string & (std::string temp) {
|
%typemap(outv) const string & (std::string temp) {
|
||||||
if (PyString_Check($input)) {
|
if (PyString_Check($input)) {
|
||||||
temp = std::string(PyString_AsString($input));
|
temp = std::string(PyString_AsString($input),
|
||||||
|
PyString_Size($input));
|
||||||
$result = &temp;
|
$result = &temp;
|
||||||
} else {
|
} else {
|
||||||
throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");
|
throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue