1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
PYTHON setup.py build_ext --inplace
PYTHON -c "import declarations"
######## setup.py ########
from distutils.core import setup
from Cython.Distutils import build_ext
from Cython.Distutils.extension import Extension
setup(
ext_modules = [
Extension("declarations", ["declarations.pyx", "external_declarations.c"]),
],
cmdclass={'build_ext': build_ext},
)
######## declarations.pyx ########
# mode: compile
cdef extern from "declarations.h":
pass
cdef extern char *cp
cdef extern char *cpa[5]
cdef extern int (*ifnpa[5])()
cdef extern char *(*cpfnpa[5])()
cdef extern int (*ifnp)()
cdef extern int (*iap)[5]
cdef extern int ifn()
cdef extern char *cpfn()
cdef extern int (*iapfn())[5]
cdef extern char *(*cpapfn())[5]
cdef extern int fnargfn(int ())
cdef extern int ia[]
cdef extern int iaa[][3]
cdef extern int a(int[][3], int[][3][5])
cdef void f():
cdef void *p=NULL
global ifnp, cpa
ifnp = <int (*)() noexcept>p
cdef char *g():
pass
f()
g()
######## declarations.h ########
#define DLL_EXPORT
#include "external_declarations.h"
######## external_declarations.h ########
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#elif defined(DLL_EXPORT)
#define DL_IMPORT(t) DL_EXPORT(t)
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern DL_IMPORT(char) *cp;
extern DL_IMPORT(char) *cpa[5];
extern DL_IMPORT(int) (*ifnpa[5])(void);
extern DL_IMPORT(char) *(*cpfnpa[5])(void);
extern DL_IMPORT(int) (*ifnp)(void);
extern DL_IMPORT(int) (*iap)[5];
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern DL_IMPORT(int) ifn(void);
extern DL_IMPORT(char *) cpfn(void);
extern DL_IMPORT(int) fnargfn(int (void));
extern DL_IMPORT(int) (*iapfn(void))[5];
extern DL_IMPORT(char *)(*cpapfn(void))[5];
extern DL_IMPORT(int) ia[];
extern DL_IMPORT(int) iaa[][3];
extern DL_IMPORT(int) a(int[][3], int[][3][5]);
#ifdef __cplusplus
}
#endif
######## external_declarations.c ########
#include <Python.h>
#ifndef DL_EXPORT
#define DL_EXPORT(t) t
#endif
DL_EXPORT(char) *cp;
DL_EXPORT(char) *cpa[5];
DL_EXPORT(int) (*ifnpa[5])(void);
DL_EXPORT(char) *(*cpfnpa[5])(void);
DL_EXPORT(int) (*ifnp)(void);
DL_EXPORT(int) (*iap)[5];
DL_EXPORT(int) ifn(void) {return 0;}
DL_EXPORT(char) *cpfn(void) {return 0;}
DL_EXPORT(int) fnargfn(int f(void)) {return 0;}
DL_EXPORT(int) ia[1];
DL_EXPORT(int) iaa[1][3];
DL_EXPORT(int) a(int a[][3], int b[][3][5]) {return 0;}
|