kunfei 3 лет назад
Родитель
Сommit
f20bb539ce

+ 18 - 0
app/src/main/java/io/legado/app/help/rhino/RhinoScriptEngine.kt

@@ -0,0 +1,18 @@
+package io.legado.app.help.rhino
+
+import org.mozilla.javascript.Context
+
+object RhinoScriptEngine {
+
+
+    fun run(function: (Context) -> Any?): Any? {
+        return try {
+            val context = Context.enter()
+            function.invoke(context)
+        } finally {
+            Context.exit()
+        }
+    }
+
+
+}

+ 0 - 9
modules/rhino1.7.3/src/main/java/com/script/rhino/RhinoScriptEngine.kt

@@ -48,15 +48,6 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
     private val indexedProps: MutableMap<Any, Any?>
     private val implementor: InterfaceImplementor
 
-    fun run(function: (Context) -> Any?): Any? {
-        return try {
-            val context = Context.enter()
-            function.invoke(context)
-        } finally {
-            Context.exit()
-        }
-    }
-
     @Throws(ScriptException::class)
     override fun eval(reader: Reader, scope: Scriptable): Any? {
         val cx = Context.enter()

+ 0 - 9
modules/rhino1.7.4/src/main/java/com/script/rhino/RhinoScriptEngine.kt

@@ -48,15 +48,6 @@ class RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
      private val indexedProps: MutableMap<Any, Any?>
      private val implementor: InterfaceImplementor
 
-     fun run(function: (Context) -> Any?): Any? {
-         return try {
-             val context = Context.enter()
-             function.invoke(context)
-         } finally {
-             Context.exit()
-         }
-     }
-
      @Throws(ScriptException::class)
      override fun eval(reader: Reader, scope: Scriptable): Any? {
          val cx = Context.enter()