Skip to content

Conversation

mlasson
Copy link
Member

@mlasson mlasson commented Aug 27, 2025

Description

This PR adds support for a new attribute [@js.runtime "string"] that allows bindings a js_of_ocaml pritimitive using Jsoo_runtime.Sys.external_ from ocsigen/js_of_ocaml#2086

For instance:

  val path: Ojs.t [@@js.runtime "node_path"]

expands to

  let (path : Ojs.t) = Jsoo_runtime.Sys.external_ "node_path"

I also added an extension of the existing "js.scope" attribute by adding an "@" to the parameter you can refer to a runtime primitive.

Example:

[@@@js.scope "@node_fs.promises"]
...
val unlink: string -> unit Promise.t [@@js.global]

expands to

let (unlink : string -> unit Promise.t) =
 fun (x50 : string) ->
   Promise.t_of_js Ojs.unit_of_js
     (Ojs.call
        (Ojs.get_prop_ascii (Jsoo_runtime.Sys.external_ "node_fs")
           "promises") "unlink" [|(Ojs.string_to_js x50)|])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant