[pypy-svn] r15760 - in pypy/dist/pypy/rpython/memory: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Aug 8 11:46:50 CEST 2005


Author: cfbolz
Date: Mon Aug  8 11:46:49 2005
New Revision: 15760

Modified:
   pypy/dist/pypy/rpython/memory/gclltype.py
   pypy/dist/pypy/rpython/memory/lltypesimulation.py
   pypy/dist/pypy/rpython/memory/test/test_llinterpsim.py
Log:
introduced a correct pyobjectptr implementation.


Modified: pypy/dist/pypy/rpython/memory/gclltype.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gclltype.py	(original)
+++ pypy/dist/pypy/rpython/memory/gclltype.py	Mon Aug  8 11:46:49 2005
@@ -8,6 +8,7 @@
 from pypy.rpython.memory.lltypesimulation import cast_pointer
 from pypy.rpython.memory.lltypesimulation import simulatorptr as _ptr
 from pypy.rpython.memory.lltypesimulation import malloc, functionptr, nullptr
+from pypy.rpython.memory.lltypesimulation import pyobjectptr
 
 
 def notimplemented(*args, **kwargs):
@@ -23,7 +24,7 @@
 # opaqueptr, pyobjectptr, attachRuntimeTypeInfo, getRuntimeTypeInfo,
 # runtime_type_info
 
-opaqueptr = pyobjectptr = attachRuntimeTypeInfo = notimplemented
+opaqueptr = attachRuntimeTypeInfo = notimplemented
 getRuntimeTypeInfo = runtime_type_info = notimplemented
 
 del notimplemented

Modified: pypy/dist/pypy/rpython/memory/lltypesimulation.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/lltypesimulation.py	(original)
+++ pypy/dist/pypy/rpython/memory/lltypesimulation.py	Mon Aug  8 11:46:49 2005
@@ -254,6 +254,7 @@
 def nullptr(T):
     return simulatorptr(lltype.Ptr(T), lladdress.NULL)
 
+#XXX unify attached objects with the address space as to samuele's suggestion
 def functionptr(TYPE, name, **attrs):
     if not isinstance(TYPE, lltype.FuncType):
         raise TypeError, "functionptr() for FuncTypes only"
@@ -264,3 +265,8 @@
     addr = lladdress.raw_malloc(get_total_size(TYPE))
     addr.attached[0] = lltype._func(TYPE, _name=name, **attrs)
     return simulatorptr(lltype.Ptr(TYPE), addr)
+
+def pyobjectptr(obj):
+    addr = lladdress.raw_malloc(get_total_size(lltype.PyObject))
+    addr.attached[0] = lltype._pyobject(obj)
+    return simulatorptr(lltype.Ptr(lltype.PyObject), addr) 

Modified: pypy/dist/pypy/rpython/memory/test/test_llinterpsim.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_llinterpsim.py	(original)
+++ pypy/dist/pypy/rpython/memory/test/test_llinterpsim.py	Mon Aug  8 11:46:49 2005
@@ -1,6 +1,6 @@
 
 import py
-from pypy.rpython.lltype import typeOf, pyobjectptr, Ptr, PyObject
+from pypy.rpython.lltype import typeOf, Ptr, PyObject
 from pypy.rpython.rtyper import RPythonTyper
 from pypy.rpython.llinterp import LLInterpreter, LLException,log
 from pypy.translator.translator import Translator
@@ -9,9 +9,10 @@
 from pypy.rpython import rstr
 from pypy.annotation.model import lltype_to_annotation
 from pypy.rpython.rarithmetic import r_uint, ovfcheck
+from pypy.rpython.memory.lltypesimulation import pyobjectptr
 from pypy.rpython.memory import gclltype
 
-from pypy.rpython.test.test_llinterp import find_exception, timelog, gengraph
+from pypy.rpython.test.test_llinterp import timelog, gengraph
 
 # switch on logging of interp to show more info on failing tests
 
@@ -22,6 +23,7 @@
 def teardown_module(mod):
     py.log._setstate(mod.logstate)
 
+
 _lastinterpreted = []
 _tcache = {}
 def interpret(func, values, view=False, viewbefore=False, policy=None, someobjects=False):
@@ -221,7 +223,7 @@
     res = interpret(f,[])
     assert len(res.items) == 3
 
-def DONOTtest_obj_obj_add():
+def test_obj_obj_add():
     def f(x,y):
         return x+y
     _1L = pyobjectptr(1L)
@@ -283,7 +285,7 @@
     assert res == (-sys.maxint - 1) % 30
 
 
-def DONOTtest_obj_obj_is():
+def test_obj_obj_is():
     def f(x,y):
         return x is y
     o = pyobjectptr(object())



More information about the Pypy-commit mailing list