本文整理汇总了C++中PyType_Ready函数的典型用法代码示例。如果您正苦于以下问题:C++ PyType_Ready函数的具体用法?C++ PyType_Ready怎么用?C++ PyType_Ready使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyType_Ready函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inithunspell
PyMODINIT_FUNC
inithunspell(void)
{
PyObject *mod;
// Create the module
mod = Py_InitModule3("hunspell", NULL,
"An extension for the Hunspell spell checker engine");
if (mod == NULL) {
return;
}
// Fill in some slots in the type, and make it ready
HunSpellType.tp_new = PyType_GenericNew;
if (PyType_Ready(&HunSpellType) < 0) {
return;
}
// Add the type to the module.
Py_INCREF(&HunSpellType);
PyModule_AddObject(mod, "HunSpell", (PyObject *)&HunSpellType);
}
示例2: qpyopengl_init
// Perform any required initialisation.
void qpyopengl_init()
{
// Initialise the OpenGL data cache type.
if (PyType_Ready(&qpyopengl_dataCache_Type) < 0)
Py_FatalError("PyQt5.QtGui: Failed to initialise dataCache type");
// Export the private helpers, ie. those that should not be used by
// external handwritten code.
#if QT_VERSION >= 0x050100
sipExportSymbol("qpyopengl_value_array", (void *)qpyopengl_value_array);
sipExportSymbol("qpyopengl_value_array_cached",
(void *)qpyopengl_value_array_cached);
sipExportSymbol("qpyopengl_from_GLint", (void *)qpyopengl_from_GLint);
sipExportSymbol("qpyopengl_from_GLuint", (void *)qpyopengl_from_GLuint);
sipExportSymbol("qpyopengl_from_GLboolean",
(void *)qpyopengl_from_GLboolean);
sipExportSymbol("qpyopengl_from_GLfloat", (void *)qpyopengl_from_GLfloat);
sipExportSymbol("qpyopengl_from_GLdouble",
(void *)qpyopengl_from_GLdouble);
#endif
}
示例3: inititeadspi
PyMODINIT_FUNC
inititeadspi(void)
{
PyObject* iteadspi;
iteadspi = Py_InitModule3
(
"iteadspi",
module_iteadspi_methods,
"iteadspi module implements the interface between Python and class SPIClass written by C++."
);
if (iteadspi == NULL)
return;
if (PyType_Ready(&SPIClassType) < 0)
return;
Py_INCREF(&SPIClassType);
PyModule_AddObject(iteadspi, "SPIClass", (PyObject *)&SPIClassType);
}
示例4: PyInit_hunspell
PyObject*
PyInit_hunspell(void)
{
PyObject *mod;
// Create the module
mod = PyModule_Create(&hunspellmodule);
if (mod == NULL) {
return NULL;
}
// Fill in some slots in the type, and make it ready
HunSpellType.tp_new = PyType_GenericNew;
if (PyType_Ready(&HunSpellType) < 0) {
return NULL;
}
// Add the type to the module.
Py_INCREF(&HunSpellType);
PyModule_AddObject(mod, "HunSpell", (PyObject *)&HunSpellType);
return mod;
}
示例5: initpyscm
PyMODINIT_FUNC
initpyscm(void)
{
PyObject *m;
/*pyscm_PySCMType.tp_new = PyType_GenericNew;*/
if (PyType_Ready(&pyscm_PySCMType) < 0) {
return; // NOT COVERED BY TESTS
}
/* Create the module and add the functions */
m = Py_InitModule4("pyscm", pyscm_methods,
pyscm_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
if (NULL == m) {
return; // NOT COVERED BY TESTS
}
Py_INCREF(&pyscm_PySCMType);
PyModule_AddObject(m, "PySCM", (PyObject *)&pyscm_PySCMType);
/* Add some symbolic constants to the module */
//PyObject *d;
//d = PyModule_GetDict(m);
//ErrorObject = PyString_FromString("pyscm.error");
//PyDict_SetItemString(d, "error", ErrorObject);
/* Add constants here */
// Currently, none is needed.
/* Check for errors */
if (PyErr_Occurred()) {
Py_FatalError("can't initialize module pyscm"); // NOT COVERED BY TESTS
}
// This part initializes the Guile data structures needed
// by this module.
pyscm_registration_hash = scm_permanent_object(scm_c_make_hash_table(65537));
pyscm_registration_index = 0;
}
示例6: qpycore_init
// Perform any required initialisation.
void qpycore_init()
{
// Initialise the meta-type.
qpycore_pyqtWrapperType_Type.tp_base = sipWrapperType_Type;
if (PyType_Ready(&qpycore_pyqtWrapperType_Type) < 0)
Py_FatalError("PyQt4.QtCore: Failed to initialise pyqtWrapperType type");
// Register the meta-type.
if (sipRegisterPyType((PyTypeObject *)&qpycore_pyqtWrapperType_Type) < 0)
Py_FatalError("PyQt4.QtCore: Failed to register pyqtWrapperType type");
// Export the helpers.
sipExportSymbol("qtcore_qt_metaobject",
(void *)qpycore_qobject_metaobject);
sipExportSymbol("qtcore_qt_metacall", (void *)qpycore_qobject_qt_metacall);
sipExportSymbol("qtcore_qt_metacast", (void *)qpycore_qobject_qt_metacast);
sipExportSymbol("qpycore_qobject_sender", (void *)qpycore_qobject_sender);
sipExportSymbol("qpycore_qobject_receivers",
(void *)qpycore_qobject_receivers);
sipExportSymbol("pyqt_kw_handler", (void *)qpycore_pyqtconfigure);
sipExportSymbol("qpycore_ArgvToC", (void *)qpycore_ArgvToC);
sipExportSymbol("qpycore_UpdatePyArgv", (void *)qpycore_UpdatePyArgv);
sipExportSymbol("qpycore_pyqtsignal_get_parts",
(void *)qpycore_pyqtsignal_get_parts);
sipExportSymbol("qpycore_pyqtslot_get_parts",
(void *)qpycore_pyqtslot_get_parts);
sipExportSymbol("qpycore_qvariant_value", (void *)qpycore_qvariant_value);
sipExportSymbol("qpycore_register_to_pyobject",
(void *)Chimera::registerToPyObject);
sipExportSymbol("qpycore_register_to_qvariant",
(void *)Chimera::registerToQVariant);
sipExportSymbol("qpycore_register_to_qvariant_data",
(void *)Chimera::registerToQVariantData);
}
示例7: pygi_struct_register_types
/**
* Returns 0 on success, or -1 and sets an exception.
*/
int
pygi_struct_register_types (PyObject *m)
{
Py_TYPE(&PyGIStruct_Type) = &PyType_Type;
g_assert (Py_TYPE (&PyGPointer_Type) != NULL);
PyGIStruct_Type.tp_base = &PyGPointer_Type;
PyGIStruct_Type.tp_new = (newfunc) struct_new;
PyGIStruct_Type.tp_init = (initproc) struct_init;
PyGIStruct_Type.tp_dealloc = (destructor) struct_dealloc;
PyGIStruct_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
PyGIStruct_Type.tp_repr = (reprfunc)struct_repr;
if (PyType_Ready (&PyGIStruct_Type) < 0)
return -1;
Py_INCREF ((PyObject *) &PyGIStruct_Type);
if (PyModule_AddObject (m, "Struct", (PyObject *) &PyGIStruct_Type) < 0) {
Py_DECREF ((PyObject *) &PyGIStruct_Type);
return -1;
}
return 0;
}
示例8: init_crypto_pkcs12
/*
* Initialize the PKCS12 part of the crypto sub module
*
* Arguments: module - The crypto module
* Returns: None
*/
int
init_crypto_pkcs12(PyObject *module) {
if (PyType_Ready(&crypto_PKCS12_Type) < 0) {
return 0;
}
/* PyModule_AddObject steals a reference.
*/
Py_INCREF((PyObject *)&crypto_PKCS12_Type);
if (PyModule_AddObject(module, "PKCS12", (PyObject *)&crypto_PKCS12_Type) != 0) {
return 0;
}
/* PyModule_AddObject steals a reference.
*/
Py_INCREF((PyObject *)&crypto_PKCS12_Type);
if (PyModule_AddObject(module, "PKCS12Type", (PyObject *)&crypto_PKCS12_Type) != 0) {
return 0;
}
return 1;
}
示例9: init_parser
PyMODINIT_FUNC
init_parser(void)
{
PyObject* module;
if (PyType_Ready(&HTTPParserType) < 0)
return;
module = Py_InitModule3("_parser", module_methods,
"HTTP Parser from nginx/Joyent.");
Py_INCREF(&HTTPParserType);
PyModule_AddObject(module, "HTTPResponseParser", (PyObject *)&HTTPParserType);
PyObject* httplib = PyImport_ImportModule("httplib");
PyObject* HTTPException = PyObject_GetAttrString(httplib, "HTTPException");
PyExc_HTTPParseError = PyErr_NewException(
"_parser.HTTPParseError", HTTPException, NULL);
Py_INCREF(PyExc_HTTPParseError);
PyModule_AddObject(module, "HTTPParseError", PyExc_HTTPParseError);
}
示例10: init_zope_hookable
PyMODINIT_FUNC
init_zope_hookable(void)
{
PyObject *m;
hookabletype.tp_new = PyType_GenericNew;
hookabletype.tp_free = _PyObject_GC_Del;
if (PyType_Ready(&hookabletype) < 0)
return;
m = Py_InitModule3("_zope_hookable", zch_methods,
"Provide an efficient implementation for hookable objects"
);
if (m == NULL)
return;
if (PyModule_AddObject(m, "hookable", (PyObject *)&hookabletype) < 0)
return;
}
示例11: init_TransformationType
void init_TransformationType(PyObject* module_dict) {
transformation_number_methods.nb_multiply = transformation_mul;
TransformationType.ob_type = &PyType_Type;
TransformationType.tp_name = "vectorcore.Transformation";
TransformationType.tp_basicsize = sizeof(TransformationObject);
TransformationType.tp_dealloc = transformation_dealloc;
TransformationType.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
TransformationType.tp_new = transformation_new;
TransformationType.tp_getattro = PyObject_GenericGetAttr;
TransformationType.tp_alloc = NULL; // PyType_GenericAlloc;
TransformationType.tp_richcompare = transformation_richcompare;
TransformationType.tp_free = NULL; // _PyObject_Del;
TransformationType.tp_methods = transformation_methods;
TransformationType.tp_getset = transformation_getset;
TransformationType.tp_repr = transformation_repr;
TransformationType.tp_doc = "Transformation objects hold a transformation matrix that can be used to apply affine transformations to 2D points. These transformations include scale, translation, rotation and shearing.\n\nSetting the values of the transformation matrix by hand can be tricky. To assist in this, convenience functions for creating transformations are available in the transformations plugin module.\n\nTransformations can be composed using the multiplication (*) operator. For instance::\n\n t = rotate_degrees(45) * scale(2)\n\nwill create a transformation that is equivalent to rotating by 45 degrees *then* scaling by 2. Note that the order of transformations reads left-to-right, which is technically the opposite of a matrix multiplication, but easier to read and understand for this application.\n\nFor more information on affine transformation matrices, see the Wikipedia.";
TransformationType.tp_as_number = &transformation_number_methods;
TransformationType.tp_call = transformation_call;
PyType_Ready(&TransformationType);
PyDict_SetItemString(module_dict, "Transformation", (PyObject*)&TransformationType);
}
示例12: Init_pyPageInfo_Type
PyObject* Init_pyPageInfo_Type() {
if (PyType_Ready(&pyPageInfo_Type) < 0)
return NULL;
PyDict_SetItemString(pyPageInfo_Type.tp_dict, "kPartialPatchFile",
PyInt_FromLong(plPageInfo::kPartialPatchFile));
PyDict_SetItemString(pyPageInfo_Type.tp_dict, "kOldDataChecksum",
PyInt_FromLong(plPageInfo::kOldDataChecksum));
PyDict_SetItemString(pyPageInfo_Type.tp_dict, "kOldIdxChecksum",
PyInt_FromLong(plPageInfo::kOldIdxChecksum));
PyDict_SetItemString(pyPageInfo_Type.tp_dict, "kBasicChecksum",
PyInt_FromLong(plPageInfo::kBasicChecksum));
PyDict_SetItemString(pyPageInfo_Type.tp_dict, "kPatchHeaderOnly",
PyInt_FromLong(plPageInfo::kPatchHeaderOnly));
PyDict_SetItemString(pyPageInfo_Type.tp_dict, "kChecksumMask",
PyInt_FromLong(plPageInfo::kChecksumMask));
PyDict_SetItemString(pyPageInfo_Type.tp_dict, "kPatchFlags",
PyInt_FromLong(plPageInfo::kPatchFlags));
Py_INCREF(&pyPageInfo_Type);
return (PyObject*)&pyPageInfo_Type;
}
示例13: initencoding
PyMODINIT_FUNC
initencoding(void)
{
int i;
PyObject *m;
EncodingType.tp_new = PyType_GenericNew;
if (PyType_Ready(&EncodingType) < 0)
return;
m = Py_InitModule3("encoding", EncodingsModule_methods,
"Encoding conversion functions.");
Py_INCREF(&EncodingType);
PyModule_AddObject(m, "Encoding", (PyObject *) &EncodingType);
for (i = 0; i < GEANY_ENCODINGS_MAX; i++)
PyModule_AddIntConstant(m, encoding_names[i], (glong) i);
for (i = 0; i < GEANY_ENCODING_GROUPS_MAX; i++)
PyModule_AddIntConstant(m, encoding_groups[i], (glong) i);
}
示例14: PyImaging_DecoderNew
static ImagingDecoderObject*
PyImaging_DecoderNew(int contextsize)
{
ImagingDecoderObject *decoder;
void *context;
if(PyType_Ready(&ImagingDecoderType) < 0)
return NULL;
decoder = PyObject_New(ImagingDecoderObject, &ImagingDecoderType);
if (decoder == NULL)
return NULL;
/* Clear the decoder state */
memset(&decoder->state, 0, sizeof(decoder->state));
/* Allocate decoder context */
if (contextsize > 0) {
context = (void*) calloc(1, contextsize);
if (!context) {
Py_DECREF(decoder);
(void) PyErr_NoMemory();
return NULL;
}
} else
context = 0;
/* Initialize decoder context */
decoder->state.context = context;
/* Target image */
decoder->lock = NULL;
decoder->im = NULL;
/* Initialize the cleanup function pointer */
decoder->cleanup = NULL;
return decoder;
}
示例15: initpyhdfs
void initpyhdfs(void)
{
PyObject *m;
if (PyType_Ready(&pyhdfsFSType) < 0)
return;
import_array();
m = Py_InitModule3("pyhdfs", pyhdfs_funcs,
"Extension for Python to read/write to HDFS");
if (m == NULL)
return;
Py_INCREF(&pyhdfsFSType);
PyModule_AddObject(m, "pyhdfsFS", (PyObject *)&pyhdfsFSType);
exception = PyErr_NewException("pyhdfs.error", NULL, NULL);
Py_INCREF(exception);
PyModule_AddObject(m, "error", exception);
}