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
Camlidl: a problem with encapsulated union #3044
Comments
Comment author: administrator
Right. There was a serious limitation in CamlIDL, namely that
|
Comment author: administrator Fixed 2002-01-16 by XL |
Comment author: administrator Xavier Leroy xavier.leroy@inria.fr writes:
Good job! Thank you very much. Frankly speaking, then I submitted that bug BTW, why CamlIDL accepts typedef struct _Array but not typedef struct _Array (function struct _Array: Illegal reference to dependent variable len. This Hope to hear from you soon, |
Original bug ID: 644
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
The following .idl definitions
[---cut---]
typedef enum _SwitchType
{
FLOAT_ARRAY = 1,
DOUBLE_ARRAY = 2
} SwitchType;
typedef struct _Array
{
int len;
SwitchType type;
[switch_is(type)] union
{
case FLOAT_ARRAY: [size_is(len)] float* fl;
case DOUBLE_ARRAY: [size_is(len)] double* db;
} data;
} Array;
[---cut---]
generate incorrect .c file:
[---cut---]
void camlidl_ml2c_union3_struct__Array(value _v1, struct _Array * _c2, camlidl_ctx _ctx)
{
value _v3;
value _v4;
value _v5;
mlsize_t _c6;
mlsize_t _c7;
value _v8;
mlsize_t _c9;
mlsize_t _c10;
_v3 = Field(_v1, 0);
(_c2).len = Int_val(_v3);
_v4 = Field(_v1, 1);
switch (Tag_val(_v4)) {
case 0: / FLOAT_ARRAY /
(_c2).type = FLOAT_ARRAY;
_v5 = Field(_v4, 0);
_c6 = Wosize_val(_v5) / Double_wosize;
(_c2).data.fl = camlidl_malloc(_c6 * sizeof(float ), _ctx);
for (_c7 = 0; _c7 < _c6; _c7++) {
(_c2).data.fl[_c7] = Double_field(_v5, _c7);
}
_badprefix.len = _c6;
break;
case 1: /* DOUBLE_ARRAY /
(_c2).type = DOUBLE_ARRAY;
_v8 = Field(_v4, 0);
_c9 = Wosize_val(_v8) / Double_wosize;
(_c2).data.db = camlidl_malloc(_c9 * sizeof(double ), _ctx);
for (_c10 = 0; _c10 < _c9; _c10++) {
(_c2).data.db[_c10] = Double_field(_v8, _c10);
}
_badprefix.len = _c9;
break;
}
}
[---cut---]
Note _badprefix instead of (*_c2) in the body. It looks like a bug ... Is
any workaround possible?
Hope to hear from you soon,
Dmitry
The text was updated successfully, but these errors were encountered: