Simplify subclassing

This commit is contained in:
Jeff Parsons 2015-04-01 17:20:26 -07:00 committed by jeffpar
commit a2b06b7626
28 changed files with 579 additions and 607 deletions

View file

@ -98,7 +98,7 @@ C1PComputer.sAppName = APPNAME || "C1Pjs";
C1PComputer.sAppVer = APPVERSION;
C1PComputer.sCopyright = "Copyright © 2012-2015 Jeff Parsons <Jeff@pcjs.org>";
Component.subclass(Component, C1PComputer);
Component.subclass(C1PComputer);
/**
* @this {C1PComputer}

View file

@ -469,7 +469,7 @@ function C1PCPU(parmsCPU)
];
}
Component.subclass(Component, C1PCPU);
Component.subclass(C1PCPU);
/**
* @this {C1PCPU}

View file

@ -484,7 +484,7 @@ function C1PDebugger(parmsDbg)
if (DEBUGGER) {
Component.subclass(Component, C1PDebugger);
Component.subclass(C1PDebugger);
/**
* @this {C1PDebugger}

View file

@ -433,7 +433,7 @@ function C1PDiskController(parmsDC)
this.reset(true);
}
Component.subclass(Component, C1PDiskController);
Component.subclass(C1PDiskController);
/**
* @this {C1PDiskController}

View file

@ -295,7 +295,7 @@ function C1PKeyboard(parmsKbd)
this.reset();
}
Component.subclass(Component, C1PKeyboard);
Component.subclass(C1PKeyboard);
/**
* @this {C1PKeyboard}

View file

@ -47,7 +47,7 @@ function C1PPanel(parmsPanel)
this.aFlags.fPowered = false;
}
Component.subclass(Component, C1PPanel);
Component.subclass(C1PPanel);
/**
* The Panel doesn't have any bindings of its own; it passes along all binding requests to

View file

@ -51,7 +51,7 @@ function C1PRAM(parmsRAM)
Component.call(this, "C1PRAM", parmsRAM);
}
Component.subclass(Component, C1PRAM);
Component.subclass(C1PRAM);
/**
* @this {C1PRAM}

View file

@ -50,6 +50,7 @@
function C1PROM(parmsROM)
{
Component.call(this, "C1PROM", parmsROM);
this.abMem = null;
this.abImage = null;
this.cbROM = parmsROM['size'];
@ -70,7 +71,7 @@ function C1PROM(parmsROM)
}
}
Component.subclass(Component, C1PROM);
Component.subclass(C1PROM);
/**
* @this {C1PROM}

View file

@ -53,7 +53,7 @@ function C1PSerialPort(parmsSerial)
this.reset();
}
Component.subclass(Component, C1PSerialPort);
Component.subclass(C1PSerialPort);
/**
* @this {C1PSerialPort}

View file

@ -152,7 +152,7 @@ function C1PVideo(parmsVideo, eCanvas, context, imgChars)
this.addrVideoPort = 0xDE00; // WARNING: Hard-coded port address -JP
}
Component.subclass(Component, C1PVideo);
Component.subclass(C1PVideo);
/**
* @this {C1PVideo}

View file

@ -191,7 +191,7 @@ function Bus(parmsBus, cpu, dbg)
this.setReady();
}
Component.subclass(Component, Bus);
Component.subclass(Bus);
if (BACKTRACK) {
/*

View file

@ -255,7 +255,7 @@ function ChipSet(parmsChipSet)
this.setReady();
}
Component.subclass(Component, ChipSet);
Component.subclass(ChipSet);
/*
* Supported model numbers

View file

@ -255,7 +255,7 @@ function Computer(parmsComputer, parmsMachine, fSuspended) {
}
}
Component.subclass(Component, Computer);
Component.subclass(Computer);
/*
* NOTE: 1.01 is the first version to provide limited save/restore support using localStorage.

View file

@ -139,7 +139,7 @@ function CPU(parmsCPU, nCyclesDefault)
this.setReady();
}
Component.subclass(Component, CPU);
Component.subclass(CPU);
/*
* Constants that control the frequency at which various updates should occur.

View file

@ -192,7 +192,7 @@ function Debugger(parmsDbg)
if (DEBUGGER) {
Component.subclass(Component, Debugger);
Component.subclass(Debugger);
/*
* Information regarding interrupts of interest (used by messageInt() and others)

View file

@ -305,7 +305,7 @@ Disk.REMOTE_WRITE_DELAY = 2000; // 2-second delay
*/
Disk.nDisks = 0;
Component.subclass(Component, Disk);
Component.subclass(Disk);
/**
* initBus(cmp, bus, cpu, dbg)

View file

@ -187,7 +187,7 @@ function FDC(parmsFDC) {
*/
}
Component.subclass(Component, FDC);
Component.subclass(FDC);
FDC.DEFAULT_DRIVE_NAME = "Floppy Drive";

View file

@ -117,7 +117,7 @@ function HDC(parmsHDC) {
*/
}
Component.subclass(Component, HDC);
Component.subclass(HDC);
/*
* HDC defaults, in case drive parameters weren't specified

View file

@ -146,7 +146,7 @@ function Keyboard(parmsKbd)
this.setReady();
}
Component.subclass(Component, Keyboard);
Component.subclass(Keyboard);
/**
* Alphanumeric and other common (printable) ASCII codes.

File diff suppressed because it is too large Load diff

View file

@ -158,7 +158,7 @@ function Mouse(parmsMouse)
* synchronize with the mouse.
*/
Component.subclass(Component, Mouse);
Component.subclass(Mouse);
Mouse.ID_SERIAL = 0x4D;
@ -267,9 +267,10 @@ Mouse.prototype.powerUp = function(data, fRepower)
*
* @this {Mouse}
* @param {boolean} fSave
* @return {Object|boolean}
* @param {boolean} [fShutdown]
* @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure
*/
Mouse.prototype.powerDown = function(fSave)
Mouse.prototype.powerDown = function(fSave, fShutdown)
{
return fSave && this.save? this.save() : true;
};

View file

@ -49,8 +49,10 @@ if (typeof module !== 'undefined') {
* @extends Component
* @param {Object} parmsPanel
*/
function Panel(parmsPanel) {
function Panel(parmsPanel)
{
Component.call(this, "Panel", parmsPanel, Panel);
this.canvas = null;
this.lockMouse = -1;
this.fMouseDown = false;
@ -61,7 +63,7 @@ function Panel(parmsPanel) {
}
}
Component.subclass(Component, Panel);
Component.subclass(Panel);
/*
* The "Live" canvases that we create internally have the following fixed dimensions, to make drawing

View file

@ -65,7 +65,7 @@ function RAM(parmsRAM)
this.fAllocated = false;
}
Component.subclass(Component, RAM);
Component.subclass(RAM);
/**
* initBus(cmp, bus, cpu, dbg)

View file

@ -101,7 +101,7 @@ function ROM(parmsROM)
}
}
Component.subclass(Component, ROM);
Component.subclass(ROM);
/*
* ROM BIOS Data Area (RBDA) definitions, in physical address form, using the same ALL-CAPS names

View file

@ -109,7 +109,7 @@ function SerialPort(parmsSerial) {
* for third-party apps.
*/
Component.subclass(Component, SerialPort);
Component.subclass(SerialPort);
/*
* Internal name used for the I/O buffer control, if any, that we bind to the SerialPort.

View file

@ -269,7 +269,7 @@ function Video(parmsVideo, canvas, context, textarea, container)
}
}
Component.subclass(Component, Video);
Component.subclass(Video);
Video.TRAPALL = true; // monitor all I/O by default (not just deltas)

View file

@ -188,7 +188,7 @@ function X86CPU(parmsCPU) {
this.resetRegs();
}
Component.subclass(CPU, X86CPU);
Component.subclass(X86CPU, CPU);
X86CPU.CYCLES_8088 = {
nWordCyclePenalty: 4, // NOTE: accurate for the 8088/80188 only (on the 8086/80186, it applies to odd addresses only)

View file

@ -185,17 +185,18 @@ Component.extend = function(o, p)
};
/**
* Component.subclass(superclass, subclass, methods, statics)
* Component.subclass(subclass, superclass, methods, statics)
*
* See: Flanagan, David (2011-04-18). JavaScript: The Definitive Guide: The Definitive Guide (Kindle Locations 9854-9903). OReilly Media - A. Kindle Edition (Example 9-11)
*
* @param {Object} superclass is the constructor of the superclass
* @param {Object} subclass is the constructor for the new subclass
* @param {Object} [superclass] is the constructor of the superclass (default is Component)
* @param {Object} [methods] contains all instance methods
* @param {Object} [statics] contains all class properties and methods
*/
Component.subclass = function(superclass, subclass, methods, statics)
Component.subclass = function(subclass, superclass, methods, statics)
{
if (!superclass) superclass = Component;
subclass.prototype = Component.inherit(superclass.prototype);
subclass.prototype.constructor = subclass;
subclass.prototype.parent = superclass.prototype;