summaryrefslogtreecommitdiffstats
path: root/swig/plist.i
diff options
context:
space:
mode:
Diffstat (limited to 'swig/plist.i')
-rw-r--r--swig/plist.i28
1 files changed, 13 insertions, 15 deletions
diff --git a/swig/plist.i b/swig/plist.i
index 0a40cf6..e3c2be2 100644
--- a/swig/plist.i
+++ b/swig/plist.i
@@ -6,10 +6,6 @@
#include <plist/plist.h>
#include <plist/plist++.h>
-#include <ctime>
-//for datetime in python
-#include <datetime.h>
-
typedef struct {
plist_t node;
char should_keep_plist;
@@ -29,22 +25,26 @@ PListNode *allocate_plist_wrapper(plist_t plist, char should_keep_plist) {
%include "std_string.i"
-#if SWIGPYTHON
+
%typemap(out) std::vector<char> {
- $result = PyString_FromStringAndSize((const char*)&($1[0]),(int)($1.size()));
+ $result = SWIG_FromCharPtrAndSize((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);
+ char* buffer = NULL;
+ int length = 0;
+ SWIG_AsCharPtrAndSize($input, &buffer, &length, NULL);
$1 = std::vector<char>(buffer, buffer + length);
}
+#if SWIGPYTHON
+//for datetime in python
+%{
+#include <ctime>
+#include <datetime.h>
+%}
+
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) timeval {
PyDateTime_IMPORT;
$1 = PyDateTime_Check($input) ? 1 : 0;
@@ -78,6 +78,7 @@ PListNode *allocate_plist_wrapper(plist_t plist, char should_keep_plist) {
timeval ret = {(int)mktime(&t), PyDateTime_DATE_GET_MICROSECOND($input)};
$1 = ret;
}
+#endif
%apply SWIGTYPE *DYNAMIC { PList::Node* };
%apply SWIGTYPE *DYNAMIC { PList::Structure* };
@@ -127,9 +128,6 @@ static swig_type_info *Node_dynamic(void **ptr)
DYNAMIC_CAST(SWIGTYPE_p_PList__Node, Node_dynamic);
DYNAMIC_CAST(SWIGTYPE_p_PList__Structure, Node_dynamic);
-#else
-#endif
-
%rename(__assign__) *::operator=;
%rename(__getitem__) *::operator[];