Skip to content

Commit b2a9ea6

Browse files
committed
GDExtension docs: advise bindings to use uint64_t for bitfields
1 parent 97b8ad1 commit b2a9ea6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/extension/gdextension_interface.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2800,12 +2800,16 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod)(G
28002800
*
28012801
* Registers an integer constant on an extension class in the ClassDB.
28022802
*
2803+
* Note about registering bitfield values (if p_is_bitfield is true): even though p_constant_value is signed, language bindings are
2804+
* advised to treat bitfields as uint64_t, since this is generally clearer and can prevent mistakes like using -1 for setting all bits.
2805+
* Language APIs should thus provide an abstraction that registers bitfields (uint64_t) separately from regular constants (int64_t).
2806+
*
28032807
* @param p_library A pointer the library received by the GDExtension's entry point function.
28042808
* @param p_class_name A pointer to a StringName with the class name.
28052809
* @param p_enum_name A pointer to a StringName with the enum name.
28062810
* @param p_constant_name A pointer to a StringName with the constant name.
28072811
* @param p_constant_value The constant value.
2808-
* @param p_is_bitfield Whether or not this is a bit field.
2812+
* @param p_is_bitfield Whether or not this constant is part of a bitfield.
28092813
*/
28102814
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield);
28112815

0 commit comments

Comments
 (0)