Add the ability to pass through any string property to PCjs declared at the top of the Markdown file

This commit is contained in:
Jeff Parsons 2016-02-01 10:00:05 -08:00
commit 5b7dce1224
7 changed files with 51 additions and 12 deletions

View file

@ -32,7 +32,7 @@ gems:
pcjs:
domain: pcjs.org # whereas site.url is used for linking purposes, site.pcjs.domain is used for display purposes
version: 1.20.8 # IMPORTANT: keep pcjs.version in sync with package.json:version
compiled: true # by default, the compiled pcjs.version scripts will be used (eg, pc.js or pc-dbg.js)
compiled: false # by default, the compiled pcjs.version scripts will be used (eg, pc.js or pc-dbg.js)
pc_scripts: # if pcjs.compiled is false, the following scripts will be included instead, in the order listed
- /modules/shared/lib/defines.js
- /modules/shared/lib/diskapi.js

View file

@ -10,7 +10,7 @@
{% else %}
{% assign machine_template = machine.template %}
{% endunless %}
{% capture machine_parms %}{{ site.left_brace }}state:"{{ machine.state }}",autoMount:{{ machine.automount|jsonify }}{{ site.right_brace }}{% endcapture %}
{% capture machine_parms %}{{ site.left_brace }}state:"{{ machine.state }}",autoMount:{{ machine.automount|jsonify }},messages:"{{ machine.messages }}"{{ site.right_brace }}{% endcapture %}
{% if site.pcjs.compiled == true and machine.uncompiled != true %}
{% capture machine_script %}<script type="text/javascript" src="{{ site.baseurl }}/versions/{{ machine.type | remove:'-dbg' }}js/{{ site.pcjs.version }}/{{ machine.type }}.js"></script>{% endcapture %}
{% unless machine_scripts contains machine_script %}

View file

@ -9,6 +9,7 @@ machines:
automount:
A:
path: /disks/pc/os2/misc/football/FOOTBALL-76817.json
messages: disk
---
OS/2 FOOTBALL Boot Disk (v7.68.17)

View file

@ -308,6 +308,28 @@ MarkOut.aHTMLEntities = {
"\\!": "&#33;"
};
/*
* This is a list of "reserved" Front Matter machine properties (ie, properties that will NOT be
* bundled as strings in the 'parms' property). Any machine property not in this list will be added
* to the 'parms' object as a string property.
*
* 'id' (eg, "ibm5150")
* 'type' (eg, "pc")
* 'config' (eg, "machine.xml")
* 'template' (eg, "machine.xsl")
* 'uncompiled' (eg, true)
* 'automount' (eg, {"A":{"name":"OS/2 FOOTBALL Boot Disk (v7.68.17)","path":"/disks/pc/os2/misc/football/debugger/FOOTBALL-7.68.17.json"}})
* 'parms'
*
* Non-reserved properties include:
*
* 'state' (eg, "state.json")
* 'messages' (eg, "disk")
*
* and any other string-based property you wish to pass through to PCjs (via the embedPC() sParms parameter).
*/
MarkOut.aFMReservedMachineProps = ['id', 'type', 'config', 'template', 'uncompiled', 'automount', 'parms'];
/**
* convertMD()
*
@ -377,30 +399,33 @@ MarkOut.prototype.convertMD = function(sIndent)
var asMachines = aMachineDefs[1].split(/\n[ \t]+-\s*/);
for (var iMachine = 0; iMachine < asMachines.length; iMachine++) {
if (!asMachines[iMachine]) continue;
var id = null;
var id = null, iProp, sProp;
var aOptions, aaOptions = [], machine = {};
var reOption = /([ \t]*)([^\s]+):[ \t]*([^\n]*)/g;
while (aOptions = reOption.exec(asMachines[iMachine])) {
aaOptions.push(aOptions);
}
for (var iOption = 0; iOption < aaOptions.length; iOption++) {
var aOptions = aaOptions[iOption];
aOptions = aaOptions[iOption];
var sSpace = aOptions[1], sName = aOptions[2], sValue = aOptions[3];
if (!id && sName == 'id') {
id = sValue;
} else if (sName == 'automount') {
/*
* I take a simplistic approach to parsing the object definition associated with "automount",
* because I know it only consist of 1 or more drive letters, each of which may be followed by
* 1 or 2 additional properties (eg, "name" and "path"). If we need to support other JSON
* because I know it only consists of 1 or more drive letters, each of which may be followed
* by 1 or 2 additional properties (eg, "name" and "path"). If we need to support other JSON
* object definitions in the future, this will have to be generalized.
*
* Here's an example of "automount" output:
*
* {"A":{"name":"OS/2 FOOTBALL Boot Disk (v7.68.17)","path":"/disks/pc/os2/misc/football/debugger/FOOTBALL-7.68.17.json"}}
*
* Note that the the only required property for a drive object is 'path'; if 'name' is omitted,
* the FDC component will search for the given 'path' and use whatever name it can find.
*/
sValue = '{';
var cDrives = 0, cProps = 0, iProp;
var cDrives = 0, cProps = 0;
for (iProp = iOption + 1; iProp < aaOptions.length; iProp++) {
var sPropSpace = aaOptions[iProp][1];
if (sPropSpace.length <= sSpace.length) break;
@ -423,9 +448,16 @@ MarkOut.prototype.convertMD = function(sIndent)
machine[sName] = sValue;
}
/*
* Any 'state' and 'automount' properties must now be merged into a 'parms' property.
* Any "non-reserved" properties are now merged into the 'parms' property; 'automount'
* is treated as reserved only because it must be encoded as an object rather than a string.
*/
machine['parms'] = '{state:"' + (machine['state'] || "") + '",autoMount:' + machine['automount'] + '}';
machine['parms'] = '{';
for (sProp in machine) {
if (MarkOut.aFMReservedMachineProps.indexOf(sProp) < 0) {
machine['parms'] += sProp + ':"' + machine[sProp] + '",';
}
}
machine['parms'] += 'autoMount:' + machine['automount'] + '}';
if (id) this.aMachineDefs[id] = machine;
}
}

View file

@ -250,6 +250,7 @@ function Debugger(parmsDbg)
/*
* Initialize Debugger message support
*/
this.afnDumpers = [];
this.messageInit(parmsDbg['messages']);
this.sInitCommands = parmsDbg['commands'];
@ -1471,6 +1472,12 @@ if (DEBUGGER) {
this.mouse = cmp.getMachineComponent("Mouse");
if (MAXDEBUG) this.chipset = cmp.getMachineComponent("ChipSet");
/*
* Re-initialize Debugger message support if necessary
*/
var sMessages = cmp.getMachineParm('messages');
if (sMessages) this.messageInit(sMessages);
this.cchAddr = bus.getWidth() >> 2;
this.maskAddr = bus.nBusLimit;
@ -3320,7 +3327,6 @@ if (DEBUGGER) {
this.dbg = this;
this.bitsMessage = this.bitsWarning = Messages.WARN;
this.sMessagePrev = null;
this.afnDumpers = [];
/*
* Internally, we use "key" instead of "keys", since the latter is a method on JavasScript objects,
* but externally, we allow the user to specify "keys"; "kbd" is also allowed as shorthand for "keyboard".

View file

@ -1441,7 +1441,7 @@ FDC.prototype.findDiskette = function(sPath)
}
}
}
return null;
return str.getBaseName(sPath, true);
};
/**

View file

@ -249,7 +249,7 @@ str.toHexLong = function(l)
*
* This is a poor-man's version of Node's path.basename(), which Node-only components should use instead.
*
* Note that fStripExt can be used to strip ANY extension, whereas path.basename() will strip the extension only
* Note that if fStripExt is true, this strips ANY extension, whereas path.basename() strips the extension only
* if it matches the second parameter (eg, path.basename("/foo/bar/baz/asdf/quux.html", ".html") returns "quux").
*
* @param {string} sFileName