X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=generator%2Fgenerator_checks.ml;h=347404703b4eaa2371551a6dbc22346448861b93;hp=f30a28684c28e51b4ada64813d0bd551bd15f66a;hb=a81bf3f3ef24c8b6d66aea1038f7a16a382ff375;hpb=04d8209077d2227eb1d42695ba71147f78987050 diff --git a/generator/generator_checks.ml b/generator/generator_checks.ml index f30a286..3474047 100644 --- a/generator/generator_checks.ml +++ b/generator/generator_checks.ml @@ -49,7 +49,7 @@ let () = if String.contains name '-' then failwithf "function name %s should not contain '-', use '_' instead." name - ) all_functions; + ) (all_functions @ fish_commands); (* Check function parameter/return names. *) List.iter ( @@ -101,7 +101,9 @@ let () = failwithf "%s has param/ret using reserved word %s" name n; in - (match fst style with + let ret, args, optargs = style in + + (match ret with | RErr -> () | RInt n | RInt64 n | RBool n | RConstString n | RConstOptString n | RString n @@ -109,7 +111,22 @@ let () = | RHashtable n | RBufferOut n -> check_arg_ret_name n ); - List.iter (fun arg -> check_arg_ret_name (name_of_argt arg)) (snd style) + List.iter (fun arg -> check_arg_ret_name (name_of_argt arg)) args; + List.iter (fun arg -> check_arg_ret_name (name_of_argt arg)) optargs; + ) all_functions; + + (* Check only certain types allowed in optargs. *) + List.iter ( + fun (name, (_, _, optargs), _, _, _, _, _) -> + if List.length optargs > 64 then + failwithf "maximum of 64 optional args allowed for %s" name; + + List.iter ( + function + | Bool _ | Int _ | Int64 _ | String _ -> () + | _ -> + failwithf "optional args of %s can only have type Bool|Int|Int64|String" name + ) optargs ) all_functions; (* Check short descriptions. *) @@ -120,14 +137,14 @@ 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; + ) (all_functions @ fish_commands); (* Check long descriptions. *) List.iter ( fun (name, _, _, _, _, _, longdesc) -> if longdesc.[String.length longdesc-1] = '\n' then failwithf "long description of %s should not end with \\n." name - ) all_functions; + ) (all_functions @ fish_commands); (* Check proc_nrs. *) List.iter (