michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: if (typeof Components != "undefined") { michael@0: throw new Error("This file is meant to be loaded in a worker"); michael@0: } michael@0: if (!module || !exports) { michael@0: throw new Error("Please load this module with require()"); michael@0: } michael@0: michael@0: let SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm"); michael@0: let libxul = new SharedAll.Library("libxul", SharedAll.Constants.Path.libxul); michael@0: let Type = SharedAll.Type; michael@0: michael@0: let Primitives = {}; michael@0: michael@0: libxul.declareLazyFFI(Primitives, "compress", michael@0: "workerlz4_compress", michael@0: null, michael@0: /*return*/ Type.size_t, michael@0: /*const source*/ Type.void_t.in_ptr, michael@0: /*inputSize*/ Type.size_t, michael@0: /*dest*/ Type.void_t.out_ptr michael@0: ); michael@0: michael@0: libxul.declareLazyFFI(Primitives, "decompress", michael@0: "workerlz4_decompress", michael@0: null, michael@0: /*return*/ Type.int, michael@0: /*const source*/ Type.void_t.in_ptr, michael@0: /*inputSize*/ Type.size_t, michael@0: /*dest*/ Type.void_t.out_ptr, michael@0: /*maxOutputSize*/ Type.size_t, michael@0: /*actualOutputSize*/ Type.size_t.out_ptr michael@0: ); michael@0: michael@0: libxul.declareLazyFFI(Primitives, "maxCompressedSize", michael@0: "workerlz4_maxCompressedSize", michael@0: null, michael@0: /*return*/ Type.size_t, michael@0: /*inputSize*/ Type.size_t michael@0: ); michael@0: michael@0: module.exports = { michael@0: get compress() { michael@0: return Primitives.compress; michael@0: }, michael@0: get decompress() { michael@0: return Primitives.decompress; michael@0: }, michael@0: get maxCompressedSize() { michael@0: return Primitives.maxCompressedSize; michael@0: } michael@0: };