| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,14 +82,14 @@ private static int OnVisit(IntPtr ob, IntPtr arg) | |||
| 82 | 82 | } | |
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | - internal static void StashPush(Stack stack) | ||
| 85 | + internal static void StashPush(RuntimeDataStorage storage) | ||
| 86 | 86 | { | |
| 87 | - stack.Push(cache); | ||
| 87 | + storage.PushValue(cache); | ||
| 88 | 88 | } | |
| 89 | 89 | ||
| 90 | - internal static void StashPop(Stack stack) | ||
| 90 | + internal static void StashPop(RuntimeDataStorage storage) | ||
| 91 | 91 | { | |
| 92 | - cache = (Dictionary<Type, ClassBase>)stack.Pop(); | ||
| 92 | + cache = storage.PopValue<Dictionary<Type, ClassBase>>(); | ||
| 93 | 93 | } | |
| 94 | 94 | ||
| 95 | 95 | /// <summary> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,10 @@ internal CLRObject(object ob, IntPtr tp) | |||
| 35 | 35 | Exceptions.SetArgsAndCause(py); | |
| 36 | 36 | } | |
| 37 | 37 | ||
| 38 | + protected CLRObject() | ||
| 39 | + { | ||
| 40 | + } | ||
| 41 | + | ||
| 38 | 42 | ||
| 39 | 43 | internal static CLRObject GetInstance(object ob, IntPtr pyType) | |
| 40 | 44 | { | |
@@ -70,6 +74,18 @@ internal static IntPtr GetInstHandle(object ob) | |||
| 70 | 74 | return co.pyHandle; | |
| 71 | 75 | } | |
| 72 | 76 | ||
| 77 | + internal static CLRObject Restore(object ob, IntPtr pyHandle) | ||
| 78 | + { | ||
| 79 | + CLRObject co = new CLRObject() | ||
| 80 | + { | ||
| 81 | + inst = ob, | ||
| 82 | + pyHandle = pyHandle, | ||
| 83 | + tpHandle = Runtime.PyObject_TYPE(pyHandle) | ||
| 84 | + }; | ||
| 85 | + co.Load(); | ||
| 86 | + return co; | ||
| 87 | + } | ||
| 88 | + | ||
| 73 | 89 | protected override void OnSave() | |
| 74 | 90 | { | |
| 75 | 91 | base.OnSave(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -564,15 +564,15 @@ public ThunkInfo(Delegate target) | |||
| 564 | 564 | } | |
| 565 | 565 | } | |
| 566 | 566 | ||
| 567 | - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] | ||
| 567 | + [StructLayout(LayoutKind.Sequential)] | ||
| 568 | 568 | struct PyGC_Node | |
| 569 | 569 | { | |
| 570 | 570 | public IntPtr gc_next; | |
| 571 | 571 | public IntPtr gc_prev; | |
| 572 | 572 | public IntPtr gc_refs; | |
| 573 | 573 | } | |
| 574 | 574 | ||
| 575 | - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] | ||
| 575 | + [StructLayout(LayoutKind.Sequential)] | ||
| 576 | 576 | struct PyGC_Head | |
| 577 | 577 | { | |
| 578 | 578 | public PyGC_Node gc; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,15 +40,15 @@ public static void Release() | |||
| 40 | 40 | _metaSlotsHodler = null; | |
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | - internal static void StashPush(Stack stack) | ||
| 43 | + internal static void StashPush(RuntimeDataStorage storage) | ||
| 44 | 44 | { | |
| 45 | 45 | Runtime.XIncref(PyCLRMetaType); | |
| 46 | - stack.Push(PyCLRMetaType); | ||
| 46 | + storage.PushValue(PyCLRMetaType); | ||
| 47 | 47 | } | |
| 48 | 48 | ||
| 49 | - internal static IntPtr StashPop(Stack stack) | ||
| 49 | + internal static IntPtr StashPop(RuntimeDataStorage storage) | ||
| 50 | 50 | { | |
| 51 | - PyCLRMetaType = (IntPtr)stack.Pop(); | ||
| 51 | + PyCLRMetaType = storage.PopValue<IntPtr>(); | ||
| 52 | 52 | _metaSlotsHodler = new SlotsHolder(PyCLRMetaType); | |
| 53 | 53 | TypeManager.InitializeSlots(PyCLRMetaType, typeof(MetaType), _metaSlotsHodler); | |
| 54 | 54 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -206,7 +206,10 @@ internal static void Initialize(bool initSigs = false, ShutdownMode mode = Shutd | |||
| 206 | 206 | string rtdir = RuntimeEnvironment.GetRuntimeDirectory(); | |
| 207 | 207 | IntPtr path = PySys_GetObject("path"); | |
| 208 | 208 | IntPtr item = PyString_FromString(rtdir); | |
| 209 | - PyList_Append(path, item); | ||
| 209 | + if (PySequence_Contains(path, item) == 0) | ||
| 210 | + { | ||
| 211 | + PyList_Append(path, item); | ||
| 212 | + } | ||
| 210 | 213 | XDecref(item); | |
| 211 | 214 | AssemblyManager.UpdatePath(); | |
| 212 | 215 | } | |
@@ -364,12 +367,7 @@ internal static void Shutdown() | |||
| 364 | 367 | AssemblyManager.Shutdown(); | |
| 365 | 368 | ImportHook.Shutdown(); | |
| 366 | 369 | ||
| 367 | - #if !NETSTANDARD | ||
| 368 | - if (mode != ShutdownMode.Reload) | ||
| 369 | - { | ||
| 370 | - ClearClrModules(); | ||
| 371 | - } | ||
| 372 | - #endif | ||
| 370 | + ClearClrModules(); | ||
| 373 | 371 | RemoveClrRootModule(); | |
| 374 | 372 | ||
| 375 | 373 | MoveClrInstancesOnwershipToPython(); | |
@@ -454,8 +452,7 @@ private static void ClearClrModules() | |||
| 454 | 452 | var item = PyList_GetItem(items, i); | |
| 455 | 453 | var name = PyTuple_GetItem(item, 0); | |
| 456 | 454 | var module = PyTuple_GetItem(item, 1); | |
| 457 | - var clrModule = ManagedType.GetManagedObject(module); | ||
| 458 | - if (clrModule != null) | ||
| 455 | + if (ManagedType.IsManagedType(module)) | ||
| 459 | 456 | { | |
| 460 | 457 | PyDict_DelItem(modules, name); | |
| 461 | 458 | } | |
@@ -486,8 +483,8 @@ private static void PyDictTryDelItem(IntPtr dict, string key) | |||
| 486 | 483 | ||
| 487 | 484 | private static void MoveClrInstancesOnwershipToPython() | |
| 488 | 485 | { | |
| 489 | - var copyObjs = ManagedType.GetManagedObjects().ToArray(); | ||
| 490 | 486 | var objs = ManagedType.GetManagedObjects(); | |
| 487 | + var copyObjs = objs.ToArray(); | ||
| 491 | 488 | foreach (var entry in copyObjs) | |
| 492 | 489 | { | |
| 493 | 490 | ManagedType obj = entry.Key; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments