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):
5252RAYWHITE = ( 245 , 245 , 245 , 255 )
5353
5454
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+
5563def makefunc (a ):
5664 #print("makefunc ",a, ffi.typeof(a).args)
5765 def func (* args ):
@@ -65,7 +73,12 @@ def func(*args):
6573 modified_args .append (ffi .addressof (arg ))
6674 else :
6775 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
6982 return func
7083
7184def 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