public Lua() { luaState = new LuaState(); Init(); // We need to keep this in a managed reference so the delegate doesn't get garbage collected panicCallback = PanicCallback; luaState.AtPanic(panicCallback); }
private int GetMethodSignatureInternal(LuaState luaState) { ProxyType klass; object target; int udata = luaState.CheckUObject(1, "luaNet_class"); if (udata != -1) { klass = (ProxyType)_objects[udata]; target = null; } else { target = GetRawNetObject(luaState, 1); if (target == null) { ThrowError(luaState, "get_method_bysig: first arg is not type or object reference"); luaState.PushNil(); return(1); } klass = new ProxyType(target.GetType()); } string methodName = luaState.ToString(2, false); var signature = new Type[luaState.GetTop() - 2]; for (int i = 0; i < signature.Length; i++) { signature[i] = FindType(luaState.ToString(i + 3, false)); } try { var method = klass.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, signature); var wrapper = new LuaMethodWrapper(this, target, klass, method); LuaNativeFunction invokeDelegate = wrapper.InvokeFunction; PushFunction(luaState, invokeDelegate); } catch (Exception e) { ThrowError(luaState, e); luaState.PushNil(); } return(1); }
public ObjectTranslator(Lua interpreter, LuaState luaState) { _tagPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int))); this.interpreter = interpreter; typeChecker = new CheckType(this); metaFunctions = new MetaFunctions(this); assemblies = new List <Assembly>(); _importTypeFunction = ImportType; _loadAssemblyFunction = LoadAssembly; _registerTableFunction = RegisterTable; _unregisterTableFunction = UnregisterTable; _getMethodSigFunction = GetMethodSignature; _getConstructorSigFunction = GetConstructorSignature; _ctypeFunction = CType; _enumFromIntFunction = EnumFromInt; CreateLuaObjectList(luaState); CreateIndexingMetaFunction(luaState); CreateBaseClassMetatable(luaState); CreateClassMetatable(luaState); CreateFunctionMetatable(luaState); SetGlobalFunctions(luaState); }
/* * Pushes a delegate into the stack */ internal void PushFunction(LuaState luaState, LuaNativeFunction func) { PushObject(luaState, func, "luaNet_function"); }
public LuaFunction(LuaNativeFunction nativeFunction, Lua interpreter) : base(0) { function = nativeFunction; _Interpreter = interpreter; }
internal void PushCSFunction(LuaNativeFunction function) { translator.PushFunction(luaState, function); }
public LuaFunction(int reference, Lua interpreter) : base(reference) { function = null; _Interpreter = interpreter; }
public LuaFunction(LuaNativeFunction nativeFunction, Lua interpreter) : base(0, interpreter) { function = nativeFunction; }
public LuaFunction(int reference, Lua interpreter) : base(reference, interpreter) { function = null; }
public LuaFunction(LuaNativeFunction nativeFunction, Lua interpreter) { _Reference = 0; function = nativeFunction; _Interpreter = interpreter; }
public LuaFunction(int reference, Lua interpreter) { _Reference = reference; function = null; _Interpreter = interpreter; }