MCPcopy Create free account
hub / github.com/defold/defold / GetBytes

Function GetBytes

engine/gamesys/src/gamesys/scripts/script_buffer.cpp:693–708  ·  view source on GitHub ↗

gets data from a stream * * Get a copy of all the bytes from a specified stream as a Lua string. * * @name buffer.get_bytes * @param buffer [type:buffer] the source buffer * @param stream_name [type:hash] the name of the stream * @return data [type:string] the buffer data as a Lua string */

Source from the content-addressed store, hash-verified

691 * @return data [type:string] the buffer data as a Lua string
692 */
693 static int GetBytes(lua_State* L)
694 {
695 DM_LUA_STACK_CHECK(L, 1);
696 dmBuffer::HBuffer hbuffer = dmScript::CheckBufferUnpack(L, 1);
697
698 uint8_t* data;
699 uint32_t datasize;
700 dmBuffer::Result r = dmBuffer::GetBytes(hbuffer, (void**)&data, &datasize);
701 if( r != dmBuffer::RESULT_OK )
702 {
703 return DM_LUA_ERROR("buffer.create: Failed getting buffer: %s", dmBuffer::GetResultString(r));
704 }
705
706 lua_pushlstring(L, (const char*)data, datasize);
707 return 1;
708 }
709
710 //////////////////////////////////////////////////////////////////
711 // BUFFER

Callers 14

Image_LoadBufferFunction · 0.70
SetFunction · 0.70
LoadFunction · 0.70
CreateTextureAsyncFunction · 0.70
SetTextureFunction · 0.70
CheckBufferOrStringFunction · 0.70
Sys_LoadBufferFunction · 0.70
MakeTextureImageFunction · 0.50
CopyBufferToVertexBufferFunction · 0.50
RenderBatchWorldVSFunction · 0.50
BuildVerticesFunction · 0.50

Calls 3

CheckBufferUnpackFunction · 0.85
GetResultStringFunction · 0.85
lua_pushlstringFunction · 0.85

Tested by 2

TEST_FFunction · 0.40
TEST_PFunction · 0.40