Merge branch 'master' of https://github.com/raysan5/raylib
This commit is contained in:
commit
2c38dad214
6 changed files with 6951 additions and 22 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -101,3 +101,6 @@ zig-out/
|
||||||
build/
|
build/
|
||||||
build-*/
|
build-*/
|
||||||
docgen_tmp/
|
docgen_tmp/
|
||||||
|
|
||||||
|
# Parser stuff
|
||||||
|
parser/raylib_parser
|
||||||
|
|
|
@ -42,6 +42,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | https://github.com/electronstudio/kaylib |
|
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | https://github.com/electronstudio/kaylib |
|
||||||
| dlang_raylib | 3.7 | [D](https://dlang.org) | https://github.com/rc-05/dlang_raylib |
|
| dlang_raylib | 3.7 | [D](https://dlang.org) | https://github.com/rc-05/dlang_raylib |
|
||||||
| raylib-freebasic | **4.0** | [FreeBASIC](https://www.freebasic.net/) | https://github.com/WIITD/raylib-freebasic |
|
| raylib-freebasic | **4.0** | [FreeBASIC](https://www.freebasic.net/) | https://github.com/WIITD/raylib-freebasic |
|
||||||
|
| raylib-cr | **4.0** | [Crystal](https://crystal-lang.org/) | https://github.com/sol-vin/raylib-cr |
|
||||||
|
|
||||||
### Utility Wrapers
|
### Utility Wrapers
|
||||||
These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's pardigm.
|
These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's pardigm.
|
||||||
|
|
27
parser/Makefile
Normal file
27
parser/Makefile
Normal file
|
@ -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
|
6816
parser/raylib_api.lua
Normal file
6816
parser/raylib_api.lua
Normal file
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");
|
||||||
|
|
37
src/rcore.c
37
src/rcore.c
|
@ -2894,41 +2894,38 @@ const char *GetWorkingDirectory(void)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get filenames in a directory path (max 512 files)
|
// Get filenames in a directory path
|
||||||
// NOTE: Files count is returned by parameters pointer
|
// NOTE: Files count is returned by parameters pointer
|
||||||
char **GetDirectoryFiles(const char *dirPath, int *fileCount)
|
char **GetDirectoryFiles(const char *dirPath, int *fileCount)
|
||||||
{
|
{
|
||||||
#define MAX_DIRECTORY_FILES 512
|
|
||||||
|
|
||||||
ClearDirectoryFiles();
|
ClearDirectoryFiles();
|
||||||
|
|
||||||
// Memory allocation for MAX_DIRECTORY_FILES
|
|
||||||
dirFilesPath = (char **)RL_MALLOC(MAX_DIRECTORY_FILES*sizeof(char *));
|
|
||||||
for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesPath[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char));
|
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
struct dirent *entity;
|
struct dirent *entity;
|
||||||
DIR *dir = opendir(dirPath);
|
DIR *dir = opendir(dirPath);
|
||||||
|
|
||||||
if (dir != NULL) // It's a directory
|
if (dir != NULL) // It's a directory
|
||||||
{
|
{
|
||||||
// TODO: Reading could be done in two passes,
|
// Count files
|
||||||
// first one to count files and second one to read names
|
while ((entity = readdir(dir)) != NULL) counter++;
|
||||||
// That way we can allocate required memory, instead of a limited pool
|
|
||||||
|
|
||||||
while ((entity = readdir(dir)) != NULL)
|
dirFileCount = counter;
|
||||||
{
|
*fileCount = dirFileCount;
|
||||||
strcpy(dirFilesPath[counter], entity->d_name);
|
|
||||||
counter++;
|
// Memory allocation for dirFileCount
|
||||||
}
|
dirFilesPath = (char **)RL_MALLOC(dirFileCount*sizeof(char *));
|
||||||
|
for (int i = 0; i < dirFileCount; i++) dirFilesPath[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char));
|
||||||
|
|
||||||
|
// Reset our position in the directory to the beginning
|
||||||
|
rewinddir(dir);
|
||||||
|
|
||||||
|
// Read file names
|
||||||
|
for (int i = 0; (entity = readdir(dir)) != NULL; i++) strcpy(dirFilesPath[i], entity->d_name);
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
else TRACELOG(LOG_WARNING, "FILEIO: Failed to open requested directory"); // Maybe it's a file...
|
else TRACELOG(LOG_WARNING, "FILEIO: Failed to open requested directory"); // Maybe it's a file...
|
||||||
|
|
||||||
dirFileCount = counter;
|
|
||||||
*fileCount = dirFileCount;
|
|
||||||
|
|
||||||
return dirFilesPath;
|
return dirFilesPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2937,7 +2934,7 @@ void ClearDirectoryFiles(void)
|
||||||
{
|
{
|
||||||
if (dirFileCount > 0)
|
if (dirFileCount > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_DIRECTORY_FILES; i++) RL_FREE(dirFilesPath[i]);
|
for (int i = 0; i < dirFileCount; i++) RL_FREE(dirFilesPath[i]);
|
||||||
|
|
||||||
RL_FREE(dirFilesPath);
|
RL_FREE(dirFilesPath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue