[pypy-svn] r25995 - in pypy/dist/pypy/rpython/rctypes: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Apr 19 19:05:09 CEST 2006
Author: arigo
Date: Wed Apr 19 19:05:02 2006
New Revision: 25995
Added:
pypy/dist/pypy/rpython/rctypes/apyobject.py (contents, props changed)
pypy/dist/pypy/rpython/rctypes/test/test_rpyobject.py (contents, props changed)
Modified:
pypy/dist/pypy/rpython/rctypes/implementation.py
Log:
Starting ctypes.py_object support: annotating calls to py_object().
Added: pypy/dist/pypy/rpython/rctypes/apyobject.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/rctypes/apyobject.py Wed Apr 19 19:05:02 2006
@@ -0,0 +1,11 @@
+from ctypes import py_object
+from pypy.annotation.model import SomeCTypesObject
+from pypy.rpython import extregistry
+
+
+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)
Modified: pypy/dist/pypy/rpython/rctypes/implementation.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/implementation.py (original)
+++ pypy/dist/pypy/rpython/rctypes/implementation.py Wed Apr 19 19:05:02 2006
@@ -7,6 +7,7 @@
import pypy.rpython.rctypes.astruct
import pypy.rpython.rctypes.avoid_p
import pypy.rpython.rctypes.astringbuf
+import pypy.rpython.rctypes.apyobject
# Register the correspondance between SomeCTypesObject and the get_repr()
Added: pypy/dist/pypy/rpython/rctypes/test/test_rpyobject.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rpyobject.py Wed Apr 19 19:05:02 2006
@@ -0,0 +1,33 @@
+"""
+Test the special py_object support.
+"""
+
+import py
+import pypy.rpython.rctypes.implementation
+from pypy.annotation import model as annmodel
+from pypy.annotation.annrpython import RPythonAnnotator
+from pypy.translator.translator import TranslationContext
+from pypy import conftest
+from pypy.translator.c.test.test_genc import compile
+import sys
+from pypy.rpython.test.test_llinterp import interpret
+
+from ctypes import py_object
+
+
+class Test_annotation:
+ def test_annotate_wrapping(self):
+ def wrap(x):
+ return py_object(x)
+
+ a = RPythonAnnotator()
+ s = a.build_types(wrap, [int])
+ assert s.knowntype == py_object
+ if conftest.option.view:
+ a.translator.view()
+
+ a = RPythonAnnotator()
+ s = a.build_types(wrap, [str])
+ assert s.knowntype == py_object
+ if conftest.option.view:
+ a.translator.view()
More information about the Pypy-commit
mailing list