Skip to content

script: Safe way to create Function #32601

@wusyong

Description

@wusyong

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:

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 a Rc<Function> using JS_NewFunction, JS_GetFunctionObject and Function::new
  • Function::new_raw_obj: Create a *mut JSObject(or handle?) using JS_NewFunction and JS_GetFunctionObject

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/bindingsThe DOM bindingsB-feature-trackingThis issue tracks a particular high-level featureC-assignedThere is someone working on resolving the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions