summaryrefslogtreecommitdiff
path: root/Lib/python/std_string.i
diff options
context:
space:
mode:
authorMark Rose <mrose@stm.lbl.gov>2003-03-06 19:21:58 +0000
committerMark Rose <mrose@stm.lbl.gov>2003-03-06 19:21:58 +0000
commitc47494cb7a725bc3355fc1c89d220935f98b02c7 (patch)
treea608ad4058afec65f7d5cac0cc12629869a895cd /Lib/python/std_string.i
parentc146f71da150362fe9d7bc13f188f420ca2b6d14 (diff)
downloadswig-c47494cb7a725bc3355fc1c89d220935f98b02c7.tar.gz
polymorphism patch merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4435 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/python/std_string.i')
-rw-r--r--Lib/python/std_string.i21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/python/std_string.i b/Lib/python/std_string.i
index 30d1afb7d..6bb5fa52b 100644
--- a/Lib/python/std_string.i
+++ b/Lib/python/std_string.i
@@ -50,5 +50,26 @@ namespace std {
%typemap(out) const string & {
$result = PyString_FromStringAndSize($1->data(),$1->size());
}
+
+ %typemap(inv, parse="s") string, const string &, string & "$1_name.c_str()";
+
+ %typemap(inv, parse="s") string *, const string * "$1_name->c_str()";
+
+ %typemap(outv) string {
+ if (PyString_Check($input))
+ $result = std::string(PyString_AsString($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));
+ $result = &temp;
+ } else {
+ throw SWIG_DIRECTOR_TYPE_MISMATCH("string expected");
+ }
+ }
+
}