Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c575b43

Browse files
committed
Revert "Remove IntPtr cast to int/long"
This reverts commit 7d0f1e3.
1 parent 7d0f1e3 commit c575b43

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/runtime/clrobject.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ internal CLRObject(object ob, IntPtr tp)
1111
{
1212
IntPtr py = Runtime.PyType_GenericAlloc(tp, 0);
1313

14-
IntPtr flags = Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
15-
if (flags != IntPtr.Zero && TypeFlags.Subclass != 0)
14+
var flags = (long)Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
15+
if ((flags & TypeFlags.Subclass) != 0)
1616
{
1717
IntPtr dict = Marshal.ReadIntPtr(py, ObjectOffset.DictOffset(tp));
1818
if (dict == IntPtr.Zero)

src/runtime/managedtype.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ internal static ManagedType GetManagedObject(IntPtr ob)
2828
tp = ob;
2929
}
3030

31-
IntPtr flags = Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
32-
if (flags != IntPtr.Zero && TypeFlags.Subclass != 0)
31+
var flags = (long)Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
32+
if ((flags & TypeFlags.Managed) != 0)
3333
{
3434
IntPtr op = tp == ob
3535
? Marshal.ReadIntPtr(tp, TypeOffset.magic())
@@ -63,8 +63,8 @@ internal static bool IsManagedType(IntPtr ob)
6363
tp = ob;
6464
}
6565

66-
IntPtr flags = Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
67-
if (flags != IntPtr.Zero && TypeFlags.Subclass != 0)
66+
var flags = (long)Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
67+
if ((flags & TypeFlags.Managed) != 0)
6868
{
6969
return true;
7070
}

src/runtime/metatype.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ public static void tp_dealloc(IntPtr tp)
247247
{
248248
// Fix this when we dont cheat on the handle for subclasses!
249249

250-
IntPtr flags = Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
251-
if (flags != IntPtr.Zero && TypeFlags.Subclass != 0)
250+
var flags = (long)Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
251+
if ((flags & TypeFlags.Subclass) == 0)
252252
{
253253
IntPtr gc = Marshal.ReadIntPtr(tp, TypeOffset.magic());
254254
((GCHandle)gc).Free();

0 commit comments

Comments
 (0)