UNPKG

@lichtblick/cdr

Version:

Common Data Representation serialization and deserialization library

73 lines 4.3 kB
"use strict"; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var _CdrSizeCalculator_instances, _CdrSizeCalculator_offset, _CdrSizeCalculator_incrementAndReturn; Object.defineProperty(exports, "__esModule", { value: true }); exports.CdrSizeCalculator = void 0; class CdrSizeCalculator { constructor() { _CdrSizeCalculator_instances.add(this); // Two bytes for Representation Id and two bytes for Options _CdrSizeCalculator_offset.set(this, 4); } get size() { return __classPrivateFieldGet(this, _CdrSizeCalculator_offset, "f"); } int8() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 1); } uint8() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 1); } int16() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 2); } uint16() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 2); } int32() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 4); } uint32() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 4); } int64() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 8); } uint64() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 8); } float32() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 4); } float64() { return __classPrivateFieldGet(this, _CdrSizeCalculator_instances, "m", _CdrSizeCalculator_incrementAndReturn).call(this, 8); } string(length) { this.uint32(); __classPrivateFieldSet(this, _CdrSizeCalculator_offset, __classPrivateFieldGet(this, _CdrSizeCalculator_offset, "f") + (length + 1), "f"); // Add one for the null terminator return __classPrivateFieldGet(this, _CdrSizeCalculator_offset, "f"); } sequenceLength() { return this.uint32(); } } exports.CdrSizeCalculator = CdrSizeCalculator; _CdrSizeCalculator_offset = new WeakMap(), _CdrSizeCalculator_instances = new WeakSet(), _CdrSizeCalculator_incrementAndReturn = function _CdrSizeCalculator_incrementAndReturn(byteCount) { const alignment = (__classPrivateFieldGet(this, _CdrSizeCalculator_offset, "f") - 4) % byteCount; if (alignment > 0) { __classPrivateFieldSet(this, _CdrSizeCalculator_offset, __classPrivateFieldGet(this, _CdrSizeCalculator_offset, "f") + (byteCount - alignment), "f"); } __classPrivateFieldSet(this, _CdrSizeCalculator_offset, __classPrivateFieldGet(this, _CdrSizeCalculator_offset, "f") + byteCount, "f"); return __classPrivateFieldGet(this, _CdrSizeCalculator_offset, "f"); }; //# sourceMappingURL=CdrSizeCalculator.js.map