XLLRT_GetEnv() private method

private XLLRT_GetEnv ( [ pstrEnvName ) : IntPtr
pstrEnvName [
return System.IntPtr
Ejemplo 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);
        }
Ejemplo n.º 2
0
        protected IntPtr GetLuaRuntime()
        {
            //var pNull = new IntPtr(0);
            var hEnviroment = XLLuaRuntime.XLLRT_GetEnv(null);
            var hRuntime    = XLLuaRuntime.XLLRT_GetRuntime(hEnviroment, null);

            return(hRuntime);
        }
Ejemplo n.º 3
0
        public static void PrintAllGlobalMethods()
        {
            var hEnviroment = XLLuaRuntime.XLLRT_GetEnv(null);
            var hEnum       = XLLRT_BeginEnumGlobalAPI(hEnviroment);
            var luaAPI      = new XLLRTGlobalAPI();
            var luaAPIPtr   = Marshal.AllocHGlobal(GLOBAL_API_SIZE);

            while (XLLRT_GetNextGlobalAPI(hEnum, luaAPIPtr))
            {
                luaAPI = (XLLRTGlobalAPI)Marshal.PtrToStructure(luaAPIPtr, typeof(XLLRTGlobalAPI));
                Console.WriteLine("name={0}", luaAPI.funName);
            }
            XLLRT_EndEnum(hEnum);
        }
Ejemplo n.º 4
0
        public static void Register()
        {
            //
            //0、得到Lua环境句柄
            //
            var pNull       = new IntPtr(0);
            var hEnviroment = XLLuaRuntime.XLLRT_GetEnv(null);

            switch (_createPolicy)
            {
            case CreatePolicy.Factory:
                //1、注册类型工厂
                XLLuaRuntime.RegisterGlobalObject(hEnviroment, new XLRTObjectInfo
                {
                    ClassName   = _typeFactoryClassName,
                    ObjectName  = _typeFactoryObjectName,
                    UserData    = pNull,
                    GetFunction = _lua_GetClassFactoryInstance,
                    Methods     = new SortedList <string, LuaCFunction> {
                        { "CreateInstance", _lua_CreateInstance }
                    }
                });

                //2、注册类型
                XLLuaRuntime.RegisterClass(hEnviroment, new XLRTClassInfo
                {
                    ClassName       = _typeFullName,
                    FatherClassName = null,
                    DeleteFunction  = _lua_DeleteInstance,
                    Methods         = _lua_functions
                });
                return;

            case CreatePolicy.Singleton:
                //1、注册单例对象
                XLLuaRuntime.RegisterGlobalObject(hEnviroment, new XLRTObjectInfo
                {
                    ClassName   = _typeFullName,
                    ObjectName  = _typeFullName,
                    UserData    = pNull,
                    GetFunction = _lua_GetClassFactoryInstance,
                    Methods     = _lua_functions
                });
                return;

            default:
                throw new Exception("UnSupport CreatePolicy!");
            }
        }
Ejemplo n.º 5
0
        public static void Register()
        {
            //
            //0、得到Lua环境句柄
            //
            //var pNull = new IntPtr(0);
            var hEnviroment = XLLuaRuntime.XLLRT_GetEnv(null);

            //1、注册类型
            XLLuaRuntime.RegisterClass(hEnviroment, new XLRTClassInfo
            {
                ClassName       = _typeFullName,
                FatherClassName = null,
                DeleteFunction  = _lua_DeleteInstance,
                Methods         = _lua_functions
            });
        }