mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Backported PyCapsule from 3.1, and converted most uses of
CObject to PyCapsule.
This commit is contained in:
parent
53ff86ea5f
commit
402b73fb8d
40 changed files with 1048 additions and 127 deletions
|
@ -80,6 +80,9 @@ typedef struct {
|
|||
|
||||
#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type)
|
||||
|
||||
#define PyCurses_CAPSULE_NAME "_curses._C_API"
|
||||
|
||||
|
||||
#ifdef CURSES_MODULE
|
||||
/* This section is used when compiling _cursesmodule.c */
|
||||
|
||||
|
@ -94,16 +97,8 @@ static void **PyCurses_API;
|
|||
#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}
|
||||
|
||||
#define import_curses() \
|
||||
{ \
|
||||
PyObject *module = PyImport_ImportModuleNoBlock("_curses"); \
|
||||
if (module != NULL) { \
|
||||
PyObject *module_dict = PyModule_GetDict(module); \
|
||||
PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \
|
||||
if (PyCObject_Check(c_api_object)) { \
|
||||
PyCurses_API = (void **)PyCObject_AsVoidPtr(c_api_object); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1);
|
||||
|
||||
#endif
|
||||
|
||||
/* general error messages */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue