[svn:parrot] r36506 - trunk/languages/lua/src/pmc
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Mon Feb 9 21:02:33 UTC 2009
Author: fperrad
Date: Mon Feb 9 21:02:32 2009
New Revision: 36506
URL: https://trac.parrot.org/parrot/changeset/36506
Log:
[Lua] refactor metatable access, and s/find_meth/_LuaAny_find_meth/
Modified:
trunk/languages/lua/src/pmc/lua_private.h
trunk/languages/lua/src/pmc/luaany.pmc
trunk/languages/lua/src/pmc/luanumber.pmc
trunk/languages/lua/src/pmc/luastring.pmc
trunk/languages/lua/src/pmc/luatable.pmc
trunk/languages/lua/src/pmc/luauserdata.pmc
Modified: trunk/languages/lua/src/pmc/lua_private.h
==============================================================================
--- trunk/languages/lua/src/pmc/lua_private.h Mon Feb 9 20:49:35 2009 (r36505)
+++ trunk/languages/lua/src/pmc/lua_private.h Mon Feb 9 21:02:32 2009 (r36506)
@@ -18,7 +18,10 @@
#define PMC_type(pmc) ((pmc)->vtable->base_type)
-extern PMC * find_meth(PARROT_INTERP, PMC *obj, const char *name);
+extern PMC * _LuaAny_find_meth(PARROT_INTERP, PMC *obj, const char *name);
+extern PMC * _LuaString_get_metatable(PARROT_INTERP);
+extern PMC * _LuaTable_get_metatable(PARROT_INTERP, PMC *obj);
+extern PMC * _LuaUserdata_get_metatable(PARROT_INTERP, PMC *obj);
#endif /* PARROT_LUA_PRIVATE_H_GUARD */
Modified: trunk/languages/lua/src/pmc/luaany.pmc
==============================================================================
--- trunk/languages/lua/src/pmc/luaany.pmc Mon Feb 9 20:49:35 2009 (r36505)
+++ trunk/languages/lua/src/pmc/luaany.pmc Mon Feb 9 21:02:32 2009 (r36506)
@@ -53,36 +53,35 @@
PMC *
-find_meth(PARROT_INTERP, PMC *obj, const char *name) {
- PMC *meta = NULL;
- INTVAL type = PMC_type(obj);
+_LuaAny_find_meth(PARROT_INTERP, PMC *obj, const char *name) {
+ PMC *meta = NULL;
+ const INTVAL type = PMC_type(obj);
- if (dynpmc_LuaString == type) {
- meta = Parrot_find_global_s(interp,
- Parrot_str_new_constant(interp, "string"),
- Parrot_str_new_constant(interp, "mt_string"));
+ if (type == dynpmc_LuaTable) {
+ meta = _LuaTable_get_metatable(interp, obj);
+ }
+ else if (type == dynpmc_LuaUserdata) {
+ meta = _LuaUserdata_get_metatable(interp, obj);
+ }
+ else if (type == dynpmc_LuaString) {
+ meta = _LuaString_get_metatable(interp);
}
- if (dynpmc_LuaFunction != type) {
- if (obj->pmc_ext)
- meta = PMC_metadata(obj);
+ if (!meta)
+ return NULL;
- if (meta && dynpmc_LuaTable != PMC_type(meta))
- return meta;
+ if (dynpmc_LuaTable != PMC_type(meta)) {
+ return meta;
}
-
- if (meta) {
+ else {
PMC *method;
- PMC *key = pmc_new(interp, dynpmc_LuaString);
+ PMC * const key = pmc_new(interp, dynpmc_LuaString);
VTABLE_set_string_native(interp, key, Parrot_str_new_constant(interp, name));
method = VTABLE_get_pmc_keyed(interp, meta, key);
- if (dynpmc_LuaNil != PMC_type(method))
- return method;
+ return (dynpmc_LuaNil != PMC_type(method)) ? method : NULL;
}
-
- return NULL;
}
@@ -155,7 +154,7 @@
*/
VTABLE PMC* get_pmc_keyed(PMC *key) {
- PMC * const meth = find_meth(INTERP, SELF, "__index");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__index");
if (meth) {
if (dynpmc_LuaFunction == PMC_type(meth)) {
@@ -184,7 +183,7 @@
*/
VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
- PMC * const meth = find_meth(INTERP, SELF, "__newindex");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__newindex");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -210,7 +209,7 @@
*/
VTABLE PMC* neg(PMC *dest) {
- PMC * const meth = find_meth(INTERP, SELF, "__unm");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__unm");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -225,7 +224,7 @@
}
VTABLE void i_neg() {
- PMC * const meth = find_meth(INTERP, SELF, "__unm");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__unm");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -276,7 +275,7 @@
*/
VTABLE opcode_t* invoke(void *next) {
- PMC * const meth = find_meth(INTERP, SELF, "__call");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__call");
PMC *retval;
if (!meth)
@@ -336,7 +335,7 @@
*/
MULTI PMC* add(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, SELF, "__add");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__add");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
"attempt to perform arithmetic on a %Ss value", SELF.name());
@@ -350,7 +349,7 @@
}
MULTI void i_add(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, SELF, "__add");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__add");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -362,7 +361,7 @@
}
MULTI PMC* subtract(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, SELF, "__sub");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__sub");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
"attempt to perform arithmetic on a %Ss value", SELF.name());
@@ -376,7 +375,7 @@
}
MULTI void i_subtract(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, SELF, "__sub");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__sub");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
"attempt to perform arithmetic on a %Ss value", SELF.name());
@@ -388,7 +387,7 @@
}
MULTI PMC* multiply(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, SELF, "__mul");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__mul");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -403,7 +402,7 @@
}
MULTI void i_multiply(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, SELF, "__mul");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__mul");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -416,7 +415,7 @@
}
MULTI PMC* divide(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, SELF, "__div");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__div");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -431,7 +430,7 @@
}
MULTI void i_divide(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, SELF, "__div");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__div");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -444,7 +443,7 @@
}
MULTI PMC* modulus(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, SELF, "__mod");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__mod");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -459,7 +458,7 @@
}
MULTI void i_modulus(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, SELF, "__mod");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__mod");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -472,7 +471,7 @@
}
MULTI PMC* pow(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, SELF, "__pow");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__pow");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -487,7 +486,7 @@
}
MULTI void i_pow(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, SELF, "__pow");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__pow");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -500,7 +499,7 @@
}
MULTI PMC* concatenate(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, SELF, "__concat");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__concat");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
@@ -515,7 +514,7 @@
}
MULTI void i_concatenate(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, SELF, "__concat");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__concat");
if (!meth)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
"attempt to concatenate a %Ss value", SELF.name());
@@ -593,7 +592,7 @@
*/
METHOD PMC* len() {
- PMC * const meth = find_meth(INTERP, SELF, "__len");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__len");
PMC *retval;
if (!meth)
@@ -634,7 +633,7 @@
*/
METHOD PMC* tostring() {
- PMC * const meth = find_meth(INTERP, SELF, "__tostring");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__tostring");
PMC *retval;
if (meth) {
Modified: trunk/languages/lua/src/pmc/luanumber.pmc
==============================================================================
--- trunk/languages/lua/src/pmc/luanumber.pmc Mon Feb 9 20:49:35 2009 (r36505)
+++ trunk/languages/lua/src/pmc/luanumber.pmc Mon Feb 9 21:02:32 2009 (r36506)
@@ -338,7 +338,7 @@
}
MULTI PMC *add(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__add");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__add");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -380,7 +380,7 @@
}
MULTI void i_add(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__add");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__add");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -424,7 +424,7 @@
}
MULTI PMC *subtract(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__sub");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__sub");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -467,7 +467,7 @@
}
MULTI void i_subtract(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__sub");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__sub");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (! SELF)
@@ -510,7 +510,7 @@
}
MULTI PMC *multiply(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__mul");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__mul");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(dest))
@@ -550,7 +550,7 @@
}
MULTI void i_multiply(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__mul");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__mul");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (! SELF)
@@ -593,7 +593,7 @@
}
MULTI PMC *divide(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__div");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__div");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(dest))
@@ -634,7 +634,7 @@
}
MULTI void i_divide(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__div");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__div");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (! SELF)
@@ -678,7 +678,7 @@
}
MULTI PMC *modulus(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__mod");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__mod");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(dest))
@@ -720,7 +720,7 @@
}
MULTI void i_modulus(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__mod");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__mod");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (! SELF)
@@ -763,7 +763,7 @@
}
MULTI PMC *pow(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__pow");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__pow");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(dest))
@@ -804,7 +804,7 @@
}
MULTI void i_pow(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__pow");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__pow");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (! SELF)
@@ -875,7 +875,7 @@
}
MULTI PMC *concatenate(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__concat");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__concat");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -911,7 +911,7 @@
}
MULTI void i_concatenate(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__concat");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__concat");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
Modified: trunk/languages/lua/src/pmc/luastring.pmc
==============================================================================
--- trunk/languages/lua/src/pmc/luastring.pmc Mon Feb 9 20:49:35 2009 (r36505)
+++ trunk/languages/lua/src/pmc/luastring.pmc Mon Feb 9 21:02:32 2009 (r36506)
@@ -22,6 +22,13 @@
#include "lua_private.h"
#include "pmc_luanumber.h"
+PMC *
+_LuaString_get_metatable(PARROT_INTERP) {
+ return Parrot_find_global_s(interp,
+ Parrot_str_new_constant(interp, "string"),
+ Parrot_str_new_constant(interp, "mt_string"));
+}
+
pmclass LuaString
extends LuaAny
@@ -300,7 +307,7 @@
}
MULTI PMC* add(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__add");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__add");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(dest))
@@ -348,7 +355,7 @@
}
MULTI void i_add(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__add");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__add");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(SELF))
@@ -394,7 +401,7 @@
}
MULTI PMC* subtract(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__sub");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__sub");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(dest))
@@ -442,7 +449,7 @@
}
MULTI void i_subtract(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__sub");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__sub");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -489,7 +496,7 @@
}
MULTI PMC* multiply(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__mul");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__mul");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(dest))
@@ -537,7 +544,7 @@
}
MULTI void i_multiply(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__mul");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__mul");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(SELF))
@@ -583,7 +590,7 @@
}
MULTI PMC* divide(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__div");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__div");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -632,7 +639,7 @@
}
MULTI void i_divide(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__div");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__div");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(SELF))
@@ -678,7 +685,7 @@
}
MULTI PMC* modulus(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__mod");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__mod");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -727,7 +734,7 @@
}
MULTI void i_modulus(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__mod");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__mod");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
if (PMC_IS_NULL(SELF))
@@ -773,7 +780,7 @@
}
MULTI PMC* pow(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__pow");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__pow");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -822,7 +829,7 @@
}
MULTI void i_pow(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__pow");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__pow");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -908,7 +915,7 @@
}
MULTI PMC* concatenate(DEFAULT value, PMC *dest) {
- PMC * const meth = find_meth(INTERP, value, "__concat");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__concat");
if (meth) {
dest = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -943,7 +950,7 @@
}
MULTI void i_concatenate(DEFAULT value) {
- PMC * const meth = find_meth(INTERP, value, "__concat");
+ PMC * const meth = _LuaAny_find_meth(INTERP, value, "__concat");
if (meth) {
SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP", SELF, value);
@@ -972,9 +979,8 @@
*/
METHOD PMC* get_metatable() {
- PMC *retval = Parrot_find_global_s(INTERP,
- Parrot_str_new_constant(INTERP, "string"),
- Parrot_str_new_constant(INTERP, "mt_string"));
+ PMC *retval = _LuaString_get_metatable(INTERP);
+
if (!retval)
retval = pmc_new(INTERP, dynpmc_LuaNil);
Modified: trunk/languages/lua/src/pmc/luatable.pmc
==============================================================================
--- trunk/languages/lua/src/pmc/luatable.pmc Mon Feb 9 20:49:35 2009 (r36505)
+++ trunk/languages/lua/src/pmc/luatable.pmc Mon Feb 9 21:02:32 2009 (r36506)
@@ -23,6 +23,11 @@
#include "lua_private.h"
+PMC *
+_LuaTable_get_metatable(PARROT_INTERP, PMC *obj) {
+ return PMC_metadata(obj);
+}
+
#define LUA_ASSERT(c, s) assert(((void)(s), (c)))
#define PMC_hash(s) (LuaHash *)PMC_struct_val((s))
@@ -508,7 +513,7 @@
if (pvalue)
value = *pvalue;
else {
- PMC * const meth = find_meth(INTERP, SELF, "__index");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__index");
if (meth) {
if (dynpmc_LuaFunction == PMC_type(meth)) {
value = Parrot_runops_fromc_args(INTERP, meth, "PPP",
@@ -536,7 +541,7 @@
*/
VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
if (! lua_get(INTERP, PMC_hash(SELF), key)) {
- PMC * const meth = find_meth(INTERP, SELF, "__newindex");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__newindex");
if (meth) {
if (dynpmc_LuaFunction == PMC_type(meth)) {
Parrot_runops_fromc_args(INTERP, meth, "vPPP", SELF,
@@ -605,7 +610,7 @@
*/
MULTI INTVAL is_equal(LuaTable value) {
- PMC * const meth = find_meth(INTERP, SELF, "__eq");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__eq");
if (meth) {
PMC * const retval = Parrot_runops_fromc_args(INTERP, meth, "PPP",
SELF, value);
@@ -632,7 +637,7 @@
*/
MULTI INTVAL cmp(LuaTable value) {
#if 0
- PMC * const meth = find_meth(INTERP, SELF, "__cmp");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__cmp");
if (meth) {
PMC * const retval = Parrot_runops_fromc_args(INTERP, meth, "PPP",
SELF, value);
@@ -641,7 +646,7 @@
return (INTVAL)VTABLE_get_number(INTERP, retval);
}
#else
- PMC * const _lt = find_meth(INTERP, SELF, "__lt");
+ PMC * const _lt = _LuaAny_find_meth(INTERP, SELF, "__lt");
if (_lt) {
PMC *retval = Parrot_runops_fromc_args(INTERP, _lt, "PPP",
@@ -651,7 +656,7 @@
if (r)
return (INTVAL)-1;
else {
- PMC * const _le = find_meth(INTERP, SELF, "__le");
+ PMC * const _le = _LuaAny_find_meth(INTERP, SELF, "__le");
if (_le) {
retval = Parrot_runops_fromc_args(INTERP, _le, "PPP",
SELF, value);
@@ -701,7 +706,7 @@
*/
METHOD PMC* get_metatable() {
- PMC *retval = PMC_metadata(SELF);
+ PMC *retval = _LuaUserdata_get_metatable(INTERP, SELF);
if (!retval)
retval = pmc_new(INTERP, dynpmc_LuaNil);
Modified: trunk/languages/lua/src/pmc/luauserdata.pmc
==============================================================================
--- trunk/languages/lua/src/pmc/luauserdata.pmc Mon Feb 9 20:49:35 2009 (r36505)
+++ trunk/languages/lua/src/pmc/luauserdata.pmc Mon Feb 9 21:02:32 2009 (r36506)
@@ -24,6 +24,11 @@
#define u_val(pmc) (PARROT_LUAUSERDATA(pmc))->val
#define u_env(pmc) (PARROT_LUAUSERDATA(pmc))->env
+PMC *
+_LuaUserdata_get_metatable(PARROT_INTERP, PMC *obj) {
+ return PMC_metadata(obj);
+}
+
static PMC* curr_func(PARROT_INTERP) {
Parrot_Context *sub_ctx = CONTEXT(interp)->caller_ctx;
while (1) {
@@ -107,7 +112,7 @@
*/
VTABLE void destroy() {
Parrot_LuaUserdata_attributes *u = PARROT_LUAUSERDATA(SELF);
- PMC * const meth = find_meth(INTERP, SELF, "__gc");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__gc");
if (meth)
(void)Parrot_runops_fromc_args(INTERP, meth, "vP", SELF);
@@ -205,7 +210,7 @@
*/
MULTI INTVAL is_equal(LuaUserdata value) {
- PMC * const meth = find_meth(INTERP, SELF, "__eq");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__eq");
if (meth) {
PMC *retval = Parrot_runops_fromc_args(INTERP, meth, "PPP",
SELF, value);
@@ -231,7 +236,7 @@
*/
MULTI INTVAL cmp(LuaUserdata value) {
#if 0
- PMC * const meth = find_meth(INTERP, SELF, "__cmp");
+ PMC * const meth = _LuaAny_find_meth(INTERP, SELF, "__cmp");
if (meth) {
PMC *retval = Parrot_runops_fromc_args(INTERP, meth, "PPP",
SELF, value);
@@ -240,7 +245,7 @@
return (INTVAL)VTABLE_get_number(INTERP, retval);
}
#else
- PMC * const _lt = find_meth(INTERP, SELF, "__lt");
+ PMC * const _lt = _LuaAny_find_meth(INTERP, SELF, "__lt");
if (_lt) {
PMC *retval = Parrot_runops_fromc_args(INTERP, _lt, "PPP",
@@ -250,7 +255,7 @@
if (r)
return (INTVAL)-1;
else {
- PMC * const _le = find_meth(INTERP, SELF, "__le");
+ PMC * const _le = _LuaAny_find_meth(INTERP, SELF, "__le");
if (_le) {
retval = Parrot_runops_fromc_args(INTERP, _le, "PPP",
SELF, value);
@@ -316,7 +321,7 @@
*/
METHOD PMC* get_metatable() {
- PMC *retval = PMC_metadata(SELF);
+ PMC *retval = _LuaUserdata_get_metatable(INTERP, SELF);
if (!retval)
retval = pmc_new(INTERP, dynpmc_LuaNil);
More information about the parrot-commits
mailing list