6bd58f010f6c996ab6bf0567b3c0ca57814c3503
[wrappi.git] / generator-lib / wrappi_types.mli
1 (* wrappi
2  * Copyright (C) 2011 Red Hat Inc.
3  *
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.
8  *
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.
13  *
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.
17  *)
18
19 type any_type =
20   | TFilePerm
21   | TInt32
22   | TInt64
23   | TPathname
24   | TUInt32
25   | TUInt64
26 (** Any API parameter or return type. *)
27
28 type parameter = string * any_type
29 (** API parameter (argument name and type). *)
30
31 type return_type = RErr | Return of any_type
32 (** API return type.  A superset of {!any_type} because we allow the
33     special value [RErr] for dealing with errno. *)
34
35 type c_code = string
36 (** C code. *)
37
38 type entry_point = {
39   ep_loc : Camlp4.PreCast.Loc.t;
40   ep_name : string;
41   ep_params : parameter list;
42   ep_return : return_type;
43   ep_code : c_code option;
44 }
45 (** An API entry point. *)
46
47 type api = {
48   api_entry_points : entry_point list;
49 }
50 (** This single structure describes the whole API. *)
51
52 val string_of_any_type : any_type -> string
53 val string_of_return_type : return_type -> string
54 val string_of_parameter : parameter -> string
55 val string_of_parameters : parameter list -> string
56 val string_of_c_code : c_code -> string
57 val string_of_entry_point : entry_point -> string
58 (** Convert structures to strings for printing, debugging etc. *)