| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,4 @@ | |||
| 1 | - // ========================================================================== | ||
| 2 | - // This software is subject to the provisions of the Zope Public License, | ||
| 3 | - // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
| 4 | - // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
| 5 | - // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 6 | - // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
| 7 | - // FOR A PARTICULAR PURPOSE. | ||
| 8 | - // ========================================================================== | ||
| 9 | - | ||
| 1 | + | ||
| 10 | 2 | //============================================================================ | |
| 11 | 3 | // This file replaces the hand-maintained stub that used to implement clr.dll. | |
| 12 | 4 | // This is a line-by-line port from IL back to C#. | |
@@ -21,7 +13,7 @@ | |||
| 21 | 13 | // If defined, the "pythonRuntimeVersionString" variable must be set to | |
| 22 | 14 | // Python.Runtime's current version. | |
| 23 | 15 | ||
| 24 | - #define USE_PYTHON_RUNTIME_VERSION | ||
| 16 | + #define USE_PYTHON_RUNTIME_VERSION | ||
| 25 | 17 | ||
| 26 | 18 | // If defined, the "PythonRuntimePublicKeyTokenData" data array must be | |
| 27 | 19 | // set to Python.Runtime's public key token. (sn -T Python.Runtin.dll) | |
@@ -32,21 +24,21 @@ | |||
| 32 | 24 | //============================================================================ | |
| 33 | 25 | using System; | |
| 34 | 26 | ||
| 35 | - // ReSharper disable CheckNamespace | ||
| 36 | - // ReSharper disable InconsistentNaming | ||
| 27 | + | ||
| 28 | + | ||
| 37 | 29 | public class clrModule | |
| 38 | - // ReSharper restore InconsistentNaming | ||
| 39 | - // ReSharper restore CheckNamespace | ||
| 30 | + | ||
| 31 | + | ||
| 40 | 32 | { | |
| 41 | - // ReSharper disable InconsistentNaming | ||
| 33 | + | ||
| 42 | 34 | #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35) | |
| 43 | 35 | [RGiesecke.DllExport.DllExport("PyInit_clr", System.Runtime.InteropServices.CallingConvention.StdCall)] | |
| 44 | 36 | public static IntPtr PyInit_clr() | |
| 45 | 37 | #else | |
| 46 | 38 | [RGiesecke.DllExport.DllExport("initclr", System.Runtime.InteropServices.CallingConvention.StdCall)] | |
| 47 | 39 | public static void initclr() | |
| 48 | 40 | #endif | |
| 49 | - // ReSharper restore InconsistentNaming | ||
| 41 | + | ||
| 50 | 42 | { | |
| 51 | 43 | #if DEBUG_PRINT | |
| 52 | 44 | System.Console.WriteLine("Attempting to load Python.Runtime using standard binding rules... "); | |
@@ -64,7 +56,7 @@ public static void initclr() | |||
| 64 | 56 | var pythonRuntimeName = new System.Reflection.AssemblyName("Python.Runtime") | |
| 65 | 57 | { | |
| 66 | 58 | #if USE_PYTHON_RUNTIME_VERSION | |
| 67 | - Version = new System.Version("4.0.0.1"), | ||
| 59 | + Version = new System.Version("4.0.0.1"), | ||
| 68 | 60 | #endif | |
| 69 | 61 | CultureInfo = System.Globalization.CultureInfo.InvariantCulture, | |
| 70 | 62 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,3 @@ | |||
| 1 | - // ========================================================================== | ||
| 2 | - // This software is subject to the provisions of the Zope Public License, | ||
| 3 | - // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
| 4 | - // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
| 5 | - // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 6 | - // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
| 7 | - // FOR A PARTICULAR PURPOSE. | ||
| 8 | - // ========================================================================== | ||
| 9 | 1 | ||
| 10 | 2 | using System; | |
| 11 | 3 | using System.Reflection; | |
@@ -21,7 +13,7 @@ | |||
| 21 | 13 | [assembly: ComVisible(false)] | |
| 22 | 14 | ||
| 23 | 15 | ||
| 24 | - [assembly:PermissionSetAttribute(SecurityAction.RequestMinimum, | ||
| 16 | + [assembly:PermissionSetAttribute(SecurityAction.RequestMinimum, | ||
| 25 | 17 | Name = "FullTrust")] | |
| 26 | 18 | [assembly: AssemblyDescriptionAttribute("")] | |
| 27 | 19 | [assembly: AssemblyCopyrightAttribute("Zope Public License, Version 2.0 (ZPL)")] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,3 @@ | |||
| 1 | - // ========================================================================== | ||
| 2 | - // This software is subject to the provisions of the Zope Public License, | ||
| 3 | - // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
| 4 | - // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
| 5 | - // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 6 | - // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
| 7 | - // FOR A PARTICULAR PURPOSE. | ||
| 8 | - // ========================================================================== | ||
| 9 | 1 | ||
| 10 | 2 | using System; | |
| 11 | 3 | using System.Reflection; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,3 @@ | |||
| 1 | - // ========================================================================== | ||
| 2 | - // This software is subject to the provisions of the Zope Public License, | ||
| 3 | - // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
| 4 | - // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
| 5 | - // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 6 | - // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
| 7 | - // FOR A PARTICULAR PURPOSE. | ||
| 8 | - // ========================================================================== | ||
| 9 | 1 | ||
| 10 | 2 | using System; | |
| 11 | 3 | using System.Collections; | |
@@ -15,7 +7,7 @@ namespace Python.Runtime { | |||
| 15 | 7 | ||
| 16 | 8 | /// <summary> | |
| 17 | 9 | /// Implements a Python type for managed arrays. This type is essentially | |
| 18 | - /// the same as a ClassObject, except that it provides sequence semantics | ||
| 10 | + /// the same as a ClassObject, except that it provides sequence semantics | ||
| 19 | 11 | /// to support natural array usage (indexing) from Python. | |
| 20 | 12 | /// </summary> | |
| 21 | 13 | ||
@@ -57,7 +49,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) { | |||
| 57 | 49 | // Note that CLR 1.0 only supports int indexes - methods to | |
| 58 | 50 | // support long indices were introduced in 1.1. We could | |
| 59 | 51 | // support long indices automatically, but given that long | |
| 60 | - // indices are not backward compatible and a relative edge | ||
| 52 | + // indices are not backward compatible and a relative edge | ||
| 61 | 53 | // case, we won't bother for now. | |
| 62 | 54 | ||
| 63 | 55 | // Single-dimensional arrays are the most common case and are | |
@@ -81,7 +73,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) { | |||
| 81 | 73 | Exceptions.SetError(Exceptions.IndexError, | |
| 82 | 74 | "array index out of range" | |
| 83 | 75 | ); | |
| 84 | - return IntPtr.Zero; | ||
| 76 | + return IntPtr.Zero; | ||
| 85 | 77 | } | |
| 86 | 78 | ||
| 87 | 79 | return Converter.ToPython(items.GetValue(index), itemType); | |
@@ -122,7 +114,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) { | |||
| 122 | 114 | Exceptions.SetError(Exceptions.IndexError, | |
| 123 | 115 | "array index out of range" | |
| 124 | 116 | ); | |
| 125 | - return IntPtr.Zero; | ||
| 117 | + return IntPtr.Zero; | ||
| 126 | 118 | } | |
| 127 | 119 | ||
| 128 | 120 | return Converter.ToPython(value, itemType); | |
@@ -169,7 +161,7 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) { | |||
| 169 | 161 | Exceptions.SetError(Exceptions.IndexError, | |
| 170 | 162 | "array index out of range" | |
| 171 | 163 | ); | |
| 172 | - return -1; | ||
| 164 | + return -1; | ||
| 173 | 165 | } | |
| 174 | 166 | ||
| 175 | 167 | return 0; | |
@@ -247,6 +239,6 @@ public static int mp_length(IntPtr ob) { | |||
| 247 | 239 | } | |
| 248 | 240 | ||
| 249 | 241 | ||
| 250 | - } | ||
| 242 | + } | ||
| 251 | 243 | ||
| 252 | 244 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,3 @@ | |||
| 1 | - // ========================================================================== | ||
| 2 | - // This software is subject to the provisions of the Zope Public License, | ||
| 3 | - // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
| 4 | - // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
| 5 | - // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 6 | - // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
| 7 | - // FOR A PARTICULAR PURPOSE. | ||
| 8 | - // ========================================================================== | ||
| 9 | 1 | ||
| 10 | 2 | using System; | |
| 11 | 3 | using System.Reflection; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,3 @@ | |||
| 1 | - // ========================================================================== | ||
| 2 | - // This software is subject to the provisions of the Zope Public License, | ||
| 3 | - // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
| 4 | - // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
| 5 | - // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 6 | - // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
| 7 | - // FOR A PARTICULAR PURPOSE. | ||
| 8 | - // ========================================================================== | ||
| 9 | 1 | ||
| 10 | 2 | using System; | |
| 11 | 3 | using System.IO; | |
@@ -19,7 +11,7 @@ | |||
| 19 | 11 | namespace Python.Runtime { | |
| 20 | 12 | ||
| 21 | 13 | /// <summary> | |
| 22 | - /// The AssemblyManager maintains information about loaded assemblies | ||
| 14 | + /// The AssemblyManager maintains information about loaded assemblies | ||
| 23 | 15 | /// namespaces and provides an interface for name-based type lookup. | |
| 24 | 16 | /// </summary> | |
| 25 | 17 | ||
@@ -42,7 +34,7 @@ private AssemblyManager() {} | |||
| 42 | 34 | //=================================================================== | |
| 43 | 35 | ||
| 44 | 36 | internal static void Initialize() { | |
| 45 | - namespaces = new | ||
| 37 | + namespaces = new | ||
| 46 | 38 | Dictionary<string, Dictionary<Assembly, string>>(32); | |
| 47 | 39 | probed = new Dictionary<string, int>(32); | |
| 48 | 40 | //generics = new Dictionary<string, Dictionary<string, string>>(); | |
@@ -54,7 +46,7 @@ internal static void Initialize() { | |||
| 54 | 46 | lhandler = new AssemblyLoadEventHandler(AssemblyLoadHandler); | |
| 55 | 47 | domain.AssemblyLoad += lhandler; | |
| 56 | 48 | ||
| 57 | - rhandler = new ResolveEventHandler(ResolveHandler); | ||
| 49 | + rhandler = new ResolveEventHandler(ResolveHandler); | ||
| 58 | 50 | domain.AssemblyResolve += rhandler; | |
| 59 | 51 | ||
| 60 | 52 | Assembly[] items = domain.GetAssemblies(); | |
@@ -85,10 +77,10 @@ internal static void Shutdown() { | |||
| 85 | 77 | ||
| 86 | 78 | ||
| 87 | 79 | //=================================================================== | |
| 88 | - // Event handler for assembly load events. At the time the Python | ||
| 80 | + // Event handler for assembly load events. At the time the Python | ||
| 89 | 81 | // runtime loads, we scan the app domain to map the assemblies that | |
| 90 | 82 | // are loaded at the time. We also have to register this event handler | |
| 91 | - // so that we can know about assemblies that get loaded after the | ||
| 83 | + // so that we can know about assemblies that get loaded after the | ||
| 92 | 84 | // Python runtime is initialized. | |
| 93 | 85 | //=================================================================== | |
| 94 | 86 | ||
@@ -122,11 +114,11 @@ static Assembly ResolveHandler(Object ob, ResolveEventArgs args){ | |||
| 122 | 114 | ||
| 123 | 115 | //=================================================================== | |
| 124 | 116 | // We __really__ want to avoid using Python objects or APIs when | |
| 125 | - // probing for assemblies to load, since our ResolveHandler may be | ||
| 117 | + // probing for assemblies to load, since our ResolveHandler may be | ||
| 126 | 118 | // called in contexts where we don't have the Python GIL and can't | |
| 127 | 119 | // even safely try to get it without risking a deadlock ;( | |
| 128 | 120 | // | |
| 129 | - // To work around that, we update a managed copy of sys.path (which | ||
| 121 | + // To work around that, we update a managed copy of sys.path (which | ||
| 130 | 122 | // is the main thing we care about) when UpdatePath is called. The | |
| 131 | 123 | // import hook calls this whenever it knows its about to use the | |
| 132 | 124 | // assembly manager, which lets us keep up with changes to sys.path | |
@@ -216,11 +208,11 @@ public static Assembly LoadAssemblyPath(string name) { | |||
| 216 | 208 | return assembly; | |
| 217 | 209 | } | |
| 218 | 210 | ||
| 219 | - /// <summary> | ||
| 220 | - /// Loads an assembly using full path. | ||
| 221 | - /// </summary> | ||
| 222 | - /// <param name="name"></param> | ||
| 223 | - /// <returns></returns> | ||
| 211 | + /// <summary> | ||
| 212 | + /// Loads an assembly using full path. | ||
| 213 | + /// </summary> | ||
| 214 | + /// <param name="name"></param> | ||
| 215 | + /// <returns></returns> | ||
| 224 | 216 | public static Assembly LoadAssemblyFullPath(string name) { | |
| 225 | 217 | Assembly assembly = null; | |
| 226 | 218 | if (Path.IsPathRooted(name)) { | |
@@ -249,7 +241,7 @@ public static Assembly FindLoadedAssembly(string name) { | |||
| 249 | 241 | } | |
| 250 | 242 | ||
| 251 | 243 | //=================================================================== | |
| 252 | - // Given a qualified name of the form A.B.C.D, attempt to load | ||
| 244 | + // Given a qualified name of the form A.B.C.D, attempt to load | ||
| 253 | 245 | // an assembly named after each of A.B.C.D, A.B.C, A.B, A. This | |
| 254 | 246 | // will only actually probe for the assembly once for each unique | |
| 255 | 247 | // namespace. Returns true if any assemblies were loaded. | |
@@ -304,7 +296,7 @@ public static bool LoadImplicit(string name, bool warn=true) { | |||
| 304 | 296 | //=================================================================== | |
| 305 | 297 | // Scans an assembly for exported namespaces, adding them to the | |
| 306 | 298 | // mapping of valid namespaces. Note that for a given namespace | |
| 307 | - // a.b.c.d, each of a, a.b, a.b.c and a.b.c.d are considered to | ||
| 299 | + // a.b.c.d, each of a, a.b, a.b.c and a.b.c.d are considered to | ||
| 308 | 300 | // be valid namespaces (to better match Python import semantics). | |
| 309 | 301 | //=================================================================== | |
| 310 | 302 | ||
@@ -402,7 +394,7 @@ public static List<string> GetNames(string nsname) { | |||
| 402 | 394 | //string tail = key.Substring(nslen); | |
| 403 | 395 | if (key.IndexOf('.') == -1) { | |
| 404 | 396 | names.Add(key); | |
| 405 | - } | ||
| 397 | + } | ||
| 406 | 398 | } | |
| 407 | 399 | } | |
| 408 | 400 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,3 @@ | |||
| 1 | - // ========================================================================== | ||
| 2 | - // This software is subject to the provisions of the Zope Public License, | ||
| 3 | - // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
| 4 | - // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
| 5 | - // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 6 | - // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
| 7 | - // FOR A PARTICULAR PURPOSE. | ||
| 8 | - // ========================================================================== | ||
| 9 | 1 | ||
| 10 | 2 | using System; | |
| 11 | 3 | using System.Collections; | |
@@ -49,15 +41,15 @@ public static int tp_init(IntPtr ob, IntPtr args, IntPtr kw) { | |||
| 49 | 41 | //==================================================================== | |
| 50 | 42 | // Default implementation of [] semantics for reflected types. | |
| 51 | 43 | //==================================================================== | |
| 52 | - | ||
| 44 | + | ||
| 53 | 45 | public virtual IntPtr type_subscript(IntPtr idx) { | |
| 54 | 46 | Type[] types = Runtime.PythonArgsToTypeArray(idx); | |
| 55 | 47 | if (types == null) { | |
| 56 | 48 | return Exceptions.RaiseTypeError("type(s) expected"); | |
| 57 | - } | ||
| 58 | - | ||
| 59 | - Type target = GenericUtil.GenericForType(this.type, types.Length); | ||
| 60 | - | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + Type target = GenericUtil.GenericForType(this.type, types.Length); | ||
| 52 | + | ||
| 61 | 53 | if (target != null) { | |
| 62 | 54 | Type t = target.MakeGenericType(types); | |
| 63 | 55 | ManagedType c = (ManagedType)ClassManager.GetClass(t); | |
@@ -66,7 +58,7 @@ public virtual IntPtr type_subscript(IntPtr idx) { | |||
| 66 | 58 | } | |
| 67 | 59 | ||
| 68 | 60 | return Exceptions.RaiseTypeError("no type matches params"); | |
| 69 | - } | ||
| 61 | + } | ||
| 70 | 62 | ||
| 71 | 63 | //==================================================================== | |
| 72 | 64 | // Standard comparison implementation for instances of reflected types. | |
@@ -151,7 +143,7 @@ public static IntPtr tp_iter(IntPtr ob) { | |||
| 151 | 143 | } | |
| 152 | 144 | else { | |
| 153 | 145 | o = co.inst as IEnumerator; | |
| 154 | - | ||
| 146 | + | ||
| 155 | 147 | if (o == null) { | |
| 156 | 148 | string message = "iteration over non-sequence"; | |
| 157 | 149 | return Exceptions.RaiseTypeError(message); | |
@@ -221,7 +213,7 @@ public static int tp_is_gc(IntPtr type) { | |||
| 221 | 213 | public static void tp_dealloc(IntPtr ob) { | |
| 222 | 214 | ManagedType self = GetManagedObject(ob); | |
| 223 | 215 | IntPtr dict = Marshal.ReadIntPtr(ob, ObjectOffset.DictOffset(ob)); | |
| 224 | - if (dict != IntPtr.Zero) { | ||
| 216 | + if (dict != IntPtr.Zero) { | ||
| 225 | 217 | Runtime.Decref(dict); | |
| 226 | 218 | } | |
| 227 | 219 | Runtime.PyObject_GC_UnTrack(self.pyHandle); | |
@@ -231,6 +223,6 @@ public static void tp_dealloc(IntPtr ob) { | |||
| 231 | 223 | } | |
| 232 | 224 | ||
| 233 | 225 | ||
| 234 | - } | ||
| 226 | + } | ||
| 235 | 227 | ||
| 236 | 228 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,4 @@ | |||
| 1 | - // ========================================================================== | ||
| 2 | - // This software is subject to the provisions of the Zope Public License, | ||
| 3 | - // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
| 4 | - // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
| 5 | - // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 6 | - // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
| 7 | - // FOR A PARTICULAR PURPOSE. | ||
| 8 | - // ========================================================================== | ||
| 9 | - | ||
| 1 | + | ||
| 10 | 2 | using System; | |
| 11 | 3 | using System.IO; | |
| 12 | 4 | using System.Reflection; | |
@@ -22,8 +14,8 @@ namespace Python.Runtime | |||
| 22 | 14 | ||
| 23 | 15 | /// <summary> | |
| 24 | 16 | /// Managed class that provides the implementation for reflected types. | |
| 25 | - /// Managed classes and value types are represented in Python by actual | ||
| 26 | - /// Python type objects. Each of those type objects is associated with | ||
| 17 | + /// Managed classes and value types are represented in Python by actual | ||
| 18 | + /// Python type objects. Each of those type objects is associated with | ||
| 27 | 19 | /// an instance of ClassObject, which provides its implementation. | |
| 28 | 20 | /// </summary> | |
| 29 | 21 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments