コード例 #1
0
ファイル: hunspell.c プロジェクト: AncientCode/HAL-old
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
0
ファイル: qpyopengl_init.cpp プロジェクト: imxiaohui/pyqt5
// 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
0
ファイル: iteadspi-py.cpp プロジェクト: KeyvanHardani/Segnix
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
0
ファイル: hunspell.c プロジェクト: tyll/pyhunspell
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
0
ファイル: pyscm.c プロジェクト: tddpirate/pyguile
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
0
ファイル: qpycore_init.cpp プロジェクト: AlexDoul/PyQt4
// 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
0
PyMODINIT_FUNC PyInit_mathutils(void)
{
	PyObject *submodule;
	PyObject *item;
	PyObject *sys_modules = PyThreadState_GET()->interp->modules;

	if (PyType_Ready(&vector_Type) < 0)
		return NULL;
	if (PyType_Ready(&matrix_Type) < 0)
		return NULL;
	if (PyType_Ready(&matrix_access_Type) < 0)
		return NULL;
	if (PyType_Ready(&euler_Type) < 0)
		return NULL;
	if (PyType_Ready(&quaternion_Type) < 0)
		return NULL;
	if (PyType_Ready(&color_Type) < 0)
		return NULL;

	submodule = PyModule_Create(&M_Mathutils_module_def);
	
	/* each type has its own new() function */
	PyModule_AddObject(submodule, "Vector",		(PyObject *)&vector_Type);
	PyModule_AddObject(submodule, "Matrix",		(PyObject *)&matrix_Type);
	PyModule_AddObject(submodule, "Euler",		(PyObject *)&euler_Type);
	PyModule_AddObject(submodule, "Quaternion",	(PyObject *)&quaternion_Type);
	PyModule_AddObject(submodule, "Color",		(PyObject *)&color_Type);
	
	/* submodule */
	PyModule_AddObject(submodule, "geometry",		(item = PyInit_mathutils_geometry()));
	/* XXX, python doesnt do imports with this usefully yet
	 * 'from mathutils.geometry import PolyFill'
	 * ...fails without this. */
	PyDict_SetItemString(sys_modules, "mathutils.geometry", item);
	Py_INCREF(item);

	/* Noise submodule */
	PyModule_AddObject(submodule, "noise",		(item = PyInit_mathutils_noise()));
	PyDict_SetItemString(sys_modules, "mathutils.noise", item);
	Py_INCREF(item);

	mathutils_matrix_row_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_row_cb);
	mathutils_matrix_col_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_col_cb);
	mathutils_matrix_translation_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_translation_cb);

	return submodule;
}
コード例 #8
0
ファイル: pygi-struct.c プロジェクト: GNOME/pygobject
/**
 * 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;
}
コード例 #9
0
ファイル: pkcs12.c プロジェクト: 15580056814/hue
/*
 * 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;
}
コード例 #10
0
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);
}
コード例 #11
0
ファイル: _zope_hookable.c プロジェクト: CGTIC/Plone_SP
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;
}
コード例 #12
0
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);
}
コード例 #13
0
ファイル: pyPageInfo.cpp プロジェクト: boq/libhsplasma
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;
}
コード例 #14
0
ファイル: geanypy-encoding.c プロジェクト: BYC/geany-plugins
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);
}
コード例 #15
0
ファイル: decode.c プロジェクト: Iadgarov/Pillow
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;
}
コード例 #16
0
PyObject* Redirector::init()
{
    StdoutType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&StdoutType) < 0)
        return NULL;
#if PY_MAJOR_VERSION >= 3
    PyObject* m = PyModule_Create(&redirectordef);
#else
    PyObject* m = Py_InitModule3("redirector", 0, 0);
#endif
    if (m)
    {
        //ABELL - This is bad code as the type cast is invalid. (type pun
        //  warning.)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
        Py_INCREF(reinterpret_cast<PyObject*>(&StdoutType));
        PyModule_AddObject(m, "Stdout", reinterpret_cast<PyObject*>(&StdoutType));
#pragma GCC diagnostic pop
    }
    return m;
}
コード例 #17
0
ファイル: pyhdfs.c プロジェクト: huyphan/pyhdfs
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);
}
コード例 #18
0
ファイル: netscape_spki.c プロジェクト: bennbollay/pyOpenSSL
/*
 * Initialize the X509Name part of the crypto module
 *
 * Arguments: module - The crypto module
 * Returns:   None
 */
int
init_crypto_netscape_spki(PyObject *module) {
    if (PyType_Ready(&crypto_NetscapeSPKI_Type) < 0) {
        return 0;
    }

    /* PyModule_AddObject steals a reference
     */
    Py_INCREF((PyObject *)&crypto_NetscapeSPKI_Type);
    if (PyModule_AddObject(module, "NetscapeSPKI", (PyObject *)&crypto_NetscapeSPKI_Type) != 0) {
        return 0;
    }

    /* PyModule_AddObject steals a reference
     */
    Py_INCREF((PyObject *)&crypto_NetscapeSPKI_Type);
    if (PyModule_AddObject(module, "NetscapeSPKIType", (PyObject *)&crypto_NetscapeSPKI_Type) != 0) {
        return 0;
    }

    return 1;
}
コード例 #19
0
ファイル: _Dragmodule.c プロジェクト: 1310701102/sl4a
void init_Drag(void)
{
	PyObject *m;
#ifndef __LP64__
	PyObject *d;



	        PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New);
	        PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert);
#endif /* !__LP64__ */


	m = Py_InitModule("_Drag", Drag_methods);
#ifndef __LP64__
	d = PyModule_GetDict(m);
	Drag_Error = PyMac_GetOSErrException();
	if (Drag_Error == NULL ||
	    PyDict_SetItemString(d, "Error", Drag_Error) != 0)
		return;
	DragObj_Type.ob_type = &PyType_Type;
	if (PyType_Ready(&DragObj_Type) < 0) return;
	Py_INCREF(&DragObj_Type);
	PyModule_AddObject(m, "DragObj", (PyObject *)&DragObj_Type);
	/* Backward-compatible name */
	Py_INCREF(&DragObj_Type);
	PyModule_AddObject(m, "DragObjType", (PyObject *)&DragObj_Type);

	dragglue_TrackingHandlerUPP = NewDragTrackingHandlerUPP(dragglue_TrackingHandler);
	dragglue_ReceiveHandlerUPP = NewDragReceiveHandlerUPP(dragglue_ReceiveHandler);
	dragglue_SendDataUPP = NewDragSendDataUPP(dragglue_SendData);
#if 0
	dragglue_InputUPP = NewDragInputUPP(dragglue_Input);
	dragglue_DrawingUPP = NewDragDrawingUPP(dragglue_Drawing);
#endif

#endif /* !__LP64__ */

}
コード例 #20
0
ファイル: pathlistobject.cpp プロジェクト: elaboris/gamera
void init_PathListType(PyObject* module_dict) {
  pathlist_sequence_methods.sq_length = pathlist_len;
  pathlist_sequence_methods.sq_item = pathlist_getitem;
  pathlist_sequence_methods.sq_ass_item = pathlist_setitem;

  PathListType.ob_type = &PyType_Type;
  PathListType.tp_name = "vectorcore.PathList";
  PathListType.tp_basicsize = sizeof(PathListObject);
  PathListType.tp_dealloc = pathlist_dealloc;
  PathListType.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
  PathListType.tp_new = pathlist_new;
  PathListType.tp_getattro = PyObject_GenericGetAttr;
  PathListType.tp_alloc = NULL; // PyType_GenericAlloc;
  PathListType.tp_getset = pathlist_getset;
  PathListType.tp_free = NULL; // _PyObject_Del;
  PathListType.tp_methods = pathlist_methods;
  PathListType.tp_repr = pathlist_repr;
  PathListType.tp_doc = "PathList represents a sequence of Paths.\n\nUnlike a mere list of Paths, PathList ensures that all elements are Paths.\n\nPathList objects support the Python list interface.";
  PathListType.tp_as_sequence = &pathlist_sequence_methods;
  PyType_Ready(&PathListType);
  PyDict_SetItemString(module_dict, "PathList", (PyObject*)&PathListType);
}
コード例 #21
0
int
pycbc_EventType_init(PyObject **ptr)
{
    PyTypeObject *p = &pycbc_EventType;
    *ptr = (PyObject*)p;

    if (p->tp_name) {
        return 0;
    }

    p->tp_name = "Event";
    p->tp_doc = PyDoc_STR("Internal event handle");
    p->tp_new = PyType_GenericNew;
    p->tp_basicsize = sizeof(pycbc_Event);
    p->tp_members = pycbc_Event_TABLE_members;
    p->tp_methods = pycbc_Event_TABLE_methods;
    p->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
    p->tp_init = (initproc)Event__init__;
    p->tp_dealloc = (destructor)Event_dealloc;
    p->tp_dictoffset = offsetof(pycbc_Event, vdict);
    return PyType_Ready(p);
}
コード例 #22
0
ファイル: encode.c プロジェクト: AnubhabB/Pillow
static ImagingEncoderObject*
PyImaging_EncoderNew(int contextsize)
{
    ImagingEncoderObject *encoder;
    void *context;

    if(!PyType_Ready(&ImagingEncoderType) < 0)
        return NULL;

    encoder = PyObject_New(ImagingEncoderObject, &ImagingEncoderType);
    if (encoder == NULL)
        return NULL;

    /* Clear the encoder state */
    memset(&encoder->state, 0, sizeof(encoder->state));

    /* Allocate encoder context */
    if (contextsize > 0) {
        context = (void*) calloc(1, contextsize);
        if (!context) {
            Py_DECREF(encoder);
            (void) PyErr_NoMemory();
            return NULL;
        }
    } else
        context = 0;

    /* Initialize encoder context */
    encoder->state.context = context;

    /* Most encoders don't need this */
    encoder->cleanup = NULL;

    /* Target image */
    encoder->lock = NULL;
    encoder->im = NULL;

    return encoder;
}
コード例 #23
0
ファイル: xbmcmodule.cpp プロジェクト: mbosner/xbmc
/*****************************************************************
 * end of methods and python objects
 * initxbmc(void);
 *****************************************************************/
  PyMODINIT_FUNC
  InitXBMCTypes(bool bInitTypes)
  {
    initKeyboard_Type();
    initPlayer_Type();
    initPlayList_Type();
    initPlayListItem_Type();
    initInfoTagMusic_Type();
    initInfoTagVideo_Type();

    if (PyType_Ready(&Keyboard_Type) < 0 ||
        PyType_Ready(&Player_Type) < 0 ||
        PyType_Ready(&PlayList_Type) < 0 ||
        PyType_Ready(&PlayListItem_Type) < 0 ||
        PyType_Ready(&InfoTagMusic_Type) < 0 ||
        PyType_Ready(&InfoTagVideo_Type) < 0) return;
  }
コード例 #24
0
ファイル: pygoom_module.c プロジェクト: adozenlines/freevo1
PyMODINIT_FUNC
initpygoom(void)
{
	PyObject *m;

    import_pygame_surface();
	/* Due to cross platform compiler issues the slots must be filled
	 * here. It's required for portability to Windows without requiring
	 * C++. */

	/* Finalize the type object including setting type of the new type
	 * object; doing it here is required for portability, too. */
	if (PyType_Ready(&PyGoomType) < 0) {
		return;
	}

	/* Create the module and add the functions */
	m = Py_InitModule3("pygoom", pygoom_methods, module_doc);
	if (m == NULL) {
		return;
	}

	updateModuleDict(m);

	Py_INCREF((PyObject *)&PyGoomType);
	PyModule_AddObject(m, "PyGoom", (PyObject *)&PyGoomType);


	/* Add some symbolic constants to the module */
	if (ErrorObject == NULL) {
		ErrorObject = PyErr_NewException("pygoom.error", NULL, NULL);
		if (ErrorObject == NULL) {
			return;
		}
	}
	Py_INCREF(ErrorObject);
	PyModule_AddObject(m, "error", ErrorObject);
}
コード例 #25
0
ファイル: bpy_app_handlers.c プロジェクト: diekev/blender
PyObject *BPY_app_handlers_struct(void)
{
	PyObject *ret;

#if defined(_MSC_VER) || defined(FREE_WINDOWS)
	BPyPersistent_Type.ob_base.ob_base.ob_type = &PyType_Type;
#endif

	if (PyType_Ready(&BPyPersistent_Type) < 0) {
		BLI_assert(!"error initializing 'bpy.app.handlers.persistent'");
	}

	PyStructSequence_InitType(&BlenderAppCbType, &app_cb_info_desc);

	ret = make_app_cb_info();

	/* prevent user from creating new instances */
	BlenderAppCbType.tp_init = NULL;
	BlenderAppCbType.tp_new = NULL;
	BlenderAppCbType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */

	/* assign the C callbacks */
	if (ret) {
		static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT] = {{NULL}};
		bCallbackFuncStore *funcstore;
		int pos = 0;

		for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) {
			funcstore = &funcstore_array[pos];
			funcstore->func = bpy_app_generic_callback;
			funcstore->alloc = 0;
			funcstore->arg = SET_INT_IN_POINTER(pos);
			BLI_callback_add(funcstore, pos);
		}
	}

	return ret;
}
コード例 #26
0
ファイル: pyLogicModBase.cpp プロジェクト: boq/libhsplasma
PyObject* Init_pyLogicModBase_Type() {
    pyLogicModBase_Type.tp_base = &pySingleModifier_Type;
    if (PyType_Ready(&pyLogicModBase_Type) < 0)
        return NULL;

    PyDict_SetItemString(pyLogicModBase_Type.tp_dict, "kLocalElement",
                         PyInt_FromLong(plLogicModBase::kLocalElement));
    PyDict_SetItemString(pyLogicModBase_Type.tp_dict, "kReset",
                         PyInt_FromLong(plLogicModBase::kReset));
    PyDict_SetItemString(pyLogicModBase_Type.tp_dict, "kTriggered",
                         PyInt_FromLong(plLogicModBase::kTriggered));
    PyDict_SetItemString(pyLogicModBase_Type.tp_dict, "kOneShot",
                         PyInt_FromLong(plLogicModBase::kOneShot));
    PyDict_SetItemString(pyLogicModBase_Type.tp_dict, "kRequestingTrigger",
                         PyInt_FromLong(plLogicModBase::kRequestingTrigger));
    PyDict_SetItemString(pyLogicModBase_Type.tp_dict, "kTypeActivator",
                         PyInt_FromLong(plLogicModBase::kTypeActivator));
    PyDict_SetItemString(pyLogicModBase_Type.tp_dict, "kMultiTrigger",
                         PyInt_FromLong(plLogicModBase::kMultiTrigger));

    Py_INCREF(&pyLogicModBase_Type);
    return (PyObject*)&pyLogicModBase_Type;
}
コード例 #27
0
    static int
PythonMod_Init(void)
{
    PyObject *mod;
    PyObject *dict;
    PyObject *tmp;
    /* The special value is removed from sys.path in Python_Init(). */
    static char *(argv[2]) = {"/must>not&exist/foo", NULL};

    /* Fixups... */
    PyType_Ready(&BufferType);
    PyType_Ready(&RangeType);
    PyType_Ready(&WindowType);
    PyType_Ready(&BufListType);
    PyType_Ready(&WinListType);
    PyType_Ready(&CurrentType);

    /* Set sys.argv[] to avoid a crash in warn(). */
    PySys_SetArgv(1, argv);

    mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION);
    dict = PyModule_GetDict(mod);

    VimError = Py_BuildValue("s", "vim.error");

    PyDict_SetItemString(dict, "error", VimError);
    PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferList);
    PyDict_SetItemString(dict, "current", (PyObject *)(void *)&TheCurrent);
    PyDict_SetItemString(dict, "windows", (PyObject *)(void *)&TheWindowList);
    tmp = DictionaryNew(&globvardict);
    PyDict_SetItemString(dict, "vars",    tmp);
    Py_DECREF(tmp);
    tmp = DictionaryNew(&vimvardict);
    PyDict_SetItemString(dict, "vvars",   tmp);
    Py_DECREF(tmp);
    PyDict_SetItemString(dict, "VAR_LOCKED",    PyInt_FromLong(VAR_LOCKED));
    PyDict_SetItemString(dict, "VAR_FIXED",     PyInt_FromLong(VAR_FIXED));
    PyDict_SetItemString(dict, "VAR_SCOPE",     PyInt_FromLong(VAR_SCOPE));
    PyDict_SetItemString(dict, "VAR_DEF_SCOPE", PyInt_FromLong(VAR_DEF_SCOPE));

    if (PyErr_Occurred())
	return -1;

    return 0;
}
コード例 #28
0
ファイル: module.c プロジェクト: rlutz/geda-gaf
PyMODINIT_FUNC initguile(void)
{
	PyObject *module;

	if (PyType_Ready(&ProcedureType) == -1)
		return;

	module = Py_InitModule3("guile", methods, PyDoc_STR("Guile bindings"));
	if (module == NULL)
		return;

	Py_INCREF(&ProcedureType);
	if (PyModule_AddObject(
		    module, "Procedure", (PyObject *)&ProcedureType) == -1)
		return;

	guile_error = PyErr_NewExceptionWithDoc(
		"xorn.guile.GuileError", PyDoc_STR("Guile exception"),
		NULL, NULL);
	if (guile_error == NULL ||
	    PyModule_AddObject(module, "GuileError", guile_error) == -1)
		return;
}
コード例 #29
0
//-------------------MODULE INITIALIZATION--------------------------------
int UnaryFunction0D_Init(PyObject *module)
{
    if (module == NULL)
        return -1;

    if (PyType_Ready(&UnaryFunction0D_Type) < 0)
        return -1;
    Py_INCREF(&UnaryFunction0D_Type);
    PyModule_AddObject(module, "UnaryFunction0D", (PyObject *)&UnaryFunction0D_Type);

    UnaryFunction0DDouble_Init(module);
    UnaryFunction0DEdgeNature_Init(module);
    UnaryFunction0DFloat_Init(module);
    UnaryFunction0DId_Init(module);
    UnaryFunction0DMaterial_Init(module);
    UnaryFunction0DUnsigned_Init(module);
    UnaryFunction0DVec2f_Init(module);
    UnaryFunction0DVec3f_Init(module);
    UnaryFunction0DVectorViewShape_Init(module);
    UnaryFunction0DViewShape_Init(module);

    return 0;
}
コード例 #30
0
ファイル: connection.c プロジェクト: svpcom/pyopenssl-pypy
/*
 * Initiailze the Connection part of the SSL sub module
 *
 * Arguments: dict - The OpenSSL.SSL module
 * Returns:   1 for success, 0 otherwise
 */
int
init_ssl_connection(PyObject *module) {

    if (PyType_Ready(&ssl_Connection_Type) < 0) {
        return 0;
    }

    /* PyModule_AddObject steals a reference.
     */
    Py_INCREF((PyObject *)&ssl_Connection_Type);
    if (PyModule_AddObject(module, "Connection", (PyObject *)&ssl_Connection_Type) != 0) {
        return 0;
    }

    /* PyModule_AddObject steals a reference.
     */
    Py_INCREF((PyObject *)&ssl_Connection_Type);
    if (PyModule_AddObject(module, "ConnectionType", (PyObject *)&ssl_Connection_Type) != 0) {
        return 0;
    }

    return 1;
}