| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -686,10 +686,8 @@ internal static bool ToPrimitive(BorrowedReference value, Type obType, out objec | |||
| 686 | 686 | { | |
| 687 | 687 | if (Runtime.PyUnicode_GetLength(value) == 1) | |
| 688 | 688 | { | |
| 689 | - IntPtr unicodePtr = Runtime.PyUnicode_AsUnicode(value); | ||
| 690 | - Char[] buff = new Char[1]; | ||
| 691 | - Marshal.Copy(unicodePtr, buff, 0, 1); | ||
| 692 | - result = buff[0]; | ||
| 689 | + int chr = Runtime.PyUnicode_ReadChar(value, 0); | ||
| 690 | + result = (Char)chr; | ||
| 693 | 691 | return true; | |
| 694 | 692 | } | |
| 695 | 693 | goto type_error; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,8 +164,8 @@ static Delegates() | |||
| 164 | 164 | PyUnicode_AsUTF8 = (delegate* unmanaged[Cdecl]<BorrowedReference, IntPtr>)GetFunctionByName(nameof(PyUnicode_AsUTF8), GetUnmanagedDll(_PythonDll)); | |
| 165 | 165 | PyUnicode_DecodeUTF16 = (delegate* unmanaged[Cdecl]<IntPtr, nint, IntPtr, IntPtr, NewReference>)GetFunctionByName(nameof(PyUnicode_DecodeUTF16), GetUnmanagedDll(_PythonDll)); | |
| 166 | 166 | PyUnicode_GetLength = (delegate* unmanaged[Cdecl]<BorrowedReference, nint>)GetFunctionByName(nameof(PyUnicode_GetLength), GetUnmanagedDll(_PythonDll)); | |
| 167 | - PyUnicode_AsUnicode = (delegate* unmanaged[Cdecl]<BorrowedReference, IntPtr>)GetFunctionByName(nameof(PyUnicode_AsUnicode), GetUnmanagedDll(_PythonDll)); | ||
| 168 | 167 | PyUnicode_AsUTF16String = (delegate* unmanaged[Cdecl]<BorrowedReference, NewReference>)GetFunctionByName(nameof(PyUnicode_AsUTF16String), GetUnmanagedDll(_PythonDll)); | |
| 168 | + PyUnicode_ReadChar = (delegate* unmanaged[Cdecl]<BorrowedReference, nint, int>)GetFunctionByName(nameof(PyUnicode_ReadChar), GetUnmanagedDll(_PythonDll)); | ||
| 169 | 169 | PyUnicode_FromOrdinal = (delegate* unmanaged[Cdecl]<int, NewReference>)GetFunctionByName(nameof(PyUnicode_FromOrdinal), GetUnmanagedDll(_PythonDll)); | |
| 170 | 170 | PyUnicode_InternFromString = (delegate* unmanaged[Cdecl]<StrPtr, NewReference>)GetFunctionByName(nameof(PyUnicode_InternFromString), GetUnmanagedDll(_PythonDll)); | |
| 171 | 171 | PyUnicode_Compare = (delegate* unmanaged[Cdecl]<BorrowedReference, BorrowedReference, int>)GetFunctionByName(nameof(PyUnicode_Compare), GetUnmanagedDll(_PythonDll)); | |
@@ -441,7 +441,7 @@ static Delegates() | |||
| 441 | 441 | internal static delegate* unmanaged[Cdecl]<BorrowedReference, IntPtr> PyUnicode_AsUTF8 { get; } | |
| 442 | 442 | internal static delegate* unmanaged[Cdecl]<IntPtr, nint, IntPtr, IntPtr, NewReference> PyUnicode_DecodeUTF16 { get; } | |
| 443 | 443 | internal static delegate* unmanaged[Cdecl]<BorrowedReference, nint> PyUnicode_GetLength { get; } | |
| 444 | - internal static delegate* unmanaged[Cdecl]<BorrowedReference, IntPtr> PyUnicode_AsUnicode { get; } | ||
| 444 | + internal static delegate* unmanaged[Cdecl]<BorrowedReference, nint, int> PyUnicode_ReadChar { get; } | ||
| 445 | 445 | internal static delegate* unmanaged[Cdecl]<BorrowedReference, NewReference> PyUnicode_AsUTF16String { get; } | |
| 446 | 446 | internal static delegate* unmanaged[Cdecl]<int, NewReference> PyUnicode_FromOrdinal { get; } | |
| 447 | 447 | internal static delegate* unmanaged[Cdecl]<StrPtr, NewReference> PyUnicode_InternFromString { get; } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1290,9 +1290,10 @@ internal static IntPtr PyBytes_AsString(BorrowedReference ob) | |||
| 1290 | 1290 | internal static nint PyUnicode_GetLength(BorrowedReference ob) => Delegates.PyUnicode_GetLength(ob); | |
| 1291 | 1291 | ||
| 1292 | 1292 | ||
| 1293 | - internal static IntPtr PyUnicode_AsUnicode(BorrowedReference ob) => Delegates.PyUnicode_AsUnicode(ob); | ||
| 1294 | 1293 | internal static NewReference PyUnicode_AsUTF16String(BorrowedReference ob) => Delegates.PyUnicode_AsUTF16String(ob); | |
| 1295 | 1294 | ||
| 1295 | + internal static int PyUnicode_ReadChar(BorrowedReference ob, nint index) => Delegates.PyUnicode_ReadChar(ob, index); | ||
| 1296 | + | ||
| 1296 | 1297 | ||
| 1297 | 1298 | ||
| 1298 | 1299 | internal static NewReference PyUnicode_FromOrdinal(int c) => Delegates.PyUnicode_FromOrdinal(c); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments