raylib 4.2.1.0__cp310-cp310-macosx_12_0_arm64.whl → 4.5.0.1__cp310-cp310-macosx_12_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of raylib might be problematic. Click here for more details.

pyray/__init__.py CHANGED
@@ -14,25 +14,22 @@
14
14
 
15
15
  from raylib import rl, ffi
16
16
  from raylib.colors import *
17
+
17
18
  try:
18
19
  from raylib.defines import *
19
20
  except AttributeError:
20
21
  print("sorry deprecated enums dont work on dynamic version")
21
22
 
22
-
23
- from inspect import ismethod,getmembers,isbuiltin
23
+ from inspect import getmembers, isbuiltin
24
24
  import inflection
25
25
 
26
26
  current_module = __import__(__name__)
27
27
 
28
28
 
29
-
30
29
  def pointer(self, struct):
31
30
  return ffi.addressof(struct)
32
31
 
33
32
 
34
-
35
-
36
33
  # I'm concerned that we are doing a lot of string comparisons on every function call to detect types.
37
34
  # Quickest way would probably be isinstance(result, ffi._backend._CDataBase) but that class name varies
38
35
  # depending on if binding is static/dynamic
@@ -42,7 +39,7 @@ def pointer(self, struct):
42
39
  # Another way to improve performance might be to special-case simple types before doing the string comparisons
43
40
 
44
41
  def makefunc(a):
45
- #print("makefunc ",a, ffi.typeof(a).args)
42
+ # print("makefunc ",a, ffi.typeof(a).args)
46
43
  def func(*args):
47
44
  modified_args = []
48
45
  for (c_arg, arg) in zip(ffi.typeof(a).args, args):
@@ -56,9 +53,11 @@ def makefunc(a):
56
53
  arg = ffi.new("int *", arg)
57
54
  elif type(arg) is float:
58
55
  arg = ffi.new("float *", arg)
59
- elif str(type(arg)) == "<class '_cffi_backend.__CDataOwn'>" and "*" not in str(arg): #CPython
56
+ elif type(arg) is list and str(c_arg) == "<ctype 'char * *'>":
57
+ arg = [ffi.new("char[]", x.encode('utf-8')) for x in arg]
58
+ elif str(type(arg)) == "<class '_cffi_backend.__CDataOwn'>" and "*" not in str(arg): # CPython
60
59
  arg = ffi.addressof(arg)
61
- elif str(type(arg)) == "<class '_cffi_backend._CDataBase'>" and "*" not in str(arg): #Pypy
60
+ elif str(type(arg)) == "<class '_cffi_backend._CDataBase'>" and "*" not in str(arg): # Pypy
62
61
  arg = ffi.addressof(arg)
63
62
  elif arg is None:
64
63
  arg = ffi.NULL
@@ -72,28 +71,32 @@ def makefunc(a):
72
71
  else:
73
72
  result = ffi.string(result).decode('utf-8')
74
73
  return result
74
+
75
75
  return func
76
76
 
77
+
77
78
  def makeStructHelper(struct):
78
79
  def func(*args):
79
80
  return ffi.new(f"struct {struct} *", args)[0]
81
+
80
82
  return func
81
83
 
82
84
 
83
85
  for name, attr in getmembers(rl):
84
- #print(name, attr)
85
- uname = inflection.underscore(name).replace('3_d','_3d').replace('2_d','_2d')
86
- if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
87
- #print(attr.__call__)
88
- #print(attr.__doc__)
89
- #print(attr.__text_signature__)
90
- #print(dir(attr))
91
- #print(dir(attr.__repr__))
86
+ # print(name, attr)
87
+ uname = inflection.underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
88
+ if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(
89
+ type(attr)) == "<class '_cffi_backend._CDataBase'>":
90
+ # print(attr.__call__)
91
+ # print(attr.__doc__)
92
+ # print(attr.__text_signature__)
93
+ # print(dir(attr))
94
+ # print(dir(attr.__repr__))
92
95
  f = makefunc(attr)
93
96
  setattr(current_module, uname, f)
94
- #def wrap(*args):
97
+ # def wrap(*args):
95
98
  # print("call to ",attr)
96
- #setattr(PyRay, uname, lambda *args: print("call to ",attr))
99
+ # setattr(PyRay, uname, lambda *args: print("call to ",attr))
97
100
  else:
98
101
  setattr(current_module, name, attr)
99
102