Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement (or derive) GodotType for godot compatible repr enums #580

Open
jrockett6 opened this issue Jan 24, 2024 · 2 comments
Open

Implement (or derive) GodotType for godot compatible repr enums #580

jrockett6 opened this issue Jan 24, 2024 · 2 comments
Labels
c: register Register classes, functions and other symbols to GDScript feature Adds functionality to the library

Comments

@jrockett6
Copy link
Contributor

I have an enum

#[repr(i32)]
enum RockType {
    Tin = 1,
    Copper = 2,
}

and I would like to be able to

    #[export]
    rock_types: Array<RockType>,

but Array can only hold a GodotType.

Storing an Array<i32> is ok, but we don't have the enum names in the editor and recreating the enum back in rust requires some extra steps.

Would be solved by #334, but posting this as I think this problem much less complex.

@Bromeon Bromeon added feature Adds functionality to the library c: register Register classes, functions and other symbols to GDScript labels Jan 25, 2024
@Bromeon Bromeon mentioned this issue Jan 25, 2024
Closed
@lilizoey
Copy link
Member

lilizoey commented Feb 6, 2024

I dont think the right solution would be to allow user-defined GodotType, rather we should decide on what types can be stored in arrays. For instance we could allow all GodotConvert + ToGodot + FromGodot types, or maybe add a Arrayable trait for things that can go in arrays. or something else.

@Bromeon
Copy link
Member

Bromeon commented Feb 6, 2024

If we want to do this properly, we need Arrayable (named ArrayElem maybe), because not every GodotType can be stored inside arrays.

For example, Array<Array<i32>> is not exportable, because the Godot runtime only stores type information about the outer array type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: register Register classes, functions and other symbols to GDScript feature Adds functionality to the library
Projects
None yet
Development

No branches or pull requests

3 participants