Build type information on first use (load-time), instead of using a hardcoded list

--HG--
branch : dynamiccore2
This commit is contained in:
Bart van Strien
2016-11-13 16:38:57 +01:00
parent 452a8a877e
commit c761202486
192 changed files with 734 additions and 614 deletions
+2
View File
@@ -27,6 +27,8 @@ namespace love
namespace sound
{
love::Type Decoder::type(&Object::type);
Decoder::Decoder(Data *data, const std::string &ext, int bufferSize)
: data(data)
, ext(ext)
+2
View File
@@ -39,6 +39,8 @@ class Decoder : public Object
{
public:
static love::Type type;
Decoder(Data *data, const std::string &ext, int bufferSize);
virtual ~Decoder();
+2
View File
@@ -25,6 +25,8 @@ namespace love
namespace sound
{
love::Type Sound::type(&Module::type);
Sound::~Sound()
{
}
+2
View File
@@ -42,6 +42,8 @@ class Sound : public Module
public:
static love::Type type;
virtual ~Sound();
// Implements Module.
+2
View File
@@ -34,6 +34,8 @@ namespace love
namespace sound
{
love::Type SoundData::type(&Data::type);
SoundData::SoundData(Decoder *decoder)
: data(0)
, size(0)
+2
View File
@@ -35,6 +35,8 @@ class SoundData : public love::Data
{
public:
static love::Type type;
SoundData(Decoder *decoder);
SoundData(int samples, int sampleRate, int bitDepth, int channels);
SoundData(void *d, int samples, int sampleRate, int bitDepth, int channels);
+3 -3
View File
@@ -31,7 +31,7 @@ namespace sound
Decoder *luax_checkdecoder(lua_State *L, int idx)
{
return luax_checktype<Decoder>(L, idx, SOUND_DECODER_ID);
return luax_checktype<Decoder>(L, idx, Decoder::type);
}
int w_Decoder_getChannels(lua_State *L)
@@ -74,7 +74,7 @@ int w_Decoder_decode(lua_State *L)
decoded / (t->getBitDepth() / 8 * t->getChannels()),
t->getSampleRate(), t->getBitDepth(), t->getChannels());
luax_pushtype(L, SOUND_SOUND_DATA_ID, s);
luax_pushtype(L, SoundData::type, s);
s->release();
});
}
@@ -109,7 +109,7 @@ static const luaL_Reg w_Decoder_functions[] =
extern "C" int luaopen_decoder(lua_State *L)
{
return luax_register_type(L, SOUND_DECODER_ID, "Decoder", w_Decoder_functions, nullptr);
return luax_register_type(L, Decoder::type, "Decoder", w_Decoder_functions, nullptr);
}
} // sound
+4 -4
View File
@@ -46,7 +46,7 @@ int w_newDecoder(lua_State *L)
if (t == nullptr)
return luaL_error(L, "Extension \"%s\" not supported.", data->getExtension().c_str());
luax_pushtype(L, SOUND_DECODER_ID, t);
luax_pushtype(L, Decoder::type, t);
t->release();
return 1;
}
@@ -68,7 +68,7 @@ int w_newSoundData(lua_State *L)
else
{
// Convert to Decoder, if necessary.
if (!luax_istype(L, 1, SOUND_DECODER_ID))
if (!luax_istype(L, 1, Decoder::type))
{
w_newDecoder(L);
lua_replace(L, 1);
@@ -77,7 +77,7 @@ int w_newSoundData(lua_State *L)
luax_catchexcept(L, [&](){ t = instance()->newSoundData(luax_checkdecoder(L, 1)); });
}
luax_pushtype(L, SOUND_SOUND_DATA_ID, t);
luax_pushtype(L, SoundData::type, t);
t->release();
return 1;
}
@@ -111,7 +111,7 @@ extern "C" int luaopen_love_sound(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "sound";
w.type = MODULE_SOUND_ID;
w.type = &Sound::type;
w.functions = functions;
w.types = types;
+3 -3
View File
@@ -39,7 +39,7 @@ namespace sound
SoundData *luax_checksounddata(lua_State *L, int idx)
{
return luax_checktype<SoundData>(L, idx, SOUND_SOUND_DATA_ID);
return luax_checktype<SoundData>(L, idx, SoundData::type);
}
int w_SoundData_getChannels(lua_State *L)
@@ -110,9 +110,9 @@ static const luaL_Reg w_SoundData_functions[] =
extern "C" int luaopen_sounddata(lua_State *L)
{
int ret = luax_register_type(L, SOUND_SOUND_DATA_ID, "SoundData", w_Data_functions, w_SoundData_functions, nullptr);
int ret = luax_register_type(L, SoundData::type, "SoundData", w_Data_functions, w_SoundData_functions, nullptr);
luax_gettypemetatable(L, SOUND_SOUND_DATA_ID);
luax_gettypemetatable(L, SoundData::type);
// Load and execute SoundData.lua, sending the metatable as an argument.
if (lua_istable(L, -1))