-
Notifications
You must be signed in to change notification settings - Fork 0
/
override.py
74 lines (66 loc) · 2.16 KB
/
override.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class Context(_Ctype):
"""Create a new Context instance.
"""
def __new__(cls, *args):
if args:
i = args[0]
if i == 0:
return None
if isinstance(i, _Ints):
return _Cobject(cls, ctypes.c_void_p(i))
elif isinstance(i, basestring):
# Init from XML file
p = ctypes.c_void_p()
err = EnumerationErrors()
status = dll.xnInitFromXmlFile(i, ctypes.byref(p), err)
if status:
xnPrintError(status, "Context creation")
return None
p = ctypes.c_void_p()
status = dll.xnInit(ctypes.byref(p))
if status:
xnPrintError(status, "Context creation")
return None
return _Cobject(cls, p)
class NodeQuery(_Ctype):
"""Create a new NodeQuery instance.
# FIXME: handle destruction
"""
def __new__(cls, *args):
if args and args[0]:
p = args[0]
else:
p = ctypes.c_void_p()
status = dll.xnNodeQueryAllocate(ctypes.byref(p))
if status:
xnPrintError(status, "NodeQuery creation")
return None
return _Cobject(cls, p)
class EnumerationErrors(_Ctype):
"""Create a new EnumerationErrors instance.
# FIXME: handle destruction
"""
def __new__(cls, *args):
if args and args[0]:
p = args[0]
else:
p = ctypes.c_void_p()
status = dll.xnEnumerationErrorsAllocate(ctypes.byref(p))
if status:
xnPrintError(status, "EnumerationErrors creation")
return None
return _Cobject(cls, p)
class NodeInfoList(_Ctype):
"""Create a new NodeInfoList instance.
# FIXME: handle destruction
"""
def __new__(cls, *args):
if args and args[0]:
p = args[0]
else:
p = ctypes.c_void_p()
status = dll.xnNodeInfoListAllocate(ctypes.byref(p))
if status:
xnPrintError(status, "NodeInfoList creation")
return None
return _Cobject(cls, p)