10BC0 Rename StashPush/Pop methods · pythonnet/pythonnet@b52bc01 · GitHub
[go: up one dir, main page]

Skip to content

Commit b52bc01

Browse files
committed
Rename StashPush/Pop methods
Addresses comment: #958
1 parent 3a8c72d commit b52bc01

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

src/runtime/classmanager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,22 @@ private static int OnVisit(IntPtr ob, IntPtr arg)
7777
return 0;
7878
}
7979

80-
internal static void StashPush(RuntimeDataStorage storage)
80+
internal static void SaveRuntimeData(RuntimeDataStorage storage)
8181
{
8282
var contexts = storage.AddValue("contexts",
8383
new Dictionary<IntPtr, InterDomainContext>());
8484
storage.AddValue("cache", cache);
8585
foreach (var cls in cache.Values)
8686
{
8787
// This incref is for cache to hold the cls,
88-
// thus no need for decreasing it at StashPop.
88+
// thus no need for decreasing it at RestoreRuntimeData.
8989
Runtime.XIncref(cls.pyHandle);
9090
var context = contexts[cls.pyHandle] = new InterDomainContext();
9191
cls.Save(context);
9292
}
9393
}
9494

95-
internal static Dictionary<ManagedType, InterDomainContext> StashPop(RuntimeDataStorage storage)
95+
internal static Dictionary<ManagedType, InterDomainContext> RestoreRuntimeData(RuntimeDataStorage storage)
9696
{
9797
cache = storage.GetValue<Dictionary<Type, ClassBase>>("cache");
9898
var contexts = storage.GetValue <Dictionary<IntPtr, InterDomainContext>>("contexts");

src/runtime/importhook.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ internal static void Shutdown()
121121
CLRModule.Reset();
122122
}
123123

124-
internal static void StashPush(RuntimeDataStorage storage)
124+
internal static void SaveRuntimeData(RuntimeDataStorage storage)
125125
{
126126
Runtime.XIncref(py_clr_module);
127127
Runtime.XIncref(root.pyHandle);
128128
storage.AddValue("py_clr_module", py_clr_module);
129129
storage.AddValue("root", root.pyHandle);
130130
}
131131

132-
internal static void StashPop(RuntimeDataStorage storage)
132+
internal static void RestoreRuntimeData(RuntimeDataStorage storage)
133133
{
134134
InitImport();
135135
storage.GetValue("py_clr_module", out py_clr_module);

src/runtime/metatype.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public static void Release()
4040
_metaSlotsHodler = null;
4141
}
4242

43-
internal static void StashPush(RuntimeDataStorage storage)
43+
internal static void SaveRuntimeData(RuntimeDataStorage storage)
4444
{
4545
Runtime.XIncref(PyCLRMetaType);
4646
storage.PushValue(PyCLRMetaType);
4747
}
4848

49-
internal static IntPtr StashPop(RuntimeDataStorage storage)
49+
internal static IntPtr RestoreRuntimeData(RuntimeDataStorage storage)
5050
{
5151
PyCLRMetaType = storage.PopValue<IntPtr>();
5252
_metaSlotsHodler = new SlotsHolder(PyCLRMetaType);

src/runtime/runtime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ internal static void Initialize(bool initSigs = false, ShutdownMode mode = Shutd
172172
#if !NETSTANDARD
173173
if (mode == ShutdownMode.Reload && RuntimeData.HasStashData())
174174
{
175-
RuntimeData.StashPop();
175+
RuntimeData.RestoreRuntimeData();
176176
}
177177
else
178178
#endif

src/runtime/runtime_data.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ public static Type FormatterType
3434
internal static void Stash()
3535
{
3636
var metaStorage = new RuntimeDataStorage();
37-
MetaType.StashPush(metaStorage);
37+
MetaType.SaveRuntimeData(metaStorage);
3838

3939
var importStorage = new RuntimeDataStorage();
40-
ImportHook.StashPush(importStorage);
40+
ImportHook.SaveRuntimeData(importStorage);
4141

4242
var typeStorage = new RuntimeDataStorage();
43-
TypeManager.StashPush(typeStorage);
43+
TypeManager.SaveRuntimeData(typeStorage);
4444

4545
var clsStorage = new RuntimeDataStorage();
46-
ClassManager.StashPush(clsStorage);
46+
ClassManager.SaveRuntimeData(clsStorage);
4747

4848
var moduleStorage = new RuntimeDataStorage();
49-
StashPushModules(moduleStorage);
49+
SaveRuntimeDataModules(moduleStorage);
5050

5151
var objStorage = new RuntimeDataStorage();
52-
StashPushObjects(objStorage);
52+
SaveRuntimeDataObjects(objStorage);
5353

5454
var runtimeStorage = new RuntimeDataStorage();
5555
runtimeStorage.AddValue("meta", metaStorage);
@@ -82,19 +82,19 @@ internal static void Stash()
8282
XDecref(capsule);
8383
}
8484

85-
internal static void StashPop()
85+
internal static void RestoreRuntimeData()
8686
{
8787
try
8888
{
89-
StashPopImpl();
89+
RestoreRuntimeDataImpl();
9090
}
9191
finally
9292
{
9393
ClearStash();
9494
}
9595
}
9696

97-
private static void StashPopImpl()
97+
private static void RestoreRuntimeDataImpl()
9898
{
9999
IntPtr capsule = PySys_GetObject("clr_data");
100100
if (capsule == IntPtr.Zero)
@@ -109,12 +109,12 @@ private static void StashPopImpl()
109109
var formatter = CreateFormatter();
110110
var storage = (RuntimeDataStorage)formatter.Deserialize(ms);
111111

112-
var objs = StashPopObjects(storage.GetStorage("objs"));
113-
StashPopModules(storage.GetStorage("modules"));
114-
var clsObjs = ClassManager.StashPop(storage.GetStorage("classes"));
115-
TypeManager.StashPop(storage.GetStorage("types"));
116-
ImportHook.StashPop(storage.GetStorage("import"));
117-
PyCLRMetaType = MetaType.StashPop(storage.GetStorage("meta"));
112+
var objs = RestoreRuntimeDataObjects(storage.GetStorage("objs"));
113+
RestoreRuntimeDataModules(storage.GetStorage("modules"));
114+
var clsObjs = ClassManager.RestoreRuntimeData(storage.GetStorage("classes"));
115+
TypeManager.RestoreRuntimeData(storage.GetStorage("types"));
116+
ImportHook.RestoreRuntimeData(storage.GetStorage("import"));
117+
PyCLRMetaType = MetaType.RestoreRuntimeData(storage.GetStorage("meta"));
118118

119119
foreach (var item in objs)
120120
{
@@ -137,7 +137,7 @@ public static void ClearStash()
137137
PySys_SetObject("clr_data", IntPtr.Zero);
138138
}
139139

140-
private static void StashPushObjects(RuntimeDataStorage storage)
140+
private static void SaveRuntimeDataObjects(RuntimeDataStorage storage)
141141
{
142142
var objs = ManagedType.GetManagedObjects();
143143
var extensionObjs = new List<ManagedType>();
@@ -215,7 +215,7 @@ private static void StashPushObjects(RuntimeDataStorage storage)
215215
storage.AddValue("contexts", contexts);
216216
}
217217

218-
private static Dictionary<ManagedType, InterDomainContext> StashPopObjects(RuntimeDataStorage storage)
218+
private static Dictionary<ManagedType, InterDomainContext> RestoreRuntimeDataObjects(RuntimeDataStorage storage)
219219
{
220220
var extensions = storage.GetValue<List<ManagedType>>("extensions");
221221
var internalStores = storage.GetValue<List<CLRObject>>("internalStores");
@@ -245,7 +245,7 @@ private static Dictionary<ManagedType, InterDomainContext> StashPopObjects(Runti
245245
return storedObjs;
246246
}
247247

248-
private static void StashPushModules(RuntimeDataStorage storage)
248+
private static void SaveRuntimeDataModules(RuntimeDataStorage storage)
249249
{
250250
var pyModules = PyImport_GetModuleDict();
251251
var itemsRef = PyDict_Items(pyModules);
@@ -268,7 +268,7 @@ private static void StashPushModules(RuntimeDataStorage storage)
268268
storage.AddValue("modules", modules);
269269
}
270270

271-
private static void StashPopModules(RuntimeDataStorage storage)
271+
private static void RestoreRuntimeDataModules(RuntimeDataStorage storage)
272272
{
273273
var modules = storage.GetValue<Dictionary<IntPtr, IntPtr>>("modules");
274274
var pyMoudles = PyImport_GetModuleDict();

src/runtime/typemanager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal static void RemoveTypes()
6262
_slotsHolders.Clear();
6363
}
6464

65-
internal static void StashPush(RuntimeDataStorage storage)
65+
internal static void SaveRuntimeData(RuntimeDataStorage storage)
6666
{
6767
foreach (var tpHandle in cache.Values)
6868
{
@@ -72,7 +72,7 @@ internal static void StashPush(RuntimeDataStorage storage)
7272
storage.AddValue("slots", _slotsImpls);
7373
}
7474

75-
internal static void StashPop(RuntimeDataStorage storage)
75+
internal static void RestoreRuntimeData(RuntimeDataStorage storage)
7676
{
7777
Debug.Assert(cache == null || cache.Count == 0);
7878
storage.GetValue("slots", out _slotsImpls);

0 commit comments

Comments
 (0)
0