I need to create a JS API to a C driver function of the following form: int myFunc(MyStruct *pStruct);
…where MyStruct
is quite a complicated beast, containing a callback function and a linked list of items:
typedef struct ListItem {
int a;
int b;
struct ListItem *pNext;
} ListItem;
typedef struct {
int a;
int (*pCallback)(void *);
void *pCallbackParam;
ListItem *pList;
} MyStruct;
I’ve looked at the s2o
stuff but that seems to be only for the C-struct-to-JS-object direction, whereas I need to handle the JS-object-to-C-struct direction.
What is the best practice for creating JS representations of such complex structures that I can then convert into the required C structure for the driver?