Compare commits
No commits in common. "2c94efb79689e8b2d3f55921bdf175c52c90c07d" and "dfd888a80a473ac0167a5cdd7d7ca6bc30056223" have entirely different histories.
2c94efb796
...
dfd888a80a
@ -7,11 +7,9 @@ with open(sys.argv[1], 'r') if sys.argv[1] != "-" else sys.stdin as f:
|
|||||||
|
|
||||||
api = json.loads(api_source)
|
api = json.loads(api_source)
|
||||||
|
|
||||||
def to_lua_type_annot(typedesc):
|
def to_lua_type_annot(typename):
|
||||||
if type(typedesc) is dict:
|
basetype = typename.rsplit(' *', 1)[0]
|
||||||
return r'{ %s }' % ','.join('%s: %s' % (f["name"], to_lua_type_annot(f["type"])) for f in typedesc["fields"])
|
if typename == "char *":
|
||||||
basetype = typedesc.rsplit(' *', 1)[0]
|
|
||||||
if typedesc == "char *":
|
|
||||||
return "string"
|
return "string"
|
||||||
elif basetype == "float":
|
elif basetype == "float":
|
||||||
return "number"
|
return "number"
|
||||||
@ -29,9 +27,7 @@ def to_lua_type_annot(typedesc):
|
|||||||
return r"{ x: number, y: number, w: number, h: number }"
|
return r"{ x: number, y: number, w: number, h: number }"
|
||||||
else:
|
else:
|
||||||
return "unknown"
|
return "unknown"
|
||||||
# raise BaseException("Unhandled type for annotation: %s" % typedesc)
|
# raise BaseException("Unhandled type for annotation: %s" % typename)
|
||||||
|
|
||||||
print("error(\"townengine lua api file is not supposed to be imported!\")")
|
|
||||||
|
|
||||||
type_annotations, enum_annotations = {}, {}
|
type_annotations, enum_annotations = {}, {}
|
||||||
type_annotations["ctx"] = r"{ %s, udata: table }" % \
|
type_annotations["ctx"] = r"{ %s, udata: table }" % \
|
||||||
@ -49,14 +45,9 @@ for annot in enum_annotations:
|
|||||||
|
|
||||||
procedure_annotations = {}
|
procedure_annotations = {}
|
||||||
for procedure, procedure_desc in api["procedures"].items():
|
for procedure, procedure_desc in api["procedures"].items():
|
||||||
procedure_annotations[procedure] = {}
|
procedure_annotations[procedure] = r"{ %s }" % \
|
||||||
procedure_annotations[procedure]["params"] = r"{ %s }" % \
|
|
||||||
', '.join("%s: %s" % (p["name"], to_lua_type_annot(p["type"]) + '?' * ("default" in p)) for p in procedure_desc["params"])
|
', '.join("%s: %s" % (p["name"], to_lua_type_annot(p["type"]) + '?' * ("default" in p)) for p in procedure_desc["params"])
|
||||||
if "return" in procedure_desc:
|
|
||||||
procedure_annotations[procedure]["return"] = to_lua_type_annot(procedure_desc["return"])
|
|
||||||
|
|
||||||
for annot in procedure_annotations:
|
for annot in procedure_annotations:
|
||||||
print("---@param args " + procedure_annotations[annot]["params"])
|
print("---@param args " + procedure_annotations[annot])
|
||||||
if "return" in procedure_annotations[annot]:
|
|
||||||
print("---@return " + procedure_annotations[annot]["return"])
|
|
||||||
print("function %s(args) end" % annot)
|
print("function %s(args) end" % annot)
|
||||||
|
@ -25,9 +25,7 @@ Matrix4 camera_look_at_matrix;
|
|||||||
double depth_range_low, depth_range_high;
|
double depth_range_low, depth_range_high;
|
||||||
|
|
||||||
|
|
||||||
void render_clear(void) {
|
void render_queue_clear(void) {
|
||||||
draw_camera((Vec3){0, 0, 0}, (Vec3){0, 0, 1}, (Vec3){0, 1, 0}, 1.57079632679f, 1);
|
|
||||||
|
|
||||||
text_cache_reset_arena(&ctx.text_cache);
|
text_cache_reset_arena(&ctx.text_cache);
|
||||||
|
|
||||||
/* since i don't intend to free the queues, */
|
/* since i don't intend to free the queues, */
|
||||||
|
@ -230,7 +230,7 @@ bool render_init(void);
|
|||||||
void render(void);
|
void render(void);
|
||||||
|
|
||||||
/* clears all render queues */
|
/* clears all render queues */
|
||||||
void render_clear(void);
|
void render_queue_clear(void);
|
||||||
|
|
||||||
/* fills two existing arrays with the geometry data of a circle */
|
/* fills two existing arrays with the geometry data of a circle */
|
||||||
/* the size of indices must be at least 3 times the number of vertices */
|
/* the size of indices must be at least 3 times the number of vertices */
|
||||||
|
@ -211,7 +211,7 @@ static void main_loop(void) {
|
|||||||
while (ctx.frame_accumulator >= ctx.desired_frametime) {
|
while (ctx.frame_accumulator >= ctx.desired_frametime) {
|
||||||
frames += 1;
|
frames += 1;
|
||||||
/* TODO: disable rendering pushes on not-last ? */
|
/* TODO: disable rendering pushes on not-last ? */
|
||||||
render_clear();
|
render_queue_clear();
|
||||||
poll_events();
|
poll_events();
|
||||||
if (ctx.window_size_has_changed)
|
if (ctx.window_size_has_changed)
|
||||||
update_viewport();
|
update_viewport();
|
||||||
|
Loading…
Reference in New Issue
Block a user