This shim sits between the C++ world and the R world. I.e. this R function gets called from the C++ code. Calls are then made from here to the R callback function.

rcallback(device_call, state, args)

Arguments

device_call

name of device call

state

list of rdata, dd and gc

args

args to the device call

Details

This shim should do the heavy lifting in terms of error checking to ensure that errors aren't propogated back to the C++ execution (because if that happens we get a segmentation fault!)

It should also do sanity checking of return objects i.e. is 'rdata' still a list?

TODO: Could then do signatures of the input state and the return values and only include them in the return object if things have changed?