File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,14 @@ def pointer(self, struct):
52
52
RAYWHITE = ( 245 , 245 , 245 , 255 )
53
53
54
54
55
+ # I'm concerned that we are doing a lot of string comparisons on every function call to detect types.
56
+ # Quickest way would probably be isinstance(result, ffi._backend._CDataBase) but that class name varies
57
+ # depending on if binding is static/dynamic
58
+ # (and possibly also different on pypy implementations?).
59
+ # which makes me reluctant to rely on it.
60
+ # Another possibility is ffi.typeof() but that will throw an exception if you give it a type that isn't a ctype
61
+ # Another way to improve performance might be to special-case simple types before doing the string comparisons
62
+
55
63
def makefunc (a ):
56
64
#print("makefunc ",a, ffi.typeof(a).args)
57
65
def func (* args ):
@@ -65,7 +73,12 @@ def func(*args):
65
73
modified_args .append (ffi .addressof (arg ))
66
74
else :
67
75
modified_args .append (arg )
68
- return a (* modified_args )
76
+ result = a (* modified_args )
77
+ if result is None :
78
+ return
79
+ if str (type (result )) == "<class '_cffi_backend._CDataBase'>" and str (result ).startswith ("<cdata 'char *'" ):
80
+ result = ffi .string (result ).decode ('utf-8' )
81
+ return result
69
82
return func
70
83
71
84
def makeStructHelper (struct ):
Original file line number Diff line number Diff line change 1
- __version__ = "4.0.0"
1
+ __version__ = "4.0.0.post1 "
You can’t perform that action at this time.
0 commit comments