MClass
MClass — the reflection descriptor for an MObject-derived type. One static instance per MCLASS type lives in the codegen-emitted .refl.cpp; MClassRegistry maps typeid → MClass. Aggregate — codegen brace-initialises every field in declaration order; keep new fields at the end.
- Module
- Core
- Header
#include "Core/MObject.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
FName | className | |
FName | superClassName | Name of the direct base class as parsed from the header. The base may live in another module's .refl.cpp (or not be registered at all — e.g. MObject itself for hand-written roots), so the pointer link resolves lazily by name. |
MClass* | superClass | Lazily resolved + cached by GetSuperClass(). nullptr until the first lookup (or forever, when the super isn't registered). Default nullptr. |
uint32_t | classSize | Default 0. |
const FMFunctionInfo* | functions | Codegen-emitted MFUNCTION table — this class's OWN reflected methods. A bare array (not an accessor like getProperties) because the thunks are free functions in the generated TU that only call PUBLIC methods, so no befriended access is needed. nullptr when the class has no MFUNCTION methods. Kept at the end so the codegen's aggregate init stays ABI-additive. Default nullptr. |
uint32_t | functionCount | Default 0. |
void* | userData | Subsystem extension slot — opaque per-class data a higher layer can attach without Core knowing the type. Visual Scripting uses it to point a synthetic (data-driven) MClass back at its VisualScriptClass definition (the source of the BeginPlay/Tick graphs). Codegen never sets it: aggregate brace-init of a generated MClass omits trailing fields, leaving this value-initialised — trailing placement keeps the layout ABI-additive. Default nullptr. |
MObject* | defaultObject | Cached Class Default Object — see GetDefaultObject(). Codegen never sets it (trailing field, value-initialised by aggregate init). Default nullptr. |
const FName* | interfaces | MIMPLEMENTS interface names — this class's OWN declarations; walk the super chain with ImplementsInterface for inherited ones. Bound by a follow-up initialiser in the generated TU (they trail the value-initialised fields, so the aggregate stays ABI-additive). Default nullptr. |
uint32_t | interfaceCount | Default 0. |
uint32_t | classFlags | FMClassFlags, and the open metadata MCLASS(...) carried — bound by the same follow-up initialiser as the interfaces. Default FMClassFlags::None. |
const FMMetaEntry* | meta | Default nullptr. |
uint32_t | metaCount | Default 0. |
Public functions
| Returns | Name | Description |
|---|---|---|
void | Codegen-emitted GC trace — walks this class's OWN MPROPERTY fields (not inherited ones; the GC walks the super chain). | |
bool | HasClassFlag | |
const char* | FindMeta | The value of an own meta entry (no super-chain walk), or nullptr. |
const FMFunctionInfo* | FindFunction | Find an own reflected method by name (no super-chain walk). |
MObject* | GetDefaultObject | Class Default Object. |
bool | ImplementsInterface | Chain-aware MIMPLEMENTS query — the data-driven complement of a dynamic_cast to the C++ interface. |
MClass* | GetSuperClass | Resolve + cache the super MClass via MClassRegistry name lookup. |
bool | IsChildOf | Walks the super chain. |
const FMPropertyInfo* | GetProperties | Returns nullptr + count 0 when the class has no MPROPERTY fields. |
const FMPropertyInfo* | FindProperty | Find an own property by name (no super-chain walk). |
Function details
void
void (*gcTrace)(MObject* self, FReferenceCollector& collector) = nullptrCodegen-emitted GC trace — walks this class's OWN MPROPERTY fields (not inherited ones; the GC walks the super chain). nullptr when the class has no MPROPERTY fields.
HasClassFlag
bool HasClassFlag(uint32_t flag) constFindMeta
const char* FindMeta(const char* key) constThe value of an own meta entry (no super-chain walk), or nullptr.
FindFunction
const FMFunctionInfo* FindFunction(FName name) constFind an own reflected method by name (no super-chain walk).
GetDefaultObject
MObject* GetDefaultObject()Class Default Object. Lazily constructed via the codegen factory on first request, GC-rooted for process lifetime, named "Default__<Class>". SpawnActorByClass clones the CDO's reflected values onto a fresh actor and the scene writer emits only the properties that differ from it, so raising a class default reaches every instance that never overrode the field. Both go through FActorSerializer, which owns the supported-value-kind rule: an edge into the archetype itself or its own components is never cloned (constructors and BeginPlay re-establish it), while value containers, reflected structs, Custom fields and references to other placed actors are cloned and diffed. Returns nullptr for abstract / non-default-constructible classes, in which case spawn constructs plainly and the writer emits the full property set.
ImplementsInterface
bool ImplementsInterface(FName interfaceName)Chain-aware MIMPLEMENTS query — the data-driven complement of a dynamic_cast to the C++ interface. Non-const: walks lazy supers.
GetSuperClass
MClass* GetSuperClass()Resolve + cache the super MClass via MClassRegistry name lookup. Benign race: concurrent callers write the same pointer. Returns nullptr for roots and for supers that aren't registered.
IsChildOf
bool IsChildOf(const MClass* base)Walks the super chain. Non-const because the walk resolves lazy super links.
GetProperties
const FMPropertyInfo* GetProperties(uint32_t& outCount)Returns nullptr + count 0 when the class has no MPROPERTY fields.
FindProperty
const FMPropertyInfo* FindProperty(FName name)Find an own property by name (no super-chain walk).