Skip to content

Allow using structs as API #425

Open
@almarklein

Description

@almarklein

We define structs in wgpu.structs, and use them as follows:

  • In the wgpu-native backend, we use it to check incoming dicts.
  • We generate docs off them, that users can use as a reference how to construct their dicts.

But they are not really part of the user-facing API, and (other than flags and enums) they are not injected into the root namespace.

I propose that we make the objects in wgpu.structs callable, so user can type e.g. wgpu.BindGroupEntry( and let autocompletion kick in to show the possible arguments. The call returns a normal Python dict.

In an interactive shell you can also call such an object, get the dict repr-ed in the console, and copy-paste that into your code.

In summary it makes our API a bit more discoverable.

BTW It's probably better to generate these function's code (as opposed to creating the functions dynamically at startup) so that they can be statically discovered and used (easier) by IDE's to show signatures to the user.

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