Add UhkArray. Don't dump arrays.

This commit is contained in:
László Monda
2016-04-03 01:25:07 +02:00
parent 7841779b46
commit 2b91aa3152
4 changed files with 13 additions and 3 deletions
+5 -2
View File
@@ -8,11 +8,14 @@ abstract class Serializable<T> {
fromJsObject(jsObject: any): T { fromJsObject(jsObject: any): T {
let identation = new Array(Serializable.depth + 1).join(' '); let identation = new Array(Serializable.depth + 1).join(' ');
process.stdout.write(`${identation}* ${this.constructor.name}.fromJsObject(${JSON.stringify(jsObject)}) => `); let isArray = this instanceof UhkArray;
process.stdout.write(`${identation}* ${this.constructor.name}.fromJsObject(${JSON.stringify(jsObject)}) ` + (isArray ? ':\n' : `=> `));
Serializable.depth++; Serializable.depth++;
let value = this._fromJsObject(jsObject); let value = this._fromJsObject(jsObject);
Serializable.depth--; Serializable.depth--;
process.stdout.write(`${value.toString()}\n`); if (!isArray) {
process.stdout.write(`${value.toString()}\n`);
}
return value; return value;
} }
+6
View File
@@ -0,0 +1,6 @@
abstract class UhkArray<T> extends Serializable<T> {
abstract _fromJsObject(jsObject: any): T;
abstract _fromBinary(buffer: UhkBuffer): T;
abstract _toJsObject(): any;
abstract _toBinary(buffer: UhkBuffer): void;
}
+1 -1
View File
@@ -1,4 +1,4 @@
class KeyActions extends Serializable<KeyActions> { class KeyActions extends UhkArray<KeyActions> {
keyActions: Serializable<KeyAction>[] = []; keyActions: Serializable<KeyAction>[] = [];
+1
View File
@@ -1,6 +1,7 @@
/// <reference path="assert.ts" /> /// <reference path="assert.ts" />
/// <reference path="TypeChecker.ts" /> /// <reference path="TypeChecker.ts" />
/// <reference path="Serializable.ts" /> /// <reference path="Serializable.ts" />
/// <reference path="UhkArray.ts" />
/// <reference path="UhkBuffer.ts" /> /// <reference path="UhkBuffer.ts" />
/// <reference path="config-items/config-items.ts" /> /// <reference path="config-items/config-items.ts" />