richard 2022-09-23 20:11:59 +01:00
parent 84c7eff4d7
commit 2c233d47fa
2 changed files with 20 additions and 19 deletions

View file

@ -14,25 +14,22 @@
from raylib import rl, ffi
from raylib.colors import *
try:
from raylib.defines import *
except AttributeError:
print("sorry deprecated enums dont work on dynamic version")
from inspect import ismethod,getmembers,isbuiltin
from inspect import getmembers, isbuiltin
import inflection
current_module = __import__(__name__)
def pointer(self, struct):
return ffi.addressof(struct)
# I'm concerned that we are doing a lot of string comparisons on every function call to detect types.
# Quickest way would probably be isinstance(result, ffi._backend._CDataBase) but that class name varies
# depending on if binding is static/dynamic
@ -72,18 +69,22 @@ def makefunc(a):
else:
result = ffi.string(result).decode('utf-8')
return result
return func
def makeStructHelper(struct):
def func(*args):
return ffi.new(f"struct {struct} *", args)[0]
return func
for name, attr in getmembers(rl):
# print(name, attr)
uname = inflection.underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(
type(attr)) == "<class '_cffi_backend._CDataBase'>":
# print(attr.__call__)
# print(attr.__doc__)
# print(attr.__text_signature__)