diff options
| author | mat <git@matdoes.dev> | 2024-11-28 03:17:58 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-11-28 03:17:58 +0000 |
| commit | c36201cc894bcc99a06358eea31d210800980dae (patch) | |
| tree | 03cf79c6e8ee6df5e3a1c198e218bc9de7c6f119 /codegen | |
| parent | 08958c2278b15ebeac8a964f392ebb792e479b61 (diff) | |
| download | azalea-drasl-c36201cc894bcc99a06358eea31d210800980dae.tar.xz | |
change DataComponentPatch::get to take in a generic (and add get_kind, has, and has_kind)
Diffstat (limited to 'codegen')
| -rw-r--r-- | codegen/genitemcomponents.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/codegen/genitemcomponents.py b/codegen/genitemcomponents.py index 73f03081..625af847 100644 --- a/codegen/genitemcomponents.py +++ b/codegen/genitemcomponents.py @@ -109,12 +109,12 @@ def remove_variant(variant: str): # now remove the struct line_before_struct = None # this is the #[derive] line - line_after_struct = None # impl DataComponent for ... {} + line_after_struct = None # impl DataComponent for ... {\n...\n} for i, line in enumerate(list(code)): if line == f'pub struct {variant} {{' or line == f'pub struct {variant};': line_before_struct = i - 1 - elif line == f'impl DataComponent for {variant} {{}}': - line_after_struct = i + 1 + elif line == f'impl DataComponent for {variant} {{': + line_after_struct = i + 3 break if line_before_struct is None: raise ValueError(f'Couldn\'t find struct {variant}') @@ -153,7 +153,9 @@ def add_variant(variant: str): code.append(f'pub struct {variant} {{') code.append(' pub todo: todo!(), // see DataComponents.java') code.append('}') - code.append(f'impl DataComponent for {variant} {{}}') + code.append(f'impl DataComponent for {variant} {{') + code.append(f' const KIND: DataComponentKind = DataComponentKind::{variant};') + code.append('}') with open(ITEM_COMPONENTS_DIR, 'w') as f: f.write('\n'.join(code)) |
