-
Notifications
You must be signed in to change notification settings - Fork 0
General info
When configured, created target takes care of generating proper class bindings completely, from class registration, to methods/enums/RPC configuration, automatically or via implemented macros.
Start with simple class extending Label node
in src/example.hpp
// include to extend Label
#include <godot_cpp/classes/label.hpp>
// include to use cppscript macros
#include <cppscript.h>
class Example : public godot::Label {
GCLASS(Example, godot::Label);
};When rebuilding, Example class will be registered and available in editor's node list, no manual registering needed.

Add a method to class and implement it
in src/example.hpp
class Example : public godot::Label {
public:
void do_something();
GCLASS(Example, godot::Label);
};in src/example.hpp
#include <godot_cpp/variant/utility_functions.hpp>
#include "example.hpp"
using namespace godot;
void Example::do_something() {
UtilityFunctions::print("GDExtension working!");
}Add node to scene, and attach this script
extends Example
func _ready():
do_something()Rebuild, run scene, and check console

Again, no manual bindings, method was registered automatically.
By default, all public enums are registered:
- Enums with names register as enums
- Enums without name registered as constants
- Enums with
GBITFIELDmacro are registered as bitfields.
By default, if auto_methods on cppscript configuration stage is True/ON, public methods are registered automatically.
By default, all registered classes are initialized on SCENE stage.
See Macros reference for all available macros.
- Python script parses .hpp headers and generates code to corresponding
.gen/<header_name>.gen.cppfile - After that, it also generates 3 files to
src/directory:-
properties.gen.hContains generated setter/getter methods and symbols that get replaced by them in class declaration
-
scripts.gen.hContains inline functions that
register_types.cppuses to register classes -
cppscript.h- or your custom nameSmall header that you need to include in headers to use cppscript macros.
-
- Then, your configuration, added to existing SCons/CMake scripts, adds needed paths and sources to targets, and builders compile as usual