From 67fbe8354f27386235e0c8dc57bd036e34a4fe5e Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 5 Feb 2003 10:48:37 +0000 Subject: dont make wrap a subdir of otk --- wrap/ustring.i | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 wrap/ustring.i (limited to 'wrap/ustring.i') diff --git a/wrap/ustring.i b/wrap/ustring.i new file mode 100644 index 00000000..d693e7dc --- /dev/null +++ b/wrap/ustring.i @@ -0,0 +1,40 @@ +// SWIG typemaps for otk::ustring + +%{ +#include "otk/ustring.hh" +%} + +namespace otk { + + class ustring; + + /* Overloading check */ + + %typemap(typecheck) ustring = char *; + %typemap(typecheck) const ustring & = char *; + + %typemap(in) ustring { + if (PyString_Check($input)) + $1 = otk::ustring(PyString_AsString($input)); + else + SWIG_exception(SWIG_TypeError, "ustring expected"); + } + + %typemap(in) const ustring & (otk::ustring temp) { + if (PyString_Check($input)) { + temp = otk::ustring(PyString_AsString($input)); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "ustring expected"); + } + } + + %typemap(out) ustring { + $result = PyString_FromString($1.c_str()); + } + + %typemap(out) const ustring & { + $result = PyString_FromString($1->c_str()); + } + +} -- cgit v1.2.3