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.
20 | TBool (** Boolean *)
21 | TBuffer (** 8 bit buffer of limited length *)
22 | TEnum of string (** Enumerated type *)
23 | TFile (** arbitrary length file in/out *)
24 | THash of ptype (** Hash of string -> ptype *)
25 | TInt (** Integer: MUST have preconditions *)
26 | TInt32 (** Signed 32 bit integer *)
27 | TInt64 (** Signed 64 bit integer *)
28 | TList of ptype (** List/array of values *)
29 | TNullable of ptype (** NULLable type modifier *)
30 | TString (** String (non-null) *)
31 | TStruct of string (** Struct *)
32 | TTypedef of string (** Typedef (before being resolved) *)
33 | TUInt32 (** Unsigned 32 bit integer *)
34 | TUInt64 (** Unsigned 64 bit integer *)
35 | TUnion of string (** Qualified union *)
36 (** API parameter type. *)
39 (** Parameter precondition (XXX not implemented yet). *)
41 type parameter = string * ptype * prec option
42 (** API parameter (argument name, type, optional precondition). *)
44 type rtype = RVoid | RStaticString | Return of ptype
45 (** API return type. A superset of {!ptype} because we allow the
46 some special return-only types. *)
48 type ftype = rtype * parameter list * parameter list
49 (** A function type. Return type, list of required parameters, list
50 of optional parameters. *)
53 cc_loc : Camlp4.PreCast.Loc.t;
59 ep_loc : Camlp4.PreCast.Loc.t;
63 ep_code : c_code option;
64 ep_includes : string list;
66 (** An API entry point. *)
69 td_loc : Camlp4.PreCast.Loc.t;
76 en_loc : Camlp4.PreCast.Loc.t;
78 en_identifiers : string array;
83 sd_loc : Camlp4.PreCast.Loc.t;
85 sd_fields : (string * ptype) array;
87 (** A struct declaration. *)
90 un_loc : Camlp4.PreCast.Loc.t;
92 un_fields : (string * ptype) array;
94 (** A qualified union declaration. *)
97 api_typedefs : typedef Wrappi_utils.StringMap.t;
98 api_enums : enum Wrappi_utils.StringMap.t;
99 api_structs : struct_decl Wrappi_utils.StringMap.t;
100 api_unions : union Wrappi_utils.StringMap.t;
101 api_entry_points : entry_point Wrappi_utils.StringMap.t;
103 (** This single structure describes the whole API. Each map is from
104 name of thing -> thing. *)
106 val iter_typedefs : api -> (typedef -> unit) -> unit
107 val iter_enums : api -> (enum -> unit) -> unit
108 val iter_structs : api -> (struct_decl -> unit) -> unit
109 val iter_unions : api -> (union -> unit) -> unit
110 val iter_entry_points : api -> (entry_point -> unit) -> unit
111 (** For convenience, iteration always presents the objects in name order. *)
113 val string_of_ptype : ptype -> string
114 val string_of_rtype : rtype -> string
115 val string_of_parameter : parameter -> string
116 val string_of_parameters : parameter list -> string
117 val string_of_ftype : ftype -> string
118 val string_of_c_code : c_code -> string
119 val string_of_typedef : typedef -> string
120 val string_of_enum : enum -> string
121 val string_of_struct : struct_decl -> string
122 val string_of_union : union -> string
123 val string_of_entry_point : entry_point -> string
124 (** Convert structures to strings for printing, debugging etc. *)