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

Allow trapping Object.getPrototypeOf in a C proxy class #324

Open
ruochenjia opened this issue Jun 26, 2024 · 0 comments
Open

Allow trapping Object.getPrototypeOf in a C proxy class #324

ruochenjia opened this issue Jun 26, 2024 · 0 comments

Comments

@ruochenjia
Copy link

Currently proxy objects created using C code can only trap property access, but not internal object operations like Object.setPrototypeOf, Object.preventExtensions, which a regular proxy handler in JavaScript could do. This makes it more difficult to pass external JS objects into the quickjs VM when running a WASM version of quickjs.

EMSCRIPTEN_KEEPALIVE void* vm_createproxyobject(JSContext* ctx, JSClassExoticMethods* handler) {
	JSClassID id = JS_NewClassID(0);

	// handler->has_property = ...
	// handler->get_property = ...

	JSClassDef def;
	def.exotic = handler;
	def.class_name = "dummy";

	JS_NewClass(JS_GetRuntime(ctx), id, &def);

	return JS_VALUE_GET_PTR(JS_NewObjectClass(ctx, id));
}
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

1 participant