Repository: godotengine/godot-cpp
Issue: Inheriting from `EditorInspectorPlugin` no longer compiles since the addition of BitField

In my project I define such a class, with a virtual method containing a `BitField<PropertyUsageFlags>`:
```cpp
class ZN_EditorInspectorPlugin : public EditorInspectorPlugin {
	GDCLASS(ZN_EditorInspectorPlugin, EditorInspectorPlugin)
public:
	// implementation of virtual method
	bool _parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint,
			const String &p_hint_text, BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
//...
```
This causes an error inside `GDCLASS` because it cannot convert the BifField argument while compiling `register_virtuals`:
```
thirdparty\\godot-cpp\\include\\godot_cpp/core/binder_common.hpp(204): error C2039: 'convert': is not a member of 'godot::PtrToArg<godot::Variant::Type>'
thirdparty\\godot-cpp\\include\\godot_cpp/core/binder_common.hpp(204): note: see declaration of 'godot::PtrToArg<godot::Variant::Type>'
thirdparty\\godot-cpp\\include\\godot_cpp/core/binder_common.hpp(223): note: see reference to function template instantiation 'void godot::call_with_ptr_args_ret_helper<T,R,godot::Object*,godot::Variant::Type,const godot::String&,godot::PropertyHint,const godot::String&,godot::BitField<godot::PropertyUsageFlags>,bool,0,1,2,3,4,5,6>(T *,R (__cdecl zylann::ZN_EditorInspectorPlugin::* )(godot::Object *,godot::Variant::Type,const godot::String &,godot::PropertyHint,const godot::String &,godot::BitField<godot::PropertyUsageFlags>,bool),const GDExtensionConstTypePtr *,void *,IndexSequence<0,1,2,3,4,5,6>)' being compiled
        with
        [
            T=zylann::ZN_EditorInspectorPlugin,
            R=bool
        ]
thirdparty\\godot-cpp\\gen\\include\\godot_cpp/classes/editor_inspector_plugin.hpp(83): note: see reference to function template instantiation 'void godot::call_with_ptr_args<T,bool,godot::Object*,godot::Variant::Type,const godot::String&,godot::PropertyHint,const godot::String&,godot::BitField<godot::PropertyUsageFlags>,bool>(T *,R (__cdecl zylann::ZN_EditorInspectorPlugin::* )(godot::Object *,godot::Variant::Type,const godot::String &,godot::PropertyHint,const godot::String &,godot::BitField<godot::PropertyUsageFlags>,bool),const GDExtensionConstTypePtr *,void *)' being compiled
        with
        [
            T=zylann::ZN_EditorInspectorPlugin,
            R=bool
        ]
D:\\a\\godot_voxel\\godot_voxel\\editor\\instance_library\\../../util/godot/classes/editor_inspector_plugin.h(14): note: see reference to function template instantiation 'void godot::EditorInspectorPlugin::register_virtuals<zylann::ZN_EditorInspectorPlugin,godot::EditorInspectorPlugin>(void)' being compiled
thirdparty\\godot-cpp\\include\\godot_cpp/core/binder_common.hpp(203): error C3861: 'convert': identifier not found
thirdparty\\godot-cpp\\include\\godot_cpp/core/binder_common.hpp(204): error C2039: 'convert': is not a member of 'godot::PtrToArg<godot::BitField<godot::PropertyUsageFlags>>'
thirdparty\\godot-cpp\\include\\godot_cpp/core/binder_common.hpp(204): note: see declaration of 'godot::PtrToArg<godot::BitField<godot::PropertyUsageFlags>>'
```

I could not find anywhere a cast for `BitField<PropertyUsageFlags>`, so I tried to workaround the issue by defining it above the class, in global space:
```cpp
VARIANT_BITFIELD_CAST(PropertyUsageFlags)
```
But it clashes with `VARIANT_ENUM_CAST` from `global_constants_binds.h`:
```
thirdparty\\godot-cpp\\gen\\include\\godot_cpp/classes/global_constants_binds.hpp(55): note: see previous definition of 'GetTypeInfo<godot::PropertyUsageFlags,void>'
D:\\a\\godot_voxel\\godot_voxel\\editor\\instance_library\\../../util/godot/classes/editor_inspector_plugin.h(11): error C2766: explicit specialization; 'godot::GetTypeInfo<const godot::PropertyUsageFlags,void>' has already been defined
thirdparty\\godot-cpp\\gen\\include\\godot_cpp/classes/global_constants_binds.hpp(55): note: see previous definition of 'GetTypeInfo<godot::PropertyUsageFlags const ,void>'
D:\\a\\godot_voxel\\godot_voxel\\editor\\instance_library\\../../util/godot/classes/editor_inspector_plugin.h(11): error C2766: explicit specialization; 'godot::GetTypeInfo<godot::PropertyUsageFlags&,void>' has already been defined
thirdparty\\godot-cpp\\gen\\include\\godot_cpp/classes/global_constants_binds.hpp(55): note: see previous definition of 'GetTypeInfo<godot::PropertyUsageFlags &,void>'
D:\\a\\godot_voxel\\godot_voxel\\editor\\instance_library\\../../util/godot/classes/editor_inspector_plugin.h(11): error C2766: explicit specialization; 'godot::GetTypeInfo<const godot::PropertyUsageFlags&,void>' has already been defined
thirdparty\\godot-cpp\\gen\\include\\godot_cpp/classes/global_constants_binds.hpp(55): note: see previous definition of 'GetTypeInfo<godot::PropertyUsageFlags const &,void>'
```

Perhaps the problem is that ALL of the enums in `global_constants_binds` are using `VARIANT_ENUM_CAST`. Maybe some must use `VARIANT_BITFIELD_CAST` *instead*. [It seems to be mutually exclusive](https://github.com/godotengine/godot/blob/00302860541e9cccc59abd93b930af2a6e6ec360/core/variant/binder_common.h#L132).

For now, I can't make my CI compile because I have no idea what kind of workaround I can use here.

Changed files:
binding_generator.py

diff --git a/binding_generator.py b/binding_generator.py
index d3c7261..7634942 100644
--- a/binding_generator.py
+++ b/binding_generator.py
@@ -1621,7 +1621,13 @@ def generate_global_constant_binds(api, output_dir):
         if enum_def["name"].startswith("Variant."):
             continue
 
-        header.append(f'VARIANT_ENUM_CAST(godot::{enum_def["name"]});')
+        if enum_def["is_bitfield"]:
+            header.append(f'VARIANT_BITFIELD_CAST(godot::{enum_def["name"]});')
+        else:
+            header.append(f'VARIANT_ENUM_CAST(godot::{enum_def["name"]});')
+
+    # Variant::Type is not a global enum, but only one line, it is worth to place in this file instead of creating new file.
+    header.append(f"VARIANT_ENUM_CAST(godot::Variant::Type);")
 
     header.append("")