+let iter xs f =
+ let xs = StringMap.bindings xs in
+ let cmp (a, _) (b, _) = compare a b in
+ let xs = List.sort cmp xs in
+ List.iter (fun (_, x) -> f x) xs
+
+let iter_typedefs { api_typedefs = tds } f = iter tds f
+let iter_enums { api_enums = ens } f = iter ens f
+let iter_structs { api_structs = sds } f = iter sds f
+let iter_unions { api_unions = uns } f = iter uns f
+let iter_entry_points { api_entry_points = eps } f = iter eps f
+
+let rec string_of_ptype = function
+ | TBool -> "bool"
+ | TBuffer -> "buffer"
+ | TEnum name -> sprintf "enum %s" name
+ | TFile -> "file"
+ | THash t -> sprintf "hash(%s)" (string_of_ptype t)
+ | TInt -> "int"