Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Apr 15, 2024
1 parent 6ab4f90 commit 47d300a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/runtime/js_of_ocaml_runtime_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ void caml_list_to_js_array () {
caml_fatal_error("Unimplemented Javascript primitive caml_list_to_js_array!");
}

void caml_ml_channel_redirect () {
caml_fatal_error("Unimplemented Javascript primitive caml_ml_channel_redirect!");
}

void caml_ml_channel_restore () {
caml_fatal_error("Unimplemented Javascript primitive caml_ml_channel_restore!");
}

void caml_ml_set_channel_output () {
caml_fatal_error("Unimplemented Javascript primitive caml_ml_set_channel_output!");
}
Expand Down
8 changes: 8 additions & 0 deletions lib/runtime/jsoo_runtime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ module Sys = struct

external unmount : string -> unit = "caml_unmount"

type redirection

external redirect_channel : out_channel -> into:out_channel -> redirection
= "caml_ml_channel_redirect"

external restore_channel : out_channel -> redirection -> unit
= "caml_ml_channel_restore"

module Config = struct
external use_js_string : unit -> bool = "caml_jsoo_flags_use_js_string"

Expand Down
22 changes: 22 additions & 0 deletions runtime/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@ caml_ml_channels_state.prototype.all = function () {

var caml_ml_channels = new caml_ml_channels_state;

//Provides: caml_ml_channel_redirect
//Requires: caml_ml_channels
function caml_ml_channel_redirect (captured, into){
var to_restore = caml_ml_channels.get(captured);
var new_ = caml_ml_channels.get(into);
caml_ml_channels.set(captured, new_);
return to_restore;
}

//Provides: caml_ml_channel_restore
//Requires: caml_ml_channels
function caml_ml_channel_restore (captured, to_restore){
caml_ml_channels.set(captured, to_restore);
return 0;
}

//Provides: caml_ml_channel_get
//Requires: caml_ml_channels
function caml_ml_channel_get(id) {
return caml_ml_channels.get(id);
}

//Provides: caml_ml_out_channels_list
//Requires: caml_ml_channels
//Requires: caml_sys_fds
Expand Down

0 comments on commit 47d300a

Please sign in to comment.