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 : conversion to ocaml of C structs with floats fields only #7990

Closed
vicuna opened this issue Jan 12, 2003 · 1 comment
Closed

camlidl : conversion to ocaml of C structs with floats fields only #7990

vicuna opened this issue Jan 12, 2003 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jan 12, 2003

Original bug ID: 1517
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues

Bug description

Full_Name: Daniel Bünzli
Version: ocaml 3.06/ camlidl 1.04
OS: macos 10.2.3
Submission from: dialin-client-62-2-142-120.hispeed.ch (62.2.142.120)

Dear Bugmaster,

The conversion function from C to ocaml of structs with fields of floats only
seems to be badly generated by camlidl. To give the simplest example, the
following idl declaration :

typedef struct {
float x;
float y;
} point;

generates this C code :

value camlidl_c2ml_struc_point(point * _c2, camlidl_ctx _ctx)
{
value _v1;
_v1 = camlidl_alloc_small(2 * Double_wosize, Double_tag);
Store_double_val(_v1, (_c2).x);
Store_double_val(_v1, (
_c2).y);
return _v1;
}

Which has the annoying property of generating points in ocaml whose second
coordinate is projected on the x axis.

The following change in the function `convert_fields' defined for the special
case of structures of floats only seems to give me more expectable results.

diff -rcs camlidl-1.04/compiler/struct.ml camlidl-1.04/compiler/struct.ml.bug

*** camlidl-1.04/compiler/struct.ml Sun Jan 12 23:13:17 2003
--- camlidl-1.04/compiler/struct.ml.bug Mon Jan 6 00:46:57 2003


*** 101,107 ****
let rec convert_fields pos = function
[] -> ()
| f :: rem ->
! iprintf oc "Store_double_field(%s, %d, %s.%s);\n" v pos c
f.field_name;
convert_fields (pos + 1) rem in
convert_fields 0 sd.sd_fields
end else begin
--- 101,107 ----
let rec convert_fields pos = function
[] -> ()
| f :: rem ->
! iprintf oc "Store_double_val(%s, %s.%s);\n" v c f.field_name;
convert_fields (pos + 1) rem in
convert_fields 0 sd.sd_fields
end else begin

Double check this, given my poor understanding of the ocaml/c interface.

Best regards,

Daniel

@vicuna
Copy link
Author

vicuna commented Jul 8, 2004

Comment author: administrator

Fixed as suggested 2004-07-08 XL

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