X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator-lib%2Fwrappi_types.mli;h=fd276c44650e141fb2cb7781c38f891165cce788;hb=00e9ee626a00324c1808ab860f00f1a07c88ade8;hp=f4b4f669cece050b2d7582cf1b2ea327b2004588;hpb=ff4a39eec0c3d92b7fda62341e0734e07d5d2987;p=wrappi.git diff --git a/generator-lib/wrappi_types.mli b/generator-lib/wrappi_types.mli index f4b4f66..fd276c4 100644 --- a/generator-lib/wrappi_types.mli +++ b/generator-lib/wrappi_types.mli @@ -16,37 +16,109 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) -type any_type = TInt32 | TInt64 | Type of string -(** Any API parameter or return type. *) +type ptype = + | TBool (** Boolean *) + | TBuffer (** 8 bit buffer of limited length *) + | TEnum of string (** Enumerated type *) + | TFile (** arbitrary length file in/out *) + | THash of ptype (** Hash of string -> ptype *) + | TInt (** Integer: MUST have preconditions *) + | TInt32 (** Signed 32 bit integer *) + | TInt64 (** Signed 64 bit integer *) + | TList of ptype (** List/array of values *) + | TNullable of ptype (** NULLable type modifier *) + | TString (** String (non-null) *) + | TStruct of string (** Struct *) + | TTypedef of string (** Typedef (before being resolved) *) + | TUInt32 (** Unsigned 32 bit integer *) + | TUInt64 (** Unsigned 64 bit integer *) + | TUnion of string (** Qualified union *) +(** API parameter type. *) -type parameter = string * any_type -(** API parameter (argument name and type). *) +type prec +(** Parameter precondition (XXX not implemented yet). *) -type return_type = RErr | Return of any_type -(** API return type. A superset of {!any_type} because we allow the - special value [RErr] for dealing with errno. *) +type parameter = string * ptype * prec option +(** API parameter (argument name, type, optional precondition). *) -type c_code = string +type rtype = RVoid | RStaticString | Return of ptype +(** API return type. A superset of {!ptype} because we allow the + some special return-only types. *) + +type ftype = rtype * parameter list * parameter list +(** A function type. Return type, list of required parameters, list + of optional parameters. *) + +type c_code = { + cc_loc : Camlp4.PreCast.Loc.t; + cc_code : string; +} (** C code. *) type entry_point = { ep_loc : Camlp4.PreCast.Loc.t; + ep_local : bool; ep_name : string; - ep_params : parameter list; - ep_return : return_type; + ep_ftype : ftype; ep_code : c_code option; + ep_includes : string list; } (** An API entry point. *) +type typedef = { + td_loc : Camlp4.PreCast.Loc.t; + td_name : string; + td_type : ptype; +} +(** A typedef. *) + +type enum = { + en_loc : Camlp4.PreCast.Loc.t; + en_name : string; + en_identifiers : string array; +} +(** An enum. *) + +type struct_decl = { + sd_loc : Camlp4.PreCast.Loc.t; + sd_name : string; + sd_fields : (string * ptype) array; +} +(** A struct declaration. *) + +type union = { + un_loc : Camlp4.PreCast.Loc.t; + un_name : string; + un_fields : (string * ptype) array; +} +(** A qualified union declaration. *) + type api = { - api_entry_points : entry_point list; + api_typedefs : typedef Wrappi_utils.StringMap.t; + api_enums : enum Wrappi_utils.StringMap.t; + api_structs : struct_decl Wrappi_utils.StringMap.t; + api_unions : union Wrappi_utils.StringMap.t; + api_entry_points : entry_point Wrappi_utils.StringMap.t; } -(** This single structure describes the whole API. *) +(** This single structure describes the whole API. Each map is from + name of thing -> thing. *) + +val iter_typedefs : api -> (typedef -> unit) -> unit +val iter_enums : api -> (enum -> unit) -> unit +val iter_structs : api -> (struct_decl -> unit) -> unit +val iter_unions : api -> (union -> unit) -> unit +val iter_entry_points : api -> (entry_point -> unit) -> unit +(** For convenience, iteration always presents the objects in name order. *) -val string_of_any_type : any_type -> string -val string_of_return_type : return_type -> string +val string_of_ptype : ptype -> string +val string_of_rtype : rtype -> string val string_of_parameter : parameter -> string val string_of_parameters : parameter list -> string +val string_of_ftype : ftype -> string val string_of_c_code : c_code -> string +val string_of_typedef : typedef -> string +val string_of_enum : enum -> string +val string_of_struct : struct_decl -> string +val string_of_union : union -> string val string_of_entry_point : entry_point -> string (** Convert structures to strings for printing, debugging etc. *)