[pypy-svn] r49079 - in pypy/branch/rewrite-compilation-logic/pypy/translator/c: . test

pedronis at codespeak.net pedronis at codespeak.net
Sun Nov 25 15:01:54 CET 2007


Author: pedronis
Date: Sun Nov 25 15:01:53 2007
New Revision: 49079

Modified:
   pypy/branch/rewrite-compilation-logic/pypy/translator/c/genc.py
   pypy/branch/rewrite-compilation-logic/pypy/translator/c/test/test_genc.py
Log:
port 49078 from trunk



Modified: pypy/branch/rewrite-compilation-logic/pypy/translator/c/genc.py
==============================================================================
--- pypy/branch/rewrite-compilation-logic/pypy/translator/c/genc.py	(original)
+++ pypy/branch/rewrite-compilation-logic/pypy/translator/c/genc.py	Sun Nov 25 15:01:53 2007
@@ -200,7 +200,7 @@
 _entry_point.restype = ctypes.py_object
 _entry_point.argtypes = %(nargs)d*(ctypes.py_object,)
 
-def %(entrypoint_name)s(*args):
+def entrypoint(*args):
     return _entry_point(*args)
 
 try:
@@ -217,7 +217,6 @@
 _rpython_startup = _lib.RPython_StartupCode
 _rpython_startup()
 """ % {'so_name': self.c_source_filename.new(ext=so_ext),
-       'entrypoint_name': self.entrypoint_name,
        'c_entrypoint_name': wrapped_entrypoint_c_name,
        'nargs': len(lltype.typeOf(entrypoint_ptr).TO.ARGS)}
         modfile.write(CODE)
@@ -239,7 +238,7 @@
         
     def get_entry_point(self, isolated=False):
         self._import_module(isolated=isolated)
-        return getattr(self._module, self.entrypoint_name)
+        return getattr(self._module, "entrypoint")
 
     def get_malloc_counters(self, isolated=False):
         self._import_module(isolated=isolated)

Modified: pypy/branch/rewrite-compilation-logic/pypy/translator/c/test/test_genc.py
==============================================================================
--- pypy/branch/rewrite-compilation-logic/pypy/translator/c/test/test_genc.py	(original)
+++ pypy/branch/rewrite-compilation-logic/pypy/translator/c/test/test_genc.py	Sun Nov 25 15:01:53 2007
@@ -81,6 +81,20 @@
     x = py.test.raises(Exception, f1, "world")
     assert not isinstance(x.value, EOFError) # EOFError === segfault
 
+def test_simple_lambda():
+    f = lambda x: x*2
+    t = TranslationContext()
+    t.buildannotator().build_types(f, [int])
+    t.buildrtyper().specialize()
+    
+    t.config.translation.countmallocs = True
+    builder = genc.CExtModuleBuilder(t, f, config=t.config)
+    builder.generate_source()
+    builder.compile()
+    f1 = builder.get_entry_point()
+
+    assert f1(5) == 10
+
 def test_rlist():
     def f(x):
         l = [x]



More information about the Pypy-commit mailing list