| |
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| |
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| |
4 |
| |
5 "use strict"; |
| |
6 |
| |
7 if (typeof Components != "undefined") { |
| |
8 throw new Error("This file is meant to be loaded in a worker"); |
| |
9 } |
| |
10 if (!module || !exports) { |
| |
11 throw new Error("Please load this module with require()"); |
| |
12 } |
| |
13 |
| |
14 let SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm"); |
| |
15 let libxul = new SharedAll.Library("libxul", SharedAll.Constants.Path.libxul); |
| |
16 let Type = SharedAll.Type; |
| |
17 |
| |
18 let Primitives = {}; |
| |
19 |
| |
20 libxul.declareLazyFFI(Primitives, "compress", |
| |
21 "workerlz4_compress", |
| |
22 null, |
| |
23 /*return*/ Type.size_t, |
| |
24 /*const source*/ Type.void_t.in_ptr, |
| |
25 /*inputSize*/ Type.size_t, |
| |
26 /*dest*/ Type.void_t.out_ptr |
| |
27 ); |
| |
28 |
| |
29 libxul.declareLazyFFI(Primitives, "decompress", |
| |
30 "workerlz4_decompress", |
| |
31 null, |
| |
32 /*return*/ Type.int, |
| |
33 /*const source*/ Type.void_t.in_ptr, |
| |
34 /*inputSize*/ Type.size_t, |
| |
35 /*dest*/ Type.void_t.out_ptr, |
| |
36 /*maxOutputSize*/ Type.size_t, |
| |
37 /*actualOutputSize*/ Type.size_t.out_ptr |
| |
38 ); |
| |
39 |
| |
40 libxul.declareLazyFFI(Primitives, "maxCompressedSize", |
| |
41 "workerlz4_maxCompressedSize", |
| |
42 null, |
| |
43 /*return*/ Type.size_t, |
| |
44 /*inputSize*/ Type.size_t |
| |
45 ); |
| |
46 |
| |
47 module.exports = { |
| |
48 get compress() { |
| |
49 return Primitives.compress; |
| |
50 }, |
| |
51 get decompress() { |
| |
52 return Primitives.decompress; |
| |
53 }, |
| |
54 get maxCompressedSize() { |
| |
55 return Primitives.maxCompressedSize; |
| |
56 } |
| |
57 }; |