• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PyModule_AddStringConstant函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PyModule_AddStringConstant函数的典型用法代码示例。如果您正苦于以下问题:C++ PyModule_AddStringConstant函数的具体用法?C++ PyModule_AddStringConstant怎么用?C++ PyModule_AddStringConstant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PyModule_AddStringConstant函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:MOBO-OSS,项目名称:systemd-relative,代码行数:9,代码来源:_journal.c


示例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");
}
开发者ID:IDA-RE-things,项目名称:uberstealth,代码行数:10,代码来源:pydistorm.c


示例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;
}
开发者ID:DinoV,项目名称:cpython,代码行数:57,代码来源:_csv.c


示例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__);
}
开发者ID:kevinarpe,项目名称:kx,代码行数:9,代码来源:_nk20.c


示例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);
}
开发者ID:gregcopenhaver,项目名称:pydeep,代码行数:10,代码来源:pydeep.c


示例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;
}
开发者ID:1310701102,项目名称:sl4a,代码行数:56,代码来源:importdl.c


示例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");
}
开发者ID:fabioz,项目名称:coev,代码行数:10,代码来源:cqsl.c


示例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);
}
开发者ID:AlexBaranosky,项目名称:systemd,代码行数:10,代码来源:_daemon.c


示例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);
  }
开发者ID:AWilco,项目名称:xbmc,代码行数:19,代码来源:xbmcaddonmodule.cpp


示例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);
}
开发者ID:ChinaQuants,项目名称:pyston,代码行数:55,代码来源:_csv.c


示例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);
}
开发者ID:gromaudio,项目名称:dashtest,代码行数:42,代码来源:sound.cpp


示例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);
}
开发者ID:UIKit0,项目名称:hustle,代码行数:11,代码来源:scamurmur3.c


示例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);
}
开发者ID:gromaudio,项目名称:dashtest,代码行数:20,代码来源:cd.cpp


示例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;
}
开发者ID:ebottabi,项目名称:guava,代码行数:53,代码来源:guava_module.c


示例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__));
}
开发者ID:twopir,项目名称:pycryptopp,代码行数:12,代码来源:aesmodule.cpp


示例16: MODINIT2

PyMODINIT_FUNC MODINIT2(void)
{
	PyObject *m;

	m = Py_InitModule(SPONGE_MODULE, NULL);
	if (m == NULL)
		return;

	PyModule_AddStringConstant(m, "__doc__", mod_doc);

	mod_init(m);
}
开发者ID:markokr,项目名称:spongeshaker,代码行数:12,代码来源:pykeccak.c


示例17: initid128

PyMODINIT_FUNC initid128(void) {
        PyObject *m;

        m = Py_InitModule3("id128", methods, module__doc__);
        if (m == NULL)
                return;

        /* a series of lines like 'add_id() ;' follow */
#define JOINER ;
#include "id128-constants.h"
#undef JOINER
        PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION);
}
开发者ID:CasaMallo,项目名称:python-systemd,代码行数:13,代码来源:id128.c


示例18: PyInit_smhasher

extern PyMODINIT_FUNC
PyInit_smhasher(void)
{
    PyObject *m;

    m = PyModule_Create(&smhasher_module);
    if (m == NULL)
        goto finally;
    PyModule_AddStringConstant(m, "__version__", MODULE_VERSION);

finally:
    return m;
}
开发者ID:UIKit0,项目名称:hustle,代码行数:13,代码来源:scamurmur3.c


示例19: gimpthumb_add_constants

void
gimpthumb_add_constants(PyObject *module, const gchar *strip_prefix)
{
#ifdef VERSION
    PyModule_AddStringConstant(module, "__version__", VERSION);
#endif
  pyg_enum_add(module, "ThumbFileType", strip_prefix, GIMP_TYPE_THUMB_FILE_TYPE);
  pyg_enum_add(module, "ThumbSize", strip_prefix, GIMP_TYPE_THUMB_SIZE);
  pyg_enum_add(module, "ThumbState", strip_prefix, GIMP_TYPE_THUMB_STATE);

  if (PyErr_Occurred())
    PyErr_Print();
}
开发者ID:trenta-os,项目名称:gimp,代码行数:13,代码来源:gimpthumb.c


示例20: get_and_load_rules

int
get_and_load_rules(struct rules_motor_env_s** me, const gchar *ns_name){
	int rc;
	GByteArray *mod_in_string = NULL;
	PyObject *py_main = NULL;
	GError *err = NULL;

	/* Free previous module and function in 'me' */
	if ((*me)->py_function != NULL) {
		Py_XDECREF((*me)->py_function);
		(*me)->py_function = NULL;
	}
	if ((*me)->py_module != NULL) {
		Py_XDECREF((*me)->py_module);
		(*me)->py_module = NULL;
	}

	/* Get rule script from conscience */
	mod_in_string = namespace_get_rules(ns_name, CHUNK_CRAWLER, &err);
	if(mod_in_string == NULL){
		ERROR("Failed to fetch rules : %s", err->message);
		g_clear_error (&err);
		return -1;
	}
	PyRun_SimpleString("import imp");
	PyRun_SimpleString("rules_mod = imp.new_module('rules_mod')");
	py_main = PyImport_AddModule("__main__");

	rc = PyModule_AddStringConstant(py_main, "mod_in_string", (char *)mod_in_string->data);
	g_byte_array_free(mod_in_string, TRUE);
	if(rc == -1){
		ERROR("Failed to import rules(GByteArray) into python environment");
		return -1;
	}

	PyRun_SimpleString("exec mod_in_string in rules_mod.__dict__");

	(*me)->py_module = PyObject_GetAttrString(py_main, "rules_mod");
	if((*me)->py_module == NULL){
		ERROR("Failed to load python module");
		return -1;
	}

	(*me)->py_function = PyObject_GetAttrString((*me)->py_module, "main");
	if((*me)->py_function == NULL){
		ERROR("Failed to get python function hook");
		return -1;
	}

	return 1;
}
开发者ID:amogrid,项目名称:redcurrant,代码行数:51,代码来源:c2python.c



注:本文中的PyModule_AddStringConstant函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyModule_Create函数代码示例发布时间:2022-05-30
下一篇:
C++ PyModule_AddIntConstant函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap