Esempio n. 1
0
        internal static Dictionary <ManagedType, InterDomainContext> RestoreRuntimeData(RuntimeDataStorage storage)
        {
            cache = storage.GetValue <Dictionary <MaybeType, ClassBase> >("cache");
            var invalidClasses = new List <KeyValuePair <MaybeType, ClassBase> >();
            var contexts       = storage.GetValue <Dictionary <IntPtr, InterDomainContext> >("contexts");
            var loadedObjs     = new Dictionary <ManagedType, InterDomainContext>();

            foreach (var pair in cache)
            {
                if (!pair.Key.Valid)
                {
                    invalidClasses.Add(pair);
                    continue;
                }
                // re-init the class
                InitClassBase(pair.Key.Value, pair.Value);
                // We modified the Type object, notify it we did.
                Runtime.PyType_Modified(pair.Value.tpHandle);
                var context = contexts[pair.Value.pyHandle];
                pair.Value.Load(context);
                loadedObjs.Add(pair.Value, context);
            }

            foreach (var pair in invalidClasses)
            {
                cache.Remove(pair.Key);
                Runtime.XDecref(pair.Value.pyHandle);
            }

            return(loadedObjs);
        }
Esempio n. 2
0
        internal static void RestoreRuntimeData(RuntimeDataStorage storage)
        {
            InitImport();
            storage.GetValue("py_clr_module", out py_clr_module);
            var rootHandle = storage.GetValue <IntPtr>("root");

            root = (CLRModule)ManagedType.GetManagedObject(rootHandle);
        }
Esempio n. 3
0
        internal static void RestoreRuntimeData(RuntimeDataStorage storage)
        {
            storage.GetValue("py_clr_module", out py_clr_module);
            var rootHandle = storage.GetValue <IntPtr>("root");

            root = (CLRModule)ManagedType.GetManagedObject(rootHandle);
            BorrowedReference dict = Runtime.PyImport_GetModuleDict();

            Runtime.PyDict_SetItemString(dict, "clr", ClrModuleReference);
            SetupNamespaceTracking();
        }
Esempio n. 4
0
 internal static void RestoreRuntimeData(RuntimeDataStorage storage)
 {
     Debug.Assert(cache == null || cache.Count == 0);
     storage.GetValue("slots", out _slotsImpls);
     storage.GetValue("cache", out cache);
     foreach (var entry in cache)
     {
         Type        type   = entry.Key;
         IntPtr      handle = entry.Value;
         SlotsHolder holder = CreateSolotsHolder(handle);
         InitializeSlots(handle, _slotsImpls[type], holder);
         // FIXME: mp_length_slot.CanAssgin(clrType)
     }
 }
Esempio n. 5
0
        internal static Dictionary <ManagedType, InterDomainContext> RestoreRuntimeData(RuntimeDataStorage storage)
        {
            cache = storage.GetValue <Dictionary <Type, ClassBase> >("cache");
            var contexts   = storage.GetValue <Dictionary <IntPtr, InterDomainContext> >("contexts");
            var loadedObjs = new Dictionary <ManagedType, InterDomainContext>();

            foreach (var cls in cache.Values)
            {
                var context = contexts[cls.pyHandle];
                cls.Load(context);
                loadedObjs.Add(cls, context);
            }
            return(loadedObjs);
        }
Esempio n. 6
0
 internal static void RestoreRuntimeData(RuntimeDataStorage storage)
 {
     Debug.Assert(cache == null || cache.Count == 0);
     storage.GetValue("slots", out _slotsImpls);
     storage.GetValue <Dictionary <MaybeType, IntPtr> >("cache", out var _cache);
     foreach (var entry in _cache)
     {
         if (!entry.Key.Valid)
         {
             Runtime.XDecref(entry.Value);
             continue;
         }
         Type   type   = entry.Key.Value;;
         IntPtr handle = entry.Value;
         cache[type] = handle;
         SlotsHolder holder = CreateSolotsHolder(handle);
         InitializeSlots(handle, _slotsImpls[type], holder);
         // FIXME: mp_length_slot.CanAssgin(clrType)
     }
 }
Esempio n. 7
0
        internal static Dictionary <ManagedType, InterDomainContext> RestoreRuntimeData(RuntimeDataStorage storage)
        {
            cache = storage.GetValue <Dictionary <MaybeType, ClassBase> >("cache");
            var invalidClasses = new List <KeyValuePair <MaybeType, ClassBase> >();
            var contexts       = storage.GetValue <Dictionary <IntPtr, InterDomainContext> >("contexts");
            var loadedObjs     = new Dictionary <ManagedType, InterDomainContext>();

            foreach (var pair in cache)
            {
                if (!pair.Key.Valid)
                {
                    invalidClasses.Add(pair);
                    continue;
                }
                // Ensure, that matching Python type exists first.
                // It is required for self-referential classes
                // (e.g. with members, that refer to the same class)
                var pyType = InitPyType(pair.Key.Value, pair.Value);
                // re-init the class
                InitClassBase(pair.Key.Value, pair.Value, pyType);
                // We modified the Type object, notify it we did.
                Runtime.PyType_Modified(pair.Value.TypeReference);
                var context = contexts[pair.Value.pyHandle];
                pair.Value.Load(context);
                var slotsHolder = TypeManager.GetSlotsHolder(pyType);
                pair.Value.InitializeSlots(slotsHolder);
                Runtime.PyType_Modified(pair.Value.TypeReference);
                loadedObjs.Add(pair.Value, context);
            }

            foreach (var pair in invalidClasses)
            {
                cache.Remove(pair.Key);
                Runtime.XDecref(pair.Value.pyHandle);
            }

            return(loadedObjs);
        }