GetPreModule() public static method

public static GetPreModule ( IntPtr L, Type t ) : LuaCSFunction
L System.IntPtr
t System.Type
return LuaCSFunction
Example #1
0
        public static void PushValue(IntPtr L, ValueType v)
        {
            if (v == null)
            {
                LuaDLL.lua_pushnil(L);
                return;
            }
            Type             type             = v.GetType();
            int              metaReference    = LuaStatic.GetMetaReference(L, type);
            ObjectTranslator objectTranslator = ObjectTranslator.Get(L);

            if (metaReference > 0)
            {
                int index = objectTranslator.AddObject(v);
                LuaDLL.tolua_pushnewudata(L, metaReference, index);
            }
            else
            {
                LuaCSFunction preModule = LuaStatic.GetPreModule(L, type);
                if (preModule != null)
                {
                    preModule(L);
                    metaReference = LuaStatic.GetMetaReference(L, type);
                    if (metaReference > 0)
                    {
                        int index2 = objectTranslator.AddObject(v);
                        LuaDLL.tolua_pushnewudata(L, metaReference, index2);
                        return;
                    }
                }
                LuaDLL.lua_pushnil(L);
                Debugger.LogError("Type {0} not wrap to lua", LuaMisc.GetTypeName(type));
            }
        }
Example #2
0
        private static void PushPreLoadType(IntPtr L, object o, Type type)
        {
            LuaCSFunction preModule = LuaStatic.GetPreModule(L, type);

            if (preModule != null)
            {
                ToLua.LuaPCall(L, preModule);
                int metaReference = LuaStatic.GetMetaReference(L, type);
                if (metaReference > 0)
                {
                    ToLua.PushUserData(L, o, metaReference);
                    return;
                }
            }
            LuaDLL.lua_pushnil(L);
            Debugger.LogError("Type {0} not wrap to lua", LuaMisc.GetTypeName(type));
        }
Example #3
0
        public static void PushValue(IntPtr L, ValueType v)
        {
            if (v == null)
            {
                LuaDLL.lua_pushnil(L);
                return;
            }

            Type             type       = v.GetType();
            int              reference  = LuaStatic.GetMetaReference(L, type);
            ObjectTranslator translator = ObjectTranslator.Get(L);

            if (reference > 0)
            {
                int index = translator.AddObject(v);
                LuaDLL.tolua_pushnewudata(L, reference, index);
            }
            else
            {
                LuaCSFunction LuaOpenLib = LuaStatic.GetPreModule(L, type);

                if (LuaOpenLib != null)
                {
#if UNITY_EDITOR
                    Debugger.LogWarning("register PreLoad type {0} to lua", LuaMisc.GetTypeName(type));
#endif
                    LuaOpenLib(L);
                    reference = LuaStatic.GetMetaReference(L, type);

                    if (reference > 0)
                    {
                        int index = translator.AddObject(v);
                        LuaDLL.tolua_pushnewudata(L, reference, index);
                        return;
                    }
                }

                //类型未Wrap
                LuaDLL.lua_pushnil(L);
                Debugger.LogError("Type {0} not wrap to lua", LuaMisc.GetTypeName(type));
            }
        }
Example #4
0
        static void PushPreLoadType(IntPtr L, object o, Type type)
        {
            LuaCSFunction LuaOpenLib = LuaStatic.GetPreModule(L, type);

            if (LuaOpenLib != null)
            {
#if UNITY_EDITOR
                Debugger.LogWarning("register PreLoad type {0} to lua", LuaMisc.GetTypeName(type));
#endif
                LuaPCall(L, LuaOpenLib);
                int reference = LuaStatic.GetMetaReference(L, type);

                if (reference > 0)
                {
                    PushUserData(L, o, reference);
                    return;
                }
            }

            //类型未Wrap
            LuaDLL.lua_pushnil(L);
            Debugger.LogError("Type {0} not wrap to lua", LuaMisc.GetTypeName(type));
        }