GetBufferAsString.
This commit is contained in:
8
API.md
8
API.md
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
23
src/core.c
23
src/core.c
@@ -3736,6 +3736,29 @@ int lcoreGetBufferData( lua_State* L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user