disallow pointer to pointer in api

This commit is contained in:
veclavtalica 2025-01-03 11:45:10 +03:00
parent 8ec5a96333
commit f4a3298906
2 changed files with 3 additions and 2 deletions

View File

@ -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());

View File

@ -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 (`<module>_<symbol>`)