I am attempting to port this code into JNA:
https://github.com/Chris911/iStats/blob/master/ext/osx_stats/smc.c
Unfortunately, I'm hitting a wall figuring out how to handle a pointer to a pointer to an int.
Specifically, this variable is defined:
static io_connect_t conn;
The io_connect_t is best mapped by an IntByReference, similar to all the other io_object_t types. Unfortunately one method is tripping me up.
result = IOServiceOpen(device, mach_task_self(), 0, &conn);
The full declaration of this method is below (note both io_service_t and io_connect_t are the same underying io_object_t, which should be IntByReference.)
kern_return_t IOServiceOpen( io_service_t service, task_port_t owningTask, uint32_t type, io_connect_t *connect );
In this case, the &conn argument is itself an IntByReference, meaning that the .getValue() method, applied to the argument I pass, should match the io_connect_t type itself... basically I want the type of IntByReference.getValue() to also be IntByReference.
In my JNA code, I've represented the argument to the above as IOConnect (extends IOObject, extends IntByReference) but unfortunately I'm stumped trying to use that returned value. connect.getValue() returns an integer, when that integer is actually still a reference... I need something like connect.getValue().getValue.
I've tried numerous combinations of ints, IntByReferences, and other shenanigans without success. I'm probably missing something obvious. Any advice?