Skip to content

Ability to pass napi-zig created structs #9

Description

@juicy-orange

I would like to be able to receive a pointer to existing struct that was created in JS land via napi class. Right now JS to Zig passes only specific types, such as primitives or Objects, which require conversion with exception to Buffer and typed arrays.

Ideally it would be great to create a struct as napi class, and pass same class from JS as struct input value in Zig code. There are multiple benefits for such approach. Certain resources that were allocated would no longer need to be converted to say Array of numbers or a string, cutting down on allocations significantly. Not to mention that it would be great to work with native structs this way in Zig.

I do not know if it is already possible to do that, I would appreciate an example if it is. Otherwise I'm sure there is a way to either recognize which struct is which (perhaps can be done by adding specific napi-zig tracking information on struct or wrapper). I would appreciate ability to use such structs in Zig.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions