/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_export_c_api.h

  • Committer: Martin
  • Date: 2017-06-27 00:10:52 UTC
  • mto: This revision was merged to the branch mainline in revision 6721.
  • Revision ID: gzlist@googlemail.com-20170627001052-o70zln144nmwhamo
Switch c_api helpers for _static_tuple_c to capsules

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 */
17
17
 
18
 
/* GZ 2017-06-22: This header needs updating to use Capsules over CObjects */
19
 
 
20
18
/* This file contains helper functions for exporting a C API for a CPython
21
19
 * extension module.
22
20
 */
44
42
_export_function(PyObject *module, char *funcname, void *func, char *signature)
45
43
{
46
44
    PyObject *d = NULL;
47
 
    PyObject *c_obj = NULL;
 
45
    PyObject *capsule = NULL;
48
46
 
49
47
    d = PyObject_GetAttrString(module, _C_API_NAME);
50
48
    if (!d) {
56
54
        if (PyModule_AddObject(module, _C_API_NAME, d) < 0)
57
55
            goto bad;
58
56
    }
59
 
    c_obj = PyCObject_FromVoidPtrAndDesc(func, signature, 0);
60
 
    if (!c_obj)
 
57
    capsule = PyCapsule_New(func, signature, 0);
 
58
    if (!capsule)
61
59
        goto bad;
62
 
    if (PyDict_SetItemString(d, funcname, c_obj) < 0)
 
60
    if (PyDict_SetItemString(d, funcname, capsule) < 0)
63
61
        goto bad;
64
62
    Py_DECREF(d);
65
63
    return 0;
66
64
bad:
67
 
    Py_XDECREF(c_obj);
 
65
    Py_XDECREF(capsule);
68
66
    Py_XDECREF(d);
69
67
    return -1;
70
68
}