Added "raw" versions of metamethods, so the original can be easily
accessed when overriding a metamethod.
This commit is contained in:
parent
156d88a020
commit
2a3ed541e7
@ -614,10 +614,15 @@ static int Lhash(lua_State *L)
|
|||||||
static const luaL_Reg Rinstance_metamethods[] =
|
static const luaL_Reg Rinstance_metamethods[] =
|
||||||
{
|
{
|
||||||
{ "__len", Llen},
|
{ "__len", Llen},
|
||||||
|
{ "__rawlen", Llen},
|
||||||
{ "__index", Lindex},
|
{ "__index", Lindex},
|
||||||
|
{ "__rawindex", Lindex},
|
||||||
{ "__tostring", Ltostring},
|
{ "__tostring", Ltostring},
|
||||||
|
{ "__rawtostring", Ltostring},
|
||||||
{ "__ipairs", Lipairs},
|
{ "__ipairs", Lipairs},
|
||||||
|
{ "__rawipairs", Lipairs},
|
||||||
{ "__pairs", Lpairs},
|
{ "__pairs", Lpairs},
|
||||||
|
{ "__rawpairs", Lpairs},
|
||||||
{ "__hash", Lhash},
|
{ "__hash", Lhash},
|
||||||
{ "from_table", Lfrom_table},
|
{ "from_table", Lfrom_table},
|
||||||
{ "is_instance", Lis_instance},
|
{ "is_instance", Lis_instance},
|
||||||
@ -629,7 +634,7 @@ static int Lmake_class(lua_State *L)
|
|||||||
{
|
{
|
||||||
size_t n_args = lua_gettop(L);
|
size_t n_args = lua_gettop(L);
|
||||||
// immutable([fields], [methods/metamethods])
|
// immutable([fields], [methods/metamethods])
|
||||||
lua_createtable(L, 0, 16); // Rough guess, 16 fields from Rinstance_metamethods + __fields, etc.
|
lua_createtable(L, 0, 20); // Rough guess, 20 fields from Rinstance_metamethods + __fields, etc.
|
||||||
// Stack: [CLS]
|
// Stack: [CLS]
|
||||||
// Populate CLS.__len, CLS.__index, CLS.__pairs, etc.
|
// Populate CLS.__len, CLS.__index, CLS.__pairs, etc.
|
||||||
luaL_register(L,NULL,Rinstance_metamethods);
|
luaL_register(L,NULL,Rinstance_metamethods);
|
||||||
|
Loading…
Reference in New Issue
Block a user