From 9f7926e7274aea9be43cf4bc1a9d1cf42ac6bec0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 5 Nov 2010 13:42:07 +0000 Subject: [PATCH] generator: Don't die if an API call isn't listed in API versions file. For example, it may just have been added. --- generator/generator_api_versions.ml | 5 ++--- generator/generator_api_versions.mli | 5 +++-- generator/generator_c.ml | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/generator/generator_api_versions.ml b/generator/generator_api_versions.ml index 5f9d96f..1749752 100644 --- a/generator/generator_api_versions.ml +++ b/generator/generator_api_versions.ml @@ -39,6 +39,5 @@ let load_api_versions filename = close_in chan let lookup_api_version sym = - try Hashtbl.find hash sym - with Not_found -> - failwithf "API symbol \"%s\" not found in API versions file" sym + try Some (Hashtbl.find hash sym) + with Not_found -> None diff --git a/generator/generator_api_versions.mli b/generator/generator_api_versions.mli index 03e8777..0932a67 100644 --- a/generator/generator_api_versions.mli +++ b/generator/generator_api_versions.mli @@ -25,7 +25,8 @@ val load_api_versions : string -> unit (** Load the data from the named file. *) -val lookup_api_version : string -> string +val lookup_api_version : string -> string option (** [lookup_api_version c_api] looks up the version that the C API call (which must be the full C name, eg. ["guestfs_launch"]) was - added. This returns the version string, eg. ["0.3"]. *) + added. This returns the version string, eg. [Some "0.3"], or + [None] if no version could be found. *) diff --git a/generator/generator_c.ml b/generator/generator_c.ml index 28cecdb..4480200 100644 --- a/generator/generator_c.ml +++ b/generator/generator_c.ml @@ -255,8 +255,10 @@ L for more information.\n\n"; | None -> () | Some txt -> pr "%s\n\n" txt ); - let version = lookup_api_version name in - pr "(Added in %s)\n\n" version; + (match lookup_api_version name with + | Some version -> pr "(Added in %s)\n\n" version + | None -> () + ); (* Handling of optional argument variants. *) if optargs <> [] then ( -- 1.8.3.1