2019-07-11 15:58:33 +00:00
|
|
|
#ifndef PYTHON_DYNLOAD_H
|
|
|
|
#define PYTHON_DYNLOAD_H
|
2016-08-22 22:53:26 +00:00
|
|
|
|
|
|
|
typedef void *PyObject;
|
|
|
|
typedef void *PyCodeObject;
|
|
|
|
|
|
|
|
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
|
|
|
|
|
|
|
|
typedef
|
|
|
|
enum {PyGILState_LOCKED, PyGILState_UNLOCKED}
|
|
|
|
PyGILState_STATE;
|
|
|
|
typedef struct {
|
2017-03-16 21:01:13 +00:00
|
|
|
char *ml_name;
|
|
|
|
PyCFunction ml_meth;
|
|
|
|
int ml_flags;
|
|
|
|
char *ml_doc;
|
2016-08-22 22:53:26 +00:00
|
|
|
} PyMethodDef;
|
|
|
|
|
2019-07-11 15:58:33 +00:00
|
|
|
struct py_imports {
|
2017-03-16 21:01:13 +00:00
|
|
|
char *name;
|
|
|
|
void (*proc)();
|
2016-08-22 22:53:26 +00:00
|
|
|
};
|
|
|
|
|
2019-07-11 15:58:33 +00:00
|
|
|
#ifndef Py_ssize_t
|
|
|
|
#ifdef ssize_t
|
|
|
|
typedef ssize_t Py_ssize_t;
|
|
|
|
#else
|
|
|
|
typedef signed long long Py_ssize_t;
|
|
|
|
#endif
|
|
|
|
#endif
|
2016-08-22 22:53:26 +00:00
|
|
|
|
2019-07-11 15:58:33 +00:00
|
|
|
#ifndef BOOL
|
|
|
|
typedef int BOOL;
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
2016-08-22 22:53:26 +00:00
|
|
|
|
2019-05-07 12:15:10 +00:00
|
|
|
#ifndef Py_INCREF
|
2019-07-11 15:58:33 +00:00
|
|
|
#define Py_INCREF Py_IncRef
|
2019-05-07 12:15:10 +00:00
|
|
|
#endif
|
2016-08-22 22:53:26 +00:00
|
|
|
|
2019-05-07 12:15:10 +00:00
|
|
|
#ifndef Py_DECREF
|
2019-07-11 15:58:33 +00:00
|
|
|
#define Py_DECREF Py_DecRef
|
2019-05-07 12:15:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef Py_XINCREF
|
2019-07-11 15:58:33 +00:00
|
|
|
#define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
|
2019-05-07 12:15:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef Py_XDECREF
|
2019-07-11 15:58:33 +00:00
|
|
|
#define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define snprintf _snprintf
|
2019-05-07 12:15:10 +00:00
|
|
|
#endif
|
2016-08-22 22:53:26 +00:00
|
|
|
|
|
|
|
#define METH_OLDARGS 0x0000
|
|
|
|
#define METH_VARARGS 0x0001
|
|
|
|
#define METH_KEYWORDS 0x0002
|
|
|
|
/* METH_NOARGS and METH_O must not be combined with the flags above. */
|
|
|
|
#define METH_NOARGS 0x0004
|
|
|
|
#define METH_O 0x0008
|
|
|
|
|
|
|
|
/* METH_CLASS and METH_STATIC are a little different; these control
|
|
|
|
the construction of methods for a class. These cannot be used for
|
|
|
|
functions in modules. */
|
|
|
|
#define METH_CLASS 0x0010
|
|
|
|
#define METH_STATIC 0x0020
|
|
|
|
|
|
|
|
#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
|
|
|
|
|
|
|
|
#define PyInt_Check(op) PyObject_IsInstance(op, &PyInt_Type) /* ??? */
|
|
|
|
#define Py_None (&_Py_NoneStruct)
|
|
|
|
|
|
|
|
#define DL_EXPORT(x) x
|
|
|
|
|
2019-07-11 15:58:33 +00:00
|
|
|
#define PYTHON_API_VERSION 1013
|
|
|
|
|
2016-08-22 22:53:26 +00:00
|
|
|
#define Py_InitModule3(name, methods, doc) \
|
2019-07-11 15:58:33 +00:00
|
|
|
Py_InitModule4(name, methods, doc, (PyObject *)NULL, \
|
|
|
|
PYTHON_API_VERSION)
|
|
|
|
|
2019-12-31 13:46:23 +00:00
|
|
|
static
|
2019-12-31 11:15:08 +00:00
|
|
|
int Py_RefCnt(const PyObject *object) {
|
|
|
|
if (!object)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return *((int *) object);
|
|
|
|
}
|
|
|
|
|
2019-07-11 15:58:33 +00:00
|
|
|
extern struct py_imports py_sym_table[];
|
|
|
|
|
2019-09-07 15:51:30 +00:00
|
|
|
BOOL initialize_python(int argc, char *argv[], BOOL is_shared_object);
|
|
|
|
void run_pupy(void);
|
|
|
|
void deinitialize_python(void);
|
2019-07-11 15:58:33 +00:00
|
|
|
|
|
|
|
#include "import-tab.h"
|
|
|
|
|
|
|
|
#endif // PYTHON_DYNLOAD_H
|