From 55c3236380c6848913b6b96b5f5e599201185c66 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Mon, 9 Nov 2015 08:22:08 -0800 Subject: [PATCH] Fixed lingering code inspection issues --- modules/pcjs/lib/bus.js | 2 +- modules/pcjs/lib/chipset.js | 2 +- modules/pcjs/lib/computer.js | 4 ++-- modules/pcjs/lib/cpu.js | 4 ++-- modules/pcjs/lib/debugger.js | 12 ++++++------ modules/pcjs/lib/fdc.js | 4 ++-- modules/pcjs/lib/hdc.js | 2 +- modules/pcjs/lib/interrupts.js | 2 +- modules/pcjs/lib/keyboard.js | 2 +- modules/pcjs/lib/memory.js | 6 +++--- modules/pcjs/lib/mouse.js | 4 ++-- modules/pcjs/lib/panel.js | 8 ++++---- modules/pcjs/lib/ram.js | 2 +- modules/pcjs/lib/serialport.js | 2 +- modules/pcjs/lib/video.js | 21 +++++++++++---------- modules/pcjs/lib/x86cpu.js | 5 +++-- modules/pcjs/lib/x86func.js | 4 ++-- modules/shared/lib/usrlib.js | 2 +- 18 files changed, 45 insertions(+), 43 deletions(-) diff --git a/modules/pcjs/lib/bus.js b/modules/pcjs/lib/bus.js index d900b048d..f9793a9c5 100644 --- a/modules/pcjs/lib/bus.js +++ b/modules/pcjs/lib/bus.js @@ -949,7 +949,7 @@ Bus.prototype.setLongDirect = function(addr, l) * * @this {Bus} * @param {Object} obj - * @param {BackTrack} bto + * @param {BackTrack|null} bto * @param {number} off (the offset within obj that this wrapper object is relative to) * @return {BackTrack|null} */ diff --git a/modules/pcjs/lib/chipset.js b/modules/pcjs/lib/chipset.js index 90df66664..57f032752 100644 --- a/modules/pcjs/lib/chipset.js +++ b/modules/pcjs/lib/chipset.js @@ -1036,7 +1036,7 @@ ChipSet.prototype.initBus = function(cmp, bus, cpu, dbg) this.cpu = cpu; this.dbg = dbg; this.cmp = cmp; - this.kbd = cmp.getComponentByType("Keyboard"); + this.kbd = cmp.getMachineComponent("Keyboard"); /* * This divisor is invariant, so we calculate it as soon as we're able to query the CPU's base speed. */ diff --git a/modules/pcjs/lib/computer.js b/modules/pcjs/lib/computer.js index df714412e..438434465 100644 --- a/modules/pcjs/lib/computer.js +++ b/modules/pcjs/lib/computer.js @@ -1235,14 +1235,14 @@ Computer.prototype.onReset = function() }; /** - * getComponentByType(sType, componentPrev) + * getMachineComponent(sType, componentPrev) * * @this {Computer} * @param {string} sType * @param {Component|null} [componentPrev] of previously returned component, if any * @return {Component|null} */ -Computer.prototype.getComponentByType = function(sType, componentPrev) +Computer.prototype.getMachineComponent = function(sType, componentPrev) { var aComponents = Component.getComponents(this.id); for (var iComponent = 0; iComponent < aComponents.length; iComponent++) { diff --git a/modules/pcjs/lib/cpu.js b/modules/pcjs/lib/cpu.js index b70511a75..34783c5b1 100644 --- a/modules/pcjs/lib/cpu.js +++ b/modules/pcjs/lib/cpu.js @@ -186,7 +186,7 @@ CPU.prototype.initBus = function(cmp, bus, cpu, dbg) * Attach the Video component to the CPU, so that the CPU can periodically update * the video display via updateVideo(), as cycles permit. */ - for (var video = null; (video = cmp.getComponentByType("Video", video));) { + for (var video = null; (video = cmp.getMachineComponent("Video", video));) { this.aVideo.push(video); } /* @@ -195,7 +195,7 @@ CPU.prototype.initBus = function(cmp, bus, cpu, dbg) * * We must also call chipset.updateAllTimers() periodically; stepCPU() takes care of that. */ - this.chipset = cmp.getComponentByType("ChipSet"); + this.chipset = cmp.getMachineComponent("ChipSet"); this.setReady(); }; diff --git a/modules/pcjs/lib/debugger.js b/modules/pcjs/lib/debugger.js index 075cc8210..3027d99aa 100644 --- a/modules/pcjs/lib/debugger.js +++ b/modules/pcjs/lib/debugger.js @@ -1202,10 +1202,10 @@ if (DEBUGGER) { this.bus = bus; this.cpu = cpu; this.cmp = cmp; - this.fdc = cmp.getComponentByType("FDC"); - this.hdc = cmp.getComponentByType("HDC"); - this.mouse = cmp.getComponentByType("Mouse"); - if (MAXDEBUG) this.chipset = cmp.getComponentByType("ChipSet"); + this.fdc = cmp.getMachineComponent("FDC"); + this.hdc = cmp.getMachineComponent("HDC"); + this.mouse = cmp.getMachineComponent("Mouse"); + if (MAXDEBUG) this.chipset = cmp.getMachineComponent("ChipSet"); this.cchAddr = bus.getWidth() >> 2; this.maskAddr = bus.nBusLimit; @@ -2630,7 +2630,7 @@ if (DEBUGGER) { sInfo = '%' + str.toHex(addr) + ": " + (this.bus.getSymbol(addr, true) || sInfo); } else { var component, componentPrev = null; - while (component = this.cmp.getComponentByType("Disk", componentPrev)) { + while (component = this.cmp.getMachineComponent("Disk", componentPrev)) { var aInfo = component.getSymbolInfo(sAddr); if (aInfo.length) { sInfo = ""; @@ -3040,7 +3040,7 @@ if (DEBUGGER) { var aSymbols = []; if (SYMBOLS) { var component, componentPrev = null; - while (component = this.cmp.getComponentByType("Disk", componentPrev)) { + while (component = this.cmp.getMachineComponent("Disk", componentPrev)) { aSymbols = component.getModuleInfo(sModule, nSegment); if (aSymbols.length) break; componentPrev = component; diff --git a/modules/pcjs/lib/fdc.js b/modules/pcjs/lib/fdc.js index f2e6aa740..aa6fd01ae 100644 --- a/modules/pcjs/lib/fdc.js +++ b/modules/pcjs/lib/fdc.js @@ -505,7 +505,7 @@ FDC.prototype.setBinding = function(sHTMLType, sBinding, control) } else { if (DEBUG) this.log("Local file support not available"); - control.parentNode.removeChild(control); + control.parentNode.removeChild(/** @type {Node} */ (control)); } return true; @@ -531,7 +531,7 @@ FDC.prototype.initBus = function(cmp, bus, cpu, dbg) this.dbg = dbg; this.cmp = cmp; - this.chipset = cmp.getComponentByType("ChipSet"); + this.chipset = cmp.getMachineComponent("ChipSet"); /* * If we didn't need auto-mount support, we could defer controller initialization until we received a powerUp() notification, diff --git a/modules/pcjs/lib/hdc.js b/modules/pcjs/lib/hdc.js index 57316a7b9..9aa4f92f3 100644 --- a/modules/pcjs/lib/hdc.js +++ b/modules/pcjs/lib/hdc.js @@ -508,7 +508,7 @@ HDC.prototype.initBus = function(cmp, bus, cpu, dbg) * We need access to the ChipSet component, because we need to communicate with * the PIC and DMA controller. */ - this.chipset = cmp.getComponentByType("ChipSet"); + this.chipset = cmp.getMachineComponent("ChipSet"); bus.addPortInputTable(this, this.fATC? HDC.aATCPortInput : HDC.aXTCPortInput); bus.addPortOutputTable(this, this.fATC? HDC.aATCPortOutput : HDC.aXTCPortOutput); diff --git a/modules/pcjs/lib/interrupts.js b/modules/pcjs/lib/interrupts.js index 44be1ed4a..cf19939cf 100644 --- a/modules/pcjs/lib/interrupts.js +++ b/modules/pcjs/lib/interrupts.js @@ -1151,7 +1151,7 @@ if (DEBUGGER) { * 01 Commit all local files (*) (3.0+) * Entry: None * Exit: None - * 02 Close all occurences of file (*) (3.0+) + * 02 Close all occurrences of file (*) (3.0+) * Entry: DS:DX->parameter block (DS:DX->qualified filespec) * Exit: CF=0 None * CF=1 AX=error code diff --git a/modules/pcjs/lib/keyboard.js b/modules/pcjs/lib/keyboard.js index 287c27116..f39d30e6d 100644 --- a/modules/pcjs/lib/keyboard.js +++ b/modules/pcjs/lib/keyboard.js @@ -1131,7 +1131,7 @@ Keyboard.prototype.initBus = function(cmp, bus, cpu, dbg) this.bus = bus; this.cpu = cpu; this.dbg = dbg; - this.chipset = cmp.getComponentByType("ChipSet"); + this.chipset = cmp.getMachineComponent("ChipSet"); }; /** diff --git a/modules/pcjs/lib/memory.js b/modules/pcjs/lib/memory.js index 4134001da..1fcc80bf4 100644 --- a/modules/pcjs/lib/memory.js +++ b/modules/pcjs/lib/memory.js @@ -1465,9 +1465,9 @@ if (PAGEBLOCKS) { } if (TYPEDARRAYS) { - Memory.afnArrayBE = [Memory.prototype.readByteBE, Memory.prototype.readShortBE, Memory.prototype.readLongBE, Memory.prototype.writeByteBE, Memory.prototype.writeShortBE, Memory.prototype.writeLongBE]; - Memory.afnArrayLE = [Memory.prototype.readByteLE, Memory.prototype.readShortLE, Memory.prototype.readLongLE, Memory.prototype.writeByteLE, Memory.prototype.writeShortLE, Memory.prototype.writeLongLE]; - Memory.afnPagedLE = [Memory.prototype.readBytePLE, Memory.prototype.readShortPLE, Memory.prototype.readLongPLE, Memory.prototype.writeBytePLE, Memory.prototype.writeShortPLE, Memory.prototype.writeLongPLE]; + Memory.afnArrayBE = [Memory.prototype.readByteBE, Memory.prototype.readShortBE, Memory.prototype.readLongBE, Memory.prototype.writeByteBE, Memory.prototype.writeShortBE, Memory.prototype.writeLongBE]; + Memory.afnArrayLE = [Memory.prototype.readByteLE, Memory.prototype.readShortLE, Memory.prototype.readLongLE, Memory.prototype.writeByteLE, Memory.prototype.writeShortLE, Memory.prototype.writeLongLE]; + Memory.afnPagedLE = [Memory.prototype.readBytePLE, Memory.prototype.readShortPLE, Memory.prototype.readLongPLE, Memory.prototype.writeBytePLE, Memory.prototype.writeShortPLE, Memory.prototype.writeLongPLE]; } if (NODE) module.exports = Memory; diff --git a/modules/pcjs/lib/mouse.js b/modules/pcjs/lib/mouse.js index fe50c5267..80ba4c1f0 100644 --- a/modules/pcjs/lib/mouse.js +++ b/modules/pcjs/lib/mouse.js @@ -193,7 +193,7 @@ Mouse.prototype.initBus = function(cmp, bus, cpu, dbg) * Attach the Video component to the CPU, so that the CPU can periodically update * the video display via updateVideo(), as cycles permit. */ - for (var video = null; (video = cmp.getComponentByType("Video", video));) { + for (var video = null; (video = cmp.getMachineComponent("Video", video));) { this.aVideo.push(video); } }; @@ -246,7 +246,7 @@ Mouse.prototype.powerUp = function(data, fRepower) } if (this.sAdapterType && !this.componentAdapter) { var componentAdapter = null; - while ((componentAdapter = this.cmp.getComponentByType(this.sAdapterType, componentAdapter))) { + while ((componentAdapter = this.cmp.getMachineComponent(this.sAdapterType, componentAdapter))) { if (componentAdapter.attachMouse) { this.componentAdapter = componentAdapter.attachMouse(this.idAdapter, this); if (this.componentAdapter) { diff --git a/modules/pcjs/lib/panel.js b/modules/pcjs/lib/panel.js index 6f35f8642..e536c7ecc 100644 --- a/modules/pcjs/lib/panel.js +++ b/modules/pcjs/lib/panel.js @@ -348,7 +348,7 @@ Panel.prototype.initBus = function(cmp, bus, cpu, dbg) this.bus = bus; this.cpu = cpu; this.dbg = dbg; - this.kbd = cmp.getComponentByType("Keyboard"); + this.kbd = cmp.getMachineComponent("Keyboard"); }; /** @@ -486,7 +486,7 @@ Panel.prototype.findAddress = function(x, y) x -= rect.x; y -= rect.y; var region = this.busInfo.aRegions[i]; - var iBlock = usr.getBitField(Bus.BlockInfo.num, this.busInfo.aBlocks[region.iBlock]); + var iBlock = usr.getBitField(/** @type {BitField} */ (Bus.BlockInfo.num), this.busInfo.aBlocks[region.iBlock]); var addr = iBlock * this.bus.nBlockSize; var addrLimit = (iBlock + region.cBlocks) * this.bus.nBlockSize - 1; @@ -619,8 +619,8 @@ Panel.prototype.findRegions = function() for (var iBlock = 0; iBlock < this.busInfo.cBlocks; iBlock++) { var blockInfo = this.busInfo.aBlocks[iBlock]; - var typeBlock = usr.getBitField(Bus.BlockInfo.type, blockInfo); - var nBlockCurr = usr.getBitField(Bus.BlockInfo.num, blockInfo); + var typeBlock = usr.getBitField(/** @type {BitField} */ (Bus.BlockInfo.type), blockInfo); + var nBlockCurr = usr.getBitField(/** @type {BitField} */ (Bus.BlockInfo.num), blockInfo); if (typeBlock != typeRegion || nBlockCurr != nBlockPrev + 1) { var cBlocks = iBlock - iBlockRegion; if (cBlocks) { diff --git a/modules/pcjs/lib/ram.js b/modules/pcjs/lib/ram.js index 2206bd80a..31fe9dfd9 100644 --- a/modules/pcjs/lib/ram.js +++ b/modules/pcjs/lib/ram.js @@ -84,7 +84,7 @@ RAM.prototype.initBus = function(cmp, bus, cpu, dbg) this.bus = bus; this.cpu = cpu; this.dbg = dbg; - this.chipset = cmp.getComponentByType("ChipSet"); + this.chipset = cmp.getMachineComponent("ChipSet"); this.setReady(); }; diff --git a/modules/pcjs/lib/serialport.js b/modules/pcjs/lib/serialport.js index 7093124a1..1dbd2b951 100644 --- a/modules/pcjs/lib/serialport.js +++ b/modules/pcjs/lib/serialport.js @@ -408,7 +408,7 @@ SerialPort.prototype.initBus = function(cmp, bus, cpu, dbg) this.bus = bus; this.cpu = cpu; this.dbg = dbg; - this.chipset = cmp.getComponentByType("ChipSet"); + this.chipset = cmp.getMachineComponent("ChipSet"); bus.addPortInputTable(this, SerialPort.aPortInput, this.portBase); bus.addPortOutputTable(this, SerialPort.aPortOutput, this.portBase); this.setReady(); diff --git a/modules/pcjs/lib/video.js b/modules/pcjs/lib/video.js index d8df27ab2..3030efe94 100644 --- a/modules/pcjs/lib/video.js +++ b/modules/pcjs/lib/video.js @@ -2880,7 +2880,7 @@ Video.prototype.initBus = function(cmp, bus, cpu, dbg) * If we have an associated keyboard, then ensure that the keyboard will be notified whenever the canvas * gets focus and receives input. */ - this.kbd = cmp.getComponentByType("Keyboard"); + this.kbd = cmp.getMachineComponent("Keyboard"); if (this.kbd && this.canvasScreen) { for (var s in this.bindings) { if (s.indexOf("lock") > 0) this.kbd.setBinding("led", s, this.bindings[s]); @@ -2889,7 +2889,7 @@ Video.prototype.initBus = function(cmp, bus, cpu, dbg) } this.bEGASwitches = 0x09; // our default "switches" setting (see aEGAMonitorSwitches) - this.chipset = cmp.getComponentByType("ChipSet"); + this.chipset = cmp.getMachineComponent("ChipSet"); if (this.chipset && this.sSwitches) { if (this.nCard == Video.CARD.EGA) this.bEGASwitches = this.chipset.parseSwitches(this.sSwitches, this.bEGASwitches); } @@ -2900,7 +2900,7 @@ Video.prototype.initBus = function(cmp, bus, cpu, dbg) * touch-screen support. */ if (this.sTouchScreen == "mouse") { - this.mouse = cmp.getComponentByType("Mouse"); + this.mouse = cmp.getMachineComponent("Mouse"); if (this.mouse) this.captureTouch(Video.TOUCH.MOUSE); } else if (this.sTouchScreen == "keygrid") { @@ -2939,7 +2939,7 @@ Video.prototype.setBinding = function(sHTMLType, sBinding, control) }; } else { if (DEBUG) this.log("FullScreen API not available"); - control.parentNode.removeChild(control); + control.parentNode.removeChild(/** @type {Node} */ (control)); } return true; @@ -2952,7 +2952,7 @@ Video.prototype.setBinding = function(sHTMLType, sBinding, control) }; } else { if (DEBUG) this.log("Pointer Lock API not available"); - control.parentNode.removeChild(control); + control.parentNode.removeChild(/** @type {Node} */ (control)); } return true; @@ -4326,7 +4326,7 @@ Video.prototype.checkBlink = function() this.cBlinks = 0; /* * At this point, we can either fire up our own timer (doBlink), or rely on updateScreen() - * being called by the CPU at a regular rate (eg, CPU.VIDEO_UPDATES_PER_SECOND = 60) and advance + * being called by the CPU at regular bursts (eg, CPU.VIDEO_UPDATES_PER_SECOND = 60) and advance * cBlinks at the start of updateScreen() accordingly. * * doBlink() wants to increment cBlinks every 266ms. On the other hand, if updateScreen() is being @@ -5142,8 +5142,8 @@ Video.prototype.invalidateScreen = function(fModified) * doBlink() * * This function is obsolete, now that the checkBlink() function is called on every updateScreen() - * and checkCursor() call. updateScreen() is driven by the CPU timer, so piggy-backing on that to - * drive blink updates seems preferable to having another active timer in the system. + * and checkCursor() call. updateScreen() is driven by CPU bursts, so piggy-backing on that to drive + * blink updates seems preferable to having another active timer in the system. * * @this {Video} * @param {boolean} [fStart] @@ -7151,8 +7151,9 @@ Video.init = function() var eTextArea = window.document.createElement("textarea"); /* - * As noted in keyboard.js, the keyboard on an iOS device pops up with the SHIFT key depressed, - * which is not the initial keyboard state that the Keyboard component expects. + * As noted in keyboard.js, the keyboard on an iOS device tends to pop up with the SHIFT key depressed, + * which is not the initial keyboard state that the Keyboard component expects, so hopefully turning off + * these "auto" attributes will help. */ if (web.isUserAgent("iOS")) { eTextArea.setAttribute("autocapitalize", "off"); diff --git a/modules/pcjs/lib/x86cpu.js b/modules/pcjs/lib/x86cpu.js index e21aecfdd..b6f29fe9f 100644 --- a/modules/pcjs/lib/x86cpu.js +++ b/modules/pcjs/lib/x86cpu.js @@ -400,6 +400,7 @@ X86CPU.prototype.enablePageBlocks = function() this.setError("PAGEBLOCKS support required"); return; } + var iBlock; if (this.aMemBlocks === this.aBusBlocks) { this.aMemBlocks = new Array(this.nBlockTotal); /* @@ -424,7 +425,7 @@ X86CPU.prototype.enablePageBlocks = function() */ this.blockUnpaged = new Memory(null, 0, 0, Memory.TYPE.UNPAGED, null, this); this.blockUnpaged.copyBreakpoints(this.dbg); - for (var iBlock = 0; iBlock < this.nBlockTotal; iBlock++) { + for (iBlock = 0; iBlock < this.nBlockTotal; iBlock++) { this.aMemBlocks[iBlock] = this.blockUnpaged; } /* @@ -448,7 +449,7 @@ X86CPU.prototype.enablePageBlocks = function() * a constrained TLB -- at least not from the 80386 era, which is all we're emulating. */ for (var i = 0; i < this.aBlocksPaged.length; i++) { - var iBlock = this.aBlocksPaged[i]; + iBlock = this.aBlocksPaged[i]; this.releasePageBlock(this.aMemBlocks[iBlock]); this.aMemBlocks[iBlock] = this.blockUnpaged; } diff --git a/modules/pcjs/lib/x86func.js b/modules/pcjs/lib/x86func.js index 721123ef2..4f6a39c1f 100644 --- a/modules/pcjs/lib/x86func.js +++ b/modules/pcjs/lib/x86func.js @@ -1694,7 +1694,7 @@ X86.fnLGDT = function(dst, src) } else { /* * Hopefully it won't hurt to always fetch a 32-bit base address (even on an 80286), which we then - * mask apppropriately. + * mask appropriately. */ this.addrGDT = this.getLong(this.regEA + 2) & (this.maskData | (this.maskData << 8)); /* @@ -1756,7 +1756,7 @@ X86.fnLIDT = function(dst, src) } else { /* * Hopefully it won't hurt to always fetch a 32-bit base address (even on an 80286), which we then - * mask apppropriately. + * mask appropriately. */ this.addrIDT = this.getLong(this.regEA + 2) & (this.maskData | (this.maskData << 8)); /* diff --git a/modules/shared/lib/usrlib.js b/modules/shared/lib/usrlib.js index 90f0e68a8..20df284b0 100644 --- a/modules/shared/lib/usrlib.js +++ b/modules/shared/lib/usrlib.js @@ -234,7 +234,7 @@ var BitFields; * The above set bit field "bfs.num" in numeric variable "n" to the value 1. * * @param {Object} bfs - * @return {*} (technically, we transform the bfs object into a BitFields object, but the Closure Compiler won't let us specify that) + * @return {BitFields} */ usr.defineBitFields = function(bfs) {