优化
This commit is contained in:
@@ -68,6 +68,7 @@ import org.mozilla.javascript.Function
|
|||||||
* @author A. Sundararajan
|
* @author A. Sundararajan
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
|
@Suppress("unused", "UNUSED_PARAMETER")
|
||||||
class JSAdapter private constructor(val adaptee: Scriptable) : Scriptable, Function {
|
class JSAdapter private constructor(val adaptee: Scriptable) : Scriptable, Function {
|
||||||
private var prototype: Scriptable? = null
|
private var prototype: Scriptable? = null
|
||||||
private var parent: Scriptable? = null
|
private var parent: Scriptable? = null
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import org.mozilla.javascript.Function
|
|||||||
* @author A. Sundararajan
|
* @author A. Sundararajan
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
internal class JavaAdapter private constructor(private val engine: Invocable) : ScriptableObject(),
|
internal class JavaAdapter private constructor(private val engine: Invocable) : ScriptableObject(),
|
||||||
Function {
|
Function {
|
||||||
override fun getClassName(): String {
|
override fun getClassName(): String {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import java.security.*
|
|||||||
* @author A. Sundararajan
|
* @author A. Sundararajan
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
||||||
var accessContext: AccessControlContext? = null
|
var accessContext: AccessControlContext? = null
|
||||||
private var topLevel: RhinoTopLevel? = null
|
private var topLevel: RhinoTopLevel? = null
|
||||||
@@ -120,12 +121,11 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|||||||
val localScope = if (thiz1 != null) thiz1 as Scriptable else engineScope
|
val localScope = if (thiz1 != null) thiz1 as Scriptable else engineScope
|
||||||
val obj = ScriptableObject.getProperty(localScope, name) as? Function
|
val obj = ScriptableObject.getProperty(localScope, name) as? Function
|
||||||
?: throw NoSuchMethodException("no such method: $name")
|
?: throw NoSuchMethodException("no such method: $name")
|
||||||
val func = obj
|
var scope = obj.parentScope
|
||||||
var scope = func.parentScope
|
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
scope = engineScope
|
scope = engineScope
|
||||||
}
|
}
|
||||||
val result = func.call(cx, scope, localScope, wrapArguments(args as? Array<Any?>))
|
val result = obj.call(cx, scope, localScope, wrapArguments(args as? Array<Any?>))
|
||||||
var11 = unwrapReturnValue(result)!!
|
var11 = unwrapReturnValue(result)!!
|
||||||
} catch (re: RhinoException) {
|
} catch (re: RhinoException) {
|
||||||
val line = if (re.lineNumber() == 0) -1 else re.lineNumber()
|
val line = if (re.lineNumber() == 0) -1 else re.lineNumber()
|
||||||
@@ -299,7 +299,9 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val DEBUG = false
|
private const val DEBUG = false
|
||||||
|
|
||||||
@Language("js")
|
@Language("js")
|
||||||
@@ -324,6 +326,7 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
ContextFactory.initGlobal(object : ContextFactory() {
|
ContextFactory.initGlobal(object : ContextFactory() {
|
||||||
|
|
||||||
override fun makeContext(): Context {
|
override fun makeContext(): Context {
|
||||||
val cx = super.makeContext()
|
val cx = super.makeContext()
|
||||||
cx.languageVersion = 200
|
cx.languageVersion = 200
|
||||||
|
|||||||
Reference in New Issue
Block a user