Skip to content

Commit 50e7915

Browse files
dmitriysevmuriart
authored andcommitted
Mono dependency removed from Linux build.
1 parent 4f71a94 commit 50e7915

File tree

2 files changed

+24
-50
lines changed

2 files changed

+24
-50
lines changed

src/runtime/monosupport.cs

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

src/runtime/runtime.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
using System.Security;
44
using System.Text;
55

6-
#if UCS4
7-
using Mono.Unix;
8-
#endif
9-
106
namespace Python.Runtime
117
{
128
[SuppressUnmanagedCodeSecurity()]
@@ -1656,10 +1652,32 @@ internal unsafe static extern IntPtr
16561652
ExactSpelling = true)]
16571653
internal unsafe static extern IntPtr
16581654
PyUnicode_FromKindAndString(int kind,
1659-
[MarshalAs(UnmanagedType.CustomMarshaler,
1660-
MarshalTypeRef = typeof(Utf32Marshaler))] string s,
1655+
IntPtr s,
16611656
int size);
16621657

1658+
internal static unsafe IntPtr PyUnicode_FromKindAndString(int kind,
1659+
string s,
1660+
int size)
1661+
{
1662+
var bufLength = Math.Max(s.Length, size) * 4;
1663+
1664+
IntPtr mem = Marshal.AllocHGlobal(bufLength);
1665+
try
1666+
{
1667+
fixed (char* ps = s)
1668+
{
1669+
Encoding.UTF32.GetBytes(ps, s.Length, (byte*)mem, bufLength);
1670+
}
1671+
1672+
var result = PyUnicode_FromKindAndString(kind, mem, bufLength);
1673+
return result;
1674+
}
1675+
finally
1676+
{
1677+
Marshal.FreeHGlobal(mem);
1678+
}
1679+
}
1680+
16631681
internal static IntPtr PyUnicode_FromUnicode(string s, int size)
16641682
{
16651683
return PyUnicode_FromKindAndString(4, s, size);

0 commit comments

Comments
 (0)