It's quite funny how similar your struct system is to one I started making
How do you define elements that are arrays with your system? e.g.
lfFaceName in LOGFONT.
I was trying to find a clean way of doing it, but I gave up (unlike me!
)
Here's an example for what I did for strings:
js code:
API.typedef('string', function(length){
return {
size : ((length + 1) * 2),
get : function(dataBloc, offset) {
return dataBloc.ReadString(offset);
},
set : function(dataBloc, offset, value) {
dataBloc.WriteString(offset, value);
}
}
});
But I "built" the DataBloc during construction rather than with an extra function, so it might be easier to do variable-size members your way.
It's nice to know you made almost exactly the same thing anyway, it means I don't need to finish mine now