LuaInterface.ObjectTranslator.push C# (CSharp) Method

push() private method

private push ( IntPtr luaState, object o ) : void
luaState IntPtr
o object
return void
        internal void push(IntPtr luaState, object o)
        {
            if(o==null)
            {
                LuaDLL.lua_pushnil(luaState);
            }
            else if(o is sbyte || o is byte || o is short || o is ushort ||
                o is int || o is uint || o is long || o is float ||
                o is ulong || o is decimal || o is double)
            {
                double d=Convert.ToDouble(o);
                LuaDLL.lua_pushnumber(luaState,d);
            }
            else if(o is char)
            {
                double d = (char)o;
                LuaDLL.lua_pushnumber(luaState,d);
            }
            else if(o is string)
            {
                string str=(string)o;
                LuaDLL.lua_pushstring(luaState,str);
            }
            else if(o is bool)
            {
                bool b=(bool)o;
                LuaDLL.lua_pushboolean(luaState,b);
            }
            else if(IsILua(o))
            {
                (((ILuaGeneratedType)o).__luaInterface_getLuaTable()).push(luaState);
            }
            else if(o is LuaTable)
            {
                ((LuaTable)o).push(luaState);
            }
            else if(o is LuaCSFunction)
            {
                pushFunction(luaState,(LuaCSFunction)o);
            }
            else if(o is LuaFunction)
            {
                ((LuaFunction)o).push(luaState);
            }
            else
            {
                pushObject(luaState,o,"luaNet_metatable");
            }
        }

Usage Example

コード例 #1
0
        //~LuaFunction()
        //{
        //    if (reference != 0)
        //        interpreter.dispose(reference);
        //}

        //bool disposed = false;
        //~LuaFunction()
        //{
        //    Dispose(false);
        //}

        //public void Dispose()
        //{
        //    Dispose(true);
        //    GC.SuppressFinalize(this);
        //}

        //public virtual void Dispose(bool disposeManagedResources)
        //{
        //    if (!this.disposed)
        //    {
        //        if (disposeManagedResources)
        //        {
        //            if (_Reference != 0)
        //                _Interpreter.dispose(_Reference);
        //        }

        //        disposed = true;
        //    }
        //}


        /*
         * Calls the function casting return values to the types
         * in returnTypes
         */
        internal object[] call(object[] args, Type[] returnTypes)
        {
            //return _Interpreter.callFunction(this, args, returnTypes);
            int nArgs  = 0;
            int oldTop = LuaDLL.lua_gettop(L);

            if (!LuaDLL.lua_checkstack(L, args.Length + 6))
            {
                throw new LuaException("Lua stack overflow");
            }
            translator.push(L, this);
            if (args != null)
            {
                nArgs = args.Length;
                for (int i = 0; i < args.Length; i++)
                {
                    translator.push(L, args[i]);
                }
            }
            int error = LuaDLL.lua_pcall(L, nArgs, -1, 0);

            if (error != 0)
            {
                ThrowExceptionFromError(oldTop);
            }

            if (returnTypes != null)
            {
                return(translator.popValues(L, oldTop, returnTypes));
            }
            else
            {
                return(translator.popValues(L, oldTop));
            }
        }
All Usage Examples Of LuaInterface.ObjectTranslator::push