change to int32_t

This commit is contained in:
Jörg Breitbart
2019-07-02 15:18:39 +02:00
parent b4ae5e1aff
commit 5827b4b0d1
4 changed files with 17 additions and 17 deletions
+3 -3
View File
@@ -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)', () => {
+8 -8
View File
@@ -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;
+3 -3
View File
@@ -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};
}
/**
+3 -3
View File
@@ -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};
}
}