From 11c5b1a728456b3deb0d466064fba35d3dd77277 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 27 May 2025 14:53:20 +0100 Subject: [PATCH] use typedefs when constructing structs --- pyray/__init__.py | 2 +- tests/test_pyray.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyray/__init__.py b/pyray/__init__.py index c85959f..4a28587 100644 --- a/pyray/__init__.py +++ b/pyray/__init__.py @@ -126,7 +126,7 @@ def _make_struct_constructor_function(struct): or isinstance(arg, (array, bytes, bytearray, memoryview)))): arg = ffi.from_buffer(field[1].type, arg) modified_args.append(arg) - s = ffi.new(f"struct {struct} *", modified_args)[0] + s = ffi.new(f"{struct} *", modified_args)[0] global_weakkeydict[s] = modified_args return s diff --git a/tests/test_pyray.py b/tests/test_pyray.py index 478fcce..e9f54bc 100644 --- a/tests/test_pyray.py +++ b/tests/test_pyray.py @@ -7,6 +7,8 @@ import pyray as pr pr.init_window(800, 450, "Raylib texture test") pr.set_target_fps(60) +test_typedef_init = pr.Texture2D() # Texture2D is typedef for Texture + image = pr.gen_image_color(800, 400, (0,0,0,255) ) texture = pr.load_texture_from_image(image) pr.update_texture(texture, image.data)