summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Bryan Forbes2011-09-26 17:17:22 +0200
committerGravatar Nikias Bassen2011-09-26 17:17:22 +0200
commitbf1dcaecc3e7c4a123059ff5347bc5180835dbad (patch)
treeb8d539cdba59e6938743758b20593a1511cf522e
parent89900d6decbfe805720a9cbce65655ec31086f94 (diff)
downloadlibplist-bf1dcaecc3e7c4a123059ff5347bc5180835dbad.tar.gz
libplist-bf1dcaecc3e7c4a123059ff5347bc5180835dbad.tar.bz2
Changed bool to bint in Cython functions. Added some more type qualifiers.
-rw-r--r--cython/plist.pxd4
-rw-r--r--cython/plist.pyx28
2 files changed, 16 insertions, 16 deletions
diff --git a/cython/plist.pxd b/cython/plist.pxd
index 6a96817..7cff51c 100644
--- a/cython/plist.pxd
+++ b/cython/plist.pxd
@@ -5,7 +5,7 @@ cdef extern from "plist/plist.h":
5 5
6cdef class Node: 6cdef class Node:
7 cdef plist_t _c_node 7 cdef plist_t _c_node
8 cdef bool _c_managed 8 cdef bint _c_managed
9 cpdef object __deepcopy__(self, memo=*) 9 cpdef object __deepcopy__(self, memo=*)
10 cpdef unicode to_xml(self) 10 cpdef unicode to_xml(self)
11 cpdef bytes to_bin(self) 11 cpdef bytes to_bin(self)
@@ -59,5 +59,5 @@ cdef class Array(Node):
59cpdef object from_xml(xml) 59cpdef object from_xml(xml)
60cpdef object from_bin(bytes bin) 60cpdef object from_bin(bytes bin)
61 61
62cdef object plist_t_to_node(plist_t c_plist, bool managed=*) 62cdef object plist_t_to_node(plist_t c_plist, bint managed=*)
63cdef plist_t native_to_plist_t(object native) 63cdef plist_t native_to_plist_t(object native)
diff --git a/cython/plist.pyx b/cython/plist.pyx
index c636f7d..aa4f0d8 100644
--- a/cython/plist.pyx
+++ b/cython/plist.pyx
@@ -171,7 +171,7 @@ cdef class Bool(Node):
171 plist_get_bool_val(self._c_node, &value) 171 plist_get_bool_val(self._c_node, &value)
172 return bool(value) 172 return bool(value)
173 173
174cdef Bool Bool_factory(plist_t c_node, bool managed=True): 174cdef Bool Bool_factory(plist_t c_node, bint managed=True):
175 cdef Bool instance = Bool.__new__(Bool) 175 cdef Bool instance = Bool.__new__(Bool)
176 instance._c_managed = managed 176 instance._c_managed = managed
177 instance._c_node = c_node 177 instance._c_node = c_node
@@ -217,7 +217,7 @@ cdef class Integer(Node):
217 plist_get_uint_val(self._c_node, &value) 217 plist_get_uint_val(self._c_node, &value)
218 return value 218 return value
219 219
220cdef Integer Integer_factory(plist_t c_node, bool managed=True): 220cdef Integer Integer_factory(plist_t c_node, bint managed=True):
221 cdef Integer instance = Integer.__new__(Integer) 221 cdef Integer instance = Integer.__new__(Integer)
222 instance._c_managed = managed 222 instance._c_managed = managed
223 instance._c_node = c_node 223 instance._c_node = c_node
@@ -263,7 +263,7 @@ cdef class Real(Node):
263 plist_get_real_val(self._c_node, &value) 263 plist_get_real_val(self._c_node, &value)
264 return value 264 return value
265 265
266cdef Real Real_factory(plist_t c_node, bool managed=True): 266cdef Real Real_factory(plist_t c_node, bint managed=True):
267 cdef Real instance = Real.__new__(Real) 267 cdef Real instance = Real.__new__(Real)
268 instance._c_managed = managed 268 instance._c_managed = managed
269 instance._c_node = c_node 269 instance._c_node = c_node
@@ -285,7 +285,7 @@ cdef class String(Node):
285 value.decode('ascii') # trial decode 285 value.decode('ascii') # trial decode
286 utf8_data = value.decode('ascii') 286 utf8_data = value.decode('ascii')
287 else: 287 else:
288 raise ValueError("requires text input, got %s" % type(value)) 288 raise ValueError("Requires unicode input, got %s" % type(value))
289 c_utf8_data = utf8_data 289 c_utf8_data = utf8_data
290 self._c_node = plist_new_string(c_utf8_data) 290 self._c_node = plist_new_string(c_utf8_data)
291 291
@@ -321,7 +321,7 @@ cdef class String(Node):
321 value.decode('ascii') # trial decode 321 value.decode('ascii') # trial decode
322 utf8_data = value.decode('ascii') 322 utf8_data = value.decode('ascii')
323 else: 323 else:
324 raise ValueError("requires text input, got %s" % type(value)) 324 raise ValueError("Requires unicode input, got %s" % type(value))
325 c_utf8_data = utf8_data 325 c_utf8_data = utf8_data
326 plist_set_string_val(self._c_node, c_utf8_data) 326 plist_set_string_val(self._c_node, c_utf8_data)
327 327
@@ -334,7 +334,7 @@ cdef class String(Node):
334 finally: 334 finally:
335 stdlib.free(c_value) 335 stdlib.free(c_value)
336 336
337cdef String String_factory(plist_t c_node, bool managed=True): 337cdef String String_factory(plist_t c_node, bint managed=True):
338 cdef String instance = String.__new__(String) 338 cdef String instance = String.__new__(String)
339 instance._c_managed = managed 339 instance._c_managed = managed
340 instance._c_node = c_node 340 instance._c_node = c_node
@@ -386,7 +386,7 @@ cdef class Date(Node):
386 plist_get_date_val(self._c_node, &secs, &usecs) 386 plist_get_date_val(self._c_node, &secs, &usecs)
387 return ints_to_datetime(secs, usecs) 387 return ints_to_datetime(secs, usecs)
388 388
389 cpdef set_value(self, value): 389 cpdef set_value(self, object value):
390 cdef int32_t secs 390 cdef int32_t secs
391 cdef int32_t usecs 391 cdef int32_t usecs
392 if not check_datetime(value): 392 if not check_datetime(value):
@@ -394,7 +394,7 @@ cdef class Date(Node):
394 datetime_to_ints(value, &secs, &usecs) 394 datetime_to_ints(value, &secs, &usecs)
395 plist_set_date_val(self._c_node, secs, usecs) 395 plist_set_date_val(self._c_node, secs, usecs)
396 396
397cdef Date Date_factory(plist_t c_node, bool managed=True): 397cdef Date Date_factory(plist_t c_node, bint managed=True):
398 cdef Date instance = Date.__new__(Date) 398 cdef Date instance = Date.__new__(Date)
399 instance._c_managed = managed 399 instance._c_managed = managed
400 instance._c_node = c_node 400 instance._c_node = c_node
@@ -440,13 +440,13 @@ cdef class Data(Node):
440 cpdef set_value(self, bytes value): 440 cpdef set_value(self, bytes value):
441 plist_set_data_val(self._c_node, value, len(value)) 441 plist_set_data_val(self._c_node, value, len(value))
442 442
443cdef Data Data_factory(plist_t c_node, bool managed=True): 443cdef Data Data_factory(plist_t c_node, bint managed=True):
444 cdef Data instance = Data.__new__(Data) 444 cdef Data instance = Data.__new__(Data)
445 instance._c_managed = managed 445 instance._c_managed = managed
446 instance._c_node = c_node 446 instance._c_node = c_node
447 return instance 447 return instance
448 448
449cdef plist_t create_dict_plist(value=None): 449cdef plist_t create_dict_plist(object value=None):
450 cdef plist_t node = NULL 450 cdef plist_t node = NULL
451 cdef plist_t c_node = NULL 451 cdef plist_t c_node = NULL
452 node = plist_new_dict() 452 node = plist_new_dict()
@@ -565,14 +565,14 @@ cdef class Dict(Node):
565 python_dict.PyDict_DelItem(self._map, key) 565 python_dict.PyDict_DelItem(self._map, key)
566 plist_dict_remove_item(self._c_node, key) 566 plist_dict_remove_item(self._c_node, key)
567 567
568cdef Dict Dict_factory(plist_t c_node, bool managed=True): 568cdef Dict Dict_factory(plist_t c_node, bint managed=True):
569 cdef Dict instance = Dict.__new__(Dict) 569 cdef Dict instance = Dict.__new__(Dict)
570 instance._c_managed = managed 570 instance._c_managed = managed
571 instance._c_node = c_node 571 instance._c_node = c_node
572 instance._init() 572 instance._init()
573 return instance 573 return instance
574 574
575cdef plist_t create_array_plist(value=None): 575cdef plist_t create_array_plist(object value=None):
576 cdef plist_t node = NULL 576 cdef plist_t node = NULL
577 cdef plist_t c_node = NULL 577 cdef plist_t c_node = NULL
578 node = plist_new_array() 578 node = plist_new_array()
@@ -666,7 +666,7 @@ cdef class Array(Node):
666 plist_array_append_item(self._c_node, n._c_node) 666 plist_array_append_item(self._c_node, n._c_node)
667 self._array.append(n) 667 self._array.append(n)
668 668
669cdef Array Array_factory(plist_t c_node, bool managed=True): 669cdef Array Array_factory(plist_t c_node, bint managed=True):
670 cdef Array instance = Array.__new__(Array) 670 cdef Array instance = Array.__new__(Array)
671 instance._c_managed = managed 671 instance._c_managed = managed
672 instance._c_node = c_node 672 instance._c_node = c_node
@@ -707,7 +707,7 @@ cdef plist_t native_to_plist_t(object native):
707 if check_datetime(native): 707 if check_datetime(native):
708 return create_date_plist(native) 708 return create_date_plist(native)
709 709
710cdef object plist_t_to_node(plist_t c_plist, bool managed=True): 710cdef object plist_t_to_node(plist_t c_plist, bint managed=True):
711 cdef plist_type t = plist_get_node_type(c_plist) 711 cdef plist_type t = plist_get_node_type(c_plist)
712 if t == PLIST_BOOLEAN: 712 if t == PLIST_BOOLEAN:
713 return Bool_factory(c_plist, managed) 713 return Bool_factory(c_plist, managed)