Skip to content

Declare component constants directly in IDL definitions #2388

@teh-cmc

Description

@teh-cmc

A common situation is to have a bunch of constants associated with a specific component, e.g.:

impl DrawOrder {
    /// Draw order used for images if no draw order was specified.
    pub const DEFAULT_IMAGE: DrawOrder = DrawOrder(-10.0);

    /// Draw order used for 2D boxes if no draw order was specified.
    pub const DEFAULT_BOX2D: DrawOrder = DrawOrder(10.0);

    /// Draw order used for 2D lines if no draw order was specified.
    pub const DEFAULT_LINES2D: DrawOrder = DrawOrder(20.0);

    /// Draw order used for 2D points if no draw order was specified.
    pub const DEFAULT_POINTS2D: DrawOrder = DrawOrder(30.0);
}

Now of course we need to manually redefine those in every languages, leading to the usual problems.

We could have some kind of very light flatbuffers DSL in order to centralize these constants and let codegen handle the rest.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions