Beispiel #1
0
 public static void SetFinalizerHelper(IPythonObject obj, WeakRefTracker value)
 {
     object[] slots = obj.GetSlotsCreate();
     if (Interlocked.CompareExchange(ref slots[slots.Length - 1], value, null) != null)
     {
         GC.SuppressFinalize(value);
     }
 }
Beispiel #2
0
        public static bool SetWeakRefHelper(IPythonObject obj, WeakRefTracker value)
        {
            if (!obj.PythonType.IsWeakReferencable)
            {
                return(false);
            }

            object[] slots = obj.GetSlotsCreate();
            slots[slots.Length - 1] = value;
            return(true);
        }