Skip to content

Commit 198f654

Browse files
committed
Remove mono dependency from PY2 as well.
1 parent 50e7915 commit 198f654

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

‎src/runtime/Python.Runtime.csproj‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
<CompileInclude="modulefunctionobject.cs" />
117117
<CompileInclude="moduleobject.cs" />
118118
<CompileInclude="modulepropertyobject.cs" />
119-
<CompileInclude="monosupport.cs" />
120119
<CompileInclude="nativecall.cs" />
121120
<CompileInclude="overload.cs" />
122121
<CompileInclude="propertyobject.cs" />

‎src/runtime/runtime.cs‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,9 +1720,28 @@ internal unsafe static extern IntPtr
17201720
EntryPoint= "PyUnicodeUCS4_FromUnicode",
17211721
ExactSpelling= true)]
17221722
internal unsafe staticexternIntPtr
1723-
PyUnicode_FromUnicode(
1724-
[MarshalAs(UnmanagedType.CustomMarshaler,
1725-
MarshalTypeRef=typeof(Utf32Marshaler))]string s,intsize);
1723+
PyUnicode_FromUnicode(IntPtrs,intsize);
1724+
1725+
internal static unsafe IntPtr PyUnicode_FromUnicode(strings,intsize)
1726+
{
1727+
var bufLength =Math.Max(s.Length,size)*4;
1728+
1729+
IntPtr mem =Marshal.AllocHGlobal(bufLength);
1730+
try
1731+
{
1732+
fixed (char*ps= s)
1733+
{
1734+
Encoding.UTF32.GetBytes(ps,s.Length,(byte*)mem,bufLength);
1735+
}
1736+
1737+
var result =PyUnicode_FromUnicode(mem,bufLength);
1738+
returnresult;
1739+
}
1740+
finally
1741+
{
1742+
Marshal.FreeHGlobal(mem);
1743+
}
1744+
}
17261745

17271746
[DllImport(Runtime.dll,CallingConvention=CallingConvention.Cdecl,
17281747
EntryPoint= "PyUnicodeUCS4_GetSize",

0 commit comments

Comments
(0)