diff options
| -rw-r--r-- | API.md | 8 | ||||
| -rw-r--r-- | ReiLua_API.lua | 6 | ||||
| -rw-r--r-- | changelog | 1 | ||||
| -rw-r--r-- | include/core.h | 1 | ||||
| -rw-r--r-- | src/core.c | 23 | ||||
| -rw-r--r-- | src/lua_core.c | 1 |
6 files changed, 40 insertions, 0 deletions
@@ -5522,6 +5522,14 @@ Get buffer data as table in the format it was stored --- +> string = RL.GetBufferAsString( Buffer buffer ) + +Get buffer as string + +- Success return string + +--- + > type = RL.GetBufferType( Buffer buffer ) Get buffer type diff --git a/ReiLua_API.lua b/ReiLua_API.lua index 5006d3a..604e6b8 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -2684,6 +2684,12 @@ function RL.SetBufferData( buffer, position, value ) end ---@return any data function RL.GetBufferData( buffer, position, length ) end +---Get buffer as string +---- Success return string +---@param buffer any +---@return any string +function RL.GetBufferAsString( buffer ) end + ---Get buffer type ---- Success return int ---@param buffer any @@ -70,6 +70,7 @@ DETAILED CHANGES: - FIXED: GenImageColor color was also argument 1. - CHANGE: GetPixelDataSize takes Vector2 instead of width and height. - ADDED: LoadBufferFormatted, SetBufferData and CopyBufferData. Compressed resource file example. + - ADDED: GetBufferAsString. ------------------------------------------------------------------------ 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 045a594..181de24 100644 --- a/include/core.h +++ b/include/core.h @@ -256,6 +256,7 @@ int lcoreUnloadBuffer( lua_State* L ); int lcoreCopyBufferData( lua_State* L ); int lcoreSetBufferData( lua_State* L ); int lcoreGetBufferData( lua_State* L ); +int lcoreGetBufferAsString( lua_State* L ); int lcoreGetBufferType( lua_State* L ); int lcoreGetBufferSize( lua_State* L ); int lcoreGetBufferElementSize( lua_State* L ); @@ -3737,6 +3737,29 @@ int lcoreGetBufferData( lua_State* L ) { } /* +> string = RL.GetBufferAsString( Buffer buffer ) + +Get buffer as string + +- Success return string +*/ +int lcoreGetBufferAsString( lua_State* L ) { + Buffer* buffer = uluaGetBuffer( L, 1 ); + + size_t size = buffer->size * getBufferElementSize( buffer ) + 1; + char* str = malloc( size ); + + memset( str, 0, size ); + memcpy( str, buffer->data, size - 1 ); + + lua_pushstring( L, buffer->data ); + + free( str ); + + return 1; +} + +/* > type = RL.GetBufferType( Buffer buffer ) Get buffer type diff --git a/src/lua_core.c b/src/lua_core.c index 50fdfda..7250cfc 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1519,6 +1519,7 @@ void luaRegister() { assingGlobalFunction( "CopyBufferData", lcoreCopyBufferData ); assingGlobalFunction( "SetBufferData", lcoreSetBufferData ); assingGlobalFunction( "GetBufferData", lcoreGetBufferData ); + assingGlobalFunction( "GetBufferAsString", lcoreGetBufferAsString ); assingGlobalFunction( "GetBufferType", lcoreGetBufferType ); assingGlobalFunction( "GetBufferSize", lcoreGetBufferSize ); assingGlobalFunction( "GetBufferElementSize", lcoreGetBufferElementSize ); |
