diff options
author | Justus Winter <[email protected]> | 2016-06-13 17:16:30 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-06-16 12:19:17 +0000 |
commit | f3618bc615e3eff1f52fb5849cbf0f0b95515a61 (patch) | |
tree | bfd2d2020b558bc8db7bd028cdc6d24167f657f3 /lang/python/helpers.h | |
parent | python: Wrap objects implementing the buffer protocol. (diff) | |
download | gpgme-f3618bc615e3eff1f52fb5849cbf0f0b95515a61.tar.gz gpgme-f3618bc615e3eff1f52fb5849cbf0f0b95515a61.zip |
python: Rework callbacks.
Simplify how the lifetime of callback arguments is managed.
* lang/python/gpgme.i (gpgme_edit_cb_t): Check arguments.
(PyObject_p_p, void_p_p): Drop rather dangerous interface.
(pygpgme_unwrap_gpgme_ctx_t): New function.
* lang/python/helpers.c (pygpgme_clear_generic_cb): Drop dangerous
function.
(pyPassphraseCb): Assert contract.
(pygpgme_set_passphrase_cb): Use Python's calling convention so that
we can raise exceptions. Hand in 'self', get the wrapped object, and
simply store the hook data as attribute of the wrapper object.
(pyProgressCb, pygpgme_set_progress_cb): Likewise.
(pygpgme_set_status_cb): Likewise.
(pygpgme_data_new_from_cbs): Likewise.
* lang/python/helpers.h (pygpgme_clear_generic_cb): Drop prototype.
(pygpgme_set_passphrase_cb): Update prototype.
(pygpgme_set_progress_cb): Likewise.
(pygpgme_set_status_cb): Likewise.
(pygpgme_data_new_from_cbs): Likewise.
(pygpgme_unwrap_gpgme_ctx_t): New prottotype.
* lang/python/pyme/core.py (Context, Data): Update callsites.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rw-r--r-- | lang/python/helpers.h | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lang/python/helpers.h b/lang/python/helpers.h index 37362aee..15642903 100644 --- a/lang/python/helpers.h +++ b/lang/python/helpers.h @@ -34,21 +34,18 @@ PyObject *object_to_gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper, PyObject **bytesio, Py_buffer *view); -void pygpgme_clear_generic_cb(PyObject **cb); PyObject *pygpgme_raise_callback_exception(PyObject *self); -void pygpgme_set_passphrase_cb(gpgme_ctx_t ctx, PyObject *cb, - PyObject **freelater); -void pygpgme_set_progress_cb(gpgme_ctx_t ctx, PyObject *cb, PyObject **freelater); -void pygpgme_set_status_cb(gpgme_ctx_t ctx, PyObject *cb, - PyObject **freelater); +PyObject *pygpgme_set_passphrase_cb(PyObject *self, PyObject *cb); +PyObject *pygpgme_set_progress_cb(PyObject *self, PyObject *cb); +PyObject *pygpgme_set_status_cb(PyObject *self, PyObject *cb); gpgme_error_t pyEditCb(void *opaque, gpgme_status_code_t status, const char *args, int fd); -gpgme_error_t pygpgme_data_new_from_cbs(gpgme_data_t *r_data, - PyObject *pycbs, - PyObject **freelater); +PyObject *pygpgme_data_new_from_cbs(PyObject *self, PyObject *pycbs, + gpgme_data_t *r_data); /* SWIG support for helpers.c */ PyObject *pygpgme_wrap_gpgme_data_t(gpgme_data_t data); +gpgme_ctx_t pygpgme_unwrap_gpgme_ctx_t(PyObject *wrapped); |