Skip to content

Commit

Permalink
gen_api: generate an all_<enum> for enum types
Browse files Browse the repository at this point in the history
This will be useful for testing record_util.ml

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Feb 16, 2024
1 parent 13258e5 commit ed13f12
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ocaml/idl/ocaml_backend/gen_api.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ let gen_non_record_type tys =
t
| ty :: t ->
let alias = OU.alias_of_ty ty in
let accu =
match ty with
| DT.Enum (name, cs) ->
sprintf "let all_%s = [%s]" name
(cs
|> List.map fst
|> List.map OU.constructor_of
|> String.concat "; "
)
:: accu
| _ ->
accu
in
if List.mem_assoc alias overrides then
aux
(sprintf "type %s = %s\n%s\n" alias (OU.ocaml_of_ty ty)
Expand Down

0 comments on commit ed13f12

Please sign in to comment.