electronstudio / raylib-python-cffi

Python CFFI bindings for Raylib
http://electronstudio.github.io/raylib-python-cffi
Eclipse Public License 2.0
142 stars 29 forks source link

Namespaces and enums #52

Open electronstudio opened 2 years ago

electronstudio commented 2 years ago

Currently the docs list enums, but they don’t actually exist as objects - cffi just converts all the values to ints.

So first we need to fix the docs.

Then, is there an automated way we could make real enums? Or just put the ints into appropriate namespaces so they are grouped appropriately together in the docs?

Yu-Vitaqua-fer-Chronos commented 2 years ago

Python has the Enum module which may be useful? Exec is usually discouraged but in certain scenarios it's fine, as this isn't running untrusted code. And recently Raylib released an official way to make automated bindings which could potentially help? If using the automated bindings, using SimpleNamespace could also help you collect the modules together

electronstudio commented 2 years ago

You mean https://github.com/raysan5/raylib/blob/master/parser/raylib_api.json ? We already use that to generate the .pyi hints. So yes you're right we could use it to generate enums.