godot
godot copied to clipboard
Use `VARIANT_BITFIELD_CAST()` consistently for all flag enums
Godot version
3.5
System information
PopOS
Issue description
When I get the list of script variables of a node by calling the get_property_list() method, the properties related to export variables comes with the value 8199 in "usage" instead of 8192 used for the flag PROPERTY_USAGE_SCRIPT_VARIABLE. I cannot find this new flag in the Docs and neither in the GlobalScope.xml.
Steps to reproduce
Create a script with some export variables, use the get_property_list() in the _ready() method and analyze the "usage" key of the script variables (that come at the end of the list).
Minimal reproduction project
No response
Property usage is a bit field.
8199 is a combination of 1, 2, 4, and 8192. (PROPERTY_USAGE_STORAGE, PROPERTY_USAGE_EDITOR, PROPERTY_USAGE_NETWORK, and PROPERTY_USAGE_SCRIPT_VARIABLE.)
We have a VARIANT_BITFIELD_CAST() which we can use as a replacement for VARIANT_ENUM_CAST() in master. This is being done for a handful of enums right now, but we need to expand its usage to be consistent across all classes.
Right now, the only visual difference is that enum is replaced by flags in the editor help:

We can probably do a few more things, like displaying the associated power of two syntax with a bitshift syntax (e.g. 1 << 3 for 8).
This will not change documentation in 3.x though, as there is no bitfield hint there.
Note that this will also require bitfield counterparts to BIND_CORE_ENUM_CONSTANT() and BIND_CORE_ENUM_CLASS_CONSTANT() macros to be implemented (for core input and MethodFlags bitfields).