Skip to content

GodotShape refactor; open Element for enums#1513

Merged
Bromeon merged 4 commits intomasterfrom
feature/godot-shape
Mar 1, 2026
Merged

GodotShape refactor; open Element for enums#1513
Bromeon merged 4 commits intomasterfrom
feature/godot-shape

Conversation

@Bromeon
Copy link
Copy Markdown
Member

@Bromeon Bromeon commented Mar 1, 2026

Major refactoring of the #[var] and #[export] inner workings, in particular regarding handling of property hints, hint strings and usage flags.

Before, property customization were widely scattered across the whole codebase, with quite some redundancy and non-intuitive data flows. For example, typed and untyped arrays need to be registered completely different, then there are subtle differences regarding #[var] and #[export] contexts, plus other nuances like VariantType::NIL being used as both Variant and void.

This PR brings an end to this mess with a central enum, being returned from GodotConvert::godot_shape():

#[non_exhaustive]
pub enum GodotShape {
    Variant,
    Builtin {
        variant_type: VariantType,
    },
    Class {
        class_id: ClassId,
        heritage: ClassHeritage,
    },
    TypedArray {
        element_shape: Box<GodotShape>,
    },
    TypedDictionary {
        key_shape: Box<GodotShape>,
        value_shape: Box<GodotShape>,
    },
    Enum {
        variant_type: VariantType,
        enumerators: Cow<'static, [Enumerator]>,
        godot_name: Option<CowStr>,
        is_bitfield: bool,
    },
    Custom {
        variant_type: VariantType,
        var_hint: PropertyHintInfo,
        export_hint: PropertyHintInfo,
        class_name: Option<CowStr>,
        usage_flags: PropertyUsageFlags,
    },
}

Removes the following APIs:

  • Var::var_hint()
  • Export::export_hint()
  • GodotType::property_info()
  • GodotType::property_hint_info()
  • Tons of tiny helpers, like PropertyHintInfo methods: var_array_element<T>, export_array_element<T>, var_dictionary_element<K, V>, export_dictionary_element<K, V>, export_packed_array_element<T>, export_gd<T>, export_dyn_gd<T, D>, ...

Furthermore, this opens up the Element trait to allow enums to be stored in arrays and dictionaries. Adds extensive tests for enums, bitfields, and nested ones in array/dictionary.

Closes #353.
Paves the way for a future #890.
Diff is +700, however this also adds a new feature (enum support). Plus, 260 of it are new tests, and 210 are extra docs.

@Bromeon Bromeon added this to the 0.5 milestone Mar 1, 2026
@Bromeon Bromeon added feature Adds functionality to the library c: core Core components c: register Register classes, functions and other symbols to GDScript breaking-change Requires SemVer bump labels Mar 1, 2026
@Bromeon Bromeon force-pushed the feature/godot-shape branch from 7cfee93 to affd5e1 Compare March 1, 2026 15:07
@GodotRust
Copy link
Copy Markdown

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1513

@Bromeon Bromeon force-pushed the feature/godot-shape branch from affd5e1 to e4c4706 Compare March 1, 2026 16:11
@Bromeon Bromeon force-pushed the feature/godot-shape branch from e4c4706 to 6134e27 Compare March 1, 2026 16:46
@Bromeon Bromeon added this pull request to the merge queue Mar 1, 2026
Merged via the queue into master with commit 89ec94c Mar 1, 2026
23 checks passed
@Bromeon Bromeon deleted the feature/godot-shape branch March 1, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Requires SemVer bump c: core Core components c: register Register classes, functions and other symbols to GDScript feature Adds functionality to the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support enums in arrays, with correct export hints

2 participants