Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
biezhihua committed Sep 19, 2024
1 parent 66c7795 commit f169ff5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,6 @@ internal class GXHostContext(val hostRuntime: GXHostRuntime, val realRuntime: IR
const val MODULE_OS = "os"
const val MODULE_GAIAX_BRIDGE = "GaiaXBridge"

/**
* Global code.
*/
const val EVAL_TYPE_GLOBAL = 0

/**
* Module code.
*/
const val EVAL_TYPE_MODULE = 1

fun create(host: GXHostRuntime, runtime: IRuntime, type: GXJSEngine.EngineType): GXHostContext {
return GXHostContext(host, runtime, type)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,16 @@ internal class QuickJSContext(
if (Log.isScriptLog()) {
Log.e("evaluateJS() called with: script = $script")
}
this.jsContext?.evaluate(script, "", GXHostContext.EVAL_TYPE_MODULE, 0)
/**
* type 代码类型标志:
* JS_EVAL_TYPE_GLOBAL:将代码作为全局代码执行(默认)。
* JS_EVAL_TYPE_MODULE:将代码作为模块代码执行,允许使用 import 和 export。
*
* flag 执行模式标志:
* JS_EVAL_FLAG_STRICT:强制以严格模式执行代码。
* JS_EVAL_FLAG_STRIP:移除调试信息,优化内存使用和安全性。
*/
this.jsContext?.evaluate(script, "index.js", JSContext.EVAL_TYPE_MODULE, JSContext.EVAL_FLAG_STRIP)
}

override fun destroyContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import android.os.Looper
import android.os.Message
import java.util.concurrent.FutureTask

/**
* JS执行线程队列
*/
internal class GaiaXJSTaskQueue private constructor(val contextId: Long) {

companion object {
Expand Down Expand Up @@ -80,6 +83,7 @@ internal class GaiaXJSTaskQueue private constructor(val contextId: Long) {
taskQueue?.sendMessageDelayed(newMsg, oldMsg.arg1.toLong())
targetFunc.invoke()
}

WHAT_DELAY_TASK -> {
val targetFunc = oldMsg.obj as (() -> Unit)
targetFunc.invoke()
Expand Down

0 comments on commit f169ff5

Please sign in to comment.