mirror of https://github.com/raysan5/raylib
added LUA output format for parser; added Makefile for raylib_parser; added raylib_api.lua parser result; added raylib_parser binary to gitignore (#2129)
This commit is contained in:
parent
fc268129ef
commit
802a1a1529
|
@ -101,3 +101,6 @@ zig-out/
|
||||||
build/
|
build/
|
||||||
build-*/
|
build-*/
|
||||||
docgen_tmp/
|
docgen_tmp/
|
||||||
|
|
||||||
|
# Parser stuff
|
||||||
|
parser/raylib_parser
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
EXTENSION?=txt
|
||||||
|
FORMAT?=DEFAULT
|
||||||
|
|
||||||
|
raylib_api:
|
||||||
|
cc raylib_parser.c -o raylib_parser
|
||||||
|
./raylib_parser -i ../src/raylib.h -o raylib_api.txt -f DEFAULT -d RLAPI
|
||||||
|
./raylib_parser -i ../src/raylib.h -o raylib_api.json -f JSON -d RLAPI
|
||||||
|
./raylib_parser -i ../src/raylib.h -o raylib_api.xml -f XML -d RLAPI
|
||||||
|
./raylib_parser -i ../src/raylib.h -o raylib_api.lua -f LUA -d RLAPI
|
||||||
|
|
||||||
|
all:
|
||||||
|
cc raylib_parser.c -o raylib_parser
|
||||||
|
FORMAT=DEFAULT EXTENSION=txt $(MAKE) parse
|
||||||
|
FORMAT=JSON EXTENSION=json $(MAKE) parse
|
||||||
|
FORMAT=XML EXTENSION=xml $(MAKE) parse
|
||||||
|
FORMAT=LUA EXTENSION=lua $(MAKE) parse
|
||||||
|
|
||||||
|
parse:
|
||||||
|
./raylib_parser -i ../src/raylib.h -o raylib_api.$(EXTENSION) -f $(FORMAT) -d RLAPI
|
||||||
|
./raylib_parser -i ../src/raymath.h -o raymath_api.$(EXTENSION) -f $(FORMAT) -d RMAPI
|
||||||
|
./raylib_parser -i ../src/extras/easings.h -o easings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF
|
||||||
|
./raylib_parser -i ../src/extras/physac.h -o physac_api.$(EXTENSION) -f $(FORMAT) -d PHYSACDEF
|
||||||
|
./raylib_parser -i ../src/extras/raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIDEF
|
||||||
|
./raylib_parser -i ../src/extras/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f raylib_parser *.json *.txt *.xml *.lua
|
File diff suppressed because it is too large
Load Diff
|
@ -109,7 +109,7 @@ typedef struct EnumInfo {
|
||||||
} EnumInfo;
|
} EnumInfo;
|
||||||
|
|
||||||
// Output format for parsed data
|
// Output format for parsed data
|
||||||
typedef enum { DEFAULT = 0, JSON, XML } OutputFormat;
|
typedef enum { DEFAULT = 0, JSON, XML, LUA } OutputFormat;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Global Variables Definition
|
// Global Variables Definition
|
||||||
|
@ -500,6 +500,7 @@ int main(int argc, char* argv[])
|
||||||
if (outputFormat == DEFAULT) printf("\nOutput format: DEFAULT\n\n");
|
if (outputFormat == DEFAULT) printf("\nOutput format: DEFAULT\n\n");
|
||||||
else if (outputFormat == JSON) printf("\nOutput format: JSON\n\n");
|
else if (outputFormat == JSON) printf("\nOutput format: JSON\n\n");
|
||||||
else if (outputFormat == XML) printf("\nOutput format: XML\n\n");
|
else if (outputFormat == XML) printf("\nOutput format: XML\n\n");
|
||||||
|
else if (outputFormat == LUA) printf("\nOutput format: LUA\n\n");
|
||||||
|
|
||||||
ExportParsedData(outFileName, outputFormat);
|
ExportParsedData(outFileName, outputFormat);
|
||||||
|
|
||||||
|
@ -535,7 +536,7 @@ static void ShowCommandLineInfo(void)
|
||||||
printf(" Supported extensions: .txt, .json, .xml, .h\n");
|
printf(" Supported extensions: .txt, .json, .xml, .h\n");
|
||||||
printf(" NOTE: If not specified, defaults to: raylib_api.txt\n\n");
|
printf(" NOTE: If not specified, defaults to: raylib_api.txt\n\n");
|
||||||
printf(" -f, --format <type> : Define output format for parser data.\n");
|
printf(" -f, --format <type> : Define output format for parser data.\n");
|
||||||
printf(" Supported types: DEFAULT, JSON, XML\n\n");
|
printf(" Supported types: DEFAULT, JSON, XML, LUA\n\n");
|
||||||
printf(" -d, --define <DEF> : Define functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc\n");
|
printf(" -d, --define <DEF> : 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(" NOTE: If not specified, defaults to: RLAPI\n\n");
|
||||||
|
|
||||||
|
@ -584,6 +585,7 @@ static void ProcessCommandLine(int argc, char *argv[])
|
||||||
if (IsTextEqual(argv[i + 1], "DEFAULT\0", 8)) outputFormat = DEFAULT;
|
if (IsTextEqual(argv[i + 1], "DEFAULT\0", 8)) outputFormat = DEFAULT;
|
||||||
else if (IsTextEqual(argv[i + 1], "JSON\0", 5)) outputFormat = JSON;
|
else if (IsTextEqual(argv[i + 1], "JSON\0", 5)) outputFormat = JSON;
|
||||||
else if (IsTextEqual(argv[i + 1], "XML\0", 4)) outputFormat = XML;
|
else if (IsTextEqual(argv[i + 1], "XML\0", 4)) outputFormat = XML;
|
||||||
|
else if (IsTextEqual(argv[i + 1], "LUA\0", 4)) outputFormat = LUA;
|
||||||
}
|
}
|
||||||
else printf("WARNING: No format parameters provided\n");
|
else printf("WARNING: No format parameters provided\n");
|
||||||
}
|
}
|
||||||
|
@ -841,6 +843,89 @@ static void ExportParsedData(const char *fileName, int format)
|
||||||
if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n");
|
if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n");
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case LUA:
|
||||||
|
{
|
||||||
|
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", structs[i].desc);
|
||||||
|
fprintf(outFile, " fields = {\n");
|
||||||
|
for (int f = 0; f < structs[i].fieldCount; f++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " {\n");
|
||||||
|
fprintf(outFile, " name = \"%s\",\n", structs[i].fieldName[f]),
|
||||||
|
fprintf(outFile, " type = \"%s\",\n", structs[i].fieldType[f]),
|
||||||
|
fprintf(outFile, " description = \"%s\"\n", structs[i].fieldDesc[f] + 3),
|
||||||
|
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 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", enums[i].desc + 3);
|
||||||
|
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", enums[i].valueDesc[e] + 3),
|
||||||
|
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 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", CharReplace(funcs[i].desc, '\\', ' ') + 3);
|
||||||
|
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, " {name = \"%s\", type = \"%s\"}", funcs[i].paramName[p], funcs[i].paramType[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;
|
||||||
case JSON:
|
case JSON:
|
||||||
{
|
{
|
||||||
fprintf(outFile, "{\n");
|
fprintf(outFile, "{\n");
|
||||||
|
|
Loading…
Reference in New Issue