Support registering godot enums and bitfields. #890
Labels
c: register
Register classes, functions and other symbols to GDScript
feature
Adds functionality to the library
In Godot, a class can have integer constants as well as enums/bitfields. These enums and bitfields are largely just a convenient way of grouping together integer constants, since under the hood they are just integer constants and not fully-featured sum types like what rust has. From what i understand, enums and bitfields are largely the same from the perspective of ffi.
We have long had support for registering integer constants associated with a class, when this was added we also made the infrastructure needed to register enums and bitfields with a class. However it wasn't clear what syntax should be used to actually register them with the proc-macros. The most obvious syntax, something like
Does not work since enums cannot be declared in an impl block. This would be helped by inherent associated types since we could then declare a type alias in the impl block.
The main things to take into account for enums and bitfields are:
Some possible syntaxes:
@Houtamelo made a declarative macro that emulates this:
The text was updated successfully, but these errors were encountered: