[pypy-svn] r49078 - in pypy/dist/pypy/translator/c: . test

pedronis at codespeak.net pedronis at codespeak.net
Sun Nov 25 14:51:52 CET 2007


Author: pedronis
Date: Sun Nov 25 14:51:52 2007
New Revision: 49078

Modified:
   pypy/dist/pypy/translator/c/genc.py
   pypy/dist/pypy/translator/c/test/test_genc.py
Log:
mmh, <lambda>s funky names



Modified: pypy/dist/pypy/translator/c/genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/genc.py	(original)
+++ pypy/dist/pypy/translator/c/genc.py	Sun Nov 25 14:51:52 2007
@@ -204,7 +204,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:
@@ -221,7 +221,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)
@@ -243,7 +242,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/dist/pypy/translator/c/test/test_genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_genc.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_genc.py	Sun Nov 25 14:51:52 2007
@@ -61,6 +61,19 @@
 
     py.test.raises(Exception, f1, "world")  # check that it's really typed
 
+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):



More information about the Pypy-commit mailing list