Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #50: Fixes to re-enable JavaAdapter support. #51

Merged
merged 3 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ subprojects {
apply plugin: 'architectury-plugin'
apply plugin: "io.github.juuxel.loom-vineflower"
apply plugin: "maven-publish"
apply from: "https://files.latmod.com/public/markdown-git-changelog.gradle"

version = rootProject.version
group = rootProject.group
Expand Down Expand Up @@ -132,4 +131,4 @@ task collectJars(type: Copy) {

assemble {
dependsOn(collectJars)
}
}
71 changes: 69 additions & 2 deletions common/src/main/java/dev/latvian/mods/rhino/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,6 @@ public Scriptable newArray(Scriptable scope, Object[] elements) {
return result;
}


/**
* Returns the maximum stack depth (in terms of number of call frames)
* allowed in a single invocation of interpreter. If the set depth would be
Expand Down Expand Up @@ -797,6 +796,74 @@ public final void setMaximumInterpreterStackDepth(int max) {
maximumInterpreterStackDepth = max;
}

//--------------------------
// Primitive conversion methods
//--------------------------

/**
* Convert the value to a JavaScript boolean value.
* <p>
* See ECMA 9.2.
*
* @param value a JavaScript value
* @return the corresponding boolean value converted using
* the ECMA rules
*/
public boolean toBoolean(Object value) {
return ScriptRuntime.toBoolean(this, value);
}

/**
* Convert the value to a JavaScript Number value.
* <p>
* Returns a Java double for the JavaScript Number.
* <p>
* See ECMA 9.3.
*
* @param value a JavaScript value
* @return the corresponding double value converted using
* the ECMA rules
*/
public double toNumber(Object value) {
return ScriptRuntime.toNumber(this, value);
}

/**
* Convert the value to a JavaScript String value.
* <p>
* See ECMA 9.8.
* <p>
*
* @param value a JavaScript value
* @return the corresponding String value converted using
* the ECMA rules
*/
public String toString(Object value) {
return ScriptRuntime.toString(this, value);
}

/**
* Convert the value to an JavaScript object value.
* <p>
* Note that a scope must be provided to look up the constructors
* for Number, Boolean, and String.
* <p>
* See ECMA 9.9.
* <p>
* Additionally, arbitrary Java objects and classes will be
* wrapped in a Scriptable object with its Java fields and methods
* reflected as JavaScript properties of the object.
*
* @param value any Java object
* @param scope global scope containing constructors for Number,
* Boolean, and String
* @return new JavaScript object
*/
public Scriptable toObject(Object value, Scriptable scope) {
return ScriptRuntime.toObject(this, scope, value);
}


/**
* Get a value corresponding to a key.
* <p>
Expand Down Expand Up @@ -1322,4 +1389,4 @@ public Object doTopCall(Scriptable scope, Callable callable, Scriptable thisObj,
}
return result;
}
}
}
Loading