-
Notifications
You must be signed in to change notification settings - Fork 30
/
cparser_utils.py
41 lines (34 loc) · 1.09 KB
/
cparser_utils.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
import types
import sys
if sys.version_info.major == 2:
def rebound_instance_method(f, newobj):
# noinspection PyArgumentList
return types.MethodType(f.im_func, newobj, newobj.__class__)
else:
def rebound_instance_method(f, newobj):
return lambda *args, **kwargs: f.__func__(newobj, *args, **kwargs)
if sys.version_info.major == 2:
def generic_class_method(f):
return f.im_func
else:
def generic_class_method(f):
return f
if sys.version_info.major >= 3:
unicode = str
long = int
unichr = chr
else:
# noinspection PyUnresolvedReferences
unicode = __builtins__["unicode"]
# noinspection PyUnresolvedReferences
long = __builtins__["long"]
# noinspection PyUnresolvedReferences
unichr = __builtins__["unichr"]
def setup_Structure_debug_helper():
import ctypes
class DebugStruct(ctypes.Structure):
def __init__(self, *args):
assert hasattr(self, "_fields_")
assert len(args) <= len(self._fields_)
super(DebugStruct, self).__init__(*args)
ctypes.Structure = DebugStruct