From 5827b4b0d1b673573ed1d3ed656901af1c9c672d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Tue, 2 Jul 2019 15:18:39 +0200 Subject: [PATCH] change to int32_t --- src/common/parser/Params.test.ts | 6 +++--- src/common/parser/Params.ts | 16 ++++++++-------- src/common/parser/Types.d.ts | 6 +++--- typings/xterm.d.ts | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/common/parser/Params.test.ts b/src/common/parser/Params.test.ts index dca5f1c2..a874e9b9 100644 --- a/src/common/parser/Params.test.ts +++ b/src/common/parser/Params.test.ts @@ -6,7 +6,7 @@ import { assert } from 'chai'; import { Params } from 'common/parser/Params'; class TestParams extends Params { - public get subParams(): Int16Array { + public get subParams(): Int32Array { return this._subParams; } public get subParamsLength(): number { @@ -129,7 +129,7 @@ describe('Params', () => { it('hasSubParams / getSubParams', () => { const params = Params.fromArray([38, [2, 50, 100, 150], 5, [], 6]); assert.equal(params.hasSubParams(0), true); - assert.deepEqual(params.getSubParams(0), new Int16Array([2, 50, 100, 150])); + assert.deepEqual(params.getSubParams(0), new Int32Array([2, 50, 100, 150])); assert.equal(params.hasSubParams(1), false); assert.deepEqual(params.getSubParams(1), null); assert.equal(params.hasSubParams(2), false); @@ -137,7 +137,7 @@ describe('Params', () => { }); it('getSubParamsAll', () => { const params = Params.fromArray([1, [2, 3], 7, 12345, [-1]]); - assert.deepEqual(params.getSubParamsAll(), {0: new Int16Array([2, 3]), 2: new Int16Array([-1])}); + assert.deepEqual(params.getSubParamsAll(), {0: new Int32Array([2, 3]), 2: new Int32Array([-1])}); }); describe('parse tests', () => { it('param defaults to 0 (ZDM - zero default mode)', () => { diff --git a/src/common/parser/Params.ts b/src/common/parser/Params.ts index 16b9d74e..1d935e0b 100644 --- a/src/common/parser/Params.ts +++ b/src/common/parser/Params.ts @@ -34,13 +34,13 @@ import { IParams } from 'common/parser/Types'; * - max. value for a single (sub) param is 2^15 (caveat: will overflow to negative values) * - max. 256 sub params possible */ -export class Params { +export class Params implements IParams { // params store and length - public params: Int16Array; + public params: Int32Array; public length: number; // sub params store and length - protected _subParams: Int16Array; + protected _subParams: Int32Array; protected _subParamsLength: number; // sub params offsets from param: param idx --> [start, end] offset @@ -79,9 +79,9 @@ export class Params { if (maxSubParamsLength > 256) { throw new Error('maxSubParamsLength must not be greater than 256'); } - this.params = new Int16Array(maxLength); + this.params = new Int32Array(maxLength); this.length = 0; - this._subParams = new Int16Array(maxSubParamsLength); + this._subParams = new Int32Array(maxSubParamsLength); this._subParamsLength = 0; this._subParamsIdx = new Uint16Array(maxLength); this._rejectDigits = false; @@ -174,7 +174,7 @@ export class Params { * Note: The values are borrowed, thus you need to copy * the values if you need to hold them in nonlocal scope. */ - public getSubParams(idx: number): Int16Array | null { + public getSubParams(idx: number): Int32Array | null { const start = this._subParamsIdx[idx] >> 8; const end = this._subParamsIdx[idx] & 0xFF; if (end - start > 0) { @@ -188,8 +188,8 @@ export class Params { * Note: The values are not borrowed, thus it is safe to hold * them without copying. */ - public getSubParamsAll(): {[idx: number]: Int16Array} { - const result: {[idx: number]: Int16Array} = {}; + public getSubParamsAll(): {[idx: number]: Int32Array} { + const result: {[idx: number]: Int32Array} = {}; for (let i = 0; i < this.length; ++i) { const start = this._subParamsIdx[i] >> 8; const end = this._subParamsIdx[i] & 0xFF; diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index e25b8cc3..436c70af 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -22,7 +22,7 @@ export interface IParams { maxSubParamsLength: number; /** param values and its length */ - params: Int16Array; + params: Int32Array; length: number; /** methods */ @@ -32,8 +32,8 @@ export interface IParams { addParam(value: number): void; addSubParam(value: number): void; hasSubParams(idx: number): boolean; - getSubParams(idx: number): Int16Array | null; - getSubParamsAll(): {[idx: number]: Int16Array}; + getSubParams(idx: number): Int32Array | null; + getSubParamsAll(): {[idx: number]: Int32Array}; } /** diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 2f161757..5ec16ca7 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -938,14 +938,14 @@ declare module 'xterm' { readonly maxSubParamsLength: number; /** param values and its length */ - readonly params: Int16Array; + readonly params: Int32Array; readonly length: number; /** exported methods */ clone(): IParams; toArray(): (number | number[])[]; hasSubParams(idx: number): boolean; - getSubParams(idx: number): Int16Array | null; - getSubParamsAll(): {[idx: number]: Int16Array}; + getSubParams(idx: number): Int32Array | null; + getSubParamsAll(): {[idx: number]: Int32Array}; } }