Method overriding and registration within Godot Classes #5

Open
opened 2026-10-21 17:56:08 -07:00 by queertherians.org · 1 comment
Owner

This pertains mostly to work being done in include/GodotClass_utilities.hpp.


Mainly following the gdextension C example guide:

  • Create templates for fetching Variant-type specific functions
  • Create ptrcall template
  • Create (variant)call template
  • Create property info utility
  • Create bind_method template
  • Create method binding registration utility
  • Create property registration utility
  • ^ Related registration macros or other registration utility for use in a derived GodotCustomClass
  • Similar binding utilities for gdxx::GodotExternClass
  • Implement annotation code for registering methods/properties
  • Have registration call each annotation
  • Add new annotation: constants(?) via something like classdb_register_extension_class_integer_constant

Type safety, type to variant mapping, and translation utilities:

  • Specialize gdxx::StringName <-> Variant converters
  • Specialize gdxx::String <-> Variant converters
  • Specialize gdxx::GodotClass <-> Variant converters (related to #1)
  • Confirm if void* and const void* are safely blindly convertible between Variant as an Object, assuming Variant pointers(??)
  • Separate conversion utility into a separate function that returns a reference to the target type
  • Future: Support for more variant types with the respective specialized converters1

  1. Refer to // NOT-DONE comment sections in include/GodotClass_utilities.hpp ↩︎

This pertains mostly to work being done in [`include/GodotClass_utilities.hpp`](https://barkvr.dev/queertherians.org/gdxx/src/branch/main/include/GodotClass_utilities.hpp). --- Mainly following the [gdextension C example guide](https://docs.godotengine.org/en/stable/engine_details/engine_api/gdextension/gdextension_c_example.html#custom-methods): - [x] Create templates for fetching Variant-type specific functions - [x] Create ptrcall template - [x] Create (variant)call template - [x] Create [property info utility](https://docs.godotengine.org/en/stable/engine_details/engine_api/gdextension/gdextension_c_example.html#custom-methods:~:text=implement%20the%20functions,-to) - [x] Create [bind_method template](https://docs.godotengine.org/en/stable/engine_details/engine_api/gdextension/gdextension_c_example.html#custom-methods:~:text=Version%20for%200%20arguments,-%2C%20with%20return%2E%20void%20bind%5Fmethod%5F0%5Fr%28%20const%20char%20%2Aclass%5Fname%2C%20const%20char%20%2Amethod%5Fname%2C%20void%20%2Afunction%2C%20GDExtensionVariantType%20return%5Ftype%29%20%7B%20StringName) - [x] Create [method binding registration](https://docs.godotengine.org/en/stable/engine_details/engine_api/gdextension/gdextension_c_example.html#custom-methods:~:text=Now%20that%20we%20have%20the%20means%20to%20bind%20methods%2C%20we%20can%20actually%20do) utility - [ ] Create [property registration](https://docs.godotengine.org/en/stable/engine_details/engine_api/gdextension/gdextension_c_example.html#custom-properties) utility - [ ] ^ Related registration macros or other registration utility for use in a derived GodotCustomClass - [ ] Similar binding utilities for gdxx::GodotExternClass - [ ] Implement annotation code for registering methods/properties - [ ] Have registration call each annotation - [ ] Add new annotation: constants(?) via something like `classdb_register_extension_class_integer_constant` --- Type safety, type to variant mapping, and translation utilities: - [x] Specialize gdxx::StringName <-> Variant converters - [x] Specialize gdxx::String <-> Variant converters - [ ] Specialize gdxx::GodotClass <-> Variant converters (related to #1) - [x] ~~Confirm if void* and const void* are safely blindly convertible between Variant as an Object, assuming Variant pointers(??)~~ - [x] Separate conversion utility into a separate function that returns a reference to the target type - Future: Support for more variant types with the respective specialized converters[^1] [^1]: Refer to `// NOT-DONE` comment sections in `include/GodotClass_utilities.hpp`
queertherians.org changed title from Method overriding and registration within gdxx::GodotCustomClass to Method overriding and registration within Godot Classes 2026-10-22 22:43:47 -07:00
Author
Owner

Regarding "Confirm if void* and const void* are safely blindly convertible", it is not. Instead, this should be (or should be treated as) GDExtensionObjectPtr.

...and this actually gives me a better idea; instead of specializing the template utility generated from include/api_symbols.hpp, we should leave that be (remove the typename ActualNativeType = void parameter) and create a more safe templated converter on the side that internally uses the lower-level utility. That way, it can be a method that actually returns a reference to the fetched resource, and can include things like getting the instance binding for object types we recognize. I'll add this as a to-do list item.

Regarding `"Confirm if void* and const void* are safely blindly convertible"`, it is not. Instead, this should be (or should be treated as) `GDExtensionObjectPtr`. ...and this actually gives me a better idea; instead of specializing the template utility generated from `include/api_symbols.hpp`, we should leave that be (remove the `typename ActualNativeType = void` parameter) and create a more safe templated converter on the side that internally uses the lower-level utility. That way, it can be a method that actually returns a reference to the fetched resource, and can include things like getting the instance binding for object types we recognize. I'll add this as a to-do list item.
Sign in to join this conversation.
No description provided.