Compare commits
No commits in common. "458b44d0b0c046942b424c3b6081cf51f2c5c596" and "ac93d114c95b40ee575f549ec4e150740f6e2427" have entirely different histories.
458b44d0b0
...
ac93d114c9
@ -84,7 +84,7 @@ for procedure, procedure_desc in api["procedures"].items():
|
|||||||
binding += " %s %s;\n" % (parameter["type"] if not parameter["type"].endswith("*") else 'const ' + parameter["type"], parameter["name"])
|
binding += " %s %s;\n" % (parameter["type"] if not parameter["type"].endswith("*") else 'const ' + parameter["type"], parameter["name"])
|
||||||
binding += " lua_getfield(L, 1, \"%s\");\n" % parameter["name"]
|
binding += " lua_getfield(L, 1, \"%s\");\n" % parameter["name"]
|
||||||
|
|
||||||
if "default" in parameter and not parameter["type"] in ("float", "bool"):
|
if "default" in parameter and parameter["type"] != "float":
|
||||||
binding += " if (lua_isnoneornil(L, -1))\n"
|
binding += " if (lua_isnoneornil(L, -1))\n"
|
||||||
binding += " %s = %s;\n" % (parameter["name"], default(parameter))
|
binding += " %s = %s;\n" % (parameter["name"], default(parameter))
|
||||||
binding += " else\n "
|
binding += " else\n "
|
||||||
@ -141,15 +141,15 @@ for typename, typedesc in used_converters.items():
|
|||||||
converter += " %s %s;\n" % (typename, typename.lower());
|
converter += " %s %s;\n" % (typename, typename.lower());
|
||||||
|
|
||||||
if "fields" in typedesc:
|
if "fields" in typedesc:
|
||||||
for idx, field in enumerate(typedesc["fields"]):
|
for field in typedesc["fields"]:
|
||||||
converter += " lua_getfield(L, -%i, \"%s\");\n" % (idx + 1, field["name"]);
|
converter += " lua_getfield(L, -1, \"%s\");\n" % (field["name"]);
|
||||||
if field["type"] == "float":
|
if field["type"] == "float":
|
||||||
converter += " %s.%s = (float)lua_tonumber(L, -1);\n" % (typename.lower(), field["name"]);
|
converter += " %s.%s = (float)lua_tonumber(L, -1);\n" % (typename.lower(), field["name"]);
|
||||||
elif field["type"] == "uint8_t":
|
elif field["type"] == "uint8_t":
|
||||||
converter += " %s.%s = (uint8_t)lua_tointeger(L, -1);\n" % (typename.lower(), field["name"]);
|
converter += " %s.%s = (uint8_t)lua_tointeger(L, -1);\n" % (typename.lower(), field["name"]);
|
||||||
else:
|
else:
|
||||||
raise BaseException("Unhandled converter field type '%s'" % (field["type"]))
|
raise BaseException("Unhandled converter field type '%s'" % (field["type"]))
|
||||||
converter += " lua_pop(L, %i);\n" % len(typedesc["fields"]);
|
converter += " lua_pop(L, 1);\n";
|
||||||
|
|
||||||
# TODO: wild idea: use compile time built hash table
|
# TODO: wild idea: use compile time built hash table
|
||||||
elif "enums" in typedesc:
|
elif "enums" in typedesc:
|
||||||
|
@ -5,7 +5,6 @@ for that certain considerations are taken:
|
|||||||
* number of public api calls is kept at the minimum
|
* number of public api calls is kept at the minimum
|
||||||
* procedure parameters can only use basic types, no aggregates, with exception of Vec/Matrix types and alike,
|
* procedure parameters can only use basic types, no aggregates, with exception of Vec/Matrix types and alike,
|
||||||
with no new additions, ever (see [/include/twn_types.h](../include/twn_types.h))
|
with no new additions, ever (see [/include/twn_types.h](../include/twn_types.h))
|
||||||
* enum types are allowed, as they decay to numeric type (but language-specific api can decide to provide simple ways to use them)
|
|
||||||
* optionals can be expressed via pointer passage of value primitives, assumed immutable, with the NULL expressing default value
|
* optionals can be expressed via pointer passage of value primitives, assumed immutable, with the NULL expressing default value
|
||||||
* no opaque types, only keys if needed
|
* no opaque types, only keys if needed
|
||||||
* pointers to pointers aren't allowed
|
* pointers to pointers aren't allowed
|
||||||
@ -16,4 +15,3 @@ for that certain considerations are taken:
|
|||||||
* 32 bit floating point is the only numeric type
|
* 32 bit floating point is the only numeric type
|
||||||
* [/include/twn_api.json](../share/twn_api.json) file is hand-kept with a schema to aid automatic binding generation and tooling
|
* [/include/twn_api.json](../share/twn_api.json) file is hand-kept with a schema to aid automatic binding generation and tooling
|
||||||
* parameter names should not collide with keywords of any language that is targetted; if so happens, parameter alias could be added
|
* parameter names should not collide with keywords of any language that is targetted; if so happens, parameter alias could be added
|
||||||
* any procedure can't have more than 8 parameters
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
/* pushes a sprite onto the sprite render queue */
|
/* pushes a sprite onto the sprite render queue */
|
||||||
/* TODO: combine flip_x and flip_y into a flip_mask with enum */
|
|
||||||
TWN_API void draw_sprite(char const *texture,
|
TWN_API void draw_sprite(char const *texture,
|
||||||
Rect rect,
|
Rect rect,
|
||||||
Rect const *texture_region, /* optional, default: NULL */
|
Rect const *texture_region, /* optional, default: NULL */
|
||||||
|
Loading…
Reference in New Issue
Block a user