Commits

Amaury Forgeot d'Arc committed 87c817c

make our @export decorator closer to the one used by carbonpython

Comments (0)

Files changed (2)

pypy/translator/c/separate.py

 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::
     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):

pypy/translator/c/test/test_separate.py

 
     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)
 
     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)
         @export
         def f(x):
             return x + 1.5
-        @export(args=[])
+        @export()
         def f2():
             f(1.0)
             f(2.0)