summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-10-03 21:18:25 +0100
committerRichard W.M. Jones <rjones@redhat.com>2010-10-03 21:18:25 +0100
commit67636f721056d2f2250b0ff8acd981a0294536a9 (patch)
tree6282c9c86f8af6823a22e436b2a95751f36b3b22 /ocaml
parent1a3324ea2b0f4a4e04f99c4efb5af1d4cc256731 (diff)
downloadlibguestfs-67636f721056d2f2250b0ff8acd981a0294536a9.tar.gz
libguestfs-67636f721056d2f2250b0ff8acd981a0294536a9.tar.xz
libguestfs-67636f721056d2f2250b0ff8acd981a0294536a9.zip
ocaml: Add alternate object-oriented programming style.
In original style: let () = let filename = Sys.argv.(1) in let g = Guestfs.create () in Guestfs.add_drive_ro g filename; Guestfs.launch g; let roots = Guestfs.inspect_os g in print_endline (Guestfs.inspect_get_product_name g roots.(0)) The same code in the new OO style: let () = let filename = Sys.argv.(1) in let g = new Guestfs.guestfs in g#add_drive_ro filename; g#launch (); let roots = g#inspect_os () in print_endline (g#inspect_get_product_name roots.(0))
Diffstat (limited to 'ocaml')
-rw-r--r--ocaml/t/guestfs_005_load.ml7
1 files changed, 6 insertions, 1 deletions
diff --git a/ocaml/t/guestfs_005_load.ml b/ocaml/t/guestfs_005_load.ml
index 779e1c0f..523f764c 100644
--- a/ocaml/t/guestfs_005_load.ml
+++ b/ocaml/t/guestfs_005_load.ml
@@ -1,5 +1,5 @@
(* libguestfs OCaml bindings
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2010 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,3 +17,8 @@
*)
let _ = Guestfs.create
+
+(* Also try the OO style. *)
+let _ =
+ let g = new Guestfs.guestfs in
+ g#get_verbose ()