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

Commit895516e

Browse files
committed
Refactor runtime.cs
1 parent85c85f2 commit895516e

File tree

1 file changed

+8
-40
lines changed

1 file changed

+8
-40
lines changed

‎src/runtime/runtime.cs

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -565,18 +565,11 @@ internal static unsafe void XDecref(IntPtr op)
565565
internalstatic unsafelong Refcount(IntPtrop)
566566
{
567567
var p=(void*)op;
568-
if((void*)0!=p)
568+
if((void*)0==p)
569569
{
570-
if(Is32Bit)
571-
{
572-
return(*(int*)p);
573-
}
574-
else
575-
{
576-
return(*(long*)p);
577-
}
570+
return0;
578571
}
579-
return0;
572+
returnIs32Bit?(*(int*)p):(*(long*)p);
580573
}
581574

582575
#ifPYTHON_WITH_PYDEBUG
@@ -676,25 +669,6 @@ public static extern int Py_Main(
676669
[DllImport(PythonDll)]
677670
internalstaticexternIntPtr PyEval_GetLocals();
678671

679-
#ifPYTHON3
680-
[DllImport(PythonDll)]
681-
internalstaticexternIntPtr Py_GetProgramName();
682-
683-
[DllImport(PythonDll)]
684-
internalstaticexternvoidPy_SetProgramName(IntPtrname);
685-
686-
[DllImport(PythonDll)]
687-
internalstaticexternIntPtr Py_GetPythonHome();
688-
689-
[DllImport(PythonDll)]
690-
internalstaticexternvoidPy_SetPythonHome(IntPtrhome);
691-
692-
[DllImport(PythonDll)]
693-
internalstaticexternIntPtr Py_GetPath();
694-
695-
[DllImport(PythonDll)]
696-
internalstaticexternvoidPy_SetPath(IntPtrhome);
697-
#elifPYTHON2
698672
[DllImport(PythonDll)]
699673
internalstaticexternIntPtr Py_GetProgramName();
700674

@@ -712,7 +686,6 @@ public static extern int Py_Main(
712686

713687
[DllImport(PythonDll)]
714688
internalstaticexternvoidPy_SetPath(IntPtrhome);
715-
#endif
716689

717690
[DllImport(PythonDll)]
718691
internalstaticexternIntPtr Py_GetVersion();
@@ -781,20 +754,15 @@ internal static unsafe IntPtr PyObject_TYPE(IntPtr op)
781754
#else
782755
var n=1;
783756
#endif
784-
if(Is32Bit)
785-
{
786-
returnnewIntPtr((void*)(*((uint*)p+ n)));
787-
}
788-
else
789-
{
790-
returnnew IntPtr((void*)(*((ulong*)p+ n)));
791-
}
757+
returnIs32Bit
758+
?newIntPtr((void*)(*((uint*)p+ n)))
759+
:new IntPtr((void*)(*((ulong*)p+ n)));
792760
}
793761

794762
/// <summary>
795763
/// Managed version of the standard Python C API PyObject_Type call.
796-
/// This version avoids a managed &lt;-&gt; unmanaged transition. This one
797-
/// does incref the returned type object.
764+
/// This version avoids a managed &lt;-&gt; unmanaged transition.
765+
///This onedoes incref the returned type object.
798766
/// </summary>
799767
internalstatic IntPtr PyObject_Type(IntPtrop)
800768
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp