/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
struct unpacker;
#define CODING_INIT(B, H, S, D) \
{ CODING_SPEC(B, H, S, D) , 0, 0, 0, 0, 0, 0, 0, 0}
// For debugging purposes, some compilers do not like this and will complain.
// #define long do_not_use_C_long_types_use_jlong_or_int
// Use of the type "long" is problematic, do not use it.
struct coding {
// Handy values derived from the spec:
return init();
}
static coding* findBySpec(int B, int H, int S=0, int D=0);
}
}
int sumInUnsignedRange(int x, int y);
}
#ifndef PRODUCT
const char* string();
#endif
void free(); // free self if isMalloc
// error handling
};
enum coding_method_kind {
// special cases hand-optimized (~50% of all decoded values)
//cmk_UNSIGNED5H16, //(5,16) 5%
//cmk_UNSIGNED2H4, //(2,4) 6%
//cmk_DELTA4H8, //(4,8,1,1) 10%
//cmk_DELTA3H16, //(3,16,1,1) 9%
};
enum {
};
enum {
};
struct coding_method;
// iterator under the control of a meta-coding
struct value_stream {
// current coding of values or values
coding c; // B,H,S,D,etc.
// Parse and decode a single value.
int getInt();
// Parse and decode a single byte, with no error checks.
int getByte() {
return *rp++ & 0xFF;
}
// Used only for asserts.
bool hasValue();
// Sometimes a value stream has an auxiliary (but there are never two).
value_stream* helper() {
return this+1;
}
bool hasHelper();
// error handling
// inline void abort(const char* msg);
// inline void aborting();
};
struct coding_method {
// these fields are used for pop codes only:
int* fValues; // favored value array
int fVlength; // maximum favored value token
// pointer to outer unpacker, for error checks etc.
unpacker* u;
// Initialize a value stream.
// Parse a band header, size a band, and initialize for further action.
// band_rp advances (but not past band_limit), and meta_rp advances.
// The mode gives context, such as "inside a pop".
// The defc and N are the incoming parameters to a meta-coding.
// The value sink is used to collect output values, when desired.
// error handling
bool aborting() { return unpack_aborting(u); }
};
//inline void value_stream::abort(const char* msg) { cm->abort(msg); }
//inline void value_stream::aborting() { cm->aborting(); }