toolkit/components/workerlz4/lz4_internal.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/workerlz4/lz4_internal.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +if (typeof Components != "undefined") {
    1.11 +  throw new Error("This file is meant to be loaded in a worker");
    1.12 +}
    1.13 +if (!module || !exports) {
    1.14 +  throw new Error("Please load this module with require()");
    1.15 +}
    1.16 +
    1.17 +let SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
    1.18 +let libxul = new SharedAll.Library("libxul", SharedAll.Constants.Path.libxul);
    1.19 +let Type = SharedAll.Type;
    1.20 +
    1.21 +let Primitives = {};
    1.22 +
    1.23 +libxul.declareLazyFFI(Primitives, "compress",
    1.24 +  "workerlz4_compress",
    1.25 +  null,
    1.26 +  /*return*/ Type.size_t,
    1.27 +  /*const source*/ Type.void_t.in_ptr,
    1.28 +  /*inputSize*/ Type.size_t,
    1.29 +  /*dest*/ Type.void_t.out_ptr
    1.30 +);
    1.31 +
    1.32 +libxul.declareLazyFFI(Primitives, "decompress",
    1.33 +  "workerlz4_decompress",
    1.34 +  null,
    1.35 +  /*return*/ Type.int,
    1.36 +  /*const source*/ Type.void_t.in_ptr,
    1.37 +  /*inputSize*/ Type.size_t,
    1.38 +  /*dest*/ Type.void_t.out_ptr,
    1.39 +  /*maxOutputSize*/ Type.size_t,
    1.40 +  /*actualOutputSize*/ Type.size_t.out_ptr
    1.41 +);
    1.42 +
    1.43 +libxul.declareLazyFFI(Primitives, "maxCompressedSize",
    1.44 +  "workerlz4_maxCompressedSize",
    1.45 +  null,
    1.46 +  /*return*/ Type.size_t,
    1.47 +  /*inputSize*/ Type.size_t
    1.48 +);
    1.49 +
    1.50 +module.exports = {
    1.51 +  get compress() {
    1.52 +    return Primitives.compress;
    1.53 +  },
    1.54 +  get decompress() {
    1.55 +    return Primitives.decompress;
    1.56 +  },
    1.57 +  get maxCompressedSize() {
    1.58 +    return Primitives.maxCompressedSize;
    1.59 +  }
    1.60 +};

mercurial