[pypy-svn] r25997 - in pypy/dist/pypy/rpython/rctypes: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Apr 19 19:07:48 CEST 2006
Author: arigo
Date: Wed Apr 19 19:07:47 2006
New Revision: 25997
Modified:
pypy/dist/pypy/rpython/rctypes/apyobject.py
pypy/dist/pypy/rpython/rctypes/test/test_rpyobject.py
Log:
Annotate prebuilt py_object instances.
Modified: pypy/dist/pypy/rpython/rctypes/apyobject.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/apyobject.py (original)
+++ pypy/dist/pypy/rpython/rctypes/apyobject.py Wed Apr 19 19:07:47 2006
@@ -3,9 +3,19 @@
from pypy.rpython import extregistry
+# __________ py_object() calls __________
+
def py_object_compute_result_annotation(s_obj=None):
return SomeCTypesObject(py_object, SomeCTypesObject.OWNSMEMORY)
extregistry.register_value(py_object,
compute_result_annotation=py_object_compute_result_annotation,
)#specialize_call=py_object_specialize_call)
+
+# __________ prebuilt py_object instances __________
+
+def py_object_instance_compute_annotation(type, instance):
+ return SomeCTypesObject(py_object, SomeCTypesObject.OWNSMEMORY)
+
+extregistry.register_type(py_object,
+ compute_annotation=py_object_instance_compute_annotation)
Modified: pypy/dist/pypy/rpython/rctypes/test/test_rpyobject.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rpyobject.py (original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rpyobject.py Wed Apr 19 19:07:47 2006
@@ -31,3 +31,16 @@
assert s.knowntype == py_object
if conftest.option.view:
a.translator.view()
+
+ def test_annotate_prebuilt(self):
+ five = py_object(5)
+ hello = py_object("hello")
+
+ def fn(i):
+ return [five, hello][i]
+
+ a = RPythonAnnotator()
+ s = a.build_types(fn, [int])
+ assert s.knowntype == py_object
+ if conftest.option.view:
+ a.translator.view()
More information about the Pypy-commit
mailing list