Commit 5866945e authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Un-nest LuaNativeFunction

Fixed build
Fixed iOS Build.
parent 2e501577
Subproject commit 48ed86961855816ef88d6a7486c3248e389f4317 Subproject commit 0e3dd8c9cf04ef6f7bbef7d9605c925b40789343
Subproject commit 922e92fa41c960e02023c258874ea81810884c6c Subproject commit 4e1378477c5a6f9fc22f0a62b5fce3dd62613341
...@@ -42,11 +42,13 @@ namespace NLua ...@@ -42,11 +42,13 @@ namespace NLua
using LuaState = KopiLua.LuaState; using LuaState = KopiLua.LuaState;
using LuaHook = KopiLua.LuaHook; using LuaHook = KopiLua.LuaHook;
using LuaDebug = KopiLua.LuaDebug; using LuaDebug = KopiLua.LuaDebug;
using LuaNativeFunction = KopiLua.LuaNativeFunction;
#else #else
using LuaCore = KeraLua.Lua; using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState; using LuaState = KeraLua.LuaState;
using LuaHook = KeraLua.LuaHook; using LuaHook = KeraLua.LuaHook;
using LuaDebug = KeraLua.LuaDebug; using LuaDebug = KeraLua.LuaDebug;
using LuaNativeFunction = KeraLua.LuaNativeFunction;
#endif #endif
/* /*
...@@ -93,7 +95,7 @@ namespace NLua ...@@ -93,7 +95,7 @@ namespace NLua
/// </summary> /// </summary>
public bool IsExecuting { get { return executing; } } public bool IsExecuting { get { return executing; } }
private LuaCore.LuaNativeFunction panicCallback; private LuaNativeFunction panicCallback;
private ObjectTranslator translator; private ObjectTranslator translator;
/// <summary> /// <summary>
/// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects /// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects
...@@ -273,7 +275,7 @@ end ...@@ -273,7 +275,7 @@ end
LuaLib.LuaLOpenLibs (luaState); // steffenj: Lua 5.1.1 API change (luaopen_base is gone, just open all libs right here) LuaLib.LuaLOpenLibs (luaState); // steffenj: Lua 5.1.1 API change (luaopen_base is gone, just open all libs right here)
Init (); Init ();
// We need to keep this in a managed reference so the delegate doesn't get garbage collected // We need to keep this in a managed reference so the delegate doesn't get garbage collected
panicCallback = new LuaCore.LuaNativeFunction (PanicCallback); panicCallback = new LuaNativeFunction (PanicCallback);
LuaLib.LuaAtPanic (luaState, panicCallback); LuaLib.LuaAtPanic (luaState, panicCallback);
} }
...@@ -329,7 +331,7 @@ end ...@@ -329,7 +331,7 @@ end
} }
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int PanicCallback (LuaState luaState) static int PanicCallback (LuaState luaState)
...@@ -587,7 +589,7 @@ end ...@@ -587,7 +589,7 @@ end
private void RegisterGlobal (string path, Type type, int recursionCounter) private void RegisterGlobal (string path, Type type, int recursionCounter)
{ {
// If the type is a global method, list it directly // If the type is a global method, list it directly
if (type == typeof(LuaCore.LuaNativeFunction)) { if (type == typeof(LuaNativeFunction)) {
// Format for easy method invocation // Format for easy method invocation
globals.Add (path + "("); globals.Add (path + "(");
} }
...@@ -709,7 +711,7 @@ end ...@@ -709,7 +711,7 @@ end
public LuaFunction GetFunction (string fullPath) public LuaFunction GetFunction (string fullPath)
{ {
object obj = this [fullPath]; object obj = this [fullPath];
return (obj is LuaCore.LuaNativeFunction ? new LuaFunction ((LuaCore.LuaNativeFunction)obj, this) : (LuaFunction)obj); return (obj is LuaNativeFunction ? new LuaFunction ((LuaNativeFunction)obj, this) : (LuaFunction)obj);
} }
/* /*
...@@ -996,7 +998,7 @@ end ...@@ -996,7 +998,7 @@ end
/// <author>Reinhard Ostermeier</author> /// <author>Reinhard Ostermeier</author>
/// ///
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_Hook))] [MonoTouch.MonoPInvokeCallback (typeof (LuaHook))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static void DebugHookCallback (LuaState luaState, LuaDebug luaDebug) private static void DebugHookCallback (LuaState luaState, LuaDebug luaDebug)
...@@ -1136,7 +1138,7 @@ end ...@@ -1136,7 +1138,7 @@ end
// We leave nothing on the stack when we are done // We leave nothing on the stack when we are done
int oldTop = LuaLib.LuaGetTop (luaState); int oldTop = LuaLib.LuaGetTop (luaState);
var wrapper = new LuaMethodWrapper (translator, target, function.DeclaringType, function); var wrapper = new LuaMethodWrapper (translator, target, function.DeclaringType, function);
translator.Push (luaState, new LuaCore.LuaNativeFunction (wrapper.invokeFunction)); translator.Push (luaState, new LuaNativeFunction (wrapper.invokeFunction));
this [path] = translator.GetObject (luaState, -1); this [path] = translator.GetObject (luaState, -1);
var f = GetFunction (path); var f = GetFunction (path);
LuaLib.LuaSetTop (luaState, oldTop); LuaLib.LuaSetTop (luaState, oldTop);
...@@ -1156,7 +1158,7 @@ end ...@@ -1156,7 +1158,7 @@ end
return (equal != 0); return (equal != 0);
} }
internal void PushCSFunction (LuaCore.LuaNativeFunction function) internal void PushCSFunction (LuaNativeFunction function)
{ {
translator.PushFunction (luaState, function); translator.PushFunction (luaState, function);
} }
......
...@@ -32,14 +32,16 @@ namespace NLua ...@@ -32,14 +32,16 @@ namespace NLua
#if USE_KOPILUA #if USE_KOPILUA
using LuaCore = KopiLua.Lua; using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState; using LuaState = KopiLua.LuaState;
using LuaNativeFunction = KopiLua.LuaNativeFunction;
#else #else
using LuaCore = KeraLua.Lua; using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState; using LuaState = KeraLua.LuaState;
using LuaNativeFunction = KeraLua.LuaNativeFunction;
#endif #endif
public class LuaFunction : LuaBase public class LuaFunction : LuaBase
{ {
internal LuaCore.LuaNativeFunction function; internal LuaNativeFunction function;
public LuaFunction (int reference, Lua interpreter) public LuaFunction (int reference, Lua interpreter)
{ {
...@@ -48,7 +50,7 @@ namespace NLua ...@@ -48,7 +50,7 @@ namespace NLua
_Interpreter = interpreter; _Interpreter = interpreter;
} }
public LuaFunction (LuaCore.LuaNativeFunction function, Lua interpreter) public LuaFunction (LuaNativeFunction function, Lua interpreter)
{ {
_Reference = 0; _Reference = 0;
this.function = function; this.function = function;
......
...@@ -30,16 +30,21 @@ using NLua.Extensions; ...@@ -30,16 +30,21 @@ using NLua.Extensions;
namespace NLua namespace NLua
{ {
#if USE_KOPILUA #if USE_KOPILUA
using LuaCore = KopiLua.Lua; using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState; using LuaState = KopiLua.LuaState;
using LuaTag = KopiLua.LuaTag; using LuaTag = KopiLua.LuaTag;
using LuaNativeFunction = KopiLua.LuaNativeFunction;
#else #else
using LuaCore = KeraLua.Lua; using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState; using LuaState = KeraLua.LuaState;
using LuaTag = KeraLua.LuaTag; using LuaTag = KeraLua.LuaTag;
using LuaNativeFunction = KeraLua.LuaNativeFunction;
#endif #endif
public class LuaLib public class LuaLib
{ {
public static int LuaGC (LuaState luaState, GCOptions what, int data) public static int LuaGC (LuaState luaState, GCOptions what, int data)
...@@ -284,7 +289,7 @@ namespace NLua ...@@ -284,7 +289,7 @@ namespace NLua
LuaCore.LuaCall (luaState, nArgs, nResults); LuaCore.LuaCall (luaState, nArgs, nResults);
} }
public static void LuaPushStdCallCFunction (LuaState luaState, LuaCore.LuaNativeFunction function) public static void LuaPushStdCallCFunction (LuaState luaState, LuaNativeFunction function)
{ {
LuaCore.LuaPushStdCallCFunction (luaState, function); LuaCore.LuaPushStdCallCFunction (luaState, function);
} }
...@@ -294,7 +299,7 @@ namespace NLua ...@@ -294,7 +299,7 @@ namespace NLua
return LuaCore.LuaNetPCall (luaState, nArgs, nResults, errfunc); return LuaCore.LuaNetPCall (luaState, nArgs, nResults, errfunc);
} }
public static LuaCore.LuaNativeFunction LuaToCFunction (LuaState luaState, int index) public static LuaNativeFunction LuaToCFunction (LuaState luaState, int index)
{ {
return LuaCore.LuaToCFunction (luaState, index); return LuaCore.LuaToCFunction (luaState, index);
} }
...@@ -331,9 +336,9 @@ namespace NLua ...@@ -331,9 +336,9 @@ namespace NLua
return "0"; // Because luaV_tostring does this return "0"; // Because luaV_tostring does this
} }
public static void LuaAtPanic (LuaState luaState, LuaCore.LuaNativeFunction panicf) public static void LuaAtPanic (LuaState luaState, LuaNativeFunction panicf)
{ {
LuaCore.LuaAtPanic (luaState, (LuaCore.LuaNativeFunction)panicf); LuaCore.LuaAtPanic (luaState, (LuaNativeFunction)panicf);
} }
......
...@@ -33,9 +33,11 @@ namespace NLua ...@@ -33,9 +33,11 @@ namespace NLua
#if USE_KOPILUA #if USE_KOPILUA
using LuaCore = KopiLua.Lua; using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState; using LuaState = KopiLua.LuaState;
using LuaNativeFunction = KopiLua.LuaNativeFunction;
#else #else
using LuaCore = KeraLua.Lua; using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState; using LuaState = KeraLua.LuaState;
using LuaNativeFunction = KeraLua.LuaNativeFunction;
#endif #endif
/* /*
...@@ -102,8 +104,8 @@ namespace NLua ...@@ -102,8 +104,8 @@ namespace NLua
{ {
object obj = _Interpreter.RawGetObject (_Reference, field); object obj = _Interpreter.RawGetObject (_Reference, field);
if (obj is LuaCore.LuaNativeFunction) if (obj is LuaNativeFunction)
return new LuaFunction ((LuaCore.LuaNativeFunction)obj, _Interpreter); return new LuaFunction ((LuaNativeFunction)obj, _Interpreter);
else else
return obj; return obj;
} }
......
...@@ -37,9 +37,11 @@ namespace NLua ...@@ -37,9 +37,11 @@ namespace NLua
#if USE_KOPILUA #if USE_KOPILUA
using LuaCore = KopiLua.Lua; using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState; using LuaState = KopiLua.LuaState;
using LuaNativeFunction = KopiLua.LuaNativeFunction;
#else #else
using LuaCore = KeraLua.Lua; using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState; using LuaState = KeraLua.LuaState;
using LuaNativeFunction = KeraLua.LuaNativeFunction;
#endif #endif
/* /*
...@@ -51,7 +53,7 @@ namespace NLua ...@@ -51,7 +53,7 @@ namespace NLua
*/ */
public class MetaFunctions public class MetaFunctions
{ {
internal LuaCore.LuaNativeFunction gcFunction, indexFunction, newindexFunction, baseIndexFunction, internal LuaNativeFunction gcFunction, indexFunction, newindexFunction, baseIndexFunction,
classIndexFunction, classNewindexFunction, execDelegateFunction, callConstructorFunction, toStringFunction; classIndexFunction, classNewindexFunction, execDelegateFunction, callConstructorFunction, toStringFunction;
private Dictionary<object, object> memberCache = new Dictionary<object, object> (); private Dictionary<object, object> memberCache = new Dictionary<object, object> ();
private ObjectTranslator translator; private ObjectTranslator translator;
...@@ -79,22 +81,22 @@ namespace NLua ...@@ -79,22 +81,22 @@ namespace NLua
public MetaFunctions (ObjectTranslator translator) public MetaFunctions (ObjectTranslator translator)
{ {
this.translator = translator; this.translator = translator;
gcFunction = new LuaCore.LuaNativeFunction (MetaFunctions.CollectObject); gcFunction = new LuaNativeFunction (MetaFunctions.CollectObject);
toStringFunction = new LuaCore.LuaNativeFunction (MetaFunctions.ToStringLua); toStringFunction = new LuaNativeFunction (MetaFunctions.ToStringLua);
indexFunction = new LuaCore.LuaNativeFunction (MetaFunctions.GetMethod); indexFunction = new LuaNativeFunction (MetaFunctions.GetMethod);
newindexFunction = new LuaCore.LuaNativeFunction (MetaFunctions.SetFieldOrProperty); newindexFunction = new LuaNativeFunction (MetaFunctions.SetFieldOrProperty);
baseIndexFunction = new LuaCore.LuaNativeFunction (MetaFunctions.GetBaseMethod); baseIndexFunction = new LuaNativeFunction (MetaFunctions.GetBaseMethod);
callConstructorFunction = new LuaCore.LuaNativeFunction (MetaFunctions.CallConstructor); callConstructorFunction = new LuaNativeFunction (MetaFunctions.CallConstructor);
classIndexFunction = new LuaCore.LuaNativeFunction (MetaFunctions.GetClassMethod); classIndexFunction = new LuaNativeFunction (MetaFunctions.GetClassMethod);
classNewindexFunction = new LuaCore.LuaNativeFunction (MetaFunctions.SetClassFieldOrProperty); classNewindexFunction = new LuaNativeFunction (MetaFunctions.SetClassFieldOrProperty);
execDelegateFunction = new LuaCore.LuaNativeFunction (MetaFunctions.RunFunctionDelegate); execDelegateFunction = new LuaNativeFunction (MetaFunctions.RunFunctionDelegate);
} }
/* /*
* __call metafunction of CLR delegates, retrieves and calls the delegate. * __call metafunction of CLR delegates, retrieves and calls the delegate.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int RunFunctionDelegate (LuaState luaState) private static int RunFunctionDelegate (LuaState luaState)
...@@ -105,7 +107,7 @@ namespace NLua ...@@ -105,7 +107,7 @@ namespace NLua
private static int RunFunctionDelegate (LuaState luaState, ObjectTranslator translator) private static int RunFunctionDelegate (LuaState luaState, ObjectTranslator translator)
{ {
LuaCore.LuaNativeFunction func = (LuaCore.LuaNativeFunction)translator.GetRawNetObject (luaState, 1); LuaNativeFunction func = (LuaNativeFunction)translator.GetRawNetObject (luaState, 1);
LuaLib.LuaRemove (luaState, 1); LuaLib.LuaRemove (luaState, 1);
return func (luaState); return func (luaState);
} }
...@@ -114,7 +116,7 @@ namespace NLua ...@@ -114,7 +116,7 @@ namespace NLua
* __gc metafunction of CLR objects. * __gc metafunction of CLR objects.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int CollectObject (LuaState luaState) private static int CollectObject (LuaState luaState)
...@@ -137,7 +139,7 @@ namespace NLua ...@@ -137,7 +139,7 @@ namespace NLua
* __tostring metafunction of CLR objects. * __tostring metafunction of CLR objects.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int ToStringLua (LuaState luaState) private static int ToStringLua (LuaState luaState)
...@@ -195,7 +197,7 @@ namespace NLua ...@@ -195,7 +197,7 @@ namespace NLua
* If the member does not exist returns nil. * If the member does not exist returns nil.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetMethod (LuaState luaState) private static int GetMethod (LuaState luaState)
...@@ -296,7 +298,7 @@ namespace NLua ...@@ -296,7 +298,7 @@ namespace NLua
* Adds a prefix to the method name to call the base version of the method. * Adds a prefix to the method name to call the base version of the method.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetBaseMethod (LuaState luaState) private static int GetBaseMethod (LuaState luaState)
...@@ -368,8 +370,8 @@ namespace NLua ...@@ -368,8 +370,8 @@ namespace NLua
object cachedMember = CheckMemberCache (memberCache, objType, methodName); object cachedMember = CheckMemberCache (memberCache, objType, methodName);
//object cachedMember=null; //object cachedMember=null;
if (cachedMember is LuaCore.LuaNativeFunction) { if (cachedMember is LuaNativeFunction) {
translator.PushFunction (luaState, (LuaCore.LuaNativeFunction)cachedMember); translator.PushFunction (luaState, (LuaNativeFunction)cachedMember);
translator.Push (luaState, true); translator.Push (luaState, true);
return 2; return 2;
} else if (!cachedMember.IsNull ()) } else if (!cachedMember.IsNull ())
...@@ -447,7 +449,7 @@ namespace NLua ...@@ -447,7 +449,7 @@ namespace NLua
translator.PushType (luaState, nestedType); translator.PushType (luaState, nestedType);
} else { } else {
// Member type must be 'method' // Member type must be 'method'
var wrapper = new LuaCore.LuaNativeFunction ((new LuaMethodWrapper (translator, objType, methodName, bindingType)).invokeFunction); var wrapper = new LuaNativeFunction ((new LuaMethodWrapper (translator, objType, methodName, bindingType)).invokeFunction);
if (cachedMember.IsNull ()) if (cachedMember.IsNull ())
SetMemberCache (memberCache, objType, methodName, wrapper); SetMemberCache (memberCache, objType, methodName, wrapper);
...@@ -518,7 +520,7 @@ namespace NLua ...@@ -518,7 +520,7 @@ namespace NLua
* and error if the assignment is invalid. * and error if the assignment is invalid.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int SetFieldOrProperty (LuaState luaState) private static int SetFieldOrProperty (LuaState luaState)
...@@ -694,7 +696,7 @@ namespace NLua ...@@ -694,7 +696,7 @@ namespace NLua
* __index metafunction of type references, works on static members. * __index metafunction of type references, works on static members.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetClassMethod (LuaState luaState) private static int GetClassMethod (LuaState luaState)
...@@ -736,7 +738,7 @@ namespace NLua ...@@ -736,7 +738,7 @@ namespace NLua
* __newindex function of type references, works on static members. * __newindex function of type references, works on static members.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int SetClassFieldOrProperty (LuaState luaState) private static int SetClassFieldOrProperty (LuaState luaState)
...@@ -767,7 +769,7 @@ namespace NLua ...@@ -767,7 +769,7 @@ namespace NLua
* generates an exception. * generates an exception.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int CallConstructor (LuaState luaState) private static int CallConstructor (LuaState luaState)
......
...@@ -33,9 +33,11 @@ namespace NLua.Method ...@@ -33,9 +33,11 @@ namespace NLua.Method
#if USE_KOPILUA #if USE_KOPILUA
using LuaCore = KopiLua.Lua; using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState; using LuaState = KopiLua.LuaState;
using LuaNativeFunction = KopiLua.LuaNativeFunction;
#else #else
using LuaCore = KeraLua.Lua; using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState; using LuaState = KeraLua.LuaState;
using LuaNativeFunction = KeraLua.LuaNativeFunction;
#endif #endif
/* /*
...@@ -51,7 +53,7 @@ namespace NLua.Method ...@@ -51,7 +53,7 @@ namespace NLua.Method
*/ */
class LuaMethodWrapper class LuaMethodWrapper
{ {
internal LuaCore.LuaNativeFunction invokeFunction; internal LuaNativeFunction invokeFunction;
private ObjectTranslator _Translator; private ObjectTranslator _Translator;
private MethodBase _Method; private MethodBase _Method;
private MethodCache _LastCalledMethod = new MethodCache (); private MethodCache _LastCalledMethod = new MethodCache ();
...@@ -66,7 +68,7 @@ namespace NLua.Method ...@@ -66,7 +68,7 @@ namespace NLua.Method
*/ */
public LuaMethodWrapper (ObjectTranslator translator, object target, IReflect targetType, MethodBase method) public LuaMethodWrapper (ObjectTranslator translator, object target, IReflect targetType, MethodBase method)
{ {
invokeFunction = new LuaCore.LuaNativeFunction (this.Call); invokeFunction = new LuaNativeFunction (this.Call);
_Translator = translator; _Translator = translator;
_Target = target; _Target = target;
...@@ -87,7 +89,7 @@ namespace NLua.Method ...@@ -87,7 +89,7 @@ namespace NLua.Method
*/ */
public LuaMethodWrapper (ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) public LuaMethodWrapper (ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType)
{ {
invokeFunction = new LuaCore.LuaNativeFunction (this.Call); invokeFunction = new LuaNativeFunction (this.Call);
_Translator = translator; _Translator = translator;
_MethodName = methodName; _MethodName = methodName;
......
...@@ -38,9 +38,11 @@ namespace NLua ...@@ -38,9 +38,11 @@ namespace NLua
#if USE_KOPILUA #if USE_KOPILUA
using LuaCore = KopiLua.Lua; using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState; using LuaState = KopiLua.LuaState;
using LuaNativeFunction = KopiLua.LuaNativeFunction;
#else #else
using LuaCore = KeraLua.Lua; using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState; using LuaState = KeraLua.LuaState;
using LuaNativeFunction = KeraLua.LuaNativeFunction;
#endif #endif
/* /*
...@@ -51,7 +53,7 @@ namespace NLua ...@@ -51,7 +53,7 @@ namespace NLua
*/ */
public class ObjectTranslator public class ObjectTranslator
{ {
private LuaCore.LuaNativeFunction registerTableFunction, unregisterTableFunction, getMethodSigFunction, private LuaNativeFunction registerTableFunction, unregisterTableFunction, getMethodSigFunction,
getConstructorSigFunction, importTypeFunction, loadAssemblyFunction; getConstructorSigFunction, importTypeFunction, loadAssemblyFunction;
// object to object # // object to object #
public readonly Dictionary<object, int> objectsBackMap = new Dictionary<object, int> (); public readonly Dictionary<object, int> objectsBackMap = new Dictionary<object, int> ();
...@@ -86,12 +88,12 @@ namespace NLua ...@@ -86,12 +88,12 @@ namespace NLua
metaFunctions = new MetaFunctions (this); metaFunctions = new MetaFunctions (this);
assemblies = new List<Assembly> (); assemblies = new List<Assembly> ();
importTypeFunction = new LuaCore.LuaNativeFunction (ObjectTranslator.ImportType); importTypeFunction = new LuaNativeFunction (ObjectTranslator.ImportType);
loadAssemblyFunction = new LuaCore.LuaNativeFunction (ObjectTranslator.LoadAssembly); loadAssemblyFunction = new LuaNativeFunction (ObjectTranslator.LoadAssembly);
registerTableFunction = new LuaCore.LuaNativeFunction (ObjectTranslator.RegisterTable); registerTableFunction = new LuaNativeFunction (ObjectTranslator.RegisterTable);
unregisterTableFunction = new LuaCore.LuaNativeFunction (ObjectTranslator.UnregisterTable); unregisterTableFunction = new LuaNativeFunction (ObjectTranslator.UnregisterTable);
getMethodSigFunction = new LuaCore.LuaNativeFunction (ObjectTranslator.GetMethodSignature); getMethodSigFunction = new LuaNativeFunction (ObjectTranslator.GetMethodSignature);
getConstructorSigFunction = new LuaCore.LuaNativeFunction (ObjectTranslator.GetConstructorSignature); getConstructorSigFunction = new LuaNativeFunction (ObjectTranslator.GetConstructorSignature);
CreateLuaObjectList (luaState); CreateLuaObjectList (luaState);
CreateIndexingMetaFunction (luaState); CreateIndexingMetaFunction (luaState);
...@@ -251,7 +253,7 @@ namespace NLua ...@@ -251,7 +253,7 @@ namespace NLua
* if the assembly is not found. * if the assembly is not found.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int LoadAssembly (LuaState luaState) private static int LoadAssembly (LuaState luaState)
...@@ -302,7 +304,7 @@ namespace NLua ...@@ -302,7 +304,7 @@ namespace NLua
* type is not found. * type is not found.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int ImportType (LuaState luaState) private static int ImportType (LuaState luaState)
...@@ -330,7 +332,7 @@ namespace NLua ...@@ -330,7 +332,7 @@ namespace NLua
* type passed as second argument in the stack. * type passed as second argument in the stack.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int RegisterTable (LuaState luaState) private static int RegisterTable (LuaState luaState)
...@@ -382,7 +384,7 @@ namespace NLua ...@@ -382,7 +384,7 @@ namespace NLua
* base field, freeing the created object for garbage-collection * base field, freeing the created object for garbage-collection
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int UnregisterTable (LuaState luaState) private static int UnregisterTable (LuaState luaState)
...@@ -427,7 +429,7 @@ namespace NLua ...@@ -427,7 +429,7 @@ namespace NLua
* if no matching method is not found. * if no matching method is not found.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetMethodSignature (LuaState luaState) private static int GetMethodSignature (LuaState luaState)
...@@ -467,7 +469,7 @@ namespace NLua ...@@ -467,7 +469,7 @@ namespace NLua
//CP: Added ignore case //CP: Added ignore case
var method = klass.GetMethod (methodName, BindingFlags.Public | BindingFlags.Static | var method = klass.GetMethod (methodName, BindingFlags.Public | BindingFlags.Static |
BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase, null, signature, null); BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase, null, signature, null);
PushFunction (luaState, new LuaCore.LuaNativeFunction ((new LuaMethodWrapper (this, target, klass, method)).invokeFunction)); PushFunction (luaState, new LuaNativeFunction ((new LuaMethodWrapper (this, target, klass, method)).invokeFunction));
} catch (Exception e) { } catch (Exception e) {
ThrowError (luaState, e); ThrowError (luaState, e);
LuaLib.LuaPushNil (luaState); LuaLib.LuaPushNil (luaState);
...@@ -481,7 +483,7 @@ namespace NLua ...@@ -481,7 +483,7 @@ namespace NLua
* if no matching constructor is found. * if no matching constructor is found.
*/ */
#if MONOTOUCH #if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaCore.lua_CFunction))] [MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif #endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls] [System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetConstructorSignature (LuaState luaState) private static int GetConstructorSignature (LuaState luaState)
...@@ -508,7 +510,7 @@ namespace NLua ...@@ -508,7 +510,7 @@ namespace NLua
try { try {
ConstructorInfo constructor = klass.UnderlyingSystemType.GetConstructor (signature); ConstructorInfo constructor = klass.UnderlyingSystemType.GetConstructor (signature);
PushFunction (luaState, new LuaCore.LuaNativeFunction ((new LuaMethodWrapper (this, null, klass, constructor)).invokeFunction)); PushFunction (luaState, new LuaNativeFunction ((new LuaMethodWrapper (this, null, klass, constructor)).invokeFunction));
} catch (Exception e) { } catch (Exception e) {
ThrowError (luaState, e); ThrowError (luaState, e);
LuaLib.LuaPushNil (luaState); LuaLib.LuaPushNil (luaState);
...@@ -528,7 +530,7 @@ namespace NLua ...@@ -528,7 +530,7 @@ namespace NLua
/* /*
* Pushes a delegate into the stack * Pushes a delegate into the stack
*/ */
internal void PushFunction (LuaState luaState, LuaCore.LuaNativeFunction func) internal void PushFunction (LuaState luaState, LuaNativeFunction func)
{ {
PushObject (luaState, func, "luaNet_function"); PushObject (luaState, func, "luaNet_function");
} }
...@@ -861,8 +863,8 @@ namespace NLua ...@@ -861,8 +863,8 @@ namespace NLua
(((ILuaGeneratedType)o).LuaInterfaceGetLuaTable ()).Push (luaState); (((ILuaGeneratedType)o).LuaInterfaceGetLuaTable ()).Push (luaState);
else if (o is LuaTable) else if (o is LuaTable)
((LuaTable)o).Push (luaState); ((LuaTable)o).Push (luaState);
else if (o is LuaCore.LuaNativeFunction) else if (o is LuaNativeFunction)
PushFunction (luaState, (LuaCore.LuaNativeFunction)o); PushFunction (luaState, (LuaNativeFunction)o);
else if (o is LuaFunction) else if (o is LuaFunction)
((LuaFunction)o).Push (luaState); ((LuaFunction)o).Push (luaState);
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