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

afa at codespeak.net afa at codespeak.net
Mon Apr 26 13:57:54 CEST 2010


Author: afa
Date: Mon Apr 26 13:57:52 2010
New Revision: 74069

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
   pypy/branch/cpython-extension/pypy/module/cpyext/include/Python.h
Log:
define the PyAPI_FUNC() macro, and use it to properly declare functions as "dllexport" on Windows.


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	Mon Apr 26 13:57:52 2010
@@ -618,13 +618,12 @@
             arg = arg.replace('@', 'arg%d' % (i,)).strip()
             args.append(arg)
         args = ', '.join(args) or "void"
-        header = "%s %s(%s)" % (restype, name, args)
-        pypy_decls.append(header + ";")
+        pypy_decls.append("PyAPI_FUNC(%s) %s(%s);" % (restype, name, args))
         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))
+            functions.append('%s %s(%s)\n%s' % (restype, name, args, body))
     for name in VA_TP_LIST:
         name_no_star = process_va_name(name)
         header = ('%s pypy_va_get_%s(va_list* vp)' %

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/include/Python.h
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/include/Python.h	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/include/Python.h	Mon Apr 26 13:57:52 2010
@@ -9,6 +9,7 @@
 # include <limits.h>
 # include <math.h>
 # define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
+# define PyAPI_FUNC(RTYPE) RTYPE
 # define PyAPI_DATA(RTYPE) extern RTYPE
 #else
 # define MS_WIN32 1
@@ -16,8 +17,10 @@
 # include <io.h>
 # define Py_DEPRECATED(VERSION_UNUSED)
 # ifdef Py_BUILD_CORE
+#  define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
 #  define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE
 # else
+#  define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
 #  define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
 # endif
 #endif



More information about the Pypy-commit mailing list