From 38d4b193cee9594d6085698f1085c9fa9c488f25 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 21 Mar 2023 19:28:15 +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/ExternalScriptable.kt | 12 ++++++------ .../main/java/com/script/rhino/RhinoScriptEngine.kt | 12 ++++++------ .../main/java/com/script/rhino/RhinoWrapFactory.kt | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/rhino/src/main/java/com/script/rhino/ExternalScriptable.kt b/rhino/src/main/java/com/script/rhino/ExternalScriptable.kt index 70a8e4c9a..4a7f7059e 100644 --- a/rhino/src/main/java/com/script/rhino/ExternalScriptable.kt +++ b/rhino/src/main/java/com/script/rhino/ExternalScriptable.kt @@ -38,10 +38,10 @@ import org.mozilla.javascript.Function */ internal class ExternalScriptable @JvmOverloads constructor( context: ScriptContext?, - indexedProps: MutableMap = HashMap() + indexedProps: MutableMap = HashMap() ) : Scriptable { val context: ScriptContext - private val indexedProps: MutableMap + private val indexedProps: MutableMap private var prototype: Scriptable? = null private var parent: Scriptable? = null @@ -63,7 +63,7 @@ internal class ExternalScriptable @JvmOverloads constructor( } @Synchronized - override fun get(name: String, start: Scriptable): Any { + override fun get(name: String, start: Scriptable): Any? { return if (this.isEmpty(name)) { indexedProps.getOrElse(name) { Scriptable.NOT_FOUND } } else { @@ -80,7 +80,7 @@ internal class ExternalScriptable @JvmOverloads constructor( } @Synchronized - override fun get(index: Int, start: Scriptable): Any { + override fun get(index: Int, start: Scriptable): Any? { return indexedProps.getOrElse(index) { Scriptable.NOT_FOUND } } @@ -98,7 +98,7 @@ internal class ExternalScriptable @JvmOverloads constructor( return indexedProps.containsKey(index) } - override fun put(name: String, start: Scriptable, value: Any) { + override fun put(name: String, start: Scriptable, value: Any?) { if (start === this) { synchronized(this) { if (this.isEmpty(name)) { @@ -272,7 +272,7 @@ internal class ExternalScriptable @JvmOverloads constructor( return list.toTypedArray() } - private fun jsToJava(jsObj: Any): Any { + private fun jsToJava(jsObj: Any?): Any? { return if (jsObj is Wrapper) { if (jsObj is NativeJavaClass) { jsObj diff --git a/rhino/src/main/java/com/script/rhino/RhinoScriptEngine.kt b/rhino/src/main/java/com/script/rhino/RhinoScriptEngine.kt index 3fd2df0a0..d69494767 100644 --- a/rhino/src/main/java/com/script/rhino/RhinoScriptEngine.kt +++ b/rhino/src/main/java/com/script/rhino/RhinoScriptEngine.kt @@ -47,7 +47,7 @@ import java.security.* class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable { var accessContext: AccessControlContext? = null private var topLevel: RhinoTopLevel? = null - private val indexedProps: MutableMap + private val indexedProps: MutableMap private val implementor: InterfaceImplementor @Throws(ScriptException::class) @@ -58,7 +58,7 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable { val scope = getRuntimeScope(ctxt) var filename = this["javax.script.filename"] as? String filename = filename ?: "" - ret = cx.evaluateReader(scope, reader, filename, 1, null as Any?) + ret = cx.evaluateReader(scope, reader, filename, 1, null) } catch (re: RhinoException) { val line = if (re.lineNumber() == 0) -1 else re.lineNumber() val msg: String = if (re is JavaScriptException) { @@ -92,7 +92,7 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable { @Throws(ScriptException::class, NoSuchMethodException::class) override fun invokeFunction(name: String, vararg args: Any): Any? { - return this.invoke(null as Any?, name, *args) + return this.invoke(null, name, *args) } @Throws(ScriptException::class, NoSuchMethodException::class) @@ -140,7 +140,7 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable { override fun getInterface(clasz: Class): T? { return try { - implementor.getInterface(null as Any?, clasz) + implementor.getInterface(null, clasz) } catch (var3: ScriptException) { null } @@ -191,7 +191,7 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable { js, "print", 1, - null as Any? + null ) } finally { Context.exit() @@ -214,7 +214,7 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable { if (fileName == null) { fileName = "" } - val scr = cx.compileReader(script, fileName, 1, null as Any?) + val scr = cx.compileReader(script, fileName, 1, null) ret = RhinoCompiledScript(this, scr) } catch (var9: Exception) { throw ScriptException(var9) diff --git a/rhino/src/main/java/com/script/rhino/RhinoWrapFactory.kt b/rhino/src/main/java/com/script/rhino/RhinoWrapFactory.kt index 17d3d6602..a09ec027a 100644 --- a/rhino/src/main/java/com/script/rhino/RhinoWrapFactory.kt +++ b/rhino/src/main/java/com/script/rhino/RhinoWrapFactory.kt @@ -105,7 +105,7 @@ internal class RhinoWrapFactory private constructor() : WrapFactory() { scope: Scriptable?, obj: Any?, type: Class<*>? - ) : NativeJavaObject(scope, null as Any?, type) { + ) : NativeJavaObject(scope, null, type) { init { javaObject = obj }