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

Commit8e54d26

Browse files
committed
Code review adjustments
- Use `BorrowedReference` where applicable- Readd `OperatingSystemName` and `MachineName` for now
1 parentc6ae15b commit8e54d26

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

‎src/runtime/runtime.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
usingSystem.Reflection.Emit;
12
usingSystem;
23
usingSystem.Diagnostics.Contracts;
34
usingSystem.Runtime.InteropServices;
@@ -118,6 +119,12 @@ public class Runtime
118119
{"Linux",OperatingSystemType.Linux},
119120
};
120121

122+
[Obsolete]
123+
publicstaticstringOperatingSystemName=>OperatingSystem.ToString();
124+
125+
[Obsolete]
126+
publicstaticstringMachineName=>Machine.ToString();
127+
121128
/// <summary>
122129
/// Gets the operating system as reported by python's platform.system().
123130
/// </summary>
@@ -1990,10 +1997,10 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size)
19901997
//====================================================================
19911998

19921999
[DllImport(_PythonDll, CallingConvention= CallingConvention.Cdecl)]
1993-
internalstaticextern NewReference PyCell_Get(IntPtr cell);
2000+
internalstaticextern NewReference PyCell_Get(BorrowedReference cell);
19942001

19952002
[DllImport(_PythonDll, CallingConvention= CallingConvention.Cdecl)]
1996-
internalstaticexternint PyCell_Set(IntPtr cell, IntPtr value);
2003+
internalstaticexternint PyCell_Set(BorrowedReference cell, IntPtr value);
19972004

19982005
//====================================================================
19992006
// Miscellaneous

‎src/runtime/typemanager.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ internal static IntPtr CreateSubType(IntPtr py_name, IntPtr py_base_type, IntPtr
281281
Runtime.PyDict_Update(cls_dict,py_dict);
282282

283283
// Update the __classcell__ if it exists
284-
IntPtrcell=Runtime.PyDict_GetItemString(cls_dict,"__classcell__");
285-
if(cell!=IntPtr.Zero)
284+
varcell=newBorrowedReference(Runtime.PyDict_GetItemString(cls_dict,"__classcell__"));
285+
if(!cell.IsNull)
286286
{
287287
Runtime.PyCell_Set(cell,py_type);
288288
Runtime.PyDict_DelItemString(cls_dict,"__classcell__");
@@ -625,7 +625,9 @@ int MAP_ANONYMOUS
625625
caseOperatingSystemType.Linux:
626626
return0x20;
627627
default:
628-
thrownewNotImplementedException($"mmap is not supported on this operating system");
628+
thrownewNotImplementedException(
629+
$"mmap is not supported on{Runtime.OperatingSystem}"
630+
);
629631
}
630632
}
631633
}
@@ -659,7 +661,9 @@ internal static IMemoryMapper CreateMemoryMapper()
659661
caseOperatingSystemType.Windows:
660662
returnnewWindowsMemoryMapper();
661663
default:
662-
thrownewNotImplementedException($"No support for this operating system");
664+
thrownewNotImplementedException(
665+
$"No support for{Runtime.OperatingSystem}"
666+
);
663667
}
664668
}
665669

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp