Skip to content

Commit f41cf63

Browse files
committed
Format, white-space .cs files
1 parent ec678f7 commit f41cf63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+6901
-5881
lines changed

src/clrmodule/ClrModule.cs

+16-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
//============================================================================
1+
//============================================================================
32
// This file replaces the hand-maintained stub that used to implement clr.dll.
43
// This is a line-by-line port from IL back to C#.
54
// We now use RGiesecke.DllExport on the required static init method so it can be
@@ -25,20 +24,15 @@
2524
using System;
2625

2726

28-
2927
public class clrModule
30-
31-
3228
{
33-
3429
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
3530
[RGiesecke.DllExport.DllExport("PyInit_clr", System.Runtime.InteropServices.CallingConvention.StdCall)]
3631
public static IntPtr PyInit_clr()
3732
#else
3833
[RGiesecke.DllExport.DllExport("initclr", System.Runtime.InteropServices.CallingConvention.StdCall)]
3934
public static void initclr()
4035
#endif
41-
4236
{
4337
#if DEBUG_PRINT
4438
System.Console.WriteLine("Attempting to load Python.Runtime using standard binding rules... ");
@@ -54,12 +48,12 @@ public static void initclr()
5448
// - A PrivateBinPath under ApplicationBase
5549
// With an unsigned assembly, the GAC is skipped.
5650
var pythonRuntimeName = new System.Reflection.AssemblyName("Python.Runtime")
57-
{
51+
{
5852
#if USE_PYTHON_RUNTIME_VERSION
59-
Version = new System.Version("4.0.0.1"),
53+
Version = new System.Version("4.0.0.1"),
6054
#endif
61-
CultureInfo = System.Globalization.CultureInfo.InvariantCulture,
62-
};
55+
CultureInfo = System.Globalization.CultureInfo.InvariantCulture,
56+
};
6357
#if USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
6458
pythonRuntimeName.SetPublicKeyToken(pythonRuntimePublicKeyTokenData);
6559
#endif
@@ -77,13 +71,13 @@ public static void initclr()
7771
try
7872
{
7973
// If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll"
80-
// from the directory this assembly is running in. "This assembly" is probably "clr.pyd",
81-
// sitting somewhere in PYTHONPATH. This is using Assembly.LoadFrom, and inherits all the
82-
// caveats of that call. See MSDN docs for details.
83-
// Suzanne Cook's blog is also an excellent source of info on this:
84-
// http://blogs.msdn.com/suzcook/
85-
// http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx
86-
// http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx
74+
// from the directory this assembly is running in. "This assembly" is probably "clr.pyd",
75+
// sitting somewhere in PYTHONPATH. This is using Assembly.LoadFrom, and inherits all the
76+
// caveats of that call. See MSDN docs for details.
77+
// Suzanne Cook's blog is also an excellent source of info on this:
78+
// http://blogs.msdn.com/suzcook/
79+
// http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx
80+
// http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx
8781

8882
var executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
8983
var assemblyDirectory = System.IO.Path.GetDirectoryName(executingAssembly.Location);
@@ -95,7 +89,8 @@ public static void initclr()
9589
#endif
9690
pythonRuntime = System.Reflection.Assembly.LoadFrom(pythonRuntimeDllPath);
9791
}
98-
catch (System.InvalidOperationException) {
92+
catch (System.InvalidOperationException)
93+
{
9994
#if DEBUG_PRINT
10095
System.Console.WriteLine("Could not load Python.Runtime, so sad.");
10196
#endif
@@ -108,7 +103,7 @@ public static void initclr()
108103
}
109104

110105
// Once here, we've successfully loaded SOME version of Python.Runtime
111-
// So now we get the PythonEngine and execute the InitExt method on it.
106+
// So now we get the PythonEngine and execute the InitExt method on it.
112107
var pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine");
113108

114109
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
@@ -117,4 +112,4 @@ public static void initclr()
117112
pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
118113
#endif
119114
}
120-
}
115+
}

src/clrmodule/Properties/AssemblyInfo.cs

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

5-
// General Information about an assembly is controlled through the following
5+
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8+
89
[assembly: AssemblyTitle("clrmodule")]
910
[assembly: AssemblyDescription("")]
1011
[assembly: AssemblyConfiguration("")]
@@ -14,23 +15,26 @@
1415
[assembly: AssemblyTrademark("")]
1516
[assembly: AssemblyCulture("")]
1617

17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
18+
// Setting ComVisible to false makes the types in this assembly not visible
19+
// to COM components. If you need to access a type in this assembly from
1920
// COM, set the ComVisible attribute to true on that type.
21+
2022
[assembly: ComVisible(false)]
2123

2224
// The following GUID is for the ID of the typelib if this project is exposed to COM
25+
2326
[assembly: Guid("ae10d6a4-55c2-482f-9716-9988e6c169e3")]
2427

2528
// Version information for an assembly consists of the following four values:
2629
//
2730
// Major Version
28-
// Minor Version
31+
// Minor Version
2932
// Build Number
3033
// Revision
3134
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
35+
// You can specify all the values or you can default the Build and Revision Numbers
3336
// by using the '*' as shown below:
3437
// [assembly: AssemblyVersion("1.0.*")]
38+
3539
[assembly: AssemblyVersion("1.0.0.0")]
3640
[assembly: AssemblyFileVersion("1.0.0.0")]

src/clrmodule/packages.config

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
23
<packages>
34
<package id="UnmanagedExports" version="1.2.6" targetFramework="net40" />
45
</packages>

src/console/app.config

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
<?xml version="1.0"?>
2+
23
<configuration>
3-
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
4+
<startup>
5+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
6+
</startup>
7+
</configuration>

src/console/assemblyinfo.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
using System;
32
using System.Reflection;
43
using System.Security.Permissions;
@@ -11,11 +10,9 @@
1110
[assembly: AssemblyDefaultAliasAttribute("python.exe")]
1211
[assembly: CLSCompliant(true)]
1312
[assembly: ComVisible(false)]
14-
15-
16-
[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum,
17-
Name = "FullTrust")]
13+
[assembly: PermissionSetAttribute(SecurityAction.RequestMinimum,
14+
Name = "FullTrust")]
1815
[assembly: AssemblyDescriptionAttribute("")]
1916
[assembly: AssemblyCopyrightAttribute("Zope Public License, Version 2.0 (ZPL)")]
2017
[assembly: AssemblyFileVersionAttribute("2.0.0.4")]
21-
[assembly: NeutralResourcesLanguageAttribute("en")]
18+
[assembly: NeutralResourcesLanguageAttribute("en")]

src/console/pythonconsole.cs

+52-47
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,69 @@
1-
21
using System;
32
using System.Reflection;
43
using System.Collections.Generic;
54
using Python.Runtime;
65

7-
namespace Python.Runtime {
8-
9-
public sealed class PythonConsole {
10-
11-
private PythonConsole() {}
12-
13-
[STAThread]
14-
public static int Main(string[] args) {
15-
// reference the static assemblyLoader to stop it being optimized away
16-
AssemblyLoader a = assemblyLoader;
6+
namespace Python.Runtime
7+
{
8+
public sealed class PythonConsole
9+
{
10+
private PythonConsole()
11+
{
12+
}
1713

18-
string [] cmd = Environment.GetCommandLineArgs();
19-
PythonEngine.Initialize();
14+
[STAThread]
15+
public static int Main(string[] args)
16+
{
17+
// reference the static assemblyLoader to stop it being optimized away
18+
AssemblyLoader a = assemblyLoader;
2019

21-
int i = Runtime.Py_Main(cmd.Length, cmd);
22-
PythonEngine.Shutdown();
20+
string[] cmd = Environment.GetCommandLineArgs();
21+
PythonEngine.Initialize();
2322

24-
return i;
25-
}
23+
int i = Runtime.Py_Main(cmd.Length, cmd);
24+
PythonEngine.Shutdown();
2625

27-
// Register a callback function to load embedded assmeblies.
28-
// (Python.Runtime.dll is included as a resource)
29-
private sealed class AssemblyLoader {
30-
Dictionary<string, Assembly> loadedAssemblies;
26+
return i;
27+
}
3128

32-
public AssemblyLoader() {
33-
loadedAssemblies = new Dictionary<string, Assembly>();
29+
// Register a callback function to load embedded assmeblies.
30+
// (Python.Runtime.dll is included as a resource)
31+
private sealed class AssemblyLoader
32+
{
33+
Dictionary<string, Assembly> loadedAssemblies;
3434

35-
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {
36-
string shortName = args.Name.Split(',')[0];
37-
String resourceName = shortName + ".dll";
35+
public AssemblyLoader()
36+
{
37+
loadedAssemblies = new Dictionary<string, Assembly>();
3838

39-
if (loadedAssemblies.ContainsKey(resourceName)) {
40-
return loadedAssemblies[resourceName];
41-
}
39+
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
40+
{
41+
string shortName = args.Name.Split(',')[0];
42+
String resourceName = shortName + ".dll";
4243

43-
// looks for the assembly from the resources and load it
44-
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) {
45-
if (stream != null) {
46-
Byte[] assemblyData = new Byte[stream.Length];
47-
stream.Read(assemblyData, 0, assemblyData.Length);
48-
Assembly assembly = Assembly.Load(assemblyData);
49-
loadedAssemblies[resourceName] = assembly;
50-
return assembly;
44+
if (loadedAssemblies.ContainsKey(resourceName))
45+
{
46+
return loadedAssemblies[resourceName];
5147
}
52-
}
5348

54-
return null;
55-
};
56-
}
57-
};
58-
59-
private static AssemblyLoader assemblyLoader = new AssemblyLoader();
60-
61-
};
49+
// looks for the assembly from the resources and load it
50+
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
51+
{
52+
if (stream != null)
53+
{
54+
Byte[] assemblyData = new Byte[stream.Length];
55+
stream.Read(assemblyData, 0, assemblyData.Length);
56+
Assembly assembly = Assembly.Load(assemblyData);
57+
loadedAssemblies[resourceName] = assembly;
58+
return assembly;
59+
}
60+
}
6261

62+
return null;
63+
};
64+
}
65+
};
6366

64-
}
67+
private static AssemblyLoader assemblyLoader = new AssemblyLoader();
68+
};
69+
}

src/embed_tests/packages.config

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
23
<packages>
34
<package id="NUnit" version="2.6.2" targetFramework="net40" />
45
</packages>

src/embed_tests/pyimport.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void SetUp()
2020
//string here = Environment.CurrentDirectory;
2121
//trunk\pythonnet\src\embed_tests\bin\x86\DebugWin
2222

23-
/*
23+
/*
2424
* Append the tests directory to sys.path
2525
* using reflection to circumvent the private modifires placed on most Runtime methods.
2626
*/
@@ -29,19 +29,21 @@ public void SetUp()
2929
Type RTClass = typeof(Runtime.Runtime);
3030

3131
/* pyStrPtr = PyString_FromString(s); */
32-
MethodInfo PyString_FromString = RTClass.GetMethod("PyString_FromString", BindingFlags.NonPublic | BindingFlags.Static);
32+
MethodInfo PyString_FromString = RTClass.GetMethod("PyString_FromString",
33+
BindingFlags.NonPublic | BindingFlags.Static);
3334
object[] funcArgs = new object[1];
3435
funcArgs[0] = s;
3536
IntPtr pyStrPtr = (IntPtr)PyString_FromString.Invoke(null, funcArgs);
3637

3738
/* SysDotPath = sys.path */
38-
MethodInfo PySys_GetObject = RTClass.GetMethod("PySys_GetObject", BindingFlags.NonPublic | BindingFlags.Static);
39+
MethodInfo PySys_GetObject = RTClass.GetMethod("PySys_GetObject",
40+
BindingFlags.NonPublic | BindingFlags.Static);
3941
funcArgs[0] = "path";
4042
IntPtr SysDotPath = (IntPtr)PySys_GetObject.Invoke(null, funcArgs);
4143

4244
/* SysDotPath.append(*pyStrPtr) */
4345
MethodInfo PyList_Append = RTClass.GetMethod("PyList_Append", BindingFlags.NonPublic | BindingFlags.Static);
44-
funcArgs = new object[] {SysDotPath, pyStrPtr};
46+
funcArgs = new object[] { SysDotPath, pyStrPtr };
4547
int r = (int)PyList_Append.Invoke(null, funcArgs);
4648
}
4749

@@ -57,7 +59,7 @@ public void TearDown()
5759
/// </summary>
5860
/// <remarks>
5961
/// The required directory structure was added to the \trunk\pythonnet\src\tests directory:
60-
///
62+
///
6163
/// PyImportTest/
6264
/// __init__.py
6365
/// test/

src/embed_tests/pyiter.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public void TestOnPyList()
3535
foreach (PyObject item in list)
3636
result.Add(item.ToString());
3737
Assert.AreEqual(3, result.Count);
38-
Assert.AreEqual("foo",result[0]);
39-
Assert.AreEqual("bar",result[1]);
40-
Assert.AreEqual("baz",result[2]);
38+
Assert.AreEqual("foo", result[0]);
39+
Assert.AreEqual("bar", result[1]);
40+
Assert.AreEqual("baz", result[2]);
4141
}
4242
}
43-
}
43+
}

src/embed_tests/pyobject.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void TearDown()
2727
public void TestUnicode()
2828
{
2929
PyObject s = new PyString("foo\u00e9");
30-
Assert.AreEqual("foo\u00e9",s.ToString());
30+
Assert.AreEqual("foo\u00e9", s.ToString());
3131
}
3232
}
33-
}
33+
}

src/embed_tests/pythonexception.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ public void TestNoError()
4444
Assert.AreEqual("", e.Message);
4545
}
4646
}
47-
}
47+
}

src/monoclr/clrmod.c

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.1 (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-
//
101
// Author: Christian Heimes <christian(at)cheimes(dot)de>
112

12-
#include "pynetclr.h"
3+
#include "pynetclr.h"
134

145
/* List of functions defined in the module */
156
static PyMethodDef clr_methods[] = {
@@ -75,4 +66,3 @@ initclr(void) {
7566
_initclr();
7667
}
7768
#endif
78-

0 commit comments

Comments
 (0)