Skip to content
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: how errorcheck() attribute is supposed to work? #3014

Closed
vicuna opened this issue Nov 6, 2001 · 2 comments
Closed

Camlidl: how errorcheck() attribute is supposed to work? #3014

vicuna opened this issue Nov 6, 2001 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Nov 6, 2001

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

@vicuna
Copy link
Author

vicuna commented Jan 15, 2002

Comment author: administrator

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

Best regards,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jan 15, 2002

Comment author: administrator

Works as documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant