Skip to content

Improve callback function support #364

Open
@vchuravy

Description

Right now we are generating:

# typedef void ( * pmix_event_notification_cbfunc_fn_t ) ( pmix_status_t status , pmix_info_t * results , size_t nresults , pmix_op_cbfunc_t cbfunc , void * thiscbdata , void * notification_cbdata )
const pmix_event_notification_cbfunc_fn_t = Ptr{Cvoid}

And I find myself writing:

function notification_fn(evhdlr_registration_id::Csize_t, status::PMIx.API.pmix_status_t, source::Ptr{PMIx.API.pmix_proc_t},
                         info::Ptr{PMIx.API.pmix_info_t}, ninfo::Csize_t,
                         results::Ptr{PMIx.API.pmix_info_t}, nresults::Csize_t,
                         cbfunc::PMIx.API.pmix_event_notification_cbfunc_fn_t, cbdata::Ptr{Cvoid})::Nothing
...
end

callback = @cfunction(notification_fn, Cvoid, (Csize_t, PMIx.API.pmix_status_t, Ptr{PMIx.API.pmix_proc_t}, Ptr{PMIx.API.pmix_info_t}, Csize_t, Ptr{PMIx.API.pmix_info_t}, Csize_t, Ptr{PMIx.API.pmix_event_notification_cbfunc_fn_t}, Ptr{Cvoid}))

The type annotation in notation_fn is not necessary, but I do find it helps with these long signature.

I was thinking of defining a custom struct, but that requires @cfunction($) and that is not fully supported everywhere.
So maybe a macro that makes the cfunction easier?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions