### Basic Project Setup Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/CMakeLists.txt Sets the minimum CMake version and project name. Includes subdirectories for dependencies. ```cmake cmake_minimum_required(VERSION 3.14.0) project(RefurekuGenerator) # Build dependencies add_subdirectory(ThirdParty/Kodgen) ``` -------------------------------- ### Get and Manipulate Class Fields Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Demonstrates how to retrieve a field by name and then read or write its value from an instance. ```cpp //Get field rfk::Field const* field = TestClass::staticGetArchetype().getFieldByName("_intField"); TestClass instance; //Read field value int value = field->get(instance); //Write field value field->set(instance, 3); ``` -------------------------------- ### Instantiate a Class using Default Constructor Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Illustrates how to get a class from the database and create a shared pointer instance using its default constructor. ```cpp rfk::Class const* c = rfk::getDatabase().getFileLevelClassByName("TestClass"); //Instantiate from default ctor rfk::SharedPtr instance = c->makeSharedInstance(); //If TestClass has a base class, we can do rfk::SharedPtr instance2 = c->makeSharedInstance(); ``` -------------------------------- ### Get and Manipulate Class Methods Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Shows how to retrieve a method by name and then invoke it, with or without arguments and return values. ```cpp //Get method rfk::Method const* method = TestClass::staticGetArchetype().getMethodByName("testMethod"); TestClass instance; //Call method without arguments method->invoke(instance); //With arguments and returned value int returnedValue = method->invoke(instance, 1, 2, 3); ``` -------------------------------- ### Include Property Declaration Source: https://github.com/jsoysouvanh/refureku/wiki/Properties Include the header file that declares the property before using it. This example shows how to include the property declaration for 'ExampleProperty'. ```cpp #include "ExampleProperty.h" enum class ENUM(ExampleProperty) ExampleEnum {}; ``` -------------------------------- ### Compile Refureku Library and Generator with Ninja Generator Source: https://github.com/jsoysouvanh/refureku/wiki/README Example of using the Ninja generator with CMake. ```cmake cmake -B Build/Release -DCMAKE_BUILD_TYPE=Release -G "Ninja" ``` -------------------------------- ### Retrieve Property by Static Type Source: https://github.com/jsoysouvanh/refureku/wiki/Properties Retrieve a property from an entity using its static type. This example shows how to get an entity by name and then attempt to retrieve an 'ExampleProperty' from it. ```cpp rfk::Entity const* entity = rfk::getDatabase().getFileLevelEnumByName("ExampleEnum"); if (rfk::ExampleProperty const* p = entity->getProperty()) { //Use p } ``` -------------------------------- ### Inheriting Properties in Classes Source: https://github.com/jsoysouvanh/refureku/wiki/Native-properties This example shows how 'ExampleProperty' can be attached to a base class 'TestClass' and is then inherited by a derived class 'TestClass2'. It verifies the property's presence in the derived class's archetype. ```cpp //OK class CLASS(ExampleProperty) TestClass { TestClass_GENERATED }; //TestClass2 inherits from TestClass' ExampleProperty class CLASS() TestClass2 : public TestClass { TestClass2_GENERATED }; TestClass2::staticGetArchetype().getProperty() != nullptr; //true ``` -------------------------------- ### Get Refureku Database Instance Source: https://github.com/jsoysouvanh/refureku/wiki/Database Retrieve the singleton instance of the Refureku Database. This instance provides access to metadata of all reflected entities in the program. ```cpp #include rfk::Database const& database = rfk::getDatabase(); ``` -------------------------------- ### Basic Refureku FileParser and FileGenerator Usage Source: https://github.com/jsoysouvanh/refureku/wiki/README This snippet demonstrates the fundamental setup for parsing files and generating code using Refureku. Ensure the logger is set before proceeding with file generation. ```cpp #include #include #include int main() { rfk::FileParser fileParser; rfk::FileGenerator fileGenerator; //Set logger kodgen::DefaultLogger logger; fileParser.logger = &logger; fileGenerator.logger = &logger; //Parse kodgen::FileGenerationResult genResult = fileGenerator.generateFiles(fileParser, false); return 0; } ``` -------------------------------- ### Retrieve Class Template by Name Source: https://github.com/jsoysouvanh/refureku/wiki/Class-template-reflection Get a pointer to a class template by its file-level name from the database. ```cpp rfk::Class const* c = rfk::getDatabase().getFileLevelClassByName("Array"); rfk::ClassTemplate const* ct = rfk::classTemplateCast(c); ``` -------------------------------- ### Instantiate Class by Name Source: https://github.com/jsoysouvanh/refureku/wiki/Instantiate-a-class Get a class by its name and create a shared pointer instance. This method is useful when you need to instantiate an object without direct static type information. ```cpp //ExampleClass inherits from ExampleClassBase rfk::Class const* c = rfk::getDatabase().getFileLevelClassByName("ExampleClass"); rfk::SharedPtr instance = c->makeSharedInstance(); //or rfk::UniquePtr instance = c->makeUniqueInstance(); ``` -------------------------------- ### Retrieve Class Metadata by Name Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Get the metadata for a reflected class using its name from the reflection database. ```cpp rfk::Class const* c = rfk::getDatabase().getFileLevelClassByName("TestClass"); ``` -------------------------------- ### Define a Custom Property (Tooltip) Source: https://github.com/jsoysouvanh/refureku/wiki/Create-custom-properties Inherit from rfk::Property and optionally use PropertySettings to define a new custom property. This example defines a 'Tooltip' property for methods and functions. ```cpp #include #include class CLASS(PropertySettings(rfk::EEntityKind::Method | rfk::EEntityKind::Function, false, true)) Tooltip : public rfk::Property { std::string _message; public: Tooltip(char const* message) noexcept: _message(message) {} std::string const& getMessage() const { return _message; } Tooltip_GENERATED }; ``` -------------------------------- ### Retrieve Class Template Instantiation by Static Type Source: https://github.com/jsoysouvanh/refureku/wiki/Class-template-reflection Get a class template instantiation pointer by providing its static type directly. ```cpp rfk::ClassTemplateInstantiation const* inst = rfk::getArchetype>(); ``` -------------------------------- ### Compile Refureku Library and Generator with Visual Studio Generator Source: https://github.com/jsoysouvanh/refureku/wiki/README Example of using the Visual Studio generator with CMake. Ensure to specify the target architecture with -A x64. ```cmake cmake -B Build/Release -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 15 2017" -A x64 ``` -------------------------------- ### Retrieve a function by name Source: https://github.com/jsoysouvanh/refureku/wiki/Call-functions Use `getFileLevelFunctionByName` to get a function pointer by its name. This is useful for dynamic function calls. ```cpp rfk::Function const* func = rfk::getDatabase().getFileLevelFunctionByName("function"); ``` -------------------------------- ### Retrieve Class Metadata by Archetype (Reflected/Unreflected) Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Get the archetype metadata for a type. Returns nullptr if the type is not reflected. ```cpp rfk::Archetype const* c3 = rfk::getArchetype(); //nullptr if not reflected ``` -------------------------------- ### Retrieve a Custom Property from a Function Source: https://github.com/jsoysouvanh/refureku/wiki/Create-custom-properties Retrieve the custom 'Tooltip' property from a function using the Refureku database. This example retrieves the message from the 'testTooltipFunction'. ```cpp #include #include //... std::cout << rfk::getDatabase().getFileLevelFunctionByName("testTooltipFunction")->getProperty()->getMessage() << std::endl; //prints "It is working!" ``` -------------------------------- ### Retrieve Class Template by Static Type Source: https://github.com/jsoysouvanh/refureku/wiki/Class-template-reflection Get a class template pointer by providing its static type directly. ```cpp rfk::ClassTemplate const* ct = rfk::classTemplateCast(rfk::getArchetype()); ``` -------------------------------- ### Attach Property with Non-Default Constructor Source: https://github.com/jsoysouvanh/refureku/wiki/Properties Attach a property to an entity using a non-default constructor. This example demonstrates attaching 'ExampleProperty' with specific string arguments to an enum. ```cpp enum class ENUM(ExampleProperty("Jan", "Ken", "Pon")) ExampleEnum {}; ``` -------------------------------- ### Define Classes in Dynamic Libraries Source: https://github.com/jsoysouvanh/refureku/wiki/Dynamic-libraries-handling Example of defining classes A and B in separate dynamic libraries, where B inherits from A and holds a pointer to A. This illustrates a dependency that must be managed when unloading libraries. ```cpp //libA.so (.lib, .dylib) class CLASS() A_API A {}; //libB.so (.lib, .dylib) class CLASS() B_API B : public A { FIELD() A* ptrToA = nullptr; }; ``` -------------------------------- ### CMake Minimum Required Version Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/LibraryGenerator/CMakeLists.txt Specifies the minimum required version of CMake for the project. Ensure your CMake installation meets this requirement. ```cmake cmake_minimum_required(VERSION 3.13.5) ``` -------------------------------- ### Call a function and get the result Source: https://github.com/jsoysouvanh/refureku/wiki/Call-functions Retrieve the result of a function call by specifying the return type as a template parameter to the `invoke()` method. ```cpp //Get result int result = func->invoke(); ``` -------------------------------- ### Apply a Custom Property to a Function Source: https://github.com/jsoysouvanh/refureku/wiki/Create-custom-properties Apply the custom 'Tooltip' property to a function using the FUNCTION macro. This example applies a tooltip with the message 'It is working!'. ```cpp #include "Tooltip.h" FUNCTION(Tooltip("It is working!")) inline void testTooltipFunction() {} ``` -------------------------------- ### Get Class Metadata from Base Pointer (Inheriting rfk::Object) Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md If a class publicly derives from rfk::Object, its metadata can be accessed through a base pointer to rfk::Object. ```cpp TestClass instance; rfk::Object const* instancePtr = &instance; rfk::Class const& archetype = instancePtr->getArchetype(); ``` -------------------------------- ### Nested Class Reflection Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities For nested classes, the generated macro name includes outer entity names to prevent collisions. This example shows a class within a namespace. ```cpp namespace ReflectedNamespace NAMESPACE() { class CLASS() ExampleClass { ReflectedNamespace_ExampleClass_GENERATED }; } ``` -------------------------------- ### Attach Property to a Function Source: https://github.com/jsoysouvanh/refureku/wiki/Native-properties Demonstrates the correct way to attach the 'ExampleProperty' to a function, which is allowed by its PropertySettings. ```cpp //OK FUNCTION(ExampleProperty) void func(); ``` -------------------------------- ### Instantiate a Class using Custom Instantiator Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Demonstrates how to instantiate a class that has a custom instantiator defined, passing arguments to it. ```cpp rfk::Class const* c2 = rfk::getDatabase().getFileLevelClassByName("TestClass2"); //Call customInstantiator rfk::SharedPtr instance3 = c2->makeSharedInstance(42); ``` -------------------------------- ### Configure RefurekuSettings.toml for Directories to Parse Source: https://github.com/jsoysouvanh/refureku/wiki/README Lists the directories containing header files that Refureku should parse. These directories are searched recursively. ```toml [FileGeneratorSettings] toParseDirectories = [ '''Path/To/Dir/To/Parse1''', ... ] ``` -------------------------------- ### Define a Class Property with PropertySettings Source: https://github.com/jsoysouvanh/refureku/wiki/Native-properties This snippet shows how to define a custom property 'ExampleProperty' that can be attached to classes and functions, disallows multiple instances per entity, and is inheritable. ```cpp #include class CLASS(rfk::PropertySettings(rfk::EEntityKind::Class | rfk::EEntityKind::Function, false, true)) ExampleProperty : public rfk::Property { public: int value = 0; ExampleProperty(int v = 0): value{v} {} ExampleProperty_GENERATED }; ``` -------------------------------- ### Serialize and Unserialize Dynamically Source: https://github.com/jsoysouvanh/refureku/wiki/Instantiate-a-class Demonstrates saving and loading object states using Refureku's instantiation capabilities. This is crucial for handling objects of unknown types at runtime, especially across different program executions. ```cpp //WARNING: This is only an example, serialize, unserialize or SerializedData are NOT part of the Refureku API rfk::SharedPtr instance = rfk::makeSharedInstance(); //Save SerializedData data; data.write(instance->getId()); //Write class Id instance->serialize(data); //Save ExampleClass to data data.save("SavedFile"); //Later (in a potentially subsequent program execution) SerializedData loadedData("SavedFile"); std::size_t classId = loadedData.read(); rfk::Class const* c = rfk::getDatabase().getClassById(classId); //We don't know the concrete type of the class but we know it inherits from ExampleInstanceBase rfk::SharedPtr instance = c->makeSharedInstance(); c->unserialize(loadedData); //Restore ExampleClass state ``` -------------------------------- ### Configure Refureku Generator: Project Include Directories Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started List all project include directories required by the Refureku generator. This list must be exhaustive to prevent generation failures. ```toml projectIncludeDirectories = [ '''./Include''', #Our project include directory '''./Path/To/Refureku/Include''' #Refureku include directory ] ``` -------------------------------- ### Configure RefurekuSettings.toml for Project Include Directories Source: https://github.com/jsoysouvanh/refureku/wiki/README Provides paths to your project's additional include directories. This is crucial for the parser to locate all included files. ```toml [FileParserSettings] projectIncludeDirectories = [ '''Path/To/Refureku/Library/Include''', '''Path/To/Your/Project/Include/Dir1''', ... ] ``` -------------------------------- ### Configure Pre-Build Event for RefurekuGenerator in Visual Studio Source: https://github.com/jsoysouvanh/refureku/wiki/README Sets up a pre-build event in Visual Studio project properties to execute the RefurekuGenerator before the project compilation begins. ```powershell Path\To\Executable\RefurekuGenerator.exe ``` -------------------------------- ### Integration Test Main File Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started This C++ code demonstrates how to use the Refureku database to check for the existence of an enum by name in your main file. ```cpp #include #include "Generated/IntegrationTest.rfks.h" int main() { assert(rfk::getDatabase().getFileLevelEnumByName("IntegrationTest") != nullptr); return 0; } ``` -------------------------------- ### Define a Custom Property Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Shows how to create a custom property by inheriting from rfk::Property and defining its settings and data. ```cpp //ExampleProperty.h #pragma once #include #include "Generated/ExampleProperty.rfkh.h" class CLASS(rfk::PropertySettings(rfk::EEntityKind::Struct | rfk::EEntityKind::Class)) ExampleProperty : public rfk::Property { public: int someData; ExampleProperty(int data): someData{data} {} ExampleProperty_GENERATED }; File_ExampleProperty_GENERATED ``` ```cpp //ExampleProperty.cpp, or any source file being part of your project #include "Generated/ExampleProperty.rfks.h" ``` -------------------------------- ### Customizing Reflection Macro Names Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Modify macro names by updating [Entity]macroName in RefurekuSettings.toml. This example shows changing the enum macro name. ```toml [ParsingSettings] enumMacroName = "MYENUM" ``` -------------------------------- ### Wrapping a Third-Party Class for Reflection Source: https://github.com/jsoysouvanh/refureku/wiki/Struct-Class-manual-reflection Demonstrates how to wrap a third-party class using inheritance to enable reflection of its protected and public members. This approach overcomes the limitations of direct manual reflection. ```cpp //ThirdPartyClassWrapper.h #include "Generated/ThirdPartyClassWrapper.rfkh.h" class CLASS() ThirdPartyClassWrapper : public ThirdPartyClass { protected: METHOD() inline void protectedMethod() { ThirdPartyClass::protectedMethod(); } public: METHOD() inline int& getProtectedField() { return protectedField; } ThirdPartyClassWrapper_GENERATED }; File_ThirdPartyClassWrapper_GENERATED ``` ```cpp //ThirdPartyClassWrapper.cpp #include "Generated/ThirdPartyClassWrapper.rfks.h" ``` -------------------------------- ### Get rfk::Type for a Static Type Source: https://github.com/jsoysouvanh/refureku/wiki/Type Use rfk::getType to obtain the rfk::Type object for any statically known C++ type, such as 'int&'. ```cpp rfk::Type const& intRefType = rfk::getType(); ``` -------------------------------- ### Generate Build Project with CMake (Visual Studio) Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Generate the build project for Refureku using the Visual Studio generator, specifying the architecture. ```shell > cmake -B Build/Release -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64 ``` -------------------------------- ### Using Custom Instantiator with makeSharedInstance Source: https://github.com/jsoysouvanh/refureku/wiki/Native-properties Demonstrates how rfk::Struct::makeSharedInstance automatically calls a custom instantiator method when the provided parameters match. This allows for flexible object creation patterns. ```cpp rfk::Class const* c = ExampleClass::staticGetArchetype(); //ExampleClass will be instantiated through customInstantiator rfk::SharedPtr instance = c.makeSharedInstance(42, 3.14f); ``` -------------------------------- ### Define a Class with a Custom Instantiator Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Shows how to define a class with a custom instantiator function for more control over object creation, including custom deleters. ```cpp //TestClass2.h #pragma once #include #include "Generated/TestClass2.rfkh.h" class CLASS() TestClass2 : public BaseClass { METHOD(rfk::Instantiator) static rfk::SharedPtr customInstantiator(int i) { //Use this if you don't need custom deleter //return rfk::makeShared(); //Use this if you want to provide a custom deleter return rfk::SharedPtr(new TestClass2(), [](TestClass2* ptr) { delete ptr; //Simple delete for example simplicity }); } TestClass2_GENERATED }; File_TestClass2_GENERATED ``` ```cpp //TestClass2.cpp #include "Generated/TestClass2.rfks.h" ``` -------------------------------- ### Implement Manual Function and Enum Reflection in C++ Source: https://github.com/jsoysouvanh/refureku/wiki/Namespace-manual-reflection This C++ source file implements the manual reflection for the `thirdPartyFunc` and the `third_party_namespace::ThirdPartyEnum`, providing necessary metadata for Refureku. ```cpp //ThirdPartyNamespaceProxy.cpp #include "ThirdPartyNamespaceProxy.h" #include //std::hash #include #include //Function manual reflection static rfk::Function const& getFunction_thirdPartyFunc() noexcept { static rfk::Function func("thirdPartyFunc", std::hash()("third_party_namespace::nested_third_party_namespace::thirdPartyFunc"), rfk::getType(), new rfk::NonMemberFunction(&third_party_namespace::nested_third_party_namespace::thirdPartyFunc), rfk::EFunctionFlags::Default); return func; } //Enum manual reflection template <> rfk::Enum const* rfk::getEnum() noexcept { static rfk::Enum enumMetadata("ThirdPartyEnum", std::hash()("third_party_namespace::ThirdPartyEnum"), rfk::getArchetype(), nullptr); return &enumMetadata; } ``` -------------------------------- ### Configure RefurekuSettings.toml for Output Directory Source: https://github.com/jsoysouvanh/refureku/wiki/README Specifies the output directory for generated metadata files in RefurekuSettings.toml. The generator will attempt to create this directory if it doesn't exist. ```toml [FileGeneratorSettings] outputDirectory = '''Path/To/An/Output/Directory''' ``` -------------------------------- ### ParseAllNested Property Example Source: https://github.com/jsoysouvanh/refureku/wiki/Native-properties The ParseAllNested property instructs the code generator to reflect all nested entities within a namespace, struct, or class automatically. This is useful for enums defined within these scopes. ```cpp #include namespace ExampleNamespace NAMESPACE(kodgen::ParseAllNested) { //This enum is reflected even without the ENUM() macro enum class ExampleEnum {}; }; ``` -------------------------------- ### Generate Build Project with CMake Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Use CMake to generate the build project for Refureku. Specify the build type and generator. Optionally, disable testing to build faster. ```shell > cmake -B Build/Release -DCMAKE_BUILD_TYPE=Release -G "" ``` -------------------------------- ### Copy RefurekuSettings Template Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/CMakeLists.txt A custom build command to copy the RefurekuSettings.toml template file to the output directory before building the target. ```cmake add_custom_command(TARGET ${RefurekuGeneratorExeTarget} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/RefurekuSettings.toml $<$,${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/RefurekuSettings.toml,${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/RefurekuSettings.toml>) ``` -------------------------------- ### Forward Declaration in Header Source: https://github.com/jsoysouvanh/refureku/wiki/Incomplete-type-reflection Demonstrates how to forward declare a type and use it as a pointer in a header file. Ensure the generated source file is included after all forward-declared types are defined. ```cpp //ExampleClass.h #pragma once #include "Generated/ExampleClass.rfkh.h" class ForwardDeclaredType; class CLASS() ExampleClass { FIELD() ForwardDeclaredType* field; METHOD() void method(ForwardDeclaredType*); ExampleClass_GENERATED }; File_ExampleClass_GENERATED ``` -------------------------------- ### Attach and Use Custom Property on a Class Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Illustrates how to attach a custom property to a class during its definition and then retrieve it. ```cpp //TestClass3.h #pragma once #include "ExampleProperty.h" //Include the custom property first #include "Generated/TestClass3.rfkh.h" class CLASS(ExampleProperty(42)) TestClass3 { TestClass3_GENERATED }; File_TestClass3_GENERATED ``` ```cpp //TestClass3.cpp #include "Generated/TestClass3.rfks.h" ``` -------------------------------- ### Manual Entity Casting (Verbose) Source: https://github.com/jsoysouvanh/refureku/wiki/Entity-cast Demonstrates the manual way to check an entity's kind and cast it. This method is verbose and less safe than using Refureku's built-in cast functions. ```cpp #include void doSomethingIfClass(rfk::Entity const* entity) { if (entity != nullptr && entity->getKind() == rfk::EEntityKind::Class) { rfk::Class const* c = reinterpret_cast(entity); //Do something with c } } ``` -------------------------------- ### Integration Test Header File Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Add this header file to your include directory for integration testing. It includes the Refureku generated header and defines an enum. ```cpp //IntegrationTest.h #include "Generated/IntegrationTest.rfkh.h" enum class ENUM() IntegrationTest {} File_IntegrationTest_GENERATED ``` -------------------------------- ### Include Refureku Library Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Include the main Refureku header file to access its functionalities. ```cpp #include ``` -------------------------------- ### Run Refureku Tests Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Execute the Refureku tests using CMake. This command builds the tests, changes directory, and then runs ctest with verbose output. ```shell > cmake --build Build/Release --config Release --target RefurekuTests > > cd Build/Release > ctest -C Release -V -R RefurekuTests ``` -------------------------------- ### Compile Refureku Library and Generator with CMake Source: https://github.com/jsoysouvanh/refureku/wiki/README Use this CMake command to build the Refureku library and its generator in Release mode. Specify your preferred generator. ```cmake cmake -B Build/Release -DCMAKE_BUILD_TYPE=Release -G "" ``` -------------------------------- ### Using Custom Enum Macro Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Demonstrates using a custom macro name for enum reflection after it has been configured in RefurekuSettings.toml. ```cpp enum class MYENUM() ReflectedEnum {}; ``` -------------------------------- ### Development Build Definitions and Options (Non-MSVC) Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/CMakeLists.txt Configures compilation definitions and sanitizers for development builds on Clang or GCC. ```cmake if (RFK_DEV) # Setup compilation definitions target_compile_definitions(${RefurekuGeneratorExeTarget} PUBLIC RFK_DEV=1) if (NOT MSVC) # Clang or GCC target_compile_options(${RefurekuGeneratorExeTarget} PUBLIC -fsanitize=address -fno-omit-frame-pointer) target_link_options(${RefurekuGeneratorExeTarget} PUBLIC -fsanitize=address -fno-omit-frame-pointer) endif() endif() ``` -------------------------------- ### Configure Refureku Generator: Directories to Process Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Specify the directories containing files with reflected entities for the Refureku code generator. Paths should be absolute or relative to the working directory. ```toml toProcessDirectories = [ '''./Include''' ] #Replace by the path to your include project's main include directory. ``` -------------------------------- ### Configure Refureku Generator: Output Directory Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Set the directory where the Refureku code generator will output the generated files. Ensure this path is correctly specified. ```toml outputDirectory = '''./Include/Generated''' ``` -------------------------------- ### Executable Target Configuration Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/CMakeLists.txt Defines the main executable target and its source files, include directories, and linked libraries. ```cmake set(RefurekuGeneratorExeTarget RefurekuGenerator) add_executable(${RefurekuGeneratorExeTarget} Source/main.cpp) target_include_directories(${RefurekuGeneratorExeTarget} PRIVATE Include) target_link_libraries(${RefurekuGeneratorExeTarget} PRIVATE Kodgen) ``` -------------------------------- ### Safe Entity Casting with Refureku Source: https://github.com/jsoysouvanh/refureku/wiki/Entity-cast Shows the recommended and concise way to cast entities using Refureku's `classCast` function. This method is safer and more readable. ```cpp #include void doSomethingIfClass(rfk::Entity const* entity) { if (rfk::Class const* c = rfk::classCast(entity)) { //Do something with c } } ``` -------------------------------- ### Link Against Refureku Library with CMake Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Link your program against the Refureku library by specifying the library path and name in CMake. ```cmake target_link_directories(MyAmazingProgram PRIVATE Path/To/Refureku/Bin) target_link_libraries(MyAmazingProgram PRIVATE Refureku) ``` -------------------------------- ### Include Order in Source File Source: https://github.com/jsoysouvanh/refureku/wiki/Incomplete-type-reflection Shows the correct include order in a source file when using forward declarations. All forward-declared type headers must be included before the generated source file. ```cpp //ExampleClass.cpp //Include all forward declared type headers before including the generated source file #include "ForwardDeclaredType.h" #include "Generated/ExampleClass.rfks.h" ``` -------------------------------- ### Implement Slider Property Rule Constructor Source: https://github.com/jsoysouvanh/refureku/wiki/Generate-property-specific-code Implements the constructor for 'SliderPropertyRule', initializing the parent class with the property name ('Slider') and the targeted entity types (Field and Variable). ```cpp #include "SliderPropertyRule.h" SliderPropertyRule::SliderPropertyRule() noexcept: rfk::DefaultComplexPropertyRule("Slider", kodgen::EEntityType::Field | kodgen::EEntityType::Variable) {} ``` -------------------------------- ### Read Entity Properties by Name or Type Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Demonstrates how to retrieve a custom property attached to a class, either by its name or by its static type. ```cpp rfk::Class const* c = rfk::getDatabase().getFileLevelClassByName("TestClass3"); //From name rfk::Property const* prop = c->getPropertyByName("ExampleProperty"); //From static type ExampleProperty const* prop2 = c->getProperty(); ``` -------------------------------- ### Create Function Metadata Source: https://github.com/jsoysouvanh/refureku/wiki/Function-manual-reflection This function builds the metadata for 'thirdPartyFunction'. It defines the function's name, hash, return type, and parameters. Ensure Refureku headers are included. ```cpp #include "ThirdPartyFunc.h" #include #include static rfk::Function const& getFunction_thirdPartyFunction() noexcept { static bool initialized = false; static rfk::Function func("thirdPartyFunction", std::hash()("thirdPartyFunction"), rfk::getType(), new rfk::NonMemberFunction(&thirdPartyFunction), rfk::EFunctionFlags::Inline); if (!initialized) { initialized = true; func.setParametersCapacity(2); func.addParameter("i", std::hash()("thirdPartyFunction i"), rfk::getType()); func.addParameter("j", std::hash()("thirdPartyFunction j"), rfk::getType()); } return func; } ``` -------------------------------- ### Build Refureku Targets with CMake Source: https://github.com/jsoysouvanh/refureku/wiki/README Builds the RefurekuGenerator and Refureku library targets after configuring the build system. ```cmake cmake --build Build/Release --config Release --target RefurekuGenerator Refureku ``` -------------------------------- ### Compilation Error: Multiple Property Attachments Source: https://github.com/jsoysouvanh/refureku/wiki/Native-properties Illustrates a compilation error that occurs when attempting to attach 'ExampleProperty' more than once to the same entity, as 'allowMultiple' is set to false in its PropertySettings. ```cpp //Compilation error, ExampleProperty can't be used more than once per entity (allowMultiple: false) FUNCTION(ExampleProperty, ExampleProperty) void func2(); ``` -------------------------------- ### Include Generated Header and File Macro Source: https://github.com/jsoysouvanh/refureku/wiki/Inject-reflection-code Include the generated header file as the last include and add the file macro at the end of your header file. ```cpp //Example.h #pragma once //Other includes... #include "Generated/Example.rfkh.h" //Your code containing reflected entities here //File_[FileNameWithoutExtension]_GENERATED File_Example_GENERATED ``` -------------------------------- ### Find Class Template Instantiation by Arguments Source: https://github.com/jsoysouvanh/refureku/wiki/Class-template-reflection Locate a specific instantiation of a class template using its template arguments. ```cpp rfk::ClassTemplate const* ct = rfk::classTemplateCast(rfk::getDatabase().getFileLevelClassByName("Array")); //Build a list of template arguments rfk::TypeTemplateArgument arg1(rfk::getDatabase().getFundamentalArchetypeByName("int")); std::size_t arg2Value = 42u; rfk::NonTypeTemplateArgument arg2(arg2Value); rfk::TemplateArgument const* templateArgs[] = { &arg1, &arg2 }; //Find the instantiation rfk::ClassTemplateInstantiation const* inst = ct->getTemplateInstantiation(templateArgs); ``` -------------------------------- ### Add Custom Property Rule to File Parser Factory Source: https://github.com/jsoysouvanh/refureku/wiki/Generate-property-specific-code Demonstrates how to add the custom 'SliderPropertyRule' to a 'FileParserFactory' by instantiating the rule and including it in the factory's constructor. ```cpp #pragma once #include #include #include "SliderPropertyRule.h" class YourFileParserFactory : public rfk::FileParserFactory { private: SliderPropertyRule _sliderPropertyRule; public: YourFileParserFactory() noexcept { ``` -------------------------------- ### Run Refureku Generator with CMake Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Create a custom CMake target to run the Refureku code generator before compilation. Ensure the working directory and command path are correctly set. ```cmake add_custom_target( RunRefurekuGenerator WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} #PROJECT_SOURCE_DIR is the path to the directory containing the Cmake with the project command COMMAND Path/To/RefurekuGenerator Path/To/RefurekuSettings.toml) add_dependencies(MyAmazingProgram RunRefurekuGenerator) ``` -------------------------------- ### Build Variable Metadata Function Source: https://github.com/jsoysouvanh/refureku/wiki/Variable-manual-reflection Create a function to construct the Refureku Variable metadata for an external variable. This function defines the variable's name, hash, type, address, and flags. ```cpp #include "ThirdPartyVar.h" #include #include static rfk::Variable const& getVariable_thirdPartyVariable() noexcept { static rfk::Variable var("thirdPartyVariable", std::hash()("thirdPartyVariable"), rfk::getType(), &thirdPartyVariable, rfk::EVarFlags::Default); return var; } ``` -------------------------------- ### Build Refureku Library and Generator Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Build the Refureku library and code generator using CMake. This command specifies the build directory, configuration, and target executables. ```shell > cmake --build Build/Release --config Release --target RefurekuGenerator Refureku ``` -------------------------------- ### Clone Refureku Repository Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Clone the Refureku git repository, ensuring that submodules are included. Navigate into the cloned directory. ```shell > git clone --recurse-submodules https://github.com/jsoysouvanh/Refureku.git > > cd Refureku ``` -------------------------------- ### Compiler Warning and Parallel Compilation Options (MSVC) Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/CMakeLists.txt Sets a high warning level (/W4) and enables multi-processor compilation (/MP) for MSVC builds. ```cmake if (MSVC) # Setup warning level string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Remove the default flag /W3 target_compile_options(${RefurekuGeneratorExeTarget} PRIVATE /W4 /MP) else () ``` -------------------------------- ### Define a Reflectable Class Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Use Refureku macros to mark a C++ class for reflection. Ensure the generated header and source files are included. ```cpp //TestClass.h #pragma once #include "Generated/TestClass.rfkh.h" class CLASS() TestClass { FIELD() int _intField; METHOD() void testMethod(); TestClass_GENERATED }; File_TestClass_GENERATED ``` ```cpp //TestClass.cpp, or any source file being part of your project #include "Generated/TestClass.rfks.h" ``` -------------------------------- ### Comparing Unreflected Types with rfk::Type Source: https://github.com/jsoysouvanh/refureku/wiki/Type Demonstrates that unreflected types with the same qualifiers can compare as equal using rfk::getType. Check the archetype for accurate comparisons if type reflection is important. ```cpp class UnreflectedClass1 {}; class UnreflectedClass2 {}; rfk::getType() == rfk::getType(); //true ``` -------------------------------- ### Configure Refureku Generator: Ignored Directories Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Define directories that the Refureku code generator should ignore. It's common to ignore the output directory to prevent processing generated code. ```toml ignoredDirectories = [ '''./Include/Generated''' ] ``` -------------------------------- ### Casting Entity to VariableInfo Source: https://github.com/jsoysouvanh/refureku/wiki/Generate-property-specific-code Demonstrates casting the generic 'entity' parameter to a more specific type, 'kodgen::VariableInfo', when the entity type is known to be a variable. ```cpp kodgen::VariableInfo const& var = static_cast(entity); ``` -------------------------------- ### Configure RefurekuSettings.toml to Ignore Output Directory Source: https://github.com/jsoysouvanh/refureku/wiki/README If the output directory is within a directory to be parsed, it should be ignored to prevent parsing generated metadata. ```toml [FileGeneratorSettings] ignoredDirectories = [ '''Path/To/An/Output/Directory''' ] ``` -------------------------------- ### Reflecting Methods and Static Methods Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Use the METHOD() macro to reflect class methods. It supports both regular and static methods and can be declared inline. ```cpp class CLASS() ExampleClass { METHOD() void reflectedMethod(); //Can be written inline as well METHOD() static void reflectedStaticMethod(); ExampleClass_GENERATED }; ``` -------------------------------- ### Compiler Warning Options (Non-MSVC) Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/CMakeLists.txt Enables verbose warning flags (-Wall, -Wextra, -Wpedantic) for Clang or GCC builds. ```cmake # Clang or GCC target_compile_options(${RefurekuGeneratorExeTarget} PRIVATE -Wall -Wextra -Wpedantic) endif() ``` -------------------------------- ### Define a Third-Party Namespace in C++ Source: https://github.com/jsoysouvanh/refureku/wiki/Namespace-manual-reflection This header defines a sample third-party namespace with a nested namespace, a function, and an enum, which will be manually reflected. ```cpp //ThirdPartyNamespace.h namespace third_party_namespace { namespace nested_third_party_namespace { void thirdPartyFunc(); } enum class ThirdPartyEnum {}; } ``` -------------------------------- ### Include Directories for Target Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/LibraryGenerator/CMakeLists.txt Adds the '../Include' directory to the public include directories for the 'LibraryGenerator' target. This allows including headers from this directory during compilation. ```cmake target_include_directories(${LibraryGeneratorTarget} PUBLIC ../Include) ``` -------------------------------- ### Register Function to Database Source: https://github.com/jsoysouvanh/refureku/wiki/Function-manual-reflection This code snippet registers the previously defined function metadata to the Refureku database. Include the DefaultEntityRegisterer header. ```cpp #include rfk::DefaultEntityRegisterer registerer_thirdPartyFunction = getFunction_thirdPartyFunction(); ``` -------------------------------- ### Retrieve Class Template Instantiation by ID Source: https://github.com/jsoysouvanh/refureku/wiki/Class-template-reflection Access a class template instantiation using its unique identifier from the database. ```cpp rfk::ClassTemplateInstantiation const* inst = rfk::classTemplateInstantiationCast(rfk::getDatabase().getClassById(classTemplateInstantiationId)); ``` -------------------------------- ### Define a Class Template Source: https://github.com/jsoysouvanh/refureku/wiki/Class-template-reflection Declare a class template using the CLASS() macro. Ensure generated members are included with _GENERATED. ```cpp template class CLASS() ExampleClassTemplate { ExampleClassTemplate_GENERATED }; ``` -------------------------------- ### Configure Refureku Generator: Compiler Executable Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Specify the compiler executable name used by the Refureku code generator. Valid options include msvc, clang++, or g++. ```toml compilerExeName = "clang++" ``` -------------------------------- ### Retrieve Class Template by ID Source: https://github.com/jsoysouvanh/refureku/wiki/Class-template-reflection Obtain a class template using its unique identifier from the database. ```cpp rfk::ClassTemplate const* ct = rfk::classTemplateCast(rfk::getDatabase().getClassById(classTemplateId)); ``` -------------------------------- ### Set C++ Standard to C++17 with CMake Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Ensure your project is compiled with C++17 or later by setting the compile features in CMake. ```cmake target_compile_features(MyAmazingProgram PUBLIC cxx_std_17) ``` -------------------------------- ### Overriding Inherited Properties with New Values Source: https://github.com/jsoysouvanh/refureku/wiki/Native-properties Demonstrates how to override an inherited property on a derived class ('TestClass3') by providing a new instance with a specific value (42), effectively replacing the inherited property. ```cpp //allowMultiple is false, so override the inherited ExampleProperty class CLASS(ExampleProperty(42)) TestClass3 : public TestClass { TestClass3_GENERATED }; TestClass3::staticGetArchetype().getProperty()->value == 42; //true ``` -------------------------------- ### Retrieve an overloaded function by signature Source: https://github.com/jsoysouvanh/refureku/wiki/Call-functions When functions have overloads, use the template version of `getFileLevelFunctionByName` with the function's signature to retrieve a specific overload. This ensures you call the correct version. ```cpp //Get the overload of the function "function" returning an int and taking a float and int as parameters rfk::Function const* func2 = rfk::getDatabase().getFileLevelFunctionByName("function"); ``` -------------------------------- ### Linking Libraries to Target Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/LibraryGenerator/CMakeLists.txt Links the 'Kodgen' library to the 'LibraryGenerator' executable as a private dependency. This makes Kodgen's symbols available during the build of LibraryGenerator. ```cmake target_link_libraries(${LibraryGeneratorTarget} PRIVATE Kodgen) ``` -------------------------------- ### Third-Party Class Definition Source: https://github.com/jsoysouvanh/refureku/wiki/Struct-Class-manual-reflection Defines a sample third-party class with protected members. This class serves as the target for manual reflection. ```cpp //ThirdPartyClass.h class ThirdPartyClass { protected: int protectedField = 0; void protectedMethod(){} }; ``` -------------------------------- ### Reflecting a Class Template Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Use the CLASS() macro for class templates. The template parameter is included in the generated macro name. A file macro and explicit instantiation are also shown. ```cpp //TestClassTemplate.h template class CLASS() TestClassTemplate { TestClassTemplate_T_GENERATED }; File_TestClassTemplate_GENERATED //file macro //Must write 1 explicit instantiation AFTER the file macro //The template parameter type doesn't matter template class CLASS() TestClassTemplate; ``` -------------------------------- ### Enabling Automatic Parsing of All Entities Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Set shouldParseAllEntities to true in RefurekuSettings.toml to automatically reflect all entities within parsed files. ```toml [ParsingSettings] shouldParseAllEntities = true ``` -------------------------------- ### Include Generated Source File Source: https://github.com/jsoysouvanh/refureku/wiki/Inject-reflection-code Include the generated source file as the last include in your cpp file. It's automatically included in the generated source file, so no manual inclusion of the header is needed. ```cpp //Example.cpp //Other includes... #include "Generated/Example.rfks.h" ``` -------------------------------- ### Executable Target Definition Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/LibraryGenerator/CMakeLists.txt Defines an executable target named 'LibraryGenerator' and specifies its source file as 'main.cpp'. ```cmake set(LibraryGeneratorTarget LibraryGenerator) add_executable(${LibraryGeneratorTarget} main.cpp) ``` -------------------------------- ### Reflecting Fields and Static Fields Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Use the FIELD() macro to reflect class members. It can be used for both regular and static fields, and can be declared inline. ```cpp class CLASS() ExampleClass { FIELD() int reflectedField; //Can be written inline as well FIELD() static int reflectedStaticField; ExampleClass_GENERATED }; ``` -------------------------------- ### Call an overloaded function with parameters Source: https://github.com/jsoysouvanh/refureku/wiki/Call-functions Invoke an overloaded function by providing the necessary parameters. The `invoke` method uses template deduction for parameter types. ```cpp int result2 = func2->invoke(3.14f, 42); ``` -------------------------------- ### Add Refureku Headers in CMake Source: https://github.com/jsoysouvanh/refureku/wiki/Getting-Started Specify the include directories for Refureku headers in your CMake project settings. ```cmake target_include_directories(MyAmazingProgram PUBLIC Path/To/Refureku/Include) ``` -------------------------------- ### Nested Class within Class Reflection Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Demonstrates reflection for a class nested within another class, including the necessary generated macro for the outer class. ```cpp class CLASS() OuterClass { class CLASS() ExampleClass { OuterClass_ExampleClass_GENERATED }; OuterClass_GENERATED }; ``` -------------------------------- ### Retrieve Variable by Name Source: https://github.com/jsoysouvanh/refureku/wiki/ReadWrite-variables Retrieves a variable from the rfk database using its name. ```cpp rfk::Variable const* var = rfk::getDatabase().getFileLevelVariableByName("variable"); ``` -------------------------------- ### Defining the rfk::getEnum<> Specialization Body Source: https://github.com/jsoysouvanh/refureku/wiki/Enum-manual-reflection Provides the implementation for the specialized rfk::getEnum function. It initializes the enum's metadata, including its name, hash, base type, and individual enum values. ```cpp //ManualEnumReflection.cpp //std::hash #include #include #include "ManualEnumReflection.h" template <> rfk::Enum const* rfk::getEnum() noexcept { static bool initialized = false; static rfk::Enum enumArchetype("EThirdPartyEnum", std::hash()("EThirdPartyEnum"), rfk::getArchetype(), nullptr); if (!initialized) { initialized = true; enumArchetype.addEnumValue("Value1", std::hash()("Value1"), 1 << 0); enumArchetype.addEnumValue("Value2", std::hash()("Value2"), 1 << 1); } return &enumArchetype; } ``` -------------------------------- ### Call a function and ignore the result Source: https://github.com/jsoysouvanh/refureku/wiki/Call-functions Invoke a retrieved function using the `invoke()` method. This is suitable when the function's return value is not needed. ```cpp //Call function and ignore result func->invoke(); ``` -------------------------------- ### Project Name Configuration Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/LibraryGenerator/CMakeLists.txt Sets the name of the project to 'LibraryGenerator'. This name is used by CMake for internal referencing. ```cmake project(LibraryGenerator) ``` -------------------------------- ### Override File Header Code Generation Source: https://github.com/jsoysouvanh/refureku/wiki/Generate-property-specific-code Injects code at the generated file's include line (#include "File.rfk.h"). Useful for adding necessary headers or directives at the beginning of generated files. ```cpp //Code is injected at the generated file include line (#include "File.rfk.h") std::string generateFileHeaderCode(kodgen::EntityInfo const& entity, kodgen::ComplexProperty const& property, rfk::PropertyCodeGenFileHeaderData& data) const noexcept override; ``` -------------------------------- ### Reflecting a Class Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Use the CLASS() macro to reflect a C++ class. Include the _GENERATED macro within the class definition. ```cpp class CLASS() ExampleClass { ExampleClass_GENERATED //Inject code in the class }; ``` -------------------------------- ### Compare Function Return Type with rfk::Type Source: https://github.com/jsoysouvanh/refureku/wiki/Type Compare the return type of a function obtained from the database with a known rfk::Type to verify its signature. This is useful for runtime type checking. ```cpp FUNCTION() int& getIntReference(); //... if (rfk::getDatabase().getFileLevelFunctionByName("getIntReference")->getReturnType() == rfk::getType()) { //getIntReference returns a int& } ``` -------------------------------- ### Add Library Generator Subdirectory Source: https://github.com/jsoysouvanh/refureku/blob/master/Refureku/Generator/CMakeLists.txt Includes the LibraryGenerator subdirectory, likely containing its own CMake configuration. ```cmake add_subdirectory(LibraryGenerator) ``` -------------------------------- ### Reflecting a Namespace Source: https://github.com/jsoysouvanh/refureku/wiki/Reflect-entities Use the NAMESPACE() macro after the namespace name to reflect it. This also applies to C++17 nested namespace declarations. ```cpp //Note that the macro is AFTER the namespace name namespace reflected_namespace NAMESPACE() { } ``` ```cpp namespace reflected_namespace::nested_namespace NAMESPACE() { } ``` -------------------------------- ### Compile Refureku Library in Debug Mode with CMake Source: https://github.com/jsoysouvanh/refureku/wiki/README Compiles the Refureku library in Debug mode. This is necessary if your project is also compiled in debug mode. ```cmake cmake -B Build/Debug -DCMAKE_BUILD_TYPE=Debug -G "" cmake --build Build/Debug --config Debug --target Refureku ``` -------------------------------- ### Generated File Inclusion for Vector Source: https://github.com/jsoysouvanh/refureku/wiki/Struct-Class-template-manual-reflection Includes the generated reflection header file for the Vector class template. This is a minimal C++ source file required for the reflection mechanism to work. ```cpp //Vector.cpp #include "Generated/Vector.rfks.h" ``` -------------------------------- ### Register Variable Metadata Source: https://github.com/jsoysouvanh/refureku/wiki/Variable-manual-reflection Register the created variable metadata with Refureku's default entity registerer. This makes the variable known to the Refureku system. ```cpp #include rfk::DefaultEntityRegisterer registerer_thirdPartyVariable = getVariable_thirdPartyVariable(); ``` -------------------------------- ### Namespace Usage for Native Properties Source: https://github.com/jsoysouvanh/refureku/wiki/Native-properties Native properties must be qualified with their namespace. Using the property name directly without the namespace will cause the code generator to fail. ```cpp namespace ExampleNamespace NAMESPACE(kodgen::ParseAllNested) {} ``` -------------------------------- ### Retrieve Class Metadata by Static Type Source: https://github.com/jsoysouvanh/refureku/blob/master/README.md Obtain the metadata for a reflected class directly from its static type information. ```cpp rfk::Class const& c2 = TestClass::staticGetArchetype(); ``` -------------------------------- ### Override Pre-Property Add Code Generation Source: https://github.com/jsoysouvanh/refureku/wiki/Generate-property-specific-code This method is overridden to generate code before a property is added. It allows for custom logic to be executed prior to property insertion. ```cpp std::string generatePrePropertyAddCode(kodgen::EntityInfo const& entity, kodgen::ComplexProperty const& property, rfk::PropertyCodeGenPropertyAddData& data) const noexcept override; ```