-
Notifications
You must be signed in to change notification settings - Fork 67
Support for Incomplete-Array in structs. #506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could we support https://github.com/twain/twain-dsm/blob/master/TWAIN_DSM/src/twain.h#L218-L221 typedef unsigned char TW_STR32[34], FAR *pTW_STR32;
typedef unsigned char TW_STR64[66], FAR *pTW_STR64;
typedef unsigned char TW_STR128[130], FAR *pTW_STR128;
typedef unsigned char TW_STR255[256], FAR *pTW_STR255; Which are used at https://github.com/twain/twain-dsm/blob/master/TWAIN_DSM/src/twain.h#L439 typedef struct {
TW_UINT16 MajorNum;
TW_UINT16 MinorNum;
TW_UINT16 Language;
TW_UINT16 Country;
TW_STR32 Info;
} TW_VERSION, FAR * pTW_VERSION; |
Hi @Sunbreak, add |
It result a quit long file with 16680 lines, T_T |
I managed to hack like below: // struct TW_VERSION {
// TW_UINT16 MajorNum;
// TW_UINT16 MinorNum;
// TW_UINT16 Language;
// TW_UINT16 Country;
// TW_STR32 Info;
// };
class TWVersion extends _TWStruct<TW_VERSION> {
static const _size = 2 + 2 + 2 + 2 + 34;
TWVersion._fromAddress(int ptr): super._fromAddress(ptr);
@override
void dispose() {
throw 'Undisposable nested structure';
}
@override
int get size => _size;
int get MajorNum => _getUint16(0);
set MajorNum(int i) => _setUint16(0, i);
int get MinorNum => _getUint16(2);
set MinorNum(int i) => _setUint16(2, i);
int get Language => _getUint16(4);
set Language(int i) => _setUint16(4, i);
int get Country => _getUint16(6);
set Country(int i) => _setUint16(6, i);
static const _InfoOffset = 2 + 2 + 2 + 2;
String get Info => _getString(_InfoOffset, 34);
set Info(String s) => _setString(_InfoOffset, s, 34);
} It seems to work, even nested in another Struct |
True, that's why we have chosen to keep it disabled by default. Hopefully, we should get inline array support soon.
That's a nice hack, but it cannot be used for all use cases (for example if these were pointers, the size would be 4/8 depending on the architecture). |
Any plan? |
C supports Flexible-Arrays as the last member of a struct having more than 1 member.
Structs of the following type -
are not supported currently.
The text was updated successfully, but these errors were encountered: