Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
/pythonnetPublic archive
forked frompythonnet/pythonnet

Commitffe6448

Browse files
committed
Rename internal StrMarshaler to UcsMarshaler
To clarify that this is meant to be applied on Unicode type IntPtr and not strings like ones.Made Marshalers internal, don't see a reason to expose it.
1 parent0cfc67a commitffe6448

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

‎src/runtime/CustomMarshaler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Python.Runtime
99
/// Abstract class defining boiler plate methods that
1010
/// Custom Marshalers will use.
1111
/// </summary>
12-
publicabstractclassMarshalerBase:ICustomMarshaler
12+
internalabstractclassMarshalerBase:ICustomMarshaler
1313
{
1414
publicobjectMarshalNativeToManaged(IntPtrpNativeData)
1515
{
@@ -39,9 +39,9 @@ public int GetNativeDataSize()
3939
/// Custom Marshaler to deal with Managed String to Native
4040
/// conversion differences on UCS2/UCS4.
4141
/// </summary>
42-
publicclassStrMarshaler:MarshalerBase
42+
internalclassUcsMarshaler:MarshalerBase
4343
{
44-
privatestaticreadonlyMarshalerBaseInstance=newStrMarshaler();
44+
privatestaticreadonlyMarshalerBaseInstance=newUcsMarshaler();
4545
privatestaticreadonlyEncodingPyEncoding=Runtime.PyEncoding;
4646

4747
publicoverrideIntPtrMarshalManagedToNative(objectmanagedObj)
@@ -106,7 +106,7 @@ public static int GetUnicodeByteLength(IntPtr p)
106106
/// Custom Marshaler to deal with Managed String Arrays to Native
107107
/// conversion differences on UCS2/UCS4.
108108
/// </summary>
109-
publicclassStrArrayMarshaler:MarshalerBase
109+
internalclassStrArrayMarshaler:MarshalerBase
110110
{
111111
privatestaticreadonlyMarshalerBaseInstance=newStrArrayMarshaler();
112112
privatestaticreadonlyEncodingPyEncoding=Runtime.PyEncoding;
@@ -161,7 +161,7 @@ public static ICustomMarshaler GetInstance(string cookie)
161161
/// If instead we used `MarshalAs(UnmanagedType.LPWStr)` the output to
162162
/// `foo` would be `f\x00o\x00o\x00`.
163163
/// </remarks>
164-
publicclassUtf8Marshaler:MarshalerBase
164+
internalclassUtf8Marshaler:MarshalerBase
165165
{
166166
privatestaticreadonlyMarshalerBaseInstance=newUtf8Marshaler();
167167
privatestaticreadonlyEncodingPyEncoding=Encoding.UTF8;

‎src/runtime/pythonengine.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static string ProgramName
5959
{
6060
IntPtrp=Runtime.Py_GetProgramName();
6161
stringresult=Runtime.IsPython3
62-
?StrMarshaler.PtrToStringUni(p)
62+
?UcsMarshaler.PtrToStringUni(p)
6363
:Marshal.PtrToStringAnsi(p);
6464

6565
returnresult??"";
@@ -73,7 +73,7 @@ public static string PythonHome
7373
{
7474
IntPtrp=Runtime.Py_GetPythonHome();
7575
stringresult=Runtime.IsPython3
76-
?StrMarshaler.PtrToStringUni(p)
76+
?UcsMarshaler.PtrToStringUni(p)
7777
:Marshal.PtrToStringAnsi(p);
7878

7979
returnresult??"";
@@ -87,7 +87,7 @@ public static string PythonPath
8787
{
8888
IntPtrp=Runtime.Py_GetPath();
8989
stringresult=Runtime.IsPython3
90-
?StrMarshaler.PtrToStringUni(p)
90+
?UcsMarshaler.PtrToStringUni(p)
9191
:Marshal.PtrToStringAnsi(p);
9292

9393
returnresult??"";

‎src/runtime/runtime.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ internal static bool PyUnicode_Check(IntPtr ob)
12391239
[DllImport(PythonDll)]
12401240
internalstaticexternIntPtrPyUnicode_FromKindAndData(
12411241
intkind,
1242-
[MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(StrMarshaler))]string s,
1242+
[MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(UcsMarshaler))]string s,
12431243
intsize
12441244
);
12451245

@@ -1265,7 +1265,7 @@ internal static IntPtr PyUnicode_FromUnicode(string s, int size)
12651265

12661266
[DllImport(PythonDll,EntryPoint=PyUnicodeEntryPoint+ "FromUnicode")]
12671267
internalstaticexternIntPtr PyUnicode_FromUnicode(
1268-
[MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(StrMarshaler))]strings,
1268+
[MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(UcsMarshaler))]strings,
12691269
intsize
12701270
);
12711271

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp