Exemplo n.º 1
0
        public static void PrintAllGlobalClasses()
        {
            var hEnviroment = XLLuaRuntime.XLLRT_GetEnv(null);
            var hEnum       = XLLRT_BeginEnumGlobalClass(hEnviroment);
            var luaClass    = new XLLRTClass();
            var luaClassPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(XLLRTClass)));

            while (XLLRT_GetNextGlobalClass(hEnum, luaClassPtr))
            {
                luaClass = (XLLRTClass)Marshal.PtrToStructure(luaClassPtr, typeof(XLLRTClass));
                if (!luaClass.className.Contains("Tree"))
                {
                    continue;
                }
                Console.WriteLine("name={0}", luaClass.className);

                var luaAPIPtr       = luaClass.MemberFunctions;
                var pClassMemberPos = luaAPIPtr;
                var luaAPI          = (XLLRTGlobalAPI)Marshal.PtrToStructure(pClassMemberPos, typeof(XLLRTGlobalAPI));
                var i = 1;
                while (luaAPI.funName != null)
                {
                    Console.WriteLine("name={0}", luaAPI.funName);

                    var pos = luaAPIPtr.ToInt32() + i * GLOBAL_API_SIZE;
                    pClassMemberPos = new IntPtr(pos);
                    luaAPI          = (XLLRTGlobalAPI)Marshal.PtrToStructure(pClassMemberPos, typeof(XLLRTGlobalAPI));
                    i++;
                }
                break;
            }
            XLLRT_EndEnum(hEnum);
        }
Exemplo n.º 2
0
        public static void PrintAllGlobalClasses()
        {
            var hEnviroment = XLLuaRuntime.XLLRT_GetEnv(null);
            var hEnum = XLLRT_BeginEnumGlobalClass(hEnviroment);
            var luaClass = new XLLRTClass();
            var luaClassPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(XLLRTClass)));
            while (XLLRT_GetNextGlobalClass(hEnum, luaClassPtr))
            {
                luaClass = (XLLRTClass)Marshal.PtrToStructure(luaClassPtr, typeof(XLLRTClass));
                if (!luaClass.className.Contains("Tree")) continue;
                Console.WriteLine("name={0}", luaClass.className);

                var luaAPIPtr = luaClass.MemberFunctions;
                var pClassMemberPos = luaAPIPtr;
                var luaAPI = (XLLRTGlobalAPI)Marshal.PtrToStructure(pClassMemberPos, typeof(XLLRTGlobalAPI));
                var i = 1;
                while (luaAPI.funName != null)
                {
                    Console.WriteLine("name={0}", luaAPI.funName);

                    var pos = luaAPIPtr.ToInt32() + i * GLOBAL_API_SIZE;
                    pClassMemberPos = new IntPtr(pos);
                    luaAPI = (XLLRTGlobalAPI)Marshal.PtrToStructure(pClassMemberPos, typeof(XLLRTGlobalAPI));
                    i++;
                }
                break;
            }
            XLLRT_EndEnum(hEnum);
        }