From 81590eb8158fdff3bfa540ff3c9c995cb45b414a Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 18 Oct 2022 10:33:37 +0100 Subject: [PATCH] automate conversion of lists of strings https://github.com/electronstudio/raylib-python-cffi/discussions/98 --- pyray/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyray/__init__.py b/pyray/__init__.py index cbfd321..5dbb530 100644 --- a/pyray/__init__.py +++ b/pyray/__init__.py @@ -43,7 +43,7 @@ def makefunc(a): def func(*args): modified_args = [] for (c_arg, arg) in zip(ffi.typeof(a).args, args): - # print("arg:",str(arg), "c_arg.kind:", c_arg.kind, "c_arg:", c_arg, "type(arg):",str(type(arg))) + #print("arg:",str(arg), "c_arg.kind:", c_arg.kind, "c_arg:", c_arg, "type(arg):",str(type(arg))) if c_arg.kind == 'pointer': if type(arg) == str: arg = arg.encode('utf-8') @@ -53,6 +53,8 @@ def makefunc(a): arg = ffi.new("int *", arg) elif type(arg) is float: arg = ffi.new("float *", arg) + elif type(arg) is list and str(c_arg) == "": + arg = [ffi.new("char[]", x.encode('utf-8')) for x in arg] elif str(type(arg)) == "" and "*" not in str(arg): # CPython arg = ffi.addressof(arg) elif str(type(arg)) == "" and "*" not in str(arg): # Pypy