"tests/vscode:/vscode.git/clone" did not exist on "26370dd22f55b571955750a7f06e2de07e2a8f20"
Commit b969a882 authored by Megax's avatar Megax
Browse files

* Project fajlok at lettek alakitva. Igy most mindegyik normalisan hasznalhato...

* Project fajlok at lettek alakitva. Igy most mindegyik normalisan hasznalhato forditasnal. Nincsenek hibak. KopiLua-ba kerult egy fix. Nem ertem mitol jott elo az a hiba ami elojott de most van a kodban (vagy is volt mert fixaltam).
parent d7bb0c93
This diff is collapsed.
This diff is collapsed.
/* /*
** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ ** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** Tag methods ** Tag methods
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace KopiLua namespace KopiLua
{ {
using TValue = Lua.lua_TValue; using TValue = Lua.lua_TValue;
public partial class Lua public partial class Lua
{ {
/* /*
* WARNING: if you change the order of this enumeration, * WARNING: if you change the order of this enumeration,
* grep "ORDER TM" * grep "ORDER TM"
*/ */
public enum TMS { public enum TMS {
TM_INDEX, TM_INDEX,
TM_NEWINDEX, TM_NEWINDEX,
TM_GC, TM_GC,
TM_MODE, TM_MODE,
TM_EQ, /* last tag method with `fast' access */ TM_EQ, /* last tag method with `fast' access */
TM_ADD, TM_ADD,
TM_SUB, TM_SUB,
TM_MUL, TM_MUL,
TM_DIV, TM_DIV,
TM_MOD, TM_MOD,
TM_POW, TM_POW,
TM_UNM, TM_UNM,
TM_LEN, TM_LEN,
TM_LT, TM_LT,
TM_LE, TM_LE,
TM_CONCAT, TM_CONCAT,
TM_CALL, TM_CALL,
TM_N /* number of elements in the enum */ TM_N /* number of elements in the enum */
}; };
public static TValue gfasttm(global_State g, Table et, TMS e) public static TValue gfasttm(global_State g, Table et, TMS e)
{ {
return (et == null) ? null : return (et == null) ? null :
((et.flags & (1 << (int)e)) != 0) ? null : ((et.flags & (1 << (int)e)) != 0) ? null :
luaT_gettm(et, e, g.tmname[(int)e]); luaT_gettm(et, e, g.tmname[(int)e]);
} }
public static TValue fasttm(lua_State l, Table et, TMS e) {return gfasttm(G(l), et, e);} public static TValue fasttm(lua_State l, Table et, TMS e) {return gfasttm(G(l), et, e);}
public readonly static CharPtr[] luaT_typenames = { public readonly static CharPtr[] luaT_typenames = {
"nil", "boolean", "userdata", "number", "nil", "boolean", "userdata", "number",
"string", "table", "function", "userdata", "thread", "string", "table", "function", "userdata", "thread",
"proto", "upval" "proto", "upval"
}; };
private readonly static CharPtr[] luaT_eventname = { /* ORDER TM */ private readonly static CharPtr[] luaT_eventname = { /* ORDER TM */
"__index", "__newindex", "__index", "__newindex",
"__gc", "__mode", "__eq", "__gc", "__mode", "__eq",
"__add", "__sub", "__mul", "__div", "__mod", "__add", "__sub", "__mul", "__div", "__mod",
"__pow", "__unm", "__len", "__lt", "__le", "__pow", "__unm", "__len", "__lt", "__le",
"__concat", "__call" "__concat", "__call"
}; };
public static void luaT_init (lua_State L) { public static void luaT_init (lua_State L) {
int i; int i;
for (i=0; i<(int)TMS.TM_N; i++) { for (i=0; i<(int)TMS.TM_N; i++) {
G(L).tmname[i] = luaS_new(L, luaT_eventname[i]); G(L).tmname[i] = luaS_new(L, luaT_eventname[i]);
luaS_fix(G(L).tmname[i]); /* never collect these names */ luaS_fix(G(L).tmname[i]); /* never collect these names */
} }
} }
/* /*
** function to be used with macro "fasttm": optimized for absence of ** function to be used with macro "fasttm": optimized for absence of
** tag methods ** tag methods
*/ */
public static TValue luaT_gettm (Table events, TMS event_, TString ename) { public static TValue luaT_gettm (Table events, TMS event_, TString ename) {
/*const*/ TValue tm = luaH_getstr(events, ename); /*const*/ TValue tm = luaH_getstr(events, ename);
lua_assert(event_ <= TMS.TM_EQ); lua_assert(event_ <= TMS.TM_EQ);
if (ttisnil(tm)) { /* no tag method? */ if (ttisnil(tm)) { /* no tag method? */
events.flags |= (byte)(1<<(int)event_); /* cache this fact */ events.flags |= (byte)(1<<(int)event_); /* cache this fact */
return null; return null;
} }
else return tm; else return tm;
} }
public static TValue luaT_gettmbyobj (lua_State L, TValue o, TMS event_) { public static TValue luaT_gettmbyobj (lua_State L, TValue o, TMS event_) {
Table mt; Table mt;
switch (ttype(o)) { switch (ttype(o)) {
case LUA_TTABLE: case LUA_TTABLE:
mt = hvalue(o).metatable; mt = hvalue(o).metatable;
break; break;
case LUA_TUSERDATA: case LUA_TUSERDATA:
mt = uvalue(o).metatable; mt = uvalue(o).metatable;
break; break;
default: default:
mt = G(L).mt[ttype(o)]; mt = G(L).mt[ttype(o)];
break; break;
} }
return ((mt!=null) ? luaH_getstr(mt, G(L).tmname[(int)event_]) : luaO_nilobject); Console.WriteLine("mt: " + (mt!=null).ToString());
} return ((mt!=null) ? luaH_getstr(mt, G(L).tmname[(int)event_]) : luaO_nilobject);
}
}
} }
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment