This mostly mechanical change moves all of the libguestfs API
lists of functions into a struct in the Actions module.
It also adds filter functions to be used elsewhere to get
subsets of these functions.
Original code Replacement
all_functions actions
daemon_functions actions |> daemon_functions
non_daemon_functions actions |> non_daemon_functions
external_functions actions |> external_functions
internal_functions actions |> internal_functions
documented_functions actions |> documented_functions
fish_functions actions |> fish_functions
*_functions_sorted ... replacement as above ... |> sort
---
generator/actions.ml | 83 +++++++++++++++++++++++++++---------------------
generator/actions.mli | 66 ++++++++++++++------------------------
generator/c.ml | 16 +++++-----
generator/checks.ml | 52 +++++++++++-------------------
generator/csharp.ml | 2 +-
generator/daemon.ml | 10 +++---
generator/erlang.ml | 10 +++---
generator/fish.ml | 20 +++++-------
generator/gobject.ml | 6 ++--
generator/golang.ml | 2 +-
generator/haskell.ml | 4 +--
generator/java.ml | 4 +--
generator/lua.ml | 8 ++---
generator/main.ml | 2 +-
generator/ocaml.ml | 12 +++----
generator/optgroups.ml | 2 +-
generator/perl.ml | 8 ++---
generator/php.ml | 6 ++--
generator/python.ml | 8 ++---
generator/ruby.ml | 4 +--
generator/tests_c_api.ml | 8 ++---
generator/xdr.ml | 4 +--
22 files changed, 155 insertions(+), 182 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index aa26649..179902e 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -13572,18 +13572,62 @@ let non_daemon_functions, daemon_functions =
List.map make_camel_case_if_not_set daemon_functions in
non_daemon_functions, daemon_functions
+(* Before we add the non_daemon_functions and daemon_functions to
+ * a single list, verify the proc_nr field which should be the only
+ * difference between them. (Note more detailed checking is done
+ * in checks.ml).
+ *)
+let () =
+ List.iter (
+ function
+ | { name = name; proc_nr = None } ->
+ failwithf "daemon function %s should have proc_nr = Some n > 0" name
+ | { name = name; proc_nr = Some n } when n <= 0 ->
+ failwithf "daemon function %s should have proc_nr = Some n > 0" name
+ | { proc_nr = Some _ } -> ()
+ ) daemon_functions;
+
+ List.iter (
+ function
+ | { name = name; proc_nr = Some _ } ->
+ failwithf "non-daemon function %s should have proc_nr = None" name
+ | { proc_nr = None } -> ()
+ ) non_daemon_functions
+
+(* This is used to generate the src/MAX_PROC_NR file which
+ * contains the maximum procedure number, a surrogate for the
+ * ABI version number. See src/Makefile.am for the details.
+ *)
+let max_proc_nr =
+ let proc_nrs = List.map (
+ function { proc_nr = Some n } -> n | { proc_nr = None } -> assert false
+ ) daemon_functions in
+ List.fold_left max 0 proc_nrs
+
(* All functions. *)
-let all_functions = non_daemon_functions @ daemon_functions
+let actions = non_daemon_functions @ daemon_functions
+
+(* Filters which can be applied. *)
+let is_non_daemon_function = function
+ | { proc_nr = None } -> true
+ | { proc_nr = Some _ } -> false
+let non_daemon_functions = List.filter is_non_daemon_function
+
+let is_daemon_function f = not (is_non_daemon_function f)
+let daemon_functions = List.filter is_daemon_function
let is_external { visibility = v } = match v with
| VPublic | VPublicNoFish | VStateTest | VBindTest | VDebug -> true
| VInternal -> false
+let external_functions = List.filter is_external
let is_internal f = not (is_external f)
+let internal_functions = List.filter is_internal
let is_documented { visibility = v } = match v with
| VPublic | VPublicNoFish | VStateTest -> true
| VBindTest | VDebug | VInternal -> false
+let documented_functions = List.filter is_documented
let is_fish { visibility = v; style = (_, args, _) } =
(* Internal functions are not exported to guestfish. *)
@@ -13595,42 +13639,9 @@ let is_fish { visibility = v; style = (_, args, _) } =
* generate a pointer.
*)
not (List.exists (function Pointer _ -> true | _ -> false) args)
-
-let external_functions =
- List.filter is_external all_functions
-
-let internal_functions =
- List.filter is_internal all_functions
-
-let documented_functions =
- List.filter is_documented all_functions
-
-let fish_functions =
- List.filter is_fish all_functions
+let fish_functions = List.filter is_fish
(* In some places we want the functions to be displayed sorted
* alphabetically, so this is useful:
*)
-let all_functions_sorted = List.sort action_compare all_functions
-
-let external_functions_sorted =
- List.sort action_compare external_functions
-
-let internal_functions_sorted =
- List.sort action_compare internal_functions
-
-let documented_functions_sorted =
- List.sort action_compare documented_functions
-
-let fish_functions_sorted =
- List.sort action_compare fish_functions
-
-(* This is used to generate the src/MAX_PROC_NR file which
- * contains the maximum procedure number, a surrogate for the
- * ABI version number. See src/Makefile.am for the details.
- *)
-let max_proc_nr =
- let proc_nrs = List.map (
- function { proc_nr = Some n } -> n | { proc_nr = None } -> 0
- ) daemon_functions in
- List.fold_left max 0 proc_nrs
+let sort = List.sort action_compare
diff --git a/generator/actions.mli b/generator/actions.mli
index 8020aaa..55bc36e 100644
--- a/generator/actions.mli
+++ b/generator/actions.mli
@@ -20,60 +20,42 @@
(** The libguestfs API. *)
-val non_daemon_functions : Types.action list
-(** API actions which are implemented within the library itself. *)
+val actions : Types.action list
+(** The list of functions in the libguestfs API. *)
-val daemon_functions : Types.action list
-(** API actions which are implemented by the daemon. *)
+val daemon_functions : Types.action list -> Types.action list
+val non_daemon_functions : Types.action list -> Types.action list
+(** Filter {!actions}, returning only daemon function /
+ non-daemon function respectively.
-val all_functions : Types.action list
-(** Concatenation of [non_daemon_functions] and [daemon_functions] lists. *)
+ The difference is that a daemon function is handled directly by
+ the daemon. A non-daemon function is implemented in the library side. *)
-val is_external : Types.action -> bool
-(** Returns true if function is external, false otherwise *)
+val external_functions : Types.action list -> Types.action list
+(** Filter {!actions}, returning only external functions. *)
-val is_internal : Types.action -> bool
-(** Returns true if function is internal, false otherwise *)
+val internal_functions : Types.action list -> Types.action list
+(** Filter {!actions}, returning only internal functions. *)
-val is_documented : Types.action -> bool
-(** Returns true if function should be documented, false otherwise *)
-
-val is_fish : Types.action -> bool
-(** Returns true if function should be in guestfish, false otherwise *)
-
-val external_functions : Types.action list
-(** [all_functions] filtered for external functions **)
-
-val internal_functions : Types.action list
-(** [all_functions] filtered for internal functions **)
-
-val documented_functions : Types.action list
-(** [all_functions] filtered for functions requiring documentation **)
-
-val fish_functions : Types.action list
-(** [all_functions] filtered for functions in guestfish **)
-
-val all_functions_sorted : Types.action list
-(** [all_functions] but sorted by name. *)
-
-val external_functions_sorted : Types.action list
-(** [external_functions] but sorted by name. *)
+val fish_functions : Types.action list -> Types.action list
+(** Filter {!actions}, returning only functions in guestfish. *)
-val internal_functions_sorted : Types.action list
-(** [internal_functions] but sorted by name. *)
+val documented_functions : Types.action list -> Types.action list
+(** Filter {!actions}, returning only functions requiring documentation. *)
-val documented_functions_sorted : Types.action list
-(** [documented_functions] but sorted by name. *)
+val sort : Types.action list -> Types.action list
+(** Sort the functions alphabetically by name
+ (see also {!Utils.action_compare}). *)
-val fish_functions_sorted : Types.action list
-(** [fish_functions] but sorted by name. *)
+val is_documented : Types.action -> bool
+(** Returns true if function should be documented, false otherwise. *)
val test_functions : Types.action list
(** Internal test functions used to test the language bindings. *)
+val fish_commands : Types.action list
+(** Non-API meta-commands available only in guestfish. *)
+
val max_proc_nr : int
(** The largest procedure number used (also saved in [src/MAX_PROC_NR] and
used as the minor version number of the shared library). *)
-
-val fish_commands : Types.action list
-(** Non-API meta-commands available only in guestfish. *)
diff --git a/generator/c.ml b/generator/c.ml
index 9643a96..35e08e3 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -52,10 +52,10 @@ let is_public { visibility = v } = match v with
let is_private f = not (is_public f)
let public_functions_sorted =
- List.filter is_public all_functions_sorted
+ List.filter is_public (actions |> sort)
let private_functions_sorted =
- List.filter is_private all_functions_sorted
+ List.filter is_private (actions |> sort)
(* Generate a C function prototype. *)
let rec generate_prototype ?(extern = true) ?(static = false)
@@ -218,7 +218,7 @@ and generate_actions_pod () =
| ({ once_had_no_optargs = true } as f) ->
generate_actions_pod_back_compat_entry f;
generate_actions_pod_entry f
- ) documented_functions_sorted
+ ) (actions |> documented_functions |> sort)
and generate_actions_pod_entry ({ c_name = c_name;
style = ret, args, optargs as style } as f) =
@@ -795,7 +795,7 @@ and generate_internal_actions_h () =
generate_prototype ~single_line:true ~newline:true ~handle:"g"
~prefix:"guestfs_impl_" ~optarg_proto:Argv
c_name style
- ) non_daemon_functions;
+ ) (actions |> non_daemon_functions);
pr "\n";
pr "#endif /* GUESTFS_INTERNAL_ACTIONS_H_ */\n"
@@ -1785,7 +1785,7 @@ and generate_client_actions hash () =
if hash_matches hash f then generate_non_daemon_wrapper f
| { wrapper = false } ->
() (* no wrapper *)
- ) non_daemon_functions;
+ ) (actions |> non_daemon_functions);
(* Client-side stubs for each function. *)
let generate_daemon_stub { name = name; c_name = c_name;
@@ -2083,7 +2083,7 @@ and generate_client_actions hash () =
List.iter (
fun f ->
if hash_matches hash f then generate_daemon_stub f
- ) daemon_functions
+ ) (actions |> daemon_functions)
(* Functions which have optional arguments have two or three
* generated variants.
@@ -2231,7 +2231,7 @@ and generate_client_actions_variants () =
| ({ style = _, _, (_::_); once_had_no_optargs = true } as f) ->
generate_va_variants f;
generate_back_compat_wrapper f
- ) all_functions_sorted
+ ) (actions |> sort)
(* Code for turning events and event bitmasks into printable strings. *)
and generate_event_string_c () =
@@ -2347,7 +2347,7 @@ and generate_linker_script () =
"guestfs_" ^ c_name;
"guestfs_" ^ c_name ^ "_va";
"guestfs_" ^ c_name ^ "_argv"]
- ) all_functions
+ ) actions
) in
let struct_frees =
List.concat (
diff --git a/generator/checks.ml b/generator/checks.ml
index 9966280..6c65a99 100644
--- a/generator/checks.ml
+++ b/generator/checks.ml
@@ -58,7 +58,7 @@ let () =
if len >= 5 && String.sub name (len-5) 5 = "_opts" then
failwithf "function name %s cannot end with _opts" name
*)
- ) (all_functions @ fish_commands);
+ ) (actions @ fish_commands);
(* Check added field was set to something. *)
List.iter (
@@ -67,7 +67,7 @@ let () =
added = (-1, _, _) } ->
failwithf "function %s has no 'added' (version when added)
field" name
| _ -> ()
- ) all_functions;
+ ) actions;
(* Check function parameter/return names. *)
List.iter (
@@ -131,14 +131,14 @@ let () =
);
List.iter (fun arg -> check_arg_ret_name (name_of_argt arg)) args;
List.iter (fun arg -> check_arg_ret_name (name_of_optargt arg)) optargs;
- ) all_functions;
+ ) actions;
(* Maximum of 63 optargs permitted. *)
List.iter (
fun { name = name; style = _, _, optargs } ->
if List.length optargs > 63 then
failwithf "maximum of 63 optional args allowed for %s" name;
- ) all_functions;
+ ) actions;
(* Some parameter types not supported for daemon functions. *)
List.iter (
@@ -150,7 +150,7 @@ let () =
| _ -> ()
in
List.iter check_arg_type args;
- ) daemon_functions;
+ ) (actions |> daemon_functions);
(* Check short descriptions. *)
List.iter (
@@ -160,7 +160,7 @@ let () =
let c = shortdesc.[String.length shortdesc-1] in
if c = '\n' || c = '.' then
failwithf "short description of %s should not end with . or \\n." name
- ) (all_functions @ fish_commands);
+ ) (actions @ fish_commands);
(* Check long descriptions. *)
List.iter (
@@ -169,31 +169,15 @@ let () =
failwithf "long description of %s should not end with \\n." name;
if longdesc.[0] <> Char.uppercase longdesc.[0] then
failwithf "long description of %s should begin with uppercase." name
- ) (all_functions @ fish_commands);
-
- (* Check proc_nrs. *)
- List.iter (
- function
- | { name = name; proc_nr = None } ->
- failwithf "daemon function %s should have proc_nr = Some n > 0" name
- | { name = name; proc_nr = Some n } when n <= 0 ->
- failwithf "daemon function %s should have proc_nr = Some n > 0" name
- | { proc_nr = Some _ } -> ()
- ) daemon_functions;
-
- List.iter (
- function
- | { name = name; proc_nr = Some _ } ->
- failwithf "non-daemon function %s should have proc_nr = None" name
- | { proc_nr = None } -> ()
- ) non_daemon_functions;
+ ) (actions @ fish_commands);
+ (* Check proc_nrs don't overlap. *)
let proc_nrs =
List.map (
function
| { name = name; proc_nr = Some proc_nr } -> (name, proc_nr)
| _ -> assert false
- ) daemon_functions in
+ ) (actions |> daemon_functions) in
let proc_nrs =
List.sort (fun (_,nr1) (_,nr2) -> compare nr1 nr2) proc_nrs in
let rec loop = function
@@ -224,7 +208,7 @@ let () =
function
| { name = n' } when n = n' -> true
| _ -> false
- ) all_functions) then
+ ) actions) then
failwithf "%s: deprecated_by flag must be cross-reference to another
action" name
| None -> ()
);
@@ -243,7 +227,7 @@ let () =
name
| _ -> ()
)
- ) (all_functions @ fish_commands);
+ ) (actions @ fish_commands);
(* Check blocking flag is set on all daemon functions. *)
List.iter (
@@ -252,7 +236,7 @@ let () =
failwithf "%s: blocking flag should be 'true' on this daemon
function"
name
| { blocking = true } -> ()
- ) daemon_functions;
+ ) (actions |> daemon_functions);
(* Check wrapper flag is set on all daemon functions. *)
List.iter (
@@ -261,7 +245,7 @@ let () =
failwithf "%s: wrapper flag should be 'true' on this daemon
function"
name
| { wrapper = true } -> ()
- ) daemon_functions;
+ ) (actions |> daemon_functions);
(* Non-fish functions must have correct camel_name. *)
List.iter (
@@ -271,7 +255,7 @@ let () =
name;
if String.contains camel_name '_' then
failwithf "%s: camel case name must not contain '_'" name;
- ) all_functions;
+ ) actions;
(* ConfigOnly should only be specified on non_daemon_functions. *)
List.iter (
@@ -279,7 +263,7 @@ let () =
| { name = name; config_only = true } ->
failwithf "%s cannot have ConfigOnly flag" name
| { config_only = false } -> ()
- ) (daemon_functions @ fish_commands);
+ ) ((actions |> daemon_functions) @ fish_commands);
(* once_had_no_optargs can only apply if the function now has optargs. *)
List.iter (
@@ -287,7 +271,7 @@ let () =
| { name = name; once_had_no_optargs = true; style = _, _, [] } ->
failwithf "%s cannot have once_had_no_optargs flag and no optargs" name
| { once_had_no_optargs = false } | { style = _, _, (_::_) } -> ()
- ) all_functions;
+ ) actions;
(* Check tests. *)
List.iter (
@@ -311,7 +295,7 @@ let () =
if not tested then
failwithf "function %s has tests but does not test itself" name
- ) all_functions;
+ ) actions;
List.iter (
function
@@ -324,4 +308,4 @@ let () =
failwithf "%s test is marked 'IfAvailable %S', but since this
function is in the %S optgroup, this is unnecessary; use 'Always' instead"
name o optgroup
| _ -> ()
) tests
- ) all_functions
+ ) actions
diff --git a/generator/csharp.ml b/generator/csharp.ml
index 0255e92..9dcdc77 100644
--- a/generator/csharp.ml
+++ b/generator/csharp.ml
@@ -290,7 +290,7 @@ namespace Guestfs
pr "\n";
List.iter generate_alias non_c_aliases
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr " }
}
diff --git a/generator/daemon.ml b/generator/daemon.ml
index 1d79126..e24ae15 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -55,7 +55,7 @@ let generate_daemon_actions_h () =
pr "#define GUESTFS_%s_%s_BITMASK (UINT64_C(1)<<%d)\n"
uc_shortname uc_n i
) optargs
- ) daemon_functions;
+ ) (actions |> daemon_functions);
List.iter (
fun { name = name; style = ret, args, optargs } ->
@@ -67,7 +67,7 @@ let generate_daemon_actions_h () =
generate_prototype
~single_line:true ~newline:true ~in_daemon:true ~prefix:"do_"
name style;
- ) daemon_functions;
+ ) (actions |> daemon_functions);
pr "\n";
pr "#endif /* GUESTFSD_ACTIONS_H */\n"
@@ -508,7 +508,7 @@ cleanup_free_mountable (mountable_t *mountable)
pr "done_no_free:\n";
pr " return;\n";
pr "}\n\n";
- ) daemon_functions;
+ ) (actions |> daemon_functions);
(* Dispatch function. *)
pr "void dispatch_incoming_message (XDR *xdr_in)\n";
@@ -520,7 +520,7 @@ cleanup_free_mountable (mountable_t *mountable)
pr " case GUESTFS_PROC_%s:\n" (String.uppercase name);
pr " %s_stub (xdr_in);\n" name;
pr " break;\n"
- ) daemon_functions;
+ ) (actions |> daemon_functions);
pr " default:\n";
pr " reply_with_error (\"dispatch_incoming_message: unknown procedure
number %%d, set LIBGUESTFS_PATH to point to the matching libguestfs appliance
directory\", proc_nr);\n";
@@ -712,7 +712,7 @@ and generate_daemon_names () =
| { name = name; proc_nr = Some proc_nr } ->
pr " [%d] = \"%s\",\n" proc_nr name
| { proc_nr = None } -> assert false
- ) daemon_functions;
+ ) (actions |> daemon_functions);
pr "};\n";
(* Generate the optional groups for the daemon to implement
diff --git a/generator/erlang.ml b/generator/erlang.ml
index a2facec..9bf0c59 100644
--- a/generator/erlang.ml
+++ b/generator/erlang.ml
@@ -52,7 +52,7 @@ let rec generate_erlang_erl () =
in
export name;
List.iter export aliases
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "\n";
@@ -180,7 +180,7 @@ loop(Port) ->
) aliases;
pr "\n"
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
and generate_erlang_c () =
generate_header CStyle GPLv2plus;
@@ -286,7 +286,7 @@ extern int64_t get_int64 (ETERM *term);
(* generate the function for typ *)
emit_copy_list_function typ
| typ, _ -> () (* empty *)
- ) (rstructs_used_by external_functions);
+ ) (rstructs_used_by (actions |> external_functions));
(* The wrapper functions. *)
List.iter (
@@ -459,7 +459,7 @@ extern int64_t get_int64 (ETERM *term);
pr "}\n";
pr "\n";
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "\
@@ -478,7 +478,7 @@ dispatch (ETERM *message)
pr "if (atom_equals (fun, \"%s\"))\n" name;
pr " return run_%s (message);\n" name;
pr " else ";
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "return unknown_function (fun);
}
diff --git a/generator/fish.ml b/generator/fish.ml
index cc869d3..2acd484 100644
--- a/generator/fish.ml
+++ b/generator/fish.ml
@@ -42,7 +42,7 @@ type func =
let func_compare (n1, _) (n2, _) = compare n1 n2
let fish_functions_and_commands_sorted =
- List.sort action_compare (fish_functions_sorted @ fish_commands)
+ List.sort action_compare ((actions |> fish_functions |> sort) @ fish_commands)
let doc_opttype_of = function
| OBool n -> "true|false"
@@ -68,7 +68,7 @@ let all_functions_commands_and_aliases_sorted =
let aliases = List.map (fun x -> x, Alias name) aliases in
let foo = (name, Function shortdesc) :: aliases in
foo @ acc
- ) (fish_functions_sorted @ fish_commands) [] in
+ ) ((actions |> fish_functions |> sort) @ fish_commands) [] in
List.sort func_compare all
let c_quoted_indented ~indent str =
@@ -118,7 +118,7 @@ let generate_fish_cmds () =
fun { name = name } ->
pr "static int run_%s (const char *cmd, size_t argc, char *argv[]);\n"
name
- ) fish_functions_sorted;
+ ) (actions |> fish_functions |> sort);
pr "\n";
@@ -210,7 +210,7 @@ Guestfish will prompt for these separately."
pr " .run = run_%s\n" name;
pr "};\n";
pr "\n";
- ) fish_functions_sorted;
+ ) (actions |> fish_functions |> sort);
(* list_commands function, which implements guestfish -h *)
pr "void\n";
@@ -276,7 +276,7 @@ Guestfish will prompt for these separately."
(* generate the function for typ *)
emit_print_list_function typ
| typ, _ -> () (* empty *)
- ) (rstructs_used_by fish_functions);
+ ) (rstructs_used_by (actions |> fish_functions));
(* Emit a print_TYPE function definition only if that function is used. *)
List.iter (
@@ -290,7 +290,7 @@ Guestfish will prompt for these separately."
pr "}\n";
pr "\n";
| typ, _ -> () (* empty *)
- ) (rstructs_used_by fish_functions);
+ ) (rstructs_used_by (actions |> fish_functions));
(* run_<action> actions *)
List.iter (
@@ -643,7 +643,7 @@ Guestfish will prompt for these separately."
pr " return ret;\n";
pr "}\n";
pr "\n"
- ) fish_functions_sorted;
+ ) (actions |> fish_functions |> sort);
(* run_action function *)
pr "int\n";
@@ -838,10 +838,6 @@ do_completion (const char *text, int start, int end)
and generate_fish_actions_pod () =
generate_header PODStyle GPLv2plus;
- let fishdoc_functions_sorted =
- List.filter is_documented fish_functions_sorted
- in
-
let rex = Str.regexp "C<guestfs_\\([^>]+\\)>" in
List.iter (
@@ -913,7 +909,7 @@ Guestfish will prompt for these separately.\n\n";
pr "This command depends on the feature C<%s>. See also
L</feature-available>.\n\n" opt
);
- ) fishdoc_functions_sorted
+ ) (actions |> fish_functions |> documented_functions |> sort)
(* Generate documentation for guestfish-only commands. *)
and generate_fish_commands_pod () =
diff --git a/generator/gobject.ml b/generator/gobject.ml
index b89463e..7ee73a6 100644
--- a/generator/gobject.ml
+++ b/generator/gobject.ml
@@ -119,7 +119,7 @@ let filenames =
function
| { style = _, _, (_::_) } -> true
| { style = _, _, [] } -> false
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
)
let header_start filename =
@@ -709,7 +709,7 @@ gboolean guestfs_session_close (GuestfsSession *session, GError
**err);
fun ({ name = name; style = style } as f) ->
generate_gobject_proto name style f;
pr ";\n";
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
header_end filename
@@ -1315,4 +1315,4 @@ guestfs_session_close (GuestfsSession *session, GError **err)
);
pr "}\n";
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
diff --git a/generator/golang.ml b/generator/golang.ml
index 1cb97fc..3140dbb 100644
--- a/generator/golang.ml
+++ b/generator/golang.ml
@@ -522,4 +522,4 @@ func return_hashtable (argv **C.char) map[string]string {
pr " return C.GoBytes (unsafe.Pointer (r), C.int (size)), nil\n"
);
pr "}\n";
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
diff --git a/generator/haskell.ml b/generator/haskell.ml
index 66c921e..c04f0c2 100644
--- a/generator/haskell.ml
+++ b/generator/haskell.ml
@@ -62,7 +62,7 @@ module Guestfs (
List.iter (
fun { name = name; style = style } ->
if can_generate style then pr ",\n %s" name
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "
) where
@@ -211,7 +211,7 @@ assocListOfHashtable (a:b:rest) = (a,b) : assocListOfHashtable rest
);
pr "\n";
)
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
and generate_haskell_prototype ~handle ?(hs = false) (ret, args, optargs) =
pr "%s -> " handle;
diff --git a/generator/java.ml b/generator/java.ml
index aa7ed04..044866e 100644
--- a/generator/java.ml
+++ b/generator/java.ml
@@ -433,7 +433,7 @@ public class GuestFS {
generate_java_prototype ~privat:true ~native:true f.name f.style;
pr "\n";
pr "\n";
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "}\n"
@@ -1197,7 +1197,7 @@ get_all_event_callbacks (JNIEnv *env, guestfs_h *g, size_t
*len_rtn)
pr "}\n";
pr "\n"
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
and generate_java_struct_return typ jtyp cols =
pr " cl = (*env)->FindClass (env,
\"com/redhat/et/libguestfs/%s\");\n" jtyp;
diff --git a/generator/lua.ml b/generator/lua.ml
index 89a8afd..d3b0b27 100644
--- a/generator/lua.ml
+++ b/generator/lua.ml
@@ -116,7 +116,7 @@ static void push_event (lua_State *L, uint64_t event);
| typ, (RStructListOnly | RStructAndList) ->
pr "static void push_%s (lua_State *L, struct guestfs_%s *v);\n" typ
typ;
pr "static void push_%s_list (lua_State *L, struct guestfs_%s_list
*v);\n" typ typ
- ) (rstructs_used_by external_functions);
+ ) (rstructs_used_by (actions |> external_functions));
pr "\
@@ -627,7 +627,7 @@ guestfs_int_lua_delete_event_callback (lua_State *L)
pr " return 1;\n";
pr "}\n";
pr "\n"
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "\
static struct userdata *
@@ -863,7 +863,7 @@ push_event (lua_State *L, uint64_t event)
| typ, (RStructListOnly | RStructAndList) ->
generate_push_struct typ;
generate_push_struct_list typ
- ) (rstructs_used_by external_functions);
+ ) (rstructs_used_by (actions |> external_functions));
pr "\
/* Metamethods.
@@ -890,7 +890,7 @@ static luaL_Reg methods[] = {
List.iter (
fun { name = name } -> pr " { \"%s\", guestfs_int_lua_%s
},\n" name name
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "\
diff --git a/generator/main.ml b/generator/main.ml
index 87616a8..69c625b 100644
--- a/generator/main.ml
+++ b/generator/main.ml
@@ -200,7 +200,7 @@ Run it from the top source directory using the command
output_to filename
(generate_gobject_optargs_source short name optargs f)
| { style = _, _, [] } -> ()
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
delete_except_generated "gobject/include/guestfs-gobject/optargs-*.h";
delete_except_generated "gobject/src/optargs-*.c";
diff --git a/generator/ocaml.ml b/generator/ocaml.ml
index ef04540..f76a3ab 100644
--- a/generator/ocaml.ml
+++ b/generator/ocaml.ml
@@ -222,7 +222,7 @@ end
) non_c_aliases;
pr "\n";
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "\
(** {2 Object-oriented API}
@@ -288,7 +288,7 @@ class guestfs : ?environment:bool -> ?close_on_exit:bool -> unit
-> object
pr "\n"
)
) non_c_aliases
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "end\n"
@@ -364,7 +364,7 @@ let () =
fun { name = name; style = style; non_c_aliases = non_c_aliases } ->
generate_ocaml_prototype ~is_external:true name style;
List.iter (fun alias -> pr "let %s = %s\n" alias name) non_c_aliases
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
(* OO API. *)
pr "
@@ -392,7 +392,7 @@ class guestfs ?environment ?close_on_exit () =
);
List.iter
(fun alias -> pr " method %s = self#%s\n" alias name)
non_c_aliases
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr " end\n"
@@ -528,7 +528,7 @@ copy_table (char * const * argv)
(* generate the function for typ *)
emit_ocaml_copy_list_function typ
| typ, _ -> () (* empty *)
- ) (rstructs_used_by external_functions);
+ ) (rstructs_used_by (actions |> external_functions));
(* The wrappers. *)
List.iter (
@@ -779,7 +779,7 @@ copy_table (char * const * argv)
pr "}\n";
pr "\n"
)
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
(* Generate the OCaml bindings C errnos. *)
and generate_ocaml_c_errnos () =
diff --git a/generator/optgroups.ml b/generator/optgroups.ml
index 0a7c1f3..a484ae7 100644
--- a/generator/optgroups.ml
+++ b/generator/optgroups.ml
@@ -40,7 +40,7 @@ let optgroups =
let fns = try Hashtbl.find h group with Not_found -> [] in
Hashtbl.replace h group (fn :: fns)
| _ -> ()
- ) daemon_functions;
+ ) (actions |> daemon_functions);
let groups = Hashtbl.fold (fun k _ ks -> k :: ks) h [] in
let groups =
List.map (
diff --git a/generator/perl.ml b/generator/perl.ml
index a665051..94d7c4f 100644
--- a/generator/perl.ml
+++ b/generator/perl.ml
@@ -583,7 +583,7 @@ PREINIT:
);
pr "\n"
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
and generate_perl_struct_list_code typ cols name style n =
pr " if (r == NULL)\n";
@@ -923,7 +923,7 @@ C<$g-E<gt>feature-available>.\n\n" opt
pr "=pod\n";
pr "\n";
) non_c_aliases
- ) documented_functions_sorted;
+ ) (actions |> documented_functions |> sort);
pr "=cut\n\n";
@@ -989,7 +989,7 @@ C<$g-E<gt>feature-available>.\n\n" opt
pr " name => \"%s\",\n" name;
pr " description => %S,\n" shortdesc;
pr " },\n";
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr ");\n\n";
pr "# Add aliases to the introspection hash.\n";
@@ -1002,7 +1002,7 @@ C<$g-E<gt>feature-available>.\n\n" opt
pr "$guestfs_introspection{%s} = \\%%ielem%d;\n" alias !i;
incr i
) non_c_aliases
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "\n";
(* End of file. *)
diff --git a/generator/php.ml b/generator/php.ml
index 5f06c0f..415c463 100644
--- a/generator/php.ml
+++ b/generator/php.ml
@@ -55,7 +55,7 @@ PHP_FUNCTION (guestfs_last_error);
List.iter (
fun { name = name } -> pr "PHP_FUNCTION (guestfs_%s);\n" name
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "\
@@ -199,7 +199,7 @@ static zend_function_entry guestfs_php_functions[] = {
List.iter (
fun { name = name } -> pr " PHP_FE (guestfs_%s, NULL)\n" name
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr " { NULL, NULL, NULL }
};
@@ -585,7 +585,7 @@ PHP_FUNCTION (guestfs_last_error)
pr "}\n";
pr "\n"
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
and generate_php_struct_code typ cols =
pr " array_init (return_value);\n";
diff --git a/generator/python.ml b/generator/python.ml
index 31b0875..3bd9c48 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -247,7 +247,7 @@ put_table (char * const * const argv)
(* generate the function for typ *)
emit_put_list_function typ
| typ, _ -> () (* empty *)
- ) (rstructs_used_by external_functions);
+ ) (rstructs_used_by (actions |> external_functions));
(* Python wrapper functions. *)
List.iter (
@@ -548,7 +548,7 @@ put_table (char * const * const argv)
pr "}\n";
pr "#endif\n";
pr "\n"
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
(* Table of functions. *)
pr "static PyMethodDef methods[] = {\n";
@@ -566,7 +566,7 @@ put_table (char * const * const argv)
pr " { (char *) \"%s\", guestfs_int_py_%s, METH_VARARGS, NULL
},\n"
name name;
pr "#endif\n"
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr " { NULL, NULL, 0, NULL }\n";
pr "};\n";
pr "\n";
@@ -901,7 +901,7 @@ class GuestFS(object):
fun alias ->
pr " %s = %s\n\n" alias f.name
) f.non_c_aliases
- ) external_functions_sorted
+ ) (actions |> external_functions |> sort)
and indent_python str indent columns =
let rec loop str endpos =
diff --git a/generator/ruby.ml b/generator/ruby.ml
index 56a387e..3bbdbc9 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -760,7 +760,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
pr "}\n";
pr "\n"
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "\
extern void Init__guestfs (void); /* keep GCC warnings happy */
@@ -824,7 +824,7 @@ Init__guestfs (void)
pr " rb_define_method (c_guestfs, \"%s\",\n" alias;
pr " guestfs_int_ruby_%s, %d);\n" name nr_args
) non_c_aliases
- ) external_functions_sorted;
+ ) (actions |> external_functions |> sort);
pr "}\n"
diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml
index 635a4a6..21ef6e3 100644
--- a/generator/tests_c_api.ml
+++ b/generator/tests_c_api.ml
@@ -76,13 +76,13 @@ let rec generate_c_api_tests () =
) tests in
let cmds_tested = List.map List.hd (List.concat seqs) in
List.iter (fun cmd -> Hashtbl.replace hash cmd true) cmds_tested
- ) all_functions;
+ ) actions;
List.iter (
fun { name = name } ->
if not (Hashtbl.mem hash name) then
pr " \"%s\",\n" name
- ) all_functions_sorted;
+ ) (actions |> sort);
pr " NULL\n";
pr " };\n";
@@ -102,7 +102,7 @@ let rec generate_c_api_tests () =
List.map (
fun { name = name; optional = optional; tests = tests } ->
mapi (generate_one_test name optional) tests
- ) (List.rev all_functions) in
+ ) (List.rev actions) in
let test_names = List.concat test_names in
let nr_tests = List.length test_names in
@@ -382,7 +382,7 @@ and generate_test_command_call ?(expect_error = false) ?(do_return =
true) ?test
(* Look up the function. *)
let f =
- try List.find (fun { name = n } -> n = name) all_functions
+ try List.find (fun { name = n } -> n = name) actions
with Not_found ->
failwithf "%s: in test, command %s was not found" test_name name in
diff --git a/generator/xdr.ml b/generator/xdr.ml
index 60ccbf9..8bd168d 100644
--- a/generator/xdr.ml
+++ b/generator/xdr.ml
@@ -169,7 +169,7 @@ let generate_xdr () =
pr " opaque %s<>;\n" n;
pr "};\n\n"
);
- ) daemon_functions;
+ ) (actions |> daemon_functions);
pr "/* Table of procedure numbers. */\n";
pr "enum guestfs_procedure {\n";
@@ -182,7 +182,7 @@ let generate_xdr () =
pr " GUESTFS_PROC_%s = %d,\n" (String.uppercase shortname) proc_nr;
loop rest
in
- loop daemon_functions;
+ loop (actions |> daemon_functions);
pr "};\n";
pr "\n";
--
2.9.3