-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit code for merging two messages and add tests to verify the implem…
…entation
- Loading branch information
1 parent
1a0f2a1
commit e1c2e1a
Showing
20 changed files
with
940 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(** Merge a two values. Need to match on the spec to merge messages recursivly *) | ||
let merge: type t. t Spec.Deserialize.compound -> t -> t -> t = fun spec t t' -> match spec with | ||
| Spec.Deserialize.Basic (_field, Message (_, merge), _) -> merge t t' | ||
| Spec.Deserialize.Basic (_field, _spec, Some default) when t' = default -> t | ||
| Spec.Deserialize.Basic (_field, _spec, _) -> t' | ||
| Spec.Deserialize.Basic_opt (_field, Message (_, merge)) -> | ||
begin | ||
match t, t' with | ||
| None, None -> None | ||
| Some t, None -> Some t | ||
| None, Some t -> Some t | ||
| Some t, Some t' -> Some (merge t t') | ||
end | ||
| Spec.Deserialize.Basic_opt (_field, _spec) -> begin | ||
match t' with | ||
| Some _ -> t' | ||
| None -> t | ||
end | ||
| Spec.Deserialize.Repeated (_field, _, _) -> t @ t' | ||
(* | Spec.Deserialize.Oneof _ when t' = `not_set -> t *) | ||
| Spec.Deserialize.Oneof _ -> failwith "Implementation is part of generated code" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.