| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ public void CanCreateHeapType() | |||
| 31 | 31 | using var doc = new StrPtr(docStr, Encoding.UTF8); | |
| 32 | 32 | var spec = new TypeSpec( | |
| 33 | 33 | name: name, | |
| 34 | - basicSize: Marshal.ReadInt32(Runtime.Runtime.PyBaseObjectType, TypeOffset.tp_basicsize), | ||
| 34 | + basicSize: Util.ReadInt32(Runtime.Runtime.PyBaseObjectType, TypeOffset.tp_basicsize), | ||
| 35 | 35 | slots: new TypeSpec.Slot[] { | |
| 36 | 36 | new (TypeSlotID.tp_doc, doc.RawPointer), | |
| 37 | 37 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,7 +52,7 @@ internal static void DumpType(BorrowedReference type) | |||
| 52 | 52 | objMember = Util.ReadRef(type, TypeOffset.tp_bases); | |
| 53 | 53 | Print(" bases: ", objMember); | |
| 54 | 54 | ||
| 55 | - //op = Marshal.ReadIntPtr(type, TypeOffset.tp_mro); | ||
| 55 | + //op = Util.ReadIntPtr(type, TypeOffset.tp_mro); | ||
| 56 | 56 | //DebugUtil.Print(" mro: ", op); | |
| 57 | 57 | ||
| 58 | 58 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ public ExtensionType() | |||
| 20 | 20 | ||
| 21 | 21 | BorrowedReference tp = TypeManager.GetTypeReference(GetType()); | |
| 22 | 22 | ||
| 23 | - //int rc = (int)Marshal.ReadIntPtr(tp, TypeOffset.ob_refcnt); | ||
| 23 | + //int rc = (int)Util.ReadIntPtr(tp, TypeOffset.ob_refcnt); | ||
| 24 | 24 | //if (rc > 1050) | |
| 25 | 25 | //{ | |
| 26 | 26 | // DebugUtil.Print("tp is: ", tp); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -275,10 +275,10 @@ internal static void GetGCHandle(BorrowedReference reflectedClrObject, BorrowedR | |||
| 275 | 275 | Debug.Assert(IsManagedType(type) || type == Runtime.CLRMetaType); | |
| 276 | 276 | Debug.Assert(Runtime.PyObject_TypeCheck(reflectedClrObject, type)); | |
| 277 | 277 | ||
| 278 | - int gcHandleOffset = Marshal.ReadInt32(type.DangerousGetAddress(), Offsets.tp_clr_inst_offset); | ||
| 278 | + int gcHandleOffset = Util.ReadInt32(type, Offsets.tp_clr_inst_offset); | ||
| 279 | 279 | Debug.Assert(gcHandleOffset > 0); | |
| 280 | 280 | ||
| 281 | - handle = Marshal.ReadIntPtr(reflectedClrObject.DangerousGetAddress(), gcHandleOffset); | ||
| 281 | + handle = Util.ReadIntPtr(reflectedClrObject, gcHandleOffset); | ||
| 282 | 282 | } | |
| 283 | 283 | ||
| 284 | 284 | internal static GCHandle? TryGetGCHandle(BorrowedReference reflectedClrObject, BorrowedReference type) | |
@@ -313,10 +313,10 @@ internal static void SetGCHandle(BorrowedReference reflectedClrObject, BorrowedR | |||
| 313 | 313 | Debug.Assert(reflectedClrObject != null); | |
| 314 | 314 | Debug.Assert(Runtime.PyObject_TypeCheck(reflectedClrObject, type)); | |
| 315 | 315 | ||
| 316 | - int offset = Marshal.ReadInt32(type.DangerousGetAddress(), Offsets.tp_clr_inst_offset); | ||
| 316 | + int offset = Util.ReadInt32(type, Offsets.tp_clr_inst_offset); | ||
| 317 | 317 | Debug.Assert(offset > 0); | |
| 318 | 318 | ||
| 319 | - Marshal.WriteIntPtr(reflectedClrObject.DangerousGetAddress(), offset, (IntPtr)newHandle); | ||
| 319 | + Util.WriteIntPtr(reflectedClrObject, offset, (IntPtr)newHandle); | ||
| 320 | 320 | } | |
| 321 | 321 | internal static void SetGCHandle(BorrowedReference reflectedClrObject, GCHandle newHandle) | |
| 322 | 322 | => SetGCHandle(reflectedClrObject, Runtime.PyObject_TYPE(reflectedClrObject), newHandle); | |
@@ -325,7 +325,7 @@ internal static class Offsets | |||
| 325 | 325 | { | |
| 326 | 326 | static Offsets() | |
| 327 | 327 | { | |
| 328 | - int pyTypeSize = Marshal.ReadInt32(Runtime.PyTypeType, TypeOffset.tp_basicsize); | ||
| 328 | + int pyTypeSize = Util.ReadInt32(Runtime.PyTypeType, TypeOffset.tp_basicsize); | ||
| 329 | 329 | if (pyTypeSize < 0) throw new InvalidOperationException(); | |
| 330 | 330 | ||
| 331 | 331 | tp_clr_inst_offset = pyTypeSize; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,7 +92,7 @@ void ClearError() | |||
| 92 | 92 | libDL.dlerror(); | |
| 93 | 93 | } | |
| 94 | 94 | ||
| 95 | - string GetError() | ||
| 95 | + string? GetError() | ||
| 96 | 96 | { | |
| 97 | 97 | var res = libDL.dlerror(); | |
| 98 | 98 | if (res != IntPtr.Zero) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -312,7 +312,7 @@ static BorrowedReference InitializeBases(PyType pyType, PyTuple baseTuple) | |||
| 312 | 312 | ||
| 313 | 313 | if (baseTuple.Length() > 1) | |
| 314 | 314 | { | |
| 315 | - Marshal.WriteIntPtr(pyType.Handle, TypeOffset.tp_bases, baseTuple.NewReferenceOrNull().DangerousMoveToPointer()); | ||
| 315 | + Util.WriteIntPtr(pyType, TypeOffset.tp_bases, baseTuple.NewReferenceOrNull().DangerousMoveToPointer()); | ||
| 316 | 316 | } | |
| 317 | 317 | return primaryBase; | |
| 318 | 318 | } | |
@@ -323,7 +323,7 @@ static void InitializeCoreFields(PyType type) | |||
| 323 | 323 | ||
| 324 | 324 | if (ManagedType.IsManagedType(type.BaseReference)) | |
| 325 | 325 | { | |
| 326 | - int baseClrInstOffset = Marshal.ReadInt32(type.BaseReference.DangerousGetAddress(), ManagedType.Offsets.tp_clr_inst_offset); | ||
| 326 | + int baseClrInstOffset = Util.ReadInt32(type.BaseReference, ManagedType.Offsets.tp_clr_inst_offset); | ||
| 327 | 327 | Util.WriteInt32(type, ManagedType.Offsets.tp_clr_inst_offset, baseClrInstOffset); | |
| 328 | 328 | } | |
| 329 | 329 | else | |
@@ -344,7 +344,7 @@ static void InitializeClass(PyType type, ClassBase impl, Type clrType) | |||
| 344 | 344 | SlotsHolder slotsHolder = CreateSolotsHolder(type); | |
| 345 | 345 | InitializeSlots(type, impl.GetType(), slotsHolder); | |
| 346 | 346 | ||
| 347 | - if (Marshal.ReadIntPtr(type, TypeOffset.mp_length) == IntPtr.Zero | ||
| 347 | + if (Util.ReadIntPtr(type, TypeOffset.mp_length) == IntPtr.Zero | ||
| 348 | 348 | && mp_length_slot.CanAssign(clrType)) | |
| 349 | 349 | { | |
| 350 | 350 | InitializeSlot(type, TypeOffset.mp_length, mp_length_slot.Method, slotsHolder); | |
@@ -381,7 +381,7 @@ static void InitializeClass(PyType type, ClassBase impl, Type clrType) | |||
| 381 | 381 | throw PythonException.ThrowLastAsClrException(); | |
| 382 | 382 | } | |
| 383 | 383 | ||
| 384 | - var dict = new BorrowedReference(Marshal.ReadIntPtr(type, TypeOffset.tp_dict)); | ||
| 384 | + var dict = Util.ReadRef(type, TypeOffset.tp_dict); | ||
| 385 | 385 | string mn = clrType.Namespace ?? ""; | |
| 386 | 386 | using (var mod = Runtime.PyString_FromString(mn)) | |
| 387 | 387 | Runtime.PyDict_SetItem(dict, PyIdentifier.__module__, mod.Borrow()); | |
@@ -410,7 +410,7 @@ static int InheritOrAllocateStandardFields(BorrowedReference typeRef, BorrowedRe | |||
| 410 | 410 | { | |
| 411 | 411 | IntPtr baseAddress = @base.DangerousGetAddress(); | |
| 412 | 412 | IntPtr type = typeRef.DangerousGetAddress(); | |
| 413 | - int baseSize = Marshal.ReadInt32(baseAddress, TypeOffset.tp_basicsize); | ||
| 413 | + int baseSize = Util.ReadInt32(@base, TypeOffset.tp_basicsize); | ||
| 414 | 414 | int newFieldOffset = baseSize; | |
| 415 | 415 | ||
| 416 | 416 | void InheritOrAllocate(int typeField) | |
@@ -538,7 +538,7 @@ internal static IntPtr WriteMethodDef(IntPtr mdef, IntPtr name, IntPtr func, int | |||
| 538 | 538 | } | |
| 539 | 539 | ||
| 540 | 540 | internal static IntPtr WriteMethodDef(IntPtr mdef, string name, IntPtr func, int flags = 0x0001, | |
| 541 | - string doc = null) | ||
| 541 | + string? doc = null) | ||
| 542 | 542 | { | |
| 543 | 543 | IntPtr namePtr = Marshal.StringToHGlobalAnsi(name); | |
| 544 | 544 | IntPtr docPtr = doc != null ? Marshal.StringToHGlobalAnsi(doc) : IntPtr.Zero; | |
@@ -581,7 +581,7 @@ internal static PyType CreateMetaType(Type impl, out SlotsHolder slotsHolder) | |||
| 581 | 581 | PyType py_type = Runtime.PyTypeType; | |
| 582 | 582 | Util.WriteRef(type, TypeOffset.tp_base, new NewReference(py_type).Steal()); | |
| 583 | 583 | ||
| 584 | - int size = Marshal.ReadInt32(Runtime.PyTypeType, TypeOffset.tp_basicsize) | ||
| 584 | + int size = Util.ReadInt32(Runtime.PyTypeType, TypeOffset.tp_basicsize) | ||
| 585 | 585 | + IntPtr.Size // tp_clr_inst_offset | |
| 586 | 586 | + IntPtr.Size // tp_clr_inst | |
| 587 | 587 | ; | |
@@ -641,7 +641,7 @@ internal static SlotsHolder SetupMetaSlots(Type impl, PyType type) | |||
| 641 | 641 | { | |
| 642 | 642 | slotsHolder.Set(TypeOffset.tp_methods, (t, offset) => | |
| 643 | 643 | { | |
| 644 | - var p = Marshal.ReadIntPtr(t, offset); | ||
| 644 | + var p = Util.ReadIntPtr(t, offset); | ||
| 645 | 645 | Runtime.PyMem_Free(p); | |
| 646 | 646 | Util.WriteIntPtr(t, offset, IntPtr.Zero); | |
| 647 | 647 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments