Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function decodeDebugVariant(self: Variant, stream: BinaryStream, options: any): void {
const tracer = options.tracer;
const encodingByte = decodeUInt8(stream);
const isArray = ((encodingByte & VARIANT_ARRAY_MASK) === VARIANT_ARRAY_MASK);
const hasDimension = ((encodingByte & VARIANT_ARRAY_DIMENSIONS_MASK) === VARIANT_ARRAY_DIMENSIONS_MASK);
self.dataType = (encodingByte & VARIANT_TYPE_MASK) as DataType;
tracer.dump("dataType: ", self.dataType);
tracer.dump("isArray: ", isArray ? "true" : "false");
tracer.dump("dimension: ", hasDimension);
const decode = findBuiltInType(DataType[self.dataType]).decode;
/* istanbul ignore next */
if (!decode) {
throw new Error("Variant.decode : cannot find decoder for type " + DataType[self.dataType]);
}
function decodeDataValueInternal(dataValue: DataValue, stream: BinaryStream) {
const encodingMask = decodeUInt8(stream);
if (encodingMask & DataValueEncodingByte.Value) {
dataValue.value = new Variant();
dataValue.value.decode(stream);
}
// read statusCode
if (encodingMask & DataValueEncodingByte.StatusCode) {
dataValue.statusCode = decodeStatusCode(stream);
} else {
dataValue.statusCode = StatusCodes.Good;
}
dataValue.sourcePicoseconds = 0;
// read sourceTimestamp
if (encodingMask & DataValueEncodingByte.SourceTimestamp) {
dataValue.sourceTimestamp = decodeHighAccuracyDateTime(stream);
dataValue.sourcePicoseconds += (dataValue.sourceTimestamp as DateWithPicoseconds).picoseconds | 0;
function decodeDebugDataValue(dataValue: DataValue, stream: BinaryStream, options: any) {
const tracer = options.tracer;
let cur = stream.length;
const encodingMask = decodeUInt8(stream);
assert(encodingMask <= 0x3F);
tracer.trace("member", "encodingByte", "0x" + encodingMask.toString(16), cur, stream.length, "Mask");
tracer.encoding_byte(encodingMask, DataValueEncodingByte, cur, stream.length);
if (encodingMask & DataValueEncodingByte.Value) {
dataValue.value = new Variant();
dataValue.value.decodeDebug(stream, options);
}
// read statusCode
cur = stream.length;
if (encodingMask & DataValueEncodingByte.StatusCode) {
dataValue.statusCode = decodeStatusCode(stream);
tracer.trace("member", "statusCode", dataValue.statusCode, cur, stream.length, "StatusCode");
}
// read sourceTimestamp
decode_debug: function(dataValue,stream,options) {
const tracer = options.tracer;
let cur = stream.length;
const encoding_mask = ec.decodeUInt8(stream);
assert(encoding_mask<=0x3F);
tracer.trace("member", "encodingByte", "0x" + encoding_mask.toString(16), cur, stream.length, "Mask");
tracer.encoding_byte(encoding_mask,DataValueEncodingByte,cur,stream.length);
if( check_flag(encoding_mask,DataValueEncodingByte.Value)) {
//xx var Variant = require("./variant").Variant;
dataValue.value = new Variant();
dataValue.value.decode_debug(stream,options);
//xx if (tracer) { tracer.trace("member","statusCode", dataValue.value,cur,stream.length,"Variant"); }
}
// read statusCode
cur = stream.length;
if (check_flag(encoding_mask,DataValueEncodingByte.StatusCode)) {
dataValue.statusCode = ec.decodeStatusCode(stream);
tracer.trace("member","statusCode", dataValue.statusCode,cur,stream.length,"StatusCode");
decode: function(dataValue,stream,options) {
const encoding_mask = ec.decodeUInt8(stream);
if( check_flag(encoding_mask,DataValueEncodingByte.Value)) {
//xx var Variant =
// re("./variant").Variant;
dataValue.value = new Variant(null);
dataValue.value.decode(stream,options);
}
// read statusCode
if (check_flag(encoding_mask,DataValueEncodingByte.StatusCode)) {
dataValue.statusCode = ec.decodeStatusCode(stream);
} else {
dataValue.statusCode = StatusCodes.Good;
}
dataValue.sourcePicoseconds = 0;
// read sourceTimestamp
decode: function (self, stream) {
const encodingByte = ec.decodeUInt8(stream);
const isArray = ((encodingByte & Variant_ArrayMask) === Variant_ArrayMask);
const hasDimension = (( encodingByte & Variant_ArrayDimensionsMask ) === Variant_ArrayDimensionsMask);
self.dataType = DataType.get(encodingByte & Variant_TypeMask);
if (!self.dataType) {
throw new Error("cannot find DataType for encodingByte = 0x" + (encodingByte & Variant_TypeMask).toString(16));
}
if (isArray) {
self.arrayType = hasDimension ? VariantArrayType.Matrix : VariantArrayType.Array;
self.value = decodeVariantArray(self.dataType, stream);
}
else {
self.arrayType = VariantArrayType.Scalar;
function internalDecodeVariant(self: Variant, stream: BinaryStream) {
const encodingByte = decodeUInt8(stream);
const isArray: boolean = ((encodingByte & VARIANT_ARRAY_MASK) === VARIANT_ARRAY_MASK);
const hasDimension: boolean = ((encodingByte & VARIANT_ARRAY_DIMENSIONS_MASK) === VARIANT_ARRAY_DIMENSIONS_MASK);
self.dataType = (encodingByte & VARIANT_TYPE_MASK) as DataType;
if (isArray) {
self.arrayType = hasDimension ? VariantArrayType.Matrix : VariantArrayType.Array;
self.value = decodeVariantArray(self.dataType, stream);
} else {
self.arrayType = VariantArrayType.Scalar;
const decode = get_decoder(self.dataType);
self.value = decode(stream);
}
if (hasDimension) {