#571·jna

Callback on a CLang code block?

Author: srsCreated Dec 31, 2015Updated Apr 4, 2025
Labelsfeature request

Hi.

I am trying to call a method on OSX that takes a closure (CLang Block) as an argument. The method is xpc_connection_set_event_handler and the signature is as follows:

typedef void (*xpc_connection_handler_t)(xpc_connection_t connection);

typedef void (^xpc_handler_t)(xpc_object_t object);

void xpc_connection_set_event_handler(xpc_connection_t connection, xpc_handler_t handler); 

Right now I am calling it using a JNA Callback but that does not seem to work. Anyone that have done the same or similar calling to a closure (or code block)?

BR, Sten Roger