[pypy-svn] r70507 - in pypy/branch/separate-compilation/pypy/translator/c: . test

afa at codespeak.net afa at codespeak.net
Mon Jan 11 16:04:28 CET 2010


Author: afa
Date: Mon Jan 11 16:04:27 2010
New Revision: 70507

Modified:
   pypy/branch/separate-compilation/pypy/translator/c/separate.py
   pypy/branch/separate-compilation/pypy/translator/c/test/test_separate.py
Log:
make our @export decorator closer to the one used by carbonpython


Modified: pypy/branch/separate-compilation/pypy/translator/c/separate.py
==============================================================================
--- pypy/branch/separate-compilation/pypy/translator/c/separate.py	(original)
+++ pypy/branch/separate-compilation/pypy/translator/c/separate.py	Mon Jan 11 16:04:27 2010
@@ -3,7 +3,7 @@
 class export(object):
     """decorator to mark a function as exported by a shared module.
     Can be used with a signature::
-        @export([float, float])
+        @export(float, float)
         def f(x, y):
             return x + y
     or without any argument at all::
@@ -17,10 +17,12 @@
     def __new__(cls, *args, **kwds):
         if len(args) == 1 and isinstance(args[0], types.FunctionType):
             func = args[0]
-            return export()(func)
+            decorated = export()(func)
+            del decorated.argtypes
+            return decorated
         return object.__new__(cls, *args, **kwds)
 
-    def __init__(self, args=None):
+    def __init__(self, *args):
         self.argtypes = args
 
     def __call__(self, func):

Modified: pypy/branch/separate-compilation/pypy/translator/c/test/test_separate.py
==============================================================================
--- pypy/branch/separate-compilation/pypy/translator/c/test/test_separate.py	(original)
+++ pypy/branch/separate-compilation/pypy/translator/c/test/test_separate.py	Mon Jan 11 16:04:27 2010
@@ -42,7 +42,7 @@
 
     def test_simple_call(self):
         # function exported from the 'first' module
-        @export(args=[float])
+        @export(float)
         def f(x):
             return x + 1.5
         firstmodule = self.compile_separated("first", f=f)
@@ -57,13 +57,13 @@
 
     def test_nested_call(self):
         # function exported from the 'first' module
-        @export(args=[float])
+        @export(float)
         def f(x):
             return x + 1.5
         firstmodule = self.compile_separated("first", f=f)
 
         # function exported from the 'second' module
-        @export(args=[float])
+        @export(float)
         def g(x):
             return firstmodule.f(x) / 2
         secondmodule = self.compile_separated("second", g=g)
@@ -85,7 +85,7 @@
         @export
         def f(x):
             return x + 1.5
-        @export(args=[])
+        @export()
         def f2():
             f(1.0)
             f(2.0)



More information about the Pypy-commit mailing list