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 | Return of ptype
45 (** API return type. A superset of {!ptype} because we allow the
46 special value [RVoid] for functions that don't return any value. *)
48 type ftype = rtype * parameter list * parameter list
49 (** A function type. Return type, list of required parameters, list
50 of optional parameters. *)
56 ep_loc : Camlp4.PreCast.Loc.t;
60 ep_code : c_code option;
62 (** An API entry point. *)
65 td_loc : Camlp4.PreCast.Loc.t;
72 en_loc : Camlp4.PreCast.Loc.t;
74 en_identifiers : string array;
79 sd_loc : Camlp4.PreCast.Loc.t;
81 sd_identifiers : string array;
82 sd_fields : ptype array;
84 (** A struct declaration. *)
87 un_loc : Camlp4.PreCast.Loc.t;
89 un_identifiers : string array;
90 un_fields : ptype array;
92 (** A qualified union declaration. *)
95 api_typedefs : typedef Wrappi_utils.StringMap.t;
96 api_enums : enum Wrappi_utils.StringMap.t;
97 api_structs : struct_decl Wrappi_utils.StringMap.t;
98 api_unions : union Wrappi_utils.StringMap.t;
99 api_entry_points : entry_point Wrappi_utils.StringMap.t;
101 (** This single structure describes the whole API. Each map is from
102 name of thing -> thing. *)
104 val iter_typedefs : api -> (typedef -> unit) -> unit
105 val iter_enums : api -> (enum -> unit) -> unit
106 val iter_structs : api -> (struct_decl -> unit) -> unit
107 val iter_unions : api -> (union -> unit) -> unit
108 val iter_entry_points : api -> (entry_point -> unit) -> unit
109 (** For convenience, iteration always presents the objects in name order. *)
111 val string_of_ptype : ptype -> string
112 val string_of_rtype : rtype -> string
113 val string_of_parameter : parameter -> string
114 val string_of_parameters : parameter list -> string
115 val string_of_ftype : ftype -> string
116 val string_of_c_code : c_code -> string
117 val string_of_typedef : typedef -> string
118 val string_of_enum : enum -> string
119 val string_of_struct : struct_decl -> string
120 val string_of_union : union -> string
121 val string_of_entry_point : entry_point -> string
122 (** Convert structures to strings for printing, debugging etc. *)