Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow additional callback arguments in Python API #369

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

argilo
Copy link
Collaborator

@argilo argilo commented Feb 26, 2025

The C API allows additional data to be passed into the callback function through an opaque pointer:

nrsc5/include/nrsc5.h

Lines 589 to 597 in a4b7883

/**
* Establish a callback function.
*
* @param[in] st pointer to an `nrsc5_t` session object
* @param[in] callback pointer to an event handling function of two arguments
* @param[in] opaque pointer to the function's intended 2nd argument
*
*/
NRSC5_API void nrsc5_set_callback(nrsc5_t *st, nrsc5_callback_t callback, void *opaque);

But the Python API doesn't have such a mechanism. It's possible to use closures, but that's not always convenient. So I've added an optional callback_args which will be passed through to the callback function. A tuple or list of arguments can be supplied.

@argilo argilo merged commit 7b29dde into master Feb 26, 2025
8 checks passed
@argilo argilo deleted the python-callback-args branch February 26, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant