Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
Reflection.hpp File Reference

Reflection and metadata system for automatic binding generation. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  esengine::is_component< T >
 Type trait to detect if a type is a reflected component. More...

Namespaces

namespace  esengine

Macros

#define ES_COMPONENT(...)
 Mark a struct/class as a component that should be exposed to scripts.
#define ES_PROPERTY(...)
 Mark a field as a property that should be exposed to scripts.
#define ES_METHOD(...)
 Mark a method that should be exposed to scripts.
#define ES_ENUM(...)
 Mark an enum that should be exposed to scripts.
#define ES_CONST(...)
 Mark a constant that CROSSES the boundary, so EHT emits its TS twin.
#define ES_ENUM_VALUE(name)
 Mark an enum value for explicit naming in bindings.
#define ES_REFLECT_BEGIN
 Begin a reflection block for the binding generator.
#define ES_REFLECT_END
 End a reflection block for the binding generator.

Functions

template<typename T>
constexpr const char * esengine::component_name ()
 Get the script name for a component type.

Variables

template<typename T>
constexpr bool esengine::is_component_v = is_component<T>::value
 Helper variable template for is_component.

Detailed Description

Reflection and metadata system for automatic binding generation.

Provides macros for marking components and properties that should be automatically exposed to scripting languages. Uses a declarative macro-based approach for code generation.

Author
ESEngine Team
Date
2026

Definition in file Reflection.hpp.

Macro Definition Documentation

◆ ES_COMPONENT

#define ES_COMPONENT ( ...)

Mark a struct/class as a component that should be exposed to scripts.

This macro generates metadata that the binding generator tool uses to automatically create JavaScript/TypeScript bindings. Place this macro immediately before the struct/class definition.

ES_COMPONENT(renderable=<field>, transient) states what is true of the COMPONENT, as ES_PROPERTY does for a field; both realms read it out of the generated COMPONENT_META. renderable names the bool gating this component's drawing — a hard EHT error unless that bool exists.

stability=public|beta|experimental is the SDK tier of the generated <Name>Data interface, declared here because the generated file is not editable and an untagged symbol is experimental by default.

ES_COMPONENT(renderable=enabled)
struct Sprite {
bool enabled{true};
};
#define ES_COMPONENT(...)
Mark a struct/class as a component that should be exposed to scripts.
#define ES_PROPERTY(...)
Mark a field as a property that should be exposed to scripts.
Examples
Basic, and Component.

Definition at line 46 of file Reflection.hpp.

Referenced by esengine::ecs::MeshMorph::MeshMorph(), and esengine::ecs::SpringBone::operator==().

◆ ES_CONST

#define ES_CONST ( ...)

Mark a constant that CROSSES the boundary, so EHT emits its TS twin.

Hand-copied, such a constant does not fail when it drifts — a wrong mask decodes a stored cell into a different tile. Marked, it has one author and joins the ABI layout hash. ts=<Name> renames the generated symbol; hex emits the value as hex, for a mask.

Definition at line 129 of file Reflection.hpp.

◆ ES_ENUM

#define ES_ENUM ( ...)

Mark an enum that should be exposed to scripts.

Enums marked with this macro will be available as TypeScript enums with proper type checking.

stability=public|beta|experimental is the SDK tier of the generated enum. A component's fields are made of these, so an enum weaker than the component naming it is a promise with a hole where its vocabulary should be. Untagged means experimental, as everywhere else.

Examples
Enum.

Definition at line 119 of file Reflection.hpp.

◆ ES_ENUM_VALUE

#define ES_ENUM_VALUE ( name)

Mark an enum value for explicit naming in bindings.

Use this to provide custom names for enum values in scripts, or to document their meaning for the binding generator.

Parameters
nameOptional custom name for the enum value
Examples
Enum.

Definition at line 139 of file Reflection.hpp.

◆ ES_METHOD

#define ES_METHOD ( ...)

Mark a method that should be exposed to scripts.

Methods marked with this macro will be callable from JavaScript/TypeScript. Works for both member functions and static functions.

Parameters
...Optional attributes (e.g., "const", "static")
Examples
Component.

Definition at line 106 of file Reflection.hpp.

◆ ES_PROPERTY

#define ES_PROPERTY ( ...)

Mark a field as a property that should be exposed to scripts.

Properties marked with this macro will be accessible from JavaScript/TypeScript with automatic getter/setter generation. Only works inside ES_COMPONENT() marked types.

This is the single authoring site for a field's editor/serialization metadata (RC9-1): the value lives in the struct, the presentation policy lives in the annotation, and EHT generates both the TS metadata and the C++ editor schema from it. Vocabulary parsed/validated by EHT:

Semantics (flags):

  • asset=<type> : asset reference (texture, material, font, audio, spine_skeleton, spine_atlas)
  • animatable : keyframeable via the Sequencer/timeline
  • anim_override : field may be tween-driven; layout must not clobber it
  • anim_flag=<flag> : animation side-effect flag (e.g. ANIM_POS_X on UINode)
  • entity_ref : entity reference (remapped on scene load / instancing)
  • readonly : not editable in the inspector

Editor presentation:

  • min=<n> / max=<n> / step=<n> : numeric range and scrub granularity
  • slider : render as a slider (requires both min= and max=)
  • unit= : unit suffix shown after the value (e.g. °, px, %)
  • label= / tooltip= : human label / hover text
  • category= : inspector group header
  • advanced : tuck behind an "advanced" fold
  • enum_source=<name> / bitmask_source=<name> : editor-resolved option/label source
  • normalized_of=<field> : this value is a fraction of that sibling (same type), so the editor can offer a pixel view of it

Serialization / runtime policy:

  • invalidates=<field> : after an editor set, flip <field> so the owning system re-runs its load path next tick
  • skip_serialize : omit from scene serialization (runtime-only state)
  • replicated : eligible for network replication (RC11; reserved)

Malformed known metadata (a non-numeric min=, slider without a range, invalidates=/normalized_of= naming no field) is a hard EHT error, not a silent drop.

Examples: ES_PROPERTY(asset=texture) ES_PROPERTY(animatable, anim_flag=ANIM_POS_X) ES_PROPERTY(min=0, max=180, unit="°", advanced, category="Spot") ES_PROPERTY(invalidates=needsReload)

Examples
Basic, and Component.

Definition at line 95 of file Reflection.hpp.

◆ ES_REFLECT_BEGIN

#define ES_REFLECT_BEGIN

Begin a reflection block for the binding generator.

The binding generator tool scans for blocks between ES_REFLECT_BEGIN and ES_REFLECT_END to find types that need bindings. This is used in header files.

Definition at line 152 of file Reflection.hpp.

◆ ES_REFLECT_END

#define ES_REFLECT_END

End a reflection block for the binding generator.

Definition at line 157 of file Reflection.hpp.