X Tutup

Hey all,

the last weeks I have been working away at the Godot Object Compiler, a Unreal Header Tool-esque code generator for Godot GDExtensions.

It allows you to annotate classes and it’s members and generates the necessary bindings to register properties, functions and signals to the Godot engine.

Internally it uses a tree-sitter parser and generates a simplified AST so the generators can query f.e. the field and parameter types and automatically create the correct variant type and property hints.

Here’s an example how what that can look like:

#include "characters/chicken.generated.h"

GODOT_CLASS();
class Chicken : public CharacterBody3D {
	GODOT_GENERATED_BODY();

public:
	void _physics_process(double p_delta) override;

        GODOT_SIGNAL();
        void goc_goc(float p_volume);

	GODOT_FUNCTION(AnyPeer, CallRemote, Reliable);
	void jump_the_fence();

	GODOT_FUNCTION(ScriptVirtual);
	int pick_food(const Ref<Food>& food);

	GODOT_CATEGORY("Behaviour");
	GODOT_GROUP("Movement");

	GODOT_PROPERTY();
	float speed = 10.0f;

	GODOT_SUBGROUP("Jumping");

	GODOT_PROPERTY();
	float jump_height = 2.0f;

	GODOT_PROPERTY();
	Ref<Curve> jump_curve;

private:
	GODOT_PROPERTY();
	TypedArray<Food> food_in_belly;
};

GODOT_GENERATED_GLOBAL();

The available property hints, usages, variant types, base classes etc are also parsed from the linked godot-cpp headers so it won’t break when something changes upstream (to an extent of course). I’m currently testing with the 4.5 branch.

It’s still early days, but if you have same feedback I’d love to hear it :)

X Tutup