Skip to content

Commit 25c5eec

Browse files
authored
Merge pull request xapi-project#3009 from gaborigloi/ppx-ely
Finish moving to ppx-based syntax extensions
2 parents fd28c32 + b713ae0 commit 25c5eec

24 files changed

+88
-93
lines changed

OMakeroot

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,6 @@ OCamlLibraryClib(name, files, clibs) =
7474

7575
return $(array $(if $(NATIVE_ENABLED), $(NATIVELIB)), $(if $(NATIVE_ENABLED), $(CLIB)), $(if $(BYTE_ENABLED), $(BYTELIB)))
7676

77-
#
78-
# Use Camlp4
79-
#
80-
UseCamlp4(packs, files) =
81-
OCAMLPACKS += $(packs)
82-
OCAMLFINDFLAGS += -syntax camlp4o
83-
$(addsuffix .cmx, $(files)):
84-
$(addsuffix .o, $(files)):
85-
$(addsuffix .cmi, $(files)):
86-
$(addsuffix .cmo, $(files)):
87-
8877
#
8978
# Include the OMakefile in this directory.
9079
#

ocaml/autogen/OMakefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ OCAMLPACKS = xml-light2 sexpr http-svr xcp rpclib
77
clean:
88
rm -rf *.*
99

10-
UseCamlp4(rpclib.syntax, aPI)
11-
1210
DB_ACTIONS_FILES = db_actions $(AUTOGEN_HELPER_DIR)/string_unmarshall_helper $(AUTOGEN_HELPER_DIR)/string_marshall_helper $(AUTOGEN_HELPER_DIR)/db_action_helper $(AUTOGEN_HELPER_DIR)/db_remote_marshall $(AUTOGEN_HELPER_DIR)/db_filter_types $(AUTOGEN_HELPER_DIR)/db_filter $(AUTOGEN_HELPER_DIR)/db_filter_parse $(AUTOGEN_HELPER_DIR)/db_filter_lex
1311
OCamlProgram(db_actions, $(DB_ACTIONS_FILES))
1412

ocaml/doc/OMakefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
OCAML_LIBS += ../idl/datamodel
22
OCAMLINCLUDES += ../idl
33

4-
CAMLP4_FILES = jsapi
5-
UseCamlp4(rpclib.syntax, $(CAMLP4_FILES))
6-
74
OCamlProgram(jsapi, jsapi)
85

96
.PHONY: doc-html

ocaml/doc/jsapi.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ open Datamodel_types
1616

1717
type change_t = lifecycle_change * string * string
1818
and changes_t = change_t list
19-
with rpc
19+
[@@deriving rpc]
2020

2121
let _ =
2222
let api = (Datamodel.all_api) in

ocaml/idl/OMakefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ PSTOPDF = $(shell bash -c "which pstopdf 2>/dev/null || which ps2pdf 2>/dev/null
55
OCAMLINCLUDES = ocaml_backend ../database
66
OCAMLPACKS = xml-light2 sexpr xcp rpclib http-svr uuid
77

8-
CAMLP4_FILES = datamodel_types
9-
10-
UseCamlp4(rpclib.syntax, $(CAMLP4_FILES))
11-
128
# -----------------------------------------------------------------------
139
# Build datamodel library
1410
# -----------------------------------------------------------------------

ocaml/idl/datamodel_types.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ type ty =
9898
| Map of ty * ty
9999
| Ref of string
100100
| Record of string
101-
with rpc
101+
[@@deriving rpc]
102102

103103
type api_value =
104104
VString of string
@@ -111,7 +111,7 @@ type api_value =
111111
| VSet of api_value list
112112
| VRef of string
113113
| VCustom of string * api_value
114-
with rpc
114+
[@@deriving rpc]
115115

116116
(** Each database field has a qualifier associated with it:
117117
* "Static" means the initial value is specified as a parameter in the object constructor.
@@ -122,14 +122,14 @@ type qualifier =
122122
| RW (** Implicitly static: set in constructor and updatable through API *)
123123
| StaticRO (** Specified in constructor; no autogenerated setter in XenAPI. *)
124124
| DynamicRO (** Initial value is a default; no autogenerated setter in XenAPI. *)
125-
with rpc
125+
[@@deriving rpc]
126126

127127
(** Release keeps track of which versions of opensource/internal products fields and messages are included in *)
128128
type release = {
129129
opensource: string list;
130130
internal: string list;
131131
internal_deprecated_since: string option; (* first release we said it was deprecated *)
132-
} with rpc
132+
} [@@deriving rpc]
133133

134134
type lifecycle_change =
135135
| Prototyped
@@ -140,7 +140,7 @@ type lifecycle_change =
140140
| Removed
141141

142142
and lifecycle_transition = lifecycle_change * string * string
143-
with rpc
143+
[@@deriving rpc]
144144

145145
(** Messages are tagged with one of these indicating whether the message was
146146
specified explicitly in the datamodel, or is one of the automatically
@@ -219,7 +219,7 @@ and error = {
219219
and mess = {
220220
mess_name: string;
221221
mess_doc: string;
222-
} with rpc
222+
} [@@deriving rpc]
223223

224224
let default_message = {
225225
msg_name = "";
@@ -258,12 +258,12 @@ let default_message = {
258258
type content =
259259
| Field of field (** An individual field *)
260260
| Namespace of string * content list (** A nice namespace for a group of fields *)
261-
with rpc
261+
[@@deriving rpc]
262262

263263
(* Note: there used be more than 2 persist_options -- that's why it isn't a bool.
264264
I figured even though there's only 2 now I may as well leave it as an enumeration type.. *)
265265

266-
type persist_option = PersistNothing | PersistEverything with rpc
266+
type persist_option = PersistNothing | PersistEverything [@@deriving rpc]
267267
(* PersistEverything - all creates/writes persisted;
268268
PersistNothing - no creates/writes to this table persisted *)
269269

@@ -285,7 +285,7 @@ type obj = {
285285
obj_release: release;
286286
in_database: bool; (* If the object is in the database *)
287287
obj_doc_tags: doc_tag list;
288-
} with rpc
288+
} [@@deriving rpc]
289289

290290
(* val rpc_of_obj : obj -> Rpc.t *)
291291
(* let s = Jsonrpc.to_string (rpc_of_obj o) *)

ocaml/idl/json_backend/OMakefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ OCAML_LIBS += ../datamodel
44

55
OCamlProgram(main, main)
66

7-
CAMLP4_FILES = main
8-
UseCamlp4(rpclib.syntax, $(CAMLP4_FILES))
9-
107
.PHONY: clean
118
clean:
129
rm -f *~ *.opt *.run *.a *.cma *.cmxa *.cmo *.cmi *.o *.cmx *.omc *.annot main *.json

ocaml/idl/ocaml_backend/OMakefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ OCAMLINCLUDES += ../.. ../../database $(AUTOGEN_DIR) ../../xapi ../../client_rec
1111

1212
OCAMLPACKS += sexpr xml-light2 http-svr rpclib stunnel
1313

14-
CAMLP4_FILES = event_types
15-
16-
UseCamlp4(rpclib.syntax, $(CAMLP4_FILES))
17-
1814
# only gen_api requires datamodel library:
1915
GEN_API_FILES = gen_api gen_test genOCaml ref ocaml_syntax gen_db_actions gen_db_check gen_empty_custom gen_client gen_server gen_common gen_rbac ../../database/escaping locking ../api_lowlevel gen_api_main ../datamodel ../constants ../api_errors ../api_messages ../datamodel_utils ../datamodel_values ocaml_utils ../datamodel_types ../dm_api $(AUTOGEN_HELPER_DIR)/string_marshall_helper
2016
OCamlProgram(gen_api_main, $(GEN_API_FILES))

ocaml/idl/ocaml_backend/event_types.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type event = {
2525
op: op;
2626
reference: string;
2727
snapshot: Rpc.t option;
28-
} with rpc
28+
} [@@deriving rpc]
2929

3030
let ev_struct_remap = [
3131
"id","id";
@@ -48,15 +48,15 @@ let rpc_of_event ev =
4848
let event_of_rpc rpc =
4949
event_of_rpc (remap (List.map (fun (k,v) -> (v,k)) ev_struct_remap) rpc)
5050

51-
type events = event list with rpc
51+
type events = event list [@@deriving rpc]
5252

53-
type token = string with rpc
53+
type token = string [@@deriving rpc]
5454

5555
type event_from = {
5656
events: event list;
5757
valid_ref_counts: (string * int32) list;
5858
token: token;
59-
} with rpc
59+
} [@@deriving rpc]
6060

6161
let rec rpc_of_event_from e =
6262
Rpc.Dict

ocaml/idl/ocaml_backend/gen_api.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ let gen_non_record_type highapi tys =
5757
| DT.Map (_, DT.Record _) :: t
5858
| DT.Set (DT.Record _) :: t -> aux accu t
5959
| DT.Set (DT.Enum (n,_) as e) as ty :: t ->
60-
aux (sprintf "type %s = %s list with rpc" (OU.alias_of_ty ty) (OU.alias_of_ty e) :: accu) t
60+
aux (sprintf "type %s = %s list [@@deriving rpc]" (OU.alias_of_ty ty) (OU.alias_of_ty e) :: accu) t
6161
| ty :: t ->
6262
let alias = OU.alias_of_ty ty in
6363
if List.mem_assoc alias overrides
6464
then aux ((sprintf "type %s = %s\n%s\n" alias (OU.ocaml_of_ty ty) (List.assoc alias overrides))::accu) t
65-
else aux (sprintf "type %s = %s with rpc" (OU.alias_of_ty ty) (OU.ocaml_of_ty ty) :: accu) t in
65+
else aux (sprintf "type %s = %s [@@deriving rpc]" (OU.alias_of_ty ty) (OU.ocaml_of_ty ty) :: accu) t in
6666
aux [] tys
6767

6868
(** Generate a list of modules for each record kind *)
@@ -93,8 +93,8 @@ let gen_record_type ~with_module highapi tys =
9393
else [
9494
sprintf "let rpc_of_%s_t x = Rpc.Dict [ %s ]" obj_name (map_fields make_of_field);
9595
sprintf "let %s_t_of_rpc x = on_dict (fun x -> { %s }) x" obj_name (map_fields make_to_field);
96-
sprintf "type ref_%s_to_%s_t_map = (ref_%s * %s_t) list with rpc" record obj_name record obj_name;
97-
sprintf "type %s_t_set = %s_t list with rpc" obj_name obj_name;
96+
sprintf "type ref_%s_to_%s_t_map = (ref_%s * %s_t) list [@@deriving rpc]" record obj_name record obj_name;
97+
sprintf "type %s_t_set = %s_t list [@@deriving rpc]" obj_name obj_name;
9898
""
9999
] in
100100
aux (type_t :: others @ accu) t
@@ -131,14 +131,14 @@ let gen_client_types highapi =
131131
List.iter (List.iter print)
132132
(List.between [""] [
133133
[
134-
"type failure = (string list) with rpc";
134+
"type failure = (string list) [@@deriving rpc]";
135135
"let response_of_failure code params =";
136136
" Rpc.failure (rpc_of_failure (code::params))";
137137
"let response_of_fault code =";
138138
" Rpc.failure (rpc_of_failure ([\"Fault\"; code]))";
139139
]; [
140140
"include Rpc";
141-
"type string_list = string list with rpc";
141+
"type string_list = string list [@@deriving rpc]";
142142
]; [
143143
"module Ref = struct";
144144
" include Ref";

0 commit comments

Comments
 (0)