Skip to content

Commit

Permalink
fix onDataInit
Browse files Browse the repository at this point in the history
  • Loading branch information
biezhihua committed Sep 23, 2024
1 parent d6adf29 commit d7f9d5a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion GaiaXAndroidJS/src/main/assets/bootstrap.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ internal class QuickJSContext(
if (Log.isScriptLog()) {
Log.e("jsContext = $jsContext, evaluateJS() called with: script = $script")
}
this.jsContext?.evaluate(script, "index.js", GXHostContext.EVAL_TYPE_MODULE, JSContext.EVAL_FLAG_STRIP)
this.jsContext?.evaluate(script, "index.js", JSContext.EVAL_TYPE_MODULE, 0)
}

override fun <T> evaluateJS(script: String, clazz: Class<T>?): T? {
if (Log.isScriptLog()) {
Log.e("jsContext = $jsContext, evaluateJS() called with: script = $script")
}
val ret = this.jsContext?.evaluate(script, "index.js", JSContext.EVAL_TYPE_MODULE, JSContext.EVAL_FLAG_STRIP, clazz)
// 执行带返回值的JS脚本,需要使用EVAL_TYPE_GLOBAL
val ret = this.jsContext?.evaluate(script, "index.js", JSContext.EVAL_TYPE_GLOBAL, 0, clazz)
if (Log.isScriptLog()) {
Log.e("jsContext = $jsContext, evaluateJS() called with: ret=$ret")
}
Expand Down
4 changes: 0 additions & 4 deletions GaiaXAndroidQuickJS/src/main/c/quickjs-jni.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,6 @@ JNIEXPORT jlong JNICALL Java_com_alibaba_gaiax_quickjs_QuickJS_evaluate(
if (source_code_utf != NULL && file_name_utf != NULL) {
JSValue val = JS_Eval(ctx, source_code_utf, (size_t) source_code_length, file_name_utf, flags);

_LOGD("evaluate val.tag: %ld", val.tag);

COPY_JS_VALUE(ctx, val, result);
}

Expand All @@ -1108,8 +1106,6 @@ JNIEXPORT jlong JNICALL Java_com_alibaba_gaiax_quickjs_QuickJS_evaluate(

CHECK_NULL_RET(env, result, MSG_OOM);

_LOGD("evaluate result: %p", result);

return (jlong) result;
}

Expand Down

0 comments on commit d7f9d5a

Please sign in to comment.