Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000610OCamlCamlIDLpublic2001-11-06 21:502002-01-15 16:19
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000610: Camlidl: how errorcheck() attribute is supposed to work?
DescriptionThe 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


TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000077)
administrator (administrator)
2002-01-15 16:19

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

(0000078)
administrator (administrator)
2002-01-15 16:19

Works as documented.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker