diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-01-13 08:48:43 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-01-13 08:48:43 +0000 |
| commit | c34f2a5241fba850f3e48a08ebeff3190c6dc9d5 (patch) | |
| tree | b2f8601fea265cd965a7b02566346e0f83a14180 | |
| parent | c97915f445017d36667a6ad32767fa41d14d23b1 (diff) | |
add ustring.i which wraps otk::ustring for to/from python conversions
| -rw-r--r-- | otk/ustring.i | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/otk/ustring.i b/otk/ustring.i new file mode 100644 index 00000000..45057334 --- /dev/null +++ b/otk/ustring.i @@ -0,0 +1,40 @@ +// SWIG typemaps for otk::ustring + +%{ +#include "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()); + } + +} |
