本文整理汇总了C++中PyModule_AddStringConstant函数的典型用法代码示例。如果您正苦于以下问题:C++ PyModule_AddStringConstant函数的具体用法?C++ PyModule_AddStringConstant怎么用?C++ PyModule_AddStringConstant使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyModule_AddStringConstant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_journal
PyMODINIT_FUNC init_journal(void) {
PyObject *m;
m = Py_InitModule("_journal", methods);
if (m == NULL)
return;
PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION);
}
示例2: initdistorm
/* PYTHON MODULE EXPORTS */
_DLLEXPORT_ void initdistorm()
{
PyObject* distormModule = Py_InitModule3("distorm", distormModulebMethods, ":[diStorm64}:");
PyModule_AddIntConstant(distormModule, "Decode16Bits", Decode16Bits);
PyModule_AddIntConstant(distormModule, "Decode32Bits", Decode32Bits);
PyModule_AddIntConstant(distormModule, "Decode64Bits", Decode64Bits);
PyModule_AddIntConstant(distormModule, "OffsetTypeSize", sizeof(_OffsetType) * 8);
PyModule_AddStringConstant(distormModule, "info", ":[diStorm64 1.7.30}:\r\nCopyright RageStorm (C) 2008, Gil Dabah \r\n\r\ndiStorm is licensed under the BSD license.\r\nhttp://ragestorm.net/distorm/\r\n");
}
示例3: PyInit__csv
PyMODINIT_FUNC
PyInit__csv(void)
{
PyObject *module;
const StyleDesc *style;
if (PyType_Ready(&Dialect_Type) < 0)
return NULL;
if (PyType_Ready(&Reader_Type) < 0)
return NULL;
if (PyType_Ready(&Writer_Type) < 0)
return NULL;
/* Create the module and add the functions */
module = PyModule_Create(&_csvmodule);
if (module == NULL)
return NULL;
/* Add version to the module. */
if (PyModule_AddStringConstant(module, "__version__",
MODULE_VERSION) == -1)
return NULL;
/* Set the field limit */
_csvstate(module)->field_limit = 128 * 1024;
/* Do I still need to add this var to the Module Dict? */
/* Add _dialects dictionary */
_csvstate(module)->dialects = PyDict_New();
if (_csvstate(module)->dialects == NULL)
return NULL;
Py_INCREF(_csvstate(module)->dialects);
if (PyModule_AddObject(module, "_dialects", _csvstate(module)->dialects))
return NULL;
/* Add quote styles into dictionary */
for (style = quote_styles; style->name; style++) {
if (PyModule_AddIntConstant(module, style->name,
style->style) == -1)
return NULL;
}
/* Add the Dialect type */
Py_INCREF(&Dialect_Type);
if (PyModule_AddObject(module, "Dialect", (PyObject *)&Dialect_Type))
return NULL;
/* Add the CSV exception object to the module. */
_csvstate(module)->error_obj = PyErr_NewException("_csv.Error", NULL, NULL);
if (_csvstate(module)->error_obj == NULL)
return NULL;
Py_INCREF(_csvstate(module)->error_obj);
PyModule_AddObject(module, "Error", _csvstate(module)->error_obj);
return module;
}
示例4: init_nk20
PyMODINIT_FUNC
init_nk20(void)
{
PyObject* m;
import_array();
import_pyk_k20();
m = Py_InitModule3("_nk20", funcs, doc);
PyModule_AddStringConstant(m, "__version__", __version__);
}
示例5: initpydeep
// Initialization
void initpydeep(void)
{
PyObject *pydeep;
pydeep = Py_InitModule3("pydeep", pydeepMethods, "C/Python bindings for ssdeep [ssdeep.sourceforge.net]");
pydeepError = PyErr_NewException("pydeep.Error", NULL, NULL);
Py_INCREF(pydeepError);
PyModule_AddObject(pydeep, "error", pydeepError);
PyModule_AddStringConstant(pydeep, "__version__", PYDEEP_VERSION);
}
示例6: _PyImport_LoadDynamicModule
PyObject *
_PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
{
PyObject *m;
char *lastdot, *shortname, *packagecontext, *oldcontext;
dl_funcptr p;
if ((m = _PyImport_FindExtension(name, pathname)) != NULL) {
Py_INCREF(m);
return m;
}
lastdot = strrchr(name, '.');
if (lastdot == NULL) {
packagecontext = NULL;
shortname = name;
}
else {
packagecontext = name;
shortname = lastdot+1;
}
p = _PyImport_GetDynLoadFunc(name, shortname, pathname, fp);
if (PyErr_Occurred())
return NULL;
if (p == NULL) {
PyErr_Format(PyExc_ImportError,
"dynamic module does not define init function (init%.200s)",
shortname);
return NULL;
}
oldcontext = _Py_PackageContext;
_Py_PackageContext = packagecontext;
(*p)();
_Py_PackageContext = oldcontext;
if (PyErr_Occurred())
return NULL;
m = PyDict_GetItemString(PyImport_GetModuleDict(), name);
if (m == NULL) {
PyErr_SetString(PyExc_SystemError,
"dynamic module not initialized properly");
return NULL;
}
/* Remember the filename as the __file__ attribute */
if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
PyErr_Clear(); /* Not important enough to report */
if (_PyImport_FixupExtension(name, pathname) == NULL)
return NULL;
if (Py_VerboseFlag)
PySys_WriteStderr(
"import %s # dynamically loaded from %s\n",
name, pathname);
Py_INCREF(m);
return m;
}
示例7: initcqsl
PyMODINIT_FUNC
initcqsl(void) {
PyObject *m;
m = Py_InitModule3("cqsl", cqsl_methods, cqsl_doc);
if (m == NULL)
return;
PyModule_AddStringConstant(m, "__version__", "1.0");
}
示例8: init_daemon
PyMODINIT_FUNC init_daemon(void) {
PyObject *m;
m = Py_InitModule3("_daemon", methods, module__doc__);
if (m == NULL)
return;
PyModule_AddIntConstant(m, "LISTEN_FDS_START", SD_LISTEN_FDS_START);
PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION);
}
示例9: InitAddonModule
PyMODINIT_FUNC
InitAddonModule(void)
{
Py_INCREF(&Addon_Type);
// init general xbmcaddon modules
PyObject* pXbmcAddonModule;
pXbmcAddonModule = Py_InitModule((char*)"xbmcaddon", xbmcAddonMethods);
if (pXbmcAddonModule == NULL) return;
PyModule_AddObject(pXbmcAddonModule, (char*)"Addon", (PyObject*)&Addon_Type);
// constants
PyModule_AddStringConstant(pXbmcAddonModule, (char*)"__author__", (char*)PY_XBMC_AUTHOR);
PyModule_AddStringConstant(pXbmcAddonModule, (char*)"__date__", (char*)"1 May 2010");
PyModule_AddStringConstant(pXbmcAddonModule, (char*)"__version__", (char*)"1.0");
PyModule_AddStringConstant(pXbmcAddonModule, (char*)"__credits__", (char*)PY_XBMC_CREDITS);
PyModule_AddStringConstant(pXbmcAddonModule, (char*)"__platform__", (char*)PY_XBMC_PLATFORM);
}
示例10: init_csv
PyMODINIT_FUNC
init_csv(void)
{
PyObject *module;
StyleDesc *style;
if (PyType_Ready(&Dialect_Type) < 0)
return;
if (PyType_Ready(&Reader_Type) < 0)
return;
if (PyType_Ready(&Writer_Type) < 0)
return;
/* Create the module and add the functions */
module = Py_InitModule3("_csv", csv_methods, csv_module_doc);
if (module == NULL)
return;
/* Add version to the module. */
if (PyModule_AddStringConstant(module, "__version__",
MODULE_VERSION) == -1)
return;
/* Add _dialects dictionary */
dialects = PyDict_New();
if (dialects == NULL)
return;
if (PyModule_AddObject(module, "_dialects", dialects))
return;
/* Add quote styles into dictionary */
for (style = quote_styles; style->name; style++) {
if (PyModule_AddIntConstant(module, style->name,
style->style) == -1)
return;
}
/* Add the Dialect type */
Py_INCREF(&Dialect_Type);
if (PyModule_AddObject(module, "Dialect", (PyObject *)&Dialect_Type))
return;
/* Add the CSV exception object to the module. */
error_obj = PyErr_NewException("_csv.Error", NULL, NULL);
if (error_obj == NULL)
return;
// Pyston change: I *think* an incref is needed here, but it doesn't matter in CPython since they don't
// try to tear down builtin classes:
Py_INCREF(error_obj);
PyModule_AddObject(module, "Error", error_obj);
}
示例11: initsound
initsound(void)
{
Py_Initialize();
PyObject *m= Py_InitModule(MODULE_NAME, pysound_methods);
// Initialize tables
PyModule_AddStringConstant(m, "__doc__", PYMODULEDOC );
PyModule_AddStringConstant(m, "version", PYSNDVERSION );
PyModule_AddIntConstant(m, "build", PYSNDBUILD );
_EXPORT_INT(m, AFMT_MU_LAW);
_EXPORT_INT(m, AFMT_A_LAW);
_EXPORT_INT(m, AFMT_IMA_ADPCM);
_EXPORT_INT(m, AFMT_U8);
_EXPORT_INT(m, AFMT_S16_LE);
_EXPORT_INT(m, AFMT_S16_BE);
_EXPORT_INT(m, AFMT_S8);
_EXPORT_INT(m, AFMT_U16_LE);
_EXPORT_INT(m, AFMT_U16_BE);
_EXPORT_INT(m, AFMT_MPEG);
_EXPORT_INT(m, AFMT_AC3);
_EXPORT_INT(m, AFMT_S16_NE);
g_cErr = PyErr_NewException(MODULE_NAME".SoundError", NULL, NULL);
if( g_cErr != NULL)
PyModule_AddObject(m, "SoundError", g_cErr );
PyISoundType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&PyISoundType);
PyModule_AddObject(m, INPUT_NAME, (PyObject *)&PyISoundType);
PySoundType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&PySoundType);
PyModule_AddObject(m, OUTPUT_NAME, (PyObject *)&PySoundType);
ResamplerType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&ResamplerType);
PyModule_AddObject(m, RESAMPLER_NAME, (PyObject *)&ResamplerType);
AnalyzerType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&AnalyzerType);
PyModule_AddObject(m, ANALYZER_NAME, (PyObject *)&AnalyzerType);
MixerType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&MixerType);
PyModule_AddObject(m, MIXER_NAME, (PyObject *)&MixerType);
}
示例12: initscamurmur3
extern PyMODINIT_FUNC
initscamurmur3(void)
{
PyObject *m;
m = Py_InitModule3("scamurmur3", scamurmur3_methods, module_doc);
if (m == NULL)
return;
PyModule_AddStringConstant(m, "__version__", MODULE_VERSION);
}
示例13: initcd
initcd(void)
{
Py_Initialize();
g_iMaxCDROMIndex= -1;
PyObject *m = Py_InitModule("cd", pycd_methods);
PyModule_AddStringConstant( m, "__doc__", (char*)PYDOC );
PyModule_AddStringConstant( m, "version", (char*)PYCDVERSION );
PyModule_AddIntConstant( m, "build", PYCDBUILD );
INT_CONSTANT( SEEK_SET );
INT_CONSTANT( SEEK_END );
INT_CONSTANT( SEEK_CUR );
g_cErr = PyErr_NewException(MODULE_NAME".CDError", NULL, NULL);
if( g_cErr != NULL)
PyModule_AddObject(m, "CDError", g_cErr );
PyCDType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&PyCDType);
PyModule_AddObject(m, "CD", (PyObject *)&PyCDType);
}
示例14: PyEval_InitThreads
PyObject *init_guava(void) {
PyObject *guava_module = NULL;
PyObject *request_module = NULL;
PyObject *server_module = NULL;
PyObject *handler_module = NULL;
PyObject *controller_module = NULL;
PyObject *router_module = NULL;
PyObject *session_module = NULL;
PyObject *cookie_module = NULL;
PyEval_InitThreads();
guava_module = Py_InitModule("guava", NULL);
request_module = init_request();
if (!register_module(guava_module, "request", request_module)) {
return NULL;
}
server_module = init_server();
if (!register_module(guava_module, "server", server_module)) {
return NULL;
}
handler_module = init_handler();
if (!register_module(guava_module, "handler", handler_module)) {
return NULL;
}
router_module = init_router();
if (!register_module(guava_module, "router", router_module)) {
return NULL;
}
controller_module = init_controller();
if (!register_module(guava_module, "controller", controller_module)) {
return NULL;
}
session_module = init_session();
if (!register_module(guava_module, "session", session_module)) {
return NULL;
}
cookie_module = init_cookie();
if (!register_module(guava_module, "cookie", cookie_module)) {
return NULL;
}
PyModule_AddStringConstant(guava_module, "version", GUAVA_VERSION);
return guava_module;
}
示例15: init_aes
void
init_aes(PyObject*const module) {
if (PyType_Ready(&AES_type) < 0)
return;
Py_INCREF(&AES_type);
PyModule_AddObject(module, "aes_AES", (PyObject *)&AES_type);
aes_error = PyErr_NewException(const_cast<char*>("_aes.Error"), NULL, NULL);
PyModule_AddObject(module, "aes_Error", aes_error);
PyModule_AddStringConstant(module, "aes___doc__", const_cast<char*>(aes___doc__));
}