From 85e47dd677e9eadf47dfcb8f9d23d4b2d2a26105 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Fri, 21 Feb 2025 12:48:51 +0300 Subject: [PATCH] api return restriction --- docs/wiki/about-townengine.html | 1 + share/twn_api.json | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/wiki/about-townengine.html b/docs/wiki/about-townengine.html index bd6a922..fed389b 100644 --- a/docs/wiki/about-townengine.html +++ b/docs/wiki/about-townengine.html @@ -73,6 +73,7 @@
  • Procedure can't have more than 8 parameters.
  • Decimal portions of floating points are lossy both due to rounding errors and text representation, thus they cannot be relied to hold for equality. Integer parts of floats are good up to 2^24. +
  • Returns must be restricted/closed on being constant over frame, parameters or asset frame. diff --git a/share/twn_api.json b/share/twn_api.json index cf543df..31a9986 100644 --- a/share/twn_api.json +++ b/share/twn_api.json @@ -19,7 +19,8 @@ "params": [ { "name": "name", "type": "char *" } ], - "return": "bool" + "return": "bool", + "restriction": "frame" }, "input_action_just_pressed": { @@ -29,7 +30,8 @@ "params": [ { "name": "name", "type": "char *" } ], - "return": "bool" + "return": "bool", + "restriction": "frame" }, "input_action_just_released": { @@ -39,7 +41,8 @@ "params": [ { "name": "name", "type": "char *" } ], - "return": "bool" + "return": "bool", + "restriction": "frame" }, "input_action_position": { @@ -49,7 +52,8 @@ "params": [ { "name": "name", "type": "char *" } ], - "return": "Vec2" + "return": "Vec2", + "restriction": "frame" }, "draw_sprite": { @@ -111,7 +115,8 @@ { "name": "height", "type": "float", "default": 22 }, { "name": "font", "type": "char *", "default": {} } ], - "return": "float" + "return": "float", + "restriction": "asset" }, "draw_nine_slice": { @@ -228,7 +233,8 @@ { "name": "up", "type": "Vec3" } ], "c_type": "DrawCameraFromPrincipalAxesResult" - } + }, + "restriction": "parameters" }, "draw_skybox": { @@ -271,7 +277,8 @@ "params": [ { "name": "file", "type": "char *" } ], - "return": "char *" + "return": "char *", + "restriction": "asset" }, "timer_tick_seconds": { @@ -281,7 +288,8 @@ "params": [ { "name": "seconds_left", "type": "float" } ], - "return": "float" + "return": "float", + "restriction": "parameters" }, "timer_elapse_seconds": { @@ -299,7 +307,8 @@ { "name": "elapsed", "type": "bool" } ], "c_type": "TimerElapseSecondsResult" - } + }, + "restriction": "parameters" }, "log_vec2": {