summaryrefslogtreecommitdiffstats
path: root/swig/plist.i
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-10-17 10:41:18 +0200
committerGravatar Jonathan Beck2009-10-17 10:41:18 +0200
commit6f453688c0b97ea979b2b2b515f4030e69e846fb (patch)
tree68ea509582004bfb5e5df61756e7e8b30ac56dd4 /swig/plist.i
parente6a0149e3be353da436c9b3cbc960233c2df2076 (diff)
downloadlibplist-6f453688c0b97ea979b2b2b515f4030e69e846fb.tar.gz
libplist-6f453688c0b97ea979b2b2b515f4030e69e846fb.tar.bz2
Use custom typemap for binary buffers as we want to hadle them as strings in python.
Diffstat (limited to 'swig/plist.i')
-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) {
23} 23}
24 %} 24 %}
25 25
26%include "stl.i" 26%include "std_string.i"
27
28#if SWIGPYTHON
29%typemap(out) std::vector<char> {
30 $result = PyString_FromStringAndSize((const char*)&($1[0]),(int)($1.size()));
31}
32
33%typemap(in) (const std::vector<char>& v)
34{
35 if (!PyString_Check($input)) {
36 PyErr_SetString(PyExc_ValueError,"Expected a string");
37 return NULL;
38 }
39 char* buffer = PyString_AsString($input);
40 int length = PyString_Size($input);
41 $1 = std::vector<char>(buffer, buffer + length);
42}
43#else
44#endif
27 45
28namespace std {
29 %template(vectorc) vector<char>;
30};
31 46
32%rename(__assign__) *::operator=; 47%rename(__assign__) *::operator=;
33%rename(__getitem__) *::operator[]; 48%rename(__getitem__) *::operator[];