python: Define a macro for wrapping fragile result objects.
* lang/python/gpgme.i (wrapresult): New Macro. -- This reduces the amount of copy and pasted code at the expense of a slightly more complicated logic with a macro. Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
This commit is contained in:
parent
ae21d2705f
commit
fb7f4cb973
@ -424,69 +424,24 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Wrap the fragile result objects into robust Python ones. */
|
/* Wrap the fragile result objects into robust Python ones. */
|
||||||
%typemap(out) gpgme_encrypt_result_t {
|
%define wrapresult(cls, name)
|
||||||
|
%typemap(out) cls {
|
||||||
PyObject *fragile;
|
PyObject *fragile;
|
||||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||||
%newpointer_flags);
|
%newpointer_flags);
|
||||||
$result = _gpg_wrap_result(fragile, "EncryptResult");
|
$result = _gpg_wrap_result(fragile, name);
|
||||||
Py_DECREF(fragile);
|
Py_DECREF(fragile);
|
||||||
}
|
}
|
||||||
|
%enddef
|
||||||
|
|
||||||
%typemap(out) gpgme_decrypt_result_t {
|
wrapresult(gpgme_encrypt_result_t, "EncryptResult")
|
||||||
PyObject *fragile;
|
wrapresult(gpgme_decrypt_result_t, "DecryptResult")
|
||||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
wrapresult(gpgme_sign_result_t, "SignResult")
|
||||||
%newpointer_flags);
|
wrapresult(gpgme_verify_result_t, "VerifyResult")
|
||||||
$result = _gpg_wrap_result(fragile, "DecryptResult");
|
wrapresult(gpgme_import_result_t, "ImportResult")
|
||||||
Py_DECREF(fragile);
|
wrapresult(gpgme_genkey_result_t, "GenkeyResult")
|
||||||
}
|
wrapresult(gpgme_keylist_result_t, "KeylistResult")
|
||||||
|
wrapresult(gpgme_vfs_mount_result_t, "VFSMountResult")
|
||||||
%typemap(out) gpgme_sign_result_t {
|
|
||||||
PyObject *fragile;
|
|
||||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
|
||||||
%newpointer_flags);
|
|
||||||
$result = _gpg_wrap_result(fragile, "SignResult");
|
|
||||||
Py_DECREF(fragile);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(out) gpgme_verify_result_t {
|
|
||||||
PyObject *fragile;
|
|
||||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
|
||||||
%newpointer_flags);
|
|
||||||
$result = _gpg_wrap_result(fragile, "VerifyResult");
|
|
||||||
Py_DECREF(fragile);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(out) gpgme_import_result_t {
|
|
||||||
PyObject *fragile;
|
|
||||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
|
||||||
%newpointer_flags);
|
|
||||||
$result = _gpg_wrap_result(fragile, "ImportResult");
|
|
||||||
Py_DECREF(fragile);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(out) gpgme_genkey_result_t {
|
|
||||||
PyObject *fragile;
|
|
||||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
|
||||||
%newpointer_flags);
|
|
||||||
$result = _gpg_wrap_result(fragile, "GenkeyResult");
|
|
||||||
Py_DECREF(fragile);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(out) gpgme_keylist_result_t {
|
|
||||||
PyObject *fragile;
|
|
||||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
|
||||||
%newpointer_flags);
|
|
||||||
$result = _gpg_wrap_result(fragile, "KeylistResult");
|
|
||||||
Py_DECREF(fragile);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(out) gpgme_vfs_mount_result_t {
|
|
||||||
PyObject *fragile;
|
|
||||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
|
||||||
%newpointer_flags);
|
|
||||||
$result = _gpg_wrap_result(fragile, "VFSMountResult");
|
|
||||||
Py_DECREF(fragile);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(out) gpgme_engine_info_t {
|
%typemap(out) gpgme_engine_info_t {
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
Reference in New Issue
Block a user