Пример #1
0
def ll_keyeq(d, weakkey1, realkey2):
    # only called by ll_dict_lookup() with the first arg coming from an
    # entry.key, and the 2nd arg being the argument to ll_dict_lookup().
    if not weakkey1:
        assert bool(realkey2)
        return False
    return weakref_deref(rclass.OBJECTPTR, weakkey1) == realkey2
Пример #2
0
def ll_keyeq(d, weakkey1, realkey2):
    # only called by ll_dict_lookup() with the first arg coming from an
    # entry.key, and the 2nd arg being the argument to ll_dict_lookup().
    if not weakkey1:
        assert bool(realkey2)
        return False
    return weakref_deref(rclass.OBJECTPTR, weakkey1) == realkey2
Пример #3
0
 def ll_get(self, d, llkey):
     hash = self.ll_keyhash(llkey)
     i = rdict.ll_dict_lookup(d, llkey, hash) & rdict.MASK
     #llop.debug_print(lltype.Void, i, 'get')
     valueref = d.entries[i].value
     if valueref:
         return weakref_deref(rclass.OBJECTPTR, valueref)
     else:
         return lltype.nullptr(rclass.OBJECTPTR.TO)
Пример #4
0
 def ll_get(self, d, llkey):
     if d.resize_counter < 0:
         self.ll_weakdict_rehash_after_translation(d)
     hash = self.ll_keyhash(llkey)
     i = rdict.ll_dict_lookup(d, llkey, hash) & rdict.MASK
     #llop.debug_print(lltype.Void, i, 'get')
     valueref = d.entries[i].value
     if valueref:
         return weakref_deref(rclass.OBJECTPTR, valueref)
     else:
         return lltype.nullptr(rclass.OBJECTPTR.TO)
Пример #5
0
def ll_valid(entries, i):
    key = entries[i].key
    if not key:
        return False
    elif weakref_deref(rclass.OBJECTPTR, key):
        return True
    else:
        # The entry might be a dead weakref still holding a strong
        # reference to the value; for this case, we clear the old
        # value from the entry, if any.
        entries[i].value = NULLVALUE
        return False
Пример #6
0
def ll_valid(entries, i):
    key = entries[i].key
    if not key:
        return False
    elif weakref_deref(rclass.OBJECTPTR, key):
        return True
    else:
        # The entry might be a dead weakref still holding a strong
        # reference to the value; for this case, we clear the old
        # value from the entry, if any.
        entries[i].value = NULLVALUE
        return False
Пример #7
0
 def ll_valid(entries, i):
     value = entries[i].value
     return bool(value) and bool(weakref_deref(rclass.OBJECTPTR, value))
Пример #8
0
 def f():
     w = g()
     rgc.collect()
     return llmemory.weakref_deref(lltype.Ptr(S), w)
Пример #9
0
 def g():
     s = lltype.malloc(S)
     w = llmemory.weakref_create(s)
     assert llmemory.weakref_deref(lltype.Ptr(S), w) == s
     assert llmemory.weakref_deref(lltype.Ptr(S), w) == s
     return w  # 's' is forgotten here
Пример #10
0
 def f():
     w = g()
     rgc.collect()
     return llmemory.weakref_deref(lltype.Ptr(S), w)
Пример #11
0
 def g():
     s = lltype.malloc(S)
     w = llmemory.weakref_create(s)
     assert llmemory.weakref_deref(lltype.Ptr(S), w) == s
     assert llmemory.weakref_deref(lltype.Ptr(S), w) == s
     return w   # 's' is forgotten here