Skip to content

Commit

Permalink
refactor: move objects from Gen_go_helper to CommonFunctions
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Zhang <[email protected]>
  • Loading branch information
duobei committed Apr 9, 2024
1 parent dc2a345 commit 32e165a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
18 changes: 18 additions & 0 deletions ocaml/sdk-gen/common/CommonFunctions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

open Printf
open Datamodel_types
open Datamodel_utils
open Dm_api

exception Unknown_wire_protocol

Expand Down Expand Up @@ -328,3 +330,19 @@ let json_releases =
, `Float (float_of_int (List.length unique_version_bumps))
)
]

let objects =
let api = Datamodel.all_api in
(* Add all implicit messages *)
let api = add_implicit_messages api in
(* Only include messages that are visible to a XenAPI client *)
let api = filter (fun _ -> true) (fun _ -> true) on_client_side api in
(* And only messages marked as not hidden from the docs, and non-internal fields *)
let api =
filter
(fun _ -> true)
(fun f -> not f.internal_only)
(fun m -> not m.msg_hide_from_docs)
api
in
objects_of_api api
5 changes: 5 additions & 0 deletions ocaml/sdk-gen/common/CommonFunctions.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Datamodel_types

(** Exception for unknown wire protocol. *)
exception Unknown_wire_protocol

Expand Down Expand Up @@ -129,3 +131,6 @@ val render_file : string * string -> Mustache.Json.t -> string -> string -> unit

val json_releases : Mustache.Json.t
(** JSON structure representing release information. *)

val objects : obj list
(** Objects of api that generate SDKs. *)
1 change: 1 addition & 0 deletions ocaml/sdk-gen/go/gen_go_binding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
GNU Lesser General Public License for more details.
*)

open CommonFunctions
open Gen_go_helper

let render_api_messages_and_errors () =
Expand Down
18 changes: 0 additions & 18 deletions ocaml/sdk-gen/go/gen_go_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
(* Generator of Go bindings from the datamodel *)

open Datamodel_types
open Datamodel_utils
open Dm_api
open CommonFunctions

let dest_dir = "autogen"
Expand Down Expand Up @@ -259,19 +257,3 @@ module Json = struct
let api_errors =
List.map (fun error -> `O [("name", `String error)]) !Api_errors.errors
end

let objects =
let api = Datamodel.all_api in
(* Add all implicit messages *)
let api = add_implicit_messages api in
(* Only include messages that are visible to a XenAPI client *)
let api = filter (fun _ -> true) (fun _ -> true) on_client_side api in
(* And only messages marked as not hidden from the docs, and non-internal fields *)
let api =
filter
(fun _ -> true)
(fun f -> not f.internal_only)
(fun m -> not m.msg_hide_from_docs)
api
in
objects_of_api api
4 changes: 0 additions & 4 deletions ocaml/sdk-gen/go/gen_go_helper.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@
GNU Lesser General Public License for more details.
*)

open Datamodel_types

val ( // ) : string -> string -> string

val snake_to_camel : string -> string

val objects : obj list

val render_template : string -> Mustache.Json.t -> string

val generate_file : string -> string -> unit
Expand Down

0 comments on commit 32e165a

Please sign in to comment.