TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
453 stars 141 forks source link

How to create pointers to dynamically allocated StructTypes? #54

Closed ztamizzen closed 7 years ago

ztamizzen commented 7 years ago

I've struggled with this for next to a week now and I need to get past it. So, the problem is this. I have a

let TobiiProEyeTracker = StructType({
    uri: "string",
    device_name: "string",
    serial_number: "string",
    model: "string",
    generation: "string",
    firmware_version: "string"
});

And I have some C code (the struct is the same as above):

TobiiProEyeTracker** trackers = NULL;

and the signature of the function to call uses the above variable as first argument, it populates it with a set amount of "trackers" of type TobiiProEyeTracker.

I've been able to populate ONE, like this:

let tobiiEyeTrackerStructPtr = (new this.TobiiProEyeTracker()).ref(),
     tobiiEyeTrackerStructPtrPtr = tobiiEyeTrackerStructPtr.ref();

I need to populate all I ask for (currently there are 14 trackers on my network). The amount is already in place so that is not a problem, the problem is the **.

Not a bug per say but I really need the help.. Thanks in advance.

TooTallNate commented 7 years ago

Sorry for the late response. Look into using ref-array here. I'd have to see exactly what the C code looked like to tell you how to port it, but let me know if you need any more help on that.