Skip to content

v8 boundary: array marshal for T[] return types #615

@cs01

Description

@cs01

Pragma-file functions declared (): number[] or (): string[] currently fall through to opaque JSHandle. Native caller can't iterate.

Ask

Marshal synth (src/marshal-wrapper.ts) detects array return types. Emits loop:

  1. cs_v8_handle_array_length(handle) -> number
  2. For each index cs_v8_handle_array_get(handle, i) -> JSHandle
  3. Unmarshal each element per element type
  4. Build native number[] / string[] array

New bridge fns (c_bridges/node-bridge.cc)

  • double cs_v8_handle_array_length(double h)
  • double cs_v8_handle_array_get(double h, double i)

Scope

  • Supported element types v1: number, string, boolean
  • Nested arrays (number[][]): later
  • Fixture: pragma exports () => [1,2,3], native sums it

Est

~200-300 LOC. ~1 day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requeststatus:plannedTracked, not scheduledv8-escape-hatchPragma / libnode / JSHandle marshalling work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions