2 * Copyright (C) 2011 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 type parameter = string * any_type
33 type return_type = RErr | Return of any_type
38 ep_loc : Camlp4.PreCast.Loc.t;
40 ep_params : parameter list;
41 ep_return : return_type;
42 ep_code : c_code option;
46 api_entry_points : entry_point list;
49 let string_of_any_type = function
50 | TFilePerm -> "fileperm"
53 | TPathname -> "pathname"
56 let string_of_return_type = function
58 | Return t -> string_of_any_type t
59 let string_of_parameter (name, t) =
60 sprintf "%s %s" (string_of_any_type t) name
61 let string_of_parameters params =
62 "(" ^ String.concat ", " (List.map string_of_parameter params) ^ ")"
63 let string_of_c_code code = code
64 let string_of_entry_point ep =
65 sprintf "entry_point %s %s %s <<%s>>"
66 (*(Loc.to_string ep.ep_loc)*)
67 (string_of_return_type ep.ep_return)
69 (string_of_parameters ep.ep_params)
70 (match ep.ep_code with
71 | None -> "/* implicit */"
72 | Some code -> string_of_c_code code)