summaryrefslogtreecommitdiffstats
path: root/swig/plist.i
diff options
context:
space:
mode:
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[];