You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
module Identity = struct
class type _accountInfo = object
method id : string
end [@bs]
type accountInfo = _accountInfo Js.t
external mkAccountInfo : ?id:string -> unit -> accountInfo = "" [@@bs.obj]
class type _getAuthTokenDetails = object
method interactive : Js.boolean
method account : accountInfo
method scopes : string list
end [@bs]
type getAuthTokenDetails = _getAuthTokenDetails Js.t
external mkGetAuthTokenDetails : ?interactive:Js.boolean -> ?account:accountInfo -> ?scopes:string list -> unit -> getAuthTokenDetails = "" [@@bs.obj]
external getAuthToken : getAuthTokenDetails -> (string -> 'a) -> unit = "getAuthToken" [@@bs.scope "chrome", "identity"] [@@bs.val]
end
So you save some time writing all that boiler place.
Essentially the AST is simple, there are 3 types of chrome level exports, module, type, method; and there are 4 constructors to represent types (object, boolean, string, function/callback).
Right now the codegen is appending strings together (because this is hacked together, and also when I did some research on ocaml code generation projects one example i found used string concatenation). I was thinking it would be nice if we could directly generate OCaml AST, but this was easier to get up and running :)
I uploaded the code generation script on my fork of master, so if you'ld like, you can invoke it like so: ocamlc script.ml && ./a.out. I have an simple example module defined in the script itself just as a test.
Posting this here to see if there is any interest, I think with the script we can generate more 80% of the bindings to Chrome quite easily.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi! I had an idea of generating bindings automatically:
I wrote some code to do something like 2. pretty easily, you declare the bindings like so.
Which generates
So you save some time writing all that boiler place.
Essentially the AST is simple, there are 3 types of chrome level exports, module, type, method; and there are 4 constructors to represent types (object, boolean, string, function/callback).
Right now the codegen is appending strings together (because this is hacked together, and also when I did some research on ocaml code generation projects one example i found used string concatenation). I was thinking it would be nice if we could directly generate OCaml AST, but this was easier to get up and running :)
I uploaded the code generation script on my fork of master, so if you'ld like, you can invoke it like so:
ocamlc script.ml && ./a.out
. I have an simple example module defined in the script itself just as a test.Posting this here to see if there is any interest, I think with the script we can generate more 80% of the bindings to Chrome quite easily.
The text was updated successfully, but these errors were encountered: