Commit 00eddcac authored by Megax's avatar Megax
Browse files

* Kisebb modositasok.

parent a0afbf36
...@@ -277,8 +277,6 @@ namespace KopiLua ...@@ -277,8 +277,6 @@ namespace KopiLua
public static int lua_rawequal (lua_State L, int index1, int index2) { public static int lua_rawequal (lua_State L, int index1, int index2) {
StkId o1 = index2adr(L, index1); StkId o1 = index2adr(L, index1);
StkId o2 = index2adr(L, index2); StkId o2 = index2adr(L, index2);
Console.WriteLine("lua_rawequal: {0}", (o1 == luaO_nilobject || o2 == luaO_nilobject));
Console.WriteLine("lua_rawequal2: {0}", luaO_rawequalObj(o1, o2));
return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
: luaO_rawequalObj(o1, o2); : luaO_rawequalObj(o1, o2);
} }
...@@ -392,11 +390,10 @@ namespace KopiLua ...@@ -392,11 +390,10 @@ namespace KopiLua
public static uint lua_touserdata2 (lua_State L, int idx) { public static uint lua_touserdata2 (lua_State L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
Console.WriteLine("x0:{0}", o);
switch (ttype(o)) { switch (ttype(o)) {
case LUA_TUSERDATA: Console.WriteLine("x:{0}", rawuvalue(o).len); return (rawuvalue(o).len); case LUA_TUSERDATA: return (rawuvalue(o).len);
case LUA_TLIGHTUSERDATA: Console.WriteLine("x2:{0}", rawuvalue(o).len); return (rawuvalue(o).len); case LUA_TLIGHTUSERDATA: return (rawuvalue(o).len);
default: Console.WriteLine("x3:{0}", 0); return 0; default: return 0;
} }
} }
...@@ -556,7 +553,6 @@ namespace KopiLua ...@@ -556,7 +553,6 @@ namespace KopiLua
} }
public static void lua_getfield (lua_State L, int idx, CharPtr k) { public static void lua_getfield (lua_State L, int idx, CharPtr k) {
Console.WriteLine("lllll:{0}", k);
StkId t; StkId t;
TValue key = new TValue(); TValue key = new TValue();
lua_lock(L); lua_lock(L);
...@@ -624,7 +620,6 @@ namespace KopiLua ...@@ -624,7 +620,6 @@ namespace KopiLua
res = 1; res = 1;
} }
lua_unlock(L); lua_unlock(L);
Console.WriteLine("nulllll: {0}", res);
return res; return res;
} }
...@@ -835,7 +830,6 @@ namespace KopiLua ...@@ -835,7 +830,6 @@ namespace KopiLua
api_checkvalidindex(L, o); api_checkvalidindex(L, o);
func = savestack(L, o); func = savestack(L, o);
} }
Console.WriteLine("func:{0}", func);
c.func = L.top - (nargs+1); /* function to be called */ c.func = L.top - (nargs+1); /* function to be called */
c.nresults = nresults; c.nresults = nresults;
status = luaD_pcall(L, f_call, c, savestack(L, c.func), func); status = luaD_pcall(L, f_call, c, savestack(L, c.func), func);
......
...@@ -758,7 +758,6 @@ namespace KopiLua ...@@ -758,7 +758,6 @@ namespace KopiLua
public static int luaO_rawequalObj (TValue t1, TValue t2) { public static int luaO_rawequalObj (TValue t1, TValue t2) {
Console.WriteLine("luaO_rawequalObj: {0}", ttype(t1) != ttype(t2));
if (ttype(t1) != ttype(t2)) return 0; if (ttype(t1) != ttype(t2)) return 0;
else switch (ttype(t1)) { else switch (ttype(t1)) {
case LUA_TNIL: case LUA_TNIL:
...@@ -771,9 +770,6 @@ namespace KopiLua ...@@ -771,9 +770,6 @@ namespace KopiLua
return pvalue(t1) == pvalue(t2) ? 1 : 0; return pvalue(t1) == pvalue(t2) ? 1 : 0;
default: default:
lua_assert(iscollectable(t1)); lua_assert(iscollectable(t1));
Console.WriteLine("luaO_rawequalObj1-0: {0}", gcvalue(t1));
Console.WriteLine("luaO_rawequalObj1-1: {0}", gcvalue(t2));
Console.WriteLine("luaO_rawequalObj1: {0}", gcvalue(t1) == gcvalue(t2));
return gcvalue(t1) == gcvalue(t2) ? 1 : 0; return gcvalue(t1) == gcvalue(t2) ? 1 : 0;
} }
} }
......
...@@ -107,7 +107,6 @@ namespace KopiLua ...@@ -107,7 +107,6 @@ namespace KopiLua
} }
//return newlstr(L, str, l, h); /* not found */ //return newlstr(L, str, l, h); /* not found */
TString res = newlstr(L, str, l, h); TString res = newlstr(L, str, l, h);
Console.WriteLine(res);
return res; return res;
} }
......
...@@ -237,11 +237,8 @@ namespace LuaInterface ...@@ -237,11 +237,8 @@ namespace LuaInterface
public object[] DoFile(string fileName) public object[] DoFile(string fileName)
{ {
int oldTop=KopiLua.Lua.lua_gettop(luaState); int oldTop=KopiLua.Lua.lua_gettop(luaState);
//Console.WriteLine("aaa: {0}",oldTop);
if(KopiLua.Lua.luaL_loadfile(luaState,fileName)==0) if(KopiLua.Lua.luaL_loadfile(luaState,fileName)==0)
{ {
//Console.WriteLine("aaa2: {0}",KopiLua.Lua.lua_pcall(luaState, 0, -1, 0));
//Console.WriteLine("zzzzzzzzzzzzzzzzzz");
if (KopiLua.Lua.lua_pcall(luaState, 0, -1, 0) == 0) if (KopiLua.Lua.lua_pcall(luaState, 0, -1, 0) == 0)
return translator.popValues(luaState, oldTop); return translator.popValues(luaState, oldTop);
else else
...@@ -348,7 +345,8 @@ namespace LuaInterface ...@@ -348,7 +345,8 @@ namespace LuaInterface
public LuaFunction GetFunction(string fullPath) public LuaFunction GetFunction(string fullPath)
{ {
object obj=this[fullPath]; object obj=this[fullPath];
return (obj is KopiLua.Lua.lua_CFunction ? new LuaFunction((KopiLua.Lua.lua_CFunction)obj,this) : (LuaFunction)obj); //return (obj is KopiLua.Lua.lua_CFunction ? new LuaFunction((KopiLua.Lua.lua_CFunction)obj,this) : (LuaFunction)obj);
return (obj is KopiLua.Lua.lua_CFunction ? new LuaFunction((KopiLua.Lua.lua_CFunction)obj,this) : /*(LuaFunction)*/new LuaFunction(obj.GetHashCode(), this));
} }
/* /*
* Gets a function global variable as a delegate of * Gets a function global variable as a delegate of
...@@ -533,7 +531,7 @@ namespace LuaInterface ...@@ -533,7 +531,7 @@ namespace LuaInterface
* Registers an object's method as a Lua function (global or table field) * Registers an object's method as a Lua function (global or table field)
* The method may have any signature * The method may have any signature
*/ */
public LuaFunction RegisterFunction(string path, object target,MethodInfo function) public LuaFunction RegisterFunction(string path, object target,MethodInfo function)
{ {
// We leave nothing on the stack when we are done // We leave nothing on the stack when we are done
int oldTop = KopiLua.Lua.lua_gettop(luaState); int oldTop = KopiLua.Lua.lua_gettop(luaState);
...@@ -545,7 +543,6 @@ namespace LuaInterface ...@@ -545,7 +543,6 @@ namespace LuaInterface
LuaFunction f = GetFunction(path); LuaFunction f = GetFunction(path);
KopiLua.Lua.lua_settop(luaState, oldTop); KopiLua.Lua.lua_settop(luaState, oldTop);
return f; return f;
} }
......
...@@ -270,7 +270,7 @@ namespace LuaWrap ...@@ -270,7 +270,7 @@ namespace LuaWrap
public static int luanet_rawnetobj(Lua.lua_State luaState,int obj) public static int luanet_rawnetobj(Lua.lua_State luaState,int obj)
{ {
int udata= Convert.ToInt32(Lua.lua_touserdata2(luaState, obj)); int udata= (int)Lua.lua_touserdata2(luaState, obj);
if(udata!=0) if(udata!=0)
return udata; return udata;
return -1; return -1;
...@@ -284,25 +284,19 @@ namespace LuaWrap ...@@ -284,25 +284,19 @@ namespace LuaWrap
public static int checkudata_raw(Lua.lua_State luaState, int ud, string tname) public static int checkudata_raw(Lua.lua_State luaState, int ud, string tname)
{ {
int p = (int)Lua.lua_touserdata2(luaState, ud); int p = (int)Lua.lua_touserdata2(luaState, ud);
Console.WriteLine("z:{0}", p);
if(p != 0) if(p != 0)
{ {
/* value is a userdata? */ /* value is a userdata? */
Console.WriteLine("z0:{0}", p);
//Console.WriteLine("z2:{0}", Lua.lua_getmetatable(luaState, ud));
if(Lua.lua_getmetatable(luaState, ud)!=0) if(Lua.lua_getmetatable(luaState, ud)!=0)
{ {
/* does it have a metatable? */ /* does it have a metatable? */
Console.WriteLine("z1:{0}", p);
Lua.lua_getfield(luaState, (int)PseudoIndex.Registry, tname); /* get correct metatable */ Lua.lua_getfield(luaState, (int)PseudoIndex.Registry, tname); /* get correct metatable */
//Console.WriteLine("z3:{0}", p);
bool isEqual = Lua.lua_rawequal(luaState, -1, -2).ToBoolean(); bool isEqual = Lua.lua_rawequal(luaState, -1, -2).ToBoolean();
Console.WriteLine("z2:{0}", p);
Console.WriteLine("z2-1:{0}", isEqual);
// NASTY - we need our own version of the lua_pop macro // NASTY - we need our own version of the lua_pop macro
// lua_pop(L, 2); /* remove both metatables */ // lua_pop(L, 2); /* remove both metatables */
Lua.lua_settop(luaState, -(2) - 1); Lua.lua_settop(luaState, -(2) - 1);
Console.WriteLine("z3:{0}", p);
if(isEqual) /* does it have the correct mt? */ if(isEqual) /* does it have the correct mt? */
return p; return p;
} }
...@@ -330,29 +324,23 @@ Console.WriteLine("z3:{0}", p); ...@@ -330,29 +324,23 @@ Console.WriteLine("z3:{0}", p);
{ {
int udata; int udata;
Console.WriteLine("asd:"+(Lua.lua_type(luaState, index).ToLuaType() == LuaType.UserData).ToString());
Console.WriteLine("asd:1"+Lua.lua_type(luaState, index));
if(Lua.lua_type(luaState, index).ToLuaType() == LuaType.UserData) if(Lua.lua_type(luaState, index).ToLuaType() == LuaType.UserData)
{ {
if(luaL_checkmetatable(luaState, index)) if(luaL_checkmetatable(luaState, index))
{ {
udata = (int)Lua.lua_touserdata2(luaState, index); udata = (int)Lua.lua_touserdata2(luaState, index);
Console.WriteLine("asd0:{0}",udata);
if(udata != 0) if(udata != 0)
return udata; return udata;
} }
udata = checkudata_raw(luaState, index, "luaNet_class"); udata = checkudata_raw(luaState, index, "luaNet_class");
Console.WriteLine("asd2:{0}",udata);
if(udata != 0) if(udata != 0)
return udata; return udata;
udata = checkudata_raw(luaState, index, "luaNet_searchbase"); udata = checkudata_raw(luaState, index, "luaNet_searchbase");
Console.WriteLine("asd3:{0}",udata);
if(udata != 0) if(udata != 0)
return udata; return udata;
udata = checkudata_raw(luaState, index, "luaNet_function"); udata = checkudata_raw(luaState, index, "luaNet_function");
Console.WriteLine("asd4:{0}",udata);
if(udata != 0) if(udata != 0)
return udata; return udata;
} }
......
This diff is collapsed.
...@@ -106,13 +106,15 @@ namespace LuaInterface ...@@ -106,13 +106,15 @@ namespace LuaInterface
object targetObject=target; object targetObject=target;
bool failedCall=true; bool failedCall=true;
int nReturnValues=0; int nReturnValues=0;
Console.WriteLine("asyyyyyyyyyyyyyy");
if(!KopiLua.Lua.lua_checkstack(luaState,5).ToBoolean()) if(!KopiLua.Lua.lua_checkstack(luaState,5).ToBoolean())
throw new LuaException("Lua stack overflow"); throw new LuaException("Lua stack overflow");
Console.WriteLine("asyyyyyyyyyyyyyy1");
bool isStatic = (bindingType & BindingFlags.Static) == BindingFlags.Static; bool isStatic = (bindingType & BindingFlags.Static) == BindingFlags.Static;
Console.WriteLine("asyyyyyyyyyyyyyy2");
SetPendingException(null); SetPendingException(null);
Console.WriteLine("asyyyyyyyyyyyyyy3");
Console.WriteLine(methodToCall==null);
if(methodToCall==null) // Method from name if(methodToCall==null) // Method from name
{ {
if (isStatic) if (isStatic)
...@@ -120,6 +122,9 @@ namespace LuaInterface ...@@ -120,6 +122,9 @@ namespace LuaInterface
else else
targetObject=extractTarget(luaState,1); targetObject=extractTarget(luaState,1);
//KopiLua.Lua.lua_remove(luaState,1); // Pops the receiver //KopiLua.Lua.lua_remove(luaState,1); // Pops the receiver
Console.WriteLine("asdxxxxxx");
Console.WriteLine(lastCalledMethod.cachedMethod);
Console.WriteLine(lastCalledMethod.cachedMethod!=null);
if(lastCalledMethod.cachedMethod!=null) // Cached? if(lastCalledMethod.cachedMethod!=null) // Cached?
{ {
int numStackToSkip = isStatic ? 0 : 1; // If this is an instance invoe we will have an extra arg on the stack for the targetObject int numStackToSkip = isStatic ? 0 : 1; // If this is an instance invoe we will have an extra arg on the stack for the targetObject
...@@ -131,6 +136,8 @@ namespace LuaInterface ...@@ -131,6 +136,8 @@ namespace LuaInterface
throw new LuaException("Lua stack overflow"); throw new LuaException("Lua stack overflow");
try try
{ {
Console.WriteLine("0");
Console.WriteLine(lastCalledMethod.argTypes.Length);
for(int i=0;i<lastCalledMethod.argTypes.Length;i++) for(int i=0;i<lastCalledMethod.argTypes.Length;i++)
{ {
lastCalledMethod.args[lastCalledMethod.argTypes[i].index]= lastCalledMethod.args[lastCalledMethod.argTypes[i].index]=
...@@ -142,12 +149,14 @@ namespace LuaInterface ...@@ -142,12 +149,14 @@ namespace LuaInterface
throw new LuaException("argument number "+(i+1)+" is invalid"); throw new LuaException("argument number "+(i+1)+" is invalid");
} }
} }
Console.WriteLine("asd");
if((bindingType & BindingFlags.Static)==BindingFlags.Static) if((bindingType & BindingFlags.Static)==BindingFlags.Static)
{ {
translator.push(luaState,lastCalledMethod.cachedMethod.Invoke(null,lastCalledMethod.args)); translator.push(luaState,lastCalledMethod.cachedMethod.Invoke(null,lastCalledMethod.args));
} }
else else
{ {
Console.WriteLine("asd2");
if(lastCalledMethod.cachedMethod.IsConstructor) if(lastCalledMethod.cachedMethod.IsConstructor)
translator.push(luaState,((ConstructorInfo)lastCalledMethod.cachedMethod).Invoke(lastCalledMethod.args)); translator.push(luaState,((ConstructorInfo)lastCalledMethod.cachedMethod).Invoke(lastCalledMethod.args));
else else
......
...@@ -618,6 +618,7 @@ namespace LuaInterface ...@@ -618,6 +618,7 @@ namespace LuaInterface
if(udata!=-1) if(udata!=-1)
return objects[udata]; return objects[udata];
else else
//return null;
return getUserData(luaState,index); return getUserData(luaState,index);
} }
default: default:
...@@ -749,7 +750,6 @@ namespace LuaInterface ...@@ -749,7 +750,6 @@ namespace LuaInterface
{ {
// Make sure we are _really_ ILuaGenerated // Make sure we are _really_ ILuaGenerated
Type typ = o.GetType(); Type typ = o.GetType();
return (typ.GetInterface("ILuaGeneratedType") != null); return (typ.GetInterface("ILuaGeneratedType") != null);
} }
else else
......
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