X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator-lib%2Fwrappi_types.mli;h=b83668567ce0af48fadfddd4c398e97d5c4ffa91;hb=38e9518c97b2ae11b68382afa1ecae7feceeae2a;hp=6120aff38c4ec0ff6e3c6bc43209f18e09cfe398;hpb=bb1329db94910f6739c839bee52177f1b3c4e695;p=wrappi.git diff --git a/generator-lib/wrappi_types.mli b/generator-lib/wrappi_types.mli index 6120aff..b836685 100644 --- a/generator-lib/wrappi_types.mli +++ b/generator-lib/wrappi_types.mli @@ -16,32 +16,106 @@ * 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 +type parameter = string * ptype * prec option +(** API parameter (argument name, type, optional precondition). *) + +type rtype = RErr | Return of ptype +(** API return type. A superset of {!ptype} because we allow the special value [RErr] for dealing with errno. *) +type ftype = rtype * parameter list * parameter list +(** A function type. Return type, list of required parameters, list + of optional parameters. *) + type c_code = string (** C code. *) type entry_point = { - (*ep_loc : Camlp4.PreCast.Loc.t;*) + ep_loc : Camlp4.PreCast.Loc.t; ep_name : string; - ep_params : parameter list; - ep_return : return_type; + ep_ftype : ftype; ep_code : c_code option; } (** An API entry point. *) -val string_of_any_type : any_type -> string -val string_of_return_type : return_type -> string +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_identifiers : string array; + sd_fields : ptype array; +} +(** A struct declaration. *) + +type union = { + un_loc : Camlp4.PreCast.Loc.t; + un_name : string; + un_identifiers : string array; + un_fields : ptype array; +} +(** A qualified union declaration. *) + +type api = { + 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. 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_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. *)