Make Serializable dump fromJsObject() calls.

This commit is contained in:
László Monda
2016-04-02 00:58:06 +02:00
parent 2dca5c1c14
commit 7841779b46
11 changed files with 121 additions and 56 deletions
@@ -1,4 +1,4 @@
class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction> {
class KeystrokeAction extends KeyAction {
private _scancode: number;
@@ -13,27 +13,31 @@ class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction>
this._scancode = value;
}
fromJsObject(jsObject: any): KeystrokeAction {
_fromJsObject(jsObject: any): KeystrokeAction {
this.assertKeyActionType(jsObject, KeyActionType.KeystrokeAction, 'KeystrokeAction');
this.scancode = jsObject.scancode;
return this;
}
fromBinary(buffer: UhkBuffer): KeystrokeAction {
_fromBinary(buffer: UhkBuffer): KeystrokeAction {
this.readAndAssertKeyActionId(buffer, KeyActionId.KeystrokeAction, 'KeystrokeAction');
this.scancode = buffer.readUInt8();
return this;
}
toJsObject(): any {
_toJsObject(): any {
return {
keyActionType: KeyActionType.KeystrokeAction,
scancode: this.scancode
};
}
toBinary(buffer: UhkBuffer) {
_toBinary(buffer: UhkBuffer) {
buffer.writeUInt8(KeyActionId.KeystrokeAction);
buffer.writeUInt8(this.scancode);
}
toString(): string {
return `<KeystrokeAction scancode="${this.scancode}">`;
}
}