mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Implemented efficient FFI versions of SoundData methods, which are used when the LuaJIT FFI and JIT compiler are present.
This commit is contained in:
@@ -22,11 +22,21 @@
|
||||
|
||||
#include "common/wrap_Data.h"
|
||||
|
||||
// Shove the wrap_SoundData.lua code directly into a raw string literal.
|
||||
static const char sounddata_lua[] =
|
||||
#include "wrap_SoundData.lua"
|
||||
;
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace sound
|
||||
{
|
||||
|
||||
/**
|
||||
* NOTE: Additional wrapper code is in wrap_SoundData.lua. Be sure to keep it
|
||||
* in sync with any changes made to this file!
|
||||
**/
|
||||
|
||||
SoundData *luax_checksounddata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<SoundData>(L, idx, SOUND_SOUND_DATA_ID);
|
||||
@@ -105,7 +115,22 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_sounddata(lua_State *L)
|
||||
{
|
||||
return luax_register_type(L, SOUND_SOUND_DATA_ID, functions);
|
||||
// The last argument pushes the type's metatable onto the stack.
|
||||
int ret = luax_register_type(L, SOUND_SOUND_DATA_ID, functions, true);
|
||||
|
||||
// Load and execute SoundData.lua, sending the metatable as an argument.
|
||||
if (ret > 0)
|
||||
{
|
||||
luaL_loadbuffer(L, sounddata_lua, sizeof(sounddata_lua), "SoundData.lua");
|
||||
lua_pushvalue(L, -2);
|
||||
lua_call(L, 1, 0);
|
||||
|
||||
// Pop the metatable.
|
||||
lua_pop(L, 1);
|
||||
ret--;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // sound
|
||||
|
||||
Reference in New Issue
Block a user