From 25ca5f6b8fc1836e85eb20f50375f53162a7fcab Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 20 Mar 2023 18:37:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/script/rhino/InterfaceImplementor.kt | 1 + rhino/src/main/java/com/script/rhino/JSAdapter.kt | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rhino/src/main/java/com/script/rhino/InterfaceImplementor.kt b/rhino/src/main/java/com/script/rhino/InterfaceImplementor.kt index 624f012ed..6bf38be08 100644 --- a/rhino/src/main/java/com/script/rhino/InterfaceImplementor.kt +++ b/rhino/src/main/java/com/script/rhino/InterfaceImplementor.kt @@ -40,6 +40,7 @@ import java.security.PrivilegedExceptionAction * @author Mike Grogan * @since 1.6 */ +@Suppress("UNUSED_PARAMETER") open class InterfaceImplementor(private val engine: Invocable) { @Throws(ScriptException::class) fun getInterface(thiz: Any?, iface: Class?): T? { diff --git a/rhino/src/main/java/com/script/rhino/JSAdapter.kt b/rhino/src/main/java/com/script/rhino/JSAdapter.kt index e68a02c12..522c920ce 100644 --- a/rhino/src/main/java/com/script/rhino/JSAdapter.kt +++ b/rhino/src/main/java/com/script/rhino/JSAdapter.kt @@ -69,7 +69,7 @@ import org.mozilla.javascript.Function * @since 1.6 */ @Suppress("unused", "UNUSED_PARAMETER") -class JSAdapter private constructor(val adaptee: Scriptable) : Scriptable, Function { +class JSAdapter private constructor(var adaptee: Scriptable) : Scriptable, Function { private var prototype: Scriptable? = null private var parent: Scriptable? = null private var isPrototype = false @@ -249,7 +249,7 @@ class JSAdapter private constructor(val adaptee: Scriptable) : Scriptable, Funct val tmp: Scriptable? return if (isPrototype) { tmp = ScriptableObject.getTopLevelScope(scope) - if (args.size > 0) { + if (args.isNotEmpty()) { JSAdapter(Context.toObject(args[0], tmp)) } else { throw Context.reportRuntimeError("JSAdapter requires adaptee") @@ -270,7 +270,7 @@ class JSAdapter private constructor(val adaptee: Scriptable) : Scriptable, Funct private fun getAdapteeFunction(name: String): Function? { val o = ScriptableObject.getProperty(adaptee, name) - return if (o is Function) o else null + return o as? Function } private fun call(func: Function, args: Array): Any { @@ -279,8 +279,8 @@ class JSAdapter private constructor(val adaptee: Scriptable) : Scriptable, Funct val scope = func.parentScope return try { func.call(cx, scope, thisObj, args) - } catch (var7: RhinoException) { - throw Context.reportRuntimeError(var7.message) + } catch (re: RhinoException) { + throw Context.reportRuntimeError(re.message) } }