Add support for truncating parser input (#2464)
* Add support for truncating parser input * Remove RLAPI from implementations in rlgl.h
This commit is contained in:
parent
19f88241ec
commit
bbc8d39185
@ -19,10 +19,10 @@ parse:
|
|||||||
./raylib_parser -i ../src/raylib.h -o raylib_api.$(EXTENSION) -f $(FORMAT) -d RLAPI
|
./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/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/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/physac.h -o physac_api.$(EXTENSION) -f $(FORMAT) -d PHYSACDEF -t "PHYSAC IMPLEMENTATION"
|
||||||
./raylib_parser -i ../src/extras/raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI
|
./raylib_parser -i ../src/extras/raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION"
|
||||||
./raylib_parser -i ../src/extras/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI
|
./raylib_parser -i ../src/extras/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI -t "RMEM IMPLEMENTATION"
|
||||||
./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI
|
./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI -t "RLGL IMPLEMENTATION"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f raylib_parser *.json *.txt *.xml *.lua
|
rm -f raylib_parser *.json *.txt *.xml *.lua
|
||||||
|
@ -154,6 +154,7 @@ static FunctionInfo *funcs = NULL;
|
|||||||
|
|
||||||
// Command line variables
|
// Command line variables
|
||||||
static char apiDefine[32] = { 0 }; // Functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc.)
|
static char apiDefine[32] = { 0 }; // Functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc.)
|
||||||
|
static char truncAfter[32] = { 0 }; // Truncate marker (i.e. "RLGL IMPLEMENTATION" for rlgl.h)
|
||||||
static char inFileName[512] = { 0 }; // Input file name (required in case of provided through CLI)
|
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 char outFileName[512] = { 0 }; // Output file name (required for file save/export)
|
||||||
static int outputFormat = DEFAULT;
|
static int outputFormat = DEFAULT;
|
||||||
@ -171,6 +172,7 @@ static void GetDescription(const char *source, char *description);
|
|||||||
static void MoveArraySize(char *name, char *type); // Move array size from name to type
|
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 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 bool IsTextEqual(const char *text1, const char *text2, unsigned int count);
|
||||||
|
static int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string
|
||||||
static void MemoryCopy(void *dest, const void *src, 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 char *EscapeBackslashes(char *text); // Replace '\' by "\\" when exporting to JSON and XML
|
||||||
static const char *StrDefineType(DefineType type); // Get string of define type
|
static const char *StrDefineType(DefineType type); // Get string of define type
|
||||||
@ -196,6 +198,19 @@ int main(int argc, char* argv[])
|
|||||||
int linesCount = 0;
|
int linesCount = 0;
|
||||||
char **lines = GetTextLines(buffer, length, &linesCount);
|
char **lines = GetTextLines(buffer, length, &linesCount);
|
||||||
|
|
||||||
|
// Truncate lines
|
||||||
|
if (truncAfter[0] != '\0')
|
||||||
|
{
|
||||||
|
int newCount = -1;
|
||||||
|
for (int i = 0; i < linesCount; i++)
|
||||||
|
{
|
||||||
|
if (newCount > -1) free(lines[i]);
|
||||||
|
else if (TextFindIndex(lines[i], truncAfter) > -1) newCount = i;
|
||||||
|
}
|
||||||
|
if (newCount > -1) linesCount = newCount;
|
||||||
|
printf("Number of truncated text lines: %i\n", linesCount);
|
||||||
|
}
|
||||||
|
|
||||||
// Defines line indices
|
// Defines line indices
|
||||||
int *defineLines = (int *)malloc(MAX_DEFINES_TO_PARSE*sizeof(int));
|
int *defineLines = (int *)malloc(MAX_DEFINES_TO_PARSE*sizeof(int));
|
||||||
|
|
||||||
@ -936,6 +951,8 @@ static void ShowCommandLineInfo(void)
|
|||||||
printf(" Supported types: DEFAULT, JSON, XML, LUA\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");
|
||||||
|
printf(" -t, --truncate <after> : Define string to truncate input after (i.e. \"RLGL IMPLEMENTATION\" for rlgl.h)\n");
|
||||||
|
printf(" NOTE: If not specified input is not truncated.\n\n");
|
||||||
|
|
||||||
printf("\nEXAMPLES:\n\n");
|
printf("\nEXAMPLES:\n\n");
|
||||||
printf(" > raylib_parser --input raylib.h --output api.json\n");
|
printf(" > raylib_parser --input raylib.h --output api.json\n");
|
||||||
@ -997,6 +1014,15 @@ static void ProcessCommandLine(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else printf("WARNING: No define key provided\n");
|
else printf("WARNING: No define key provided\n");
|
||||||
}
|
}
|
||||||
|
else if (IsTextEqual(argv[i], "-t", 2) || IsTextEqual(argv[i], "--truncate", 10))
|
||||||
|
{
|
||||||
|
if (((i + 1) < argc) && (argv[i + 1][0] != '-'))
|
||||||
|
{
|
||||||
|
MemoryCopy(truncAfter, argv[i + 1], TextLength(argv[i + 1])); // Read truncate marker
|
||||||
|
truncAfter[TextLength(argv[i + 1])] = '\0';
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1174,6 +1200,20 @@ static bool IsTextEqual(const char *text1, const char *text2, unsigned int count
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find first text occurrence within a string
|
||||||
|
int TextFindIndex(const char *text, const char *find)
|
||||||
|
{
|
||||||
|
int textLen = TextLength(text);
|
||||||
|
int findLen = TextLength(find);
|
||||||
|
|
||||||
|
for (int i = 0; i <= textLen - findLen; i++)
|
||||||
|
{
|
||||||
|
if (IsTextEqual(&text[i], find, findLen)) return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Custom memcpy() to avoid <string.h>
|
// Custom memcpy() to avoid <string.h>
|
||||||
static void MemoryCopy(void *dest, const void *src, unsigned int count)
|
static void MemoryCopy(void *dest, const void *src, unsigned int count)
|
||||||
{
|
{
|
||||||
|
@ -4091,7 +4091,7 @@ Matrix rlGetMatrixTransform(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get internal projection matrix for stereo render (selected eye)
|
// Get internal projection matrix for stereo render (selected eye)
|
||||||
RLAPI Matrix rlGetMatrixProjectionStereo(int eye)
|
Matrix rlGetMatrixProjectionStereo(int eye)
|
||||||
{
|
{
|
||||||
Matrix mat = rlMatrixIdentity();
|
Matrix mat = rlMatrixIdentity();
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
@ -4101,7 +4101,7 @@ RLAPI Matrix rlGetMatrixProjectionStereo(int eye)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get internal view offset matrix for stereo render (selected eye)
|
// Get internal view offset matrix for stereo render (selected eye)
|
||||||
RLAPI Matrix rlGetMatrixViewOffsetStereo(int eye)
|
Matrix rlGetMatrixViewOffsetStereo(int eye)
|
||||||
{
|
{
|
||||||
Matrix mat = rlMatrixIdentity();
|
Matrix mat = rlMatrixIdentity();
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user