[pypy-svn] r67480 - in pypy/branch/weakdict2/pypy/rpython/memory: . test

arigo at codespeak.net arigo at codespeak.net
Fri Sep 4 16:06:33 CEST 2009


Author: arigo
Date: Fri Sep  4 16:06:33 2009
New Revision: 67480

Modified:
   pypy/branch/weakdict2/pypy/rpython/memory/gctypelayout.py
   pypy/branch/weakdict2/pypy/rpython/memory/test/test_gc.py
   pypy/branch/weakdict2/pypy/rpython/memory/test/test_gctypelayout.py
Log:
Revert checkins that were about 'weakarray'.


Modified: pypy/branch/weakdict2/pypy/rpython/memory/gctypelayout.py
==============================================================================
--- pypy/branch/weakdict2/pypy/rpython/memory/gctypelayout.py	(original)
+++ pypy/branch/weakdict2/pypy/rpython/memory/gctypelayout.py	Fri Sep  4 16:06:33 2009
@@ -166,8 +166,7 @@
             info.ofstovar = llmemory.itemoffsetof(TYPE, 0)
         assert isinstance(ARRAY, lltype.Array)
         if ARRAY.OF != lltype.Void:
-            ignore = ARRAY._hints.get('weakarray', None)
-            offsets = offsets_to_gc_pointers(ARRAY.OF, ignoring=ignore)
+            offsets = offsets_to_gc_pointers(ARRAY.OF)
         else:
             offsets = ()
         info.varofstoptrs = builder.offsets2table(offsets, ARRAY.OF)
@@ -323,12 +322,10 @@
 #
 # Helpers to discover GC pointers inside structures
 
-def offsets_to_gc_pointers(TYPE, ignoring=None):
+def offsets_to_gc_pointers(TYPE):
     offsets = []
     if isinstance(TYPE, lltype.Struct):
         for name in TYPE._names:
-            if name == ignoring:
-                continue
             FIELD = getattr(TYPE, name)
             if isinstance(FIELD, lltype.Array):
                 continue    # skip inlined array
@@ -355,9 +352,6 @@
 def weakpointer_offset(TYPE):
     if TYPE == WEAKREF:
         return llmemory.offsetof(WEAKREF, "weakptr")
-    if isinstance(TYPE, lltype.GcArray) and 'weakarray' in TYPE._hints:
-        weakfieldname = TYPE._hints['weakarray']
-        return llmemory.offsetof(TYPE.OF, weakfieldname)
     return -1
 
 def gc_pointers_inside(v, adr, mutable_only=False):

Modified: pypy/branch/weakdict2/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/branch/weakdict2/pypy/rpython/memory/test/test_gc.py	(original)
+++ pypy/branch/weakdict2/pypy/rpython/memory/test/test_gc.py	Fri Sep  4 16:06:33 2009
@@ -222,7 +222,7 @@
         assert 160 <= res <= 165
 
     def test_weakref(self):
-        import weakref
+        import weakref, gc
         class A(object):
             pass
         def g():
@@ -243,7 +243,7 @@
         assert res
 
     def test_weakref_to_object_with_finalizer(self):
-        import weakref
+        import weakref, gc
         class A(object):
             count = 0
         a = A()
@@ -262,31 +262,6 @@
         res = self.interpret(f, [])
         assert res
 
-    def test_weakvaluedict(self):
-        py.test.skip("in-progress")
-        from pypy.rlib.rweakref import RWeakValueDictionary
-        class X(object):
-            def __init__(self, n):
-                self.n = n
-        def g(d, x111):
-            x222 = X(222)
-            d.set("abc", x111)
-            d.set("def", x222)
-            return ((d.get("abc") is x111) * 100 +
-                    (d.get("def") is x222) * 10 +
-                    (d.get("foobar") is not None))
-        def f():
-            d = RWeakValueDictionary(X)
-            x111 = X(111)
-            res = g(d, x111)
-            llop.gc__collect(lltype.Void)
-            llop.gc__collect(lltype.Void)
-            res = res + ((d.get("abc") is x111) * 10000 +
-                         (d.get("def") is not None) * 1000)
-            return res
-        res = self.interpret(f, [])
-        assert res == 10110
-
     def test_id(self):
         class A(object):
             pass

Modified: pypy/branch/weakdict2/pypy/rpython/memory/test/test_gctypelayout.py
==============================================================================
--- pypy/branch/weakdict2/pypy/rpython/memory/test/test_gctypelayout.py	(original)
+++ pypy/branch/weakdict2/pypy/rpython/memory/test/test_gctypelayout.py	Fri Sep  4 16:06:33 2009
@@ -1,6 +1,6 @@
 from pypy.rpython.memory.gctypelayout import TypeLayoutBuilder, GCData
 from pypy.rpython.memory.gctypelayout import offsets_to_gc_pointers
-from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.rpython.lltypesystem import lltype
 
 def getname(T):
     try:
@@ -40,22 +40,3 @@
         lst1 = gcdata.q_varsize_offsets_to_gcpointers_in_var_part(tid1)
         lst2 = gcdata.q_offsets_to_gc_pointers(tid2)
         assert len(lst1) == len(lst2)
-
-def test_weakarray():
-    OBJ = lltype.GcStruct('some_object')
-    S = lltype.Struct('weakstruct',
-                      ('foo', lltype.Ptr(OBJ)),
-                      ('bar', lltype.Ptr(OBJ)))
-    A = lltype.GcArray(S, hints={'weakarray': 'bar'})
-    layoutbuilder = TypeLayoutBuilder()
-    tid = layoutbuilder.get_type_id(A)
-    gcdata = GCData(layoutbuilder.type_info_list)
-    assert gcdata.q_is_varsize(tid)
-    assert gcdata.q_has_gcptr_in_varsize(tid)
-    assert not gcdata.q_is_gcarrayofgcptr(tid)
-    assert len(gcdata.q_offsets_to_gc_pointers(tid)) == 0
-    assert len(gcdata.q_varsize_offsets_to_gcpointers_in_var_part(tid)) == 1
-    weakofs = gcdata.q_weakpointer_offset(tid)
-    assert isinstance(weakofs, llmemory.FieldOffset)
-    assert weakofs.TYPE == S
-    assert weakofs.fldname == 'bar'



More information about the Pypy-commit mailing list