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
+14 -14
View File
@@ -43,7 +43,7 @@ namespace math
int w__getRandomGenerator(lua_State *L)
{
RandomGenerator *t = Math::instance.getRandomGenerator();
luax_pushtype(L, MATH_RANDOM_GENERATOR_ID, t);
luax_pushtype(L, RandomGenerator::type, t);
return 1;
}
@@ -74,7 +74,7 @@ int w_newRandomGenerator(lua_State *L)
return luaL_error(L, "%s", lua_tostring(L, -1));
}
luax_pushtype(L, MATH_RANDOM_GENERATOR_ID, t);
luax_pushtype(L, RandomGenerator::type, t);
t->release();
return 1;
}
@@ -113,7 +113,7 @@ int w_newBezierCurve(lua_State *L)
}
BezierCurve *curve = Math::instance.newBezierCurve(points);
luax_pushtype(L, MATH_BEZIER_CURVE_ID, curve);
luax_pushtype(L, BezierCurve::type, curve);
curve->release();
return 1;
}
@@ -338,11 +338,11 @@ int w_compress(lua_State *L)
}
else
{
Data *rawdata = luax_checktype<Data>(L, 1, DATA_ID);
Data *rawdata = luax_checktype<Data>(L, 1, Data::type);
luax_catchexcept(L, [&](){ cdata = compress(format, rawdata, level); });
}
luax_pushtype(L, MATH_COMPRESSED_DATA_ID, cdata);
luax_pushtype(L, CompressedData::type, cdata);
return 1;
}
@@ -351,7 +351,7 @@ int w_decompress(lua_State *L)
char *rawbytes = nullptr;
size_t rawsize = 0;
if (luax_istype(L, 1, MATH_COMPRESSED_DATA_ID))
if (luax_istype(L, 1, CompressedData::type))
{
CompressedData *data = luax_checkcompresseddata(L, 1);
rawsize = data->getDecompressedSize();
@@ -368,9 +368,9 @@ int w_decompress(lua_State *L)
size_t compressedsize = 0;
const char *cbytes = nullptr;
if (luax_istype(L, 1, DATA_ID))
if (luax_istype(L, 1, Data::type))
{
Data *data = luax_checktype<Data>(L, 1, DATA_ID);
Data *data = luax_checktype<Data>(L, 1, Data::type);
cbytes = (const char *) data->getData();
compressedsize = data->getSize();
}
@@ -396,9 +396,9 @@ int w_encode(lua_State *L)
size_t srclen = 0;
const char *src = nullptr;
if (luax_istype(L, 2, DATA_ID))
if (luax_istype(L, 2, Data::type))
{
Data *data = luax_totype<Data>(L, 2, DATA_ID);
Data *data = luax_totype<Data>(L, 2, Data::type);
src = (const char *) data->getData();
srclen = data->getSize();
}
@@ -430,9 +430,9 @@ int w_decode(lua_State *L)
size_t srclen = 0;
const char *src = nullptr;
if (luax_istype(L, 2, DATA_ID))
if (luax_istype(L, 2, Data::type))
{
Data *data = luax_totype<Data>(L, 2, DATA_ID);
Data *data = luax_totype<Data>(L, 2, Data::type);
src = (const char *) data->getData();
srclen = data->getSize();
}
@@ -468,7 +468,7 @@ int w_hash(lua_State *L)
}
else
{
Data *rawdata = luax_checktype<Data>(L, 2, DATA_ID);
Data *rawdata = luax_checktype<Data>(L, 2, Data::type);
luax_catchexcept(L, [&](){ hash = love::math::hash(function, rawdata); });
}
@@ -535,7 +535,7 @@ extern "C" int luaopen_love_math(lua_State *L)
WrappedModule w;
w.module = &Math::instance;
w.name = "math";
w.type = MODULE_ID;
w.type = &Module::type;
w.functions = functions;
w.types = types;