Author: Amaury Forgeot d'Arc <amaur...@gmail.com>
Branch: 
Changeset: r83611:b66575a3eea9
Date: 2016-04-12 11:25 +0200
http://bitbucket.org/pypy/pypy/changeset/b66575a3eea9/

Log:    cpyext: Move header logic to .h files, and remove the #ifdef guards,
        these _decl.h files are truly internal.

        Also skip the declaration of structmember_decl.h when compiling PyPy
        itself. (declarations generated in forwarddecl.h sometimes differ a
        bit, e.g. "const char*" is replaced by "char*)

        This will be important when PyMember_Get() is changed to accept a
        "const char*".

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1001,12 +1001,6 @@
     functions = []
     decls = {}
     pypy_decls = decls['pypy_decl.h'] = []
-    pypy_decls.append("#ifndef _PYPY_PYPY_DECL_H\n")
-    pypy_decls.append("#define _PYPY_PYPY_DECL_H\n")
-    pypy_decls.append("#ifndef PYPY_STANDALONE\n")
-    pypy_decls.append("#ifdef __cplusplus")
-    pypy_decls.append("extern \"C\" {")
-    pypy_decls.append("#endif\n")
     pypy_decls.append('#define Signed   long           /* xxx temporary fix 
*/\n')
     pypy_decls.append('#define Unsigned unsigned long  /* xxx temporary fix 
*/\n')
 
@@ -1047,11 +1041,6 @@
 
     pypy_decls.append('#undef Signed    /* xxx temporary fix */\n')
     pypy_decls.append('#undef Unsigned  /* xxx temporary fix */\n')
-    pypy_decls.append("#ifdef __cplusplus")
-    pypy_decls.append("}")
-    pypy_decls.append("#endif")
-    pypy_decls.append("#endif /*PYPY_STANDALONE*/\n")
-    pypy_decls.append("#endif /*_PYPY_PYPY_DECL_H*/\n")
 
     for header_name, header_decls in decls.iteritems():
         decl_h = udir.join(header_name)
diff --git a/pypy/module/cpyext/include/Python.h 
b/pypy/module/cpyext/include/Python.h
--- a/pypy/module/cpyext/include/Python.h
+++ b/pypy/module/cpyext/include/Python.h
@@ -132,7 +132,18 @@
 /* Missing definitions */
 #include "missing.h"
 
-#include <pypy_decl.h>
+/* The declarations of most API functions are generated in a separate file */
+/* Don't include them while building PyPy, RPython also generated signatures
+ * which are similar but not identical. */
+#ifndef PYPY_STANDALONE
+#ifdef __cplusplus
+extern "C" {
+#endif
+  #include <pypy_decl.h>
+#ifdef __cplusplus
+}
+#endif
+#endif  /* PYPY_STANDALONE */
 
 /* Define macros for inline documentation. */
 #define PyDoc_VAR(name) static char name[]
diff --git a/pypy/module/cpyext/include/structmember.h 
b/pypy/module/cpyext/include/structmember.h
--- a/pypy/module/cpyext/include/structmember.h
+++ b/pypy/module/cpyext/include/structmember.h
@@ -78,7 +78,11 @@
 
 
 /* API functions. */
+/* Don't include them while building PyPy, RPython also generated signatures
+ * which are similar but not identical. */
+#ifndef PYPY_STANDALONE
 #include "pypy_structmember_decl.h"
+#endif
 
 
 #ifdef __cplusplus
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to