Exemplo n.º 1
0
 protected static void SetObjectDict(BorrowedReference ob, StolenReference value)
 {
     if (value.Pointer == IntPtr.Zero)
     {
         throw new ArgumentNullException(nameof(value));
     }
     SetObjectDictNullable(ob, value.AnalyzerWorkaround());
 }
Exemplo n.º 2
0
        protected static void SetObjectDictNullable(BorrowedReference ob, StolenReference value)
        {
            BorrowedReference type = Runtime.PyObject_TYPE(ob);
            int instanceDictOffset = Util.ReadInt32(type, TypeOffset.tp_dictoffset);

            Debug.Assert(instanceDictOffset > 0);
            Runtime.ReplaceReference(ob, instanceDictOffset, value.AnalyzerWorkaround());
        }
Exemplo n.º 3
0
        internal static unsafe void DecrefTypeAndFree(StolenReference ob)
        {
            if (ob == null)
            {
                throw new ArgumentNullException(nameof(ob));
            }
            var borrowed = new BorrowedReference(ob.DangerousGetAddress());

            var type = Runtime.PyObject_TYPE(borrowed);

            var freePtr = Util.ReadIntPtr(type, TypeOffset.tp_free);

            Debug.Assert(freePtr != IntPtr.Zero);
            var free = (delegate * unmanaged[Cdecl] < StolenReference, void >)freePtr;

            free(ob);

            Runtime.XDecref(StolenReference.DangerousFromPointer(type.DangerousGetAddress()));
        }
Exemplo n.º 4
0
 internal PyType(StolenReference reference) : base(EnsureIsType(in reference))
Exemplo n.º 5
0
        public static void CallDealloc(IntPtr fp, StolenReference a1)
        {
            var d = (delegate * unmanaged[Cdecl] < StolenReference, void >)fp;

            d(a1);
        }