Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ppx_yojson_conv with ppx_deriving_yojson #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
lwt
lwt_ppx
yojson
ppx_yojson_conv ; TODO: switch to ppx_deriving_yojson like Goblint itself
ppx_deriving_yojson
conduit-lwt-unix
jsoo-react
js_of_ocaml-lwt
Expand Down
20 changes: 8 additions & 12 deletions goblint-http-server/api.ml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
open Batteries
open State
open Ppx_yojson_conv_lib.Yojson_conv.Primitives

module type Request = sig
val name: string

type body
type response

val body_of_yojson: Yojson.Safe.t -> body
val yojson_of_response: response -> Yojson.Safe.t
type body [@@deriving of_yojson]
type response [@@deriving to_yojson]

val process: State.t -> body -> response Lwt.t
end
Expand All @@ -20,22 +16,22 @@ let register (module R : Request) = Hashtbl.add registry R.name (module R : Requ

module Ping = struct
let name = "ping"
type body = unit [@@deriving yojson]
type response = unit [@@deriving yojson]
type body = unit [@@deriving of_yojson]
type response = unit [@@deriving to_yojson]
let process state () = Goblint.ping state.goblint
end

module Config = struct
let name = "config"
type body = string * Json.t [@@deriving yojson]
type response = unit [@@deriving yojson]
type body = string * Yojson.Safe.t [@@deriving of_yojson]
type response = unit [@@deriving to_yojson]
let process state (conf, json) = Goblint.config state.goblint conf json
end

module Analyze = struct
let name = "analyze"
type body = [`All | `Functions of string list] option [@@deriving yojson]
type response = unit [@@deriving yojson]
type body = [`All | `Functions of string list] option [@@deriving of_yojson]
type response = unit [@@deriving to_yojson]
let process state reanalyze =
let%lwt save_run = Goblint.analyze state.goblint ?reanalyze in
state.save_run <- Some save_run;
Expand Down
2 changes: 1 addition & 1 deletion goblint-http-server/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
yojson
uri)
(preprocess
(pps lwt_ppx ppx_yojson_conv)))
(pps lwt_ppx ppx_deriving_yojson)))
10 changes: 4 additions & 6 deletions goblint-http-server/goblint_http.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ open Cohttp_lwt
open Cohttp_lwt_unix
open Lwt.Infix

module Yojson_conv = Ppx_yojson_conv_lib.Yojson_conv

let docroot = ref "run"
let distroot = ref "gobview/_dist"
let index = ref "index.html"
Expand Down Expand Up @@ -35,13 +33,13 @@ let process state name body =
| exception Yojson.Json_error err -> Server.respond_error ~status:`Bad_request ~body:err ()
| json ->
match R.body_of_yojson json with
| exception Yojson_conv.Of_yojson_error (exn, _) ->
Server.respond_error ~status:`Bad_request ~body:(Printexc.to_string exn) ()
| body ->
| Error msg ->
Server.respond_error ~status:`Bad_request ~body:msg ()
| Ok body ->
Lwt.catch
(fun () ->
R.process state body
>|= R.yojson_of_response
>|= R.response_to_yojson
>|= Yojson.Safe.to_string
>>= fun body -> Server.respond_string ~status:`OK ~body ())
(fun exn -> Server.respond_error ~status:`Bad_request ~body:(Printexc.to_string exn) ())
Expand Down
4 changes: 0 additions & 4 deletions goblint-http-server/json.ml

This file was deleted.

2 changes: 1 addition & 1 deletion gobview.opam
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ depends: [
"lwt"
"lwt_ppx"
"yojson"
"ppx_yojson_conv"
"ppx_deriving_yojson"
"conduit-lwt-unix"
"jsoo-react"
"js_of_ocaml-lwt"
Expand Down
4 changes: 0 additions & 4 deletions gobview.opam.locked
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ depends: [
"ocamlbuild" {= "0.14.3"}
"ocamlfind" {= "1.9.6"}
"ocplib-endian" {= "1.2"}
"octavius" {= "1.2.2"}
"odoc" {= "2.4.2" & with-doc}
"odoc-parser" {= "2.4.2" & with-doc}
"ojs" {= "1.1.2"}
Expand All @@ -103,10 +102,7 @@ depends: [
"ppx_derivers" {= "1.2.1"}
"ppx_deriving" {= "6.0.2"}
"ppx_deriving_yojson" {= "3.8.0"}
"ppx_js_style" {= "v0.16.0"}
"ppx_sexp_conv" {= "v0.16.0"}
"ppx_yojson_conv" {= "v0.16.0"}
"ppx_yojson_conv_lib" {= "v0.16.0"}
"ppxlib" {= "0.32.1"}
"ptime" {= "1.1.0"}
"re" {= "1.11.0"}
Expand Down