summaryrefslogtreecommitdiffstats
path: root/swig
diff options
context:
space:
mode:
Diffstat (limited to 'swig')
-rw-r--r--swig/plist.i23
1 files changed, 19 insertions, 4 deletions
diff --git a/swig/plist.i b/swig/plist.i
index 91124b2..1b97451 100644
--- a/swig/plist.i
+++ b/swig/plist.i
@@ -23,11 +23,26 @@ PListNode *allocate_plist_wrapper(plist_t plist, char should_keep_plist) {
}
%}
-%include "stl.i"
+%include "std_string.i"
+
+#if SWIGPYTHON
+%typemap(out) std::vector<char> {
+ $result = PyString_FromStringAndSize((const char*)&($1[0]),(int)($1.size()));
+}
+
+%typemap(in) (const std::vector<char>& v)
+{
+ if (!PyString_Check($input)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a string");
+ return NULL;
+ }
+ char* buffer = PyString_AsString($input);
+ int length = PyString_Size($input);
+ $1 = std::vector<char>(buffer, buffer + length);
+}
+#else
+#endif
-namespace std {
- %template(vectorc) vector<char>;
-};
%rename(__assign__) *::operator=;
%rename(__getitem__) *::operator[];