raylib 5.0.0.0__pp38-pypy38_pp73-win_amd64.whl → 5.0.0.2__pp38-pypy38_pp73-win_amd64.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 +67 -32
- pyray/__init__.pyi +968 -1312
- raylib/__init__.pyi +974 -1281
- raylib/_raylib_cffi.pypy38-pp73-win_amd64.pyd +0 -0
- raylib/build.py +14 -1
- raylib/defines.py +489 -4
- raylib/version.py +1 -1
- {raylib-5.0.0.0.dist-info → raylib-5.0.0.2.dist-info}/METADATA +44 -3
- raylib-5.0.0.2.dist-info/RECORD +15 -0
- {raylib-5.0.0.0.dist-info → raylib-5.0.0.2.dist-info}/WHEEL +1 -1
- raylib-5.0.0.0.dist-info/RECORD +0 -15
- {raylib-5.0.0.0.dist-info → raylib-5.0.0.2.dist-info}/LICENSE +0 -0
- {raylib-5.0.0.0.dist-info → raylib-5.0.0.2.dist-info}/top_level.txt +0 -0
pyray/__init__.py
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
# available at https://www.gnu.org/software/classpath/license.html.
|
|
12
12
|
#
|
|
13
13
|
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
import re
|
|
15
|
+
import weakref
|
|
16
|
+
from array import array
|
|
14
17
|
|
|
15
18
|
from raylib import rl, ffi
|
|
16
19
|
from raylib.colors import *
|
|
@@ -21,12 +24,21 @@ except AttributeError:
|
|
|
21
24
|
print("sorry deprecated enums dont work on dynamic version")
|
|
22
25
|
|
|
23
26
|
from inspect import getmembers, isbuiltin
|
|
24
|
-
import inflection
|
|
25
27
|
|
|
26
28
|
current_module = __import__(__name__)
|
|
27
29
|
|
|
28
30
|
|
|
29
|
-
def
|
|
31
|
+
def _underscore(word: str) -> str:
|
|
32
|
+
"""
|
|
33
|
+
from inflection
|
|
34
|
+
"""
|
|
35
|
+
word = re.sub(r"([A-Z]+)([A-Z][a-z])", r'\1_\2', word)
|
|
36
|
+
word = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', word)
|
|
37
|
+
word = word.replace("-", "_")
|
|
38
|
+
return word.lower()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def pointer(struct):
|
|
30
42
|
return ffi.addressof(struct)
|
|
31
43
|
|
|
32
44
|
|
|
@@ -38,70 +50,93 @@ def pointer(self, struct):
|
|
|
38
50
|
# Another possibility is ffi.typeof() but that will throw an exception if you give it a type that isn't a ctype
|
|
39
51
|
# Another way to improve performance might be to special-case simple types before doing the string comparisons
|
|
40
52
|
|
|
41
|
-
def
|
|
53
|
+
def _wrap_function(original_func):
|
|
42
54
|
# print("makefunc ",a, ffi.typeof(a).args)
|
|
43
|
-
def
|
|
55
|
+
def wrapped_func(*args):
|
|
44
56
|
modified_args = []
|
|
45
|
-
for (c_arg, arg) in zip(ffi.typeof(
|
|
46
|
-
#print("arg:",str(arg), "c_arg.kind:", c_arg.kind, "c_arg:", c_arg, "type(arg):",str(type(arg)))
|
|
57
|
+
for (c_arg, arg) in zip(ffi.typeof(original_func).args, args):
|
|
58
|
+
# print("arg:",str(arg), "c_arg.kind:", c_arg.kind, "c_arg:", c_arg, "type(arg):",str(type(arg)))
|
|
47
59
|
if c_arg.kind == 'pointer':
|
|
48
|
-
if type(arg)
|
|
60
|
+
if type(arg) is str:
|
|
49
61
|
arg = arg.encode('utf-8')
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
elif type(arg) is float:
|
|
55
|
-
arg = ffi.new("float *", arg)
|
|
56
|
-
elif type(arg) is list and str(c_arg) == "<ctype 'char * *'>":
|
|
62
|
+
# if c_arg is a 'char *' not a 'const char *' then we ought to raise here because its an out
|
|
63
|
+
# parameter and user should supply a ctype pointer, but cffi cant detect const
|
|
64
|
+
# so we would have to get the info from raylib.json
|
|
65
|
+
elif type(arg) is list and str(c_arg) == "<ctype 'char * *'>":
|
|
57
66
|
arg = [ffi.new("char[]", x.encode('utf-8')) for x in arg]
|
|
58
|
-
elif
|
|
59
|
-
arg = ffi.addressof(arg)
|
|
60
|
-
elif str(type(arg)) == "<class '_cffi_backend._CDataBase'>" and "*" not in str(arg): # Pypy
|
|
67
|
+
elif is_cdata(arg) and "*" not in str(arg):
|
|
61
68
|
arg = ffi.addressof(arg)
|
|
62
69
|
elif arg is None:
|
|
63
70
|
arg = ffi.NULL
|
|
71
|
+
elif not is_cdata(arg):
|
|
72
|
+
if str(c_arg) == "<ctype '_Bool *'>":
|
|
73
|
+
raise TypeError(
|
|
74
|
+
"Argument must be a ctype bool, please create one with: pyray.ffi.new('bool *', True)")
|
|
75
|
+
elif str(c_arg) == "<ctype 'int *'>":
|
|
76
|
+
raise TypeError(
|
|
77
|
+
"Argument must be a ctype int, please create one with: pyray.ffi.new('int *', 1)")
|
|
78
|
+
elif str(c_arg) == "<ctype 'float *'>":
|
|
79
|
+
raise TypeError(
|
|
80
|
+
"Argument must be a ctype float, please create one with: pyray.ffi.new('float *', 1.0)")
|
|
64
81
|
modified_args.append(arg)
|
|
65
|
-
result =
|
|
82
|
+
result = original_func(*modified_args)
|
|
66
83
|
if result is None:
|
|
67
84
|
return
|
|
68
|
-
|
|
85
|
+
elif is_cdata(result) and str(result).startswith("<cdata 'char *'"):
|
|
69
86
|
if str(result) == "<cdata 'char *' NULL>":
|
|
70
|
-
|
|
87
|
+
return ""
|
|
71
88
|
else:
|
|
72
|
-
|
|
73
|
-
|
|
89
|
+
return ffi.string(result).decode('utf-8')
|
|
90
|
+
else:
|
|
91
|
+
return result
|
|
74
92
|
|
|
75
|
-
|
|
93
|
+
# apparently pypy and cpython produce different types so check for both
|
|
94
|
+
def is_cdata(arg):
|
|
95
|
+
return str(type(arg)) == "<class '_cffi_backend.__CDataOwn'>" or str(
|
|
96
|
+
type(arg)) == "<class '_cffi_backend._CDataBase'>"
|
|
76
97
|
|
|
98
|
+
return wrapped_func
|
|
77
99
|
|
|
78
|
-
|
|
100
|
+
|
|
101
|
+
global_weakkeydict = weakref.WeakKeyDictionary()
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _make_struct_constructor_function(struct):
|
|
79
105
|
def func(*args):
|
|
80
|
-
|
|
106
|
+
# print(struct, args)
|
|
107
|
+
modified_args = []
|
|
108
|
+
for (field, arg) in zip(ffi.typeof(struct).fields, args):
|
|
109
|
+
# print("arg:", str(arg), "field:", field[1], "field type:", field[1].type, "type(arg):", str(type(arg)))
|
|
110
|
+
if arg is None:
|
|
111
|
+
arg = ffi.NULL
|
|
112
|
+
elif (field[1].type.kind == 'pointer'
|
|
113
|
+
and (str(type(arg)) == "<class 'numpy.ndarray'>"
|
|
114
|
+
or isinstance(arg, (array, bytes, bytearray, memoryview)))):
|
|
115
|
+
arg = ffi.from_buffer(field[1].type, arg)
|
|
116
|
+
modified_args.append(arg)
|
|
117
|
+
s = ffi.new(f"struct {struct} *", modified_args)[0]
|
|
118
|
+
global_weakkeydict[s] = modified_args
|
|
119
|
+
return s
|
|
81
120
|
|
|
82
121
|
return func
|
|
83
122
|
|
|
84
123
|
|
|
85
124
|
for name, attr in getmembers(rl):
|
|
86
125
|
# print(name, attr)
|
|
87
|
-
uname =
|
|
126
|
+
uname = _underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
|
|
88
127
|
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(
|
|
89
128
|
type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
|
90
129
|
# print(attr.__call__)
|
|
91
130
|
# print(attr.__doc__)
|
|
92
|
-
# print(attr.__text_signature__)
|
|
93
131
|
# print(dir(attr))
|
|
94
132
|
# print(dir(attr.__repr__))
|
|
95
|
-
f =
|
|
133
|
+
f = _wrap_function(attr)
|
|
96
134
|
setattr(current_module, uname, f)
|
|
97
|
-
# def wrap(*args):
|
|
98
|
-
# print("call to ",attr)
|
|
99
|
-
# setattr(PyRay, uname, lambda *args: print("call to ",attr))
|
|
100
135
|
else:
|
|
101
136
|
setattr(current_module, name, attr)
|
|
102
137
|
|
|
103
138
|
for struct in ffi.list_types()[0]:
|
|
104
|
-
f =
|
|
139
|
+
f = _make_struct_constructor_function(struct)
|
|
105
140
|
setattr(current_module, struct, f)
|
|
106
141
|
|
|
107
142
|
# overwrite ffi enums with our own
|