You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 610 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
The manual says on errorcheck() attribute:
[---cut---]
If the errorcheck( fn ) attribute is provided for the typedef ty, the error
checking function fn is called each time a function result of type ty is
converted from C to Caml. The function can then check the ty value for
values indicating an error condition, and raise the appropriate
exception. If in addition the errorcode attribute is provided, the
conversion from C to Caml is suppressed: values of type ty are only passed
to fn for error checking, then discarded.
[---cut---]
Having read this I tried the following test example:
[---errorcheck.idl---]
typedef [errorcheck(echeck)] int INT;
void f(INT i);
[---errorcheck.idl---]
Camlidl is happy with that, but echeck() function is never used in the
generated stub, atlhough "errorcheck" is appended to conversion function
names:
value camlidl_c2ml_errorcheck_INT(INT * _c2, camlidl_ctx _ctx)
{
value _v1;
_v1 = Val_int((*_c2));
return _v1;
}
value camlidl_errorcheck_f(
value _v_i)
{
INT i; /in/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_errorcheck_INT(_v_i, &i, _ctx);
f(i);
camlidl_free(_ctx);
return Val_unit;
}
[---errorcheck.c---]
What am I doing wrong and how errorcheck() attribute is supposed to be
used? Sorry for posting it to caml-bugs (it may not be a bug, just my
misunderstanding).
Hope to hear from you soon,
Dmitry
The text was updated successfully, but these errors were encountered:
Apologies for taking so long to reply, but I'm just back on working on
CamlIDL maintenance.
If the errorcheck( fn ) attribute is provided for the typedef ty, the error
checking function fn is called each time a function result of type ty is
^^^^^^^^^^^^^^^
converted from C to Caml. The function can then check the ty value for
values indicating an error condition, and raise the appropriate
exception.
Having read this I tried the following test example:
[---errorcheck.idl---]
typedef [errorcheck(echeck)] int INT;
void f(INT i);
[---errorcheck.idl---]
Camlidl is happy with that, but echeck() function is never used in the
generated stub
This is normal, since your function does not return a value of type INT.
Try declaring "INT g();" for instance.
, atlhough "errorcheck" is appended to conversion function
names:
This "errorcheck" prefix comes from the name of your idl file,
i.e. errorcheck.idl
Original bug ID: 610
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
The manual says on errorcheck() attribute:
[---cut---]
If the errorcheck( fn ) attribute is provided for the typedef ty, the error
checking function fn is called each time a function result of type ty is
converted from C to Caml. The function can then check the ty value for
values indicating an error condition, and raise the appropriate
exception. If in addition the errorcode attribute is provided, the
conversion from C to Caml is suppressed: values of type ty are only passed
to fn for error checking, then discarded.
[---cut---]
Having read this I tried the following test example:
[---errorcheck.idl---]
typedef [errorcheck(echeck)] int INT;
void f(INT i);
[---errorcheck.idl---]
Camlidl is happy with that, but echeck() function is never used in the
generated stub, atlhough "errorcheck" is appended to conversion function
names:
[---errorcheck.c---]
void camlidl_ml2c_errorcheck_INT(value _v1, INT * _c2, camlidl_ctx _ctx)
{
(*_c2) = Int_val(_v1);
}
value camlidl_c2ml_errorcheck_INT(INT * _c2, camlidl_ctx _ctx)
{
value _v1;
_v1 = Val_int((*_c2));
return _v1;
}
value camlidl_errorcheck_f(
value _v_i)
{
INT i; /in/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_errorcheck_INT(_v_i, &i, _ctx);
f(i);
camlidl_free(_ctx);
return Val_unit;
}
[---errorcheck.c---]
What am I doing wrong and how errorcheck() attribute is supposed to be
used? Sorry for posting it to caml-bugs (it may not be a bug, just my
misunderstanding).
Hope to hear from you soon,
Dmitry
The text was updated successfully, but these errors were encountered: