[pypy-svn] r73297 - in pypy/branch/cpython-extension/pypy/module/cpyext: . include

afa at codespeak.net afa at codespeak.net
Fri Apr 2 14:35:42 CEST 2010


Author: afa
Date: Fri Apr  2 14:35:39 2010
New Revision: 73297

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
   pypy/branch/cpython-extension/pypy/module/cpyext/include/structmember.h
Log:
compile the various pypy_va_get_%s with the translated pypy


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/api.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/api.py	Fri Apr  2 14:35:39 2010
@@ -484,7 +484,7 @@
     pypy_macros_h = udir.join('pypy_macros.h')
     pypy_macros_h.write('\n'.join(pypy_macros))
 
-def generate_decls_and_callbacks(db, export_symbols):
+def generate_decls_and_callbacks(db, export_symbols, api_struct=True):
     # implement function callbacks and generate function decls
     functions = []
     pypy_decls = []
@@ -496,11 +496,13 @@
             arg = arg.replace('@', 'arg%d' % (i,))
             args.append(arg)
         args = ', '.join(args) or "void"
-        callargs = ', '.join('arg%d' % (i,) for i in range(len(func.argtypes)))
         header = "%s %s(%s)" % (restype, name, args)
         pypy_decls.append(header + ";")
-        body = "{ return _pypyAPI.%s(%s); }" % (name, callargs)
-        functions.append('%s\n%s\n' % (header, body))
+        if api_struct:
+            callargs = ', '.join('arg%d' % (i,)
+                                 for i in range(len(func.argtypes)))
+            body = "{ return _pypyAPI.%s(%s); }" % (name, callargs)
+            functions.append('%s\n%s\n' % (header, body))
     pypy_decls.append("#ifndef PYPY_STANDALONE\n")
     for name, (typ, expr) in GLOBALS.iteritems():
         pypy_decls.append('PyAPI_DATA(%s) %s;' % (typ, name.replace("#", "")))
@@ -518,22 +520,19 @@
     pypy_decl_h.write('\n'.join(pypy_decls))
     return functions
 
-def build_eci(build_bridge, export_symbols, code=None):
+def build_eci(build_bridge, export_symbols, code):
     # Build code and get pointer to the structure
     kwds = {}
     export_symbols_eci = export_symbols[:]
 
     if build_bridge:
-        assert code is not None
         if sys.platform == "win32":
             # '%s' undefined; assuming extern returning int
             kwds["compile_extra"] = ["/we4013"]
         else:
             kwds["compile_extra"] = ["-Werror=implicit-function-declaration"]
-        kwds["separate_module_sources"] = [code]
         export_symbols_eci.append('pypyAPI')
     else:
-        assert code is None
         kwds["includes"] = ['Python.h'] # this is our Python.h
 
     eci = ExternalCompilationInfo(
@@ -542,6 +541,7 @@
                                include_dir / "pyerrors.c",
                                include_dir / "modsupport.c",
                                include_dir / "getargs.c"],
+        separate_module_sources = [code],
         export_symbols=export_symbols_eci,
         **kwds
         )
@@ -557,9 +557,10 @@
 
     generate_macros(export_symbols, rename, False)
 
-    generate_decls_and_callbacks(db, [])
+    functions = generate_decls_and_callbacks(db, [], api_struct=False)
+    code = "#include <Python.h>\n" + "\n".join(functions)
 
-    eci = build_eci(False, export_symbols)
+    eci = build_eci(False, export_symbols, code)
 
     bootstrap_types(space)
     setup_va_functions(eci)

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/include/structmember.h
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/include/structmember.h	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/include/structmember.h	Fri Apr  2 14:35:39 2010
@@ -4,7 +4,7 @@
 extern "C" {
 #endif
 
-
+#include <stddef.h> /* For offsetof */
 #ifndef offsetof
 #define offsetof(type, member) ( (int) & ((type*)0) -> member )
 #endif



More information about the Pypy-commit mailing list