From f4a32989061108a49acf10e4bfb6c8df87ea18bf Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Fri, 3 Jan 2025 11:45:10 +0300 Subject: [PATCH] disallow pointer to pointer in api --- apps/twnlua/bindgen.py | 4 ++-- docs/interop.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/twnlua/bindgen.py b/apps/twnlua/bindgen.py index bfafcf5..c14114a 100755 --- a/apps/twnlua/bindgen.py +++ b/apps/twnlua/bindgen.py @@ -19,7 +19,7 @@ def default(parameter): return "NULL" else: return '"' + parameter["default"] + '"' elif basetype in api["types"]: - if parameter["type"].endswith("*"): + if parameter["type"].endswith(" *"): if parameter["default"] == {}: return "NULL" else: @@ -103,7 +103,7 @@ for procedure, procedure_desc in api["procedures"].items(): elif parameter["type"] == "char *": binding += " %s = lua_tostring(L, -1);\n" % (parameter["name"]); elif basetype in api["types"]: - if parameter["type"].endswith("*"): + if parameter["type"].endswith(" *"): binding += " { %s_value = to_%s(L, -1); %s = &%s_value; }\n" % (parameter["name"], basetype.lower(), parameter["name"], parameter["name"]); else: binding += " %s = to_%s(L, -1);\n" % (parameter["name"], basetype.lower()); diff --git a/docs/interop.md b/docs/interop.md index a9e3bed..dbf4729 100644 --- a/docs/interop.md +++ b/docs/interop.md @@ -7,6 +7,7 @@ for that certain considerations are taken: with no expectation on new additions (see [/include/twn_types.h](../include/twn_types.h)) * optionals can be expressed via pointer passage of value primitives, assumed immutable, with the NULL expressing default * no opaque types, only keys +* pointers to pointers aren't allowed * when mutation on input is done, - it shouldn't be achieved from a mutable pointer, but the return value * return value could be a simple aggregate that is translatable to pure data dictionary * module prefix is used for namespacing, actual symbols come after the prefix (`_`)