Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Mono dependency removed from Linux build.
  • Loading branch information
dmitriyse authored and vmuriart committed Feb 6, 2017
commit 50e7915fb0dd793f364d3002fcc29d0c2138d9c9
44 changes: 0 additions & 44 deletions src/runtime/monosupport.cs

This file was deleted.

30 changes: 24 additions & 6 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
using System.Security;
using System.Text;

#if UCS4
using Mono.Unix;
#endif

namespace Python.Runtime
{
[SuppressUnmanagedCodeSecurity()]
Expand Down Expand Up @@ -1656,10 +1652,32 @@ internal unsafe static extern IntPtr
ExactSpelling = true)]
internal unsafe static extern IntPtr
PyUnicode_FromKindAndString(int kind,
[MarshalAs(UnmanagedType.CustomMarshaler,
MarshalTypeRef = typeof(Utf32Marshaler))] string s,
IntPtr s,
int size);

internal static unsafe IntPtr PyUnicode_FromKindAndString(int kind,
string s,
int size)
{
var bufLength = Math.Max(s.Length, size) * 4;

IntPtr mem = Marshal.AllocHGlobal(bufLength);
try
{
fixed (char* ps = s)
{
Encoding.UTF32.GetBytes(ps, s.Length, (byte*)mem, bufLength);
}

var result = PyUnicode_FromKindAndString(kind, mem, bufLength);
return result;
}
finally
{
Marshal.FreeHGlobal(mem);
}
}

internal static IntPtr PyUnicode_FromUnicode(string s, int size)
{
return PyUnicode_FromKindAndString(4, s, size);
Expand Down