Skip to content

Commit 0b988d2

Browse files
committed
Mono dependency removed from Linux build.
1 parent dca0737 commit 0b988d2

File tree

3 files changed

+25
-57
lines changed

3 files changed

+25
-57
lines changed

src/Python.Runtime/Python.Runtime.xproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
88
<PropertyGroup Label="Globals">
99
<ProjectGuid>c41b9f67-571d-4852-b7c4-b54e84dcbcdc</ProjectGuid>
10-
<RootNamespace>runtime.x</RootNamespace>
10+
<RootNamespace>Python.Runtime</RootNamespace>
1111
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
1212
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
1313
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

src/Python.Runtime/monosupport.cs

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

src/Python.Runtime/runtime.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#if (UCS4)
88
using System.Text;
9-
using Mono.Unix;
109

1110
#endif
1211

@@ -1766,10 +1765,32 @@ internal unsafe static extern IntPtr
17661765
ExactSpelling = true)]
17671766
internal unsafe static extern IntPtr
17681767
PyUnicode_FromKindAndString(int kind,
1769-
[MarshalAs (UnmanagedType.CustomMarshaler,
1770-
MarshalTypeRef=typeof(Utf32Marshaler))] string s,
1768+
IntPtr s,
17711769
int size);
17721770

1771+
internal static unsafe IntPtr PyUnicode_FromKindAndString(int kind,
1772+
string s,
1773+
int size)
1774+
{
1775+
var bufLength = Math.Max(s.Length, size) * 4;
1776+
1777+
IntPtr mem = Marshal.AllocHGlobal(bufLength);
1778+
try
1779+
{
1780+
fixed(char* ps = s)
1781+
{
1782+
Encoding.UTF32.GetBytes(ps, s.Length, (byte*)mem, bufLength);
1783+
}
1784+
1785+
var result = PyUnicode_FromKindAndString(kind, mem, bufLength);
1786+
return result;
1787+
}
1788+
finally
1789+
{
1790+
Marshal.FreeHGlobal(mem);
1791+
}
1792+
}
1793+
17731794
internal static IntPtr PyUnicode_FromUnicode(string s, int size) {
17741795
return PyUnicode_FromKindAndString(4, s, size);
17751796
}

0 commit comments

Comments
 (0)