Start generating C code.
[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 = TInt32 | TInt64 | Type of string
20 (** Any API parameter or return type. *)
21
22 type parameter = string * any_type
23 (** API parameter (argument name and type). *)
24
25 type return_type = RErr | Return of any_type
26 (** API return type.  A superset of {!any_type} because we allow the
27     special value [RErr] for dealing with errno. *)
28
29 type c_code = string
30 (** C code. *)
31
32 type entry_point = {
33   ep_loc : Camlp4.PreCast.Loc.t;
34   ep_name : string;
35   ep_params : parameter list;
36   ep_return : return_type;
37   ep_code : c_code option;
38 }
39 (** An API entry point. *)
40
41 type api = {
42   api_entry_points : entry_point list;
43 }
44 (** This single structure describes the whole API. *)
45
46 val string_of_any_type : any_type -> string
47 val string_of_return_type : return_type -> string
48 val string_of_parameter : parameter -> string
49 val string_of_parameters : parameter list -> string
50 val string_of_c_code : c_code -> string
51 val string_of_entry_point : entry_point -> string
52 (** Convert structures to strings for printing, debugging etc. *)