UNPKG

bs-ajv

Version:

BucklesScript bindings to Ajv (Another JSON Validator)

1,392 lines (1,278 loc) 66.4 kB
'use strict'; define(["exports", "./sys.js", "./list.js", "./array.js", "./block.js", "./curry.js", "./js_exn.js", "./printf.js", "./caml_io.js", "./hashtbl.js", "./callback.js", "./caml_sys.js", "./printexc.js", "./caml_array.js", "./pervasives.js", "./caml_format.js", "./caml_string.js", "./caml_exceptions.js", "./caml_missing_polyfill.js", "./caml_builtin_exceptions.js"], function(exports, Sys, List, $$Array, Block, Curry, Js_exn, Printf, Caml_io, Hashtbl, Callback, Caml_sys, Printexc, Caml_array, Pervasives, Caml_format, Caml_string, Caml_exceptions, Caml_missing_polyfill, Caml_builtin_exceptions){ 'use strict'; var Unix_error = Caml_exceptions.create("Unix.Unix_error"); Callback.register_exception("Unix.Unix_error", [ Unix_error, /* E2BIG */0, "", "" ]); Printexc.register_printer((function (param) { if (param[0] === Unix_error) { var e = param[1]; var msg; if (typeof e === "number") { switch (e) { case 0 : msg = "E2BIG"; break; case 1 : msg = "EACCES"; break; case 2 : msg = "EAGAIN"; break; case 3 : msg = "EBADF"; break; case 4 : msg = "EBUSY"; break; case 5 : msg = "ECHILD"; break; case 6 : msg = "EDEADLK"; break; case 7 : msg = "EDOM"; break; case 8 : msg = "EEXIST"; break; case 9 : msg = "EFAULT"; break; case 10 : msg = "EFBIG"; break; case 11 : msg = "EINTR"; break; case 12 : msg = "EINVAL"; break; case 13 : msg = "EIO"; break; case 14 : msg = "EISDIR"; break; case 15 : msg = "EMFILE"; break; case 16 : msg = "EMLINK"; break; case 17 : msg = "ENAMETOOLONG"; break; case 18 : msg = "ENFILE"; break; case 19 : msg = "ENODEV"; break; case 20 : msg = "ENOENT"; break; case 21 : msg = "ENOEXEC"; break; case 22 : msg = "ENOLCK"; break; case 23 : msg = "ENOMEM"; break; case 24 : msg = "ENOSPC"; break; case 25 : msg = "ENOSYS"; break; case 26 : msg = "ENOTDIR"; break; case 27 : msg = "ENOTEMPTY"; break; case 28 : msg = "ENOTTY"; break; case 29 : msg = "ENXIO"; break; case 30 : msg = "EPERM"; break; case 31 : msg = "EPIPE"; break; case 32 : msg = "ERANGE"; break; case 33 : msg = "EROFS"; break; case 34 : msg = "ESPIPE"; break; case 35 : msg = "ESRCH"; break; case 36 : msg = "EXDEV"; break; case 37 : msg = "EWOULDBLOCK"; break; case 38 : msg = "EINPROGRESS"; break; case 39 : msg = "EALREADY"; break; case 40 : msg = "ENOTSOCK"; break; case 41 : msg = "EDESTADDRREQ"; break; case 42 : msg = "EMSGSIZE"; break; case 43 : msg = "EPROTOTYPE"; break; case 44 : msg = "ENOPROTOOPT"; break; case 45 : msg = "EPROTONOSUPPORT"; break; case 46 : msg = "ESOCKTNOSUPPORT"; break; case 47 : msg = "EOPNOTSUPP"; break; case 48 : msg = "EPFNOSUPPORT"; break; case 49 : msg = "EAFNOSUPPORT"; break; case 50 : msg = "EADDRINUSE"; break; case 51 : msg = "EADDRNOTAVAIL"; break; case 52 : msg = "ENETDOWN"; break; case 53 : msg = "ENETUNREACH"; break; case 54 : msg = "ENETRESET"; break; case 55 : msg = "ECONNABORTED"; break; case 56 : msg = "ECONNRESET"; break; case 57 : msg = "ENOBUFS"; break; case 58 : msg = "EISCONN"; break; case 59 : msg = "ENOTCONN"; break; case 60 : msg = "ESHUTDOWN"; break; case 61 : msg = "ETOOMANYREFS"; break; case 62 : msg = "ETIMEDOUT"; break; case 63 : msg = "ECONNREFUSED"; break; case 64 : msg = "EHOSTDOWN"; break; case 65 : msg = "EHOSTUNREACH"; break; case 66 : msg = "ELOOP"; break; case 67 : msg = "EOVERFLOW"; break; } } else { msg = Curry._1(Printf.sprintf(/* Format */[ /* String_literal */Block.__(11, [ "EUNKNOWNERR ", /* Int */Block.__(4, [ /* Int_d */0, /* No_padding */0, /* No_precision */0, /* End_of_format */0 ]) ]), "EUNKNOWNERR %d" ]), e[0]); } return /* Some */[Curry._3(Printf.sprintf(/* Format */[ /* String_literal */Block.__(11, [ "Unix.Unix_error(Unix.", /* String */Block.__(2, [ /* No_padding */0, /* String_literal */Block.__(11, [ ", ", /* Caml_string */Block.__(3, [ /* No_padding */0, /* String_literal */Block.__(11, [ ", ", /* Caml_string */Block.__(3, [ /* No_padding */0, /* Char_literal */Block.__(12, [ /* ")" */41, /* End_of_format */0 ]) ]) ]) ]) ]) ]) ]), "Unix.Unix_error(Unix.%s, %S, %S)" ]), msg, param[2], param[3])]; } else { return /* None */0; } })); function handle_unix_error(f, arg) { try { return Curry._1(f, arg); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Unix_error) { var arg$1 = exn[3]; Pervasives.prerr_string(Caml_array.caml_array_get(Sys.argv, 0)); Pervasives.prerr_string(": \""); Pervasives.prerr_string(exn[2]); Pervasives.prerr_string("\" failed"); if (arg$1.length) { Pervasives.prerr_string(" on \""); Pervasives.prerr_string(arg$1); Pervasives.prerr_string("\""); } Pervasives.prerr_string(": "); console.error(Caml_missing_polyfill.not_implemented("unix_error_message not implemented by bucklescript yet\n")); return Pervasives.exit(2); } else { throw exn; } } } function read(_, buf, ofs, len) { if (ofs < 0 || len < 0 || ofs > (buf.length - len | 0)) { throw [ Caml_builtin_exceptions.invalid_argument, "Unix.read" ]; } else { return Caml_missing_polyfill.not_implemented("unix_read not implemented by bucklescript yet\n"); } } function write(_, buf, ofs, len) { if (ofs < 0 || len < 0 || ofs > (buf.length - len | 0)) { throw [ Caml_builtin_exceptions.invalid_argument, "Unix.write" ]; } else { return Caml_missing_polyfill.not_implemented("unix_write not implemented by bucklescript yet\n"); } } function single_write(_, buf, ofs, len) { if (ofs < 0 || len < 0 || ofs > (buf.length - len | 0)) { throw [ Caml_builtin_exceptions.invalid_argument, "Unix.single_write" ]; } else { return Caml_missing_polyfill.not_implemented("unix_single_write not implemented by bucklescript yet\n"); } } function write_substring(fd, buf, ofs, len) { return write(fd, Caml_string.bytes_of_string(buf), ofs, len); } function single_write_substring(fd, buf, ofs, len) { return single_write(fd, Caml_string.bytes_of_string(buf), ofs, len); } function try_set_close_on_exec() { try { Caml_missing_polyfill.not_implemented("unix_set_close_on_exec not implemented by bucklescript yet\n"); return /* true */1; } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Caml_builtin_exceptions.invalid_argument) { return /* false */0; } else { throw exn; } } } function pause() { return Caml_missing_polyfill.not_implemented("unix_sigsuspend not implemented by bucklescript yet\n"); } var inet_addr_any = Caml_missing_polyfill.not_implemented("unix_inet_addr_of_string not implemented by bucklescript yet\n"); var inet_addr_loopback = Caml_missing_polyfill.not_implemented("unix_inet_addr_of_string not implemented by bucklescript yet\n"); var inet6_addr_any; try { inet6_addr_any = Caml_missing_polyfill.not_implemented("unix_inet_addr_of_string not implemented by bucklescript yet\n"); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Caml_builtin_exceptions.failure) { inet6_addr_any = inet_addr_any; } else { throw exn; } } var inet6_addr_loopback; try { inet6_addr_loopback = Caml_missing_polyfill.not_implemented("unix_inet_addr_of_string not implemented by bucklescript yet\n"); } catch (raw_exn$1){ var exn$1 = Js_exn.internalToOCamlException(raw_exn$1); if (exn$1[0] === Caml_builtin_exceptions.failure) { inet6_addr_loopback = inet_addr_loopback; } else { throw exn$1; } } function domain_of_sockaddr(param) { if (param.tag) { if (param[0].length === 16) { return /* PF_INET6 */2; } else { return /* PF_INET */1; } } else { return /* PF_UNIX */0; } } function recv(_, buf, ofs, len, _$1) { if (ofs < 0 || len < 0 || ofs > (buf.length - len | 0)) { throw [ Caml_builtin_exceptions.invalid_argument, "Unix.recv" ]; } else { return Caml_missing_polyfill.not_implemented("unix_recv not implemented by bucklescript yet\n"); } } function recvfrom(_, buf, ofs, len, _$1) { if (ofs < 0 || len < 0 || ofs > (buf.length - len | 0)) { throw [ Caml_builtin_exceptions.invalid_argument, "Unix.recvfrom" ]; } else { return Caml_missing_polyfill.not_implemented("unix_recvfrom not implemented by bucklescript yet\n"); } } function send(_, buf, ofs, len, _$1) { if (ofs < 0 || len < 0 || ofs > (buf.length - len | 0)) { throw [ Caml_builtin_exceptions.invalid_argument, "Unix.send" ]; } else { return Caml_missing_polyfill.not_implemented("unix_send not implemented by bucklescript yet\n"); } } function sendto(_, buf, ofs, len, _$1, _$2) { if (ofs < 0 || len < 0 || ofs > (buf.length - len | 0)) { throw [ Caml_builtin_exceptions.invalid_argument, "Unix.sendto" ]; } else { return Caml_missing_polyfill.not_implemented("unix_sendto not implemented by bucklescript yet\n"); } } function send_substring(fd, buf, ofs, len, flags) { return send(fd, Caml_string.bytes_of_string(buf), ofs, len, flags); } function sendto_substring(fd, buf, ofs, len, flags, addr) { return sendto(fd, Caml_string.bytes_of_string(buf), ofs, len, flags, addr); } function SO_005(_, _$1, _$2) { return Caml_missing_polyfill.not_implemented("unix_getsockopt not implemented by bucklescript yet\n"); } function SO_006(_, _$1, _$2, _$3) { return Caml_missing_polyfill.not_implemented("unix_setsockopt not implemented by bucklescript yet\n"); } function getsockopt(fd, opt) { return Curry._3(SO_005, 0, fd, opt); } function setsockopt(fd, opt, v) { return Curry._4(SO_006, 0, fd, opt, v); } function getsockopt_int(fd, opt) { return Curry._3(SO_005, 1, fd, opt); } function setsockopt_int(fd, opt, v) { return Curry._4(SO_006, 1, fd, opt, v); } function getsockopt_optint(fd, opt) { return Curry._3(SO_005, 2, fd, opt); } function setsockopt_optint(fd, opt, v) { return Curry._4(SO_006, 2, fd, opt, v); } function getsockopt_float(fd, opt) { return Curry._3(SO_005, 3, fd, opt); } function setsockopt_float(fd, opt, v) { return Curry._4(SO_006, 3, fd, opt, v); } function getsockopt_error(fd) { return Curry._3(SO_005, 4, fd, /* SO_ERROR */0); } function getaddrinfo(node, service, opts) { try { return List.rev(Caml_missing_polyfill.not_implemented("unix_getaddrinfo not implemented by bucklescript yet\n")); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Caml_builtin_exceptions.invalid_argument) { var node$1 = node; var service$1 = service; var opts$1 = opts; var opt_socktype = [/* None */0]; var opt_protocol = [0]; var opt_passive = [/* false */0]; List.iter((function (param) { if (typeof param === "number") { if (param === 2) { opt_passive[0] = /* true */1; return /* () */0; } else { return /* () */0; } } else { switch (param.tag | 0) { case 1 : opt_socktype[0] = /* Some */[param[0]]; return /* () */0; case 2 : opt_protocol[0] = param[0]; return /* () */0; default: return /* () */0; } } }), opts$1); var get_port = function (ty, _) { if (service$1 === "") { return /* :: */[ /* tuple */[ ty, 0 ], /* [] */0 ]; } else { try { return /* :: */[ /* tuple */[ ty, Caml_format.caml_int_of_string(service$1) ], /* [] */0 ]; } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Caml_builtin_exceptions.failure) { try { return /* :: */[ /* tuple */[ ty, Caml_missing_polyfill.not_implemented("unix_getservbyname not implemented by bucklescript yet\n")[/* s_port */2] ], /* [] */0 ]; } catch (exn$1){ if (exn$1 === Caml_builtin_exceptions.not_found) { return /* [] */0; } else { throw exn$1; } } } else { throw exn; } } } }; var match = opt_socktype[0]; var ports; if (match) { var ty = match[0]; ports = ty !== 1 ? ( ty !== 0 ? ( service$1 === "" ? /* :: */[ /* tuple */[ ty, 0 ], /* [] */0 ] : /* [] */0 ) : get_port(/* SOCK_STREAM */0, "tcp") ) : get_port(/* SOCK_DGRAM */1, "udp"); } else { ports = Pervasives.$at(get_port(/* SOCK_STREAM */0, "tcp"), get_port(/* SOCK_DGRAM */1, "udp")); } var addresses; if (node$1 === "") { addresses = List.mem(/* AI_PASSIVE */2, opts$1) ? /* :: */[ /* tuple */[ inet_addr_any, "0.0.0.0" ], /* [] */0 ] : /* :: */[ /* tuple */[ inet_addr_loopback, "127.0.0.1" ], /* [] */0 ]; } else { try { addresses = /* :: */[ /* tuple */[ Caml_missing_polyfill.not_implemented("unix_inet_addr_of_string not implemented by bucklescript yet\n"), node$1 ], /* [] */0 ]; } catch (raw_exn$1){ var exn$1 = Js_exn.internalToOCamlException(raw_exn$1); if (exn$1[0] === Caml_builtin_exceptions.failure) { try { var he = Caml_missing_polyfill.not_implemented("unix_gethostbyname not implemented by bucklescript yet\n"); addresses = List.map((function (a) { return /* tuple */[ a, he[/* h_name */0] ]; }), $$Array.to_list(he[/* h_addr_list */3])); } catch (exn$2){ if (exn$2 === Caml_builtin_exceptions.not_found) { addresses = /* [] */0; } else { throw exn$2; } } } else { throw exn$1; } } } return List.flatten(List.map((function (param) { var port = param[1]; var ty = param[0]; return List.map((function (param) { return /* record */[ /* ai_family : PF_INET */1, /* ai_socktype */ty, /* ai_protocol */opt_protocol[0], /* ai_addr : ADDR_INET */Block.__(1, [ param[0], port ]), /* ai_canonname */param[1] ]; }), addresses); }), ports)); } else { throw exn; } } } function getnameinfo(addr, opts) { try { return Caml_missing_polyfill.not_implemented("unix_getnameinfo not implemented by bucklescript yet\n"); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Caml_builtin_exceptions.invalid_argument) { var addr$1 = addr; var opts$1 = opts; if (addr$1.tag) { var p = addr$1[1]; var hostname; try { if (List.mem(/* NI_NUMERICHOST */1, opts$1)) { throw Caml_builtin_exceptions.not_found; } hostname = Caml_missing_polyfill.not_implemented("unix_gethostbyaddr not implemented by bucklescript yet\n")[/* h_name */0]; } catch (exn$1){ if (exn$1 === Caml_builtin_exceptions.not_found) { if (List.mem(/* NI_NAMEREQD */2, opts$1)) { throw Caml_builtin_exceptions.not_found; } hostname = Caml_missing_polyfill.not_implemented("unix_string_of_inet_addr not implemented by bucklescript yet\n"); } else { throw exn$1; } } var service; try { if (List.mem(/* NI_NUMERICSERV */3, opts$1)) { throw Caml_builtin_exceptions.not_found; } List.mem(/* NI_DGRAM */4, opts$1) ? "udp" : "tcp"; service = Caml_missing_polyfill.not_implemented("unix_getservbyport not implemented by bucklescript yet\n")[/* s_name */0]; } catch (exn$2){ if (exn$2 === Caml_builtin_exceptions.not_found) { service = String(p); } else { throw exn$2; } } return /* record */[ /* ni_hostname */hostname, /* ni_service */service ]; } else { return /* record */[ /* ni_hostname */"", /* ni_service */addr$1[0] ]; } } else { throw exn; } } } function waitpid_non_intr() { while(true) { try { return Caml_missing_polyfill.not_implemented("unix_waitpid not implemented by bucklescript yet\n"); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Unix_error) { var match = exn[1]; if (typeof match === "number") { if (match !== 11) { throw exn; } else { continue ; } } else { throw exn; } } else { throw exn; } } }; } function system() { var id = Caml_missing_polyfill.not_implemented("unix_fork not implemented by bucklescript yet\n"); if (id !== 0) { return waitpid_non_intr(id)[1]; } else { try { return Caml_missing_polyfill.not_implemented("unix_execv not implemented by bucklescript yet\n"); } catch (exn){ return Pervasives.exit(127); } } } function safe_dup(fd) { var new_fd = Caml_missing_polyfill.not_implemented("unix_dup not implemented by bucklescript yet\n"); if (new_fd >= 3) { return new_fd; } else { var res = safe_dup(fd); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); return res; } } function safe_close() { try { return Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Unix_error) { return /* () */0; } else { throw exn; } } } function perform_redirections(new_stdin, new_stdout, new_stderr) { safe_dup(new_stdin); safe_dup(new_stdout); safe_dup(new_stderr); safe_close(new_stdin); safe_close(new_stdout); safe_close(new_stderr); Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); return Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); } function create_process(_, _$1, new_stdin, new_stdout, new_stderr) { var id = Caml_missing_polyfill.not_implemented("unix_fork not implemented by bucklescript yet\n"); if (id !== 0) { return id; } else { try { perform_redirections(new_stdin, new_stdout, new_stderr); return Caml_missing_polyfill.not_implemented("unix_execvp not implemented by bucklescript yet\n"); } catch (exn){ return Pervasives.exit(127); } } } function create_process_env(_, _$1, _$2, new_stdin, new_stdout, new_stderr) { var id = Caml_missing_polyfill.not_implemented("unix_fork not implemented by bucklescript yet\n"); if (id !== 0) { return id; } else { try { perform_redirections(new_stdin, new_stdout, new_stderr); return Caml_missing_polyfill.not_implemented("unix_execvpe not implemented by bucklescript yet\n"); } catch (exn){ return Pervasives.exit(127); } } } var popen_processes = Hashtbl.create(/* None */0, 7); function open_proc(_, proc, input, output, toclose) { var cloexec = List.for_all(try_set_close_on_exec, toclose); var id = Caml_missing_polyfill.not_implemented("unix_fork not implemented by bucklescript yet\n"); if (id !== 0) { return Hashtbl.add(popen_processes, proc, id); } else { if (input !== 0) { Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); } if (output !== 1) { Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); } if (!cloexec) { List.iter((function () { return Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); }), toclose); } try { return Caml_missing_polyfill.not_implemented("unix_execv not implemented by bucklescript yet\n"); } catch (exn){ return Pervasives.exit(127); } } } function open_process_in(cmd) { var match = Caml_missing_polyfill.not_implemented("unix_pipe not implemented by bucklescript yet\n"); var in_write = match[1]; var in_read = match[0]; var inchan = Caml_io.caml_ml_open_descriptor_in(in_read); try { open_proc(cmd, /* Process_in */Block.__(1, [inchan]), 0, in_write, /* :: */[ in_read, /* [] */0 ]); } catch (e){ Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); throw e; } Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); return inchan; } function open_process_out(cmd) { var match = Caml_missing_polyfill.not_implemented("unix_pipe not implemented by bucklescript yet\n"); var out_write = match[1]; var out_read = match[0]; var outchan = Caml_io.caml_ml_open_descriptor_out(out_write); try { open_proc(cmd, /* Process_out */Block.__(2, [outchan]), out_read, 1, /* :: */[ out_write, /* [] */0 ]); } catch (e){ Caml_io.caml_ml_flush(outchan); Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); throw e; } Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); return outchan; } function open_process(cmd) { var match = Caml_missing_polyfill.not_implemented("unix_pipe not implemented by bucklescript yet\n"); var in_write = match[1]; var in_read = match[0]; var fds_to_close = /* :: */[ in_read, /* :: */[ in_write, /* [] */0 ] ]; try { var match$1 = Caml_missing_polyfill.not_implemented("unix_pipe not implemented by bucklescript yet\n"); var out_write = match$1[1]; var out_read = match$1[0]; fds_to_close = /* :: */[ in_read, /* :: */[ in_write, /* :: */[ out_read, /* :: */[ out_write, /* [] */0 ] ] ] ]; var inchan = Caml_io.caml_ml_open_descriptor_in(in_read); var outchan = Caml_io.caml_ml_open_descriptor_out(out_write); open_proc(cmd, /* Process */Block.__(0, [ inchan, outchan ]), out_read, in_write, /* :: */[ in_read, /* :: */[ out_write, /* [] */0 ] ]); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); return /* tuple */[ inchan, outchan ]; } catch (e){ List.iter((function () { return Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); }), fds_to_close); throw e; } } function open_proc_full(_, _$1, proc, _$2, _$3, _$4, toclose) { var cloexec = List.for_all(try_set_close_on_exec, toclose); var id = Caml_missing_polyfill.not_implemented("unix_fork not implemented by bucklescript yet\n"); if (id !== 0) { return Hashtbl.add(popen_processes, proc, id); } else { Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); if (!cloexec) { List.iter((function () { return Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); }), toclose); } try { return Caml_missing_polyfill.not_implemented("unix_execve not implemented by bucklescript yet\n"); } catch (exn){ return Pervasives.exit(127); } } } function open_process_full(cmd, env) { var match = Caml_missing_polyfill.not_implemented("unix_pipe not implemented by bucklescript yet\n"); var in_write = match[1]; var in_read = match[0]; var fds_to_close = /* :: */[ in_read, /* :: */[ in_write, /* [] */0 ] ]; try { var match$1 = Caml_missing_polyfill.not_implemented("unix_pipe not implemented by bucklescript yet\n"); var out_write = match$1[1]; var out_read = match$1[0]; fds_to_close = /* :: */[ out_read, /* :: */[ out_write, fds_to_close ] ]; var match$2 = Caml_missing_polyfill.not_implemented("unix_pipe not implemented by bucklescript yet\n"); var err_write = match$2[1]; var err_read = match$2[0]; fds_to_close = /* :: */[ err_read, /* :: */[ err_write, fds_to_close ] ]; var inchan = Caml_io.caml_ml_open_descriptor_in(in_read); var outchan = Caml_io.caml_ml_open_descriptor_out(out_write); var errchan = Caml_io.caml_ml_open_descriptor_in(err_read); open_proc_full(cmd, env, /* Process_full */Block.__(3, [ inchan, outchan, errchan ]), out_read, in_write, err_write, /* :: */[ in_read, /* :: */[ out_write, /* :: */[ err_read, /* [] */0 ] ] ]); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); return /* tuple */[ inchan, outchan, errchan ]; } catch (e){ List.iter((function () { return Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); }), fds_to_close); throw e; } } function find_proc_id(fun_name, proc) { try { var pid = Hashtbl.find(popen_processes, proc); Hashtbl.remove(popen_processes, proc); return pid; } catch (exn){ if (exn === Caml_builtin_exceptions.not_found) { throw [ Unix_error, /* EBADF */3, fun_name, "" ]; } else { throw exn; } } } function close_process_in(inchan) { var pid = find_proc_id("close_process_in", /* Process_in */Block.__(1, [inchan])); Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); return waitpid_non_intr(pid)[1]; } function close_process_out(outchan) { var pid = find_proc_id("close_process_out", /* Process_out */Block.__(2, [outchan])); Caml_io.caml_ml_flush(outchan); Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); return waitpid_non_intr(pid)[1]; } function close_process(param) { var outchan = param[1]; var inchan = param[0]; var pid = find_proc_id("close_process", /* Process */Block.__(0, [ inchan, outchan ])); Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); try { Caml_io.caml_ml_flush(outchan); Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] !== Caml_builtin_exceptions.sys_error) { throw exn; } } return waitpid_non_intr(pid)[1]; } function close_process_full(param) { var errchan = param[2]; var outchan = param[1]; var inchan = param[0]; var pid = find_proc_id("close_process_full", /* Process_full */Block.__(3, [ inchan, outchan, errchan ])); Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); try { Caml_io.caml_ml_flush(outchan); Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] !== Caml_builtin_exceptions.sys_error) { throw exn; } } Caml_missing_polyfill.not_implemented("caml_ml_close_channel not implemented by bucklescript yet\n"); return waitpid_non_intr(pid)[1]; } function open_connection() { var sock = Caml_missing_polyfill.not_implemented("unix_socket not implemented by bucklescript yet\n"); try { Caml_missing_polyfill.not_implemented("unix_connect not implemented by bucklescript yet\n"); try_set_close_on_exec(sock); return /* tuple */[ Caml_io.caml_ml_open_descriptor_in(sock), Caml_io.caml_ml_open_descriptor_out(sock) ]; } catch (exn){ Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); throw exn; } } function shutdown_connection() { return Caml_missing_polyfill.not_implemented("unix_shutdown not implemented by bucklescript yet\n"); } function accept_non_intr() { while(true) { try { return Caml_missing_polyfill.not_implemented("unix_accept not implemented by bucklescript yet\n"); } catch (raw_exn){ var exn = Js_exn.internalToOCamlException(raw_exn); if (exn[0] === Unix_error) { var match = exn[1]; if (typeof match === "number") { if (match !== 11) { throw exn; } else { continue ; } } else { throw exn; } } else { throw exn; } } }; } function establish_server(server_fun, _) { var sock = Caml_missing_polyfill.not_implemented("unix_socket not implemented by bucklescript yet\n"); setsockopt(sock, /* SO_REUSEADDR */2, /* true */1); Caml_missing_polyfill.not_implemented("unix_bind not implemented by bucklescript yet\n"); Caml_missing_polyfill.not_implemented("unix_listen not implemented by bucklescript yet\n"); while(true) { var match = accept_non_intr(sock); var s = match[0]; var id = Caml_missing_polyfill.not_implemented("unix_fork not implemented by bucklescript yet\n"); if (id !== 0) { Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); waitpid_non_intr(id); } else { if (Caml_missing_polyfill.not_implemented("unix_fork not implemented by bucklescript yet\n") !== 0) { Pervasives.exit(0); } Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); try_set_close_on_exec(s); var inchan = Caml_io.caml_ml_open_descriptor_in(s); var outchan = Caml_io.caml_ml_open_descriptor_out(s); Curry._2(server_fun, inchan, outchan); Pervasives.exit(0); } }; return /* () */0; } function error_message() { return Caml_missing_polyfill.not_implemented("unix_error_message not implemented by bucklescript yet\n"); } function environment() { return Caml_missing_polyfill.not_implemented("unix_environment not implemented by bucklescript yet\n"); } var getenv = Caml_sys.caml_sys_getenv; function putenv(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_putenv not implemented by bucklescript yet\n"); } function execv(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_execv not implemented by bucklescript yet\n"); } function execve(_, _$1, _$2) { return Caml_missing_polyfill.not_implemented("unix_execve not implemented by bucklescript yet\n"); } function execvp(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_execvp not implemented by bucklescript yet\n"); } function execvpe(_, _$1, _$2) { return Caml_missing_polyfill.not_implemented("unix_execvpe not implemented by bucklescript yet\n"); } function fork() { return Caml_missing_polyfill.not_implemented("unix_fork not implemented by bucklescript yet\n"); } function wait() { return Caml_missing_polyfill.not_implemented("unix_wait not implemented by bucklescript yet\n"); } function waitpid(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_waitpid not implemented by bucklescript yet\n"); } function getpid() { return Caml_missing_polyfill.not_implemented("unix_getpid not implemented by bucklescript yet\n"); } function getppid() { return Caml_missing_polyfill.not_implemented("unix_getppid not implemented by bucklescript yet\n"); } function nice() { return Caml_missing_polyfill.not_implemented("unix_nice not implemented by bucklescript yet\n"); } var stdin = 0; var stdout = 1; var stderr = 2; function openfile(_, _$1, _$2) { return Caml_missing_polyfill.not_implemented("unix_open not implemented by bucklescript yet\n"); } function close() { return Caml_missing_polyfill.not_implemented("unix_close not implemented by bucklescript yet\n"); } var in_channel_of_descr = Caml_io.caml_ml_open_descriptor_in; var out_channel_of_descr = Caml_io.caml_ml_open_descriptor_out; function descr_of_in_channel() { return Caml_missing_polyfill.not_implemented("caml_channel_descriptor not implemented by bucklescript yet\n"); } function descr_of_out_channel() { return Caml_missing_polyfill.not_implemented("caml_channel_descriptor not implemented by bucklescript yet\n"); } function lseek(_, _$1, _$2) { return Caml_missing_polyfill.not_implemented("unix_lseek not implemented by bucklescript yet\n"); } function truncate(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_truncate not implemented by bucklescript yet\n"); } function ftruncate(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_ftruncate not implemented by bucklescript yet\n"); } function stat() { return Caml_missing_polyfill.not_implemented("unix_stat not implemented by bucklescript yet\n"); } function lstat() { return Caml_missing_polyfill.not_implemented("unix_lstat not implemented by bucklescript yet\n"); } function fstat() { return Caml_missing_polyfill.not_implemented("unix_fstat not implemented by bucklescript yet\n"); } function isatty() { return Caml_missing_polyfill.not_implemented("unix_isatty not implemented by bucklescript yet\n"); } function LargeFile_000(_, _$1, _$2) { return Caml_missing_polyfill.not_implemented("unix_lseek_64 not implemented by bucklescript yet\n"); } function LargeFile_001(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_truncate_64 not implemented by bucklescript yet\n"); } function LargeFile_002(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_ftruncate_64 not implemented by bucklescript yet\n"); } function LargeFile_003() { return Caml_missing_polyfill.not_implemented("unix_stat_64 not implemented by bucklescript yet\n"); } function LargeFile_004() { return Caml_missing_polyfill.not_implemented("unix_lstat_64 not implemented by bucklescript yet\n"); } function LargeFile_005() { return Caml_missing_polyfill.not_implemented("unix_fstat_64 not implemented by bucklescript yet\n"); } var LargeFile = [ LargeFile_000, LargeFile_001, LargeFile_002, LargeFile_003, LargeFile_004, LargeFile_005 ]; function unlink() { return Caml_missing_polyfill.not_implemented("unix_unlink not implemented by bucklescript yet\n"); } function rename(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_rename not implemented by bucklescript yet\n"); } function link(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_link not implemented by bucklescript yet\n"); } function chmod(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_chmod not implemented by bucklescript yet\n"); } function fchmod(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_fchmod not implemented by bucklescript yet\n"); } function chown(_, _$1, _$2) { return Caml_missing_polyfill.not_implemented("unix_chown not implemented by bucklescript yet\n"); } function fchown(_, _$1, _$2) { return Caml_missing_polyfill.not_implemented("unix_fchown not implemented by bucklescript yet\n"); } function umask() { return Caml_missing_polyfill.not_implemented("unix_umask not implemented by bucklescript yet\n"); } function access(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_access not implemented by bucklescript yet\n"); } function dup() { return Caml_missing_polyfill.not_implemented("unix_dup not implemented by bucklescript yet\n"); } function dup2(_, _$1) { return Caml_missing_polyfill.not_implemented("unix_dup2 not implemented by bucklescript yet\n"); } function set_nonblock() { return Caml_missing_polyfill.not_implemented("unix_set_nonblock not implemented by bucklescript yet\n"); } function clear_nonblock(