toolkit/components/workerlz4/lz4_internal.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     5 "use strict";
     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 }
    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;
    18 let Primitives = {};
    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 );
    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 );
    40 libxul.declareLazyFFI(Primitives, "maxCompressedSize",
    41   "workerlz4_maxCompressedSize",
    42   null,
    43   /*return*/ Type.size_t,
    44   /*inputSize*/ Type.size_t
    45 );
    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 };

mercurial