summaryrefslogtreecommitdiffstats
path: root/cython/plist.pyx
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-19 17:24:25 +0100
committerGravatar Nikias Bassen2013-03-19 17:24:25 +0100
commit1b12d348f7efd0a5a1ead163a68111b1def98e8d (patch)
tree6ad7ad4f5e20e79d72568d1bd1fc3db0c79c67a4 /cython/plist.pyx
parentef7347435a77a97444e61a52ce9305c3924d2df6 (diff)
downloadlibplist-1b12d348f7efd0a5a1ead163a68111b1def98e8d.tar.gz
libplist-1b12d348f7efd0a5a1ead163a68111b1def98e8d.tar.bz2
cython: added PLIST_UID support
Diffstat (limited to 'cython/plist.pyx')
-rw-r--r--cython/plist.pyx51
1 files changed, 51 insertions, 0 deletions
diff --git a/cython/plist.pyx b/cython/plist.pyx
index 09c0bbc..4eccdb1 100644
--- a/cython/plist.pyx
+++ b/cython/plist.pyx
@@ -13,6 +13,7 @@ cdef extern from *:
PLIST_DATE,
PLIST_DATA,
PLIST_KEY,
+ PLIST_UID,
PLIST_NONE
plist_t plist_new_bool(uint8_t val)
@@ -35,6 +36,10 @@ cdef extern from *:
void plist_get_key_val(plist_t node, char **val)
void plist_set_key_val(plist_t node, char *val)
+ plist_t plist_new_uid(uint64_t val)
+ void plist_get_uid_val(plist_t node, uint64_t *val)
+ void plist_set_uid_val(plist_t node, uint64_t val)
+
plist_t plist_new_string(char *val)
void plist_get_string_val(plist_t node, char **val)
void plist_set_string_val(plist_t node, char *val)
@@ -264,6 +269,52 @@ cdef Real Real_factory(plist_t c_node, bint managed=True):
instance._c_node = c_node
return instance
+cdef class Uid(Node):
+ def __cinit__(self, object value=None, *args, **kwargs):
+ if value is None:
+ self._c_node = plist_new_uid(0)
+ else:
+ self._c_node = plist_new_uid(int(value))
+
+ def __repr__(self):
+ cdef uint64_t i = self.get_value()
+ return '<Uid: %s>' % i
+
+ def __int__(self):
+ return self.get_value()
+
+ def __float__(self):
+ return float(self.get_value())
+
+ def __richcmp__(self, other, op):
+ cdef int i = self.get_value()
+ if op == 0:
+ return i < other
+ if op == 1:
+ return i <= other
+ if op == 2:
+ return i == other
+ if op == 3:
+ return i != other
+ if op == 4:
+ return i > other
+ if op == 5:
+ return i >= other
+
+ cpdef set_value(self, object value):
+ plist_set_uid_val(self._c_node, int(value))
+
+ cpdef uint64_t get_value(self):
+ cdef uint64_t value
+ plist_get_uid_val(self._c_node, &value)
+ return value
+
+cdef Uid Uid_factory(plist_t c_node, bint managed=True):
+ cdef Uid instance = Uid.__new__(Uid)
+ instance._c_managed = managed
+ instance._c_node = c_node
+ return instance
+
from cpython cimport PY_MAJOR_VERSION
cdef class Key(Node):