Skip to content

Releases: jsoysouvanh/Refureku

v2.2.0

13 May 06:04
Compare
Choose a tag to compare

New

  • (#11) A bunch of new methods were added to the Field and Method classes to have more control when instances are stored in void* variables.
    • Field::getUnsafe<>(void [const]* instance)
    • Field::setUnsafe<>(void [const]* instance, Value value)
    • Field::setUnsafe(void [const]* instance, void const* valuePtr, size_t valueSize)
    • Field::getPtrUnsafe(void [const]* instance)
    • Field::getConstPtrUnsafe(void [const]* instance)
    • Method::invokeUnsafe(void [const]* caller, ArgTypes&&... args)
    • Method::checkedInvokeUnsafe(void [const]* caller, ArgTypes&&... args)

Since the static and dynamic archetypes of provided instances is unknown, no pointer adjustment can be performed explaining the "unsafe" naming, but it is nearly always safe as long as instances do not use multiple inheritance.

Updates

  • The InvalidCaller exception was renamed InvalidArchetype
  • Since unsafe methods have been added to Field and Method classes, all originally available methods are now completely safe and require the provided instance to be reflected and implement both the static staticGetArchetype method and override the virtual getArchetype method inherited from rfk::Object. If the provided instance has an invalid type to access the field / call the method, the InvalidArchetype exception is thrown.
    • Field::get<>
    • Field::set<>
    • Field::set
    • Field::getPtr
    • Field::getConstPtr
    • Method::invoke
    • Method::checkedInvoke

The rfk::Object inheritance requirement is heavy so I'm thinking about a way to tell the generator to generate the getArchetype base definition / override if the parsed class is or inherits from any of a user-customizable set of classes.

  • TypeTemplateArgument class now stores a Type instead of an Archetype.

Fixes

  • Field class methods now correctly perform the instance pointer adjustment when necessary.

v2.1.2

22 Apr 08:16
Compare
Choose a tag to compare

New

  • A new optional parameter orderedByDeclaration has been added to the method rfk::Struct::getFieldsByPredicate. As its name states it, the returned fields are ordered by declaration order (inherited fields first) when orderedByDeclaration is set to true. You can now easily iterate over all fields of a Struct in the right order with the following lines:
rfk::Struct const& yourStruct = ...;
for (rfk::Field const* field : yourStruct.getFieldsByPredicate([](rfk::Field const&, void*){ return true; }, nullptr, true, true))
{
}
  • A macro has been added to automatically generate the base getArchetype method for class templates from a given template signature:
//Before 2.1.2
namespace rfk
{
    template <template <typename, int> typename>
    rfk::Archetype const* getArchetype() noexcept { return nullptr; }
}

//From 2.1.2
RFK_DEFINE_GET_ARCHETYPE_TEMPLATE(typename, int)

template <typename T, int U>
class CLASS() ClassTemplateWithDifferentTemplateParamTypes
{
    ClassTemplateWithDifferentTemplateParamTypes_GENERATED
};

Updates

  • Code generation has been simplified for enums. This doesn't impact the Refureku API.
  • Code generation for reflected class templates have been slightly improved (especially class templates nested in other classes).

Fixes

  • Archetypes non-publicly nested in structs/classes are now correctly handled. rfk::getArchetype<> and rfk::getEnum<> now return valid metadata in contexts where said archetypes are accessible (it was retruning nullptr before).
#include "Generated/ExampleClass.rfkh.h"

class CLASS() ExampleClass
{
    private:
        class CLASS() NestedPrivateClass
        {
            ExampleClass_NestedPrivateClass_GENERATED
        };

        enum class ENUM() NestedPrivateEnum
        {
        };

        void testMethod()
        {
            //Both of those calls do not return nullptr anymore
            rfk::getArchetype<NestedPrivateClass>();
            rfk::getEnum<NestedPrivateEnum>();
        }

    ExampleClass_GENERATED
};

File_ExampleClass_GENERATED

v2.1.1

18 Apr 07:51
Compare
Choose a tag to compare

This patch brings some fixes and stability improvements:

  • rfk::dynamicCast / rfk::dynamicUpCast / rfk::dynamicDownCast internal implementations moved from header file to source file to avoid recompilations if the implementation is modified.
  • When instantiating a class through the rfk::Struct::makeSharedInstance and rfk::Struct::makeUniqueInstance methods, the pointer is correctly adjusted if the return type has a non-zero memory offset compared to the instantiated class (happens when the class uses multiple inheritance with polymorphic parents -> multiple virtual tables).
class CLASS() A
{
    public:
        virtual ~A() = default;

    A_GENERATED
};

class CLASS() B
{
    public:
        virtual ~B() = default;

    B_GENERATED
};

class CLASS() C : public A, public B
{
    C_GENERATED
};

//....

//Was valid before since casting from C to A doesn't change the pointer address
C::staticGetArchetype().makeSharedInstance<A>();

//Was not valid before since casting from C to B does change the pointer address
//but Refureku was not doing the pointer adjustment internally
//This is now fixed with version 2.1.1
C::staticGetArchetype().makeSharedInstance<B>();

v2.1.0

14 Apr 05:46
Compare
Choose a tag to compare

The 2.1.0 minor update introduces a few new features, some slight performance/memory improvements and patch some bugs.

New

  • Custom instantiators now support rfk::UniquePtr as well! You can now declare instantiators returning a rfk::UniquePtr. See the Instantiator wiki page for more information.
  • The last version of Kodgen brings a new feature allowing to select the C++ version used to parse the code, hence bringing support for C++20 syntax (concepts etc...). See Kodgen file parser settings for details.
  • A custom dynamicCast function is now available to perform casts on reflected class types independently of the native c++ RTTI system. It hasn't been benchmarked nor optimized yet, so there's no performance improvement guarantee compared to the native C++ dynamic_cast as of now.

Updates

  • checkedInvoked can't be called on instances not inheriting from rfk::Object anymore. checkedInvoke needs to access the dynamic archetype of an instance to be able to adjust the caller pointer when necessary.
  • Memory for fields and methods is now allocated ahead of time with the exact necessary amount of memory to avoid unnecessary reallocations and unused memory, slightly improving startup time and memory footprint.

Fixes

  • Parent virtual methods are now callable with rfk::Method::invoke and rfk::Method::checkedInvoke on children instances without crash. However, rfk::Method::checkedInvoke now requires the caller to inherit from rfk::Object, and rfk::Method::invoke is not safe if the method is virtual, the caller pointer doesn't immediately point to the called method vtable, and the caller doesn't inherit from rfk::Object.
  • Structs metadata are now correctly unregistered from other related Structs (parents, subclasses) when they are released. Not doing so was causing corrupted pointers to released metadata when said metadata was part of a dynamically unloaded library.

v2.0.3

21 Mar 08:26
Compare
Choose a tag to compare

This patch brings some fixes when Refureku is used on dynamic libraries.

  • The parser now correctly detects rfk::Object inheritance when using export macro on classes, hence correctly generating the getArchetype override.
  • We now have the possibility to define an export macro in the CodeGenUnit settings so that the generated code is also exported in the dynamic library.

With the generator c++ API:

kodgen::MacroCodeGenUnitSettings codeGenUnitSettings;
codeGenUnitSettings.setExportSymbolMacroName("YOUR_EXPORT_MACRO");

With the toml settings file:

[CodeGenUnitSettings]
exportSymbolMacroName = "YOUR_EXPORT_MACRO"

v2.0.2

23 Dec 23:46
Compare
Choose a tag to compare

This new patch version brings a few quality of life slight modifications not related to the API:

  • The Linux prebuilt binaries are 2 times smaller than in the previous releases. This was due to the fact that libclang.so was incorrectly included twice in the archive because of a symlink.
  • In prebuilt binaries, the RefurekuGenerator executable should be able to locate and load libclang.so automatically if it is placed next to the executable (see #8).
  • GoogleTests is not a git submodule anymore and is fetched when building the project if tests are enabled. You can generate the project without tests with the -DBUILD_TESTING=OFF CMake flag (in which case Google tests won't be fetched).
  • There's now a REFUREKU_VERSION macro in the Config.h file. For the v2.0.2, REFUREKU_VERSION evaluates to (0)20002.
#if REFUREKU_VERSION >= 20002
//This Refureku version is >= to v2.0.2
#endif
  • [RefurekuGenerator] All entity registerers are now marked as const variables.

v2.0.1

20 Nov 16:54
Compare
Choose a tag to compare

This update only fixes a few generator bugs by updating Kodgen to the latest version. See Kodgen release notes for more info.

v2.0.0

12 Nov 15:57
Compare
Choose a tag to compare

It’s been nearly a year since the last Refureku release (v1.4.0). I was really busy and unfortunately couldn’t spend much time on the project. I had a lot of feedbacks from users and realized a bunch of things were not right, which is the reason for this major jump to v2. This release brings new interesting features and is overall more robust and stable than the previous major release.

Breaking changes

  • The library is now dynamic instead of static. The static model could not support reflection on dynamically loaded libraries and had a lot of limitations when linked to the target executable as well as dynamically loaded libraries (symbols duplication, bad registration, among others).
  • Library classes content is not accessible through public fields anymore. The API now uses the Pimpl idiom for better compatibility and robustness, and all data are accessible through method calls.
  • rfk::isReflectedClass traits doesn’t exist anymore.
  • A lot of members have been renamed with more explicit names.
  • The CustomInstantiator property was renamed in Instantiator.
  • Database is now accessible by calling rfk::getDatabase().
  • Refureku native properties moved in the rfk namespace.
  • The generated code is now split in 2 files. The generated header file must be included in headers (like before), and the generated source file must be included in a single translation unit.
  • Kodgen was updated to v2.0.0 along Refureku, so the code generation API has completely changed.

New

  • Class templates support (except variadic and auto non-type template parameters).
  • Dynamically loaded libraries reflection support.
  • When providing a custom instantiator, custom deleters can now be specified as well.
  • rfk::getField<&field> and rfk::getMethod<&method> functions.
  • Tested MacOS support!
  • Online hosted documentation: documentation
  • Code coverage as well as a full tests suite using GoogleTests.
  • Logo

Update

  • Due to the use of the Pimpl idiom, all implementation details are now hidden in the library source files, greatly reducing compile times and obj files size.
  • Get[Entity]ByPredicate methods are not noexcept anymore to allow exception propagation from the user provided predicate.
  • Database now issues a warning in case an id is registered multiple times (id collision).
  • Completely reworked Wiki and README.

Fix

  • Structs generate new ids for each inherited field. Having the same id could lead to crashes if a parent's field was used on a child class having different internal offsets.
  • Variable / function reflection using incomplete (forward declared) types are now working as expected.

v1.4.0

27 Nov 23:51
Compare
Choose a tag to compare

Add

  • New cmake compilation flag GEN_PROPERTY_RTTI for programs using the library with RTTI on
  • User-defined properties can now generate custom code
  • New overloads to search all kinds of entities by predicate
  • Intermediate methods to fill entities metadata. It is used by the generated code and makes a cleaner way to manually setup and register entities.

Update

  • Complete rework of the property system
  • Spaces are not ignored by default when parsing properties

Remove

/

v1.3.0

27 Oct 23:55
Compare
Choose a tag to compare

Add

  • Function reflection
  • Variable reflection
  • Multithreaded code generator
  • rfk::Enum::underlyingType
  • rfk::getArchetype template function available for any type
  • compiler setting
  • More informative logs when loading settings from the RefurekuSettings.toml file

Update

  • Accelerate file parsing (ignore generated code)
  • Entity::EKind enum now contains a value of each concrete Entity class
  • Fundamental archetypes now register to the database
  • Rename rfk::ReflectedObject to rfk::Object
  • Settings are now safer to manipulate (check paths, compiler support...)

Remove

  • DynamicGetArchetype property - Each reflected class inheriting directly or indirectly from rfk::Object will now have their getArchetype method overriden