Beispiel #1
0
static void enumBits( uint_32 mask, uint_32 remaining, void (*func)( ins_flags, ins_table * ), void *parm ) {
//******************************************************************************************************

    uint_32     low_bit;

    if( remaining == 0 ) {
        func( mask, parm );
        return;
    }
    low_bit = remaining & -remaining;
    remaining ^= low_bit;
    enumBits( mask,             remaining, func, parm );
    enumBits( mask | low_bit,   remaining, func, parm );
}
Beispiel #2
0
void Decoder::readBoolsAndStrictEnums(size_t skipBits) {
  auto& s = top();

  size_t nbytes = byteCount(skipBits + s.bools.count + s.totalStrictEnumBits);
  if (s.bools.count + s.totalStrictEnumBits) {
    s.boolStartBit = skipBits;
    s.bools.values.resize(nbytes);
    cursor_.pull(&s.bools.values.front(), nbytes);

    // Strict enums are only supported in structs for now
    DCHECK(s.totalStrictEnumBits == 0 || s.state == IN_STRUCT);

    // Extract strict enums
    size_t bit = skipBits + s.bools.count;
    for (size_t i = 0; i < s.strictEnums.count; ++i) {
      auto dt = s.str.strictEnumTags[i].second.dataType;
      auto bitCount = dt->enumBits();
      auto index = getBits(&s.bools.values.front(), bit, bitCount);
      bit += bitCount;
      s.strictEnums.values.push_back(*(dt->enumValues.begin() + index));
    }

    DCHECK_EQ(bit, skipBits + s.bools.count + s.totalStrictEnumBits);
  } else {
    cursor_.skip(nbytes);
  }
  s.bytesRead += nbytes;
}
Beispiel #3
0
static void bitSetCover( uint_32 subset, void (*func)( ins_flags set, ins_table *parm ), void *parm ) {
//************************************************************************************************
// This is a little different - when this routine is called with a set of bits, it guarantees
// that the function passed in will be called exactly once for each subset of those bits,
// including 0 and the bit-set itself. It is recursive and can recurse up to n-levels deep,
// where n is the number of bits on in the subset.

    enumBits( 0, subset, func, parm );
}