[C++26] Unification of GodotXXXClass into GodotClass, removal of registration macros, using Static Reflection #8

Open
opened 2026-10-22 22:44:10 -07:00 by queertherians.org · 0 comments
Owner

Using C++26, we will no longer require GodotCustomClass; typename TSelf will be entirely obsolete and phased out, GodotExternClass will be renamed to GodotClass<...>, and custom classes will simply inherit from GodotClass<...>.

Registration macros will also be entirely phased out, and in its place will be Annotations, to be processed with Reflection.

All of this will clean up the code SIGNIFICANTLY, and this is a feature I am hugely anticipating. Static Reflection my beloved. <3

We can expect future Custom and Extern classes to look like the following prototypical examples:

// Type alias for readability
using Sprite2D = GodotClass<"Sprite2D">;

// Inherit from an Extern GodotClass with C++26
class MySprite : public Sprite2D
{
public:
    [[=gdxx::Property]] // with default setter/getter
    public long test = 0;

    // custom setter and getter would be defined like this:
    // [[=gdxx::Property(setter_func, getter_func)]]
    // with setter_func and getter_func being methods
    
    [[=gdxx::Method]]
    virtual void _Update(double delta)
    {
        // your code here...
    }
};

// Usual registration (C++23)
static auto& MySprite = MySprite::Register();

// for the purposes of these examples, proper header formatting with the forward declarations is assumed
#include "MySprite.hpp"

// Inherit from a Custom GodotClass(!!) with C++26
class MySpriteButCooler : public MySprite
{
    // your properties/methods here...
};

// Usual registration (C++23)
static auto& MySprite = MySprite::Register(); // ensure this registered first in this TU (Register() is idempotent)
static auto& MySpriteButCooler = MySpriteButCooler::Register();

As of writing, this issue is blocked by Clang/LLVM not yet supporting Static Reflection.

Using C++26, we will no longer require GodotCustomClass; `typename TSelf` will be entirely obsolete and phased out, GodotExternClass will be renamed to `GodotClass<...>`, and custom classes will simply inherit from `GodotClass<...>`. Registration macros will also be entirely phased out, and in its place will be Annotations, to be processed with Reflection. All of this will clean up the code SIGNIFICANTLY, and this is a feature I am hugely anticipating. ~~Static Reflection my beloved. <3~~ We can expect future Custom and Extern classes to look like the following prototypical examples: ```cpp // Type alias for readability using Sprite2D = GodotClass<"Sprite2D">; // Inherit from an Extern GodotClass with C++26 class MySprite : public Sprite2D { public: [[=gdxx::Property]] // with default setter/getter public long test = 0; // custom setter and getter would be defined like this: // [[=gdxx::Property(setter_func, getter_func)]] // with setter_func and getter_func being methods [[=gdxx::Method]] virtual void _Update(double delta) { // your code here... } }; // Usual registration (C++23) static auto& MySprite = MySprite::Register(); ``` --- ```cpp // for the purposes of these examples, proper header formatting with the forward declarations is assumed #include "MySprite.hpp" // Inherit from a Custom GodotClass(!!) with C++26 class MySpriteButCooler : public MySprite { // your properties/methods here... }; // Usual registration (C++23) static auto& MySprite = MySprite::Register(); // ensure this registered first in this TU (Register() is idempotent) static auto& MySpriteButCooler = MySpriteButCooler::Register(); ``` --- As of writing, this issue is blocked by Clang/LLVM not yet supporting Static Reflection.
queertherians.org added this to the C++26 milestone 2026-10-22 22:44:10 -07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
queertherians.org/gdxx#8
No description provided.