Simplify subclassing
This commit is contained in:
parent
0e77c0c88a
commit
a2b06b7626
28 changed files with 579 additions and 607 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ function C1PCPU(parmsCPU)
|
|||
];
|
||||
}
|
||||
|
||||
Component.subclass(Component, C1PCPU);
|
||||
Component.subclass(C1PCPU);
|
||||
|
||||
/**
|
||||
* @this {C1PCPU}
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ function C1PDebugger(parmsDbg)
|
|||
|
||||
if (DEBUGGER) {
|
||||
|
||||
Component.subclass(Component, C1PDebugger);
|
||||
Component.subclass(C1PDebugger);
|
||||
|
||||
/**
|
||||
* @this {C1PDebugger}
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ function C1PDiskController(parmsDC)
|
|||
this.reset(true);
|
||||
}
|
||||
|
||||
Component.subclass(Component, C1PDiskController);
|
||||
Component.subclass(C1PDiskController);
|
||||
|
||||
/**
|
||||
* @this {C1PDiskController}
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ function C1PKeyboard(parmsKbd)
|
|||
this.reset();
|
||||
}
|
||||
|
||||
Component.subclass(Component, C1PKeyboard);
|
||||
Component.subclass(C1PKeyboard);
|
||||
|
||||
/**
|
||||
* @this {C1PKeyboard}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function C1PRAM(parmsRAM)
|
|||
Component.call(this, "C1PRAM", parmsRAM);
|
||||
}
|
||||
|
||||
Component.subclass(Component, C1PRAM);
|
||||
Component.subclass(C1PRAM);
|
||||
|
||||
/**
|
||||
* @this {C1PRAM}
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ function C1PSerialPort(parmsSerial)
|
|||
this.reset();
|
||||
}
|
||||
|
||||
Component.subclass(Component, C1PSerialPort);
|
||||
Component.subclass(C1PSerialPort);
|
||||
|
||||
/**
|
||||
* @this {C1PSerialPort}
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ function Bus(parmsBus, cpu, dbg)
|
|||
this.setReady();
|
||||
}
|
||||
|
||||
Component.subclass(Component, Bus);
|
||||
Component.subclass(Bus);
|
||||
|
||||
if (BACKTRACK) {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ function ChipSet(parmsChipSet)
|
|||
this.setReady();
|
||||
}
|
||||
|
||||
Component.subclass(Component, ChipSet);
|
||||
Component.subclass(ChipSet);
|
||||
|
||||
/*
|
||||
* Supported model numbers
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ function FDC(parmsFDC) {
|
|||
*/
|
||||
}
|
||||
|
||||
Component.subclass(Component, FDC);
|
||||
Component.subclass(FDC);
|
||||
|
||||
FDC.DEFAULT_DRIVE_NAME = "Floppy Drive";
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ function HDC(parmsHDC) {
|
|||
*/
|
||||
}
|
||||
|
||||
Component.subclass(Component, HDC);
|
||||
Component.subclass(HDC);
|
||||
|
||||
/*
|
||||
* HDC defaults, in case drive parameters weren't specified
|
||||
|
|
|
|||
|
|
@ -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
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function RAM(parmsRAM)
|
|||
this.fAllocated = false;
|
||||
}
|
||||
|
||||
Component.subclass(Component, RAM);
|
||||
Component.subclass(RAM);
|
||||
|
||||
/**
|
||||
* initBus(cmp, bus, cpu, dbg)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue