X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=generator%2Fgenerator_ocaml.ml;h=6cb843aae4c970a6ef9abd79891476d0716a3db7;hp=e5dfc686a9503f2e02d83a84d985bc2de096ea7d;hb=c50eb8f1cc33009f1ed29a002066e026fe2923f4;hpb=67636f721056d2f2250b0ff8acd981a0294536a9 diff --git a/generator/generator_ocaml.ml b/generator/generator_ocaml.ml index e5dfc68..6cb843a 100644 --- a/generator/generator_ocaml.ml +++ b/generator/generator_ocaml.ml @@ -101,15 +101,23 @@ val clear_progress_callback : t -> unit [Guestfs.add_drive g filename]. Apart from the different style, it offers exactly the same functionality. + Calling [new guestfs ()] creates both the object and the handle. + The object and handle are closed either implicitly when the + object is garbage collected, or explicitly by calling the [g#close ()] + method. + + You can get the {!Guestfs.t} handle by calling [g#ocaml_handle]. + Note that methods that take no parameters (except the implicit handle) get an extra unit [()] parameter. This is so you can create a closure from the method easily. For example [g#get_verbose ()] calls the method, whereas [g#get_verbose] is a function. *) -class guestfs : object +class guestfs : unit -> object method close : unit -> unit method set_progress_callback : progress_cb -> unit method clear_progress_callback : unit -> unit + method ocaml_handle : t "; List.iter ( @@ -124,7 +132,7 @@ class guestfs : object pr "\n" ) all_functions_sorted; - pr " end\n" + pr "end\n" (* Generate the OCaml bindings implementation. *) and generate_ocaml_ml () = @@ -163,12 +171,13 @@ let () = (* OO API. *) pr " -class guestfs = +class guestfs () = let g = create () in object method close () = close g method set_progress_callback = set_progress_callback g method clear_progress_callback () = clear_progress_callback g + method ocaml_handle = g "; List.iter (