Skip to content

Commit 47d300a

Browse files
committed
WIP
1 parent 6ab4f90 commit 47d300a

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

lib/runtime/js_of_ocaml_runtime_stubs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ void caml_list_to_js_array () {
220220
caml_fatal_error("Unimplemented Javascript primitive caml_list_to_js_array!");
221221
}
222222

223+
void caml_ml_channel_redirect () {
224+
caml_fatal_error("Unimplemented Javascript primitive caml_ml_channel_redirect!");
225+
}
226+
227+
void caml_ml_channel_restore () {
228+
caml_fatal_error("Unimplemented Javascript primitive caml_ml_channel_restore!");
229+
}
230+
223231
void caml_ml_set_channel_output () {
224232
caml_fatal_error("Unimplemented Javascript primitive caml_ml_set_channel_output!");
225233
}

lib/runtime/jsoo_runtime.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ module Sys = struct
116116

117117
external unmount : string -> unit = "caml_unmount"
118118

119+
type redirection
120+
121+
external redirect_channel : out_channel -> into:out_channel -> redirection
122+
= "caml_ml_channel_redirect"
123+
124+
external restore_channel : out_channel -> redirection -> unit
125+
= "caml_ml_channel_restore"
126+
119127
module Config = struct
120128
external use_js_string : unit -> bool = "caml_jsoo_flags_use_js_string"
121129

runtime/io.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,28 @@ caml_ml_channels_state.prototype.all = function () {
129129

130130
var caml_ml_channels = new caml_ml_channels_state;
131131

132+
//Provides: caml_ml_channel_redirect
133+
//Requires: caml_ml_channels
134+
function caml_ml_channel_redirect (captured, into){
135+
var to_restore = caml_ml_channels.get(captured);
136+
var new_ = caml_ml_channels.get(into);
137+
caml_ml_channels.set(captured, new_);
138+
return to_restore;
139+
}
140+
141+
//Provides: caml_ml_channel_restore
142+
//Requires: caml_ml_channels
143+
function caml_ml_channel_restore (captured, to_restore){
144+
caml_ml_channels.set(captured, to_restore);
145+
return 0;
146+
}
147+
148+
//Provides: caml_ml_channel_get
149+
//Requires: caml_ml_channels
150+
function caml_ml_channel_get(id) {
151+
return caml_ml_channels.get(id);
152+
}
153+
132154
//Provides: caml_ml_out_channels_list
133155
//Requires: caml_ml_channels
134156
//Requires: caml_sys_fds

0 commit comments

Comments
 (0)