-
Notifications
You must be signed in to change notification settings - Fork 464
/
Copy pathmarshal.js
89 lines (79 loc) · 2.25 KB
/
marshal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
var Caml_string = require("./caml_string");
var Caml_builtin_exceptions = require("./caml_builtin_exceptions");
function to_buffer(buff, ofs, len, _, _$1) {
if (ofs < 0 || len < 0 || ofs > (buff.length - len | 0)) {
throw [
Caml_builtin_exceptions.invalid_argument,
"Marshal.to_buffer: substring out of bounds"
];
}
else {
return function () {
throw "caml_output_value_to_buffer not implemented by bucklescript yet\n";
}();
}
}
function data_size(buff, ofs) {
if (ofs < 0 || ofs > (buff.length - 20 | 0)) {
throw [
Caml_builtin_exceptions.invalid_argument,
"Marshal.data_size"
];
}
else {
return function () {
throw "caml_marshal_data_size not implemented by bucklescript yet\n";
}();
}
}
function total_size(buff, ofs) {
return 20 + data_size(buff, ofs) | 0;
}
function from_bytes(buff, ofs) {
if (ofs < 0 || ofs > (buff.length - 20 | 0)) {
throw [
Caml_builtin_exceptions.invalid_argument,
"Marshal.from_bytes"
];
}
else {
var len = function () {
throw "caml_marshal_data_size not implemented by bucklescript yet\n";
}();
if (ofs > (buff.length - (20 + len | 0) | 0)) {
throw [
Caml_builtin_exceptions.invalid_argument,
"Marshal.from_bytes"
];
}
else {
return function () {
throw "caml_input_value_from_string not implemented by bucklescript yet\n";
}();
}
}
}
function from_string(buff, ofs) {
return from_bytes(Caml_string.bytes_of_string(buff), ofs);
}
function to_channel(_, _$1, _$2) {
return function () {
throw "caml_output_value not implemented by bucklescript yet\n";
}();
}
function from_channel() {
return function () {
throw "caml_input_value not implemented by bucklescript yet\n";
}();
}
var header_size = 20;
exports.to_channel = to_channel;
exports.to_buffer = to_buffer;
exports.from_channel = from_channel;
exports.from_bytes = from_bytes;
exports.from_string = from_string;
exports.header_size = header_size;
exports.data_size = data_size;
exports.total_size = total_size;
/* No side effect */