优化
This commit is contained in:
@@ -38,10 +38,10 @@ import org.mozilla.javascript.Function
|
||||
*/
|
||||
internal class ExternalScriptable @JvmOverloads constructor(
|
||||
context: ScriptContext?,
|
||||
indexedProps: MutableMap<Any, Any> = HashMap()
|
||||
indexedProps: MutableMap<Any, Any?> = HashMap()
|
||||
) : Scriptable {
|
||||
val context: ScriptContext
|
||||
private val indexedProps: MutableMap<Any, Any>
|
||||
private val indexedProps: MutableMap<Any, Any?>
|
||||
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
|
||||
|
||||
@@ -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<Any, Any>
|
||||
private val indexedProps: MutableMap<Any, Any?>
|
||||
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 ?: "<Unknown source>"
|
||||
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 <T> getInterface(clasz: Class<T>): 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 = "<Unknown Source>"
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user