public static void Wrap(ILuaState L)
    {
        var type = Register(L);

        L.L_GetMetaTable("System.Object");
        L.SetMetaTable(-2);

        s_meta = WrapToLua.GetMetaName(type.FullName);
        L.SetMetaTable(-2);
        L.Pop(1);
    }
예제 #2
0
    public static void Wrap(ILuaState L)
    {
        // 没有类表,只有元表
        L.L_NewMetaTable(WrapToLua.GetMetaName(CLASS));

        // 继承自System.Object
        L.L_GetMetaTable("System.Object");
        L.SetMetaTable(-2);

        L.SetDict("__gc", new LuaCSFunction(MetaMethods.__gc));
        L.SetDict("__tostring", new LuaCSFunction(MetaMethods.__tostring));
        L.SetDict("__index", new LuaCSFunction(__index_Array));
        L.SetDict("__newindex", new LuaCSFunction(__newindex_Array));

        L.RegistMembers(null, new LuaField[] {
            new LuaField("Length", get_Length, null),
        });

        L.Pop(1);
    }
예제 #3
0
    public static void Wrap(ILuaState L)
    {
        // 没有类表,只有元表
        L.L_NewMetaTable(WrapToLua.GetMetaName("System.MonoType"));

        // 继承自System.Object
        L.L_GetMetaTable("System.Object");
        L.SetMetaTable(-2);

        LuaDLL.tolua_setindex(L);
        LuaDLL.tolua_setnewindex(L);
        L.SetDict("__gc", new LuaCSFunction(MetaMethods.__gc));
        L.SetDict("__tostring", new LuaCSFunction(MetaMethods.__tostring));

        L.RegistMembers(new LuaMethod[] {
            new LuaMethod("IsSubclassOf", IsSubclassOf),
        }, null);

        L.Pop(1);
    }
예제 #4
0
    public static void PushUData(this ILuaState self, System.Enum value)
    {
        var type = value.GetType();

        // 自动绑定到Lua
        var typeName = type.FullName.Replace('+', '.');
        var metaName = WrapToLua.GetMetaName(typeName);

        self.L_GetMetaTable(metaName);
        if (self.IsNil(-1))
        {
            Wrap(self, type);
        }

        var name = System.Enum.GetName(type, value);

        //var id = (int)System.Convert.ChangeType(value, typeof(int));

        self.GetGlobal("package", "loaded", type.FullName);
        self.GetField(-1, name);
        self.Remove(-2);
    }