Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix how regex inserts underscore in function names with '2d' and '3d' #149

Open
wants to merge 1 commit into
base: sdl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion create_stub_pyray.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from pathlib import Path
from raylib import rl, ffi
from pyray import _underscore
from inspect import ismethod, getmembers, isbuiltin
import inflection, sys, json

Expand Down Expand Up @@ -69,7 +70,7 @@ def ctype_to_python_type(t):
reserved_words = ("in", "list", "tuple", "set", "dict", "from", "range", "min", "max", "any", "all", "len")

for name, attr in getmembers(rl):
uname = inflection.underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
uname = _underscore(name)
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>":
json_object = known_functions.get(name, None)
if json_object is None:
Expand Down
7 changes: 3 additions & 4 deletions pyray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@


def _underscore(word: str) -> str:
"""
from inflection
"""
word = re.sub('2D$', '_2d', word)
word = re.sub('3D$', '_3d', word)
word = re.sub(r"([A-Z]+)([A-Z][a-z])", r'\1_\2', word)
word = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', word)
word = word.replace("-", "_")
Expand Down Expand Up @@ -136,7 +135,7 @@ def func(*args):

for name, attr in getmembers(rl):
# print(name, attr)
uname = _underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
uname = _underscore(name)
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(
type(attr)) == "<class '_cffi_backend._CDataBase'>":
# print(attr.__call__)
Expand Down
16 changes: 8 additions & 8 deletions pyray/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2120,16 +2120,16 @@ def vector2_clamp(v: Vector2,min_1: Vector2,max_2: Vector2,) -> Vector2:
def vector2_clamp_value(v: Vector2,min_1: float,max_2: float,) -> Vector2:
""""""
...
def vector_2distance(v1: Vector2,v2: Vector2,) -> float:
def vector2_distance(v1: Vector2,v2: Vector2,) -> float:
""""""
...
def vector_2distance_sqr(v1: Vector2,v2: Vector2,) -> float:
def vector2_distance_sqr(v1: Vector2,v2: Vector2,) -> float:
""""""
...
def vector_2divide(v1: Vector2,v2: Vector2,) -> Vector2:
def vector2_divide(v1: Vector2,v2: Vector2,) -> Vector2:
""""""
...
def vector_2dot_product(v1: Vector2,v2: Vector2,) -> float:
def vector2_dot_product(v1: Vector2,v2: Vector2,) -> float:
""""""
...
def vector2_equals(p: Vector2,q: Vector2,) -> int:
Expand Down Expand Up @@ -2219,16 +2219,16 @@ def vector3_cross_product(v1: Vector3,v2: Vector3,) -> Vector3:
def vector3_cubic_hermite(v1: Vector3,tangent1: Vector3,v2: Vector3,tangent2: Vector3,amount: float,) -> Vector3:
""""""
...
def vector_3distance(v1: Vector3,v2: Vector3,) -> float:
def vector3_distance(v1: Vector3,v2: Vector3,) -> float:
""""""
...
def vector_3distance_sqr(v1: Vector3,v2: Vector3,) -> float:
def vector3_distance_sqr(v1: Vector3,v2: Vector3,) -> float:
""""""
...
def vector_3divide(v1: Vector3,v2: Vector3,) -> Vector3:
def vector3_divide(v1: Vector3,v2: Vector3,) -> Vector3:
""""""
...
def vector_3dot_product(v1: Vector3,v2: Vector3,) -> float:
def vector3_dot_product(v1: Vector3,v2: Vector3,) -> float:
""""""
...
def vector3_equals(p: Vector3,q: Vector3,) -> int:
Expand Down
Loading