-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
script: Safe way to create Function #32601
Copy link
Copy link
Closed
Labels
A-content/bindingsThe DOM bindingsThe DOM bindingsB-feature-trackingThis issue tracks a particular high-level featureThis issue tracks a particular high-level featureC-assignedThere is someone working on resolving the issueThere is someone working on resolving the issue
Description
Describe the new feature:
In #32572, we still need to use unsafe code to create Funtion. The FunctionBinging doesn't provide a safe way to create one. And considering many dom types don't really want Function. Instead, they just want the *mut JSObject from *mut JSFunction:
- https://github.com/servo/servo/blob/main/components/script/dom/bindings/interface.rs#L341
- https://github.com/servo/servo/blob/main/components/script/dom/promise.rs
We should propose a safe wrapper function(s) for JS_NewFunction and JS_GetFunctionObject. Here are the method I think we could add:
-
Function::new_native: Create aRc<Function>usingJS_NewFunction,JS_GetFunctionObjectandFunction::new -
Function::new_raw_obj: Create a*mut JSObject(or handle?) usingJS_NewFunctionandJS_GetFunctionObject
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-content/bindingsThe DOM bindingsThe DOM bindingsB-feature-trackingThis issue tracks a particular high-level featureThis issue tracks a particular high-level featureC-assignedThere is someone working on resolving the issueThere is someone working on resolving the issue