diff --git a/parser/Makefile b/parser/Makefile
index df152c262..9446e2826 100644
--- a/parser/Makefile
+++ b/parser/Makefile
@@ -22,6 +22,7 @@ parse:
./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 RAYGUIAPI
./raylib_parser -i ../src/extras/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI
+ ./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI
clean:
rm -f raylib_parser *.json *.txt *.xml *.lua
diff --git a/parser/raylib_api.txt b/parser/raylib_api.txt
index fb18745c7..0036636bf 100644
--- a/parser/raylib_api.txt
+++ b/parser/raylib_api.txt
@@ -3714,7 +3714,7 @@ Define 003: RLAPI
Define 004: PI
Name: PI
Type: FLOAT
- Value: 3.14159265358979323846f
+ Value: 3.14159265358979323846
Description:
Define 005: DEG2RAD
Name: DEG2RAD
diff --git a/parser/raylib_api.xml b/parser/raylib_api.xml
index 3a180b9d3..f9e474cbf 100644
--- a/parser/raylib_api.xml
+++ b/parser/raylib_api.xml
@@ -546,7 +546,7 @@
-
+
diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c
index 72730baf0..68c893f4e 100644
--- a/parser/raylib_parser.c
+++ b/parser/raylib_parser.c
@@ -120,6 +120,7 @@ typedef struct DefineInfo {
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;
// Output format for parsed data
@@ -482,10 +483,11 @@ int main(int argc, char* argv[])
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;
+ 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++;
}
@@ -494,6 +496,7 @@ int main(int argc, char* argv[])
defines[defineIndex].type = linePtr[j-1] == 'f' ? FLOAT : DOUBLE;
} else {
defines[defineIndex].type = linePtr[j-1] == 'L' ? LONG : INT;
+ defines[defineIndex].isHex = isHex;
}
}
}
@@ -501,7 +504,8 @@ int main(int argc, char* argv[])
// 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
+ 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;
@@ -1061,13 +1065,8 @@ static void ExportParsedData(const char *fileName, int format)
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 == DOUBLE || defines[i].type == STRING) {
+ 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 if (defines[i].type == FLOAT || defines[i].type == LONG) {
- int n = TextLength(defines[i].value);
- defines[i].value[n-1] = '\0';
- fprintf(outFile, " value = %s,\n", defines[i].value);
- defines[i].value[n-1] = defines[i].type == FLOAT ? 'f' : 'L';
} else {
fprintf(outFile, " value = \"%s\",\n", defines[i].value);
}
@@ -1169,13 +1168,10 @@ static void ExportParsedData(const char *fileName, int format)
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 == DOUBLE || defines[i].type == STRING) {
+ 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);
- } else if (defines[i].type == FLOAT || defines[i].type == LONG) {
- int n = TextLength(defines[i].value);
- defines[i].value[n-1] = '\0';
- fprintf(outFile, " \"value\": %s,\n", defines[i].value);
- defines[i].value[n-1] = defines[i].type == FLOAT ? 'f' : 'L';
} else {
fprintf(outFile, " \"value\": \"%s\",\n", defines[i].value);
}