[pypy-svn] r26112 - pypy/dist/pypy/translator/c/test
arigo at codespeak.net
arigo at codespeak.net
Fri Apr 21 21:16:05 CEST 2006
Author: arigo
Date: Fri Apr 21 21:16:05 2006
New Revision: 26112
Modified:
pypy/dist/pypy/translator/c/test/test_wrapping.py
Log:
Forgot this usage of extregistry. One of the tests is still failing,
but it already did before the extregistry refactoring.
Modified: pypy/dist/pypy/translator/c/test/test_wrapping.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_wrapping.py (original)
+++ pypy/dist/pypy/translator/c/test/test_wrapping.py Fri Apr 21 21:16:05 2006
@@ -1,7 +1,7 @@
from pypy.translator.translator import TranslationContext
from pypy import conftest
from py.test import raises
-from pypy.rpython import extregistry
+from pypy.rpython.extregistry import ExtRegistryEntry
from pypy.annotation import model as annmodel
from pypy.rpython.lltypesystem import lltype
from pypy.rpython import robject, rclass
@@ -93,36 +93,37 @@
unwrap._annspecialcase_ = 'specialize:arg(1)'
-def rtype_unwrap(hop):
- v_obj = hop.inputarg(hop.args_r[0], 0)
- return hop.llops.convertvar(v_obj, hop.args_r[0], hop.r_result)
-
-def rtype_wrap(hop):
- assert len(hop.args_r) == 1, 'wrap() takes exactly one argument'
- v_obj, = hop.inputargs(*hop.args_r)
- return hop.llops.convertvar(v_obj, hop.args_r[0], robject.pyobj_repr)
-
-def compute_annotation_unwrap(s_wrapped, s_spec):
- # this will go away, much better way found!
- assert hasattr(s_spec, 'descriptions'), 'need a class in unwrap 2nd arg'
- descs = s_spec.descriptions
- assert len(descs) == 1, 'missing specialisation, classdesc not unique!'
- for desc in descs.keys():
- classdef = desc.getuniqueclassdef()
- return annmodel.SomeInstance(classdef)
-
# XXX
# wrapping/unwrapping should be annotatable.
# Idea: create tunnel objects which share
# annotation across SomeObjectness, sharing a key!
-extregistry.register_value(wrap,
- compute_result_annotation=annmodel.SomeObject(),
- specialize_call=rtype_wrap)
-
-extregistry.register_value(unwrap,
- compute_result_annotation=compute_annotation_unwrap,
- specialize_call=rtype_unwrap)
+class Entry(ExtRegistryEntry):
+ _about_ = unwrap
+
+ def compute_result_annotation(self, s_wrapped, s_spec):
+ # this will go away, much better way found!
+ assert hasattr(s_spec, 'descriptions'), 'need a class in unwrap 2nd arg'
+ descs = s_spec.descriptions
+ assert len(descs) == 1, 'missing specialisation, classdesc not unique!'
+ for desc in descs.keys():
+ classdef = desc.getuniqueclassdef()
+ return annmodel.SomeInstance(classdef)
+
+ def specialize_call(self, hop):
+ v_obj = hop.inputarg(hop.args_r[0], 0)
+ return hop.llops.convertvar(v_obj, hop.args_r[0], hop.r_result)
+
+
+class Entry(ExtRegistryEntry):
+ _about_ = wrap
+
+ s_result_annotation = annmodel.SomeObject()
+
+ def specialize_call(self, hop):
+ assert len(hop.args_r) == 1, 'wrap() takes exactly one argument'
+ v_obj, = hop.inputargs(*hop.args_r)
+ return hop.llops.convertvar(v_obj, hop.args_r[0], robject.pyobj_repr)
# _______________________________________________-
# the actual tests
More information about the Pypy-commit
mailing list