extensions/universalchardet/src/base/nsPkgInt.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/universalchardet/src/base/nsPkgInt.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsPkgInt_h__
    1.10 +#define nsPkgInt_h__
    1.11 +#include "nscore.h"
    1.12 +
    1.13 +typedef enum {
    1.14 +  eIdxSft4bits  = 3,
    1.15 +  eIdxSft8bits  = 2,
    1.16 +  eIdxSft16bits = 1
    1.17 +} nsIdxSft; 
    1.18 +
    1.19 +typedef enum {
    1.20 +  eSftMsk4bits  = 7,
    1.21 +  eSftMsk8bits  = 3,
    1.22 +  eSftMsk16bits = 1
    1.23 +} nsSftMsk; 
    1.24 +
    1.25 +typedef enum {
    1.26 +  eBitSft4bits  = 2,
    1.27 +  eBitSft8bits  = 3,
    1.28 +  eBitSft16bits = 4
    1.29 +} nsBitSft; 
    1.30 +
    1.31 +typedef enum {
    1.32 +  eUnitMsk4bits  = 0x0000000FL,
    1.33 +  eUnitMsk8bits  = 0x000000FFL,
    1.34 +  eUnitMsk16bits = 0x0000FFFFL
    1.35 +} nsUnitMsk; 
    1.36 +
    1.37 +typedef struct nsPkgInt {
    1.38 +  nsIdxSft  idxsft;
    1.39 +  nsSftMsk  sftmsk;
    1.40 +  nsBitSft  bitsft;
    1.41 +  nsUnitMsk unitmsk;
    1.42 +  const uint32_t* const data;
    1.43 +} nsPkgInt;
    1.44 +
    1.45 +
    1.46 +#define PCK16BITS(a,b)            ((uint32_t)(((b) << 16) | (a)))
    1.47 +
    1.48 +#define PCK8BITS(a,b,c,d)         PCK16BITS( ((uint32_t)(((b) << 8) | (a))),  \
    1.49 +                                             ((uint32_t)(((d) << 8) | (c))))
    1.50 +
    1.51 +#define PCK4BITS(a,b,c,d,e,f,g,h) PCK8BITS(  ((uint32_t)(((b) << 4) | (a))), \
    1.52 +                                             ((uint32_t)(((d) << 4) | (c))), \
    1.53 +                                             ((uint32_t)(((f) << 4) | (e))), \
    1.54 +                                             ((uint32_t)(((h) << 4) | (g))) )
    1.55 +
    1.56 +#define GETFROMPCK(i, c) \
    1.57 + (((((c).data)[(i)>>(c).idxsft])>>(((i)&(c).sftmsk)<<(c).bitsft))&(c).unitmsk)
    1.58 +
    1.59 +#endif /* nsPkgInt_h__ */
    1.60 +

mercurial