mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
a53a25c23d
commit
1f74343a5a
@ -37,23 +37,12 @@ import org.mozilla.javascript.Function
|
|||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
internal class ExternalScriptable @JvmOverloads constructor(
|
internal class ExternalScriptable @JvmOverloads constructor(
|
||||||
context: ScriptContext?,
|
val context: ScriptContext,
|
||||||
indexedProps: MutableMap<Any, Any?> = HashMap()
|
private val indexedProps: MutableMap<Any, Any?> = HashMap()
|
||||||
) : Scriptable {
|
) : Scriptable {
|
||||||
val context: ScriptContext
|
|
||||||
private val indexedProps: MutableMap<Any, Any?>
|
|
||||||
private var prototype: Scriptable? = null
|
private var prototype: Scriptable? = null
|
||||||
private var parent: Scriptable? = null
|
private var parent: Scriptable? = null
|
||||||
|
|
||||||
init {
|
|
||||||
if (context == null) {
|
|
||||||
throw NullPointerException("context is null")
|
|
||||||
} else {
|
|
||||||
this.context = context
|
|
||||||
this.indexedProps = indexedProps
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isEmpty(name: String): Boolean {
|
private fun isEmpty(name: String): Boolean {
|
||||||
return name == ""
|
return name == ""
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.security.AccessControlContext
|
|||||||
* @author A. Sundararajan
|
* @author A. Sundararajan
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER", "unused")
|
||||||
class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
||||||
ImporterTopLevel(cx, System.getSecurityManager() != null) {
|
ImporterTopLevel(cx, System.getSecurityManager() != null) {
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun bindings(
|
fun bindings(
|
||||||
cx: Context?,
|
cx: Context,
|
||||||
thisObj: Scriptable?,
|
thisObj: Scriptable?,
|
||||||
args: Array<Any?>,
|
args: Array<Any?>,
|
||||||
funObj: Function?
|
funObj: Function?
|
||||||
@ -77,7 +77,7 @@ class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun scope(cx: Context?, thisObj: Scriptable?, args: Array<Any?>, funObj: Function?): Any {
|
fun scope(cx: Context, thisObj: Scriptable?, args: Array<Any?>, funObj: Function?): Any {
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
var arg = args[0]
|
var arg = args[0]
|
||||||
if (arg is Wrapper) {
|
if (arg is Wrapper) {
|
||||||
@ -96,7 +96,7 @@ class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sync(cx: Context?, thisObj: Scriptable?, args: Array<Any?>, funObj: Function?): Any {
|
fun sync(cx: Context, thisObj: Scriptable?, args: Array<Any?>, funObj: Function?): Any {
|
||||||
return if (args.size == 1 && args[0] is Function) {
|
return if (args.size == 1 && args[0] is Function) {
|
||||||
Synchronizer(args[0] as Function?)
|
Synchronizer(args[0] as Function?)
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,23 +37,12 @@ import org.mozilla.javascript.Function
|
|||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
internal class ExternalScriptable @JvmOverloads constructor(
|
internal class ExternalScriptable @JvmOverloads constructor(
|
||||||
context: ScriptContext?,
|
val context: ScriptContext,
|
||||||
indexedProps: MutableMap<Any, Any?> = HashMap()
|
private val indexedProps: MutableMap<Any, Any?> = HashMap()
|
||||||
) : Scriptable {
|
) : Scriptable {
|
||||||
val context: ScriptContext
|
|
||||||
private val indexedProps: MutableMap<Any, Any?>
|
|
||||||
private var prototype: Scriptable? = null
|
private var prototype: Scriptable? = null
|
||||||
private var parent: Scriptable? = null
|
private var parent: Scriptable? = null
|
||||||
|
|
||||||
init {
|
|
||||||
if (context == null) {
|
|
||||||
throw NullPointerException("context is null")
|
|
||||||
} else {
|
|
||||||
this.context = context
|
|
||||||
this.indexedProps = indexedProps
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getClassName(): String {
|
override fun getClassName(): String {
|
||||||
return "Global"
|
return "Global"
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import java.security.AccessControlContext
|
|||||||
* @author A. Sundararajan
|
* @author A. Sundararajan
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER", "unused")
|
||||||
class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
||||||
ImporterTopLevel(cx, System.getSecurityManager() != null) {
|
ImporterTopLevel(cx, System.getSecurityManager() != null) {
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun bindings(
|
fun bindings(
|
||||||
cx: Context?,
|
cx: Context,
|
||||||
thisObj: Scriptable?,
|
thisObj: Scriptable?,
|
||||||
args: Array<Any?>,
|
args: Array<Any?>,
|
||||||
funObj: Function?
|
funObj: Function?
|
||||||
@ -77,7 +77,7 @@ class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun scope(cx: Context?, thisObj: Scriptable?, args: Array<Any?>, funObj: Function?): Any {
|
fun scope(cx: Context, thisObj: Scriptable?, args: Array<Any?>, funObj: Function?): Any {
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
var arg = args[0]
|
var arg = args[0]
|
||||||
if (arg is Wrapper) {
|
if (arg is Wrapper) {
|
||||||
@ -86,7 +86,7 @@ class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
|||||||
if (arg is Bindings) {
|
if (arg is Bindings) {
|
||||||
val ctx: ScriptContext = SimpleScriptContext()
|
val ctx: ScriptContext = SimpleScriptContext()
|
||||||
ctx.setBindings(arg as Bindings?, 100)
|
ctx.setBindings(arg as Bindings?, 100)
|
||||||
val res: Scriptable = ExternalScriptable(ctx)
|
val res: Scriptable = cx.initSafeStandardObjects()
|
||||||
res.prototype = getObjectPrototype(thisObj)
|
res.prototype = getObjectPrototype(thisObj)
|
||||||
res.parentScope = getTopLevelScope(thisObj)
|
res.parentScope = getTopLevelScope(thisObj)
|
||||||
return res
|
return res
|
||||||
@ -96,7 +96,7 @@ class RhinoTopLevel(cx: Context, val scriptEngine: RhinoScriptEngine) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sync(cx: Context?, thisObj: Scriptable?, args: Array<Any?>, funObj: Function?): Any {
|
fun sync(cx: Context, thisObj: Scriptable?, args: Array<Any?>, funObj: Function?): Any {
|
||||||
return if (args.size == 1 && args[0] is Function) {
|
return if (args.size == 1 && args[0] is Function) {
|
||||||
Synchronizer(args[0] as Function?)
|
Synchronizer(args[0] as Function?)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user