[Pkg-libvirt-commits] [libguestfs] 63/156: generator: Sort the structs.

Hilko Bengen bengen at moszumanska.debian.org
Sat Aug 30 08:25:52 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch master
in repository libguestfs.

commit 45ca799df71b8fb5aec8e59fc42b4400cbfa2b51
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Jul 1 16:12:32 2014 +0100

    generator: Sort the structs.
    
    Sort the structs when generating code.  Since the structs are
    logically indepedent of each other, this should have no effect except
    to make generated files list the structs in a different order.
    
    However this also fixes the following build problem:
    
      File "convert_linux.ml", line 322, characters 43-50:
      Error: This expression has type G.stat = Guestfs.stat
        but an expression was expected of type G.dirent = Guestfs.dirent
    
    It turns out the OCaml bindings don't like the fact that we have
    two structs with a common field name (dirent.ino and stat.ino).
    
    In OCaml < 4.01, this means that any attempt to reference stat.ino
    would fail because dirent.ino appears second in the file, overriding
    stat.ino.
    
    Sorting the structs has the side effect of making stat.ino appear
    second, thus resolving the build failure above.
    
    In OCaml >= 4.01 the compiler now uses some disambiguation rules based
    on the known types to resolve this problem, so accessing either field
    would work no matter what order they are listed in.
    
    See:
    
    http://ocaml.org/releases/4.01.0.html
    http://www.lexifi.com/blog/type-based-selection-label-and-constructors
    http://www.lexifi.com/blog/ocaml-extensions-lexifi-overidding-record-labels-and-constructors
    (cherry picked from commit 544b087d4b4ee92239d26211effe192da4f71d38)
---
 generator/structs.ml |  8 ++++++--
 gobject/Makefile.inc | 48 ++++++++++++++++++++++++------------------------
 2 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/generator/structs.ml b/generator/structs.ml
index 1bc6e08..65c78b2 100644
--- a/generator/structs.ml
+++ b/generator/structs.ml
@@ -382,6 +382,10 @@ let camel_name_of_struct name = (lookup_struct name).s_camel_name
 
 let cols_of_struct name = (lookup_struct name).s_cols
 
-let external_structs = List.filter (fun x -> not x.s_internal) structs
+let compare_structs { s_name = n1 } { s_name = n2 } = compare n1 n2
 
-let internal_structs = List.filter (fun x -> x.s_internal) structs
+let external_structs =
+  List.sort compare_structs (List.filter (fun x -> not x.s_internal) structs)
+
+let internal_structs =
+  List.sort compare_structs (List.filter (fun x -> x.s_internal) structs)
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index cfb6ed3..1941498 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -23,26 +23,26 @@ guestfs_gobject_headers= \
   include/guestfs-gobject.h \
   include/guestfs-gobject/session.h \
   include/guestfs-gobject/tristate.h \
+  include/guestfs-gobject/struct-application.h \
+  include/guestfs-gobject/struct-application2.h \
+  include/guestfs-gobject/struct-btrfssubvolume.h \
+  include/guestfs-gobject/struct-dirent.h \
+  include/guestfs-gobject/struct-hivex_node.h \
+  include/guestfs-gobject/struct-hivex_value.h \
+  include/guestfs-gobject/struct-inotify_event.h \
   include/guestfs-gobject/struct-int_bool.h \
+  include/guestfs-gobject/struct-isoinfo.h \
+  include/guestfs-gobject/struct-lvm_lv.h \
   include/guestfs-gobject/struct-lvm_pv.h \
   include/guestfs-gobject/struct-lvm_vg.h \
-  include/guestfs-gobject/struct-lvm_lv.h \
+  include/guestfs-gobject/struct-mdstat.h \
+  include/guestfs-gobject/struct-partition.h \
   include/guestfs-gobject/struct-stat.h \
   include/guestfs-gobject/struct-statvfs.h \
-  include/guestfs-gobject/struct-dirent.h \
+  include/guestfs-gobject/struct-utsname.h \
   include/guestfs-gobject/struct-version.h \
   include/guestfs-gobject/struct-xattr.h \
-  include/guestfs-gobject/struct-inotify_event.h \
-  include/guestfs-gobject/struct-partition.h \
-  include/guestfs-gobject/struct-application.h \
-  include/guestfs-gobject/struct-application2.h \
-  include/guestfs-gobject/struct-isoinfo.h \
-  include/guestfs-gobject/struct-mdstat.h \
-  include/guestfs-gobject/struct-btrfssubvolume.h \
   include/guestfs-gobject/struct-xfsinfo.h \
-  include/guestfs-gobject/struct-utsname.h \
-  include/guestfs-gobject/struct-hivex_node.h \
-  include/guestfs-gobject/struct-hivex_value.h \
   include/guestfs-gobject/optargs-add_domain.h \
   include/guestfs-gobject/optargs-add_drive.h \
   include/guestfs-gobject/optargs-add_drive_scratch.h \
@@ -99,26 +99,26 @@ guestfs_gobject_headers= \
 guestfs_gobject_sources= \
   src/session.c \
   src/tristate.c \
+  src/struct-application.c \
+  src/struct-application2.c \
+  src/struct-btrfssubvolume.c \
+  src/struct-dirent.c \
+  src/struct-hivex_node.c \
+  src/struct-hivex_value.c \
+  src/struct-inotify_event.c \
   src/struct-int_bool.c \
+  src/struct-isoinfo.c \
+  src/struct-lvm_lv.c \
   src/struct-lvm_pv.c \
   src/struct-lvm_vg.c \
-  src/struct-lvm_lv.c \
+  src/struct-mdstat.c \
+  src/struct-partition.c \
   src/struct-stat.c \
   src/struct-statvfs.c \
-  src/struct-dirent.c \
+  src/struct-utsname.c \
   src/struct-version.c \
   src/struct-xattr.c \
-  src/struct-inotify_event.c \
-  src/struct-partition.c \
-  src/struct-application.c \
-  src/struct-application2.c \
-  src/struct-isoinfo.c \
-  src/struct-mdstat.c \
-  src/struct-btrfssubvolume.c \
   src/struct-xfsinfo.c \
-  src/struct-utsname.c \
-  src/struct-hivex_node.c \
-  src/struct-hivex_value.c \
   src/optargs-add_domain.c \
   src/optargs-add_drive.c \
   src/optargs-add_drive_scratch.c \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list