示例#1
0
// Return the Python result from a QGenericReturnArgument.
PyObject *qpycore_ReturnValue(PyObject *gra_obj)
{
    PyObject *as_obj = sipGetUserObject((sipSimpleWrapper *)gra_obj);

#if defined(SIP_USE_PYCAPSULE)
    Chimera::Storage *st = reinterpret_cast<Chimera::Storage *>(
            PyCapsule_GetPointer(as_obj, NULL));
#else
    Chimera::Storage *st = reinterpret_cast<Chimera::Storage *>(
            PyCObject_AsVoidPtr(as_obj));
#endif

    return st->toPyObject();
}
// Get the cache for a set of bindings.
static qpyopengl_dataCache *get_cache(PyObject *bindings)
{
    // Create the cache if it doesn't already exist.
    qpyopengl_dataCache *data_cache = (qpyopengl_dataCache *)sipGetUserObject((sipSimpleWrapper *)bindings);

    if (!data_cache)
    {
        data_cache = qpyopengl_dataCache_New();

        if (data_cache)
            sipSetUserObject((sipSimpleWrapper *)bindings,
                    (PyObject *)data_cache);
    }

    return data_cache;
}