Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vm里使用eval问题 #427

Closed
FoxNick opened this issue Dec 14, 2024 · 2 comments
Closed

Vm里使用eval问题 #427

FoxNick opened this issue Dec 14, 2024 · 2 comments

Comments

@FoxNick
Copy link

FoxNick commented Dec 14, 2024

Vm没法直接使用eval 通过注入方式 存在作用域问题 没法获取结果

@caoccao
Copy link
Owner

caoccao commented Dec 14, 2024

Please check #425 out.

@FoxNick
Copy link
Author

FoxNick commented Dec 18, 2024

// Set a callback that disallows the code generation.
ModifyCodeGenerationFromStringsResult CodeGenerationDisallowed(
V8LocalContext context, V8LocalValue source, bool is_code_like) {
return {false, {}};
}

JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_allowCodeGenerationFromStrings
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jboolean allow) {
RUNTIME_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle);
v8Context->AllowCodeGenerationFromStrings(allow);
#ifdef ENABLE_NODE
if(!allow) {
v8Context->GetIsolate()->SetModifyCodeGenerationFromStringsCallback(&CodeGenerationDisallowed);
}
#endif
}

注释掉 //v8Isolate->SetModifyCodeGenerationFromStringsCallback(nullptr); allowCodeGenerationFromStrings接口判断 设置一个禁用回调

@FoxNick FoxNick closed this as completed Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants