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

Wrap functions supplied to Ojs.iter_properties #170

Merged
merged 1 commit into from
Mar 10, 2023
Merged
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
5 changes: 4 additions & 1 deletion lib/ojs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ external new_obj_arr: t -> t -> t = "caml_ojs_new_arr"

let empty_obj () = new_obj (get_prop_ascii global "Object") [||]

external iter_properties: t -> (string -> unit) -> unit = "caml_ojs_iterate_properties"
external iter_properties_untyped : t -> t -> unit = "caml_ojs_iterate_properties"
let iter_properties x f =
iter_properties_untyped x (fun_to_js 1 (fun x -> f (string_of_js x)))

let apply_arr o arr = call o "apply" [| null; arr |]
let call_arr o s arr = call (get_prop o (string_to_js s)) "apply" [| o; arr |]

Expand Down
2 changes: 1 addition & 1 deletion lib/ojs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ external obj: (string * t) array -> t = "caml_js_object"
val empty_obj: unit -> t

val has_property: t -> string -> bool
external iter_properties: t -> (string -> unit) -> unit = "caml_ojs_iterate_properties"
val iter_properties: t -> (string -> unit) -> unit

(** {2 Calling JS functions} *)

Expand Down
2 changes: 1 addition & 1 deletion lib/ojs_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function caml_ojs_iterate_properties(o, f) {
var name;
for(name in o) {
if(o.hasOwnProperty(name)) {
f(caml_js_to_string(name));
f(name);
}
}
}