From 67d5ad4860118fc699362abfd3ab57c96ef07a0e Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 21 Dec 2017 10:40:56 +0300 Subject: [PATCH] #477 api keywords moved to TIC module --- src/code.c | 6 ++---- src/jsapi.c | 6 +++++- src/luaapi.c | 8 ++++++++ src/machine.h | 5 +++++ src/tic.h | 6 ------ src/ticapi.h | 3 +++ 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/code.c b/src/code.c index 12892f3..ddc1929 100644 --- a/src/code.c +++ b/src/code.c @@ -281,10 +281,8 @@ static void parse(const char* start, u8* color, const tic_script_config* config) if(!keyword) { - static const char* const Api[] = API_KEYWORDS; - - for(s32 i = 0; i < COUNT_OF(Api); i++) - if(len == strlen(Api[i]) && memcmp(wordStart, Api[i], len) == 0) + for(s32 i = 0; i < config->apiCount; i++) + if(len == strlen(config->api[i]) && memcmp(wordStart, config->api[i], len) == 0) { memset(color + (wordStart - start), getConfig()->theme.code.api, len); break; diff --git a/src/jsapi.c b/src/jsapi.c index 08bddf3..9dc802c 100644 --- a/src/jsapi.c +++ b/src/jsapi.c @@ -816,7 +816,7 @@ static bool initJavascript(tic_mem* tic, const char* code) static void callJavascriptTick(tic_mem* tic) { tic_machine* machine = (tic_machine*)tic; - + const char* TicFunc = ApiKeywords[0]; duk_context* duk = machine->js; @@ -901,8 +901,12 @@ static const tic_script_config JsSyntaxConfig = .blockStringStart = NULL, .blockStringEnd = NULL, .singleComment = "//", + .keywords = JsKeywords, .keywordsCount = COUNT_OF(JsKeywords), + + .api = ApiKeywords, + .apiCount = COUNT_OF(ApiKeywords), }; const tic_script_config* getJsScriptConfig() diff --git a/src/luaapi.c b/src/luaapi.c index 6742d8f..97b0148 100644 --- a/src/luaapi.c +++ b/src/luaapi.c @@ -1329,8 +1329,12 @@ static const tic_script_config LuaSyntaxConfig = .singleComment = "--", .blockStringStart = "[[", .blockStringEnd = "]]", + .keywords = LuaKeywords, .keywordsCount = COUNT_OF(LuaKeywords), + + .api = ApiKeywords, + .apiCount = COUNT_OF(ApiKeywords), }; const tic_script_config* getLuaScriptConfig() @@ -1364,8 +1368,12 @@ static const tic_script_config MoonSyntaxConfig = .blockStringStart = NULL, .blockStringEnd = NULL, .singleComment = "--", + .keywords = MoonKeywords, .keywordsCount = COUNT_OF(MoonKeywords), + + .api = ApiKeywords, + .apiCount = COUNT_OF(ApiKeywords), }; const tic_script_config* getMoonScriptConfig() diff --git a/src/machine.h b/src/machine.h index 6047ccc..400b7c9 100644 --- a/src/machine.h +++ b/src/machine.h @@ -28,6 +28,11 @@ #define SFX_DEF_SPEED (1 << SFX_SPEED_BITS) +#define API_KEYWORDS {"TIC", "scanline", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \ + "spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \ + "memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \ + "clip", "music", "sync", "reset"} + typedef struct { s32 time; /* clock time of next delta */ diff --git a/src/tic.h b/src/tic.h index 08ef58e..6cdd327 100644 --- a/src/tic.h +++ b/src/tic.h @@ -111,12 +111,6 @@ #define TIC_BANKS (1 << TIC_BANK_BITS) #define SFX_NOTES {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"} - -#define API_KEYWORDS {"TIC", "scanline", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \ - "spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \ - "memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \ - "clip", "music", "sync", "reset"} - #define TIC_FONT_CHARS 128 enum diff --git a/src/ticapi.h b/src/ticapi.h index caa2b4f..db5be10 100644 --- a/src/ticapi.h +++ b/src/ticapi.h @@ -90,6 +90,9 @@ typedef struct const char* const * keywords; s32 keywordsCount; + + const char* const * api; + s32 apiCount; } tic_script_config; typedef struct