Quite a few structures passed to Windows API functions have their own size as a field. I could just have the user of my P/Invoke command-line tool figure out the size in bytes and supply that manually, but that gets difficult for large structures. Besides, when there are pointer-sized fields in play, the lengths will be different between bitnesses. So today, I added a keyword that, in parameter lists, gets replaced with the size of the structure once all the rest of the parameters are processed.
While testing that, I realized that's it's really inconvenient to be required to specify in (units) before as (type) when expressing a length. So I adjusted the function responsible for parsing those to take them in either order and allow as to be supplied on its own.
newslot block withSize = blocksize as int, ulong 1, ulong 77;
newslot int theSize = 0;
copyslot theSize = withSize field 0;
readslot theSize
That returns 24 (not 20, because of alignment requirements).
No comments:
Post a Comment