Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.

Preprocessing macros #20

@Galdormin

Description

@Galdormin

First of all, I would like to thank you for this fantastic crate. I think the Cobweb format is really great, especially all the little features that make it so handy.

I would like to know if you had planned to make a preprocessing system with a macro system or a system to quickly define a large number of data?

Here's my use case. I have a large spritesheet and I defined the relation between the index of the atlas and the (composite) enum:

LightAtlas<ComplexLightIcon>{
    off: 0
    on_index:{
        Full(Off): 0
        Full(Green): 1
        Full(Yellow): 2
        Full(Red): 3
        Id(Off): 4
        ....
        Heart(Green): 29
        Heart(Yellow): 30
        Heart(Red): 31
    }
}

It's particularly long and a macro or data definition system could be useful. This could look like this (here inspired by Python):

#defs
$atlas_map = \ 
    $icon.value($color.value):$icon.idx*4 + $color.idx
    for icon, color in combination(
        [Full, Id, Sun, Key, Lever, Hashtag, Corner, Heart],
        [Off, Green, Yellow, Red]
    ) 
\

...

LightAtlas<ComplexLightIcon>{
    off: 0
    on_index:{$atlas_map}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions