From 4eb3d8857f1a8377f2cfa6e804183512cde5973e Mon Sep 17 00:00:00 2001 From: lazaray <104470294+lazaray@users.noreply.github.com> Date: Wed, 4 May 2022 13:44:55 +0200 Subject: [PATCH] Reorder parser (#2462) * Reorder parser output * Regenerate parser output * Reorder parser line reading * Reorder parser data parsing * Reorder remaining parser stuff --- parser/raylib_api.json | 794 +++++++++++++++--------------- parser/raylib_api.lua | 716 +++++++++++++-------------- parser/raylib_api.txt | 606 +++++++++++------------ parser/raylib_api.xml | 162 +++--- parser/raylib_parser.c | 1054 ++++++++++++++++++++-------------------- 5 files changed, 1665 insertions(+), 1667 deletions(-) diff --git a/parser/raylib_api.json b/parser/raylib_api.json index 98a939b25..5006e2069 100644 --- a/parser/raylib_api.json +++ b/parser/raylib_api.json @@ -1,4 +1,318 @@ { + "defines": [ + { + "name": "RAYLIB_H", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RAYLIB_VERSION", + "type": "STRING", + "value": "4.1-dev", + "description": "" + }, + { + "name": "RLAPI", + "type": "UNKNOWN", + "value": "__declspec(dllexport)", + "description": "We are building the library as a Win32 shared library (.dll)" + }, + { + "name": "PI", + "type": "FLOAT", + "value": 3.14159265358979323846, + "description": "" + }, + { + "name": "DEG2RAD", + "type": "UNKNOWN", + "value": "(PI/180.0f)", + "description": "" + }, + { + "name": "RAD2DEG", + "type": "UNKNOWN", + "value": "(180.0f/PI)", + "description": "" + }, + { + "name": "RL_MALLOC(sz)", + "type": "MACRO", + "value": "malloc(sz)", + "description": "" + }, + { + "name": "RL_CALLOC(n,sz)", + "type": "MACRO", + "value": "calloc(n,sz)", + "description": "" + }, + { + "name": "RL_REALLOC(ptr,sz)", + "type": "MACRO", + "value": "realloc(ptr,sz)", + "description": "" + }, + { + "name": "RL_FREE(ptr)", + "type": "MACRO", + "value": "free(ptr)", + "description": "" + }, + { + "name": "CLITERAL(type)", + "type": "MACRO", + "value": "type", + "description": "" + }, + { + "name": "RL_COLOR_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_RECTANGLE_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_VECTOR2_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_VECTOR3_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_VECTOR4_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_QUATERNION_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_MATRIX_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "LIGHTGRAY", + "type": "COLOR", + "value": "CLITERAL(Color){ 200, 200, 200, 255 }", + "description": "Light Gray" + }, + { + "name": "GRAY", + "type": "COLOR", + "value": "CLITERAL(Color){ 130, 130, 130, 255 }", + "description": "Gray" + }, + { + "name": "DARKGRAY", + "type": "COLOR", + "value": "CLITERAL(Color){ 80, 80, 80, 255 }", + "description": "Dark Gray" + }, + { + "name": "YELLOW", + "type": "COLOR", + "value": "CLITERAL(Color){ 253, 249, 0, 255 }", + "description": "Yellow" + }, + { + "name": "GOLD", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 203, 0, 255 }", + "description": "Gold" + }, + { + "name": "ORANGE", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 161, 0, 255 }", + "description": "Orange" + }, + { + "name": "PINK", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 109, 194, 255 }", + "description": "Pink" + }, + { + "name": "RED", + "type": "COLOR", + "value": "CLITERAL(Color){ 230, 41, 55, 255 }", + "description": "Red" + }, + { + "name": "MAROON", + "type": "COLOR", + "value": "CLITERAL(Color){ 190, 33, 55, 255 }", + "description": "Maroon" + }, + { + "name": "GREEN", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 228, 48, 255 }", + "description": "Green" + }, + { + "name": "LIME", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 158, 47, 255 }", + "description": "Lime" + }, + { + "name": "DARKGREEN", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 117, 44, 255 }", + "description": "Dark Green" + }, + { + "name": "SKYBLUE", + "type": "COLOR", + "value": "CLITERAL(Color){ 102, 191, 255, 255 }", + "description": "Sky Blue" + }, + { + "name": "BLUE", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 121, 241, 255 }", + "description": "Blue" + }, + { + "name": "DARKBLUE", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 82, 172, 255 }", + "description": "Dark Blue" + }, + { + "name": "PURPLE", + "type": "COLOR", + "value": "CLITERAL(Color){ 200, 122, 255, 255 }", + "description": "Purple" + }, + { + "name": "VIOLET", + "type": "COLOR", + "value": "CLITERAL(Color){ 135, 60, 190, 255 }", + "description": "Violet" + }, + { + "name": "DARKPURPLE", + "type": "COLOR", + "value": "CLITERAL(Color){ 112, 31, 126, 255 }", + "description": "Dark Purple" + }, + { + "name": "BEIGE", + "type": "COLOR", + "value": "CLITERAL(Color){ 211, 176, 131, 255 }", + "description": "Beige" + }, + { + "name": "BROWN", + "type": "COLOR", + "value": "CLITERAL(Color){ 127, 106, 79, 255 }", + "description": "Brown" + }, + { + "name": "DARKBROWN", + "type": "COLOR", + "value": "CLITERAL(Color){ 76, 63, 47, 255 }", + "description": "Dark Brown" + }, + { + "name": "WHITE", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 255, 255, 255 }", + "description": "White" + }, + { + "name": "BLACK", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 0, 0, 255 }", + "description": "Black" + }, + { + "name": "BLANK", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 0, 0, 0 }", + "description": "Blank (Transparent)" + }, + { + "name": "MAGENTA", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 0, 255, 255 }", + "description": "Magenta" + }, + { + "name": "RAYWHITE", + "type": "COLOR", + "value": "CLITERAL(Color){ 245, 245, 245, 255 }", + "description": "My own White (raylib logo)" + }, + { + "name": "RL_BOOL_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "MOUSE_LEFT_BUTTON", + "type": "UNKNOWN", + "value": "MOUSE_BUTTON_LEFT", + "description": "" + }, + { + "name": "MOUSE_RIGHT_BUTTON", + "type": "UNKNOWN", + "value": "MOUSE_BUTTON_RIGHT", + "description": "" + }, + { + "name": "MOUSE_MIDDLE_BUTTON", + "type": "UNKNOWN", + "value": "MOUSE_BUTTON_MIDDLE", + "description": "" + }, + { + "name": "MATERIAL_MAP_DIFFUSE", + "type": "UNKNOWN", + "value": "MATERIAL_MAP_ALBEDO", + "description": "" + }, + { + "name": "MATERIAL_MAP_SPECULAR", + "type": "UNKNOWN", + "value": "MATERIAL_MAP_METALNESS", + "description": "" + }, + { + "name": "SHADER_LOC_MAP_DIFFUSE", + "type": "UNKNOWN", + "value": "SHADER_LOC_MAP_ALBEDO", + "description": "" + }, + { + "name": "SHADER_LOC_MAP_SPECULAR", + "type": "UNKNOWN", + "value": "SHADER_LOC_MAP_METALNESS", + "description": "" + } + ], "structs": [ { "name": "Vector2", @@ -2582,318 +2896,100 @@ ] } ], - "defines": [ + "callbacks": [ { - "name": "RAYLIB_H", - "type": "GUARD", - "value": "", - "description": "" + "name": "TraceLogCallback", + "description": "Logging: Redirect trace log messages", + "returnType": "void", + "params": [ + { + "type": "int", + "name": "logLevel" + }, + { + "type": "const char *", + "name": "text" + }, + { + "type": "va_list", + "name": "args" + } + ] }, { - "name": "RAYLIB_VERSION", - "type": "STRING", - "value": "4.1-dev", - "description": "" + "name": "LoadFileDataCallback", + "description": "FileIO: Load binary data", + "returnType": "unsigned char *", + "params": [ + { + "type": "const char *", + "name": "fileName" + }, + { + "type": "unsigned int *", + "name": "bytesRead" + } + ] }, { - "name": "RLAPI", - "type": "UNKNOWN", - "value": "__declspec(dllexport)", - "description": "We are building the library as a Win32 shared library (.dll)" + "name": "SaveFileDataCallback", + "description": "FileIO: Save binary data", + "returnType": "bool", + "params": [ + { + "type": "const char *", + "name": "fileName" + }, + { + "type": "void *", + "name": "data" + }, + { + "type": "unsigned int", + "name": "bytesToWrite" + } + ] }, { - "name": "PI", - "type": "FLOAT", - "value": 3.14159265358979323846, - "description": "" + "name": "LoadFileTextCallback", + "description": "FileIO: Load text data", + "returnType": "char *", + "params": [ + { + "type": "const char *", + "name": "fileName" + } + ] }, { - "name": "DEG2RAD", - "type": "UNKNOWN", - "value": "(PI/180.0f)", - "description": "" + "name": "SaveFileTextCallback", + "description": "FileIO: Save text data", + "returnType": "bool", + "params": [ + { + "type": "const char *", + "name": "fileName" + }, + { + "type": "char *", + "name": "text" + } + ] }, { - "name": "RAD2DEG", - "type": "UNKNOWN", - "value": "(180.0f/PI)", - "description": "" - }, - { - "name": "RL_MALLOC(sz)", - "type": "MACRO", - "value": "malloc(sz)", - "description": "" - }, - { - "name": "RL_CALLOC(n,sz)", - "type": "MACRO", - "value": "calloc(n,sz)", - "description": "" - }, - { - "name": "RL_REALLOC(ptr,sz)", - "type": "MACRO", - "value": "realloc(ptr,sz)", - "description": "" - }, - { - "name": "RL_FREE(ptr)", - "type": "MACRO", - "value": "free(ptr)", - "description": "" - }, - { - "name": "CLITERAL(type)", - "type": "MACRO", - "value": "type", - "description": "" - }, - { - "name": "RL_COLOR_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_RECTANGLE_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_VECTOR2_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_VECTOR3_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_VECTOR4_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_QUATERNION_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_MATRIX_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "LIGHTGRAY", - "type": "COLOR", - "value": "CLITERAL(Color){ 200, 200, 200, 255 }", - "description": "Light Gray" - }, - { - "name": "GRAY", - "type": "COLOR", - "value": "CLITERAL(Color){ 130, 130, 130, 255 }", - "description": "Gray" - }, - { - "name": "DARKGRAY", - "type": "COLOR", - "value": "CLITERAL(Color){ 80, 80, 80, 255 }", - "description": "Dark Gray" - }, - { - "name": "YELLOW", - "type": "COLOR", - "value": "CLITERAL(Color){ 253, 249, 0, 255 }", - "description": "Yellow" - }, - { - "name": "GOLD", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 203, 0, 255 }", - "description": "Gold" - }, - { - "name": "ORANGE", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 161, 0, 255 }", - "description": "Orange" - }, - { - "name": "PINK", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 109, 194, 255 }", - "description": "Pink" - }, - { - "name": "RED", - "type": "COLOR", - "value": "CLITERAL(Color){ 230, 41, 55, 255 }", - "description": "Red" - }, - { - "name": "MAROON", - "type": "COLOR", - "value": "CLITERAL(Color){ 190, 33, 55, 255 }", - "description": "Maroon" - }, - { - "name": "GREEN", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 228, 48, 255 }", - "description": "Green" - }, - { - "name": "LIME", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 158, 47, 255 }", - "description": "Lime" - }, - { - "name": "DARKGREEN", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 117, 44, 255 }", - "description": "Dark Green" - }, - { - "name": "SKYBLUE", - "type": "COLOR", - "value": "CLITERAL(Color){ 102, 191, 255, 255 }", - "description": "Sky Blue" - }, - { - "name": "BLUE", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 121, 241, 255 }", - "description": "Blue" - }, - { - "name": "DARKBLUE", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 82, 172, 255 }", - "description": "Dark Blue" - }, - { - "name": "PURPLE", - "type": "COLOR", - "value": "CLITERAL(Color){ 200, 122, 255, 255 }", - "description": "Purple" - }, - { - "name": "VIOLET", - "type": "COLOR", - "value": "CLITERAL(Color){ 135, 60, 190, 255 }", - "description": "Violet" - }, - { - "name": "DARKPURPLE", - "type": "COLOR", - "value": "CLITERAL(Color){ 112, 31, 126, 255 }", - "description": "Dark Purple" - }, - { - "name": "BEIGE", - "type": "COLOR", - "value": "CLITERAL(Color){ 211, 176, 131, 255 }", - "description": "Beige" - }, - { - "name": "BROWN", - "type": "COLOR", - "value": "CLITERAL(Color){ 127, 106, 79, 255 }", - "description": "Brown" - }, - { - "name": "DARKBROWN", - "type": "COLOR", - "value": "CLITERAL(Color){ 76, 63, 47, 255 }", - "description": "Dark Brown" - }, - { - "name": "WHITE", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 255, 255, 255 }", - "description": "White" - }, - { - "name": "BLACK", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 0, 0, 255 }", - "description": "Black" - }, - { - "name": "BLANK", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 0, 0, 0 }", - "description": "Blank (Transparent)" - }, - { - "name": "MAGENTA", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 0, 255, 255 }", - "description": "Magenta" - }, - { - "name": "RAYWHITE", - "type": "COLOR", - "value": "CLITERAL(Color){ 245, 245, 245, 255 }", - "description": "My own White (raylib logo)" - }, - { - "name": "RL_BOOL_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "MOUSE_LEFT_BUTTON", - "type": "UNKNOWN", - "value": "MOUSE_BUTTON_LEFT", - "description": "" - }, - { - "name": "MOUSE_RIGHT_BUTTON", - "type": "UNKNOWN", - "value": "MOUSE_BUTTON_RIGHT", - "description": "" - }, - { - "name": "MOUSE_MIDDLE_BUTTON", - "type": "UNKNOWN", - "value": "MOUSE_BUTTON_MIDDLE", - "description": "" - }, - { - "name": "MATERIAL_MAP_DIFFUSE", - "type": "UNKNOWN", - "value": "MATERIAL_MAP_ALBEDO", - "description": "" - }, - { - "name": "MATERIAL_MAP_SPECULAR", - "type": "UNKNOWN", - "value": "MATERIAL_MAP_METALNESS", - "description": "" - }, - { - "name": "SHADER_LOC_MAP_DIFFUSE", - "type": "UNKNOWN", - "value": "SHADER_LOC_MAP_ALBEDO", - "description": "" - }, - { - "name": "SHADER_LOC_MAP_SPECULAR", - "type": "UNKNOWN", - "value": "SHADER_LOC_MAP_METALNESS", - "description": "" + "name": "AudioCallback", + "description": "", + "returnType": "void", + "params": [ + { + "type": "void *", + "name": "bufferData" + }, + { + "type": "unsigned int", + "name": "frames" + } + ] } ], "functions": [ @@ -10556,101 +10652,5 @@ } ] } - ], - "callbacks": [ - { - "name": "TraceLogCallback", - "description": "Logging: Redirect trace log messages", - "returnType": "void", - "params": [ - { - "type": "int", - "name": "logLevel" - }, - { - "type": "const char *", - "name": "text" - }, - { - "type": "va_list", - "name": "args" - } - ] - }, - { - "name": "LoadFileDataCallback", - "description": "FileIO: Load binary data", - "returnType": "unsigned char *", - "params": [ - { - "type": "const char *", - "name": "fileName" - }, - { - "type": "unsigned int *", - "name": "bytesRead" - } - ] - }, - { - "name": "SaveFileDataCallback", - "description": "FileIO: Save binary data", - "returnType": "bool", - "params": [ - { - "type": "const char *", - "name": "fileName" - }, - { - "type": "void *", - "name": "data" - }, - { - "type": "unsigned int", - "name": "bytesToWrite" - } - ] - }, - { - "name": "LoadFileTextCallback", - "description": "FileIO: Load text data", - "returnType": "char *", - "params": [ - { - "type": "const char *", - "name": "fileName" - } - ] - }, - { - "name": "SaveFileTextCallback", - "description": "FileIO: Save text data", - "returnType": "bool", - "params": [ - { - "type": "const char *", - "name": "fileName" - }, - { - "type": "char *", - "name": "text" - } - ] - }, - { - "name": "AudioCallback", - "description": "", - "returnType": "void", - "params": [ - { - "type": "void *", - "name": "bufferData" - }, - { - "type": "unsigned int", - "name": "frames" - } - ] - } ] } diff --git a/parser/raylib_api.lua b/parser/raylib_api.lua index 8888fadef..2cbd388ff 100644 --- a/parser/raylib_api.lua +++ b/parser/raylib_api.lua @@ -1,4 +1,318 @@ return { + defines = { + { + name = "RAYLIB_H", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RAYLIB_VERSION", + type = "STRING", + value = "4.1-dev", + description = "" + }, + { + name = "RLAPI", + type = "UNKNOWN", + value = "__declspec(dllexport)", + description = "We are building the library as a Win32 shared library (.dll)" + }, + { + name = "PI", + type = "FLOAT", + value = 3.14159265358979323846, + description = "" + }, + { + name = "DEG2RAD", + type = "UNKNOWN", + value = "(PI/180.0f)", + description = "" + }, + { + name = "RAD2DEG", + type = "UNKNOWN", + value = "(180.0f/PI)", + description = "" + }, + { + name = "RL_MALLOC(sz)", + type = "MACRO", + value = "malloc(sz)", + description = "" + }, + { + name = "RL_CALLOC(n,sz)", + type = "MACRO", + value = "calloc(n,sz)", + description = "" + }, + { + name = "RL_REALLOC(ptr,sz)", + type = "MACRO", + value = "realloc(ptr,sz)", + description = "" + }, + { + name = "RL_FREE(ptr)", + type = "MACRO", + value = "free(ptr)", + description = "" + }, + { + name = "CLITERAL(type)", + type = "MACRO", + value = "type", + description = "" + }, + { + name = "RL_COLOR_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_RECTANGLE_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_VECTOR2_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_VECTOR3_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_VECTOR4_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_QUATERNION_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_MATRIX_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "LIGHTGRAY", + type = "COLOR", + value = "CLITERAL(Color){ 200, 200, 200, 255 }", + description = "Light Gray" + }, + { + name = "GRAY", + type = "COLOR", + value = "CLITERAL(Color){ 130, 130, 130, 255 }", + description = "Gray" + }, + { + name = "DARKGRAY", + type = "COLOR", + value = "CLITERAL(Color){ 80, 80, 80, 255 }", + description = "Dark Gray" + }, + { + name = "YELLOW", + type = "COLOR", + value = "CLITERAL(Color){ 253, 249, 0, 255 }", + description = "Yellow" + }, + { + name = "GOLD", + type = "COLOR", + value = "CLITERAL(Color){ 255, 203, 0, 255 }", + description = "Gold" + }, + { + name = "ORANGE", + type = "COLOR", + value = "CLITERAL(Color){ 255, 161, 0, 255 }", + description = "Orange" + }, + { + name = "PINK", + type = "COLOR", + value = "CLITERAL(Color){ 255, 109, 194, 255 }", + description = "Pink" + }, + { + name = "RED", + type = "COLOR", + value = "CLITERAL(Color){ 230, 41, 55, 255 }", + description = "Red" + }, + { + name = "MAROON", + type = "COLOR", + value = "CLITERAL(Color){ 190, 33, 55, 255 }", + description = "Maroon" + }, + { + name = "GREEN", + type = "COLOR", + value = "CLITERAL(Color){ 0, 228, 48, 255 }", + description = "Green" + }, + { + name = "LIME", + type = "COLOR", + value = "CLITERAL(Color){ 0, 158, 47, 255 }", + description = "Lime" + }, + { + name = "DARKGREEN", + type = "COLOR", + value = "CLITERAL(Color){ 0, 117, 44, 255 }", + description = "Dark Green" + }, + { + name = "SKYBLUE", + type = "COLOR", + value = "CLITERAL(Color){ 102, 191, 255, 255 }", + description = "Sky Blue" + }, + { + name = "BLUE", + type = "COLOR", + value = "CLITERAL(Color){ 0, 121, 241, 255 }", + description = "Blue" + }, + { + name = "DARKBLUE", + type = "COLOR", + value = "CLITERAL(Color){ 0, 82, 172, 255 }", + description = "Dark Blue" + }, + { + name = "PURPLE", + type = "COLOR", + value = "CLITERAL(Color){ 200, 122, 255, 255 }", + description = "Purple" + }, + { + name = "VIOLET", + type = "COLOR", + value = "CLITERAL(Color){ 135, 60, 190, 255 }", + description = "Violet" + }, + { + name = "DARKPURPLE", + type = "COLOR", + value = "CLITERAL(Color){ 112, 31, 126, 255 }", + description = "Dark Purple" + }, + { + name = "BEIGE", + type = "COLOR", + value = "CLITERAL(Color){ 211, 176, 131, 255 }", + description = "Beige" + }, + { + name = "BROWN", + type = "COLOR", + value = "CLITERAL(Color){ 127, 106, 79, 255 }", + description = "Brown" + }, + { + name = "DARKBROWN", + type = "COLOR", + value = "CLITERAL(Color){ 76, 63, 47, 255 }", + description = "Dark Brown" + }, + { + name = "WHITE", + type = "COLOR", + value = "CLITERAL(Color){ 255, 255, 255, 255 }", + description = "White" + }, + { + name = "BLACK", + type = "COLOR", + value = "CLITERAL(Color){ 0, 0, 0, 255 }", + description = "Black" + }, + { + name = "BLANK", + type = "COLOR", + value = "CLITERAL(Color){ 0, 0, 0, 0 }", + description = "Blank (Transparent)" + }, + { + name = "MAGENTA", + type = "COLOR", + value = "CLITERAL(Color){ 255, 0, 255, 255 }", + description = "Magenta" + }, + { + name = "RAYWHITE", + type = "COLOR", + value = "CLITERAL(Color){ 245, 245, 245, 255 }", + description = "My own White (raylib logo)" + }, + { + name = "RL_BOOL_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "MOUSE_LEFT_BUTTON", + type = "UNKNOWN", + value = "MOUSE_BUTTON_LEFT", + description = "" + }, + { + name = "MOUSE_RIGHT_BUTTON", + type = "UNKNOWN", + value = "MOUSE_BUTTON_RIGHT", + description = "" + }, + { + name = "MOUSE_MIDDLE_BUTTON", + type = "UNKNOWN", + value = "MOUSE_BUTTON_MIDDLE", + description = "" + }, + { + name = "MATERIAL_MAP_DIFFUSE", + type = "UNKNOWN", + value = "MATERIAL_MAP_ALBEDO", + description = "" + }, + { + name = "MATERIAL_MAP_SPECULAR", + type = "UNKNOWN", + value = "MATERIAL_MAP_METALNESS", + description = "" + }, + { + name = "SHADER_LOC_MAP_DIFFUSE", + type = "UNKNOWN", + value = "SHADER_LOC_MAP_ALBEDO", + description = "" + }, + { + name = "SHADER_LOC_MAP_SPECULAR", + type = "UNKNOWN", + value = "SHADER_LOC_MAP_METALNESS", + description = "" + } + }, structs = { { name = "Vector2", @@ -2582,318 +2896,61 @@ return { } } }, - defines = { + callbacks = { { - name = "RAYLIB_H", - type = "GUARD", - value = "", - description = "" + name = "TraceLogCallback", + description = "Logging: Redirect trace log messages", + returnType = "void", + params = { + {type = "int", name = "logLevel"}, + {type = "const char *", name = "text"}, + {type = "va_list", name = "args"} + } }, { - name = "RAYLIB_VERSION", - type = "STRING", - value = "4.1-dev", - description = "" + name = "LoadFileDataCallback", + description = "FileIO: Load binary data", + returnType = "unsigned char *", + params = { + {type = "const char *", name = "fileName"}, + {type = "unsigned int *", name = "bytesRead"} + } }, { - name = "RLAPI", - type = "UNKNOWN", - value = "__declspec(dllexport)", - description = "We are building the library as a Win32 shared library (.dll)" + name = "SaveFileDataCallback", + description = "FileIO: Save binary data", + returnType = "bool", + params = { + {type = "const char *", name = "fileName"}, + {type = "void *", name = "data"}, + {type = "unsigned int", name = "bytesToWrite"} + } }, { - name = "PI", - type = "FLOAT", - value = 3.14159265358979323846, - description = "" + name = "LoadFileTextCallback", + description = "FileIO: Load text data", + returnType = "char *", + params = { + {type = "const char *", name = "fileName"} + } }, { - name = "DEG2RAD", - type = "UNKNOWN", - value = "(PI/180.0f)", - description = "" + name = "SaveFileTextCallback", + description = "FileIO: Save text data", + returnType = "bool", + params = { + {type = "const char *", name = "fileName"}, + {type = "char *", name = "text"} + } }, { - name = "RAD2DEG", - type = "UNKNOWN", - value = "(180.0f/PI)", - description = "" - }, - { - name = "RL_MALLOC(sz)", - type = "MACRO", - value = "malloc(sz)", - description = "" - }, - { - name = "RL_CALLOC(n,sz)", - type = "MACRO", - value = "calloc(n,sz)", - description = "" - }, - { - name = "RL_REALLOC(ptr,sz)", - type = "MACRO", - value = "realloc(ptr,sz)", - description = "" - }, - { - name = "RL_FREE(ptr)", - type = "MACRO", - value = "free(ptr)", - description = "" - }, - { - name = "CLITERAL(type)", - type = "MACRO", - value = "type", - description = "" - }, - { - name = "RL_COLOR_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_RECTANGLE_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_VECTOR2_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_VECTOR3_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_VECTOR4_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_QUATERNION_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_MATRIX_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "LIGHTGRAY", - type = "COLOR", - value = "CLITERAL(Color){ 200, 200, 200, 255 }", - description = "Light Gray" - }, - { - name = "GRAY", - type = "COLOR", - value = "CLITERAL(Color){ 130, 130, 130, 255 }", - description = "Gray" - }, - { - name = "DARKGRAY", - type = "COLOR", - value = "CLITERAL(Color){ 80, 80, 80, 255 }", - description = "Dark Gray" - }, - { - name = "YELLOW", - type = "COLOR", - value = "CLITERAL(Color){ 253, 249, 0, 255 }", - description = "Yellow" - }, - { - name = "GOLD", - type = "COLOR", - value = "CLITERAL(Color){ 255, 203, 0, 255 }", - description = "Gold" - }, - { - name = "ORANGE", - type = "COLOR", - value = "CLITERAL(Color){ 255, 161, 0, 255 }", - description = "Orange" - }, - { - name = "PINK", - type = "COLOR", - value = "CLITERAL(Color){ 255, 109, 194, 255 }", - description = "Pink" - }, - { - name = "RED", - type = "COLOR", - value = "CLITERAL(Color){ 230, 41, 55, 255 }", - description = "Red" - }, - { - name = "MAROON", - type = "COLOR", - value = "CLITERAL(Color){ 190, 33, 55, 255 }", - description = "Maroon" - }, - { - name = "GREEN", - type = "COLOR", - value = "CLITERAL(Color){ 0, 228, 48, 255 }", - description = "Green" - }, - { - name = "LIME", - type = "COLOR", - value = "CLITERAL(Color){ 0, 158, 47, 255 }", - description = "Lime" - }, - { - name = "DARKGREEN", - type = "COLOR", - value = "CLITERAL(Color){ 0, 117, 44, 255 }", - description = "Dark Green" - }, - { - name = "SKYBLUE", - type = "COLOR", - value = "CLITERAL(Color){ 102, 191, 255, 255 }", - description = "Sky Blue" - }, - { - name = "BLUE", - type = "COLOR", - value = "CLITERAL(Color){ 0, 121, 241, 255 }", - description = "Blue" - }, - { - name = "DARKBLUE", - type = "COLOR", - value = "CLITERAL(Color){ 0, 82, 172, 255 }", - description = "Dark Blue" - }, - { - name = "PURPLE", - type = "COLOR", - value = "CLITERAL(Color){ 200, 122, 255, 255 }", - description = "Purple" - }, - { - name = "VIOLET", - type = "COLOR", - value = "CLITERAL(Color){ 135, 60, 190, 255 }", - description = "Violet" - }, - { - name = "DARKPURPLE", - type = "COLOR", - value = "CLITERAL(Color){ 112, 31, 126, 255 }", - description = "Dark Purple" - }, - { - name = "BEIGE", - type = "COLOR", - value = "CLITERAL(Color){ 211, 176, 131, 255 }", - description = "Beige" - }, - { - name = "BROWN", - type = "COLOR", - value = "CLITERAL(Color){ 127, 106, 79, 255 }", - description = "Brown" - }, - { - name = "DARKBROWN", - type = "COLOR", - value = "CLITERAL(Color){ 76, 63, 47, 255 }", - description = "Dark Brown" - }, - { - name = "WHITE", - type = "COLOR", - value = "CLITERAL(Color){ 255, 255, 255, 255 }", - description = "White" - }, - { - name = "BLACK", - type = "COLOR", - value = "CLITERAL(Color){ 0, 0, 0, 255 }", - description = "Black" - }, - { - name = "BLANK", - type = "COLOR", - value = "CLITERAL(Color){ 0, 0, 0, 0 }", - description = "Blank (Transparent)" - }, - { - name = "MAGENTA", - type = "COLOR", - value = "CLITERAL(Color){ 255, 0, 255, 255 }", - description = "Magenta" - }, - { - name = "RAYWHITE", - type = "COLOR", - value = "CLITERAL(Color){ 245, 245, 245, 255 }", - description = "My own White (raylib logo)" - }, - { - name = "RL_BOOL_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "MOUSE_LEFT_BUTTON", - type = "UNKNOWN", - value = "MOUSE_BUTTON_LEFT", - description = "" - }, - { - name = "MOUSE_RIGHT_BUTTON", - type = "UNKNOWN", - value = "MOUSE_BUTTON_RIGHT", - description = "" - }, - { - name = "MOUSE_MIDDLE_BUTTON", - type = "UNKNOWN", - value = "MOUSE_BUTTON_MIDDLE", - description = "" - }, - { - name = "MATERIAL_MAP_DIFFUSE", - type = "UNKNOWN", - value = "MATERIAL_MAP_ALBEDO", - description = "" - }, - { - name = "MATERIAL_MAP_SPECULAR", - type = "UNKNOWN", - value = "MATERIAL_MAP_METALNESS", - description = "" - }, - { - name = "SHADER_LOC_MAP_DIFFUSE", - type = "UNKNOWN", - value = "SHADER_LOC_MAP_ALBEDO", - description = "" - }, - { - name = "SHADER_LOC_MAP_SPECULAR", - type = "UNKNOWN", - value = "SHADER_LOC_MAP_METALNESS", - description = "" + name = "AudioCallback", + description = "", + returnType = "void", + params = { + {type = "void *", name = "bufferData"}, + {type = "unsigned int", name = "frames"} + } } }, functions = { @@ -7322,62 +7379,5 @@ return { {type = "AudioCallback", name = "processor"} } } - }, - callbacks = { - { - name = "TraceLogCallback", - description = "Logging: Redirect trace log messages", - returnType = "void", - params = { - {type = "int", name = "logLevel"}, - {type = "const char *", name = "text"}, - {type = "va_list", name = "args"} - } - }, - { - name = "LoadFileDataCallback", - description = "FileIO: Load binary data", - returnType = "unsigned char *", - params = { - {type = "const char *", name = "fileName"}, - {type = "unsigned int *", name = "bytesRead"} - } - }, - { - name = "SaveFileDataCallback", - description = "FileIO: Save binary data", - returnType = "bool", - params = { - {type = "const char *", name = "fileName"}, - {type = "void *", name = "data"}, - {type = "unsigned int", name = "bytesToWrite"} - } - }, - { - name = "LoadFileTextCallback", - description = "FileIO: Load text data", - returnType = "char *", - params = { - {type = "const char *", name = "fileName"} - } - }, - { - name = "SaveFileTextCallback", - description = "FileIO: Save text data", - returnType = "bool", - params = { - {type = "const char *", name = "fileName"}, - {type = "char *", name = "text"} - } - }, - { - name = "AudioCallback", - description = "", - returnType = "void", - params = { - {type = "void *", name = "bufferData"}, - {type = "unsigned int", name = "frames"} - } - } } } diff --git a/parser/raylib_api.txt b/parser/raylib_api.txt index 972b4d65a..10b9727ca 100644 --- a/parser/raylib_api.txt +++ b/parser/raylib_api.txt @@ -1,4 +1,267 @@ +Defines found: 52 + +Define 001: RAYLIB_H + Name: RAYLIB_H + Type: GUARD + Value: + Description: +Define 002: RAYLIB_VERSION + Name: RAYLIB_VERSION + Type: STRING + Value: "4.1-dev" + Description: +Define 003: RLAPI + Name: RLAPI + Type: UNKNOWN + Value: __declspec(dllexport) + Description: We are building the library as a Win32 shared library (.dll) +Define 004: PI + Name: PI + Type: FLOAT + Value: 3.14159265358979323846 + Description: +Define 005: DEG2RAD + Name: DEG2RAD + Type: UNKNOWN + Value: (PI/180.0f) + Description: +Define 006: RAD2DEG + Name: RAD2DEG + Type: UNKNOWN + Value: (180.0f/PI) + Description: +Define 007: RL_MALLOC(sz) + Name: RL_MALLOC(sz) + Type: MACRO + Value: malloc(sz) + Description: +Define 008: RL_CALLOC(n,sz) + Name: RL_CALLOC(n,sz) + Type: MACRO + Value: calloc(n,sz) + Description: +Define 009: RL_REALLOC(ptr,sz) + Name: RL_REALLOC(ptr,sz) + Type: MACRO + Value: realloc(ptr,sz) + Description: +Define 010: RL_FREE(ptr) + Name: RL_FREE(ptr) + Type: MACRO + Value: free(ptr) + Description: +Define 011: CLITERAL(type) + Name: CLITERAL(type) + Type: MACRO + Value: type + Description: +Define 012: RL_COLOR_TYPE + Name: RL_COLOR_TYPE + Type: GUARD + Value: + Description: +Define 013: RL_RECTANGLE_TYPE + Name: RL_RECTANGLE_TYPE + Type: GUARD + Value: + Description: +Define 014: RL_VECTOR2_TYPE + Name: RL_VECTOR2_TYPE + Type: GUARD + Value: + Description: +Define 015: RL_VECTOR3_TYPE + Name: RL_VECTOR3_TYPE + Type: GUARD + Value: + Description: +Define 016: RL_VECTOR4_TYPE + Name: RL_VECTOR4_TYPE + Type: GUARD + Value: + Description: +Define 017: RL_QUATERNION_TYPE + Name: RL_QUATERNION_TYPE + Type: GUARD + Value: + Description: +Define 018: RL_MATRIX_TYPE + Name: RL_MATRIX_TYPE + Type: GUARD + Value: + Description: +Define 019: LIGHTGRAY + Name: LIGHTGRAY + Type: COLOR + Value: CLITERAL(Color){ 200, 200, 200, 255 } + Description: Light Gray +Define 020: GRAY + Name: GRAY + Type: COLOR + Value: CLITERAL(Color){ 130, 130, 130, 255 } + Description: Gray +Define 021: DARKGRAY + Name: DARKGRAY + Type: COLOR + Value: CLITERAL(Color){ 80, 80, 80, 255 } + Description: Dark Gray +Define 022: YELLOW + Name: YELLOW + Type: COLOR + Value: CLITERAL(Color){ 253, 249, 0, 255 } + Description: Yellow +Define 023: GOLD + Name: GOLD + Type: COLOR + Value: CLITERAL(Color){ 255, 203, 0, 255 } + Description: Gold +Define 024: ORANGE + Name: ORANGE + Type: COLOR + Value: CLITERAL(Color){ 255, 161, 0, 255 } + Description: Orange +Define 025: PINK + Name: PINK + Type: COLOR + Value: CLITERAL(Color){ 255, 109, 194, 255 } + Description: Pink +Define 026: RED + Name: RED + Type: COLOR + Value: CLITERAL(Color){ 230, 41, 55, 255 } + Description: Red +Define 027: MAROON + Name: MAROON + Type: COLOR + Value: CLITERAL(Color){ 190, 33, 55, 255 } + Description: Maroon +Define 028: GREEN + Name: GREEN + Type: COLOR + Value: CLITERAL(Color){ 0, 228, 48, 255 } + Description: Green +Define 029: LIME + Name: LIME + Type: COLOR + Value: CLITERAL(Color){ 0, 158, 47, 255 } + Description: Lime +Define 030: DARKGREEN + Name: DARKGREEN + Type: COLOR + Value: CLITERAL(Color){ 0, 117, 44, 255 } + Description: Dark Green +Define 031: SKYBLUE + Name: SKYBLUE + Type: COLOR + Value: CLITERAL(Color){ 102, 191, 255, 255 } + Description: Sky Blue +Define 032: BLUE + Name: BLUE + Type: COLOR + Value: CLITERAL(Color){ 0, 121, 241, 255 } + Description: Blue +Define 033: DARKBLUE + Name: DARKBLUE + Type: COLOR + Value: CLITERAL(Color){ 0, 82, 172, 255 } + Description: Dark Blue +Define 034: PURPLE + Name: PURPLE + Type: COLOR + Value: CLITERAL(Color){ 200, 122, 255, 255 } + Description: Purple +Define 035: VIOLET + Name: VIOLET + Type: COLOR + Value: CLITERAL(Color){ 135, 60, 190, 255 } + Description: Violet +Define 036: DARKPURPLE + Name: DARKPURPLE + Type: COLOR + Value: CLITERAL(Color){ 112, 31, 126, 255 } + Description: Dark Purple +Define 037: BEIGE + Name: BEIGE + Type: COLOR + Value: CLITERAL(Color){ 211, 176, 131, 255 } + Description: Beige +Define 038: BROWN + Name: BROWN + Type: COLOR + Value: CLITERAL(Color){ 127, 106, 79, 255 } + Description: Brown +Define 039: DARKBROWN + Name: DARKBROWN + Type: COLOR + Value: CLITERAL(Color){ 76, 63, 47, 255 } + Description: Dark Brown +Define 040: WHITE + Name: WHITE + Type: COLOR + Value: CLITERAL(Color){ 255, 255, 255, 255 } + Description: White +Define 041: BLACK + Name: BLACK + Type: COLOR + Value: CLITERAL(Color){ 0, 0, 0, 255 } + Description: Black +Define 042: BLANK + Name: BLANK + Type: COLOR + Value: CLITERAL(Color){ 0, 0, 0, 0 } + Description: Blank (Transparent) +Define 043: MAGENTA + Name: MAGENTA + Type: COLOR + Value: CLITERAL(Color){ 255, 0, 255, 255 } + Description: Magenta +Define 044: RAYWHITE + Name: RAYWHITE + Type: COLOR + Value: CLITERAL(Color){ 245, 245, 245, 255 } + Description: My own White (raylib logo) +Define 045: RL_BOOL_TYPE + Name: RL_BOOL_TYPE + Type: GUARD + Value: + Description: +Define 046: MOUSE_LEFT_BUTTON + Name: MOUSE_LEFT_BUTTON + Type: UNKNOWN + Value: MOUSE_BUTTON_LEFT + Description: +Define 047: MOUSE_RIGHT_BUTTON + Name: MOUSE_RIGHT_BUTTON + Type: UNKNOWN + Value: MOUSE_BUTTON_RIGHT + Description: +Define 048: MOUSE_MIDDLE_BUTTON + Name: MOUSE_MIDDLE_BUTTON + Type: UNKNOWN + Value: MOUSE_BUTTON_MIDDLE + Description: +Define 049: MATERIAL_MAP_DIFFUSE + Name: MATERIAL_MAP_DIFFUSE + Type: UNKNOWN + Value: MATERIAL_MAP_ALBEDO + Description: +Define 050: MATERIAL_MAP_SPECULAR + Name: MATERIAL_MAP_SPECULAR + Type: UNKNOWN + Value: MATERIAL_MAP_METALNESS + Description: +Define 051: SHADER_LOC_MAP_DIFFUSE + Name: SHADER_LOC_MAP_DIFFUSE + Type: UNKNOWN + Value: SHADER_LOC_MAP_ALBEDO + Description: +Define 052: SHADER_LOC_MAP_SPECULAR + Name: SHADER_LOC_MAP_SPECULAR + Type: UNKNOWN + Value: SHADER_LOC_MAP_METALNESS + Description: + Structures found: 31 Struct 01: Vector2 (2 fields) @@ -632,6 +895,46 @@ Enum 21: NPatchLayout (3 values) Value[NPATCH_THREE_PATCH_VERTICAL]: 1 Value[NPATCH_THREE_PATCH_HORIZONTAL]: 2 +Callbacks found: 6 + +Callback 001: TraceLogCallback() (3 input parameters) + Name: TraceLogCallback + Return type: void + Description: Logging: Redirect trace log messages + Param[1]: logLevel (type: int) + Param[2]: text (type: const char *) + Param[3]: args (type: va_list) +Callback 002: LoadFileDataCallback() (2 input parameters) + Name: LoadFileDataCallback + Return type: unsigned char * + Description: FileIO: Load binary data + Param[1]: fileName (type: const char *) + Param[2]: bytesRead (type: unsigned int *) +Callback 003: SaveFileDataCallback() (3 input parameters) + Name: SaveFileDataCallback + Return type: bool + Description: FileIO: Save binary data + Param[1]: fileName (type: const char *) + Param[2]: data (type: void *) + Param[3]: bytesToWrite (type: unsigned int) +Callback 004: LoadFileTextCallback() (1 input parameters) + Name: LoadFileTextCallback + Return type: char * + Description: FileIO: Load text data + Param[1]: fileName (type: const char *) +Callback 005: SaveFileTextCallback() (2 input parameters) + Name: SaveFileTextCallback + Return type: bool + Description: FileIO: Save text data + Param[1]: fileName (type: const char *) + Param[2]: text (type: char *) +Callback 006: AudioCallback() (2 input parameters) + Name: AudioCallback + Return type: void + Description: + Param[1]: bufferData (type: void *) + Param[2]: frames (type: unsigned int) + Functions found: 499 Function 001: InitWindow() (3 input parameters) @@ -3781,306 +4084,3 @@ Function 499: DetachAudioStreamProcessor() (2 input parameters) Description: Param[1]: stream (type: AudioStream) Param[2]: processor (type: AudioCallback) - -Callbacks found: 6 - -Callback 001: TraceLogCallback() (3 input parameters) - Name: TraceLogCallback - Return type: void - Description: Logging: Redirect trace log messages - Param[1]: logLevel (type: int) - Param[2]: text (type: const char *) - Param[3]: args (type: va_list) -Callback 002: LoadFileDataCallback() (2 input parameters) - Name: LoadFileDataCallback - Return type: unsigned char * - Description: FileIO: Load binary data - Param[1]: fileName (type: const char *) - Param[2]: bytesRead (type: unsigned int *) -Callback 003: SaveFileDataCallback() (3 input parameters) - Name: SaveFileDataCallback - Return type: bool - Description: FileIO: Save binary data - Param[1]: fileName (type: const char *) - Param[2]: data (type: void *) - Param[3]: bytesToWrite (type: unsigned int) -Callback 004: LoadFileTextCallback() (1 input parameters) - Name: LoadFileTextCallback - Return type: char * - Description: FileIO: Load text data - Param[1]: fileName (type: const char *) -Callback 005: SaveFileTextCallback() (2 input parameters) - Name: SaveFileTextCallback - Return type: bool - Description: FileIO: Save text data - Param[1]: fileName (type: const char *) - Param[2]: text (type: char *) -Callback 006: AudioCallback() (2 input parameters) - Name: AudioCallback - Return type: void - Description: - Param[1]: bufferData (type: void *) - Param[2]: frames (type: unsigned int) - -Defines found: 52 - -Define 001: RAYLIB_H - Name: RAYLIB_H - Type: GUARD - Value: - Description: -Define 002: RAYLIB_VERSION - Name: RAYLIB_VERSION - Type: STRING - Value: "4.1-dev" - Description: -Define 003: RLAPI - Name: RLAPI - Type: UNKNOWN - Value: __declspec(dllexport) - Description: We are building the library as a Win32 shared library (.dll) -Define 004: PI - Name: PI - Type: FLOAT - Value: 3.14159265358979323846 - Description: -Define 005: DEG2RAD - Name: DEG2RAD - Type: UNKNOWN - Value: (PI/180.0f) - Description: -Define 006: RAD2DEG - Name: RAD2DEG - Type: UNKNOWN - Value: (180.0f/PI) - Description: -Define 007: RL_MALLOC(sz) - Name: RL_MALLOC(sz) - Type: MACRO - Value: malloc(sz) - Description: -Define 008: RL_CALLOC(n,sz) - Name: RL_CALLOC(n,sz) - Type: MACRO - Value: calloc(n,sz) - Description: -Define 009: RL_REALLOC(ptr,sz) - Name: RL_REALLOC(ptr,sz) - Type: MACRO - Value: realloc(ptr,sz) - Description: -Define 010: RL_FREE(ptr) - Name: RL_FREE(ptr) - Type: MACRO - Value: free(ptr) - Description: -Define 011: CLITERAL(type) - Name: CLITERAL(type) - Type: MACRO - Value: type - Description: -Define 012: RL_COLOR_TYPE - Name: RL_COLOR_TYPE - Type: GUARD - Value: - Description: -Define 013: RL_RECTANGLE_TYPE - Name: RL_RECTANGLE_TYPE - Type: GUARD - Value: - Description: -Define 014: RL_VECTOR2_TYPE - Name: RL_VECTOR2_TYPE - Type: GUARD - Value: - Description: -Define 015: RL_VECTOR3_TYPE - Name: RL_VECTOR3_TYPE - Type: GUARD - Value: - Description: -Define 016: RL_VECTOR4_TYPE - Name: RL_VECTOR4_TYPE - Type: GUARD - Value: - Description: -Define 017: RL_QUATERNION_TYPE - Name: RL_QUATERNION_TYPE - Type: GUARD - Value: - Description: -Define 018: RL_MATRIX_TYPE - Name: RL_MATRIX_TYPE - Type: GUARD - Value: - Description: -Define 019: LIGHTGRAY - Name: LIGHTGRAY - Type: COLOR - Value: CLITERAL(Color){ 200, 200, 200, 255 } - Description: Light Gray -Define 020: GRAY - Name: GRAY - Type: COLOR - Value: CLITERAL(Color){ 130, 130, 130, 255 } - Description: Gray -Define 021: DARKGRAY - Name: DARKGRAY - Type: COLOR - Value: CLITERAL(Color){ 80, 80, 80, 255 } - Description: Dark Gray -Define 022: YELLOW - Name: YELLOW - Type: COLOR - Value: CLITERAL(Color){ 253, 249, 0, 255 } - Description: Yellow -Define 023: GOLD - Name: GOLD - Type: COLOR - Value: CLITERAL(Color){ 255, 203, 0, 255 } - Description: Gold -Define 024: ORANGE - Name: ORANGE - Type: COLOR - Value: CLITERAL(Color){ 255, 161, 0, 255 } - Description: Orange -Define 025: PINK - Name: PINK - Type: COLOR - Value: CLITERAL(Color){ 255, 109, 194, 255 } - Description: Pink -Define 026: RED - Name: RED - Type: COLOR - Value: CLITERAL(Color){ 230, 41, 55, 255 } - Description: Red -Define 027: MAROON - Name: MAROON - Type: COLOR - Value: CLITERAL(Color){ 190, 33, 55, 255 } - Description: Maroon -Define 028: GREEN - Name: GREEN - Type: COLOR - Value: CLITERAL(Color){ 0, 228, 48, 255 } - Description: Green -Define 029: LIME - Name: LIME - Type: COLOR - Value: CLITERAL(Color){ 0, 158, 47, 255 } - Description: Lime -Define 030: DARKGREEN - Name: DARKGREEN - Type: COLOR - Value: CLITERAL(Color){ 0, 117, 44, 255 } - Description: Dark Green -Define 031: SKYBLUE - Name: SKYBLUE - Type: COLOR - Value: CLITERAL(Color){ 102, 191, 255, 255 } - Description: Sky Blue -Define 032: BLUE - Name: BLUE - Type: COLOR - Value: CLITERAL(Color){ 0, 121, 241, 255 } - Description: Blue -Define 033: DARKBLUE - Name: DARKBLUE - Type: COLOR - Value: CLITERAL(Color){ 0, 82, 172, 255 } - Description: Dark Blue -Define 034: PURPLE - Name: PURPLE - Type: COLOR - Value: CLITERAL(Color){ 200, 122, 255, 255 } - Description: Purple -Define 035: VIOLET - Name: VIOLET - Type: COLOR - Value: CLITERAL(Color){ 135, 60, 190, 255 } - Description: Violet -Define 036: DARKPURPLE - Name: DARKPURPLE - Type: COLOR - Value: CLITERAL(Color){ 112, 31, 126, 255 } - Description: Dark Purple -Define 037: BEIGE - Name: BEIGE - Type: COLOR - Value: CLITERAL(Color){ 211, 176, 131, 255 } - Description: Beige -Define 038: BROWN - Name: BROWN - Type: COLOR - Value: CLITERAL(Color){ 127, 106, 79, 255 } - Description: Brown -Define 039: DARKBROWN - Name: DARKBROWN - Type: COLOR - Value: CLITERAL(Color){ 76, 63, 47, 255 } - Description: Dark Brown -Define 040: WHITE - Name: WHITE - Type: COLOR - Value: CLITERAL(Color){ 255, 255, 255, 255 } - Description: White -Define 041: BLACK - Name: BLACK - Type: COLOR - Value: CLITERAL(Color){ 0, 0, 0, 255 } - Description: Black -Define 042: BLANK - Name: BLANK - Type: COLOR - Value: CLITERAL(Color){ 0, 0, 0, 0 } - Description: Blank (Transparent) -Define 043: MAGENTA - Name: MAGENTA - Type: COLOR - Value: CLITERAL(Color){ 255, 0, 255, 255 } - Description: Magenta -Define 044: RAYWHITE - Name: RAYWHITE - Type: COLOR - Value: CLITERAL(Color){ 245, 245, 245, 255 } - Description: My own White (raylib logo) -Define 045: RL_BOOL_TYPE - Name: RL_BOOL_TYPE - Type: GUARD - Value: - Description: -Define 046: MOUSE_LEFT_BUTTON - Name: MOUSE_LEFT_BUTTON - Type: UNKNOWN - Value: MOUSE_BUTTON_LEFT - Description: -Define 047: MOUSE_RIGHT_BUTTON - Name: MOUSE_RIGHT_BUTTON - Type: UNKNOWN - Value: MOUSE_BUTTON_RIGHT - Description: -Define 048: MOUSE_MIDDLE_BUTTON - Name: MOUSE_MIDDLE_BUTTON - Type: UNKNOWN - Value: MOUSE_BUTTON_MIDDLE - Description: -Define 049: MATERIAL_MAP_DIFFUSE - Name: MATERIAL_MAP_DIFFUSE - Type: UNKNOWN - Value: MATERIAL_MAP_ALBEDO - Description: -Define 050: MATERIAL_MAP_SPECULAR - Name: MATERIAL_MAP_SPECULAR - Type: UNKNOWN - Value: MATERIAL_MAP_METALNESS - Description: -Define 051: SHADER_LOC_MAP_DIFFUSE - Name: SHADER_LOC_MAP_DIFFUSE - Type: UNKNOWN - Value: SHADER_LOC_MAP_ALBEDO - Description: -Define 052: SHADER_LOC_MAP_SPECULAR - Name: SHADER_LOC_MAP_SPECULAR - Type: UNKNOWN - Value: SHADER_LOC_MAP_METALNESS - Description: diff --git a/parser/raylib_api.xml b/parser/raylib_api.xml index db7761c52..917d26f5e 100644 --- a/parser/raylib_api.xml +++ b/parser/raylib_api.xml @@ -1,5 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -563,60 +617,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2695,31 +2722,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c index d7eee55f5..884ff7c61 100644 --- a/parser/raylib_parser.c +++ b/parser/raylib_parser.c @@ -2,14 +2,14 @@ raylib API parser - This parser scans raylib.h to get API information about structs, aliases, enums, functions and defines. + This parser scans raylib.h to get API information about defines, structs, aliases, enums, callbacks and functions. All data is divided into pieces, usually as strings. The following types are used for data: - - struct FunctionInfo + - struct DefineInfo - struct StructInfo - struct AliasInfo - struct EnumInfo - - struct DefInfo + - struct FunctionInfo CONSTRAINTS: @@ -66,33 +66,34 @@ #include // Required for: bool #include // Required for: isdigit() -#define MAX_FUNCS_TO_PARSE 512 // Maximum number of functions to parse -#define MAX_CALLBACKS_TO_PARSE 64 // Maximum number of callbacks to parse +#define MAX_DEFINES_TO_PARSE 2048 // Maximum number of defines to parse #define MAX_STRUCTS_TO_PARSE 64 // Maximum number of structures to parse #define MAX_ALIASES_TO_PARSE 64 // Maximum number of aliases to parse #define MAX_ENUMS_TO_PARSE 64 // Maximum number of enums to parse -#define MAX_DEFINES_TO_PARSE 2048 // Maximum number of defines to parse +#define MAX_CALLBACKS_TO_PARSE 64 // Maximum number of callbacks to parse +#define MAX_FUNCS_TO_PARSE 512 // Maximum number of functions to parse #define MAX_LINE_LENGTH 512 // Maximum length of one line (including comments) -#define MAX_STRUCT_LINE_LENGTH 2048 // Maximum length of one struct (multiple lines) -#define MAX_FUNCTION_PARAMETERS 12 // Maximum number of function parameters #define MAX_STRUCT_FIELDS 64 // Maximum number of struct fields #define MAX_ENUM_VALUES 512 // Maximum number of enum values +#define MAX_FUNCTION_PARAMETERS 12 // Maximum number of function parameters //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- -// Function info data -typedef struct FunctionInfo { - char name[64]; // Function name - char desc[128]; // Function description (comment at the end) - char retType[32]; // Return value type - int paramCount; // Number of function parameters - char paramType[MAX_FUNCTION_PARAMETERS][32]; // Parameters type - char paramName[MAX_FUNCTION_PARAMETERS][32]; // Parameters name - char paramDesc[MAX_FUNCTION_PARAMETERS][128]; // Parameters description -} FunctionInfo; + +// Type of parsed define +typedef enum { UNKNOWN = 0, MACRO, GUARD, INT, LONG, FLOAT, DOUBLE, CHAR, STRING, COLOR } DefineType; + +// Define info data +typedef struct DefineInfo { + char name[64]; // Define name + DefineType type; // Define type + char value[256]; // Define value + char desc[128]; // Define description + bool isHex; // Define is hex number (for types INT, LONG) +} DefineInfo; // Struct info data typedef struct StructInfo { @@ -121,17 +122,16 @@ typedef struct EnumInfo { char valueDesc[MAX_ENUM_VALUES][128]; // Value description } EnumInfo; -// Type of parsed define -typedef enum { UNKNOWN = 0, MACRO, GUARD, INT, LONG, FLOAT, DOUBLE, CHAR, STRING, COLOR } DefineType; - -// Define info data -typedef struct DefineInfo { - char name[64]; // Define name - DefineType type; // Define type - char value[256]; // Define value - char desc[128]; // Define description - bool isHex; // Define is hex number (for types INT, LONG) -} DefineInfo; +// Function info data +typedef struct FunctionInfo { + char name[64]; // Function name + char desc[128]; // Function description (comment at the end) + char retType[32]; // Return value type + int paramCount; // Number of function parameters + char paramType[MAX_FUNCTION_PARAMETERS][32]; // Parameters type + char paramName[MAX_FUNCTION_PARAMETERS][32]; // Parameters name + char paramDesc[MAX_FUNCTION_PARAMETERS][128]; // Parameters description +} FunctionInfo; // Output format for parsed data typedef enum { DEFAULT = 0, JSON, XML, LUA } OutputFormat; @@ -139,21 +139,21 @@ typedef enum { DEFAULT = 0, JSON, XML, LUA } OutputFormat; //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -static int funcCount = 0; -static int callbackCount = 0; +static int defineCount = 0; static int structCount = 0; static int aliasCount = 0; static int enumCount = 0; -static int defineCount = 0; -static FunctionInfo *funcs = NULL; -static FunctionInfo *callbacks = NULL; +static int callbackCount = 0; +static int funcCount = 0; +static DefineInfo *defines = NULL; static StructInfo *structs = NULL; static AliasInfo *aliases = NULL; static EnumInfo *enums = NULL; -static DefineInfo *defines = NULL; -static char apiDefine[32] = "RLAPI\0"; +static FunctionInfo *callbacks = NULL; +static FunctionInfo *funcs = NULL; // Command line variables +static char apiDefine[32] = { 0 }; // Functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc.) static char inFileName[512] = { 0 }; // Input file name (required in case of provided through CLI) static char outFileName[512] = { 0 }; // Output file name (required for file save/export) static int outputFormat = DEFAULT; @@ -168,25 +168,25 @@ static char *LoadFileText(const char *fileName, int *length); static char **GetTextLines(const char *buffer, int length, int *linesCount); static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name); static void GetDescription(const char *source, char *description); +static void MoveArraySize(char *name, char *type); // Move array size from name to type static unsigned int TextLength(const char *text); // Get text length in bytes, check for \0 character static bool IsTextEqual(const char *text1, const char *text2, unsigned int count); static void MemoryCopy(void *dest, const void *src, unsigned int count); static char *EscapeBackslashes(char *text); // Replace '\' by "\\" when exporting to JSON and XML +static const char *StrDefineType(DefineType type); // Get string of define type static void ExportParsedData(const char *fileName, int format); // Export parsed data in desired format -static const char *StrDefineType(DefineType type); // Get string of define type - -static void MoveArraySize(char *name, char *type); // Move array size from name to type - -//------------------------------------------------------------------------------------ +//---------------------------------------------------------------------------------- // Program main entry point -//------------------------------------------------------------------------------------ +//---------------------------------------------------------------------------------- int main(int argc, char* argv[]) { if (argc > 1) ProcessCommandLine(argc, argv); if (inFileName[0] == '\0') MemoryCopy(inFileName, "../src/raylib.h\0", 16); + if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15); + if (apiDefine[0] == '\0') MemoryCopy(apiDefine, "RLAPI\0", 6); int length = 0; char *buffer = LoadFileText(inFileName, &length); @@ -196,11 +196,8 @@ int main(int argc, char* argv[]) int linesCount = 0; char **lines = GetTextLines(buffer, length, &linesCount); - // Function line indices - int *funcLines = (int *)malloc(MAX_FUNCS_TO_PARSE*sizeof(int)); - - // Callbacks line indices - int *callbackLines = (int *)malloc(MAX_CALLBACKS_TO_PARSE*sizeof(int)); + // Defines line indices + int *defineLines = (int *)malloc(MAX_DEFINES_TO_PARSE*sizeof(int)); // Structs line indices int *structLines = (int *)malloc(MAX_STRUCTS_TO_PARSE*sizeof(int)); @@ -211,46 +208,27 @@ int main(int argc, char* argv[]) // Enums line indices int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int)); - // Defines line indices - int *defineLines = (int *)malloc(MAX_DEFINES_TO_PARSE*sizeof(int)); + // Callbacks line indices + int *callbackLines = (int *)malloc(MAX_CALLBACKS_TO_PARSE*sizeof(int)); + + // Function line indices + int *funcLines = (int *)malloc(MAX_FUNCS_TO_PARSE*sizeof(int)); // Prepare required lines for parsing - //-------------------------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- - // Read function lines + // Read define lines for (int i = 0; i < linesCount; i++) { - // Read function line (starting with `define`, i.e. for raylib.h "RLAPI") - if (IsTextEqual(lines[i], apiDefine, TextLength(apiDefine))) + int j = 0; + while ((lines[i][j] == ' ') || (lines[i][j] == '\t')) j++; // skip spaces and tabs in the begining + // Read define line + if (IsTextEqual(lines[i]+j, "#define ", 8)) { - funcLines[funcCount] = i; - funcCount++; - } - } - - // Read callback lines - for (int i = 0; i < linesCount; i++) - { - // Find callbacks (lines with "typedef ... (* ... )( ... );") - if (IsTextEqual(lines[i], "typedef", 7)) - { - bool hasBeginning = false; - bool hasMiddle = false; - bool hasEnd = false; - - for (int c = 0; c < MAX_LINE_LENGTH; c++) - { - if ((lines[i][c] == '(') && (lines[i][c + 1] == '*')) hasBeginning = true; - if ((lines[i][c] == ')') && (lines[i][c + 1] == '(')) hasMiddle = true; - if ((lines[i][c] == ')') && (lines[i][c + 1] == ';')) hasEnd = true; - if (hasEnd) break; - } - - if (hasBeginning && hasMiddle && hasEnd) - { - callbackLines[callbackCount] = i; - callbackCount++; - } + // Keep the line position in the array of lines, + // so, we can scan that position and following lines + defineLines[defineCount] = i; + defineCount++; } } @@ -316,27 +294,160 @@ int main(int argc, char* argv[]) } } - // Read const lines + // Read callback lines for (int i = 0; i < linesCount; i++) { - int j = 0; - while ((lines[i][j] == ' ') || (lines[i][j] == '\t')) j++; // skip spaces and tabs in the begining - // Read define line - if (IsTextEqual(lines[i]+j, "#define ", 8)) + // Find callbacks (lines with "typedef ... (* ... )( ... );") + if (IsTextEqual(lines[i], "typedef", 7)) { - // Keep the line position in the array of lines, - // so, we can scan that position and following lines - defineLines[defineCount] = i; - defineCount++; + bool hasBeginning = false; + bool hasMiddle = false; + bool hasEnd = false; + + for (int c = 0; c < MAX_LINE_LENGTH; c++) + { + if ((lines[i][c] == '(') && (lines[i][c + 1] == '*')) hasBeginning = true; + if ((lines[i][c] == ')') && (lines[i][c + 1] == '(')) hasMiddle = true; + if ((lines[i][c] == ')') && (lines[i][c + 1] == ';')) hasEnd = true; + if (hasEnd) break; + } + + if (hasBeginning && hasMiddle && hasEnd) + { + callbackLines[callbackCount] = i; + callbackCount++; + } } } - // At this point we have all raylib structs, enums, functions, defines lines data to start parsing + // Read function lines + for (int i = 0; i < linesCount; i++) + { + // Read function line (starting with `define`, i.e. for raylib.h "RLAPI") + if (IsTextEqual(lines[i], apiDefine, TextLength(apiDefine))) + { + funcLines[funcCount] = i; + funcCount++; + } + } + + // At this point we have all raylib defines, structs, aliases, enums, callbacks, functions lines data to start parsing free(buffer); // Unload text buffer // Parsing raylib data - //-------------------------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- + + // Define info data + defines = (DefineInfo *)calloc(MAX_DEFINES_TO_PARSE, sizeof(DefineInfo)); + int defineIndex = 0; + + for (int i = 0; i < defineCount; i++) + { + char *linePtr = lines[defineLines[i]]; + int j = 0; + + while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs in the begining + j += 8; // Skip "#define " + while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs after "#define " + + // Extract name + int defineNameStart = j; + int openBraces = 0; + while (linePtr[j] != '\0') + { + if (((linePtr[j] == ' ') || (linePtr[j] == '\t')) && (openBraces == 0)) break; + if (linePtr[j] == '(') openBraces++; + if (linePtr[j] == ')') openBraces--; + j++; + } + int defineNameEnd = j-1; + + // Skip duplicates + int nameLen = defineNameEnd - defineNameStart + 1; + bool isDuplicate = false; + for (int k = 0; k < defineIndex; k++) + { + if ((nameLen == TextLength(defines[k].name)) && IsTextEqual(defines[k].name, &linePtr[defineNameStart], nameLen)) + { + isDuplicate = true; + break; + } + } + if (isDuplicate) continue; + + MemoryCopy(defines[defineIndex].name, &linePtr[defineNameStart], nameLen); + + // Determine type + if (linePtr[defineNameEnd] == ')') defines[defineIndex].type = MACRO; + + while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs after name + + int defineValueStart = j; + if ((linePtr[j] == '\0') || (linePtr == "/")) defines[defineIndex].type = GUARD; + if (linePtr[j] == '"') defines[defineIndex].type = STRING; + else if (linePtr[j] == '\'') defines[defineIndex].type = CHAR; + else if (IsTextEqual(linePtr+j, "CLITERAL(Color)", 15)) defines[defineIndex].type = COLOR; + else if (isdigit(linePtr[j])) // Parsing numbers + { + bool isFloat = false, isNumber = true, isHex = false; + while ((linePtr[j] != ' ') && (linePtr[j] != '\t') && (linePtr[j] != '\0')) + { + char ch = linePtr[j]; + if (ch == '.') isFloat = true; + if (ch == 'x') isHex = true; + if (!(isdigit(ch) || + ((ch >= 'a') && (ch <= 'f')) || + ((ch >= 'A') && (ch <= 'F')) || + (ch == 'x') || + (ch == 'L') || + (ch == '.') || + (ch == '+') || + (ch == '-'))) isNumber = false; + j++; + } + if (isNumber) + { + if (isFloat) + { + defines[defineIndex].type = linePtr[j-1] == 'f' ? FLOAT : DOUBLE; + } + else + { + defines[defineIndex].type = linePtr[j-1] == 'L' ? LONG : INT; + defines[defineIndex].isHex = isHex; + } + } + } + + // Extracting value + while ((linePtr[j] != '\\') && (linePtr[j] != '\0') && !((linePtr[j] == '/') && (linePtr[j+1] == '/'))) j++; + int defineValueEnd = j-1; + while ((linePtr[defineValueEnd] == ' ') || (linePtr[defineValueEnd] == '\t')) defineValueEnd--; // Remove trailing spaces and tabs + if ((defines[defineIndex].type == LONG) || (defines[defineIndex].type == FLOAT)) defineValueEnd--; // Remove number postfix + int valueLen = defineValueEnd - defineValueStart + 1; + if (valueLen > 255) valueLen = 255; + + if (valueLen > 0) MemoryCopy(defines[defineIndex].value, &linePtr[defineValueStart], valueLen); + + // Extracting description + if ((linePtr[j] == '/') && linePtr[j + 1] == '/') + { + j += 2; + while (linePtr[j] == ' ') j++; + int commentStart = j; + while ((linePtr[j] != '\\') && (linePtr[j] != '\0')) j++; + int commentEnd = j-1; + int commentLen = commentEnd - commentStart + 1; + if (commentLen > 127) commentLen = 127; + + MemoryCopy(defines[defineIndex].desc, &linePtr[commentStart], commentLen); + } + + defineIndex++; + } + defineCount = defineIndex; + free(defineLines); // Structs info data structs = (StructInfo *)calloc(MAX_STRUCTS_TO_PARSE, sizeof(StructInfo)); @@ -476,7 +587,6 @@ int main(int argc, char* argv[]) { MemoryCopy(structs[i].fieldType[originalIndex + j], &structs[i].fieldType[originalIndex][0], fieldTypeLength); MemoryCopy(structs[i].fieldDesc[originalIndex + j], &structs[i].fieldDesc[originalIndex][0], TextLength(structs[i].fieldDesc[originalIndex])); - } } } @@ -526,62 +636,6 @@ int main(int argc, char* argv[]) } free(aliasLines); - // Callback info data - callbacks = (FunctionInfo *)calloc(MAX_CALLBACKS_TO_PARSE, sizeof(FunctionInfo)); - - for (int i = 0; i < callbackCount; i++) - { - char *linePtr = lines[callbackLines[i]]; - - // Skip "typedef " - int c = 8; - - // Return type - int retTypeStart = c; - while(linePtr[c] != '(') c++; - int retTypeLen = c - retTypeStart; - while(linePtr[retTypeStart + retTypeLen - 1] == ' ') retTypeLen--; - MemoryCopy(callbacks[i].retType, &linePtr[retTypeStart], retTypeLen); - - // Skip "(*" - c += 2; - - // Name - int nameStart = c; - while(linePtr[c] != ')') c++; - int nameLen = c - nameStart; - MemoryCopy(callbacks[i].name, &linePtr[nameStart], nameLen); - - // Skip ")(" - c += 2; - - // Params - int paramStart = c; - for (c; c < MAX_LINE_LENGTH; c++) - { - if ((linePtr[c] == ',') || (linePtr[c] == ')')) - { - // Get parameter type + name, extract info - int paramLen = c - paramStart; - GetDataTypeAndName(&linePtr[paramStart], paramLen, callbacks[i].paramType[callbacks[i].paramCount], callbacks[i].paramName[callbacks[i].paramCount]); - callbacks[i].paramCount++; - paramStart = c + 1; - while(linePtr[paramStart] == ' ') paramStart++; - } - if (linePtr[c] == ')') break; - } - - // Description - GetDescription(&linePtr[c], callbacks[i].desc); - - // Move array sizes from name to type - for (int j = 0; j < callbacks[i].paramCount; j++) - { - MoveArraySize(callbacks[i].paramName[j], callbacks[i].paramType[j]); - } - } - free(callbackLines); - // Enum info data enums = (EnumInfo *)calloc(MAX_ENUMS_TO_PARSE, sizeof(EnumInfo)); @@ -692,116 +746,61 @@ int main(int argc, char* argv[]) } free(enumLines); - // Define info data - defines = (DefineInfo *)calloc(MAX_DEFINES_TO_PARSE, sizeof(DefineInfo)); - int defineIndex = 0; + // Callback info data + callbacks = (FunctionInfo *)calloc(MAX_CALLBACKS_TO_PARSE, sizeof(FunctionInfo)); - for (int i = 0; i < defineCount; i++) + for (int i = 0; i < callbackCount; i++) { - char *linePtr = lines[defineLines[i]]; - int j = 0; + char *linePtr = lines[callbackLines[i]]; - while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs in the begining - j += 8; // Skip "#define " - while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs after "#define " + // Skip "typedef " + int c = 8; - // Extract name - int defineNameStart = j; - int openBraces = 0; - while (linePtr[j] != '\0') + // Return type + int retTypeStart = c; + while(linePtr[c] != '(') c++; + int retTypeLen = c - retTypeStart; + while(linePtr[retTypeStart + retTypeLen - 1] == ' ') retTypeLen--; + MemoryCopy(callbacks[i].retType, &linePtr[retTypeStart], retTypeLen); + + // Skip "(*" + c += 2; + + // Name + int nameStart = c; + while(linePtr[c] != ')') c++; + int nameLen = c - nameStart; + MemoryCopy(callbacks[i].name, &linePtr[nameStart], nameLen); + + // Skip ")(" + c += 2; + + // Params + int paramStart = c; + for (c; c < MAX_LINE_LENGTH; c++) { - if (((linePtr[j] == ' ') || (linePtr[j] == '\t')) && (openBraces == 0)) break; - if (linePtr[j] == '(') openBraces++; - if (linePtr[j] == ')') openBraces--; - j++; - } - int defineNameEnd = j-1; - - // Skip duplicates - int nameLen = defineNameEnd - defineNameStart + 1; - bool isDuplicate = false; - for (int k = 0; k < defineIndex; k++) - { - if ((nameLen == TextLength(defines[k].name)) && IsTextEqual(defines[k].name, &linePtr[defineNameStart], nameLen)) + if ((linePtr[c] == ',') || (linePtr[c] == ')')) { - isDuplicate = true; - break; + // Get parameter type + name, extract info + int paramLen = c - paramStart; + GetDataTypeAndName(&linePtr[paramStart], paramLen, callbacks[i].paramType[callbacks[i].paramCount], callbacks[i].paramName[callbacks[i].paramCount]); + callbacks[i].paramCount++; + paramStart = c + 1; + while(linePtr[paramStart] == ' ') paramStart++; } + if (linePtr[c] == ')') break; } - if (isDuplicate) continue; - MemoryCopy(defines[defineIndex].name, &linePtr[defineNameStart], nameLen); + // Description + GetDescription(&linePtr[c], callbacks[i].desc); - // Determine type - if (linePtr[defineNameEnd] == ')') defines[defineIndex].type = MACRO; - - while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs after name - - int defineValueStart = j; - if ((linePtr[j] == '\0') || (linePtr == "/")) defines[defineIndex].type = GUARD; - if (linePtr[j] == '"') defines[defineIndex].type = STRING; - else if (linePtr[j] == '\'') defines[defineIndex].type = CHAR; - else if (IsTextEqual(linePtr+j, "CLITERAL(Color)", 15)) defines[defineIndex].type = COLOR; - else if (isdigit(linePtr[j])) // Parsing numbers + // Move array sizes from name to type + for (int j = 0; j < callbacks[i].paramCount; j++) { - bool isFloat = false, isNumber = true, isHex = false; - while ((linePtr[j] != ' ') && (linePtr[j] != '\t') && (linePtr[j] != '\0')) - { - char ch = linePtr[j]; - if (ch == '.') isFloat = true; - if (ch == 'x') isHex = true; - if (!(isdigit(ch) || - ((ch >= 'a') && (ch <= 'f')) || - ((ch >= 'A') && (ch <= 'F')) || - (ch == 'x') || - (ch == 'L') || - (ch == '.') || - (ch == '+') || - (ch == '-'))) isNumber = false; - j++; - } - if (isNumber) - { - if (isFloat) - { - defines[defineIndex].type = linePtr[j-1] == 'f' ? FLOAT : DOUBLE; - } - else - { - defines[defineIndex].type = linePtr[j-1] == 'L' ? LONG : INT; - defines[defineIndex].isHex = isHex; - } - } + MoveArraySize(callbacks[i].paramName[j], callbacks[i].paramType[j]); } - - // Extracting value - while ((linePtr[j] != '\\') && (linePtr[j] != '\0') && !((linePtr[j] == '/') && (linePtr[j+1] == '/'))) j++; - int defineValueEnd = j-1; - while ((linePtr[defineValueEnd] == ' ') || (linePtr[defineValueEnd] == '\t')) defineValueEnd--; // Remove trailing spaces and tabs - if ((defines[defineIndex].type == LONG) || (defines[defineIndex].type == FLOAT)) defineValueEnd--; // Remove number postfix - int valueLen = defineValueEnd - defineValueStart + 1; - if (valueLen > 255) valueLen = 255; - - if (valueLen > 0) MemoryCopy(defines[defineIndex].value, &linePtr[defineValueStart], valueLen); - - // Extracting description - if ((linePtr[j] == '/') && linePtr[j + 1] == '/') - { - j += 2; - while (linePtr[j] == ' ') j++; - int commentStart = j; - while ((linePtr[j] != '\\') && (linePtr[j] != '\0')) j++; - int commentEnd = j-1; - int commentLen = commentEnd - commentStart + 1; - if (commentLen > 127) commentLen = 127; - - MemoryCopy(defines[defineIndex].desc, &linePtr[commentStart], commentLen); - } - - defineIndex++; } - defineCount = defineIndex; - free(defineLines); + free(callbackLines); // Functions info data funcs = (FunctionInfo *)calloc(MAX_FUNCS_TO_PARSE, sizeof(FunctionInfo)); @@ -881,16 +880,13 @@ int main(int argc, char* argv[]) free(lines); // At this point, all raylib data has been parsed! - //----------------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- + // defines[] -> We have all the defines decomposed into pieces for further analysis // structs[] -> We have all the structs decomposed into pieces for further analysis // aliases[] -> We have all the aliases decomposed into pieces for further analysis // enums[] -> We have all the enums decomposed into pieces for further analysis - // funcs[] -> We have all the functions decomposed into pieces for further analysis // callbacks[] -> We have all the callbacks decomposed into pieces for further analysis - // defines[] -> We have all the defines decomposed into pieces for further analysis - - // Process input file to output - if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15); + // funcs[] -> We have all the functions decomposed into pieces for further analysis printf("\nInput file: %s", inFileName); printf("\nOutput file: %s", outFileName); @@ -901,17 +897,18 @@ int main(int argc, char* argv[]) ExportParsedData(outFileName, outputFormat); - free(funcs); - free(callbacks); + free(defines); free(structs); free(aliases); free(enums); - free(defines); + free(callbacks); + free(funcs); } //---------------------------------------------------------------------------------- // Module Functions Definition //---------------------------------------------------------------------------------- + // Show command line usage info static void ShowCommandLineInfo(void) { @@ -937,7 +934,7 @@ static void ShowCommandLineInfo(void) printf(" NOTE: If not specified, defaults to: raylib_api.txt\n\n"); printf(" -f, --format : Define output format for parser data.\n"); printf(" Supported types: DEFAULT, JSON, XML, LUA\n\n"); - printf(" -d, --define : Define functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc\n"); + printf(" -d, --define : Define functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc.)\n"); printf(" NOTE: If not specified, defaults to: RLAPI\n\n"); printf("\nEXAMPLES:\n\n"); @@ -958,6 +955,7 @@ static void ProcessCommandLine(int argc, char *argv[]) { // Show info ShowCommandLineInfo(); + exit(0); } else if (IsTextEqual(argv[i], "-i", 2) || IsTextEqual(argv[i], "--input", 7)) { @@ -1131,6 +1129,24 @@ static void GetDescription(const char *line, char *description) if (descStart != -1) MemoryCopy(description, &line[descStart], c - descStart); } +// Move array size from name to type +static void MoveArraySize(char *name, char *type) +{ + int nameLength = TextLength(name); + if (name[nameLength - 1] == ']') + { + for (int k = nameLength; k > 0; k--) + { + if (name[k] == '[') + { + int sizeLength = nameLength - k; + MemoryCopy(&type[TextLength(type)], &name[k], sizeLength); + name[k] = '\0'; + } + } + } +} + // Get text length in bytes, check for \0 character static unsigned int TextLength(const char *text) { @@ -1141,15 +1157,6 @@ static unsigned int TextLength(const char *text) return length; } -// Custom memcpy() to avoid -static void MemoryCopy(void *dest, const void *src, unsigned int count) -{ - char *srcPtr = (char *)src; - char *destPtr = (char *)dest; - - for (unsigned int i = 0; i < count; i++) destPtr[i] = srcPtr[i]; -} - // Compare two text strings, requires number of characters to compare static bool IsTextEqual(const char *text1, const char *text2, unsigned int count) { @@ -1167,6 +1174,15 @@ static bool IsTextEqual(const char *text1, const char *text2, unsigned int count return result; } +// Custom memcpy() to avoid +static void MemoryCopy(void *dest, const void *src, unsigned int count) +{ + char *srcPtr = (char *)src; + char *destPtr = (char *)dest; + + for (unsigned int i = 0; i < count; i++) destPtr[i] = srcPtr[i]; +} + // Escape backslashes in a string, writing the escaped string into a static buffer static char *EscapeBackslashes(char *text) { @@ -1209,24 +1225,6 @@ static const char *StrDefineType(DefineType type) return ""; } -// Move array size from name to type -static void MoveArraySize(char *name, char *type) -{ - int nameLength = TextLength(name); - if (name[nameLength - 1] == ']') - { - for (int k = nameLength; k > 0; k--) - { - if (name[k] == '[') - { - int sizeLength = nameLength - k; - MemoryCopy(&type[TextLength(type)], &name[k], sizeLength); - name[k] = '\0'; - } - } - } -} - /* // Replace text string // REQUIRES: strlen(), strstr(), strncpy(), strcpy() -> TODO: Replace by custom implementations! @@ -1288,6 +1286,17 @@ static void ExportParsedData(const char *fileName, int format) { case DEFAULT: { + // Print defines info + fprintf(outFile, "\nDefines found: %i\n\n", defineCount); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, "Define %03i: %s\n", i + 1, defines[i].name); + fprintf(outFile, " Name: %s\n", defines[i].name); + fprintf(outFile, " Type: %s\n", StrDefineType(defines[i].type)); + fprintf(outFile, " Value: %s\n", defines[i].value); + fprintf(outFile, " Description: %s\n", defines[i].desc); + } + // Print structs info fprintf(outFile, "\nStructures found: %i\n\n", structCount); for (int i = 0; i < structCount; i++) @@ -1323,18 +1332,6 @@ static void ExportParsedData(const char *fileName, int format) for (int e = 0; e < enums[i].valueCount; e++) fprintf(outFile, " Value[%s]: %i\n", enums[i].valueName[e], enums[i].valueInteger[e]); } - // Print functions info - fprintf(outFile, "\nFunctions found: %i\n\n", funcCount); - for (int i = 0; i < funcCount; i++) - { - fprintf(outFile, "Function %03i: %s() (%i input parameters)\n", i + 1, funcs[i].name, funcs[i].paramCount); - fprintf(outFile, " Name: %s\n", funcs[i].name); - fprintf(outFile, " Return type: %s\n", funcs[i].retType); - fprintf(outFile, " Description: %s\n", funcs[i].desc); - for (int p = 0; p < funcs[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]); - if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n"); - } - // Print callbacks info fprintf(outFile, "\nCallbacks found: %i\n\n", callbackCount); for (int i = 0; i < callbackCount; i++) @@ -1347,173 +1344,52 @@ static void ExportParsedData(const char *fileName, int format) if (callbacks[i].paramCount == 0) fprintf(outFile, " No input parameters\n"); } - // Print defines info - fprintf(outFile, "\nDefines found: %i\n\n", defineCount); - for (int i = 0; i < defineCount; i++) + // Print functions info + fprintf(outFile, "\nFunctions found: %i\n\n", funcCount); + for (int i = 0; i < funcCount; i++) { - fprintf(outFile, "Define %03i: %s\n", i + 1, defines[i].name); - fprintf(outFile, " Name: %s\n", defines[i].name); - fprintf(outFile, " Type: %s\n", StrDefineType(defines[i].type)); - fprintf(outFile, " Value: %s\n", defines[i].value); - fprintf(outFile, " Description: %s\n", defines[i].desc); + fprintf(outFile, "Function %03i: %s() (%i input parameters)\n", i + 1, funcs[i].name, funcs[i].paramCount); + fprintf(outFile, " Name: %s\n", funcs[i].name); + fprintf(outFile, " Return type: %s\n", funcs[i].retType); + fprintf(outFile, " Description: %s\n", funcs[i].desc); + for (int p = 0; p < funcs[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]); + if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n"); } } break; - case LUA: + case JSON: { - fprintf(outFile, "return {\n"); - - // Print structs info - fprintf(outFile, " structs = {\n"); - for (int i = 0; i < structCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", structs[i].name); - fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(structs[i].desc)); - fprintf(outFile, " fields = {\n"); - for (int f = 0; f < structs[i].fieldCount; f++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " type = \"%s\",\n", structs[i].fieldType[f]); - fprintf(outFile, " name = \"%s\",\n", structs[i].fieldName[f]); - fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(structs[i].fieldDesc[f])); - fprintf(outFile, " }"); - if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - fprintf(outFile, " }"); - if (i < structCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " },\n"); - - // Print aliases info - fprintf(outFile, " aliases = {\n"); - for (int i = 0; i < aliasCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " type = \"%s\",\n", aliases[i].type); - fprintf(outFile, " name = \"%s\",\n", aliases[i].name); - fprintf(outFile, " description = \"%s\"\n", aliases[i].desc); - fprintf(outFile, " }"); - - if (i < aliasCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " },\n"); - - // Print enums info - fprintf(outFile, " enums = {\n"); - for (int i = 0; i < enumCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", enums[i].name); - fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(enums[i].desc)); - fprintf(outFile, " values = {\n"); - for (int e = 0; e < enums[i].valueCount; e++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", enums[i].valueName[e]); - fprintf(outFile, " value = %i,\n", enums[i].valueInteger[e]); - fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(enums[i].valueDesc[e])); - fprintf(outFile, " }"); - if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - fprintf(outFile, " }"); - if (i < enumCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " },\n"); + fprintf(outFile, "{\n"); // Print defines info - fprintf(outFile, " defines = {\n"); + fprintf(outFile, " \"defines\": [\n"); for (int i = 0; i < defineCount; i++) { fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", defines[i].name); - fprintf(outFile, " type = \"%s\",\n", StrDefineType(defines[i].type)); - if ((defines[i].type == INT) || - (defines[i].type == LONG) || - (defines[i].type == FLOAT) || - (defines[i].type == DOUBLE) || - (defines[i].type == STRING)) + fprintf(outFile, " \"name\": \"%s\",\n", defines[i].name); + fprintf(outFile, " \"type\": \"%s\",\n", StrDefineType(defines[i].type)); + if (defines[i].isHex) // INT or LONG { - fprintf(outFile, " value = %s,\n", defines[i].value); + fprintf(outFile, " \"value\": %ld,\n", strtol(defines[i].value, NULL, 16)); + } + else if ((defines[i].type == INT) || + (defines[i].type == LONG) || + (defines[i].type == FLOAT) || + (defines[i].type == DOUBLE) || + (defines[i].type == STRING)) + { + fprintf(outFile, " \"value\": %s,\n", defines[i].value); } else { - fprintf(outFile, " value = \"%s\",\n", defines[i].value); + fprintf(outFile, " \"value\": \"%s\",\n", defines[i].value); } - fprintf(outFile, " description = \"%s\"\n", defines[i].desc); + fprintf(outFile, " \"description\": \"%s\"\n", defines[i].desc); fprintf(outFile, " }"); if (i < defineCount - 1) fprintf(outFile, ",\n"); else fprintf(outFile, "\n"); } - fprintf(outFile, " },\n"); - - // Print functions info - fprintf(outFile, " functions = {\n"); - for (int i = 0; i < funcCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", funcs[i].name); - fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(funcs[i].desc)); - fprintf(outFile, " returnType = \"%s\"", funcs[i].retType); - - if (funcs[i].paramCount == 0) fprintf(outFile, "\n"); - else - { - fprintf(outFile, ",\n params = {\n"); - for (int p = 0; p < funcs[i].paramCount; p++) - { - fprintf(outFile, " {type = \"%s\", name = \"%s\"}", funcs[i].paramType[p], funcs[i].paramName[p]); - if (p < funcs[i].paramCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - } - fprintf(outFile, " }"); - - if (i < funcCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " },\n"); - - // Print callbacks info - fprintf(outFile, " callbacks = {\n"); - for (int i = 0; i < callbackCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", callbacks[i].name); - fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(callbacks[i].desc)); - fprintf(outFile, " returnType = \"%s\"", callbacks[i].retType); - - if (callbacks[i].paramCount == 0) fprintf(outFile, "\n"); - else - { - fprintf(outFile, ",\n params = {\n"); - for (int p = 0; p < callbacks[i].paramCount; p++) - { - fprintf(outFile, " {type = \"%s\", name = \"%s\"}", callbacks[i].paramType[p], callbacks[i].paramName[p]); - if (p < callbacks[i].paramCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - } - fprintf(outFile, " }"); - - if (i < callbackCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - fprintf(outFile, "}\n"); - } break; - case JSON: - { - fprintf(outFile, "{\n"); + fprintf(outFile, " ],\n"); // Print structs info fprintf(outFile, " \"structs\": [\n"); @@ -1580,33 +1456,33 @@ static void ExportParsedData(const char *fileName, int format) } fprintf(outFile, " ],\n"); - // Print defines info - fprintf(outFile, " \"defines\": [\n"); - for (int i = 0; i < defineCount; i++) + // Print callbacks info + fprintf(outFile, " \"callbacks\": [\n"); + for (int i = 0; i < callbackCount; i++) { fprintf(outFile, " {\n"); - fprintf(outFile, " \"name\": \"%s\",\n", defines[i].name); - fprintf(outFile, " \"type\": \"%s\",\n", StrDefineType(defines[i].type)); - if (defines[i].isHex) // INT or LONG - { - fprintf(outFile, " \"value\": %ld,\n", strtol(defines[i].value, NULL, 16)); - } - else if ((defines[i].type == INT) || - (defines[i].type == LONG) || - (defines[i].type == FLOAT) || - (defines[i].type == DOUBLE) || - (defines[i].type == STRING)) - { - fprintf(outFile, " \"value\": %s,\n", defines[i].value); - } + fprintf(outFile, " \"name\": \"%s\",\n", callbacks[i].name); + fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(callbacks[i].desc)); + fprintf(outFile, " \"returnType\": \"%s\"", callbacks[i].retType); + + if (callbacks[i].paramCount == 0) fprintf(outFile, "\n"); else { - fprintf(outFile, " \"value\": \"%s\",\n", defines[i].value); + fprintf(outFile, ",\n \"params\": [\n"); + for (int p = 0; p < callbacks[i].paramCount; p++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " \"type\": \"%s\",\n", callbacks[i].paramType[p]); + fprintf(outFile, " \"name\": \"%s\"\n", callbacks[i].paramName[p]); + fprintf(outFile, " }"); + if (p < callbacks[i].paramCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " ]\n"); } - fprintf(outFile, " \"description\": \"%s\"\n", defines[i].desc); fprintf(outFile, " }"); - if (i < defineCount - 1) fprintf(outFile, ",\n"); + if (i < callbackCount - 1) fprintf(outFile, ",\n"); else fprintf(outFile, "\n"); } fprintf(outFile, " ],\n"); @@ -1640,37 +1516,6 @@ static void ExportParsedData(const char *fileName, int format) if (i < funcCount - 1) fprintf(outFile, ",\n"); else fprintf(outFile, "\n"); } - fprintf(outFile, " ],\n"); - - // Print callbacks info - fprintf(outFile, " \"callbacks\": [\n"); - for (int i = 0; i < callbackCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " \"name\": \"%s\",\n", callbacks[i].name); - fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(callbacks[i].desc)); - fprintf(outFile, " \"returnType\": \"%s\"", callbacks[i].retType); - - if (callbacks[i].paramCount == 0) fprintf(outFile, "\n"); - else - { - fprintf(outFile, ",\n \"params\": [\n"); - for (int p = 0; p < callbacks[i].paramCount; p++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " \"type\": \"%s\",\n", callbacks[i].paramType[p]); - fprintf(outFile, " \"name\": \"%s\"\n", callbacks[i].paramName[p]); - fprintf(outFile, " }"); - if (p < callbacks[i].paramCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " ]\n"); - } - fprintf(outFile, " }"); - - if (i < callbackCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } fprintf(outFile, " ]\n"); fprintf(outFile, "}\n"); } break; @@ -1680,6 +1525,9 @@ static void ExportParsedData(const char *fileName, int format) /* + + + @@ -1695,27 +1543,41 @@ static void ExportParsedData(const char *fileName, int format) - - - - - - - - - + + + + + + */ fprintf(outFile, "\n"); fprintf(outFile, "\n"); + // Print defines info + fprintf(outFile, " \n", defineCount); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, " \n", defines[i].desc); + } + fprintf(outFile, " \n"); + // Print structs info fprintf(outFile, " \n", structCount); for (int i = 0; i < structCount; i++) @@ -1750,22 +1612,18 @@ static void ExportParsedData(const char *fileName, int format) } fprintf(outFile, " \n"); - // Print defines info - fprintf(outFile, " \n", defineCount); - for (int i = 0; i < defineCount; i++) + // Print callbacks info + fprintf(outFile, " \n", callbackCount); + for (int i = 0; i < callbackCount; i++) { - fprintf(outFile, " \n", callbacks[i].name, callbacks[i].retType, callbacks[i].paramCount, callbacks[i].desc); + for (int p = 0; p < callbacks[i].paramCount; p++) { - fprintf(outFile, "value=%s", defines[i].value); + fprintf(outFile, " \n", callbacks[i].paramType[p], callbacks[i].paramName[p], callbacks[i].paramDesc[p]); } - else - { - fprintf(outFile, "value=\"%s\"", defines[i].value); - } - fprintf(outFile, " desc=\"%s\" />\n", defines[i].desc); + fprintf(outFile, " \n"); } - fprintf(outFile, " \n"); + fprintf(outFile, " \n"); // Print functions info fprintf(outFile, " \n", funcCount); @@ -1780,22 +1638,162 @@ static void ExportParsedData(const char *fileName, int format) } fprintf(outFile, " \n"); - // Print callbacks info - fprintf(outFile, " \n", callbackCount); - for (int i = 0; i < callbackCount; i++) - { - fprintf(outFile, " \n", callbacks[i].name, callbacks[i].retType, callbacks[i].paramCount, callbacks[i].desc); - for (int p = 0; p < callbacks[i].paramCount; p++) - { - fprintf(outFile, " \n", callbacks[i].paramType[p], callbacks[i].paramName[p], callbacks[i].paramDesc[p]); - } - fprintf(outFile, " \n"); - } - fprintf(outFile, " \n"); - fprintf(outFile, "\n"); } break; + case LUA: + { + fprintf(outFile, "return {\n"); + + // Print defines info + fprintf(outFile, " defines = {\n"); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", defines[i].name); + fprintf(outFile, " type = \"%s\",\n", StrDefineType(defines[i].type)); + if ((defines[i].type == INT) || + (defines[i].type == LONG) || + (defines[i].type == FLOAT) || + (defines[i].type == DOUBLE) || + (defines[i].type == STRING)) + { + fprintf(outFile, " value = %s,\n", defines[i].value); + } + else + { + fprintf(outFile, " value = \"%s\",\n", defines[i].value); + } + fprintf(outFile, " description = \"%s\"\n", defines[i].desc); + fprintf(outFile, " }"); + + if (i < defineCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print structs info + fprintf(outFile, " structs = {\n"); + for (int i = 0; i < structCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", structs[i].name); + fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(structs[i].desc)); + fprintf(outFile, " fields = {\n"); + for (int f = 0; f < structs[i].fieldCount; f++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " type = \"%s\",\n", structs[i].fieldType[f]); + fprintf(outFile, " name = \"%s\",\n", structs[i].fieldName[f]); + fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(structs[i].fieldDesc[f])); + fprintf(outFile, " }"); + if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + fprintf(outFile, " }"); + if (i < structCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print aliases info + fprintf(outFile, " aliases = {\n"); + for (int i = 0; i < aliasCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " type = \"%s\",\n", aliases[i].type); + fprintf(outFile, " name = \"%s\",\n", aliases[i].name); + fprintf(outFile, " description = \"%s\"\n", aliases[i].desc); + fprintf(outFile, " }"); + + if (i < aliasCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print enums info + fprintf(outFile, " enums = {\n"); + for (int i = 0; i < enumCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", enums[i].name); + fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(enums[i].desc)); + fprintf(outFile, " values = {\n"); + for (int e = 0; e < enums[i].valueCount; e++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", enums[i].valueName[e]); + fprintf(outFile, " value = %i,\n", enums[i].valueInteger[e]); + fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(enums[i].valueDesc[e])); + fprintf(outFile, " }"); + if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + fprintf(outFile, " }"); + if (i < enumCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print callbacks info + fprintf(outFile, " callbacks = {\n"); + for (int i = 0; i < callbackCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", callbacks[i].name); + fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(callbacks[i].desc)); + fprintf(outFile, " returnType = \"%s\"", callbacks[i].retType); + + if (callbacks[i].paramCount == 0) fprintf(outFile, "\n"); + else + { + fprintf(outFile, ",\n params = {\n"); + for (int p = 0; p < callbacks[i].paramCount; p++) + { + fprintf(outFile, " {type = \"%s\", name = \"%s\"}", callbacks[i].paramType[p], callbacks[i].paramName[p]); + if (p < callbacks[i].paramCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + } + fprintf(outFile, " }"); + + if (i < callbackCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print functions info + fprintf(outFile, " functions = {\n"); + for (int i = 0; i < funcCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", funcs[i].name); + fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(funcs[i].desc)); + fprintf(outFile, " returnType = \"%s\"", funcs[i].retType); + + if (funcs[i].paramCount == 0) fprintf(outFile, "\n"); + else + { + fprintf(outFile, ",\n params = {\n"); + for (int p = 0; p < funcs[i].paramCount; p++) + { + fprintf(outFile, " {type = \"%s\", name = \"%s\"}", funcs[i].paramType[p], funcs[i].paramName[p]); + if (p < funcs[i].paramCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + } + fprintf(outFile, " }"); + + if (i < funcCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + fprintf(outFile, "}\n"); + } break; default: break; }