Skip to content

Callback types (Discussion: was: Generic interface for arrays (eg:wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features)) #486

@zokrezyl

Description

@zokrezyl

Hi,

I am trying to write some (partially) automated binding generators but functions like wgpuDeviceEnumerateFeatures are creating a bit of a headache as it is difficult to reason about them and to expose them.

I would like to suggest a type specific array type or generic interface for the arrays maybe inspired by

https://troydhanson.github.io/uthash/utarray.html

Example:

size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features))

Would become

size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureNameArray *features))

// where
typedef struct WGPUFeatureNameArray {
WGPUFeatureName *array;
size_t size;
} WGPUFeatureNameArray;

One could expose some C like iterators for the xxxArray types.

This would be easier to expose as binding than a random pointer that in specific situations means C array.

Opinions?

Regards

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