Wrappi_accumulator.add_typedef td
>>
+let add_enum _loc name identifiers =
+ let loc = expr_of_loc _loc _loc in
+
+ <:str_item<
+ let en = { Wrappi_types.en_loc = $loc$;
+ en_name = $str:name$;
+ en_identifiers = Array.of_list $identifiers$ } in
+ Wrappi_accumulator.add_enum en
+ >>
+
let () =
(* Quotation expander for C code. *)
let c_quotation_expander _loc _ code =
ptype: [
[ "bool" -> <:expr< Wrappi_types.TBool >> ]
| [ "buffer" -> <:expr< Wrappi_types.TBuffer >> ]
- (* enum XXX *)
+ | [ "enum"; name = LIDENT -> <:expr< Wrappi_types.TEnum $str:name$ >> ]
| [ "file" -> <:expr< Wrappi_types.TFile >> ]
| [ "hash"; "("; t = ptype; ")" -> <:expr< Wrappi_types.THash $t$ >> ]
| [ "int" -> <:expr< Wrappi_types.TInt >> ]
| [ "struct"; name = LIDENT -> <:expr< Wrappi_types.TStruct $str:name$ >> ]
| [ "uint32" -> <:expr< Wrappi_types.TUInt32 >> ]
| [ "uint64" -> <:expr< Wrappi_types.TUInt64 >> ]
- (* union XXX *)
+ | [ "union"; name = LIDENT -> <:expr< Wrappi_types.TUnion $str:name$ >> ]
| [ name = LIDENT -> <:expr< Wrappi_types.TTypedef $str:name$ >> ]
];
->
add_entry_point _loc local name parameters rtype code includes
]
+
+ | [ "enum"; name = LIDENT; identifiers = expr ->
+ add_enum _loc name identifiers
+ ]
+
| [ "typedef"; t = ptype; name = LIDENT ->
add_typedef _loc name t
]