[pypy-svn] r16159 - in pypy/dist/pypy/rpython/memory: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Aug 19 13:35:27 CEST 2005
Author: cfbolz
Date: Fri Aug 19 13:35:27 2005
New Revision: 16159
Modified:
pypy/dist/pypy/rpython/memory/gc.py
pypy/dist/pypy/rpython/memory/support.py
pypy/dist/pypy/rpython/memory/test/test_gc.py
Log:
added a failing test that tries to annotate a class with (the former)
_raw_alloc_ = True. _raw_alloc_ = True was changed (as to samuele's
suggestion) to _alloc_flavor_ = "". The plan is that the flavor is
passed to malloc which then decides what to do with it.
Modified: pypy/dist/pypy/rpython/memory/gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc.py (original)
+++ pypy/dist/pypy/rpython/memory/gc.py Fri Aug 19 13:35:27 2005
@@ -15,13 +15,13 @@
def free_non_gc_object(obj):
- assert getattr(obj.__class__, "_raw_allocate_", False), "trying to free regular object"
+ assert getattr(obj.__class__, "_alloc_flavor_", False) == "", "trying to free regular object"
obj.__dict__ = {}
obj.__class__ = FREED_OBJECT
class MarkSweepGC(object):
- _raw_allocate_ = True
+ _alloc_flavor_ = ""
def __init__(self, objectmodel, collect_every_bytes):
self.bytes_malloced = 0
Modified: pypy/dist/pypy/rpython/memory/support.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/support.py (original)
+++ pypy/dist/pypy/rpython/memory/support.py Fri Aug 19 13:35:27 2005
@@ -5,7 +5,7 @@
INT_SIZE = struct.calcsize("i")
class AddressLinkedList(object):
- _raw_allocate_ = True
+ _alloc_flavor_ = ""
def __init__(self):
self.first = NULL
self.last = NULL
Modified: pypy/dist/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gc.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_gc.py Fri Aug 19 13:35:27 2005
@@ -1,5 +1,8 @@
import py
+from pypy.annotation import model as annmodel
+from pypy.translator.annrpython import RPythonAnnotator
+from pypy.rpython.rtyper import RPythonTyper
from pypy.rpython.memory.gc import free_non_gc_object, GCError, MarkSweepGC
from pypy.rpython.memory.support import AddressLinkedList, INT_SIZE
from pypy.rpython.memory.lladdress import raw_malloc, raw_free, NULL
@@ -19,7 +22,7 @@
def test_free_non_gc_object():
class TestClass(object):
- _raw_allocate_ = True
+ _alloc_flavor_ = ""
def __init__(self, a):
self.a = a
def method1(self):
@@ -37,6 +40,26 @@
py.test.raises(GCError, "t.a")
py.test.raises(AssertionError, "free_non_gc_object(TestClass2())")
+def DONOTtest_rtype_free_non_gc_object():
+ class TestClass(object):
+ _alloc_flavor_ = ""
+ def __init__(self, a):
+ self.a = a
+ def method1(self):
+ return self.a
+ def method2(self):
+ return 42
+ def malloc_and_free(a):
+ ci = TestClass(a)
+ b = ci.a
+ free_non_gc_object(ci)
+ return b
+ a = RPythonAnnotator()
+ #does not raise:
+ s = a.build_types(malloc_and_free, [annmodel.SomeAddress()])
+ assert isinstance(s, annmodel.SomeAddress)
+ rtyper = RPythonTyper(a)
+ rtyper.specialize()
class PseudoObjectModel(object):
"""Object model for testing purposes: you can specify roots and a
More information about the Pypy-commit
mailing list