Skip to content

Commit f04e948

Browse files
committed
First chunk of modernisation changes
- Move projects around and add clean project/solution files - Drop monoclr and clrmodule - Add stub clr module - Drop nuget config - Add test helper project - Drop PYTHON3 flag (default now) - Remove unneeded additional interop files - Make NETSTANDARD the default Drops also - Custom XDecref/XIncref (should be readded) - Remote object handling for .NET Framework - Remove Runtime._UCS dependency from CustomMarshaler - Stop using Runtime.IsPython2/3
1 parent 2a83fe5 commit f04e948

File tree

207 files changed

+402
-3994
lines changed

Some content is hidden

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

207 files changed

+402
-3994
lines changed

NuGet.config

Lines changed: 0 additions & 7 deletions
This file was deleted.

Python.Runtime/AssemblyInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using System;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: CLSCompliant(true)]
5+
[assembly: InternalsVisibleTo("Python.Test.Embed")]

src/runtime/CustomMarshaler.cs renamed to Python.Runtime/CustomMarshaler.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ public static int GetUnicodeByteLength(IntPtr p)
9191
var len = 0;
9292
while (true)
9393
{
94-
int c = Runtime._UCS == 2
95-
? Marshal.ReadInt16(p, len * 2)
96-
: Marshal.ReadInt32(p, len * 4);
94+
#if UCS2
95+
int c = Marshal.ReadInt16(p, len * 2);
96+
#else
97+
int c = Marshal.ReadInt32(p, len * 4);
98+
#endif
9799

98100
if (c == 0)
99101
{
@@ -120,9 +122,11 @@ public static int GetUnicodeByteLength(IntPtr p)
120122
/// </remarks>
121123
public static IntPtr Py3UnicodePy2StringtoPtr(string s)
122124
{
123-
return Runtime.IsPython3
124-
? Instance.MarshalManagedToNative(s)
125-
: Marshal.StringToHGlobalAnsi(s);
125+
#if PYTHON2
126+
return Marshal.StringToHGlobalAnsi(s);
127+
#else
128+
return Instance.MarshalManagedToNative(s);
129+
#endif
126130
}
127131

128132
/// <summary>
@@ -137,9 +141,11 @@ public static IntPtr Py3UnicodePy2StringtoPtr(string s)
137141
/// </returns>
138142
public static string PtrToPy3UnicodePy2String(IntPtr p)
139143
{
140-
return Runtime.IsPython3
141-
? PtrToStringUni(p)
142-
: Marshal.PtrToStringAnsi(p);
144+
#if PYTHON2
145+
return Marshal.PtrToStringAnsi(p);
146+
#else
147+
return PtrToStringUni(p);
148+
#endif
143149
}
144150
}
145151

Python.Runtime/Python.Runtime.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="System.Reflection.Emit" Version="4.6.0" />
10+
</ItemGroup>
11+
12+
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)