Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001517OCamlCamlIDLpublic2003-01-12 23:222004-07-08 11:55
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001517: camlidl : conversion to ocaml of C structs with floats fields only
DescriptionFull_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

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000089)
administrator (administrator)
2004-07-08 11:55

Fixed as suggested 2004-07-08 XL

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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker