Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
/pythonnetPublic archive
forked frompythonnet/pythonnet

Commitf41cf63

Browse files
committed
Format, white-space .cs files
1 parentec678f7 commitf41cf63

File tree

96 files changed

+6901
-5881
lines changed

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

Lines changed: 16 additions & 21 deletions
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
usingSystem;
2625

2726

28-
2927
publicclassclrModule
30-
31-
3228
{
33-
3429
#if(PYTHON32||PYTHON33||PYTHON34||PYTHON35)
3530
[RGiesecke.DllExport.DllExport("PyInit_clr",System.Runtime.InteropServices.CallingConvention.StdCall)]
3631
publicstaticIntPtrPyInit_clr()
3732
#else
3833
[RGiesecke.DllExport.DllExport("initclr",System.Runtime.InteropServices.CallingConvention.StdCall)]
3934
publicstaticvoidinitclr()
4035
#endif
41-
4236
{
4337
#ifDEBUG_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
varpythonRuntimeName=newSystem.Reflection.AssemblyName("Python.Runtime")
57-
{
51+
{
5852
#ifUSE_PYTHON_RUNTIME_VERSION
59-
Version=newSystem.Version("4.0.0.1"),
53+
Version=newSystem.Version("4.0.0.1"),
6054
#endif
61-
CultureInfo= System.Globalization.CultureInfo.InvariantCulture,
62-
};
55+
CultureInfo= System.Globalization.CultureInfo.InvariantCulture,
56+
};
6357
#ifUSE_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
varexecutingAssembly=System.Reflection.Assembly.GetExecutingAssembly();
8983
varassemblyDirectory=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
#ifDEBUG_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
varpythonEngineType=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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
usingSystem.Runtime.CompilerServices;
33
usingSystem.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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
23
<packages>
34
<packageid="UnmanagedExports"version="1.2.6"targetFramework="net40" />
45
</packages>

‎src/console/app.config

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

‎src/console/assemblyinfo.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
usingSystem;
32
usingSystem.Reflection;
43
usingSystem.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

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,69 @@
1-
21
usingSystem;
32
usingSystem.Reflection;
43
usingSystem.Collections.Generic;
54
usingPython.Runtime;
65

7-
namespacePython.Runtime{
8-
9-
publicsealedclassPythonConsole{
10-
11-
privatePythonConsole(){}
12-
13-
[STAThread]
14-
publicstaticintMain(string[]args){
15-
// reference the static assemblyLoader to stop it being optimized away
16-
AssemblyLoadera=assemblyLoader;
6+
namespacePython.Runtime
7+
{
8+
publicsealedclassPythonConsole
9+
{
10+
privatePythonConsole()
11+
{
12+
}
1713

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

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

24-
returni;
25-
}
23+
inti=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-
privatesealedclassAssemblyLoader{
30-
Dictionary<string,Assembly>loadedAssemblies;
26+
returni;
27+
}
3128

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

35-
AppDomain.CurrentDomain.AssemblyResolve+=(sender,args)=>{
36-
stringshortName=args.Name.Split(',')[0];
37-
StringresourceName=shortName+".dll";
35+
publicAssemblyLoader()
36+
{
37+
loadedAssemblies=newDictionary<string,Assembly>();
3838

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

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

54-
returnnull;
55-
};
56-
}
57-
};
58-
59-
privatestaticAssemblyLoaderassemblyLoader=newAssemblyLoader();
60-
61-
};
49+
// looks for the assembly from the resources and load it
50+
using(varstream=Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
51+
{
52+
if(stream!=null)
53+
{
54+
Byte[]assemblyData=newByte[stream.Length];
55+
stream.Read(assemblyData,0,assemblyData.Length);
56+
Assemblyassembly=Assembly.Load(assemblyData);
57+
loadedAssemblies[resourceName]=assembly;
58+
returnassembly;
59+
}
60+
}
6261

62+
returnnull;
63+
};
64+
}
65+
};
6366

64-
}
67+
privatestaticAssemblyLoaderassemblyLoader=newAssemblyLoader();
68+
};
69+
}

‎src/embed_tests/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
23
<packages>
34
<packageid="NUnit"version="2.6.2"targetFramework="net40" />
45
</packages>

‎src/embed_tests/pyimport.cs

Lines changed: 7 additions & 5 deletions
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
TypeRTClass=typeof(Runtime.Runtime);
3030

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

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

4244
/* SysDotPath.append(*pyStrPtr) */
4345
MethodInfoPyList_Append=RTClass.GetMethod("PyList_Append",BindingFlags.NonPublic|BindingFlags.Static);
44-
funcArgs=newobject[]{SysDotPath,pyStrPtr};
46+
funcArgs=newobject[]{SysDotPath,pyStrPtr};
4547
intr=(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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public void TestOnPyList()
3535
foreach(PyObjectiteminlist)
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void TearDown()
2727
publicvoidTestUnicode()
2828
{
2929
PyObjects=newPyString("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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 11 deletions
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
staticPyMethodDefclr_methods[]= {
@@ -75,4 +66,3 @@ initclr(void) {
7566
_initclr();
7667
}
7768
#endif
78-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp