From c95c797da61b4b2829d542f6d7c164a88951cad4 Mon Sep 17 00:00:00 2001 From: jussi Date: Mon, 20 May 2024 17:56:28 +0300 Subject: GetPlatform. --- API.md | 8 ++++++++ ReiLua_API.lua | 5 +++++ changelog | 1 + include/core.h | 1 + src/core.c | 25 +++++++++++++++++++++++++ src/lua_core.c | 1 + 6 files changed, 41 insertions(+) diff --git a/API.md b/API.md index c7f17d8..5f740c5 100644 --- a/API.md +++ b/API.md @@ -4496,6 +4496,14 @@ Set Lua garbage collection to unload object data --- +> platform = RL.GetPlatform() + +Get platform. Returns "Windows", "Linux", "FreeBSD", "OpenBSD", "Apple" or "Emscripten" + +- Success return string + +--- + ## Core - Files management functions --- diff --git a/ReiLua_API.lua b/ReiLua_API.lua index 35b0778..7e0b28e 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -1882,6 +1882,11 @@ function RL.IsGCUnloadEnabled() end ---@return any RL.SetGCUnload function RL.SetGCUnload( enabled ) end +---Get platform. Returns "Windows", "Linux", "FreeBSD", "OpenBSD", "Apple" or "Emscripten" +---- Success return string +---@return any platform +function RL.GetPlatform() end + -- Core - Files management functions ---Load file data as byte array (read). Buffer type is BUFFER_UNSIGNED_CHAR diff --git a/changelog b/changelog index db8008e..966316c 100644 --- a/changelog +++ b/changelog @@ -49,6 +49,7 @@ DETAILED CHANGES: - ADDED: Bitwise operations for cross Lua compatibility. - ADDED: GetMeshData. - FIXED: GenMeshCustom indices wasn't changing triangleCount. + - ADDED: GetPlatform. ------------------------------------------------------------------------ Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0 diff --git a/include/core.h b/include/core.h index 11a8d2a..d72fdb9 100644 --- a/include/core.h +++ b/include/core.h @@ -114,6 +114,7 @@ int lcoreGetLogLevelInvalid( lua_State* L ); int lcoreOpenURL( lua_State* L ); int lcoreIsGCUnloadEnabled( lua_State* L ); int lcoreSetGCUnload( lua_State* L ); +int lcoreGetPlatform( lua_State* L ); /* Files management functions. */ int lcoreLoadFileData( lua_State* L ); int lcoreSaveFileData( lua_State* L ); diff --git a/src/core.c b/src/core.c index 2146510..d22ed60 100644 --- a/src/core.c +++ b/src/core.c @@ -1490,6 +1490,31 @@ int lcoreSetGCUnload( lua_State* L ) { return 0; } +/* +> platform = RL.GetPlatform() + +Get platform. Returns "Windows", "Linux", "FreeBSD", "OpenBSD", "Apple" or "Emscripten" + +- Success return string +*/ +int lcoreGetPlatform( lua_State* L ) { +#if defined( _WIN32 ) + lua_pushstring( L, "Windows" ); +#elif defined( __linux__ ) + lua_pushstring( L, "Linux" ); +#elif defined( __FreeBSD__ ) + lua_pushstring( L, "FreeBSD" ); +#elif defined( __OpenBSD__ ) + lua_pushstring( L, "OpenBSD" ); +#elif defined( __APPLE__ ) + lua_pushstring( L, "Apple" ); +#elif defined( __EMSCRIPTEN__ ) + lua_pushstring( L, "Emscripten" ); +#endif + + return 1; +} + /* ## Core - Files management functions */ diff --git a/src/lua_core.c b/src/lua_core.c index 6d89777..6330930 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1378,6 +1378,7 @@ void luaRegister() { assingGlobalFunction( "OpenURL", lcoreOpenURL ); assingGlobalFunction( "IsGCUnloadEnabled", lcoreIsGCUnloadEnabled ); assingGlobalFunction( "SetGCUnload", lcoreSetGCUnload ); + assingGlobalFunction( "GetPlatform", lcoreGetPlatform ); /* Files management functions. */ assingGlobalFunction( "LoadFileData", lcoreLoadFileData ); assingGlobalFunction( "SaveFileData", lcoreSaveFileData ); -- cgit v1.2.3