mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-16 09:29:55 +00:00
.. Using SIP thats used in PyQt et al we have a module called `goldencheetah' which includes bindings. Currently there is only a single method `getValue()' that returns 1. It's to get the basic plumbing in place. src/Python/SIP contains all the files related to the module. The cpp files are generated by the `sip' utility which will need to be available if you want to work on the bindings. Run make -f Makefile.hack to regenerate the cpp files if you edit them. I prefer to distribute the generated files at this point whilst development occurs. We may change that at a later date. .. Please note that the gcconfig.pri.in file has changed as we now include the python include path rather than set a macro for the include directive (See PYTHONINCLUDES in gcconfig.pri.in) .. lastly, to test this is working in a python chart console: > print(GC.getValue()) 1 >
172 lines
4.1 KiB
C++
172 lines
4.1 KiB
C++
/*
|
|
* Module code.
|
|
*
|
|
* Generated by SIP 4.19.6
|
|
*/
|
|
|
|
#include "sipAPIgoldencheetah.h"
|
|
|
|
#line 6 "goldencheetah.sip"
|
|
#include "Bindings.h"
|
|
#line 12 "./sipgoldencheetahcmodule.cpp"
|
|
|
|
/* Define the strings used by this module. */
|
|
const char sipStrings_goldencheetah[] = {
|
|
'g', 'o', 'l', 'd', 'e', 'n', 'c', 'h', 'e', 'e', 't', 'a', 'h', 0,
|
|
'g', 'e', 't', 'V', 'a', 'l', 'u', 'e', 0,
|
|
'B', 'i', 'n', 'd', 'i', 'n', 'g', 's', 0,
|
|
};
|
|
|
|
|
|
/*
|
|
* This defines each type in this module.
|
|
*/
|
|
sipTypeDef *sipExportedTypes_goldencheetah[] = {
|
|
&sipTypeDef_goldencheetah_Bindings.ctd_base,
|
|
};
|
|
|
|
|
|
/* This defines this module. */
|
|
sipExportedModuleDef sipModuleAPI_goldencheetah = {
|
|
0,
|
|
SIP_API_MINOR_NR,
|
|
sipNameNr_goldencheetah,
|
|
0,
|
|
sipStrings_goldencheetah,
|
|
NULL,
|
|
NULL,
|
|
1,
|
|
sipExportedTypes_goldencheetah,
|
|
NULL,
|
|
0,
|
|
NULL,
|
|
0,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
{NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL
|
|
};
|
|
|
|
|
|
/* The SIP API and the APIs of any imported modules. */
|
|
const sipAPIDef *sipAPI_goldencheetah;
|
|
|
|
|
|
/* The Python module initialisation function. */
|
|
#if PY_MAJOR_VERSION >= 3
|
|
#define SIP_MODULE_ENTRY PyInit_goldencheetah
|
|
#define SIP_MODULE_TYPE PyObject *
|
|
#define SIP_MODULE_DISCARD(r) Py_DECREF(r)
|
|
#define SIP_MODULE_RETURN(r) return (r)
|
|
#else
|
|
#define SIP_MODULE_ENTRY initgoldencheetah
|
|
#define SIP_MODULE_TYPE void
|
|
#define SIP_MODULE_DISCARD(r)
|
|
#define SIP_MODULE_RETURN(r) return
|
|
#endif
|
|
|
|
#if defined(SIP_STATIC_MODULE)
|
|
extern "C" SIP_MODULE_TYPE SIP_MODULE_ENTRY()
|
|
#else
|
|
PyMODINIT_FUNC SIP_MODULE_ENTRY()
|
|
#endif
|
|
{
|
|
static PyMethodDef sip_methods[] = {
|
|
{0, 0, 0, 0}
|
|
};
|
|
|
|
#if PY_MAJOR_VERSION >= 3
|
|
static PyModuleDef sip_module_def = {
|
|
PyModuleDef_HEAD_INIT,
|
|
"goldencheetah",
|
|
NULL,
|
|
-1,
|
|
sip_methods,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL
|
|
};
|
|
#endif
|
|
|
|
PyObject *sipModule, *sipModuleDict;
|
|
PyObject *sip_sipmod, *sip_capiobj;
|
|
|
|
/* Initialise the module and get it's dictionary. */
|
|
#if PY_MAJOR_VERSION >= 3
|
|
sipModule = PyModule_Create(&sip_module_def);
|
|
#elif PY_VERSION_HEX >= 0x02050000
|
|
sipModule = Py_InitModule(sipName_goldencheetah, sip_methods);
|
|
#else
|
|
sipModule = Py_InitModule(const_cast<char *>(sipName_goldencheetah), sip_methods);
|
|
#endif
|
|
|
|
if (sipModule == NULL)
|
|
SIP_MODULE_RETURN(NULL);
|
|
|
|
sipModuleDict = PyModule_GetDict(sipModule);
|
|
|
|
/* Get the SIP module's API. */
|
|
#if PY_VERSION_HEX >= 0x02050000
|
|
sip_sipmod = PyImport_ImportModule(SIP_MODULE_NAME);
|
|
#else
|
|
sip_sipmod = PyImport_ImportModule(const_cast<char *>(SIP_MODULE_NAME));
|
|
#endif
|
|
|
|
if (sip_sipmod == NULL)
|
|
{
|
|
SIP_MODULE_DISCARD(sipModule);
|
|
SIP_MODULE_RETURN(NULL);
|
|
}
|
|
|
|
sip_capiobj = PyDict_GetItemString(PyModule_GetDict(sip_sipmod), "_C_API");
|
|
Py_DECREF(sip_sipmod);
|
|
|
|
#if defined(SIP_USE_PYCAPSULE)
|
|
if (sip_capiobj == NULL || !PyCapsule_CheckExact(sip_capiobj))
|
|
#else
|
|
if (sip_capiobj == NULL || !PyCObject_Check(sip_capiobj))
|
|
#endif
|
|
{
|
|
SIP_MODULE_DISCARD(sipModule);
|
|
SIP_MODULE_RETURN(NULL);
|
|
}
|
|
|
|
#if defined(SIP_USE_PYCAPSULE)
|
|
sipAPI_goldencheetah = reinterpret_cast<const sipAPIDef *>(PyCapsule_GetPointer(sip_capiobj, SIP_MODULE_NAME "._C_API"));
|
|
#else
|
|
sipAPI_goldencheetah = reinterpret_cast<const sipAPIDef *>(PyCObject_AsVoidPtr(sip_capiobj));
|
|
#endif
|
|
|
|
#if defined(SIP_USE_PYCAPSULE)
|
|
if (sipAPI_goldencheetah == NULL)
|
|
{
|
|
SIP_MODULE_DISCARD(sipModule);
|
|
SIP_MODULE_RETURN(NULL);
|
|
}
|
|
#endif
|
|
|
|
/* Export the module and publish it's API. */
|
|
if (sipExportModule(&sipModuleAPI_goldencheetah,SIP_API_MAJOR_NR,SIP_API_MINOR_NR,0) < 0)
|
|
{
|
|
SIP_MODULE_DISCARD(sipModule);
|
|
SIP_MODULE_RETURN(0);
|
|
}
|
|
/* Initialise the module now all its dependencies have been set up. */
|
|
if (sipInitModule(&sipModuleAPI_goldencheetah,sipModuleDict) < 0)
|
|
{
|
|
SIP_MODULE_DISCARD(sipModule);
|
|
SIP_MODULE_RETURN(0);
|
|
}
|
|
|
|
SIP_MODULE_RETURN(sipModule);
|
|
}
|