Handle MAKI functions being case insensitive (#825)

This commit is contained in:
jberg 2019-08-02 06:58:57 -07:00 committed by Jordan Eldredge
parent 3559953440
commit 97dd22f314
12 changed files with 37 additions and 40 deletions

View file

@ -12,7 +12,7 @@ export default function Variable({ variable }) {
if (obj == null) {
type = "Unknown object";
} else {
type = obj.getClassName();
type = obj.getclassname();
}
break;
case "STRING": {

View file

@ -24,7 +24,7 @@ beforeEach(() => {
mockMessageBox = jest.fn();
// The VM depends upon the arity of this function, so we can't use
// `mockMessageBox` directly.
System.prototype.messageBox = function(a, b, c, d) {
System.prototype.messagebox = function(a, b, c, d) {
mockMessageBox(...arguments);
};
});

View file

@ -14,7 +14,7 @@ function printValue(value) {
if (obj == null) {
type = "Unknown object";
} else {
type = obj.getClassName();
type = obj.getclassname();
}
break;
case "STRING":

View file

@ -132,9 +132,11 @@ function* interpret(start, program, stack = []) {
case 24:
case 112: {
const methodOffset = command.arg;
const { name: methodName, typeOffset: classesOffset } = methods[
let { name: methodName, typeOffset: classesOffset } = methods[
methodOffset
];
methodName = methodName.toLowerCase();
const klass = classes[classesOffset];
// This is a bit awkward. Because the variables are stored on the stack
// before the object, we have to find the number of arguments without

View file

@ -2,12 +2,12 @@ const GuiObject = require("./GuiObject");
class Button extends GuiObject {
/**
* getClassName()
* getclassname()
*
* Returns the class name for the object.
* @ret The class name.
*/
static getClassName() {
static getclassname() {
return "Button";
}
}

View file

@ -3,15 +3,15 @@ const { findDescendantByTypeAndId } = require("../utils");
class Container extends GuiObject {
/**
* getClassName()
* getclassname()
*
* Returns the class name for the object.
* @ret The class name.
*/
static getClassName() {
static getclassname() {
return "Container";
}
getLayout(id) {
getlayout(id) {
return findDescendantByTypeAndId(this, "layout", id);
}
}

View file

@ -2,17 +2,17 @@ const GuiObject = require("./GuiObject");
class Group extends GuiObject {
/**
* getClassName()
* getclassname()
*
* Returns the class name for the object.
* @ret The class name.
*/
static getClassName() {
static getclassname() {
return "Group";
}
getObject(id) {
getobject(id) {
// Not sure this is correct, but it is my understanding this is just an alias
return this.findObject(id);
return this.findobject(id);
}
}

View file

@ -3,38 +3,33 @@ const { findDescendantByTypeAndId } = require("../utils");
class GuiObject extends MakiObject {
/**
* getClassName()
* getclassname()
*
* Returns the class name for the object.
* @ret The class name.
*/
static getClassName() {
static getclassname() {
return "GuiObject";
}
findObject(id) {
findobject(id) {
return findDescendantByTypeAndId(this, null, id);
}
init(newRoot) {
newRoot.js_addChild(this);
return this;
}
setXmlParam(param, value) {
setxmlparam(param, value) {
this.xmlNode.attributes[param] = value;
return value;
}
// need to force all function names to lowercase in the interpreter
// bad hack for now
setXMLParam(param, value) {
return this.setXmlParam(param, value);
}
getXmlParam(param) {
getxmlparam(param) {
const attributes = this.xmlNode.attributes;
if (attributes !== undefined && attributes.hasOwnProperty(param)) {
return attributes[param];
}
return null;
}
getParent() {
getparent() {
return this.parent;
}
}

View file

@ -3,15 +3,15 @@ const { findParentNodeOfType } = require("../utils");
class Layout extends GuiObject {
/**
* getClassName()
* getclassname()
*
* Returns the class name for the object.
* @ret The class name.
*/
static getClassName() {
static getclassname() {
return "Layout";
}
getContainer() {
getcontainer() {
return findParentNodeOfType(this, ["container"]);;
}
}

View file

@ -43,19 +43,19 @@ class MakiObject {
}
/**
* getClassName()
* getclassname()
*
* Returns the class name for the object.
* @ret The class name.
*/
static getClassName() {
static getclassname() {
return "Object";
}
/**
* getId()
*/
getId() {
getid() {
throw new Error("getId not implemented");
}
}

View file

@ -14,12 +14,12 @@ class System extends MakiObject {
}
/**
* getClassName()
* getclassname()
*
* Returns the class name for the object.
* @ret The class name.
*/
static getClassName() {
static getclassname() {
return "System";
}
@ -27,22 +27,22 @@ class System extends MakiObject {
this.js_trigger("onScriptLoaded");
}
getScriptGroup() {
getscriptgroup() {
return this.scriptGroup;
}
getContainer(id) {
getcontainer(id) {
return findDescendantByTypeAndId(this.root, "container", id);
}
getRuntimeVersion() {
getruntimeversion() {
return "5.666";
}
getToken(str, separator, tokennum) {
gettoken(str, separator, tokennum) {
return "Some Token String";
}
getParam() {
getparam() {
return "Some String";
}
messageBox(message, msgtitle, flag, notanymoreId) {
messagebox(message, msgtitle, flag, notanymoreId) {
console.log({ message, msgtitle, flag, notanymoreId });
}
}

View file

@ -3,12 +3,12 @@ const Group = require("./Group");
// Needs to behavve like a group to work with top level scripts that call `getScriptGroup`
class WinampAbstractionLayer extends Group {
/**
* getClassName()
* getclassname()
*
* Returns the class name for the object.
* @ret The class name.
*/
static getClassName() {
static getclassname() {
return "WinampAbstractionLayer";
}
}