Esempio n. 1
0
        public static int GetIndex(IntPtr luaState)
        {
            var instancePointer = XLLuaRuntime.luaL_checkudata(luaState, 1, _typeFullName);
            var instanceIndex   = new IntPtr(Marshal.ReadInt32(instancePointer));

            return(instanceIndex.ToInt32());
        }
Esempio n. 2
0
        private static int DeleteInstance(IntPtr luaState)
        {
            var instancePointer = XLLuaRuntime.luaL_checkudata(luaState, 1, _typeFullName);
            var instanceIndex   = new IntPtr(Marshal.ReadInt32(instancePointer));

            _instancesDict[instanceIndex.ToInt32()] = default(T);
            _instancesDict.Remove(instanceIndex.ToInt32());
            return(0);
        }
Esempio n. 3
0
        public static T GetInstance(IntPtr luaState)
        {
            switch (_createPolicy)
            {
            case CreatePolicy.Factory:
                var instancePointer = XLLuaRuntime.luaL_checkudata(luaState, 1, _typeFullName);
                var instanceIndex   = new IntPtr(Marshal.ReadInt32(instancePointer));
                var instance        = _instancesDict[instanceIndex.ToInt32()];
                return(instance);

            case CreatePolicy.Singleton:
                return(_instance);

            default:
                return(default(T));
            }
        }