raylib 4.5.0.1__pp310-pypy310_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 +108 -0
- pyray/__init__.pyi +4333 -0
- raylib/__init__.py +24 -0
- raylib/__init__.pyi +4080 -0
- raylib/_raylib_cffi.pypy310-pp73-win_amd64.pyd +0 -0
- raylib/build.py +206 -0
- raylib/colors.py +41 -0
- raylib/defines.py +9 -0
- raylib/enums.py +702 -0
- raylib/version.py +1 -0
- raylib-4.5.0.1.dist-info/LICENSE +277 -0
- raylib-4.5.0.1.dist-info/METADATA +160 -0
- raylib-4.5.0.1.dist-info/RECORD +15 -0
- raylib-4.5.0.1.dist-info/WHEEL +5 -0
- raylib-4.5.0.1.dist-info/top_level.txt +2 -0
pyray/__init__.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Copyright (c) 2021 Richard Smith and others
|
|
2
|
+
#
|
|
3
|
+
# This program and the accompanying materials are made available under the
|
|
4
|
+
# terms of the Eclipse Public License 2.0 which is available at
|
|
5
|
+
# http://www.eclipse.org/legal/epl-2.0.
|
|
6
|
+
#
|
|
7
|
+
# This Source Code may also be made available under the following Secondary
|
|
8
|
+
# licenses when the conditions for such availability set forth in the Eclipse
|
|
9
|
+
# Public License, v. 2.0 are satisfied: GNU General Public License, version 2
|
|
10
|
+
# with the GNU Classpath Exception which is
|
|
11
|
+
# available at https://www.gnu.org/software/classpath/license.html.
|
|
12
|
+
#
|
|
13
|
+
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
|
|
15
|
+
from raylib import rl, ffi
|
|
16
|
+
from raylib.colors import *
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
from raylib.defines import *
|
|
20
|
+
except AttributeError:
|
|
21
|
+
print("sorry deprecated enums dont work on dynamic version")
|
|
22
|
+
|
|
23
|
+
from inspect import getmembers, isbuiltin
|
|
24
|
+
import inflection
|
|
25
|
+
|
|
26
|
+
current_module = __import__(__name__)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def pointer(self, struct):
|
|
30
|
+
return ffi.addressof(struct)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# I'm concerned that we are doing a lot of string comparisons on every function call to detect types.
|
|
34
|
+
# Quickest way would probably be isinstance(result, ffi._backend._CDataBase) but that class name varies
|
|
35
|
+
# depending on if binding is static/dynamic
|
|
36
|
+
# (and possibly also different on pypy implementations?).
|
|
37
|
+
# which makes me reluctant to rely on it.
|
|
38
|
+
# Another possibility is ffi.typeof() but that will throw an exception if you give it a type that isn't a ctype
|
|
39
|
+
# Another way to improve performance might be to special-case simple types before doing the string comparisons
|
|
40
|
+
|
|
41
|
+
def makefunc(a):
|
|
42
|
+
# print("makefunc ",a, ffi.typeof(a).args)
|
|
43
|
+
def func(*args):
|
|
44
|
+
modified_args = []
|
|
45
|
+
for (c_arg, arg) in zip(ffi.typeof(a).args, args):
|
|
46
|
+
#print("arg:",str(arg), "c_arg.kind:", c_arg.kind, "c_arg:", c_arg, "type(arg):",str(type(arg)))
|
|
47
|
+
if c_arg.kind == 'pointer':
|
|
48
|
+
if type(arg) == str:
|
|
49
|
+
arg = arg.encode('utf-8')
|
|
50
|
+
elif type(arg) is bool:
|
|
51
|
+
arg = ffi.new("bool *", arg)
|
|
52
|
+
elif type(arg) is int:
|
|
53
|
+
arg = ffi.new("int *", arg)
|
|
54
|
+
elif type(arg) is float:
|
|
55
|
+
arg = ffi.new("float *", arg)
|
|
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
|
|
59
|
+
arg = ffi.addressof(arg)
|
|
60
|
+
elif str(type(arg)) == "<class '_cffi_backend._CDataBase'>" and "*" not in str(arg): # Pypy
|
|
61
|
+
arg = ffi.addressof(arg)
|
|
62
|
+
elif arg is None:
|
|
63
|
+
arg = ffi.NULL
|
|
64
|
+
modified_args.append(arg)
|
|
65
|
+
result = a(*modified_args)
|
|
66
|
+
if result is None:
|
|
67
|
+
return
|
|
68
|
+
if str(type(result)) == "<class '_cffi_backend._CDataBase'>" and str(result).startswith("<cdata 'char *'"):
|
|
69
|
+
if str(result) == "<cdata 'char *' NULL>":
|
|
70
|
+
result = ""
|
|
71
|
+
else:
|
|
72
|
+
result = ffi.string(result).decode('utf-8')
|
|
73
|
+
return result
|
|
74
|
+
|
|
75
|
+
return func
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def makeStructHelper(struct):
|
|
79
|
+
def func(*args):
|
|
80
|
+
return ffi.new(f"struct {struct} *", args)[0]
|
|
81
|
+
|
|
82
|
+
return func
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
for name, attr in getmembers(rl):
|
|
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__))
|
|
95
|
+
f = makefunc(attr)
|
|
96
|
+
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
|
+
else:
|
|
101
|
+
setattr(current_module, name, attr)
|
|
102
|
+
|
|
103
|
+
for struct in ffi.list_types()[0]:
|
|
104
|
+
f = makeStructHelper(struct)
|
|
105
|
+
setattr(current_module, struct, f)
|
|
106
|
+
|
|
107
|
+
# overwrite ffi enums with our own
|
|
108
|
+
from raylib.enums import *
|