Skip to content

Format and White-spacing #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor license, fix typo
  • Loading branch information
vmuriart committed Apr 18, 2016
commit ec678f724f54a88b569498e13e3d5997b85b5f2e
26 changes: 9 additions & 17 deletions src/clrmodule/ClrModule.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================


//============================================================================
// This file replaces the hand-maintained stub that used to implement clr.dll.
// This is a line-by-line port from IL back to C#.
Expand All @@ -21,7 +13,7 @@
// If defined, the "pythonRuntimeVersionString" variable must be set to
// Python.Runtime's current version.

#define USE_PYTHON_RUNTIME_VERSION
#define USE_PYTHON_RUNTIME_VERSION

// If defined, the "PythonRuntimePublicKeyTokenData" data array must be
// set to Python.Runtime's public key token. (sn -T Python.Runtin.dll)
Expand All @@ -32,21 +24,21 @@
//============================================================================
using System;

// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming


public class clrModule
// ReSharper restore InconsistentNaming
// ReSharper restore CheckNamespace


{
// ReSharper disable InconsistentNaming

#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
[RGiesecke.DllExport.DllExport("PyInit_clr", System.Runtime.InteropServices.CallingConvention.StdCall)]
public static IntPtr PyInit_clr()
#else
[RGiesecke.DllExport.DllExport("initclr", System.Runtime.InteropServices.CallingConvention.StdCall)]
public static void initclr()
#endif
// ReSharper restore InconsistentNaming

{
#if DEBUG_PRINT
System.Console.WriteLine("Attempting to load Python.Runtime using standard binding rules... ");
Expand All @@ -64,7 +56,7 @@ public static void initclr()
var pythonRuntimeName = new System.Reflection.AssemblyName("Python.Runtime")
{
#if USE_PYTHON_RUNTIME_VERSION
Version = new System.Version("4.0.0.1"),
Version = new System.Version("4.0.0.1"),
#endif
CultureInfo = System.Globalization.CultureInfo.InvariantCulture,
};
Expand Down
10 changes: 1 addition & 9 deletions src/console/assemblyinfo.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

using System;
using System.Reflection;
Expand All @@ -21,7 +13,7 @@
[assembly: ComVisible(false)]


[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum,
[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum,
Name = "FullTrust")]
[assembly: AssemblyDescriptionAttribute("")]
[assembly: AssemblyCopyrightAttribute("Zope Public License, Version 2.0 (ZPL)")]
Expand Down
8 changes: 0 additions & 8 deletions src/console/pythonconsole.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

using System;
using System.Reflection;
Expand Down
20 changes: 6 additions & 14 deletions src/runtime/arrayobject.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

using System;
using System.Collections;
Expand All @@ -15,7 +7,7 @@ namespace Python.Runtime {

/// <summary>
/// Implements a Python type for managed arrays. This type is essentially
/// the same as a ClassObject, except that it provides sequence semantics
/// the same as a ClassObject, except that it provides sequence semantics
/// to support natural array usage (indexing) from Python.
/// </summary>

Expand Down Expand Up @@ -57,7 +49,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) {
// Note that CLR 1.0 only supports int indexes - methods to
// support long indices were introduced in 1.1. We could
// support long indices automatically, but given that long
// indices are not backward compatible and a relative edge
// indices are not backward compatible and a relative edge
// case, we won't bother for now.

// Single-dimensional arrays are the most common case and are
Expand All @@ -81,7 +73,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) {
Exceptions.SetError(Exceptions.IndexError,
"array index out of range"
);
return IntPtr.Zero;
return IntPtr.Zero;
}

return Converter.ToPython(items.GetValue(index), itemType);
Expand Down Expand Up @@ -122,7 +114,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) {
Exceptions.SetError(Exceptions.IndexError,
"array index out of range"
);
return IntPtr.Zero;
return IntPtr.Zero;
}

return Converter.ToPython(value, itemType);
Expand Down Expand Up @@ -169,7 +161,7 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) {
Exceptions.SetError(Exceptions.IndexError,
"array index out of range"
);
return -1;
return -1;
}

return 0;
Expand Down Expand Up @@ -247,6 +239,6 @@ public static int mp_length(IntPtr ob) {
}


}
}

}
8 changes: 0 additions & 8 deletions src/runtime/assemblyinfo.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

using System;
using System.Reflection;
Expand Down
38 changes: 15 additions & 23 deletions src/runtime/assemblymanager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

using System;
using System.IO;
Expand All @@ -19,7 +11,7 @@
namespace Python.Runtime {

/// <summary>
/// The AssemblyManager maintains information about loaded assemblies
/// The AssemblyManager maintains information about loaded assemblies
/// namespaces and provides an interface for name-based type lookup.
/// </summary>

Expand All @@ -42,7 +34,7 @@ private AssemblyManager() {}
//===================================================================

internal static void Initialize() {
namespaces = new
namespaces = new
Dictionary<string, Dictionary<Assembly, string>>(32);
probed = new Dictionary<string, int>(32);
//generics = new Dictionary<string, Dictionary<string, string>>();
Expand All @@ -54,7 +46,7 @@ internal static void Initialize() {
lhandler = new AssemblyLoadEventHandler(AssemblyLoadHandler);
domain.AssemblyLoad += lhandler;

rhandler = new ResolveEventHandler(ResolveHandler);
rhandler = new ResolveEventHandler(ResolveHandler);
domain.AssemblyResolve += rhandler;

Assembly[] items = domain.GetAssemblies();
Expand Down Expand Up @@ -85,10 +77,10 @@ internal static void Shutdown() {


//===================================================================
// Event handler for assembly load events. At the time the Python
// Event handler for assembly load events. At the time the Python
// runtime loads, we scan the app domain to map the assemblies that
// are loaded at the time. We also have to register this event handler
// so that we can know about assemblies that get loaded after the
// so that we can know about assemblies that get loaded after the
// Python runtime is initialized.
//===================================================================

Expand Down Expand Up @@ -122,11 +114,11 @@ static Assembly ResolveHandler(Object ob, ResolveEventArgs args){

//===================================================================
// We __really__ want to avoid using Python objects or APIs when
// probing for assemblies to load, since our ResolveHandler may be
// probing for assemblies to load, since our ResolveHandler may be
// called in contexts where we don't have the Python GIL and can't
// even safely try to get it without risking a deadlock ;(
//
// To work around that, we update a managed copy of sys.path (which
// To work around that, we update a managed copy of sys.path (which
// is the main thing we care about) when UpdatePath is called. The
// import hook calls this whenever it knows its about to use the
// assembly manager, which lets us keep up with changes to sys.path
Expand Down Expand Up @@ -216,11 +208,11 @@ public static Assembly LoadAssemblyPath(string name) {
return assembly;
}

/// <summary>
/// Loads an assembly using full path.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
/// <summary>
/// Loads an assembly using full path.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static Assembly LoadAssemblyFullPath(string name) {
Assembly assembly = null;
if (Path.IsPathRooted(name)) {
Expand Down Expand Up @@ -249,7 +241,7 @@ public static Assembly FindLoadedAssembly(string name) {
}

//===================================================================
// Given a qualified name of the form A.B.C.D, attempt to load
// Given a qualified name of the form A.B.C.D, attempt to load
// an assembly named after each of A.B.C.D, A.B.C, A.B, A. This
// will only actually probe for the assembly once for each unique
// namespace. Returns true if any assemblies were loaded.
Expand Down Expand Up @@ -304,7 +296,7 @@ public static bool LoadImplicit(string name, bool warn=true) {
//===================================================================
// Scans an assembly for exported namespaces, adding them to the
// mapping of valid namespaces. Note that for a given namespace
// a.b.c.d, each of a, a.b, a.b.c and a.b.c.d are considered to
// a.b.c.d, each of a, a.b, a.b.c and a.b.c.d are considered to
// be valid namespaces (to better match Python import semantics).
//===================================================================

Expand Down Expand Up @@ -402,7 +394,7 @@ public static List<string> GetNames(string nsname) {
//string tail = key.Substring(nslen);
if (key.IndexOf('.') == -1) {
names.Add(key);
}
}
}
}
}
Expand Down
26 changes: 9 additions & 17 deletions src/runtime/classbase.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

using System;
using System.Collections;
Expand Down Expand Up @@ -49,15 +41,15 @@ public static int tp_init(IntPtr ob, IntPtr args, IntPtr kw) {
//====================================================================
// Default implementation of [] semantics for reflected types.
//====================================================================

public virtual IntPtr type_subscript(IntPtr idx) {
Type[] types = Runtime.PythonArgsToTypeArray(idx);
if (types == null) {
return Exceptions.RaiseTypeError("type(s) expected");
}
Type target = GenericUtil.GenericForType(this.type, types.Length);
}

Type target = GenericUtil.GenericForType(this.type, types.Length);

if (target != null) {
Type t = target.MakeGenericType(types);
ManagedType c = (ManagedType)ClassManager.GetClass(t);
Expand All @@ -66,7 +58,7 @@ public virtual IntPtr type_subscript(IntPtr idx) {
}

return Exceptions.RaiseTypeError("no type matches params");
}
}

//====================================================================
// Standard comparison implementation for instances of reflected types.
Expand Down Expand Up @@ -151,7 +143,7 @@ public static IntPtr tp_iter(IntPtr ob) {
}
else {
o = co.inst as IEnumerator;

if (o == null) {
string message = "iteration over non-sequence";
return Exceptions.RaiseTypeError(message);
Expand Down Expand Up @@ -221,7 +213,7 @@ public static int tp_is_gc(IntPtr type) {
public static void tp_dealloc(IntPtr ob) {
ManagedType self = GetManagedObject(ob);
IntPtr dict = Marshal.ReadIntPtr(ob, ObjectOffset.DictOffset(ob));
if (dict != IntPtr.Zero) {
if (dict != IntPtr.Zero) {
Runtime.Decref(dict);
}
Runtime.PyObject_GC_UnTrack(self.pyHandle);
Expand All @@ -231,6 +223,6 @@ public static void tp_dealloc(IntPtr ob) {
}


}
}

}
14 changes: 3 additions & 11 deletions src/runtime/classderived.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================


using System;
using System.IO;
using System.Reflection;
Expand All @@ -22,8 +14,8 @@ namespace Python.Runtime

/// <summary>
/// Managed class that provides the implementation for reflected types.
/// Managed classes and value types are represented in Python by actual
/// Python type objects. Each of those type objects is associated with
/// Managed classes and value types are represented in Python by actual
/// Python type objects. Each of those type objects is associated with
/// an instance of ClassObject, which provides its implementation.
/// </summary>

Expand Down
Loading