Example #1
0
        public LuaFunction CreateFunction(object target, MethodBase function)
        {
            int newTop = LuaDLL.lua_gettop(this.L);
            LuaMethodWrapper @object = new LuaMethodWrapper(this.translator, target, function.DeclaringType, function);

            this.translator.push(this.L, new LuaCSFunction(@object.call));
            object      object2 = this.translator.getObject(this.L, -1);
            LuaFunction result  = (!(object2 is LuaCSFunction)) ? ((LuaFunction)object2) : new LuaFunction((LuaCSFunction)object2, this);

            LuaDLL.lua_settop(this.L, newTop);
            return(result);
        }
Example #2
0
        public LuaFunction RegisterFunction(string path, object target, MethodBase function)
        {
            int newTop = LuaDLL.lua_gettop(this.L);
            LuaMethodWrapper @object = new LuaMethodWrapper(this.translator, target, function.DeclaringType, function);

            this.translator.push(this.L, new LuaCSFunction(@object.call));
            this[path] = this.translator.getObject(this.L, -1);
            LuaFunction function2 = this.GetFunction(path);

            LuaDLL.lua_settop(this.L, newTop);
            return(function2);
        }
Example #3
0
        /*
         * Registers an object's method as a Lua function (global or table field)
         * The method may have any signature
         */
        public LuaFunction RegisterFunction(string path, object target, MethodBase function /*MethodInfo function*/)          //CP: Fix for struct constructor by Alexander Kappner (link: http://luaforge.net/forum/forum.php?thread_id = 2859&forum_id = 145)
        {
            // We leave nothing on the stack when we are done
            int oldTop  = LuaLib.lua_gettop(luaState);
            var wrapper = new LuaMethodWrapper(translator, target, function.DeclaringType, function);

            translator.push(luaState, new LuaCore.lua_CFunction(wrapper.call));
            this[path] = translator.getObject(luaState, -1);
            var f = GetFunction(path);

            LuaLib.lua_settop(luaState, oldTop);
            return(f);
        }
Example #4
0
        /*
         * Registers an object's method as a Lua function (global or table field)
         * The method may have any signature
         */
        public LuaFunction RegisterFunction(string path, object target, MethodInfo function)
        {
            // We leave nothing on the stack when we are done
            int oldTop = LuaDLL.lua_gettop(luaState);

            LuaMethodWrapper wrapper = new LuaMethodWrapper(translator, target, function.DeclaringType, function);

            translator.push(luaState, new LuaCSFunction(wrapper.call));

            this[path] = translator.getObject(luaState, -1);
            LuaFunction f = GetFunction(path);

            LuaDLL.lua_settop(luaState, oldTop);

            return(f);
        }
Example #5
0
        public LuaFunction CreateFunction(object target, MethodBase function /*MethodInfo function*/)          //CP: Fix for struct constructor by Alexander Kappner (link: http://luaforge.net/forum/forum.php?thread_id=2859&forum_id=145)
        {
            // We leave nothing on the stack when we are done
            int oldTop = LuaDLL.lua_gettop(L);

            LuaMethodWrapper wrapper = new LuaMethodWrapper(translator, target, function.DeclaringType, function);

            translator.push(L, new LuaCSFunction(wrapper.call));

            object      obj = translator.getObject(L, -1);
            LuaFunction f   = (obj is LuaCSFunction ? new LuaFunction((LuaCSFunction)obj, this) : (LuaFunction)obj);

            LuaDLL.lua_settop(L, oldTop);

            return(f);
        }
Example #6
0
		public LuaFunction CreateFunction(object target, MethodBase function /*MethodInfo function*/)  //CP: Fix for struct constructor by Alexander Kappner (link: http://luaforge.net/forum/forum.php?thread_id=2859&forum_id=145)
        {
            // We leave nothing on the stack when we are done
            int oldTop = LuaDLL.lua_gettop(L);

            LuaMethodWrapper wrapper=new LuaMethodWrapper(translator,target,function.DeclaringType,function);
            translator.push(L,new LuaCSFunction(wrapper.call));
			
			object obj = translator.getObject(L,-1);
			LuaFunction f = (obj is LuaCSFunction ? new LuaFunction((LuaCSFunction)obj,this) : (LuaFunction)obj);

            LuaDLL.lua_settop(L, oldTop);

            return f;
        }
Example #7
0
        //CP: Fix for struct constructor by Alexander Kappner (link: http://luaforge.net/forum/forum.php?thread_id=2859&forum_id=145)
        /*
         * Registers an object's method as a Lua function (global or table field)
         * The method may have any signature
         */
        public LuaFunction RegisterFunction(string path, object target, MethodBase function /*MethodInfo function*/)
        {
            // We leave nothing on the stack when we are done
            int oldTop = LuaDLL.lua_gettop(luaState);

            LuaMethodWrapper wrapper=new LuaMethodWrapper(translator,target,function.DeclaringType,function);
            translator.push(luaState, new KopiLua.Lua.lua_CFunction(wrapper.call));

            this[path]=translator.getObject(luaState,-1);
            LuaFunction f = GetFunction(path);

            LuaDLL.lua_settop(luaState, oldTop);

            return f;
        }
Example #8
0
 public LuaFunction RegisterFunction(string path, object target, MethodBase function)
 {
     int newTop = LuaJIT.lua_gettop(this.luaState);
     LuaMethodWrapper wrapper = new LuaMethodWrapper(this.translator, target, function.DeclaringType, function);
     this.translator.push(this.luaState, new LuaCSFunction(wrapper.call));
     this[path] = this.translator.getObject(this.luaState, -1);
     LuaFunction function2 = this.GetFunction(path);
     LuaJIT.lua_settop(this.luaState, newTop);
     return function2;
 }
Example #9
0
		/*
		 * Registers an object's method as a Lua function (global or table field)
		 * The method may have any signature
		 */
        public LuaFunction RegisterFunction(string path, object target, MethodBase function /*MethodInfo function*/)  //CP: Fix for struct constructor by Alexander Kappner (link: http://luaforge.net/forum/forum.php?thread_id=2859&forum_id=145)
		{
            // We leave nothing on the stack when we are done
            int oldTop = LuaDLL.lua_gettop(luaState);
            
			LuaMethodWrapper wrapper=new LuaMethodWrapper(translator,target,function.DeclaringType,function);
			translator.push(luaState,new LuaCSFunction(wrapper.call));

			this[path]=translator.getObject(luaState,-1);
            LuaFunction f = GetFunction(path);

            LuaDLL.lua_settop(luaState, oldTop);

            return f;
		}
Example #10
0
 /*
  * Registers an object's method as a Lua function (global or table field)
  * The method may have any signature
  */
 public LuaFunction RegisterFunction(string path, object target,MethodInfo function)
 {
     LuaMethodWrapper wrapper=new LuaMethodWrapper(translator,target,function.DeclaringType,function);
     int oldTop=LuaDLL.lua_gettop(luaState);
     translator.push(luaState,new LuaCSFunction(wrapper.call));
     this[path]=translator.getObject(luaState,-1);
     return GetFunction(path);
 }