[pypy-svn] r45709 - in pypy/branch/pypy-more-rtti-inprogress/interpreter: . test

arigo at codespeak.net arigo at codespeak.net
Thu Aug 16 13:05:03 CEST 2007


Author: arigo
Date: Thu Aug 16 13:05:03 2007
New Revision: 45709

Modified:
   pypy/branch/pypy-more-rtti-inprogress/interpreter/gateway.py
   pypy/branch/pypy-more-rtti-inprogress/interpreter/test/test_gateway.py
Log:
Gateway support for 'r_longlong' in unwrap_spec.


Modified: pypy/branch/pypy-more-rtti-inprogress/interpreter/gateway.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/interpreter/gateway.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/interpreter/gateway.py	Thu Aug 16 13:05:03 2007
@@ -20,6 +20,7 @@
 from pypy.interpreter.argument import Arguments, AbstractArguments
 from pypy.tool.sourcetools import NiceCompile, compile2
 from pypy.rlib.jit import hint
+from pypy.rlib.rarithmetic import r_longlong
 
 # internal non-translatable parts: 
 import py
@@ -163,7 +164,7 @@
         app_sig.varargname = argname[2:]
 
     def visit__object(self, typ, app_sig):
-        if typ not in (int, str, float):
+        if typ not in (int, str, float, r_longlong):
             assert False, "unsupported basic type in unwrap_spec"
         self.checked_space_method(typ.__name__, app_sig)
 
@@ -209,7 +210,7 @@
         self.run_args.append(self.scopenext())
 
     def visit__object(self, typ):
-        if typ not in (int, str, float):
+        if typ not in (int, str, float, r_longlong):
             assert False, "unsupported basic type in uwnrap_spec"
         self.run_args.append("space.%s_w(%s)" %
                              (typ.__name__, self.scopenext()))
@@ -322,7 +323,7 @@
         raise FastFuncNotSupported
 
     def visit__object(self, typ):
-        if typ not in (int, str, float):
+        if typ not in (int, str, float, r_longlong):
             assert False, "unsupported basic type in uwnrap_spec"
         self.unwrap.append("space.%s_w(%s)" % (typ.__name__,
                                                self.nextarg()))

Modified: pypy/branch/pypy-more-rtti-inprogress/interpreter/test/test_gateway.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/interpreter/test/test_gateway.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/interpreter/test/test_gateway.py	Thu Aug 16 13:05:03 2007
@@ -209,6 +209,28 @@
             space.call_function(w_app_g3_if, w(1), w(1.0)),
             w(2.0))
 
+    def test_interp2app_unwrap_spec_r_longlong(self):
+        space = self.space
+        w = space.wrap
+        def g3_ll(space, n):
+            return space.wrap(n * 3)
+        app_g3_ll = gateway.interp2app_temp(g3_ll,
+                                         unwrap_spec=[gateway.ObjSpace,
+                                                      gateway.r_longlong])
+        w_app_g3_ll = space.wrap(app_g3_ll)
+        w_big = w(gateway.r_longlong(10**10))
+        assert space.eq_w(
+            space.call(w_app_g3_ll, 
+                       space.newtuple([w_big]),
+                       space.newdict()),
+            w(gateway.r_longlong(3 * 10**10)))
+        assert space.eq_w(
+            space.call_function(w_app_g3_ll, w_big),
+            w(gateway.r_longlong(3 * 10**10)))
+        w_huge = w(10L**100)
+        space.raises_w(space.w_OverflowError,
+                       space.call_function, w_app_g3_ll, w_huge)
+
     def test_interp2app_unwrap_spec_index(self):
         space = self.space
         w = space.wrap


More information about the pypy-svn mailing list