| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,7 +85,7 @@ public static void RunPython() { | |||
| 85 | 85 | AppDomain.CurrentDomain.DomainUnload += OnDomainUnload; | |
| 86 | 86 | string name = AppDomain.CurrentDomain.FriendlyName; | |
| 87 | 87 | Console.WriteLine(string.Format(""[{0} in .NET] In PythonRunner.RunPython"", name)); | |
| 88 | - PythonEngine.Initialize(softShutdown: true); | ||
| 88 | + PythonEngine.Initialize(mode: ShutdownMode.Reload); | ||
| 89 | 89 | using (Py.GIL()) { | |
| 90 | 90 | try { | |
| 91 | 91 | var pyScript = string.Format(""import clr\n"" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ namespace Python.Runtime | |||
| 13 | 13 | /// concrete subclasses provide slot implementations appropriate for | |
| 14 | 14 | /// each variety of reflected type. | |
| 15 | 15 | /// </summary> | |
| 16 | + [Serializable] | ||
| 16 | 17 | internal class ClassBase : ManagedType | |
| 17 | 18 | { | |
| 18 | 19 | internal Indexer indexer; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ namespace Python.Runtime | |||
| 19 | 19 | internal class ClassManager | |
| 20 | 20 | { | |
| 21 | 21 | private static Dictionary<Type, ClassBase> cache; | |
| 22 | - private static Type dtype; | ||
| 22 | + private static readonly Type dtype; | ||
| 23 | 23 | ||
| 24 | 24 | private ClassManager() | |
| 25 | 25 | { | |
@@ -81,6 +81,17 @@ private static int OnVisit(IntPtr ob, IntPtr arg) | |||
| 81 | 81 | return 0; | |
| 82 | 82 | } | |
| 83 | 83 | ||
| 84 | + | ||
| 85 | + internal static void StashPush(Stack stack) | ||
| 86 | + { | ||
| 87 | + stack.Push(cache); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + internal static void StashPop(Stack stack) | ||
| 91 | + { | ||
| 92 | + cache = (Dictionary<Type, ClassBase>)stack.Pop(); | ||
| 93 | + } | ||
| 94 | + | ||
| 84 | 95 | /// <summary> | |
| 85 | 96 | /// Return the ClassBase-derived instance that implements a particular | |
| 86 | 97 | /// reflected managed type, creating it if it doesn't yet exist. | |
@@ -239,7 +250,7 @@ private static void InitClassBase(Type type, ClassBase impl) | |||
| 239 | 250 | ||
| 240 | 251 | private static ClassInfo GetClassInfo(Type type) | |
| 241 | 252 | { | |
| 242 | - var ci = new ClassInfo(type); | ||
| 253 | + var ci = new ClassInfo(); | ||
| 243 | 254 | var methods = new Hashtable(); | |
| 244 | 255 | ArrayList list; | |
| 245 | 256 | MethodInfo meth; | |
@@ -443,7 +454,7 @@ internal class ClassInfo | |||
| 443 | 454 | public Indexer indexer; | |
| 444 | 455 | public Hashtable members; | |
| 445 | 456 | ||
| 446 | - internal ClassInfo(Type t) | ||
| 457 | + internal ClassInfo() | ||
| 447 | 458 | { | |
| 448 | 459 | members = new Hashtable(); | |
| 449 | 460 | indexer = null; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ namespace Python.Runtime | |||
| 9 | 9 | /// Python type objects. Each of those type objects is associated with | |
| 10 | 10 | /// an instance of ClassObject, which provides its implementation. | |
| 11 | 11 | /// </summary> | |
| 12 | + [Serializable] | ||
| 12 | 13 | internal class ClassObject : ClassBase | |
| 13 | 14 | { | |
| 14 | 15 | internal ConstructorBinder binder; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ internal class CLRObject : ManagedType | |||
| 9 | 9 | ||
| 10 | 10 | internal CLRObject(object ob, IntPtr tp) | |
| 11 | 11 | { | |
| 12 | + System.Diagnostics.Debug.Assert(tp != IntPtr.Zero); | ||
| 12 | 13 | IntPtr py = Runtime.PyType_GenericAlloc(tp, 0); | |
| 13 | 14 | ||
| 14 | 15 | long flags = Util.ReadCLong(tp, TypeOffset.tp_flags); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ namespace Python.Runtime | |||
| 10 | 10 | /// standard MethodBinder because of a difference in invoking constructors | |
| 11 | 11 | /// using reflection (which is seems to be a CLR bug). | |
| 12 | 12 | /// </summary> | |
| 13 | + [Serializable] | ||
| 13 | 14 | internal class ConstructorBinder : MethodBinder | |
| 14 | 15 | { | |
| 15 | 16 | private Type _containingType; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,11 +19,14 @@ namespace Python.Runtime | |||
| 19 | 19 | /// and creating the BoundContructor object which contains ContructorInfo object. | |
| 20 | 20 | /// 3) In tp_call, if ctorInfo is not null, ctorBinder.InvokeRaw() is called. | |
| 21 | 21 | /// </remarks> | |
| 22 | + [Serializable] | ||
| 22 | 23 | internal class ConstructorBinding : ExtensionType | |
| 23 | 24 | { | |
| 24 | 25 | private Type type; // The managed Type being wrapped in a ClassObject | |
| 25 | 26 | private IntPtr pyTypeHndl; // The python type tells GetInstHandle which Type to create. | |
| 26 | 27 | private ConstructorBinder ctorBinder; | |
| 28 | + | ||
| 29 | + [NonSerialized] | ||
| 27 | 30 | private IntPtr repr; | |
| 28 | 31 | ||
| 29 | 32 | public ConstructorBinding(Type type, IntPtr pyTypeHndl, ConstructorBinder ctorBinder) | |
@@ -173,6 +176,7 @@ public static int tp_traverse(IntPtr ob, IntPtr visit, IntPtr arg) | |||
| 173 | 176 | /// An earlier implementation hung the __call__ on the ContructorBinding class and | |
| 174 | 177 | /// returned an Incref()ed self.pyHandle from the __get__ function. | |
| 175 | 178 | /// </remarks> | |
| 179 | + [Serializable] | ||
| 176 | 180 | internal class BoundContructor : ExtensionType | |
| 177 | 181 | { | |
| 178 | 182 | private Type type; // The managed Type being wrapped in a ClassObject | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ namespace Python.Runtime | |||
| 8 | 8 | /// Each of those type objects is associated an instance of this class, | |
| 9 | 9 | /// which provides its implementation. | |
| 10 | 10 | /// </summary> | |
| 11 | + [Serializable] | ||
| 11 | 12 | internal class DelegateObject : ClassBase | |
| 12 | 13 | { | |
| 13 | 14 | private MethodBinder binder; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ namespace Python.Runtime | |||
| 5 | 5 | /// <summary> | |
| 6 | 6 | /// Implements a Python event binding type, similar to a method binding. | |
| 7 | 7 | /// </summary> | |
| 8 | + [Serializable] | ||
| 8 | 9 | internal class EventBinding : ExtensionType | |
| 9 | 10 | { | |
| 10 | 11 | private EventObject e; | |
@@ -127,5 +128,11 @@ public static int tp_clear(IntPtr ob) | |||
| 127 | 128 | Runtime.Py_CLEAR(ref self.target); | |
| 128 | 129 | return 0; | |
| 129 | 130 | } | |
| 131 | + | ||
| 132 | + protected override void OnSave() | ||
| 133 | + { | ||
| 134 | + base.OnSave(); | ||
| 135 | + Runtime.XIncref(target); | ||
| 136 | + } | ||
| 130 | 137 | } | |
| 131 | 138 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ namespace Python.Runtime | |||
| 7 | 7 | /// <summary> | |
| 8 | 8 | /// Implements a Python descriptor type that provides access to CLR events. | |
| 9 | 9 | /// </summary> | |
| 10 | + [Serializable] | ||
| 10 | 11 | internal class EventObject : ExtensionType | |
| 11 | 12 | { | |
| 12 | 13 | internal string name; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments