Bugfixes / Tutorial cleanup

This commit is contained in:
Anuken
2020-11-21 15:50:44 -05:00
parent 96b55c6b1c
commit b09dc47aad
8 changed files with 110 additions and 80 deletions

View File

@ -19,28 +19,28 @@ let modName = "none"
const print = text => log(modName + "/" + scriptName, text);
// js 'extend(Base, ..., {})' = java 'new Base(...) {}'
function extend(/*Base, ..., def*/) {
const Base = arguments[0];
const def = arguments[arguments.length - 1];
// swap order from Base, def, ... to Base, ..., def
const args = [Base, def].concat(Array.from(arguments).splice(1, arguments.length - 2));
//js 'extend(Base, ..., {})' = java 'new Base(...) {}'
function extend(/*Base, ..., def*/){
const Base = arguments[0]
const def = arguments[arguments.length - 1]
//swap order from Base, def, ... to Base, ..., def
const args = [Base, def].concat(Array.from(arguments).splice(1, arguments.length - 2))
// forward constructor arguments to new JavaAdapter
const instance = JavaAdapter.apply(null, args);
// JavaAdapter only overrides functions; set fields too
for (var i in def) {
if (typeof(def[i]) != "function") {
instance[i] = def[i];
//forward constructor arguments to new JavaAdapter
const instance = JavaAdapter.apply(null, args)
//JavaAdapter only overrides functions; set fields too
for(var i in def){
if(typeof(def[i]) != "function"){
instance[i] = def[i]
}
}
return instance;
return instance
}
// For backwards compatibility, use extend instead
//For backwards compatibility, use extend instead
const extendContent = extend;
//these are not sctrictly necessary, but are kept for edge cases
//these are not strictly necessary, but are kept for edge cases
const run = method => new java.lang.Runnable(){run: method}
const boolf = method => new Boolf(){get: method}
const boolp = method => new Boolp(){get: method}