From d1c80a30ee8b13c7331a3e410b4d4f5e05c0dd21 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 13 Sep 2025 16:31:03 +0530 Subject: [PATCH 001/148] introducing rtl::detail::lambda_table --- ReflectionTemplateLib/access/inc/Function.h | 2 + ReflectionTemplateLib/access/inc/Function.hpp | 12 ++ .../detail/inc/CallReflector.h | 9 +- .../detail/inc/FunctionCaller.hpp | 10 +- .../detail/inc/FunctorContainer.h | 40 +++-- ReflectionTemplateLib/detail/inc/FunctorId.h | 103 +++++------ .../detail/inc/LambdaTable.h | 82 +++++++++ .../detail/inc/MethodContainer.h | 54 ++++-- .../detail/inc/SetupConstructor.hpp | 18 +- .../detail/inc/SetupFunction.hpp | 14 +- .../detail/inc/SetupMethod.hpp | 166 +++++++++--------- .../detail/src/CMakeLists.txt | 1 + 12 files changed, 332 insertions(+), 179 deletions(-) create mode 100644 ReflectionTemplateLib/detail/inc/LambdaTable.h diff --git a/ReflectionTemplateLib/access/inc/Function.h b/ReflectionTemplateLib/access/inc/Function.h index 42d0bd4a..88192f05 100644 --- a/ReflectionTemplateLib/access/inc/Function.h +++ b/ReflectionTemplateLib/access/inc/Function.h @@ -67,6 +67,8 @@ namespace rtl { const std::size_t hasSignatureId(const std::size_t pSignatureId) const; + const detail::FunctorId* hasFunctorId(const std::size_t pSignatureId) const; + GETTER(detail::methodQ, Qualifier, m_qualifier); GETTER_REF(std::vector, FunctorIds, m_functorIds) diff --git a/ReflectionTemplateLib/access/inc/Function.hpp b/ReflectionTemplateLib/access/inc/Function.hpp index 4c620c71..b00ddf0d 100644 --- a/ReflectionTemplateLib/access/inc/Function.hpp +++ b/ReflectionTemplateLib/access/inc/Function.hpp @@ -63,4 +63,16 @@ namespace rtl } return rtl::index_none; } + + + FORCE_INLINE const detail::FunctorId* Function::hasFunctorId(const std::size_t pSignatureId) const + { + //simple linear-search, efficient for small set of elements. + for (const auto& functorId : m_functorIds) { + if (functorId.getSignatureId() == pSignatureId) [[likely]] { + return &functorId; + } + } + return nullptr; + } } diff --git a/ReflectionTemplateLib/detail/inc/CallReflector.h b/ReflectionTemplateLib/detail/inc/CallReflector.h index fad4ecd6..5b0abb0f 100644 --- a/ReflectionTemplateLib/detail/inc/CallReflector.h +++ b/ReflectionTemplateLib/detail/inc/CallReflector.h @@ -14,6 +14,7 @@ #include #include "RObject.h" #include "Constants.h" +#include "FunctorId.h" namespace rtl::detail { @@ -30,10 +31,14 @@ namespace rtl::detail { * gets the lambda vector from '_derivedType' and calls the lambda at given index with '_args'. * this 'forwardCall' is for calling lambda containing non-member-function and static-member-function functors. */ template - FORCE_INLINE static Return forwardCall(std::size_t pFunctorIndex, _params&&..._args) + FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, _params&&..._args) { + // static_cast to derived type, gaurateed safe by design. + //auto lambdaTable = static_cast<_derivedType::lambda_t*>(pFunctorId.m_lambdaTable); + //return lambdaTable->get()[pFunctorId.m_index](std::forward<_params>(_args)...); + //'getFunctors()' must be implemented by _derivedType (FunctorContainer). - return _derivedType::getFunctors()[pFunctorIndex](std::forward<_params>(_args)...); + return _derivedType::getFunctors()[pFunctorId.m_index](std::forward<_params>(_args)...); } diff --git a/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp index a673afd5..de652d62 100644 --- a/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp @@ -26,9 +26,13 @@ namespace rtl::detail FunctorContainer...>, FunctorContainer<_signature...>>; - std::size_t index = m_function->hasSignatureId(Container::getContainerId()); - if (index != rtl::index_none) [[likely]] { - return Container::template forwardCall<_args...>(index, std::forward<_args>(params)...); + //auto containerId = Container::getContainerId(); + //const detail::FunctorId* functorId = m_function->hasFunctorId(containerId); + //return { error::None, RObject{} }; + + const detail::FunctorId* functorId = m_function->hasFunctorId(Container::getContainerId()); + if (functorId != nullptr) [[likely]] { + return Container::template forwardCall<_args...>(*functorId, std::forward<_args>(params)...); } return { error::SignatureMismatch, RObject{} }; } diff --git a/ReflectionTemplateLib/detail/inc/FunctorContainer.h b/ReflectionTemplateLib/detail/inc/FunctorContainer.h index 425ad930..8f96bc5a 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorContainer.h +++ b/ReflectionTemplateLib/detail/inc/FunctorContainer.h @@ -15,6 +15,7 @@ #include #include +#include "LambdaTable.h" #include "Constants.h" #include "CallReflector.h" #include "SetupFunction.h" @@ -27,10 +28,10 @@ namespace rtl { //forward decl class ReflectionBuilder; - /* @class: FunctorContainer - @param: '_signature...' (combination of any types) - * container class for holding lambda's wrapping functor, constructor calls of same signatures. - * maintains a std::vector with static lifetime. + /* @class: FunctorContainer + @param: '_signature...' (combination of any types) + * container class for holding lambda's wrapping functor, constructor calls of same signatures. + * maintains a std::vector with static lifetime. */ template class FunctorContainer : public SetupFunction>, public SetupConstructor>, @@ -39,6 +40,8 @@ namespace rtl { using FunctionLambda = std::function < Return(_signature...) >; public: + using lambda_t = detail::functors<_signature...>; + //every FunctorContainer<...> will have a unique-id. FORCE_INLINE static std::size_t getContainerId() { static const std::size_t containerId = generate_unique_id(); @@ -67,26 +70,37 @@ namespace rtl { return functorTable; } + static lambda_t& lambdaCache() + { + static lambda_t functorsCache; + return functorsCache; + } + /* @method: pushBack @params: pFunctor (lambda containing functor or constructor call) - pGetIndex (lambda providing index if the functor is already registered) - pUpdate (lambda updating the already registered functors/ctor/d'tor set) + pGetIndex (lambda providing index if the functor is already registered) + pUpdate (lambda updating the already registered functors/ctor/d'tor set) @return: index of newly added or already existing lambda in vector 'm_functors'. - */ static std::size_t pushBack(const FunctionLambda& pFunctor, - std::function pGetIndex, - std::function pUpdate) + */ static std::pair pushBack(const FunctionLambda& pFunctor, + std::function pGetIndex, + std::function pUpdate) { //critical section, thread safe. static std::mutex mtx; std::lock_guard lock(mtx); std::size_t index = pGetIndex(); - if (index == rtl::index_none) { - index = getFunctorTable().size(); - pUpdate(index); + if (index == rtl::index_none) + { + index = lambdaCache().get().size(); + + lambdaCache().pushBack(pFunctor); + getFunctorTable().push_back(pFunctor); + + pUpdate(index); } - return index; + return { index, &lambdaCache() }; } //friends :) diff --git a/ReflectionTemplateLib/detail/inc/FunctorId.h b/ReflectionTemplateLib/detail/inc/FunctorId.h index 5fee2669..b15d804e 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/detail/inc/FunctorId.h @@ -14,64 +14,65 @@ #include "TypeId.h" #include "Constants.h" -namespace rtl +namespace rtl::detail { - namespace detail + class lambda_table; + +/* @class: FunctorId + * 'FunctorId' object is generated for every functor (member/non-member function pointer) registered. + * acts as a hash-key to lookup a particular functor in the functor-table. + * first, using 'm_containerId', the functor-table container is found. + * once table is found, the functor is accessed at index 'm_index', (never fails, noexcept) + * 'FunctorId' generated for a each functor is unique, even for overloaded functions. + * multiple registartion of same functor will generate same duplicate 'FunctorId'. +*/ struct FunctorId { - /* @class: FunctorId - * 'FunctorId' object is generated for every functor (member/non-member function pointer) registered. - * acts as a hash-key to lookup a particular functor in the functor-table. - * first, using 'm_containerId', the functor-table container is found. - * once table is found, the functor is accessed at index 'm_index', (never fails, noexcept) - * 'FunctorId' generated for a each functor is unique, even for overloaded functions. - * multiple registartion of same functor will generate same duplicate 'FunctorId'. - */ struct FunctorId - { - //index of the functor in the functor-table. - std::size_t m_index; + //index of the functor in the functor-table. + std::size_t m_index; - //return type-id of the functor registered. - std::size_t m_returnId; + //return type-id of the functor registered. + std::size_t m_returnId; - //if functor is a member-function, type id of class/struct it belongs to. - std::size_t m_recordId; + //if functor is a member-function, type id of class/struct it belongs to. + std::size_t m_recordId; - //containerId of the functor-table. - std::size_t m_containerId; + //containerId of the functor-table. + std::size_t m_containerId; - //signature of functor as string. platform dependent, may not be very much readable format. - std::string m_signature; + //signature of functor as string. platform dependent, may not be very much readable format. + std::string m_signature; - GETTER(std::size_t, Index, m_index) - GETTER(std::size_t, ReturnId, m_returnId); - GETTER(std::size_t, RecordId, m_recordId); - GETTER(std::size_t, SignatureId, m_containerId) - GETTER(std::string, SignatureStr, m_signature) + lambda_table* m_lambdaTable = nullptr; - /* @method: getHashCode() - @return: std::size_t (a unique hash-code for a functor) - * 'm_containerId' will be same for functors(non-member) with same signatures. - * for member functions, a functor will have three atrributes - - signature - - whether it is const or non-const - - class/struct type - 'm_containerId' will be same for functors with same above attributes. - * every functor will have a distinct index in the functor-wrapped-lambda-table. - * so, combination of m_containerId & m_index is unique for every functor. - */ std::size_t getHashCode() const - { - return std::stoull(std::to_string(m_containerId) + - std::to_string(m_index) + - std::to_string(m_recordId) + - std::to_string(m_returnId)); - } + GETTER(std::size_t, Index, m_index) + GETTER(std::size_t, ReturnId, m_returnId); + GETTER(std::size_t, RecordId, m_recordId); + GETTER(std::size_t, SignatureId, m_containerId) + GETTER(std::string, SignatureStr, m_signature) - const bool operator==(const FunctorId& pOther) const - { - return (m_index == pOther.m_index && m_returnId == pOther.m_returnId && - m_recordId == pOther.m_recordId && m_containerId == pOther.m_containerId && - m_signature == pOther.m_signature); - } - }; - } + /* @method: getHashCode() + @return: std::size_t (a unique hash-code for a functor) + * 'm_containerId' will be same for functors(non-member) with same signatures. + * for member functions, a functor will have three atrributes + - signature + - whether it is const or non-const + - class/struct type + 'm_containerId' will be same for functors with same above attributes. + * every functor will have a distinct index in the functor-wrapped-lambda-table. + * so, combination of m_containerId & m_index is unique for every functor. + */ std::size_t getHashCode() const + { + return std::stoull(std::to_string(m_containerId) + + std::to_string(m_index) + + std::to_string(m_recordId) + + std::to_string(m_returnId)); + } + + const bool operator==(const FunctorId& pOther) const + { + return (m_index == pOther.m_index && m_returnId == pOther.m_returnId && + m_recordId == pOther.m_recordId && m_containerId == pOther.m_containerId && + m_signature == pOther.m_signature); + } + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/LambdaTable.h b/ReflectionTemplateLib/detail/inc/LambdaTable.h new file mode 100644 index 00000000..2d3de000 --- /dev/null +++ b/ReflectionTemplateLib/detail/inc/LambdaTable.h @@ -0,0 +1,82 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include +#include + +#include "Constants.h" + +namespace rtl { + + class RObject; + struct Return; +} + +namespace rtl::detail +{ + class lambda_table { }; +} + + +namespace rtl::detail +{ + template + class functors : public lambda_table + { + using lambda_t = std::function ; + + std::vector m_lambdaTable; + + public: + + GETTER_CREF(std::vector, , m_lambdaTable) + + void pushBack(const lambda_t& pLambda) { + m_lambdaTable.push_back(pLambda); + } + }; + + + template + class const_functors : public lambda_table + { + using lambda_t = std::function ; + + std::vector m_lambdaTable; + + public: + + GETTER_CREF(std::vector, , m_lambdaTable) + + void pushBack(const lambda_t& pLambda) { + m_lambdaTable.push_back(pLambda); + } + }; + + + template + class nonconst_functors : public lambda_table + { + using lambda_t = std::function ; + + std::vector m_lambdaTable; + + public: + + GETTER_CREF(std::vector, , m_lambdaTable) + + void pushBack(const lambda_t& pLambda) { + m_lambdaTable.push_back(pLambda); + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/MethodContainer.h b/ReflectionTemplateLib/detail/inc/MethodContainer.h index 3a9ec85a..a81d86e1 100644 --- a/ReflectionTemplateLib/detail/inc/MethodContainer.h +++ b/ReflectionTemplateLib/detail/inc/MethodContainer.h @@ -44,6 +44,8 @@ namespace rtl { public: + using lambda_t = detail::nonconst_functors<_signature...>; + //every MethodContainer will have a unique-id. static std::size_t getContainerId() { //holds unique-id @@ -73,26 +75,37 @@ namespace rtl { return functorTable; } + static lambda_t& lambdaCache() + { + static lambda_t functorsCache; + return functorsCache; + } + /* @method: pushBack @params: pFunctor (lambda containing non-const-member-function functor call) pGetIndex (lambda providing index if the functor is already registered) pUpdate (lambda updating the already registered functors set) @return: index of newly added or already existing lambda in vector 'm_methodPtrs'. - */ static std::size_t pushBack(const MethodLambda& pFunctor, - std::function pGetIndex, - std::function pUpdateIndex) + */ static std::pair pushBack(const MethodLambda& pFunctor, + std::function pGetIndex, + std::function pUpdateIndex) { //critical section, thread safe. static std::mutex mtx; std::lock_guard lock(mtx); std::size_t index = pGetIndex(); - if (index == rtl::index_none) { - index = getFunctorTable().size(); - pUpdateIndex(index); + if (index == rtl::index_none) + { + index = lambdaCache().get().size(); + + lambdaCache().pushBack(pFunctor); + getFunctorTable().push_back(pFunctor); + + pUpdateIndex(index); } - return index; + return { index, &lambdaCache() }; } //friends :) @@ -116,6 +129,8 @@ namespace rtl { public: + using lambda_t = detail::const_functors<_signature...>; + //every MethodContainer will have a unique-id. FORCE_INLINE static std::size_t getContainerId() { //holds unique-id @@ -145,26 +160,37 @@ namespace rtl { return functorTable; } + static lambda_t& lambdaCache() + { + static lambda_t functorsCache; + return functorsCache; + } + /* @method: pushBack @params: pFunctor (lambda containing const-member-function functor call) pGetIndex (lambda providing index if the functor is already registered) pUpdate (lambda updating the already registered functors set) @return: index of newly added or already existing lambda in vector 'm_methodPtrs'. - */ static std::size_t pushBack(const MethodLambda& pFunctor, - std::function pGetIndex, - std::function pUpdateIndex) + */ static std::pair pushBack(const MethodLambda& pFunctor, + std::function pGetIndex, + std::function pUpdateIndex) { //critical section, thread safe. static std::mutex mtx; std::lock_guard lock(mtx); std::size_t index = pGetIndex(); - if (index == rtl::index_none) { - index = getFunctorTable().size(); - pUpdateIndex(index); + if (index == rtl::index_none) + { + index = lambdaCache().get().size(); + + lambdaCache().pushBack(pFunctor); + getFunctorTable().push_back(pFunctor); + + pUpdateIndex(index); } - return index; + return { index, &lambdaCache() }; } //friends :) diff --git a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp b/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp index e2d025be..8a963920 100644 --- a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp @@ -133,9 +133,12 @@ namespace rtl::detail }; //add the lambda in 'FunctorContainer'. - std::size_t index = _derivedType::pushBack(getConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); - const auto& signatureStr = _derivedType::template getSignatureStr<_recordType>(true); - return detail::FunctorId(index, recordId, recordId, containerId, signatureStr); + auto [index, lambdaPtr] = _derivedType::pushBack(getConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); + + return detail::FunctorId { + index, recordId, recordId, containerId, + _derivedType::template getSignatureStr<_recordType>(true), lambdaPtr + }; } @@ -162,8 +165,11 @@ namespace rtl::detail }; //add the lambda in 'FunctorContainer'. - std::size_t index = _derivedType::pushBack(getCopyConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); - const auto& signatureStr = _derivedType::template getSignatureStr<_recordType>(true); - return detail::FunctorId(index, recordId, recordId, containerId, signatureStr); + auto [index, lambdaPtr] = _derivedType::pushBack(getCopyConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); + + return detail::FunctorId { + index, recordId, recordId, containerId, + _derivedType::template getSignatureStr<_recordType>(true), lambdaPtr + }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp b/ReflectionTemplateLib/detail/inc/SetupFunction.hpp index 07b9931d..916e5193 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupFunction.hpp @@ -36,15 +36,15 @@ namespace rtl inline SetupFunction<_derivedType>::FunctionLambda<_signature...> SetupFunction<_derivedType>::getCaller(_returnType(*pFunctor)(_signature...)) { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (FunctorContainer) vector holding lambda's. - */ return [pFunctor](_signature&&...params)-> Return + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (FunctorContainer) vector holding lambda's. + */ return [pFunctor](_signature&&...params)-> Return { constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); if constexpr (std::is_reference_v<_returnType>) { /* if the function returns reference, this block will be retained by compiler. - Note: reference to temporary or dangling is not checked here. + Note: reference to temporary or dangling is not checked here. */ using _rawRetType = traits::raw_t<_returnType>; const _rawRetType& retObj = pFunctor(std::forward<_signature>(params)...); return { error::None, @@ -107,12 +107,12 @@ namespace rtl //generate a type-id of '_returnType'. const std::size_t retTypeId = TypeId>::get(); //finally add the lambda 'functor' in 'FunctorContainer' lambda vector and get the index. - const std::size_t index = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); + auto [index, lambdaPtr] = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. - return detail::FunctorId{ + return detail::FunctorId { index, retTypeId, pRecordId, _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_returnType>() + _derivedType::template getSignatureStr<_returnType>(), lambdaPtr }; } } diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp b/ReflectionTemplateLib/detail/inc/SetupMethod.hpp index 78979dae..377361e9 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupMethod.hpp @@ -26,9 +26,9 @@ namespace rtl inline SetupMethod<_derivedType>::MethodLambda<_signature...> SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...)) { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. + */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return { if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -44,41 +44,41 @@ namespace rtl template template inline SetupMethod<_derivedType>::MethodLambda<_signature...> - SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...)) + SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...)) { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return - { - if (!pTargetObj.isConstCastSafe()) [[unlikely]] { - return { error::IllegalConstCast, RObject{} }; - } - - constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); - //'target' needs const_cast, since the functor is non-const-member-function. - _recordType& target = const_cast<_recordType&>(pTargetObj.view<_recordType>()->get()); - if constexpr (std::is_reference_v<_returnType>) + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. + */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return { - /* if the function returns reference, this block will be retained by compiler. - Note: reference to temporary or dangling is not checked here. - */ using _rawRetType = traits::raw_t<_returnType>; - const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); - return { error::None, - RObjectBuilder::template - build(&retObj, rtl::index_none, isConstCastSafe) - }; - } - else { + if (!pTargetObj.isConstCastSafe()) [[unlikely]] { + return { error::IllegalConstCast, RObject{} }; + } - auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); - using T = std::remove_cvref_t; + constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); + //'target' needs const_cast, since the functor is non-const-member-function. + _recordType& target = const_cast<_recordType&>(pTargetObj.view<_recordType>()->get()); + if constexpr (std::is_reference_v<_returnType>) + { + /* if the function returns reference, this block will be retained by compiler. + Note: reference to temporary or dangling is not checked here. + */ using _rawRetType = traits::raw_t<_returnType>; + const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + return { error::None, + RObjectBuilder::template + build(&retObj, rtl::index_none, isConstCastSafe) + }; + } + else { - return { error::None, - RObjectBuilder::template - build(std::forward(retObj), rtl::index_none, isConstCastSafe) - }; - } - }; + auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + using T = std::remove_cvref_t; + + return { error::None, + RObjectBuilder::template + build(std::forward(retObj), rtl::index_none, isConstCastSafe) + }; + } + }; } @@ -86,52 +86,52 @@ namespace rtl template template inline SetupMethod<_derivedType>::MethodLambda<_signature...> - SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...) const) + SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...) const) { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return - { - const _recordType& target = pTargetObj.view<_recordType>()->get(); - (target.*pFunctor)(std::forward<_signature>(params)...); - return { error::None, RObject{} }; - }; + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. + */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return + { + const _recordType& target = pTargetObj.view<_recordType>()->get(); + (target.*pFunctor)(std::forward<_signature>(params)...); + return { error::None, RObject{} }; + }; } template template inline SetupMethod<_derivedType>::MethodLambda<_signature...> - SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...) const) + SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...) const) { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return - { - constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); - //'target' is const and 'pFunctor' is const-member-function. - const _recordType& target = pTargetObj.view<_recordType>()->get(); - if constexpr (std::is_reference_v<_returnType>) { - /* if the function returns reference, this block will be retained by compiler. - Note: reference to temporary or dangling is not checked here. - */ using _rawRetType = traits::raw_t<_returnType>; - const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); - return { error::None, - RObjectBuilder::template - build(&retObj, rtl::index_none, isConstCastSafe) - }; - } - else { + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. + */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return + { + constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); + //'target' is const and 'pFunctor' is const-member-function. + const _recordType& target = pTargetObj.view<_recordType>()->get(); + if constexpr (std::is_reference_v<_returnType>) { + /* if the function returns reference, this block will be retained by compiler. + Note: reference to temporary or dangling is not checked here. + */ using _rawRetType = traits::raw_t<_returnType>; + const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + return { error::None, + RObjectBuilder::template + build(&retObj, rtl::index_none, isConstCastSafe) + }; + } + else { - auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); - using T = std::remove_cvref_t; + auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + using T = std::remove_cvref_t; - return { error::None, - RObjectBuilder::template - build(std::forward(retObj), rtl::index_none, isConstCastSafe) - }; - } - }; + return { error::None, + RObjectBuilder::template + build(std::forward(retObj), rtl::index_none, isConstCastSafe) + }; + } + }; } @@ -145,9 +145,9 @@ namespace rtl * adds lambda (functor-wrapped) in '_derivedType' (MethodContainer) and maintains functorSet. * thread safe, multiple functors can be registered simultaneously. */ template - template - inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) - { + template + inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) + { /* set of already registered functors. (static life time). used std::vector, efficient for small sets. std::set/map will be overhead. */ static std::vector> functorSet; @@ -155,7 +155,7 @@ namespace rtl /* adds the generated functor index to the 'functorSet'. (thread safe). called from '_derivedType' (MethodContainer) */ const auto& updateIndex = [&](std::size_t pIndex)->void { - functorSet.emplace_back(pFunctor, pIndex); + functorSet.emplace_back(pFunctor, pIndex); }; /* checks if the 'pFunctor' is already present in 'functorSet'. (thread safe). @@ -179,20 +179,20 @@ namespace rtl if constexpr (std::is_same_v<_returnType, void>) { - const std::size_t index = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. - return detail::FunctorId{ + return detail::FunctorId { index, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>() + _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr }; } else { - const std::size_t index = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { index, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>() + _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr }; } } @@ -239,20 +239,20 @@ namespace rtl if constexpr (std::is_same_v<_returnType, void>) { - const std::size_t index = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { index, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>() + _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr }; } else { - const std::size_t index = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { index, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>() + _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr }; } } diff --git a/ReflectionTemplateLib/detail/src/CMakeLists.txt b/ReflectionTemplateLib/detail/src/CMakeLists.txt index 46ec416a..7db6be7a 100644 --- a/ReflectionTemplateLib/detail/src/CMakeLists.txt +++ b/ReflectionTemplateLib/detail/src/CMakeLists.txt @@ -12,6 +12,7 @@ SET(LOCAL_HEADERS "${PROJECT_SOURCE_DIR}/detail/inc/CxxReflection.h" "${PROJECT_SOURCE_DIR}/detail/inc/FunctionCaller.h" "${PROJECT_SOURCE_DIR}/detail/inc/FunctionCaller.hpp" + "${PROJECT_SOURCE_DIR}/detail/inc/LambdaTable.h" "${PROJECT_SOURCE_DIR}/detail/inc/MethodInvoker.h" "${PROJECT_SOURCE_DIR}/detail/inc/MethodInvoker.hpp" "${PROJECT_SOURCE_DIR}/detail/inc/FunctorContainer.h" From 0af7adf88ac712144e89463e871dd9a574086456 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sun, 14 Sep 2025 15:20:33 +0530 Subject: [PATCH 002/148] integrated functor/lambda static cache and other types. --- RTLBenchmarkApp/src/ReflectedCall.cpp | 2 +- .../detail/inc/CallReflector.h | 6 +- .../detail/inc/FunctorContainer.h | 29 +- ReflectionTemplateLib/detail/inc/FunctorId.h | 19 +- .../detail/inc/FunctorRegistry.h | 129 ++++++ .../detail/inc/LambdaBridge.h | 35 ++ .../inc/{LambdaTable.h => LambdaRegistry.h} | 42 +- .../detail/inc/MethodContainer.h | 12 +- .../detail/inc/SetupConstructor.hpp | 4 +- .../detail/inc/SetupFunction.h | 12 + .../detail/inc/SetupFunction.hpp | 34 +- .../detail/inc/SetupMethod.h | 92 +++-- .../detail/inc/SetupMethod.hpp | 380 ++++++++---------- .../detail/src/CMakeLists.txt | 4 +- 14 files changed, 485 insertions(+), 315 deletions(-) create mode 100644 ReflectionTemplateLib/detail/inc/FunctorRegistry.h create mode 100644 ReflectionTemplateLib/detail/inc/LambdaBridge.h rename ReflectionTemplateLib/detail/inc/{LambdaTable.h => LambdaRegistry.h} (59%) diff --git a/RTLBenchmarkApp/src/ReflectedCall.cpp b/RTLBenchmarkApp/src/ReflectedCall.cpp index 325c72ea..337c676f 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.cpp +++ b/RTLBenchmarkApp/src/ReflectedCall.cpp @@ -22,7 +22,7 @@ namespace { auto Node = cxx::mirror().getRecord("Node").value(); auto [err, robj] = Node.create(); - if (nodeObj.isEmpty()) { + if (robj.isEmpty()) { std::cout << "[0] nodeObj empty! \n"; } return std::move(robj); diff --git a/ReflectionTemplateLib/detail/inc/CallReflector.h b/ReflectionTemplateLib/detail/inc/CallReflector.h index 5b0abb0f..7a896cfd 100644 --- a/ReflectionTemplateLib/detail/inc/CallReflector.h +++ b/ReflectionTemplateLib/detail/inc/CallReflector.h @@ -33,12 +33,8 @@ namespace rtl::detail { */ template FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, _params&&..._args) { - // static_cast to derived type, gaurateed safe by design. - //auto lambdaTable = static_cast<_derivedType::lambda_t*>(pFunctorId.m_lambdaTable); - //return lambdaTable->get()[pFunctorId.m_index](std::forward<_params>(_args)...); - //'getFunctors()' must be implemented by _derivedType (FunctorContainer). - return _derivedType::getFunctors()[pFunctorId.m_index](std::forward<_params>(_args)...); + return _derivedType::getFunctors()[pFunctorId.m_lambdaIndex](std::forward<_params>(_args)...); } diff --git a/ReflectionTemplateLib/detail/inc/FunctorContainer.h b/ReflectionTemplateLib/detail/inc/FunctorContainer.h index 8f96bc5a..d35e5376 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorContainer.h +++ b/ReflectionTemplateLib/detail/inc/FunctorContainer.h @@ -15,7 +15,7 @@ #include #include -#include "LambdaTable.h" +#include "LambdaRegistry.h" #include "Constants.h" #include "CallReflector.h" #include "SetupFunction.h" @@ -28,10 +28,10 @@ namespace rtl { //forward decl class ReflectionBuilder; - /* @class: FunctorContainer - @param: '_signature...' (combination of any types) - * container class for holding lambda's wrapping functor, constructor calls of same signatures. - * maintains a std::vector with static lifetime. + /* @class: FunctorContainer + @param: '_signature...' (combination of any types) + * container class for holding lambda_hop's wrapping functor, constructor calls of same signatures. + * maintains a std::vector with static lifetime. */ template class FunctorContainer : public SetupFunction>, public SetupConstructor>, @@ -40,7 +40,7 @@ namespace rtl { using FunctionLambda = std::function < Return(_signature...) >; public: - using lambda_t = detail::functors<_signature...>; + using lambda_t = detail::lambda_registry<_signature...>; //every FunctorContainer<...> will have a unique-id. FORCE_INLINE static std::size_t getContainerId() { @@ -62,6 +62,14 @@ namespace rtl { "(" + TypeId<_signature...>::toString() + ")"); } + + static lambda_t& lambdaCache() + { + static lambda_t lambdaRegistry; + return lambdaRegistry; + } + + private: //vector holding lambdas @@ -70,18 +78,13 @@ namespace rtl { return functorTable; } - static lambda_t& lambdaCache() - { - static lambda_t functorsCache; - return functorsCache; - } /* @method: pushBack @params: pFunctor (lambda containing functor or constructor call) pGetIndex (lambda providing index if the functor is already registered) pUpdate (lambda updating the already registered functors/ctor/d'tor set) @return: index of newly added or already existing lambda in vector 'm_functors'. - */ static std::pair pushBack(const FunctionLambda& pFunctor, + */ static std::pair pushBack(const FunctionLambda& pFunctor, std::function pGetIndex, std::function pUpdate) { @@ -94,7 +97,7 @@ namespace rtl { { index = lambdaCache().get().size(); - lambdaCache().pushBack(pFunctor); + lambdaCache().push(pFunctor); getFunctorTable().push_back(pFunctor); diff --git a/ReflectionTemplateLib/detail/inc/FunctorId.h b/ReflectionTemplateLib/detail/inc/FunctorId.h index b15d804e..5f606e0f 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/detail/inc/FunctorId.h @@ -16,7 +16,7 @@ namespace rtl::detail { - class lambda_table; + class lambda_hop; /* @class: FunctorId * 'FunctorId' object is generated for every functor (member/non-member function pointer) registered. @@ -28,7 +28,9 @@ namespace rtl::detail */ struct FunctorId { //index of the functor in the functor-table. - std::size_t m_index; + std::size_t m_lambdaIndex; + + std::size_t m_functorIndex; //return type-id of the functor registered. std::size_t m_returnId; @@ -42,9 +44,9 @@ namespace rtl::detail //signature of functor as string. platform dependent, may not be very much readable format. std::string m_signature; - lambda_table* m_lambdaTable = nullptr; + lambda_hop* m_lambdas = nullptr; - GETTER(std::size_t, Index, m_index) + GETTER(std::size_t, Index, m_lambdaIndex) GETTER(std::size_t, ReturnId, m_returnId); GETTER(std::size_t, RecordId, m_recordId); GETTER(std::size_t, SignatureId, m_containerId) @@ -63,15 +65,18 @@ namespace rtl::detail */ std::size_t getHashCode() const { return std::stoull(std::to_string(m_containerId) + - std::to_string(m_index) + + std::to_string(m_lambdaIndex) + std::to_string(m_recordId) + std::to_string(m_returnId)); } const bool operator==(const FunctorId& pOther) const { - return (m_index == pOther.m_index && m_returnId == pOther.m_returnId && - m_recordId == pOther.m_recordId && m_containerId == pOther.m_containerId && + return (m_returnId == pOther.m_returnId && + m_recordId == pOther.m_recordId && + m_containerId == pOther.m_containerId && + m_lambdaIndex == pOther.m_lambdaIndex && + m_functorIndex == pOther.m_functorIndex && m_signature == pOther.m_signature); } }; diff --git a/ReflectionTemplateLib/detail/inc/FunctorRegistry.h b/ReflectionTemplateLib/detail/inc/FunctorRegistry.h new file mode 100644 index 00000000..72b62908 --- /dev/null +++ b/ReflectionTemplateLib/detail/inc/FunctorRegistry.h @@ -0,0 +1,129 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +namespace rtl { + struct Return; +} + + +namespace rtl::detail +{ + class functor_hop {}; +} + + +namespace rtl::detail +{ + template + class functor_registry : public functor_hop + { + using functor_t = return_t(*)(signature_ts...); + + std::vector> m_functors; + + public: + + functor_t operator[](std::size_t index) { + return m_functors[index].first; + } + + void push(functor_t fptr, std::size_t lambda_index) { + m_functors.emplace_back(fptr, lambda_index); + } + + std::size_t find(functor_t fptr) + { + //linear search, efficient for small set. + for (const auto& itr : m_functors) { + if (itr.first == fptr) { + //functor already registered, return its 'index'. + return itr.second; + } + } + //functor is not already registered, return '-1'. + return rtl::index_none; + } + }; +} + + +namespace rtl::detail +{ + template + class method_registry : public functor_hop + { + using functor_t = return_t(record_t::*)(signature_ts...); + + std::vector> m_functors; + + public: + + functor_t operator[](std::size_t index) { + return m_functors[index].first; + } + + void push(functor_t fptr, std::size_t lambda_index) { + m_functors.emplace_back(fptr, lambda_index); + } + + std::size_t find(functor_t fptr) + { + //linear search, efficient for small set. + for (const auto& itr : m_functors) { + if (itr.first == fptr) { + //functor already registered, return its 'index'. + return itr.second; + } + } + //functor is not already registered, return '-1'. + return rtl::index_none; + } + }; +} + + +namespace rtl::detail +{ + template + class const_method_registry : public functor_hop + { + using functor_t = return_t(record_t::*)(signature_ts...) const; + + std::vector> m_functors; + + public: + + functor_t operator[](std::size_t index) { + return m_functors[index].first; + } + + void push(functor_t fptr, std::size_t lambda_index) { + m_functors.emplace_back(fptr, lambda_index); + } + + std::size_t find(functor_t fptr) + { + //linear search, efficient for small set. + for (const auto& itr : m_functors) { + if (itr.first == fptr) { + //functor already registered, return its 'index'. + return itr.second; + } + } + //functor is not already registered, return '-1'. + return rtl::index_none; + } + }; +} diff --git a/ReflectionTemplateLib/detail/inc/LambdaBridge.h b/ReflectionTemplateLib/detail/inc/LambdaBridge.h new file mode 100644 index 00000000..9a5387c5 --- /dev/null +++ b/ReflectionTemplateLib/detail/inc/LambdaBridge.h @@ -0,0 +1,35 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "FunctorId.h" +#include "FunctorRegistry.h" + +namespace rtl { + struct Return; +} + +namespace rtl::detail::bridge +{ + template + struct lambda_def + { + template + static auto get() + { + return [](const FunctorId& functorId, signature_ts&&...params) + { + + }; + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/LambdaTable.h b/ReflectionTemplateLib/detail/inc/LambdaRegistry.h similarity index 59% rename from ReflectionTemplateLib/detail/inc/LambdaTable.h rename to ReflectionTemplateLib/detail/inc/LambdaRegistry.h index 2d3de000..446d8a3e 100644 --- a/ReflectionTemplateLib/detail/inc/LambdaTable.h +++ b/ReflectionTemplateLib/detail/inc/LambdaRegistry.h @@ -11,10 +11,13 @@ #pragma once +#include "LambdaBridge.h" + #include #include #include "Constants.h" +#include "FunctorRegistry.h" namespace rtl { @@ -22,61 +25,70 @@ namespace rtl { struct Return; } + namespace rtl::detail { - class lambda_table { }; + class lambda_hop { }; } namespace rtl::detail { template - class functors : public lambda_table + class lambda_registry : public lambda_hop { - using lambda_t = std::function ; + using lambda_t = std::function; - std::vector m_lambdaTable; + std::vector m_lambdas; + + std::vector m_functors; public: - GETTER_CREF(std::vector, , m_lambdaTable) + GETTER_CREF(std::vector, , m_lambdas) - void pushBack(const lambda_t& pLambda) { - m_lambdaTable.push_back(pLambda); + void push(const lambda_t& pLambda) { + m_lambdas.push_back(pLambda); + } + + Return operator()(std::size_t index, signature_ts&&...params) + { + return m_lambdas[index](m_functors[index], index, std::forward(params)...); } }; + template - class const_functors : public lambda_table + class const_functors : public lambda_hop { using lambda_t = std::function ; - std::vector m_lambdaTable; + std::vector m_lambdas; public: - GETTER_CREF(std::vector, , m_lambdaTable) + GETTER_CREF(std::vector, , m_lambdas) void pushBack(const lambda_t& pLambda) { - m_lambdaTable.push_back(pLambda); + m_lambdas.push_back(pLambda); } }; template - class nonconst_functors : public lambda_table + class nonconst_functors : public lambda_hop { using lambda_t = std::function ; - std::vector m_lambdaTable; + std::vector m_lambdas; public: - GETTER_CREF(std::vector, , m_lambdaTable) + GETTER_CREF(std::vector, , m_lambdas) void pushBack(const lambda_t& pLambda) { - m_lambdaTable.push_back(pLambda); + m_lambdas.push_back(pLambda); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/MethodContainer.h b/ReflectionTemplateLib/detail/inc/MethodContainer.h index a81d86e1..2be9735e 100644 --- a/ReflectionTemplateLib/detail/inc/MethodContainer.h +++ b/ReflectionTemplateLib/detail/inc/MethodContainer.h @@ -86,9 +86,9 @@ namespace rtl { pGetIndex (lambda providing index if the functor is already registered) pUpdate (lambda updating the already registered functors set) @return: index of newly added or already existing lambda in vector 'm_methodPtrs'. - */ static std::pair pushBack(const MethodLambda& pFunctor, - std::function pGetIndex, - std::function pUpdateIndex) + */ static std::pair pushBack(const MethodLambda& pFunctor, + std::function pGetIndex, + std::function pUpdateIndex) { //critical section, thread safe. static std::mutex mtx; @@ -171,9 +171,9 @@ namespace rtl { pGetIndex (lambda providing index if the functor is already registered) pUpdate (lambda updating the already registered functors set) @return: index of newly added or already existing lambda in vector 'm_methodPtrs'. - */ static std::pair pushBack(const MethodLambda& pFunctor, - std::function pGetIndex, - std::function pUpdateIndex) + */ static std::pair pushBack(const MethodLambda& pFunctor, + std::function pGetIndex, + std::function pUpdateIndex) { //critical section, thread safe. static std::mutex mtx; diff --git a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp b/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp index 8a963920..4673e9f6 100644 --- a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp @@ -136,7 +136,7 @@ namespace rtl::detail auto [index, lambdaPtr] = _derivedType::pushBack(getConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); return detail::FunctorId { - index, recordId, recordId, containerId, + index, 0, recordId, recordId, containerId, _derivedType::template getSignatureStr<_recordType>(true), lambdaPtr }; } @@ -168,7 +168,7 @@ namespace rtl::detail auto [index, lambdaPtr] = _derivedType::pushBack(getCopyConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); return detail::FunctorId { - index, recordId, recordId, containerId, + index, 0, recordId, recordId, containerId, _derivedType::template getSignatureStr<_recordType>(true), lambdaPtr }; } diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.h b/ReflectionTemplateLib/detail/inc/SetupFunction.h index 493aa4a9..cdc3b0c2 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.h +++ b/ReflectionTemplateLib/detail/inc/SetupFunction.h @@ -12,6 +12,7 @@ #pragma once #include "FunctorId.h" +#include "FunctorRegistry.h" namespace rtl { @@ -46,5 +47,16 @@ namespace rtl { template static const detail::FunctorId addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId); }; + + + struct FunctorCache + { + template + static functor_registry& get() + { + static functor_registry functorRegistry; + return functorRegistry; + } + }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp b/ReflectionTemplateLib/detail/inc/SetupFunction.hpp index 916e5193..fb665b31 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupFunction.hpp @@ -36,9 +36,9 @@ namespace rtl inline SetupFunction<_derivedType>::FunctionLambda<_signature...> SetupFunction<_derivedType>::getCaller(_returnType(*pFunctor)(_signature...)) { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (FunctorContainer) vector holding lambda's. - */ return [pFunctor](_signature&&...params)-> Return + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (FunctorContainer) vector holding lambda's. + */ return [pFunctor](_signature&&...params)-> Return { constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); @@ -78,30 +78,16 @@ namespace rtl template inline const detail::FunctorId SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) { - /* set of already registered functors. (static life time). - used std::vector, since std::set/map are not designed for function pointers - */ static std::vector> functorSet; - - /* adds the generated functor index to the 'functorSet'. (thread safe). - called from '_derivedType' ('FunctorContainer') - */ const auto& updateIndex = [&](std::size_t pIndex)->void + // called from '_derivedType' ('FunctorContainer') + const auto& updateIndex = [pFunctor](std::size_t pIndex)->void { - functorSet.emplace_back(pFunctor, pIndex); + FunctorCache::get<_returnType, _signature...>().push(pFunctor, pIndex); }; - /* checks if the 'pFunctor' is already present in 'functorSet'. (thread safe). - called from '_derivedType' ('FunctorContainer') - */ const auto& getIndex = [&]()-> std::size_t + // called from '_derivedType' ('FunctorContainer') + const auto& getIndex = [pFunctor]()-> std::size_t { - //linear search, efficient for small set. - for (const auto& fptr : functorSet) { - if (fptr.first == pFunctor) { - //functor already registered, return its 'index'. - return fptr.second; - } - } - //functor is not already registered, return '-1'. - return rtl::index_none; + return FunctorCache::get<_returnType, _signature...>().find(pFunctor); }; //generate a type-id of '_returnType'. @@ -111,7 +97,7 @@ namespace rtl //construct the hash-key 'FunctorId' and return. return detail::FunctorId { - index, retTypeId, pRecordId, _derivedType::getContainerId(), + index, 0, retTypeId, pRecordId, _derivedType::getContainerId(), _derivedType::template getSignatureStr<_returnType>(), lambdaPtr }; } diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.h b/ReflectionTemplateLib/detail/inc/SetupMethod.h index ee521194..3e39090b 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.h +++ b/ReflectionTemplateLib/detail/inc/SetupMethod.h @@ -12,49 +12,67 @@ #pragma once #include "FunctorId.h" +#include "FunctorRegistry.h" -namespace rtl { - - namespace detail - { - /* @struct: SetupMethod - @param: _derivedType (type which inherits this class) - * creates a lambda to perform call on the registered functor. - * adds it to the functor-container, maintains the already added functor set as well. - * deriving classes is MethodContainer & - MethodContainer, which must implement - - - std::size_t& _derived::getContainerId(); - - std::string _derivedType::getSignatureStr(); - - std::size_t& _derived::pushBack(std::function < RObject (error&, const rtl::RObject&, _signature...) >, - std::function, - std::function); - * sets up only non-static-member-function functors in lambda table. - * called from 'ReflectionBuilder', as _derivedType member. - */ template - class SetupMethod - { - template - using MethodLambda = std::function < Return(const rtl::RObject&, _signature...) >; +namespace rtl::detail { + +/* @struct: SetupMethod + @param: _derivedType (type which inherits this class) + * creates a lambda to perform call on the registered functor. + * adds it to the functor-container, maintains the already added functor set as well. + * deriving classes is MethodContainer & + MethodContainer, which must implement - + - std::size_t& _derived::getContainerId(); + - std::string _derivedType::getSignatureStr(); + - std::size_t& _derived::pushBack(std::function < RObject (error&, const rtl::RObject&, _signature...) >, + std::function, + std::function); + * sets up only non-static-member-function functors in lambda table. + * called from 'ReflectionBuilder', as _derivedType member. +*/ template + class SetupMethod + { + template + using MethodLambda = std::function < Return(const rtl::RObject&, _signature...) >; - template - static MethodLambda<_signature...> getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...)); + template + static MethodLambda<_signature...> getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...)); - template - static MethodLambda<_signature...> getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...) const); + template + static MethodLambda<_signature...> getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...) const); - template - static MethodLambda<_signature...> getMethodCaller(void(_recordType::* pFunctor)(_signature...)); + template + static MethodLambda<_signature...> getMethodCaller(void(_recordType::* pFunctor)(_signature...)); - template - static MethodLambda<_signature...> getMethodCaller(void(_recordType::* pFunctor)(_signature...) const); + template + static MethodLambda<_signature...> getMethodCaller(void(_recordType::* pFunctor)(_signature...) const); - protected: + protected: + + template + static const detail::FunctorId addFunctor(_returnType(_recordType::* pFunctor)(_signature...)); - template - static const detail::FunctorId addFunctor(_returnType(_recordType::* pFunctor)(_signature...)); + template + static const detail::FunctorId addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const); + }; - template - static const detail::FunctorId addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const); - }; - } + struct MethodPtrCache + { + template + static method_registry& get() + { + static method_registry methodRegistry; + return methodRegistry; + } + }; + + struct ConstMethodPtrCache + { + template + static const_method_registry& get() + { + static const_method_registry methodRegistry; + return methodRegistry; + } + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp b/ReflectionTemplateLib/detail/inc/SetupMethod.hpp index 377361e9..eb4e953f 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupMethod.hpp @@ -16,245 +16,217 @@ #include "SetupMethod.h" #include "RObjectBuilder.hpp" -namespace rtl +namespace rtl::detail { - namespace detail + template + template + inline SetupMethod<_derivedType>::MethodLambda<_signature...> + SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...)) { - - template - template - inline SetupMethod<_derivedType>::MethodLambda<_signature...> - SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...)) + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. + */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return - { - if (!pTargetObj.isConstCastSafe()) [[unlikely]] { - return { error::IllegalConstCast, RObject{} }; - } + if (!pTargetObj.isConstCastSafe()) [[unlikely]] { + return { error::IllegalConstCast, RObject{} }; + } - _recordType& target = const_cast<_recordType&>(pTargetObj.view<_recordType>()->get()); - (target.*pFunctor)(std::forward<_signature>(params)...); - return { error::None, RObject{} }; - }; - } + _recordType& target = const_cast<_recordType&>(pTargetObj.view<_recordType>()->get()); + (target.*pFunctor)(std::forward<_signature>(params)...); + return { error::None, RObject{} }; + }; + } - template - template - inline SetupMethod<_derivedType>::MethodLambda<_signature...> - SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...)) + template + template + inline SetupMethod<_derivedType>::MethodLambda<_signature...> + SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...)) + { + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. + */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return - { - if (!pTargetObj.isConstCastSafe()) [[unlikely]] { - return { error::IllegalConstCast, RObject{} }; - } + if (!pTargetObj.isConstCastSafe()) [[unlikely]] { + return { error::IllegalConstCast, RObject{} }; + } - constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); - //'target' needs const_cast, since the functor is non-const-member-function. - _recordType& target = const_cast<_recordType&>(pTargetObj.view<_recordType>()->get()); - if constexpr (std::is_reference_v<_returnType>) - { - /* if the function returns reference, this block will be retained by compiler. - Note: reference to temporary or dangling is not checked here. - */ using _rawRetType = traits::raw_t<_returnType>; - const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); - return { error::None, - RObjectBuilder::template - build(&retObj, rtl::index_none, isConstCastSafe) - }; - } - else { + constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); + //'target' needs const_cast, since the functor is non-const-member-function. + _recordType& target = const_cast<_recordType&>(pTargetObj.view<_recordType>()->get()); + if constexpr (std::is_reference_v<_returnType>) + { + /* if the function returns reference, this block will be retained by compiler. + Note: reference to temporary or dangling is not checked here. + */ using _rawRetType = traits::raw_t<_returnType>; + const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + return { error::None, + RObjectBuilder::template + build(&retObj, rtl::index_none, isConstCastSafe) + }; + } + else { - auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); - using T = std::remove_cvref_t; + auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + using T = std::remove_cvref_t; - return { error::None, - RObjectBuilder::template - build(std::forward(retObj), rtl::index_none, isConstCastSafe) - }; - } + return { error::None, + RObjectBuilder::template + build(std::forward(retObj), rtl::index_none, isConstCastSafe) }; - } - + } + }; + } - template - template - inline SetupMethod<_derivedType>::MethodLambda<_signature...> - SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...) const) + template + template + inline SetupMethod<_derivedType>::MethodLambda<_signature...> + SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...) const) + { + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. + */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return - { - const _recordType& target = pTargetObj.view<_recordType>()->get(); - (target.*pFunctor)(std::forward<_signature>(params)...); - return { error::None, RObject{} }; - }; - } + const _recordType& target = pTargetObj.view<_recordType>()->get(); + (target.*pFunctor)(std::forward<_signature>(params)...); + return { error::None, RObject{} }; + }; + } - template - template - inline SetupMethod<_derivedType>::MethodLambda<_signature...> - SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...) const) + template + template + inline SetupMethod<_derivedType>::MethodLambda<_signature...> + SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...) const) + { + /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. + */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return { - /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return - { - constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); - //'target' is const and 'pFunctor' is const-member-function. - const _recordType& target = pTargetObj.view<_recordType>()->get(); - if constexpr (std::is_reference_v<_returnType>) { - /* if the function returns reference, this block will be retained by compiler. - Note: reference to temporary or dangling is not checked here. - */ using _rawRetType = traits::raw_t<_returnType>; - const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); - return { error::None, - RObjectBuilder::template - build(&retObj, rtl::index_none, isConstCastSafe) - }; - } - else { + constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); + //'target' is const and 'pFunctor' is const-member-function. + const _recordType& target = pTargetObj.view<_recordType>()->get(); + if constexpr (std::is_reference_v<_returnType>) { + /* if the function returns reference, this block will be retained by compiler. + Note: reference to temporary or dangling is not checked here. + */ using _rawRetType = traits::raw_t<_returnType>; + const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + return { error::None, + RObjectBuilder::template + build(&retObj, rtl::index_none, isConstCastSafe) + }; + } + else { - auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); - using T = std::remove_cvref_t; + auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + using T = std::remove_cvref_t; - return { error::None, - RObjectBuilder::template - build(std::forward(retObj), rtl::index_none, isConstCastSafe) - }; - } + return { error::None, + RObjectBuilder::template + build(std::forward(retObj), rtl::index_none, isConstCastSafe) }; - } + } + }; + } - /* @method: addFunctor(). - @param: 'pFuntor' (a non-const, non-static-member function pointer). - '_derivedType' : class deriving this class ('MethodContainer'). - '_recordType' : the owner 'class/stuct' type of the functor. - '_returnType' : return type deduced from 'pFunctor'. - '_signature...' : function signature deduced from 'pFunctor'. - @return: 'FunctorId' object, a hash-key to lookup the lambda (functor-wrapped) in the _derivedType's lambda-table. - * adds lambda (functor-wrapped) in '_derivedType' (MethodContainer) and maintains functorSet. - * thread safe, multiple functors can be registered simultaneously. - */ template +/* @method: addFunctor(). + @param: 'pFuntor' (a non-const, non-static-member function pointer). + '_derivedType' : class deriving this class ('MethodContainer'). + '_recordType' : the owner 'class/stuct' type of the functor. + '_returnType' : return type deduced from 'pFunctor'. + '_signature...' : function signature deduced from 'pFunctor'. + @return: 'FunctorId' object, a hash-key to lookup the lambda (functor-wrapped) in the _derivedType's lambda-table. + * adds lambda (functor-wrapped) in '_derivedType' (MethodContainer) and maintains functorSet. + * thread safe, multiple functors can be registered simultaneously. +*/ template template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { - /* set of already registered functors. (static life time). - used std::vector, efficient for small sets. std::set/map will be overhead. - */ static std::vector> functorSet; - - /* adds the generated functor index to the 'functorSet'. (thread safe). - called from '_derivedType' (MethodContainer) - */ const auto& updateIndex = [&](std::size_t pIndex)->void { - functorSet.emplace_back(pFunctor, pIndex); - }; + // called from '_derivedType' (MethodContainer) + const auto& updateIndex = [pFunctor](std::size_t pIndex)->void + { + MethodPtrCache::get<_recordType, _returnType, _signature...>().push(pFunctor, pIndex); + }; - /* checks if the 'pFunctor' is already present in 'functorSet'. (thread safe). - called from '_derivedType' ('FunctorContainer') - */ const auto& getIndex = [&]()->std::size_t - { - //linear search, efficient for small set. - for (const auto& fptr : functorSet) { - if (fptr.first == pFunctor) { - //functor already registered, return its 'index'. - return fptr.second; - } - } - //functor is not already registered, return '-1'. - return index_none; - }; + // called from '_derivedType' (MethodContainer) + const auto& getIndex = [pFunctor]()-> std::size_t + { + return MethodPtrCache::get<_recordType, _returnType, _signature...>().find(pFunctor); + }; - //generate a type-id of '_returnType'. - const std::size_t retTypeId = TypeId>::get(); - //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. + //generate a type-id of '_returnType'. + const std::size_t retTypeId = TypeId>::get(); + //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. - if constexpr (std::is_same_v<_returnType, void>) - { - auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); - //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { - index, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr - }; - } - else - { - auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); - //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { - index, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr - }; - } + if constexpr (std::is_same_v<_returnType, void>) + { + auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + //construct the hash-key 'FunctorId' and return. + return detail::FunctorId { + index, 0, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr + }; + } + else + { + auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + //construct the hash-key 'FunctorId' and return. + return detail::FunctorId { + index, 0, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr + }; } + } - /* @method: addFunctor(). - @param: 'pFuntor' (a const, non-static-member function pointer). - '_derivedType' : class deriving this class ('MethodContainer'). - '_recordType' : the owner 'class/stuct' type of the functor. - '_returnType' : return type deduced from 'pFunctor'. - '_signature...' : function signature deduced from 'pFunctor'. - @return: 'FunctorId' object, a hash-key to lookup the lambda (containing functor) in the _derivedType's lambda table. - * adds lambda (containing functor) in '_derivedType' (MethodContainer) and maintains a functorSet. - * thread safe, multiple functors can be registered simultaneously. - */ template - template - inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) +/* @method: addFunctor(). + @param: 'pFuntor' (a const, non-static-member function pointer). + '_derivedType' : class deriving this class ('MethodContainer'). + '_recordType' : the owner 'class/stuct' type of the functor. + '_returnType' : return type deduced from 'pFunctor'. + '_signature...' : function signature deduced from 'pFunctor'. + @return: 'FunctorId' object, a hash-key to lookup the lambda (containing functor) in the _derivedType's lambda table. + * adds lambda (containing functor) in '_derivedType' (MethodContainer) and maintains a functorSet. + * thread safe, multiple functors can be registered simultaneously. +*/ template + template + inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) + { + // called from '_derivedType' (MethodContainer) + const auto& updateIndex = [pFunctor](std::size_t pIndex)->void { - /* set of already registered functors. (static life time). - used std::vector, efficient for small sets. std::set/map will be overhead. - */ static std::vector> functorSet; - const auto& updateIndex = [&](std::size_t pIndex)->void { - functorSet.emplace_back(pFunctor, pIndex); - }; + ConstMethodPtrCache::get<_recordType, _returnType, _signature...>().push(pFunctor, pIndex); + }; - /* adds the generated functor index to the 'functorSet'. (thread safe). - called from '_derivedType' (MethodContainer) - */ const auto& getIndex = [&]()->std::size_t - { - //linear search, efficient for small set. - for (const auto& fptr : functorSet) { - if (fptr.first == pFunctor) { - //functor already registered, return its 'index'. - return fptr.second; - } - } - //functor is not already registered, return '-1'. - return index_none; - }; + // called from '_derivedType' (MethodContainer) + const auto& getIndex = [pFunctor]()-> std::size_t + { + return ConstMethodPtrCache::get<_recordType, _returnType, _signature...>().find(pFunctor); + }; - //generate a type-id of '_returnType'. - const std::size_t retTypeId = TypeId>::get(); - //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. + //generate a type-id of '_returnType'. + const std::size_t retTypeId = TypeId>::get(); + //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. - if constexpr (std::is_same_v<_returnType, void>) - { - auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); - //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { - index, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr - }; - } - else - { - auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); - //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { - index, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr - }; - } + if constexpr (std::is_same_v<_returnType, void>) + { + auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + //construct the hash-key 'FunctorId' and return. + return detail::FunctorId { + index, 0, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr + }; + } + else + { + auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + //construct the hash-key 'FunctorId' and return. + return detail::FunctorId { + index, 0, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr + }; } } } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/src/CMakeLists.txt b/ReflectionTemplateLib/detail/src/CMakeLists.txt index 7db6be7a..6152a560 100644 --- a/ReflectionTemplateLib/detail/src/CMakeLists.txt +++ b/ReflectionTemplateLib/detail/src/CMakeLists.txt @@ -8,11 +8,13 @@ set(LOCAL_SOURCES SET(LOCAL_HEADERS + "${PROJECT_SOURCE_DIR}/detail/inc/LambdaBridge.h" + "${PROJECT_SOURCE_DIR}/detail/inc/LambdaRegistry.h" + "${PROJECT_SOURCE_DIR}/detail/inc/FunctorRegistry.h" "${PROJECT_SOURCE_DIR}/detail/inc/CallReflector.h" "${PROJECT_SOURCE_DIR}/detail/inc/CxxReflection.h" "${PROJECT_SOURCE_DIR}/detail/inc/FunctionCaller.h" "${PROJECT_SOURCE_DIR}/detail/inc/FunctionCaller.hpp" - "${PROJECT_SOURCE_DIR}/detail/inc/LambdaTable.h" "${PROJECT_SOURCE_DIR}/detail/inc/MethodInvoker.h" "${PROJECT_SOURCE_DIR}/detail/inc/MethodInvoker.hpp" "${PROJECT_SOURCE_DIR}/detail/inc/FunctorContainer.h" From 5762021ef4fb885026a07887b7daf9f73007dad8 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sun, 14 Sep 2025 20:48:09 +0530 Subject: [PATCH 003/148] functor/lambda index added to type metadata. --- RTLBenchmarkApp/src/ReflectedCall.cpp | 25 ++++-- ReflectionTemplateLib/access/inc/Function.hpp | 2 +- ReflectionTemplateLib/access/inc/Record.h | 2 +- .../access/src/CMakeLists.txt | 1 + .../access/src/CxxMirror.cpp | 2 +- .../access/src/CxxMirrorToJson.cpp | 8 +- ReflectionTemplateLib/builder/CMakeLists.txt | 4 +- ReflectionTemplateLib/common/forward_decls.h | 19 +++++ .../detail/inc/FunctorCache.h | 58 +++++++++++++ .../detail/inc/FunctorContainer.h | 25 ++---- ReflectionTemplateLib/detail/inc/FunctorId.h | 11 +-- .../detail/inc/FunctorRegistry.h | 65 ++++++++------- .../detail/inc/LambdaBridge.h | 10 +-- .../detail/inc/LambdaCache.h | 59 ++++++++++++++ .../detail/inc/LambdaRegistry.h | 54 ++++++++----- .../detail/inc/MethodContainer.h | 30 +++---- .../detail/inc/SetupConstructor.hpp | 24 ++++-- .../detail/inc/SetupFunction.h | 74 +++++++---------- .../detail/inc/SetupFunction.hpp | 27 +++++-- .../detail/inc/SetupMethod.h | 20 ----- .../detail/inc/SetupMethod.hpp | 81 ++++++++++++++----- .../detail/src/CMakeLists.txt | 9 +++ 22 files changed, 404 insertions(+), 206 deletions(-) create mode 100644 ReflectionTemplateLib/common/forward_decls.h create mode 100644 ReflectionTemplateLib/detail/inc/FunctorCache.h create mode 100644 ReflectionTemplateLib/detail/inc/LambdaCache.h diff --git a/RTLBenchmarkApp/src/ReflectedCall.cpp b/RTLBenchmarkApp/src/ReflectedCall.cpp index 337c676f..ce4048d7 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.cpp +++ b/RTLBenchmarkApp/src/ReflectedCall.cpp @@ -12,26 +12,37 @@ namespace cxx namespace { - static rtl::Function GetMessage = cxx::mirror().getFunction("getMessage").value(); - static rtl::Function SendMessage = cxx::mirror().getFunction("sendMessage").value(); + static rtl::Function GetMessage; + static rtl::Function SendMessage; - static rtl::Method NodeGetMessage = cxx::mirror().getRecord("Node")->getMethod("getMessage").value(); - static rtl::Method NodeSendMessage = cxx::mirror().getRecord("Node")->getMethod("sendMessage").value(); + static rtl::Method NodeGetMessage; + static rtl::Method NodeSendMessage; static rtl::RObject nodeObj = []() { + GetMessage = cxx::mirror().getFunction("getMessage").value(); + + SendMessage = cxx::mirror().getFunction("sendMessage").value(); + auto Node = cxx::mirror().getRecord("Node").value(); + + NodeGetMessage = Node.getMethod("getMessage").value(); + + NodeSendMessage = Node.getMethod("sendMessage").value(); + auto [err, robj] = Node.create(); + if (robj.isEmpty()) { - std::cout << "[0] nodeObj empty! \n"; + std::cout << "[0] error: " << rtl::to_string(err) << "\n"; } + return std::move(robj); }(); } - namespace - { +namespace +{ static auto _test0 = []() { auto err = SendMessage(bm::g_longStr).err; diff --git a/ReflectionTemplateLib/access/inc/Function.hpp b/ReflectionTemplateLib/access/inc/Function.hpp index b00ddf0d..b16039de 100644 --- a/ReflectionTemplateLib/access/inc/Function.hpp +++ b/ReflectionTemplateLib/access/inc/Function.hpp @@ -58,7 +58,7 @@ namespace rtl //simple linear-search, efficient for small set of elements. for (const auto& functorId : m_functorIds) { if (functorId.getSignatureId() == pSignatureId) [[likely]] { - return functorId.getIndex(); + return functorId.getLambdaIndex(); } } return rtl::index_none; diff --git a/ReflectionTemplateLib/access/inc/Record.h b/ReflectionTemplateLib/access/inc/Record.h index 6a608de8..357c2eb7 100644 --- a/ReflectionTemplateLib/access/inc/Record.h +++ b/ReflectionTemplateLib/access/inc/Record.h @@ -94,7 +94,7 @@ namespace rtl { { static_assert(_alloc != rtl::alloc::None, "Instance cannot be created with 'rtl::alloc::None' option."); const auto& method = m_methods.at(detail::ctor_name(m_recordName)); - std::size_t copyCtorIndex = method.getFunctorIds()[detail::Index::CopyCtor].getIndex(); + std::size_t copyCtorIndex = method.getFunctorIds()[detail::Index::CopyCtor].getLambdaIndex(); return method.invokeCtor(_alloc, copyCtorIndex, std::forward<_ctorArgs>(params)...); } diff --git a/ReflectionTemplateLib/access/src/CMakeLists.txt b/ReflectionTemplateLib/access/src/CMakeLists.txt index 2615a2f3..c8935285 100644 --- a/ReflectionTemplateLib/access/src/CMakeLists.txt +++ b/ReflectionTemplateLib/access/src/CMakeLists.txt @@ -12,6 +12,7 @@ SET(COMMON_HEADERS "${PROJECT_SOURCE_DIR}/common/Constants.h" "${PROJECT_SOURCE_DIR}/common/rtl_traits.h" "${PROJECT_SOURCE_DIR}/common/error_codes.h" + "${PROJECT_SOURCE_DIR}/common/forward_decls.h" "${PROJECT_SOURCE_DIR}/common/ConversionUtils.h" "${PROJECT_SOURCE_DIR}/common/RTLibInterface.h" ) diff --git a/ReflectionTemplateLib/access/src/CxxMirror.cpp b/ReflectionTemplateLib/access/src/CxxMirror.cpp index b0167bf2..8ec1eb3e 100644 --- a/ReflectionTemplateLib/access/src/CxxMirror.cpp +++ b/ReflectionTemplateLib/access/src/CxxMirror.cpp @@ -32,7 +32,7 @@ namespace rtl { const Record& record = itr->second; Method ctors = record.getMethod(detail::ctor_name(record.getRecordName())).value(); - std::size_t copyCtorIndex = ctors.getFunctors()[detail::Index::CopyCtor].getIndex(); + std::size_t copyCtorIndex = ctors.getFunctors()[detail::Index::CopyCtor].getLambdaIndex(); const_cast(pTarget).m_objectId.m_clonerIndex = copyCtorIndex; return error::None; } diff --git a/ReflectionTemplateLib/access/src/CxxMirrorToJson.cpp b/ReflectionTemplateLib/access/src/CxxMirrorToJson.cpp index cf03c065..0143cd39 100644 --- a/ReflectionTemplateLib/access/src/CxxMirrorToJson.cpp +++ b/ReflectionTemplateLib/access/src/CxxMirrorToJson.cpp @@ -26,7 +26,13 @@ static const std::string toJson(const FunctorId& pFunctorId) { std::stringstream sout; sout << "{\"containerId\": \"" << std::to_string(pFunctorId.getSignatureId()) << "\","; - sout << "\"index\": \"" << std::to_string(pFunctorId.getIndex()) << "\","; + sout << "\"lambdaIndex\": \"" << std::to_string(pFunctorId.getLambdaIndex()) << "\","; + if (pFunctorId.getFunctorIndex() != rtl::index_none) { + sout << "\"functorIndex\": \"" << std::to_string(pFunctorId.getFunctorIndex()) << "\","; + } + else { + sout << "\"functorIndex\": \"-1\","; + } if (pFunctorId.getRecordId() != TypeId<>::None) { sout << "\"recordId\": \"" << std::to_string(pFunctorId.getRecordId()) << "\","; } diff --git a/ReflectionTemplateLib/builder/CMakeLists.txt b/ReflectionTemplateLib/builder/CMakeLists.txt index 0484adc6..379e654e 100644 --- a/ReflectionTemplateLib/builder/CMakeLists.txt +++ b/ReflectionTemplateLib/builder/CMakeLists.txt @@ -1,7 +1,9 @@ # Create a variable containing the source files for your target SET(COMMON_HEADERS - "${PROJECT_SOURCE_DIR}/common/Constants.h" + "${PROJECT_SOURCE_DIR}/common/rtl_traits.h" + "${PROJECT_SOURCE_DIR}/common/error_codes.h" + "${PROJECT_SOURCE_DIR}/common/forward_decls.h" ) SET(LOCAL_HEADERS diff --git a/ReflectionTemplateLib/common/forward_decls.h b/ReflectionTemplateLib/common/forward_decls.h new file mode 100644 index 00000000..0666b3f2 --- /dev/null +++ b/ReflectionTemplateLib/common/forward_decls.h @@ -0,0 +1,19 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +namespace rtl { + + struct Return; + + class RObject; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/FunctorCache.h b/ReflectionTemplateLib/detail/inc/FunctorCache.h new file mode 100644 index 00000000..1a89a0cd --- /dev/null +++ b/ReflectionTemplateLib/detail/inc/FunctorCache.h @@ -0,0 +1,58 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "Constants.h" +#include "FunctorRegistry.h" + + +namespace rtl::detail +{ + template + struct functor_cache; +} + +namespace rtl::detail +{ + template<> + struct functor_cache + { + template + static functor_registry& get() + { + static functor_registry functors; + return functors; + } + }; + + template<> + struct functor_cache + { + template + static functor_registry_m& get() + { + static functor_registry_m functors; + return functors; + } + }; + + template<> + struct functor_cache + { + template + static functor_registry_m& get() + { + static functor_registry_m functors; + return functors; + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/FunctorContainer.h b/ReflectionTemplateLib/detail/inc/FunctorContainer.h index d35e5376..c3d89fc2 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorContainer.h +++ b/ReflectionTemplateLib/detail/inc/FunctorContainer.h @@ -15,7 +15,7 @@ #include #include -#include "LambdaRegistry.h" +#include "LambdaCache.h" #include "Constants.h" #include "CallReflector.h" #include "SetupFunction.h" @@ -40,8 +40,6 @@ namespace rtl { using FunctionLambda = std::function < Return(_signature...) >; public: - using lambda_t = detail::lambda_registry<_signature...>; - //every FunctorContainer<...> will have a unique-id. FORCE_INLINE static std::size_t getContainerId() { static const std::size_t containerId = generate_unique_id(); @@ -62,14 +60,6 @@ namespace rtl { "(" + TypeId<_signature...>::toString() + ")"); } - - static lambda_t& lambdaCache() - { - static lambda_t lambdaRegistry; - return lambdaRegistry; - } - - private: //vector holding lambdas @@ -85,25 +75,26 @@ namespace rtl { pUpdate (lambda updating the already registered functors/ctor/d'tor set) @return: index of newly added or already existing lambda in vector 'm_functors'. */ static std::pair pushBack(const FunctionLambda& pFunctor, - std::function pGetIndex, - std::function pUpdate) + std::function pGetIndex, + std::function pUpdate) { //critical section, thread safe. static std::mutex mtx; std::lock_guard lock(mtx); + auto& lamdba_store = lambda_cache::get<_signature...>(); std::size_t index = pGetIndex(); + if (index == rtl::index_none) { - index = lambdaCache().get().size(); - - lambdaCache().push(pFunctor); + index = lamdba_store.get().size(); + lamdba_store.push(pFunctor); getFunctorTable().push_back(pFunctor); pUpdate(index); } - return { index, &lambdaCache() }; + return { index, &lamdba_store }; } //friends :) diff --git a/ReflectionTemplateLib/detail/inc/FunctorId.h b/ReflectionTemplateLib/detail/inc/FunctorId.h index 5f606e0f..de0f7a89 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/detail/inc/FunctorId.h @@ -44,9 +44,10 @@ namespace rtl::detail //signature of functor as string. platform dependent, may not be very much readable format. std::string m_signature; - lambda_hop* m_lambdas = nullptr; + lambda_hop* m_lambda = nullptr; - GETTER(std::size_t, Index, m_lambdaIndex) + GETTER(std::size_t, LambdaIndex, m_lambdaIndex) + GETTER(std::size_t, FunctorIndex, m_functorIndex) GETTER(std::size_t, ReturnId, m_returnId); GETTER(std::size_t, RecordId, m_recordId); GETTER(std::size_t, SignatureId, m_containerId) @@ -65,9 +66,9 @@ namespace rtl::detail */ std::size_t getHashCode() const { return std::stoull(std::to_string(m_containerId) + - std::to_string(m_lambdaIndex) + - std::to_string(m_recordId) + - std::to_string(m_returnId)); + std::to_string(m_lambdaIndex) + + std::to_string(m_recordId) + + std::to_string(m_returnId)); } const bool operator==(const FunctorId& pOther) const diff --git a/ReflectionTemplateLib/detail/inc/FunctorRegistry.h b/ReflectionTemplateLib/detail/inc/FunctorRegistry.h index 72b62908..8ef91ea8 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorRegistry.h +++ b/ReflectionTemplateLib/detail/inc/FunctorRegistry.h @@ -13,9 +13,8 @@ #include -namespace rtl { - struct Return; -} +#include "Constants.h" +#include "forward_decls.h" namespace rtl::detail @@ -27,7 +26,7 @@ namespace rtl::detail namespace rtl::detail { template - class functor_registry : public functor_hop + class functor_registry: public functor_hop { using functor_t = return_t(*)(signature_ts...); @@ -35,6 +34,10 @@ namespace rtl::detail public: + const std::vector>& get() { + return m_functors; + } + functor_t operator[](std::size_t index) { return m_functors[index].first; } @@ -43,17 +46,15 @@ namespace rtl::detail m_functors.emplace_back(fptr, lambda_index); } - std::size_t find(functor_t fptr) + std::pair find(functor_t fptr) { //linear search, efficient for small set. - for (const auto& itr : m_functors) { - if (itr.first == fptr) { - //functor already registered, return its 'index'. - return itr.second; + for (int index = 0; index < m_functors.size(); index++) { + if (m_functors[index].first == fptr) { + return { index, m_functors[index].second }; } } - //functor is not already registered, return '-1'. - return rtl::index_none; + return { rtl::index_none, rtl::index_none }; } }; } @@ -61,8 +62,11 @@ namespace rtl::detail namespace rtl::detail { + template + class functor_registry_m; + template - class method_registry : public functor_hop + class functor_registry_m : public functor_hop { using functor_t = return_t(record_t::*)(signature_ts...); @@ -70,6 +74,11 @@ namespace rtl::detail public: + const std::vector>& get() { + return m_functors; + } + + functor_t operator[](std::size_t index) { return m_functors[index].first; } @@ -78,17 +87,15 @@ namespace rtl::detail m_functors.emplace_back(fptr, lambda_index); } - std::size_t find(functor_t fptr) + std::pair find(functor_t fptr) { //linear search, efficient for small set. - for (const auto& itr : m_functors) { - if (itr.first == fptr) { - //functor already registered, return its 'index'. - return itr.second; + for (int index = 0; index < m_functors.size(); index++) { + if (m_functors[index].first == fptr) { + return { index, m_functors[index].second }; } } - //functor is not already registered, return '-1'. - return rtl::index_none; + return { rtl::index_none, rtl::index_none }; } }; } @@ -97,7 +104,7 @@ namespace rtl::detail namespace rtl::detail { template - class const_method_registry : public functor_hop + class functor_registry_m : public functor_hop { using functor_t = return_t(record_t::*)(signature_ts...) const; @@ -105,6 +112,10 @@ namespace rtl::detail public: + const std::vector>& get() { + return m_functors; + } + functor_t operator[](std::size_t index) { return m_functors[index].first; } @@ -113,17 +124,15 @@ namespace rtl::detail m_functors.emplace_back(fptr, lambda_index); } - std::size_t find(functor_t fptr) + std::pair find(functor_t fptr) { //linear search, efficient for small set. - for (const auto& itr : m_functors) { - if (itr.first == fptr) { - //functor already registered, return its 'index'. - return itr.second; + for (int index = 0; index < m_functors.size(); index++) { + if (m_functors[index].first == fptr) { + return { index, m_functors[index].second }; } } - //functor is not already registered, return '-1'. - return rtl::index_none; + return { rtl::index_none, rtl::index_none }; } }; -} +} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/LambdaBridge.h b/ReflectionTemplateLib/detail/inc/LambdaBridge.h index 9a5387c5..b467bf49 100644 --- a/ReflectionTemplateLib/detail/inc/LambdaBridge.h +++ b/ReflectionTemplateLib/detail/inc/LambdaBridge.h @@ -11,13 +11,11 @@ #pragma once +#include "forward_decls.h" + #include "FunctorId.h" #include "FunctorRegistry.h" -namespace rtl { - struct Return; -} - namespace rtl::detail::bridge { template @@ -26,9 +24,9 @@ namespace rtl::detail::bridge template static auto get() { - return [](const FunctorId& functorId, signature_ts&&...params) + return [](const FunctorId& functorId, signature_ts&&...params)-> Return { - + return { error::None, RObject{} }; }; } }; diff --git a/ReflectionTemplateLib/detail/inc/LambdaCache.h b/ReflectionTemplateLib/detail/inc/LambdaCache.h new file mode 100644 index 00000000..8c5daa5c --- /dev/null +++ b/ReflectionTemplateLib/detail/inc/LambdaCache.h @@ -0,0 +1,59 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "LambdaRegistry.h" + + +namespace rtl::detail +{ + template + struct lambda_cache; +} + +namespace rtl::detail +{ + template<> + struct lambda_cache + { + template + static lambda_registry& get() + { + static lambda_registry registry; + return registry; + } + }; + + + template<> + struct lambda_cache + { + template + static lambda_registry& get() + { + static lambda_registry registry; + return registry; + } + }; + + + template<> + struct lambda_cache + { + template + static lambda_registry& get() + { + static lambda_registry registry; + return registry; + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/LambdaRegistry.h b/ReflectionTemplateLib/detail/inc/LambdaRegistry.h index 446d8a3e..9bb6aba7 100644 --- a/ReflectionTemplateLib/detail/inc/LambdaRegistry.h +++ b/ReflectionTemplateLib/detail/inc/LambdaRegistry.h @@ -19,12 +19,6 @@ #include "Constants.h" #include "FunctorRegistry.h" -namespace rtl { - - class RObject; - struct Return; -} - namespace rtl::detail { @@ -34,61 +28,77 @@ namespace rtl::detail namespace rtl::detail { + template + class lambda_registry; + template - class lambda_registry : public lambda_hop + class lambda_registry : public lambda_hop { using lambda_t = std::function; - std::vector m_lambdas; + std::vector lambda_table; std::vector m_functors; public: - GETTER_CREF(std::vector, , m_lambdas) + GETTER_CREF(std::vector, , lambda_table) void push(const lambda_t& pLambda) { - m_lambdas.push_back(pLambda); + lambda_table.push_back(pLambda); } Return operator()(std::size_t index, signature_ts&&...params) { - return m_lambdas[index](m_functors[index], index, std::forward(params)...); + return lambda_table[index](m_functors[index], index, std::forward(params)...); } }; - template - class const_functors : public lambda_hop + class lambda_registry : public lambda_hop { using lambda_t = std::function ; - std::vector m_lambdas; + std::vector lambda_table; + + std::vector m_functors; public: - GETTER_CREF(std::vector, , m_lambdas) + GETTER_CREF(std::vector, , lambda_table) - void pushBack(const lambda_t& pLambda) { - m_lambdas.push_back(pLambda); + void push(const lambda_t& pLambda) { + lambda_table.push_back(pLambda); + } + + Return operator()(std::size_t index, signature_ts&&...params) + { + return lambda_table[index](m_functors[index], index, std::forward(params)...); } }; template - class nonconst_functors : public lambda_hop + class lambda_registry : public lambda_hop { using lambda_t = std::function ; - std::vector m_lambdas; + std::vector lambda_table; + + std::vector m_functors; public: - GETTER_CREF(std::vector, , m_lambdas) + GETTER_CREF(std::vector, , lambda_table) - void pushBack(const lambda_t& pLambda) { - m_lambdas.push_back(pLambda); + void push(const lambda_t& pLambda) { + lambda_table.push_back(pLambda); + } + + Return operator()(std::size_t index, signature_ts&&...params) + { + return lambda_table[index](m_functors[index], index, std::forward(params)...); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/MethodContainer.h b/ReflectionTemplateLib/detail/inc/MethodContainer.h index 2be9735e..0763ef7e 100644 --- a/ReflectionTemplateLib/detail/inc/MethodContainer.h +++ b/ReflectionTemplateLib/detail/inc/MethodContainer.h @@ -44,7 +44,7 @@ namespace rtl { public: - using lambda_t = detail::nonconst_functors<_signature...>; + using lambda_t = detail::lambda_registry; //every MethodContainer will have a unique-id. static std::size_t getContainerId() { @@ -75,11 +75,6 @@ namespace rtl { return functorTable; } - static lambda_t& lambdaCache() - { - static lambda_t functorsCache; - return functorsCache; - } /* @method: pushBack @params: pFunctor (lambda containing non-const-member-function functor call) @@ -95,17 +90,19 @@ namespace rtl { std::lock_guard lock(mtx); std::size_t index = pGetIndex(); + auto& lamdba_store = lambda_cache::get<_signature...>(); + if (index == rtl::index_none) { - index = lambdaCache().get().size(); + index = lamdba_store.get().size(); - lambdaCache().pushBack(pFunctor); + lamdba_store.push(pFunctor); getFunctorTable().push_back(pFunctor); pUpdateIndex(index); } - return { index, &lambdaCache() }; + return { index, &lamdba_store }; } //friends :) @@ -129,7 +126,7 @@ namespace rtl { public: - using lambda_t = detail::const_functors<_signature...>; + using lambda_t = detail::lambda_registry; //every MethodContainer will have a unique-id. FORCE_INLINE static std::size_t getContainerId() { @@ -160,11 +157,6 @@ namespace rtl { return functorTable; } - static lambda_t& lambdaCache() - { - static lambda_t functorsCache; - return functorsCache; - } /* @method: pushBack @params: pFunctor (lambda containing const-member-function functor call) @@ -179,18 +171,20 @@ namespace rtl { static std::mutex mtx; std::lock_guard lock(mtx); + auto& lamdba_store = lambda_cache::get<_signature...>(); std::size_t index = pGetIndex(); + if (index == rtl::index_none) { - index = lambdaCache().get().size(); + index = lamdba_store.get().size(); - lambdaCache().pushBack(pFunctor); + lamdba_store.push(pFunctor); getFunctorTable().push_back(pFunctor); pUpdateIndex(index); } - return { index, &lambdaCache() }; + return { index, &lamdba_store }; } //friends :) diff --git a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp b/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp index 4673e9f6..cc33c5e6 100644 --- a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp @@ -133,11 +133,17 @@ namespace rtl::detail }; //add the lambda in 'FunctorContainer'. - auto [index, lambdaPtr] = _derivedType::pushBack(getConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); + auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); return detail::FunctorId { - index, 0, recordId, recordId, containerId, - _derivedType::template getSignatureStr<_recordType>(true), lambdaPtr + + lambdaIndex, + rtl::index_none, + recordId, + recordId, + containerId, + _derivedType::template getSignatureStr<_recordType>(true), + lambdaPtr }; } @@ -165,11 +171,17 @@ namespace rtl::detail }; //add the lambda in 'FunctorContainer'. - auto [index, lambdaPtr] = _derivedType::pushBack(getCopyConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); + auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getCopyConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); return detail::FunctorId { - index, 0, recordId, recordId, containerId, - _derivedType::template getSignatureStr<_recordType>(true), lambdaPtr + + lambdaIndex, + rtl::index_none, + recordId, + recordId, + containerId, + _derivedType::template getSignatureStr<_recordType>(true), + lambdaPtr }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.h b/ReflectionTemplateLib/detail/inc/SetupFunction.h index cdc3b0c2..894598a6 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.h +++ b/ReflectionTemplateLib/detail/inc/SetupFunction.h @@ -14,49 +14,35 @@ #include "FunctorId.h" #include "FunctorRegistry.h" -namespace rtl { - - namespace detail +namespace rtl::detail +{ +/* @struct: SetupFunction + @param: _derivedType (type which inherits this class) + * creates a functor-wrapped-lambda to perform call on the registered functor. + * adds it to the functor-container, maintains the already added functor set as well. + * deriving classes is FunctorContainer<...>, which must implement - + - std::size_t& _derived::getContainerId(); + - std::string _derivedType::getSignatureStr(); + - std::size_t& _derived::pushBack(std::function, + std::function, + std::function); + * sets up only non-member or static-member-function functors in table. + * called from 'ReflectionBuilder', as _derivedType member. +*/ template + class SetupFunction { - /* @struct: SetupFunction - @param: _derivedType (type which inherits this class) - * creates a functor-wrapped-lambda to perform call on the registered functor. - * adds it to the functor-container, maintains the already added functor set as well. - * deriving classes is FunctorContainer<...>, which must implement - - - std::size_t& _derived::getContainerId(); - - std::string _derivedType::getSignatureStr(); - - std::size_t& _derived::pushBack(std::function, - std::function, - std::function); - * sets up only non-member or static-member-function functors in table. - * called from 'ReflectionBuilder', as _derivedType member. - */ template - class SetupFunction - { - template - using FunctionLambda = std::function < Return(_signature...) >; - - template - static FunctionLambda<_signature...> getCaller(void(*pFunctor)(_signature...)); - - template - static FunctionLambda<_signature...> getCaller(_returnType(*pFunctor)(_signature...)); - - protected: - - template - static const detail::FunctorId addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId); - }; - - - struct FunctorCache - { - template - static functor_registry& get() - { - static functor_registry functorRegistry; - return functorRegistry; - } - }; - } + template + using FunctionLambda = std::function < Return(_signature...) >; + + template + static FunctionLambda<_signature...> getCaller(void(*pFunctor)(_signature...)); + + template + static FunctionLambda<_signature...> getCaller(_returnType(*pFunctor)(_signature...)); + + protected: + + template + static const detail::FunctorId addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId); + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp b/ReflectionTemplateLib/detail/inc/SetupFunction.hpp index fb665b31..bd6abdda 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupFunction.hpp @@ -11,6 +11,7 @@ #pragma once +#include "FunctorCache.h" #include "SetupFunction.h" #include "RObjectBuilder.hpp" @@ -78,27 +79,39 @@ namespace rtl template inline const detail::FunctorId SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) { + auto& functorCache = functor_cache::get<_returnType, _signature...>(); + std::size_t functorIndex = rtl::index_none; + // called from '_derivedType' ('FunctorContainer') - const auto& updateIndex = [pFunctor](std::size_t pIndex)->void + const auto& updateIndex = [&](std::size_t pIndex)-> void { - FunctorCache::get<_returnType, _signature...>().push(pFunctor, pIndex); + functorIndex = functorCache.get().size(); + functorCache.push(pFunctor, pIndex); }; // called from '_derivedType' ('FunctorContainer') - const auto& getIndex = [pFunctor]()-> std::size_t + const auto& getIndex = [&]()-> std::size_t { - return FunctorCache::get<_returnType, _signature...>().find(pFunctor); + auto [functor_i, lambda_i] = functorCache.find(pFunctor); + functorIndex = functor_i; + return lambda_i; }; //generate a type-id of '_returnType'. const std::size_t retTypeId = TypeId>::get(); //finally add the lambda 'functor' in 'FunctorContainer' lambda vector and get the index. - auto [index, lambdaPtr] = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); + auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { - index, 0, retTypeId, pRecordId, _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_returnType>(), lambdaPtr + + lambdaIndex, + functorIndex, + retTypeId, + pRecordId, + _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_returnType>(), + lambdaPtr }; } } diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.h b/ReflectionTemplateLib/detail/inc/SetupMethod.h index 3e39090b..9219858f 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.h +++ b/ReflectionTemplateLib/detail/inc/SetupMethod.h @@ -55,24 +55,4 @@ namespace rtl::detail { template static const detail::FunctorId addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const); }; - - struct MethodPtrCache - { - template - static method_registry& get() - { - static method_registry methodRegistry; - return methodRegistry; - } - }; - - struct ConstMethodPtrCache - { - template - static const_method_registry& get() - { - static const_method_registry methodRegistry; - return methodRegistry; - } - }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp b/ReflectionTemplateLib/detail/inc/SetupMethod.hpp index eb4e953f..91faebac 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupMethod.hpp @@ -15,6 +15,7 @@ #include "TypeId.h" #include "SetupMethod.h" #include "RObjectBuilder.hpp" +#include "FunctorCache.h" namespace rtl::detail { @@ -144,16 +145,22 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { + auto& functorCache = functor_cache::get<_recordType, _returnType, _signature...>(); + std::size_t functorIndex = rtl::index_none; + // called from '_derivedType' (MethodContainer) - const auto& updateIndex = [pFunctor](std::size_t pIndex)->void + const auto& updateIndex = [&](std::size_t pIndex)->void { - MethodPtrCache::get<_recordType, _returnType, _signature...>().push(pFunctor, pIndex); + functorIndex = functorCache.get().size(); + functorCache.push(pFunctor, pIndex); }; // called from '_derivedType' (MethodContainer) - const auto& getIndex = [pFunctor]()-> std::size_t + const auto& getIndex = [&]()-> std::size_t { - return MethodPtrCache::get<_recordType, _returnType, _signature...>().find(pFunctor); + auto [functor_i, lambda_i] = functorCache.find(pFunctor); + functorIndex = functor_i; + return lambda_i; }; //generate a type-id of '_returnType'. @@ -162,20 +169,32 @@ namespace rtl::detail if constexpr (std::is_same_v<_returnType, void>) { - auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { - index, 0, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr + + lambdaIndex, + functorIndex, + retTypeId, + TypeId<_recordType>::get(), + _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_recordType, _returnType>(), + lambdaPtr }; } else { - auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { - index, 0, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr + + lambdaIndex, + functorIndex, + retTypeId, + TypeId<_recordType>::get(), + _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_recordType, _returnType>(), + lambdaPtr }; } } @@ -194,16 +213,23 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) { + + auto& functorCache = functor_cache::get<_recordType, _returnType, _signature...>(); + std::size_t functorIndex = rtl::index_none; + // called from '_derivedType' (MethodContainer) - const auto& updateIndex = [pFunctor](std::size_t pIndex)->void + const auto& updateIndex = [&](std::size_t pIndex)-> void { - ConstMethodPtrCache::get<_recordType, _returnType, _signature...>().push(pFunctor, pIndex); + functorIndex = functorCache.get().size(); + functorCache.push(pFunctor, pIndex); }; // called from '_derivedType' (MethodContainer) - const auto& getIndex = [pFunctor]()-> std::size_t + const auto& getIndex = [&]()-> std::size_t { - return ConstMethodPtrCache::get<_recordType, _returnType, _signature...>().find(pFunctor); + auto [functor_i, lambda_i] = functorCache.find(pFunctor); + functorIndex = functor_i; + return lambda_i; }; //generate a type-id of '_returnType'. @@ -212,20 +238,33 @@ namespace rtl::detail if constexpr (std::is_same_v<_returnType, void>) { - auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + //construct the hash-key 'FunctorId' and return. return detail::FunctorId { - index, 0, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr + + lambdaIndex, + functorIndex, + retTypeId, + TypeId<_recordType>::get(), + _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_recordType, _returnType>(), + lambdaPtr }; } else { - auto [index, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { - index, 0, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), lambdaPtr + return detail::FunctorId { + + lambdaIndex, + functorIndex, + retTypeId, + TypeId<_recordType>::get(), + _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_recordType, _returnType>(), + lambdaPtr }; } } diff --git a/ReflectionTemplateLib/detail/src/CMakeLists.txt b/ReflectionTemplateLib/detail/src/CMakeLists.txt index 6152a560..d5f37592 100644 --- a/ReflectionTemplateLib/detail/src/CMakeLists.txt +++ b/ReflectionTemplateLib/detail/src/CMakeLists.txt @@ -6,8 +6,17 @@ set(LOCAL_SOURCES ) +SET(COMMON_HEADERS + + "${PROJECT_SOURCE_DIR}/common/rtl_traits.h" + "${PROJECT_SOURCE_DIR}/common/error_codes.h" + "${PROJECT_SOURCE_DIR}/common/forward_decls.h" +) + SET(LOCAL_HEADERS + "${PROJECT_SOURCE_DIR}/detail/inc/LambdaCache.h" + "${PROJECT_SOURCE_DIR}/detail/inc/FunctorCache.h" "${PROJECT_SOURCE_DIR}/detail/inc/LambdaBridge.h" "${PROJECT_SOURCE_DIR}/detail/inc/LambdaRegistry.h" "${PROJECT_SOURCE_DIR}/detail/inc/FunctorRegistry.h" From 98ff22ff332e8646fda038c6a89079bc420a0369 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 15 Sep 2025 15:00:33 +0530 Subject: [PATCH 004/148] lambda_registry tested with type-identificaton-system --- RTLBenchmarkApp/src/ReflectedCall.cpp | 2 +- .../CxxMirrorTests/CxxMirrorObjectTest.cpp | 10 +- .../RObjectReflecting_stdSharedPtr.cpp | 2 + ReflectionTemplateLib/access/inc/Method.h | 2 +- ReflectionTemplateLib/access/inc/Method.hpp | 10 +- ReflectionTemplateLib/access/inc/RObject.hpp | 12 +- ReflectionTemplateLib/access/inc/Record.h | 4 +- .../access/src/CxxMirror.cpp | 3 +- ReflectionTemplateLib/common/forward_decls.h | 12 +- ReflectionTemplateLib/common/rtl_traits.h | 11 +- .../detail/inc/CallReflector.h | 18 ++- .../detail/inc/FunctionCaller.hpp | 4 - .../detail/inc/FunctorContainer.h | 2 +- .../detail/inc/LambdaRegistry.h | 132 +++++++++++------- .../detail/inc/MethodContainer.h | 4 +- .../detail/inc/MethodInvoker.hpp | 19 +-- .../detail/inc/RObjectBuilder.h | 20 ++- .../detail/inc/RObjectBuilder.hpp | 12 +- ReflectionTemplateLib/detail/inc/RObjectId.h | 26 +++- .../detail/inc/ReflectionBuilder.hpp | 4 +- .../detail/inc/SetupConstructor.h | 12 +- .../detail/inc/SetupConstructor.hpp | 45 ++++-- .../detail/inc/SetupFunction.h | 2 +- .../detail/inc/SetupFunction.hpp | 22 ++- .../detail/inc/SetupMethod.h | 2 +- .../detail/inc/SetupMethod.hpp | 36 +++-- ReflectionTemplateLib/detail/inc/TypeId.h | 49 ++++++- 27 files changed, 301 insertions(+), 176 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCall.cpp b/RTLBenchmarkApp/src/ReflectedCall.cpp index ce4048d7..099d3c44 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.cpp +++ b/RTLBenchmarkApp/src/ReflectedCall.cpp @@ -55,7 +55,7 @@ namespace static auto _test1 = []() { - auto err = NodeSendMessage.bind(nodeObj).call(bm::g_longStr).err; + auto err = NodeSendMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[2] error: " << rtl::to_string(err) << "\n"; diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp index d98723d4..57f445ea 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp @@ -116,11 +116,11 @@ namespace rtl_tests // This test demonstrates redundant function registration handling // and argument forwarding quirks for C-style strings. - TEST(CxxMirrorObjectTest, rednudent_registration__std_cstring_function) + TEST(CxxMirrorObjectTest, rednudant_registration__std_cstring_function) { auto cxxMirror = rtl::CxxMirror({ - // Redundent registrations + // Redundant registrations rtl::type().function("strlen").build(std::strlen), rtl::type().function("strlen").build(std::strlen) @@ -185,7 +185,7 @@ namespace rtl_tests } - TEST(CxxMirrorObjectTest, redundent_registration__std_cstring_func_with_global_cstring) + TEST(CxxMirrorObjectTest, redundant_registration__std_cstring_func_with_global_cstring) { auto cxxMirror = rtl::CxxMirror({ @@ -233,7 +233,7 @@ namespace rtl_tests - TEST(CxxMirrorObjectTest, redundent_regis_with_namespace__std_cstring_func_with_global_cstring) + TEST(CxxMirrorObjectTest, redundant_regis_with_namespace__std_cstring_func_with_global_cstring) { auto cxxMirror = rtl::CxxMirror({ // Redundant registrations with different namespaces. @@ -296,7 +296,7 @@ namespace rtl_tests - TEST(CxxMirrorObjectTest, redundent_regis_with_different_names__std_cstring_func_with_global_cstring) + TEST(CxxMirrorObjectTest, redundant_regis_with_different_names__std_cstring_func_with_global_cstring) { auto cxxMirror = rtl::CxxMirror({ // Redundant registrations with different symbolic names. diff --git a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdSharedPtr.cpp b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdSharedPtr.cpp index 30d463fa..5b71d321 100644 --- a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdSharedPtr.cpp +++ b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdSharedPtr.cpp @@ -152,6 +152,7 @@ namespace rtl::unit_test // Copies the underlying value, *not* the wrapper. auto [err, robj0] = robj.clone(); EXPECT_TRUE(err == error::None); + ASSERT_FALSE(robj0.isEmpty()); // Cannot view as shared_ptr, because we cloned the contained value. EXPECT_FALSE(robj0.canViewAs>()); @@ -230,6 +231,7 @@ namespace rtl::unit_test // Copies the underlying value, *not* the wrapper. auto [err, robj0] = robj.clone(); EXPECT_TRUE(err == error::None); + ASSERT_FALSE(robj0.isEmpty()); // Cannot view as shared_ptr, because we cloned the contained value. EXPECT_FALSE(robj0.canViewAs>()); diff --git a/ReflectionTemplateLib/access/inc/Method.h b/ReflectionTemplateLib/access/inc/Method.h index a57bcbf5..60d26ca7 100644 --- a/ReflectionTemplateLib/access/inc/Method.h +++ b/ReflectionTemplateLib/access/inc/Method.h @@ -41,7 +41,7 @@ namespace rtl { //invokes the constructor associated with this 'Method' template - Return invokeCtor(alloc pAllocType, std::size_t pClonerIndex, _args&&...params) const; + Return invokeCtor(alloc pAllocType, const detail::FunctorId& pClonerId, _args&&...params) const; public: diff --git a/ReflectionTemplateLib/access/inc/Method.hpp b/ReflectionTemplateLib/access/inc/Method.hpp index eed7f822..dcff5e13 100644 --- a/ReflectionTemplateLib/access/inc/Method.hpp +++ b/ReflectionTemplateLib/access/inc/Method.hpp @@ -34,13 +34,13 @@ namespace rtl @return: RStatus * calls the constructor with given arguments. */ template - inline Return Method::invokeCtor(alloc pAllocType, std::size_t pClonerIndex, _args&& ...params) const + inline Return Method::invokeCtor(alloc pAllocType, const detail::FunctorId& pClonerId, _args&& ...params) const { - using Container = detail::FunctorContainer...>; + using Container = detail::FunctorContainer...>; - std::size_t index = hasSignatureId(Container::getContainerId()); - if (index != rtl::index_none) [[likely]] { - return Container::template forwardCall<_args...>(index, pAllocType, pClonerIndex, std::forward<_args>(params)...); + const detail::FunctorId* functorId = hasFunctorId(Container::getContainerId()); + if (functorId != nullptr) [[likely]] { + return Container::template forwardCall<_args...>(*functorId, pAllocType, pClonerId, std::forward<_args>(params)...); } return { error::SignatureMismatch, RObject{} }; } diff --git a/ReflectionTemplateLib/access/inc/RObject.hpp b/ReflectionTemplateLib/access/inc/RObject.hpp index 792dfcfd..a34886ea 100644 --- a/ReflectionTemplateLib/access/inc/RObject.hpp +++ b/ReflectionTemplateLib/access/inc/RObject.hpp @@ -196,10 +196,10 @@ namespace rtl template<> inline Return RObject::createCopy() const { - std::size_t pClonerIndex = m_objectId.m_clonerIndex; - if (pClonerIndex != rtl::index_none) + if (m_objectId.m_clonerId.has_value()) { - return traits::Cloner::template forwardCall(pClonerIndex, alloc::Heap, pClonerIndex, *this); + const detail::FunctorId& functorId = m_objectId.m_clonerId.value(); + return traits::Cloner::template forwardCall(functorId, *this, alloc::Heap); } return { error::CloningDisabled, RObject{} }; } @@ -208,10 +208,10 @@ namespace rtl template<> inline Return RObject::createCopy() const { - std::size_t pClonerIndex = m_objectId.m_clonerIndex; - if (pClonerIndex != rtl::index_none) + if (m_objectId.m_clonerId.has_value()) { - return traits::Cloner::template forwardCall(pClonerIndex, alloc::Stack, pClonerIndex, *this); + const detail::FunctorId& functorId = m_objectId.m_clonerId.value(); + return traits::Cloner::template forwardCall(functorId, *this, alloc::Stack); } return { error::CloningDisabled, RObject{} }; } diff --git a/ReflectionTemplateLib/access/inc/Record.h b/ReflectionTemplateLib/access/inc/Record.h index 357c2eb7..e081b37c 100644 --- a/ReflectionTemplateLib/access/inc/Record.h +++ b/ReflectionTemplateLib/access/inc/Record.h @@ -94,8 +94,8 @@ namespace rtl { { static_assert(_alloc != rtl::alloc::None, "Instance cannot be created with 'rtl::alloc::None' option."); const auto& method = m_methods.at(detail::ctor_name(m_recordName)); - std::size_t copyCtorIndex = method.getFunctorIds()[detail::Index::CopyCtor].getLambdaIndex(); - return method.invokeCtor(_alloc, copyCtorIndex, std::forward<_ctorArgs>(params)...); + const detail::FunctorId& clonerId = method.getFunctorIds()[detail::Index::CopyCtor]; + return method.invokeCtor(_alloc, clonerId, std::forward<_ctorArgs>(params)...); } //only class which can create objects of this class & manipulates 'm_methods'. diff --git a/ReflectionTemplateLib/access/src/CxxMirror.cpp b/ReflectionTemplateLib/access/src/CxxMirror.cpp index 8ec1eb3e..9054699d 100644 --- a/ReflectionTemplateLib/access/src/CxxMirror.cpp +++ b/ReflectionTemplateLib/access/src/CxxMirror.cpp @@ -32,8 +32,7 @@ namespace rtl { const Record& record = itr->second; Method ctors = record.getMethod(detail::ctor_name(record.getRecordName())).value(); - std::size_t copyCtorIndex = ctors.getFunctors()[detail::Index::CopyCtor].getLambdaIndex(); - const_cast(pTarget).m_objectId.m_clonerIndex = copyCtorIndex; + const_cast(pTarget).m_objectId.m_clonerId = ctors.getFunctors()[detail::Index::CopyCtor]; return error::None; } return error::CloningDisabled; diff --git a/ReflectionTemplateLib/common/forward_decls.h b/ReflectionTemplateLib/common/forward_decls.h index 0666b3f2..cf60c39a 100644 --- a/ReflectionTemplateLib/common/forward_decls.h +++ b/ReflectionTemplateLib/common/forward_decls.h @@ -11,9 +11,17 @@ #pragma once -namespace rtl { - +namespace rtl +{ struct Return; class RObject; + + namespace detail + { + struct FunctorId; + + template + class FunctorContainer; + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/common/rtl_traits.h b/ReflectionTemplateLib/common/rtl_traits.h index 323c6af3..257ef64a 100644 --- a/ReflectionTemplateLib/common/rtl_traits.h +++ b/ReflectionTemplateLib/common/rtl_traits.h @@ -21,24 +21,17 @@ #include "TypeId.h" #include "Constants.h" +#include "forward_decls.h" namespace rtl { - class RObject; - - namespace detail { - - template - class FunctorContainer; - } - namespace traits { using Converter = std::function< std::any(const std::any&, const detail::EntityKind&, detail::EntityKind&) >; using ConverterPair = std::pair< std::size_t, Converter >; - using Cloner = detail::FunctorContainer; + using Cloner = detail::FunctorContainer; } namespace traits diff --git a/ReflectionTemplateLib/detail/inc/CallReflector.h b/ReflectionTemplateLib/detail/inc/CallReflector.h index 7a896cfd..20ad94a4 100644 --- a/ReflectionTemplateLib/detail/inc/CallReflector.h +++ b/ReflectionTemplateLib/detail/inc/CallReflector.h @@ -34,7 +34,7 @@ namespace rtl::detail { FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, _params&&..._args) { //'getFunctors()' must be implemented by _derivedType (FunctorContainer). - return _derivedType::getFunctors()[pFunctorId.m_lambdaIndex](std::forward<_params>(_args)...); + return _derivedType::getFunctors()[pFunctorId.m_lambdaIndex](pFunctorId, std::forward<_params>(_args)...); } @@ -43,10 +43,18 @@ namespace rtl::detail { * gets the lambda vector from '_derivedType' and calls the lambda at given index with '_args'. * this 'forwardCall' is for calling lambda containing constructors. */ template - FORCE_INLINE static Return forwardCall(std::size_t pFunctorIndex, rtl::alloc pAllocType, std::size_t pClonerIndex, _params&&..._args) + FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, rtl::alloc pAllocType, const detail::FunctorId& pClonerId, _params&&..._args) { //'getFunctors()' must be implemented by _derivedType (FunctorContainer). - return _derivedType::getFunctors()[pFunctorIndex](pAllocType, pClonerIndex, std::forward<_params>(_args)...); + return _derivedType::getFunctors()[pFunctorId.m_lambdaIndex](pFunctorId, pAllocType, pClonerId, std::forward<_params>(_args)...); + } + + + template + FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, const RObject& pSrcObj, rtl::alloc pAllocType) + { + //'getFunctors()' must be implemented by _derivedType (FunctorContainer). + return _derivedType::getFunctors()[pFunctorId.m_lambdaIndex](pFunctorId, pSrcObj, pAllocType); } @@ -55,10 +63,10 @@ namespace rtl::detail { * gets the lambda vector from '_derivedType' and calls the lambda at given index with '_args'. * this 'forwardCall' is for calling lambda containing member-function functors. */ template - FORCE_INLINE static Return forwardCall(const rtl::RObject& pTarget, std::size_t pFunctorIndex, _params&&..._args) + FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, const rtl::RObject& pTarget, _params&&..._args) { //'getMethodFunctors()' is implemented by _derivedType (MethodContainer) - return _derivedType::getMethodFunctors()[pFunctorIndex](pTarget, std::forward<_params>(_args)...); + return _derivedType::getMethodFunctors()[pFunctorId.m_lambdaIndex](pFunctorId, pTarget, std::forward<_params>(_args)...); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp index de652d62..f5426d05 100644 --- a/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp @@ -26,10 +26,6 @@ namespace rtl::detail FunctorContainer...>, FunctorContainer<_signature...>>; - //auto containerId = Container::getContainerId(); - //const detail::FunctorId* functorId = m_function->hasFunctorId(containerId); - //return { error::None, RObject{} }; - const detail::FunctorId* functorId = m_function->hasFunctorId(Container::getContainerId()); if (functorId != nullptr) [[likely]] { return Container::template forwardCall<_args...>(*functorId, std::forward<_args>(params)...); diff --git a/ReflectionTemplateLib/detail/inc/FunctorContainer.h b/ReflectionTemplateLib/detail/inc/FunctorContainer.h index c3d89fc2..73afd576 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorContainer.h +++ b/ReflectionTemplateLib/detail/inc/FunctorContainer.h @@ -37,7 +37,7 @@ namespace rtl { public SetupConstructor>, public CallReflector> { - using FunctionLambda = std::function < Return(_signature...) >; + using FunctionLambda = std::function < Return(const FunctorId&, _signature...) >; public: //every FunctorContainer<...> will have a unique-id. diff --git a/ReflectionTemplateLib/detail/inc/LambdaRegistry.h b/ReflectionTemplateLib/detail/inc/LambdaRegistry.h index 9bb6aba7..58b15385 100644 --- a/ReflectionTemplateLib/detail/inc/LambdaRegistry.h +++ b/ReflectionTemplateLib/detail/inc/LambdaRegistry.h @@ -13,92 +13,120 @@ #include "LambdaBridge.h" +#include #include #include +#include "TypeId.h" #include "Constants.h" #include "FunctorRegistry.h" namespace rtl::detail { - class lambda_hop { }; + class lambda_hop { + public: + + std::size_t m_signatureId = TypeId<>::None; + std::vector m_argsId; + }; } namespace rtl::detail { - template - class lambda_registry; + template + class lambda_registry; - template - class lambda_registry : public lambda_hop - { - using lambda_t = std::function; + template + class lambda_registry : public lambda_hop + { + using lambda_t = std::function; - std::vector lambda_table; + std::vector lambda_table; - std::vector m_functors; + std::vector m_functors; - public: + public: - GETTER_CREF(std::vector, , lambda_table) + lambda_registry() + { + m_signatureId = TypeId>::get(); + TypeId::get(m_argsId); + } - void push(const lambda_t& pLambda) { - lambda_table.push_back(pLambda); - } + GETTER_CREF(std::vector, , lambda_table) - Return operator()(std::size_t index, signature_ts&&...params) - { - return lambda_table[index](m_functors[index], index, std::forward(params)...); - } - }; + void push(const lambda_t& lambda) + { + lambda_table.push_back(lambda); + } + Return operator()(std::size_t index, signature_ts&&...params) + { + return lambda_table[index](m_functors[index], index, std::forward(params)...); + } + }; - template - class lambda_registry : public lambda_hop - { - using lambda_t = std::function ; - std::vector lambda_table; + template + class lambda_registry : public lambda_hop + { + using lambda_t = std::function ; - std::vector m_functors; + std::vector lambda_table; - public: + std::vector m_functors; - GETTER_CREF(std::vector, , lambda_table) + public: - void push(const lambda_t& pLambda) { - lambda_table.push_back(pLambda); - } + lambda_registry() + { + m_signatureId = TypeId>::get(); + TypeId::get(m_argsId); + } - Return operator()(std::size_t index, signature_ts&&...params) - { - return lambda_table[index](m_functors[index], index, std::forward(params)...); - } - }; + GETTER_CREF(std::vector, , lambda_table) + void push(const lambda_t& lambda) + { + lambda_table.push_back(lambda); + } - template - class lambda_registry : public lambda_hop - { - using lambda_t = std::function ; - - std::vector lambda_table; + Return operator()(std::size_t index, signature_ts&&...params) + { + return lambda_table[index](m_functors[index], index, std::forward(params)...); + } + }; - std::vector m_functors; - public: + template + class lambda_registry : public lambda_hop + { + using lambda_t = std::function ; - GETTER_CREF(std::vector, , lambda_table) + std::vector lambda_table; - void push(const lambda_t& pLambda) { - lambda_table.push_back(pLambda); - } + std::vector m_functors; - Return operator()(std::size_t index, signature_ts&&...params) - { - return lambda_table[index](m_functors[index], index, std::forward(params)...); - } - }; + public: + + lambda_registry() + { + m_signatureId = TypeId>::get(); + TypeId::get(m_argsId); + } + + GETTER_CREF(std::vector, , lambda_table) + + void push(const lambda_t& lambda) + { + lambda_table.push_back(lambda); + } + + Return operator()(std::size_t index, signature_ts&&...params) + { + return lambda_table[index](m_functors[index], index, std::forward(params)...); + } + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/MethodContainer.h b/ReflectionTemplateLib/detail/inc/MethodContainer.h index 0763ef7e..9d8a53f8 100644 --- a/ReflectionTemplateLib/detail/inc/MethodContainer.h +++ b/ReflectionTemplateLib/detail/inc/MethodContainer.h @@ -40,7 +40,7 @@ namespace rtl { class MethodContainer : public SetupMethod>, public CallReflector> { - using MethodLambda = std::function < Return (const rtl::RObject&, _signature...) >; + using MethodLambda = std::function < Return (const FunctorId&, const rtl::RObject&, _signature...) >; public: @@ -122,7 +122,7 @@ namespace rtl { class MethodContainer : public SetupMethod>, public CallReflector> { - using MethodLambda = std::function < Return (const rtl::RObject&, _signature...) >; + using MethodLambda = std::function < Return (const FunctorId&, const rtl::RObject&, _signature...) >; public: diff --git a/ReflectionTemplateLib/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/detail/inc/MethodInvoker.hpp index fb06f8cd..76a1c4e9 100644 --- a/ReflectionTemplateLib/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/detail/inc/MethodInvoker.hpp @@ -61,23 +61,23 @@ namespace rtl::detail _args&&... params) { using containerConst = detail::MethodContainer; - std::size_t constMethodIndex = pMethod.hasSignatureId(containerConst::getContainerId()); + const FunctorId* constFunctorId = pMethod.hasFunctorId(containerConst::getContainerId()); - if (constMethodIndex != rtl::index_none) [[likely]] + if (constFunctorId != nullptr) [[likely]] { - return containerConst::template forwardCall<_args...>(pTarget, constMethodIndex, std::forward<_args>(params)...); + return containerConst::template forwardCall<_args...>(*constFunctorId, pTarget, std::forward<_args>(params)...); } else [[unlikely]] { using containerNonConst = detail::MethodContainer; - std::size_t nonConstMethodIndex = pMethod.hasSignatureId(containerNonConst::getContainerId()); + const FunctorId* functorId = pMethod.hasFunctorId(containerNonConst::getContainerId()); - if (nonConstMethodIndex != rtl::index_none) + if (functorId != nullptr) { if (!pTarget.isConstCastSafe()) { return { error::ConstOverloadMissing, RObject{} }; } - return containerNonConst::template forwardCall<_args...>(pTarget, nonConstMethodIndex, std::forward<_args>(params)...); + return containerNonConst::template forwardCall<_args...>(*functorId, pTarget, std::forward<_args>(params)...); } } return { error::SignatureMismatch, RObject{} }; @@ -128,9 +128,10 @@ namespace rtl::detail _args&&... params) { using container0 = detail::MethodContainer; - const std::size_t index = pMethod.hasSignatureId(container0::getContainerId()); - if (index != rtl::index_none) [[likely]] { - return container0::template forwardCall<_args...>(pTarget, index, std::forward<_args>(params)...); + const FunctorId* functorId = pMethod.hasFunctorId(container0::getContainerId()); + + if (functorId != nullptr) [[likely]] { + return container0::template forwardCall<_args...>(*functorId, pTarget, std::forward<_args>(params)...); } else { diff --git a/ReflectionTemplateLib/detail/inc/RObjectBuilder.h b/ReflectionTemplateLib/detail/inc/RObjectBuilder.h index b847dacc..58b352b5 100644 --- a/ReflectionTemplateLib/detail/inc/RObjectBuilder.h +++ b/ReflectionTemplateLib/detail/inc/RObjectBuilder.h @@ -11,12 +11,10 @@ #pragma once -#include "rtl_traits.h" +#include -namespace rtl { - class RObject; - struct Return; -} +#include "rtl_traits.h" +#include "forward_decls.h" namespace rtl::detail { @@ -27,10 +25,10 @@ namespace rtl::detail RObjectBuilder(const RObjectBuilder&) = delete; template requires (_allocOn == alloc::Heap) - static RObject build(T&& pVal, std::size_t pClonerIndex, bool pIsConstCastSafe) noexcept; + static RObject build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept; template requires (_allocOn == alloc::Stack) - static RObject build(T&& pVal, std::size_t pClonerIndex, bool pIsConstCastSafe) noexcept; + static RObject build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept; }; } @@ -48,11 +46,11 @@ namespace rtl { if constexpr (std::is_same_v, char>) { return detail::RObjectBuilder::template - build(std::string_view(pArr, N - 1), rtl::index_none, !traits::is_const_v); + build(std::string_view(pArr, N - 1), std::nullopt, !traits::is_const_v); } else { return detail::RObjectBuilder>::template - build(std::vector(pArr, pArr + N), rtl::index_none, !traits::is_const_v); + build(std::vector(pArr, pArr + N), std::nullopt, !traits::is_const_v); } } @@ -64,13 +62,13 @@ namespace rtl if constexpr (traits::std_wrapper<_T>::type == detail::Wrapper::None) { return detail::RObjectBuilder::template - build(std::forward(pVal), rtl::index_none, !traits::is_const_v); + build(std::forward(pVal), std::nullopt, !traits::is_const_v); } else { constexpr bool isConstCastSafe = !traits::is_const_v::value_type>; return detail::RObjectBuilder::template - build(std::forward(pVal), rtl::index_none, isConstCastSafe); + build(std::forward(pVal), std::nullopt, isConstCastSafe); } } } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/RObjectBuilder.hpp b/ReflectionTemplateLib/detail/inc/RObjectBuilder.hpp index 5de6e142..ded14dad 100644 --- a/ReflectionTemplateLib/detail/inc/RObjectBuilder.hpp +++ b/ReflectionTemplateLib/detail/inc/RObjectBuilder.hpp @@ -32,21 +32,21 @@ namespace rtl::detail template template requires (_allocOn == alloc::Heap) - FORCE_INLINE RObject RObjectBuilder::build(T&& pVal, std::size_t pClonerIndex, bool pIsConstCastSafe) noexcept + FORCE_INLINE RObject RObjectBuilder::build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept { using _T = traits::raw_t; return RObject( std::any{ std::in_place_type>, RObjectUPtr<_T>(std::unique_ptr<_T>(static_cast<_T*>(pVal))) }, - RObjectId::create, alloc::Heap>(pClonerIndex, pIsConstCastSafe), + RObjectId::create, alloc::Heap>(pClonerId, pIsConstCastSafe), &getConverters>()); } template template requires (_allocOn == alloc::Stack) - FORCE_INLINE RObject RObjectBuilder::build(T&& pVal, std::size_t pClonerIndex, bool pIsConstCastSafe) noexcept + FORCE_INLINE RObject RObjectBuilder::build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept { using _T = traits::raw_t; constexpr bool isRawPointer = std::is_pointer_v>; @@ -54,7 +54,7 @@ namespace rtl::detail if constexpr (isRawPointer) { return RObject( std::any { static_cast(pVal) }, - RObjectId::create(pClonerIndex, pIsConstCastSafe), + RObjectId::create(pClonerId, pIsConstCastSafe), &getConverters() ); } else @@ -66,7 +66,7 @@ namespace rtl::detail std::in_place_type>, RObjectUPtr(std::move(pVal)) }, - RObjectId::create(pClonerIndex, pIsConstCastSafe), + RObjectId::create(pClonerId, pIsConstCastSafe), &getConverters() ); } else @@ -76,7 +76,7 @@ namespace rtl::detail std::in_place_type, std::forward(pVal) }, - RObjectId::create(pClonerIndex, pIsConstCastSafe), + RObjectId::create(pClonerId, pIsConstCastSafe), &getConverters() ); } } diff --git a/ReflectionTemplateLib/detail/inc/RObjectId.h b/ReflectionTemplateLib/detail/inc/RObjectId.h index 5455ca9f..403e9b96 100644 --- a/ReflectionTemplateLib/detail/inc/RObjectId.h +++ b/ReflectionTemplateLib/detail/inc/RObjectId.h @@ -13,11 +13,11 @@ #include #include -#include "ReflectCast.h" +#include -namespace rtl { - class RObject; -} +#include "ReflectCast.h" +#include "forward_decls.h" +#include "FunctorId.h" namespace rtl::detail { @@ -27,13 +27,14 @@ namespace rtl::detail bool m_isConstCastSafe; std::size_t m_typeId; - std::size_t m_clonerIndex; std::size_t m_wrapperTypeId; alloc m_allocatedOn; Wrapper m_wrapperType; EntityKind m_containsAs; + std::optional m_clonerId; + GETTER(std::size_t, TypeId, m_typeId) GETTER(EntityKind, ContainedAs, m_containsAs) @@ -58,7 +59,7 @@ namespace rtl::detail template - FORCE_INLINE static RObjectId create(std::size_t pClonerIndex, bool pIsConstCastSafe) noexcept + FORCE_INLINE static RObjectId create(std::optional pClonerId, bool pIsConstCastSafe) noexcept { // extract wrapper info. using _W = traits::std_wrapper>; @@ -68,8 +69,19 @@ namespace rtl::detail const std::size_t wrapperId = _W::id(); const std::size_t typeId = rtl::detail::TypeId<_T>::get(); + constexpr bool isWrappingConst = (_W::type != Wrapper::None && traits::is_const_v); - return RObjectId{ isWrappingConst, pIsConstCastSafe, typeId, pClonerIndex, wrapperId, _allocOn, _W::type, entityKind }; + return RObjectId { + + isWrappingConst, + pIsConstCastSafe, + typeId, + wrapperId, + _allocOn, + _W::type, + entityKind, + pClonerId + }; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/ReflectionBuilder.hpp b/ReflectionTemplateLib/detail/inc/ReflectionBuilder.hpp index 29e96bb4..f6712332 100644 --- a/ReflectionTemplateLib/detail/inc/ReflectionBuilder.hpp +++ b/ReflectionTemplateLib/detail/inc/ReflectionBuilder.hpp @@ -87,9 +87,9 @@ namespace rtl::detail */ template inline const Function ReflectionBuilder::buildConstructor() const { - using Container = FunctorContainer < rtl::alloc, std::size_t, traits::remove_const_if_not_reference<_ctorSignature>... > ; + using Container = FunctorContainer < rtl::alloc, FunctorId, traits::remove_const_if_not_reference<_ctorSignature>... > ; const FunctorId& functorId = Container::template addConstructor<_recordType, _ctorSignature...>(); - const FunctorId& copyCtorId = traits::Cloner::template addCopyConstructor<_recordType, const RObject&>(); + const FunctorId& copyCtorId = traits::Cloner::template addCopyConstructor<_recordType, RObject, alloc>(); const Function& ctorFunction = Function(m_namespace, m_record, m_function, functorId, m_recordId, methodQ::None); ctorFunction.getFunctorIds().push_back(copyCtorId); diff --git a/ReflectionTemplateLib/detail/inc/SetupConstructor.h b/ReflectionTemplateLib/detail/inc/SetupConstructor.h index 44d06345..6dfc38b2 100644 --- a/ReflectionTemplateLib/detail/inc/SetupConstructor.h +++ b/ReflectionTemplateLib/detail/inc/SetupConstructor.h @@ -11,12 +11,12 @@ #pragma once + #include "FunctorId.h" +#include "forward_decls.h" namespace rtl { - class RObject; - namespace detail { /* @struct: SetupConstructor @@ -28,13 +28,15 @@ namespace rtl { class SetupConstructor { template - using CtorLambda = std::function < Return(alloc, std::size_t, _signature...) >; + using CtorLambda = std::function < Return(FunctorId, alloc, FunctorId, _signature...) >; + + using CopyCtorLambda = std::function < Return(const FunctorId&, const RObject&, alloc) >; template static CtorLambda<_signature...> getConstructorCaller(); - template - static CtorLambda<_signature...> getCopyConstructorCaller(); + template + static CopyCtorLambda getCopyConstructorCaller(); protected: diff --git a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp b/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp index cc33c5e6..e3ca1fb5 100644 --- a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp @@ -11,6 +11,7 @@ #pragma once #include +#include #include "RObjectBuilder.hpp" #include "SetupConstructor.h" @@ -22,8 +23,11 @@ namespace rtl::detail inline SetupConstructor<_derivedType>::CtorLambda<_signature...> SetupConstructor<_derivedType>::getConstructorCaller() { - return [](alloc pAllocType, std::size_t pClonerIndex, _signature&&...params)-> Return + return [](const FunctorId& pFunctorId, alloc pAllocType, const FunctorId& pClonerId, _signature&&...params)-> Return { + std::size_t signatureId = TypeId...>>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + if constexpr (sizeof...(_signature) == 0 && !std::is_default_constructible_v<_recordType>) { //default constructor, private or deleted. return { error::TypeNotDefaultConstructible, RObject{} }; @@ -32,24 +36,27 @@ namespace rtl::detail { if (pAllocType == alloc::Stack) { - if constexpr (!std::is_copy_constructible_v<_recordType>) { + if constexpr (!std::is_copy_constructible_v<_recordType>) + { return { error::TypeNotCopyConstructible, RObject{} }; } - else { + else + { return { error::None, RObjectBuilder<_recordType>::template - build(_recordType(std::forward<_signature>(params)...), pClonerIndex, true) + build(_recordType(std::forward<_signature>(params)...), pClonerId, true) }; } } - else if (pAllocType == alloc::Heap) { + else if (pAllocType == alloc::Heap) + { return { error::None, RObjectBuilder<_recordType*>::template - build(new _recordType(std::forward<_signature>(params)...), pClonerIndex, true) + build(new _recordType(std::forward<_signature>(params)...), pClonerId, true) }; } } @@ -60,26 +67,29 @@ namespace rtl::detail template - template - inline SetupConstructor<_derivedType>::CtorLambda<_signature...> + template + inline SetupConstructor<_derivedType>::CopyCtorLambda SetupConstructor<_derivedType>::getCopyConstructorCaller() { if constexpr (std::is_copy_constructible_v<_recordType>) { - return [](alloc pAllocOn, std::size_t pClonerIndex, const RObject& pOther) -> Return + return [](const FunctorId& pFunctorId, const RObject& pOther, alloc pAllocOn) -> Return { + std::size_t signatureId = TypeId>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + const auto& srcObj = pOther.view<_recordType>()->get(); switch (pAllocOn) { case alloc::Stack: return { error::None, - RObjectBuilder<_recordType>::template build(_recordType(srcObj), pClonerIndex, true) + RObjectBuilder<_recordType>::template build(_recordType(srcObj), pFunctorId, true) }; case alloc::Heap: return { error::None, - RObjectBuilder<_recordType*>::template build(new _recordType(srcObj), pClonerIndex, true) + RObjectBuilder<_recordType*>::template build(new _recordType(srcObj), pFunctorId, true) }; default: return { @@ -91,8 +101,11 @@ namespace rtl::detail } else { - return [](alloc pAllocOn, std::size_t pClonerIndex, const RObject&) -> Return + return [](const FunctorId& pFunctorId, const RObject& pOther, alloc pAllocOn) -> Return { + std::size_t signatureId = TypeId>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + return { error::TypeNotCopyConstructible, RObject{} @@ -115,6 +128,7 @@ namespace rtl::detail inline const detail::FunctorId SetupConstructor<_derivedType>::addConstructor() { std::size_t recordId = TypeId<_recordType>::get(); + std::size_t returnId = recordId; std::size_t containerId = _derivedType::getContainerId(); std::size_t hashKey = std::stoull(std::to_string(containerId) + std::to_string(recordId)); @@ -139,7 +153,7 @@ namespace rtl::detail lambdaIndex, rtl::index_none, - recordId, + returnId, recordId, containerId, _derivedType::template getSignatureStr<_recordType>(true), @@ -153,6 +167,7 @@ namespace rtl::detail inline const detail::FunctorId SetupConstructor<_derivedType>::addCopyConstructor() { std::size_t recordId = TypeId<_recordType>::get(); + std::size_t returnId = recordId; std::size_t containerId = _derivedType::getContainerId(); std::size_t hashKey = std::stoull(std::to_string(containerId) + std::to_string(recordId)); @@ -171,13 +186,13 @@ namespace rtl::detail }; //add the lambda in 'FunctorContainer'. - auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getCopyConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); + auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getCopyConstructorCaller<_recordType>(), getIndex, updateIndex); return detail::FunctorId { lambdaIndex, rtl::index_none, - recordId, + returnId, recordId, containerId, _derivedType::template getSignatureStr<_recordType>(true), diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.h b/ReflectionTemplateLib/detail/inc/SetupFunction.h index 894598a6..d8ef3a24 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.h +++ b/ReflectionTemplateLib/detail/inc/SetupFunction.h @@ -32,7 +32,7 @@ namespace rtl::detail class SetupFunction { template - using FunctionLambda = std::function < Return(_signature...) >; + using FunctionLambda = std::function < Return(const FunctorId&, _signature...) >; template static FunctionLambda<_signature...> getCaller(void(*pFunctor)(_signature...)); diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp b/ReflectionTemplateLib/detail/inc/SetupFunction.hpp index bd6abdda..9390ee3b 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupFunction.hpp @@ -11,6 +11,8 @@ #pragma once +#include + #include "FunctorCache.h" #include "SetupFunction.h" #include "RObjectBuilder.hpp" @@ -24,8 +26,11 @@ namespace rtl inline SetupFunction<_derivedType>::FunctionLambda<_signature...> SetupFunction<_derivedType>::getCaller(void(*pFunctor)(_signature...)) { - return [pFunctor](_signature&&... params) -> Return + return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { + std::size_t signatureId = TypeId...>>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; }; @@ -39,18 +44,21 @@ namespace rtl { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (FunctorContainer) vector holding lambda's. - */ return [pFunctor](_signature&&...params)-> Return + */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); + std::size_t signatureId = TypeId...>>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + if constexpr (std::is_reference_v<_returnType>) { /* if the function returns reference, this block will be retained by compiler. - Note: reference to temporary or dangling is not checked here. + Note: reference to temporary or dangling is not checked here. */ using _rawRetType = traits::raw_t<_returnType>; const _rawRetType& retObj = pFunctor(std::forward<_signature>(params)...); return { error::None, RObjectBuilder::template - build(&retObj, rtl::index_none, isConstCastSafe) + build(&retObj, std::nullopt, isConstCastSafe) }; } else { @@ -60,7 +68,7 @@ namespace rtl return { error::None, RObjectBuilder::template - build(std::forward(retObj), rtl::index_none, isConstCastSafe) + build(std::forward(retObj), std::nullopt, isConstCastSafe) }; } }; @@ -98,7 +106,7 @@ namespace rtl }; //generate a type-id of '_returnType'. - const std::size_t retTypeId = TypeId>::get(); + const std::size_t returnId = TypeId>::get(); //finally add the lambda 'functor' in 'FunctorContainer' lambda vector and get the index. auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); @@ -107,7 +115,7 @@ namespace rtl lambdaIndex, functorIndex, - retTypeId, + returnId, pRecordId, _derivedType::getContainerId(), _derivedType::template getSignatureStr<_returnType>(), diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.h b/ReflectionTemplateLib/detail/inc/SetupMethod.h index 9219858f..1e08fc9e 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.h +++ b/ReflectionTemplateLib/detail/inc/SetupMethod.h @@ -33,7 +33,7 @@ namespace rtl::detail { class SetupMethod { template - using MethodLambda = std::function < Return(const rtl::RObject&, _signature...) >; + using MethodLambda = std::function < Return(const FunctorId&, const rtl::RObject&, _signature...) >; template static MethodLambda<_signature...> getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...)); diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp b/ReflectionTemplateLib/detail/inc/SetupMethod.hpp index 91faebac..90f6d9bb 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp +++ b/ReflectionTemplateLib/detail/inc/SetupMethod.hpp @@ -11,6 +11,8 @@ #pragma once +#include + #include "view.h" #include "TypeId.h" #include "SetupMethod.h" @@ -26,8 +28,17 @@ namespace rtl::detail { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return + */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { + std::size_t signatureId = TypeId...>>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + + //using lambda_t = lambda_registry...>; + + //lambda_t registry = static_cast(pFunctorId.m_lambda); + + //registry-> + if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; } @@ -46,8 +57,11 @@ namespace rtl::detail { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return + */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { + std::size_t signatureId = TypeId...>>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; } @@ -63,7 +77,7 @@ namespace rtl::detail const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); return { error::None, RObjectBuilder::template - build(&retObj, rtl::index_none, isConstCastSafe) + build(&retObj, std::nullopt, isConstCastSafe) }; } else { @@ -73,7 +87,7 @@ namespace rtl::detail return { error::None, RObjectBuilder::template - build(std::forward(retObj), rtl::index_none, isConstCastSafe) + build(std::forward(retObj), std::nullopt, isConstCastSafe) }; } }; @@ -87,8 +101,11 @@ namespace rtl::detail { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return + */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { + std::size_t signatureId = TypeId...>>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + const _recordType& target = pTargetObj.view<_recordType>()->get(); (target.*pFunctor)(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -103,8 +120,11 @@ namespace rtl::detail { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const RObject& pTargetObj, _signature&&...params)-> Return + */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { + std::size_t signatureId = TypeId...>>::get(); + assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); + constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); //'target' is const and 'pFunctor' is const-member-function. const _recordType& target = pTargetObj.view<_recordType>()->get(); @@ -115,7 +135,7 @@ namespace rtl::detail const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); return { error::None, RObjectBuilder::template - build(&retObj, rtl::index_none, isConstCastSafe) + build(&retObj, std::nullopt, isConstCastSafe) }; } else { @@ -125,7 +145,7 @@ namespace rtl::detail return { error::None, RObjectBuilder::template - build(std::forward(retObj), rtl::index_none, isConstCastSafe) + build(std::forward(retObj), std::nullopt, isConstCastSafe) }; } }; diff --git a/ReflectionTemplateLib/detail/inc/TypeId.h b/ReflectionTemplateLib/detail/inc/TypeId.h index 09f4dce6..ce6f8140 100644 --- a/ReflectionTemplateLib/detail/inc/TypeId.h +++ b/ReflectionTemplateLib/detail/inc/TypeId.h @@ -11,16 +11,18 @@ #pragma once +#include #include #include #include namespace rtl { - namespace detail + namespace detail { extern std::size_t generate_unique_id(); + //class to generate unique type-id for a type or combination of types. template struct TypeId; @@ -32,14 +34,25 @@ namespace rtl { //represents '_type' or 'std::nullptr_t' for TypeId<> (empty). using HEAD = _type; + using TAIL = std::nullptr_t; + //'0' represents no type. [Never change, critical.] static constexpr const std::size_t None = 0; static const std::size_t get() { - //statically initialize a unique-id. - static const std::size_t typeId = generate_unique_id(); - return typeId; + if constexpr (!std::is_same_v<_type, std::nullptr_t>) + { + //statically initialize a unique-id. + static const std::size_t TypeId = detail::generate_unique_id(); + return TypeId; + } + return None; + } + + static void get(std::vector& pIds) + { + pIds.push_back(get()); } //returns the type-list as string. @@ -63,11 +76,14 @@ namespace rtl { if constexpr (std::is_same_v<_type, std::string&&>) { return std::string("const std::string&&"); } + if constexpr (std::is_same_v<_type, std::string_view>) { + return std::string("std::string_view"); + } if constexpr (!std::is_same_v<_type, std::nullptr_t>) { return std::string(typeid(_type).name()); } if constexpr (std::is_same_v<_type, std::nullptr_t>) { - return "std::nullptr_t"; + return ""; } else return std::string(); } @@ -84,13 +100,32 @@ namespace rtl { //represents a new list created excluding '_first'. using TAIL = TypeId<_rest...>; + static void get(std::vector& pIds) + { + if constexpr (std::is_same_v) + { + pIds.push_back(TypeId::get()); + } + else { + pIds.push_back(TypeId::get()); + TAIL::get(pIds); + } + } + + //returns the type-list as string. - static std::string toString() + static std::string toString() { const std::string& tailStr = TAIL::toString(); - if (std::is_same::value) { + if (std::is_same::value) { + return ""; + } + else if constexpr (std::is_same::value) { return std::string("std::string") + ", " + tailStr; } + else if constexpr (std::is_same::value) { + return std::string("std::string_view") + ", " + tailStr; + } return (std::string(typeid(HEAD).name()) + ", " + tailStr); } }; From 578589f9c147af11b539fbc4a49289cf05f01428 Mon Sep 17 00:00:00 2001 From: neeraj Date: Mon, 15 Sep 2025 15:48:36 +0530 Subject: [PATCH 005/148] fixed cland/gcc compile error --- ReflectionTemplateLib/access/inc/RObject.hpp | 4 ++-- ReflectionTemplateLib/detail/inc/TypeId.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ReflectionTemplateLib/access/inc/RObject.hpp b/ReflectionTemplateLib/access/inc/RObject.hpp index a34886ea..c692e8ef 100644 --- a/ReflectionTemplateLib/access/inc/RObject.hpp +++ b/ReflectionTemplateLib/access/inc/RObject.hpp @@ -199,7 +199,7 @@ namespace rtl if (m_objectId.m_clonerId.has_value()) { const detail::FunctorId& functorId = m_objectId.m_clonerId.value(); - return traits::Cloner::template forwardCall(functorId, *this, alloc::Heap); + return traits::Cloner::forwardCall(functorId, *this, alloc::Heap); } return { error::CloningDisabled, RObject{} }; } @@ -211,7 +211,7 @@ namespace rtl if (m_objectId.m_clonerId.has_value()) { const detail::FunctorId& functorId = m_objectId.m_clonerId.value(); - return traits::Cloner::template forwardCall(functorId, *this, alloc::Stack); + return traits::Cloner::forwardCall(functorId, *this, alloc::Stack); } return { error::CloningDisabled, RObject{} }; } diff --git a/ReflectionTemplateLib/detail/inc/TypeId.h b/ReflectionTemplateLib/detail/inc/TypeId.h index ce6f8140..2e170f01 100644 --- a/ReflectionTemplateLib/detail/inc/TypeId.h +++ b/ReflectionTemplateLib/detail/inc/TypeId.h @@ -102,7 +102,7 @@ namespace rtl { static void get(std::vector& pIds) { - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { pIds.push_back(TypeId::get()); } From 2a13e3c13ce6d6f2311f5f1e2179acb737f44bde Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 17 Sep 2025 16:23:34 +0530 Subject: [PATCH 006/148] New dispatch-design in progress, functor_cache integrated & working. --- CMakeLists.txt | 6 +- CxxTestRegistration/CMakeLists.txt | 4 - CxxTestRegistration/inc/TestMirrorProvider.h | 2 +- .../src/TestMirrorProvider.cpp | 11 +- CxxTestUtils/CMakeLists.txt | 6 +- RTLBenchmarkApp/CMakeLists.txt | 10 -- RTLBenchmarkApp/src/BenchMark.cpp | 2 +- RTLBenchmarkApp/src/ReflectedCall.cpp | 2 +- RTLTestRunApp/CMakeLists.txt | 7 +- .../CxxMirrorTests/CxxMirrorObjectTest.cpp | 3 +- .../CxxMirrorTests/CxxMirrorThreadingTest.cpp | 2 +- .../MyReflectionTests/MyCxxMirrorProvider.cpp | 3 +- .../MyReflectionTests/MyReflectionTests.cpp | 2 +- .../RObjectTests/RObjectReflecting_arrays.cpp | 3 +- .../RObjectTests/RObjectReflecting_bool.cpp | 3 +- .../RObjectTests/RObjectReflecting_char.cpp | 3 +- .../RObjectTests/RObjectReflecting_int.cpp | 3 +- .../RObjectReflecting_stdSharedPtr.cpp | 2 +- .../RObjectReflecting_stdUniquePtr.cpp | 2 +- .../RObjectReflecting_strings.cpp | 3 +- ReflectionTemplateLib/CMakeLists.txt | 25 ++-- .../access/src/CMakeLists.txt | 43 ------ ReflectionTemplateLib/builder/CMakeLists.txt | 26 ---- ReflectionTemplateLib/common/rtl_debug.hpp | 27 ---- .../detail/inc/FunctorCache.h | 58 -------- .../detail/inc/FunctorRegistry.h | 138 ------------------ .../detail/inc/LambdaCache.h | 59 -------- .../detail/inc/LambdaRegistry.h | 132 ----------------- .../detail/src/CMakeLists.txt | 61 -------- ReflectionTemplateLib/rtl/CMakeLists.txt | 21 +++ .../{builder/inc => rtl/builder}/Builder.h | 0 .../{builder/inc => rtl/builder}/Builder.hpp | 2 +- .../rtl/builder/CMakeLists.txt | 27 ++++ .../inc => rtl/builder}/ConstructorBuilder.h | 2 +- .../inc => rtl/builder}/FunctorContainer.h | 24 ++- .../inc => rtl/builder}/MethodContainer.h | 56 +++---- .../inc => rtl/builder}/RObjectBuilder.h | 0 .../inc => rtl/builder}/RObjectBuilder.hpp | 0 .../inc => rtl/builder}/RecordBuilder.h | 0 .../inc => rtl/builder}/RecordBuilder.hpp | 0 .../{builder/inc => rtl/builder}/Reflect.h | 2 +- .../{builder/inc => rtl/builder}/Reflect.hpp | 0 .../inc => rtl/builder}/ReflectionBuilder.h | 0 .../inc => rtl/builder}/ReflectionBuilder.hpp | 0 .../inc => rtl/builder}/SetupConstructor.h | 0 .../inc => rtl/builder}/SetupConstructor.hpp | 32 ++-- .../inc => rtl/builder}/SetupFunction.h | 3 +- .../inc => rtl/builder}/SetupFunction.hpp | 30 ++-- .../{detail/inc => rtl/builder}/SetupMethod.h | 3 +- .../inc => rtl/builder}/SetupMethod.hpp | 85 +++++------ .../rtl/cache/CMakeLists.txt | 12 ++ .../rtl/cache/functor_cache.h | 61 ++++++++ .../rtl/cache/functor_cache_const.h | 61 ++++++++ .../rtl/cache/functor_cache_nonconst.h | 61 ++++++++ .../rtl/cache/lambda_cache.h | 45 ++++++ .../rtl/detail/CMakeLists.txt | 10 ++ .../rtl/detail/inc/CMakeLists.txt | 18 +++ .../detail/inc}/ConversionUtils.h | 0 .../{ => rtl}/detail/inc/CxxReflection.h | 0 .../{ => rtl}/detail/inc/FunctorId.h | 11 +- .../{ => rtl}/detail/inc/RObjExtracter.h | 0 .../{ => rtl}/detail/inc/RObjectId.h | 0 .../{ => rtl}/detail/inc/RObjectUPtr.h | 0 .../{ => rtl}/detail/inc/ReflectCast.h | 0 .../{ => rtl}/detail/inc/ReflectCast.hpp | 2 +- .../{ => rtl}/detail/inc/ReflectCastUtil.h | 0 .../detail/inc}/forward_decls.h | 6 + .../rtl/detail/src/CMakeLists.txt | 11 ++ .../{ => rtl}/detail/src/CxxReflection.cpp | 2 +- .../detail/src/RObjectConverters_string.cpp | 2 +- .../{ => rtl}/detail/src/ReflectCast.cpp | 0 .../rtl/dispatch/CMakeLists.txt | 27 ++++ .../inc => rtl/dispatch}/CallReflector.h | 2 +- .../inc => rtl/dispatch}/FunctionCaller.h | 0 .../inc => rtl/dispatch}/FunctionCaller.hpp | 0 .../inc => rtl/dispatch}/MethodInvoker.h | 0 .../inc => rtl/dispatch}/MethodInvoker.hpp | 0 .../rtl/dispatch/dispatch_interface.h | 80 ++++++++++ ReflectionTemplateLib/rtl/dispatch/functor.h | 43 ++++++ .../rtl/dispatch/functor_const.h | 45 ++++++ .../rtl/dispatch/functor_nonconst.h | 45 ++++++ ReflectionTemplateLib/rtl/dispatch/lambda.h | 58 ++++++++ .../dispatch/lambda_copy_ctor.hpp} | 25 ++-- .../rtl/dispatch/lambda_ctor.hpp | 25 ++++ .../rtl/dispatch/lambda_function.hpp | 70 +++++++++ .../rtl/dispatch/lambda_method_const.hpp | 25 ++++ .../rtl/dispatch/lambda_method_nonconst.hpp | 24 +++ ReflectionTemplateLib/rtl/inc/CMakeLists.txt | 20 +++ .../{access => rtl}/inc/CxxMirror.h | 0 .../{access => rtl}/inc/CxxMirror.hpp | 0 .../{access => rtl}/inc/CxxMirrorToJson.h | 0 .../{access => rtl}/inc/Function.h | 2 +- .../{access => rtl}/inc/Function.hpp | 0 .../{access => rtl}/inc/Method.h | 0 .../{access => rtl}/inc/Method.hpp | 0 .../{access => rtl}/inc/RObject.h | 3 +- .../{access => rtl}/inc/RObject.hpp | 4 +- .../{access => rtl}/inc/Record.h | 2 +- .../{common => rtl/inc}/view.h | 0 .../{common => rtl/inc}/view.hpp | 0 .../{common/RTLibInterface.h => rtl/rtl.h} | 2 - .../Constants.h => rtl/rtl_constants.h} | 2 +- .../error_codes.h => rtl/rtl_errors.h} | 0 .../{common => rtl}/rtl_traits.h | 4 +- .../{detail/inc/TypeId.h => rtl/rtl_typeid.h} | 0 ReflectionTemplateLib/rtl/src/CMakeLists.txt | 11 ++ .../{access => rtl}/src/CxxMirror.cpp | 0 .../{access => rtl}/src/CxxMirrorToJson.cpp | 6 - .../{access => rtl}/src/Function.cpp | 0 109 files changed, 975 insertions(+), 787 deletions(-) delete mode 100644 ReflectionTemplateLib/access/src/CMakeLists.txt delete mode 100644 ReflectionTemplateLib/builder/CMakeLists.txt delete mode 100644 ReflectionTemplateLib/common/rtl_debug.hpp delete mode 100644 ReflectionTemplateLib/detail/inc/FunctorCache.h delete mode 100644 ReflectionTemplateLib/detail/inc/FunctorRegistry.h delete mode 100644 ReflectionTemplateLib/detail/inc/LambdaCache.h delete mode 100644 ReflectionTemplateLib/detail/inc/LambdaRegistry.h delete mode 100644 ReflectionTemplateLib/detail/src/CMakeLists.txt create mode 100644 ReflectionTemplateLib/rtl/CMakeLists.txt rename ReflectionTemplateLib/{builder/inc => rtl/builder}/Builder.h (100%) rename ReflectionTemplateLib/{builder/inc => rtl/builder}/Builder.hpp (99%) create mode 100644 ReflectionTemplateLib/rtl/builder/CMakeLists.txt rename ReflectionTemplateLib/{builder/inc => rtl/builder}/ConstructorBuilder.h (99%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/FunctorContainer.h (84%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/MethodContainer.h (77%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/RObjectBuilder.h (100%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/RObjectBuilder.hpp (100%) rename ReflectionTemplateLib/{builder/inc => rtl/builder}/RecordBuilder.h (100%) rename ReflectionTemplateLib/{builder/inc => rtl/builder}/RecordBuilder.hpp (100%) rename ReflectionTemplateLib/{builder/inc => rtl/builder}/Reflect.h (99%) rename ReflectionTemplateLib/{builder/inc => rtl/builder}/Reflect.hpp (100%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/ReflectionBuilder.h (100%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/ReflectionBuilder.hpp (100%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/SetupConstructor.h (100%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/SetupConstructor.hpp (87%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/SetupFunction.h (97%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/SetupFunction.hpp (83%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/SetupMethod.h (98%) rename ReflectionTemplateLib/{detail/inc => rtl/builder}/SetupMethod.hpp (81%) create mode 100644 ReflectionTemplateLib/rtl/cache/CMakeLists.txt create mode 100644 ReflectionTemplateLib/rtl/cache/functor_cache.h create mode 100644 ReflectionTemplateLib/rtl/cache/functor_cache_const.h create mode 100644 ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h create mode 100644 ReflectionTemplateLib/rtl/cache/lambda_cache.h create mode 100644 ReflectionTemplateLib/rtl/detail/CMakeLists.txt create mode 100644 ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt rename ReflectionTemplateLib/{common => rtl/detail/inc}/ConversionUtils.h (100%) rename ReflectionTemplateLib/{ => rtl}/detail/inc/CxxReflection.h (100%) rename ReflectionTemplateLib/{ => rtl}/detail/inc/FunctorId.h (93%) rename ReflectionTemplateLib/{ => rtl}/detail/inc/RObjExtracter.h (100%) rename ReflectionTemplateLib/{ => rtl}/detail/inc/RObjectId.h (100%) rename ReflectionTemplateLib/{ => rtl}/detail/inc/RObjectUPtr.h (100%) rename ReflectionTemplateLib/{ => rtl}/detail/inc/ReflectCast.h (100%) rename ReflectionTemplateLib/{ => rtl}/detail/inc/ReflectCast.hpp (99%) rename ReflectionTemplateLib/{ => rtl}/detail/inc/ReflectCastUtil.h (100%) rename ReflectionTemplateLib/{common => rtl/detail/inc}/forward_decls.h (91%) create mode 100644 ReflectionTemplateLib/rtl/detail/src/CMakeLists.txt rename ReflectionTemplateLib/{ => rtl}/detail/src/CxxReflection.cpp (99%) rename ReflectionTemplateLib/{ => rtl}/detail/src/RObjectConverters_string.cpp (99%) rename ReflectionTemplateLib/{ => rtl}/detail/src/ReflectCast.cpp (100%) create mode 100644 ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt rename ReflectionTemplateLib/{detail/inc => rtl/dispatch}/CallReflector.h (99%) rename ReflectionTemplateLib/{detail/inc => rtl/dispatch}/FunctionCaller.h (100%) rename ReflectionTemplateLib/{detail/inc => rtl/dispatch}/FunctionCaller.hpp (100%) rename ReflectionTemplateLib/{detail/inc => rtl/dispatch}/MethodInvoker.h (100%) rename ReflectionTemplateLib/{detail/inc => rtl/dispatch}/MethodInvoker.hpp (100%) create mode 100644 ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/functor.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/functor_const.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda.h rename ReflectionTemplateLib/{detail/inc/LambdaBridge.h => rtl/dispatch/lambda_copy_ctor.hpp} (66%) create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp create mode 100644 ReflectionTemplateLib/rtl/inc/CMakeLists.txt rename ReflectionTemplateLib/{access => rtl}/inc/CxxMirror.h (100%) rename ReflectionTemplateLib/{access => rtl}/inc/CxxMirror.hpp (100%) rename ReflectionTemplateLib/{access => rtl}/inc/CxxMirrorToJson.h (100%) rename ReflectionTemplateLib/{access => rtl}/inc/Function.h (99%) rename ReflectionTemplateLib/{access => rtl}/inc/Function.hpp (100%) rename ReflectionTemplateLib/{access => rtl}/inc/Method.h (100%) rename ReflectionTemplateLib/{access => rtl}/inc/Method.hpp (100%) rename ReflectionTemplateLib/{access => rtl}/inc/RObject.h (99%) rename ReflectionTemplateLib/{access => rtl}/inc/RObject.hpp (97%) rename ReflectionTemplateLib/{access => rtl}/inc/Record.h (99%) rename ReflectionTemplateLib/{common => rtl/inc}/view.h (100%) rename ReflectionTemplateLib/{common => rtl/inc}/view.hpp (100%) rename ReflectionTemplateLib/{common/RTLibInterface.h => rtl/rtl.h} (97%) rename ReflectionTemplateLib/{common/Constants.h => rtl/rtl_constants.h} (99%) rename ReflectionTemplateLib/{common/error_codes.h => rtl/rtl_errors.h} (100%) rename ReflectionTemplateLib/{common => rtl}/rtl_traits.h (99%) rename ReflectionTemplateLib/{detail/inc/TypeId.h => rtl/rtl_typeid.h} (100%) create mode 100644 ReflectionTemplateLib/rtl/src/CMakeLists.txt rename ReflectionTemplateLib/{access => rtl}/src/CxxMirror.cpp (100%) rename ReflectionTemplateLib/{access => rtl}/src/CxxMirrorToJson.cpp (94%) rename ReflectionTemplateLib/{access => rtl}/src/Function.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0500cf1d..5c611b4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,9 @@ project(CxxReflectionProject) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin") # Add the subdirectories +add_subdirectory(ReflectionTemplateLib) add_subdirectory(CxxTestRegistration) -add_subdirectory(RTLTestRunApp) -add_subdirectory(RTLBenchmarkApp) add_subdirectory(CxxTestProps) add_subdirectory(CxxTestUtils) -add_subdirectory(ReflectionTemplateLib) \ No newline at end of file +add_subdirectory(RTLTestRunApp) +add_subdirectory(RTLBenchmarkApp) \ No newline at end of file diff --git a/CxxTestRegistration/CMakeLists.txt b/CxxTestRegistration/CMakeLists.txt index 96b0a6a3..fe4d4a19 100644 --- a/CxxTestRegistration/CMakeLists.txt +++ b/CxxTestRegistration/CMakeLists.txt @@ -15,10 +15,6 @@ ADD_LIBRARY(${PROJECT_NAME} STATIC "") INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/CxxTestUtils/inc") INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/CxxTestProps/inc") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/common") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/detail/inc") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/access/inc") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/builder/inc") TARGET_LINK_LIBRARIES(${CXX_LIB_NAME} ReflectionTemplateLib) diff --git a/CxxTestRegistration/inc/TestMirrorProvider.h b/CxxTestRegistration/inc/TestMirrorProvider.h index 42072a54..d71113f4 100644 --- a/CxxTestRegistration/inc/TestMirrorProvider.h +++ b/CxxTestRegistration/inc/TestMirrorProvider.h @@ -1,6 +1,6 @@ #pragma once -#include "RTLibInterface.h" +#include namespace test_mirror { diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index db44c78e..5388abea 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -202,9 +202,14 @@ namespace test_mirror rtl::type().member().methodStatic(animal::str_updateZooKeeper).build(&Animal::updateZooKeeper), #if defined(__GNUC__) && !defined(__clang__) - /* GCC fails to automatically identify the correct overloaded functor to pick. (non-const-lvalue-ref & rvalue as argument) - we need to explicitly cast the functor like, static_cast(&Animal::setAnimalName). - */ rtl::type().member() + /* + GCC fails to automatically resolve the correct overloaded functor + when both a non-const lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the member function pointer, e.g.: + + static_cast(&Animal::setAnimalName); + */ + rtl::type().member() .method(animal::str_setAnimalName) .build(static_cast(&Animal::setAnimalName)), //overloaded method, taking non-const lvalue reference as argument. diff --git a/CxxTestUtils/CMakeLists.txt b/CxxTestUtils/CMakeLists.txt index b43de122..bca425cc 100644 --- a/CxxTestUtils/CMakeLists.txt +++ b/CxxTestUtils/CMakeLists.txt @@ -14,8 +14,8 @@ ADD_LIBRARY(${PROJECT_NAME} STATIC "") INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/CxxTestProps/inc") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/common") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/access/inc") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/detail/inc") + +TARGET_LINK_LIBRARIES(${CXX_LIB_NAME} ReflectionTemplateLib) + # Add the source directory INCLUDE(src/CMakeLists.txt) \ No newline at end of file diff --git a/RTLBenchmarkApp/CMakeLists.txt b/RTLBenchmarkApp/CMakeLists.txt index ae302c8c..72cd7492 100644 --- a/RTLBenchmarkApp/CMakeLists.txt +++ b/RTLBenchmarkApp/CMakeLists.txt @@ -25,16 +25,6 @@ if(NOT benchmark_POPULATED) add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR} EXCLUDE_FROM_ALL) endif() -# =============================== -# Common Include Paths -# =============================== -set(RTL_INCLUDE_DIRS - inc - "${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/common" - "${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/detail/inc" - "${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/access/inc" - "${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/builder/inc" -) # =============================== # Test Executable diff --git a/RTLBenchmarkApp/src/BenchMark.cpp b/RTLBenchmarkApp/src/BenchMark.cpp index 72b66cc6..350617aa 100644 --- a/RTLBenchmarkApp/src/BenchMark.cpp +++ b/RTLBenchmarkApp/src/BenchMark.cpp @@ -5,7 +5,7 @@ #include #include "BenchMark.h" -#include "RTLibInterface.h" +#include namespace bm diff --git a/RTLBenchmarkApp/src/ReflectedCall.cpp b/RTLBenchmarkApp/src/ReflectedCall.cpp index 099d3c44..4c2bf8ac 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.cpp +++ b/RTLBenchmarkApp/src/ReflectedCall.cpp @@ -2,7 +2,7 @@ #include #include "ReflectedCall.h" -#include "RTLibInterface.h" +#include #include "BenchMark.h" namespace cxx diff --git a/RTLTestRunApp/CMakeLists.txt b/RTLTestRunApp/CMakeLists.txt index 3b2177eb..3b88d6c2 100644 --- a/RTLTestRunApp/CMakeLists.txt +++ b/RTLTestRunApp/CMakeLists.txt @@ -31,10 +31,6 @@ set(RTL_INCLUDE_DIRS inc "${CMAKE_SOURCE_DIR}/CxxTestUtils/inc" "${CMAKE_SOURCE_DIR}/CxxTestRegistration/inc" - "${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/common" - "${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/detail/inc" - "${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/access/inc" - "${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/builder/inc" ) # =============================== @@ -42,7 +38,6 @@ set(RTL_INCLUDE_DIRS # =============================== set(CXX_EXE_NAME RTLTestRunApp) -# Add all test sources (either glob or include your src/CMakeLists.txt) file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS src/*.cpp) add_executable(${CXX_EXE_NAME} ${TEST_SOURCES}) @@ -56,8 +51,10 @@ target_link_libraries(${CXX_EXE_NAME} GTest::gtest_main ) + # =============================== # GoogleTest Integration # =============================== + include(GoogleTest) gtest_discover_tests(${CXX_EXE_NAME}) diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp index 57f445ea..d6f62f6e 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp @@ -1,9 +1,8 @@ #include - #include +#include -#include "RTLibInterface.h" #include "CxxMirrorToJson.h" namespace diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp index b340a9c0..c3246388 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "../../CxxTestProps/inc/Date.h" #include "../../CxxTestProps/inc/Book.h" @@ -18,7 +19,6 @@ #include "TestUtilsAnimal.h" #include "GlobalTestUtils.h" -#include "RTLibInterface.h" #include "CxxMirrorThreadingTest.h" using namespace test_utils; diff --git a/RTLTestRunApp/src/MyReflectionTests/MyCxxMirrorProvider.cpp b/RTLTestRunApp/src/MyReflectionTests/MyCxxMirrorProvider.cpp index d406e941..1fa8fe82 100644 --- a/RTLTestRunApp/src/MyReflectionTests/MyCxxMirrorProvider.cpp +++ b/RTLTestRunApp/src/MyReflectionTests/MyCxxMirrorProvider.cpp @@ -1,5 +1,6 @@ -#include "RTLibInterface.h" +#include + #include "MyReflectingType.h" namespace my_type diff --git a/RTLTestRunApp/src/MyReflectionTests/MyReflectionTests.cpp b/RTLTestRunApp/src/MyReflectionTests/MyReflectionTests.cpp index 349c1836..b076085f 100644 --- a/RTLTestRunApp/src/MyReflectionTests/MyReflectionTests.cpp +++ b/RTLTestRunApp/src/MyReflectionTests/MyReflectionTests.cpp @@ -1,7 +1,7 @@ #include +#include -#include "RTLibInterface.h" #include "MyReflectingType.h" using namespace my_type; diff --git a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_arrays.cpp b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_arrays.cpp index 1a1753c6..692c85ba 100644 --- a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_arrays.cpp +++ b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_arrays.cpp @@ -14,8 +14,7 @@ */ #include - -#include "RTLibInterface.h" +#include using namespace rtl; diff --git a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_bool.cpp b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_bool.cpp index 914b0dc7..71396728 100644 --- a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_bool.cpp +++ b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_bool.cpp @@ -1,7 +1,6 @@  #include - -#include "RTLibInterface.h" +#include using namespace rtl; diff --git a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_char.cpp b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_char.cpp index 5acfa96e..d8d5da7a 100644 --- a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_char.cpp +++ b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_char.cpp @@ -1,7 +1,6 @@  #include - -#include "RTLibInterface.h" +#include using namespace rtl; diff --git a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_int.cpp b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_int.cpp index 57b8cd6c..6abb91e8 100644 --- a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_int.cpp +++ b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_int.cpp @@ -1,7 +1,6 @@  #include - -#include "RTLibInterface.h" +#include using namespace rtl; diff --git a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdSharedPtr.cpp b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdSharedPtr.cpp index 5b71d321..6a483e8d 100644 --- a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdSharedPtr.cpp +++ b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdSharedPtr.cpp @@ -1,9 +1,9 @@ #include #include +#include #include "Node.h" -#include "RTLibInterface.h" using namespace test_utils; using namespace rtl; diff --git a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdUniquePtr.cpp b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdUniquePtr.cpp index 5ff37e92..a43a8cd9 100644 --- a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdUniquePtr.cpp +++ b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_stdUniquePtr.cpp @@ -1,9 +1,9 @@ #include #include +#include #include "Node.h" -#include "RTLibInterface.h" using namespace test_utils; using namespace rtl; diff --git a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_strings.cpp b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_strings.cpp index 21d27632..c3ff3713 100644 --- a/RTLTestRunApp/src/RObjectTests/RObjectReflecting_strings.cpp +++ b/RTLTestRunApp/src/RObjectTests/RObjectReflecting_strings.cpp @@ -1,7 +1,6 @@ #include - -#include "RTLibInterface.h" +#include using namespace rtl; diff --git a/ReflectionTemplateLib/CMakeLists.txt b/ReflectionTemplateLib/CMakeLists.txt index 894d02b8..24defcf1 100644 --- a/ReflectionTemplateLib/CMakeLists.txt +++ b/ReflectionTemplateLib/CMakeLists.txt @@ -1,8 +1,5 @@ -# CMakeLists.txt for ReflectionTemplateLib - cmake_minimum_required(VERSION 3.20) -# Project definition project(ReflectionTemplateLib LANGUAGES CXX) # Require C++20 @@ -10,19 +7,21 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -# Library target +# Library target (static or shared) add_library(${PROJECT_NAME} STATIC) -# Public include directories +# Public include paths for this library target_include_directories(${PROJECT_NAME} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/common - ${CMAKE_CURRENT_SOURCE_DIR}/detail/inc - ${CMAKE_CURRENT_SOURCE_DIR}/access/inc - ${CMAKE_CURRENT_SOURCE_DIR}/builder/inc + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/rtl/builder + ${CMAKE_CURRENT_SOURCE_DIR}/rtl/cache + ${CMAKE_CURRENT_SOURCE_DIR}/rtl/detail + ${CMAKE_CURRENT_SOURCE_DIR}/rtl/dispatch + ${CMAKE_CURRENT_SOURCE_DIR}/rtl/registry + ${CMAKE_CURRENT_SOURCE_DIR}/rtl/inc + ${CMAKE_CURRENT_SOURCE_DIR}/rtl ) -# Add subdirectories for sources -add_subdirectory(detail/src) -add_subdirectory(access/src) -add_subdirectory(builder) \ No newline at end of file +# Add subdirectories +add_subdirectory(rtl) \ No newline at end of file diff --git a/ReflectionTemplateLib/access/src/CMakeLists.txt b/ReflectionTemplateLib/access/src/CMakeLists.txt deleted file mode 100644 index c8935285..00000000 --- a/ReflectionTemplateLib/access/src/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Create a variable containing the source files for your target -set(LOCAL_SOURCES - "${CMAKE_CURRENT_LIST_DIR}/CxxMirror.cpp" - "${CMAKE_CURRENT_LIST_DIR}/CxxMirrorToJson.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Function.cpp" -) - -SET(COMMON_HEADERS - - "${PROJECT_SOURCE_DIR}/common/view.h" - "${PROJECT_SOURCE_DIR}/common/view.hpp" - "${PROJECT_SOURCE_DIR}/common/Constants.h" - "${PROJECT_SOURCE_DIR}/common/rtl_traits.h" - "${PROJECT_SOURCE_DIR}/common/error_codes.h" - "${PROJECT_SOURCE_DIR}/common/forward_decls.h" - "${PROJECT_SOURCE_DIR}/common/ConversionUtils.h" - "${PROJECT_SOURCE_DIR}/common/RTLibInterface.h" -) - -SET(LOCAL_HEADERS - "${PROJECT_SOURCE_DIR}/access/inc/CxxMirror.h" - "${PROJECT_SOURCE_DIR}/access/inc/CxxMirror.hpp" - "${PROJECT_SOURCE_DIR}/access/inc/CxxMirrorToJson.h" - "${PROJECT_SOURCE_DIR}/access/inc/Function.h" - "${PROJECT_SOURCE_DIR}/access/inc/Function.hpp" - "${PROJECT_SOURCE_DIR}/access/inc/Method.h" - "${PROJECT_SOURCE_DIR}/access/inc/Method.hpp" - "${PROJECT_SOURCE_DIR}/access/inc/Record.h" - "${PROJECT_SOURCE_DIR}/access/inc/RObject.h" - "${PROJECT_SOURCE_DIR}/access/inc/RObject.hpp" -) - -# Add any additional source files if needed -target_sources(ReflectionTemplateLib - PRIVATE - "${LOCAL_HEADERS}" - "${COMMON_HEADERS}" - "${LOCAL_SOURCES}" -) - - -SOURCE_GROUP("Source Files\\Access" FILES ${LOCAL_SOURCES}) -SOURCE_GROUP("Header Files\\Access" FILES ${LOCAL_HEADERS}) \ No newline at end of file diff --git a/ReflectionTemplateLib/builder/CMakeLists.txt b/ReflectionTemplateLib/builder/CMakeLists.txt deleted file mode 100644 index 379e654e..00000000 --- a/ReflectionTemplateLib/builder/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Create a variable containing the source files for your target - -SET(COMMON_HEADERS - "${PROJECT_SOURCE_DIR}/common/rtl_traits.h" - "${PROJECT_SOURCE_DIR}/common/error_codes.h" - "${PROJECT_SOURCE_DIR}/common/forward_decls.h" -) - -SET(LOCAL_HEADERS - "${CMAKE_CURRENT_LIST_DIR}/inc/ConstructorBuilder.h" - "${CMAKE_CURRENT_LIST_DIR}/inc/Builder.h" - "${CMAKE_CURRENT_LIST_DIR}/inc/Builder.hpp" - "${CMAKE_CURRENT_LIST_DIR}/inc/RecordBuilder.h" - "${CMAKE_CURRENT_LIST_DIR}/inc/RecordBuilder.hpp" - "${CMAKE_CURRENT_LIST_DIR}/inc/Reflect.h" - "${CMAKE_CURRENT_LIST_DIR}/inc/Reflect.hpp" -) - -# Add any additional source files if needed -target_sources(ReflectionTemplateLib - PRIVATE - "${LOCAL_HEADERS}" - "${COMMON_HEADERS}" -) - -SOURCE_GROUP("Header Files\\Builder" FILES ${LOCAL_HEADERS}) \ No newline at end of file diff --git a/ReflectionTemplateLib/common/rtl_debug.hpp b/ReflectionTemplateLib/common/rtl_debug.hpp deleted file mode 100644 index 4d2b4739..00000000 --- a/ReflectionTemplateLib/common/rtl_debug.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -// #include - -#ifdef RTL_DEBUG - -// Runs arbitrary code safely in Debug builds (single-statement safe) -#define RTL_DEBUG_ONLY(code) do { code } while(0) - -// Simple debug log -// #define RTL_LOG(msg) do { std::cout << "[RTL-DEBUG] " << msg << '\n'; } while(0) - -// Exception-free assert: if condition fails, prints message and returns error code -// #define RTL_ASSERT(cond, err_code) do { \ -// if (!(cond)) { \ -// std::cerr << "[RTL-ASSERT] " #cond " failed!\n"; \ -// return err_code; \ -// } \ -// } while(0) - -#else - -// Release builds: completely stripped out -#define RTL_DEBUG_ONLY(code) do {} while(0) -// #define RTL_LOG(msg) do {} while(0) -// #define RTL_ASSERT(cond, err_code) do {} while(0) - -#endif diff --git a/ReflectionTemplateLib/detail/inc/FunctorCache.h b/ReflectionTemplateLib/detail/inc/FunctorCache.h deleted file mode 100644 index 1a89a0cd..00000000 --- a/ReflectionTemplateLib/detail/inc/FunctorCache.h +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include "Constants.h" -#include "FunctorRegistry.h" - - -namespace rtl::detail -{ - template - struct functor_cache; -} - -namespace rtl::detail -{ - template<> - struct functor_cache - { - template - static functor_registry& get() - { - static functor_registry functors; - return functors; - } - }; - - template<> - struct functor_cache - { - template - static functor_registry_m& get() - { - static functor_registry_m functors; - return functors; - } - }; - - template<> - struct functor_cache - { - template - static functor_registry_m& get() - { - static functor_registry_m functors; - return functors; - } - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/FunctorRegistry.h b/ReflectionTemplateLib/detail/inc/FunctorRegistry.h deleted file mode 100644 index 8ef91ea8..00000000 --- a/ReflectionTemplateLib/detail/inc/FunctorRegistry.h +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include - -#include "Constants.h" -#include "forward_decls.h" - - -namespace rtl::detail -{ - class functor_hop {}; -} - - -namespace rtl::detail -{ - template - class functor_registry: public functor_hop - { - using functor_t = return_t(*)(signature_ts...); - - std::vector> m_functors; - - public: - - const std::vector>& get() { - return m_functors; - } - - functor_t operator[](std::size_t index) { - return m_functors[index].first; - } - - void push(functor_t fptr, std::size_t lambda_index) { - m_functors.emplace_back(fptr, lambda_index); - } - - std::pair find(functor_t fptr) - { - //linear search, efficient for small set. - for (int index = 0; index < m_functors.size(); index++) { - if (m_functors[index].first == fptr) { - return { index, m_functors[index].second }; - } - } - return { rtl::index_none, rtl::index_none }; - } - }; -} - - -namespace rtl::detail -{ - template - class functor_registry_m; - - template - class functor_registry_m : public functor_hop - { - using functor_t = return_t(record_t::*)(signature_ts...); - - std::vector> m_functors; - - public: - - const std::vector>& get() { - return m_functors; - } - - - functor_t operator[](std::size_t index) { - return m_functors[index].first; - } - - void push(functor_t fptr, std::size_t lambda_index) { - m_functors.emplace_back(fptr, lambda_index); - } - - std::pair find(functor_t fptr) - { - //linear search, efficient for small set. - for (int index = 0; index < m_functors.size(); index++) { - if (m_functors[index].first == fptr) { - return { index, m_functors[index].second }; - } - } - return { rtl::index_none, rtl::index_none }; - } - }; -} - - -namespace rtl::detail -{ - template - class functor_registry_m : public functor_hop - { - using functor_t = return_t(record_t::*)(signature_ts...) const; - - std::vector> m_functors; - - public: - - const std::vector>& get() { - return m_functors; - } - - functor_t operator[](std::size_t index) { - return m_functors[index].first; - } - - void push(functor_t fptr, std::size_t lambda_index) { - m_functors.emplace_back(fptr, lambda_index); - } - - std::pair find(functor_t fptr) - { - //linear search, efficient for small set. - for (int index = 0; index < m_functors.size(); index++) { - if (m_functors[index].first == fptr) { - return { index, m_functors[index].second }; - } - } - return { rtl::index_none, rtl::index_none }; - } - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/LambdaCache.h b/ReflectionTemplateLib/detail/inc/LambdaCache.h deleted file mode 100644 index 8c5daa5c..00000000 --- a/ReflectionTemplateLib/detail/inc/LambdaCache.h +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include "LambdaRegistry.h" - - -namespace rtl::detail -{ - template - struct lambda_cache; -} - -namespace rtl::detail -{ - template<> - struct lambda_cache - { - template - static lambda_registry& get() - { - static lambda_registry registry; - return registry; - } - }; - - - template<> - struct lambda_cache - { - template - static lambda_registry& get() - { - static lambda_registry registry; - return registry; - } - }; - - - template<> - struct lambda_cache - { - template - static lambda_registry& get() - { - static lambda_registry registry; - return registry; - } - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/LambdaRegistry.h b/ReflectionTemplateLib/detail/inc/LambdaRegistry.h deleted file mode 100644 index 58b15385..00000000 --- a/ReflectionTemplateLib/detail/inc/LambdaRegistry.h +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include "LambdaBridge.h" - -#include -#include -#include - -#include "TypeId.h" -#include "Constants.h" -#include "FunctorRegistry.h" - - -namespace rtl::detail -{ - class lambda_hop { - public: - - std::size_t m_signatureId = TypeId<>::None; - std::vector m_argsId; - }; -} - - -namespace rtl::detail -{ - template - class lambda_registry; - - template - class lambda_registry : public lambda_hop - { - using lambda_t = std::function; - - std::vector lambda_table; - - std::vector m_functors; - - public: - - lambda_registry() - { - m_signatureId = TypeId>::get(); - TypeId::get(m_argsId); - } - - GETTER_CREF(std::vector, , lambda_table) - - void push(const lambda_t& lambda) - { - lambda_table.push_back(lambda); - } - - Return operator()(std::size_t index, signature_ts&&...params) - { - return lambda_table[index](m_functors[index], index, std::forward(params)...); - } - }; - - - template - class lambda_registry : public lambda_hop - { - using lambda_t = std::function ; - - std::vector lambda_table; - - std::vector m_functors; - - public: - - lambda_registry() - { - m_signatureId = TypeId>::get(); - TypeId::get(m_argsId); - } - - GETTER_CREF(std::vector, , lambda_table) - - void push(const lambda_t& lambda) - { - lambda_table.push_back(lambda); - } - - Return operator()(std::size_t index, signature_ts&&...params) - { - return lambda_table[index](m_functors[index], index, std::forward(params)...); - } - }; - - - template - class lambda_registry : public lambda_hop - { - using lambda_t = std::function ; - - std::vector lambda_table; - - std::vector m_functors; - - public: - - lambda_registry() - { - m_signatureId = TypeId>::get(); - TypeId::get(m_argsId); - } - - GETTER_CREF(std::vector, , lambda_table) - - void push(const lambda_t& lambda) - { - lambda_table.push_back(lambda); - } - - Return operator()(std::size_t index, signature_ts&&...params) - { - return lambda_table[index](m_functors[index], index, std::forward(params)...); - } - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/src/CMakeLists.txt b/ReflectionTemplateLib/detail/src/CMakeLists.txt deleted file mode 100644 index d5f37592..00000000 --- a/ReflectionTemplateLib/detail/src/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -# Create a variable containing the source files for your target -set(LOCAL_SOURCES - "${CMAKE_CURRENT_LIST_DIR}/CxxReflection.cpp" - "${CMAKE_CURRENT_LIST_DIR}/ReflectCast.cpp" - "${CMAKE_CURRENT_LIST_DIR}/RObjectConverters_string.cpp" -) - - -SET(COMMON_HEADERS - - "${PROJECT_SOURCE_DIR}/common/rtl_traits.h" - "${PROJECT_SOURCE_DIR}/common/error_codes.h" - "${PROJECT_SOURCE_DIR}/common/forward_decls.h" -) - -SET(LOCAL_HEADERS - - "${PROJECT_SOURCE_DIR}/detail/inc/LambdaCache.h" - "${PROJECT_SOURCE_DIR}/detail/inc/FunctorCache.h" - "${PROJECT_SOURCE_DIR}/detail/inc/LambdaBridge.h" - "${PROJECT_SOURCE_DIR}/detail/inc/LambdaRegistry.h" - "${PROJECT_SOURCE_DIR}/detail/inc/FunctorRegistry.h" - "${PROJECT_SOURCE_DIR}/detail/inc/CallReflector.h" - "${PROJECT_SOURCE_DIR}/detail/inc/CxxReflection.h" - "${PROJECT_SOURCE_DIR}/detail/inc/FunctionCaller.h" - "${PROJECT_SOURCE_DIR}/detail/inc/FunctionCaller.hpp" - "${PROJECT_SOURCE_DIR}/detail/inc/MethodInvoker.h" - "${PROJECT_SOURCE_DIR}/detail/inc/MethodInvoker.hpp" - "${PROJECT_SOURCE_DIR}/detail/inc/FunctorContainer.h" - "${PROJECT_SOURCE_DIR}/detail/inc/FunctorId.h" - "${PROJECT_SOURCE_DIR}/detail/inc/RObjectId.h" - "${PROJECT_SOURCE_DIR}/detail/inc/MethodContainer.h" - "${PROJECT_SOURCE_DIR}/detail/inc/ReflectCast.h" - "${PROJECT_SOURCE_DIR}/detail/inc/ReflectCast.hpp" - "${PROJECT_SOURCE_DIR}/detail/inc/ReflectCastUtil.h" - "${PROJECT_SOURCE_DIR}/detail/inc/ReflectionBuilder.h" - "${PROJECT_SOURCE_DIR}/detail/inc/ReflectionBuilder.hpp" - "${PROJECT_SOURCE_DIR}/detail/inc/SetupConstructor.h" - "${PROJECT_SOURCE_DIR}/detail/inc/SetupConstructor.hpp" - "${PROJECT_SOURCE_DIR}/detail/inc/SetupFunction.h" - "${PROJECT_SOURCE_DIR}/detail/inc/SetupFunction.hpp" - "${PROJECT_SOURCE_DIR}/detail/inc/SetupMethod.h" - "${PROJECT_SOURCE_DIR}/detail/inc/SetupMethod.hpp" - "${PROJECT_SOURCE_DIR}/detail/inc/TypeId.h" - "${PROJECT_SOURCE_DIR}/detail/inc/RObjectUPtr.h" - "${PROJECT_SOURCE_DIR}/detail/inc/RObjExtracter.h" - "${PROJECT_SOURCE_DIR}/detail/inc/RObjectBuilder.h" - "${PROJECT_SOURCE_DIR}/detail/inc/RObjectBuilder.hpp" -) - - -# Add any additional source files if needed -target_sources(ReflectionTemplateLib - PRIVATE - "${LOCAL_HEADERS}" - "${LOCAL_SOURCES}" -) - - -SOURCE_GROUP("Source Files\\Detail" FILES ${LOCAL_SOURCES}) -SOURCE_GROUP("Header Files\\Detail" FILES ${LOCAL_HEADERS}) \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/CMakeLists.txt b/ReflectionTemplateLib/rtl/CMakeLists.txt new file mode 100644 index 00000000..0f97298d --- /dev/null +++ b/ReflectionTemplateLib/rtl/CMakeLists.txt @@ -0,0 +1,21 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/rtl/CMakeLists.txt + +# Top-level headers in rtl/ (absolute paths) +set(LOCAL_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/rtl.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_constants.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_errors.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_traits.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_typeid.h" +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) +source_group("Header Files\\RTL" FILES ${LOCAL_HEADERS}) + +# Add subdirectories +add_subdirectory(inc) +add_subdirectory(src) +add_subdirectory(builder) +add_subdirectory(cache) +add_subdirectory(detail) +add_subdirectory(dispatch) \ No newline at end of file diff --git a/ReflectionTemplateLib/builder/inc/Builder.h b/ReflectionTemplateLib/rtl/builder/Builder.h similarity index 100% rename from ReflectionTemplateLib/builder/inc/Builder.h rename to ReflectionTemplateLib/rtl/builder/Builder.h diff --git a/ReflectionTemplateLib/builder/inc/Builder.hpp b/ReflectionTemplateLib/rtl/builder/Builder.hpp similarity index 99% rename from ReflectionTemplateLib/builder/inc/Builder.hpp rename to ReflectionTemplateLib/rtl/builder/Builder.hpp index ee74df9c..a343fbd8 100644 --- a/ReflectionTemplateLib/builder/inc/Builder.hpp +++ b/ReflectionTemplateLib/rtl/builder/Builder.hpp @@ -11,7 +11,7 @@ #pragma once -#include "TypeId.h" +#include "rtl_typeid.h" #include "Builder.h" #include "ReflectionBuilder.hpp" diff --git a/ReflectionTemplateLib/rtl/builder/CMakeLists.txt b/ReflectionTemplateLib/rtl/builder/CMakeLists.txt new file mode 100644 index 00000000..03414d6b --- /dev/null +++ b/ReflectionTemplateLib/rtl/builder/CMakeLists.txt @@ -0,0 +1,27 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/builder/CMakeLists.txt + +# Collect all headers in builder/ (absolute paths) +set(LOCAL_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/Builder.h" + "${CMAKE_CURRENT_SOURCE_DIR}/Builder.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/ConstructorBuilder.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FunctorContainer.h" + "${CMAKE_CURRENT_SOURCE_DIR}/MethodContainer.h" + "${CMAKE_CURRENT_SOURCE_DIR}/RecordBuilder.h" + "${CMAKE_CURRENT_SOURCE_DIR}/RecordBuilder.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Reflect.h" + "${CMAKE_CURRENT_SOURCE_DIR}/Reflect.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/ReflectionBuilder.h" + "${CMAKE_CURRENT_SOURCE_DIR}/ReflectionBuilder.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/RObjectBuilder.h" + "${CMAKE_CURRENT_SOURCE_DIR}/RObjectBuilder.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/SetupConstructor.h" + "${CMAKE_CURRENT_SOURCE_DIR}/SetupConstructor.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/SetupFunction.h" + "${CMAKE_CURRENT_SOURCE_DIR}/SetupFunction.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/SetupMethod.h" + "${CMAKE_CURRENT_SOURCE_DIR}/SetupMethod.hpp" +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) +source_group("Header Files\\Builder" FILES ${LOCAL_HEADERS}) \ No newline at end of file diff --git a/ReflectionTemplateLib/builder/inc/ConstructorBuilder.h b/ReflectionTemplateLib/rtl/builder/ConstructorBuilder.h similarity index 99% rename from ReflectionTemplateLib/builder/inc/ConstructorBuilder.h rename to ReflectionTemplateLib/rtl/builder/ConstructorBuilder.h index 94e4ba3f..5031b02e 100644 --- a/ReflectionTemplateLib/builder/inc/ConstructorBuilder.h +++ b/ReflectionTemplateLib/rtl/builder/ConstructorBuilder.h @@ -11,7 +11,7 @@ #pragma once -#include "Constants.h" +#include "rtl_constants.h" namespace rtl { diff --git a/ReflectionTemplateLib/detail/inc/FunctorContainer.h b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h similarity index 84% rename from ReflectionTemplateLib/detail/inc/FunctorContainer.h rename to ReflectionTemplateLib/rtl/builder/FunctorContainer.h index 73afd576..2ecfbf4c 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorContainer.h +++ b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h @@ -15,8 +15,8 @@ #include #include -#include "LambdaCache.h" -#include "Constants.h" +#include "lambda_cache.h" +#include "rtl_constants.h" #include "CallReflector.h" #include "SetupFunction.h" #include "SetupConstructor.h" @@ -74,27 +74,21 @@ namespace rtl { pGetIndex (lambda providing index if the functor is already registered) pUpdate (lambda updating the already registered functors/ctor/d'tor set) @return: index of newly added or already existing lambda in vector 'm_functors'. - */ static std::pair pushBack(const FunctionLambda& pFunctor, - std::function pGetIndex, - std::function pUpdate) + */ static std::size_t pushBack(const FunctionLambda& pFunctor, + std::function pGetIndex, + std::function pUpdate) { //critical section, thread safe. static std::mutex mtx; std::lock_guard lock(mtx); - auto& lamdba_store = lambda_cache::get<_signature...>(); std::size_t index = pGetIndex(); - - if (index == rtl::index_none) - { - index = lamdba_store.get().size(); - - lamdba_store.push(pFunctor); - getFunctorTable().push_back(pFunctor); - + if (index == rtl::index_none) { + index = getFunctorTable().size(); pUpdate(index); + getFunctorTable().push_back(pFunctor); } - return { index, &lamdba_store }; + return index; } //friends :) diff --git a/ReflectionTemplateLib/detail/inc/MethodContainer.h b/ReflectionTemplateLib/rtl/builder/MethodContainer.h similarity index 77% rename from ReflectionTemplateLib/detail/inc/MethodContainer.h rename to ReflectionTemplateLib/rtl/builder/MethodContainer.h index 9d8a53f8..0a84ffd6 100644 --- a/ReflectionTemplateLib/detail/inc/MethodContainer.h +++ b/ReflectionTemplateLib/rtl/builder/MethodContainer.h @@ -15,7 +15,7 @@ #include #include -#include "Constants.h" +#include "rtl_constants.h" #include "CallReflector.h" #include "SetupMethod.h" @@ -44,8 +44,6 @@ namespace rtl { public: - using lambda_t = detail::lambda_registry; - //every MethodContainer will have a unique-id. static std::size_t getContainerId() { //holds unique-id @@ -78,31 +76,24 @@ namespace rtl { /* @method: pushBack @params: pFunctor (lambda containing non-const-member-function functor call) - pGetIndex (lambda providing index if the functor is already registered) + pGetIndex (lambda providing lambdaIndex if the functor is already registered) pUpdate (lambda updating the already registered functors set) - @return: index of newly added or already existing lambda in vector 'm_methodPtrs'. - */ static std::pair pushBack(const MethodLambda& pFunctor, - std::function pGetIndex, - std::function pUpdateIndex) + @return: lambdaIndex of newly added or already existing lambda in vector 'm_methodPtrs'. + */ static std::size_t pushBack(const MethodLambda& pFunctor, + std::function pGetIndex, + std::function pUpdateIndex) { //critical section, thread safe. static std::mutex mtx; std::lock_guard lock(mtx); std::size_t index = pGetIndex(); - auto& lamdba_store = lambda_cache::get<_signature...>(); - - if (index == rtl::index_none) - { - index = lamdba_store.get().size(); - - lamdba_store.push(pFunctor); - - getFunctorTable().push_back(pFunctor); - + if (index == rtl::index_none) { + index = getFunctorTable().size(); pUpdateIndex(index); + getFunctorTable().push_back(pFunctor); } - return { index, &lamdba_store }; + return index; } //friends :) @@ -126,8 +117,6 @@ namespace rtl { public: - using lambda_t = detail::lambda_registry; - //every MethodContainer will have a unique-id. FORCE_INLINE static std::size_t getContainerId() { //holds unique-id @@ -160,31 +149,24 @@ namespace rtl { /* @method: pushBack @params: pFunctor (lambda containing const-member-function functor call) - pGetIndex (lambda providing index if the functor is already registered) + pGetIndex (lambda providing lambdaIndex if the functor is already registered) pUpdate (lambda updating the already registered functors set) - @return: index of newly added or already existing lambda in vector 'm_methodPtrs'. - */ static std::pair pushBack(const MethodLambda& pFunctor, - std::function pGetIndex, - std::function pUpdateIndex) + @return: lambdaIndex of newly added or already existing lambda in vector 'm_methodPtrs'. + */ static std::size_t pushBack(const MethodLambda& pFunctor, + std::function pGetIndex, + std::function pUpdateIndex) { //critical section, thread safe. static std::mutex mtx; std::lock_guard lock(mtx); - auto& lamdba_store = lambda_cache::get<_signature...>(); std::size_t index = pGetIndex(); - - if (index == rtl::index_none) - { - index = lamdba_store.get().size(); - - lamdba_store.push(pFunctor); - - getFunctorTable().push_back(pFunctor); - + if (index == rtl::index_none) { + index = getFunctorTable().size(); pUpdateIndex(index); + getFunctorTable().push_back(pFunctor); } - return { index, &lamdba_store }; + return index; } //friends :) diff --git a/ReflectionTemplateLib/detail/inc/RObjectBuilder.h b/ReflectionTemplateLib/rtl/builder/RObjectBuilder.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/RObjectBuilder.h rename to ReflectionTemplateLib/rtl/builder/RObjectBuilder.h diff --git a/ReflectionTemplateLib/detail/inc/RObjectBuilder.hpp b/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp similarity index 100% rename from ReflectionTemplateLib/detail/inc/RObjectBuilder.hpp rename to ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp diff --git a/ReflectionTemplateLib/builder/inc/RecordBuilder.h b/ReflectionTemplateLib/rtl/builder/RecordBuilder.h similarity index 100% rename from ReflectionTemplateLib/builder/inc/RecordBuilder.h rename to ReflectionTemplateLib/rtl/builder/RecordBuilder.h diff --git a/ReflectionTemplateLib/builder/inc/RecordBuilder.hpp b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp similarity index 100% rename from ReflectionTemplateLib/builder/inc/RecordBuilder.hpp rename to ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp diff --git a/ReflectionTemplateLib/builder/inc/Reflect.h b/ReflectionTemplateLib/rtl/builder/Reflect.h similarity index 99% rename from ReflectionTemplateLib/builder/inc/Reflect.h rename to ReflectionTemplateLib/rtl/builder/Reflect.h index e187d34b..3d7f37e8 100644 --- a/ReflectionTemplateLib/builder/inc/Reflect.h +++ b/ReflectionTemplateLib/rtl/builder/Reflect.h @@ -12,7 +12,7 @@ #pragma once #include -#include "Constants.h" +#include "rtl_constants.h" #include "Builder.h" namespace rtl::builder diff --git a/ReflectionTemplateLib/builder/inc/Reflect.hpp b/ReflectionTemplateLib/rtl/builder/Reflect.hpp similarity index 100% rename from ReflectionTemplateLib/builder/inc/Reflect.hpp rename to ReflectionTemplateLib/rtl/builder/Reflect.hpp diff --git a/ReflectionTemplateLib/detail/inc/ReflectionBuilder.h b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/ReflectionBuilder.h rename to ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h diff --git a/ReflectionTemplateLib/detail/inc/ReflectionBuilder.hpp b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp similarity index 100% rename from ReflectionTemplateLib/detail/inc/ReflectionBuilder.hpp rename to ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp diff --git a/ReflectionTemplateLib/detail/inc/SetupConstructor.h b/ReflectionTemplateLib/rtl/builder/SetupConstructor.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/SetupConstructor.h rename to ReflectionTemplateLib/rtl/builder/SetupConstructor.h diff --git a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp b/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp similarity index 87% rename from ReflectionTemplateLib/detail/inc/SetupConstructor.hpp rename to ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp index e3ca1fb5..a090b24f 100644 --- a/ReflectionTemplateLib/detail/inc/SetupConstructor.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp @@ -25,9 +25,6 @@ namespace rtl::detail { return [](const FunctorId& pFunctorId, alloc pAllocType, const FunctorId& pClonerId, _signature&&...params)-> Return { - std::size_t signatureId = TypeId...>>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - if constexpr (sizeof...(_signature) == 0 && !std::is_default_constructible_v<_recordType>) { //default constructor, private or deleted. return { error::TypeNotDefaultConstructible, RObject{} }; @@ -75,9 +72,6 @@ namespace rtl::detail { return [](const FunctorId& pFunctorId, const RObject& pOther, alloc pAllocOn) -> Return { - std::size_t signatureId = TypeId>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - const auto& srcObj = pOther.view<_recordType>()->get(); switch (pAllocOn) { @@ -103,9 +97,6 @@ namespace rtl::detail { return [](const FunctorId& pFunctorId, const RObject& pOther, alloc pAllocOn) -> Return { - std::size_t signatureId = TypeId>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - return { error::TypeNotCopyConstructible, RObject{} @@ -146,18 +137,23 @@ namespace rtl::detail return (itr != ctorSet.end() ? itr->second : index_none); }; + //auto& lambdaCache = lambda_cache::get<_signature...>(); + //const auto& pushLambdaHopper = [&]()-> std::size_t + //{ + // return lambdaCache.push_ctor<_recordType>(); + //}; + //add the lambda in 'FunctorContainer'. - auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); + auto lambdaIndex = _derivedType::pushBack(getConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); return detail::FunctorId { lambdaIndex, - rtl::index_none, returnId, recordId, containerId, _derivedType::template getSignatureStr<_recordType>(true), - lambdaPtr + nullptr//&lambdaCache }; } @@ -185,18 +181,22 @@ namespace rtl::detail return (itr != ctorSet.end() ? itr->second : index_none); }; - //add the lambda in 'FunctorContainer'. - auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getCopyConstructorCaller<_recordType>(), getIndex, updateIndex); + //auto& lambdaCache = lambda_cache::get<_signature...>(); + //const auto& pushLambdaHopper = [&]()-> std::size_t + //{ + // return lambdaCache.push_cloner<_recordType>(); + //}; + //add the lambda in 'FunctorContainer'. + auto lambdaIndex = _derivedType::pushBack(getCopyConstructorCaller<_recordType>(), getIndex, updateIndex); return detail::FunctorId { lambdaIndex, - rtl::index_none, returnId, recordId, containerId, _derivedType::template getSignatureStr<_recordType>(true), - lambdaPtr + nullptr//&lambdaCache }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.h b/ReflectionTemplateLib/rtl/builder/SetupFunction.h similarity index 97% rename from ReflectionTemplateLib/detail/inc/SetupFunction.h rename to ReflectionTemplateLib/rtl/builder/SetupFunction.h index d8ef3a24..bdcad635 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.h +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.h @@ -11,8 +11,7 @@ #pragma once -#include "FunctorId.h" -#include "FunctorRegistry.h" +#include "forward_decls.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp similarity index 83% rename from ReflectionTemplateLib/detail/inc/SetupFunction.hpp rename to ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 9390ee3b..c3a80b2d 100644 --- a/ReflectionTemplateLib/detail/inc/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -13,7 +13,8 @@ #include -#include "FunctorCache.h" +#include "lambda_cache.h" +#include "functor_cache.h" #include "SetupFunction.h" #include "RObjectBuilder.hpp" @@ -28,9 +29,6 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - std::size_t signatureId = TypeId...>>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; }; @@ -48,9 +46,6 @@ namespace rtl { constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); - std::size_t signatureId = TypeId...>>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - if constexpr (std::is_reference_v<_returnType>) { /* if the function returns reference, this block will be retained by compiler. Note: reference to temporary or dangling is not checked here. @@ -87,39 +82,42 @@ namespace rtl template inline const detail::FunctorId SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) { - auto& functorCache = functor_cache::get<_returnType, _signature...>(); - std::size_t functorIndex = rtl::index_none; + auto& functorCache = functor_cache<_returnType, _signature...>::get(); // called from '_derivedType' ('FunctorContainer') const auto& updateIndex = [&](std::size_t pIndex)-> void { - functorIndex = functorCache.get().size(); + //functorIndex = functorCache.get().size(); functorCache.push(pFunctor, pIndex); }; // called from '_derivedType' ('FunctorContainer') const auto& getIndex = [&]()-> std::size_t { - auto [functor_i, lambda_i] = functorCache.find(pFunctor); - functorIndex = functor_i; - return lambda_i; + std::size_t lambda_index = functorCache.find(pFunctor); + return lambda_index; }; + //auto& lambdaCache = lambda_cache::get<_signature...>(); + //const auto& pushLambdaHopper = [&]()-> std::size_t + //{ + // return lambdaCache.push_function<_returnType>(); + //}; + //generate a type-id of '_returnType'. const std::size_t returnId = TypeId>::get(); //finally add the lambda 'functor' in 'FunctorContainer' lambda vector and get the index. - auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); + auto lambdaIndex = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { lambdaIndex, - functorIndex, returnId, pRecordId, _derivedType::getContainerId(), _derivedType::template getSignatureStr<_returnType>(), - lambdaPtr + nullptr//&lambdaCache }; } } diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.h b/ReflectionTemplateLib/rtl/builder/SetupMethod.h similarity index 98% rename from ReflectionTemplateLib/detail/inc/SetupMethod.h rename to ReflectionTemplateLib/rtl/builder/SetupMethod.h index 1e08fc9e..768bcff4 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.h +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.h @@ -11,8 +11,7 @@ #pragma once -#include "FunctorId.h" -#include "FunctorRegistry.h" +#include "forward_decls.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp similarity index 81% rename from ReflectionTemplateLib/detail/inc/SetupMethod.hpp rename to ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 90f6d9bb..8b791d0b 100644 --- a/ReflectionTemplateLib/detail/inc/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -14,10 +14,11 @@ #include #include "view.h" -#include "TypeId.h" +#include "rtl_typeid.h" #include "SetupMethod.h" #include "RObjectBuilder.hpp" -#include "FunctorCache.h" +#include "functor_cache_const.h" +#include "functor_cache_nonconst.h" namespace rtl::detail { @@ -30,15 +31,6 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - std::size_t signatureId = TypeId...>>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - - //using lambda_t = lambda_registry...>; - - //lambda_t registry = static_cast(pFunctorId.m_lambda); - - //registry-> - if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; } @@ -59,9 +51,6 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - std::size_t signatureId = TypeId...>>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; } @@ -103,9 +92,6 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - std::size_t signatureId = TypeId...>>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - const _recordType& target = pTargetObj.view<_recordType>()->get(); (target.*pFunctor)(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -122,9 +108,6 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - std::size_t signatureId = TypeId...>>::get(); - assert((pFunctorId.m_lambda->m_signatureId == signatureId) && "Type resolution system failed!"); - constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); //'target' is const and 'pFunctor' is const-member-function. const _recordType& target = pTargetObj.view<_recordType>()->get(); @@ -165,56 +148,59 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { - auto& functorCache = functor_cache::get<_recordType, _returnType, _signature...>(); - std::size_t functorIndex = rtl::index_none; + auto& functorCache = functor_cache_nonconst<_recordType, _returnType, _signature...>::get(); // called from '_derivedType' (MethodContainer) const auto& updateIndex = [&](std::size_t pIndex)->void { - functorIndex = functorCache.get().size(); functorCache.push(pFunctor, pIndex); }; // called from '_derivedType' (MethodContainer) const auto& getIndex = [&]()-> std::size_t { - auto [functor_i, lambda_i] = functorCache.find(pFunctor); - functorIndex = functor_i; - return lambda_i; + std::size_t lambdaIndex = functorCache.find(pFunctor); + return lambdaIndex; }; + //auto& lambdaCache = lambda_cache::get<_signature...>(); + //const auto& pushLambdaHopper = [&]() + //{ + // std::size_t lambdaIndex = lambdaCache.get().size(); + // lambdaCache.push(); + // return lambdaIndex; + //}; + //generate a type-id of '_returnType'. const std::size_t retTypeId = TypeId>::get(); //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. if constexpr (std::is_same_v<_returnType, void>) { - auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { + return detail::FunctorId{ lambdaIndex, - functorIndex, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - lambdaPtr + nullptr }; } else { - auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { lambdaIndex, - functorIndex, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - lambdaPtr + nullptr }; } } @@ -234,57 +220,62 @@ namespace rtl::detail inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) { - auto& functorCache = functor_cache::get<_recordType, _returnType, _signature...>(); - std::size_t functorIndex = rtl::index_none; + auto& functorCache = functor_cache_const<_recordType, _returnType, _signature...>::get(); + + //std::size_t functorIndex = rtl::index_none; // called from '_derivedType' (MethodContainer) const auto& updateIndex = [&](std::size_t pIndex)-> void { - functorIndex = functorCache.get().size(); + //functorIndex = functorCache.get().size(); functorCache.push(pFunctor, pIndex); }; // called from '_derivedType' (MethodContainer) const auto& getIndex = [&]()-> std::size_t { - auto [functor_i, lambda_i] = functorCache.find(pFunctor); - functorIndex = functor_i; - return lambda_i; + std::size_t lambdaIndex = functorCache.find(pFunctor); + return lambdaIndex; }; + //auto& lambdaCache = lambda_cache::get<_signature...>(); + //const auto& pushLambdaHopper = [&]() { + // std::size_t lambdaIndex = lambdaCache.get().size(); + // lambdaCache.push(); + // return lambdaIndex; + //}; + //generate a type-id of '_returnType'. const std::size_t retTypeId = TypeId>::get(); //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. if constexpr (std::is_same_v<_returnType, void>) { - auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. return detail::FunctorId { - lambdaIndex, - functorIndex, + lambdaIndex, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - lambdaPtr + nullptr//&lambdaCache }; } else { - auto [lambdaIndex, lambdaPtr] = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { + return detail::FunctorId{ lambdaIndex, - functorIndex, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - lambdaPtr + nullptr// &lambdaCache }; } } diff --git a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt new file mode 100644 index 00000000..bd77a74f --- /dev/null +++ b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt @@ -0,0 +1,12 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/cache/CMakeLists.txt + +# Collect headers (absolute paths) +set(LOCAL_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_cache.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache_nonconst.h" +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) +source_group("Header Files\\Cache" FILES ${LOCAL_HEADERS}) \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache.h b/ReflectionTemplateLib/rtl/cache/functor_cache.h new file mode 100644 index 00000000..32ef06d1 --- /dev/null +++ b/ReflectionTemplateLib/rtl/cache/functor_cache.h @@ -0,0 +1,61 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "functor.h" + +namespace rtl::detail +{ + template + struct functor_cache + { + using fptr_t = return_t(*)(signature_ts...); + using functor_t = dispatch::functor; + + static functor_cache& get() + { + static functor_cache instance; + return instance; + } + + const dispatch::functor_hop* push(const functor_t& functor, std::size_t lambda_index) + { + m_cache.emplace_back(std::make_pair(functor, lambda_index)); + return &(m_cache.back().first); + } + + std::size_t find(fptr_t fptr) + { + for (auto& itr : m_cache) + { + const auto& functor = itr.first; + if (fptr == functor.get()) { + return itr.second; + } + } + return rtl::index_none; + } + + functor_cache(functor_cache&&) = delete; + functor_cache(const functor_cache&) = delete; + functor_cache& operator=(functor_cache&&) = delete; + functor_cache& operator=(const functor_cache&) = delete; + + private: + + // No reallocation occurs; original objects stay intact + std::deque> m_cache; + functor_cache() {} + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h b/ReflectionTemplateLib/rtl/cache/functor_cache_const.h new file mode 100644 index 00000000..534d30cf --- /dev/null +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_const.h @@ -0,0 +1,61 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "functor_const.h" + +namespace rtl::detail +{ + template + struct functor_cache_const + { + using fptr_t = return_t(record_t::*)(signature_ts...) const; + using functor_t = dispatch::functor_const; + + static functor_cache_const& get() + { + static functor_cache_const instance; + return instance; + } + + const dispatch::functor_hop* push(const functor_t& functor, std::size_t lambda_index) + { + m_cache.emplace_back(std::make_pair(functor, lambda_index)); + return &(m_cache.back().first); + } + + std::size_t find(fptr_t fptr) + { + for (auto& itr : m_cache) + { + const auto& functor = itr.first; + if (fptr == functor.get()) { + return itr.second; + } + } + return rtl::index_none; + } + + functor_cache_const(functor_cache_const&&) = delete; + functor_cache_const(const functor_cache_const&) = delete; + functor_cache_const& operator=(functor_cache_const&&) = delete; + functor_cache_const& operator=(const functor_cache_const&) = delete; + + private: + + // No reallocation occurs; original objects stay intact + std::deque> m_cache; + functor_cache_const() {} + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h new file mode 100644 index 00000000..3b9ba13d --- /dev/null +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h @@ -0,0 +1,61 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "functor_nonconst.h" + +namespace rtl::detail +{ + template + struct functor_cache_nonconst + { + using fptr_t = return_t(record_t::*)(signature_ts...); + using functor_t = typename dispatch::functor_nonconst; + + static functor_cache_nonconst& get() + { + static functor_cache_nonconst instance; + return instance; + } + + const dispatch::functor_hop* push(const functor_t& functor, std::size_t lambda_index) + { + m_cache.emplace_back(std::make_pair(functor, lambda_index)); + return &(m_cache.back().first); + } + + std::size_t find(fptr_t fptr) + { + for (auto& itr : m_cache) + { + const auto& functor = itr.first; + if (fptr == functor.get()) { + return itr.second; + } + } + return rtl::index_none; + } + + functor_cache_nonconst(functor_cache_nonconst&&) = delete; + functor_cache_nonconst(const functor_cache_nonconst&) = delete; + functor_cache_nonconst& operator=(functor_cache_nonconst&&) = delete; + functor_cache_nonconst& operator=(const functor_cache_nonconst&) = delete; + + private: + + // No reallocation occurs; original objects stay intact + std::deque> m_cache; + functor_cache_nonconst() {} + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/lambda_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_cache.h new file mode 100644 index 00000000..4a37b970 --- /dev/null +++ b/ReflectionTemplateLib/rtl/cache/lambda_cache.h @@ -0,0 +1,45 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "lambda.h" + +namespace rtl::detail +{ + template + struct lambda_cache + { + static lambda_cache& get() { + static lambda_cache instance; + return instance; + } + + std::pair push(const dispatch::lambda& lambda_hop) + { + m_cache.push_back(lambda_hop); + return { (m_cache.size() - 1), &m_cache.back() }; + } + + lambda_cache(lambda_cache&&) = delete; + lambda_cache(const lambda_cache&) = delete; + lambda_cache& operator=(lambda_cache&&) = delete; + lambda_cache& operator=(const lambda_cache&) = delete; + + private: + + // No reallocation occurs; original objects stay intact + std::deque> m_cache; + lambda_cache() {} + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/CMakeLists.txt b/ReflectionTemplateLib/rtl/detail/CMakeLists.txt new file mode 100644 index 00000000..c99483ce --- /dev/null +++ b/ReflectionTemplateLib/rtl/detail/CMakeLists.txt @@ -0,0 +1,10 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/detail/CMakeLists.txt + +# Make the 'inc' folder visible as a public include dir +target_include_directories(ReflectionTemplateLib + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) + +add_subdirectory(inc) +add_subdirectory(src) \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt b/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt new file mode 100644 index 00000000..343cfb2f --- /dev/null +++ b/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt @@ -0,0 +1,18 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/detail/inc/CMakeLists.txt + +# All headers in this folder (absolute paths) +set(LOCAL_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/ConversionUtils.h" + "${CMAKE_CURRENT_SOURCE_DIR}/CxxReflection.h" + "${CMAKE_CURRENT_SOURCE_DIR}/forward_decls.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FunctorId.h" + "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.h" + "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCastUtil.h" + "${CMAKE_CURRENT_SOURCE_DIR}/RObjectId.h" + "${CMAKE_CURRENT_SOURCE_DIR}/RObjectUPtr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/RObjExtracter.h" +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) +source_group("Header Files\\Detail" FILES ${LOCAL_HEADERS}) \ No newline at end of file diff --git a/ReflectionTemplateLib/common/ConversionUtils.h b/ReflectionTemplateLib/rtl/detail/inc/ConversionUtils.h similarity index 100% rename from ReflectionTemplateLib/common/ConversionUtils.h rename to ReflectionTemplateLib/rtl/detail/inc/ConversionUtils.h diff --git a/ReflectionTemplateLib/detail/inc/CxxReflection.h b/ReflectionTemplateLib/rtl/detail/inc/CxxReflection.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/CxxReflection.h rename to ReflectionTemplateLib/rtl/detail/inc/CxxReflection.h diff --git a/ReflectionTemplateLib/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h similarity index 93% rename from ReflectionTemplateLib/detail/inc/FunctorId.h rename to ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index de0f7a89..501c083a 100644 --- a/ReflectionTemplateLib/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -11,13 +11,12 @@ #pragma once -#include "TypeId.h" -#include "Constants.h" +#include "rtl_typeid.h" +#include "rtl_constants.h" +#include "forward_decls.h" namespace rtl::detail { - class lambda_hop; - /* @class: FunctorId * 'FunctorId' object is generated for every functor (member/non-member function pointer) registered. * acts as a hash-key to lookup a particular functor in the functor-table. @@ -30,8 +29,6 @@ namespace rtl::detail //index of the functor in the functor-table. std::size_t m_lambdaIndex; - std::size_t m_functorIndex; - //return type-id of the functor registered. std::size_t m_returnId; @@ -47,7 +44,6 @@ namespace rtl::detail lambda_hop* m_lambda = nullptr; GETTER(std::size_t, LambdaIndex, m_lambdaIndex) - GETTER(std::size_t, FunctorIndex, m_functorIndex) GETTER(std::size_t, ReturnId, m_returnId); GETTER(std::size_t, RecordId, m_recordId); GETTER(std::size_t, SignatureId, m_containerId) @@ -77,7 +73,6 @@ namespace rtl::detail m_recordId == pOther.m_recordId && m_containerId == pOther.m_containerId && m_lambdaIndex == pOther.m_lambdaIndex && - m_functorIndex == pOther.m_functorIndex && m_signature == pOther.m_signature); } }; diff --git a/ReflectionTemplateLib/detail/inc/RObjExtracter.h b/ReflectionTemplateLib/rtl/detail/inc/RObjExtracter.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/RObjExtracter.h rename to ReflectionTemplateLib/rtl/detail/inc/RObjExtracter.h diff --git a/ReflectionTemplateLib/detail/inc/RObjectId.h b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/RObjectId.h rename to ReflectionTemplateLib/rtl/detail/inc/RObjectId.h diff --git a/ReflectionTemplateLib/detail/inc/RObjectUPtr.h b/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/RObjectUPtr.h rename to ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h diff --git a/ReflectionTemplateLib/detail/inc/ReflectCast.h b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/ReflectCast.h rename to ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h diff --git a/ReflectionTemplateLib/detail/inc/ReflectCast.hpp b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.hpp similarity index 99% rename from ReflectionTemplateLib/detail/inc/ReflectCast.hpp rename to ReflectionTemplateLib/rtl/detail/inc/ReflectCast.hpp index 85b405aa..78e32745 100644 --- a/ReflectionTemplateLib/detail/inc/ReflectCast.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.hpp @@ -11,7 +11,7 @@ #pragma once -#include "TypeId.h" +#include "rtl_typeid.h" #include "ReflectCast.h" #include "ConversionUtils.h" diff --git a/ReflectionTemplateLib/detail/inc/ReflectCastUtil.h b/ReflectionTemplateLib/rtl/detail/inc/ReflectCastUtil.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/ReflectCastUtil.h rename to ReflectionTemplateLib/rtl/detail/inc/ReflectCastUtil.h diff --git a/ReflectionTemplateLib/common/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h similarity index 91% rename from ReflectionTemplateLib/common/forward_decls.h rename to ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index cf60c39a..1370c224 100644 --- a/ReflectionTemplateLib/common/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -11,6 +11,8 @@ #pragma once +#include "rtl_constants.h" + namespace rtl { struct Return; @@ -19,6 +21,10 @@ namespace rtl namespace detail { + struct lambda_hop; + + struct functor_hop; + struct FunctorId; template diff --git a/ReflectionTemplateLib/rtl/detail/src/CMakeLists.txt b/ReflectionTemplateLib/rtl/detail/src/CMakeLists.txt new file mode 100644 index 00000000..668c6728 --- /dev/null +++ b/ReflectionTemplateLib/rtl/detail/src/CMakeLists.txt @@ -0,0 +1,11 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/detail/src/CMakeLists.txt + +# All .cpp files in this folder (absolute paths) +set(LOCAL_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/CxxReflection.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/RObjectConverters_string.cpp" +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_SOURCES}) +source_group("Source Files\\Detail" FILES ${LOCAL_SOURCES}) \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/src/CxxReflection.cpp b/ReflectionTemplateLib/rtl/detail/src/CxxReflection.cpp similarity index 99% rename from ReflectionTemplateLib/detail/src/CxxReflection.cpp rename to ReflectionTemplateLib/rtl/detail/src/CxxReflection.cpp index 762974c7..cfc2683c 100644 --- a/ReflectionTemplateLib/detail/src/CxxReflection.cpp +++ b/ReflectionTemplateLib/rtl/detail/src/CxxReflection.cpp @@ -12,7 +12,7 @@ #include #include -#include "TypeId.h" +#include "rtl_typeid.h" #include "Record.h" #include "Method.h" #include "CxxReflection.h" diff --git a/ReflectionTemplateLib/detail/src/RObjectConverters_string.cpp b/ReflectionTemplateLib/rtl/detail/src/RObjectConverters_string.cpp similarity index 99% rename from ReflectionTemplateLib/detail/src/RObjectConverters_string.cpp rename to ReflectionTemplateLib/rtl/detail/src/RObjectConverters_string.cpp index 8e8363a3..67355763 100644 --- a/ReflectionTemplateLib/detail/src/RObjectConverters_string.cpp +++ b/ReflectionTemplateLib/rtl/detail/src/RObjectConverters_string.cpp @@ -9,7 +9,7 @@ *************************************************************************/ -#include "TypeId.h" +#include "rtl_typeid.h" #include "ReflectCast.hpp" #include diff --git a/ReflectionTemplateLib/detail/src/ReflectCast.cpp b/ReflectionTemplateLib/rtl/detail/src/ReflectCast.cpp similarity index 100% rename from ReflectionTemplateLib/detail/src/ReflectCast.cpp rename to ReflectionTemplateLib/rtl/detail/src/ReflectCast.cpp diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt new file mode 100644 index 00000000..6fa05029 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -0,0 +1,27 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/dispatch/CMakeLists.txt + +# Collect headers in this folder (absolute paths) +set(LOCAL_HEADERS + + "${CMAKE_CURRENT_SOURCE_DIR}/dispatch_interface.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor_nonconst.h" + + "${CMAKE_CURRENT_SOURCE_DIR}/lambda.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_ctor.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_copy_ctor.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method_const.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method_nonconst.hpp" + + "${CMAKE_CURRENT_SOURCE_DIR}/CallReflector.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FunctionCaller.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FunctionCaller.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/MethodInvoker.h" + "${CMAKE_CURRENT_SOURCE_DIR}/MethodInvoker.hpp" + +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) +source_group("Header Files\\Dispatch" FILES ${LOCAL_HEADERS}) \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/CallReflector.h b/ReflectionTemplateLib/rtl/dispatch/CallReflector.h similarity index 99% rename from ReflectionTemplateLib/detail/inc/CallReflector.h rename to ReflectionTemplateLib/rtl/dispatch/CallReflector.h index 20ad94a4..4940eb8f 100644 --- a/ReflectionTemplateLib/detail/inc/CallReflector.h +++ b/ReflectionTemplateLib/rtl/dispatch/CallReflector.h @@ -13,7 +13,7 @@ #include #include "RObject.h" -#include "Constants.h" +#include "rtl_constants.h" #include "FunctorId.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/dispatch/FunctionCaller.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/FunctionCaller.h rename to ReflectionTemplateLib/rtl/dispatch/FunctionCaller.h diff --git a/ReflectionTemplateLib/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/dispatch/FunctionCaller.hpp similarity index 100% rename from ReflectionTemplateLib/detail/inc/FunctionCaller.hpp rename to ReflectionTemplateLib/rtl/dispatch/FunctionCaller.hpp diff --git a/ReflectionTemplateLib/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/dispatch/MethodInvoker.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/MethodInvoker.h rename to ReflectionTemplateLib/rtl/dispatch/MethodInvoker.h diff --git a/ReflectionTemplateLib/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/dispatch/MethodInvoker.hpp similarity index 100% rename from ReflectionTemplateLib/detail/inc/MethodInvoker.hpp rename to ReflectionTemplateLib/rtl/dispatch/MethodInvoker.hpp diff --git a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h new file mode 100644 index 00000000..a9eeae00 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h @@ -0,0 +1,80 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "rtl_typeid.h" +#include "rtl_constants.h" + +namespace rtl::dispatch +{ + struct functor_hop; + + template + struct lambda; + + struct lambda_hop + { + const functor_hop* m_functor = nullptr; + + std::vector m_argsTypeIds; + std::size_t m_signatureId = detail::TypeId<>::None; + + template + const lambda& get() const + { + return (*static_cast*>(this)); + } + }; +} + + +namespace rtl::dispatch +{ + template + struct functor; + + template + struct functor_const; + + template + struct functor_nonconst; + + struct functor_hop + { + const lambda_hop* m_lambda = nullptr; + + std::size_t m_recordId = detail::TypeId<>::None; + std::size_t m_returnId = detail::TypeId<>::None; + std::size_t m_signatureId = detail::TypeId<>::None; + detail::methodQ m_qualifier = detail::methodQ::None; + + template + const functor& get() const + { + return *(static_cast*>(this)); + } + + template + const functor_const& get_const() const + { + return *(static_cast*>(this)); + } + + template + const functor_nonconst& get_nonconst() const + { + return *(static_cast*>(this)); + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h new file mode 100644 index 00000000..5164719d --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -0,0 +1,43 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "dispatch_interface.h" + +namespace rtl::dispatch +{ + template + struct functor: public functor_hop + { + using fptr_t = return_t(*)(signature_ts...); + + fptr_t get() const + { + return m_functor; + } + + return_t operator()(signature_ts&&...params) const + { + return (*m_functor)(std::forward(params)...); + } + + functor(fptr_t fptr) :m_functor(fptr) + { + m_returnId = detail::TypeId::get(); + m_signatureId = detail::TypeId>::get(); + } + + private: + + fptr_t m_functor; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_const.h b/ReflectionTemplateLib/rtl/dispatch/functor_const.h new file mode 100644 index 00000000..fff2d5ff --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/functor_const.h @@ -0,0 +1,45 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "dispatch_interface.h" + +namespace rtl::dispatch +{ + template + struct functor_const : public functor_hop + { + using fptr_t = return_t(record_t::*)(signature_ts...) const; + + fptr_t get() const + { + return m_functor; + } + + return_t operator()(const record_t& pTarget, signature_ts&&...params) const + { + return (pTarget.*m_functor)(std::forward(params)...); + } + + functor_const(fptr_t fptr) :m_functor(fptr) + { + m_returnId = detail::TypeId::get(); + m_signatureId = detail::TypeId>::get(); + } + + private: + + fptr_t m_functor; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h new file mode 100644 index 00000000..646eef67 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h @@ -0,0 +1,45 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "dispatch_interface.h" + +namespace rtl::dispatch +{ + template + struct functor_nonconst : public functor_hop + { + using fptr_t = return_t(record_t::*)(signature_ts...); + + fptr_t get() const + { + return m_functor; + } + + return_t operator()(record_t& pTarget, signature_ts&&...params) const + { + return (pTarget.*m_functor)(std::forward(params)...); + } + + functor_nonconst(fptr_t fptr) :m_functor(fptr) + { + m_returnId = detail::TypeId::get(); + m_signatureId = detail::TypeId>::get(); + } + + private: + + fptr_t m_functor; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h new file mode 100644 index 00000000..10a54382 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -0,0 +1,58 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include +#include + +#include "forward_decls.h" +#include "dispatch_interface.h" + +namespace rtl::dispatch +{ + template + struct lambda: public lambda_hop + { + using lambda_t = std::function; + + template + void init_ctor() const; + + template + void init_cloner() const; + + template + void init_function() const; + + template + void init_method_const() const; + + template + void init_method_nonconst() const; + + Return operator()(signature_ts&&...params) const + { + return m_hopper(this, std::forward(params)...); + } + + private: + + lambda(const functor_hop* fptr_hopper) + { + detail::TypeId::get(m_argsTypeIds); + m_signatureId = detail::TypeId>::get(); + m_functor = fptr_hopper; + } + + lambda_t m_hopper; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/detail/inc/LambdaBridge.h b/ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp similarity index 66% rename from ReflectionTemplateLib/detail/inc/LambdaBridge.h rename to ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp index b467bf49..dd8b664c 100644 --- a/ReflectionTemplateLib/detail/inc/LambdaBridge.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp @@ -11,23 +11,16 @@ #pragma once -#include "forward_decls.h" -#include "FunctorId.h" -#include "FunctorRegistry.h" +#include "lambda.h" +#include "RObjectBuilder.hpp" -namespace rtl::detail::bridge +namespace rtl::dispatch { - template - struct lambda_def - { - template - static auto get() - { - return [](const FunctorId& functorId, signature_ts&&...params)-> Return - { - return { error::None, RObject{} }; - }; - } - }; + template + template + inline void lambda::init_cloner() const + { + + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp new file mode 100644 index 00000000..e864c2f7 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp @@ -0,0 +1,25 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "lambda.h" +#include "RObjectBuilder.hpp" + +namespace rtl::dispatch +{ + template + template + inline void lambda::init_ctor() const + { + + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp new file mode 100644 index 00000000..bd980c3f --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp @@ -0,0 +1,70 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "lambda.h" +#include "RObjectBuilder.hpp" + +namespace rtl::dispatch +{ + template + template + inline void lambda::init_function() const + { + if constexpr (std::is_same_v) + { + m_hopper = [](const lambda_hop* hopper, signature_ts&&... params) -> Return + { + auto& functor = hopper->m_functor->get(); + + functor(std::forward(params)...); + + return{ error::None, RObject{} }; + }; + } + else + { + m_hopper = [](const lambda_hop* hopper, signature_ts&&...params) -> Return + { + auto& functor = hopper->m_functor->get(); + + constexpr bool isConstCastSafe = (!traits::is_const_v); + if constexpr (std::is_reference_v) + { + using T = traits::raw_t; + const T& retObj = functor(std::forward(params)...); + + return{ error::None, + builder::RObjectBuilder::template build( + &retObj, + std::nullopt, + isConstCastSafe) + }; + } + else { + + auto&& retObj = functor(std::forward(params)...); + using T = std::remove_cvref_t; + + return{ error::None, + builder::RObjectBuilder::template build( + std::forward(retObj), + std::nullopt, + isConstCastSafe) + }; + } + }; + } + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp new file mode 100644 index 00000000..d6c1a39e --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp @@ -0,0 +1,25 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "lambda.h" +#include "RObjectBuilder.hpp" + +namespace rtl::dispatch +{ + template + template + inline void lambda::init_method_const() const + { + + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp new file mode 100644 index 00000000..9203bfd7 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp @@ -0,0 +1,24 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "lambda.h" + +namespace rtl::dispatch +{ + template + template + inline void lambda::init_method_nonconst() const + { + + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/CMakeLists.txt b/ReflectionTemplateLib/rtl/inc/CMakeLists.txt new file mode 100644 index 00000000..1896bc2f --- /dev/null +++ b/ReflectionTemplateLib/rtl/inc/CMakeLists.txt @@ -0,0 +1,20 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/rtl/inc/CMakeLists.txt + +# Collect local headers (absolute paths) +set(LOCAL_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/CxxMirror.h" + "${CMAKE_CURRENT_SOURCE_DIR}/CxxMirror.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/CxxMirrorToJson.h" + "${CMAKE_CURRENT_SOURCE_DIR}/Function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/Function.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/Method.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Record.h" + "${CMAKE_CURRENT_SOURCE_DIR}/RObject.h" + "${CMAKE_CURRENT_SOURCE_DIR}/RObject.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/view.h" + "${CMAKE_CURRENT_SOURCE_DIR}/view.hpp" +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) +source_group("Header Files\\RTL" FILES ${LOCAL_HEADERS}) \ No newline at end of file diff --git a/ReflectionTemplateLib/access/inc/CxxMirror.h b/ReflectionTemplateLib/rtl/inc/CxxMirror.h similarity index 100% rename from ReflectionTemplateLib/access/inc/CxxMirror.h rename to ReflectionTemplateLib/rtl/inc/CxxMirror.h diff --git a/ReflectionTemplateLib/access/inc/CxxMirror.hpp b/ReflectionTemplateLib/rtl/inc/CxxMirror.hpp similarity index 100% rename from ReflectionTemplateLib/access/inc/CxxMirror.hpp rename to ReflectionTemplateLib/rtl/inc/CxxMirror.hpp diff --git a/ReflectionTemplateLib/access/inc/CxxMirrorToJson.h b/ReflectionTemplateLib/rtl/inc/CxxMirrorToJson.h similarity index 100% rename from ReflectionTemplateLib/access/inc/CxxMirrorToJson.h rename to ReflectionTemplateLib/rtl/inc/CxxMirrorToJson.h diff --git a/ReflectionTemplateLib/access/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h similarity index 99% rename from ReflectionTemplateLib/access/inc/Function.h rename to ReflectionTemplateLib/rtl/inc/Function.h index 88192f05..768ba5cf 100644 --- a/ReflectionTemplateLib/access/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -16,7 +16,7 @@ #include #include "FunctorId.h" -#include "Constants.h" +#include "rtl_constants.h" #include "FunctionCaller.h" namespace rtl { diff --git a/ReflectionTemplateLib/access/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp similarity index 100% rename from ReflectionTemplateLib/access/inc/Function.hpp rename to ReflectionTemplateLib/rtl/inc/Function.hpp diff --git a/ReflectionTemplateLib/access/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h similarity index 100% rename from ReflectionTemplateLib/access/inc/Method.h rename to ReflectionTemplateLib/rtl/inc/Method.h diff --git a/ReflectionTemplateLib/access/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp similarity index 100% rename from ReflectionTemplateLib/access/inc/Method.hpp rename to ReflectionTemplateLib/rtl/inc/Method.hpp diff --git a/ReflectionTemplateLib/access/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h similarity index 99% rename from ReflectionTemplateLib/access/inc/RObject.h rename to ReflectionTemplateLib/rtl/inc/RObject.h index 86ded7c0..58f5fc10 100644 --- a/ReflectionTemplateLib/access/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -16,8 +16,9 @@ #include #include "view.h" -#include "TypeId.h" #include "RObjectId.h" + +#include "rtl_typeid.h" #include "rtl_traits.h" diff --git a/ReflectionTemplateLib/access/inc/RObject.hpp b/ReflectionTemplateLib/rtl/inc/RObject.hpp similarity index 97% rename from ReflectionTemplateLib/access/inc/RObject.hpp rename to ReflectionTemplateLib/rtl/inc/RObject.hpp index c692e8ef..51091c24 100644 --- a/ReflectionTemplateLib/access/inc/RObject.hpp +++ b/ReflectionTemplateLib/rtl/inc/RObject.hpp @@ -199,7 +199,7 @@ namespace rtl if (m_objectId.m_clonerId.has_value()) { const detail::FunctorId& functorId = m_objectId.m_clonerId.value(); - return traits::Cloner::forwardCall(functorId, *this, alloc::Heap); + return traits::Cloner::template forwardCall(functorId, *this, alloc::Heap); } return { error::CloningDisabled, RObject{} }; } @@ -211,7 +211,7 @@ namespace rtl if (m_objectId.m_clonerId.has_value()) { const detail::FunctorId& functorId = m_objectId.m_clonerId.value(); - return traits::Cloner::forwardCall(functorId, *this, alloc::Stack); + return traits::Cloner::template forwardCall(functorId, *this, alloc::Stack); } return { error::CloningDisabled, RObject{} }; } diff --git a/ReflectionTemplateLib/access/inc/Record.h b/ReflectionTemplateLib/rtl/inc/Record.h similarity index 99% rename from ReflectionTemplateLib/access/inc/Record.h rename to ReflectionTemplateLib/rtl/inc/Record.h index e081b37c..b6d9fb81 100644 --- a/ReflectionTemplateLib/access/inc/Record.h +++ b/ReflectionTemplateLib/rtl/inc/Record.h @@ -16,7 +16,7 @@ #include #include "Method.h" -#include "Constants.h" +#include "rtl_constants.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/common/view.h b/ReflectionTemplateLib/rtl/inc/view.h similarity index 100% rename from ReflectionTemplateLib/common/view.h rename to ReflectionTemplateLib/rtl/inc/view.h diff --git a/ReflectionTemplateLib/common/view.hpp b/ReflectionTemplateLib/rtl/inc/view.hpp similarity index 100% rename from ReflectionTemplateLib/common/view.hpp rename to ReflectionTemplateLib/rtl/inc/view.hpp diff --git a/ReflectionTemplateLib/common/RTLibInterface.h b/ReflectionTemplateLib/rtl/rtl.h similarity index 97% rename from ReflectionTemplateLib/common/RTLibInterface.h rename to ReflectionTemplateLib/rtl/rtl.h index 2f1cdd4d..d4185e61 100644 --- a/ReflectionTemplateLib/common/RTLibInterface.h +++ b/ReflectionTemplateLib/rtl/rtl.h @@ -87,8 +87,6 @@ /* * The root reflection container that aggregates all registrations. -* Users are expected to define a singleton CxxMirror that holds all -* records and functions: * * namespace cxx { * const rtl::CxxMirror& mirror() { diff --git a/ReflectionTemplateLib/common/Constants.h b/ReflectionTemplateLib/rtl/rtl_constants.h similarity index 99% rename from ReflectionTemplateLib/common/Constants.h rename to ReflectionTemplateLib/rtl/rtl_constants.h index d595fdc0..09e927c4 100644 --- a/ReflectionTemplateLib/common/Constants.h +++ b/ReflectionTemplateLib/rtl/rtl_constants.h @@ -11,7 +11,7 @@ #pragma once -#include "error_codes.h" +#include "rtl_errors.h" namespace rtl { diff --git a/ReflectionTemplateLib/common/error_codes.h b/ReflectionTemplateLib/rtl/rtl_errors.h similarity index 100% rename from ReflectionTemplateLib/common/error_codes.h rename to ReflectionTemplateLib/rtl/rtl_errors.h diff --git a/ReflectionTemplateLib/common/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h similarity index 99% rename from ReflectionTemplateLib/common/rtl_traits.h rename to ReflectionTemplateLib/rtl/rtl_traits.h index 257ef64a..d2ccb404 100644 --- a/ReflectionTemplateLib/common/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -19,8 +19,8 @@ #include #include -#include "TypeId.h" -#include "Constants.h" +#include "rtl_typeid.h" +#include "rtl_constants.h" #include "forward_decls.h" namespace rtl diff --git a/ReflectionTemplateLib/detail/inc/TypeId.h b/ReflectionTemplateLib/rtl/rtl_typeid.h similarity index 100% rename from ReflectionTemplateLib/detail/inc/TypeId.h rename to ReflectionTemplateLib/rtl/rtl_typeid.h diff --git a/ReflectionTemplateLib/rtl/src/CMakeLists.txt b/ReflectionTemplateLib/rtl/src/CMakeLists.txt new file mode 100644 index 00000000..22a75169 --- /dev/null +++ b/ReflectionTemplateLib/rtl/src/CMakeLists.txt @@ -0,0 +1,11 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/rtl/src/CMakeLists.txt + +# Collect local sources (absolute paths) +set(LOCAL_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/CxxMirror.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/CxxMirrorToJson.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Function.cpp" +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_SOURCES}) +source_group("Source Files\\RTL" FILES ${LOCAL_SOURCES}) \ No newline at end of file diff --git a/ReflectionTemplateLib/access/src/CxxMirror.cpp b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp similarity index 100% rename from ReflectionTemplateLib/access/src/CxxMirror.cpp rename to ReflectionTemplateLib/rtl/src/CxxMirror.cpp diff --git a/ReflectionTemplateLib/access/src/CxxMirrorToJson.cpp b/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp similarity index 94% rename from ReflectionTemplateLib/access/src/CxxMirrorToJson.cpp rename to ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp index 0143cd39..9905c356 100644 --- a/ReflectionTemplateLib/access/src/CxxMirrorToJson.cpp +++ b/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp @@ -27,12 +27,6 @@ static const std::string toJson(const FunctorId& pFunctorId) std::stringstream sout; sout << "{\"containerId\": \"" << std::to_string(pFunctorId.getSignatureId()) << "\","; sout << "\"lambdaIndex\": \"" << std::to_string(pFunctorId.getLambdaIndex()) << "\","; - if (pFunctorId.getFunctorIndex() != rtl::index_none) { - sout << "\"functorIndex\": \"" << std::to_string(pFunctorId.getFunctorIndex()) << "\","; - } - else { - sout << "\"functorIndex\": \"-1\","; - } if (pFunctorId.getRecordId() != TypeId<>::None) { sout << "\"recordId\": \"" << std::to_string(pFunctorId.getRecordId()) << "\","; } diff --git a/ReflectionTemplateLib/access/src/Function.cpp b/ReflectionTemplateLib/rtl/src/Function.cpp similarity index 100% rename from ReflectionTemplateLib/access/src/Function.cpp rename to ReflectionTemplateLib/rtl/src/Function.cpp From c03af5ff3b5c454adfaea05aee25e720ce28a485 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 18 Sep 2025 02:07:02 +0530 Subject: [PATCH 007/148] new dispatch-mechanism working, in-progress. --- RTLBenchmarkApp/src/ReflectedCall.cpp | 15 ++++++- RTLBenchmarkApp/src/ReflectedCall.h | 2 + RTLBenchmarkApp/src/main.cpp | 1 + .../rtl/builder/SetupConstructor.hpp | 6 --- .../rtl/builder/SetupFunction.hpp | 45 ++++++++++++------- .../rtl/builder/SetupMethod.hpp | 22 +-------- .../rtl/cache/functor_cache.h | 17 +++---- .../rtl/cache/functor_cache_const.h | 12 ++--- .../rtl/cache/functor_cache_nonconst.h | 14 +++--- .../rtl/cache/lambda_cache.h | 18 +++++--- .../rtl/detail/inc/FunctorId.h | 2 +- .../rtl/detail/inc/forward_decls.h | 11 +++-- .../rtl/dispatch/dispatch_interface.h | 26 ++++++++--- ReflectionTemplateLib/rtl/dispatch/functor.h | 2 +- .../rtl/dispatch/functor_const.h | 2 +- .../rtl/dispatch/functor_nonconst.h | 2 +- ReflectionTemplateLib/rtl/dispatch/lambda.h | 12 ++--- .../rtl/dispatch/lambda_function.hpp | 26 +++++------ ReflectionTemplateLib/rtl/rtl_traits.h | 2 + 19 files changed, 131 insertions(+), 106 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCall.cpp b/RTLBenchmarkApp/src/ReflectedCall.cpp index 4c2bf8ac..e62e3a11 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.cpp +++ b/RTLBenchmarkApp/src/ReflectedCall.cpp @@ -1,8 +1,8 @@ #include +#include #include "ReflectedCall.h" -#include #include "BenchMark.h" namespace cxx @@ -46,7 +46,7 @@ namespace static auto _test0 = []() { auto err = SendMessage(bm::g_longStr).err; - + if (err != rtl::error::None) { std::cout << "[1] error: "<< rtl::to_string(err)<<"\n"; } @@ -107,6 +107,17 @@ void ReflectedCall::get(benchmark::State& state) } } +void ReflectedCall::new_design_set(benchmark::State& state) +{ + static auto& hopper = (SendMessage.getFunctors()[0].m_lambda)->get(); + static bm::argStr_t&& argStr = bm::argStr_t(bm::g_longStr); + for (auto _ : state) { + + auto error = hopper(std::forward(argStr)).err; + benchmark::DoNotOptimize(error); + } +} + void ReflectedMethodCall::set(benchmark::State& state) { diff --git a/RTLBenchmarkApp/src/ReflectedCall.h b/RTLBenchmarkApp/src/ReflectedCall.h index 59416ca2..77b410c5 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.h +++ b/RTLBenchmarkApp/src/ReflectedCall.h @@ -7,6 +7,8 @@ struct ReflectedCall static void set(benchmark::State& state); static void get(benchmark::State& state); + + static void new_design_set(benchmark::State& state); }; diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index bcefd8d1..860bba04 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -10,6 +10,7 @@ BENCHMARK(NativeCall::set); BENCHMARK(StdFuncCall::set); BENCHMARK(ReflectedCall::set); +BENCHMARK(ReflectedCall::new_design_set); BENCHMARK(StdFuncMethodCall::set); BENCHMARK(ReflectedMethodCall::set); diff --git a/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp b/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp index a090b24f..bfa6a1cd 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp @@ -137,12 +137,6 @@ namespace rtl::detail return (itr != ctorSet.end() ? itr->second : index_none); }; - //auto& lambdaCache = lambda_cache::get<_signature...>(); - //const auto& pushLambdaHopper = [&]()-> std::size_t - //{ - // return lambdaCache.push_ctor<_recordType>(); - //}; - //add the lambda in 'FunctorContainer'. auto lambdaIndex = _derivedType::pushBack(getConstructorCaller<_recordType, _signature...>(), getIndex, updateIndex); diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index c3a80b2d..d01be707 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -15,6 +15,8 @@ #include "lambda_cache.h" #include "functor_cache.h" +#include "lambda_function.hpp" + #include "SetupFunction.h" #include "RObjectBuilder.hpp" @@ -29,6 +31,9 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { + bool isAmazing = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + assert(isAmazing && "new type-system corrupted."); + pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; }; @@ -44,6 +49,9 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { + bool isAmazing = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + assert(isAmazing && "new type-system corrupted."); + constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); if constexpr (std::is_reference_v<_returnType>) { @@ -82,42 +90,47 @@ namespace rtl template inline const detail::FunctorId SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) { - auto& functorCache = functor_cache<_returnType, _signature...>::get(); + const dispatch::lambda_hop* lambdaPtr = nullptr; - // called from '_derivedType' ('FunctorContainer') const auto& updateIndex = [&](std::size_t pIndex)-> void { - //functorIndex = functorCache.get().size(); - functorCache.push(pFunctor, pIndex); + auto& functorCache = dispatch::functor_cache<_returnType, _signature...>::get(); + + const dispatch::functor_hop* functor = functorCache.push(pFunctor, pIndex); + + auto& lambdaCache = dispatch::lambda_cache<_signature...>::get(); + + auto& lambda = lambdaCache.push(functor); + + lambda.init_function<_returnType>(); + + lambdaPtr = λ }; - // called from '_derivedType' ('FunctorContainer') const auto& getIndex = [&]()-> std::size_t { - std::size_t lambda_index = functorCache.find(pFunctor); - return lambda_index; + auto& functorCache = dispatch::functor_cache<_returnType, _signature...>::get(); + auto [functor, lambdaIndex] = functorCache.find(pFunctor); + if (lambdaIndex != rtl::index_none) { + lambdaPtr = functor->m_lambda; + } + return lambdaIndex; }; - //auto& lambdaCache = lambda_cache::get<_signature...>(); - //const auto& pushLambdaHopper = [&]()-> std::size_t - //{ - // return lambdaCache.push_function<_returnType>(); - //}; - //generate a type-id of '_returnType'. const std::size_t returnId = TypeId>::get(); //finally add the lambda 'functor' in 'FunctorContainer' lambda vector and get the index. auto lambdaIndex = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { - + return detail::FunctorId{ + lambdaIndex, returnId, pRecordId, _derivedType::getContainerId(), _derivedType::template getSignatureStr<_returnType>(), - nullptr//&lambdaCache + lambdaPtr }; } } diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 8b791d0b..6cc63e50 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -148,7 +148,7 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { - auto& functorCache = functor_cache_nonconst<_recordType, _returnType, _signature...>::get(); + auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _returnType, _signature...>::get(); // called from '_derivedType' (MethodContainer) const auto& updateIndex = [&](std::size_t pIndex)->void @@ -163,14 +163,6 @@ namespace rtl::detail return lambdaIndex; }; - //auto& lambdaCache = lambda_cache::get<_signature...>(); - //const auto& pushLambdaHopper = [&]() - //{ - // std::size_t lambdaIndex = lambdaCache.get().size(); - // lambdaCache.push(); - // return lambdaIndex; - //}; - //generate a type-id of '_returnType'. const std::size_t retTypeId = TypeId>::get(); //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. @@ -219,10 +211,7 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) { - - auto& functorCache = functor_cache_const<_recordType, _returnType, _signature...>::get(); - - //std::size_t functorIndex = rtl::index_none; + auto& functorCache = dispatch::functor_cache_const<_recordType, _returnType, _signature...>::get(); // called from '_derivedType' (MethodContainer) const auto& updateIndex = [&](std::size_t pIndex)-> void @@ -238,13 +227,6 @@ namespace rtl::detail return lambdaIndex; }; - //auto& lambdaCache = lambda_cache::get<_signature...>(); - //const auto& pushLambdaHopper = [&]() { - // std::size_t lambdaIndex = lambdaCache.get().size(); - // lambdaCache.push(); - // return lambdaIndex; - //}; - //generate a type-id of '_returnType'. const std::size_t retTypeId = TypeId>::get(); //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache.h b/ReflectionTemplateLib/rtl/cache/functor_cache.h index 32ef06d1..13fd39b7 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache.h @@ -11,17 +11,17 @@ #pragma once -#include +#include #include "functor.h" -namespace rtl::detail +namespace rtl::dispatch { template struct functor_cache { using fptr_t = return_t(*)(signature_ts...); - using functor_t = dispatch::functor; + using functor_t = functor; static functor_cache& get() { @@ -29,22 +29,22 @@ namespace rtl::detail return instance; } - const dispatch::functor_hop* push(const functor_t& functor, std::size_t lambda_index) + const functor_hop* push(const functor_t& functor, std::size_t lambda_index) { m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); } - std::size_t find(fptr_t fptr) + std::pair find(fptr_t fptr) { for (auto& itr : m_cache) { const auto& functor = itr.first; if (fptr == functor.get()) { - return itr.second; + return { &itr.first, itr.second }; } } - return rtl::index_none; + return { nullptr, rtl::index_none }; } functor_cache(functor_cache&&) = delete; @@ -55,7 +55,8 @@ namespace rtl::detail private: // No reallocation occurs; original objects stay intact - std::deque> m_cache; + std::list> m_cache; + functor_cache() {} }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h b/ReflectionTemplateLib/rtl/cache/functor_cache_const.h index 534d30cf..7d1af246 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_const.h @@ -11,17 +11,17 @@ #pragma once -#include +#include #include "functor_const.h" -namespace rtl::detail +namespace rtl::dispatch { template struct functor_cache_const { using fptr_t = return_t(record_t::*)(signature_ts...) const; - using functor_t = dispatch::functor_const; + using functor_t = functor_const; static functor_cache_const& get() { @@ -29,7 +29,7 @@ namespace rtl::detail return instance; } - const dispatch::functor_hop* push(const functor_t& functor, std::size_t lambda_index) + const functor_hop* push(const functor_t& functor, std::size_t lambda_index) { m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); @@ -47,6 +47,7 @@ namespace rtl::detail return rtl::index_none; } + functor_cache_const(functor_cache_const&&) = delete; functor_cache_const(const functor_cache_const&) = delete; functor_cache_const& operator=(functor_cache_const&&) = delete; @@ -55,7 +56,8 @@ namespace rtl::detail private: // No reallocation occurs; original objects stay intact - std::deque> m_cache; + std::list> m_cache; + functor_cache_const() {} }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h index 3b9ba13d..9c8f4b5c 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h @@ -11,25 +11,25 @@ #pragma once -#include +#include #include "functor_nonconst.h" -namespace rtl::detail +namespace rtl::dispatch { template struct functor_cache_nonconst { using fptr_t = return_t(record_t::*)(signature_ts...); - using functor_t = typename dispatch::functor_nonconst; - + using functor_t = typename functor_nonconst; + static functor_cache_nonconst& get() { static functor_cache_nonconst instance; return instance; } - const dispatch::functor_hop* push(const functor_t& functor, std::size_t lambda_index) + const functor_hop* push(const functor_t& functor, std::size_t lambda_index) { m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); @@ -47,6 +47,7 @@ namespace rtl::detail return rtl::index_none; } + functor_cache_nonconst(functor_cache_nonconst&&) = delete; functor_cache_nonconst(const functor_cache_nonconst&) = delete; functor_cache_nonconst& operator=(functor_cache_nonconst&&) = delete; @@ -55,7 +56,8 @@ namespace rtl::detail private: // No reallocation occurs; original objects stay intact - std::deque> m_cache; + std::list> m_cache; + functor_cache_nonconst() {} }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/lambda_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_cache.h index 4a37b970..7c011a7e 100644 --- a/ReflectionTemplateLib/rtl/cache/lambda_cache.h +++ b/ReflectionTemplateLib/rtl/cache/lambda_cache.h @@ -11,24 +11,27 @@ #pragma once -#include +#include #include "lambda.h" -namespace rtl::detail +namespace rtl::dispatch { template struct lambda_cache { - static lambda_cache& get() { + static lambda_cache& get() + { static lambda_cache instance; return instance; } - std::pair push(const dispatch::lambda& lambda_hop) + const lambda& push(const functor_hop* fptr_hopper) { - m_cache.push_back(lambda_hop); - return { (m_cache.size() - 1), &m_cache.back() }; + m_cache.push_back(lambda(fptr_hopper)); + const lambda& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; } lambda_cache(lambda_cache&&) = delete; @@ -39,7 +42,8 @@ namespace rtl::detail private: // No reallocation occurs; original objects stay intact - std::deque> m_cache; + std::list> m_cache; + lambda_cache() {} }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 501c083a..788827bb 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -41,7 +41,7 @@ namespace rtl::detail //signature of functor as string. platform dependent, may not be very much readable format. std::string m_signature; - lambda_hop* m_lambda = nullptr; + const dispatch::lambda_hop* m_lambda = nullptr; GETTER(std::size_t, LambdaIndex, m_lambdaIndex) GETTER(std::size_t, ReturnId, m_returnId); diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 1370c224..46404cb9 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -21,13 +21,16 @@ namespace rtl namespace detail { - struct lambda_hop; - - struct functor_hop; - struct FunctorId; template class FunctorContainer; } + + namespace dispatch + { + struct lambda_hop; + + struct functor_hop; + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h index a9eeae00..7ecb6723 100644 --- a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h +++ b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h @@ -13,6 +13,7 @@ #include +#include "rtl_traits.h" #include "rtl_typeid.h" #include "rtl_constants.h" @@ -25,15 +26,21 @@ namespace rtl::dispatch struct lambda_hop { + std::size_t m_signatureId = detail::TypeId<>::None; + + traits::args_t m_argumentsId = {}; + const functor_hop* m_functor = nullptr; - std::vector m_argsTypeIds; - std::size_t m_signatureId = detail::TypeId<>::None; + const functor_hop& functor() const + { + return *m_functor; + } template const lambda& get() const { - return (*static_cast*>(this)); + return (*static_cast*>(this)); } }; } @@ -52,29 +59,34 @@ namespace rtl::dispatch struct functor_hop { - const lambda_hop* m_lambda = nullptr; + mutable const lambda_hop* m_lambda = nullptr; std::size_t m_recordId = detail::TypeId<>::None; std::size_t m_returnId = detail::TypeId<>::None; std::size_t m_signatureId = detail::TypeId<>::None; detail::methodQ m_qualifier = detail::methodQ::None; + void set_lambda(const lambda_hop* lambda) const + { + m_lambda = lambda; + } + template const functor& get() const { - return *(static_cast*>(this)); + return *(static_cast*>(this)); } template const functor_const& get_const() const { - return *(static_cast*>(this)); + return *(static_cast*>(this)); } template const functor_nonconst& get_nonconst() const { - return *(static_cast*>(this)); + return *(static_cast*>(this)); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 5164719d..12782759 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -25,7 +25,7 @@ namespace rtl::dispatch return m_functor; } - return_t operator()(signature_ts&&...params) const + decltype(auto) operator()(signature_ts&&...params) const noexcept // TODO: handle exception. { return (*m_functor)(std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_const.h b/ReflectionTemplateLib/rtl/dispatch/functor_const.h index fff2d5ff..dea777bd 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_const.h @@ -27,7 +27,7 @@ namespace rtl::dispatch return m_functor; } - return_t operator()(const record_t& pTarget, signature_ts&&...params) const + decltype(auto) operator()(const record_t& pTarget, signature_ts&&...params) const noexcept // TODO: handle exception. { return (pTarget.*m_functor)(std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h index 646eef67..4ca1310a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h @@ -27,7 +27,7 @@ namespace rtl::dispatch return m_functor; } - return_t operator()(record_t& pTarget, signature_ts&&...params) const + decltype(auto) operator()(record_t& pTarget, signature_ts&&...params) const noexcept // TODO: handle exception. { return (pTarget.*m_functor)(std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 10a54382..6a05ef00 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -22,7 +22,7 @@ namespace rtl::dispatch template struct lambda: public lambda_hop { - using lambda_t = std::function; + using lambda_t = std::function; template void init_ctor() const; @@ -41,18 +41,18 @@ namespace rtl::dispatch Return operator()(signature_ts&&...params) const { - return m_hopper(this, std::forward(params)...); + return m_hopper(*this, std::forward(params)...); } - private: - lambda(const functor_hop* fptr_hopper) { - detail::TypeId::get(m_argsTypeIds); + detail::TypeId::get(m_argumentsId); m_signatureId = detail::TypeId>::get(); m_functor = fptr_hopper; } - lambda_t m_hopper; + private: + + mutable lambda_t m_hopper; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp index bd980c3f..9a919ff2 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp @@ -24,20 +24,20 @@ namespace rtl::dispatch { if constexpr (std::is_same_v) { - m_hopper = [](const lambda_hop* hopper, signature_ts&&... params) -> Return + m_hopper = [](const lambda_hop& hopper, signature_ts&&... params) noexcept -> Return { - auto& functor = hopper->m_functor->get(); + auto& functor = hopper.functor().get(); functor(std::forward(params)...); - return{ error::None, RObject{} }; + return { error::None, RObject{} }; }; } else { - m_hopper = [](const lambda_hop* hopper, signature_ts&&...params) -> Return + m_hopper = [](const lambda_hop& hopper, signature_ts&&...params) noexcept -> Return { - auto& functor = hopper->m_functor->get(); + auto& functor = hopper.functor().get(); constexpr bool isConstCastSafe = (!traits::is_const_v); if constexpr (std::is_reference_v) @@ -45,11 +45,9 @@ namespace rtl::dispatch using T = traits::raw_t; const T& retObj = functor(std::forward(params)...); - return{ error::None, - builder::RObjectBuilder::template build( - &retObj, - std::nullopt, - isConstCastSafe) + return { error::None, + detail::RObjectBuilder::template + build(&retObj, std::nullopt, isConstCastSafe) }; } else { @@ -57,11 +55,9 @@ namespace rtl::dispatch auto&& retObj = functor(std::forward(params)...); using T = std::remove_cvref_t; - return{ error::None, - builder::RObjectBuilder::template build( - std::forward(retObj), - std::nullopt, - isConstCastSafe) + return { error::None, + detail::RObjectBuilder::template + build(std::forward(retObj), std::nullopt, isConstCastSafe) }; } }; diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index d2ccb404..cc2d25a3 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -27,6 +27,8 @@ namespace rtl { namespace traits { + using args_t = std::vector; + using Converter = std::function< std::any(const std::any&, const detail::EntityKind&, detail::EntityKind&) >; using ConverterPair = std::pair< std::size_t, Converter >; From d0df22470331c964c9ecf5c13d5e9a9ffb6adb8b Mon Sep 17 00:00:00 2001 From: neeraj Date: Thu, 18 Sep 2025 02:17:18 +0530 Subject: [PATCH 008/148] fixed cland/gcc compile error --- ReflectionTemplateLib/rtl/builder/SetupFunction.hpp | 2 +- ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index d01be707..ea170d1c 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -102,7 +102,7 @@ namespace rtl auto& lambda = lambdaCache.push(functor); - lambda.init_function<_returnType>(); + lambda.template init_function<_returnType>(); lambdaPtr = λ }; diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h index 9c8f4b5c..b0f8a3cc 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h @@ -21,7 +21,7 @@ namespace rtl::dispatch struct functor_cache_nonconst { using fptr_t = return_t(record_t::*)(signature_ts...); - using functor_t = typename functor_nonconst; + using functor_t = functor_nonconst; static functor_cache_nonconst& get() { From 0fde83be0bfa36b0bc9a9975f8bdefda7036a836 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 18 Sep 2025 11:52:28 +0530 Subject: [PATCH 009/148] lambda refactored, std::function init with functor directly. --- RTLBenchmarkApp/src/ReflectedCall.cpp | 3 +- RTLBenchmarkApp/src/main.cpp | 2 +- .../rtl/builder/SetupFunction.hpp | 8 +-- .../rtl/cache/lambda_cache.h | 8 ++- ReflectionTemplateLib/rtl/dispatch/functor.h | 7 +-- ReflectionTemplateLib/rtl/dispatch/lambda.h | 54 +++++++++++++---- .../rtl/dispatch/lambda_copy_ctor.hpp | 4 +- .../rtl/dispatch/lambda_ctor.hpp | 4 +- .../rtl/dispatch/lambda_function.hpp | 59 ++++++++----------- .../rtl/dispatch/lambda_method_const.hpp | 4 +- .../rtl/dispatch/lambda_method_nonconst.hpp | 4 +- 11 files changed, 89 insertions(+), 68 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCall.cpp b/RTLBenchmarkApp/src/ReflectedCall.cpp index e62e3a11..d0225f3e 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.cpp +++ b/RTLBenchmarkApp/src/ReflectedCall.cpp @@ -110,10 +110,9 @@ void ReflectedCall::get(benchmark::State& state) void ReflectedCall::new_design_set(benchmark::State& state) { static auto& hopper = (SendMessage.getFunctors()[0].m_lambda)->get(); - static bm::argStr_t&& argStr = bm::argStr_t(bm::g_longStr); for (auto _ : state) { - auto error = hopper(std::forward(argStr)).err; + auto error = hopper(bm::g_longStr).err; benchmark::DoNotOptimize(error); } } diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index 860bba04..e2de9214 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -9,8 +9,8 @@ BENCHMARK(NativeCall::set); BENCHMARK(StdFuncCall::set); -BENCHMARK(ReflectedCall::set); BENCHMARK(ReflectedCall::new_design_set); +BENCHMARK(ReflectedCall::set); BENCHMARK(StdFuncMethodCall::set); BENCHMARK(ReflectedMethodCall::set); diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index ea170d1c..c949782b 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -31,8 +31,8 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - bool isAmazing = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); - assert(isAmazing && "new type-system corrupted."); + //bool isAmazing = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + //assert(isAmazing && "new type-system corrupted."); pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -100,9 +100,7 @@ namespace rtl auto& lambdaCache = dispatch::lambda_cache<_signature...>::get(); - auto& lambda = lambdaCache.push(functor); - - lambda.template init_function<_returnType>(); + auto& lambda = lambdaCache.template push_function<_returnType>(functor); lambdaPtr = λ }; diff --git a/ReflectionTemplateLib/rtl/cache/lambda_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_cache.h index 7c011a7e..9e0e1927 100644 --- a/ReflectionTemplateLib/rtl/cache/lambda_cache.h +++ b/ReflectionTemplateLib/rtl/cache/lambda_cache.h @@ -26,11 +26,15 @@ namespace rtl::dispatch return instance; } - const lambda& push(const functor_hop* fptr_hopper) + template + const lambda& push_function(const functor_hop* fptr_hopper) { - m_cache.push_back(lambda(fptr_hopper)); + m_cache.push_back(lambda::template create_function(fptr_hopper)); + const lambda& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; } diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 12782759..a3650e45 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -25,11 +25,6 @@ namespace rtl::dispatch return m_functor; } - decltype(auto) operator()(signature_ts&&...params) const noexcept // TODO: handle exception. - { - return (*m_functor)(std::forward(params)...); - } - functor(fptr_t fptr) :m_functor(fptr) { m_returnId = detail::TypeId::get(); @@ -38,6 +33,6 @@ namespace rtl::dispatch private: - fptr_t m_functor; + const fptr_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 6a05ef00..469e701a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -25,34 +25,66 @@ namespace rtl::dispatch using lambda_t = std::function; template - void init_ctor() const; + static lambda create_ctor(const functor_hop* fptr_hopper) + { + return lambda(fptr_hopper, &ctor); + } template - void init_cloner() const; + static lambda create_copy_ctor(const functor_hop* fptr_hopper) + { + return lambda(fptr_hopper, ©_ctor); + } template - void init_function() const; + static lambda create_function(const functor_hop* fptr_hopper) + { + return lambda(fptr_hopper, &function); + } template - void init_method_const() const; + static lambda create_method_const(const functor_hop* fptr_hopper) + { + return lambda(fptr_hopper, &method_const); + } template - void init_method_nonconst() const; - - Return operator()(signature_ts&&...params) const + static lambda create_method_nonconst(const functor_hop* fptr_hopper) { - return m_hopper(*this, std::forward(params)...); + return lambda(fptr_hopper, &method_nonconst); + } + + template + decltype(auto) operator()(args_t&&...params) const noexcept + { + return m_hopper(*this, std::forward(params)...); } - lambda(const functor_hop* fptr_hopper) + private: + + const lambda_t m_hopper; + + lambda(const functor_hop* fptr_hopper, lambda_t hopper) noexcept + : m_hopper(std::move(hopper)) { detail::TypeId::get(m_argumentsId); m_signatureId = detail::TypeId>::get(); m_functor = fptr_hopper; } - private: + template + static Return ctor(const lambda_hop&, signature_ts&&...) noexcept; + + template + static Return copy_ctor(const lambda_hop&, signature_ts&&...) noexcept; - mutable lambda_t m_hopper; + template + static Return function(const lambda_hop&, signature_ts&&...) noexcept; + + template + static Return method_const(const lambda_hop&, signature_ts&&...) noexcept; + + template + static Return method_nonconst(const lambda_hop&, signature_ts&&...) noexcept; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp index dd8b664c..2406fd6e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp @@ -19,8 +19,8 @@ namespace rtl::dispatch { template template - inline void lambda::init_cloner() const + inline Return lambda::copy_ctor(const lambda_hop&, signature_ts&&...) noexcept { - + return { error::EmptyRObject, RObject{} }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp index e864c2f7..e42ef552 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp @@ -18,8 +18,8 @@ namespace rtl::dispatch { template template - inline void lambda::init_ctor() const + inline Return lambda::ctor(const lambda_hop&, signature_ts&&...) noexcept { - + return { error::EmptyRObject, RObject{} }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp index 9a919ff2..64392aec 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp @@ -14,53 +14,46 @@ #include #include "lambda.h" +#include "functor.h" #include "RObjectBuilder.hpp" namespace rtl::dispatch { template template - inline void lambda::init_function() const + inline Return lambda::function(const lambda_hop& hopper, signature_ts&&...params) noexcept { + auto functor = hopper.functor().get().get(); + if constexpr (std::is_same_v) { - m_hopper = [](const lambda_hop& hopper, signature_ts&&... params) noexcept -> Return - { - auto& functor = hopper.functor().get(); - - functor(std::forward(params)...); + (*functor)(std::forward(params)...); - return { error::None, RObject{} }; - }; + return { error::None, RObject{} }; } else { - m_hopper = [](const lambda_hop& hopper, signature_ts&&...params) noexcept -> Return + constexpr bool isConstCastSafe = (!traits::is_const_v); + if constexpr (std::is_reference_v) { - auto& functor = hopper.functor().get(); - - constexpr bool isConstCastSafe = (!traits::is_const_v); - if constexpr (std::is_reference_v) - { - using T = traits::raw_t; - const T& retObj = functor(std::forward(params)...); - - return { error::None, - detail::RObjectBuilder::template - build(&retObj, std::nullopt, isConstCastSafe) - }; - } - else { - - auto&& retObj = functor(std::forward(params)...); - using T = std::remove_cvref_t; - - return { error::None, - detail::RObjectBuilder::template - build(std::forward(retObj), std::nullopt, isConstCastSafe) - }; - } - }; + using T = traits::raw_t; + const T& retObj = functor(std::forward(params)...); + + return { error::None, + detail::RObjectBuilder::template + build(&retObj, std::nullopt, isConstCastSafe) + }; + } + else { + + auto&& retObj = functor(std::forward(params)...); + using T = std::remove_cvref_t; + + return { error::None, + detail::RObjectBuilder::template + build(std::forward(retObj), std::nullopt, isConstCastSafe) + }; + } } } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp index d6c1a39e..8e1137a0 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp @@ -18,8 +18,8 @@ namespace rtl::dispatch { template template - inline void lambda::init_method_const() const + inline Return lambda::method_const(const lambda_hop&, signature_ts&&...) noexcept { - + return { error::EmptyRObject, RObject{} }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp index 9203bfd7..befceb5a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp @@ -17,8 +17,8 @@ namespace rtl::dispatch { template template - inline void lambda::init_method_nonconst() const + inline Return lambda::method_nonconst(const lambda_hop&, signature_ts&&...) noexcept { - + return { error::EmptyRObject, RObject{} }; } } \ No newline at end of file From 387fcaad74da40be5a0a253ebd856b26c2cd53fe Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 19 Sep 2025 01:23:48 +0530 Subject: [PATCH 010/148] return-type erased from cache/functor/lambda containers. --- .../rtl/builder/SetupFunction.hpp | 21 +++--- .../rtl/builder/SetupMethod.hpp | 72 ++++++++++++++----- .../rtl/cache/functor_cache.h | 26 ++++--- .../rtl/cache/functor_cache_const.h | 29 ++++---- .../rtl/cache/functor_cache_nonconst.h | 28 ++++---- .../rtl/cache/lambda_cache.h | 25 +++++-- .../rtl/dispatch/dispatch_interface.h | 53 +++++++------- ReflectionTemplateLib/rtl/dispatch/functor.h | 28 ++++++-- .../rtl/dispatch/functor_const.h | 25 ++++--- .../rtl/dispatch/functor_nonconst.h | 25 ++++--- ReflectionTemplateLib/rtl/dispatch/lambda.h | 23 +++--- .../rtl/dispatch/lambda_function.hpp | 2 +- .../rtl/dispatch/lambda_method_const.hpp | 1 - ReflectionTemplateLib/rtl/rtl_traits.h | 2 - 14 files changed, 231 insertions(+), 129 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index c949782b..264337cc 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -31,8 +31,8 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - //bool isAmazing = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); - //assert(isAmazing && "new type-system corrupted."); + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + assert(isAllGood && "new type-id-system not working."); pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -49,8 +49,8 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { - bool isAmazing = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); - assert(isAmazing && "new type-system corrupted."); + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + assert(isAllGood && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); @@ -94,11 +94,11 @@ namespace rtl const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& functorCache = dispatch::functor_cache<_returnType, _signature...>::get(); + auto& functorCache = dispatch::functor_cache<_signature...>::instance(); - const dispatch::functor_hop* functor = functorCache.push(pFunctor, pIndex); + const dispatch::functor_hop* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambdaCache = dispatch::lambda_cache<_signature...>::get(); + auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); auto& lambda = lambdaCache.template push_function<_returnType>(functor); @@ -107,11 +107,14 @@ namespace rtl const auto& getIndex = [&]()-> std::size_t { - auto& functorCache = dispatch::functor_cache<_returnType, _signature...>::get(); - auto [functor, lambdaIndex] = functorCache.find(pFunctor); + auto& functorCache = dispatch::functor_cache<_signature...>::instance(); + + auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); + if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; } + return lambdaIndex; }; diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 6cc63e50..1ea5f350 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -17,8 +17,11 @@ #include "rtl_typeid.h" #include "SetupMethod.h" #include "RObjectBuilder.hpp" + #include "functor_cache_const.h" #include "functor_cache_nonconst.h" +#include "lambda_method_const.hpp" +#include "lambda_method_nonconst.hpp" namespace rtl::detail { @@ -31,6 +34,9 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + assert(isAllGood && "new type-id-system not working."); + if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; } @@ -51,6 +57,9 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + assert(isAllGood && "new type-id-system not working."); + if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; } @@ -92,6 +101,9 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + assert(isAllGood && "new type-id-system not working."); + const _recordType& target = pTargetObj.view<_recordType>()->get(); (target.*pFunctor)(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -108,6 +120,9 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + assert(isAllGood && "new type-id-system not working."); + constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); //'target' is const and 'pFunctor' is const-member-function. const _recordType& target = pTargetObj.view<_recordType>()->get(); @@ -148,18 +163,31 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { - auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _returnType, _signature...>::get(); + const dispatch::lambda_hop* lambdaPtr = nullptr; - // called from '_derivedType' (MethodContainer) - const auto& updateIndex = [&](std::size_t pIndex)->void + const auto& updateIndex = [&](std::size_t pIndex)-> void { - functorCache.push(pFunctor, pIndex); + auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _signature...>::instance(); + + const dispatch::functor_hop* functor = functorCache.template push<_returnType>(pFunctor, pIndex); + + auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); + + auto& lambda = lambdaCache.template push_method_nonconst<_recordType, _returnType>(functor); + + lambdaPtr = λ }; - // called from '_derivedType' (MethodContainer) const auto& getIndex = [&]()-> std::size_t { - std::size_t lambdaIndex = functorCache.find(pFunctor); + auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _signature...>::instance(); + + auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); + + if (lambdaIndex != rtl::index_none) { + lambdaPtr = functor->m_lambda; + } + return lambdaIndex; }; @@ -178,7 +206,7 @@ namespace rtl::detail TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - nullptr + lambdaPtr }; } else @@ -192,7 +220,7 @@ namespace rtl::detail TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - nullptr + lambdaPtr }; } } @@ -211,19 +239,31 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) { - auto& functorCache = dispatch::functor_cache_const<_recordType, _returnType, _signature...>::get(); + const dispatch::lambda_hop* lambdaPtr = nullptr; - // called from '_derivedType' (MethodContainer) const auto& updateIndex = [&](std::size_t pIndex)-> void { - //functorIndex = functorCache.get().size(); - functorCache.push(pFunctor, pIndex); + auto& functorCache = dispatch::functor_cache_const<_recordType, _signature...>::instance(); + + const dispatch::functor_hop* functor = functorCache.template push<_returnType>(pFunctor, pIndex); + + auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); + + auto& lambda = lambdaCache.template push_method_const<_recordType, _returnType>(functor); + + lambdaPtr = λ }; - // called from '_derivedType' (MethodContainer) const auto& getIndex = [&]()-> std::size_t { - std::size_t lambdaIndex = functorCache.find(pFunctor); + auto& functorCache = dispatch::functor_cache_const<_recordType, _signature...>::instance(); + + auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); + + if (lambdaIndex != rtl::index_none) { + lambdaPtr = functor->m_lambda; + } + return lambdaIndex; }; @@ -243,7 +283,7 @@ namespace rtl::detail TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - nullptr//&lambdaCache + lambdaPtr }; } else @@ -257,7 +297,7 @@ namespace rtl::detail TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - nullptr// &lambdaCache + lambdaPtr }; } } diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache.h b/ReflectionTemplateLib/rtl/cache/functor_cache.h index 13fd39b7..4ba654a8 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache.h @@ -17,30 +17,34 @@ namespace rtl::dispatch { - template + template struct functor_cache { - using fptr_t = return_t(*)(signature_ts...); - using functor_t = functor; + using functor_t = functor; - static functor_cache& get() + static const functor_cache& instance() { - static functor_cache instance; - return instance; + static functor_cache instance_; + return instance_; } - const functor_hop* push(const functor_t& functor, std::size_t lambda_index) + template + const functor_hop* push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const { - m_cache.emplace_back(std::make_pair(functor, lambda_index)); + using voidfn_t = typename functor::voidfn_t; + + auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); + m_cache.emplace_back(std::make_pair(functor , lambda_index)); return &(m_cache.back().first); } - std::pair find(fptr_t fptr) + template + std::pair find(return_t(*fptr)(signature_ts...)) const { for (auto& itr : m_cache) { const auto& functor = itr.first; - if (fptr == functor.get()) { + if (functor.template is_same(fptr)) { return { &itr.first, itr.second }; } } @@ -55,7 +59,7 @@ namespace rtl::dispatch private: // No reallocation occurs; original objects stay intact - std::list> m_cache; + mutable std::list> m_cache; functor_cache() {} }; diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h b/ReflectionTemplateLib/rtl/cache/functor_cache_const.h index 7d1af246..a7a351a3 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_const.h @@ -17,37 +17,40 @@ namespace rtl::dispatch { - template + template struct functor_cache_const { - using fptr_t = return_t(record_t::*)(signature_ts...) const; - using functor_t = functor_const; + using functor_t = functor_const; - static functor_cache_const& get() + static const functor_cache_const& instance() { - static functor_cache_const instance; - return instance; + static functor_cache_const instance_; + return instance_; } - const functor_hop* push(const functor_t& functor, std::size_t lambda_index) + template + const functor_hop* push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const { + using voidfn_t = typename functor_const::voidfn_t; + auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); + } - std::size_t find(fptr_t fptr) + template + std::pair find(return_t(record_t::* fptr)(signature_ts...) const) const { for (auto& itr : m_cache) { const auto& functor = itr.first; - if (fptr == functor.get()) { - return itr.second; + if (functor.template is_same(fptr)) { + return { &itr.first, itr.second }; } } - return rtl::index_none; + return { nullptr, rtl::index_none }; } - functor_cache_const(functor_cache_const&&) = delete; functor_cache_const(const functor_cache_const&) = delete; functor_cache_const& operator=(functor_cache_const&&) = delete; @@ -56,7 +59,7 @@ namespace rtl::dispatch private: // No reallocation occurs; original objects stay intact - std::list> m_cache; + mutable std::list> m_cache; functor_cache_const() {} }; diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h index b0f8a3cc..e9a240e9 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h @@ -17,37 +17,39 @@ namespace rtl::dispatch { - template + template struct functor_cache_nonconst { - using fptr_t = return_t(record_t::*)(signature_ts...); - using functor_t = functor_nonconst; + using functor_t = functor_nonconst; - static functor_cache_nonconst& get() + static const functor_cache_nonconst& instance() { - static functor_cache_nonconst instance; - return instance; + static const functor_cache_nonconst instance_; + return instance_; } - const functor_hop* push(const functor_t& functor, std::size_t lambda_index) + template + const functor_hop* push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const { + using voidfn_t = typename functor_nonconst::voidfn_t; + auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); } - std::size_t find(fptr_t fptr) + template + std::pair find(return_t(record_t::* fptr)(signature_ts...)) const { for (auto& itr : m_cache) { const auto& functor = itr.first; - if (fptr == functor.get()) { - return itr.second; + if (functor.template is_same(fptr)) { + return { &itr.first, itr.second }; } } - return rtl::index_none; + return { nullptr, rtl::index_none }; } - functor_cache_nonconst(functor_cache_nonconst&&) = delete; functor_cache_nonconst(const functor_cache_nonconst&) = delete; functor_cache_nonconst& operator=(functor_cache_nonconst&&) = delete; @@ -56,7 +58,7 @@ namespace rtl::dispatch private: // No reallocation occurs; original objects stay intact - std::list> m_cache; + mutable std::list> m_cache; functor_cache_nonconst() {} }; diff --git a/ReflectionTemplateLib/rtl/cache/lambda_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_cache.h index 9e0e1927..21d249f1 100644 --- a/ReflectionTemplateLib/rtl/cache/lambda_cache.h +++ b/ReflectionTemplateLib/rtl/cache/lambda_cache.h @@ -20,21 +20,36 @@ namespace rtl::dispatch template struct lambda_cache { - static lambda_cache& get() + static lambda_cache& instance() { - static lambda_cache instance; - return instance; + static lambda_cache instance_; + return instance_; } template const lambda& push_function(const functor_hop* fptr_hopper) { m_cache.push_back(lambda::template create_function(fptr_hopper)); + const lambda& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; + } + template + const lambda& push_method_const(const functor_hop* fptr_hopper) + { + m_cache.push_back(lambda::template create_method_const(fptr_hopper)); + const lambda& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; + } + + template + const lambda& push_method_nonconst(const functor_hop* fptr_hopper) + { + m_cache.push_back(lambda::template create_method_nonconst(fptr_hopper)); const lambda& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; } diff --git a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h index 7ecb6723..eee70c23 100644 --- a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h +++ b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h @@ -26,12 +26,6 @@ namespace rtl::dispatch struct lambda_hop { - std::size_t m_signatureId = detail::TypeId<>::None; - - traits::args_t m_argumentsId = {}; - - const functor_hop* m_functor = nullptr; - const functor_hop& functor() const { return *m_functor; @@ -42,51 +36,60 @@ namespace rtl::dispatch { return (*static_cast*>(this)); } + +// protected: + + const functor_hop* m_functor = nullptr; + std::size_t m_returnId = detail::TypeId<>::None; + std::size_t m_signatureId = detail::TypeId<>::None; + std::vector m_argumentsId = {}; }; } namespace rtl::dispatch { - template + template struct functor; - template + template struct functor_const; - template + template struct functor_nonconst; struct functor_hop { - mutable const lambda_hop* m_lambda = nullptr; - - std::size_t m_recordId = detail::TypeId<>::None; - std::size_t m_returnId = detail::TypeId<>::None; - std::size_t m_signatureId = detail::TypeId<>::None; - detail::methodQ m_qualifier = detail::methodQ::None; - void set_lambda(const lambda_hop* lambda) const { m_lambda = lambda; } - template - const functor& get() const + template + const functor& get() const { - return *(static_cast*>(this)); + return *(static_cast*>(this)); } - template - const functor_const& get_const() const + template + const functor_const& get_const() const { - return *(static_cast*>(this)); + return *(static_cast*>(this)); } - template - const functor_nonconst& get_nonconst() const + template + const functor_nonconst& get_nonconst() const { - return *(static_cast*>(this)); + return *(static_cast*>(this)); } + +// protected: + + mutable const lambda_hop* m_lambda = nullptr; + + std::size_t m_recordId = detail::TypeId<>::None; + std::size_t m_returnId = detail::TypeId<>::None; + std::size_t m_signatureId = detail::TypeId<>::None; + detail::methodQ m_qualifier = detail::methodQ::None; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index a3650e45..886551e6 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -15,24 +15,38 @@ namespace rtl::dispatch { - template + template struct functor: public functor_hop { - using fptr_t = return_t(*)(signature_ts...); + using voidfn_t = void(*)(signature_ts...); - fptr_t get() const + template + decltype(auto) get(std::size_t returnId) const { - return m_functor; + using fptr_t = return_t(*)(signature_ts...); + if (returnId == m_returnId) + { + return reinterpret_cast(m_functor); + } + return static_cast(nullptr); } - functor(fptr_t fptr) :m_functor(fptr) + template + bool is_same(return_t(*fptr)(signature_ts...)) const { - m_returnId = detail::TypeId::get(); + return (m_functor == reinterpret_cast(fptr)); + } + + functor(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) + { + m_returnId = returnId; m_signatureId = detail::TypeId>::get(); } + functor(const functor&) = default; + private: - const fptr_t m_functor; + const voidfn_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_const.h b/ReflectionTemplateLib/rtl/dispatch/functor_const.h index dea777bd..7a0ae4b9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_const.h @@ -17,29 +17,36 @@ namespace rtl::dispatch { - template + template struct functor_const : public functor_hop { - using fptr_t = return_t(record_t::*)(signature_ts...) const; + using voidfn_t = void(record_t::*)(signature_ts...) const; - fptr_t get() const + template + decltype(auto) get(std::size_t returnId) const { - return m_functor; + using fptr_t = return_t(record_t::*)(signature_ts...); + if (returnId == m_returnId) + { + return reinterpret_cast(m_functor); + } + return static_cast(nullptr); } - decltype(auto) operator()(const record_t& pTarget, signature_ts&&...params) const noexcept // TODO: handle exception. + template + bool is_same(return_t(record_t::*fptr)(signature_ts...) const) const { - return (pTarget.*m_functor)(std::forward(params)...); + return (m_functor == reinterpret_cast(fptr)); } - functor_const(fptr_t fptr) :m_functor(fptr) + functor_const(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) { - m_returnId = detail::TypeId::get(); + m_returnId = returnId; m_signatureId = detail::TypeId>::get(); } private: - fptr_t m_functor; + const voidfn_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h index 4ca1310a..f42e3e64 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h @@ -17,29 +17,36 @@ namespace rtl::dispatch { - template + template struct functor_nonconst : public functor_hop { - using fptr_t = return_t(record_t::*)(signature_ts...); + using voidfn_t = void(record_t::*)(signature_ts...); - fptr_t get() const + template + decltype(auto) get(std::size_t returnId) const { - return m_functor; + using fptr_t = return_t(record_t::*)(signature_ts...); + if (returnId == m_returnId) + { + return reinterpret_cast(m_functor); + } + return static_cast(nullptr); } - decltype(auto) operator()(record_t& pTarget, signature_ts&&...params) const noexcept // TODO: handle exception. + template + bool is_same(return_t(record_t::* fptr)(signature_ts...)) const { - return (pTarget.*m_functor)(std::forward(params)...); + return (m_functor == reinterpret_cast(fptr)); } - functor_nonconst(fptr_t fptr) :m_functor(fptr) + functor_nonconst(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) { - m_returnId = detail::TypeId::get(); + m_returnId = returnId; m_signatureId = detail::TypeId>::get(); } private: - fptr_t m_functor; + const voidfn_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 469e701a..ddde9833 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -13,6 +13,7 @@ #include #include +#include #include "forward_decls.h" #include "dispatch_interface.h" @@ -27,31 +28,36 @@ namespace rtl::dispatch template static lambda create_ctor(const functor_hop* fptr_hopper) { - return lambda(fptr_hopper, &ctor); + std::size_t returnId = detail::TypeId::get(); + return lambda(returnId, fptr_hopper, &ctor); } template static lambda create_copy_ctor(const functor_hop* fptr_hopper) { - return lambda(fptr_hopper, ©_ctor); + std::size_t returnId = detail::TypeId::get(); + return lambda(returnId, fptr_hopper, ©_ctor); } template static lambda create_function(const functor_hop* fptr_hopper) { - return lambda(fptr_hopper, &function); + std::size_t returnId = detail::TypeId::get(); + return lambda(returnId, fptr_hopper, &function); } template static lambda create_method_const(const functor_hop* fptr_hopper) { - return lambda(fptr_hopper, &method_const); + std::size_t returnId = detail::TypeId::get(); + return lambda(returnId, fptr_hopper, &method_const); } template static lambda create_method_nonconst(const functor_hop* fptr_hopper) { - return lambda(fptr_hopper, &method_nonconst); + std::size_t returnId = detail::TypeId::get(); + return lambda(returnId, fptr_hopper, &method_nonconst); } template @@ -64,12 +70,13 @@ namespace rtl::dispatch const lambda_t m_hopper; - lambda(const functor_hop* fptr_hopper, lambda_t hopper) noexcept + lambda(std::size_t returnId, const functor_hop* functor, lambda_t hopper) noexcept : m_hopper(std::move(hopper)) { - detail::TypeId::get(m_argumentsId); + m_functor = functor; + m_returnId = returnId; m_signatureId = detail::TypeId>::get(); - m_functor = fptr_hopper; + detail::TypeId::get(m_argumentsId); } template diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp index 64392aec..d972a882 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp @@ -23,7 +23,7 @@ namespace rtl::dispatch template inline Return lambda::function(const lambda_hop& hopper, signature_ts&&...params) noexcept { - auto functor = hopper.functor().get().get(); + auto functor = hopper.functor().get().get(hopper.m_returnId); if constexpr (std::is_same_v) { diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp index 8e1137a0..79fa3c5f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp @@ -12,7 +12,6 @@ #pragma once #include "lambda.h" -#include "RObjectBuilder.hpp" namespace rtl::dispatch { diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index cc2d25a3..d2ccb404 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -27,8 +27,6 @@ namespace rtl { namespace traits { - using args_t = std::vector; - using Converter = std::function< std::any(const std::any&, const detail::EntityKind&, detail::EntityKind&) >; using ConverterPair = std::pair< std::size_t, Converter >; From d9aef490cffaf5746c42c9635cf9a88bf63464e1 Mon Sep 17 00:00:00 2001 From: neeraj Date: Fri, 19 Sep 2025 01:37:29 +0530 Subject: [PATCH 011/148] fixed cland/gcc compile error --- ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp index d972a882..3a183df9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp @@ -23,7 +23,7 @@ namespace rtl::dispatch template inline Return lambda::function(const lambda_hop& hopper, signature_ts&&...params) noexcept { - auto functor = hopper.functor().get().get(hopper.m_returnId); + auto functor = hopper.functor().get().template get(hopper.m_returnId); if constexpr (std::is_same_v) { From 7c1af2415ea11f90a37ac810ec9f941d4f517c7d Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 19 Sep 2025 09:42:01 +0530 Subject: [PATCH 012/148] enabled reflective call with known return-type --- RTLBenchmarkApp/src/ReflectedCall.cpp | 33 ++++++-- .../rtl/builder/SetupFunction.hpp | 12 +-- .../rtl/builder/SetupMethod.hpp | 26 +----- .../rtl/dispatch/CMakeLists.txt | 9 +-- ReflectionTemplateLib/rtl/dispatch/hopper.h | 80 +++++++++++++++++++ .../{lambda_ctor.hpp => hopper_const.h} | 12 +-- ...mbda_method_nonconst.hpp => hopper_ctor.h} | 18 ++++- ...lambda_copy_ctor.hpp => hopper_nonconst.h} | 13 +-- ReflectionTemplateLib/rtl/dispatch/lambda.h | 45 +++++++---- .../rtl/dispatch/lambda_function.hpp | 59 -------------- .../rtl/dispatch/lambda_method_const.hpp | 24 ------ 11 files changed, 175 insertions(+), 156 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/dispatch/hopper.h rename ReflectionTemplateLib/rtl/dispatch/{lambda_ctor.hpp => hopper_const.h} (76%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_method_nonconst.hpp => hopper_ctor.h} (65%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_copy_ctor.hpp => hopper_nonconst.h} (76%) delete mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp delete mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp diff --git a/RTLBenchmarkApp/src/ReflectedCall.cpp b/RTLBenchmarkApp/src/ReflectedCall.cpp index d0225f3e..84cc6370 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.cpp +++ b/RTLBenchmarkApp/src/ReflectedCall.cpp @@ -5,6 +5,12 @@ #include "ReflectedCall.h" #include "BenchMark.h" + +namespace bm +{ + extern std::optional g_work_done; +} + namespace cxx { extern const rtl::CxxMirror& mirror(); @@ -48,17 +54,29 @@ namespace auto err = SendMessage(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[1] error: "<< rtl::to_string(err)<<"\n"; + std::cout << "[0] error: "<< rtl::to_string(err)<<"\n"; } return 0; }; + + static auto _test4 = []() + { + auto& hopper = (SendMessage.getFunctors()[0].m_lambda)->get(); + //auto err = hopper(bm::g_longStr).err; + //if (err != rtl::error::None) { + // std::cout << "[4] error: " << rtl::to_string(err) << "\n"; + //} + return hopper; + }; + + static auto _test1 = []() { auto err = NodeSendMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[2] error: " << rtl::to_string(err) << "\n"; + std::cout << "[1] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -68,7 +86,7 @@ namespace auto err = GetMessage(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[3] error: " << rtl::to_string(err) << "\n"; + std::cout << "[2] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -78,7 +96,7 @@ namespace auto err = NodeGetMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[4] error: " << rtl::to_string(err) << "\n"; + std::cout << "[3] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -109,11 +127,12 @@ void ReflectedCall::get(benchmark::State& state) void ReflectedCall::new_design_set(benchmark::State& state) { - static auto& hopper = (SendMessage.getFunctors()[0].m_lambda)->get(); + static const auto& hopper = _test4(); for (auto _ : state) { - auto error = hopper(bm::g_longStr).err; - benchmark::DoNotOptimize(error); + hopper.call(bm::g_longStr); + //auto ret = hopper(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 264337cc..ac0cc135 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -15,7 +15,6 @@ #include "lambda_cache.h" #include "functor_cache.h" -#include "lambda_function.hpp" #include "SetupFunction.h" #include "RObjectBuilder.hpp" @@ -94,27 +93,20 @@ namespace rtl const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& functorCache = dispatch::functor_cache<_signature...>::instance(); - - const dispatch::functor_hop* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); - + auto& functorCache = dispatch::functor_cache<_signature...>::instance(); + auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); auto& lambda = lambdaCache.template push_function<_returnType>(functor); - lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { auto& functorCache = dispatch::functor_cache<_signature...>::instance(); - auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); - if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; } - return lambdaIndex; }; diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 1ea5f350..f420f873 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -20,8 +20,6 @@ #include "functor_cache_const.h" #include "functor_cache_nonconst.h" -#include "lambda_method_const.hpp" -#include "lambda_method_nonconst.hpp" namespace rtl::detail { @@ -164,30 +162,22 @@ namespace rtl::detail inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { const dispatch::lambda_hop* lambdaPtr = nullptr; - const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _signature...>::instance(); - - const dispatch::functor_hop* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); - + auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _signature...>::instance(); + auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); auto& lambda = lambdaCache.template push_method_nonconst<_recordType, _returnType>(functor); - lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _signature...>::instance(); - auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); - if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; } - return lambdaIndex; }; @@ -240,30 +230,22 @@ namespace rtl::detail inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) { const dispatch::lambda_hop* lambdaPtr = nullptr; - const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& functorCache = dispatch::functor_cache_const<_recordType, _signature...>::instance(); - - const dispatch::functor_hop* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); - + auto& functorCache = dispatch::functor_cache_const<_recordType, _signature...>::instance(); + auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); auto& lambda = lambdaCache.template push_method_const<_recordType, _returnType>(functor); - lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { auto& functorCache = dispatch::functor_cache_const<_recordType, _signature...>::instance(); - auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); - if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; } - return lambdaIndex; }; diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 6fa05029..5f1ba12a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -9,11 +9,10 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/functor_nonconst.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_ctor.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_copy_ctor.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method_const.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method_nonconst.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/hopper.h" + "${CMAKE_CURRENT_SOURCE_DIR}/hopper_ctor.h" + "${CMAKE_CURRENT_SOURCE_DIR}/hopper_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/hoppert_nonconst.h" "${CMAKE_CURRENT_SOURCE_DIR}/CallReflector.h" "${CMAKE_CURRENT_SOURCE_DIR}/FunctionCaller.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper.h b/ReflectionTemplateLib/rtl/dispatch/hopper.h new file mode 100644 index 00000000..62a26bbb --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/hopper.h @@ -0,0 +1,80 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "lambda.h" +#include "functor.h" +//#include "RObjectBuilder.hpp" + +namespace rtl::dispatch +{ + template + struct hopper + { + template + static decltype(auto) function(const lambda_hop& lambda_ref, signature_ts&&...params) noexcept + { + auto functor = lambda_ref.functor().template get().template get(lambda_ref.m_returnId); + if constexpr (std::is_same_v) { + (*functor)(std::forward(params)...); + } + else { + return (*functor)(std::forward(params)...); + } + } + + template requires (is_void_t == true) + static Return function(const lambda_hop& lambda_ref, signature_ts&&...params) noexcept + { + if constexpr (std::is_same_v) { + auto functor = lambda_ref.functor().template get().template get(lambda_ref.m_returnId); + (*functor)(std::forward(params)...); + } + else { + static_assert("return-type mismatch."); + } + return { error::None, RObject{} }; + } + + template requires (is_void_t == false) + static Return function(const lambda_hop& lambda_ref, signature_ts&&...params) noexcept + { + constexpr bool isConstCastSafe = (!traits::is_const_v); + + auto functor = lambda_ref.functor().template get().template get(lambda_ref.m_returnId); + + if constexpr (std::is_reference_v) + { + using T = traits::raw_t; + const T& retObj = functor(std::forward(params)...); + + //return { error::None, + // detail::RObjectBuilder::template + // build(&retObj, std::nullopt, isConstCastSafe) + //}; + } + else { + + auto&& retObj = functor(std::forward(params)...); + using T = std::remove_cvref_t; + + //return { error::None, + // detail::RObjectBuilder::template + // build(std::forward(retObj), std::nullopt, isConstCastSafe) + //}; + } + return { error::None, RObject{} }; + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp b/ReflectionTemplateLib/rtl/dispatch/hopper_const.h similarity index 76% rename from ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp rename to ReflectionTemplateLib/rtl/dispatch/hopper_const.h index e42ef552..57edc292 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_ctor.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_const.h @@ -12,14 +12,16 @@ #pragma once #include "lambda.h" -#include "RObjectBuilder.hpp" namespace rtl::dispatch { template - template - inline Return lambda::ctor(const lambda_hop&, signature_ts&&...) noexcept + struct hopper_const { - return { error::EmptyRObject, RObject{} }; - } + template + static Return method(const lambda_hop&, signature_ts&&...) noexcept + { + return { error::EmptyRObject, RObject{} }; + } + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp b/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h similarity index 65% rename from ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp rename to ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h index befceb5a..629f9cd2 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method_nonconst.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h @@ -11,14 +11,24 @@ #pragma once + #include "lambda.h" namespace rtl::dispatch { template - template - inline Return lambda::method_nonconst(const lambda_hop&, signature_ts&&...) noexcept + struct hopper_ctor { - return { error::EmptyRObject, RObject{} }; - } + template + static Return cloner(const lambda_hop&, signature_ts&&...) noexcept + { + return { error::EmptyRObject, RObject{} }; + } + + template + static Return constructor(const lambda_hop&, signature_ts&&...) noexcept + { + return { error::EmptyRObject, RObject{} }; + } + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h similarity index 76% rename from ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp rename to ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h index 2406fd6e..efdd6ca3 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_copy_ctor.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h @@ -11,16 +11,17 @@ #pragma once - #include "lambda.h" -#include "RObjectBuilder.hpp" namespace rtl::dispatch { template - template - inline Return lambda::copy_ctor(const lambda_hop&, signature_ts&&...) noexcept + struct hopper_nonconst { - return { error::EmptyRObject, RObject{} }; - } + template + static Return method(const lambda_hop&, signature_ts&&...) noexcept + { + return { error::EmptyRObject, RObject{} }; + } + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index ddde9833..6d95bd2f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -16,6 +16,12 @@ #include #include "forward_decls.h" + +#include "hopper.h" +#include "hopper_ctor.h" +#include "hopper_const.h" +#include "hopper_nonconst.h" + #include "dispatch_interface.h" namespace rtl::dispatch @@ -23,47 +29,58 @@ namespace rtl::dispatch template struct lambda: public lambda_hop { - using lambda_t = std::function; + using lambda_t = std::function; template static lambda create_ctor(const functor_hop* fptr_hopper) { - std::size_t returnId = detail::TypeId::get(); - return lambda(returnId, fptr_hopper, &ctor); + return lambda(detail::TypeId::get(), fptr_hopper, + &hopper_ctor::template constructor); } template static lambda create_copy_ctor(const functor_hop* fptr_hopper) { - std::size_t returnId = detail::TypeId::get(); - return lambda(returnId, fptr_hopper, ©_ctor); + return lambda(detail::TypeId::get(), fptr_hopper, + &hopper_ctor::template cloner); } template static lambda create_function(const functor_hop* fptr_hopper) { - std::size_t returnId = detail::TypeId::get(); - return lambda(returnId, fptr_hopper, &function); + return lambda(detail::TypeId::get(), fptr_hopper, + &hopper::template function>); } template static lambda create_method_const(const functor_hop* fptr_hopper) { - std::size_t returnId = detail::TypeId::get(); - return lambda(returnId, fptr_hopper, &method_const); + return lambda(detail::TypeId::get(), fptr_hopper, + &hopper_const::template method); } template static lambda create_method_nonconst(const functor_hop* fptr_hopper) { - std::size_t returnId = detail::TypeId::get(); - return lambda(returnId, fptr_hopper, &method_nonconst); + return lambda(detail::TypeId::get(), fptr_hopper, + &hopper_nonconst::template method); } template - decltype(auto) operator()(args_t&&...params) const noexcept + Return operator()(args_t&&...params) const noexcept + { + return m_hopper(*this, std::forward(params)...); + } + + template + decltype(auto) call(args_t&&...params) const noexcept { - return m_hopper(*this, std::forward(params)...); + if constexpr (std::is_same_v) { + hopper::template function(*this, std::forward(params)...); + } + else { + return hopper::template function(*this, std::forward(params)...); + } } private: @@ -86,7 +103,7 @@ namespace rtl::dispatch static Return copy_ctor(const lambda_hop&, signature_ts&&...) noexcept; template - static Return function(const lambda_hop&, signature_ts&&...) noexcept; + static return_t function(const lambda_hop&, signature_ts&&...) noexcept; template static Return method_const(const lambda_hop&, signature_ts&&...) noexcept; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp deleted file mode 100644 index 3a183df9..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include - -#include "lambda.h" -#include "functor.h" -#include "RObjectBuilder.hpp" - -namespace rtl::dispatch -{ - template - template - inline Return lambda::function(const lambda_hop& hopper, signature_ts&&...params) noexcept - { - auto functor = hopper.functor().get().template get(hopper.m_returnId); - - if constexpr (std::is_same_v) - { - (*functor)(std::forward(params)...); - - return { error::None, RObject{} }; - } - else - { - constexpr bool isConstCastSafe = (!traits::is_const_v); - if constexpr (std::is_reference_v) - { - using T = traits::raw_t; - const T& retObj = functor(std::forward(params)...); - - return { error::None, - detail::RObjectBuilder::template - build(&retObj, std::nullopt, isConstCastSafe) - }; - } - else { - - auto&& retObj = functor(std::forward(params)...); - using T = std::remove_cvref_t; - - return { error::None, - detail::RObjectBuilder::template - build(std::forward(retObj), std::nullopt, isConstCastSafe) - }; - } - } - } -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp deleted file mode 100644 index 79fa3c5f..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method_const.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include "lambda.h" - -namespace rtl::dispatch -{ - template - template - inline Return lambda::method_const(const lambda_hop&, signature_ts&&...) noexcept - { - return { error::EmptyRObject, RObject{} }; - } -} \ No newline at end of file From 599c1cac51a931ce6c4ba7bfac435033b698ed84 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Fri, 19 Sep 2025 10:02:42 +0530 Subject: [PATCH 013/148] Fixed CMakeLists.txt error. --- ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 5f1ba12a..cb9634e1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -12,7 +12,7 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/hopper.h" "${CMAKE_CURRENT_SOURCE_DIR}/hopper_ctor.h" "${CMAKE_CURRENT_SOURCE_DIR}/hopper_const.h" - "${CMAKE_CURRENT_SOURCE_DIR}/hoppert_nonconst.h" + "${CMAKE_CURRENT_SOURCE_DIR}/hopper_nonconst.h" "${CMAKE_CURRENT_SOURCE_DIR}/CallReflector.h" "${CMAKE_CURRENT_SOURCE_DIR}/FunctionCaller.h" @@ -23,4 +23,4 @@ set(LOCAL_HEADERS ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) -source_group("Header Files\\Dispatch" FILES ${LOCAL_HEADERS}) \ No newline at end of file +source_group("Header Files\\Dispatch" FILES ${LOCAL_HEADERS}) From f401a11e904440004307b7d61a156fd5b3feda95 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 20 Sep 2025 02:50:13 +0530 Subject: [PATCH 014/148] method-call with known return-type: In Progress. --- RTLBenchmarkApp/CMakeLists.txt | 6 +- .../src/ReflectedCallKnownReturn.cpp | 159 ++++++++++++++++++ ...ectedCall.h => ReflectedCallKnownReturn.h} | 6 +- ...all.cpp => ReflectedCallUnknownReturn.cpp} | 81 +++------ .../src/ReflectedCallUnknownReturn.h | 18 ++ RTLBenchmarkApp/src/StandardCall.cpp | 12 +- RTLBenchmarkApp/src/StandardCall.h | 4 +- RTLBenchmarkApp/src/main.cpp | 24 +-- .../CxxMirrorTests/CxxMirrorObjectTest.cpp | 8 +- .../rtl/builder/FunctorContainer.h | 4 +- .../rtl/builder/SetupConstructor.hpp | 2 +- .../rtl/builder/SetupFunction.hpp | 11 +- .../rtl/builder/SetupMethod.hpp | 24 ++- .../rtl/cache/CMakeLists.txt | 3 +- .../rtl/cache/functor_cache.h | 28 +-- .../rtl/cache/functor_cache_const.h | 26 +-- .../rtl/cache/functor_cache_nonconst.h | 26 +-- .../rtl/cache/lambda_cache.h | 68 -------- .../rtl/cache/lambda_function_cache.h | 59 +++++++ .../rtl/cache/lambda_method_cache.h | 51 ++++++ .../rtl/detail/inc/FunctorId.h | 12 ++ .../rtl/detail/inc/ReflectCast.h | 6 +- .../rtl/detail/inc/forward_decls.h | 21 +++ .../rtl/dispatch/CMakeLists.txt | 5 +- .../rtl/dispatch/CallReflector.h | 12 +- .../rtl/dispatch/FunctionCaller.h | 7 +- .../rtl/dispatch/MethodInvoker.h | 5 +- .../rtl/dispatch/dispatch_interface.h | 53 ++++-- ReflectionTemplateLib/rtl/dispatch/hopper.h | 58 +++---- .../rtl/dispatch/hopper_const.h | 4 +- .../rtl/dispatch/hopper_ctor.h | 12 +- .../rtl/dispatch/hopper_nonconst.h | 62 ++++++- ReflectionTemplateLib/rtl/dispatch/lambda.h | 114 ------------- .../rtl/dispatch/lambda_function.h | 60 +++++++ .../rtl/dispatch/lambda_function.hpp | 46 +++++ .../rtl/dispatch/lambda_method.h | 53 ++++++ .../rtl/dispatch/lambda_method.hpp | 52 ++++++ ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/src/CxxMirror.cpp | 2 +- .../rtl/src/CxxMirrorToJson.cpp | 2 +- 40 files changed, 806 insertions(+), 402 deletions(-) create mode 100644 RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp rename RTLBenchmarkApp/src/{ReflectedCall.h => ReflectedCallKnownReturn.h} (70%) rename RTLBenchmarkApp/src/{ReflectedCall.cpp => ReflectedCallUnknownReturn.cpp} (59%) create mode 100644 RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h delete mode 100644 ReflectionTemplateLib/rtl/cache/lambda_cache.h create mode 100644 ReflectionTemplateLib/rtl/cache/lambda_function_cache.h create mode 100644 ReflectionTemplateLib/rtl/cache/lambda_method_cache.h delete mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_function.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_method.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp diff --git a/RTLBenchmarkApp/CMakeLists.txt b/RTLBenchmarkApp/CMakeLists.txt index 72cd7492..7e94e053 100644 --- a/RTLBenchmarkApp/CMakeLists.txt +++ b/RTLBenchmarkApp/CMakeLists.txt @@ -41,8 +41,10 @@ add_executable(${CXX_EXE_NAME} src/StandardCall.h src/StandardCall.cpp src/StdFunction.cpp - src/ReflectedCall.h - src/ReflectedCall.cpp + src/ReflectedCallKnownReturn.h + src/ReflectedCallKnownReturn.cpp + src/ReflectedCallUnknownReturn.h + src/ReflectedCallUnknownReturn.cpp ) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp new file mode 100644 index 00000000..9ea401fb --- /dev/null +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -0,0 +1,159 @@ + +#include +#include +#include + +#include "BenchMark.h" +#include "ReflectedCallKnownReturn.h" + + +namespace bm +{ + extern std::optional g_work_done; +} + +namespace cxx +{ + extern const rtl::CxxMirror& mirror(); +} + +namespace +{ + static const rtl::dispatch::lambda* GetMessage_lambda = nullptr; + + static const rtl::dispatch::lambda* SendMessage_lambda = nullptr; + + static const rtl::dispatch::lambda* NodeGetMessage_lambda = nullptr; + + static const rtl::dispatch::lambda* NodeSendMessage_lambda = nullptr; + + static const rtl::RObject nodeObj = []() + { + rtl::Record Node = cxx::mirror().getRecord("Node").value(); + + rtl::Method getMsgNode = Node.getMethod("getMessage").value(); + + rtl::Method sendMsgNode = Node.getMethod("sendMessage").value(); + + rtl::Function getMsg = cxx::mirror().getFunction("getMessage").value(); + + rtl::Function sendMsg = cxx::mirror().getFunction("sendMessage").value(); + + GetMessage_lambda = getMsg.getOverloads()[0].get_lambda_function(); + + SendMessage_lambda = sendMsg.getOverloads()[0].get_lambda_function(); + + NodeGetMessage_lambda = getMsgNode.getOverloads()[0].get_lambda_function(); + + NodeSendMessage_lambda = sendMsgNode.getOverloads()[0].get_lambda_function(); + + auto [err, robj] = Node.create(); + + if (robj.isEmpty()) { + std::cout << "[0] error: " << rtl::to_string(err) << "\n"; + } + + return std::move(robj); + }(); +} + + +namespace +{ + static auto _test0 = []() + { + if( SendMessage_lambda == nullptr || + !SendMessage_lambda->is_returning() || + !SendMessage_lambda->is_signature()) + { + std::cout << "[0] error: signature mismatch.\n"; + return false; + } + return true; + }; + + + static auto _test1 = []() + { + if (NodeSendMessage_lambda == nullptr) + { + std::cout << "[1] error: signature mismatch.\n"; + return false; + } + return true; + }; + + + static auto _test2 = []() + { + if ( GetMessage_lambda == nullptr || + !GetMessage_lambda->is_returning() || + !GetMessage_lambda->is_signature()) + { + std::cout << "[0] error: signature mismatch.\n"; + return false; + } + return true; + }; + + static auto _test3 = []() + { + if (NodeGetMessage_lambda == nullptr) + { + std::cout << "[3] error: signature mismatch.\n"; + return false; + } + return true; + }; +} + + + +void ReflectedCallKnownReturn::set(benchmark::State& state) +{ + static auto passed = _test0(); + for (auto _ : state) + { + if (passed) + { + (*SendMessage_lambda).dispatch(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } + } +} + + +void ReflectedCallKnownReturn::get(benchmark::State& state) +{ + static auto passed = _test2(); + for (auto _: state) + { + if (passed) + { + auto retStr = (*GetMessage_lambda).dispatch(bm::g_longStr); + benchmark::DoNotOptimize(retStr); + } + } +} + + +void ReflectedMethodCallKnownReturn::set(benchmark::State& state) +{ + //static auto _=_test1(); + //for (auto _: state) + //{ + // auto error = (NodeSendMessage(nodeObj)(bm::g_longStr).err; + // benchmark::DoNotOptimize(error); + //} +} + + +void ReflectedMethodCallKnownReturn::get(benchmark::State& state) +{ + //static auto _=_test3(); + //for (auto _: state) + //{ + // auto error = NodeGetMessage(nodeObj)(bm::g_longStr).err; + // benchmark::DoNotOptimize(error); + //} +} \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCall.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h similarity index 70% rename from RTLBenchmarkApp/src/ReflectedCall.h rename to RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index 77b410c5..42a9011f 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -2,17 +2,15 @@ #include -struct ReflectedCall +struct ReflectedCallKnownReturn { static void set(benchmark::State& state); static void get(benchmark::State& state); - - static void new_design_set(benchmark::State& state); }; -struct ReflectedMethodCall +struct ReflectedMethodCallKnownReturn { static void set(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/ReflectedCall.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp similarity index 59% rename from RTLBenchmarkApp/src/ReflectedCall.cpp rename to RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 84cc6370..34f7fb43 100644 --- a/RTLBenchmarkApp/src/ReflectedCall.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -2,16 +2,10 @@ #include #include -#include "ReflectedCall.h" #include "BenchMark.h" +#include "ReflectedCallUnknownReturn.h" - -namespace bm -{ - extern std::optional g_work_done; -} - -namespace cxx +namespace cxx { extern const rtl::CxxMirror& mirror(); } @@ -23,19 +17,19 @@ namespace static rtl::Method NodeGetMessage; static rtl::Method NodeSendMessage; - - static rtl::RObject nodeObj = []() - { + + static rtl::RObject nodeObj = []() + { GetMessage = cxx::mirror().getFunction("getMessage").value(); - + SendMessage = cxx::mirror().getFunction("sendMessage").value(); - auto Node = cxx::mirror().getRecord("Node").value(); + rtl::Record Node = cxx::mirror().getRecord("Node").value(); NodeGetMessage = Node.getMethod("getMessage").value(); - + NodeSendMessage = Node.getMethod("sendMessage").value(); - + auto [err, robj] = Node.create(); if (robj.isEmpty()) { @@ -52,30 +46,16 @@ namespace static auto _test0 = []() { auto err = SendMessage(bm::g_longStr).err; - if (err != rtl::error::None) { - std::cout << "[0] error: "<< rtl::to_string(err)<<"\n"; + std::cout << "[0] error: " << rtl::to_string(err) << "\n"; } return 0; }; - - static auto _test4 = []() - { - auto& hopper = (SendMessage.getFunctors()[0].m_lambda)->get(); - //auto err = hopper(bm::g_longStr).err; - //if (err != rtl::error::None) { - // std::cout << "[4] error: " << rtl::to_string(err) << "\n"; - //} - return hopper; - }; - - static auto _test1 = []() { auto err = NodeSendMessage(nodeObj)(bm::g_longStr).err; - - if (err != rtl::error::None) { + if (err != rtl::error::None) { std::cout << "[1] error: " << rtl::to_string(err) << "\n"; } return 0; @@ -84,7 +64,6 @@ namespace static auto _test2 = []() { auto err = GetMessage(bm::g_longStr).err; - if (err != rtl::error::None) { std::cout << "[2] error: " << rtl::to_string(err) << "\n"; } @@ -94,7 +73,6 @@ namespace static auto _test3 = []() { auto err = NodeGetMessage(nodeObj)(bm::g_longStr).err; - if (err != rtl::error::None) { std::cout << "[3] error: " << rtl::to_string(err) << "\n"; } @@ -104,43 +82,32 @@ namespace -void ReflectedCall::set(benchmark::State& state) +void ReflectedCallUnknownReturn::set(benchmark::State& state) { - static auto _=_test0(); - for (auto _: state) { - + static auto _ = _test0(); + for (auto _ : state) + { auto error = SendMessage(bm::g_longStr).err; benchmark::DoNotOptimize(error); } } -void ReflectedCall::get(benchmark::State& state) +void ReflectedCallUnknownReturn::get(benchmark::State& state) { - static auto _=_test2(); - for (auto _: state) + static auto _ = _test2(); + for (auto _ : state) { auto error = GetMessage(bm::g_longStr).err; benchmark::DoNotOptimize(error); } } -void ReflectedCall::new_design_set(benchmark::State& state) -{ - static const auto& hopper = _test4(); - for (auto _ : state) { - - hopper.call(bm::g_longStr); - //auto ret = hopper(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); - } -} - -void ReflectedMethodCall::set(benchmark::State& state) +void ReflectedMethodCallUnknownReturn::set(benchmark::State& state) { - static auto _=_test1(); - for (auto _: state) + static auto _ = _test1(); + for (auto _ : state) { auto error = NodeSendMessage(nodeObj)(bm::g_longStr).err; benchmark::DoNotOptimize(error); @@ -148,10 +115,10 @@ void ReflectedMethodCall::set(benchmark::State& state) } -void ReflectedMethodCall::get(benchmark::State& state) +void ReflectedMethodCallUnknownReturn::get(benchmark::State& state) { - static auto _=_test3(); - for (auto _: state) + static auto _ = _test3(); + for (auto _ : state) { auto error = NodeGetMessage(nodeObj)(bm::g_longStr).err; benchmark::DoNotOptimize(error); diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h new file mode 100644 index 00000000..65c28df9 --- /dev/null +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +struct ReflectedCallUnknownReturn +{ + static void set(benchmark::State& state); + + static void get(benchmark::State& state); +}; + + +struct ReflectedMethodCallUnknownReturn +{ + static void set(benchmark::State& state); + + static void get(benchmark::State& state); +}; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 39dda878..419fd315 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -9,8 +9,8 @@ namespace { static auto _put_line = []() { - std::cout << "-------------------------------------" - "-------------------------------------" << std::endl; + std::cout << "----------------------------------------" + "----------------------------------------" << std::endl; return 0; }; @@ -59,7 +59,7 @@ void NativeCall::get(benchmark::State& state) } -void StdFuncCall::set(benchmark::State& state) +void StdFunctionCall::set(benchmark::State& state) { static auto _=_new_line(); for (auto _: state) @@ -70,7 +70,7 @@ void StdFuncCall::set(benchmark::State& state) } -void StdFuncMethodCall::set(benchmark::State& state) +void StdFunctionMethodCall::set(benchmark::State& state) { static auto _=_new_line(); for (auto _: state) @@ -81,7 +81,7 @@ void StdFuncMethodCall::set(benchmark::State& state) } -void StdFuncCall::get(benchmark::State& state) +void StdFunctionCall::get(benchmark::State& state) { static auto _=_new_line(); for (auto _: state) @@ -91,7 +91,7 @@ void StdFuncCall::get(benchmark::State& state) } -void StdFuncMethodCall::get(benchmark::State& state) +void StdFunctionMethodCall::get(benchmark::State& state) { static auto _=_new_line(); for (auto _: state) diff --git a/RTLBenchmarkApp/src/StandardCall.h b/RTLBenchmarkApp/src/StandardCall.h index da2e4a45..76bd70f2 100644 --- a/RTLBenchmarkApp/src/StandardCall.h +++ b/RTLBenchmarkApp/src/StandardCall.h @@ -10,7 +10,7 @@ struct NativeCall }; -struct StdFuncCall +struct StdFunctionCall { static void set(benchmark::State& state); @@ -18,7 +18,7 @@ struct StdFuncCall }; -struct StdFuncMethodCall +struct StdFunctionMethodCall { static void set(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index e2de9214..77914b8a 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -4,24 +4,28 @@ #include #include "StandardCall.h" -#include "ReflectedCall.h" +#include "ReflectedCallKnownReturn.h" +#include "ReflectedCallUnknownReturn.h" BENCHMARK(NativeCall::set); -BENCHMARK(StdFuncCall::set); -BENCHMARK(ReflectedCall::new_design_set); -BENCHMARK(ReflectedCall::set); +BENCHMARK(StdFunctionCall::set); +BENCHMARK(ReflectedCallKnownReturn::set); +BENCHMARK(ReflectedCallUnknownReturn::set); -BENCHMARK(StdFuncMethodCall::set); -BENCHMARK(ReflectedMethodCall::set); +BENCHMARK(StdFunctionMethodCall::set); +//BENCHMARK(ReflectedMethodCallKnownReturn::set); +BENCHMARK(ReflectedMethodCallUnknownReturn::set); BENCHMARK(NativeCall::get); -BENCHMARK(StdFuncCall::get); -BENCHMARK(ReflectedCall::get); +BENCHMARK(StdFunctionCall::get); +BENCHMARK(ReflectedCallKnownReturn::get); +BENCHMARK(ReflectedCallUnknownReturn::get); -BENCHMARK(StdFuncMethodCall::get); -BENCHMARK(ReflectedMethodCall::get); +BENCHMARK(StdFunctionMethodCall::get); +//BENCHMARK(ReflectedMethodCallKnownReturn::get); +BENCHMARK(ReflectedMethodCallUnknownReturn::get); namespace bm { diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp index d6f62f6e..41492567 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp @@ -287,8 +287,8 @@ namespace rtl_tests // Even though the functions are registered in different namespaces, // the underlying FunctorIds (which identify function-pointers) must be equal. - const std::vector& cfunctorIds = cstrLen->getFunctors(); - const std::vector& stdfunctorIds = stdStrLen->getFunctors(); + const std::vector& cfunctorIds = cstrLen->getOverloads(); + const std::vector& stdfunctorIds = stdStrLen->getOverloads(); EXPECT_EQ(cfunctorIds, stdfunctorIds); } @@ -349,8 +349,8 @@ namespace rtl_tests // Despite different symbolic names, both reflect the same function-pointer. // Hence, their FunctorIds must be identical. - const std::vector& cfunctorIds = cstrLen->getFunctors(); - const std::vector& stdfunctorIds = stdStrLen->getFunctors(); + const std::vector& cfunctorIds = cstrLen->getOverloads(); + const std::vector& stdfunctorIds = stdStrLen->getOverloads(); EXPECT_EQ(cfunctorIds, stdfunctorIds); } diff --git a/ReflectionTemplateLib/rtl/builder/FunctorContainer.h b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h index 2ecfbf4c..532fa188 100644 --- a/ReflectionTemplateLib/rtl/builder/FunctorContainer.h +++ b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h @@ -15,7 +15,7 @@ #include #include -#include "lambda_cache.h" +#include "lambda_function_cache.h" #include "rtl_constants.h" #include "CallReflector.h" #include "SetupFunction.h" @@ -47,7 +47,7 @@ namespace rtl { } //get the vector holding lambdas as 'const-ref' - FORCE_INLINE const static std::vector& getFunctors() { + FORCE_INLINE const static std::vector& getOverloads() { static std::vector& functorTable = getFunctorTable(); return functorTable; } diff --git a/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp b/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp index bfa6a1cd..dfe8245e 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp @@ -175,7 +175,7 @@ namespace rtl::detail return (itr != ctorSet.end() ? itr->second : index_none); }; - //auto& lambdaCache = lambda_cache::get<_signature...>(); + //auto& lambdaCache = lambda_function::get<_signature...>(); //const auto& pushLambdaHopper = [&]()-> std::size_t //{ // return lambdaCache.push_cloner<_recordType>(); diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index ac0cc135..5be59247 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -13,8 +13,9 @@ #include -#include "lambda_cache.h" #include "functor_cache.h" +#include "lambda_function.hpp" +#include "lambda_function_cache.h" #include "SetupFunction.h" #include "RObjectBuilder.hpp" @@ -93,16 +94,16 @@ namespace rtl const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); - auto& functorCache = dispatch::functor_cache<_signature...>::instance(); + auto& lambdaCache = cache::lambda_function<_signature...>::instance(); + auto& functorCache = cache::function_ptr<_signature...>::instance(); auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambda = lambdaCache.template push_function<_returnType>(functor); + auto& lambda = lambdaCache.template push<_returnType>(functor); lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { - auto& functorCache = dispatch::functor_cache<_signature...>::instance(); + auto& functorCache = cache::function_ptr<_signature...>::instance(); auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index f420f873..d2ecf3d7 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -21,6 +21,10 @@ #include "functor_cache_const.h" #include "functor_cache_nonconst.h" +#include "lambda_method.hpp" +#include "lambda_method_cache.h" + + namespace rtl::detail { template @@ -164,17 +168,20 @@ namespace rtl::detail const dispatch::lambda_hop* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); - auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _signature...>::instance(); + auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); + auto& functorCache = cache::method_ptr<_recordType, _signature...>::instance(); + auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambda = lambdaCache.template push_method_nonconst<_recordType, _returnType>(functor); + auto& lambda = lambdaCache.template push<_recordType, _returnType>(functor); + lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { - auto& functorCache = dispatch::functor_cache_nonconst<_recordType, _signature...>::instance(); + auto& functorCache = cache::method_ptr<_recordType, _signature...>::instance(); auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); + if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; } @@ -232,17 +239,20 @@ namespace rtl::detail const dispatch::lambda_hop* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = dispatch::lambda_cache<_signature...>::instance(); - auto& functorCache = dispatch::functor_cache_const<_recordType, _signature...>::instance(); + auto& lambdaCache = cache::lambda_function<_signature...>::instance(); + auto& functorCache = cache::const_method_ptr<_recordType, _signature...>::instance(); + auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); auto& lambda = lambdaCache.template push_method_const<_recordType, _returnType>(functor); + lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { - auto& functorCache = dispatch::functor_cache_const<_recordType, _signature...>::instance(); + auto& functorCache = cache::const_method_ptr<_recordType, _signature...>::instance(); auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); + if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; } diff --git a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt index bd77a74f..e31be8d4 100644 --- a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt @@ -2,7 +2,8 @@ # Collect headers (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_cache.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method_cache.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function_cache.h" "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache.h" "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache_const.h" "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache_nonconst.h" diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache.h b/ReflectionTemplateLib/rtl/cache/functor_cache.h index 4ba654a8..484ee6e0 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache.h @@ -15,23 +15,23 @@ #include "functor.h" -namespace rtl::dispatch +namespace rtl::cache { template - struct functor_cache + struct function_ptr { - using functor_t = functor; + using functor_t = dispatch::functor; - static const functor_cache& instance() + static const function_ptr& instance() { - static functor_cache instance_; + static function_ptr instance_; return instance_; } template - const functor_hop* push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const + const dispatch::functor_hop* push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const { - using voidfn_t = typename functor::voidfn_t; + using voidfn_t = typename dispatch::functor::voidfn_t; auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); m_cache.emplace_back(std::make_pair(functor , lambda_index)); @@ -39,7 +39,7 @@ namespace rtl::dispatch } template - std::pair find(return_t(*fptr)(signature_ts...)) const + std::pair find(return_t(*fptr)(signature_ts...)) const { for (auto& itr : m_cache) { @@ -51,16 +51,16 @@ namespace rtl::dispatch return { nullptr, rtl::index_none }; } - functor_cache(functor_cache&&) = delete; - functor_cache(const functor_cache&) = delete; - functor_cache& operator=(functor_cache&&) = delete; - functor_cache& operator=(const functor_cache&) = delete; + function_ptr(function_ptr&&) = delete; + function_ptr(const function_ptr&) = delete; + function_ptr& operator=(function_ptr&&) = delete; + function_ptr& operator=(const function_ptr&) = delete; private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; - functor_cache() {} + function_ptr() {} }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h b/ReflectionTemplateLib/rtl/cache/functor_cache_const.h index a7a351a3..c1775fce 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_const.h @@ -15,23 +15,23 @@ #include "functor_const.h" -namespace rtl::dispatch +namespace rtl::cache { template - struct functor_cache_const + struct const_method_ptr { - using functor_t = functor_const; + using functor_t = dispatch::functor_const; - static const functor_cache_const& instance() + static const const_method_ptr& instance() { - static functor_cache_const instance_; + static const_method_ptr instance_; return instance_; } template - const functor_hop* push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const + const dispatch::functor_hop* push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const { - using voidfn_t = typename functor_const::voidfn_t; + using voidfn_t = typename dispatch::functor_const::voidfn_t; auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); @@ -39,7 +39,7 @@ namespace rtl::dispatch } template - std::pair find(return_t(record_t::* fptr)(signature_ts...) const) const + std::pair find(return_t(record_t::* fptr)(signature_ts...) const) const { for (auto& itr : m_cache) { @@ -51,16 +51,16 @@ namespace rtl::dispatch return { nullptr, rtl::index_none }; } - functor_cache_const(functor_cache_const&&) = delete; - functor_cache_const(const functor_cache_const&) = delete; - functor_cache_const& operator=(functor_cache_const&&) = delete; - functor_cache_const& operator=(const functor_cache_const&) = delete; + const_method_ptr(const_method_ptr&&) = delete; + const_method_ptr(const const_method_ptr&) = delete; + const_method_ptr& operator=(const_method_ptr&&) = delete; + const_method_ptr& operator=(const const_method_ptr&) = delete; private: // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - functor_cache_const() {} + const_method_ptr() {} }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h index e9a240e9..41e67629 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h +++ b/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h @@ -15,30 +15,30 @@ #include "functor_nonconst.h" -namespace rtl::dispatch +namespace rtl::cache { template - struct functor_cache_nonconst + struct method_ptr { - using functor_t = functor_nonconst; + using functor_t = dispatch::functor_nonconst; - static const functor_cache_nonconst& instance() + static const method_ptr& instance() { - static const functor_cache_nonconst instance_; + static const method_ptr instance_; return instance_; } template - const functor_hop* push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const + const dispatch::functor_hop* push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const { - using voidfn_t = typename functor_nonconst::voidfn_t; + using voidfn_t = typename dispatch::functor_nonconst::voidfn_t; auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); } template - std::pair find(return_t(record_t::* fptr)(signature_ts...)) const + std::pair find(return_t(record_t::* fptr)(signature_ts...)) const { for (auto& itr : m_cache) { @@ -50,16 +50,16 @@ namespace rtl::dispatch return { nullptr, rtl::index_none }; } - functor_cache_nonconst(functor_cache_nonconst&&) = delete; - functor_cache_nonconst(const functor_cache_nonconst&) = delete; - functor_cache_nonconst& operator=(functor_cache_nonconst&&) = delete; - functor_cache_nonconst& operator=(const functor_cache_nonconst&) = delete; + method_ptr(method_ptr&&) = delete; + method_ptr(const method_ptr&) = delete; + method_ptr& operator=(method_ptr&&) = delete; + method_ptr& operator=(const method_ptr&) = delete; private: // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - functor_cache_nonconst() {} + method_ptr() {} }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/lambda_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_cache.h deleted file mode 100644 index 21d249f1..00000000 --- a/ReflectionTemplateLib/rtl/cache/lambda_cache.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include - -#include "lambda.h" - -namespace rtl::dispatch -{ - template - struct lambda_cache - { - static lambda_cache& instance() - { - static lambda_cache instance_; - return instance_; - } - - template - const lambda& push_function(const functor_hop* fptr_hopper) - { - m_cache.push_back(lambda::template create_function(fptr_hopper)); - const lambda& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; - } - - template - const lambda& push_method_const(const functor_hop* fptr_hopper) - { - m_cache.push_back(lambda::template create_method_const(fptr_hopper)); - const lambda& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; - } - - template - const lambda& push_method_nonconst(const functor_hop* fptr_hopper) - { - m_cache.push_back(lambda::template create_method_nonconst(fptr_hopper)); - const lambda& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; - } - - lambda_cache(lambda_cache&&) = delete; - lambda_cache(const lambda_cache&) = delete; - lambda_cache& operator=(lambda_cache&&) = delete; - lambda_cache& operator=(const lambda_cache&) = delete; - - private: - - // No reallocation occurs; original objects stay intact - std::list> m_cache; - - lambda_cache() {} - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/lambda_function_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_function_cache.h new file mode 100644 index 00000000..fae533a3 --- /dev/null +++ b/ReflectionTemplateLib/rtl/cache/lambda_function_cache.h @@ -0,0 +1,59 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "lambda_function.h" + +namespace rtl::cache +{ + template + struct lambda_function + { + static const lambda_function& instance() + { + static const lambda_function instance_; + return instance_; + } + + template + const dispatch::lambda& push(const dispatch::functor_hop* fptr_hopper) const + { + m_cache.push_back(dispatch::lambda::template create(fptr_hopper)); + const dispatch::lambda& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; + } + + template + const dispatch::lambda& push_method_const(const dispatch::functor_hop* fptr_hopper) const + { + m_cache.push_back(dispatch::lambda::template create_method_const(fptr_hopper)); + const dispatch::lambda& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; + } + + lambda_function(lambda_function&&) = delete; + lambda_function(const lambda_function&) = delete; + lambda_function& operator=(lambda_function&&) = delete; + lambda_function& operator=(const lambda_function&) = delete; + + private: + + // No reallocation occurs; original objects stay intact + mutable std::list> m_cache; + + lambda_function() {} + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h new file mode 100644 index 00000000..a43268ed --- /dev/null +++ b/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h @@ -0,0 +1,51 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "lambda_function.h" + + +namespace rtl::cache +{ + template + struct lambda_method + { + static const lambda_method& instance() + { + static const lambda_method instance_; + return instance_; + } + + template + const dispatch::lambda_method& push(const dispatch::functor_hop* fptr_hopper) const + { + m_cache.push_back(dispatch::lambda_method::template create(fptr_hopper)); + const dispatch::lambda_method& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; + } + + lambda_method(lambda_method&&) = delete; + lambda_method(const lambda_method&) = delete; + lambda_method& operator=(lambda_method&&) = delete; + lambda_method& operator=(const lambda_method&) = delete; + + private: + + // No reallocation occurs; original objects stay intact + mutable std::list> m_cache; + + lambda_method() {} + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 788827bb..6514cfc2 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -14,6 +14,8 @@ #include "rtl_typeid.h" #include "rtl_constants.h" #include "forward_decls.h" +#include "lambda_method.h" +#include "lambda_function.h" namespace rtl::detail { @@ -49,6 +51,16 @@ namespace rtl::detail GETTER(std::size_t, SignatureId, m_containerId) GETTER(std::string, SignatureStr, m_signature) + template + const dispatch::lambda<_signature...>* get_lambda_function() const { + return m_lambda->get_function<_signature...>(); + } + + template + const dispatch::lambda_method<_signature...>* get_lambda_method() const { + return m_lambda->get_method(); + } + /* @method: getHashCode() @return: std::size_t (a unique hash-code for a functor) * 'm_containerId' will be same for functors(non-member) with same signatures. diff --git a/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h index ae748ba8..1e3fc638 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h +++ b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h @@ -16,11 +16,7 @@ #include #include "rtl_traits.h" - -namespace rtl { - - class CxxMirror; -} +#include "forward_decls.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 46404cb9..0e1776b9 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -19,6 +19,12 @@ namespace rtl class RObject; + class Function; + + class Method; + + class CxxMirror; + namespace detail { struct FunctorId; @@ -32,5 +38,20 @@ namespace rtl struct lambda_hop; struct functor_hop; + + template + class lambda; + + template + class lambda_method; + + template + struct functor; + + template + struct functor_const; + + template + struct functor_nonconst; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index cb9634e1..45ffd2a7 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -8,7 +8,10 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/functor_const.h" "${CMAKE_CURRENT_SOURCE_DIR}/functor_nonconst.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/hopper.h" "${CMAKE_CURRENT_SOURCE_DIR}/hopper_ctor.h" "${CMAKE_CURRENT_SOURCE_DIR}/hopper_const.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/CallReflector.h b/ReflectionTemplateLib/rtl/dispatch/CallReflector.h index 4940eb8f..775b6786 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CallReflector.h +++ b/ReflectionTemplateLib/rtl/dispatch/CallReflector.h @@ -33,8 +33,8 @@ namespace rtl::detail { */ template FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, _params&&..._args) { - //'getFunctors()' must be implemented by _derivedType (FunctorContainer). - return _derivedType::getFunctors()[pFunctorId.m_lambdaIndex](pFunctorId, std::forward<_params>(_args)...); + //'getOverloads()' must be implemented by _derivedType (FunctorContainer). + return _derivedType::getOverloads()[pFunctorId.m_lambdaIndex](pFunctorId, std::forward<_params>(_args)...); } @@ -45,16 +45,16 @@ namespace rtl::detail { */ template FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, rtl::alloc pAllocType, const detail::FunctorId& pClonerId, _params&&..._args) { - //'getFunctors()' must be implemented by _derivedType (FunctorContainer). - return _derivedType::getFunctors()[pFunctorId.m_lambdaIndex](pFunctorId, pAllocType, pClonerId, std::forward<_params>(_args)...); + //'getOverloads()' must be implemented by _derivedType (FunctorContainer). + return _derivedType::getOverloads()[pFunctorId.m_lambdaIndex](pFunctorId, pAllocType, pClonerId, std::forward<_params>(_args)...); } template FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, const RObject& pSrcObj, rtl::alloc pAllocType) { - //'getFunctors()' must be implemented by _derivedType (FunctorContainer). - return _derivedType::getFunctors()[pFunctorId.m_lambdaIndex](pFunctorId, pSrcObj, pAllocType); + //'getOverloads()' must be implemented by _derivedType (FunctorContainer). + return _derivedType::getOverloads()[pFunctorId.m_lambdaIndex](pFunctorId, pSrcObj, pAllocType); } diff --git a/ReflectionTemplateLib/rtl/dispatch/FunctionCaller.h b/ReflectionTemplateLib/rtl/dispatch/FunctionCaller.h index fdcfb53b..ae63d80a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/dispatch/FunctionCaller.h @@ -11,12 +11,9 @@ #pragma once -#include "RObject.h" +#include "forward_decls.h" -namespace rtl -{ - class Function; -} +#include "RObject.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/dispatch/MethodInvoker.h b/ReflectionTemplateLib/rtl/dispatch/MethodInvoker.h index 198cf761..4cbb83fe 100644 --- a/ReflectionTemplateLib/rtl/dispatch/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/dispatch/MethodInvoker.h @@ -11,11 +11,8 @@ #pragma once -namespace rtl { +#include "forward_decls.h" - //forward decls - class Method; -} namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h index eee70c23..6c720eb0 100644 --- a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h +++ b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h @@ -19,11 +19,6 @@ namespace rtl::dispatch { - struct functor_hop; - - template - struct lambda; - struct lambda_hop { const functor_hop& functor() const @@ -31,15 +26,50 @@ namespace rtl::dispatch return *m_functor; } + template + bool is_member() const + { + return (m_recordId == detail::TypeId>::get() || + m_recordId == detail::TypeId>::get()); + } + + template + bool is_returning() const + { + return (m_returnId == detail::TypeId::get()); + } + + template + bool is_signature() const + { + return (m_signatureId == detail::TypeId>::get()); + } + template - const lambda& get() const + const lambda* get_function() const { - return (*static_cast*>(this)); + std::size_t typeId = detail::TypeId>::get(); + if (typeId == m_signatureId) { + return static_cast*>(this); + } + return nullptr; + } + + template + const lambda_method* get_method() const + { + std::size_t recordId = detail::TypeId::get(); + std::size_t typeId = detail::TypeId>::get(); + if (typeId == m_signatureId && recordId == m_recordId) { + return static_cast*>(this); + } + return nullptr; } // protected: const functor_hop* m_functor = nullptr; + std::size_t m_recordId = detail::TypeId<>::None; std::size_t m_returnId = detail::TypeId<>::None; std::size_t m_signatureId = detail::TypeId<>::None; std::vector m_argumentsId = {}; @@ -49,15 +79,6 @@ namespace rtl::dispatch namespace rtl::dispatch { - template - struct functor; - - template - struct functor_const; - - template - struct functor_nonconst; - struct functor_hop { void set_lambda(const lambda_hop* lambda) const diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper.h b/ReflectionTemplateLib/rtl/dispatch/hopper.h index 62a26bbb..11451ff9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper.h @@ -13,7 +13,7 @@ #include -#include "lambda.h" +#include "lambda_function.h" #include "functor.h" //#include "RObjectBuilder.hpp" @@ -22,59 +22,59 @@ namespace rtl::dispatch template struct hopper { - template - static decltype(auto) function(const lambda_hop& lambda_ref, signature_ts&&...params) noexcept + template requires (std::is_same_v == false) + static decltype(auto) dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept { - auto functor = lambda_ref.functor().template get().template get(lambda_ref.m_returnId); + auto functor = lambda_ref.functor().template get() + .template get(lambda_ref.m_returnId); + if constexpr (std::is_same_v) { - (*functor)(std::forward(params)...); + (*functor)(params...); } else { - return (*functor)(std::forward(params)...); + return (*functor)(params...); } } - template requires (is_void_t == true) - static Return function(const lambda_hop& lambda_ref, signature_ts&&...params) noexcept + + template requires (void_t == true) + static Return dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept { - if constexpr (std::is_same_v) { - auto functor = lambda_ref.functor().template get().template get(lambda_ref.m_returnId); - (*functor)(std::forward(params)...); + if constexpr (std::is_same_v) + { + auto functor = lambda_ref.functor().template get() + .template get(lambda_ref.m_returnId); + + (*functor)(params...); } - else { + else + { static_assert("return-type mismatch."); } return { error::None, RObject{} }; } - template requires (is_void_t == false) - static Return function(const lambda_hop& lambda_ref, signature_ts&&...params) noexcept + + template requires (void_t == false) + static Return dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept { constexpr bool isConstCastSafe = (!traits::is_const_v); - auto functor = lambda_ref.functor().template get().template get(lambda_ref.m_returnId); + auto functor = lambda_ref.functor().template get() + .template get(lambda_ref.m_returnId); if constexpr (std::is_reference_v) { using T = traits::raw_t; - const T& retObj = functor(std::forward(params)...); - - //return { error::None, - // detail::RObjectBuilder::template - // build(&retObj, std::nullopt, isConstCastSafe) - //}; + const T& retObj = (*functor)(params...); + return { error::None, RObject{} }; } else { - auto&& retObj = functor(std::forward(params)...); - using T = std::remove_cvref_t; - - //return { error::None, - // detail::RObjectBuilder::template - // build(std::forward(retObj), std::nullopt, isConstCastSafe) - //}; + //auto&& retObj = (*functor)(params...); + //using T = std::remove_cvref_t; + return { error::None, RObject{} }; } - return { error::None, RObject{} }; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_const.h b/ReflectionTemplateLib/rtl/dispatch/hopper_const.h index 57edc292..00acfdc4 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_const.h @@ -11,7 +11,7 @@ #pragma once -#include "lambda.h" +#include "lambda_function.h" namespace rtl::dispatch { @@ -19,7 +19,7 @@ namespace rtl::dispatch struct hopper_const { template - static Return method(const lambda_hop&, signature_ts&&...) noexcept + static Return dispatch(const lambda_hop&, const signature_ts&...) noexcept { return { error::EmptyRObject, RObject{} }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h b/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h index 629f9cd2..076e6cb9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h @@ -12,7 +12,7 @@ #pragma once -#include "lambda.h" +#include "lambda_function.h" namespace rtl::dispatch { @@ -20,15 +20,21 @@ namespace rtl::dispatch struct hopper_ctor { template - static Return cloner(const lambda_hop&, signature_ts&&...) noexcept + static Return dispatch(const lambda_hop&, const signature_ts&...) noexcept { return { error::EmptyRObject, RObject{} }; } + }; + + template + struct hopper_copyctor + { template - static Return constructor(const lambda_hop&, signature_ts&&...) noexcept + static Return dispatch(const lambda_hop&, signature_ts&&...) noexcept { return { error::EmptyRObject, RObject{} }; } }; + } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h index efdd6ca3..e629ad66 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h @@ -11,17 +11,69 @@ #pragma once -#include "lambda.h" +#include "forward_decls.h" + +#include "lambda_function.h" +#include "functor.h" namespace rtl::dispatch { - template + template struct hopper_nonconst { - template - static Return method(const lambda_hop&, signature_ts&&...) noexcept + template requires (std::is_same_v == false) + static decltype(auto) dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept + { + auto functor = lambda_ref.functor().template get_nonconst() + .template get(lambda_ref.m_returnId); + + if constexpr (std::is_same_v) { + (target.*functor)(params...); + } + else { + return (target.*functor)(params...); + } + } + + + template requires (void_t == true) + static Return dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept + { + if constexpr (std::is_same_v) + { + auto functor = lambda_ref.functor().template get_nonconst() + .template get(lambda_ref.m_returnId); + + (target.*functor)(params...); + } + else + { + static_assert("return-type mismatch."); + } + return { error::None, RObject{} }; + } + + + template requires (void_t == false) + static Return dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept { - return { error::EmptyRObject, RObject{} }; + constexpr bool isConstCastSafe = (!traits::is_const_v); + + auto functor = lambda_ref.functor().template get_nonconst() + .template get(lambda_ref.m_returnId); + + if constexpr (std::is_reference_v) + { + using T = traits::raw_t; + const T& retObj = (target.*functor)(params...); + return { error::None, RObject{} }; + } + else { + + auto&& retObj = (target.*functor)(params...); + using T = std::remove_cvref_t; + return { error::None, RObject{} }; + } } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h deleted file mode 100644 index 6d95bd2f..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include -#include -#include - -#include "forward_decls.h" - -#include "hopper.h" -#include "hopper_ctor.h" -#include "hopper_const.h" -#include "hopper_nonconst.h" - -#include "dispatch_interface.h" - -namespace rtl::dispatch -{ - template - struct lambda: public lambda_hop - { - using lambda_t = std::function; - - template - static lambda create_ctor(const functor_hop* fptr_hopper) - { - return lambda(detail::TypeId::get(), fptr_hopper, - &hopper_ctor::template constructor); - } - - template - static lambda create_copy_ctor(const functor_hop* fptr_hopper) - { - return lambda(detail::TypeId::get(), fptr_hopper, - &hopper_ctor::template cloner); - } - - template - static lambda create_function(const functor_hop* fptr_hopper) - { - return lambda(detail::TypeId::get(), fptr_hopper, - &hopper::template function>); - } - - template - static lambda create_method_const(const functor_hop* fptr_hopper) - { - return lambda(detail::TypeId::get(), fptr_hopper, - &hopper_const::template method); - } - - template - static lambda create_method_nonconst(const functor_hop* fptr_hopper) - { - return lambda(detail::TypeId::get(), fptr_hopper, - &hopper_nonconst::template method); - } - - template - Return operator()(args_t&&...params) const noexcept - { - return m_hopper(*this, std::forward(params)...); - } - - template - decltype(auto) call(args_t&&...params) const noexcept - { - if constexpr (std::is_same_v) { - hopper::template function(*this, std::forward(params)...); - } - else { - return hopper::template function(*this, std::forward(params)...); - } - } - - private: - - const lambda_t m_hopper; - - lambda(std::size_t returnId, const functor_hop* functor, lambda_t hopper) noexcept - : m_hopper(std::move(hopper)) - { - m_functor = functor; - m_returnId = returnId; - m_signatureId = detail::TypeId>::get(); - detail::TypeId::get(m_argumentsId); - } - - template - static Return ctor(const lambda_hop&, signature_ts&&...) noexcept; - - template - static Return copy_ctor(const lambda_hop&, signature_ts&&...) noexcept; - - template - static return_t function(const lambda_hop&, signature_ts&&...) noexcept; - - template - static Return method_const(const lambda_hop&, signature_ts&&...) noexcept; - - template - static Return method_nonconst(const lambda_hop&, signature_ts&&...) noexcept; - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h new file mode 100644 index 00000000..8ff7d4aa --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -0,0 +1,60 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include +#include +#include + +#include "forward_decls.h" + +#include "hopper.h" +#include "hopper_ctor.h" +#include "hopper_const.h" +#include "dispatch_interface.h" + +namespace rtl::dispatch +{ + template + class lambda: public lambda_hop + { + using lambda_t = std::function; + + const lambda_t m_hopper; + + lambda(std::size_t returnId, const functor_hop* functor, lambda_t hopper) noexcept + : m_hopper(std::move(hopper)) + { + m_functor = functor; + m_returnId = returnId; + m_signatureId = detail::TypeId>::get(); + detail::TypeId::get(m_argumentsId); + } + + public: + + decltype(auto) operator()(const signature_ts&...) const noexcept; + + template + decltype(auto) dispatch(const signature_ts&...) const noexcept; + + template + static lambda create(const functor_hop*); + + template + static lambda create_method_const(const functor_hop* fptr_hopper) + { + return lambda(detail::TypeId::get(), fptr_hopper, + &hopper_const::template dispatch); + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp new file mode 100644 index 00000000..b959eb1a --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp @@ -0,0 +1,46 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "lambda_function.h" + +namespace rtl::dispatch +{ + template + template + static lambda lambda::create(const functor_hop* fptr_hopper) + { + return lambda(detail::TypeId::get(), fptr_hopper, + &hopper::template dispatch, return_t>); + } + + template + inline decltype(auto) lambda::operator()(const signature_ts& ...params) const noexcept + { + //TODO: static-assert signature_ts == args_t. + return m_hopper(*this, params...); + } + + + template + template + inline decltype(auto) lambda::dispatch(const signature_ts&...params) const noexcept + { + //TODO: static-assert signature_ts == args_t. + if constexpr (std::is_same_v) { + hopper::template dispatch(*this, params...); + } + else { + return hopper::template dispatch(*this, params...); + } + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h new file mode 100644 index 00000000..9cf7c1d9 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -0,0 +1,53 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "forward_decls.h" +#include "dispatch_interface.h" +#include "hopper_nonconst.h" + +namespace rtl::dispatch +{ + template + class lambda_method : public lambda_hop + { + using lambda_t = std::function; + + const lambda_t m_hopper; + + lambda_method(std::size_t returnId, const functor_hop* functor, lambda_t hopper) noexcept + : m_hopper(std::move(hopper)) + { + m_functor = functor; + m_returnId = returnId; + m_recordId = detail::TypeId::get(); + m_signatureId = detail::TypeId>::get(); + detail::TypeId::get(m_argumentsId); + } + + public: + + template + static lambda_method create(const functor_hop* fptr_hopper) + { + return lambda_method(detail::TypeId::get(), fptr_hopper, nullptr); + //&hopper_nonconst::template dispatch, return_t>); + } + + decltype(auto) operator()(record_t&, const signature_ts&...) const noexcept; + + template + decltype(auto) dispatch(record_t&, const signature_ts&...) const noexcept; + + //lambda_method() :m_hopper(nullptr) {} + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp new file mode 100644 index 00000000..ae7103bc --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp @@ -0,0 +1,52 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "dispatch_interface.h" + +#include "lambda_method.h" +#include "hopper_nonconst.h" + +namespace rtl::detail +{ + + //template + //template + //inline lambda_method lambda_method::create(const functor_hop* fptr_hopper) + //{ + // return lambda_method(); + // //lambda_method(detail::TypeId::get(), fptr_hopper, + // // &hopper_nonconst::template dispatch, return_t>); + //} + + + //template + //inline decltype(auto) lambda_method::operator()(record_t& target, const signature_ts& ...params) const noexcept + //{ + // //TODO: static-assert signature_ts == args_t && enable perfect-forwarding + // return m_hopper(target, *this, params...); + //} + + + //template + //template + //inline decltype(auto) lambda_method::dispatch(record_t& target, const signature_ts&...params) const noexcept + //{ + // //TODO: static-assert signature_ts == args_t && enable perfect-forwarding + // if constexpr (std::is_same_v) { + // hopper_nonconst::template dispatch(target, *this, params...); + // } + // else { + // return hopper_nonconst::template dispatch(target, *this, params...); + // } + //} +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 768ba5cf..67c7f702 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -80,7 +80,7 @@ namespace rtl { GETTER(std::string, Namespace, m_namespace); GETTER(std::string, FunctionName, m_function); GETTER(std::size_t, RecordTypeId, m_recordTypeId); - GETTER(std::vector, Functors, m_functorIds); + GETTER(std::vector, Overloads, m_functorIds); Function() = default; Function(Function&&) = default; diff --git a/ReflectionTemplateLib/rtl/src/CxxMirror.cpp b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp index 9054699d..72d8f202 100644 --- a/ReflectionTemplateLib/rtl/src/CxxMirror.cpp +++ b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp @@ -32,7 +32,7 @@ namespace rtl { const Record& record = itr->second; Method ctors = record.getMethod(detail::ctor_name(record.getRecordName())).value(); - const_cast(pTarget).m_objectId.m_clonerId = ctors.getFunctors()[detail::Index::CopyCtor]; + const_cast(pTarget).m_objectId.m_clonerId = ctors.getOverloads()[detail::Index::CopyCtor]; return error::None; } return error::CloningDisabled; diff --git a/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp b/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp index 9905c356..fe35b583 100644 --- a/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp +++ b/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp @@ -40,7 +40,7 @@ static const std::string toJson(const FunctorId& pFunctorId) static const std::string toJson(const Function& pFunction) { std::stringstream sout; - const auto& functors = pFunction.getFunctors(); + const auto& functors = pFunction.getOverloads(); const std::string& record = pFunction.getRecordName(); const std::string& nmspace = pFunction.getNamespace(); From 847e1a2e93cb1c42065467f62888f816002967a3 Mon Sep 17 00:00:00 2001 From: neeraj Date: Sat, 20 Sep 2025 10:47:36 +0530 Subject: [PATCH 015/148] fixed cland/gcc compile errors, known-return reflective calls in progress. --- .../src/ReflectedCallKnownReturn.cpp | 4 +- .../rtl/builder/RObjectBuilder.h | 2 +- .../rtl/builder/SetupMethod.hpp | 4 +- .../rtl/cache/lambda_method_cache.h | 2 +- .../rtl/detail/inc/RObjectUPtr.h | 2 +- .../rtl/detail/inc/forward_decls.h | 2 + ReflectionTemplateLib/rtl/dispatch/hopper.h | 67 +++++++++-------- .../rtl/dispatch/hopper_const.h | 21 +++--- .../rtl/dispatch/hopper_ctor.h | 43 ++++++----- .../rtl/dispatch/hopper_nonconst.h | 74 +++++++++---------- .../rtl/dispatch/lambda_function.h | 10 +-- .../rtl/dispatch/lambda_function.hpp | 6 +- .../rtl/dispatch/lambda_method.h | 19 ++++- .../rtl/dispatch/lambda_method.hpp | 17 ++--- ReflectionTemplateLib/rtl/inc/RObject.h | 6 +- 15 files changed, 143 insertions(+), 136 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 9ea401fb..1c9d2293 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -114,7 +114,7 @@ void ReflectedCallKnownReturn::set(benchmark::State& state) static auto passed = _test0(); for (auto _ : state) { - if (passed) + //if (passed) { (*SendMessage_lambda).dispatch(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); @@ -128,7 +128,7 @@ void ReflectedCallKnownReturn::get(benchmark::State& state) static auto passed = _test2(); for (auto _: state) { - if (passed) + //if (passed) { auto retStr = (*GetMessage_lambda).dispatch(bm::g_longStr); benchmark::DoNotOptimize(retStr); diff --git a/ReflectionTemplateLib/rtl/builder/RObjectBuilder.h b/ReflectionTemplateLib/rtl/builder/RObjectBuilder.h index 58b352b5..b5cd0750 100644 --- a/ReflectionTemplateLib/rtl/builder/RObjectBuilder.h +++ b/ReflectionTemplateLib/rtl/builder/RObjectBuilder.h @@ -14,7 +14,7 @@ #include #include "rtl_traits.h" -#include "forward_decls.h" +#include "RObject.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index d2ecf3d7..ca9c419a 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -21,7 +21,7 @@ #include "functor_cache_const.h" #include "functor_cache_nonconst.h" -#include "lambda_method.hpp" +#include "lambda_method.h" #include "lambda_method_cache.h" @@ -172,7 +172,7 @@ namespace rtl::detail auto& functorCache = cache::method_ptr<_recordType, _signature...>::instance(); auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambda = lambdaCache.template push<_recordType, _returnType>(functor); + auto& lambda = lambdaCache.template push<_returnType>(functor); lambdaPtr = λ }; diff --git a/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h index a43268ed..e86d0cb0 100644 --- a/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h +++ b/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h @@ -27,7 +27,7 @@ namespace rtl::cache return instance_; } - template + template const dispatch::lambda_method& push(const dispatch::functor_hop* fptr_hopper) const { m_cache.push_back(dispatch::lambda_method::template create(fptr_hopper)); diff --git a/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h b/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h index 67137208..1fd4ce58 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h +++ b/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h @@ -15,7 +15,7 @@ #include #include -#include "RObject.h" +#include "RObjectBuilder.hpp" /*------------------------------------------------------------------------------------------ RObjectUPtr diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 0e1776b9..8f96bca2 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -25,6 +25,8 @@ namespace rtl class CxxMirror; + struct Return; + namespace detail { struct FunctorId; diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper.h b/ReflectionTemplateLib/rtl/dispatch/hopper.h index 11451ff9..00cc87ea 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper.h @@ -15,7 +15,6 @@ #include "lambda_function.h" #include "functor.h" -//#include "RObjectBuilder.hpp" namespace rtl::dispatch { @@ -37,44 +36,44 @@ namespace rtl::dispatch } - template requires (void_t == true) - static Return dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - { - if constexpr (std::is_same_v) - { - auto functor = lambda_ref.functor().template get() - .template get(lambda_ref.m_returnId); + // template requires (void_t == true) + // static Return dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept + // { + // if constexpr (std::is_same_v) + // { + // auto functor = lambda_ref.functor().template get() + // .template get(lambda_ref.m_returnId); - (*functor)(params...); - } - else - { - static_assert("return-type mismatch."); - } - return { error::None, RObject{} }; - } + // (*functor)(params...); + // } + // else + // { + // static_assert("return-type mismatch."); + // } + // return { error::None, RObject{} }; + // } - template requires (void_t == false) - static Return dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - { - constexpr bool isConstCastSafe = (!traits::is_const_v); + // template requires (void_t == false) + // static Return dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept + // { + // constexpr bool isConstCastSafe = (!traits::is_const_v); - auto functor = lambda_ref.functor().template get() - .template get(lambda_ref.m_returnId); + // auto functor = lambda_ref.functor().template get() + // .template get(lambda_ref.m_returnId); - if constexpr (std::is_reference_v) - { - using T = traits::raw_t; - const T& retObj = (*functor)(params...); - return { error::None, RObject{} }; - } - else { + // if constexpr (std::is_reference_v) + // { + // using T = traits::raw_t; + // const T& retObj = (*functor)(params...); + // return { error::None, RObject{} }; + // } + // else { - //auto&& retObj = (*functor)(params...); - //using T = std::remove_cvref_t; - return { error::None, RObject{} }; - } - } + // auto&& retObj = (*functor)(params...); + // using T = std::remove_cvref_t; + // return { error::None, RObject{} }; + // } + // } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_const.h b/ReflectionTemplateLib/rtl/dispatch/hopper_const.h index 00acfdc4..9134db40 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_const.h @@ -11,17 +11,18 @@ #pragma once -#include "lambda_function.h" +//#include "RObject.h" +//#include "lambda_function.h" namespace rtl::dispatch { - template - struct hopper_const - { - template - static Return dispatch(const lambda_hop&, const signature_ts&...) noexcept - { - return { error::EmptyRObject, RObject{} }; - } - }; + // template + // struct hopper_const + // { + // template + // static Return dispatch(const lambda_hop&, const signature_ts&...) noexcept + // { + // return { error::EmptyRObject, RObject{} }; + // } + // }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h b/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h index 076e6cb9..d058d568 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h @@ -12,29 +12,28 @@ #pragma once -#include "lambda_function.h" +//#include "lambda_function.h" namespace rtl::dispatch { - template - struct hopper_ctor - { - template - static Return dispatch(const lambda_hop&, const signature_ts&...) noexcept - { - return { error::EmptyRObject, RObject{} }; - } - }; - - - template - struct hopper_copyctor - { - template - static Return dispatch(const lambda_hop&, signature_ts&&...) noexcept - { - return { error::EmptyRObject, RObject{} }; - } - }; - + // template + // struct hopper_ctor + // { + // template + // static Return dispatch(const lambda_hop&, const signature_ts&...) noexcept + // { + // return { error::EmptyRObject, RObject{} }; + // } + // }; + + + // template + // struct hopper_copyctor + // { + // template + // static Return dispatch(const lambda_hop&, signature_ts&&...) noexcept + // { + // return { error::EmptyRObject, RObject{} }; + // } + // }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h index e629ad66..789b8e27 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h @@ -11,17 +11,17 @@ #pragma once -#include "forward_decls.h" +//#include "forward_decls.h" -#include "lambda_function.h" -#include "functor.h" +//#include "lambda_function.h" +//#include "functor.h" namespace rtl::dispatch { template struct hopper_nonconst { - template requires (std::is_same_v == false) + template requires (std::is_same_v == false) static decltype(auto) dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept { auto functor = lambda_ref.functor().template get_nonconst() @@ -36,44 +36,44 @@ namespace rtl::dispatch } - template requires (void_t == true) - static Return dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - { - if constexpr (std::is_same_v) - { - auto functor = lambda_ref.functor().template get_nonconst() - .template get(lambda_ref.m_returnId); + // template requires (void_t == true) + // static Return dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept + // { + // if constexpr (std::is_same_v) + // { + // auto functor = lambda_ref.functor().template get_nonconst() + // .template get(lambda_ref.m_returnId); - (target.*functor)(params...); - } - else - { - static_assert("return-type mismatch."); - } - return { error::None, RObject{} }; - } + // (target.*functor)(params...); + // } + // else + // { + // static_assert("return-type mismatch."); + // } + // return { error::None, RObject{} }; + // } - template requires (void_t == false) - static Return dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - { - constexpr bool isConstCastSafe = (!traits::is_const_v); + // template requires (void_t == false) + // static Return dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept + // { + // constexpr bool isConstCastSafe = (!traits::is_const_v); - auto functor = lambda_ref.functor().template get_nonconst() - .template get(lambda_ref.m_returnId); + // auto functor = lambda_ref.functor().template get_nonconst() + // .template get(lambda_ref.m_returnId); - if constexpr (std::is_reference_v) - { - using T = traits::raw_t; - const T& retObj = (target.*functor)(params...); - return { error::None, RObject{} }; - } - else { + // if constexpr (std::is_reference_v) + // { + // using T = traits::raw_t; + // const T& retObj = (target.*functor)(params...); + // return { error::None, RObject{} }; + // } + // else { - auto&& retObj = (target.*functor)(params...); - using T = std::remove_cvref_t; - return { error::None, RObject{} }; - } - } + // auto&& retObj = (target.*functor)(params...); + // using T = std::remove_cvref_t; + // return { error::None, RObject{} }; + // } + // } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 8ff7d4aa..7cc22fa4 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -42,19 +42,19 @@ namespace rtl::dispatch public: + template + static lambda create(const functor_hop*); + decltype(auto) operator()(const signature_ts&...) const noexcept; template decltype(auto) dispatch(const signature_ts&...) const noexcept; - template - static lambda create(const functor_hop*); - template static lambda create_method_const(const functor_hop* fptr_hopper) { - return lambda(detail::TypeId::get(), fptr_hopper, - &hopper_const::template dispatch); + return lambda(detail::TypeId::get(), fptr_hopper, nullptr); + //&hopper_const::template dispatch); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp index b959eb1a..fb424486 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp @@ -17,10 +17,10 @@ namespace rtl::dispatch { template template - static lambda lambda::create(const functor_hop* fptr_hopper) + inline lambda lambda::create(const functor_hop* fptr_hopper) { - return lambda(detail::TypeId::get(), fptr_hopper, - &hopper::template dispatch, return_t>); + return lambda(detail::TypeId::get(), fptr_hopper, nullptr); + //&hopper::template dispatch, return_t>); } template diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 9cf7c1d9..94441fdc 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -11,7 +11,7 @@ #pragma once -#include "forward_decls.h" +//#include "forward_decls.h" #include "dispatch_interface.h" #include "hopper_nonconst.h" @@ -43,10 +43,21 @@ namespace rtl::dispatch //&hopper_nonconst::template dispatch, return_t>); } - decltype(auto) operator()(record_t&, const signature_ts&...) const noexcept; + decltype(auto) operator()(record_t& target, const signature_ts& ...params) const noexcept + { + return m_hopper(target, *this, params...); + } - template - decltype(auto) dispatch(record_t&, const signature_ts&...) const noexcept; + template + decltype(auto) dispatch(record_t& target, const signature_ts& ...params) const noexcept + { + if constexpr (std::is_same_v) { + hopper_nonconst::template dispatch(target, *this, params...); + } + else { + return hopper_nonconst::template dispatch(target, *this, params...); + } + } //lambda_method() :m_hopper(nullptr) {} }; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp index ae7103bc..5a0e14b3 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp @@ -11,10 +11,10 @@ #pragma once -#include "dispatch_interface.h" +//#include "dispatch_interface.h" -#include "lambda_method.h" -#include "hopper_nonconst.h" +//#include "lambda_method.h" +//#include "hopper_nonconst.h" namespace rtl::detail { @@ -37,16 +37,15 @@ namespace rtl::detail //} - //template - //template - //inline decltype(auto) lambda_method::dispatch(record_t& target, const signature_ts&...params) const noexcept - //{ - // //TODO: static-assert signature_ts == args_t && enable perfect-forwarding + // template + // template + // inline return_t lambda_method::dispatch(record_t& target, const signature_ts&...params) const noexcept + // { // if constexpr (std::is_same_v) { // hopper_nonconst::template dispatch(target, *this, params...); // } // else { // return hopper_nonconst::template dispatch(target, *this, params...); // } - //} + // } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index 58f5fc10..e91f162c 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -20,7 +20,7 @@ #include "rtl_typeid.h" #include "rtl_traits.h" - +#include "forward_decls.h" namespace rtl::detail { @@ -36,10 +36,6 @@ namespace rtl::detail namespace rtl { - struct Return; - class Function; - class CxxMirror; - //Reflecting the object within. class RObject { From 3bd868cc6d94103a57f028fb2ddc18c787539ca3 Mon Sep 17 00:00:00 2001 From: neeraj Date: Sat, 20 Sep 2025 14:00:14 +0530 Subject: [PATCH 016/148] better renaming for functor/method/lambda/cache --- .../src/ReflectedCallKnownReturn.cpp | 15 +-- .../rtl/builder/FunctorContainer.h | 2 +- .../rtl/builder/SetupFunction.hpp | 8 +- .../rtl/builder/SetupMethod.hpp | 16 ++-- .../rtl/cache/CMakeLists.txt | 10 +- ...cache_const.h => cache_const_method_ptr.h} | 12 +-- .../{functor_cache.h => cache_function_ptr.h} | 10 +- .../rtl/cache/cache_lambda_hop_function.h | 59 ++++++++++++ ...thod_cache.h => cache_lambda_hop_method.h} | 26 ++--- ...or_cache_nonconst.h => cache_method_ptr.h} | 10 +- .../rtl/cache/lambda_function_cache.h | 59 ------------ .../rtl/detail/inc/FunctorId.h | 12 +-- .../rtl/detail/inc/forward_decls.h | 16 +--- .../rtl/dispatch/CMakeLists.txt | 14 +-- .../{functor_const.h => const_method_ptr.h} | 4 +- .../rtl/dispatch/dispatch_interface.h | 96 ++++++++++--------- .../dispatch/{functor.h => function_ptr.h} | 6 +- ReflectionTemplateLib/rtl/dispatch/hopper.h | 8 +- .../rtl/dispatch/hopper_nonconst.h | 4 +- ...ambda_function.h => lambda_hop_function.h} | 8 +- ...a_function.hpp => lambda_hop_function.hpp} | 11 +-- .../{lambda_method.h => lambda_hop_method.h} | 10 +- ...ambda_method.hpp => lambda_hop_method.hpp} | 2 +- .../{functor_nonconst.h => method_ptr.h} | 4 +- ReflectionTemplateLib/rtl/rtl.h | 12 ++- 25 files changed, 219 insertions(+), 215 deletions(-) rename ReflectionTemplateLib/rtl/cache/{functor_cache_const.h => cache_const_method_ptr.h} (80%) rename ReflectionTemplateLib/rtl/cache/{functor_cache.h => cache_function_ptr.h} (83%) create mode 100644 ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h rename ReflectionTemplateLib/rtl/cache/{lambda_method_cache.h => cache_lambda_hop_method.h} (54%) rename ReflectionTemplateLib/rtl/cache/{functor_cache_nonconst.h => cache_method_ptr.h} (81%) delete mode 100644 ReflectionTemplateLib/rtl/cache/lambda_function_cache.h rename ReflectionTemplateLib/rtl/dispatch/{functor_const.h => const_method_ptr.h} (92%) rename ReflectionTemplateLib/rtl/dispatch/{functor.h => function_ptr.h} (90%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_function.h => lambda_hop_function.h} (86%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_function.hpp => lambda_hop_function.hpp} (75%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_method.h => lambda_hop_method.h} (87%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_method.hpp => lambda_hop_method.hpp} (96%) rename ReflectionTemplateLib/rtl/dispatch/{functor_nonconst.h => method_ptr.h} (92%) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 1c9d2293..84c36503 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -1,7 +1,8 @@ #include #include -#include +//#include +#include #include "BenchMark.h" #include "ReflectedCallKnownReturn.h" @@ -19,13 +20,13 @@ namespace cxx namespace { - static const rtl::dispatch::lambda* GetMessage_lambda = nullptr; + static const rtl::lambda_function* GetMessage_lambda = nullptr; - static const rtl::dispatch::lambda* SendMessage_lambda = nullptr; + static const rtl::lambda_function* SendMessage_lambda = nullptr; - static const rtl::dispatch::lambda* NodeGetMessage_lambda = nullptr; + static const rtl::lambda_method* NodeGetMessage_lambda = nullptr; - static const rtl::dispatch::lambda* NodeSendMessage_lambda = nullptr; + static const rtl::lambda_method* NodeSendMessage_lambda = nullptr; static const rtl::RObject nodeObj = []() { @@ -43,9 +44,9 @@ namespace SendMessage_lambda = sendMsg.getOverloads()[0].get_lambda_function(); - NodeGetMessage_lambda = getMsgNode.getOverloads()[0].get_lambda_function(); + NodeGetMessage_lambda = getMsgNode.getOverloads()[0].get_lambda_method(); - NodeSendMessage_lambda = sendMsgNode.getOverloads()[0].get_lambda_function(); + NodeSendMessage_lambda = sendMsgNode.getOverloads()[0].get_lambda_method(); auto [err, robj] = Node.create(); diff --git a/ReflectionTemplateLib/rtl/builder/FunctorContainer.h b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h index 532fa188..dba8bd9a 100644 --- a/ReflectionTemplateLib/rtl/builder/FunctorContainer.h +++ b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h @@ -15,12 +15,12 @@ #include #include -#include "lambda_function_cache.h" #include "rtl_constants.h" #include "CallReflector.h" #include "SetupFunction.h" #include "SetupConstructor.h" + namespace rtl { namespace detail diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 5be59247..65479e5d 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -13,9 +13,9 @@ #include -#include "functor_cache.h" -#include "lambda_function.hpp" -#include "lambda_function_cache.h" +#include "lambda_hop_function.hpp" +#include "cache_lambda_hop_function.h" +#include "cache_function_ptr.h" #include "SetupFunction.h" #include "RObjectBuilder.hpp" @@ -94,7 +94,7 @@ namespace rtl const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_function<_signature...>::instance(); + auto& lambdaCache = cache::lambda_hop_function<_signature...>::instance(); auto& functorCache = cache::function_ptr<_signature...>::instance(); auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); auto& lambda = lambdaCache.template push<_returnType>(functor); diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index ca9c419a..424d0361 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -18,12 +18,10 @@ #include "SetupMethod.h" #include "RObjectBuilder.hpp" -#include "functor_cache_const.h" -#include "functor_cache_nonconst.h" - -#include "lambda_method.h" -#include "lambda_method_cache.h" - +#include "lambda_hop_method.h" +#include "cache_method_ptr.h" +#include "cache_const_method_ptr.h" +#include "cache_lambda_hop_method.h" namespace rtl::detail { @@ -168,8 +166,8 @@ namespace rtl::detail const dispatch::lambda_hop* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); auto& functorCache = cache::method_ptr<_recordType, _signature...>::instance(); + auto& lambdaCache = cache::lambda_hop_method<_recordType, _signature...>::instance(); auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); auto& lambda = lambdaCache.template push<_returnType>(functor); @@ -239,11 +237,11 @@ namespace rtl::detail const dispatch::lambda_hop* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_function<_signature...>::instance(); + auto& lambdaCache = cache::lambda_hop_method<_recordType, _signature...>::instance(); auto& functorCache = cache::const_method_ptr<_recordType, _signature...>::instance(); auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambda = lambdaCache.template push_method_const<_recordType, _returnType>(functor); + auto& lambda = lambdaCache.template push<_returnType>(functor); lambdaPtr = λ }; diff --git a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt index e31be8d4..24ac7968 100644 --- a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt @@ -2,11 +2,11 @@ # Collect headers (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method_cache.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function_cache.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache_const.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor_cache_nonconst.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_lambda_hop_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_lambda_hop_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_function_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_method_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_const_method_ptr.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h b/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h similarity index 80% rename from ReflectionTemplateLib/rtl/cache/functor_cache_const.h rename to ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h index c1775fce..163bbffa 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_const.h +++ b/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h @@ -13,14 +13,14 @@ #include -#include "functor_const.h" +#include "const_method_ptr.h" namespace rtl::cache { template struct const_method_ptr { - using functor_t = dispatch::functor_const; + using functor_t = dispatch::const_method_ptr; static const const_method_ptr& instance() { @@ -29,9 +29,9 @@ namespace rtl::cache } template - const dispatch::functor_hop* push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const + const dispatch::functor* push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const { - using voidfn_t = typename dispatch::functor_const::voidfn_t; + using voidfn_t = typename dispatch::const_method_ptr::voidfn_t; auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); @@ -39,7 +39,7 @@ namespace rtl::cache } template - std::pair find(return_t(record_t::* fptr)(signature_ts...) const) const + std::pair find(return_t(record_t::* fptr)(signature_ts...) const) const { for (auto& itr : m_cache) { @@ -61,6 +61,6 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - const_method_ptr() {} + const_method_ptr() = default; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h similarity index 83% rename from ReflectionTemplateLib/rtl/cache/functor_cache.h rename to ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index 484ee6e0..5552fc0a 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -13,14 +13,14 @@ #include -#include "functor.h" +#include "function_ptr.h" namespace rtl::cache { template struct function_ptr { - using functor_t = dispatch::functor; + using functor_t = dispatch::function_ptr; static const function_ptr& instance() { @@ -29,9 +29,9 @@ namespace rtl::cache } template - const dispatch::functor_hop* push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const + const dispatch::functor* push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const { - using voidfn_t = typename dispatch::functor::voidfn_t; + using voidfn_t = typename dispatch::function_ptr::voidfn_t; auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); m_cache.emplace_back(std::make_pair(functor , lambda_index)); @@ -39,7 +39,7 @@ namespace rtl::cache } template - std::pair find(return_t(*fptr)(signature_ts...)) const + std::pair find(return_t(*fptr)(signature_ts...)) const { for (auto& itr : m_cache) { diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h new file mode 100644 index 00000000..941a24b2 --- /dev/null +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h @@ -0,0 +1,59 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "lambda_hop_function.h" + +namespace rtl::cache +{ + template + struct lambda_hop_function + { + static const lambda_hop_function& instance() + { + static const lambda_hop_function instance_; + return instance_; + } + + template + const dispatch::lambda_hop_function& push(const dispatch::functor* fptr_hopper) const + { + m_cache.push_back(dispatch::lambda_hop_function::template create(fptr_hopper)); + const dispatch::lambda_hop_function& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; + } + + template + const dispatch::lambda_hop_function& push_method_const(const dispatch::functor* fptr_hopper) const + { + m_cache.push_back(dispatch::lambda_hop_function::template create_method_const(fptr_hopper)); + const dispatch::lambda_hop_function& lambda_hop = m_cache.back(); + fptr_hopper->set_lambda(&lambda_hop); + return lambda_hop; + } + + lambda_hop_function(lambda_hop_function&&) = delete; + lambda_hop_function(const lambda_hop_function&) = delete; + lambda_hop_function& operator=(lambda_hop_function&&) = delete; + lambda_hop_function& operator=(const lambda_hop_function&) = delete; + + private: + + // No reallocation occurs; original objects stay intact + mutable std::list> m_cache; + + lambda_hop_function() = default; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h similarity index 54% rename from ReflectionTemplateLib/rtl/cache/lambda_method_cache.h rename to ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h index e86d0cb0..3e814eb1 100644 --- a/ReflectionTemplateLib/rtl/cache/lambda_method_cache.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h @@ -13,39 +13,39 @@ #include -#include "lambda_function.h" +#include "lambda_hop_method.h" namespace rtl::cache { template - struct lambda_method + struct lambda_hop_method { - static const lambda_method& instance() + static const lambda_hop_method& instance() { - static const lambda_method instance_; + static const lambda_hop_method instance_; return instance_; } template - const dispatch::lambda_method& push(const dispatch::functor_hop* fptr_hopper) const + const dispatch::lambda_hop_method& push(const dispatch::functor* fptr_hopper) const { - m_cache.push_back(dispatch::lambda_method::template create(fptr_hopper)); - const dispatch::lambda_method& lambda_hop = m_cache.back(); + m_cache.push_back(dispatch::lambda_hop_method::template create(fptr_hopper)); + const dispatch::lambda_hop_method& lambda_hop = m_cache.back(); fptr_hopper->set_lambda(&lambda_hop); return lambda_hop; } - lambda_method(lambda_method&&) = delete; - lambda_method(const lambda_method&) = delete; - lambda_method& operator=(lambda_method&&) = delete; - lambda_method& operator=(const lambda_method&) = delete; + lambda_hop_method(lambda_hop_method&&) = delete; + lambda_hop_method(const lambda_hop_method&) = delete; + lambda_hop_method& operator=(lambda_hop_method&&) = delete; + lambda_hop_method& operator=(const lambda_hop_method&) = delete; private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; - lambda_method() {} + lambda_hop_method() = default; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h similarity index 81% rename from ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h rename to ReflectionTemplateLib/rtl/cache/cache_method_ptr.h index 41e67629..05e63d2a 100644 --- a/ReflectionTemplateLib/rtl/cache/functor_cache_nonconst.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h @@ -13,14 +13,14 @@ #include -#include "functor_nonconst.h" +#include "method_ptr.h" namespace rtl::cache { template struct method_ptr { - using functor_t = dispatch::functor_nonconst; + using functor_t = dispatch::method_ptr; static const method_ptr& instance() { @@ -29,16 +29,16 @@ namespace rtl::cache } template - const dispatch::functor_hop* push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const + const dispatch::functor* push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const { - using voidfn_t = typename dispatch::functor_nonconst::voidfn_t; + using voidfn_t = typename dispatch::method_ptr::voidfn_t; auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); m_cache.emplace_back(std::make_pair(functor, lambda_index)); return &(m_cache.back().first); } template - std::pair find(return_t(record_t::* fptr)(signature_ts...)) const + std::pair find(return_t(record_t::* fptr)(signature_ts...)) const { for (auto& itr : m_cache) { diff --git a/ReflectionTemplateLib/rtl/cache/lambda_function_cache.h b/ReflectionTemplateLib/rtl/cache/lambda_function_cache.h deleted file mode 100644 index fae533a3..00000000 --- a/ReflectionTemplateLib/rtl/cache/lambda_function_cache.h +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include - -#include "lambda_function.h" - -namespace rtl::cache -{ - template - struct lambda_function - { - static const lambda_function& instance() - { - static const lambda_function instance_; - return instance_; - } - - template - const dispatch::lambda& push(const dispatch::functor_hop* fptr_hopper) const - { - m_cache.push_back(dispatch::lambda::template create(fptr_hopper)); - const dispatch::lambda& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; - } - - template - const dispatch::lambda& push_method_const(const dispatch::functor_hop* fptr_hopper) const - { - m_cache.push_back(dispatch::lambda::template create_method_const(fptr_hopper)); - const dispatch::lambda& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; - } - - lambda_function(lambda_function&&) = delete; - lambda_function(const lambda_function&) = delete; - lambda_function& operator=(lambda_function&&) = delete; - lambda_function& operator=(const lambda_function&) = delete; - - private: - - // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; - - lambda_function() {} - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 6514cfc2..b5976e80 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -14,8 +14,8 @@ #include "rtl_typeid.h" #include "rtl_constants.h" #include "forward_decls.h" -#include "lambda_method.h" -#include "lambda_function.h" +#include "lambda_hop_method.h" +#include "lambda_hop_function.h" namespace rtl::detail { @@ -52,13 +52,13 @@ namespace rtl::detail GETTER(std::string, SignatureStr, m_signature) template - const dispatch::lambda<_signature...>* get_lambda_function() const { + const dispatch::lambda_hop_function<_signature...>* get_lambda_function() const { return m_lambda->get_function<_signature...>(); } - template - const dispatch::lambda_method<_signature...>* get_lambda_method() const { - return m_lambda->get_method(); + template + const dispatch::lambda_hop_method<_recordType, _signature...>* get_lambda_method() const { + return m_lambda->get_method<_recordType, _signature...>(); } /* @method: getHashCode() diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 8f96bca2..3657de57 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -24,8 +24,6 @@ namespace rtl class Method; class CxxMirror; - - struct Return; namespace detail { @@ -37,23 +35,19 @@ namespace rtl namespace dispatch { - struct lambda_hop; - - struct functor_hop; - template - class lambda; + class lambda_hop_function; template - class lambda_method; + class lambda_hop_method; template - struct functor; + struct function_ptr; template - struct functor_const; + struct const_method_ptr; template - struct functor_nonconst; + struct method_ptr; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 45ffd2a7..6071378d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -4,14 +4,14 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/dispatch_interface.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor_const.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor_nonconst.h" + "${CMAKE_CURRENT_SOURCE_DIR}/function_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/const_method_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/method_ptr.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_method.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_function.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/hopper.h" "${CMAKE_CURRENT_SOURCE_DIR}/hopper_ctor.h" "${CMAKE_CURRENT_SOURCE_DIR}/hopper_const.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_const.h b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h similarity index 92% rename from ReflectionTemplateLib/rtl/dispatch/functor_const.h rename to ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h index 7a0ae4b9..8f02294a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h @@ -18,7 +18,7 @@ namespace rtl::dispatch { template - struct functor_const : public functor_hop + struct const_method_ptr : public functor { using voidfn_t = void(record_t::*)(signature_ts...) const; @@ -39,7 +39,7 @@ namespace rtl::dispatch return (m_functor == reinterpret_cast(fptr)); } - functor_const(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) + const_method_ptr(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) { m_returnId = returnId; m_signatureId = detail::TypeId>::get(); diff --git a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h index 6c720eb0..413cf06f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h +++ b/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h @@ -16,12 +16,55 @@ #include "rtl_traits.h" #include "rtl_typeid.h" #include "rtl_constants.h" +#include "forward_decls.h" + + +namespace rtl::dispatch +{ + struct lambda_hop; + + struct functor + { + void set_lambda(const lambda_hop* lambda) const + { + m_lambda = lambda; + } + + template + const function_ptr& get() const + { + return *(static_cast*>(this)); + } + + template + const const_method_ptr& get_const() const + { + return *(static_cast*>(this)); + } + + template + const method_ptr& get_nonconst() const + { + return *(static_cast*>(this)); + } + +// protected: + + mutable const lambda_hop* m_lambda = nullptr; + + std::size_t m_recordId = detail::TypeId<>::None; + std::size_t m_returnId = detail::TypeId<>::None; + std::size_t m_signatureId = detail::TypeId<>::None; + detail::methodQ m_qualifier = detail::methodQ::None; + }; +} + namespace rtl::dispatch { struct lambda_hop { - const functor_hop& functor() const + const functor& get_functor() const { return *m_functor; } @@ -46,71 +89,32 @@ namespace rtl::dispatch } template - const lambda* get_function() const - { + const lambda_hop_function* get_function() const + { std::size_t typeId = detail::TypeId>::get(); if (typeId == m_signatureId) { - return static_cast*>(this); + return static_cast*>(this); } return nullptr; } template - const lambda_method* get_method() const + const lambda_hop_method* get_method() const { std::size_t recordId = detail::TypeId::get(); std::size_t typeId = detail::TypeId>::get(); if (typeId == m_signatureId && recordId == m_recordId) { - return static_cast*>(this); + return static_cast*>(this); } return nullptr; } // protected: - const functor_hop* m_functor = nullptr; + const functor* m_functor = nullptr; std::size_t m_recordId = detail::TypeId<>::None; std::size_t m_returnId = detail::TypeId<>::None; std::size_t m_signatureId = detail::TypeId<>::None; std::vector m_argumentsId = {}; }; -} - - -namespace rtl::dispatch -{ - struct functor_hop - { - void set_lambda(const lambda_hop* lambda) const - { - m_lambda = lambda; - } - - template - const functor& get() const - { - return *(static_cast*>(this)); - } - - template - const functor_const& get_const() const - { - return *(static_cast*>(this)); - } - - template - const functor_nonconst& get_nonconst() const - { - return *(static_cast*>(this)); - } - -// protected: - - mutable const lambda_hop* m_lambda = nullptr; - - std::size_t m_recordId = detail::TypeId<>::None; - std::size_t m_returnId = detail::TypeId<>::None; - std::size_t m_signatureId = detail::TypeId<>::None; - detail::methodQ m_qualifier = detail::methodQ::None; - }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h similarity index 90% rename from ReflectionTemplateLib/rtl/dispatch/functor.h rename to ReflectionTemplateLib/rtl/dispatch/function_ptr.h index 886551e6..46506099 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -16,7 +16,7 @@ namespace rtl::dispatch { template - struct functor: public functor_hop + struct function_ptr: public functor { using voidfn_t = void(*)(signature_ts...); @@ -37,13 +37,13 @@ namespace rtl::dispatch return (m_functor == reinterpret_cast(fptr)); } - functor(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) + function_ptr(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) { m_returnId = returnId; m_signatureId = detail::TypeId>::get(); } - functor(const functor&) = default; + function_ptr(const function_ptr&) = default; private: diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper.h b/ReflectionTemplateLib/rtl/dispatch/hopper.h index 00cc87ea..7e08e20d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper.h @@ -13,8 +13,8 @@ #include -#include "lambda_function.h" -#include "functor.h" +#include "lambda_hop_function.h" +#include "function_ptr.h" namespace rtl::dispatch { @@ -24,8 +24,8 @@ namespace rtl::dispatch template requires (std::is_same_v == false) static decltype(auto) dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept { - auto functor = lambda_ref.functor().template get() - .template get(lambda_ref.m_returnId); + auto functor = lambda_ref.get_functor().template get() + .template get(lambda_ref.m_returnId); if constexpr (std::is_same_v) { (*functor)(params...); diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h index 789b8e27..d5f8c978 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h @@ -24,8 +24,8 @@ namespace rtl::dispatch template requires (std::is_same_v == false) static decltype(auto) dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept { - auto functor = lambda_ref.functor().template get_nonconst() - .template get(lambda_ref.m_returnId); + auto functor = lambda_ref.get_functor().template get_nonconst() + .template get(lambda_ref.m_returnId); if constexpr (std::is_same_v) { (target.*functor)(params...); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h similarity index 86% rename from ReflectionTemplateLib/rtl/dispatch/lambda_function.h rename to ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h index 7cc22fa4..a1615d6f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h @@ -25,13 +25,13 @@ namespace rtl::dispatch { template - class lambda: public lambda_hop + class lambda_hop_function: public lambda_hop { using lambda_t = std::function; const lambda_t m_hopper; - lambda(std::size_t returnId, const functor_hop* functor, lambda_t hopper) noexcept + lambda_hop_function(std::size_t returnId, const functor* functor, lambda_t hopper) noexcept : m_hopper(std::move(hopper)) { m_functor = functor; @@ -43,7 +43,7 @@ namespace rtl::dispatch public: template - static lambda create(const functor_hop*); + static lambda_hop_function create(const functor*); decltype(auto) operator()(const signature_ts&...) const noexcept; @@ -51,7 +51,7 @@ namespace rtl::dispatch decltype(auto) dispatch(const signature_ts&...) const noexcept; template - static lambda create_method_const(const functor_hop* fptr_hopper) + static lambda_hop_function create_method_const(const functor* fptr_hopper) { return lambda(detail::TypeId::get(), fptr_hopper, nullptr); //&hopper_const::template dispatch); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp similarity index 75% rename from ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp rename to ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp index fb424486..8a22e556 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp @@ -11,29 +11,28 @@ #pragma once -#include "lambda_function.h" +#include "lambda_hop_function.h" namespace rtl::dispatch { template template - inline lambda lambda::create(const functor_hop* fptr_hopper) + inline lambda_hop_function lambda_hop_function::create(const functor* fptr_hopper) { - return lambda(detail::TypeId::get(), fptr_hopper, nullptr); + return lambda_hop_function(detail::TypeId::get(), fptr_hopper, nullptr); //&hopper::template dispatch, return_t>); } template - inline decltype(auto) lambda::operator()(const signature_ts& ...params) const noexcept + inline decltype(auto) lambda_hop_function::operator()(const signature_ts& ...params) const noexcept { //TODO: static-assert signature_ts == args_t. return m_hopper(*this, params...); } - template template - inline decltype(auto) lambda::dispatch(const signature_ts&...params) const noexcept + inline decltype(auto) lambda_hop_function::dispatch(const signature_ts&...params) const noexcept { //TODO: static-assert signature_ts == args_t. if constexpr (std::is_same_v) { diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h similarity index 87% rename from ReflectionTemplateLib/rtl/dispatch/lambda_method.h rename to ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h index 94441fdc..734ae0de 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h @@ -18,13 +18,13 @@ namespace rtl::dispatch { template - class lambda_method : public lambda_hop + class lambda_hop_method : public lambda_hop { using lambda_t = std::function; const lambda_t m_hopper; - lambda_method(std::size_t returnId, const functor_hop* functor, lambda_t hopper) noexcept + lambda_hop_method(std::size_t returnId, const functor* functor, lambda_t hopper) noexcept : m_hopper(std::move(hopper)) { m_functor = functor; @@ -37,9 +37,9 @@ namespace rtl::dispatch public: template - static lambda_method create(const functor_hop* fptr_hopper) + static lambda_hop_method create(const functor* fptr_hopper) { - return lambda_method(detail::TypeId::get(), fptr_hopper, nullptr); + return lambda_hop_method(detail::TypeId::get(), fptr_hopper, nullptr); //&hopper_nonconst::template dispatch, return_t>); } @@ -58,7 +58,5 @@ namespace rtl::dispatch return hopper_nonconst::template dispatch(target, *this, params...); } } - - //lambda_method() :m_hopper(nullptr) {} }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp similarity index 96% rename from ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp rename to ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp index 5a0e14b3..2a92ccac 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp @@ -21,7 +21,7 @@ namespace rtl::detail //template //template - //inline lambda_method lambda_method::create(const functor_hop* fptr_hopper) + //inline lambda_method lambda_method::create(const functor* fptr_hopper) //{ // return lambda_method(); // //lambda_method(detail::TypeId::get(), fptr_hopper, diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h similarity index 92% rename from ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h rename to ReflectionTemplateLib/rtl/dispatch/method_ptr.h index f42e3e64..077d4117 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_nonconst.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -18,7 +18,7 @@ namespace rtl::dispatch { template - struct functor_nonconst : public functor_hop + struct method_ptr : public functor { using voidfn_t = void(record_t::*)(signature_ts...); @@ -39,7 +39,7 @@ namespace rtl::dispatch return (m_functor == reinterpret_cast(fptr)); } - functor_nonconst(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) + method_ptr(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) { m_returnId = returnId; m_signatureId = detail::TypeId>::get(); diff --git a/ReflectionTemplateLib/rtl/rtl.h b/ReflectionTemplateLib/rtl/rtl.h index d4185e61..9a803b14 100644 --- a/ReflectionTemplateLib/rtl/rtl.h +++ b/ReflectionTemplateLib/rtl/rtl.h @@ -99,4 +99,14 @@ * * Declared in namespace rtl. */ -#include "CxxMirror.hpp" \ No newline at end of file +#include "CxxMirror.hpp" + + +namespace rtl { + + template + using lambda_function = dispatch::lambda_hop_function; + + template + using lambda_method = dispatch::lambda_hop_method; +} \ No newline at end of file From 5e37927e46c9308c2bf29ed6a7df08c4de9dbb24 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 20 Sep 2025 20:44:47 +0530 Subject: [PATCH 017/148] added raw-functor access interface, perfect-forwarding. --- .../src/ReflectedCallKnownReturn.cpp | 110 ++++++++++-------- .../src/ReflectedCallKnownReturn.h | 8 ++ RTLBenchmarkApp/src/main.cpp | 3 + .../rtl/cache/cache_lambda_hop_function.h | 19 +-- .../rtl/cache/cache_lambda_hop_method.h | 10 +- .../rtl/detail/inc/FunctorId.h | 11 +- .../rtl/detail/inc/forward_decls.h | 4 + .../rtl/dispatch/CMakeLists.txt | 5 +- .../rtl/dispatch/const_method_ptr.h | 12 +- .../rtl/dispatch/function_ptr.h | 16 +-- ReflectionTemplateLib/rtl/dispatch/functor.h | 60 ++++++++++ ReflectionTemplateLib/rtl/dispatch/hopper.h | 15 ++- .../{dispatch_interface.h => lambda_hop.h} | 60 ++-------- .../rtl/dispatch/lambda_hop_function.h | 9 +- .../rtl/dispatch/lambda_hop_function.hpp | 15 +-- .../rtl/dispatch/lambda_hop_method.h | 2 +- .../rtl/dispatch/lambda_hop_method.hpp | 3 +- .../rtl/dispatch/method_ptr.h | 12 +- ReflectionTemplateLib/rtl/inc/Function.h | 4 + ReflectionTemplateLib/rtl/inc/Function.hpp | 10 ++ ReflectionTemplateLib/rtl/inc/Method.h | 4 + ReflectionTemplateLib/rtl/inc/Method.hpp | 12 ++ 22 files changed, 224 insertions(+), 180 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/dispatch/functor.h rename ReflectionTemplateLib/rtl/dispatch/{dispatch_interface.h => lambda_hop.h} (61%) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 84c36503..f8f06598 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -20,40 +20,33 @@ namespace cxx namespace { - static const rtl::lambda_function* GetMessage_lambda = nullptr; - - static const rtl::lambda_function* SendMessage_lambda = nullptr; + static const rtl::lambda_function& getMessage_lambda = []() + { + return *(cxx::mirror().getFunction("getMessage")->lambda_hop()); + }(); - static const rtl::lambda_method* NodeGetMessage_lambda = nullptr; + static const rtl::lambda_function& sendMessage_lambda = []() + { + return *(cxx::mirror().getFunction("sendMessage")->lambda_hop()); + }(); - static const rtl::lambda_method* NodeSendMessage_lambda = nullptr; + static const rtl::lambda_method& getMessageOnNode_lambda = []() + { + return *(cxx::mirror().getRecord("Node")->getMethod("getMessage")->lambda_hop()); + }(); - static const rtl::RObject nodeObj = []() + static const rtl::lambda_method& sendMessageOnNode_lambda = []() { rtl::Record Node = cxx::mirror().getRecord("Node").value(); + return *(cxx::mirror().getRecord("Node")->getMethod("sendMessage")->lambda_hop()); + }(); - rtl::Method getMsgNode = Node.getMethod("getMessage").value(); - - rtl::Method sendMsgNode = Node.getMethod("sendMessage").value(); - - rtl::Function getMsg = cxx::mirror().getFunction("getMessage").value(); - - rtl::Function sendMsg = cxx::mirror().getFunction("sendMessage").value(); - - GetMessage_lambda = getMsg.getOverloads()[0].get_lambda_function(); - - SendMessage_lambda = sendMsg.getOverloads()[0].get_lambda_function(); - - NodeGetMessage_lambda = getMsgNode.getOverloads()[0].get_lambda_method(); - - NodeSendMessage_lambda = sendMsgNode.getOverloads()[0].get_lambda_method(); - - auto [err, robj] = Node.create(); - + static const rtl::RObject nodeObj = []() + { + auto [err, robj] = cxx::mirror().getRecord("Node")->create(); if (robj.isEmpty()) { std::cout << "[0] error: " << rtl::to_string(err) << "\n"; } - return std::move(robj); }(); } @@ -63,9 +56,8 @@ namespace { static auto _test0 = []() { - if( SendMessage_lambda == nullptr || - !SendMessage_lambda->is_returning() || - !SendMessage_lambda->is_signature()) + if(!sendMessage_lambda.is_signature() || + !sendMessage_lambda.is_returning()) { std::cout << "[0] error: signature mismatch.\n"; return false; @@ -74,22 +66,21 @@ namespace }; - static auto _test1 = []() - { - if (NodeSendMessage_lambda == nullptr) - { - std::cout << "[1] error: signature mismatch.\n"; - return false; - } - return true; - }; + //static auto _test1 = []() + //{ + // if (sendMessageOnNode_lambda == nullptr) + // { + // std::cout << "[1] error: signature mismatch.\n"; + // return false; + // } + // return true; + //}; static auto _test2 = []() { - if ( GetMessage_lambda == nullptr || - !GetMessage_lambda->is_returning() || - !GetMessage_lambda->is_signature()) + if (!getMessage_lambda.is_signature() || + !getMessage_lambda.is_returning()) { std::cout << "[0] error: signature mismatch.\n"; return false; @@ -97,15 +88,34 @@ namespace return true; }; - static auto _test3 = []() + //static auto _test3 = []() + //{ + // if (getMessageOnNode_lambda == nullptr) + // { + // std::cout << "[3] error: signature mismatch.\n"; + // return false; + // } + // return true; + //}; +} + + +void FunctionPointerCall::set(benchmark::State& state) +{ + static auto passed = _test0(); + + // Unchecked: Passing an incorrect signature or return type is undefined behaviour. + // No validation is performed and the function will not return nullptr on mismatch. + static auto functor = sendMessage_lambda.get_functor().template args_t() + .template return_t(); + for (auto _ : state) { - if (NodeGetMessage_lambda == nullptr) + if (passed) { - std::cout << "[3] error: signature mismatch.\n"; - return false; + (*functor)(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); } - return true; - }; + } } @@ -115,9 +125,9 @@ void ReflectedCallKnownReturn::set(benchmark::State& state) static auto passed = _test0(); for (auto _ : state) { - //if (passed) + if (passed) { - (*SendMessage_lambda).dispatch(bm::g_longStr); + sendMessage_lambda.dispatch(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -129,9 +139,9 @@ void ReflectedCallKnownReturn::get(benchmark::State& state) static auto passed = _test2(); for (auto _: state) { - //if (passed) + if (passed) { - auto retStr = (*GetMessage_lambda).dispatch(bm::g_longStr); + auto retStr = getMessage_lambda.dispatch(bm::g_longStr); benchmark::DoNotOptimize(retStr); } } diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index 42a9011f..7084e5fa 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -10,6 +10,14 @@ struct ReflectedCallKnownReturn }; +struct FunctionPointerCall +{ + static void set(benchmark::State& state); + + static void get(benchmark::State& state); +}; + + struct ReflectedMethodCallKnownReturn { static void set(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index 77914b8a..c632e469 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -8,6 +8,9 @@ #include "ReflectedCallUnknownReturn.h" BENCHMARK(NativeCall::set); +BENCHMARK(FunctionPointerCall::set); +//BENCHMARK(ReflectedCallKnownReturn::set); +//BENCHMARK(ReflectedCallKnownReturn::set); BENCHMARK(StdFunctionCall::set); BENCHMARK(ReflectedCallKnownReturn::set); diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h index 941a24b2..ffc6109d 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h @@ -27,21 +27,12 @@ namespace rtl::cache } template - const dispatch::lambda_hop_function& push(const dispatch::functor* fptr_hopper) const + const dispatch::lambda_hop_function& push(const dispatch::functor* fptr) const { - m_cache.push_back(dispatch::lambda_hop_function::template create(fptr_hopper)); - const dispatch::lambda_hop_function& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; - } - - template - const dispatch::lambda_hop_function& push_method_const(const dispatch::functor* fptr_hopper) const - { - m_cache.push_back(dispatch::lambda_hop_function::template create_method_const(fptr_hopper)); - const dispatch::lambda_hop_function& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; + auto lambda = dispatch::lambda_hop_function::template create(fptr); + m_cache.push_back(lambda); + fptr->set_lambda(&m_cache.back()); + return m_cache.back(); } lambda_hop_function(lambda_hop_function&&) = delete; diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h index 3e814eb1..a2e02f64 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h @@ -28,12 +28,12 @@ namespace rtl::cache } template - const dispatch::lambda_hop_method& push(const dispatch::functor* fptr_hopper) const + const dispatch::lambda_hop_method& push(const dispatch::functor* fptr) const { - m_cache.push_back(dispatch::lambda_hop_method::template create(fptr_hopper)); - const dispatch::lambda_hop_method& lambda_hop = m_cache.back(); - fptr_hopper->set_lambda(&lambda_hop); - return lambda_hop; + auto lambda = dispatch::lambda_hop_method::template create(fptr); + m_cache.push_back(lambda); + fptr->set_lambda(&m_cache.back()); + return m_cache.back(); } lambda_hop_method(lambda_hop_method&&) = delete; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index b5976e80..7dd8a163 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -15,7 +15,7 @@ #include "rtl_constants.h" #include "forward_decls.h" #include "lambda_hop_method.h" -#include "lambda_hop_function.h" + namespace rtl::detail { @@ -51,15 +51,6 @@ namespace rtl::detail GETTER(std::size_t, SignatureId, m_containerId) GETTER(std::string, SignatureStr, m_signature) - template - const dispatch::lambda_hop_function<_signature...>* get_lambda_function() const { - return m_lambda->get_function<_signature...>(); - } - - template - const dispatch::lambda_hop_method<_recordType, _signature...>* get_lambda_method() const { - return m_lambda->get_method<_recordType, _signature...>(); - } /* @method: getHashCode() @return: std::size_t (a unique hash-code for a functor) diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 3657de57..16317a9a 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -35,6 +35,10 @@ namespace rtl namespace dispatch { + struct functor; + + class lambda_hop; + template class lambda_hop_function; diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 6071378d..3d512652 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -3,11 +3,12 @@ # Collect headers in this folder (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/dispatch_interface.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor.h" "${CMAKE_CURRENT_SOURCE_DIR}/function_ptr.h" - "${CMAKE_CURRENT_SOURCE_DIR}/const_method_ptr.h" "${CMAKE_CURRENT_SOURCE_DIR}/method_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/const_method_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_method.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_function.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h index 8f02294a..04cad3cc 100644 --- a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h @@ -13,7 +13,7 @@ #include -#include "dispatch_interface.h" +#include "functor.h" namespace rtl::dispatch { @@ -23,18 +23,14 @@ namespace rtl::dispatch using voidfn_t = void(record_t::*)(signature_ts...) const; template - decltype(auto) get(std::size_t returnId) const + constexpr decltype(auto) return_t() const { using fptr_t = return_t(record_t::*)(signature_ts...); - if (returnId == m_returnId) - { - return reinterpret_cast(m_functor); - } - return static_cast(nullptr); + return reinterpret_cast(m_functor); } template - bool is_same(return_t(record_t::*fptr)(signature_ts...) const) const + constexpr bool is_same(return_t(record_t::*fptr)(signature_ts...) const) const { return (m_functor == reinterpret_cast(fptr)); } diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index 46506099..2fe0b843 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -11,7 +11,7 @@ #pragma once -#include "dispatch_interface.h" +#include "functor.h" namespace rtl::dispatch { @@ -20,19 +20,15 @@ namespace rtl::dispatch { using voidfn_t = void(*)(signature_ts...); - template - decltype(auto) get(std::size_t returnId) const + template + constexpr decltype(auto) return_t() const { - using fptr_t = return_t(*)(signature_ts...); - if (returnId == m_returnId) - { - return reinterpret_cast(m_functor); - } - return static_cast(nullptr); + using fptr_t = ret_t(*)(signature_ts...); + return reinterpret_cast(m_functor); } template - bool is_same(return_t(*fptr)(signature_ts...)) const + constexpr bool is_same(return_t(*fptr)(signature_ts...)) const { return (m_functor == reinterpret_cast(fptr)); } diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h new file mode 100644 index 00000000..07a81a21 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -0,0 +1,60 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_typeid.h" +#include "rtl_constants.h" +#include "forward_decls.h" + + +namespace rtl::dispatch +{ + struct functor + { + constexpr void set_lambda(const lambda_hop* lambda) const + { + m_lambda = lambda; + } + + template + constexpr const function_ptr& args_t() const + { + return *(static_cast*>(this)); + } + + template + constexpr const const_method_ptr& get_const() const + { + return *(static_cast*>(this)); + } + + template + constexpr const method_ptr& get_nonconst() const + { + return *(static_cast*>(this)); + } + + GETTER(std::size_t, ReturnId, m_returnId); + GETTER(std::size_t, RecordId, m_recordId); + GETTER(std::size_t, SignatureId, m_signatureId); + +// protected: + + mutable const lambda_hop* m_lambda = nullptr; + + std::size_t m_recordId = detail::TypeId<>::None; + std::size_t m_returnId = detail::TypeId<>::None; + std::size_t m_signatureId = detail::TypeId<>::None; + detail::methodQ m_qualifier = detail::methodQ::None; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper.h b/ReflectionTemplateLib/rtl/dispatch/hopper.h index 7e08e20d..0c75f21f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper.h @@ -18,20 +18,19 @@ namespace rtl::dispatch { - template struct hopper { - template requires (std::is_same_v == false) - static decltype(auto) dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept + template //requires (std::is_same_v == false) + static decltype(auto) dispatch(const lambda_hop& lambda_ref, params_t&&...params) noexcept { - auto functor = lambda_ref.get_functor().template get() - .template get(lambda_ref.m_returnId); + auto functor = lambda_ref.get_functor().template args_t...>() + .template return_t>(); - if constexpr (std::is_same_v) { - (*functor)(params...); + if constexpr (std::is_same_v) { + (*functor)(std::forward(params)...); } else { - return (*functor)(params...); + return (*functor)(std::forward(params)...); } } diff --git a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h similarity index 61% rename from ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h rename to ReflectionTemplateLib/rtl/dispatch/lambda_hop.h index 413cf06f..7dc2b79d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/dispatch_interface.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h @@ -18,80 +18,38 @@ #include "rtl_constants.h" #include "forward_decls.h" - -namespace rtl::dispatch -{ - struct lambda_hop; - - struct functor - { - void set_lambda(const lambda_hop* lambda) const - { - m_lambda = lambda; - } - - template - const function_ptr& get() const - { - return *(static_cast*>(this)); - } - - template - const const_method_ptr& get_const() const - { - return *(static_cast*>(this)); - } - - template - const method_ptr& get_nonconst() const - { - return *(static_cast*>(this)); - } - -// protected: - - mutable const lambda_hop* m_lambda = nullptr; - - std::size_t m_recordId = detail::TypeId<>::None; - std::size_t m_returnId = detail::TypeId<>::None; - std::size_t m_signatureId = detail::TypeId<>::None; - detail::methodQ m_qualifier = detail::methodQ::None; - }; -} - - namespace rtl::dispatch { struct lambda_hop { - const functor& get_functor() const + constexpr const functor& get_functor() const { return *m_functor; } template - bool is_member() const + constexpr bool is_member() const { - return (m_recordId == detail::TypeId>::get() || + return (m_recordId == detail::TypeId>::get() || m_recordId == detail::TypeId>::get()); } template - bool is_returning() const + constexpr bool is_returning() const { return (m_returnId == detail::TypeId::get()); } template - bool is_signature() const + constexpr bool is_signature() const { return (m_signatureId == detail::TypeId>::get()); } template - const lambda_hop_function* get_function() const + constexpr const lambda_hop_function* get_function() const { - std::size_t typeId = detail::TypeId>::get(); + const std::size_t typeId = detail::TypeId>::get(); if (typeId == m_signatureId) { return static_cast*>(this); } @@ -109,6 +67,10 @@ namespace rtl::dispatch return nullptr; } + GETTER(std::size_t, ReturnId, m_returnId); + GETTER(std::size_t, RecordId, m_recordId); + GETTER(std::size_t, SignatureId, m_signatureId); + // protected: const functor* m_functor = nullptr; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h index a1615d6f..7cc96cf7 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h @@ -20,7 +20,7 @@ #include "hopper.h" #include "hopper_ctor.h" #include "hopper_const.h" -#include "dispatch_interface.h" +#include "lambda_hop.h" namespace rtl::dispatch { @@ -45,10 +45,11 @@ namespace rtl::dispatch template static lambda_hop_function create(const functor*); - decltype(auto) operator()(const signature_ts&...) const noexcept; + decltype(auto) operator()(signature_ts&&...) const noexcept; + + template + decltype(auto) dispatch(args_t&& ...) const noexcept; - template - decltype(auto) dispatch(const signature_ts&...) const noexcept; template static lambda_hop_function create_method_const(const functor* fptr_hopper) diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp index 8a22e556..9b0a692f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp @@ -20,26 +20,23 @@ namespace rtl::dispatch inline lambda_hop_function lambda_hop_function::create(const functor* fptr_hopper) { return lambda_hop_function(detail::TypeId::get(), fptr_hopper, nullptr); - //&hopper::template dispatch, return_t>); } - template - inline decltype(auto) lambda_hop_function::operator()(const signature_ts& ...params) const noexcept + template //TODO: static-assert signature_ts == args_t. + inline decltype(auto) lambda_hop_function::operator()(signature_ts&& ...params) const noexcept { - //TODO: static-assert signature_ts == args_t. return m_hopper(*this, params...); } template - template - inline decltype(auto) lambda_hop_function::dispatch(const signature_ts&...params) const noexcept + template //TODO: static-assert signature_ts == args_t. + inline decltype(auto) lambda_hop_function::dispatch(args_t&& ...params) const noexcept { - //TODO: static-assert signature_ts == args_t. if constexpr (std::is_same_v) { - hopper::template dispatch(*this, params...); + hopper::dispatch(*this, std::forward(params)...); } else { - return hopper::template dispatch(*this, params...); + return hopper::dispatch(*this, std::forward(params)...); } } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h index 734ae0de..925cce77 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h @@ -12,7 +12,7 @@ #pragma once //#include "forward_decls.h" -#include "dispatch_interface.h" +#include "lambda_hop.h" #include "hopper_nonconst.h" namespace rtl::dispatch diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp index 2a92ccac..5c8cdc9e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp @@ -11,8 +11,7 @@ #pragma once -//#include "dispatch_interface.h" - +//#include "functor.h" //#include "lambda_method.h" //#include "hopper_nonconst.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 077d4117..332376e1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -13,7 +13,7 @@ #include -#include "dispatch_interface.h" +#include "functor.h" namespace rtl::dispatch { @@ -23,18 +23,14 @@ namespace rtl::dispatch using voidfn_t = void(record_t::*)(signature_ts...); template - decltype(auto) get(std::size_t returnId) const + constexpr decltype(auto) return_t() const { using fptr_t = return_t(record_t::*)(signature_ts...); - if (returnId == m_returnId) - { - return reinterpret_cast(m_functor); - } - return static_cast(nullptr); + return reinterpret_cast(m_functor); } template - bool is_same(return_t(record_t::* fptr)(signature_ts...)) const + constexpr bool is_same(return_t(record_t::* fptr)(signature_ts...)) const { return (m_functor == reinterpret_cast(fptr)); } diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 67c7f702..a4a4e9b6 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -18,6 +18,7 @@ #include "FunctorId.h" #include "rtl_constants.h" #include "FunctionCaller.h" +#include "lambda_hop_function.h" namespace rtl { @@ -94,6 +95,9 @@ namespace rtl { template bool hasSignature() const; + template + const dispatch::lambda_hop_function<_signature...>* lambda_hop(std::size_t pOverloadIndex = 0) const; + template Return operator()(_args&&...params) const noexcept; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index b16039de..cf8f230b 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -22,6 +22,16 @@ namespace rtl return detail::FunctionCaller<_signature...>{ this }; } + template + const dispatch::lambda_hop_function<_signature...>* Function::lambda_hop(std::size_t pOverloadIndex) const + { + if (pOverloadIndex < m_functorIds.size()) + { + return m_functorIds[pOverloadIndex].m_lambda->get_function<_signature...>(); + } + return nullptr; + } + /* @method: hasSignature<...>() @param: set of arguments, explicitly specified as template parameter. @return: bool, if the functor associated with this object is of certain signature or not. diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 60d26ca7..d6394d03 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -16,6 +16,7 @@ #include "RObject.h" #include "Function.h" #include "MethodInvoker.h" +#include "lambda_hop_method.h" namespace rtl { @@ -65,6 +66,9 @@ namespace rtl { template const detail::NonConstInvoker<_signature...> bind(constCast&& pTarget) const; + template + const dispatch::lambda_hop_method<_recordType, _signature...>* lambda_hop(std::size_t pOverloadIndex = 0) const; + /* @method: operator()() @return: lambda * accepts no arguments for 'target', since associated functor is static-member-functions. diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index dcff5e13..86517622 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -29,6 +29,18 @@ namespace rtl } + template + const dispatch::lambda_hop_method<_recordType, _signature...>* Method::lambda_hop(std::size_t pOverloadIndex) const + { + auto& functorIds = getOverloads(); + if (pOverloadIndex < functorIds.size()) + { + return functorIds[pOverloadIndex].m_lambda->get_method<_recordType, _signature...>(); + } + return nullptr; + } + + /* @method: invokeCtor() @params: variable arguments. @return: RStatus From 0e7fc8b4b1001a92b531aef5e914bf1b42f0e4d0 Mon Sep 17 00:00:00 2001 From: neeraj Date: Sat, 20 Sep 2025 20:52:33 +0530 Subject: [PATCH 018/148] clang/gcc compile error fix. --- .../rtl/dispatch/const_method_ptr.h | 4 ++-- .../rtl/dispatch/hopper_nonconst.h | 24 +++++++++---------- .../rtl/dispatch/method_ptr.h | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h index 04cad3cc..c5d71095 100644 --- a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h @@ -22,10 +22,10 @@ namespace rtl::dispatch { using voidfn_t = void(record_t::*)(signature_ts...) const; - template + template constexpr decltype(auto) return_t() const { - using fptr_t = return_t(record_t::*)(signature_ts...); + using fptr_t = ret_t(record_t::*)(signature_ts...); return reinterpret_cast(m_functor); } diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h index d5f8c978..08da2b17 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h @@ -21,19 +21,19 @@ namespace rtl::dispatch template struct hopper_nonconst { - template requires (std::is_same_v == false) - static decltype(auto) dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - { - auto functor = lambda_ref.get_functor().template get_nonconst() - .template get(lambda_ref.m_returnId); + // template requires (std::is_same_v == false) + // static decltype(auto) dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept + // { + // auto functor = lambda_ref.get_functor().template get_nonconst() + // .template get(lambda_ref.m_returnId); - if constexpr (std::is_same_v) { - (target.*functor)(params...); - } - else { - return (target.*functor)(params...); - } - } + // if constexpr (std::is_same_v) { + // (target.*functor)(params...); + // } + // else { + // return (target.*functor)(params...); + // } + // } // template requires (void_t == true) diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 332376e1..72383eff 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -22,10 +22,10 @@ namespace rtl::dispatch { using voidfn_t = void(record_t::*)(signature_ts...); - template + template constexpr decltype(auto) return_t() const { - using fptr_t = return_t(record_t::*)(signature_ts...); + using fptr_t = ret_t(record_t::*)(signature_ts...); return reinterpret_cast(m_functor); } From ed06e75b40ad622550e7a941a29fafe87b44a774 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sun, 21 Sep 2025 03:04:35 +0530 Subject: [PATCH 019/148] removed unnecessory reinterpret_cast, code refined. --- .../src/ReflectedCallKnownReturn.cpp | 17 +++--- .../src/ReflectedCallUnknownReturn.cpp | 34 ++++++------ .../rtl/builder/SetupFunction.hpp | 12 +++-- .../rtl/builder/SetupMethod.hpp | 20 +++---- .../rtl/cache/cache_const_method_ptr.h | 15 ++---- .../rtl/cache/cache_function_ptr.h | 15 ++---- .../rtl/cache/cache_lambda_hop_function.h | 4 +- .../rtl/cache/cache_lambda_hop_method.h | 5 +- .../rtl/cache/cache_method_ptr.h | 14 ++--- .../rtl/detail/inc/forward_decls.h | 14 ++--- .../rtl/dispatch/const_method_ptr.h | 23 ++++---- .../rtl/dispatch/function_ptr.h | 27 +++++----- ReflectionTemplateLib/rtl/dispatch/functor.h | 36 +++++++------ ReflectionTemplateLib/rtl/dispatch/hopper.h | 52 +------------------ .../rtl/dispatch/lambda_hop.h | 28 +++++----- .../rtl/dispatch/lambda_hop_function.h | 41 ++------------- .../rtl/dispatch/lambda_hop_function.hpp | 28 +++++----- .../rtl/dispatch/lambda_hop_method.h | 28 ++-------- .../rtl/dispatch/lambda_hop_method.hpp | 29 ----------- .../rtl/dispatch/method_ptr.h | 24 ++++----- 20 files changed, 161 insertions(+), 305 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index f8f06598..3fae81fa 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -102,15 +102,20 @@ namespace void FunctionPointerCall::set(benchmark::State& state) { - static auto passed = _test0(); + static auto* functor = []() -> void(*)(bm::argStr_t) + { + // Must be checked: Passing an incorrect argument or return type is undefined behaviour. + if (sendMessage_lambda.is_returning() && sendMessage_lambda.is_signature()) + { + // No validation is performed internally and the function will not return nullptr on mismatch. + return sendMessage_lambda.return_type().signature().f_ptr(); + } + return nullptr; + }(); - // Unchecked: Passing an incorrect signature or return type is undefined behaviour. - // No validation is performed and the function will not return nullptr on mismatch. - static auto functor = sendMessage_lambda.get_functor().template args_t() - .template return_t(); for (auto _ : state) { - if (passed) + if (functor) { (*functor)(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 34f7fb43..d669541f 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -12,30 +12,32 @@ namespace cxx namespace { - static rtl::Function GetMessage; - static rtl::Function SendMessage; - - static rtl::Method NodeGetMessage; - static rtl::Method NodeSendMessage; - - static rtl::RObject nodeObj = []() + static rtl::Function GetMessage = []() { - GetMessage = cxx::mirror().getFunction("getMessage").value(); - - SendMessage = cxx::mirror().getFunction("sendMessage").value(); - - rtl::Record Node = cxx::mirror().getRecord("Node").value(); + return *(cxx::mirror().getFunction("getMessage")); + }(); - NodeGetMessage = Node.getMethod("getMessage").value(); + static rtl::Function SendMessage = []() + { + return *(cxx::mirror().getFunction("sendMessage")); + }(); - NodeSendMessage = Node.getMethod("sendMessage").value(); + static rtl::Method NodeGetMessage = []() + { + return *(cxx::mirror().getRecord("Node")->getMethod("getMessage")); + }(); - auto [err, robj] = Node.create(); + static rtl::Method NodeSendMessage = []() + { + return *(cxx::mirror().getRecord("Node")->getMethod("sendMessage")); + }(); + static const rtl::RObject nodeObj = []() + { + auto [err, robj] = cxx::mirror().getRecord("Node")->create(); if (robj.isEmpty()) { std::cout << "[0] error: " << rtl::to_string(err) << "\n"; } - return std::move(robj); }(); } diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 65479e5d..2300e812 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -95,16 +95,18 @@ namespace rtl const auto& updateIndex = [&](std::size_t pIndex)-> void { auto& lambdaCache = cache::lambda_hop_function<_signature...>::instance(); - auto& functorCache = cache::function_ptr<_signature...>::instance(); - auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambda = lambdaCache.template push<_returnType>(functor); + auto& functorCache = cache::function_ptr<_returnType, _signature...>::instance(); + + auto* functor = functorCache.push(pFunctor, pIndex); + auto& lambda = lambdaCache.push(functor); + lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { - auto& functorCache = cache::function_ptr<_signature...>::instance(); - auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); + auto& functorCache = cache::function_ptr<_returnType, _signature...>::instance(); + auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; } diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 424d0361..e82e1b7d 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -166,19 +166,19 @@ namespace rtl::detail const dispatch::lambda_hop* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& functorCache = cache::method_ptr<_recordType, _signature...>::instance(); auto& lambdaCache = cache::lambda_hop_method<_recordType, _signature...>::instance(); + auto& functorCache = cache::method_ptr<_recordType, _returnType, _signature...>::instance(); - auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambda = lambdaCache.template push<_returnType>(functor); + auto* functor = functorCache.push(pFunctor, pIndex); + auto& lambda = lambdaCache.push(functor); lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { - auto& functorCache = cache::method_ptr<_recordType, _signature...>::instance(); - auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); + auto& functorCache = cache::method_ptr<_recordType, _returnType, _signature...>::instance(); + auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; @@ -238,18 +238,18 @@ namespace rtl::detail const auto& updateIndex = [&](std::size_t pIndex)-> void { auto& lambdaCache = cache::lambda_hop_method<_recordType, _signature...>::instance(); - auto& functorCache = cache::const_method_ptr<_recordType, _signature...>::instance(); + auto& functorCache = cache::const_method_ptr<_recordType, _returnType, _signature...>::instance(); - auto* functor = functorCache.template push<_returnType>(pFunctor, pIndex); - auto& lambda = lambdaCache.template push<_returnType>(functor); + auto* functor = functorCache.push(pFunctor, pIndex); + auto& lambda = lambdaCache.push(functor); lambdaPtr = λ }; const auto& getIndex = [&]()-> std::size_t { - auto& functorCache = cache::const_method_ptr<_recordType, _signature...>::instance(); - auto [functor, lambdaIndex] = functorCache.template find<_returnType>(pFunctor); + auto& functorCache = cache::const_method_ptr<_recordType, _returnType, _signature...>::instance(); + auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { lambdaPtr = functor->m_lambda; diff --git a/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h index 163bbffa..94ce76a0 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h @@ -17,34 +17,29 @@ namespace rtl::cache { - template + template struct const_method_ptr { - using functor_t = dispatch::const_method_ptr; + using functor_t = dispatch::const_method_ptr; static const const_method_ptr& instance() { - static const_method_ptr instance_; + static const const_method_ptr instance_; return instance_; } - template const dispatch::functor* push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const { - using voidfn_t = typename dispatch::const_method_ptr::voidfn_t; - auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); - m_cache.emplace_back(std::make_pair(functor, lambda_index)); + m_cache.emplace_back(std::make_pair(fptr, lambda_index)); return &(m_cache.back().first); - } - template std::pair find(return_t(record_t::* fptr)(signature_ts...) const) const { for (auto& itr : m_cache) { const auto& functor = itr.first; - if (functor.template is_same(fptr)) { + if (functor.is_same(fptr)) { return { &itr.first, itr.second }; } } diff --git a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index 5552fc0a..2337eee7 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -17,10 +17,10 @@ namespace rtl::cache { - template + template struct function_ptr { - using functor_t = dispatch::function_ptr; + using functor_t = dispatch::function_ptr; static const function_ptr& instance() { @@ -28,23 +28,18 @@ namespace rtl::cache return instance_; } - template const dispatch::functor* push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const { - using voidfn_t = typename dispatch::function_ptr::voidfn_t; - - auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); - m_cache.emplace_back(std::make_pair(functor , lambda_index)); + m_cache.emplace_back(std::make_pair(fptr, lambda_index)); return &(m_cache.back().first); } - template std::pair find(return_t(*fptr)(signature_ts...)) const { for (auto& itr : m_cache) { const auto& functor = itr.first; - if (functor.template is_same(fptr)) { + if (functor.is_same(fptr)) { return { &itr.first, itr.second }; } } @@ -61,6 +56,6 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - function_ptr() {} + function_ptr() = default; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h index ffc6109d..b27274e5 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h @@ -26,11 +26,9 @@ namespace rtl::cache return instance_; } - template const dispatch::lambda_hop_function& push(const dispatch::functor* fptr) const { - auto lambda = dispatch::lambda_hop_function::template create(fptr); - m_cache.push_back(lambda); + m_cache.push_back(dispatch::lambda_hop_function(fptr)); fptr->set_lambda(&m_cache.back()); return m_cache.back(); } diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h index a2e02f64..f72bc546 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h @@ -15,7 +15,6 @@ #include "lambda_hop_method.h" - namespace rtl::cache { template @@ -27,11 +26,9 @@ namespace rtl::cache return instance_; } - template const dispatch::lambda_hop_method& push(const dispatch::functor* fptr) const { - auto lambda = dispatch::lambda_hop_method::template create(fptr); - m_cache.push_back(lambda); + m_cache.push_back(dispatch::lambda_hop_method(fptr)); fptr->set_lambda(&m_cache.back()); return m_cache.back(); } diff --git a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h index 05e63d2a..16c19862 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h @@ -17,10 +17,10 @@ namespace rtl::cache { - template + template struct method_ptr { - using functor_t = dispatch::method_ptr; + using functor_t = dispatch::method_ptr; static const method_ptr& instance() { @@ -28,22 +28,18 @@ namespace rtl::cache return instance_; } - template const dispatch::functor* push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const { - using voidfn_t = typename dispatch::method_ptr::voidfn_t; - auto functor = functor_t(reinterpret_cast(fptr), detail::TypeId::get()); - m_cache.emplace_back(std::make_pair(functor, lambda_index)); + m_cache.emplace_back(std::make_pair(fptr, lambda_index)); return &(m_cache.back().first); } - template std::pair find(return_t(record_t::* fptr)(signature_ts...)) const { for (auto& itr : m_cache) { const auto& functor = itr.first; - if (functor.template is_same(fptr)) { + if (functor.is_same(fptr)) { return { &itr.first, itr.second }; } } @@ -60,6 +56,6 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - method_ptr() {} + method_ptr() = default; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 16317a9a..0497b75d 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -40,18 +40,18 @@ namespace rtl class lambda_hop; template - class lambda_hop_function; + struct lambda_hop_function; template - class lambda_hop_method; + struct lambda_hop_method; - template + template struct function_ptr; - template - struct const_method_ptr; - - template + template struct method_ptr; + + template + struct const_method_ptr; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h index c5d71095..e555d72f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h @@ -17,32 +17,29 @@ namespace rtl::dispatch { - template + template struct const_method_ptr : public functor { - using voidfn_t = void(record_t::*)(signature_ts...) const; + using functor_t = return_t(record_t::*)(signature_ts...) const; - template - constexpr decltype(auto) return_t() const + constexpr functor_t get() const { - using fptr_t = ret_t(record_t::*)(signature_ts...); - return reinterpret_cast(m_functor); + return m_functor; } - template - constexpr bool is_same(return_t(record_t::*fptr)(signature_ts...) const) const + constexpr bool is_same(functor_t fptr) const { - return (m_functor == reinterpret_cast(fptr)); + return (fptr == m_functor); } - const_method_ptr(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) + const_method_ptr(functor_t fptr) :m_functor(fptr) { - m_returnId = returnId; - m_signatureId = detail::TypeId>::get(); + m_returnId = detail::TypeId>::get(); + m_signatureId = detail::TypeId...>>::get(); } private: - const voidfn_t m_functor; + const functor_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index 2fe0b843..fcf92c5d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -11,38 +11,35 @@ #pragma once +#include + #include "functor.h" namespace rtl::dispatch { - template + template struct function_ptr: public functor { - using voidfn_t = void(*)(signature_ts...); + using functor_t = return_t(*)(signature_ts...); - template - constexpr decltype(auto) return_t() const + constexpr functor_t f_ptr() const { - using fptr_t = ret_t(*)(signature_ts...); - return reinterpret_cast(m_functor); + return m_functor; } - template - constexpr bool is_same(return_t(*fptr)(signature_ts...)) const + constexpr bool is_same(functor_t fptr) const { - return (m_functor == reinterpret_cast(fptr)); + return (fptr == m_functor); } - function_ptr(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) + function_ptr(functor_t fptr) :m_functor(fptr) { - m_returnId = returnId; - m_signatureId = detail::TypeId>::get(); + m_returnId = detail::TypeId>::get(); + m_signatureId = detail::TypeId...>>::get(); } - function_ptr(const function_ptr&) = default; - private: - const voidfn_t m_functor; + const functor_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 07a81a21..1f99015a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -19,30 +19,36 @@ namespace rtl::dispatch { - struct functor + template + struct functor_cast { - constexpr void set_lambda(const lambda_hop* lambda) const - { - m_lambda = lambda; - } + const functor* m_functor; template - constexpr const function_ptr& args_t() const + constexpr const function_ptr& signature() const { - return *(static_cast*>(this)); + return *(static_cast*>(m_functor)); } + }; - template - constexpr const const_method_ptr& get_const() const + struct functor + { + constexpr void set_lambda(const lambda_hop* lambda) const { - return *(static_cast*>(this)); + m_lambda = lambda; } - template - constexpr const method_ptr& get_nonconst() const - { - return *(static_cast*>(this)); - } + //template + //constexpr const const_method_ptr& get_const() const + //{ + // return *(static_cast*>(this)); + //} + + //template + //constexpr const method_ptr& get_nonconst() const + //{ + // return *(static_cast*>(this)); + //} GETTER(std::size_t, ReturnId, m_returnId); GETTER(std::size_t, RecordId, m_recordId); diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper.h b/ReflectionTemplateLib/rtl/dispatch/hopper.h index 0c75f21f..005eec92 100644 --- a/ReflectionTemplateLib/rtl/dispatch/hopper.h +++ b/ReflectionTemplateLib/rtl/dispatch/hopper.h @@ -20,59 +20,9 @@ namespace rtl::dispatch { struct hopper { - template //requires (std::is_same_v == false) + template static decltype(auto) dispatch(const lambda_hop& lambda_ref, params_t&&...params) noexcept { - auto functor = lambda_ref.get_functor().template args_t...>() - .template return_t>(); - - if constexpr (std::is_same_v) { - (*functor)(std::forward(params)...); - } - else { - return (*functor)(std::forward(params)...); - } } - - - // template requires (void_t == true) - // static Return dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - // { - // if constexpr (std::is_same_v) - // { - // auto functor = lambda_ref.functor().template get() - // .template get(lambda_ref.m_returnId); - - // (*functor)(params...); - // } - // else - // { - // static_assert("return-type mismatch."); - // } - // return { error::None, RObject{} }; - // } - - - // template requires (void_t == false) - // static Return dispatch(const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - // { - // constexpr bool isConstCastSafe = (!traits::is_const_v); - - // auto functor = lambda_ref.functor().template get() - // .template get(lambda_ref.m_returnId); - - // if constexpr (std::is_reference_v) - // { - // using T = traits::raw_t; - // const T& retObj = (*functor)(params...); - // return { error::None, RObject{} }; - // } - // else { - - // auto&& retObj = (*functor)(params...); - // using T = std::remove_cvref_t; - // return { error::None, RObject{} }; - // } - // } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h index 7dc2b79d..2e249d9a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h @@ -17,40 +17,43 @@ #include "rtl_typeid.h" #include "rtl_constants.h" #include "forward_decls.h" +#include "functor.h" namespace rtl::dispatch { struct lambda_hop { - constexpr const functor& get_functor() const + template + constexpr const functor_cast return_type() const { - return *m_functor; + return functor_cast{ m_functor }; } template constexpr bool is_member() const { - return (m_recordId == detail::TypeId>::get() || - m_recordId == detail::TypeId>::get()); + return (m_functor->m_recordId == detail::TypeId>::get() || + m_functor->m_recordId == detail::TypeId>::get()); } template constexpr bool is_returning() const { - return (m_returnId == detail::TypeId::get()); + return (m_functor->m_returnId == detail::TypeId>::get()); } template constexpr bool is_signature() const { - return (m_signatureId == detail::TypeId>::get()); + return (m_signatureId == detail::TypeId...>>::get()); } template constexpr const lambda_hop_function* get_function() const { - const std::size_t typeId = detail::TypeId>::get(); - if (typeId == m_signatureId) { + const std::size_t typeId = detail::TypeId...>>::get(); + if (typeId == m_signatureId) + { return static_cast*>(this); } return nullptr; @@ -60,22 +63,19 @@ namespace rtl::dispatch const lambda_hop_method* get_method() const { std::size_t recordId = detail::TypeId::get(); - std::size_t typeId = detail::TypeId>::get(); - if (typeId == m_signatureId && recordId == m_recordId) { + std::size_t typeId = detail::TypeId...>>::get(); + if (typeId == m_signatureId && recordId == m_functor->m_recordId) + { return static_cast*>(this); } return nullptr; } - GETTER(std::size_t, ReturnId, m_returnId); - GETTER(std::size_t, RecordId, m_recordId); GETTER(std::size_t, SignatureId, m_signatureId); // protected: const functor* m_functor = nullptr; - std::size_t m_recordId = detail::TypeId<>::None; - std::size_t m_returnId = detail::TypeId<>::None; std::size_t m_signatureId = detail::TypeId<>::None; std::vector m_argumentsId = {}; }; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h index 7cc96cf7..06aff442 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h @@ -11,51 +11,16 @@ #pragma once -#include -#include -#include - -#include "forward_decls.h" - -#include "hopper.h" -#include "hopper_ctor.h" -#include "hopper_const.h" #include "lambda_hop.h" namespace rtl::dispatch { template - class lambda_hop_function: public lambda_hop + struct lambda_hop_function: public lambda_hop { - using lambda_t = std::function; - - const lambda_t m_hopper; - - lambda_hop_function(std::size_t returnId, const functor* functor, lambda_t hopper) noexcept - : m_hopper(std::move(hopper)) - { - m_functor = functor; - m_returnId = returnId; - m_signatureId = detail::TypeId>::get(); - detail::TypeId::get(m_argumentsId); - } - - public: - - template - static lambda_hop_function create(const functor*); - - decltype(auto) operator()(signature_ts&&...) const noexcept; + lambda_hop_function(const functor*) noexcept; template - decltype(auto) dispatch(args_t&& ...) const noexcept; - - - template - static lambda_hop_function create_method_const(const functor* fptr_hopper) - { - return lambda(detail::TypeId::get(), fptr_hopper, nullptr); - //&hopper_const::template dispatch); - } + decltype(auto) dispatch(args_t&&...) const noexcept; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp index 9b0a692f..d17581ab 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp @@ -11,32 +11,36 @@ #pragma once +#include "rtl_typeid.h" #include "lambda_hop_function.h" namespace rtl::dispatch { template - template - inline lambda_hop_function lambda_hop_function::create(const functor* fptr_hopper) + inline lambda_hop_function::lambda_hop_function(const functor* functor) noexcept { - return lambda_hop_function(detail::TypeId::get(), fptr_hopper, nullptr); + m_functor = functor; + m_signatureId = detail::TypeId...>>::get(); + detail::TypeId::get(m_argumentsId); } - template //TODO: static-assert signature_ts == args_t. - inline decltype(auto) lambda_hop_function::operator()(signature_ts&& ...params) const noexcept - { - return m_hopper(*this, params...); - } template - template //TODO: static-assert signature_ts == args_t. + template inline decltype(auto) lambda_hop_function::dispatch(args_t&& ...params) const noexcept { - if constexpr (std::is_same_v) { - hopper::dispatch(*this, std::forward(params)...); + constexpr bool signature_ok = std::is_same_v< std::tuple...>, + std::tuple>; + + static_assert( signature_ok, "Argument types dont match signature."); + + auto* functor = return_type>().template signature...>().f_ptr(); + + if constexpr (std::is_same_v) { + (*functor)(std::forward(params)...); } else { - return hopper::dispatch(*this, std::forward(params)...); + return (*functor)(std::forward(params)...); } } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h index 925cce77..f193d720 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h @@ -11,43 +11,21 @@ #pragma once -//#include "forward_decls.h" #include "lambda_hop.h" #include "hopper_nonconst.h" namespace rtl::dispatch { template - class lambda_hop_method : public lambda_hop + struct lambda_hop_method : public lambda_hop { - using lambda_t = std::function; - - const lambda_t m_hopper; - - lambda_hop_method(std::size_t returnId, const functor* functor, lambda_t hopper) noexcept - : m_hopper(std::move(hopper)) + lambda_hop_method(const functor* functor) noexcept { m_functor = functor; - m_returnId = returnId; - m_recordId = detail::TypeId::get(); - m_signatureId = detail::TypeId>::get(); + m_signatureId = detail::TypeId...>>::get(); detail::TypeId::get(m_argumentsId); } - public: - - template - static lambda_hop_method create(const functor* fptr_hopper) - { - return lambda_hop_method(detail::TypeId::get(), fptr_hopper, nullptr); - //&hopper_nonconst::template dispatch, return_t>); - } - - decltype(auto) operator()(record_t& target, const signature_ts& ...params) const noexcept - { - return m_hopper(target, *this, params...); - } - template decltype(auto) dispatch(record_t& target, const signature_ts& ...params) const noexcept { diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp index 5c8cdc9e..3b1a16c9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp @@ -18,33 +18,4 @@ namespace rtl::detail { - //template - //template - //inline lambda_method lambda_method::create(const functor* fptr_hopper) - //{ - // return lambda_method(); - // //lambda_method(detail::TypeId::get(), fptr_hopper, - // // &hopper_nonconst::template dispatch, return_t>); - //} - - - //template - //inline decltype(auto) lambda_method::operator()(record_t& target, const signature_ts& ...params) const noexcept - //{ - // //TODO: static-assert signature_ts == args_t && enable perfect-forwarding - // return m_hopper(target, *this, params...); - //} - - - // template - // template - // inline return_t lambda_method::dispatch(record_t& target, const signature_ts&...params) const noexcept - // { - // if constexpr (std::is_same_v) { - // hopper_nonconst::template dispatch(target, *this, params...); - // } - // else { - // return hopper_nonconst::template dispatch(target, *this, params...); - // } - // } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 72383eff..403afeae 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -17,32 +17,30 @@ namespace rtl::dispatch { - template + template struct method_ptr : public functor { - using voidfn_t = void(record_t::*)(signature_ts...); + using functor_t = return_t(record_t::*)(signature_ts...); - template - constexpr decltype(auto) return_t() const + constexpr functor_t get() const { - using fptr_t = ret_t(record_t::*)(signature_ts...); - return reinterpret_cast(m_functor); + return m_functor; } - template - constexpr bool is_same(return_t(record_t::* fptr)(signature_ts...)) const + constexpr bool is_same(functor_t fptr) const { - return (m_functor == reinterpret_cast(fptr)); + return (fptr == m_functor); } - method_ptr(voidfn_t fptr, std::size_t returnId) :m_functor(fptr) + method_ptr(functor_t fptr) :m_functor(fptr) { - m_returnId = returnId; - m_signatureId = detail::TypeId>::get(); + m_recordId = detail::TypeId>::get(); + m_returnId = detail::TypeId>::get(); + m_signatureId = detail::TypeId...>>::get(); } private: - const voidfn_t m_functor; + const functor_t m_functor; }; } \ No newline at end of file From dca661d685f9bde7f60f27b252550aa7ade0aab0 Mon Sep 17 00:00:00 2001 From: neeraj Date: Sun, 21 Sep 2025 03:12:28 +0530 Subject: [PATCH 020/148] unicode-char from comment removed. --- ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp index d17581ab..e1fd291a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp @@ -32,7 +32,7 @@ namespace rtl::dispatch constexpr bool signature_ok = std::is_same_v< std::tuple...>, std::tuple>; - static_assert( signature_ok, "Argument types dont match signature."); + static_assert( signature_ok, "Argument types don't match signature."); auto* functor = return_type>().template signature...>().f_ptr(); From 8610277a2fbb61de2e618a09878aa6460c06ba6a Mon Sep 17 00:00:00 2001 From: neeraj Date: Sun, 21 Sep 2025 13:58:15 +0530 Subject: [PATCH 021/148] benchmark for method-call with known return added. --- .../src/ReflectedCallKnownReturn.cpp | 142 ++++++++++++------ .../src/ReflectedCallKnownReturn.h | 2 +- .../src/ReflectedCallUnknownReturn.cpp | 2 +- RTLBenchmarkApp/src/main.cpp | 6 +- .../rtl/builder/SetupFunction.hpp | 7 +- .../rtl/builder/SetupMethod.hpp | 12 +- .../rtl/detail/inc/CMakeLists.txt | 5 + .../{dispatch => detail/inc}/CallReflector.h | 0 .../{dispatch => detail/inc}/FunctionCaller.h | 0 .../inc}/FunctionCaller.hpp | 0 .../{dispatch => detail/inc}/MethodInvoker.h | 0 .../inc}/MethodInvoker.hpp | 0 .../rtl/dispatch/CMakeLists.txt | 13 -- ReflectionTemplateLib/rtl/dispatch/functor.h | 29 +--- ReflectionTemplateLib/rtl/dispatch/hopper.h | 28 ---- .../rtl/dispatch/hopper_const.h | 28 ---- .../rtl/dispatch/hopper_ctor.h | 39 ----- .../rtl/dispatch/hopper_nonconst.h | 79 ---------- .../rtl/dispatch/lambda_hop.h | 15 +- .../rtl/dispatch/lambda_hop_function.h | 39 ++++- .../rtl/dispatch/lambda_hop_function.hpp | 46 ------ .../rtl/dispatch/lambda_hop_method.h | 32 +++- .../rtl/dispatch/lambda_hop_method.hpp | 21 --- .../rtl/dispatch/method_ptr.h | 2 +- 24 files changed, 189 insertions(+), 358 deletions(-) rename ReflectionTemplateLib/rtl/{dispatch => detail/inc}/CallReflector.h (100%) rename ReflectionTemplateLib/rtl/{dispatch => detail/inc}/FunctionCaller.h (100%) rename ReflectionTemplateLib/rtl/{dispatch => detail/inc}/FunctionCaller.hpp (100%) rename ReflectionTemplateLib/rtl/{dispatch => detail/inc}/MethodInvoker.h (100%) rename ReflectionTemplateLib/rtl/{dispatch => detail/inc}/MethodInvoker.hpp (100%) delete mode 100644 ReflectionTemplateLib/rtl/dispatch/hopper.h delete mode 100644 ReflectionTemplateLib/rtl/dispatch/hopper_const.h delete mode 100644 ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h delete mode 100644 ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h delete mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp delete mode 100644 ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 3fae81fa..dd2457ef 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -1,8 +1,6 @@ #include #include -//#include -#include #include "BenchMark.h" #include "ReflectedCallKnownReturn.h" @@ -22,33 +20,32 @@ namespace { static const rtl::lambda_function& getMessage_lambda = []() { + // No validation is performed internally and lambda_hop + // will not return nullptr on signature mismatch. (by design) return *(cxx::mirror().getFunction("getMessage")->lambda_hop()); }(); static const rtl::lambda_function& sendMessage_lambda = []() { + // No validation is performed internally and lambda_hop + // will not return nullptr on signature mismatch. (by design) return *(cxx::mirror().getFunction("sendMessage")->lambda_hop()); }(); static const rtl::lambda_method& getMessageOnNode_lambda = []() { + // No validation is performed internally and lambda_hop + // will not return nullptr on signature mismatch. (by design) return *(cxx::mirror().getRecord("Node")->getMethod("getMessage")->lambda_hop()); }(); static const rtl::lambda_method& sendMessageOnNode_lambda = []() { rtl::Record Node = cxx::mirror().getRecord("Node").value(); + // No validation is performed internally and lambda_hop + // will not return nullptr on signature mismatch. (by design) return *(cxx::mirror().getRecord("Node")->getMethod("sendMessage")->lambda_hop()); }(); - - static const rtl::RObject nodeObj = []() - { - auto [err, robj] = cxx::mirror().getRecord("Node")->create(); - if (robj.isEmpty()) { - std::cout << "[0] error: " << rtl::to_string(err) << "\n"; - } - return std::move(robj); - }(); } @@ -65,38 +62,38 @@ namespace return true; }; - - //static auto _test1 = []() - //{ - // if (sendMessageOnNode_lambda == nullptr) - // { - // std::cout << "[1] error: signature mismatch.\n"; - // return false; - // } - // return true; - //}; - + static auto _test1 = []() + { + if(!sendMessageOnNode_lambda.is_signature() || + !sendMessageOnNode_lambda.is_returning()) + { + std::cout << "[1] error: signature mismatch.\n"; + return false; + } + return true; + }; static auto _test2 = []() { if (!getMessage_lambda.is_signature() || !getMessage_lambda.is_returning()) { - std::cout << "[0] error: signature mismatch.\n"; + std::cout << "[2] error: signature mismatch.\n"; return false; } return true; }; - //static auto _test3 = []() - //{ - // if (getMessageOnNode_lambda == nullptr) - // { - // std::cout << "[3] error: signature mismatch.\n"; - // return false; - // } - // return true; - //}; + static auto _test3 = []() + { + if (!getMessageOnNode_lambda.is_signature() || + !getMessageOnNode_lambda.is_returning()) + { + std::cout << "[3] error: signature mismatch.\n"; + return false; + } + return true; + }; } @@ -108,8 +105,9 @@ void FunctionPointerCall::set(benchmark::State& state) if (sendMessage_lambda.is_returning() && sendMessage_lambda.is_signature()) { // No validation is performed internally and the function will not return nullptr on mismatch. - return sendMessage_lambda.return_type().signature().f_ptr(); + return sendMessage_lambda.get_functor().f_ptr(); } + std::cout << "[4] error: signature mismatch.\n"; return nullptr; }(); @@ -124,6 +122,30 @@ void FunctionPointerCall::set(benchmark::State& state) } +void FunctionPointerCall::get(benchmark::State& state) +{ + static auto* functor = []() -> bm::retStr_t(*)(bm::argStr_t) + { + // Must be checked: Passing an incorrect argument or return type is undefined behaviour. + if (getMessage_lambda.is_returning() && getMessage_lambda.is_signature()) + { + // No validation is performed internally and the function will not return nullptr on mismatch. + return getMessage_lambda.get_functor().f_ptr(); + } + std::cout << "[5] error: signature mismatch.\n"; + return nullptr; + }(); + + for (auto _ : state) + { + if (functor) + { + auto ret = (*functor)(bm::g_longStr); + benchmark::DoNotOptimize(ret); + } + } +} + void ReflectedCallKnownReturn::set(benchmark::State& state) { @@ -155,21 +177,51 @@ void ReflectedCallKnownReturn::get(benchmark::State& state) void ReflectedMethodCallKnownReturn::set(benchmark::State& state) { - //static auto _=_test1(); - //for (auto _: state) - //{ - // auto error = (NodeSendMessage(nodeObj)(bm::g_longStr).err; - // benchmark::DoNotOptimize(error); - //} + static bm::Node nodeObj; + static auto functor = []() -> void(bm::Node::*)(bm::argStr_t) + { + // Must be checked: Passing an incorrect argument or return type is undefined behaviour. + if (sendMessageOnNode_lambda.is_returning() && sendMessageOnNode_lambda.is_signature()) + { + // No validation is performed internally and the function will not return nullptr on mismatch. + return sendMessageOnNode_lambda.get_functor().f_ptr(); + } + std::cout << "[6] error: signature mismatch.\n"; + return nullptr; + }(); + + for (auto _ : state) + { + if (functor) + { + sendMessageOnNode_lambda.dispatch(nodeObj, bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } + } } void ReflectedMethodCallKnownReturn::get(benchmark::State& state) { - //static auto _=_test3(); - //for (auto _: state) - //{ - // auto error = NodeGetMessage(nodeObj)(bm::g_longStr).err; - // benchmark::DoNotOptimize(error); - //} + static bm::Node nodeObj; + static auto functor = []() -> bm::retStr_t(bm::Node::*)(bm::argStr_t) + { + // Must be checked: Passing an incorrect argument or return type is undefined behaviour. + if (getMessageOnNode_lambda.is_returning() && getMessageOnNode_lambda.is_signature()) + { + // No validation is performed internally and the function will not return nullptr on mismatch. + return getMessageOnNode_lambda.get_functor().f_ptr(); + } + std::cout << "[7] error: signature mismatch.\n"; + return nullptr; + }(); + + for (auto _ : state) + { + if (functor) + { + auto retStr = getMessageOnNode_lambda.dispatch(nodeObj, bm::g_longStr); + benchmark::DoNotOptimize(retStr); + } + } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index 7084e5fa..eefbd04c 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -19,7 +19,7 @@ struct FunctionPointerCall struct ReflectedMethodCallKnownReturn -{ +{ static void set(benchmark::State& state); static void get(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index d669541f..91ca4fb4 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -36,7 +36,7 @@ namespace { auto [err, robj] = cxx::mirror().getRecord("Node")->create(); if (robj.isEmpty()) { - std::cout << "[0] error: " << rtl::to_string(err) << "\n"; + std::cout << "[_] error: " << rtl::to_string(err) << "\n"; } return std::move(robj); }(); diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index c632e469..d459fd79 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -9,6 +9,7 @@ BENCHMARK(NativeCall::set); BENCHMARK(FunctionPointerCall::set); + //BENCHMARK(ReflectedCallKnownReturn::set); //BENCHMARK(ReflectedCallKnownReturn::set); @@ -17,17 +18,18 @@ BENCHMARK(ReflectedCallKnownReturn::set); BENCHMARK(ReflectedCallUnknownReturn::set); BENCHMARK(StdFunctionMethodCall::set); -//BENCHMARK(ReflectedMethodCallKnownReturn::set); +BENCHMARK(ReflectedMethodCallKnownReturn::set); BENCHMARK(ReflectedMethodCallUnknownReturn::set); BENCHMARK(NativeCall::get); +BENCHMARK(FunctionPointerCall::get); BENCHMARK(StdFunctionCall::get); BENCHMARK(ReflectedCallKnownReturn::get); BENCHMARK(ReflectedCallUnknownReturn::get); BENCHMARK(StdFunctionMethodCall::get); -//BENCHMARK(ReflectedMethodCallKnownReturn::get); +BENCHMARK(ReflectedMethodCallKnownReturn::get); BENCHMARK(ReflectedMethodCallUnknownReturn::get); namespace bm diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 2300e812..a5cc37eb 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -13,7 +13,6 @@ #include -#include "lambda_hop_function.hpp" #include "cache_lambda_hop_function.h" #include "cache_function_ptr.h" @@ -31,7 +30,7 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); assert(isAllGood && "new type-id-system not working."); pFunctor(std::forward<_signature>(params)...); @@ -49,7 +48,7 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); assert(isAllGood && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); @@ -108,7 +107,7 @@ namespace rtl auto& functorCache = cache::function_ptr<_returnType, _signature...>::instance(); auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->m_lambda; + lambdaPtr = functor->getLambdaHop(); } return lambdaIndex; }; diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index e82e1b7d..2d416b8b 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -34,7 +34,7 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); assert(isAllGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { @@ -57,7 +57,7 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); assert(isAllGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { @@ -101,7 +101,7 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); assert(isAllGood && "new type-id-system not working."); const _recordType& target = pTargetObj.view<_recordType>()->get(); @@ -120,7 +120,7 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->m_lambda); + bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); assert(isAllGood && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); @@ -181,7 +181,7 @@ namespace rtl::detail auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->m_lambda; + lambdaPtr = functor->getLambdaHop(); } return lambdaIndex; }; @@ -252,7 +252,7 @@ namespace rtl::detail auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->m_lambda; + lambdaPtr = functor->getLambdaHop(); } return lambdaIndex; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt b/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt index 343cfb2f..ff6e9609 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt @@ -12,6 +12,11 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/RObjectId.h" "${CMAKE_CURRENT_SOURCE_DIR}/RObjectUPtr.h" "${CMAKE_CURRENT_SOURCE_DIR}/RObjExtracter.h" + "${CMAKE_CURRENT_SOURCE_DIR}/CallReflector.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FunctionCaller.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FunctionCaller.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/MethodInvoker.h" + "${CMAKE_CURRENT_SOURCE_DIR}/MethodInvoker.hpp" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/dispatch/CallReflector.h b/ReflectionTemplateLib/rtl/detail/inc/CallReflector.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/CallReflector.h rename to ReflectionTemplateLib/rtl/detail/inc/CallReflector.h diff --git a/ReflectionTemplateLib/rtl/dispatch/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/FunctionCaller.h rename to ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h diff --git a/ReflectionTemplateLib/rtl/dispatch/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/FunctionCaller.hpp rename to ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp diff --git a/ReflectionTemplateLib/rtl/dispatch/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/MethodInvoker.h rename to ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h diff --git a/ReflectionTemplateLib/rtl/dispatch/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/MethodInvoker.hpp rename to ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 3d512652..6be5bbee 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -10,20 +10,7 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_method.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_function.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/hopper.h" - "${CMAKE_CURRENT_SOURCE_DIR}/hopper_ctor.h" - "${CMAKE_CURRENT_SOURCE_DIR}/hopper_const.h" - "${CMAKE_CURRENT_SOURCE_DIR}/hopper_nonconst.h" - - "${CMAKE_CURRENT_SOURCE_DIR}/CallReflector.h" - "${CMAKE_CURRENT_SOURCE_DIR}/FunctionCaller.h" - "${CMAKE_CURRENT_SOURCE_DIR}/FunctionCaller.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/MethodInvoker.h" - "${CMAKE_CURRENT_SOURCE_DIR}/MethodInvoker.hpp" - ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 1f99015a..5f8e6152 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -11,26 +11,12 @@ #pragma once -#include "rtl_traits.h" #include "rtl_typeid.h" #include "rtl_constants.h" #include "forward_decls.h" - namespace rtl::dispatch { - template - struct functor_cast - { - const functor* m_functor; - - template - constexpr const function_ptr& signature() const - { - return *(static_cast*>(m_functor)); - } - }; - struct functor { constexpr void set_lambda(const lambda_hop* lambda) const @@ -38,23 +24,12 @@ namespace rtl::dispatch m_lambda = lambda; } - //template - //constexpr const const_method_ptr& get_const() const - //{ - // return *(static_cast*>(this)); - //} - - //template - //constexpr const method_ptr& get_nonconst() const - //{ - // return *(static_cast*>(this)); - //} - GETTER(std::size_t, ReturnId, m_returnId); GETTER(std::size_t, RecordId, m_recordId); GETTER(std::size_t, SignatureId, m_signatureId); + GETTER(lambda_hop*, LambdaHop, m_lambda); -// protected: + protected: mutable const lambda_hop* m_lambda = nullptr; diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper.h b/ReflectionTemplateLib/rtl/dispatch/hopper.h deleted file mode 100644 index 005eec92..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/hopper.h +++ /dev/null @@ -1,28 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include - -#include "lambda_hop_function.h" -#include "function_ptr.h" - -namespace rtl::dispatch -{ - struct hopper - { - template - static decltype(auto) dispatch(const lambda_hop& lambda_ref, params_t&&...params) noexcept - { - } - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_const.h b/ReflectionTemplateLib/rtl/dispatch/hopper_const.h deleted file mode 100644 index 9134db40..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_const.h +++ /dev/null @@ -1,28 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -//#include "RObject.h" -//#include "lambda_function.h" - -namespace rtl::dispatch -{ - // template - // struct hopper_const - // { - // template - // static Return dispatch(const lambda_hop&, const signature_ts&...) noexcept - // { - // return { error::EmptyRObject, RObject{} }; - // } - // }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h b/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h deleted file mode 100644 index d058d568..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_ctor.h +++ /dev/null @@ -1,39 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - - -//#include "lambda_function.h" - -namespace rtl::dispatch -{ - // template - // struct hopper_ctor - // { - // template - // static Return dispatch(const lambda_hop&, const signature_ts&...) noexcept - // { - // return { error::EmptyRObject, RObject{} }; - // } - // }; - - - // template - // struct hopper_copyctor - // { - // template - // static Return dispatch(const lambda_hop&, signature_ts&&...) noexcept - // { - // return { error::EmptyRObject, RObject{} }; - // } - // }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h b/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h deleted file mode 100644 index 08da2b17..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/hopper_nonconst.h +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -//#include "forward_decls.h" - -//#include "lambda_function.h" -//#include "functor.h" - -namespace rtl::dispatch -{ - template - struct hopper_nonconst - { - // template requires (std::is_same_v == false) - // static decltype(auto) dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - // { - // auto functor = lambda_ref.get_functor().template get_nonconst() - // .template get(lambda_ref.m_returnId); - - // if constexpr (std::is_same_v) { - // (target.*functor)(params...); - // } - // else { - // return (target.*functor)(params...); - // } - // } - - - // template requires (void_t == true) - // static Return dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - // { - // if constexpr (std::is_same_v) - // { - // auto functor = lambda_ref.functor().template get_nonconst() - // .template get(lambda_ref.m_returnId); - - // (target.*functor)(params...); - // } - // else - // { - // static_assert("return-type mismatch."); - // } - // return { error::None, RObject{} }; - // } - - - // template requires (void_t == false) - // static Return dispatch(record_t& target, const lambda_hop& lambda_ref, const signature_ts&...params) noexcept - // { - // constexpr bool isConstCastSafe = (!traits::is_const_v); - - // auto functor = lambda_ref.functor().template get_nonconst() - // .template get(lambda_ref.m_returnId); - - // if constexpr (std::is_reference_v) - // { - // using T = traits::raw_t; - // const T& retObj = (target.*functor)(params...); - // return { error::None, RObject{} }; - // } - // else { - - // auto&& retObj = (target.*functor)(params...); - // using T = std::remove_cvref_t; - // return { error::None, RObject{} }; - // } - // } - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h index 2e249d9a..c537db26 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h @@ -16,30 +16,23 @@ #include "rtl_traits.h" #include "rtl_typeid.h" #include "rtl_constants.h" -#include "forward_decls.h" #include "functor.h" namespace rtl::dispatch { struct lambda_hop { - template - constexpr const functor_cast return_type() const - { - return functor_cast{ m_functor }; - } - template constexpr bool is_member() const { - return (m_functor->m_recordId == detail::TypeId>::get() || - m_functor->m_recordId == detail::TypeId>::get()); + return (m_functor->getRecordId() == detail::TypeId>::get() || + m_functor->getRecordId() == detail::TypeId>::get()); } template constexpr bool is_returning() const { - return (m_functor->m_returnId == detail::TypeId>::get()); + return (m_functor->getReturnId() == detail::TypeId>::get()); } template @@ -64,7 +57,7 @@ namespace rtl::dispatch { std::size_t recordId = detail::TypeId::get(); std::size_t typeId = detail::TypeId...>>::get(); - if (typeId == m_signatureId && recordId == m_functor->m_recordId) + if (typeId == m_signatureId && recordId == m_functor->getRecordId()) { return static_cast*>(this); } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h index 06aff442..4401acd7 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h @@ -12,15 +12,50 @@ #pragma once #include "lambda_hop.h" +#include "function_ptr.h" namespace rtl::dispatch { template struct lambda_hop_function: public lambda_hop { - lambda_hop_function(const functor*) noexcept; + lambda_hop_function(const functor* fptr) noexcept + { + m_functor = fptr; + m_signatureId = detail::TypeId...>>::get(); + detail::TypeId::get(m_argumentsId); + } + + template + constexpr const function_ptr& get_functor() const + { + // Unchecked: using an incorrect argument or return type is undefined behaviour. + // No validation is performed and the function will not return nullptr on mismatch. (By Design) + return *(static_cast*>(m_functor)); + } template - decltype(auto) dispatch(args_t&&...) const noexcept; + constexpr decltype(auto) dispatch(args_t&&...params) const + noexcept(noexcept( + std::invoke(get_functor().f_ptr(),std::declval()...) + )) + { + constexpr bool signature_ok = std::is_same_v< + std::tuple...>, + std::tuple + >; + static_assert( signature_ok, "Argument types don't match signature."); + + using fptr_t = typename function_ptr::functor_t; + + fptr_t functor = get_functor().f_ptr(); + + if constexpr (std::is_same_v) { + (*functor)(std::forward(params)...); + } + else { + return (*functor)(std::forward(params)...); + } + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp deleted file mode 100644 index e1fd291a..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include "rtl_typeid.h" -#include "lambda_hop_function.h" - -namespace rtl::dispatch -{ - template - inline lambda_hop_function::lambda_hop_function(const functor* functor) noexcept - { - m_functor = functor; - m_signatureId = detail::TypeId...>>::get(); - detail::TypeId::get(m_argumentsId); - } - - - template - template - inline decltype(auto) lambda_hop_function::dispatch(args_t&& ...params) const noexcept - { - constexpr bool signature_ok = std::is_same_v< std::tuple...>, - std::tuple>; - - static_assert( signature_ok, "Argument types don't match signature."); - - auto* functor = return_type>().template signature...>().f_ptr(); - - if constexpr (std::is_same_v) { - (*functor)(std::forward(params)...); - } - else { - return (*functor)(std::forward(params)...); - } - } -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h index f193d720..a607488c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h @@ -12,13 +12,17 @@ #pragma once #include "lambda_hop.h" -#include "hopper_nonconst.h" +#include "method_ptr.h" +#include namespace rtl::dispatch { template struct lambda_hop_method : public lambda_hop { + template + using fptr_t = typename method_ptr::functor_t; + lambda_hop_method(const functor* functor) noexcept { m_functor = functor; @@ -27,13 +31,33 @@ namespace rtl::dispatch } template - decltype(auto) dispatch(record_t& target, const signature_ts& ...params) const noexcept + constexpr const method_ptr& get_functor() const { + // Unchecked: using an incorrect argument or return type is undefined behaviour. + // No validation is performed and the function will not return nullptr on mismatch. (By Design) + return *(static_cast*>(m_functor)); + } + + template + constexpr decltype(auto) dispatch(record_t& target, args_t&& ...params) const + noexcept(noexcept( + (std::declval().*std::declval>())(std::declval()...) + )) + { + constexpr bool signature_ok = std::is_same_v< + std::tuple...>, + std::tuple + >; + + static_assert( signature_ok, "Argument types don't match signature."); + + fptr_t functor = get_functor().f_ptr(); + if constexpr (std::is_same_v) { - hopper_nonconst::template dispatch(target, *this, params...); + (target.*functor)(std::forward(params)...); } else { - return hopper_nonconst::template dispatch(target, *this, params...); + return (target.*functor)(std::forward(params)...); } } }; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp deleted file mode 100644 index 3b1a16c9..00000000 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.hpp +++ /dev/null @@ -1,21 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -//#include "functor.h" -//#include "lambda_method.h" -//#include "hopper_nonconst.h" - -namespace rtl::detail -{ - -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 403afeae..12563781 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -22,7 +22,7 @@ namespace rtl::dispatch { using functor_t = return_t(record_t::*)(signature_ts...); - constexpr functor_t get() const + constexpr functor_t f_ptr() const { return m_functor; } From fb21c8461b7ce8750dad2e7769aaa4553df6f15b Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 22 Sep 2025 01:56:11 +0530 Subject: [PATCH 022/148] refactored/refined & tested caches/lambda/functor for correct fptrs. --- .../src/ReflectedCallKnownReturn.cpp | 24 +++---- RTLBenchmarkApp/src/main.cpp | 2 + .../CxxMirrorTests/CxxMirrorObjectTest.cpp | 8 +-- .../rtl/builder/SetupFunction.hpp | 16 ++--- .../rtl/builder/SetupMethod.hpp | 32 ++++----- .../rtl/cache/cache_const_method_ptr.h | 4 +- .../rtl/cache/cache_function_ptr.h | 4 +- .../rtl/cache/cache_lambda_hop_function.h | 24 +++---- .../rtl/cache/cache_lambda_hop_method.h | 24 +++---- .../rtl/cache/cache_method_ptr.h | 4 +- .../rtl/detail/inc/FunctorId.h | 2 +- .../rtl/detail/inc/forward_decls.h | 15 ++++- ReflectionTemplateLib/rtl/dispatch/functor.h | 29 ++++---- .../rtl/dispatch/lambda_hop.h | 67 +++++++++++-------- .../rtl/dispatch/lambda_hop_function.h | 40 ++++++----- .../rtl/dispatch/lambda_hop_method.h | 39 +++++------ ReflectionTemplateLib/rtl/inc/Function.h | 4 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 4 +- ReflectionTemplateLib/rtl/inc/Method.h | 2 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 6 +- ReflectionTemplateLib/rtl/rtl.h | 4 +- ReflectionTemplateLib/rtl/rtl_constants.h | 17 +++++ ReflectionTemplateLib/rtl/src/CxxMirror.cpp | 2 +- .../rtl/src/CxxMirrorToJson.cpp | 2 +- 24 files changed, 204 insertions(+), 171 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index dd2457ef..29fb08e1 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -20,31 +20,31 @@ namespace { static const rtl::lambda_function& getMessage_lambda = []() { - // No validation is performed internally and lambda_hop + // No validation is performed internally and lambda // will not return nullptr on signature mismatch. (by design) - return *(cxx::mirror().getFunction("getMessage")->lambda_hop()); + return *(cxx::mirror().getFunction("getMessage")->get_lambda()); }(); static const rtl::lambda_function& sendMessage_lambda = []() { - // No validation is performed internally and lambda_hop + // No validation is performed internally and lambda // will not return nullptr on signature mismatch. (by design) - return *(cxx::mirror().getFunction("sendMessage")->lambda_hop()); + return *(cxx::mirror().getFunction("sendMessage")->get_lambda()); }(); static const rtl::lambda_method& getMessageOnNode_lambda = []() { - // No validation is performed internally and lambda_hop + // No validation is performed internally and lambda // will not return nullptr on signature mismatch. (by design) - return *(cxx::mirror().getRecord("Node")->getMethod("getMessage")->lambda_hop()); + return *(cxx::mirror().getRecord("Node")->getMethod("getMessage")->get_lambda()); }(); static const rtl::lambda_method& sendMessageOnNode_lambda = []() { rtl::Record Node = cxx::mirror().getRecord("Node").value(); - // No validation is performed internally and lambda_hop + // No validation is performed internally and lambda // will not return nullptr on signature mismatch. (by design) - return *(cxx::mirror().getRecord("Node")->getMethod("sendMessage")->lambda_hop()); + return *(cxx::mirror().getRecord("Node")->getMethod("sendMessage")->get_lambda()); }(); } @@ -154,7 +154,7 @@ void ReflectedCallKnownReturn::set(benchmark::State& state) { if (passed) { - sendMessage_lambda.dispatch(bm::g_longStr); + sendMessage_lambda.hop(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -168,7 +168,7 @@ void ReflectedCallKnownReturn::get(benchmark::State& state) { if (passed) { - auto retStr = getMessage_lambda.dispatch(bm::g_longStr); + auto retStr = getMessage_lambda.hop(bm::g_longStr); benchmark::DoNotOptimize(retStr); } } @@ -194,7 +194,7 @@ void ReflectedMethodCallKnownReturn::set(benchmark::State& state) { if (functor) { - sendMessageOnNode_lambda.dispatch(nodeObj, bm::g_longStr); + sendMessageOnNode_lambda.hop(nodeObj, bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -220,7 +220,7 @@ void ReflectedMethodCallKnownReturn::get(benchmark::State& state) { if (functor) { - auto retStr = getMessageOnNode_lambda.dispatch(nodeObj, bm::g_longStr); + auto retStr = getMessageOnNode_lambda.hop(nodeObj, bm::g_longStr); benchmark::DoNotOptimize(retStr); } } diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index d459fd79..bd07a5c3 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -24,9 +24,11 @@ BENCHMARK(ReflectedMethodCallUnknownReturn::set); BENCHMARK(NativeCall::get); BENCHMARK(FunctionPointerCall::get); +//BENCHMARK(ReflectedMethodCallKnownReturn::get); BENCHMARK(StdFunctionCall::get); BENCHMARK(ReflectedCallKnownReturn::get); BENCHMARK(ReflectedCallUnknownReturn::get); +//BENCHMARK(ReflectedMethodCallKnownReturn::get); BENCHMARK(StdFunctionMethodCall::get); BENCHMARK(ReflectedMethodCallKnownReturn::get); diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp index 41492567..d6f62f6e 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp @@ -287,8 +287,8 @@ namespace rtl_tests // Even though the functions are registered in different namespaces, // the underlying FunctorIds (which identify function-pointers) must be equal. - const std::vector& cfunctorIds = cstrLen->getOverloads(); - const std::vector& stdfunctorIds = stdStrLen->getOverloads(); + const std::vector& cfunctorIds = cstrLen->getFunctors(); + const std::vector& stdfunctorIds = stdStrLen->getFunctors(); EXPECT_EQ(cfunctorIds, stdfunctorIds); } @@ -349,8 +349,8 @@ namespace rtl_tests // Despite different symbolic names, both reflect the same function-pointer. // Hence, their FunctorIds must be identical. - const std::vector& cfunctorIds = cstrLen->getOverloads(); - const std::vector& stdfunctorIds = stdStrLen->getOverloads(); + const std::vector& cfunctorIds = cstrLen->getFunctors(); + const std::vector& stdfunctorIds = stdStrLen->getFunctors(); EXPECT_EQ(cfunctorIds, stdfunctorIds); } diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index a5cc37eb..dd94db02 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -30,8 +30,8 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); - assert(isAllGood && "new type-id-system not working."); + bool isFunctorGood = (pFunctor == pFunctorId.m_lambda->to_function<_signature...>()->template get_functor().f_ptr()); + assert(isFunctorGood && "new type-id-system not working."); pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -48,8 +48,8 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); - assert(isAllGood && "new type-id-system not working."); + bool isFunctorGood = (pFunctor == pFunctorId.m_lambda->to_function<_signature...>()->template get_functor<_returnType>().f_ptr()); + assert(isFunctorGood && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); @@ -89,14 +89,14 @@ namespace rtl template inline const detail::FunctorId SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) { - const dispatch::lambda_hop* lambdaPtr = nullptr; + const dispatch::lambda* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_hop_function<_signature...>::instance(); + auto& lambdaCache = cache::lambda_function<_signature...>::instance(); auto& functorCache = cache::function_ptr<_returnType, _signature...>::instance(); - auto* functor = functorCache.push(pFunctor, pIndex); + auto& functor = functorCache.push(pFunctor, pIndex); auto& lambda = lambdaCache.push(functor); lambdaPtr = λ @@ -107,7 +107,7 @@ namespace rtl auto& functorCache = cache::function_ptr<_returnType, _signature...>::instance(); auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->getLambdaHop(); + lambdaPtr = functor->get_lambda(); } return lambdaIndex; }; diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 2d416b8b..dde8b903 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -34,8 +34,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); - assert(isAllGood && "new type-id-system not working."); + bool isFunctorGood = (pFunctor == pFunctorId.m_lambda->to_method<_recordType, _signature...>()->template get_functor().f_ptr()); + assert(isFunctorGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -57,8 +57,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); - assert(isAllGood && "new type-id-system not working."); + bool isFunctorGood = (pFunctor == pFunctorId.m_lambda->to_method<_recordType, _signature...>()->template get_functor<_returnType>().f_ptr()); + assert(isFunctorGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -101,8 +101,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); - assert(isAllGood && "new type-id-system not working."); + bool isLambdaGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->get_functor().get_lambda()); + assert(isLambdaGood && "new type-id-system not working."); const _recordType& target = pTargetObj.view<_recordType>()->get(); (target.*pFunctor)(std::forward<_signature>(params)...); @@ -120,8 +120,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isAllGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->m_functor->getLambdaHop()); - assert(isAllGood && "new type-id-system not working."); + bool isLambdaGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->get_functor().get_lambda()); + assert(isLambdaGood && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); //'target' is const and 'pFunctor' is const-member-function. @@ -163,13 +163,13 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { - const dispatch::lambda_hop* lambdaPtr = nullptr; + const dispatch::lambda* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_hop_method<_recordType, _signature...>::instance(); + auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); auto& functorCache = cache::method_ptr<_recordType, _returnType, _signature...>::instance(); - auto* functor = functorCache.push(pFunctor, pIndex); + auto& functor = functorCache.push(pFunctor, pIndex); auto& lambda = lambdaCache.push(functor); lambdaPtr = λ @@ -181,7 +181,7 @@ namespace rtl::detail auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->getLambdaHop(); + lambdaPtr = functor->get_lambda(); } return lambdaIndex; }; @@ -234,13 +234,13 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) { - const dispatch::lambda_hop* lambdaPtr = nullptr; + const dispatch::lambda* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_hop_method<_recordType, _signature...>::instance(); + auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); auto& functorCache = cache::const_method_ptr<_recordType, _returnType, _signature...>::instance(); - auto* functor = functorCache.push(pFunctor, pIndex); + auto& functor = functorCache.push(pFunctor, pIndex); auto& lambda = lambdaCache.push(functor); lambdaPtr = λ @@ -252,7 +252,7 @@ namespace rtl::detail auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->getLambdaHop(); + lambdaPtr = functor->get_lambda(); } return lambdaIndex; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h index 94ce76a0..e4a8826b 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h @@ -28,10 +28,10 @@ namespace rtl::cache return instance_; } - const dispatch::functor* push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const + const dispatch::functor& push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const { m_cache.emplace_back(std::make_pair(fptr, lambda_index)); - return &(m_cache.back().first); + return m_cache.back().first; } std::pair find(return_t(record_t::* fptr)(signature_ts...) const) const diff --git a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index 2337eee7..8167b8fe 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -28,10 +28,10 @@ namespace rtl::cache return instance_; } - const dispatch::functor* push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const + const dispatch::functor& push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const { m_cache.emplace_back(std::make_pair(fptr, lambda_index)); - return &(m_cache.back().first); + return m_cache.back().first; } std::pair find(return_t(*fptr)(signature_ts...)) const diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h index b27274e5..c64687c0 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h @@ -18,31 +18,31 @@ namespace rtl::cache { template - struct lambda_hop_function + struct lambda_function { - static const lambda_hop_function& instance() + static const lambda_function& instance() { - static const lambda_hop_function instance_; + static const lambda_function instance_; return instance_; } - const dispatch::lambda_hop_function& push(const dispatch::functor* fptr) const + const dispatch::lambda_function& push(const dispatch::functor& fptr) const { - m_cache.push_back(dispatch::lambda_hop_function(fptr)); - fptr->set_lambda(&m_cache.back()); + m_cache.push_back(dispatch::lambda_function(fptr)); + fptr.m_lambda = &m_cache.back(); return m_cache.back(); } - lambda_hop_function(lambda_hop_function&&) = delete; - lambda_hop_function(const lambda_hop_function&) = delete; - lambda_hop_function& operator=(lambda_hop_function&&) = delete; - lambda_hop_function& operator=(const lambda_hop_function&) = delete; + lambda_function(lambda_function&&) = delete; + lambda_function(const lambda_function&) = delete; + lambda_function& operator=(lambda_function&&) = delete; + lambda_function& operator=(const lambda_function&) = delete; private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; - lambda_hop_function() = default; + lambda_function() = default; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h index f72bc546..9d6c30c0 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h @@ -18,31 +18,31 @@ namespace rtl::cache { template - struct lambda_hop_method + struct lambda_method { - static const lambda_hop_method& instance() + static const lambda_method& instance() { - static const lambda_hop_method instance_; + static const lambda_method instance_; return instance_; } - const dispatch::lambda_hop_method& push(const dispatch::functor* fptr) const + const dispatch::lambda_method& push(const dispatch::functor& fptr) const { - m_cache.push_back(dispatch::lambda_hop_method(fptr)); - fptr->set_lambda(&m_cache.back()); + m_cache.push_back(dispatch::lambda_method(fptr)); + fptr.m_lambda = &m_cache.back(); return m_cache.back(); } - lambda_hop_method(lambda_hop_method&&) = delete; - lambda_hop_method(const lambda_hop_method&) = delete; - lambda_hop_method& operator=(lambda_hop_method&&) = delete; - lambda_hop_method& operator=(const lambda_hop_method&) = delete; + lambda_method(lambda_method&&) = delete; + lambda_method(const lambda_method&) = delete; + lambda_method& operator=(lambda_method&&) = delete; + lambda_method& operator=(const lambda_method&) = delete; private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; - lambda_hop_method() = default; + lambda_method() = default; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h index 16c19862..a607f1e2 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h @@ -28,10 +28,10 @@ namespace rtl::cache return instance_; } - const dispatch::functor* push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const + const dispatch::functor& push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const { m_cache.emplace_back(std::make_pair(fptr, lambda_index)); - return &(m_cache.back().first); + return m_cache.back().first; } std::pair find(return_t(record_t::* fptr)(signature_ts...)) const diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 7dd8a163..f9a28da7 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -43,7 +43,7 @@ namespace rtl::detail //signature of functor as string. platform dependent, may not be very much readable format. std::string m_signature; - const dispatch::lambda_hop* m_lambda = nullptr; + const dispatch::lambda* m_lambda = nullptr; GETTER(std::size_t, LambdaIndex, m_lambdaIndex) GETTER(std::size_t, ReturnId, m_returnId); diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 0497b75d..63456bd0 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -33,17 +33,26 @@ namespace rtl class FunctorContainer; } + namespace cache + { + template + struct lambda_function; + + template + struct lambda_method; + } + namespace dispatch { struct functor; - class lambda_hop; + struct lambda; template - struct lambda_hop_function; + class lambda_function; template - struct lambda_hop_method; + class lambda_method; template struct function_ptr; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 5f8e6152..06a6a9ce 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -19,23 +19,24 @@ namespace rtl::dispatch { struct functor { - constexpr void set_lambda(const lambda_hop* lambda) const - { - m_lambda = lambda; - } + std::size_t m_recordId = detail::TypeId<>::None; + std::size_t m_returnId = detail::TypeId<>::None; + std::size_t m_signatureId = detail::TypeId<>::None; - GETTER(std::size_t, ReturnId, m_returnId); - GETTER(std::size_t, RecordId, m_recordId); - GETTER(std::size_t, SignatureId, m_signatureId); - GETTER(lambda_hop*, LambdaHop, m_lambda); + std::vector m_argumentsId = {}; - protected: + detail::methodQ m_qualifier = detail::methodQ::None; - mutable const lambda_hop* m_lambda = nullptr; + GETTER_CPTR(lambda, _lambda, m_lambda) - std::size_t m_recordId = detail::TypeId<>::None; - std::size_t m_returnId = detail::TypeId<>::None; - std::size_t m_signatureId = detail::TypeId<>::None; - detail::methodQ m_qualifier = detail::methodQ::None; + private: + + mutable const lambda* m_lambda = nullptr; + + template + friend struct cache::lambda_function; + + template + friend struct cache::lambda_method; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h index c537db26..a783689a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h @@ -20,56 +20,67 @@ namespace rtl::dispatch { - struct lambda_hop + struct lambda { - template - constexpr bool is_member() const - { - return (m_functor->getRecordId() == detail::TypeId>::get() || - m_functor->getRecordId() == detail::TypeId>::get()); - } + protected: - template - constexpr bool is_returning() const - { - return (m_functor->getReturnId() == detail::TypeId>::get()); - } + const functor& m_functor; - template - constexpr bool is_signature() const - { - return (m_signatureId == detail::TypeId...>>::get()); - } + lambda(const functor& p_functor) noexcept + :m_functor(p_functor) + { } + + template + using function_t = lambda_function; + + template + using method_t = lambda_method; + + public: + + GETTER_CREF(functor, _functor, m_functor); template - constexpr const lambda_hop_function* get_function() const + constexpr const function_t* to_function() const { const std::size_t typeId = detail::TypeId...>>::get(); - if (typeId == m_signatureId) + if (typeId == m_functor.m_signatureId) { - return static_cast*>(this); + return static_cast*>(this); } return nullptr; } template - const lambda_hop_method* get_method() const + const method_t* to_method() const { std::size_t recordId = detail::TypeId::get(); std::size_t typeId = detail::TypeId...>>::get(); - if (typeId == m_signatureId && recordId == m_functor->getRecordId()) + if (typeId == m_functor.m_signatureId && recordId == m_functor.m_recordId) { - return static_cast*>(this); + return static_cast*>(this); } return nullptr; } - GETTER(std::size_t, SignatureId, m_signatureId); -// protected: + template + constexpr bool is_returning() const + { + return (m_functor.m_returnId == detail::TypeId>::get()); + } + + template + constexpr bool is_signature() const + { + return (m_functor.m_signatureId == detail::TypeId...>>::get()); + } - const functor* m_functor = nullptr; - std::size_t m_signatureId = detail::TypeId<>::None; - std::vector m_argumentsId = {}; + template + constexpr bool is_member() const + { + return (m_functor.m_recordId == detail::TypeId>::get() || + m_functor.m_recordId == detail::TypeId>::get()); + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h index 4401acd7..17e2b4b4 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h @@ -17,39 +17,37 @@ namespace rtl::dispatch { template - struct lambda_hop_function: public lambda_hop + class lambda_function: public lambda { - lambda_hop_function(const functor* fptr) noexcept - { - m_functor = fptr; - m_signatureId = detail::TypeId...>>::get(); - detail::TypeId::get(m_argumentsId); - } + template + using fptr_t = typename function_ptr::functor_t; + + template + static constexpr bool is_argst_ok = std::is_same_v...>, std::tuple>; + + template + static constexpr bool noexcept_v = noexcept(std::declval>()(std::declval()...)); + + public: + + lambda_function(const functor& fptr) noexcept + :lambda(fptr) + { } template constexpr const function_ptr& get_functor() const { // Unchecked: using an incorrect argument or return type is undefined behaviour. // No validation is performed and the function will not return nullptr on mismatch. (By Design) - return *(static_cast*>(m_functor)); + return static_cast&>(m_functor); } template - constexpr decltype(auto) dispatch(args_t&&...params) const - noexcept(noexcept( - std::invoke(get_functor().f_ptr(),std::declval()...) - )) + constexpr decltype(auto) hop(args_t&&...params) const //noexcept(noexcept_v) { - constexpr bool signature_ok = std::is_same_v< - std::tuple...>, - std::tuple - >; - static_assert( signature_ok, "Argument types don't match signature."); - - using fptr_t = typename function_ptr::functor_t; - - fptr_t functor = get_functor().f_ptr(); + static_assert(is_argst_ok, "Argument types don't match signature."); + fptr_t functor = get_functor().f_ptr(); if constexpr (std::is_same_v) { (*functor)(std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h index a607488c..967659ff 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h @@ -13,46 +13,41 @@ #include "lambda_hop.h" #include "method_ptr.h" -#include namespace rtl::dispatch { template - struct lambda_hop_method : public lambda_hop + class lambda_method : public lambda { template using fptr_t = typename method_ptr::functor_t; - lambda_hop_method(const functor* functor) noexcept - { - m_functor = functor; - m_signatureId = detail::TypeId...>>::get(); - detail::TypeId::get(m_argumentsId); - } + template + static constexpr bool is_argst_ok = std::is_same_v...>, std::tuple>; + template + static constexpr bool noexcept_v = noexcept((std::declval().*std::declval>())(std::declval()...)); + + public: + + lambda_method(const functor& fptr) noexcept + :lambda(fptr) + { } + + // Unsafe: using an incorrect argument or return type is undefined behaviour. + // Not validated here and the function will not return nullptr on mismatch. (By Design) template constexpr const method_ptr& get_functor() const { - // Unchecked: using an incorrect argument or return type is undefined behaviour. - // No validation is performed and the function will not return nullptr on mismatch. (By Design) - return *(static_cast*>(m_functor)); + return static_cast&>(m_functor); } template - constexpr decltype(auto) dispatch(record_t& target, args_t&& ...params) const - noexcept(noexcept( - (std::declval().*std::declval>())(std::declval()...) - )) + constexpr decltype(auto) hop(record_t& target, args_t&& ...params) const noexcept(noexcept_v) { - constexpr bool signature_ok = std::is_same_v< - std::tuple...>, - std::tuple - >; - - static_assert( signature_ok, "Argument types don't match signature."); + static_assert(is_argst_ok, "Argument types don't match signature."); fptr_t functor = get_functor().f_ptr(); - if constexpr (std::is_same_v) { (target.*functor)(std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index a4a4e9b6..6310aaf4 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -81,7 +81,7 @@ namespace rtl { GETTER(std::string, Namespace, m_namespace); GETTER(std::string, FunctionName, m_function); GETTER(std::size_t, RecordTypeId, m_recordTypeId); - GETTER(std::vector, Overloads, m_functorIds); + GETTER(std::vector, Functors, m_functorIds); Function() = default; Function(Function&&) = default; @@ -96,7 +96,7 @@ namespace rtl { bool hasSignature() const; template - const dispatch::lambda_hop_function<_signature...>* lambda_hop(std::size_t pOverloadIndex = 0) const; + const dispatch::lambda_function<_signature...>* get_lambda(std::size_t pOverloadIndex = 0) const; template Return operator()(_args&&...params) const noexcept; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index cf8f230b..56eea735 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -23,11 +23,11 @@ namespace rtl } template - const dispatch::lambda_hop_function<_signature...>* Function::lambda_hop(std::size_t pOverloadIndex) const + const dispatch::lambda_function<_signature...>* Function::get_lambda(std::size_t pOverloadIndex) const { if (pOverloadIndex < m_functorIds.size()) { - return m_functorIds[pOverloadIndex].m_lambda->get_function<_signature...>(); + return m_functorIds[pOverloadIndex].m_lambda->to_function<_signature...>(); } return nullptr; } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index d6394d03..2733d58c 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -67,7 +67,7 @@ namespace rtl { const detail::NonConstInvoker<_signature...> bind(constCast&& pTarget) const; template - const dispatch::lambda_hop_method<_recordType, _signature...>* lambda_hop(std::size_t pOverloadIndex = 0) const; + const dispatch::lambda_method<_recordType, _signature...>* get_lambda(std::size_t pOverloadIndex = 0) const; /* @method: operator()() @return: lambda diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 86517622..57bdbab5 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -30,12 +30,12 @@ namespace rtl template - const dispatch::lambda_hop_method<_recordType, _signature...>* Method::lambda_hop(std::size_t pOverloadIndex) const + const dispatch::lambda_method<_recordType, _signature...>* Method::get_lambda(std::size_t pOverloadIndex) const { - auto& functorIds = getOverloads(); + auto& functorIds = getFunctors(); if (pOverloadIndex < functorIds.size()) { - return functorIds[pOverloadIndex].m_lambda->get_method<_recordType, _signature...>(); + return functorIds[pOverloadIndex].m_lambda->to_method<_recordType, _signature...>(); } return nullptr; } diff --git a/ReflectionTemplateLib/rtl/rtl.h b/ReflectionTemplateLib/rtl/rtl.h index 9a803b14..4c53df70 100644 --- a/ReflectionTemplateLib/rtl/rtl.h +++ b/ReflectionTemplateLib/rtl/rtl.h @@ -105,8 +105,8 @@ namespace rtl { template - using lambda_function = dispatch::lambda_hop_function; + using lambda_function = dispatch::lambda_function; template - using lambda_method = dispatch::lambda_hop_method; + using lambda_method = dispatch::lambda_method; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_constants.h b/ReflectionTemplateLib/rtl/rtl_constants.h index 09e927c4..99af7fb8 100644 --- a/ReflectionTemplateLib/rtl/rtl_constants.h +++ b/ReflectionTemplateLib/rtl/rtl_constants.h @@ -144,6 +144,12 @@ namespace rtl::detail return (std::string(pRecordName) + "::" + std::string(pRecordName) + "()"); } + +#define GETTER_(_varType, _name, _var) \ + inline constexpr const _varType& _name() const { \ + return _var; \ + } + #define GETTER(_varType, _name, _var) \ inline constexpr const _varType& get##_name() const { \ return _var; \ @@ -154,6 +160,17 @@ namespace rtl::detail return _var; \ } + +#define GETTER_CPTR_(_varType, _name, _var) \ + constexpr inline const _varType* _name() const { \ + return _var; \ + } + +#define GETTER_CPTR(_varType, _name, _var) \ + constexpr inline const _varType* get##_name() const { \ + return _var; \ + } + #define GETTER_CREF(_varType, _name, _var) \ inline const _varType& get##_name() const { \ return _var; \ diff --git a/ReflectionTemplateLib/rtl/src/CxxMirror.cpp b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp index 72d8f202..9054699d 100644 --- a/ReflectionTemplateLib/rtl/src/CxxMirror.cpp +++ b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp @@ -32,7 +32,7 @@ namespace rtl { const Record& record = itr->second; Method ctors = record.getMethod(detail::ctor_name(record.getRecordName())).value(); - const_cast(pTarget).m_objectId.m_clonerId = ctors.getOverloads()[detail::Index::CopyCtor]; + const_cast(pTarget).m_objectId.m_clonerId = ctors.getFunctors()[detail::Index::CopyCtor]; return error::None; } return error::CloningDisabled; diff --git a/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp b/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp index fe35b583..9905c356 100644 --- a/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp +++ b/ReflectionTemplateLib/rtl/src/CxxMirrorToJson.cpp @@ -40,7 +40,7 @@ static const std::string toJson(const FunctorId& pFunctorId) static const std::string toJson(const Function& pFunction) { std::stringstream sout; - const auto& functors = pFunction.getOverloads(); + const auto& functors = pFunction.getFunctors(); const std::string& record = pFunction.getRecordName(); const std::string& nmspace = pFunction.getNamespace(); From 88f189d31185f43694febbaec98a5cf2b7ce050d Mon Sep 17 00:00:00 2001 From: neeraj Date: Mon, 22 Sep 2025 13:11:08 +0530 Subject: [PATCH 023/148] return value propogation optimized. --- RTLBenchmarkApp/src/BenchMark.cpp | 13 ++-- RTLBenchmarkApp/src/BenchMark.h | 4 +- .../src/ReflectedCallKnownReturn.cpp | 60 +++++++++++++++++-- .../src/ReflectedCallKnownReturn.h | 12 +++- .../src/ReflectedCallUnknownReturn.cpp | 8 +-- .../src/ReflectedCallUnknownReturn.h | 4 +- RTLBenchmarkApp/src/StandardCall.cpp | 12 ++-- RTLBenchmarkApp/src/StdFunction.cpp | 10 ++-- RTLBenchmarkApp/src/main.cpp | 19 +++--- .../rtl/builder/FunctorContainer.h | 2 +- .../rtl/builder/SetupFunction.hpp | 2 +- .../rtl/builder/SetupMethod.hpp | 4 +- .../rtl/cache/CMakeLists.txt | 4 +- ...hop_function.h => cache_lambda_function.h} | 2 +- ...bda_hop_method.h => cache_lambda_method.h} | 2 +- .../rtl/detail/inc/FunctorId.h | 2 +- .../rtl/dispatch/CMakeLists.txt | 6 +- .../rtl/dispatch/function_ptr.h | 4 +- .../rtl/dispatch/{lambda_hop.h => lambda.h} | 6 +- ...ambda_hop_function.h => lambda_function.h} | 23 ++++--- .../{lambda_hop_method.h => lambda_method.h} | 23 ++++--- .../rtl/dispatch/method_ptr.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/inc/Method.h | 2 +- ReflectionTemplateLib/rtl/inc/RObject.h | 4 +- ReflectionTemplateLib/rtl/rtl.h | 8 +-- ReflectionTemplateLib/rtl/rtl_constants.h | 13 ---- ReflectionTemplateLib/rtl/rtl_traits.h | 2 - ReflectionTemplateLib/rtl/rtl_typeid.h | 1 - ReflectionTemplateLib/rtl/src/CxxMirror.cpp | 1 - 30 files changed, 143 insertions(+), 114 deletions(-) rename ReflectionTemplateLib/rtl/cache/{cache_lambda_hop_function.h => cache_lambda_function.h} (98%) rename ReflectionTemplateLib/rtl/cache/{cache_lambda_hop_method.h => cache_lambda_method.h} (98%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_hop.h => lambda.h} (95%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_hop_function.h => lambda_function.h} (69%) rename ReflectionTemplateLib/rtl/dispatch/{lambda_hop_method.h => lambda_method.h} (68%) diff --git a/RTLBenchmarkApp/src/BenchMark.cpp b/RTLBenchmarkApp/src/BenchMark.cpp index 350617aa..2b1ef9f1 100644 --- a/RTLBenchmarkApp/src/BenchMark.cpp +++ b/RTLBenchmarkApp/src/BenchMark.cpp @@ -1,11 +1,10 @@ #include -#include -#include +#include #include "BenchMark.h" -#include + namespace bm @@ -20,21 +19,21 @@ namespace bm namespace bm { - void sendMessage(argStr_t pMsg) + void sendMessage(argStr_t pMsg) noexcept { if(g_work_load){ g_work_done = perform_work(pMsg); } } - void Node::sendMessage(argStr_t pMsg) + void Node::sendMessage(argStr_t pMsg) noexcept { if(g_work_load){ g_work_done = perform_work(pMsg); } } - retStr_t getMessage(argStr_t pMsg) + retStr_t getMessage(argStr_t pMsg) noexcept { if(g_work_load){ g_work_done = perform_work(pMsg); @@ -42,7 +41,7 @@ namespace bm return retStr_t(g_work_done->c_str()); } - retStr_t Node::getMessage(argStr_t pMsg) + retStr_t Node::getMessage(argStr_t pMsg) noexcept { if(g_work_load){ g_work_done = perform_work(pMsg); diff --git a/RTLBenchmarkApp/src/BenchMark.h b/RTLBenchmarkApp/src/BenchMark.h index ac27f784..a6bbc513 100644 --- a/RTLBenchmarkApp/src/BenchMark.h +++ b/RTLBenchmarkApp/src/BenchMark.h @@ -10,8 +10,8 @@ namespace bm struct Node { - void sendMessage(argStr_t); - retStr_t getMessage(argStr_t); + void sendMessage(argStr_t) noexcept; + retStr_t getMessage(argStr_t) noexcept; }; } diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 29fb08e1..1f074814 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -122,6 +122,58 @@ void FunctionPointerCall::set(benchmark::State& state) } +void MethodFnPointerCall::set(benchmark::State& state) +{ + static bm::Node nodeObj; + static auto functor = []() -> void(bm::Node::*)(bm::argStr_t) + { + // Must be checked: Passing an incorrect argument or return type is undefined behaviour. + if (sendMessageOnNode_lambda.is_returning() && sendMessageOnNode_lambda.is_signature()) + { + // No validation is performed internally and the function will not return nullptr on mismatch. + return sendMessageOnNode_lambda.get_functor().f_ptr(); + } + std::cout << "[8] error: signature mismatch.\n"; + return nullptr; + }(); + + for (auto _ : state) + { + if (functor) + { + (nodeObj.*functor)(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } + } +} + + +void MethodFnPointerCall::get(benchmark::State& state) +{ + static bm::Node nodeObj; + static auto functor = []() -> bm::retStr_t(bm::Node::*)(bm::argStr_t) + { + // Must be checked: Passing an incorrect argument or return type is undefined behaviour. + if (getMessageOnNode_lambda.is_returning() && getMessageOnNode_lambda.is_signature()) + { + // No validation is performed internally and the function will not return nullptr on mismatch. + return getMessageOnNode_lambda.get_functor().f_ptr(); + } + std::cout << "[9] error: signature mismatch.\n"; + return nullptr; + }(); + + for (auto _ : state) + { + if (functor) + { + auto ret = (nodeObj.*functor)(bm::g_longStr); + benchmark::DoNotOptimize(ret); + } + } +} + + void FunctionPointerCall::get(benchmark::State& state) { static auto* functor = []() -> bm::retStr_t(*)(bm::argStr_t) @@ -147,7 +199,7 @@ void FunctionPointerCall::get(benchmark::State& state) } -void ReflectedCallKnownReturn::set(benchmark::State& state) +void RtlReflectedCall::set(benchmark::State& state) { static auto passed = _test0(); for (auto _ : state) @@ -161,7 +213,7 @@ void ReflectedCallKnownReturn::set(benchmark::State& state) } -void ReflectedCallKnownReturn::get(benchmark::State& state) +void RtlReflectedCall::get(benchmark::State& state) { static auto passed = _test2(); for (auto _: state) @@ -175,7 +227,7 @@ void ReflectedCallKnownReturn::get(benchmark::State& state) } -void ReflectedMethodCallKnownReturn::set(benchmark::State& state) +void RtlReflectedMethodCall::set(benchmark::State& state) { static bm::Node nodeObj; static auto functor = []() -> void(bm::Node::*)(bm::argStr_t) @@ -201,7 +253,7 @@ void ReflectedMethodCallKnownReturn::set(benchmark::State& state) } -void ReflectedMethodCallKnownReturn::get(benchmark::State& state) +void RtlReflectedMethodCall::get(benchmark::State& state) { static bm::Node nodeObj; static auto functor = []() -> bm::retStr_t(bm::Node::*)(bm::argStr_t) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index eefbd04c..e1f9c47a 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -2,7 +2,7 @@ #include -struct ReflectedCallKnownReturn +struct RtlReflectedCall { static void set(benchmark::State& state); @@ -18,7 +18,15 @@ struct FunctionPointerCall }; -struct ReflectedMethodCallKnownReturn +struct MethodFnPointerCall +{ + static void set(benchmark::State& state); + + static void get(benchmark::State& state); +}; + + +struct RtlReflectedMethodCall { static void set(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 91ca4fb4..db9b2ee9 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -84,7 +84,7 @@ namespace -void ReflectedCallUnknownReturn::set(benchmark::State& state) +void RtlReflectedCall_retUnknown::set(benchmark::State& state) { static auto _ = _test0(); for (auto _ : state) @@ -95,7 +95,7 @@ void ReflectedCallUnknownReturn::set(benchmark::State& state) } -void ReflectedCallUnknownReturn::get(benchmark::State& state) +void RtlReflectedCall_retUnknown::get(benchmark::State& state) { static auto _ = _test2(); for (auto _ : state) @@ -106,7 +106,7 @@ void ReflectedCallUnknownReturn::get(benchmark::State& state) } -void ReflectedMethodCallUnknownReturn::set(benchmark::State& state) +void RtlReflectionMethodCall_retUnknown::set(benchmark::State& state) { static auto _ = _test1(); for (auto _ : state) @@ -117,7 +117,7 @@ void ReflectedMethodCallUnknownReturn::set(benchmark::State& state) } -void ReflectedMethodCallUnknownReturn::get(benchmark::State& state) +void RtlReflectionMethodCall_retUnknown::get(benchmark::State& state) { static auto _ = _test3(); for (auto _ : state) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index 65c28df9..c2890430 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -2,7 +2,7 @@ #include -struct ReflectedCallUnknownReturn +struct RtlReflectedCall_retUnknown { static void set(benchmark::State& state); @@ -10,7 +10,7 @@ struct ReflectedCallUnknownReturn }; -struct ReflectedMethodCallUnknownReturn +struct RtlReflectionMethodCall_retUnknown { static void set(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 419fd315..53294634 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -10,7 +10,7 @@ namespace { static auto _put_line = []() { std::cout << "----------------------------------------" - "----------------------------------------" << std::endl; + "------------------------------------------" << std::endl; return 0; }; @@ -31,11 +31,11 @@ namespace bm extern std::function SendMessage; - extern std::function NodeSendMessage; + extern std::function NodeSendMessage; extern std::function GetMessage; - extern std::function NodeGetMessage; + extern std::function NodeGetMessage; } @@ -72,10 +72,11 @@ void StdFunctionCall::set(benchmark::State& state) void StdFunctionMethodCall::set(benchmark::State& state) { + static bm::Node nodeObj; static auto _=_new_line(); for (auto _: state) { - bm::NodeSendMessage(bm::g_longStr); + bm::NodeSendMessage(nodeObj, bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -93,9 +94,10 @@ void StdFunctionCall::get(benchmark::State& state) void StdFunctionMethodCall::get(benchmark::State& state) { + static bm::Node nodeObj; static auto _=_new_line(); for (auto _: state) { - benchmark::DoNotOptimize(bm::NodeGetMessage(bm::g_longStr)); + benchmark::DoNotOptimize(bm::NodeGetMessage(nodeObj, bm::g_longStr)); } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StdFunction.cpp b/RTLBenchmarkApp/src/StdFunction.cpp index b7c170e3..f3998942 100644 --- a/RTLBenchmarkApp/src/StdFunction.cpp +++ b/RTLBenchmarkApp/src/StdFunction.cpp @@ -19,8 +19,6 @@ namespace bm namespace bm { - static Node node; - extern void sendMessage(argStr_t); extern retStr_t getMessage(argStr_t); @@ -30,9 +28,9 @@ namespace bm bm::sendMessage(pMsg); }; - std::function NodeSendMessage = [](bm::argStr_t& pMsg) + std::function NodeSendMessage = [](bm::Node pNode, bm::argStr_t& pMsg) { - node.sendMessage(pMsg); + pNode.sendMessage(pMsg); }; std::function GetMessage = [](bm::argStr_t& pMsg) @@ -41,9 +39,9 @@ namespace bm return retMsg; }; - std::function NodeGetMessage = [](bm::argStr_t& pMsg) + std::function NodeGetMessage = [](bm::Node pNode, bm::argStr_t& pMsg) { - auto retMsg = node.getMessage(pMsg); + auto retMsg = pNode.getMessage(pMsg); return retMsg; }; } diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index bd07a5c3..b9a7d869 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -1,6 +1,5 @@ #include -#include #include #include "StandardCall.h" @@ -9,30 +8,32 @@ BENCHMARK(NativeCall::set); BENCHMARK(FunctionPointerCall::set); +BENCHMARK(MethodFnPointerCall::set); //BENCHMARK(ReflectedCallKnownReturn::set); //BENCHMARK(ReflectedCallKnownReturn::set); BENCHMARK(StdFunctionCall::set); -BENCHMARK(ReflectedCallKnownReturn::set); -BENCHMARK(ReflectedCallUnknownReturn::set); +BENCHMARK(RtlReflectedCall::set); +BENCHMARK(RtlReflectedCall_retUnknown::set); BENCHMARK(StdFunctionMethodCall::set); -BENCHMARK(ReflectedMethodCallKnownReturn::set); -BENCHMARK(ReflectedMethodCallUnknownReturn::set); +BENCHMARK(RtlReflectedMethodCall::set); +BENCHMARK(RtlReflectionMethodCall_retUnknown::set); BENCHMARK(NativeCall::get); BENCHMARK(FunctionPointerCall::get); +BENCHMARK(MethodFnPointerCall::get); //BENCHMARK(ReflectedMethodCallKnownReturn::get); BENCHMARK(StdFunctionCall::get); -BENCHMARK(ReflectedCallKnownReturn::get); -BENCHMARK(ReflectedCallUnknownReturn::get); +BENCHMARK(RtlReflectedCall::get); +BENCHMARK(RtlReflectedCall_retUnknown::get); //BENCHMARK(ReflectedMethodCallKnownReturn::get); BENCHMARK(StdFunctionMethodCall::get); -BENCHMARK(ReflectedMethodCallKnownReturn::get); -BENCHMARK(ReflectedMethodCallUnknownReturn::get); +BENCHMARK(RtlReflectedMethodCall::get); +BENCHMARK(RtlReflectionMethodCall_retUnknown::get); namespace bm { diff --git a/ReflectionTemplateLib/rtl/builder/FunctorContainer.h b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h index dba8bd9a..31c1e82f 100644 --- a/ReflectionTemplateLib/rtl/builder/FunctorContainer.h +++ b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h @@ -30,7 +30,7 @@ namespace rtl { /* @class: FunctorContainer @param: '_signature...' (combination of any types) - * container class for holding lambda_hop's wrapping functor, constructor calls of same signatures. + * container class for holding std::function, wrapping functor, constructor calls of same signatures. * maintains a std::vector with static lifetime. */ template class FunctorContainer : public SetupFunction>, diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index dd94db02..080ea460 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -13,7 +13,7 @@ #include -#include "cache_lambda_hop_function.h" +#include "cache_lambda_function.h" #include "cache_function_ptr.h" #include "SetupFunction.h" diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index dde8b903..1bf64725 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -18,10 +18,10 @@ #include "SetupMethod.h" #include "RObjectBuilder.hpp" -#include "lambda_hop_method.h" +#include "lambda_method.h" #include "cache_method_ptr.h" #include "cache_const_method_ptr.h" -#include "cache_lambda_hop_method.h" +#include "cache_lambda_method.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt index 24ac7968..4e5af74d 100644 --- a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt @@ -2,8 +2,8 @@ # Collect headers (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/cache_lambda_hop_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/cache_lambda_hop_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_lambda_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_lambda_function.h" "${CMAKE_CURRENT_SOURCE_DIR}/cache_function_ptr.h" "${CMAKE_CURRENT_SOURCE_DIR}/cache_method_ptr.h" "${CMAKE_CURRENT_SOURCE_DIR}/cache_const_method_ptr.h" diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h similarity index 98% rename from ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h rename to ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index c64687c0..0bc1ed17 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -13,7 +13,7 @@ #include -#include "lambda_hop_function.h" +#include "lambda_function.h" namespace rtl::cache { diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h similarity index 98% rename from ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h rename to ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index 9d6c30c0..f096814d 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -13,7 +13,7 @@ #include -#include "lambda_hop_method.h" +#include "lambda_method.h" namespace rtl::cache { diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index f9a28da7..23fcd69f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -14,7 +14,7 @@ #include "rtl_typeid.h" #include "rtl_constants.h" #include "forward_decls.h" -#include "lambda_hop_method.h" +#include "lambda_method.h" namespace rtl::detail diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 6be5bbee..d1c8956b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -8,9 +8,9 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/method_ptr.h" "${CMAKE_CURRENT_SOURCE_DIR}/const_method_ptr.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda_hop_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index fcf92c5d..7de9df89 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -11,8 +11,6 @@ #pragma once -#include - #include "functor.h" namespace rtl::dispatch @@ -22,7 +20,7 @@ namespace rtl::dispatch { using functor_t = return_t(*)(signature_ts...); - constexpr functor_t f_ptr() const + [[nodiscard]] constexpr auto f_ptr() const { return m_functor; } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h similarity index 95% rename from ReflectionTemplateLib/rtl/dispatch/lambda_hop.h rename to ReflectionTemplateLib/rtl/dispatch/lambda.h index a783689a..b2cfde79 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -11,11 +11,7 @@ #pragma once -#include - #include "rtl_traits.h" -#include "rtl_typeid.h" -#include "rtl_constants.h" #include "functor.h" namespace rtl::dispatch @@ -52,7 +48,7 @@ namespace rtl::dispatch } template - const method_t* to_method() const + constexpr const method_t* to_method() const { std::size_t recordId = detail::TypeId::get(); std::size_t typeId = detail::TypeId...>>::get(); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h similarity index 69% rename from ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h rename to ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 17e2b4b4..690d6c15 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -11,7 +11,7 @@ #pragma once -#include "lambda_hop.h" +#include "lambda.h" #include "function_ptr.h" namespace rtl::dispatch @@ -23,7 +23,7 @@ namespace rtl::dispatch using fptr_t = typename function_ptr::functor_t; template - static constexpr bool is_argst_ok = std::is_same_v...>, std::tuple>; + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; template static constexpr bool noexcept_v = noexcept(std::declval>()(std::declval()...)); @@ -35,7 +35,7 @@ namespace rtl::dispatch { } template - constexpr const function_ptr& get_functor() const + [[nodiscard]] constexpr auto& get_functor() const { // Unchecked: using an incorrect argument or return type is undefined behaviour. // No validation is performed and the function will not return nullptr on mismatch. (By Design) @@ -43,17 +43,14 @@ namespace rtl::dispatch } template - constexpr decltype(auto) hop(args_t&&...params) const //noexcept(noexcept_v) + [[nodiscard]] constexpr decltype(auto) hop(args_t&&...params) const noexcept(noexcept_v) { - static_assert(is_argst_ok, "Argument types don't match signature."); - - fptr_t functor = get_functor().f_ptr(); - if constexpr (std::is_same_v) { - (*functor)(std::forward(params)...); - } - else { - return (*functor)(std::forward(params)...); - } + static_assert(is_args_t_ok, "Argument types don't match signature."); + + constexpr auto call = [](auto fp, auto&&... a) -> decltype(auto) { + return (*fp)(std::forward(a)...); + }; + return call(get_functor().f_ptr(), std::forward(params)...); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h similarity index 68% rename from ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h rename to ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 967659ff..dfd1e9a8 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_hop_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -11,7 +11,7 @@ #pragma once -#include "lambda_hop.h" +#include "lambda.h" #include "method_ptr.h" namespace rtl::dispatch @@ -23,7 +23,7 @@ namespace rtl::dispatch using fptr_t = typename method_ptr::functor_t; template - static constexpr bool is_argst_ok = std::is_same_v...>, std::tuple>; + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; template static constexpr bool noexcept_v = noexcept((std::declval().*std::declval>())(std::declval()...)); @@ -37,23 +37,20 @@ namespace rtl::dispatch // Unsafe: using an incorrect argument or return type is undefined behaviour. // Not validated here and the function will not return nullptr on mismatch. (By Design) template - constexpr const method_ptr& get_functor() const + [[nodiscard]] constexpr auto& get_functor() const { return static_cast&>(m_functor); } template - constexpr decltype(auto) hop(record_t& target, args_t&& ...params) const noexcept(noexcept_v) + [[nodiscard]] constexpr decltype(auto) hop(record_t& target, args_t&& ...params) const noexcept(noexcept_v) { - static_assert(is_argst_ok, "Argument types don't match signature."); - - fptr_t functor = get_functor().f_ptr(); - if constexpr (std::is_same_v) { - (target.*functor)(std::forward(params)...); - } - else { - return (target.*functor)(std::forward(params)...); - } + static_assert(is_args_t_ok, "Argument types don't match signature."); + + constexpr auto call = [](record_t& obj, auto fp, auto&&... a) -> decltype(auto) { + return (obj.*fp)(std::forward(a)...); + }; + return call(target, get_functor().f_ptr(), std::forward(params)...); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 12563781..60ae79fb 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -22,7 +22,7 @@ namespace rtl::dispatch { using functor_t = return_t(record_t::*)(signature_ts...); - constexpr functor_t f_ptr() const + [[nodiscard]] constexpr auto f_ptr() const { return m_functor; } diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 6310aaf4..1df345be 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -18,7 +18,7 @@ #include "FunctorId.h" #include "rtl_constants.h" #include "FunctionCaller.h" -#include "lambda_hop_function.h" +#include "lambda_function.h" namespace rtl { diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 2733d58c..a3b551b3 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -16,7 +16,7 @@ #include "RObject.h" #include "Function.h" #include "MethodInvoker.h" -#include "lambda_hop_method.h" +#include "lambda_method.h" namespace rtl { diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index e91f162c..3705c3a7 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -11,15 +11,13 @@ #pragma once -#include #include -#include #include "view.h" #include "RObjectId.h" -#include "rtl_typeid.h" #include "rtl_traits.h" +#include "rtl_errors.h" #include "forward_decls.h" namespace rtl::detail diff --git a/ReflectionTemplateLib/rtl/rtl.h b/ReflectionTemplateLib/rtl/rtl.h index 4c53df70..a21b849a 100644 --- a/ReflectionTemplateLib/rtl/rtl.h +++ b/ReflectionTemplateLib/rtl/rtl.h @@ -104,9 +104,9 @@ namespace rtl { - template - using lambda_function = dispatch::lambda_function; + template + using lambda_function = dispatch::lambda_function; - template - using lambda_method = dispatch::lambda_method; + template + using lambda_method = dispatch::lambda_method; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_constants.h b/ReflectionTemplateLib/rtl/rtl_constants.h index 99af7fb8..aeb28150 100644 --- a/ReflectionTemplateLib/rtl/rtl_constants.h +++ b/ReflectionTemplateLib/rtl/rtl_constants.h @@ -11,8 +11,6 @@ #pragma once -#include "rtl_errors.h" - namespace rtl { // Allocation policy for rtl::RObject. @@ -144,12 +142,6 @@ namespace rtl::detail return (std::string(pRecordName) + "::" + std::string(pRecordName) + "()"); } - -#define GETTER_(_varType, _name, _var) \ - inline constexpr const _varType& _name() const { \ - return _var; \ - } - #define GETTER(_varType, _name, _var) \ inline constexpr const _varType& get##_name() const { \ return _var; \ @@ -161,11 +153,6 @@ namespace rtl::detail } -#define GETTER_CPTR_(_varType, _name, _var) \ - constexpr inline const _varType* _name() const { \ - return _var; \ - } - #define GETTER_CPTR(_varType, _name, _var) \ constexpr inline const _varType* get##_name() const { \ return _var; \ diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index d2ccb404..84f4d631 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -12,8 +12,6 @@ #pragma once #include -#include -#include #include #include #include diff --git a/ReflectionTemplateLib/rtl/rtl_typeid.h b/ReflectionTemplateLib/rtl/rtl_typeid.h index 2e170f01..e898b588 100644 --- a/ReflectionTemplateLib/rtl/rtl_typeid.h +++ b/ReflectionTemplateLib/rtl/rtl_typeid.h @@ -14,7 +14,6 @@ #include #include #include -#include namespace rtl { diff --git a/ReflectionTemplateLib/rtl/src/CxxMirror.cpp b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp index 9054699d..e75c71f4 100644 --- a/ReflectionTemplateLib/rtl/src/CxxMirror.cpp +++ b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp @@ -11,7 +11,6 @@ #include "RObject.h" #include "CxxMirror.h" -#include "ReflectCast.h" namespace rtl { From e72d37a725b0943dfe8f156b4ad774e5c922e828 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 22 Sep 2025 14:03:25 +0530 Subject: [PATCH 024/148] removed temporary affecting stats, from benchmark. --- RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp | 12 ++++-------- ReflectionTemplateLib/rtl/dispatch/lambda_function.h | 6 +++--- ReflectionTemplateLib/rtl/dispatch/lambda_method.h | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 1f074814..9247b0a4 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -167,8 +167,7 @@ void MethodFnPointerCall::get(benchmark::State& state) { if (functor) { - auto ret = (nodeObj.*functor)(bm::g_longStr); - benchmark::DoNotOptimize(ret); + benchmark::DoNotOptimize((nodeObj.*functor)(bm::g_longStr)); } } } @@ -192,8 +191,7 @@ void FunctionPointerCall::get(benchmark::State& state) { if (functor) { - auto ret = (*functor)(bm::g_longStr); - benchmark::DoNotOptimize(ret); + benchmark::DoNotOptimize((*functor)(bm::g_longStr)); } } } @@ -220,8 +218,7 @@ void RtlReflectedCall::get(benchmark::State& state) { if (passed) { - auto retStr = getMessage_lambda.hop(bm::g_longStr); - benchmark::DoNotOptimize(retStr); + benchmark::DoNotOptimize(getMessage_lambda.hop(bm::g_longStr)); } } } @@ -272,8 +269,7 @@ void RtlReflectedMethodCall::get(benchmark::State& state) { if (functor) { - auto retStr = getMessageOnNode_lambda.hop(nodeObj, bm::g_longStr); - benchmark::DoNotOptimize(retStr); + benchmark::DoNotOptimize(getMessageOnNode_lambda.hop(nodeObj, bm::g_longStr)); } } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 690d6c15..86bc612a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -46,11 +46,11 @@ namespace rtl::dispatch [[nodiscard]] constexpr decltype(auto) hop(args_t&&...params) const noexcept(noexcept_v) { static_assert(is_args_t_ok, "Argument types don't match signature."); - - constexpr auto call = [](auto fp, auto&&... a) -> decltype(auto) { + + constexpr auto hopper = [](auto fp, auto&&... a) -> decltype(auto) { return (*fp)(std::forward(a)...); }; - return call(get_functor().f_ptr(), std::forward(params)...); + return hopper(get_functor().f_ptr(), std::forward(params)...); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index dfd1e9a8..1d7fd42c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -47,10 +47,10 @@ namespace rtl::dispatch { static_assert(is_args_t_ok, "Argument types don't match signature."); - constexpr auto call = [](record_t& obj, auto fp, auto&&... a) -> decltype(auto) { + constexpr auto hopper = [](record_t& obj, auto fp, auto&&... a) -> decltype(auto) { return (obj.*fp)(std::forward(a)...); }; - return call(target, get_functor().f_ptr(), std::forward(params)...); + return hopper(target, get_functor().f_ptr(), std::forward(params)...); } }; } \ No newline at end of file From 7780b027ad8ac5253de53ffac7ab39e482754d7e Mon Sep 17 00:00:00 2001 From: neeraj Date: Mon, 22 Sep 2025 18:15:55 +0530 Subject: [PATCH 025/148] added type-safe access, code refined. --- .../src/ReflectedCallKnownReturn.cpp | 265 +++++++----------- .../src/ReflectedCallUnknownReturn.cpp | 14 +- RTLBenchmarkApp/src/StandardCall.cpp | 2 - RTLBenchmarkApp/src/main.cpp | 17 +- .../rtl/builder/SetupFunction.hpp | 5 +- .../rtl/builder/SetupMethod.hpp | 6 +- .../rtl/detail/inc/FunctorId.h | 19 ++ .../rtl/detail/inc/forward_decls.h | 3 + ReflectionTemplateLib/rtl/dispatch/lambda.h | 11 +- .../rtl/dispatch/lambda_method.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 5 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 5 +- 12 files changed, 147 insertions(+), 207 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 9247b0a4..225fe6cc 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -1,6 +1,6 @@ -#include #include +#include #include "BenchMark.h" #include "ReflectedCallKnownReturn.h" @@ -20,256 +20,183 @@ namespace { static const rtl::lambda_function& getMessage_lambda = []() { - // No validation is performed internally and lambda - // will not return nullptr on signature mismatch. (by design) - return *(cxx::mirror().getFunction("getMessage")->get_lambda()); + auto lambda_ptr = cxx::mirror().getFunction("getMessage")->get_lambda(); + if(!lambda_ptr) { + std::cerr << "[0] error: return-type mismatch.\n"; + std::abort(); + } + return *lambda_ptr; }(); static const rtl::lambda_function& sendMessage_lambda = []() { - // No validation is performed internally and lambda - // will not return nullptr on signature mismatch. (by design) - return *(cxx::mirror().getFunction("sendMessage")->get_lambda()); + auto lambda_ptr = cxx::mirror().getFunction("sendMessage")->get_lambda(); + if(!lambda_ptr) { + std::cerr << "[1] error: return-type mismatch.\n"; + std::abort(); + } + return *lambda_ptr; + }(); static const rtl::lambda_method& getMessageOnNode_lambda = []() { - // No validation is performed internally and lambda - // will not return nullptr on signature mismatch. (by design) - return *(cxx::mirror().getRecord("Node")->getMethod("getMessage")->get_lambda()); + auto lambda_ptr = cxx::mirror().getRecord("Node")->getMethod("getMessage")->get_lambda(); + if(!lambda_ptr) { + std::cerr << "[2] error: return-type mismatch.\n"; + std::abort(); + } + return *lambda_ptr; }(); static const rtl::lambda_method& sendMessageOnNode_lambda = []() { - rtl::Record Node = cxx::mirror().getRecord("Node").value(); - // No validation is performed internally and lambda - // will not return nullptr on signature mismatch. (by design) - return *(cxx::mirror().getRecord("Node")->getMethod("sendMessage")->get_lambda()); + auto lambda_ptr = cxx::mirror().getRecord("Node")->getMethod("sendMessage")->get_lambda(); + if(!lambda_ptr) { + std::cerr << "[3] error: return-type mismatch.\n"; + std::abort(); + } + return *lambda_ptr; }(); } namespace { - static auto _test0 = []() + static auto functor_set = [](int n) { - if(!sendMessage_lambda.is_signature() || - !sendMessage_lambda.is_returning()) - { - std::cout << "[0] error: signature mismatch.\n"; - return false; + if(!sendMessage_lambda.is_returning()) { + std::cerr << "[0"<< n <<"] error: return-type mismatch.\n"; + std::abort(); } - return true; + // 'get_functor': No validation is performed internally and this function + // will not return nullptr on return_t mismatch. (by design). + return sendMessage_lambda.get_functor().f_ptr(); }; - static auto _test1 = []() + static auto method_set = [](int n) { - if(!sendMessageOnNode_lambda.is_signature() || - !sendMessageOnNode_lambda.is_returning()) - { - std::cout << "[1] error: signature mismatch.\n"; - return false; - } - return true; + if(!sendMessageOnNode_lambda.is_returning()) { + std::cerr << "[1"<< n <<"] error: return-type mismatch.\n"; + std::abort(); + } + // 'get_functor': No validation is performed internally and this function + // will not return nullptr on return_t mismatch. (by design). + return sendMessageOnNode_lambda.get_functor().f_ptr(); }; - static auto _test2 = []() + static auto functor_get = [](int n) { - if (!getMessage_lambda.is_signature() || - !getMessage_lambda.is_returning()) - { - std::cout << "[2] error: signature mismatch.\n"; - return false; + if (!getMessage_lambda.is_returning()) { + std::cerr << "[2"<< n <<"] error: return-type mismatch.\n"; + std::abort(); } - return true; + // 'get_functor': No validation is performed internally and this function + // will not return nullptr on return_t mismatch. (by design). + return getMessage_lambda.get_functor().f_ptr(); }; - static auto _test3 = []() + static auto method_get = [](int n) { - if (!getMessageOnNode_lambda.is_signature() || - !getMessageOnNode_lambda.is_returning()) + if (!getMessageOnNode_lambda.is_returning()) { - std::cout << "[3] error: signature mismatch.\n"; - return false; + std::cerr << "[3"<< n <<"] error: return-type mismatch.\n"; + std::abort(); } - return true; + // 'get_functor': No validation is performed internally and this function + // will not return nullptr on return_t mismatch. (by design). + return getMessageOnNode_lambda.get_functor().f_ptr(); }; -} - -void FunctionPointerCall::set(benchmark::State& state) -{ - static auto* functor = []() -> void(*)(bm::argStr_t) - { - // Must be checked: Passing an incorrect argument or return type is undefined behaviour. - if (sendMessage_lambda.is_returning() && sendMessage_lambda.is_signature()) - { - // No validation is performed internally and the function will not return nullptr on mismatch. - return sendMessage_lambda.get_functor().f_ptr(); - } - std::cout << "[4] error: signature mismatch.\n"; - return nullptr; - }(); - - for (auto _ : state) - { - if (functor) - { - (*functor)(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); - } - } + static auto _new_line = []() { + std::cout << std::endl; + return 0; + }; } -void MethodFnPointerCall::set(benchmark::State& state) -{ - static bm::Node nodeObj; - static auto functor = []() -> void(bm::Node::*)(bm::argStr_t) - { - // Must be checked: Passing an incorrect argument or return type is undefined behaviour. - if (sendMessageOnNode_lambda.is_returning() && sendMessageOnNode_lambda.is_signature()) - { - // No validation is performed internally and the function will not return nullptr on mismatch. - return sendMessageOnNode_lambda.get_functor().f_ptr(); - } - std::cout << "[8] error: signature mismatch.\n"; - return nullptr; - }(); +void FunctionPointerCall::get(benchmark::State& state) +{ + static auto functor = functor_get(0); for (auto _ : state) { - if (functor) - { - (nodeObj.*functor)(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); - } + benchmark::DoNotOptimize((*functor)(bm::g_longStr)); } } - void MethodFnPointerCall::get(benchmark::State& state) { static bm::Node nodeObj; - static auto functor = []() -> bm::retStr_t(bm::Node::*)(bm::argStr_t) - { - // Must be checked: Passing an incorrect argument or return type is undefined behaviour. - if (getMessageOnNode_lambda.is_returning() && getMessageOnNode_lambda.is_signature()) - { - // No validation is performed internally and the function will not return nullptr on mismatch. - return getMessageOnNode_lambda.get_functor().f_ptr(); - } - std::cout << "[9] error: signature mismatch.\n"; - return nullptr; - }(); - + static auto functor = method_get(0); for (auto _ : state) { - if (functor) - { - benchmark::DoNotOptimize((nodeObj.*functor)(bm::g_longStr)); - } + benchmark::DoNotOptimize((nodeObj.*functor)(bm::g_longStr)); } } - -void FunctionPointerCall::get(benchmark::State& state) +void FunctionPointerCall::set(benchmark::State& state) { - static auto* functor = []() -> bm::retStr_t(*)(bm::argStr_t) - { - // Must be checked: Passing an incorrect argument or return type is undefined behaviour. - if (getMessage_lambda.is_returning() && getMessage_lambda.is_signature()) - { - // No validation is performed internally and the function will not return nullptr on mismatch. - return getMessage_lambda.get_functor().f_ptr(); - } - std::cout << "[5] error: signature mismatch.\n"; - return nullptr; - }(); - + static auto _ = functor_set(0); + static auto functor = sendMessage_lambda.get_functor().f_ptr(); for (auto _ : state) { - if (functor) - { - benchmark::DoNotOptimize((*functor)(bm::g_longStr)); - } + (*functor)(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } - -void RtlReflectedCall::set(benchmark::State& state) +void MethodFnPointerCall::set(benchmark::State& state) { - static auto passed = _test0(); + static bm::Node nodeObj; + static auto functor = method_set(0); for (auto _ : state) { - if (passed) - { - sendMessage_lambda.hop(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); - } + (nodeObj.*functor)(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } + void RtlReflectedCall::get(benchmark::State& state) { - static auto passed = _test2(); + static auto _=_new_line(); + static auto _test = functor_get(1); for (auto _: state) { - if (passed) - { - benchmark::DoNotOptimize(getMessage_lambda.hop(bm::g_longStr)); - } + benchmark::DoNotOptimize(getMessage_lambda.hop(bm::g_longStr)); } } - -void RtlReflectedMethodCall::set(benchmark::State& state) +void RtlReflectedMethodCall::get(benchmark::State& state) { static bm::Node nodeObj; - static auto functor = []() -> void(bm::Node::*)(bm::argStr_t) - { - // Must be checked: Passing an incorrect argument or return type is undefined behaviour. - if (sendMessageOnNode_lambda.is_returning() && sendMessageOnNode_lambda.is_signature()) - { - // No validation is performed internally and the function will not return nullptr on mismatch. - return sendMessageOnNode_lambda.get_functor().f_ptr(); - } - std::cout << "[6] error: signature mismatch.\n"; - return nullptr; - }(); - + static auto _test = method_get(1); for (auto _ : state) { - if (functor) - { - sendMessageOnNode_lambda.hop(nodeObj, bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); - } + benchmark::DoNotOptimize(getMessageOnNode_lambda.hop(nodeObj, bm::g_longStr)); } } +void RtlReflectedCall::set(benchmark::State& state) +{ + static auto _=_new_line(); + static auto _test = functor_set(1); + for (auto _ : state) + { + sendMessage_lambda.hop(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } +} -void RtlReflectedMethodCall::get(benchmark::State& state) +void RtlReflectedMethodCall::set(benchmark::State& state) { static bm::Node nodeObj; - static auto functor = []() -> bm::retStr_t(bm::Node::*)(bm::argStr_t) - { - // Must be checked: Passing an incorrect argument or return type is undefined behaviour. - if (getMessageOnNode_lambda.is_returning() && getMessageOnNode_lambda.is_signature()) - { - // No validation is performed internally and the function will not return nullptr on mismatch. - return getMessageOnNode_lambda.get_functor().f_ptr(); - } - std::cout << "[7] error: signature mismatch.\n"; - return nullptr; - }(); - + static auto _test = method_set(1); for (auto _ : state) { - if (functor) - { - benchmark::DoNotOptimize(getMessageOnNode_lambda.hop(nodeObj, bm::g_longStr)); - } + sendMessageOnNode_lambda.hop(nodeObj, bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index db9b2ee9..a73adb8e 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -36,7 +36,7 @@ namespace { auto [err, robj] = cxx::mirror().getRecord("Node")->create(); if (robj.isEmpty()) { - std::cout << "[_] error: " << rtl::to_string(err) << "\n"; + std::cout << "[x] error: " << rtl::to_string(err) << "\n"; } return std::move(robj); }(); @@ -89,8 +89,7 @@ void RtlReflectedCall_retUnknown::set(benchmark::State& state) static auto _ = _test0(); for (auto _ : state) { - auto error = SendMessage(bm::g_longStr).err; - benchmark::DoNotOptimize(error); + benchmark::DoNotOptimize(SendMessage(bm::g_longStr)); } } @@ -100,8 +99,7 @@ void RtlReflectedCall_retUnknown::get(benchmark::State& state) static auto _ = _test2(); for (auto _ : state) { - auto error = GetMessage(bm::g_longStr).err; - benchmark::DoNotOptimize(error); + benchmark::DoNotOptimize(GetMessage(bm::g_longStr)); } } @@ -111,8 +109,7 @@ void RtlReflectionMethodCall_retUnknown::set(benchmark::State& state) static auto _ = _test1(); for (auto _ : state) { - auto error = NodeSendMessage(nodeObj)(bm::g_longStr).err; - benchmark::DoNotOptimize(error); + benchmark::DoNotOptimize(NodeSendMessage(nodeObj)(bm::g_longStr)); } } @@ -122,7 +119,6 @@ void RtlReflectionMethodCall_retUnknown::get(benchmark::State& state) static auto _ = _test3(); for (auto _ : state) { - auto error = NodeGetMessage(nodeObj)(bm::g_longStr).err; - benchmark::DoNotOptimize(error); + benchmark::DoNotOptimize(NodeGetMessage(nodeObj)(bm::g_longStr)); } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 53294634..c8dad681 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -73,7 +73,6 @@ void StdFunctionCall::set(benchmark::State& state) void StdFunctionMethodCall::set(benchmark::State& state) { static bm::Node nodeObj; - static auto _=_new_line(); for (auto _: state) { bm::NodeSendMessage(nodeObj, bm::g_longStr); @@ -95,7 +94,6 @@ void StdFunctionCall::get(benchmark::State& state) void StdFunctionMethodCall::get(benchmark::State& state) { static bm::Node nodeObj; - static auto _=_new_line(); for (auto _: state) { benchmark::DoNotOptimize(bm::NodeGetMessage(nodeObj, bm::g_longStr)); diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index b9a7d869..eae49a1f 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -10,29 +10,24 @@ BENCHMARK(NativeCall::set); BENCHMARK(FunctionPointerCall::set); BENCHMARK(MethodFnPointerCall::set); -//BENCHMARK(ReflectedCallKnownReturn::set); -//BENCHMARK(ReflectedCallKnownReturn::set); - BENCHMARK(StdFunctionCall::set); -BENCHMARK(RtlReflectedCall::set); -BENCHMARK(RtlReflectedCall_retUnknown::set); - BENCHMARK(StdFunctionMethodCall::set); + +BENCHMARK(RtlReflectedCall::set); BENCHMARK(RtlReflectedMethodCall::set); +BENCHMARK(RtlReflectedCall_retUnknown::set); BENCHMARK(RtlReflectionMethodCall_retUnknown::set); BENCHMARK(NativeCall::get); BENCHMARK(FunctionPointerCall::get); BENCHMARK(MethodFnPointerCall::get); -//BENCHMARK(ReflectedMethodCallKnownReturn::get); BENCHMARK(StdFunctionCall::get); -BENCHMARK(RtlReflectedCall::get); -BENCHMARK(RtlReflectedCall_retUnknown::get); -//BENCHMARK(ReflectedMethodCallKnownReturn::get); - BENCHMARK(StdFunctionMethodCall::get); + +BENCHMARK(RtlReflectedCall::get); BENCHMARK(RtlReflectedMethodCall::get); +BENCHMARK(RtlReflectedCall_retUnknown::get); BENCHMARK(RtlReflectionMethodCall_retUnknown::get); namespace bm diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 080ea460..d609cb83 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -30,7 +30,7 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - bool isFunctorGood = (pFunctor == pFunctorId.m_lambda->to_function<_signature...>()->template get_functor().f_ptr()); + bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_function<_signature...>()->template get_functor().f_ptr()); assert(isFunctorGood && "new type-id-system not working."); pFunctor(std::forward<_signature>(params)...); @@ -48,7 +48,8 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { - bool isFunctorGood = (pFunctor == pFunctorId.m_lambda->to_function<_signature...>()->template get_functor<_returnType>().f_ptr()); + bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_function<_signature...>()->template get_functor<_returnType>().f_ptr()); + assert(isFunctorGood && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 1bf64725..ac4f83ca 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -34,7 +34,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isFunctorGood = (pFunctor == pFunctorId.m_lambda->to_method<_recordType, _signature...>()->template get_functor().f_ptr()); + bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor().f_ptr()); + assert(isFunctorGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { @@ -57,7 +58,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isFunctorGood = (pFunctor == pFunctorId.m_lambda->to_method<_recordType, _signature...>()->template get_functor<_returnType>().f_ptr()); + bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor<_returnType>().f_ptr()); + assert(isFunctorGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 23fcd69f..a3de2455 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -15,6 +15,7 @@ #include "rtl_constants.h" #include "forward_decls.h" #include "lambda_method.h" +#include "lambda_function.h" namespace rtl::detail @@ -78,5 +79,23 @@ namespace rtl::detail m_lambdaIndex == pOther.m_lambdaIndex && m_signature == pOther.m_signature); } + + template + const dispatch::lambda_function<_signature...>* get_lambda_function() const + { + if(m_lambda->is_signature<_signature...>()) { + return m_lambda->to_function<_signature...>(); + } + return nullptr; + } + + template + const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method() const + { + if(m_lambda->is_member<_recordType>() && m_lambda->is_signature<_signature...>()) { + return m_lambda->to_method<_recordType, _signature...>(); + } + return nullptr; + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 63456bd0..9d7b956a 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -31,6 +31,9 @@ namespace rtl template class FunctorContainer; + + template + class SetupMethod; } namespace cache diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index b2cfde79..7661a1cd 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -31,11 +31,7 @@ namespace rtl::dispatch template using method_t = lambda_method; - - public: - - GETTER_CREF(functor, _functor, m_functor); - + template constexpr const function_t* to_function() const { @@ -59,6 +55,9 @@ namespace rtl::dispatch return nullptr; } + public: + + GETTER_CREF(functor, _functor, m_functor); template constexpr bool is_returning() const @@ -78,5 +77,7 @@ namespace rtl::dispatch return (m_functor.m_recordId == detail::TypeId>::get() || m_functor.m_recordId == detail::TypeId>::get()); } + + friend detail::FunctorId; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 1d7fd42c..2aee249a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -34,7 +34,7 @@ namespace rtl::dispatch :lambda(fptr) { } - // Unsafe: using an incorrect argument or return type is undefined behaviour. + // Unsafe: using an incorrect return type is undefined behaviour. // Not validated here and the function will not return nullptr on mismatch. (By Design) template [[nodiscard]] constexpr auto& get_functor() const diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 56eea735..76fdb9a4 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -25,9 +25,8 @@ namespace rtl template const dispatch::lambda_function<_signature...>* Function::get_lambda(std::size_t pOverloadIndex) const { - if (pOverloadIndex < m_functorIds.size()) - { - return m_functorIds[pOverloadIndex].m_lambda->to_function<_signature...>(); + if (pOverloadIndex < m_functorIds.size()) { + return m_functorIds[pOverloadIndex].get_lambda_function<_signature...>(); } return nullptr; } diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 57bdbab5..431154d8 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -33,9 +33,8 @@ namespace rtl const dispatch::lambda_method<_recordType, _signature...>* Method::get_lambda(std::size_t pOverloadIndex) const { auto& functorIds = getFunctors(); - if (pOverloadIndex < functorIds.size()) - { - return functorIds[pOverloadIndex].m_lambda->to_method<_recordType, _signature...>(); + if (pOverloadIndex < functorIds.size()) { + return functorIds[pOverloadIndex].get_lambda_method<_recordType, _signature...>(); } return nullptr; } From 7bdc319ae7ba4990cb310389f7a57172c5827bbd Mon Sep 17 00:00:00 2001 From: neeraj Date: Mon, 22 Sep 2025 22:07:39 +0530 Subject: [PATCH 026/148] minor refactor. --- .../src/ReflectedCallKnownReturn.cpp | 18 +++++---- .../src/ReflectedCallKnownReturn.h | 20 +++++----- .../src/ReflectedCallUnknownReturn.cpp | 15 +++++-- .../src/ReflectedCallUnknownReturn.h | 12 +++--- RTLBenchmarkApp/src/StandardCall.cpp | 12 +++--- RTLBenchmarkApp/src/StandardCall.h | 12 +++--- RTLBenchmarkApp/src/main.cpp | 40 ++++++++++--------- .../rtl/builder/SetupFunction.hpp | 9 ++--- .../rtl/builder/SetupMethod.hpp | 18 ++++----- .../rtl/dispatch/lambda_function.h | 4 +- .../rtl/dispatch/lambda_method.h | 2 +- 11 files changed, 86 insertions(+), 76 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 225fe6cc..f5caeaaf 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -116,8 +116,9 @@ namespace -void FunctionPointerCall::get(benchmark::State& state) +void FunctionPointerCall::returnTypeNonVoid(benchmark::State& state) { + static auto _=_new_line(); static auto functor = functor_get(0); for (auto _ : state) { @@ -125,7 +126,7 @@ void FunctionPointerCall::get(benchmark::State& state) } } -void MethodFnPointerCall::get(benchmark::State& state) +void MethodFnPointerCall::returnTypeNonVoid(benchmark::State& state) { static bm::Node nodeObj; static auto functor = method_get(0); @@ -135,8 +136,9 @@ void MethodFnPointerCall::get(benchmark::State& state) } } -void FunctionPointerCall::set(benchmark::State& state) +void FunctionPointerCall::returnTypeVoid(benchmark::State& state) { + static auto __=_new_line(); static auto _ = functor_set(0); static auto functor = sendMessage_lambda.get_functor().f_ptr(); for (auto _ : state) @@ -146,7 +148,7 @@ void FunctionPointerCall::set(benchmark::State& state) } } -void MethodFnPointerCall::set(benchmark::State& state) +void MethodFnPointerCall::returnTypeVoid(benchmark::State& state) { static bm::Node nodeObj; static auto functor = method_set(0); @@ -159,7 +161,7 @@ void MethodFnPointerCall::set(benchmark::State& state) -void RtlReflectedCall::get(benchmark::State& state) +void ReflectedCallKnownReturn::typeNonVoid(benchmark::State& state) { static auto _=_new_line(); static auto _test = functor_get(1); @@ -169,7 +171,7 @@ void RtlReflectedCall::get(benchmark::State& state) } } -void RtlReflectedMethodCall::get(benchmark::State& state) +void ReflectedMethodCallKnownReturn::typeNonVoid(benchmark::State& state) { static bm::Node nodeObj; static auto _test = method_get(1); @@ -179,7 +181,7 @@ void RtlReflectedMethodCall::get(benchmark::State& state) } } -void RtlReflectedCall::set(benchmark::State& state) +void ReflectedCallKnownReturn::typeVoid(benchmark::State& state) { static auto _=_new_line(); static auto _test = functor_set(1); @@ -190,7 +192,7 @@ void RtlReflectedCall::set(benchmark::State& state) } } -void RtlReflectedMethodCall::set(benchmark::State& state) +void ReflectedMethodCallKnownReturn::typeVoid(benchmark::State& state) { static bm::Node nodeObj; static auto _test = method_set(1); diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index e1f9c47a..a6a5a61d 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -2,33 +2,33 @@ #include -struct RtlReflectedCall +struct ReflectedCallKnownReturn { - static void set(benchmark::State& state); + static void typeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void typeNonVoid(benchmark::State& state); }; struct FunctionPointerCall { - static void set(benchmark::State& state); + static void returnTypeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void returnTypeNonVoid(benchmark::State& state); }; struct MethodFnPointerCall { - static void set(benchmark::State& state); + static void returnTypeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void returnTypeNonVoid(benchmark::State& state); }; -struct RtlReflectedMethodCall +struct ReflectedMethodCallKnownReturn { - static void set(benchmark::State& state); + static void typeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void typeNonVoid(benchmark::State& state); }; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index a73adb8e..ba82d409 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -80,12 +80,18 @@ namespace } return 0; }; + + static auto _new_line = []() { + std::cout << std::endl; + return 0; + }; } -void RtlReflectedCall_retUnknown::set(benchmark::State& state) +void ReflectedCallUnknownReturn::typeVoid(benchmark::State& state) { + static auto __=_new_line(); static auto _ = _test0(); for (auto _ : state) { @@ -94,8 +100,9 @@ void RtlReflectedCall_retUnknown::set(benchmark::State& state) } -void RtlReflectedCall_retUnknown::get(benchmark::State& state) +void ReflectedCallUnknownReturn::typeNonVoid(benchmark::State& state) { + static auto __=_new_line(); static auto _ = _test2(); for (auto _ : state) { @@ -104,7 +111,7 @@ void RtlReflectedCall_retUnknown::get(benchmark::State& state) } -void RtlReflectionMethodCall_retUnknown::set(benchmark::State& state) +void ReflectedMethodCallUnknownReturn::typeVoid(benchmark::State& state) { static auto _ = _test1(); for (auto _ : state) @@ -114,7 +121,7 @@ void RtlReflectionMethodCall_retUnknown::set(benchmark::State& state) } -void RtlReflectionMethodCall_retUnknown::get(benchmark::State& state) +void ReflectedMethodCallUnknownReturn::typeNonVoid(benchmark::State& state) { static auto _ = _test3(); for (auto _ : state) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index c2890430..9ceec026 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -2,17 +2,17 @@ #include -struct RtlReflectedCall_retUnknown +struct ReflectedCallUnknownReturn { - static void set(benchmark::State& state); + static void typeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void typeNonVoid(benchmark::State& state); }; -struct RtlReflectionMethodCall_retUnknown +struct ReflectedMethodCallUnknownReturn { - static void set(benchmark::State& state); + static void typeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void typeNonVoid(benchmark::State& state); }; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index c8dad681..53e14830 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -39,7 +39,7 @@ namespace bm } -void NativeCall::set(benchmark::State& state) +void NativeCall::returnTypeVoid(benchmark::State& state) { for (auto _: state) { @@ -49,7 +49,7 @@ void NativeCall::set(benchmark::State& state) } -void NativeCall::get(benchmark::State& state) +void NativeCall::returnTypeNonVoid(benchmark::State& state) { static auto _=_put_line(); for (auto _: state) @@ -59,7 +59,7 @@ void NativeCall::get(benchmark::State& state) } -void StdFunctionCall::set(benchmark::State& state) +void StdFunctionCall::returnTypeVoid(benchmark::State& state) { static auto _=_new_line(); for (auto _: state) @@ -70,7 +70,7 @@ void StdFunctionCall::set(benchmark::State& state) } -void StdFunctionMethodCall::set(benchmark::State& state) +void StdFunctionMethodCall::returnTypeVoid(benchmark::State& state) { static bm::Node nodeObj; for (auto _: state) @@ -81,7 +81,7 @@ void StdFunctionMethodCall::set(benchmark::State& state) } -void StdFunctionCall::get(benchmark::State& state) +void StdFunctionCall::returnTypeNonVoid(benchmark::State& state) { static auto _=_new_line(); for (auto _: state) @@ -91,7 +91,7 @@ void StdFunctionCall::get(benchmark::State& state) } -void StdFunctionMethodCall::get(benchmark::State& state) +void StdFunctionMethodCall::returnTypeNonVoid(benchmark::State& state) { static bm::Node nodeObj; for (auto _: state) diff --git a/RTLBenchmarkApp/src/StandardCall.h b/RTLBenchmarkApp/src/StandardCall.h index 76bd70f2..e6ca7b00 100644 --- a/RTLBenchmarkApp/src/StandardCall.h +++ b/RTLBenchmarkApp/src/StandardCall.h @@ -4,23 +4,23 @@ struct NativeCall { - static void set(benchmark::State& state); + static void returnTypeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void returnTypeNonVoid(benchmark::State& state); }; struct StdFunctionCall { - static void set(benchmark::State& state); + static void returnTypeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void returnTypeNonVoid(benchmark::State& state); }; struct StdFunctionMethodCall { - static void set(benchmark::State& state); + static void returnTypeVoid(benchmark::State& state); - static void get(benchmark::State& state); + static void returnTypeNonVoid(benchmark::State& state); }; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index eae49a1f..44119ff6 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -6,29 +6,33 @@ #include "ReflectedCallKnownReturn.h" #include "ReflectedCallUnknownReturn.h" -BENCHMARK(NativeCall::set); -BENCHMARK(FunctionPointerCall::set); -BENCHMARK(MethodFnPointerCall::set); +BENCHMARK(NativeCall::returnTypeVoid); -BENCHMARK(StdFunctionCall::set); -BENCHMARK(StdFunctionMethodCall::set); +BENCHMARK(FunctionPointerCall::returnTypeVoid); +BENCHMARK(MethodFnPointerCall::returnTypeVoid); -BENCHMARK(RtlReflectedCall::set); -BENCHMARK(RtlReflectedMethodCall::set); -BENCHMARK(RtlReflectedCall_retUnknown::set); -BENCHMARK(RtlReflectionMethodCall_retUnknown::set); +BENCHMARK(StdFunctionCall::returnTypeVoid); +BENCHMARK(StdFunctionMethodCall::returnTypeVoid); -BENCHMARK(NativeCall::get); -BENCHMARK(FunctionPointerCall::get); -BENCHMARK(MethodFnPointerCall::get); +BENCHMARK(ReflectedCallKnownReturn::typeVoid); +BENCHMARK(ReflectedMethodCallKnownReturn::typeVoid); -BENCHMARK(StdFunctionCall::get); -BENCHMARK(StdFunctionMethodCall::get); +BENCHMARK(ReflectedCallUnknownReturn::typeVoid); +BENCHMARK(ReflectedMethodCallUnknownReturn::typeVoid); -BENCHMARK(RtlReflectedCall::get); -BENCHMARK(RtlReflectedMethodCall::get); -BENCHMARK(RtlReflectedCall_retUnknown::get); -BENCHMARK(RtlReflectionMethodCall_retUnknown::get); +BENCHMARK(NativeCall::returnTypeNonVoid); + +BENCHMARK(FunctionPointerCall::returnTypeNonVoid); +BENCHMARK(MethodFnPointerCall::returnTypeNonVoid); + +BENCHMARK(StdFunctionCall::returnTypeNonVoid); +BENCHMARK(StdFunctionMethodCall::returnTypeNonVoid); + +BENCHMARK(ReflectedCallKnownReturn::typeNonVoid); +BENCHMARK(ReflectedMethodCallKnownReturn::typeNonVoid); + +BENCHMARK(ReflectedCallUnknownReturn::typeNonVoid); +BENCHMARK(ReflectedMethodCallUnknownReturn::typeNonVoid); namespace bm { diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index d609cb83..1677e692 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -30,8 +30,8 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_function<_signature...>()->template get_functor().f_ptr()); - assert(isFunctorGood && "new type-id-system not working."); + // bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_function<_signature...>()->template get_functor().f_ptr()); + // assert(isFunctorGood && "new type-id-system not working."); pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -48,9 +48,8 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { - bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_function<_signature...>()->template get_functor<_returnType>().f_ptr()); - - assert(isFunctorGood && "new type-id-system not working."); + // bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_function<_signature...>()->template get_functor<_returnType>().f_ptr()); + // assert(isFunctorGood && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index ac4f83ca..0fdead0c 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -34,9 +34,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor().f_ptr()); - - assert(isFunctorGood && "new type-id-system not working."); + // bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor().f_ptr()); + // assert(isFunctorGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -58,9 +57,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor<_returnType>().f_ptr()); - - assert(isFunctorGood && "new type-id-system not working."); + // bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor<_returnType>().f_ptr()); + // assert(isFunctorGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -103,8 +101,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isLambdaGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->get_functor().get_lambda()); - assert(isLambdaGood && "new type-id-system not working."); + // bool isLambdaGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->get_functor().get_lambda()); + // assert(isLambdaGood && "new type-id-system not working."); const _recordType& target = pTargetObj.view<_recordType>()->get(); (target.*pFunctor)(std::forward<_signature>(params)...); @@ -122,8 +120,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - bool isLambdaGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->get_functor().get_lambda()); - assert(isLambdaGood && "new type-id-system not working."); + // bool isLambdaGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->get_functor().get_lambda()); + // assert(isLambdaGood && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); //'target' is const and 'pFunctor' is const-member-function. diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 86bc612a..84397b1f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -37,8 +37,8 @@ namespace rtl::dispatch template [[nodiscard]] constexpr auto& get_functor() const { - // Unchecked: using an incorrect argument or return type is undefined behaviour. - // No validation is performed and the function will not return nullptr on mismatch. (By Design) + // Unsafe: using an incorrect return type is undefined behaviour. + // Not validated here and the function will not return nullptr on mismatch. (By Design) return static_cast&>(m_functor); } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 2aee249a..bbab99b8 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -47,7 +47,7 @@ namespace rtl::dispatch { static_assert(is_args_t_ok, "Argument types don't match signature."); - constexpr auto hopper = [](record_t& obj, auto fp, auto&&... a) -> decltype(auto) { + constexpr auto hopper = [](auto& obj, auto fp, auto&&... a) -> decltype(auto) { return (obj.*fp)(std::forward(a)...); }; return hopper(target, get_functor().f_ptr(), std::forward(params)...); From a2330ba18a1d66e9efa6f12df3c25e3d0f08a7ef Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 23 Sep 2025 12:10:49 +0530 Subject: [PATCH 027/148] add safe acess api's to dispatch-interface. --- .../src/ReflectedCallKnownReturn.cpp | 141 +++++------------- .../src/ReflectedCallUnknownReturn.cpp | 56 +++++-- RTLBenchmarkApp/src/StandardCall.cpp | 2 +- .../rtl/detail/inc/FunctorId.h | 10 +- .../rtl/detail/inc/forward_decls.h | 6 +- ReflectionTemplateLib/rtl/dispatch/lambda.h | 15 +- .../rtl/dispatch/lambda_function.h | 57 ++++--- .../rtl/dispatch/lambda_method.h | 57 ++++--- ReflectionTemplateLib/rtl/inc/Function.h | 15 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 24 ++- ReflectionTemplateLib/rtl/inc/Method.h | 16 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 26 +++- ReflectionTemplateLib/rtl/rtl.h | 8 +- 13 files changed, 234 insertions(+), 199 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index f5caeaaf..704955fb 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -18,132 +18,62 @@ namespace cxx namespace { - static const rtl::lambda_function& getMessage_lambda = []() - { - auto lambda_ptr = cxx::mirror().getFunction("getMessage")->get_lambda(); - if(!lambda_ptr) { - std::cerr << "[0] error: return-type mismatch.\n"; - std::abort(); - } - return *lambda_ptr; - }(); + static const auto getMessage_functor = cxx::mirror().getFunction("getMessage")->args_t().return_t(); - static const rtl::lambda_function& sendMessage_lambda = []() - { - auto lambda_ptr = cxx::mirror().getFunction("sendMessage")->get_lambda(); - if(!lambda_ptr) { - std::cerr << "[1] error: return-type mismatch.\n"; - std::abort(); - } - return *lambda_ptr; + static const auto sendMessage_functor = cxx::mirror().getFunction("sendMessage")->args_t().return_t(); - }(); + static const auto getMessageOnNode_functor = cxx::mirror().getRecord("Node")->getMethod("getMessage")->args_t().return_t(); - static const rtl::lambda_method& getMessageOnNode_lambda = []() - { - auto lambda_ptr = cxx::mirror().getRecord("Node")->getMethod("getMessage")->get_lambda(); - if(!lambda_ptr) { - std::cerr << "[2] error: return-type mismatch.\n"; - std::abort(); - } - return *lambda_ptr; - }(); - - static const rtl::lambda_method& sendMessageOnNode_lambda = []() - { - auto lambda_ptr = cxx::mirror().getRecord("Node")->getMethod("sendMessage")->get_lambda(); - if(!lambda_ptr) { - std::cerr << "[3] error: return-type mismatch.\n"; - std::abort(); - } - return *lambda_ptr; - }(); + static const auto sendMessageOnNode_functor = cxx::mirror().getRecord("Node")->getMethod("sendMessage")->args_t().return_t(); } namespace { - static auto functor_set = [](int n) - { - if(!sendMessage_lambda.is_returning()) { - std::cerr << "[0"<< n <<"] error: return-type mismatch.\n"; - std::abort(); - } - // 'get_functor': No validation is performed internally and this function - // will not return nullptr on return_t mismatch. (by design). - return sendMessage_lambda.get_functor().f_ptr(); - }; - - static auto method_set = [](int n) - { - if(!sendMessageOnNode_lambda.is_returning()) { - std::cerr << "[1"<< n <<"] error: return-type mismatch.\n"; - std::abort(); - } - // 'get_functor': No validation is performed internally and this function - // will not return nullptr on return_t mismatch. (by design). - return sendMessageOnNode_lambda.get_functor().f_ptr(); - }; - - static auto functor_get = [](int n) - { - if (!getMessage_lambda.is_returning()) { - std::cerr << "[2"<< n <<"] error: return-type mismatch.\n"; - std::abort(); - } - // 'get_functor': No validation is performed internally and this function - // will not return nullptr on return_t mismatch. (by design). - return getMessage_lambda.get_functor().f_ptr(); + static auto _new_line = []() { + std::cout << std::endl; + return 0; }; - static auto method_get = [](int n) + template + static bool test(const T& functor, int n) { - if (!getMessageOnNode_lambda.is_returning()) - { - std::cerr << "[3"<< n <<"] error: return-type mismatch.\n"; + if (!functor.is_valid()) { + std::cerr << "[" << n << "] error: functor not valid, return-type or signature mismatch.\n"; std::abort(); } - // 'get_functor': No validation is performed internally and this function - // will not return nullptr on return_t mismatch. (by design). - return getMessageOnNode_lambda.get_functor().f_ptr(); - }; - - static auto _new_line = []() { - std::cout << std::endl; - return 0; - }; + return true; + } } - void FunctionPointerCall::returnTypeNonVoid(benchmark::State& state) { static auto _=_new_line(); - static auto functor = functor_get(0); + static auto is_ok = test(getMessage_functor, 0); for (auto _ : state) { - benchmark::DoNotOptimize((*functor)(bm::g_longStr)); + benchmark::DoNotOptimize((getMessage_functor.f_ptr())(bm::g_longStr)); } } void MethodFnPointerCall::returnTypeNonVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto functor = method_get(0); + static auto is_ok = test(getMessageOnNode_functor, 1); for (auto _ : state) { - benchmark::DoNotOptimize((nodeObj.*functor)(bm::g_longStr)); + benchmark::DoNotOptimize((nodeObj.*getMessageOnNode_functor.f_ptr())(bm::g_longStr)); } } void FunctionPointerCall::returnTypeVoid(benchmark::State& state) { - static auto __=_new_line(); - static auto _ = functor_set(0); - static auto functor = sendMessage_lambda.get_functor().f_ptr(); + static auto _ = _new_line(); + static auto is_ok = test(sendMessage_functor, 2); for (auto _ : state) { - (*functor)(bm::g_longStr); + (sendMessage_functor.f_ptr())(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -151,11 +81,14 @@ void FunctionPointerCall::returnTypeVoid(benchmark::State& state) void MethodFnPointerCall::returnTypeVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto functor = method_set(0); + static auto is_ok = test(getMessageOnNode_functor, 2); for (auto _ : state) { - (nodeObj.*functor)(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + if (sendMessageOnNode_functor.is_valid()) + { + (nodeObj.*sendMessageOnNode_functor.f_ptr())(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } } } @@ -163,31 +96,31 @@ void MethodFnPointerCall::returnTypeVoid(benchmark::State& state) void ReflectedCallKnownReturn::typeNonVoid(benchmark::State& state) { - static auto _=_new_line(); - static auto _test = functor_get(1); - for (auto _: state) + static auto _ = _new_line(); + static auto is_ok = test(getMessage_functor, 3); + for (auto _ : state) { - benchmark::DoNotOptimize(getMessage_lambda.hop(bm::g_longStr)); + benchmark::DoNotOptimize(getMessage_functor(bm::g_longStr)); } } void ReflectedMethodCallKnownReturn::typeNonVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto _test = method_get(1); + static auto is_ok = test(getMessageOnNode_functor, 4); for (auto _ : state) { - benchmark::DoNotOptimize(getMessageOnNode_lambda.hop(nodeObj, bm::g_longStr)); + benchmark::DoNotOptimize(getMessageOnNode_functor(nodeObj, bm::g_longStr)); } } void ReflectedCallKnownReturn::typeVoid(benchmark::State& state) { - static auto _=_new_line(); - static auto _test = functor_set(1); + static auto _ = _new_line(); + static auto is_ok = test(sendMessage_functor, 0); for (auto _ : state) { - sendMessage_lambda.hop(bm::g_longStr); + sendMessage_functor(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -195,10 +128,10 @@ void ReflectedCallKnownReturn::typeVoid(benchmark::State& state) void ReflectedMethodCallKnownReturn::typeVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto _test = method_set(1); + static auto is_ok = test(sendMessageOnNode_functor, 5); for (auto _ : state) { - sendMessageOnNode_lambda.hop(nodeObj, bm::g_longStr); + sendMessageOnNode_functor(nodeObj, bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index ba82d409..760b7734 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -14,27 +14,65 @@ namespace { static rtl::Function GetMessage = []() { - return *(cxx::mirror().getFunction("getMessage")); + std::optional function = cxx::mirror().getFunction("getMessage"); + if (!function) { + std::cerr << "[0] error: function 'getMessage' not found.\n"; + std::abort(); + } + return *function; }(); static rtl::Function SendMessage = []() { - return *(cxx::mirror().getFunction("sendMessage")); + std::optional function = cxx::mirror().getFunction("sendMessage"); + if (!function) { + std::cerr << "[1] error: function 'sendMessage' not found.\n"; + std::abort(); + } + return *function; }(); static rtl::Method NodeGetMessage = []() { - return *(cxx::mirror().getRecord("Node")->getMethod("getMessage")); + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } + + std::optional method = Node->getMethod("getMessage"); + if (!method) { + std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; + std::abort(); + } + return *method; }(); static rtl::Method NodeSendMessage = []() { - return *(cxx::mirror().getRecord("Node")->getMethod("sendMessage")); + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } + + std::optional method = Node->getMethod("sendMessage"); + if (!method) { + std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; + std::abort(); + } + return *method; }(); static const rtl::RObject nodeObj = []() { - auto [err, robj] = cxx::mirror().getRecord("Node")->create(); + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } + + auto [err, robj] = Node->create(); if (robj.isEmpty()) { std::cout << "[x] error: " << rtl::to_string(err) << "\n"; } @@ -49,7 +87,7 @@ namespace { auto err = SendMessage(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[0] error: " << rtl::to_string(err) << "\n"; + std::cout << "[00] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -58,7 +96,7 @@ namespace { auto err = NodeSendMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[1] error: " << rtl::to_string(err) << "\n"; + std::cout << "[01] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -67,7 +105,7 @@ namespace { auto err = GetMessage(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[2] error: " << rtl::to_string(err) << "\n"; + std::cout << "[02] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -76,7 +114,7 @@ namespace { auto err = NodeGetMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[3] error: " << rtl::to_string(err) << "\n"; + std::cout << "[03] error: " << rtl::to_string(err) << "\n"; } return 0; }; diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 53e14830..d79c3d44 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -10,7 +10,7 @@ namespace { static auto _put_line = []() { std::cout << "----------------------------------------" - "------------------------------------------" << std::endl; + "------------------------------------------------" << std::endl; return 0; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index a3de2455..bd919b1a 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -83,19 +83,13 @@ namespace rtl::detail template const dispatch::lambda_function<_signature...>* get_lambda_function() const { - if(m_lambda->is_signature<_signature...>()) { - return m_lambda->to_function<_signature...>(); - } - return nullptr; + return m_lambda->to_function<_signature...>(); } template const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method() const { - if(m_lambda->is_member<_recordType>() && m_lambda->is_signature<_signature...>()) { - return m_lambda->to_method<_recordType, _signature...>(); - } - return nullptr; + return m_lambda->to_method<_recordType, _signature...>(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index 9d7b956a..ac9e6df5 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -24,7 +24,7 @@ namespace rtl class Method; class CxxMirror; - + namespace detail { struct FunctorId; @@ -52,10 +52,10 @@ namespace rtl struct lambda; template - class lambda_function; + struct lambda_function; template - class lambda_method; + struct lambda_method; template struct function_ptr; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 7661a1cd..36a3ef0c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -35,24 +35,13 @@ namespace rtl::dispatch template constexpr const function_t* to_function() const { - const std::size_t typeId = detail::TypeId...>>::get(); - if (typeId == m_functor.m_signatureId) - { - return static_cast*>(this); - } - return nullptr; + return static_cast*>(this); } template constexpr const method_t* to_method() const { - std::size_t recordId = detail::TypeId::get(); - std::size_t typeId = detail::TypeId...>>::get(); - if (typeId == m_functor.m_signatureId && recordId == m_functor.m_recordId) - { - return static_cast*>(this); - } - return nullptr; + return static_cast*>(this); } public: diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 84397b1f..a09b9788 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -17,40 +17,53 @@ namespace rtl::dispatch { template - class lambda_function: public lambda + struct lambda_function: public lambda { template using fptr_t = typename function_ptr::functor_t; - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - - template - static constexpr bool noexcept_v = noexcept(std::declval>()(std::declval()...)); - - public: - lambda_function(const functor& fptr) noexcept :lambda(fptr) { } template - [[nodiscard]] constexpr auto& get_functor() const + struct hopper { - // Unsafe: using an incorrect return type is undefined behaviour. - // Not validated here and the function will not return nullptr on mismatch. (By Design) - return static_cast&>(m_functor); - } + constexpr auto f_ptr() const { + return m_functor; + } - template - [[nodiscard]] constexpr decltype(auto) hop(args_t&&...params) const noexcept(noexcept_v) - { - static_assert(is_args_t_ok, "Argument types don't match signature."); + constexpr auto is_valid() const { + return (m_functor != nullptr); + } + + template + [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept(noexcept_v) + { + static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + return (*m_functor)(std::forward(params)...); + } - constexpr auto hopper = [](auto fp, auto&&... a) -> decltype(auto) { - return (*fp)(std::forward(a)...); - }; - return hopper(get_functor().f_ptr(), std::forward(params)...); + const fptr_t m_functor = nullptr; + + private: + + template + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; + + template + static constexpr bool noexcept_v = noexcept(std::declval>()(std::declval()...)); + }; + + template + [[nodiscard]] constexpr const hopper get_hopper() const + { + if (m_functor.m_returnId == detail::TypeId::get()) + { + fptr_t func_ptr = (static_cast&>(m_functor)).f_ptr(); + return hopper{ func_ptr }; + } + return hopper(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index bbab99b8..241ecc31 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -17,40 +17,57 @@ namespace rtl::dispatch { template - class lambda_method : public lambda + struct lambda_method : public lambda { template using fptr_t = typename method_ptr::functor_t; - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - - template - static constexpr bool noexcept_v = noexcept((std::declval().*std::declval>())(std::declval()...)); - public: lambda_method(const functor& fptr) noexcept :lambda(fptr) { } - // Unsafe: using an incorrect return type is undefined behaviour. - // Not validated here and the function will not return nullptr on mismatch. (By Design) + template - [[nodiscard]] constexpr auto& get_functor() const + struct hopper { - return static_cast&>(m_functor); - } + constexpr auto f_ptr() const { + return m_functor; + } + + constexpr auto is_valid() const { + return (m_functor != nullptr); + } + + template + [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) + { + static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + return (target.*m_functor)(std::forward(params)...); + } - template - [[nodiscard]] constexpr decltype(auto) hop(record_t& target, args_t&& ...params) const noexcept(noexcept_v) + const fptr_t m_functor = nullptr; + + private: + + template + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; + + template + static constexpr bool noexcept_v = noexcept((std::declval().*std::declval>())(std::declval()...)); + }; + + + template + [[nodiscard]] constexpr const hopper get_hopper() const { - static_assert(is_args_t_ok, "Argument types don't match signature."); - - constexpr auto hopper = [](auto& obj, auto fp, auto&&... a) -> decltype(auto) { - return (obj.*fp)(std::forward(a)...); - }; - return hopper(target, get_functor().f_ptr(), std::forward(params)...); + if (m_functor.m_returnId == detail::TypeId::get()) + { + fptr_t func_ptr = (static_cast&>(m_functor)).f_ptr(); + return hopper{ func_ptr }; + } + return hopper(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 1df345be..ac35efe2 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -89,15 +89,24 @@ namespace rtl { Function& operator=(Function&&) = default; Function& operator=(const Function&) = default; + template + struct Hopper + { + const dispatch::lambda_function<_signature...>* m_lambda = nullptr; + + template + constexpr const dispatch::lambda_function<_signature...>::hopper<_returnType> return_t() const; + }; + + template + const Hopper<_signature...> args_t() const; + //indicates if a functor associated with it takes zero arguments. bool hasSignature() const; template bool hasSignature() const; - template - const dispatch::lambda_function<_signature...>* get_lambda(std::size_t pOverloadIndex = 0) const; - template Return operator()(_args&&...params) const noexcept; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 76fdb9a4..f07640c1 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -23,14 +23,30 @@ namespace rtl } template - const dispatch::lambda_function<_signature...>* Function::get_lambda(std::size_t pOverloadIndex) const + const Function::Hopper<_signature...> Function::args_t() const { - if (pOverloadIndex < m_functorIds.size()) { - return m_functorIds[pOverloadIndex].get_lambda_function<_signature...>(); + for (auto& functorId : m_functorIds) + { + if (functorId.m_lambda->is_signature<_signature...>()) [[likely]] { + return { functorId.get_lambda_function<_signature...>() }; + } } - return nullptr; + return Hopper<_signature...>(); } + + template + template + inline constexpr const dispatch::lambda_function<_signature...>::hopper<_returnType> + Function::Hopper<_signature...>::return_t() const + { + if (m_lambda != nullptr && m_lambda->is_returning<_returnType>()) { + return m_lambda->get_hopper<_returnType>(); + } + return dispatch::lambda_function<_signature...>::template hopper<_returnType>(); + } + + /* @method: hasSignature<...>() @param: set of arguments, explicitly specified as template parameter. @return: bool, if the functor associated with this object is of certain signature or not. diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index a3b551b3..166c9790 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -56,6 +56,19 @@ namespace rtl { GETTER_BOOL(Const, (getQualifier() == detail::methodQ::Const)); + + template + struct Hopper + { + const dispatch::lambda_method<_recordType, _signature...>* m_lambda = nullptr; + + template + constexpr const dispatch::lambda_method<_recordType, _signature...>::hopper<_returnType> return_t() const; + }; + + template + const Hopper<_recordType, _signature...> args_t() const; + //indicates if a particular set of arguments accepted by the functor associated with it. template bool hasSignature() const; @@ -66,9 +79,6 @@ namespace rtl { template const detail::NonConstInvoker<_signature...> bind(constCast&& pTarget) const; - template - const dispatch::lambda_method<_recordType, _signature...>* get_lambda(std::size_t pOverloadIndex = 0) const; - /* @method: operator()() @return: lambda * accepts no arguments for 'target', since associated functor is static-member-functions. diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 431154d8..b354bda1 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -30,13 +30,29 @@ namespace rtl template - const dispatch::lambda_method<_recordType, _signature...>* Method::get_lambda(std::size_t pOverloadIndex) const + const Method::Hopper<_recordType, _signature...> Method::args_t() const { - auto& functorIds = getFunctors(); - if (pOverloadIndex < functorIds.size()) { - return functorIds[pOverloadIndex].get_lambda_method<_recordType, _signature...>(); + for (auto& functorId : getFunctorIds()) + { + if (functorId.m_lambda->is_member<_recordType>() && + functorId.m_lambda->is_signature<_signature...>()) [[likely]] + { + return { functorId.get_lambda_method<_recordType, _signature...>() }; + } + } + return Hopper<_recordType, _signature...>(); + } + + + template + template + inline constexpr const dispatch::lambda_method<_recordType, _signature...>::hopper<_returnType> + Method::Hopper<_recordType, _signature...>::return_t() const + { + if (m_lambda != nullptr && m_lambda->is_returning<_returnType>()) { + return m_lambda->get_hopper<_returnType>(); } - return nullptr; + return dispatch::lambda_method<_recordType, _signature...>::template hopper<_returnType>(); } diff --git a/ReflectionTemplateLib/rtl/rtl.h b/ReflectionTemplateLib/rtl/rtl.h index a21b849a..e8196fc7 100644 --- a/ReflectionTemplateLib/rtl/rtl.h +++ b/ReflectionTemplateLib/rtl/rtl.h @@ -104,9 +104,9 @@ namespace rtl { - template - using lambda_function = dispatch::lambda_function; + template + using function_ptr = dispatch::lambda_function::template hopper; - template - using lambda_method = dispatch::lambda_method; + template + using method_ptr = dispatch::lambda_method::template hopper; } \ No newline at end of file From 7d1ef56f60b032a863d048f1647a0910b8774ea7 Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 23 Sep 2025 16:59:20 +0530 Subject: [PATCH 028/148] fixed nested-template fiasco that clang couldn't handle. --- .../src/ReflectedCallKnownReturn.cpp | 56 +++++++++++++- .../rtl/detail/inc/forward_decls.h | 6 ++ .../rtl/dispatch/lambda_function.h | 73 ++++++++++-------- .../rtl/dispatch/lambda_method.h | 76 ++++++++++--------- ReflectionTemplateLib/rtl/inc/Function.h | 6 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 13 ++-- ReflectionTemplateLib/rtl/inc/Method.h | 6 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 13 ++-- ReflectionTemplateLib/rtl/rtl.h | 12 +-- 9 files changed, 157 insertions(+), 104 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 704955fb..ca19a74a 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -1,8 +1,10 @@ +#include #include #include #include "BenchMark.h" +#include "Function.h" #include "ReflectedCallKnownReturn.h" @@ -18,13 +20,59 @@ namespace cxx namespace { - static const auto getMessage_functor = cxx::mirror().getFunction("getMessage")->args_t().return_t(); + static const auto getMessage_functor = []() + { + std::optional function = cxx::mirror().getFunction("getMessage"); + if(!function) + { + std::cerr << "[00] error: function 'getMessage' not found.\n"; + std::abort(); + } + return function->args_t().return_t(); + }(); + + static const auto sendMessage_functor = []() + { + std::optional sendMessage = cxx::mirror().getFunction("sendMessage"); + if(!sendMessage) + { + std::cerr << "[01] error: function 'sendMessage' not found.\n"; + std::abort(); + } + return sendMessage->args_t().return_t(); + }(); + + static const auto getMessageOnNode_functor = []() + { + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } - static const auto sendMessage_functor = cxx::mirror().getFunction("sendMessage")->args_t().return_t(); + std::optional method = Node->getMethod("getMessage"); + if (!method) { + std::cerr << "[02] error: method 'Node::getMessage' not found.\n"; + std::abort(); + } + return method->args_t().return_t(); + }(); - static const auto getMessageOnNode_functor = cxx::mirror().getRecord("Node")->getMethod("getMessage")->args_t().return_t(); + static const auto sendMessageOnNode_functor = []() + { + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } - static const auto sendMessageOnNode_functor = cxx::mirror().getRecord("Node")->getMethod("sendMessage")->args_t().return_t(); + std::optional method = Node->getMethod("sendMessage"); + if (!method) { + std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; + std::abort(); + } + return method->args_t().return_t(); + }(); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index ac9e6df5..a755fb9c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -25,6 +25,12 @@ namespace rtl class CxxMirror; + template + struct function_hop; + + template + struct method_hop; + namespace detail { struct FunctorId; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index a09b9788..77587425 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -14,56 +14,63 @@ #include "lambda.h" #include "function_ptr.h" -namespace rtl::dispatch +namespace rtl { - template - struct lambda_function: public lambda + template + struct function_hop { - template - using fptr_t = typename function_ptr::functor_t; + using fptr_t = return_t(*)(signature_ts...); - lambda_function(const functor& fptr) noexcept - :lambda(fptr) - { } + const fptr_t m_functor = nullptr; - template - struct hopper + constexpr auto f_ptr() const { + return m_functor; + } + + constexpr auto is_valid() const { + return (m_functor != nullptr); + } + + template + [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept(noexcept_v) { - constexpr auto f_ptr() const { - return m_functor; - } + static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + return (*m_functor)(std::forward(params)...); + } - constexpr auto is_valid() const { - return (m_functor != nullptr); - } - template - [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept(noexcept_v) - { - static_assert(is_args_t_ok, "Argument types don't match the expected signature."); - return (*m_functor)(std::forward(params)...); - } + private: - const fptr_t m_functor = nullptr; + template + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - private: + template + static constexpr bool noexcept_v = noexcept(std::declval()(std::declval()...)); + }; +} - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; +namespace rtl::dispatch +{ + template + struct lambda_function: public lambda + { + template + using hopper_t = function_hop; - template - static constexpr bool noexcept_v = noexcept(std::declval>()(std::declval()...)); - }; + lambda_function(const functor& p_functor) noexcept + :lambda(p_functor) + { } template - [[nodiscard]] constexpr const hopper get_hopper() const + constexpr const hopper_t get_hopper() const { if (m_functor.m_returnId == detail::TypeId::get()) { - fptr_t func_ptr = (static_cast&>(m_functor)).f_ptr(); - return hopper{ func_ptr }; + return hopper_t { + static_cast&>(m_functor).f_ptr() + }; } - return hopper(); + return hopper_t(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 241ecc31..d8cec377 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -14,60 +14,64 @@ #include "lambda.h" #include "method_ptr.h" -namespace rtl::dispatch + +namespace rtl { - template - struct lambda_method : public lambda + template + struct method_hop { - template - using fptr_t = typename method_ptr::functor_t; + using fptr_t = return_t (record_t::*)(signature_ts...); - public: + const fptr_t m_functor = nullptr; - lambda_method(const functor& fptr) noexcept - :lambda(fptr) - { } + constexpr auto f_ptr() const { + return m_functor; + } + constexpr auto is_valid() const { + return (m_functor != nullptr); + } - template - struct hopper + template + [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) { - constexpr auto f_ptr() const { - return m_functor; - } - - constexpr auto is_valid() const { - return (m_functor != nullptr); - } - - template - [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) - { - static_assert(is_args_t_ok, "Argument types don't match the expected signature."); - return (target.*m_functor)(std::forward(params)...); - } + static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + return (target.*m_functor)(std::forward(params)...); + } - const fptr_t m_functor = nullptr; + private: + + template + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - private: + template + static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); + }; +} - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - template - static constexpr bool noexcept_v = noexcept((std::declval().*std::declval>())(std::declval()...)); - }; +namespace rtl::dispatch +{ + template + struct lambda_method : public lambda + { + template + using hopper_t = method_hop; + lambda_method(const functor& p_functor) noexcept + :lambda(p_functor) + { } template - [[nodiscard]] constexpr const hopper get_hopper() const + constexpr const hopper_t get_hopper() const { if (m_functor.m_returnId == detail::TypeId::get()) { - fptr_t func_ptr = (static_cast&>(m_functor)).f_ptr(); - return hopper{ func_ptr }; + return hopper_t { + static_cast&>(m_functor).f_ptr() + }; } - return hopper(); + return hopper_t(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index ac35efe2..2371f9b0 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -90,16 +90,16 @@ namespace rtl { Function& operator=(const Function&) = default; template - struct Hopper + struct HopBuilder { const dispatch::lambda_function<_signature...>* m_lambda = nullptr; template - constexpr const dispatch::lambda_function<_signature...>::hopper<_returnType> return_t() const; + constexpr const function_hop<_returnType(_signature...)> return_t() const; }; template - const Hopper<_signature...> args_t() const; + const HopBuilder<_signature...> args_t() const; //indicates if a functor associated with it takes zero arguments. bool hasSignature() const; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index f07640c1..49650789 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -23,7 +23,7 @@ namespace rtl } template - const Function::Hopper<_signature...> Function::args_t() const + const Function::HopBuilder<_signature...> Function::args_t() const { for (auto& functorId : m_functorIds) { @@ -31,19 +31,18 @@ namespace rtl return { functorId.get_lambda_function<_signature...>() }; } } - return Hopper<_signature...>(); + return HopBuilder<_signature...>(); } template template - inline constexpr const dispatch::lambda_function<_signature...>::hopper<_returnType> - Function::Hopper<_signature...>::return_t() const + inline constexpr const function_hop<_returnType(_signature...)> Function::HopBuilder<_signature...>::return_t() const { - if (m_lambda != nullptr && m_lambda->is_returning<_returnType>()) { - return m_lambda->get_hopper<_returnType>(); + if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { + return m_lambda->template get_hopper<_returnType>(); } - return dispatch::lambda_function<_signature...>::template hopper<_returnType>(); + return function_hop<_returnType(_signature...)>(); } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 166c9790..4e46f80b 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -58,16 +58,16 @@ namespace rtl { template - struct Hopper + struct HopBuilder { const dispatch::lambda_method<_recordType, _signature...>* m_lambda = nullptr; template - constexpr const dispatch::lambda_method<_recordType, _signature...>::hopper<_returnType> return_t() const; + constexpr const method_hop<_returnType (_recordType::*)(_signature...)> return_t() const; }; template - const Hopper<_recordType, _signature...> args_t() const; + const HopBuilder<_recordType, _signature...> args_t() const; //indicates if a particular set of arguments accepted by the functor associated with it. template diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index b354bda1..fb88da15 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -30,7 +30,7 @@ namespace rtl template - const Method::Hopper<_recordType, _signature...> Method::args_t() const + const Method::HopBuilder<_recordType, _signature...> Method::args_t() const { for (auto& functorId : getFunctorIds()) { @@ -40,19 +40,18 @@ namespace rtl return { functorId.get_lambda_method<_recordType, _signature...>() }; } } - return Hopper<_recordType, _signature...>(); + return HopBuilder<_recordType, _signature...>(); } template template - inline constexpr const dispatch::lambda_method<_recordType, _signature...>::hopper<_returnType> - Method::Hopper<_recordType, _signature...>::return_t() const + inline constexpr const method_hop<_returnType (_recordType::*)(_signature...)> Method::HopBuilder<_recordType, _signature...>::return_t() const { - if (m_lambda != nullptr && m_lambda->is_returning<_returnType>()) { - return m_lambda->get_hopper<_returnType>(); + if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { + return m_lambda->template get_hopper<_returnType>(); } - return dispatch::lambda_method<_recordType, _signature...>::template hopper<_returnType>(); + return method_hop<_returnType (_recordType::*)(_signature...)>(); } diff --git a/ReflectionTemplateLib/rtl/rtl.h b/ReflectionTemplateLib/rtl/rtl.h index e8196fc7..d4185e61 100644 --- a/ReflectionTemplateLib/rtl/rtl.h +++ b/ReflectionTemplateLib/rtl/rtl.h @@ -99,14 +99,4 @@ * * Declared in namespace rtl. */ -#include "CxxMirror.hpp" - - -namespace rtl { - - template - using function_ptr = dispatch::lambda_function::template hopper; - - template - using method_ptr = dispatch::lambda_method::template hopper; -} \ No newline at end of file +#include "CxxMirror.hpp" \ No newline at end of file From 0f8f46fa707ff8a5c229914054950e34283bb8e3 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 23 Sep 2025 20:11:26 +0530 Subject: [PATCH 029/148] refined dispatch apis, added- rtl::function, rtl::method. --- .../src/ReflectedCallKnownReturn.cpp | 72 +++++++++---------- .../rtl/detail/inc/FunctionCaller.h | 30 ++++++-- .../rtl/detail/inc/FunctionCaller.hpp | 37 +++++++++- .../rtl/detail/inc/MethodInvoker.h | 22 ++++++ .../rtl/detail/inc/MethodInvoker.hpp | 31 ++++++++ .../rtl/detail/inc/forward_decls.h | 7 +- .../rtl/dispatch/lambda_function.h | 4 +- .../rtl/dispatch/lambda_method.h | 4 +- ReflectionTemplateLib/rtl/inc/Function.h | 13 +--- ReflectionTemplateLib/rtl/inc/Function.hpp | 24 +------ ReflectionTemplateLib/rtl/inc/Method.h | 12 +--- ReflectionTemplateLib/rtl/inc/Method.hpp | 25 +------ 12 files changed, 166 insertions(+), 115 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index ca19a74a..4e981360 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -20,58 +20,58 @@ namespace cxx namespace { - static const auto getMessage_functor = []() + static const rtl::function getMessage = []() { std::optional function = cxx::mirror().getFunction("getMessage"); if(!function) { - std::cerr << "[00] error: function 'getMessage' not found.\n"; + std::cerr << "[00] error: function 'getMessage' not found.\callerId"; std::abort(); } - return function->args_t().return_t(); + return function->getLambda().argsT().returnT(); }(); - static const auto sendMessage_functor = []() + static const rtl::function sendMessage = []() { - std::optional sendMessage = cxx::mirror().getFunction("sendMessage"); - if(!sendMessage) + std::optional function = cxx::mirror().getFunction("sendMessage"); + if(!function) { - std::cerr << "[01] error: function 'sendMessage' not found.\n"; + std::cerr << "[01] error: function 'sendMessage' not found.\callerId"; std::abort(); } - return sendMessage->args_t().return_t(); + return function->getLambda().argsT().returnT(); }(); - static const auto getMessageOnNode_functor = []() + static const rtl::method getMessageNode = []() { std::optional Node = cxx::mirror().getRecord("Node"); if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; + std::cerr << "[x] error: record 'Node' not found.\callerId"; std::abort(); } std::optional method = Node->getMethod("getMessage"); if (!method) { - std::cerr << "[02] error: method 'Node::getMessage' not found.\n"; + std::cerr << "[02] error: method 'Node::getMessage' not found.\callerId"; std::abort(); } - return method->args_t().return_t(); + return method->getLambda().argsT().returnT(); }(); - static const auto sendMessageOnNode_functor = []() + static const rtl::method sendMessageOnNode = []() { std::optional Node = cxx::mirror().getRecord("Node"); if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; + std::cerr << "[x] error: record 'Node' not found.\callerId"; std::abort(); } std::optional method = Node->getMethod("sendMessage"); if (!method) { - std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; + std::cerr << "[3] error: method 'Node::sendMessage' not found.\callerId"; std::abort(); } - return method->args_t().return_t(); + return method->getLambda().argsT().returnT(); }(); } @@ -84,10 +84,10 @@ namespace }; template - static bool test(const T& functor, int n) + static bool test(const T& lambda, int callerId) { - if (!functor.is_valid()) { - std::cerr << "[" << n << "] error: functor not valid, return-type or signature mismatch.\n"; + if (!lambda.is_valid()) { + std::cerr << "[" << callerId << "] error: functor not valid, return-type or signature mismatch.\callerId"; std::abort(); } return true; @@ -98,30 +98,30 @@ namespace void FunctionPointerCall::returnTypeNonVoid(benchmark::State& state) { static auto _=_new_line(); - static auto is_ok = test(getMessage_functor, 0); + static auto is_ok = test(getMessage, 0); for (auto _ : state) { - benchmark::DoNotOptimize((getMessage_functor.f_ptr())(bm::g_longStr)); + benchmark::DoNotOptimize((getMessage.f_ptr())(bm::g_longStr)); } } void MethodFnPointerCall::returnTypeNonVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto is_ok = test(getMessageOnNode_functor, 1); + static auto is_ok = test(getMessageNode, 1); for (auto _ : state) { - benchmark::DoNotOptimize((nodeObj.*getMessageOnNode_functor.f_ptr())(bm::g_longStr)); + benchmark::DoNotOptimize((nodeObj.*getMessageNode.f_ptr())(bm::g_longStr)); } } void FunctionPointerCall::returnTypeVoid(benchmark::State& state) { static auto _ = _new_line(); - static auto is_ok = test(sendMessage_functor, 2); + static auto is_ok = test(sendMessage, 2); for (auto _ : state) { - (sendMessage_functor.f_ptr())(bm::g_longStr); + (sendMessage.f_ptr())(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -129,12 +129,12 @@ void FunctionPointerCall::returnTypeVoid(benchmark::State& state) void MethodFnPointerCall::returnTypeVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto is_ok = test(getMessageOnNode_functor, 2); + static auto is_ok = test(getMessageNode, 2); for (auto _ : state) { - if (sendMessageOnNode_functor.is_valid()) + if (sendMessageOnNode.is_valid()) { - (nodeObj.*sendMessageOnNode_functor.f_ptr())(bm::g_longStr); + (nodeObj.*sendMessageOnNode.f_ptr())(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -145,30 +145,30 @@ void MethodFnPointerCall::returnTypeVoid(benchmark::State& state) void ReflectedCallKnownReturn::typeNonVoid(benchmark::State& state) { static auto _ = _new_line(); - static auto is_ok = test(getMessage_functor, 3); + static auto is_ok = test(getMessage, 3); for (auto _ : state) { - benchmark::DoNotOptimize(getMessage_functor(bm::g_longStr)); + benchmark::DoNotOptimize(getMessage(bm::g_longStr)); } } void ReflectedMethodCallKnownReturn::typeNonVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto is_ok = test(getMessageOnNode_functor, 4); + static auto is_ok = test(getMessageNode, 4); for (auto _ : state) { - benchmark::DoNotOptimize(getMessageOnNode_functor(nodeObj, bm::g_longStr)); + benchmark::DoNotOptimize(getMessageNode(nodeObj, bm::g_longStr)); } } void ReflectedCallKnownReturn::typeVoid(benchmark::State& state) { static auto _ = _new_line(); - static auto is_ok = test(sendMessage_functor, 0); + static auto is_ok = test(sendMessage, 0); for (auto _ : state) { - sendMessage_functor(bm::g_longStr); + sendMessage(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -176,10 +176,10 @@ void ReflectedCallKnownReturn::typeVoid(benchmark::State& state) void ReflectedMethodCallKnownReturn::typeVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto is_ok = test(sendMessageOnNode_functor, 5); + static auto is_ok = test(sendMessageOnNode, 5); for (auto _ : state) { - sendMessageOnNode_functor(nodeObj, bm::g_longStr); + sendMessageOnNode(nodeObj, bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index ae63d80a..b4063ce4 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -20,20 +20,38 @@ namespace rtl::detail template struct FunctionCaller { - //the function to be called. const Function* m_function; public: template - rtl::Return call(_args&&...) const; + rtl::Return call(_args&&...) const noexcept; template - constexpr rtl::Return operator()(_args&&...params) const - { - return call(std::forward<_args>(params)...); - } + constexpr rtl::Return operator()(_args&&...params) const noexcept; friend Function; }; } + + +namespace rtl::detail +{ + template<> + struct Hopper + { + const std::vector& m_functorIds; + + template + struct Build + { + const dispatch::lambda_function<_signature...>* m_lambda = nullptr; + + template + constexpr const function<_returnType(_signature...)> returnT() const; + }; + + template + const Build<_signature...> argsT() const; + }; +} diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index f5426d05..428356b8 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -20,7 +20,7 @@ namespace rtl::detail { template template - FORCE_INLINE Return FunctionCaller<_signature...>::call(_args&&...params) const + FORCE_INLINE Return FunctionCaller<_signature...>::call(_args&&...params) const noexcept { using Container = std::conditional_t...>, @@ -32,4 +32,39 @@ namespace rtl::detail } return { error::SignatureMismatch, RObject{} }; } + + + template + template + constexpr inline rtl::Return FunctionCaller<_signature...>::operator()(_args&&...params) const noexcept + { + return call(std::forward<_args>(params)...); + } +} + + +namespace rtl::detail +{ + template + const Hopper::Build<_signature...> Hopper::argsT() const + { + for (auto& functorId : m_functorIds) + { + if (functorId.m_lambda->is_signature<_signature...>()) [[likely]] { + return { functorId.get_lambda_function<_signature...>() }; + } + } + return Build<_signature...>(); + } + + + template + template + inline constexpr const function<_returnType(_signature...)> Hopper::Build<_signature...>::returnT() const + { + if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { + return m_lambda->template get_hopper<_returnType>(); + } + return function<_returnType(_signature...)>(); + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 4cbb83fe..8f9d40bd 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -74,4 +74,26 @@ namespace rtl::detail { friend Method; }; +} + + +namespace rtl::detail +{ + template + struct Hopper + { + const std::vector& m_functorIds; + + template + struct Build + { + const dispatch::lambda_method<_recordType, _signature...>* m_lambda = nullptr; + + template + constexpr const method<_returnType(_recordType::*)(_signature...)> returnT() const; + }; + + template + const Build<_signature...> argsT() const; + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 76a1c4e9..ab007d71 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -146,4 +146,35 @@ namespace rtl::detail return { error::SignatureMismatch , RObject{} }; } } +} + + +namespace rtl::detail +{ + template + template + const Hopper<_recordType>::Build<_signature...> Hopper<_recordType>::argsT() const + { + for (auto& functorId : m_functorIds) + { + if (functorId.m_lambda->is_member<_recordType>() && + functorId.m_lambda->is_signature<_signature...>()) [[likely]] + { + return { functorId.get_lambda_method<_recordType, _signature...>() }; + } + } + return Build<_signature...>(); + } + + + template + template + template + inline constexpr const method<_returnType(_recordType::*)(_signature...)> Hopper<_recordType>::Build<_signature...>::returnT() const + { + if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { + return m_lambda->template get_hopper<_returnType>(); + } + return method<_returnType(_recordType::*)(_signature...)>(); + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h index a755fb9c..70420b2f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h +++ b/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h @@ -26,10 +26,10 @@ namespace rtl class CxxMirror; template - struct function_hop; + struct function; template - struct method_hop; + struct method; namespace detail { @@ -40,6 +40,9 @@ namespace rtl template class SetupMethod; + + template + struct Hopper; } namespace cache diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 77587425..98424128 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -17,7 +17,7 @@ namespace rtl { template - struct function_hop + struct function { using fptr_t = return_t(*)(signature_ts...); @@ -55,7 +55,7 @@ namespace rtl::dispatch struct lambda_function: public lambda { template - using hopper_t = function_hop; + using hopper_t = function; lambda_function(const functor& p_functor) noexcept :lambda(p_functor) diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index d8cec377..6d771717 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -18,7 +18,7 @@ namespace rtl { template - struct method_hop + struct method { using fptr_t = return_t (record_t::*)(signature_ts...); @@ -56,7 +56,7 @@ namespace rtl::dispatch struct lambda_method : public lambda { template - using hopper_t = method_hop; + using hopper_t = method; lambda_method(const functor& p_functor) noexcept :lambda(p_functor) diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 2371f9b0..807f69a6 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -89,19 +89,8 @@ namespace rtl { Function& operator=(Function&&) = default; Function& operator=(const Function&) = default; - template - struct HopBuilder - { - const dispatch::lambda_function<_signature...>* m_lambda = nullptr; - - template - constexpr const function_hop<_returnType(_signature...)> return_t() const; - }; - - template - const HopBuilder<_signature...> args_t() const; + detail::Hopper<> getLambda(); - //indicates if a functor associated with it takes zero arguments. bool hasSignature() const; template diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 49650789..da8aec10 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -22,31 +22,13 @@ namespace rtl return detail::FunctionCaller<_signature...>{ this }; } - template - const Function::HopBuilder<_signature...> Function::args_t() const - { - for (auto& functorId : m_functorIds) - { - if (functorId.m_lambda->is_signature<_signature...>()) [[likely]] { - return { functorId.get_lambda_function<_signature...>() }; - } - } - return HopBuilder<_signature...>(); - } - - template - template - inline constexpr const function_hop<_returnType(_signature...)> Function::HopBuilder<_signature...>::return_t() const + inline detail::Hopper<> Function::getLambda() { - if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { - return m_lambda->template get_hopper<_returnType>(); - } - return function_hop<_returnType(_signature...)>(); + return detail::Hopper<>{ m_functorIds }; } - -/* @method: hasSignature<...>() + /* @method: hasSignature<...>() @param: set of arguments, explicitly specified as template parameter. @return: bool, if the functor associated with this object is of certain signature or not. * a single 'Function' object can be associated with multiple overloads of same function. diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 4e46f80b..a2762b40 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -56,18 +56,8 @@ namespace rtl { GETTER_BOOL(Const, (getQualifier() == detail::methodQ::Const)); - - template - struct HopBuilder - { - const dispatch::lambda_method<_recordType, _signature...>* m_lambda = nullptr; - - template - constexpr const method_hop<_returnType (_recordType::*)(_signature...)> return_t() const; - }; - template - const HopBuilder<_recordType, _signature...> args_t() const; + constexpr detail::Hopper<_recordType> getLambda() const; //indicates if a particular set of arguments accepted by the functor associated with it. template diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index fb88da15..614d0bf3 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -30,28 +30,9 @@ namespace rtl template - const Method::HopBuilder<_recordType, _signature...> Method::args_t() const + inline constexpr detail::Hopper<_recordType> Method::getLambda() const { - for (auto& functorId : getFunctorIds()) - { - if (functorId.m_lambda->is_member<_recordType>() && - functorId.m_lambda->is_signature<_signature...>()) [[likely]] - { - return { functorId.get_lambda_method<_recordType, _signature...>() }; - } - } - return HopBuilder<_recordType, _signature...>(); - } - - - template - template - inline constexpr const method_hop<_returnType (_recordType::*)(_signature...)> Method::HopBuilder<_recordType, _signature...>::return_t() const - { - if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { - return m_lambda->template get_hopper<_returnType>(); - } - return method_hop<_returnType (_recordType::*)(_signature...)>(); + return detail::Hopper<_recordType>{ getFunctorIds() }; } @@ -72,7 +53,7 @@ namespace rtl } -/* @method: hasSignature<...>() + /* @method: hasSignature<...>() @params: template params, <_arg0, ..._args> (expects at least one args- _args0) @return: bool * checks if the member-function functor associated with this 'Method', takes template specified arguments set or not. From c30f20cb57e049786b7b10ae0ea3762d4ac0a741 Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 23 Sep 2025 21:58:08 +0530 Subject: [PATCH 030/148] fixed gcc 'template' error --- .../src/ReflectedCallKnownReturn.cpp | 48 +++++++++---------- .../src/ReflectedCallKnownReturn.h | 24 +++++----- .../src/ReflectedCallUnknownReturn.cpp | 8 ++-- .../src/ReflectedCallUnknownReturn.h | 4 +- RTLBenchmarkApp/src/StandardCall.cpp | 16 +++---- RTLBenchmarkApp/src/StandardCall.h | 16 +++---- RTLBenchmarkApp/src/main.cpp | 36 +++++++------- .../rtl/detail/inc/MethodInvoker.hpp | 2 +- ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 2 +- ReflectionTemplateLib/rtl/inc/Method.h | 2 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 2 +- 12 files changed, 81 insertions(+), 81 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 4e981360..f9fdf180 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -25,10 +25,10 @@ namespace std::optional function = cxx::mirror().getFunction("getMessage"); if(!function) { - std::cerr << "[00] error: function 'getMessage' not found.\callerId"; + std::cerr << "[00] error: function 'getMessage' not found."; std::abort(); } - return function->getLambda().argsT().returnT(); + return function->lambda().argsT().returnT(); }(); static const rtl::function sendMessage = []() @@ -36,42 +36,42 @@ namespace std::optional function = cxx::mirror().getFunction("sendMessage"); if(!function) { - std::cerr << "[01] error: function 'sendMessage' not found.\callerId"; + std::cerr << "[01] error: function 'sendMessage' not found."; std::abort(); } - return function->getLambda().argsT().returnT(); + return function->lambda().argsT().returnT(); }(); static const rtl::method getMessageNode = []() { std::optional Node = cxx::mirror().getRecord("Node"); if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\callerId"; + std::cerr << "[x] error: record 'Node' not found"; std::abort(); } std::optional method = Node->getMethod("getMessage"); if (!method) { - std::cerr << "[02] error: method 'Node::getMessage' not found.\callerId"; + std::cerr << "[02] error: method 'Node::getMessage' not found."; std::abort(); } - return method->getLambda().argsT().returnT(); + return method->lambda().argsT().returnT(); }(); - static const rtl::method sendMessageOnNode = []() + static const rtl::method sendMessageNode = []() { std::optional Node = cxx::mirror().getRecord("Node"); if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\callerId"; + std::cerr << "[x] error: record 'Node' not found."; std::abort(); } std::optional method = Node->getMethod("sendMessage"); if (!method) { - std::cerr << "[3] error: method 'Node::sendMessage' not found.\callerId"; + std::cerr << "[3] error: method 'Node::sendMessage' not found."; std::abort(); } - return method->getLambda().argsT().returnT(); + return method->lambda().argsT().returnT(); }(); } @@ -87,7 +87,7 @@ namespace static bool test(const T& lambda, int callerId) { if (!lambda.is_valid()) { - std::cerr << "[" << callerId << "] error: functor not valid, return-type or signature mismatch.\callerId"; + std::cerr << "[" << callerId << "] error: functor not valid, return-type or signature mismatch."; std::abort(); } return true; @@ -95,7 +95,7 @@ namespace } -void FunctionPointerCall::returnTypeNonVoid(benchmark::State& state) +void NativeFunctionPtr_call::returnNonVoid(benchmark::State& state) { static auto _=_new_line(); static auto is_ok = test(getMessage, 0); @@ -105,7 +105,7 @@ void FunctionPointerCall::returnTypeNonVoid(benchmark::State& state) } } -void MethodFnPointerCall::returnTypeNonVoid(benchmark::State& state) +void NativeFunctionPtr_callMethod::returnNonVoid(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(getMessageNode, 1); @@ -115,7 +115,7 @@ void MethodFnPointerCall::returnTypeNonVoid(benchmark::State& state) } } -void FunctionPointerCall::returnTypeVoid(benchmark::State& state) +void NativeFunctionPtr_call::returnVoid(benchmark::State& state) { static auto _ = _new_line(); static auto is_ok = test(sendMessage, 2); @@ -126,15 +126,15 @@ void FunctionPointerCall::returnTypeVoid(benchmark::State& state) } } -void MethodFnPointerCall::returnTypeVoid(benchmark::State& state) +void NativeFunctionPtr_callMethod::returnVoid(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(getMessageNode, 2); for (auto _ : state) { - if (sendMessageOnNode.is_valid()) + if (sendMessageNode.is_valid()) { - (nodeObj.*sendMessageOnNode.f_ptr())(bm::g_longStr); + (nodeObj.*sendMessageNode.f_ptr())(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } @@ -142,7 +142,7 @@ void MethodFnPointerCall::returnTypeVoid(benchmark::State& state) -void ReflectedCallKnownReturn::typeNonVoid(benchmark::State& state) +void RtlFunction_call::returnNonVoid(benchmark::State &state) { static auto _ = _new_line(); static auto is_ok = test(getMessage, 3); @@ -152,7 +152,7 @@ void ReflectedCallKnownReturn::typeNonVoid(benchmark::State& state) } } -void ReflectedMethodCallKnownReturn::typeNonVoid(benchmark::State& state) +void RtlFunction_callMethod::returnNonVoid(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(getMessageNode, 4); @@ -162,7 +162,7 @@ void ReflectedMethodCallKnownReturn::typeNonVoid(benchmark::State& state) } } -void ReflectedCallKnownReturn::typeVoid(benchmark::State& state) +void RtlFunction_call::returnVoid(benchmark::State& state) { static auto _ = _new_line(); static auto is_ok = test(sendMessage, 0); @@ -173,13 +173,13 @@ void ReflectedCallKnownReturn::typeVoid(benchmark::State& state) } } -void ReflectedMethodCallKnownReturn::typeVoid(benchmark::State& state) +void RtlFunction_callMethod::returnVoid(benchmark::State& state) { static bm::Node nodeObj; - static auto is_ok = test(sendMessageOnNode, 5); + static auto is_ok = test(sendMessageNode, 5); for (auto _ : state) { - sendMessageOnNode(nodeObj, bm::g_longStr); + sendMessageNode(nodeObj, bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index a6a5a61d..6e369771 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -2,33 +2,33 @@ #include -struct ReflectedCallKnownReturn +struct RtlFunction_call { - static void typeVoid(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void typeNonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); }; -struct FunctionPointerCall +struct NativeFunctionPtr_call { - static void returnTypeVoid(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void returnTypeNonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); }; -struct MethodFnPointerCall +struct NativeFunctionPtr_callMethod { - static void returnTypeVoid(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void returnTypeNonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); }; -struct ReflectedMethodCallKnownReturn +struct RtlFunction_callMethod { - static void typeVoid(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void typeNonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); }; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 760b7734..ab150e50 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -127,7 +127,7 @@ namespace -void ReflectedCallUnknownReturn::typeVoid(benchmark::State& state) +void RtlFunction_call_ReturnUnknown::typeVoid(benchmark::State& state) { static auto __=_new_line(); static auto _ = _test0(); @@ -138,7 +138,7 @@ void ReflectedCallUnknownReturn::typeVoid(benchmark::State& state) } -void ReflectedCallUnknownReturn::typeNonVoid(benchmark::State& state) +void RtlFunction_call_ReturnUnknown::typeNonVoid(benchmark::State& state) { static auto __=_new_line(); static auto _ = _test2(); @@ -149,7 +149,7 @@ void ReflectedCallUnknownReturn::typeNonVoid(benchmark::State& state) } -void ReflectedMethodCallUnknownReturn::typeVoid(benchmark::State& state) +void RtlFunctionCall_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) { static auto _ = _test1(); for (auto _ : state) @@ -159,7 +159,7 @@ void ReflectedMethodCallUnknownReturn::typeVoid(benchmark::State& state) } -void ReflectedMethodCallUnknownReturn::typeNonVoid(benchmark::State& state) +void RtlFunctionCall_callMethod_ReturnUnknown::typeNonVoid(benchmark::State& state) { static auto _ = _test3(); for (auto _ : state) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index 9ceec026..03a2dfd1 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -2,7 +2,7 @@ #include -struct ReflectedCallUnknownReturn +struct RtlFunction_call_ReturnUnknown { static void typeVoid(benchmark::State& state); @@ -10,7 +10,7 @@ struct ReflectedCallUnknownReturn }; -struct ReflectedMethodCallUnknownReturn +struct RtlFunctionCall_callMethod_ReturnUnknown { static void typeVoid(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index d79c3d44..215a92d4 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -9,8 +9,8 @@ namespace { static auto _put_line = []() { - std::cout << "----------------------------------------" - "------------------------------------------------" << std::endl; + std::cout << "--------------------------------------------" + "----------------------------------------------------" << std::endl; return 0; }; @@ -39,7 +39,7 @@ namespace bm } -void NativeCall::returnTypeVoid(benchmark::State& state) +void NativeCall::returnVoid(benchmark::State& state) { for (auto _: state) { @@ -49,7 +49,7 @@ void NativeCall::returnTypeVoid(benchmark::State& state) } -void NativeCall::returnTypeNonVoid(benchmark::State& state) +void NativeCall::returnNonVoid(benchmark::State& state) { static auto _=_put_line(); for (auto _: state) @@ -59,7 +59,7 @@ void NativeCall::returnTypeNonVoid(benchmark::State& state) } -void StdFunctionCall::returnTypeVoid(benchmark::State& state) +void StdFunction_call::returnVoid(benchmark::State& state) { static auto _=_new_line(); for (auto _: state) @@ -70,7 +70,7 @@ void StdFunctionCall::returnTypeVoid(benchmark::State& state) } -void StdFunctionMethodCall::returnTypeVoid(benchmark::State& state) +void StdFunction_callMethod::returnVoid(benchmark::State& state) { static bm::Node nodeObj; for (auto _: state) @@ -81,7 +81,7 @@ void StdFunctionMethodCall::returnTypeVoid(benchmark::State& state) } -void StdFunctionCall::returnTypeNonVoid(benchmark::State& state) +void StdFunction_call::returnNonVoid(benchmark::State& state) { static auto _=_new_line(); for (auto _: state) @@ -91,7 +91,7 @@ void StdFunctionCall::returnTypeNonVoid(benchmark::State& state) } -void StdFunctionMethodCall::returnTypeNonVoid(benchmark::State& state) +void StdFunction_callMethod::returnNonVoid(benchmark::State& state) { static bm::Node nodeObj; for (auto _: state) diff --git a/RTLBenchmarkApp/src/StandardCall.h b/RTLBenchmarkApp/src/StandardCall.h index e6ca7b00..bbc77907 100644 --- a/RTLBenchmarkApp/src/StandardCall.h +++ b/RTLBenchmarkApp/src/StandardCall.h @@ -4,23 +4,23 @@ struct NativeCall { - static void returnTypeVoid(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void returnTypeNonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); }; -struct StdFunctionCall +struct StdFunction_call { - static void returnTypeVoid(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void returnTypeNonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); }; -struct StdFunctionMethodCall +struct StdFunction_callMethod { - static void returnTypeVoid(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void returnTypeNonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); }; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index 44119ff6..bde3f594 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -6,33 +6,33 @@ #include "ReflectedCallKnownReturn.h" #include "ReflectedCallUnknownReturn.h" -BENCHMARK(NativeCall::returnTypeVoid); +BENCHMARK(NativeCall::returnVoid); -BENCHMARK(FunctionPointerCall::returnTypeVoid); -BENCHMARK(MethodFnPointerCall::returnTypeVoid); +BENCHMARK(NativeFunctionPtr_call::returnVoid); +BENCHMARK(NativeFunctionPtr_callMethod::returnVoid); -BENCHMARK(StdFunctionCall::returnTypeVoid); -BENCHMARK(StdFunctionMethodCall::returnTypeVoid); +BENCHMARK(StdFunction_call::returnVoid); +BENCHMARK(StdFunction_callMethod::returnVoid); -BENCHMARK(ReflectedCallKnownReturn::typeVoid); -BENCHMARK(ReflectedMethodCallKnownReturn::typeVoid); +BENCHMARK(RtlFunction_call::returnVoid); +BENCHMARK(RtlFunction_callMethod::returnVoid); -BENCHMARK(ReflectedCallUnknownReturn::typeVoid); -BENCHMARK(ReflectedMethodCallUnknownReturn::typeVoid); +BENCHMARK(RtlFunction_call_ReturnUnknown::typeVoid); +BENCHMARK(RtlFunctionCall_callMethod_ReturnUnknown::typeVoid); -BENCHMARK(NativeCall::returnTypeNonVoid); +BENCHMARK(NativeCall::returnNonVoid); -BENCHMARK(FunctionPointerCall::returnTypeNonVoid); -BENCHMARK(MethodFnPointerCall::returnTypeNonVoid); +BENCHMARK(NativeFunctionPtr_call::returnNonVoid); +BENCHMARK(NativeFunctionPtr_callMethod::returnNonVoid); -BENCHMARK(StdFunctionCall::returnTypeNonVoid); -BENCHMARK(StdFunctionMethodCall::returnTypeNonVoid); +BENCHMARK(StdFunction_call::returnNonVoid); +BENCHMARK(StdFunction_callMethod::returnNonVoid); -BENCHMARK(ReflectedCallKnownReturn::typeNonVoid); -BENCHMARK(ReflectedMethodCallKnownReturn::typeNonVoid); +BENCHMARK(RtlFunction_call::returnNonVoid); +BENCHMARK(RtlFunction_callMethod::returnNonVoid); -BENCHMARK(ReflectedCallUnknownReturn::typeNonVoid); -BENCHMARK(ReflectedMethodCallUnknownReturn::typeNonVoid); +BENCHMARK(RtlFunction_call_ReturnUnknown::typeNonVoid); +BENCHMARK(RtlFunctionCall_callMethod_ReturnUnknown::typeNonVoid); namespace bm { diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index ab007d71..f66e9a7d 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -153,7 +153,7 @@ namespace rtl::detail { template template - const Hopper<_recordType>::Build<_signature...> Hopper<_recordType>::argsT() const + const Hopper<_recordType>::template Build<_signature...> Hopper<_recordType>::argsT() const { for (auto& functorId : m_functorIds) { diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 807f69a6..38e46d0f 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -89,7 +89,7 @@ namespace rtl { Function& operator=(Function&&) = default; Function& operator=(const Function&) = default; - detail::Hopper<> getLambda(); + detail::Hopper<> lambda(); bool hasSignature() const; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index da8aec10..e4b3f3e1 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -23,7 +23,7 @@ namespace rtl } - inline detail::Hopper<> Function::getLambda() + inline detail::Hopper<> Function::lambda() { return detail::Hopper<>{ m_functorIds }; } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index a2762b40..18cf1ea3 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -57,7 +57,7 @@ namespace rtl { GETTER_BOOL(Const, (getQualifier() == detail::methodQ::Const)); template - constexpr detail::Hopper<_recordType> getLambda() const; + constexpr detail::Hopper<_recordType> lambda() const; //indicates if a particular set of arguments accepted by the functor associated with it. template diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 614d0bf3..91f7c56f 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -30,7 +30,7 @@ namespace rtl template - inline constexpr detail::Hopper<_recordType> Method::getLambda() const + inline constexpr detail::Hopper<_recordType> Method::lambda() const { return detail::Hopper<_recordType>{ getFunctorIds() }; } From e82728be3343f58e665b532099d3d7d6765b866d Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 23 Sep 2025 23:17:06 +0530 Subject: [PATCH 031/148] err fix: msvc, removed nested/dependent templates --- .../rtl/detail/inc/FunctionCaller.h | 23 ++++++++++--------- .../rtl/detail/inc/FunctionCaller.hpp | 8 ++++--- .../rtl/detail/inc/MethodInvoker.h | 20 ++++++++-------- .../rtl/detail/inc/MethodInvoker.hpp | 11 +++++---- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index b4063ce4..93b5bfbc 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -37,21 +37,22 @@ namespace rtl::detail namespace rtl::detail { - template<> - struct Hopper + template + struct HopFunction { - const std::vector& m_functorIds; + const dispatch::lambda_function<_signature...>* m_lambda = nullptr; - template - struct Build - { - const dispatch::lambda_function<_signature...>* m_lambda = nullptr; + template + constexpr const function<_returnType(_signature...)> returnT() const; + }; - template - constexpr const function<_returnType(_signature...)> returnT() const; - }; + + template<> + struct Hopper<> + { + const std::vector& m_functorIds; template - const Build<_signature...> argsT() const; + const HopFunction<_signature...> argsT() const; }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 428356b8..3d0079fd 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -46,7 +46,7 @@ namespace rtl::detail namespace rtl::detail { template - const Hopper::Build<_signature...> Hopper::argsT() const + const HopFunction<_signature...> Hopper<>::argsT() const { for (auto& functorId : m_functorIds) { @@ -54,13 +54,15 @@ namespace rtl::detail return { functorId.get_lambda_function<_signature...>() }; } } - return Build<_signature...>(); + return HopFunction<_signature...>(); } template template - inline constexpr const function<_returnType(_signature...)> Hopper::Build<_signature...>::returnT() const + inline constexpr + const function<_returnType(_signature...)> + HopFunction<_signature...>::returnT() const { if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { return m_lambda->template get_hopper<_returnType>(); diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 8f9d40bd..1c370da4 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -79,21 +79,21 @@ namespace rtl::detail { namespace rtl::detail { + template + struct HopMethod + { + const dispatch::lambda_method<_recordType, _signature...>* m_lambda = nullptr; + + template + constexpr const method<_returnType(_recordType::*)(_signature...)> returnT() const; + }; + template struct Hopper { const std::vector& m_functorIds; template - struct Build - { - const dispatch::lambda_method<_recordType, _signature...>* m_lambda = nullptr; - - template - constexpr const method<_returnType(_recordType::*)(_signature...)> returnT() const; - }; - - template - const Build<_signature...> argsT() const; + constexpr HopMethod<_recordType, _signature...> argsT() const; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index f66e9a7d..b83c1e97 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -153,7 +153,7 @@ namespace rtl::detail { template template - const Hopper<_recordType>::template Build<_signature...> Hopper<_recordType>::argsT() const + inline constexpr HopMethod<_recordType, _signature...> Hopper<_recordType>::argsT() const { for (auto& functorId : m_functorIds) { @@ -163,14 +163,15 @@ namespace rtl::detail return { functorId.get_lambda_method<_recordType, _signature...>() }; } } - return Build<_signature...>(); + return HopMethod<_recordType, _signature...>(); } - template - template + template template - inline constexpr const method<_returnType(_recordType::*)(_signature...)> Hopper<_recordType>::Build<_signature...>::returnT() const + inline constexpr + const method<_returnType(_recordType::*)(_signature...)> + HopMethod<_recordType, _signature...>::returnT() const { if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { return m_lambda->template get_hopper<_returnType>(); From 3a6ab51ae62d05f173d68c3c627c9319336e45ca Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 24 Sep 2025 01:16:52 +0530 Subject: [PATCH 032/148] specalized cache/method_ptr for const-member-functors. --- .../rtl/builder/SetupMethod.hpp | 12 ++++---- .../rtl/cache/cache_const_method_ptr.h | 30 ++++++++++--------- .../rtl/cache/cache_function_ptr.h | 4 +-- .../rtl/cache/cache_method_ptr.h | 12 ++++---- .../rtl/dispatch/const_method_ptr.h | 7 +++-- 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 0fdead0c..8d8f13a6 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -34,8 +34,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - // bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor().f_ptr()); - // assert(isFunctorGood && "new type-id-system not working."); + //bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor().f_ptr()); + //assert(isFunctorGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -57,8 +57,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - // bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor<_returnType>().f_ptr()); - // assert(isFunctorGood && "new type-id-system not working."); + //bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor<_returnType>().f_ptr()); + //assert(isFunctorGood && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -238,7 +238,7 @@ namespace rtl::detail const auto& updateIndex = [&](std::size_t pIndex)-> void { auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); - auto& functorCache = cache::const_method_ptr<_recordType, _returnType, _signature...>::instance(); + auto& functorCache = cache::method_ptr::instance(); auto& functor = functorCache.push(pFunctor, pIndex); auto& lambda = lambdaCache.push(functor); @@ -248,7 +248,7 @@ namespace rtl::detail const auto& getIndex = [&]()-> std::size_t { - auto& functorCache = cache::const_method_ptr<_recordType, _returnType, _signature...>::instance(); + auto& functorCache = cache::method_ptr::instance(); auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { diff --git a/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h index e4a8826b..3cc9783d 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h @@ -15,26 +15,28 @@ #include "const_method_ptr.h" -namespace rtl::cache +namespace rtl::cache { template - struct const_method_ptr + struct method_ptr { - using functor_t = dispatch::const_method_ptr; + using method_t = dispatch::method_ptr; - static const const_method_ptr& instance() + using functor_t = return_t(record_t::*)(signature_ts...) const; + + static const method_ptr& instance() { - static const const_method_ptr instance_; + static const method_ptr instance_; return instance_; } - const dispatch::functor& push(return_t(record_t::* fptr)(signature_ts...) const, std::size_t lambda_index) const + const dispatch::functor& push(functor_t fptr, std::size_t lambda_index) const { - m_cache.emplace_back(std::make_pair(fptr, lambda_index)); + m_cache.emplace_back(std::make_pair(method_t(fptr), lambda_index)); return m_cache.back().first; } - std::pair find(return_t(record_t::* fptr)(signature_ts...) const) const + std::pair find(functor_t fptr) const { for (auto& itr : m_cache) { @@ -46,16 +48,16 @@ namespace rtl::cache return { nullptr, rtl::index_none }; } - const_method_ptr(const_method_ptr&&) = delete; - const_method_ptr(const const_method_ptr&) = delete; - const_method_ptr& operator=(const_method_ptr&&) = delete; - const_method_ptr& operator=(const const_method_ptr&) = delete; + method_ptr(method_ptr&&) = delete; + method_ptr(const method_ptr&) = delete; + method_ptr& operator=(method_ptr&&) = delete; + method_ptr& operator=(const method_ptr&) = delete; private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; - const_method_ptr() = default; + method_ptr() = default; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index 8167b8fe..34c40f4b 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -20,7 +20,7 @@ namespace rtl::cache template struct function_ptr { - using functor_t = dispatch::function_ptr; + using function_t = dispatch::function_ptr; static const function_ptr& instance() { @@ -54,7 +54,7 @@ namespace rtl::cache private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; function_ptr() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h index a607f1e2..59ce1144 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h @@ -20,7 +20,9 @@ namespace rtl::cache template struct method_ptr { - using functor_t = dispatch::method_ptr; + using method_t = dispatch::method_ptr; + + using functor_t = return_t(record_t::*)(signature_ts...); static const method_ptr& instance() { @@ -28,13 +30,13 @@ namespace rtl::cache return instance_; } - const dispatch::functor& push(return_t(record_t::* fptr)(signature_ts...), std::size_t lambda_index) const + const dispatch::functor& push(functor_t fptr, std::size_t lambda_index) const { - m_cache.emplace_back(std::make_pair(fptr, lambda_index)); + m_cache.emplace_back(std::make_pair(method_t(fptr), lambda_index)); return m_cache.back().first; } - std::pair find(return_t(record_t::* fptr)(signature_ts...)) const + std::pair find(functor_t fptr) const { for (auto& itr : m_cache) { @@ -54,7 +56,7 @@ namespace rtl::cache private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; method_ptr() = default; }; diff --git a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h index e555d72f..0efabe53 100644 --- a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h @@ -18,11 +18,11 @@ namespace rtl::dispatch { template - struct const_method_ptr : public functor + struct method_ptr : public functor { using functor_t = return_t(record_t::*)(signature_ts...) const; - constexpr functor_t get() const + [[nodiscard]] constexpr auto f_ptr() const { return m_functor; } @@ -32,8 +32,9 @@ namespace rtl::dispatch return (fptr == m_functor); } - const_method_ptr(functor_t fptr) :m_functor(fptr) + method_ptr(functor_t fptr) :m_functor(fptr) { + m_recordId = detail::TypeId>::get(); m_returnId = detail::TypeId>::get(); m_signatureId = detail::TypeId...>>::get(); } From e1901e1217bb4d6de4c84c3a0a98c67e58241a68 Mon Sep 17 00:00:00 2001 From: neeraj Date: Wed, 24 Sep 2025 08:42:10 +0530 Subject: [PATCH 033/148] minor refactor. --- RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp | 4 ++-- RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h | 2 +- RTLBenchmarkApp/src/main.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index ab150e50..119e5eff 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -149,7 +149,7 @@ void RtlFunction_call_ReturnUnknown::typeNonVoid(benchmark::State& state) } -void RtlFunctionCall_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) +void RtlFunction_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) { static auto _ = _test1(); for (auto _ : state) @@ -159,7 +159,7 @@ void RtlFunctionCall_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) } -void RtlFunctionCall_callMethod_ReturnUnknown::typeNonVoid(benchmark::State& state) +void RtlFunction_callMethod_ReturnUnknown::typeNonVoid(benchmark::State& state) { static auto _ = _test3(); for (auto _ : state) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index 03a2dfd1..cc986820 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -10,7 +10,7 @@ struct RtlFunction_call_ReturnUnknown }; -struct RtlFunctionCall_callMethod_ReturnUnknown +struct RtlFunction_callMethod_ReturnUnknown { static void typeVoid(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index bde3f594..1c2c145d 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -18,7 +18,7 @@ BENCHMARK(RtlFunction_call::returnVoid); BENCHMARK(RtlFunction_callMethod::returnVoid); BENCHMARK(RtlFunction_call_ReturnUnknown::typeVoid); -BENCHMARK(RtlFunctionCall_callMethod_ReturnUnknown::typeVoid); +BENCHMARK(RtlFunction_callMethod_ReturnUnknown::typeVoid); BENCHMARK(NativeCall::returnNonVoid); @@ -32,7 +32,7 @@ BENCHMARK(RtlFunction_call::returnNonVoid); BENCHMARK(RtlFunction_callMethod::returnNonVoid); BENCHMARK(RtlFunction_call_ReturnUnknown::typeNonVoid); -BENCHMARK(RtlFunctionCall_callMethod_ReturnUnknown::typeNonVoid); +BENCHMARK(RtlFunction_callMethod_ReturnUnknown::typeNonVoid); namespace bm { From 046ad80c1ead8964f5d710db4b7550766cebe181 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 24 Sep 2025 14:41:21 +0530 Subject: [PATCH 034/148] enabled const-methods access from cache, tests:passing. --- .../src/ReflectedCallKnownReturn.cpp | 9 +-- .../rtl/builder/SetupFunction.hpp | 8 +-- .../rtl/builder/SetupMethod.hpp | 16 +++--- .../rtl/detail/inc/FunctionCaller.h | 4 +- .../rtl/detail/inc/FunctionCaller.hpp | 4 +- .../rtl/detail/inc/FunctorId.h | 4 +- .../rtl/dispatch/const_method_ptr.h | 7 ++- .../rtl/dispatch/function_ptr.h | 7 ++- ReflectionTemplateLib/rtl/dispatch/functor.h | 4 ++ ReflectionTemplateLib/rtl/dispatch/lambda.h | 6 +- .../rtl/dispatch/lambda_function.h | 2 +- .../rtl/dispatch/lambda_method.h | 55 ++++++++++++++++++- .../rtl/dispatch/method_ptr.h | 11 +++- ReflectionTemplateLib/rtl/inc/Function.h | 4 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 4 +- 15 files changed, 104 insertions(+), 41 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index f9fdf180..7dd43790 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -86,7 +86,7 @@ namespace template static bool test(const T& lambda, int callerId) { - if (!lambda.is_valid()) { + if (!lambda) { std::cerr << "[" << callerId << "] error: functor not valid, return-type or signature mismatch."; std::abort(); } @@ -132,11 +132,8 @@ void NativeFunctionPtr_callMethod::returnVoid(benchmark::State& state) static auto is_ok = test(getMessageNode, 2); for (auto _ : state) { - if (sendMessageNode.is_valid()) - { - (nodeObj.*sendMessageNode.f_ptr())(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); - } + (nodeObj.*sendMessageNode.f_ptr())(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 1677e692..a9e460cd 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -30,8 +30,8 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - // bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_function<_signature...>()->template get_functor().f_ptr()); - // assert(isFunctorGood && "new type-id-system not working."); + decltype(pFunctor) functor = pFunctorId.get_lambda_function<_signature...>()->template get_hopper().f_ptr(); + assert((functor == pFunctor) && "new type-id-system not working."); pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -48,8 +48,8 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { - // bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_function<_signature...>()->template get_functor<_returnType>().f_ptr()); - // assert(isFunctorGood && "new type-id-system not working."); + decltype(pFunctor) functor = pFunctorId.get_lambda_function<_signature...>()->template get_hopper<_returnType>().f_ptr(); + assert((functor == pFunctor) && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 8d8f13a6..793ff705 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -34,8 +34,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - //bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor().f_ptr()); - //assert(isFunctorGood && "new type-id-system not working."); + auto functor = pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_hopper().f_ptr(); + assert((functor == pFunctor) && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -57,8 +57,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - //bool isFunctorGood = (pFunctor == pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_functor<_returnType>().f_ptr()); - //assert(isFunctorGood && "new type-id-system not working."); + decltype(pFunctor) functor = pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_hopper<_returnType>().f_ptr(); + assert((functor == pFunctor) && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -101,8 +101,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - // bool isLambdaGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->get_functor().get_lambda()); - // assert(isLambdaGood && "new type-id-system not working."); + decltype(pFunctor) functor = pFunctorId.get_lambda_method()->template get_hopper().f_ptr(); + assert(pFunctor == functor && "new type-id-system not working."); const _recordType& target = pTargetObj.view<_recordType>()->get(); (target.*pFunctor)(std::forward<_signature>(params)...); @@ -120,8 +120,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - // bool isLambdaGood = (pFunctorId.m_lambda == pFunctorId.m_lambda->get_functor().get_lambda()); - // assert(isLambdaGood && "new type-id-system not working."); + decltype(pFunctor) functor = pFunctorId.get_lambda_method()->template get_hopper<_returnType>().f_ptr(); + assert(pFunctor == functor && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); //'target' is const and 'pFunctor' is const-member-function. diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 93b5bfbc..953cb600 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -53,6 +53,6 @@ namespace rtl::detail const std::vector& m_functorIds; template - const HopFunction<_signature...> argsT() const; + constexpr const HopFunction<_signature...> argsT() const; }; -} +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 3d0079fd..c0503298 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -46,7 +46,7 @@ namespace rtl::detail namespace rtl::detail { template - const HopFunction<_signature...> Hopper<>::argsT() const + inline constexpr const HopFunction<_signature...> Hopper<>::argsT() const { for (auto& functorId : m_functorIds) { @@ -64,7 +64,7 @@ namespace rtl::detail const function<_returnType(_signature...)> HopFunction<_signature...>::returnT() const { - if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { + if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) [[likely]] { return m_lambda->template get_hopper<_returnType>(); } return function<_returnType(_signature...)>(); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index bd919b1a..0f26862f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -81,13 +81,13 @@ namespace rtl::detail } template - const dispatch::lambda_function<_signature...>* get_lambda_function() const + constexpr const dispatch::lambda_function<_signature...>* get_lambda_function() const { return m_lambda->to_function<_signature...>(); } template - const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method() const + constexpr const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method() const { return m_lambda->to_method<_recordType, _signature...>(); } diff --git a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h index 0efabe53..d229e29d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h @@ -34,9 +34,14 @@ namespace rtl::dispatch method_ptr(functor_t fptr) :m_functor(fptr) { - m_recordId = detail::TypeId>::get(); + m_qualifier = detail::methodQ::Const; + m_recordId = detail::TypeId::get(); m_returnId = detail::TypeId>::get(); m_signatureId = detail::TypeId...>>::get(); + + m_returnStr = detail::TypeId::toString(); + m_recordStr = detail::TypeId::toString(); + m_signatureStr = detail::TypeId::toString(); } private: diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index 7de9df89..0ce1b59c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -32,12 +32,15 @@ namespace rtl::dispatch function_ptr(functor_t fptr) :m_functor(fptr) { - m_returnId = detail::TypeId>::get(); + m_returnId = detail::TypeId::get(); m_signatureId = detail::TypeId...>>::get(); + + m_returnStr = detail::TypeId::toString(); + m_signatureStr = detail::TypeId::toString(); } private: - const functor_t m_functor; + functor_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 06a6a9ce..c071582d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -23,6 +23,10 @@ namespace rtl::dispatch std::size_t m_returnId = detail::TypeId<>::None; std::size_t m_signatureId = detail::TypeId<>::None; + std::string m_recordStr; + std::string m_returnStr; + std::string m_signatureStr; + std::vector m_argumentsId = {}; detail::methodQ m_qualifier = detail::methodQ::None; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 36a3ef0c..c3f4b1d1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -51,7 +51,7 @@ namespace rtl::dispatch template constexpr bool is_returning() const { - return (m_functor.m_returnId == detail::TypeId>::get()); + return (m_functor.m_returnId == detail::TypeId::get()); } template @@ -63,8 +63,8 @@ namespace rtl::dispatch template constexpr bool is_member() const { - return (m_functor.m_recordId == detail::TypeId>::get() || - m_functor.m_recordId == detail::TypeId>::get()); + return (m_functor.m_recordId == detail::TypeId::get() || + m_functor.m_recordId == detail::TypeId::get()); } friend detail::FunctorId; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 98424128..7b87a3fb 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -27,7 +27,7 @@ namespace rtl return m_functor; } - constexpr auto is_valid() const { + constexpr operator bool() const { return (m_functor != nullptr); } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 6d771717..766ca007 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -14,7 +14,6 @@ #include "lambda.h" #include "method_ptr.h" - namespace rtl { template @@ -28,7 +27,7 @@ namespace rtl return m_functor; } - constexpr auto is_valid() const { + constexpr operator bool() const { return (m_functor != nullptr); } @@ -50,6 +49,41 @@ namespace rtl } +namespace rtl +{ + template + struct method + { + using fptr_t = return_t(record_t::*)(signature_ts...) const; + + const fptr_t m_functor = nullptr; + + constexpr auto f_ptr() const { + return m_functor; + } + + constexpr operator bool() const { + return (m_functor != nullptr); + } + + template + [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) + { + static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + return (target.*m_functor)(std::forward(params)...); + } + + private: + + template + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; + + template + static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); + }; +} + + namespace rtl::dispatch { template @@ -58,11 +92,14 @@ namespace rtl::dispatch template using hopper_t = method; + template + using hopper_ct = method; + lambda_method(const functor& p_functor) noexcept :lambda(p_functor) { } - template + template requires (std::is_const_v == false) constexpr const hopper_t get_hopper() const { if (m_functor.m_returnId == detail::TypeId::get()) @@ -73,5 +110,17 @@ namespace rtl::dispatch } return hopper_t(); } + + template requires (std::is_const_v == true) + constexpr const hopper_ct get_hopper() const + { + if (m_functor.m_returnId == detail::TypeId::get()) + { + return hopper_ct { + static_cast&>(m_functor).f_ptr() + }; + } + return hopper_ct(); + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 60ae79fb..479e3ba5 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -34,13 +34,18 @@ namespace rtl::dispatch method_ptr(functor_t fptr) :m_functor(fptr) { - m_recordId = detail::TypeId>::get(); - m_returnId = detail::TypeId>::get(); + m_qualifier = detail::methodQ::NonConst; + m_recordId = detail::TypeId::get(); + m_returnId = detail::TypeId::get(); m_signatureId = detail::TypeId...>>::get(); + + m_returnStr = detail::TypeId::toString(); + m_recordStr = detail::TypeId::toString(); + m_signatureStr = detail::TypeId::toString(); } private: - const functor_t m_functor; + functor_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 38e46d0f..3bdab774 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -89,7 +89,7 @@ namespace rtl { Function& operator=(Function&&) = default; Function& operator=(const Function&) = default; - detail::Hopper<> lambda(); + constexpr detail::Hopper<> lambda() const; bool hasSignature() const; @@ -100,7 +100,7 @@ namespace rtl { Return operator()(_args&&...params) const noexcept; template - const detail::FunctionCaller<_signature...> bind() const noexcept; + constexpr const detail::FunctionCaller<_signature...> bind() const noexcept; friend detail::CxxReflection; friend detail::ReflectionBuilder; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index e4b3f3e1..a102d50b 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -17,13 +17,13 @@ namespace rtl { template - inline const detail::FunctionCaller<_signature...> Function::bind() const noexcept + inline constexpr const detail::FunctionCaller<_signature...> Function::bind() const noexcept { return detail::FunctionCaller<_signature...>{ this }; } - inline detail::Hopper<> Function::lambda() + inline constexpr detail::Hopper<> Function::lambda() const { return detail::Hopper<>{ m_functorIds }; } From 5099da50be54e2ef7c26f43299f959036317cc30 Mon Sep 17 00:00:00 2001 From: neeraj Date: Wed, 24 Sep 2025 15:29:54 +0530 Subject: [PATCH 035/148] minor refactor. --- ReflectionTemplateLib/rtl/CMakeLists.txt | 1 + ReflectionTemplateLib/rtl/builder/SetupConstructor.h | 2 +- ReflectionTemplateLib/rtl/builder/SetupFunction.h | 2 +- ReflectionTemplateLib/rtl/builder/SetupMethod.h | 2 +- ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt | 1 - ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h | 2 +- ReflectionTemplateLib/rtl/detail/inc/FunctorId.h | 2 +- ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h | 2 +- ReflectionTemplateLib/rtl/detail/inc/RObjectId.h | 2 +- ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h | 2 +- ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h | 2 +- ReflectionTemplateLib/rtl/dispatch/functor.h | 2 +- ReflectionTemplateLib/rtl/inc/RObject.h | 2 +- .../rtl/{detail/inc/forward_decls.h => rtl_forward_decls.h} | 0 ReflectionTemplateLib/rtl/rtl_traits.h | 2 +- 15 files changed, 13 insertions(+), 13 deletions(-) rename ReflectionTemplateLib/rtl/{detail/inc/forward_decls.h => rtl_forward_decls.h} (100%) diff --git a/ReflectionTemplateLib/rtl/CMakeLists.txt b/ReflectionTemplateLib/rtl/CMakeLists.txt index 0f97298d..dd7b3895 100644 --- a/ReflectionTemplateLib/rtl/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/CMakeLists.txt @@ -3,6 +3,7 @@ # Top-level headers in rtl/ (absolute paths) set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/rtl.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_forward_decls.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_constants.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_errors.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_traits.h" diff --git a/ReflectionTemplateLib/rtl/builder/SetupConstructor.h b/ReflectionTemplateLib/rtl/builder/SetupConstructor.h index 6dfc38b2..ee41ec5b 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupConstructor.h +++ b/ReflectionTemplateLib/rtl/builder/SetupConstructor.h @@ -13,7 +13,7 @@ #include "FunctorId.h" -#include "forward_decls.h" +#include "rtl_forward_decls.h" namespace rtl { diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.h b/ReflectionTemplateLib/rtl/builder/SetupFunction.h index bdcad635..33dee711 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.h +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.h @@ -11,7 +11,7 @@ #pragma once -#include "forward_decls.h" +#include "rtl_forward_decls.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.h b/ReflectionTemplateLib/rtl/builder/SetupMethod.h index 768bcff4..7e2dc220 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.h +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.h @@ -11,7 +11,7 @@ #pragma once -#include "forward_decls.h" +#include "rtl_forward_decls.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt b/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt index ff6e9609..a4020ede 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt @@ -4,7 +4,6 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/ConversionUtils.h" "${CMAKE_CURRENT_SOURCE_DIR}/CxxReflection.h" - "${CMAKE_CURRENT_SOURCE_DIR}/forward_decls.h" "${CMAKE_CURRENT_SOURCE_DIR}/FunctorId.h" "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.h" "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.hpp" diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 953cb600..957c8c00 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -11,7 +11,7 @@ #pragma once -#include "forward_decls.h" +#include "rtl_forward_decls.h" #include "RObject.h" diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 0f26862f..5db78d47 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -13,7 +13,7 @@ #include "rtl_typeid.h" #include "rtl_constants.h" -#include "forward_decls.h" +#include "rtl_forward_decls.h" #include "lambda_method.h" #include "lambda_function.h" diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 1c370da4..38ba7f74 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -11,7 +11,7 @@ #pragma once -#include "forward_decls.h" +#include "rtl_forward_decls.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h index 403e9b96..cab52049 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h @@ -16,7 +16,7 @@ #include #include "ReflectCast.h" -#include "forward_decls.h" +#include "rtl_forward_decls.h" #include "FunctorId.h" namespace rtl::detail diff --git a/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h index 1e3fc638..104d1142 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h +++ b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h @@ -16,7 +16,7 @@ #include #include "rtl_traits.h" -#include "forward_decls.h" +#include "rtl_forward_decls.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h index d229e29d..002c7794 100644 --- a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h @@ -36,7 +36,7 @@ namespace rtl::dispatch { m_qualifier = detail::methodQ::Const; m_recordId = detail::TypeId::get(); - m_returnId = detail::TypeId>::get(); + m_returnId = detail::TypeId::get(); m_signatureId = detail::TypeId...>>::get(); m_returnStr = detail::TypeId::toString(); diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index c071582d..06ee12a6 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -13,7 +13,7 @@ #include "rtl_typeid.h" #include "rtl_constants.h" -#include "forward_decls.h" +#include "rtl_forward_decls.h" namespace rtl::dispatch { diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index 3705c3a7..4e89d6f7 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -18,7 +18,7 @@ #include "rtl_traits.h" #include "rtl_errors.h" -#include "forward_decls.h" +#include "rtl_forward_decls.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/detail/inc/forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h similarity index 100% rename from ReflectionTemplateLib/rtl/detail/inc/forward_decls.h rename to ReflectionTemplateLib/rtl/rtl_forward_decls.h diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index 84f4d631..0bef3cda 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -19,7 +19,7 @@ #include "rtl_typeid.h" #include "rtl_constants.h" -#include "forward_decls.h" +#include "rtl_forward_decls.h" namespace rtl { From 24f9fa2a181f802cd87900cc03c45b881c022a73 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 24 Sep 2025 21:17:30 +0530 Subject: [PATCH 036/148] interface refined. wip. --- .../rtl/builder/SetupFunction.hpp | 22 ++++++-- .../rtl/builder/SetupMethod.hpp | 50 +++++++++++++++---- .../rtl/detail/inc/FunctionCaller.hpp | 11 ++-- .../rtl/detail/inc/FunctorId.h | 10 ++-- .../rtl/detail/inc/MethodInvoker.hpp | 15 +++--- ReflectionTemplateLib/rtl/dispatch/functor.h | 4 +- ReflectionTemplateLib/rtl/dispatch/lambda.h | 20 +++++--- .../rtl/dispatch/lambda_function.h | 11 ++-- .../rtl/dispatch/lambda_method.h | 14 +++--- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 2 +- 10 files changed, 108 insertions(+), 51 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index a9e460cd..2af99d2a 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -30,8 +30,14 @@ namespace rtl { return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return { - decltype(pFunctor) functor = pFunctorId.get_lambda_function<_signature...>()->template get_hopper().f_ptr(); - assert((functor == pFunctor) && "new type-id-system not working."); + auto retId = TypeId::get(); + auto argsId = TypeId...>>::get(); + + decltype(pFunctor) functor = pFunctorId.get_lambda_function<_signature...>(argsId) + ->template get_hopper(retId) + .f_ptr(); + + //assert((functor == pFunctor) && "new type-id-system not working."); pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -48,8 +54,14 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return { - decltype(pFunctor) functor = pFunctorId.get_lambda_function<_signature...>()->template get_hopper<_returnType>().f_ptr(); - assert((functor == pFunctor) && "new type-id-system not working."); + auto retId = TypeId<_returnType>::get(); + auto argsId = TypeId...>>::get(); + + decltype(pFunctor) functor = pFunctorId.get_lambda_function<_signature...>(argsId) + ->template get_hopper<_returnType>(retId) + .f_ptr(); + + //assert((functor == pFunctor) && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); @@ -89,7 +101,7 @@ namespace rtl template inline const detail::FunctorId SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) { - const dispatch::lambda* lambdaPtr = nullptr; + const dispatch::lambda_base* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 793ff705..fc42cb20 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -34,8 +34,15 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - auto functor = pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_hopper().f_ptr(); - assert((functor == pFunctor) && "new type-id-system not working."); + auto recId = TypeId<_recordType>::get(); + auto returnId = TypeId::get(); + auto argsId = TypeId...>>::get(); + + auto functor = pFunctorId.get_lambda_method<_recordType, _signature...>(recId, argsId) + ->template get_hopper(returnId) + .f_ptr(); + + //assert((functor == pFunctor) && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -57,8 +64,16 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - decltype(pFunctor) functor = pFunctorId.get_lambda_method<_recordType, _signature...>()->template get_hopper<_returnType>().f_ptr(); - assert((functor == pFunctor) && "new type-id-system not working."); + + auto recId = TypeId<_recordType>::get(); + auto returnId = TypeId<_returnType>::get(); + auto argsId = TypeId...>>::get(); + + decltype(pFunctor) functor = pFunctorId.get_lambda_method<_recordType, _signature...>(recId, argsId) + ->template get_hopper<_returnType>(returnId) + .f_ptr(); + + //assert((functor == pFunctor) && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -101,8 +116,15 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - decltype(pFunctor) functor = pFunctorId.get_lambda_method()->template get_hopper().f_ptr(); - assert(pFunctor == functor && "new type-id-system not working."); + auto recId = TypeId::get(); + auto returnId = TypeId::get(); + auto argsId = TypeId...>>::get(); + + decltype(pFunctor) functor = pFunctorId.get_lambda_method(recId, argsId) + ->template get_hopper(returnId) + .f_ptr(); + + //assert(pFunctor == functor && "new type-id-system not working."); const _recordType& target = pTargetObj.view<_recordType>()->get(); (target.*pFunctor)(std::forward<_signature>(params)...); @@ -120,8 +142,16 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - decltype(pFunctor) functor = pFunctorId.get_lambda_method()->template get_hopper<_returnType>().f_ptr(); - assert(pFunctor == functor && "new type-id-system not working."); + + auto recId = TypeId::get(); + auto returnId = TypeId::get(); + auto argsId = TypeId...>>::get(); + + decltype(pFunctor) functor = pFunctorId.get_lambda_method(recId, argsId) + ->template get_hopper<_returnType>(returnId) + .f_ptr(); + + //assert(pFunctor == functor && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); //'target' is const and 'pFunctor' is const-member-function. @@ -163,7 +193,7 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { - const dispatch::lambda* lambdaPtr = nullptr; + const dispatch::lambda_base* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); @@ -234,7 +264,7 @@ namespace rtl::detail template inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) { - const dispatch::lambda* lambdaPtr = nullptr; + const dispatch::lambda_base* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index c0503298..eab66974 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -48,10 +48,12 @@ namespace rtl::detail template inline constexpr const HopFunction<_signature...> Hopper<>::argsT() const { + const auto argsId = TypeId>>::get(); for (auto& functorId : m_functorIds) { - if (functorId.m_lambda->is_signature<_signature...>()) [[likely]] { - return { functorId.get_lambda_function<_signature...>() }; + auto lambda = functorId.get_lambda_function<_signature...>(argsId); + if (lambda != nullptr) { + return { lambda }; } } return HopFunction<_signature...>(); @@ -64,8 +66,9 @@ namespace rtl::detail const function<_returnType(_signature...)> HopFunction<_signature...>::returnT() const { - if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) [[likely]] { - return m_lambda->template get_hopper<_returnType>(); + const auto retId = TypeId::get(); + if (m_lambda != nullptr) [[likely]] { + return m_lambda->template get_hopper<_returnType>(retId); } return function<_returnType(_signature...)>(); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 5db78d47..b0c19c5c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -44,7 +44,7 @@ namespace rtl::detail //signature of functor as string. platform dependent, may not be very much readable format. std::string m_signature; - const dispatch::lambda* m_lambda = nullptr; + const dispatch::lambda_base* m_lambda = nullptr; GETTER(std::size_t, LambdaIndex, m_lambdaIndex) GETTER(std::size_t, ReturnId, m_returnId); @@ -81,15 +81,15 @@ namespace rtl::detail } template - constexpr const dispatch::lambda_function<_signature...>* get_lambda_function() const + constexpr const dispatch::lambda_function<_signature...>* get_lambda_function(std::size_t p_argsId) const { - return m_lambda->to_function<_signature...>(); + return m_lambda->to_function<_signature...>(p_argsId); } template - constexpr const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method() const + constexpr const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method(std::size_t p_recordId, std::size_t p_argsId) const { - return m_lambda->to_method<_recordType, _signature...>(); + return m_lambda->to_method<_recordType, _signature...>(p_recordId, p_argsId); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index b83c1e97..5c09bf9c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -155,12 +155,13 @@ namespace rtl::detail template inline constexpr HopMethod<_recordType, _signature...> Hopper<_recordType>::argsT() const { + const auto recId = TypeId<_recordType>::get(); + const auto argsId = TypeId>>::get(); for (auto& functorId : m_functorIds) { - if (functorId.m_lambda->is_member<_recordType>() && - functorId.m_lambda->is_signature<_signature...>()) [[likely]] - { - return { functorId.get_lambda_method<_recordType, _signature...>() }; + auto lambda = functorId.get_lambda_method<_recordType, _signature...>(recId, argsId); + if (lambda != nullptr) { + return { lambda }; } } return HopMethod<_recordType, _signature...>(); @@ -173,8 +174,10 @@ namespace rtl::detail const method<_returnType(_recordType::*)(_signature...)> HopMethod<_recordType, _signature...>::returnT() const { - if (m_lambda != nullptr && m_lambda->template is_returning<_returnType>()) { - return m_lambda->template get_hopper<_returnType>(); + if (m_lambda != nullptr) + { + const auto retId = TypeId::get(); + return m_lambda->template get_hopper<_returnType>(retId); } return method<_returnType(_recordType::*)(_signature...)>(); } diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 06ee12a6..312bb974 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -31,11 +31,11 @@ namespace rtl::dispatch detail::methodQ m_qualifier = detail::methodQ::None; - GETTER_CPTR(lambda, _lambda, m_lambda) + GETTER_CPTR(lambda_base, _lambda, m_lambda) private: - mutable const lambda* m_lambda = nullptr; + mutable const lambda_base* m_lambda = nullptr; template friend struct cache::lambda_function; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index c3f4b1d1..16e063f1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -16,13 +16,13 @@ namespace rtl::dispatch { - struct lambda + struct lambda_base { protected: const functor& m_functor; - lambda(const functor& p_functor) noexcept + lambda_base(const functor& p_functor) noexcept :m_functor(p_functor) { } @@ -33,15 +33,23 @@ namespace rtl::dispatch using method_t = lambda_method; template - constexpr const function_t* to_function() const + constexpr const function_t* to_function(std::size_t p_argsId) const { - return static_cast*>(this); + if (p_argsId == m_functor.m_signatureId) [[likely]] + { + return static_cast*>(this); + } + else return nullptr; } template - constexpr const method_t* to_method() const + constexpr const method_t* to_method(std::size_t p_recordId, std::size_t p_argsId) const { - return static_cast*>(this); + if (p_recordId == m_functor.m_recordId && p_argsId == m_functor.m_signatureId) [[likely]] + { + return static_cast*>(this); + } + else return nullptr; } public: diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 7b87a3fb..798d4340 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -38,7 +38,6 @@ namespace rtl return (*m_functor)(std::forward(params)...); } - private: template @@ -52,21 +51,21 @@ namespace rtl namespace rtl::dispatch { template - struct lambda_function: public lambda + struct lambda_function: public lambda_base { template using hopper_t = function; lambda_function(const functor& p_functor) noexcept - :lambda(p_functor) + :lambda_base(p_functor) { } template - constexpr const hopper_t get_hopper() const + constexpr const hopper_t get_hopper(const std::size_t p_returnId) const { - if (m_functor.m_returnId == detail::TypeId::get()) + if (p_returnId == m_functor.m_returnId) [[likely]] { - return hopper_t { + return hopper_t { static_cast&>(m_functor).f_ptr() }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 766ca007..89619e55 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -87,7 +87,7 @@ namespace rtl namespace rtl::dispatch { template - struct lambda_method : public lambda + struct lambda_method : public lambda_base { template using hopper_t = method; @@ -96,13 +96,14 @@ namespace rtl::dispatch using hopper_ct = method; lambda_method(const functor& p_functor) noexcept - :lambda(p_functor) + :lambda_base(p_functor) { } + template requires (std::is_const_v == false) - constexpr const hopper_t get_hopper() const + constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { - if (m_functor.m_returnId == detail::TypeId::get()) + if (p_returnId == m_functor.m_returnId) [[likely]] { return hopper_t { static_cast&>(m_functor).f_ptr() @@ -111,10 +112,11 @@ namespace rtl::dispatch return hopper_t(); } + template requires (std::is_const_v == true) - constexpr const hopper_ct get_hopper() const + constexpr const hopper_ct get_hopper(std::size_t p_returnId) const { - if (m_functor.m_returnId == detail::TypeId::get()) + if (p_returnId == m_functor.m_returnId) [[likely]] { return hopper_ct { static_cast&>(m_functor).f_ptr() diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 70420b2f..84ff5eea 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -58,7 +58,7 @@ namespace rtl { struct functor; - struct lambda; + struct lambda_base; template struct lambda_function; From 0fb9e1f72e22e012181f5093010dca2dabef3c09 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 24 Sep 2025 17:39:51 +0000 Subject: [PATCH 037/148] fixed error and hardcoded-type bug. --- ReflectionTemplateLib/rtl/builder/SetupFunction.hpp | 4 ++-- ReflectionTemplateLib/rtl/builder/SetupMethod.hpp | 4 ++-- ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp | 4 ++-- ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 2af99d2a..cd9357d1 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -37,7 +37,7 @@ namespace rtl ->template get_hopper(retId) .f_ptr(); - //assert((functor == pFunctor) && "new type-id-system not working."); + assert((functor == pFunctor) && "new type-id-system not working."); pFunctor(std::forward<_signature>(params)...); return { error::None, RObject{} }; @@ -61,7 +61,7 @@ namespace rtl ->template get_hopper<_returnType>(retId) .f_ptr(); - //assert((functor == pFunctor) && "new type-id-system not working."); + assert((functor == pFunctor) && "new type-id-system not working."); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index fc42cb20..e02a5b05 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -42,7 +42,7 @@ namespace rtl::detail ->template get_hopper(returnId) .f_ptr(); - //assert((functor == pFunctor) && "new type-id-system not working."); + assert((functor == pFunctor) && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -73,7 +73,7 @@ namespace rtl::detail ->template get_hopper<_returnType>(returnId) .f_ptr(); - //assert((functor == pFunctor) && "new type-id-system not working."); + assert((functor == pFunctor) && "new type-id-system not working."); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index eab66974..0bebaf34 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -48,7 +48,7 @@ namespace rtl::detail template inline constexpr const HopFunction<_signature...> Hopper<>::argsT() const { - const auto argsId = TypeId>>::get(); + const auto argsId = TypeId... >>::get(); for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_function<_signature...>(argsId); @@ -66,7 +66,7 @@ namespace rtl::detail const function<_returnType(_signature...)> HopFunction<_signature...>::returnT() const { - const auto retId = TypeId::get(); + const auto retId = TypeId<_returnType>::get(); if (m_lambda != nullptr) [[likely]] { return m_lambda->template get_hopper<_returnType>(retId); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 5c09bf9c..348f7530 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -156,7 +156,7 @@ namespace rtl::detail inline constexpr HopMethod<_recordType, _signature...> Hopper<_recordType>::argsT() const { const auto recId = TypeId<_recordType>::get(); - const auto argsId = TypeId>>::get(); + const auto argsId = TypeId...>>::get(); for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_method<_recordType, _signature...>(recId, argsId); @@ -176,7 +176,7 @@ namespace rtl::detail { if (m_lambda != nullptr) { - const auto retId = TypeId::get(); + const auto retId = TypeId<_returnType>::get(); return m_lambda->template get_hopper<_returnType>(retId); } return method<_returnType(_recordType::*)(_signature...)>(); From bf495e1d3b004f0a81bef0a24ed8c507121060d6 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 24 Sep 2025 20:18:41 +0000 Subject: [PATCH 038/148] type erasing lambdas are stateless now. --- .../rtl/builder/SetupFunction.hpp | 36 ++++----- .../rtl/builder/SetupMethod.hpp | 74 +++++++------------ ReflectionTemplateLib/rtl/dispatch/lambda.h | 4 +- 3 files changed, 42 insertions(+), 72 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index cd9357d1..d18fc575 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -28,18 +28,14 @@ namespace rtl inline SetupFunction<_derivedType>::FunctionLambda<_signature...> SetupFunction<_derivedType>::getCaller(void(*pFunctor)(_signature...)) { - return [pFunctor](const FunctorId& pFunctorId, _signature&&... params) -> Return + return [](const FunctorId& pFunctorId, _signature&&... params) -> Return { - auto retId = TypeId::get(); - auto argsId = TypeId...>>::get(); - - decltype(pFunctor) functor = pFunctorId.get_lambda_function<_signature...>(argsId) - ->template get_hopper(retId) - .f_ptr(); - - assert((functor == pFunctor) && "new type-id-system not working."); - - pFunctor(std::forward<_signature>(params)...); + auto& functorId = pFunctorId.m_lambda->m_functor; + auto fptr = pFunctorId.get_lambda_function<_signature...>(functorId.m_signatureId) + ->template get_hopper(functorId.m_returnId) + .f_ptr(); + + fptr(std::forward<_signature>(params)...); return { error::None, RObject{} }; }; } @@ -52,16 +48,12 @@ namespace rtl { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (FunctorContainer) vector holding lambda's. - */ return [pFunctor](const FunctorId& pFunctorId, _signature&&...params)-> Return + */ return [](const FunctorId& pFunctorId, _signature&&...params)-> Return { - auto retId = TypeId<_returnType>::get(); - auto argsId = TypeId...>>::get(); - - decltype(pFunctor) functor = pFunctorId.get_lambda_function<_signature...>(argsId) - ->template get_hopper<_returnType>(retId) - .f_ptr(); - - assert((functor == pFunctor) && "new type-id-system not working."); + auto& functorId = pFunctorId.m_lambda->m_functor; + auto fptr = pFunctorId.get_lambda_function<_signature...>(functorId.m_signatureId) + ->template get_hopper<_returnType>(functorId.m_returnId) + .f_ptr(); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); @@ -69,7 +61,7 @@ namespace rtl /* if the function returns reference, this block will be retained by compiler. Note: reference to temporary or dangling is not checked here. */ using _rawRetType = traits::raw_t<_returnType>; - const _rawRetType& retObj = pFunctor(std::forward<_signature>(params)...); + const _rawRetType& retObj = fptr(std::forward<_signature>(params)...); return { error::None, RObjectBuilder::template build(&retObj, std::nullopt, isConstCastSafe) @@ -77,7 +69,7 @@ namespace rtl } else { //if the function returns anything (not refrence), this block will be retained by compiler. - auto&& retObj = pFunctor(std::forward<_signature>(params)...); + auto&& retObj = fptr(std::forward<_signature>(params)...); using T = std::remove_cvref_t; return { error::None, diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index e02a5b05..dbadadaf 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -32,24 +32,19 @@ namespace rtl::detail { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return + */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - auto recId = TypeId<_recordType>::get(); - auto returnId = TypeId::get(); - auto argsId = TypeId...>>::get(); - - auto functor = pFunctorId.get_lambda_method<_recordType, _signature...>(recId, argsId) - ->template get_hopper(returnId) - .f_ptr(); - - assert((functor == pFunctor) && "new type-id-system not working."); + auto& functorId = pFunctorId.m_lambda->m_functor; + auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>(functorId.m_recordId, functorId.m_signatureId) + ->template get_hopper(functorId.m_returnId) + .f_ptr(); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; } _recordType& target = const_cast<_recordType&>(pTargetObj.view<_recordType>()->get()); - (target.*pFunctor)(std::forward<_signature>(params)...); + (target.*fptr)(std::forward<_signature>(params)...); return { error::None, RObject{} }; }; } @@ -62,18 +57,12 @@ namespace rtl::detail { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return + */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - - auto recId = TypeId<_recordType>::get(); - auto returnId = TypeId<_returnType>::get(); - auto argsId = TypeId...>>::get(); - - decltype(pFunctor) functor = pFunctorId.get_lambda_method<_recordType, _signature...>(recId, argsId) - ->template get_hopper<_returnType>(returnId) - .f_ptr(); - - assert((functor == pFunctor) && "new type-id-system not working."); + auto& functorId = pFunctorId.m_lambda->m_functor; + auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>(functorId.m_recordId, functorId.m_signatureId) + ->template get_hopper<_returnType>(functorId.m_returnId) + .f_ptr(); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { return { error::IllegalConstCast, RObject{} }; @@ -87,7 +76,7 @@ namespace rtl::detail /* if the function returns reference, this block will be retained by compiler. Note: reference to temporary or dangling is not checked here. */ using _rawRetType = traits::raw_t<_returnType>; - const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + const _rawRetType& retObj = (target.*fptr)(std::forward<_signature>(params)...); return { error::None, RObjectBuilder::template build(&retObj, std::nullopt, isConstCastSafe) @@ -95,7 +84,7 @@ namespace rtl::detail } else { - auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + auto&& retObj = (target.*fptr)(std::forward<_signature>(params)...); using T = std::remove_cvref_t; return { error::None, @@ -114,20 +103,15 @@ namespace rtl::detail { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return + */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - auto recId = TypeId::get(); - auto returnId = TypeId::get(); - auto argsId = TypeId...>>::get(); - - decltype(pFunctor) functor = pFunctorId.get_lambda_method(recId, argsId) - ->template get_hopper(returnId) - .f_ptr(); - - //assert(pFunctor == functor && "new type-id-system not working."); + auto& functorId = pFunctorId.m_lambda->m_functor; + auto fptr = pFunctorId.get_lambda_method(functorId.m_recordId, functorId.m_signatureId) + ->template get_hopper(functorId.m_returnId) + .f_ptr(); const _recordType& target = pTargetObj.view<_recordType>()->get(); - (target.*pFunctor)(std::forward<_signature>(params)...); + (target.*fptr)(std::forward<_signature>(params)...); return { error::None, RObject{} }; }; } @@ -140,18 +124,12 @@ namespace rtl::detail { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. - */ return [pFunctor](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return + */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - - auto recId = TypeId::get(); - auto returnId = TypeId::get(); - auto argsId = TypeId...>>::get(); - - decltype(pFunctor) functor = pFunctorId.get_lambda_method(recId, argsId) - ->template get_hopper<_returnType>(returnId) - .f_ptr(); - - //assert(pFunctor == functor && "new type-id-system not working."); + auto& functorId = pFunctorId.m_lambda->m_functor; + auto fptr = pFunctorId.get_lambda_method(functorId.m_recordId, functorId.m_signatureId) + ->template get_hopper<_returnType>(functorId.m_returnId) + .f_ptr(); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); //'target' is const and 'pFunctor' is const-member-function. @@ -160,7 +138,7 @@ namespace rtl::detail /* if the function returns reference, this block will be retained by compiler. Note: reference to temporary or dangling is not checked here. */ using _rawRetType = traits::raw_t<_returnType>; - const _rawRetType& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + const _rawRetType& retObj = (target.*fptr)(std::forward<_signature>(params)...); return { error::None, RObjectBuilder::template build(&retObj, std::nullopt, isConstCastSafe) @@ -168,7 +146,7 @@ namespace rtl::detail } else { - auto&& retObj = (target.*pFunctor)(std::forward<_signature>(params)...); + auto&& retObj = (target.*fptr)(std::forward<_signature>(params)...); using T = std::remove_cvref_t; return { error::None, diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 16e063f1..4afb8a9b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -18,9 +18,9 @@ namespace rtl::dispatch { struct lambda_base { - protected: - const functor& m_functor; + + protected: lambda_base(const functor& p_functor) noexcept :m_functor(p_functor) From cdd86768d4740b8ba1db6504519b5b9f0d748224 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Thu, 25 Sep 2025 06:24:25 +0000 Subject: [PATCH 039/148] new dispatch-mechanism integration. wip. --- RTLBenchmarkApp/src/StandardCall.cpp | 4 ++-- .../rtl/builder/SetupFunction.hpp | 10 ++++----- .../rtl/builder/SetupMethod.hpp | 22 ++++++++----------- .../rtl/detail/inc/FunctionCaller.hpp | 7 +++--- .../rtl/detail/inc/FunctorId.h | 4 ++-- .../rtl/detail/inc/MethodInvoker.hpp | 9 ++++---- ReflectionTemplateLib/rtl/dispatch/lambda.h | 5 +++-- .../rtl/dispatch/lambda_function.h | 4 ++-- .../rtl/dispatch/lambda_method.h | 6 ++--- 9 files changed, 32 insertions(+), 39 deletions(-) diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 215a92d4..623b21cc 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -9,8 +9,8 @@ namespace { static auto _put_line = []() { - std::cout << "--------------------------------------------" - "----------------------------------------------------" << std::endl; + std::cout << "------------------------------------------" + "--------------------------------------------------" << std::endl; return 0; }; diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index d18fc575..ce32d60f 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -30,9 +30,8 @@ namespace rtl { return [](const FunctorId& pFunctorId, _signature&&... params) -> Return { - auto& functorId = pFunctorId.m_lambda->m_functor; - auto fptr = pFunctorId.get_lambda_function<_signature...>(functorId.m_signatureId) - ->template get_hopper(functorId.m_returnId) + auto fptr = pFunctorId.get_lambda_function<_signature...>() + ->template get_hopper() .f_ptr(); fptr(std::forward<_signature>(params)...); @@ -50,9 +49,8 @@ namespace rtl this is stored in _derivedType's (FunctorContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, _signature&&...params)-> Return { - auto& functorId = pFunctorId.m_lambda->m_functor; - auto fptr = pFunctorId.get_lambda_function<_signature...>(functorId.m_signatureId) - ->template get_hopper<_returnType>(functorId.m_returnId) + auto fptr = pFunctorId.get_lambda_function<_signature...>() + ->template get_hopper<_returnType>() .f_ptr(); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index dbadadaf..08c1e9d2 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -33,10 +33,9 @@ namespace rtl::detail /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return - { - auto& functorId = pFunctorId.m_lambda->m_functor; - auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>(functorId.m_recordId, functorId.m_signatureId) - ->template get_hopper(functorId.m_returnId) + { + auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>() + ->template get_hopper() .f_ptr(); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { @@ -59,9 +58,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - auto& functorId = pFunctorId.m_lambda->m_functor; - auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>(functorId.m_recordId, functorId.m_signatureId) - ->template get_hopper<_returnType>(functorId.m_returnId) + auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>() + ->template get_hopper<_returnType>() .f_ptr(); if (!pTargetObj.isConstCastSafe()) [[unlikely]] { @@ -105,9 +103,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - auto& functorId = pFunctorId.m_lambda->m_functor; - auto fptr = pFunctorId.get_lambda_method(functorId.m_recordId, functorId.m_signatureId) - ->template get_hopper(functorId.m_returnId) + auto fptr = pFunctorId.get_lambda_method() + ->template get_hopper() .f_ptr(); const _recordType& target = pTargetObj.view<_recordType>()->get(); @@ -126,9 +123,8 @@ namespace rtl::detail this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { - auto& functorId = pFunctorId.m_lambda->m_functor; - auto fptr = pFunctorId.get_lambda_method(functorId.m_recordId, functorId.m_signatureId) - ->template get_hopper<_returnType>(functorId.m_returnId) + auto fptr = pFunctorId.get_lambda_method() + ->template get_hopper<_returnType>() .f_ptr(); constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 0bebaf34..af125bd2 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -52,7 +52,7 @@ namespace rtl::detail for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_function<_signature...>(argsId); - if (lambda != nullptr) { + if (lambda != nullptr) [[likely]] { return { lambda }; } } @@ -62,9 +62,8 @@ namespace rtl::detail template template - inline constexpr - const function<_returnType(_signature...)> - HopFunction<_signature...>::returnT() const + inline constexpr const function<_returnType(_signature...)> + HopFunction<_signature...>::returnT() const { const auto retId = TypeId<_returnType>::get(); if (m_lambda != nullptr) [[likely]] { diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index b0c19c5c..2761736c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -81,13 +81,13 @@ namespace rtl::detail } template - constexpr const dispatch::lambda_function<_signature...>* get_lambda_function(std::size_t p_argsId) const + constexpr const dispatch::lambda_function<_signature...>* get_lambda_function(std::size_t p_argsId = 0) const { return m_lambda->to_function<_signature...>(p_argsId); } template - constexpr const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method(std::size_t p_recordId, std::size_t p_argsId) const + constexpr const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method(std::size_t p_recordId = 0, std::size_t p_argsId = 0) const { return m_lambda->to_method<_recordType, _signature...>(p_recordId, p_argsId); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 348f7530..6f7d9074 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -160,7 +160,7 @@ namespace rtl::detail for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_method<_recordType, _signature...>(recId, argsId); - if (lambda != nullptr) { + if (lambda != nullptr) [[likely]] { return { lambda }; } } @@ -170,11 +170,10 @@ namespace rtl::detail template template - inline constexpr - const method<_returnType(_recordType::*)(_signature...)> - HopMethod<_recordType, _signature...>::returnT() const + inline constexpr const method<_returnType(_recordType::*)(_signature...)> + HopMethod<_recordType, _signature...>::returnT() const { - if (m_lambda != nullptr) + if (m_lambda != nullptr) [[likely]] { const auto retId = TypeId<_returnType>::get(); return m_lambda->template get_hopper<_returnType>(retId); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 4afb8a9b..a1467bc7 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -35,7 +35,7 @@ namespace rtl::dispatch template constexpr const function_t* to_function(std::size_t p_argsId) const { - if (p_argsId == m_functor.m_signatureId) [[likely]] + if (p_argsId == 0 || p_argsId == m_functor.m_signatureId) [[likely]] { return static_cast*>(this); } @@ -45,7 +45,8 @@ namespace rtl::dispatch template constexpr const method_t* to_method(std::size_t p_recordId, std::size_t p_argsId) const { - if (p_recordId == m_functor.m_recordId && p_argsId == m_functor.m_signatureId) [[likely]] + if (p_recordId == 0 || p_argsId ==0 || + (p_recordId == m_functor.m_recordId && p_argsId == m_functor.m_signatureId)) [[likely]] { return static_cast*>(this); } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 798d4340..ade3aef1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -61,9 +61,9 @@ namespace rtl::dispatch { } template - constexpr const hopper_t get_hopper(const std::size_t p_returnId) const + constexpr const hopper_t get_hopper(const std::size_t p_returnId = 0) const { - if (p_returnId == m_functor.m_returnId) [[likely]] + if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { return hopper_t { static_cast&>(m_functor).f_ptr() diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 89619e55..5f0f03ff 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -103,7 +103,7 @@ namespace rtl::dispatch template requires (std::is_const_v == false) constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { - if (p_returnId == m_functor.m_returnId) [[likely]] + if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { return hopper_t { static_cast&>(m_functor).f_ptr() @@ -114,9 +114,9 @@ namespace rtl::dispatch template requires (std::is_const_v == true) - constexpr const hopper_ct get_hopper(std::size_t p_returnId) const + constexpr const hopper_ct get_hopper(std::size_t p_returnId = 0) const { - if (p_returnId == m_functor.m_returnId) [[likely]] + if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { return hopper_ct { static_cast&>(m_functor).f_ptr() From e14381fc427fb5d9347865bfcb696af27b755cd5 Mon Sep 17 00:00:00 2001 From: neeraj Date: Thu, 25 Sep 2025 20:35:59 +0530 Subject: [PATCH 040/148] return-type reased dispatch, wip. --- ReflectionTemplateLib/CMakeLists.txt | 2 +- .../rtl/dispatch/CMakeLists.txt | 4 ++ .../rtl/dispatch/lambda_function.h | 35 +-------- .../rtl/dispatch/lambda_method.h | 72 +------------------ .../rtl/dispatch/rtl_const_method.h | 50 +++++++++++++ .../rtl/dispatch/rtl_function.h | 49 +++++++++++++ .../rtl/dispatch/rtl_method.h | 50 +++++++++++++ .../rtl/erasure/CMakeLists.txt | 9 +++ .../rtl/erasure/erasure_function.h | 26 +++++++ ReflectionTemplateLib/rtl/rtl_forward_decls.h | 9 +++ 10 files changed, 201 insertions(+), 105 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_function.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_method.h create mode 100644 ReflectionTemplateLib/rtl/erasure/CMakeLists.txt create mode 100644 ReflectionTemplateLib/rtl/erasure/erasure_function.h diff --git a/ReflectionTemplateLib/CMakeLists.txt b/ReflectionTemplateLib/CMakeLists.txt index 24defcf1..ce4f2db7 100644 --- a/ReflectionTemplateLib/CMakeLists.txt +++ b/ReflectionTemplateLib/CMakeLists.txt @@ -18,7 +18,7 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/rtl/cache ${CMAKE_CURRENT_SOURCE_DIR}/rtl/detail ${CMAKE_CURRENT_SOURCE_DIR}/rtl/dispatch - ${CMAKE_CURRENT_SOURCE_DIR}/rtl/registry + ${CMAKE_CURRENT_SOURCE_DIR}/rtl/erasure ${CMAKE_CURRENT_SOURCE_DIR}/rtl/inc ${CMAKE_CURRENT_SOURCE_DIR}/rtl ) diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index d1c8956b..cf3b911f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -11,6 +11,10 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/lambda.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.h" + + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_const_method.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index ade3aef1..fd85d9b8 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -13,40 +13,7 @@ #include "lambda.h" #include "function_ptr.h" - -namespace rtl -{ - template - struct function - { - using fptr_t = return_t(*)(signature_ts...); - - const fptr_t m_functor = nullptr; - - constexpr auto f_ptr() const { - return m_functor; - } - - constexpr operator bool() const { - return (m_functor != nullptr); - } - - template - [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept(noexcept_v) - { - static_assert(is_args_t_ok, "Argument types don't match the expected signature."); - return (*m_functor)(std::forward(params)...); - } - - private: - - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - - template - static constexpr bool noexcept_v = noexcept(std::declval()(std::declval()...)); - }; -} +#include "rtl_function.h" namespace rtl::dispatch { diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 5f0f03ff..b7b24fb5 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -13,76 +13,8 @@ #include "lambda.h" #include "method_ptr.h" - -namespace rtl -{ - template - struct method - { - using fptr_t = return_t (record_t::*)(signature_ts...); - - const fptr_t m_functor = nullptr; - - constexpr auto f_ptr() const { - return m_functor; - } - - constexpr operator bool() const { - return (m_functor != nullptr); - } - - template - [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) - { - static_assert(is_args_t_ok, "Argument types don't match the expected signature."); - return (target.*m_functor)(std::forward(params)...); - } - - private: - - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - - template - static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); - }; -} - - -namespace rtl -{ - template - struct method - { - using fptr_t = return_t(record_t::*)(signature_ts...) const; - - const fptr_t m_functor = nullptr; - - constexpr auto f_ptr() const { - return m_functor; - } - - constexpr operator bool() const { - return (m_functor != nullptr); - } - - template - [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) - { - static_assert(is_args_t_ok, "Argument types don't match the expected signature."); - return (target.*m_functor)(std::forward(params)...); - } - - private: - - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - - template - static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); - }; -} - +#include "rtl_method.h" +#include "rtl_const_method.h" namespace rtl::dispatch { diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h new file mode 100644 index 00000000..62da2180 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h @@ -0,0 +1,50 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_forward_decls.h" + + +namespace rtl +{ + template + struct method + { + using fptr_t = return_t(record_t::*)(signature_ts...) const; + + const fptr_t m_functor = nullptr; + + constexpr auto f_ptr() const { + return m_functor; + } + + constexpr operator bool() const { + return (m_functor != nullptr); + } + + template + [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) + { + static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + return (target.*m_functor)(std::forward(params)...); + } + + private: + + template + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; + + template + static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h new file mode 100644 index 00000000..ed81c7c6 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -0,0 +1,49 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_forward_decls.h" + +namespace rtl +{ + template + struct function + { + using fptr_t = return_t(*)(signature_ts...); + + const fptr_t m_functor = nullptr; + + constexpr auto f_ptr() const { + return m_functor; + } + + constexpr operator bool() const { + return (m_functor != nullptr); + } + + template + [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept(noexcept_v) + { + static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + return (*m_functor)(std::forward(params)...); + } + + private: + + template + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; + + template + static constexpr bool noexcept_v = noexcept(std::declval()(std::declval()...)); + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h new file mode 100644 index 00000000..27e9912c --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -0,0 +1,50 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_forward_decls.h" + + +namespace rtl +{ + template + struct method + { + using fptr_t = return_t (record_t::*)(signature_ts...); + + const fptr_t m_functor = nullptr; + + constexpr auto f_ptr() const { + return m_functor; + } + + constexpr operator bool() const { + return (m_functor != nullptr); + } + + template + [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) + { + static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + return (target.*m_functor)(std::forward(params)...); + } + + private: + + template + static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; + + template + static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt new file mode 100644 index 00000000..bd5acdb2 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -0,0 +1,9 @@ +# ReflectionTemplateLibrary-CPP/ReflectionTemplateLib/erasure/CMakeLists.txt + +# Collect headers in this folder (absolute paths) +set(LOCAL_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/erasure_function.h" +) + +target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) +source_group("Header Files\\Erasure" FILES ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_function.h b/ReflectionTemplateLib/rtl/erasure/erasure_function.h new file mode 100644 index 00000000..6ee85387 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erasure_function.h @@ -0,0 +1,26 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + + +// #include "RObject.h" +// #include "rtl_traits.h" +// #include "rtl_forward_decls.h" + +// namespace rtl::erasure +// { +// template +// struct function +// { +// virtual Return +// }; +// } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 84ff5eea..4f3c4e95 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -31,6 +31,15 @@ namespace rtl template struct method; + namespace erasure + { + template + struct function; + + template + struct method; + } + namespace detail { struct FunctorId; From cf8900711a2bf933fc221657790bda7c02d45d92 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 26 Sep 2025 01:45:34 +0530 Subject: [PATCH 041/148] erasure_base, wip. --- ReflectionTemplateLib/rtl/CMakeLists.txt | 1 + .../rtl/erasure/erasure_function.h | 33 ++++++++++++------- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 5 ++- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/ReflectionTemplateLib/rtl/CMakeLists.txt b/ReflectionTemplateLib/rtl/CMakeLists.txt index dd7b3895..daa071c9 100644 --- a/ReflectionTemplateLib/rtl/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/CMakeLists.txt @@ -19,4 +19,5 @@ add_subdirectory(src) add_subdirectory(builder) add_subdirectory(cache) add_subdirectory(detail) +add_subdirectory(erasure) add_subdirectory(dispatch) \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_function.h b/ReflectionTemplateLib/rtl/erasure/erasure_function.h index 6ee85387..aa3ab9a8 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure_function.h @@ -4,7 +4,7 @@ * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * * * * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * + * SPDX-License-Identifier: MIT * * * *************************************************************************/ @@ -12,15 +12,24 @@ #pragma once -// #include "RObject.h" -// #include "rtl_traits.h" -// #include "rtl_forward_decls.h" + #include "RObject.h" + #include "rtl_traits.h" + #include "rtl_forward_decls.h" -// namespace rtl::erasure -// { -// template -// struct function -// { -// virtual Return -// }; -// } \ No newline at end of file + namespace rtl::erase + { + template + struct erasure_base + { + virtual Return forward(signature_ts&&...) = 0; + }; + + template + struct function_return : public erasure_base + { + Return forward(signature_ts&&...) override + { + return Return{ error::None, RObject{ return_t() } }; + } + }; + } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 4f3c4e95..3132fb24 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -31,8 +31,11 @@ namespace rtl template struct method; - namespace erasure + namespace erase { + //template + //struct erasure_base; + template struct function; From 09d5b6cb40377babd6aa50faaf54c04c1bea69cd Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 26 Sep 2025 01:52:02 +0530 Subject: [PATCH 042/148] fixed last incomplete commit --- ReflectionTemplateLib/rtl/erasure/erasure_function.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_function.h b/ReflectionTemplateLib/rtl/erasure/erasure_function.h index aa3ab9a8..8525e87f 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure_function.h @@ -19,13 +19,13 @@ namespace rtl::erase { template - struct erasure_base + struct erasure_base { virtual Return forward(signature_ts&&...) = 0; }; template - struct function_return : public erasure_base + struct function_return : public erasure_base { Return forward(signature_ts&&...) override { From 3ad119b43cf5699a0bcce8d7a60b4063cb5d417a Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 26 Sep 2025 11:22:24 +0530 Subject: [PATCH 043/148] return erased, wip. --- .../rtl/erasure/CMakeLists.txt | 3 +- .../rtl/erasure/erase_return.h | 64 +++++++++++++++++++ .../erasure/{erasure_function.h => erasure.h} | 32 +++------- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 4 +- 4 files changed, 78 insertions(+), 25 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/erasure/erase_return.h rename ReflectionTemplateLib/rtl/erasure/{erasure_function.h => erasure.h} (56%) diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt index bd5acdb2..03494399 100644 --- a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -2,7 +2,8 @@ # Collect headers in this folder (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/erasure_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erasure.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_return.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return.h b/ReflectionTemplateLib/rtl/erasure/erase_return.h new file mode 100644 index 00000000..ef250ada --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erase_return.h @@ -0,0 +1,64 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + + +#include "erasure.h" +#include "rtl_traits.h" +#include "rtl_function.h" +#include "RObjectBuilder.hpp" + +namespace rtl::erase +{ + template + struct function_return : public erasure_base + { + rtl::function m_function; + + Return forward(signature_ts&&...params) override + { + if constexpr (std::is_void_v) + { + m_function(std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + constexpr bool isConstCastSafe = (!traits::is_const_v); + + if constexpr (std::is_reference_v) { + + auto& retObj = m_function(std::forward(params)...); + + using T = std::remove_cvref_t; + return Return { + error::None, + detail::RObjectBuilder::template + build(&retObj, std::nullopt, isConstCastSafe) + }; + } + else + { + auto&& retObj = fptr(std::forward(params)...); + + using T = std::remove_cvref_t; + return Return { + error::None, + detail::RObjectBuilder::template + build(std::forward(retObj), std::nullopt, isConstCastSafe) + }; + } + } + return Return{ error::None, RObject{} }; + } + }; + } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_function.h b/ReflectionTemplateLib/rtl/erasure/erasure.h similarity index 56% rename from ReflectionTemplateLib/rtl/erasure/erasure_function.h rename to ReflectionTemplateLib/rtl/erasure/erasure.h index 8525e87f..70695683 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure.h @@ -4,32 +4,20 @@ * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * * * * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * + * SPDX-License-Identifier: MIT * * * *************************************************************************/ #pragma once +#include "rtl_forward_decls.h" - #include "RObject.h" - #include "rtl_traits.h" - #include "rtl_forward_decls.h" - - namespace rtl::erase - { - template - struct erasure_base - { - virtual Return forward(signature_ts&&...) = 0; - }; - - template - struct function_return : public erasure_base - { - Return forward(signature_ts&&...) override - { - return Return{ error::None, RObject{ return_t() } }; - } - }; - } \ No newline at end of file +namespace rtl::erase +{ + template + struct erasure_base + { + virtual rtl::Return forward(signature_ts&&...) = 0; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 3132fb24..e7b962ed 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -33,8 +33,8 @@ namespace rtl namespace erase { - //template - //struct erasure_base; + template + struct erasure_base; template struct function; From 8937d9c4282b0cf55cf3373197546c72518be4b5 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Sat, 27 Sep 2025 14:08:33 +0000 Subject: [PATCH 044/148] return erased, wip. --- .../rtl/builder/SetupFunction.hpp | 2 +- .../rtl/cache/cache_lambda_function.h | 11 +++- ReflectionTemplateLib/rtl/dispatch/functor.h | 2 +- ReflectionTemplateLib/rtl/dispatch/lambda.h | 4 +- .../rtl/dispatch/lambda_function.h | 22 +++++--- .../rtl/dispatch/rtl_function.h | 19 +++++-- .../rtl/erasure/erase_return.h | 54 ++++--------------- ReflectionTemplateLib/rtl/erasure/erasure.h | 2 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 2 +- 9 files changed, 58 insertions(+), 60 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index ce32d60f..8794ec85 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -95,7 +95,7 @@ namespace rtl const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_function<_signature...>::instance(); + auto& lambdaCache = cache::lambda_function<_returnType, _signature...>::instance(); auto& functorCache = cache::function_ptr<_returnType, _signature...>::instance(); auto& functor = functorCache.push(pFunctor, pIndex); diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index 0bc1ed17..a83566e0 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -14,10 +14,11 @@ #include #include "lambda_function.h" +#include "erase_return.h" namespace rtl::cache { - template + template struct lambda_function { static const lambda_function& instance() @@ -28,8 +29,13 @@ namespace rtl::cache const dispatch::lambda_function& push(const dispatch::functor& fptr) const { - m_cache.push_back(dispatch::lambda_function(fptr)); + m_erasure_cache.push_back(erase::function_return()); + erase::erasure_base* erasure = &m_erasure_cache.back(); + + m_cache.push_back(dispatch::lambda_function(fptr, erasure)); fptr.m_lambda = &m_cache.back(); + + (m_cache.back()).template init_erasure(); return m_cache.back(); } @@ -42,6 +48,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; + mutable std::list> m_erasure_cache; lambda_function() = default; }; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 312bb974..070c4a59 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -37,7 +37,7 @@ namespace rtl::dispatch mutable const lambda_base* m_lambda = nullptr; - template + template friend struct cache::lambda_function; template diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index a1467bc7..06ec3000 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -20,7 +20,7 @@ namespace rtl::dispatch { const functor& m_functor; - protected: +// protected: lambda_base(const functor& p_functor) noexcept :m_functor(p_functor) @@ -53,7 +53,7 @@ namespace rtl::dispatch else return nullptr; } - public: +// public: GETTER_CREF(functor, _functor, m_functor); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index fd85d9b8..426239fb 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -14,6 +14,7 @@ #include "lambda.h" #include "function_ptr.h" #include "rtl_function.h" +#include "erase_return.h" namespace rtl::dispatch { @@ -21,20 +22,29 @@ namespace rtl::dispatch struct lambda_function: public lambda_base { template - using hopper_t = function; + using hopper_t = rtl::function; - lambda_function(const functor& p_functor) noexcept - :lambda_base(p_functor) + erase::erasure_base* m_erasure; + + lambda_function(const functor& p_functor, erase::erasure_base* p_erasure) noexcept + : lambda_base(p_functor) + , m_erasure(p_erasure) { } + template + constexpr void init_erasure() const + { + auto erasure = static_cast*>(m_erasure); + erasure->m_function = get_hopper(); + } + template constexpr const hopper_t get_hopper(const std::size_t p_returnId = 0) const { if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { - return hopper_t { - static_cast&>(m_functor).f_ptr() - }; + auto fptr = static_cast&>(m_functor).f_ptr(); + return hopper_t(fptr); } return hopper_t(); } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index ed81c7c6..e8fd153e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -21,8 +21,6 @@ namespace rtl { using fptr_t = return_t(*)(signature_ts...); - const fptr_t m_functor = nullptr; - constexpr auto f_ptr() const { return m_functor; } @@ -38,12 +36,27 @@ namespace rtl return (*m_functor)(std::forward(params)...); } + function(fptr_t p_functor): m_functor(p_functor) + { } + + function() = default; + function(function&&) = default; + function(const function&) = default; + + function& operator=(function&&) = default; + function& operator=(const function&) = default; + private: + fptr_t m_functor = nullptr; + template static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; template static constexpr bool noexcept_v = noexcept(std::declval()(std::declval()...)); + + template + friend struct dispatch::lambda_function; }; -} \ No newline at end of file +} diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return.h b/ReflectionTemplateLib/rtl/erasure/erase_return.h index ef250ada..5dd4136b 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_return.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_return.h @@ -15,50 +15,18 @@ #include "erasure.h" #include "rtl_traits.h" #include "rtl_function.h" -#include "RObjectBuilder.hpp" +#include "rtl_errors.h" namespace rtl::erase { - template - struct function_return : public erasure_base - { - rtl::function m_function; - - Return forward(signature_ts&&...params) override - { - if constexpr (std::is_void_v) - { - m_function(std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - constexpr bool isConstCastSafe = (!traits::is_const_v); - - if constexpr (std::is_reference_v) { - - auto& retObj = m_function(std::forward(params)...); - - using T = std::remove_cvref_t; - return Return { - error::None, - detail::RObjectBuilder::template - build(&retObj, std::nullopt, isConstCastSafe) - }; - } - else - { - auto&& retObj = fptr(std::forward(params)...); - - using T = std::remove_cvref_t; - return Return { - error::None, - detail::RObjectBuilder::template - build(std::forward(retObj), std::nullopt, isConstCastSafe) - }; - } - } - return Return{ error::None, RObject{} }; - } - }; + template + struct function_return : public erasure_base + { + rtl::function m_function; + + void forward(signature_ts&&...params) override + { + //m_function(std::forward(params)...); + } + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure.h b/ReflectionTemplateLib/rtl/erasure/erasure.h index 70695683..9866bd6d 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure.h @@ -18,6 +18,6 @@ namespace rtl::erase template struct erasure_base { - virtual rtl::Return forward(signature_ts&&...) = 0; + virtual void forward(signature_ts&&...) = 0; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index e7b962ed..36e30570 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -59,7 +59,7 @@ namespace rtl namespace cache { - template + template struct lambda_function; template From 7531afa59a2ec3d955b427adeee9e7a37f0a8a2d Mon Sep 17 00:00:00 2001 From: neeraj Date: Sun, 28 Sep 2025 00:27:20 +0530 Subject: [PATCH 045/148] erased return calls in benchmarks, wip. --- .../src/ReflectedCallUnknownReturn.cpp | 14 +++++- RTLBenchmarkApp/src/StandardCall.cpp | 3 +- RTLBenchmarkApp/src/StdFunction.cpp | 9 ++-- .../rtl/dispatch/lambda_function.h | 6 +++ .../rtl/dispatch/rtl_function.h | 2 +- .../rtl/erasure/erase_return.h | 18 +++++-- ReflectionTemplateLib/rtl/erasure/erasure.h | 4 +- ReflectionTemplateLib/rtl/inc/Function.h | 11 +++++ ReflectionTemplateLib/rtl/inc/Function.hpp | 47 +++++++++++++++++++ ReflectionTemplateLib/rtl/rtl_typeid.h | 10 +++- 10 files changed, 112 insertions(+), 12 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 119e5eff..468afbb9 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -5,6 +5,11 @@ #include "BenchMark.h" #include "ReflectedCallUnknownReturn.h" +namespace bm +{ + extern std::optional g_work_done; +} + namespace cxx { extern const rtl::CxxMirror& mirror(); @@ -154,7 +159,10 @@ void RtlFunction_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) static auto _ = _test1(); for (auto _ : state) { - benchmark::DoNotOptimize(NodeSendMessage(nodeObj)(bm::g_longStr)); + //Testings: + SendMessage.ecall_v(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + //benchmark::DoNotOptimize(NodeSendMessage(nodeObj)(bm::g_longStr)); } } @@ -164,6 +172,8 @@ void RtlFunction_callMethod_ReturnUnknown::typeNonVoid(benchmark::State& state) static auto _ = _test3(); for (auto _ : state) { - benchmark::DoNotOptimize(NodeGetMessage(nodeObj)(bm::g_longStr)); + //Testing: + benchmark::DoNotOptimize(GetMessage.ecall_r(bm::g_longStr)); + //benchmark::DoNotOptimize(NodeGetMessage(nodeObj)(bm::g_longStr)); } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 623b21cc..30de3b2c 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -1,4 +1,5 @@ +#include #include #include #include @@ -33,7 +34,7 @@ namespace bm extern std::function NodeSendMessage; - extern std::function GetMessage; + extern std::function GetMessage; extern std::function NodeGetMessage; } diff --git a/RTLBenchmarkApp/src/StdFunction.cpp b/RTLBenchmarkApp/src/StdFunction.cpp index f3998942..c8d5647c 100644 --- a/RTLBenchmarkApp/src/StdFunction.cpp +++ b/RTLBenchmarkApp/src/StdFunction.cpp @@ -1,4 +1,5 @@ +#include #include #include "BenchMark.h" @@ -33,10 +34,12 @@ namespace bm pNode.sendMessage(pMsg); }; - std::function GetMessage = [](bm::argStr_t& pMsg) + std::function GetMessage = [](bm::argStr_t& pMsg) { - auto retMsg = bm::getMessage(pMsg); - return retMsg; + //Testing. + return std::any(bm::getMessage(pMsg)); + // auto retMsg = bm::getMessage(pMsg); + // return retMsg; }; std::function NodeGetMessage = [](bm::Node pNode, bm::argStr_t& pMsg) diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 426239fb..14a90ded 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -48,5 +48,11 @@ namespace rtl::dispatch } return hopper_t(); } + + template + constexpr decltype(auto) operator()(args_t&&...params) const + { + return m_erasure->forward(std::forward(params)...); + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index e8fd153e..14ada51e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -32,7 +32,7 @@ namespace rtl template [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept(noexcept_v) { - static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (*m_functor)(std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return.h b/ReflectionTemplateLib/rtl/erasure/erase_return.h index 5dd4136b..0f880333 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_return.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_return.h @@ -11,11 +11,11 @@ #pragma once - #include "erasure.h" #include "rtl_traits.h" #include "rtl_function.h" #include "rtl_errors.h" +#include namespace rtl::erase { @@ -24,9 +24,21 @@ namespace rtl::erase { rtl::function m_function; - void forward(signature_ts&&...params) override + void hop_v(signature_ts&&...params) const noexcept override + { + if constexpr (std::is_void_v) + { + m_function(std::forward(params)...); + } + } + + std::any hop_r(signature_ts&&...params) const noexcept override { - //m_function(std::forward(params)...); + if constexpr (!std::is_void_v) + { + return std::any(m_function(std::forward(params)...)); + } + else return std::any(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure.h b/ReflectionTemplateLib/rtl/erasure/erasure.h index 9866bd6d..57cb6ea9 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure.h @@ -11,6 +11,7 @@ #pragma once +#include #include "rtl_forward_decls.h" namespace rtl::erase @@ -18,6 +19,7 @@ namespace rtl::erase template struct erasure_base { - virtual void forward(signature_ts&&...) = 0; + virtual void hop_v(signature_ts&&...) const noexcept = 0; + virtual std::any hop_r(signature_ts&&...) const noexcept = 0; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 3bdab774..a08aade2 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -11,14 +11,17 @@ #pragma once +#include #include #include #include #include "FunctorId.h" +#include "RObject.h" #include "rtl_constants.h" #include "FunctionCaller.h" #include "lambda_function.h" +#include "rtl_errors.h" namespace rtl { @@ -70,6 +73,8 @@ namespace rtl { const detail::FunctorId* hasFunctorId(const std::size_t pSignatureId) const; + const detail::FunctorId* getLambdaById(const std::size_t pSignatureId) const; + GETTER(detail::methodQ, Qualifier, m_qualifier); GETTER_REF(std::vector, FunctorIds, m_functorIds) @@ -102,6 +107,12 @@ namespace rtl { template constexpr const detail::FunctionCaller<_signature...> bind() const noexcept; + template + rtl::error ecall_v(_args&&...) const noexcept; + + template + std::any ecall_r(_args&&...) const noexcept; + friend detail::CxxReflection; friend detail::ReflectionBuilder; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index a102d50b..49a531d5 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -13,6 +13,14 @@ #include "Function.h" #include "FunctionCaller.hpp" +#include "RObject.h" +#include "rtl_constants.h" +#include "rtl_errors.h" +#include +#include +#include + +#include "erase_return.h" namespace rtl { @@ -53,6 +61,34 @@ namespace rtl } + template + FORCE_INLINE error Function::ecall_v(_args&& ...params) const noexcept + { + //m_functorIds[0].get_lambda_function<_args...>()->m_erasure->hop(std::forward<_args>(params)...); + const std::size_t argsId = detail::TypeId... >>::get(); + for (auto& functorId : m_functorIds) + { + if(argsId == functorId.m_lambda->m_functor.m_signatureId) [[likely]] + { + functorId.get_lambda_function<_args...>()->m_erasure->hop_v(std::forward<_args>(params)...); + break; + } + } + return error::None; + } + + + template + FORCE_INLINE std::any Function::ecall_r(_args&& ...params) const noexcept + { + auto functorId = getLambdaById(detail::TypeId... >>::get()); + if(functorId) { + return functorId->template get_lambda_function<_args...>()->m_erasure->hop_r(std::forward<_args>(params)...); + } + return std::any(); + } + + /* @method: hasSignatureId() @param: const std::size_t& (signatureId to be found) @return: the index of the functor in the functor-table. @@ -81,4 +117,15 @@ namespace rtl } return nullptr; } + + FORCE_INLINE const detail::FunctorId* Function::getLambdaById(const std::size_t pSignatureId) const + { + //simple linear-search, efficient for small set of elements. + for (const auto& functorId : m_functorIds) { + if (pSignatureId == functorId.m_lambda->m_functor.m_signatureId) [[likely]] { + return &functorId; + } + } + return nullptr; + } } diff --git a/ReflectionTemplateLib/rtl/rtl_typeid.h b/ReflectionTemplateLib/rtl/rtl_typeid.h index e898b588..8fe1d88e 100644 --- a/ReflectionTemplateLib/rtl/rtl_typeid.h +++ b/ReflectionTemplateLib/rtl/rtl_typeid.h @@ -15,6 +15,14 @@ #include #include +#if defined(_MSC_VER) +#define FORCE_INLINE __forceinline +#elif defined(__GNUC__) || defined(__clang__) +#define FORCE_INLINE inline __attribute__((always_inline)) +#else +#define FORCE_INLINE inline +#endif + namespace rtl { namespace detail @@ -38,7 +46,7 @@ namespace rtl { //'0' represents no type. [Never change, critical.] static constexpr const std::size_t None = 0; - static const std::size_t get() + FORCE_INLINE static std::size_t get() { if constexpr (!std::is_same_v<_type, std::nullptr_t>) { From 0312cd37bdacd919bb4c3d9bffc4d886f56b866d Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sun, 28 Sep 2025 13:10:48 +0530 Subject: [PATCH 046/148] removed RTTI/virtual-funcs, wip. --- .../rtl/dispatch/lambda_function.h | 6 ------ .../rtl/dispatch/rtl_function.h | 6 +++--- .../rtl/dispatch/rtl_method.h | 6 +++--- .../rtl/erasure/erase_return.h | 19 ++++++++++++++----- ReflectionTemplateLib/rtl/erasure/erasure.h | 17 +++++++++++++++-- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 14a90ded..426239fb 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -48,11 +48,5 @@ namespace rtl::dispatch } return hopper_t(); } - - template - constexpr decltype(auto) operator()(args_t&&...params) const - { - return m_erasure->forward(std::forward(params)...); - } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index 14ada51e..edcdea67 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -30,7 +30,7 @@ namespace rtl } template - [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept(noexcept_v) + [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept // (noexcept_v) { //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (*m_functor)(std::forward(params)...); @@ -53,8 +53,8 @@ namespace rtl template static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - template - static constexpr bool noexcept_v = noexcept(std::declval()(std::declval()...)); + //template + //static constexpr bool noexcept_v = noexcept(std::declval()(std::declval()...)); template friend struct dispatch::lambda_function; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 27e9912c..4f60a560 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -33,7 +33,7 @@ namespace rtl } template - [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) + [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept //(noexcept_v) { static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (target.*m_functor)(std::forward(params)...); @@ -44,7 +44,7 @@ namespace rtl template static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - template - static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); + //template + //static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return.h b/ReflectionTemplateLib/rtl/erasure/erase_return.h index 0f880333..571cfe8d 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_return.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_return.h @@ -24,21 +24,30 @@ namespace rtl::erase { rtl::function m_function; - void hop_v(signature_ts&&...params) const noexcept override + function_return() + { + erasure_base::v_hop = vhop; + erasure_base::r_hop = rhop; + } + + FORCE_INLINE static void vhop(erasure_base* p_this, signature_ts&&...params) { if constexpr (std::is_void_v) { - m_function(std::forward(params)...); + auto this_p = static_cast*>(p_this); + this_p->m_function(std::forward(params)...); } } - std::any hop_r(signature_ts&&...params) const noexcept override + FORCE_INLINE static std::any rhop(erasure_base* p_this, signature_ts&&...params) { if constexpr (!std::is_void_v) { - return std::any(m_function(std::forward(params)...)); + auto this_p = static_cast*>(p_this); + auto&& ret_v = this_p->m_function(std::forward(params)...); + return std::any(std::forward(ret_v)); } else return std::any(); } }; - } \ No newline at end of file +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure.h b/ReflectionTemplateLib/rtl/erasure/erasure.h index 57cb6ea9..2f5a2b29 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure.h @@ -19,7 +19,20 @@ namespace rtl::erase template struct erasure_base { - virtual void hop_v(signature_ts&&...) const noexcept = 0; - virtual std::any hop_r(signature_ts&&...) const noexcept = 0; + using functor_vt = void(*)(erasure_base*, signature_ts&&...); + using functor_rt = std::any(*)(erasure_base*, signature_ts&&...); + + functor_vt v_hop = nullptr; + functor_rt r_hop = nullptr; + + FORCE_INLINE void hop_v(signature_ts&&...params) + { + v_hop(this, std::forward(params)...); + } + + FORCE_INLINE std::any hop_r(signature_ts&&...params) + { + return r_hop(this, std::forward(params)...); + } }; } \ No newline at end of file From dc0fff7f889c1baef188a23da054a4ed564fa35e Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 29 Sep 2025 12:02:16 +0530 Subject: [PATCH 047/148] return-erased basic integration done, method calls impl. --- .../src/ReflectedCallUnknownReturn.cpp | 17 +++--- .../MoveConstructorTests.cpp | 2 +- .../FunctionalityTests/StaticMethodTests.cpp | 4 +- .../rtl/builder/SetupMethod.hpp | 4 +- .../rtl/cache/cache_lambda_function.h | 8 +-- .../rtl/cache/cache_lambda_method.h | 13 +++- .../rtl/detail/inc/FunctionCaller.h | 6 ++ .../rtl/detail/inc/FunctionCaller.hpp | 26 ++++++++ .../rtl/detail/inc/MethodInvoker.h | 41 ++++++++++--- ReflectionTemplateLib/rtl/dispatch/functor.h | 2 +- .../rtl/dispatch/lambda_function.h | 8 +-- .../rtl/dispatch/lambda_method.h | 31 ++++++---- .../rtl/dispatch/rtl_const_method.h | 26 +++++--- .../rtl/dispatch/rtl_method.h | 19 +++++- .../rtl/erasure/CMakeLists.txt | 7 ++- .../erasure/{erasure.h => erase_function.h} | 10 ++- .../rtl/erasure/erase_method.h | 42 +++++++++++++ .../rtl/erasure/return_const_method.h | 61 +++++++++++++++++++ .../{erase_return.h => return_function.h} | 35 +++++++---- .../rtl/erasure/return_method.h | 61 +++++++++++++++++++ ReflectionTemplateLib/rtl/inc/Function.h | 6 -- ReflectionTemplateLib/rtl/inc/Function.hpp | 33 +--------- ReflectionTemplateLib/rtl/inc/Method.h | 13 ++-- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 15 +++-- 24 files changed, 365 insertions(+), 125 deletions(-) rename ReflectionTemplateLib/rtl/erasure/{erasure.h => erase_function.h} (85%) create mode 100644 ReflectionTemplateLib/rtl/erasure/erase_method.h create mode 100644 ReflectionTemplateLib/rtl/erasure/return_const_method.h rename ReflectionTemplateLib/rtl/erasure/{erase_return.h => return_function.h} (59%) create mode 100644 ReflectionTemplateLib/rtl/erasure/return_method.h diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 468afbb9..a4408980 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -138,7 +138,8 @@ void RtlFunction_call_ReturnUnknown::typeVoid(benchmark::State& state) static auto _ = _test0(); for (auto _ : state) { - benchmark::DoNotOptimize(SendMessage(bm::g_longStr)); + SendMessage.bind().call_v(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done); } } @@ -149,7 +150,7 @@ void RtlFunction_call_ReturnUnknown::typeNonVoid(benchmark::State& state) static auto _ = _test2(); for (auto _ : state) { - benchmark::DoNotOptimize(GetMessage(bm::g_longStr)); + benchmark::DoNotOptimize(GetMessage.bind().call_r(bm::g_longStr)); } } @@ -157,12 +158,11 @@ void RtlFunction_call_ReturnUnknown::typeNonVoid(benchmark::State& state) void RtlFunction_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) { static auto _ = _test1(); + static bm::Node node; for (auto _ : state) { - //Testings: - SendMessage.ecall_v(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); - //benchmark::DoNotOptimize(NodeSendMessage(nodeObj)(bm::g_longStr)); + NodeSendMessage(node).call_v(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done); } } @@ -170,10 +170,9 @@ void RtlFunction_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) void RtlFunction_callMethod_ReturnUnknown::typeNonVoid(benchmark::State& state) { static auto _ = _test3(); + static bm::Node node; for (auto _ : state) { - //Testing: - benchmark::DoNotOptimize(GetMessage.ecall_r(bm::g_longStr)); - //benchmark::DoNotOptimize(NodeGetMessage(nodeObj)(bm::g_longStr)); + benchmark::DoNotOptimize(NodeGetMessage(node).call_r(bm::g_longStr)); } } \ No newline at end of file diff --git a/RTLTestRunApp/src/FunctionalityTests/MoveConstructorTests.cpp b/RTLTestRunApp/src/FunctionalityTests/MoveConstructorTests.cpp index d4c07bc0..02431be3 100644 --- a/RTLTestRunApp/src/FunctionalityTests/MoveConstructorTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/MoveConstructorTests.cpp @@ -228,7 +228,7 @@ namespace rtl_tests // Calender::create is a static method that returns stack-allocated Calender object. // Calling this via reflection, moves the return value from Calender::create to here. - auto [err0, calender0] = (*createCalender)()(); + auto [err0, calender0] = createCalender->bind().call(); EXPECT_TRUE(err0 == error::None); ASSERT_FALSE(calender0.isEmpty()); diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp index 5d93608f..f8a80759 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp @@ -21,7 +21,7 @@ namespace rtl_tests ASSERT_TRUE(getDefaults); EXPECT_TRUE(getDefaults->hasSignature<>()); //empty template params checks for zero arguments. - auto [err, ret] = (*getDefaults)()(); + auto [err, ret] = getDefaults->bind().call(); EXPECT_TRUE(err == error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); @@ -59,7 +59,7 @@ namespace rtl_tests ASSERT_TRUE(getProfile); EXPECT_TRUE(getProfile->hasSignature()); { - auto [err, ret] = (*getProfile)()(true); + auto [err, ret] = getProfile->bind().call(true); EXPECT_TRUE(err == error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 08c1e9d2..69661226 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -170,7 +170,7 @@ namespace rtl::detail const dispatch::lambda_base* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); + auto& lambdaCache = cache::lambda_method<_recordType, _returnType, _signature...>::instance(); auto& functorCache = cache::method_ptr<_recordType, _returnType, _signature...>::instance(); auto& functor = functorCache.push(pFunctor, pIndex); @@ -241,7 +241,7 @@ namespace rtl::detail const dispatch::lambda_base* lambdaPtr = nullptr; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_method<_recordType, _signature...>::instance(); + auto& lambdaCache = cache::lambda_method<_recordType, _returnType, _signature...>::instance(); auto& functorCache = cache::method_ptr::instance(); auto& functor = functorCache.push(pFunctor, pIndex); diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index a83566e0..6318614f 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -14,7 +14,7 @@ #include #include "lambda_function.h" -#include "erase_return.h" +#include "return_function.h" namespace rtl::cache { @@ -29,8 +29,8 @@ namespace rtl::cache const dispatch::lambda_function& push(const dispatch::functor& fptr) const { - m_erasure_cache.push_back(erase::function_return()); - erase::erasure_base* erasure = &m_erasure_cache.back(); + m_erasure_cache.push_back(erase::return_function()); + erase::function* erasure = &m_erasure_cache.back(); m_cache.push_back(dispatch::lambda_function(fptr, erasure)); fptr.m_lambda = &m_cache.back(); @@ -48,7 +48,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_function() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index f096814d..28a6c235 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -14,10 +14,12 @@ #include #include "lambda_method.h" +#include "return_method.h" +#include "return_const_method.h" namespace rtl::cache { - template + template struct lambda_method { static const lambda_method& instance() @@ -28,8 +30,14 @@ namespace rtl::cache const dispatch::lambda_method& push(const dispatch::functor& fptr) const { - m_cache.push_back(dispatch::lambda_method(fptr)); + m_erasure_cache.push_back(erase::return_method()); + erase::method* erasure = &m_erasure_cache.back(); + + m_cache.push_back(dispatch::lambda_method(fptr, erasure)); fptr.m_lambda = &m_cache.back(); + + (m_cache.back()).template init_erasure(); + return m_cache.back(); } @@ -42,6 +50,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; + mutable std::list> m_erasure_cache; lambda_method() = default; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 957c8c00..f4e1fd65 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -30,6 +30,12 @@ namespace rtl::detail template constexpr rtl::Return operator()(_args&&...params) const noexcept; + template + rtl::error call_v(_args&&...) const noexcept; + + template + std::any call_r(_args&&...) const noexcept; + friend Function; }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index af125bd2..5ce082e0 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -16,6 +16,8 @@ #include "FunctionCaller.h" #include "FunctorContainer.h" +#include "erase_function.h" + namespace rtl::detail { template @@ -40,6 +42,30 @@ namespace rtl::detail { return call(std::forward<_args>(params)...); } + + + template + template + FORCE_INLINE error FunctionCaller<_signature...>::call_v(_args&& ...params) const noexcept + { + auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); + if (functorId) [[likely]] { + functorId->template get_lambda_function<_args...>()->m_erasure->hop_v(std::forward<_args>(params)...); + } + return error::None; + } + + + template + template + FORCE_INLINE std::any FunctionCaller<_signature...>::call_r(_args&& ...params) const noexcept + { + auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); + if (functorId) [[likely]] { + return functorId->template get_lambda_function<_args...>()->m_erasure->hop_r(std::forward<_args>(params)...); + } + return std::any(); + } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 38ba7f74..0e32e36f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -11,7 +11,38 @@ #pragma once -#include "rtl_forward_decls.h" +#include "erase_method.h" + +namespace rtl::detail +{ + template + struct ErasedInvoker + { + const Method& m_method; + + const _recordType& m_target; + + template + constexpr error call_v(_args&&...params) const noexcept + { + auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + if (functorId) [[likely]] { + functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->hop_v(m_target, std::forward<_args>(params)...); + } + return error::None; + } + + template + constexpr std::any call_r(_args&&...params) const noexcept + { + auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + if (functorId) [[likely]] { + return functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->hop_r(m_target, std::forward<_args>(params)...); + } + return std::any(); + } + }; +} namespace rtl::detail { @@ -32,8 +63,6 @@ namespace rtl::detail { static Return invoke(const Method& pMethod, const RObject& pTarget, _args&&...); }; - public: - template Return call(_args&&...) const noexcept; @@ -41,8 +70,6 @@ namespace rtl::detail { constexpr Return operator()(_args&&...params) const noexcept { return call(std::forward<_args>(params)...); } - - friend Method; }; @@ -62,8 +89,6 @@ namespace rtl::detail { static Return invoke(const Method& pMethod, const RObject& pTarget, _args&&...); }; - public: - template Return call(_args&&...) const noexcept; @@ -71,8 +96,6 @@ namespace rtl::detail { constexpr Return operator()(_args&&...params) const noexcept { return call(std::forward<_args>(params)...); } - - friend Method; }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 070c4a59..e079761d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -40,7 +40,7 @@ namespace rtl::dispatch template friend struct cache::lambda_function; - template + template friend struct cache::lambda_method; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 426239fb..efd7d7df 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -14,7 +14,7 @@ #include "lambda.h" #include "function_ptr.h" #include "rtl_function.h" -#include "erase_return.h" +#include "return_function.h" namespace rtl::dispatch { @@ -24,9 +24,9 @@ namespace rtl::dispatch template using hopper_t = rtl::function; - erase::erasure_base* m_erasure; + erase::function* m_erasure; - lambda_function(const functor& p_functor, erase::erasure_base* p_erasure) noexcept + lambda_function(const functor& p_functor, erase::function* p_erasure) noexcept : lambda_base(p_functor) , m_erasure(p_erasure) { } @@ -34,7 +34,7 @@ namespace rtl::dispatch template constexpr void init_erasure() const { - auto erasure = static_cast*>(m_erasure); + auto erasure = static_cast*>(m_erasure); erasure->m_function = get_hopper(); } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index b7b24fb5..cfc3d954 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -15,6 +15,9 @@ #include "method_ptr.h" #include "rtl_method.h" #include "rtl_const_method.h" +#include "return_method.h" +#include "return_const_method.h" + namespace rtl::dispatch { @@ -22,37 +25,43 @@ namespace rtl::dispatch struct lambda_method : public lambda_base { template - using hopper_t = method; + using hopper_t = rtl::method; template - using hopper_ct = method; + using hopper_ct = rtl::method; + + erase::method* m_erasure; - lambda_method(const functor& p_functor) noexcept - :lambda_base(p_functor) + lambda_method(const functor& p_functor, erase::method* p_erasure) noexcept + : lambda_base(p_functor) + , m_erasure(p_erasure) { } + template + constexpr void init_erasure() const + { + auto erasure = static_cast*>(m_erasure); + erasure->m_method = get_hopper(); + } template requires (std::is_const_v == false) constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { - return hopper_t { - static_cast&>(m_functor).f_ptr() - }; + auto fptr = static_cast&>(m_functor).f_ptr(); + return hopper_t(fptr); } return hopper_t(); } - template requires (std::is_const_v == true) constexpr const hopper_ct get_hopper(std::size_t p_returnId = 0) const { if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { - return hopper_ct { - static_cast&>(m_functor).f_ptr() - }; + auto fptr = static_cast&>(m_functor).f_ptr(); + return hopper_ct(fptr); } return hopper_ct(); } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h index 62da2180..5b4edf73 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h @@ -18,11 +18,9 @@ namespace rtl { template - struct method + struct method { - using fptr_t = return_t(record_t::*)(signature_ts...) const; - - const fptr_t m_functor = nullptr; + using fptr_t = return_t (record_t::*)(signature_ts...) const; constexpr auto f_ptr() const { return m_functor; @@ -33,18 +31,30 @@ namespace rtl } template - [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept(noexcept_v) + [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept//(noexcept_v) { - static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (target.*m_functor)(std::forward(params)...); } + method(fptr_t p_functor) : m_functor(p_functor) + { } + + method() = default; + method(method&&) = default; + method(const method&) = default; + + method& operator=(method&&) = default; + method& operator=(const method&) = default; + private: + fptr_t m_functor = nullptr; + template static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - template - static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); + //template + //static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 4f60a560..8154e69b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -22,8 +22,6 @@ namespace rtl { using fptr_t = return_t (record_t::*)(signature_ts...); - const fptr_t m_functor = nullptr; - constexpr auto f_ptr() const { return m_functor; } @@ -35,16 +33,31 @@ namespace rtl template [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept //(noexcept_v) { - static_assert(is_args_t_ok, "Argument types don't match the expected signature."); + //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (target.*m_functor)(std::forward(params)...); } + method(fptr_t p_functor) : m_functor(p_functor) + { } + + method() = default; + method(method&&) = default; + method(const method&) = default; + + method& operator=(method&&) = default; + method& operator=(const method&) = default; + private: + fptr_t m_functor = nullptr; + template static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; //template //static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); + + template + friend struct dispatch::lambda_method; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt index 03494399..da69ba9b 100644 --- a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -2,8 +2,11 @@ # Collect headers in this folder (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/erasure.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erase_return.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/return_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/return_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/return_const_method.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/erasure/erasure.h b/ReflectionTemplateLib/rtl/erasure/erase_function.h similarity index 85% rename from ReflectionTemplateLib/rtl/erasure/erasure.h rename to ReflectionTemplateLib/rtl/erasure/erase_function.h index 2f5a2b29..dd6012be 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_function.h @@ -17,12 +17,16 @@ namespace rtl::erase { template - struct erasure_base + struct function { - using functor_vt = void(*)(erasure_base*, signature_ts&&...); - using functor_rt = std::any(*)(erasure_base*, signature_ts&&...); + using this_t = function; + + using functor_vt = void(*)(this_t*, signature_ts&&...); + + using functor_rt = std::any(*)(this_t*, signature_ts&&...); functor_vt v_hop = nullptr; + functor_rt r_hop = nullptr; FORCE_INLINE void hop_v(signature_ts&&...params) diff --git a/ReflectionTemplateLib/rtl/erasure/erase_method.h b/ReflectionTemplateLib/rtl/erasure/erase_method.h new file mode 100644 index 00000000..a90ffbf7 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erase_method.h @@ -0,0 +1,42 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include +#include "rtl_forward_decls.h" + +namespace rtl::erase +{ + template + struct method + { + using this_t = method; + + using functor_vt = void(*)(this_t*, const record_t&, signature_ts&&...); + + using functor_rt = std::any(*)(this_t*, const record_t&, signature_ts&&...); + + functor_vt v_hop = nullptr; + + functor_rt r_hop = nullptr; + + FORCE_INLINE void hop_v(const record_t& p_target, signature_ts&&...params) + { + v_hop(this, p_target, std::forward(params)...); + } + + FORCE_INLINE std::any hop_r(const record_t& p_target, signature_ts&&...params) + { + return r_hop(this, p_target, std::forward(params)...); + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/return_const_method.h b/ReflectionTemplateLib/rtl/erasure/return_const_method.h new file mode 100644 index 00000000..a47f8521 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/return_const_method.h @@ -0,0 +1,61 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "erase_method.h" + +namespace rtl::erase +{ + template + struct return_method : public method + { + using base_t = method; + + using this_t = return_method; + + rtl::method m_method; + + return_method() + { + base_t::v_hop = hop_v; + base_t::r_hop = hop_r; + } + + FORCE_INLINE static void hop_v(base_t* p_this, const record_t& p_target, signature_ts&&...params) + { + if constexpr (std::is_void_v) + { + auto this_p = static_cast(p_this); + this_p->m_method(p_target, std::forward(params)...); + } + } + + FORCE_INLINE static std::any hop_r(base_t* p_this, const record_t& p_target, signature_ts&&...params) + { + if constexpr (!std::is_void_v) + { + auto this_p = static_cast(p_this); + auto&& ret_v = this_p->m_method(p_target, std::forward(params)...); + + if constexpr (std::is_reference_v) + { + return std::any(&ret_v); + } + else + { + return std::any(std::forward(ret_v)); + } + } + else return std::any(); + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return.h b/ReflectionTemplateLib/rtl/erasure/return_function.h similarity index 59% rename from ReflectionTemplateLib/rtl/erasure/erase_return.h rename to ReflectionTemplateLib/rtl/erasure/return_function.h index 571cfe8d..54b2d1e0 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_return.h +++ b/ReflectionTemplateLib/rtl/erasure/return_function.h @@ -11,41 +11,50 @@ #pragma once -#include "erasure.h" -#include "rtl_traits.h" +#include "erase_function.h" #include "rtl_function.h" -#include "rtl_errors.h" -#include namespace rtl::erase { template - struct function_return : public erasure_base + struct return_function : public function { + using base_t = function; + + using this_t = return_function; + rtl::function m_function; - function_return() + return_function() { - erasure_base::v_hop = vhop; - erasure_base::r_hop = rhop; + base_t::v_hop = hop_v; + base_t::r_hop = hop_r; } - FORCE_INLINE static void vhop(erasure_base* p_this, signature_ts&&...params) + FORCE_INLINE static void hop_v(base_t* p_this, signature_ts&&...params) { if constexpr (std::is_void_v) { - auto this_p = static_cast*>(p_this); + auto this_p = static_cast(p_this); this_p->m_function(std::forward(params)...); } } - FORCE_INLINE static std::any rhop(erasure_base* p_this, signature_ts&&...params) + FORCE_INLINE static std::any hop_r(base_t* p_this, signature_ts&&...params) { if constexpr (!std::is_void_v) { - auto this_p = static_cast*>(p_this); + auto this_p = static_cast(p_this); auto&& ret_v = this_p->m_function(std::forward(params)...); - return std::any(std::forward(ret_v)); + + if constexpr (std::is_reference_v) + { + return std::any(&ret_v); + } + else + { + return std::any(std::forward(ret_v)); + } } else return std::any(); } diff --git a/ReflectionTemplateLib/rtl/erasure/return_method.h b/ReflectionTemplateLib/rtl/erasure/return_method.h new file mode 100644 index 00000000..3129c06f --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/return_method.h @@ -0,0 +1,61 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "erase_method.h" + +namespace rtl::erase +{ + template + struct return_method : public method + { + using base_t = method; + + using this_t = return_method; + + rtl::method m_method; + + return_method() + { + base_t::v_hop = hop_v; + base_t::r_hop = hop_r; + } + + FORCE_INLINE static void hop_v(base_t* p_this, const record_t& p_target, signature_ts&&...params) + { + if constexpr (std::is_void_v) + { + auto this_p = static_cast(p_this); + this_p->m_method(const_cast(p_target), std::forward(params)...); + } + } + + FORCE_INLINE static std::any hop_r(base_t* p_this, const record_t& p_target, signature_ts&&...params) + { + if constexpr (!std::is_void_v) + { + auto this_p = static_cast(p_this); + auto&& ret_v = this_p->m_method(const_cast(p_target), std::forward(params)...); + + if constexpr (std::is_reference_v) + { + return std::any(&ret_v); + } + else + { + return std::any(std::forward(ret_v)); + } + } + else return std::any(); + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index a08aade2..97822e37 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -107,12 +107,6 @@ namespace rtl { template constexpr const detail::FunctionCaller<_signature...> bind() const noexcept; - template - rtl::error ecall_v(_args&&...) const noexcept; - - template - std::any ecall_r(_args&&...) const noexcept; - friend detail::CxxReflection; friend detail::ReflectionBuilder; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 49a531d5..ebc2d6f8 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -16,11 +16,7 @@ #include "RObject.h" #include "rtl_constants.h" #include "rtl_errors.h" -#include -#include -#include -#include "erase_return.h" namespace rtl { @@ -61,34 +57,6 @@ namespace rtl } - template - FORCE_INLINE error Function::ecall_v(_args&& ...params) const noexcept - { - //m_functorIds[0].get_lambda_function<_args...>()->m_erasure->hop(std::forward<_args>(params)...); - const std::size_t argsId = detail::TypeId... >>::get(); - for (auto& functorId : m_functorIds) - { - if(argsId == functorId.m_lambda->m_functor.m_signatureId) [[likely]] - { - functorId.get_lambda_function<_args...>()->m_erasure->hop_v(std::forward<_args>(params)...); - break; - } - } - return error::None; - } - - - template - FORCE_INLINE std::any Function::ecall_r(_args&& ...params) const noexcept - { - auto functorId = getLambdaById(detail::TypeId... >>::get()); - if(functorId) { - return functorId->template get_lambda_function<_args...>()->m_erasure->hop_r(std::forward<_args>(params)...); - } - return std::any(); - } - - /* @method: hasSignatureId() @param: const std::size_t& (signatureId to be found) @return: the index of the functor in the functor-table. @@ -118,6 +86,7 @@ namespace rtl return nullptr; } + FORCE_INLINE const detail::FunctorId* Function::getLambdaById(const std::size_t pSignatureId) const { //simple linear-search, efficient for small set of elements. diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 18cf1ea3..f4249ca5 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -69,14 +69,10 @@ namespace rtl { template const detail::NonConstInvoker<_signature...> bind(constCast&& pTarget) const; - /* @method: operator()() - @return: lambda - * accepts no arguments for 'target', since associated functor is static-member-functions. - * returns a lambda, which forwards the call to finally call the associated static-member-function functor. - * provides syntax like,'method()(params...)', first'()' is empty & second'()' takes the actual params. - */ constexpr auto operator()() const + template + constexpr detail::ErasedInvoker<_recordType> operator()(const _recordType& pTarget) const { - return detail::FunctionCaller<>{ this }; + return detail::ErasedInvoker<_recordType>{ (*this), pTarget }; } @@ -105,5 +101,8 @@ namespace rtl { template friend struct detail::NonConstInvoker; + + template + friend struct detail::ErasedInvoker; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 36e30570..5d5c391e 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -34,13 +34,16 @@ namespace rtl namespace erase { template - struct erasure_base; - - template struct function; - template - struct method; + template + struct method; + + template + struct return_function; + + template + struct return_method; } namespace detail @@ -62,7 +65,7 @@ namespace rtl template struct lambda_function; - template + template struct lambda_method; } From 7eb3dd6f38b3b48dfa5f97dbc88177f9b08b7742 Mon Sep 17 00:00:00 2001 From: neeraj Date: Mon, 29 Sep 2025 12:26:12 +0530 Subject: [PATCH 048/148] gcc/clang compile error fix. --- .../src/ReflectedCallUnknownReturn.cpp | 2 +- .../rtl/detail/inc/FunctionCaller.h | 6 +---- .../rtl/detail/inc/FunctionCaller.hpp | 2 +- .../rtl/detail/inc/MethodInvoker.h | 20 +++----------- .../rtl/detail/inc/MethodInvoker.hpp | 26 +++++++++++++++++++ .../rtl/dispatch/rtl_function.h | 3 --- .../rtl/dispatch/rtl_method.h | 3 --- 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index a4408980..3c65fee9 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -162,7 +162,7 @@ void RtlFunction_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) for (auto _ : state) { NodeSendMessage(node).call_v(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index f4e1fd65..2ec2e6c2 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -22,8 +22,6 @@ namespace rtl::detail { const Function* m_function; - public: - template rtl::Return call(_args&&...) const noexcept; @@ -31,12 +29,10 @@ namespace rtl::detail constexpr rtl::Return operator()(_args&&...params) const noexcept; template - rtl::error call_v(_args&&...) const noexcept; + constexpr rtl::error call_v(_args&&...) const noexcept; template std::any call_r(_args&&...) const noexcept; - - friend Function; }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 5ce082e0..491a9c89 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -46,7 +46,7 @@ namespace rtl::detail template template - FORCE_INLINE error FunctionCaller<_signature...>::call_v(_args&& ...params) const noexcept + constexpr error FunctionCaller<_signature...>::call_v(_args&& ...params) const noexcept { auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 0e32e36f..02cc947b 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -13,7 +13,7 @@ #include "erase_method.h" -namespace rtl::detail +namespace rtl::detail { template struct ErasedInvoker @@ -23,24 +23,10 @@ namespace rtl::detail const _recordType& m_target; template - constexpr error call_v(_args&&...params) const noexcept - { - auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); - if (functorId) [[likely]] { - functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->hop_v(m_target, std::forward<_args>(params)...); - } - return error::None; - } + constexpr error call_v(_args&&...params) const noexcept; template - constexpr std::any call_r(_args&&...params) const noexcept - { - auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); - if (functorId) [[likely]] { - return functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->hop_r(m_target, std::forward<_args>(params)...); - } - return std::any(); - } + std::any call_r(_args&&...params) const noexcept; }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 6f7d9074..c8e6d4ee 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -180,4 +180,30 @@ namespace rtl::detail } return method<_returnType(_recordType::*)(_signature...)>(); } +} + + +namespace rtl::detail +{ + template + template + constexpr error ErasedInvoker<_recordType>::call_v(_args&&...params) const noexcept + { + auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + if (functorId) [[likely]] { + functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->hop_v(m_target, std::forward<_args>(params)...); + } + return error::None; + } + + template + template + FORCE_INLINE std::any ErasedInvoker<_recordType>::call_r(_args&&...params) const noexcept + { + auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + if (functorId) [[likely]] { + return functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->hop_r(m_target, std::forward<_args>(params)...); + } + return std::any(); + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index edcdea67..f08071de 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -55,8 +55,5 @@ namespace rtl //template //static constexpr bool noexcept_v = noexcept(std::declval()(std::declval()...)); - - template - friend struct dispatch::lambda_function; }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 8154e69b..0f60353a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -56,8 +56,5 @@ namespace rtl //template //static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); - - template - friend struct dispatch::lambda_method; }; } \ No newline at end of file From 5a81261124603bdd3915a30c5694562c4f60bd00 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 29 Sep 2025 20:42:10 +0530 Subject: [PATCH 049/148] general refactor, restructure, renames. --- .../src/ReflectedCallKnownReturn.cpp | 4 +-- .../src/ReflectedCallUnknownReturn.cpp | 4 +-- .../rtl/builder/FunctorContainer.h | 4 +-- .../rtl/builder/MethodContainer.h | 6 ++-- .../rtl/builder/RObjectBuilder.hpp | 6 ++-- .../rtl/builder/SetupMethod.hpp | 2 +- .../rtl/cache/CMakeLists.txt | 5 ++-- .../rtl/cache/cache_function_ptr.h | 2 +- .../rtl/cache/cache_lambda_function.h | 16 +++++----- .../rtl/cache/cache_lambda_method.h | 18 +++++------ .../rtl/cache/cache_method_ptr.h | 2 +- ..._method_ptr.h => cache_method_ptr_const.h} | 2 +- .../rtl/detail/inc/CallReflector.h | 8 ++--- .../rtl/detail/inc/FunctionCaller.hpp | 10 +++---- .../rtl/detail/inc/MethodInvoker.h | 2 +- .../rtl/detail/inc/MethodInvoker.hpp | 14 ++++----- .../rtl/detail/inc/RObjExtracter.h | 10 +++---- .../rtl/detail/inc/RObjectId.h | 4 +-- .../rtl/dispatch/CMakeLists.txt | 11 +++---- .../{function_ptr.h => functor_function.h} | 0 .../{method_ptr.h => functor_method.h} | 0 ...st_method_ptr.h => functor_method_const.h} | 0 .../rtl/dispatch/lambda_function.h | 15 +++------- .../rtl/dispatch/lambda_method.h | 18 ++++------- ...{rtl_const_method.h => rtl_method_const.h} | 0 .../rtl/erasure/CMakeLists.txt | 12 ++++---- .../{return_function.h => aware_function.h} | 30 +++++++++---------- .../{return_method.h => aware_method.h} | 28 ++++++++--------- ...rn_const_method.h => aware_method_const.h} | 28 ++++++++--------- .../{erase_function.h => erased_function.h} | 30 ++++++++++--------- .../{erase_method.h => erased_method.h} | 30 ++++++++++--------- ReflectionTemplateLib/rtl/inc/Function.hpp | 6 ++-- ReflectionTemplateLib/rtl/inc/Method.hpp | 4 +-- ReflectionTemplateLib/rtl/inc/RObject.hpp | 8 ++--- ReflectionTemplateLib/rtl/rtl_constants.h | 6 ++-- ReflectionTemplateLib/rtl/rtl_errors.h | 2 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 8 ++--- ReflectionTemplateLib/rtl/rtl_typeid.h | 8 ++--- 38 files changed, 175 insertions(+), 188 deletions(-) rename ReflectionTemplateLib/rtl/cache/{cache_const_method_ptr.h => cache_method_ptr_const.h} (98%) rename ReflectionTemplateLib/rtl/dispatch/{function_ptr.h => functor_function.h} (100%) rename ReflectionTemplateLib/rtl/dispatch/{method_ptr.h => functor_method.h} (100%) rename ReflectionTemplateLib/rtl/dispatch/{const_method_ptr.h => functor_method_const.h} (100%) rename ReflectionTemplateLib/rtl/dispatch/{rtl_const_method.h => rtl_method_const.h} (100%) rename ReflectionTemplateLib/rtl/erasure/{return_function.h => aware_function.h} (66%) rename ReflectionTemplateLib/rtl/erasure/{return_method.h => aware_method.h} (65%) rename ReflectionTemplateLib/rtl/erasure/{return_const_method.h => aware_method_const.h} (63%) rename ReflectionTemplateLib/rtl/erasure/{erase_function.h => erased_function.h} (57%) rename ReflectionTemplateLib/rtl/erasure/{erase_method.h => erased_method.h} (54%) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 7dd43790..f03456ba 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -25,7 +25,7 @@ namespace std::optional function = cxx::mirror().getFunction("getMessage"); if(!function) { - std::cerr << "[00] error: function 'getMessage' not found."; + std::cerr << "[00] error: erase_function 'getMessage' not found."; std::abort(); } return function->lambda().argsT().returnT(); @@ -36,7 +36,7 @@ namespace std::optional function = cxx::mirror().getFunction("sendMessage"); if(!function) { - std::cerr << "[01] error: function 'sendMessage' not found."; + std::cerr << "[01] error: erase_function 'sendMessage' not found."; std::abort(); } return function->lambda().argsT().returnT(); diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 3c65fee9..81e287b1 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -21,7 +21,7 @@ namespace { std::optional function = cxx::mirror().getFunction("getMessage"); if (!function) { - std::cerr << "[0] error: function 'getMessage' not found.\n"; + std::cerr << "[0] error: erase_function 'getMessage' not found.\n"; std::abort(); } return *function; @@ -31,7 +31,7 @@ namespace { std::optional function = cxx::mirror().getFunction("sendMessage"); if (!function) { - std::cerr << "[1] error: function 'sendMessage' not found.\n"; + std::cerr << "[1] error: erase_function 'sendMessage' not found.\n"; std::abort(); } return *function; diff --git a/ReflectionTemplateLib/rtl/builder/FunctorContainer.h b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h index 31c1e82f..f2109e41 100644 --- a/ReflectionTemplateLib/rtl/builder/FunctorContainer.h +++ b/ReflectionTemplateLib/rtl/builder/FunctorContainer.h @@ -41,13 +41,13 @@ namespace rtl { public: //every FunctorContainer<...> will have a unique-id. - FORCE_INLINE static std::size_t getContainerId() { + ForceInline static std::size_t getContainerId() { static const std::size_t containerId = generate_unique_id(); return containerId; } //get the vector holding lambdas as 'const-ref' - FORCE_INLINE const static std::vector& getOverloads() { + ForceInline const static std::vector& getOverloads() { static std::vector& functorTable = getFunctorTable(); return functorTable; } diff --git a/ReflectionTemplateLib/rtl/builder/MethodContainer.h b/ReflectionTemplateLib/rtl/builder/MethodContainer.h index 0a84ffd6..a542b033 100644 --- a/ReflectionTemplateLib/rtl/builder/MethodContainer.h +++ b/ReflectionTemplateLib/rtl/builder/MethodContainer.h @@ -52,7 +52,7 @@ namespace rtl { } //get the vector holding lambdas as 'const-ref' - FORCE_INLINE static const std::vector& getMethodFunctors() { + ForceInline static const std::vector& getMethodFunctors() { static std::vector& functorTable = getFunctorTable(); return functorTable; } @@ -118,14 +118,14 @@ namespace rtl { public: //every MethodContainer will have a unique-id. - FORCE_INLINE static std::size_t getContainerId() { + ForceInline static std::size_t getContainerId() { //holds unique-id static const std::size_t containerId = generate_unique_id(); return containerId; } //get the vector holding lambdas as 'const-ref' - FORCE_INLINE static const std::vector& getMethodFunctors() { + ForceInline static const std::vector& getMethodFunctors() { static std::vector& functorTable = getFunctorTable(); return functorTable; } diff --git a/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp b/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp index ded14dad..1504f405 100644 --- a/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp @@ -20,7 +20,7 @@ namespace rtl::detail { template - FORCE_INLINE const std::vector& getConverters() noexcept + ForceInline const std::vector& getConverters() noexcept { // extract wrapper info. using _W = traits::std_wrapper>; @@ -32,7 +32,7 @@ namespace rtl::detail template template requires (_allocOn == alloc::Heap) - FORCE_INLINE RObject RObjectBuilder::build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept + ForceInline RObject RObjectBuilder::build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept { using _T = traits::raw_t; return RObject( std::any{ @@ -46,7 +46,7 @@ namespace rtl::detail template template requires (_allocOn == alloc::Stack) - FORCE_INLINE RObject RObjectBuilder::build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept + ForceInline RObject RObjectBuilder::build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept { using _T = traits::raw_t; constexpr bool isRawPointer = std::is_pointer_v>; diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 69661226..2957d82b 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -20,7 +20,7 @@ #include "lambda_method.h" #include "cache_method_ptr.h" -#include "cache_const_method_ptr.h" +#include "cache_method_ptr_const.h" #include "cache_lambda_method.h" namespace rtl::detail diff --git a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt index 4e5af74d..b301f6a4 100644 --- a/ReflectionTemplateLib/rtl/cache/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/cache/CMakeLists.txt @@ -4,9 +4,10 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/cache_lambda_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/cache_lambda_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/cache_function_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_method_ptr.h" - "${CMAKE_CURRENT_SOURCE_DIR}/cache_const_method_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_function_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/cache_method_ptr_const.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index 34c40f4b..fd012ac2 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -13,7 +13,7 @@ #include -#include "function_ptr.h" +#include "functor_function.h" namespace rtl::cache { diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index 6318614f..4e3095fc 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -14,7 +14,7 @@ #include #include "lambda_function.h" -#include "return_function.h" +#include "aware_function.h" namespace rtl::cache { @@ -27,15 +27,15 @@ namespace rtl::cache return instance_; } - const dispatch::lambda_function& push(const dispatch::functor& fptr) const + const dispatch::lambda_function& push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(erase::return_function()); - erase::function* erasure = &m_erasure_cache.back(); + m_erasure_cache.push_back(erase::aware_function()); + erase::erased_function* erasure = &m_erasure_cache.back(); - m_cache.push_back(dispatch::lambda_function(fptr, erasure)); - fptr.m_lambda = &m_cache.back(); + m_cache.push_back(dispatch::lambda_function(p_functor, erasure)); + p_functor.m_lambda = &m_cache.back(); - (m_cache.back()).template init_erasure(); + (m_erasure_cache.back()).m_function = m_cache.back().template get_hopper(); return m_cache.back(); } @@ -48,7 +48,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_function() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index 28a6c235..50e00856 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -13,9 +13,9 @@ #include +#include "aware_method.h" #include "lambda_method.h" -#include "return_method.h" -#include "return_const_method.h" +#include "aware_method_const.h" namespace rtl::cache { @@ -28,15 +28,15 @@ namespace rtl::cache return instance_; } - const dispatch::lambda_method& push(const dispatch::functor& fptr) const + const dispatch::lambda_method& push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(erase::return_method()); - erase::method* erasure = &m_erasure_cache.back(); + m_erasure_cache.push_back(erase::aware_method()); + erase::erased_method* erasure = &m_erasure_cache.back(); - m_cache.push_back(dispatch::lambda_method(fptr, erasure)); - fptr.m_lambda = &m_cache.back(); + m_cache.push_back(dispatch::lambda_method(p_functor, erasure)); + p_functor.m_lambda = &m_cache.back(); - (m_cache.back()).template init_erasure(); + (m_erasure_cache.back()).m_method = m_cache.back().template get_hopper(); return m_cache.back(); } @@ -50,7 +50,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_method() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h index 59ce1144..bfe749f7 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h @@ -13,7 +13,7 @@ #include -#include "method_ptr.h" +#include "functor_method.h" namespace rtl::cache { diff --git a/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h similarity index 98% rename from ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h rename to ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h index 3cc9783d..3a548048 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_const_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h @@ -13,7 +13,7 @@ #include -#include "const_method_ptr.h" +#include "functor_method_const.h" namespace rtl::cache { diff --git a/ReflectionTemplateLib/rtl/detail/inc/CallReflector.h b/ReflectionTemplateLib/rtl/detail/inc/CallReflector.h index 775b6786..98f77596 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/CallReflector.h +++ b/ReflectionTemplateLib/rtl/detail/inc/CallReflector.h @@ -31,7 +31,7 @@ namespace rtl::detail { * gets the lambda vector from '_derivedType' and calls the lambda at given index with '_args'. * this 'forwardCall' is for calling lambda containing non-member-function and static-member-function functors. */ template - FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, _params&&..._args) + ForceInline static Return forwardCall(const detail::FunctorId& pFunctorId, _params&&..._args) { //'getOverloads()' must be implemented by _derivedType (FunctorContainer). return _derivedType::getOverloads()[pFunctorId.m_lambdaIndex](pFunctorId, std::forward<_params>(_args)...); @@ -43,7 +43,7 @@ namespace rtl::detail { * gets the lambda vector from '_derivedType' and calls the lambda at given index with '_args'. * this 'forwardCall' is for calling lambda containing constructors. */ template - FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, rtl::alloc pAllocType, const detail::FunctorId& pClonerId, _params&&..._args) + ForceInline static Return forwardCall(const detail::FunctorId& pFunctorId, rtl::alloc pAllocType, const detail::FunctorId& pClonerId, _params&&..._args) { //'getOverloads()' must be implemented by _derivedType (FunctorContainer). return _derivedType::getOverloads()[pFunctorId.m_lambdaIndex](pFunctorId, pAllocType, pClonerId, std::forward<_params>(_args)...); @@ -51,7 +51,7 @@ namespace rtl::detail { template - FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, const RObject& pSrcObj, rtl::alloc pAllocType) + ForceInline static Return forwardCall(const detail::FunctorId& pFunctorId, const RObject& pSrcObj, rtl::alloc pAllocType) { //'getOverloads()' must be implemented by _derivedType (FunctorContainer). return _derivedType::getOverloads()[pFunctorId.m_lambdaIndex](pFunctorId, pSrcObj, pAllocType); @@ -63,7 +63,7 @@ namespace rtl::detail { * gets the lambda vector from '_derivedType' and calls the lambda at given index with '_args'. * this 'forwardCall' is for calling lambda containing member-function functors. */ template - FORCE_INLINE static Return forwardCall(const detail::FunctorId& pFunctorId, const rtl::RObject& pTarget, _params&&..._args) + ForceInline static Return forwardCall(const detail::FunctorId& pFunctorId, const rtl::RObject& pTarget, _params&&..._args) { //'getMethodFunctors()' is implemented by _derivedType (MethodContainer) return _derivedType::getMethodFunctors()[pFunctorId.m_lambdaIndex](pFunctorId, pTarget, std::forward<_params>(_args)...); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 491a9c89..b322b959 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -16,13 +16,13 @@ #include "FunctionCaller.h" #include "FunctorContainer.h" -#include "erase_function.h" +#include "erased_function.h" namespace rtl::detail { template template - FORCE_INLINE Return FunctionCaller<_signature...>::call(_args&&...params) const noexcept + ForceInline Return FunctionCaller<_signature...>::call(_args&&...params) const noexcept { using Container = std::conditional_t...>, @@ -50,7 +50,7 @@ namespace rtl::detail { auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { - functorId->template get_lambda_function<_args...>()->m_erasure->hop_v(std::forward<_args>(params)...); + functorId->template get_lambda_function<_args...>()->m_erasure->void_hop(std::forward<_args>(params)...); } return error::None; } @@ -58,11 +58,11 @@ namespace rtl::detail template template - FORCE_INLINE std::any FunctionCaller<_signature...>::call_r(_args&& ...params) const noexcept + ForceInline std::any FunctionCaller<_signature...>::call_r(_args&& ...params) const noexcept { auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { - return functorId->template get_lambda_function<_args...>()->m_erasure->hop_r(std::forward<_args>(params)...); + return functorId->template get_lambda_function<_args...>()->m_erasure->return_hop(std::forward<_args>(params)...); } return std::any(); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 02cc947b..2e7f529e 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -11,7 +11,7 @@ #pragma once -#include "erase_method.h" +#include "erased_method.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index c8e6d4ee..4c1dbb13 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -24,7 +24,7 @@ namespace rtl::detail * invokes non-static-member-function functor associated with 'm_method' on object 'm_target'. */ template template - FORCE_INLINE Return DefaultInvoker<_signature...>::call(_args&& ...params) const noexcept + ForceInline Return DefaultInvoker<_signature...>::call(_args&& ...params) const noexcept { //Only static-member-functions have Qualifier- 'methodQ::None' if (m_method->getQualifier() == methodQ::None) [[unlikely]] { @@ -55,7 +55,7 @@ namespace rtl::detail template template template - FORCE_INLINE Return + ForceInline Return DefaultInvoker<_signature...>::Invoker<_invokSignature...>::invoke(const Method& pMethod, const RObject& pTarget, _args&&... params) @@ -93,7 +93,7 @@ namespace rtl::detail * invokes non-static-member-function functor associated with 'm_method' on object 'm_target'. */ template template - FORCE_INLINE Return NonConstInvoker<_signature...>::call(_args&& ...params) const noexcept + ForceInline Return NonConstInvoker<_signature...>::call(_args&& ...params) const noexcept { if (m_method->getQualifier() == methodQ::None) [[unlikely]] { return static_cast(*m_method).bind().call(std::forward<_args>(params)...); @@ -122,7 +122,7 @@ namespace rtl::detail template template template - FORCE_INLINE Return + ForceInline Return NonConstInvoker<_signature...>::Invoker<_invokSignature...>::invoke(const Method& pMethod, const RObject& pTarget, _args&&... params) @@ -191,18 +191,18 @@ namespace rtl::detail { auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { - functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->hop_v(m_target, std::forward<_args>(params)...); + functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->void_hop(m_target, std::forward<_args>(params)...); } return error::None; } template template - FORCE_INLINE std::any ErasedInvoker<_recordType>::call_r(_args&&...params) const noexcept + ForceInline std::any ErasedInvoker<_recordType>::call_r(_args&&...params) const noexcept { auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { - return functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->hop_r(m_target, std::forward<_args>(params)...); + return functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->return_hop(m_target, std::forward<_args>(params)...); } return std::any(); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/RObjExtracter.h b/ReflectionTemplateLib/rtl/detail/inc/RObjExtracter.h index 8f1c11ef..14ab3623 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/RObjExtracter.h +++ b/ReflectionTemplateLib/rtl/detail/inc/RObjExtracter.h @@ -22,7 +22,7 @@ namespace rtl::detail const RObject* m_rObj; template - FORCE_INLINE static const T* getPointer(const std::any& pObject, const EntityKind pEntityKind) noexcept + ForceInline static const T* getPointer(const std::any& pObject, const EntityKind pEntityKind) noexcept { switch (pEntityKind) { @@ -39,7 +39,7 @@ namespace rtl::detail template - FORCE_INLINE const T* getPointer() const noexcept + ForceInline const T* getPointer() const noexcept { switch (m_rObj->m_objectId.m_containsAs) { @@ -59,7 +59,7 @@ namespace rtl::detail template = 0> - FORCE_INLINE auto getWrapper() const noexcept -> const RObjectUPtr::value_type>* + ForceInline auto getWrapper() const noexcept -> const RObjectUPtr::value_type>* { if (m_rObj->m_objectId.m_wrapperType == detail::Wrapper::Unique) { @@ -83,7 +83,7 @@ namespace rtl::detail template = 0> - FORCE_INLINE const T* getWrapper() const noexcept + ForceInline const T* getWrapper() const noexcept { if (m_rObj->m_objectId.m_wrapperType == detail::Wrapper::Shared) { @@ -106,7 +106,7 @@ namespace rtl::detail template - FORCE_INLINE const T* getFromWrapper() const noexcept + ForceInline const T* getFromWrapper() const noexcept { if constexpr (std::is_destructible_v) { diff --git a/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h index cab52049..bb43306b 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h @@ -39,7 +39,7 @@ namespace rtl::detail GETTER(EntityKind, ContainedAs, m_containsAs) template - FORCE_INLINE static constexpr EntityKind getEntityKind() noexcept + ForceInline static constexpr EntityKind getEntityKind() noexcept { using W = traits::std_wrapper>; using _T = traits::raw_t>; @@ -59,7 +59,7 @@ namespace rtl::detail template - FORCE_INLINE static RObjectId create(std::optional pClonerId, bool pIsConstCastSafe) noexcept + ForceInline static RObjectId create(std::optional pClonerId, bool pIsConstCastSafe) noexcept { // extract wrapper info. using _W = traits::std_wrapper>; diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index cf3b911f..efec0dc1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -4,17 +4,18 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/functor.h" - "${CMAKE_CURRENT_SOURCE_DIR}/function_ptr.h" - "${CMAKE_CURRENT_SOURCE_DIR}/method_ptr.h" - "${CMAKE_CURRENT_SOURCE_DIR}/const_method_ptr.h" + + "${CMAKE_CURRENT_SOURCE_DIR}/functor_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/functor_method_const.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_const_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/functor_function.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/function_ptr.h rename to ReflectionTemplateLib/rtl/dispatch/functor_function.h diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/functor_method.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/method_ptr.h rename to ReflectionTemplateLib/rtl/dispatch/functor_method.h diff --git a/ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/const_method_ptr.h rename to ReflectionTemplateLib/rtl/dispatch/functor_method_const.h diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index efd7d7df..2e62c42d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -12,9 +12,9 @@ #pragma once #include "lambda.h" -#include "function_ptr.h" #include "rtl_function.h" -#include "return_function.h" +#include "functor_function.h" +#include "erased_function.h" namespace rtl::dispatch { @@ -24,20 +24,13 @@ namespace rtl::dispatch template using hopper_t = rtl::function; - erase::function* m_erasure; + erase::erased_function* m_erasure; - lambda_function(const functor& p_functor, erase::function* p_erasure) noexcept + lambda_function(const functor& p_functor, erase::erased_function* p_erasure) noexcept : lambda_base(p_functor) , m_erasure(p_erasure) { } - template - constexpr void init_erasure() const - { - auto erasure = static_cast*>(m_erasure); - erasure->m_function = get_hopper(); - } - template constexpr const hopper_t get_hopper(const std::size_t p_returnId = 0) const { diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index cfc3d954..6e5c1cc6 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -12,11 +12,10 @@ #pragma once #include "lambda.h" -#include "method_ptr.h" #include "rtl_method.h" -#include "rtl_const_method.h" -#include "return_method.h" -#include "return_const_method.h" +#include "erased_method.h" +#include "functor_method.h" +#include "rtl_method_const.h" namespace rtl::dispatch @@ -30,20 +29,13 @@ namespace rtl::dispatch template using hopper_ct = rtl::method; - erase::method* m_erasure; + erase::erased_method* m_erasure; - lambda_method(const functor& p_functor, erase::method* p_erasure) noexcept + lambda_method(const functor& p_functor, erase::erased_method* p_erasure) noexcept : lambda_base(p_functor) , m_erasure(p_erasure) { } - template - constexpr void init_erasure() const - { - auto erasure = static_cast*>(m_erasure); - erasure->m_method = get_hopper(); - } - template requires (std::is_const_v == false) constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/rtl_const_method.h rename to ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt index da69ba9b..b2f4a6d3 100644 --- a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -2,11 +2,13 @@ # Collect headers in this folder (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/erase_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erase_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/return_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/return_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/return_const_method.h" + + "${CMAKE_CURRENT_SOURCE_DIR}/erased_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erased_function.h" + + "${CMAKE_CURRENT_SOURCE_DIR}/aware_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_method_const.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/erasure/return_function.h b/ReflectionTemplateLib/rtl/erasure/aware_function.h similarity index 66% rename from ReflectionTemplateLib/rtl/erasure/return_function.h rename to ReflectionTemplateLib/rtl/erasure/aware_function.h index 54b2d1e0..b139055d 100644 --- a/ReflectionTemplateLib/rtl/erasure/return_function.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_function.h @@ -11,48 +11,46 @@ #pragma once -#include "erase_function.h" +#include "erased_function.h" #include "rtl_function.h" namespace rtl::erase { template - struct return_function : public function + struct aware_function : public erased_function { - using base_t = function; + rtl::function m_function; - using this_t = return_function; + using base_t = erased_function; - rtl::function m_function; + using this_t = aware_function; - return_function() + aware_function() { - base_t::v_hop = hop_v; - base_t::r_hop = hop_r; + base_t::hop_void = void_hop; + base_t::hop_return = return_hop; } - FORCE_INLINE static void hop_v(base_t* p_this, signature_ts&&...params) + constexpr static void void_hop(const base_t* p_this, signature_ts&&...params) noexcept { if constexpr (std::is_void_v) { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); this_p->m_function(std::forward(params)...); } } - FORCE_INLINE static std::any hop_r(base_t* p_this, signature_ts&&...params) + ForceInline static std::any return_hop(const base_t* p_this, signature_ts&&...params) noexcept { if constexpr (!std::is_void_v) { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); auto&& ret_v = this_p->m_function(std::forward(params)...); - if constexpr (std::is_reference_v) - { + if constexpr (std::is_reference_v) { return std::any(&ret_v); } - else - { + else { return std::any(std::forward(ret_v)); } } diff --git a/ReflectionTemplateLib/rtl/erasure/return_method.h b/ReflectionTemplateLib/rtl/erasure/aware_method.h similarity index 65% rename from ReflectionTemplateLib/rtl/erasure/return_method.h rename to ReflectionTemplateLib/rtl/erasure/aware_method.h index 3129c06f..784cfb65 100644 --- a/ReflectionTemplateLib/rtl/erasure/return_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method.h @@ -11,47 +11,45 @@ #pragma once -#include "erase_method.h" +#include "erased_method.h" namespace rtl::erase { template - struct return_method : public method + struct aware_method : public erased_method { - using base_t = method; + using base_t = erased_method; - using this_t = return_method; + using this_t = aware_method; rtl::method m_method; - return_method() + aware_method() { - base_t::v_hop = hop_v; - base_t::r_hop = hop_r; + base_t::hop_void = void_hop; + base_t::hop_return = return_hop; } - FORCE_INLINE static void hop_v(base_t* p_this, const record_t& p_target, signature_ts&&...params) + constexpr static void void_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { if constexpr (std::is_void_v) { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); this_p->m_method(const_cast(p_target), std::forward(params)...); } } - FORCE_INLINE static std::any hop_r(base_t* p_this, const record_t& p_target, signature_ts&&...params) + ForceInline static std::any return_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { if constexpr (!std::is_void_v) { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); auto&& ret_v = this_p->m_method(const_cast(p_target), std::forward(params)...); - if constexpr (std::is_reference_v) - { + if constexpr (std::is_reference_v) { return std::any(&ret_v); } - else - { + else { return std::any(std::forward(ret_v)); } } diff --git a/ReflectionTemplateLib/rtl/erasure/return_const_method.h b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h similarity index 63% rename from ReflectionTemplateLib/rtl/erasure/return_const_method.h rename to ReflectionTemplateLib/rtl/erasure/aware_method_const.h index a47f8521..5caedf3a 100644 --- a/ReflectionTemplateLib/rtl/erasure/return_const_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h @@ -11,47 +11,45 @@ #pragma once -#include "erase_method.h" +#include "erased_method.h" namespace rtl::erase { template - struct return_method : public method + struct aware_method : public erased_method { - using base_t = method; + using base_t = erased_method; - using this_t = return_method; + using this_t = aware_method; rtl::method m_method; - return_method() + aware_method() { - base_t::v_hop = hop_v; - base_t::r_hop = hop_r; + base_t::v_hop = void_hop; + base_t::r_hop = return_hop; } - FORCE_INLINE static void hop_v(base_t* p_this, const record_t& p_target, signature_ts&&...params) + constexpr static void void_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { if constexpr (std::is_void_v) { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); this_p->m_method(p_target, std::forward(params)...); } } - FORCE_INLINE static std::any hop_r(base_t* p_this, const record_t& p_target, signature_ts&&...params) + ForceInline static std::any return_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { if constexpr (!std::is_void_v) { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); auto&& ret_v = this_p->m_method(p_target, std::forward(params)...); - if constexpr (std::is_reference_v) - { + if constexpr (std::is_reference_v) { return std::any(&ret_v); } - else - { + else { return std::any(std::forward(ret_v)); } } diff --git a/ReflectionTemplateLib/rtl/erasure/erase_function.h b/ReflectionTemplateLib/rtl/erasure/erased_function.h similarity index 57% rename from ReflectionTemplateLib/rtl/erasure/erase_function.h rename to ReflectionTemplateLib/rtl/erasure/erased_function.h index dd6012be..30050564 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_function.h @@ -17,26 +17,28 @@ namespace rtl::erase { template - struct function + struct erased_function { - using this_t = function; + constexpr void void_hop(signature_ts&&...params) const noexcept + { + (*hop_void)(this, std::forward(params)...); + } - using functor_vt = void(*)(this_t*, signature_ts&&...); + ForceInline std::any return_hop(signature_ts&&...params) const noexcept + { + return (*hop_return)(this, std::forward(params)...); + } - using functor_rt = std::any(*)(this_t*, signature_ts&&...); + protected: - functor_vt v_hop = nullptr; + using this_t = erased_function; - functor_rt r_hop = nullptr; + using functor_vt = void(*)(const this_t*, signature_ts&&...); - FORCE_INLINE void hop_v(signature_ts&&...params) - { - v_hop(this, std::forward(params)...); - } + using functor_rt = std::any(*)(const this_t*, signature_ts&&...); - FORCE_INLINE std::any hop_r(signature_ts&&...params) - { - return r_hop(this, std::forward(params)...); - } + functor_vt hop_void = nullptr; + + functor_rt hop_return = nullptr; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method.h similarity index 54% rename from ReflectionTemplateLib/rtl/erasure/erase_method.h rename to ReflectionTemplateLib/rtl/erasure/erased_method.h index a90ffbf7..56050586 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method.h @@ -17,26 +17,28 @@ namespace rtl::erase { template - struct method + struct erased_method { - using this_t = method; + constexpr void void_hop(const record_t& p_target, signature_ts&&...params) const noexcept + { + (*hop_void)(this, p_target, std::forward(params)...); + } - using functor_vt = void(*)(this_t*, const record_t&, signature_ts&&...); + ForceInline std::any return_hop(const record_t& p_target, signature_ts&&...params) const noexcept + { + return (*hop_return)(this, p_target, std::forward(params)...); + } - using functor_rt = std::any(*)(this_t*, const record_t&, signature_ts&&...); + protected: - functor_vt v_hop = nullptr; + using this_t = erased_method; - functor_rt r_hop = nullptr; + using functor_vt = void(*)(const this_t*, const record_t&, signature_ts&&...); - FORCE_INLINE void hop_v(const record_t& p_target, signature_ts&&...params) - { - v_hop(this, p_target, std::forward(params)...); - } + using functor_rt = std::any(*)(const this_t*, const record_t&, signature_ts&&...); - FORCE_INLINE std::any hop_r(const record_t& p_target, signature_ts&&...params) - { - return r_hop(this, p_target, std::forward(params)...); - } + functor_vt hop_void = nullptr; + + functor_rt hop_return = nullptr; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index ebc2d6f8..e728d6c4 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -63,7 +63,7 @@ namespace rtl * a 'Function' object may be associated with multiple functors in case of overloads. * every overload will have unique 'FunctorId', contained by one 'Function' object. * given signatureId is compared against the signatureId of all overloads registered. -*/ FORCE_INLINE const std::size_t Function::hasSignatureId(const std::size_t pSignatureId) const +*/ ForceInline const std::size_t Function::hasSignatureId(const std::size_t pSignatureId) const { //simple linear-search, efficient for small set of elements. for (const auto& functorId : m_functorIds) { @@ -75,7 +75,7 @@ namespace rtl } - FORCE_INLINE const detail::FunctorId* Function::hasFunctorId(const std::size_t pSignatureId) const + ForceInline const detail::FunctorId* Function::hasFunctorId(const std::size_t pSignatureId) const { //simple linear-search, efficient for small set of elements. for (const auto& functorId : m_functorIds) { @@ -87,7 +87,7 @@ namespace rtl } - FORCE_INLINE const detail::FunctorId* Function::getLambdaById(const std::size_t pSignatureId) const + ForceInline const detail::FunctorId* Function::getLambdaById(const std::size_t pSignatureId) const { //simple linear-search, efficient for small set of elements. for (const auto& functorId : m_functorIds) { diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 91f7c56f..9e63f222 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -16,14 +16,14 @@ namespace rtl { template - FORCE_INLINE const detail::DefaultInvoker<_signature...> Method::bind(const RObject& pTarget) const + ForceInline const detail::DefaultInvoker<_signature...> Method::bind(const RObject& pTarget) const { return detail::DefaultInvoker<_signature...>{ this, &pTarget }; } template - FORCE_INLINE const detail::NonConstInvoker<_signature...> Method::bind(constCast&& pTarget) const + ForceInline const detail::NonConstInvoker<_signature...> Method::bind(constCast&& pTarget) const { return detail::NonConstInvoker<_signature...>{ this, &pTarget.m_target }; } diff --git a/ReflectionTemplateLib/rtl/inc/RObject.hpp b/ReflectionTemplateLib/rtl/inc/RObject.hpp index 51091c24..35802478 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.hpp +++ b/ReflectionTemplateLib/rtl/inc/RObject.hpp @@ -25,7 +25,7 @@ namespace rtl { - FORCE_INLINE RObject::RObject(std::any&& pObject, detail::RObjectId&& pRObjId, + ForceInline RObject::RObject(std::any&& pObject, detail::RObjectId&& pRObjId, const std::vector* pConverters) noexcept : m_object(std::in_place, std::move(pObject)) , m_objectId(pRObjId) @@ -120,7 +120,7 @@ namespace rtl template , int>> - FORCE_INLINE std::optional> RObject::view() const noexcept + ForceInline std::optional> RObject::view() const noexcept { if (isEmpty()) { return std::nullopt; @@ -140,7 +140,7 @@ namespace rtl template , int>> - FORCE_INLINE std::optional> RObject::view() const noexcept + ForceInline std::optional> RObject::view() const noexcept { if (isEmpty()) { return std::nullopt; @@ -161,7 +161,7 @@ namespace rtl template , int>> - FORCE_INLINE std::optional> RObject::view() const noexcept + ForceInline std::optional> RObject::view() const noexcept { if (isEmpty()) { return std::nullopt; diff --git a/ReflectionTemplateLib/rtl/rtl_constants.h b/ReflectionTemplateLib/rtl/rtl_constants.h index aeb28150..9ee16c65 100644 --- a/ReflectionTemplateLib/rtl/rtl_constants.h +++ b/ReflectionTemplateLib/rtl/rtl_constants.h @@ -169,10 +169,10 @@ namespace rtl::detail } #if defined(_MSC_VER) -#define FORCE_INLINE __forceinline +#define ForceInline __forceinline #elif defined(__GNUC__) || defined(__clang__) -#define FORCE_INLINE inline __attribute__((always_inline)) +#define ForceInline inline __attribute__((always_inline)) #else -#define FORCE_INLINE inline +#define ForceInline inline #endif } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index 4dc5e28c..153008c3 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -49,7 +49,7 @@ namespace rtl case error::CloningDisabled: return "Type not registered: The requested type is not explicitly registered in the Reflection system"; case error::FunctionNotRegistered: - return "Function not registered: The requested function/method is not registered in the Reflection system"; + return "Function not registered: The requested erase_function/method is not registered in the Reflection system"; case error::TargetMismatch: return "The object you're trying to bind doesn't match the expected type of the method."; case error::NonConstOverloadMissing: diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 5d5c391e..228a29dd 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -34,16 +34,16 @@ namespace rtl namespace erase { template - struct function; + struct erased_function; template - struct method; + struct erased_method; template - struct return_function; + struct aware_function; template - struct return_method; + struct aware_method; } namespace detail diff --git a/ReflectionTemplateLib/rtl/rtl_typeid.h b/ReflectionTemplateLib/rtl/rtl_typeid.h index 8fe1d88e..fa5158f4 100644 --- a/ReflectionTemplateLib/rtl/rtl_typeid.h +++ b/ReflectionTemplateLib/rtl/rtl_typeid.h @@ -16,11 +16,11 @@ #include #if defined(_MSC_VER) -#define FORCE_INLINE __forceinline +#define ForceInline __forceinline #elif defined(__GNUC__) || defined(__clang__) -#define FORCE_INLINE inline __attribute__((always_inline)) +#define ForceInline inline __attribute__((always_inline)) #else -#define FORCE_INLINE inline +#define ForceInline inline #endif namespace rtl { @@ -46,7 +46,7 @@ namespace rtl { //'0' represents no type. [Never change, critical.] static constexpr const std::size_t None = 0; - FORCE_INLINE static std::size_t get() + ForceInline static std::size_t get() { if constexpr (!std::is_same_v<_type, std::nullptr_t>) { From ef1be6ccb48f04f4c368e296a0de087e005dd6f2 Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 30 Sep 2025 14:10:47 +0530 Subject: [PATCH 050/148] return erased-type boxed in RObject, integrated. --- .../src/ReflectedCallUnknownReturn.cpp | 50 +++++++++---------- .../NameSpaceGlobalsTests.cpp | 12 ++--- .../rtl/builder/SetupFunction.hpp | 4 +- .../rtl/builder/SetupMethod.hpp | 5 +- .../rtl/cache/cache_lambda_function.h | 3 +- .../rtl/cache/cache_lambda_method.h | 2 +- .../rtl/detail/inc/CMakeLists.txt | 1 + .../rtl/detail/inc/FunctionCaller.h | 8 --- .../rtl/detail/inc/FunctionCaller.hpp | 38 +++++--------- .../rtl/detail/inc/FunctorId.h | 23 ++++----- .../rtl/detail/inc/FunctorId.hpp | 32 ++++++++++++ .../rtl/detail/inc/MethodInvoker.h | 8 ++- .../rtl/detail/inc/MethodInvoker.hpp | 32 ++++++------ .../rtl/detail/inc/RObjectId.h | 2 - .../rtl/detail/inc/RObjectUPtr.h | 9 ++-- .../rtl/detail/inc/ReflectCast.h | 4 +- ReflectionTemplateLib/rtl/dispatch/lambda.h | 9 +++- .../rtl/erasure/aware_function.h | 30 ++++++++--- .../rtl/erasure/aware_method.h | 26 +++++++--- .../rtl/erasure/aware_method_const.h | 27 +++++++--- .../rtl/erasure/erased_function.h | 5 +- .../rtl/erasure/erased_method.h | 5 +- ReflectionTemplateLib/rtl/inc/Function.h | 8 +-- ReflectionTemplateLib/rtl/inc/Function.hpp | 4 +- ReflectionTemplateLib/rtl/inc/Method.h | 3 +- ReflectionTemplateLib/rtl/inc/RObject.h | 9 +++- ReflectionTemplateLib/rtl/inc/RObject.hpp | 8 +-- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 2 +- ReflectionTemplateLib/rtl/src/CxxMirror.cpp | 2 +- ReflectionTemplateLib/rtl/src/Function.cpp | 1 + 30 files changed, 209 insertions(+), 163 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/detail/inc/FunctorId.hpp diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 81e287b1..294f8f60 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -69,20 +69,20 @@ namespace return *method; }(); - static const rtl::RObject nodeObj = []() - { - std::optional Node = cxx::mirror().getRecord("Node"); - if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; - std::abort(); - } - - auto [err, robj] = Node->create(); - if (robj.isEmpty()) { - std::cout << "[x] error: " << rtl::to_string(err) << "\n"; - } - return std::move(robj); - }(); + // static const rtl::RObject nodeObj = []() + // { + // std::optional Node = cxx::mirror().getRecord("Node"); + // if (!Node) { + // std::cerr << "[x] error: record 'Node' not found.\n"; + // std::abort(); + // } + + // auto [err, robj] = Node->create(); + // if (robj.isEmpty()) { + // std::cout << "[x] error: " << rtl::to_string(err) << "\n"; + // } + // return std::move(robj); + // }(); } @@ -90,7 +90,7 @@ namespace { static auto _test0 = []() { - auto err = SendMessage(bm::g_longStr).err; + auto err = SendMessage()(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[00] error: " << rtl::to_string(err) << "\n"; } @@ -99,7 +99,7 @@ namespace static auto _test1 = []() { - auto err = NodeSendMessage(nodeObj)(bm::g_longStr).err; + auto err = NodeSendMessage(bm::Node())(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[01] error: " << rtl::to_string(err) << "\n"; } @@ -108,7 +108,7 @@ namespace static auto _test2 = []() { - auto err = GetMessage(bm::g_longStr).err; + auto err = GetMessage()(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[02] error: " << rtl::to_string(err) << "\n"; } @@ -117,7 +117,7 @@ namespace static auto _test3 = []() { - auto err = NodeGetMessage(nodeObj)(bm::g_longStr).err; + auto err = NodeGetMessage(bm::Node())(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[03] error: " << rtl::to_string(err) << "\n"; } @@ -134,23 +134,22 @@ namespace void RtlFunction_call_ReturnUnknown::typeVoid(benchmark::State& state) { - static auto __=_new_line(); + static auto __= _new_line(); static auto _ = _test0(); for (auto _ : state) { - SendMessage.bind().call_v(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done); + benchmark::DoNotOptimize(SendMessage()(bm::g_longStr)); } } void RtlFunction_call_ReturnUnknown::typeNonVoid(benchmark::State& state) { - static auto __=_new_line(); + static auto __= _new_line(); static auto _ = _test2(); for (auto _ : state) { - benchmark::DoNotOptimize(GetMessage.bind().call_r(bm::g_longStr)); + benchmark::DoNotOptimize(GetMessage()(bm::g_longStr)); } } @@ -161,8 +160,7 @@ void RtlFunction_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) static bm::Node node; for (auto _ : state) { - NodeSendMessage(node).call_v(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + benchmark::DoNotOptimize(NodeSendMessage(node)(bm::g_longStr)); } } @@ -173,6 +171,6 @@ void RtlFunction_callMethod_ReturnUnknown::typeNonVoid(benchmark::State& state) static bm::Node node; for (auto _ : state) { - benchmark::DoNotOptimize(NodeGetMessage(node).call_r(bm::g_longStr)); + benchmark::DoNotOptimize(NodeGetMessage(node)(bm::g_longStr)); } } \ No newline at end of file diff --git a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp index 705e5beb..b236aa79 100644 --- a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp @@ -144,7 +144,7 @@ namespace rtl_tests double real = g_real; //g_real's type is "const double", so can't be passed directly to setReal else, //its type will be inferred 'const double' instead of 'double'. - auto [err0, ret0] = (*setReal)(real); + auto [err0, ret0] = setReal->bind().call(real); EXPECT_TRUE(err0 == rtl::error::None); ASSERT_TRUE(ret0.isEmpty()); @@ -152,13 +152,13 @@ namespace rtl_tests double imaginary = g_imaginary; //g_imaginary's type is "const double", so can't be passed directly to setImaginary else, //its type will be inferred 'const double' instead of 'double'. - auto [err1, ret1] = (*setImaginary)(imaginary); + auto [err1, ret1] = setImaginary->bind().call(imaginary); EXPECT_TRUE(err1 == rtl::error::None); ASSERT_TRUE(ret1.isEmpty()); EXPECT_TRUE(getMagnitude->hasSignature<>()); //empty template params checks for zero arguments. - auto [err2, ret2] = (*getMagnitude)(); + auto [err2, ret2] = getMagnitude->bind().call(); EXPECT_TRUE(err2 == rtl::error::None); ASSERT_FALSE(ret2.isEmpty()); @@ -194,7 +194,7 @@ namespace rtl_tests optional getComplexNumAsString = cxx::mirror().getFunction(str_getComplexNumAsString); ASSERT_TRUE(getComplexNumAsString); - auto [err, ret] = (*getComplexNumAsString)(); + auto [err, ret] = getComplexNumAsString->bind().call(); EXPECT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); @@ -213,7 +213,7 @@ namespace rtl_tests { //STRA's type is 'consexpr const char*', function accepts 'string', //so type-casting in place as 'string' - auto [err, ret] = (*reverseString)(string(STRA)); + auto [err, ret] = reverseString->bind().call(string(STRA)); EXPECT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); @@ -232,7 +232,7 @@ namespace rtl_tests string retVal = ret.view()->get(); EXPECT_TRUE(retVal == STRB_REVERSE); } { - auto [err, ret] = (*reverseString)(); + auto [err, ret] = reverseString->bind().call(); EXPECT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index 8794ec85..d8236545 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -13,12 +13,14 @@ #include -#include "cache_lambda_function.h" #include "cache_function_ptr.h" +#include "cache_lambda_function.h" #include "SetupFunction.h" #include "RObjectBuilder.hpp" +#include "FunctorId.hpp" + namespace rtl { namespace detail diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 2957d82b..52b1ee85 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -18,10 +18,11 @@ #include "SetupMethod.h" #include "RObjectBuilder.hpp" -#include "lambda_method.h" +#include "cache_lambda_method.h" #include "cache_method_ptr.h" #include "cache_method_ptr_const.h" -#include "cache_lambda_method.h" + +#include "FunctorId.hpp" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index 4e3095fc..e7eccd61 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -35,7 +35,8 @@ namespace rtl::cache m_cache.push_back(dispatch::lambda_function(p_functor, erasure)); p_functor.m_lambda = &m_cache.back(); - (m_erasure_cache.back()).m_function = m_cache.back().template get_hopper(); + m_erasure_cache.back().m_function = m_cache.back().template get_hopper(); + return m_cache.back(); } diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index 50e00856..f2582276 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -36,7 +36,7 @@ namespace rtl::cache m_cache.push_back(dispatch::lambda_method(p_functor, erasure)); p_functor.m_lambda = &m_cache.back(); - (m_erasure_cache.back()).m_method = m_cache.back().template get_hopper(); + m_erasure_cache.back().m_method = m_cache.back().template get_hopper(); return m_cache.back(); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt b/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt index a4020ede..feb99088 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt @@ -5,6 +5,7 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/ConversionUtils.h" "${CMAKE_CURRENT_SOURCE_DIR}/CxxReflection.h" "${CMAKE_CURRENT_SOURCE_DIR}/FunctorId.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FunctorId.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.h" "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/ReflectCastUtil.h" diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 2ec2e6c2..ab3453a9 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -13,8 +13,6 @@ #include "rtl_forward_decls.h" -#include "RObject.h" - namespace rtl::detail { template @@ -27,12 +25,6 @@ namespace rtl::detail template constexpr rtl::Return operator()(_args&&...params) const noexcept; - - template - constexpr rtl::error call_v(_args&&...) const noexcept; - - template - std::any call_r(_args&&...) const noexcept; }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index b322b959..c967376b 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -38,33 +38,21 @@ namespace rtl::detail template template - constexpr inline rtl::Return FunctionCaller<_signature...>::operator()(_args&&...params) const noexcept - { - return call(std::forward<_args>(params)...); - } - - - template - template - constexpr error FunctionCaller<_signature...>::call_v(_args&& ...params) const noexcept + ForceInline constexpr Return FunctionCaller<_signature...>::operator()(_args&&...params) const noexcept { auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); - if (functorId) [[likely]] { - functorId->template get_lambda_function<_args...>()->m_erasure->void_hop(std::forward<_args>(params)...); - } - return error::None; - } - - - template - template - ForceInline std::any FunctionCaller<_signature...>::call_r(_args&& ...params) const noexcept - { - auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); - if (functorId) [[likely]] { - return functorId->template get_lambda_function<_args...>()->m_erasure->return_hop(std::forward<_args>(params)...); + if (functorId) [[likely]] + { + auto caller = functorId->template get_lambda_function<_args...>()->m_erasure; + if(functorId->m_lambda->is_void()) { + caller->void_hop(std::forward<_args>(params)...); + return {error::None, RObject{} }; + } + else { + return caller->return_hop(std::forward<_args>(params)...); + } } - return std::any(); + return {error::SignatureMismatch, RObject{} }; } } @@ -89,7 +77,7 @@ namespace rtl::detail template template inline constexpr const function<_returnType(_signature...)> - HopFunction<_signature...>::returnT() const + HopFunction<_signature...>::returnT() const { const auto retId = TypeId<_returnType>::get(); if (m_lambda != nullptr) [[likely]] { diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 2761736c..ce30dd96 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -11,12 +11,7 @@ #pragma once -#include "rtl_typeid.h" -#include "rtl_constants.h" #include "rtl_forward_decls.h" -#include "lambda_method.h" -#include "lambda_function.h" - namespace rtl::detail { @@ -81,15 +76,15 @@ namespace rtl::detail } template - constexpr const dispatch::lambda_function<_signature...>* get_lambda_function(std::size_t p_argsId = 0) const - { - return m_lambda->to_function<_signature...>(p_argsId); - } + using lambda_ft = dispatch::lambda_function<_signature...>; + + template + using lambda_mt = dispatch::lambda_method; + + template + constexpr const lambda_ft* get_lambda_function(std::size_t p_argsId = 0) const; - template - constexpr const dispatch::lambda_method<_recordType, _signature...>* get_lambda_method(std::size_t p_recordId = 0, std::size_t p_argsId = 0) const - { - return m_lambda->to_method<_recordType, _signature...>(p_recordId, p_argsId); - } + template + constexpr const lambda_mt* get_lambda_method(std::size_t p_recordId = 0, std::size_t p_argsId = 0) const; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.hpp new file mode 100644 index 00000000..5d81b100 --- /dev/null +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.hpp @@ -0,0 +1,32 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "FunctorId.h" + +#include "lambda_method.h" +#include "lambda_function.h" + +namespace rtl::detail +{ + template + inline constexpr const FunctorId::lambda_ft* FunctorId::get_lambda_function(std::size_t p_argsId) const + { + return m_lambda->to_function(p_argsId); + } + + template + inline constexpr const FunctorId::lambda_mt* FunctorId::get_lambda_method(std::size_t p_recordId, std::size_t p_argsId) const + { + return m_lambda->to_method(p_recordId, p_argsId); + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 2e7f529e..7654618e 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -11,7 +11,8 @@ #pragma once -#include "erased_method.h" +#include "rtl_typeid.h" +#include "rtl_forward_decls.h" namespace rtl::detail { @@ -23,10 +24,7 @@ namespace rtl::detail const _recordType& m_target; template - constexpr error call_v(_args&&...params) const noexcept; - - template - std::any call_r(_args&&...params) const noexcept; + constexpr Return operator()(_args&&...params) const noexcept; }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 4c1dbb13..301c6128 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -15,6 +15,7 @@ #include "RObject.h" #include "MethodInvoker.h" #include "MethodContainer.h" +#include "erased_method.h" namespace rtl::detail { @@ -143,7 +144,7 @@ namespace rtl::detail return { error::NonConstOverloadMissing, RObject{} }; } // else the signature might be wrong. - return { error::SignatureMismatch , RObject{} }; + return { error::SignatureMismatch, RObject{} }; } } } @@ -171,7 +172,7 @@ namespace rtl::detail template template inline constexpr const method<_returnType(_recordType::*)(_signature...)> - HopMethod<_recordType, _signature...>::returnT() const + HopMethod<_recordType, _signature...>::returnT() const { if (m_lambda != nullptr) [[likely]] { @@ -187,23 +188,20 @@ namespace rtl::detail { template template - constexpr error ErasedInvoker<_recordType>::call_v(_args&&...params) const noexcept + ForceInline constexpr Return ErasedInvoker<_recordType>::operator()(_args&&...params) const noexcept { auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); - if (functorId) [[likely]] { - functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->void_hop(m_target, std::forward<_args>(params)...); - } - return error::None; - } - - template - template - ForceInline std::any ErasedInvoker<_recordType>::call_r(_args&&...params) const noexcept - { - auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); - if (functorId) [[likely]] { - return functorId->template get_lambda_method<_recordType, _args...>()->m_erasure->return_hop(m_target, std::forward<_args>(params)...); + if (functorId) [[likely]] + { + auto caller = functorId->template get_lambda_method<_recordType, _args...>()->m_erasure; + if(functorId->m_lambda->is_void()) { + caller->void_hop(m_target, std::forward<_args>(params)...); + return { error::None, RObject{} }; + } + else { + return caller->return_hop(m_target, std::forward<_args>(params)...); + } } - return std::any(); + return { error::SignatureMismatch, RObject{} }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h index bb43306b..a5a9723c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h @@ -12,11 +12,9 @@ #pragma once #include -#include #include #include "ReflectCast.h" -#include "rtl_forward_decls.h" #include "FunctorId.h" namespace rtl::detail diff --git a/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h b/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h index 1fd4ce58..4fe7c442 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h +++ b/ReflectionTemplateLib/rtl/detail/inc/RObjectUPtr.h @@ -13,9 +13,8 @@ #include #include #include -#include -#include "RObjectBuilder.hpp" +#include "RObject.h" /*------------------------------------------------------------------------------------------ RObjectUPtr @@ -70,13 +69,13 @@ namespace rtl::detail // Construct directly from std::unique_ptr, tracking RTL-owned heap allocations. RObjectUPtr(std::unique_ptr&& pUniquePtr) : m_uniquePtr(std::move(pUniquePtr)) { - RObject::getInstanceCounter().fetch_add(1, std::memory_order_relaxed); + RObject::getInstanceCounter()++;//.fetch_add(1, std::memory_order_relaxed); } // Destructor: decrements allocation count if we still own the object. ~RObjectUPtr() { if (m_uniquePtr) { - RObject::getInstanceCounter().fetch_sub(1, std::memory_order_relaxed); + RObject::getInstanceCounter()--;//.fetch_sub(1, std::memory_order_relaxed); } } @@ -87,7 +86,7 @@ namespace rtl::detail std::unique_ptr release() const { if (m_uniquePtr) { - RObject::getInstanceCounter().fetch_sub(1, std::memory_order_relaxed); + RObject::getInstanceCounter()--;//.fetch_sub(1, std::memory_order_relaxed); return std::move(m_uniquePtr); } return nullptr; diff --git a/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h index 104d1142..726ad21b 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h +++ b/ReflectionTemplateLib/rtl/detail/inc/ReflectCast.h @@ -31,7 +31,7 @@ namespace rtl::detail template class ReflectCast { - static std::vector>& conversions() { + ForceInline static std::vector>& conversions() { static std::vector> converters; return converters; } @@ -40,7 +40,7 @@ namespace rtl::detail template static void pushConversion(); - static const std::vector>& getConversions() { + ForceInline static const std::vector>& getConversions() { return conversions(); } }; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 06ec3000..15ec6e99 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -20,10 +20,13 @@ namespace rtl::dispatch { const functor& m_functor; + const bool m_is_void; + // protected: lambda_base(const functor& p_functor) noexcept - :m_functor(p_functor) + : m_functor(p_functor) + , m_is_void(p_functor.m_returnId == detail::TypeId::get()) { } template @@ -57,6 +60,10 @@ namespace rtl::dispatch GETTER_CREF(functor, _functor, m_functor); + constexpr bool is_void() const { + return m_is_void; + } + template constexpr bool is_returning() const { diff --git a/ReflectionTemplateLib/rtl/erasure/aware_function.h b/ReflectionTemplateLib/rtl/erasure/aware_function.h index b139055d..f8e93b2e 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_function.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_function.h @@ -11,8 +11,9 @@ #pragma once +#include "RObject.h" #include "erased_function.h" -#include "rtl_function.h" +#include "RObjectBuilder.hpp" namespace rtl::erase { @@ -40,21 +41,36 @@ namespace rtl::erase } } - ForceInline static std::any return_hop(const base_t* p_this, signature_ts&&...params) noexcept + + ForceInline static rtl::Return return_hop(const base_t* p_this, signature_ts&&...params) noexcept { if constexpr (!std::is_void_v) { auto this_p = static_cast(p_this); auto&& ret_v = this_p->m_function(std::forward(params)...); - if constexpr (std::is_reference_v) { - return std::any(&ret_v); + constexpr bool isConstCastSafe = (!traits::is_const_v); + + if constexpr (std::is_reference_v) + { + using T = traits::raw_t; + return{ error::None, + detail::RObjectBuilder::template build ( + &ret_v, std::nullopt, isConstCastSafe + ) + }; } - else { - return std::any(std::forward(ret_v)); + else + { + using T = std::remove_cvref_t; + return{ error::None, + detail::RObjectBuilder::template build ( + std::forward(ret_v), std::nullopt, isConstCastSafe + ) + }; } } - else return std::any(); + return {error::SignatureMismatch, RObject{ }}; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method.h b/ReflectionTemplateLib/rtl/erasure/aware_method.h index 784cfb65..86a5516b 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method.h @@ -12,6 +12,7 @@ #pragma once #include "erased_method.h" +#include "RObjectBuilder.hpp" namespace rtl::erase { @@ -39,21 +40,34 @@ namespace rtl::erase } } - ForceInline static std::any return_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + ForceInline static rtl::Return return_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { if constexpr (!std::is_void_v) { auto this_p = static_cast(p_this); auto&& ret_v = this_p->m_method(const_cast(p_target), std::forward(params)...); + constexpr bool isConstCastSafe = (!traits::is_const_v); - if constexpr (std::is_reference_v) { - return std::any(&ret_v); + if constexpr (std::is_reference_v) + { + using T = traits::raw_t; + return{ error::None, + detail::RObjectBuilder::template build ( + &ret_v, std::nullopt, isConstCastSafe + ) + }; } - else { - return std::any(std::forward(ret_v)); + else + { + using T = std::remove_cvref_t; + return{ error::None, + detail::RObjectBuilder::template build ( + std::forward(ret_v), std::nullopt, isConstCastSafe + ) + }; } } - else return std::any(); + return {error::SignatureMismatch, RObject{ }}; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h index 5caedf3a..0d669649 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h @@ -11,7 +11,9 @@ #pragma once +#include "RObject.h" #include "erased_method.h" +#include "RObjectBuilder.hpp" namespace rtl::erase { @@ -39,21 +41,34 @@ namespace rtl::erase } } - ForceInline static std::any return_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + ForceInline static rtl::Return return_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { if constexpr (!std::is_void_v) { auto this_p = static_cast(p_this); auto&& ret_v = this_p->m_method(p_target, std::forward(params)...); + constexpr bool isConstCastSafe = (!traits::is_const_v); - if constexpr (std::is_reference_v) { - return std::any(&ret_v); + if constexpr (std::is_reference_v) + { + using T = traits::raw_t; + return{ error::None, + detail::RObjectBuilder::template build ( + &ret_v, std::nullopt, isConstCastSafe + ) + }; } - else { - return std::any(std::forward(ret_v)); + else + { + using T = std::remove_cvref_t; + return{ error::None, + detail::RObjectBuilder::template build ( + std::forward(ret_v), std::nullopt, isConstCastSafe + ) + }; } } - else return std::any(); + return {error::SignatureMismatch, RObject{ }}; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_function.h b/ReflectionTemplateLib/rtl/erasure/erased_function.h index 30050564..9e535d08 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_function.h @@ -11,7 +11,6 @@ #pragma once -#include #include "rtl_forward_decls.h" namespace rtl::erase @@ -24,7 +23,7 @@ namespace rtl::erase (*hop_void)(this, std::forward(params)...); } - ForceInline std::any return_hop(signature_ts&&...params) const noexcept + ForceInline rtl::Return return_hop(signature_ts&&...params) const noexcept { return (*hop_return)(this, std::forward(params)...); } @@ -35,7 +34,7 @@ namespace rtl::erase using functor_vt = void(*)(const this_t*, signature_ts&&...); - using functor_rt = std::any(*)(const this_t*, signature_ts&&...); + using functor_rt = rtl::Return(*)(const this_t*, signature_ts&&...); functor_vt hop_void = nullptr; diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method.h index 56050586..16da0582 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method.h @@ -11,7 +11,6 @@ #pragma once -#include #include "rtl_forward_decls.h" namespace rtl::erase @@ -24,7 +23,7 @@ namespace rtl::erase (*hop_void)(this, p_target, std::forward(params)...); } - ForceInline std::any return_hop(const record_t& p_target, signature_ts&&...params) const noexcept + ForceInline rtl::Return return_hop(const record_t& p_target, signature_ts&&...params) const noexcept { return (*hop_return)(this, p_target, std::forward(params)...); } @@ -35,7 +34,7 @@ namespace rtl::erase using functor_vt = void(*)(const this_t*, const record_t&, signature_ts&&...); - using functor_rt = std::any(*)(const this_t*, const record_t&, signature_ts&&...); + using functor_rt = rtl::Return(*)(const this_t*, const record_t&, signature_ts&&...); functor_vt hop_void = nullptr; diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 97822e37..6edd8c0d 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -14,14 +14,8 @@ #include #include #include -#include -#include "FunctorId.h" -#include "RObject.h" -#include "rtl_constants.h" #include "FunctionCaller.h" -#include "lambda_function.h" -#include "rtl_errors.h" namespace rtl { @@ -102,7 +96,7 @@ namespace rtl { bool hasSignature() const; template - Return operator()(_args&&...params) const noexcept; + constexpr const detail::FunctionCaller<_args...> operator()(_args&&...params) const noexcept; template constexpr const detail::FunctionCaller<_signature...> bind() const noexcept; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index e728d6c4..77dd5ec1 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -51,9 +51,9 @@ namespace rtl * if the arguments did not match with any overload, returns RObject with error::SignatureMismatch * providing optional syntax, Function::call() does the exact same thing. */ template - inline Return Function::operator()(_args&& ...params) const noexcept + inline constexpr const detail::FunctionCaller<_args...> Function::operator()(_args&& ...params) const noexcept { - return detail::FunctionCaller<>{ this }.call(std::forward<_args>(params)...); + return detail::FunctionCaller<_args...>{ this }; } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index f4249ca5..d298fb60 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -16,7 +16,6 @@ #include "RObject.h" #include "Function.h" #include "MethodInvoker.h" -#include "lambda_method.h" namespace rtl { @@ -70,7 +69,7 @@ namespace rtl { const detail::NonConstInvoker<_signature...> bind(constCast&& pTarget) const; template - constexpr detail::ErasedInvoker<_recordType> operator()(const _recordType& pTarget) const + constexpr const detail::ErasedInvoker<_recordType> operator()(const _recordType& pTarget) const { return detail::ErasedInvoker<_recordType>{ (*this), pTarget }; } diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index 4e89d6f7..8e5daa38 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -11,7 +11,8 @@ #pragma once -#include +//#include +#include #include "view.h" #include "RObjectId.h" @@ -89,7 +90,11 @@ namespace rtl template, int> = 0> std::optional> view() const noexcept; - static std::atomic& getInstanceCounter(); + static std::size_t& /*std::atomic&*/ getInstanceCounter() + { + static std::size_t/*std::atomic*/ instanceCounter = {0}; + return instanceCounter; + } //friends :) friend CxxMirror; diff --git a/ReflectionTemplateLib/rtl/inc/RObject.hpp b/ReflectionTemplateLib/rtl/inc/RObject.hpp index 35802478..85a86213 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.hpp +++ b/ReflectionTemplateLib/rtl/inc/RObject.hpp @@ -59,13 +59,7 @@ namespace rtl pOther.m_converters = nullptr; return *this; } - - inline std::atomic& RObject::getInstanceCounter() - { - static std::atomic instanceCounter = {0}; - return instanceCounter; - } - + inline std::size_t RObject::getConverterIndex(const std::size_t pToTypeId) const { diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 228a29dd..13c690be 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -31,7 +31,7 @@ namespace rtl template struct method; - namespace erase + namespace erase { template struct erased_function; diff --git a/ReflectionTemplateLib/rtl/src/CxxMirror.cpp b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp index e75c71f4..3b3f21e8 100644 --- a/ReflectionTemplateLib/rtl/src/CxxMirror.cpp +++ b/ReflectionTemplateLib/rtl/src/CxxMirror.cpp @@ -8,7 +8,7 @@ * * *************************************************************************/ - +#include #include "RObject.h" #include "CxxMirror.h" diff --git a/ReflectionTemplateLib/rtl/src/Function.cpp b/ReflectionTemplateLib/rtl/src/Function.cpp index ad1109c9..94db0f1c 100644 --- a/ReflectionTemplateLib/rtl/src/Function.cpp +++ b/ReflectionTemplateLib/rtl/src/Function.cpp @@ -12,6 +12,7 @@ #include #include "Function.h" +#include "FunctorId.h" namespace rtl { From d73a85fc4913f1b741be3143f43456f493d210aa Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 30 Sep 2025 23:02:13 +0530 Subject: [PATCH 051/148] type-erased return value optimized. --- .../rtl/builder/RObjectBuilder.hpp | 10 ++-- .../rtl/builder/RecordBuilder.h | 2 +- .../rtl/builder/RecordBuilder.hpp | 4 +- .../rtl/detail/inc/FunctionCaller.hpp | 17 +++--- .../rtl/detail/inc/MethodInvoker.hpp | 23 ++++---- .../rtl/detail/inc/RObjectId.h | 2 +- .../rtl/erasure/aware_function.h | 51 +++++++----------- .../rtl/erasure/aware_method.h | 51 ++++++++---------- .../rtl/erasure/aware_method_const.h | 52 ++++++++----------- .../rtl/erasure/erased_function.h | 18 +++---- .../rtl/erasure/erased_method.h | 17 +++--- ReflectionTemplateLib/rtl/inc/RObject.h | 6 +++ ReflectionTemplateLib/rtl/rtl_forward_decls.h | 6 +++ ReflectionTemplateLib/rtl/rtl_traits.h | 4 +- 14 files changed, 118 insertions(+), 145 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp b/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp index 1504f405..e7b4cd91 100644 --- a/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/RObjectBuilder.hpp @@ -39,7 +39,7 @@ namespace rtl::detail std::in_place_type>, RObjectUPtr<_T>(std::unique_ptr<_T>(static_cast<_T*>(pVal))) }, - RObjectId::create, alloc::Heap>(pClonerId, pIsConstCastSafe), + RObjectId::create, alloc::Heap>(pIsConstCastSafe, pClonerId), &getConverters>()); } @@ -49,12 +49,12 @@ namespace rtl::detail ForceInline RObject RObjectBuilder::build(T&& pVal, std::optional pClonerId, bool pIsConstCastSafe) noexcept { using _T = traits::raw_t; - constexpr bool isRawPointer = std::is_pointer_v>; + constexpr bool isRawPointer = std::is_pointer_v>; if constexpr (isRawPointer) { return RObject( std::any { static_cast(pVal) }, - RObjectId::create(pClonerId, pIsConstCastSafe), + RObjectId::create(pIsConstCastSafe, pClonerId), &getConverters() ); } else @@ -66,7 +66,7 @@ namespace rtl::detail std::in_place_type>, RObjectUPtr(std::move(pVal)) }, - RObjectId::create(pClonerId, pIsConstCastSafe), + RObjectId::create(pIsConstCastSafe, pClonerId), &getConverters() ); } else @@ -76,7 +76,7 @@ namespace rtl::detail std::in_place_type, std::forward(pVal) }, - RObjectId::create(pClonerId, pIsConstCastSafe), + RObjectId::create(pIsConstCastSafe, pClonerId), &getConverters() ); } } diff --git a/ReflectionTemplateLib/rtl/builder/RecordBuilder.h b/ReflectionTemplateLib/rtl/builder/RecordBuilder.h index da6db803..7f28bd76 100644 --- a/ReflectionTemplateLib/rtl/builder/RecordBuilder.h +++ b/ReflectionTemplateLib/rtl/builder/RecordBuilder.h @@ -62,7 +62,7 @@ namespace rtl { const Builder methodStatic(const std::string_view pFunction) const; template - constexpr const ConstructorBuilder<_recordType, traits::remove_const_n_ref_t<_signature>...> constructor() const; + constexpr const ConstructorBuilder<_recordType, traits::remove_cref_t<_signature>...> constructor() const; }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp index b05f5b0b..b9a74cf6 100644 --- a/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp @@ -41,7 +41,7 @@ namespace rtl::builder * template params <...> - any combination of parameters. */ template template - inline constexpr const ConstructorBuilder<_recordType, traits::remove_const_n_ref_t<_signature>...> MethodBuilder<_recordType>::constructor() const + inline constexpr const ConstructorBuilder<_recordType, traits::remove_cref_t<_signature>...> MethodBuilder<_recordType>::constructor() const { constexpr bool isDefaultCtor = (sizeof...(_signature) == 0); constexpr bool isCopyOrMoveCtor = (sizeof...(_signature) == 1 && traits::is_first_type_same_v<_recordType, _signature...>); @@ -51,7 +51,7 @@ namespace rtl::builder static_assert(!isCopyOrMoveCtor, "Copy/Move-constructor registration detected! It is implicitly registered with the Type."); static_assert(isDeclearedCtor, "Constructor with given signature is not valid or declearation not found."); - return ConstructorBuilder<_recordType, traits::remove_const_n_ref_t<_signature>...>(); + return ConstructorBuilder<_recordType, traits::remove_cref_t<_signature>...>(); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index c967376b..5b89a0c7 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -43,16 +43,17 @@ namespace rtl::detail auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { + RObject robject; + auto caller = functorId->template get_lambda_function<_args...>()->m_erasure; - if(functorId->m_lambda->is_void()) { - caller->void_hop(std::forward<_args>(params)...); - return {error::None, RObject{} }; - } - else { - return caller->return_hop(std::forward<_args>(params)...); - } + + caller->hop(robject.m_object, std::forward<_args>(params)...); + + robject.m_objectId = caller->get_robject_id(); + + return { error::None, robject }; } - return {error::SignatureMismatch, RObject{} }; + else return {error::SignatureMismatch, RObject{} }; } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 301c6128..f8b5d5ce 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -43,7 +43,7 @@ namespace rtl::detail { if constexpr (sizeof...(_signature) == 0) { // executes when bind doesn't have any explicit signature types specified. (e.g. perfect-forwaring) - return Invoker...>::invoke(*m_method, *m_target, std::forward<_args>(params)...); + return Invoker...>::invoke(*m_method, *m_target, std::forward<_args>(params)...); } else { return Invoker<_signature...>::invoke(*m_method, *m_target, std::forward<_args>(params)...); @@ -110,7 +110,7 @@ namespace rtl::detail else [[likely]] { if constexpr (sizeof...(_signature) == 0) { - return Invoker...>::invoke(*m_method, *m_target, std::forward<_args>(params)...); + return Invoker...>::invoke(*m_method, *m_target, std::forward<_args>(params)...); } else { return Invoker<_signature...>::invoke(*m_method, *m_target, std::forward<_args>(params)...); @@ -191,17 +191,18 @@ namespace rtl::detail ForceInline constexpr Return ErasedInvoker<_recordType>::operator()(_args&&...params) const noexcept { auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); - if (functorId) [[likely]] + if (functorId) [[likely]] { + RObject robject; + auto caller = functorId->template get_lambda_method<_recordType, _args...>()->m_erasure; - if(functorId->m_lambda->is_void()) { - caller->void_hop(m_target, std::forward<_args>(params)...); - return { error::None, RObject{} }; - } - else { - return caller->return_hop(m_target, std::forward<_args>(params)...); - } + + caller->hop(robject.m_object, m_target, std::forward<_args>(params)...); + + robject.m_objectId = caller->get_robject_id(); + + return { error::None, robject }; } - return { error::SignatureMismatch, RObject{} }; + else return { error::SignatureMismatch, RObject{} }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h index a5a9723c..3dd82196 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/RObjectId.h @@ -57,7 +57,7 @@ namespace rtl::detail template - ForceInline static RObjectId create(std::optional pClonerId, bool pIsConstCastSafe) noexcept + ForceInline static RObjectId create(bool pIsConstCastSafe, std::optional pClonerId = std::nullopt) noexcept { // extract wrapper info. using _W = traits::std_wrapper>; diff --git a/ReflectionTemplateLib/rtl/erasure/aware_function.h b/ReflectionTemplateLib/rtl/erasure/aware_function.h index f8e93b2e..9b5c1ae2 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_function.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_function.h @@ -11,9 +11,7 @@ #pragma once -#include "RObject.h" #include "erased_function.h" -#include "RObjectBuilder.hpp" namespace rtl::erase { @@ -28,49 +26,38 @@ namespace rtl::erase aware_function() { - base_t::hop_void = void_hop; - base_t::hop_return = return_hop; + constexpr bool isConstCastSafe = (!traits::is_const_v); + + base_t::hopper = hopper; + base_t::robj_id = detail::RObjectId::create(isConstCastSafe); } - constexpr static void void_hop(const base_t* p_this, signature_ts&&...params) noexcept + constexpr static void hopper(const base_t* p_this, std::optional& p_return, signature_ts&&...params) noexcept { - if constexpr (std::is_void_v) - { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); + + if constexpr (std::is_void_v) { this_p->m_function(std::forward(params)...); } - } - - - ForceInline static rtl::Return return_hop(const base_t* p_this, signature_ts&&...params) noexcept - { - if constexpr (!std::is_void_v) - { - auto this_p = static_cast(p_this); + else { auto&& ret_v = this_p->m_function(std::forward(params)...); - constexpr bool isConstCastSafe = (!traits::is_const_v); - - if constexpr (std::is_reference_v) + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + p_return.emplace(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) { - using T = traits::raw_t; - return{ error::None, - detail::RObjectBuilder::template build ( - &ret_v, std::nullopt, isConstCastSafe - ) - }; + using raw_t = std::remove_cv_t>; + p_return.emplace(static_cast(&ret_v)); } else { - using T = std::remove_cvref_t; - return{ error::None, - detail::RObjectBuilder::template build ( - std::forward(ret_v), std::nullopt, isConstCastSafe - ) - }; + using rconst_t = std::add_const_t>; + p_return.emplace(rconst_t(std::forward(ret_v))); } } - return {error::SignatureMismatch, RObject{ }}; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method.h b/ReflectionTemplateLib/rtl/erasure/aware_method.h index 86a5516b..a2b02483 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method.h @@ -11,8 +11,8 @@ #pragma once +#include "RObjectId.h" #include "erased_method.h" -#include "RObjectBuilder.hpp" namespace rtl::erase { @@ -27,47 +27,38 @@ namespace rtl::erase aware_method() { - base_t::hop_void = void_hop; - base_t::hop_return = return_hop; + constexpr bool isConstCastSafe = (!traits::is_const_v); + + base_t::hopper = hopper; + base_t::robj_id = detail::RObjectId::create(isConstCastSafe); } - constexpr static void void_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + constexpr static void hopper(const base_t* p_this, std::optional& p_return, const record_t& p_target, signature_ts&&...params) noexcept { - if constexpr (std::is_void_v) - { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); + + if constexpr (std::is_void_v) { this_p->m_method(const_cast(p_target), std::forward(params)...); } - } - - ForceInline static rtl::Return return_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept - { - if constexpr (!std::is_void_v) - { - auto this_p = static_cast(p_this); + else { auto&& ret_v = this_p->m_method(const_cast(p_target), std::forward(params)...); - constexpr bool isConstCastSafe = (!traits::is_const_v); - if constexpr (std::is_reference_v) + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + p_return.emplace(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) { - using T = traits::raw_t; - return{ error::None, - detail::RObjectBuilder::template build ( - &ret_v, std::nullopt, isConstCastSafe - ) - }; + using raw_t = std::remove_cv_t>; + p_return.emplace(static_cast(&ret_v)); } - else + else { - using T = std::remove_cvref_t; - return{ error::None, - detail::RObjectBuilder::template build ( - std::forward(ret_v), std::nullopt, isConstCastSafe - ) - }; + using rconst_t = std::add_const_t>; + p_return.emplace(rconst_t(std::forward(ret_v))); } } - return {error::SignatureMismatch, RObject{ }}; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h index 0d669649..6c02f0af 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h @@ -11,9 +11,8 @@ #pragma once -#include "RObject.h" +#include "RObjectId.h" #include "erased_method.h" -#include "RObjectBuilder.hpp" namespace rtl::erase { @@ -28,47 +27,38 @@ namespace rtl::erase aware_method() { - base_t::v_hop = void_hop; - base_t::r_hop = return_hop; + constexpr bool isConstCastSafe = (!traits::is_const_v); + + base_t::hopper = hopper; + base_t::robj_id = detail::RObjectId::create(isConstCastSafe); } - constexpr static void void_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + constexpr static void hopper(const base_t* p_this, std::optional& p_return, const record_t& p_target, signature_ts&&...params) noexcept { - if constexpr (std::is_void_v) - { - auto this_p = static_cast(p_this); + auto this_p = static_cast(p_this); + + if constexpr (std::is_void_v) { this_p->m_method(p_target, std::forward(params)...); } - } - - ForceInline static rtl::Return return_hop(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept - { - if constexpr (!std::is_void_v) - { - auto this_p = static_cast(p_this); + else { auto&& ret_v = this_p->m_method(p_target, std::forward(params)...); - constexpr bool isConstCastSafe = (!traits::is_const_v); - if constexpr (std::is_reference_v) + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + p_return.emplace(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) { - using T = traits::raw_t; - return{ error::None, - detail::RObjectBuilder::template build ( - &ret_v, std::nullopt, isConstCastSafe - ) - }; + using raw_t = std::remove_cv_t>; + p_return.emplace(static_cast(&ret_v)); } - else + else { - using T = std::remove_cvref_t; - return{ error::None, - detail::RObjectBuilder::template build ( - std::forward(ret_v), std::nullopt, isConstCastSafe - ) - }; + using rconst_t = std::add_const_t>; + p_return.emplace(rconst_t(std::forward(ret_v))); } } - return {error::SignatureMismatch, RObject{ }}; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_function.h b/ReflectionTemplateLib/rtl/erasure/erased_function.h index 9e535d08..f0c6cb0c 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_function.h @@ -11,6 +11,7 @@ #pragma once +#include "RObjectId.h" #include "rtl_forward_decls.h" namespace rtl::erase @@ -18,26 +19,21 @@ namespace rtl::erase template struct erased_function { - constexpr void void_hop(signature_ts&&...params) const noexcept + constexpr void hop(std::optional& p_return, signature_ts&&...params) const noexcept { - (*hop_void)(this, std::forward(params)...); + (*hopper)(this, p_return, std::forward(params)...); } - ForceInline rtl::Return return_hop(signature_ts&&...params) const noexcept - { - return (*hop_return)(this, std::forward(params)...); - } + GETTER(detail::RObjectId, _robject_id, robj_id); protected: using this_t = erased_function; - using functor_vt = void(*)(const this_t*, signature_ts&&...); - - using functor_rt = rtl::Return(*)(const this_t*, signature_ts&&...); + using functor_t = void(*)(const this_t*, std::optional&, signature_ts&&...); - functor_vt hop_void = nullptr; + functor_t hopper = nullptr; - functor_rt hop_return = nullptr; + detail::RObjectId robj_id; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method.h index 16da0582..507e1e4d 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method.h @@ -18,26 +18,21 @@ namespace rtl::erase template struct erased_method { - constexpr void void_hop(const record_t& p_target, signature_ts&&...params) const noexcept + constexpr void hop(std::optional& p_return, const record_t& p_target, signature_ts&&...params) const noexcept { - (*hop_void)(this, p_target, std::forward(params)...); + (*hopper)(this, p_return, p_target, std::forward(params)...); } - ForceInline rtl::Return return_hop(const record_t& p_target, signature_ts&&...params) const noexcept - { - return (*hop_return)(this, p_target, std::forward(params)...); - } + GETTER(detail::RObjectId, _robject_id, robj_id); protected: using this_t = erased_method; - using functor_vt = void(*)(const this_t*, const record_t&, signature_ts&&...); - - using functor_rt = rtl::Return(*)(const this_t*, const record_t&, signature_ts&&...); + using functor_t = void(*)(const this_t*, std::optional& , const record_t&, signature_ts&&...); - functor_vt hop_void = nullptr; + functor_t hopper = nullptr; - functor_rt hop_return = nullptr; + detail::RObjectId robj_id; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index 8e5daa38..26562732 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -105,6 +105,12 @@ namespace rtl template friend struct detail::RObjectBuilder; + + template + friend struct detail::FunctionCaller; + + template + friend struct detail::ErasedInvoker; }; struct [[nodiscard]] Return { diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 13c690be..08b1f8ac 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -53,6 +53,12 @@ namespace rtl template class FunctorContainer; + template + struct FunctionCaller; + + template + struct ErasedInvoker; + template class SetupMethod; diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index 0bef3cda..e1a53809 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -44,7 +44,7 @@ namespace rtl // Utility: Remove const and reference qualifiers from T. template - using remove_const_n_ref_t = std::remove_const_t>; + using remove_cref_t = std::remove_const_t>; // Utility: Remove const from T if T is not a reference; otherwise, leave as is. template @@ -55,7 +55,7 @@ namespace rtl using remove_const_n_ref_n_ptr = std::remove_const_t>>>; template - inline constexpr bool is_raw_ptr_v = std::is_pointer_v>; + inline constexpr bool is_raw_ptr_v = std::is_pointer_v>; template inline constexpr bool is_const_v = (std::is_const_v> || (std::is_pointer_v && std::is_const_v>)); From e3949213f54431e96fad1533fa58ad911eabe71b Mon Sep 17 00:00:00 2001 From: neeraj Date: Wed, 1 Oct 2025 01:11:08 +0530 Subject: [PATCH 052/148] refined erased return-type design. --- .../rtl/detail/inc/FunctionCaller.hpp | 22 ++++++++------ .../rtl/detail/inc/MethodInvoker.hpp | 20 ++++++++----- .../rtl/erasure/aware_function.h | 29 ++++++++++++------- .../rtl/erasure/aware_method.h | 28 +++++++++++------- .../rtl/erasure/erased_function.h | 18 +++++++++--- .../rtl/erasure/erased_method.h | 19 +++++++++--- ReflectionTemplateLib/rtl/inc/RObject.h | 2 +- ReflectionTemplateLib/rtl/inc/RObject.hpp | 2 +- 8 files changed, 93 insertions(+), 47 deletions(-) diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 5b89a0c7..c662b825 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -43,17 +43,21 @@ namespace rtl::detail auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { - RObject robject; - auto caller = functorId->template get_lambda_function<_args...>()->m_erasure; - - caller->hop(robject.m_object, std::forward<_args>(params)...); - - robject.m_objectId = caller->get_robject_id(); - - return { error::None, robject }; + if(functorId->m_lambda->is_void()) + { + caller->hop_v(std::forward<_args>(params)...); + return { error::None, RObject{} }; + } + else + { + return{ error::None, + RObject{ caller->hop_r(std::forward<_args>(params)...), + caller->get_robject_id(), nullptr } + }; + } } - else return {error::SignatureMismatch, RObject{} }; + else return { error::SignatureMismatch, RObject{} }; } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index f8b5d5ce..0135bf47 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -193,15 +193,19 @@ namespace rtl::detail auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { - RObject robject; - auto caller = functorId->template get_lambda_method<_recordType, _args...>()->m_erasure; - - caller->hop(robject.m_object, m_target, std::forward<_args>(params)...); - - robject.m_objectId = caller->get_robject_id(); - - return { error::None, robject }; + if(functorId->m_lambda->is_void()) + { + caller->hop_v(m_target, std::forward<_args>(params)...); + return { error::None, RObject{} }; + } + else + { + return{ error::None, + RObject{ caller->hop_r(m_target, std::forward<_args>(params)...), + caller->get_robject_id(), nullptr } + }; + } } else return { error::SignatureMismatch, RObject{} }; } diff --git a/ReflectionTemplateLib/rtl/erasure/aware_function.h b/ReflectionTemplateLib/rtl/erasure/aware_function.h index 9b5c1ae2..80a3282d 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_function.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_function.h @@ -11,7 +11,9 @@ #pragma once +#include #include "erased_function.h" +#include "rtl_constants.h" namespace rtl::erase { @@ -28,36 +30,43 @@ namespace rtl::erase { constexpr bool isConstCastSafe = (!traits::is_const_v); - base_t::hopper = hopper; + base_t::hopper_v = hop_v; + base_t::hopper_r = hop_r; base_t::robj_id = detail::RObjectId::create(isConstCastSafe); } - constexpr static void hopper(const base_t* p_this, std::optional& p_return, signature_ts&&...params) noexcept + constexpr static void hop_v(const base_t* p_this, signature_ts&&...params) noexcept { - auto this_p = static_cast(p_this); - - if constexpr (std::is_void_v) { + if constexpr (std::is_void_v) + { + auto this_p = static_cast(p_this); this_p->m_function(std::forward(params)...); } - else { - auto&& ret_v = this_p->m_function(std::forward(params)...); + } + ForceInline static std::any hop_r(const base_t* p_this, signature_ts&&...params) noexcept + { + auto this_p = static_cast(p_this); + if constexpr (!std::is_void_v) + { + auto&& ret_v = this_p->m_function(std::forward(params)...); if constexpr (std::is_pointer_v) { using raw_t = std::remove_pointer_t; - p_return.emplace(static_cast(ret_v)); + return std::any(static_cast(ret_v)); } else if constexpr (std::is_reference_v) { using raw_t = std::remove_cv_t>; - p_return.emplace(static_cast(&ret_v)); + return std::any(static_cast(&ret_v)); } else { using rconst_t = std::add_const_t>; - p_return.emplace(rconst_t(std::forward(ret_v))); + return std::any(rconst_t(std::forward(ret_v))); } } + else return std::any(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method.h b/ReflectionTemplateLib/rtl/erasure/aware_method.h index a2b02483..6eee7ce6 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method.h @@ -13,6 +13,7 @@ #include "RObjectId.h" #include "erased_method.h" +#include namespace rtl::erase { @@ -29,36 +30,43 @@ namespace rtl::erase { constexpr bool isConstCastSafe = (!traits::is_const_v); - base_t::hopper = hopper; + base_t::hopper_v = hop_v; + base_t::hopper_r = hop_r; base_t::robj_id = detail::RObjectId::create(isConstCastSafe); } - constexpr static void hopper(const base_t* p_this, std::optional& p_return, const record_t& p_target, signature_ts&&...params) noexcept + constexpr static void hop_v(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { - auto this_p = static_cast(p_this); - - if constexpr (std::is_void_v) { + if constexpr (std::is_void_v) + { + auto this_p = static_cast(p_this); this_p->m_method(const_cast(p_target), std::forward(params)...); } - else { - auto&& ret_v = this_p->m_method(const_cast(p_target), std::forward(params)...); + } + ForceInline static std::any hop_r(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + { + if constexpr (!std::is_void_v) + { + auto this_p = static_cast(p_this); + auto&& ret_v = this_p->m_method(const_cast(p_target), std::forward(params)...); if constexpr (std::is_pointer_v) { using raw_t = std::remove_pointer_t; - p_return.emplace(static_cast(ret_v)); + return std::any(static_cast(ret_v)); } else if constexpr (std::is_reference_v) { using raw_t = std::remove_cv_t>; - p_return.emplace(static_cast(&ret_v)); + return std::any(static_cast(&ret_v)); } else { using rconst_t = std::add_const_t>; - p_return.emplace(rconst_t(std::forward(ret_v))); + return std::any(rconst_t(std::forward(ret_v))); } } + else return std::any(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_function.h b/ReflectionTemplateLib/rtl/erasure/erased_function.h index f0c6cb0c..08a76e03 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_function.h @@ -13,15 +13,21 @@ #include "RObjectId.h" #include "rtl_forward_decls.h" +#include "rtl_typeid.h" namespace rtl::erase { template struct erased_function { - constexpr void hop(std::optional& p_return, signature_ts&&...params) const noexcept + constexpr void hop_v(signature_ts&&...params) const noexcept { - (*hopper)(this, p_return, std::forward(params)...); + (*hopper_v)(this, std::forward(params)...); + } + + ForceInline std::any hop_r(signature_ts&&...params) const noexcept + { + return (*hopper_r)(this, std::forward(params)...); } GETTER(detail::RObjectId, _robject_id, robj_id); @@ -30,9 +36,13 @@ namespace rtl::erase using this_t = erased_function; - using functor_t = void(*)(const this_t*, std::optional&, signature_ts&&...); + using functor_vt = void(*)(const this_t*, signature_ts&&...); + + using functor_rt = std::any(*)(const this_t*, signature_ts&&...); + + functor_vt hopper_v = nullptr; - functor_t hopper = nullptr; + functor_rt hopper_r = nullptr; detail::RObjectId robj_id; }; diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method.h index 507e1e4d..2a725312 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method.h @@ -11,6 +11,8 @@ #pragma once +#include +#include "RObjectId.h" #include "rtl_forward_decls.h" namespace rtl::erase @@ -18,9 +20,14 @@ namespace rtl::erase template struct erased_method { - constexpr void hop(std::optional& p_return, const record_t& p_target, signature_ts&&...params) const noexcept + constexpr void hop_v(const record_t& p_target, signature_ts&&...params) const noexcept { - (*hopper)(this, p_return, p_target, std::forward(params)...); + (*hopper_v)(this, p_target, std::forward(params)...); + } + + ForceInline std::any hop_r(const record_t& p_target, signature_ts&&...params) const noexcept + { + return (*hopper_r)(this, p_target, std::forward(params)...); } GETTER(detail::RObjectId, _robject_id, robj_id); @@ -29,9 +36,13 @@ namespace rtl::erase using this_t = erased_method; - using functor_t = void(*)(const this_t*, std::optional& , const record_t&, signature_ts&&...); + using functor_vt = void(*)(const this_t*, const record_t& , signature_ts&&...); + + using functor_rt = std::any(*)(const this_t*, const record_t& , signature_ts&&...); + + functor_vt hopper_v = nullptr; - functor_t hopper = nullptr; + functor_rt hopper_r = nullptr; detail::RObjectId robj_id; }; diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index 26562732..b3b6a27a 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -43,7 +43,7 @@ namespace rtl const std::vector* m_converters = nullptr; RObject(const RObject&) = default; - RObject(std::any&& pObject, detail::RObjectId&& pRObjId, + RObject(std::any&& pObject, const detail::RObjectId& pRObjId, const std::vector* pConverters) noexcept; std::size_t getConverterIndex(const std::size_t pToTypeId) const; diff --git a/ReflectionTemplateLib/rtl/inc/RObject.hpp b/ReflectionTemplateLib/rtl/inc/RObject.hpp index 85a86213..b84b4bac 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.hpp +++ b/ReflectionTemplateLib/rtl/inc/RObject.hpp @@ -25,7 +25,7 @@ namespace rtl { - ForceInline RObject::RObject(std::any&& pObject, detail::RObjectId&& pRObjId, + ForceInline RObject::RObject(std::any&& pObject, const detail::RObjectId& pRObjId, const std::vector* pConverters) noexcept : m_object(std::in_place, std::move(pObject)) , m_objectId(pRObjId) From 22535c1375ccaa3a126f205bbc2f28264e20caf3 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 3 Oct 2025 00:13:21 +0530 Subject: [PATCH 053/148] erased-target method call benchmark added. --- .../src/ReflectedCallUnknownReturn.cpp | 78 ++++++++++++++----- .../src/ReflectedCallUnknownReturn.h | 12 ++- RTLBenchmarkApp/src/StandardCall.cpp | 4 +- RTLBenchmarkApp/src/StdFunction.cpp | 6 +- RTLBenchmarkApp/src/main.cpp | 10 ++- .../FunctionalityTests/ClassMethodsTests.cpp | 24 +++--- .../ConstMethodOverloadTests.cpp | 8 +- .../CopyConstructorTests.cpp | 16 ++-- .../FunctionalityTests/StaticMethodTests.cpp | 4 +- .../rtl/cache/cache_lambda_function.h | 6 +- .../rtl/cache/cache_lambda_method.h | 6 +- .../rtl/detail/inc/FunctionCaller.hpp | 9 ++- .../rtl/detail/inc/MethodInvoker.h | 5 +- .../rtl/detail/inc/MethodInvoker.hpp | 37 +++++++-- ReflectionTemplateLib/rtl/dispatch/lambda.h | 52 ++++--------- .../rtl/dispatch/lambda_function.h | 11 +-- .../rtl/dispatch/lambda_method.h | 17 ++-- .../rtl/dispatch/rtl_method_const.h | 2 +- .../rtl/erasure/CMakeLists.txt | 1 + .../rtl/erasure/aware_function.h | 13 ++-- .../rtl/erasure/aware_method.h | 46 ++++++++++- .../rtl/erasure/aware_method_const.h | 65 +++++++++++++--- .../rtl/erasure/erased_function.h | 27 +++++-- .../rtl/erasure/erased_method.h | 10 ++- ReflectionTemplateLib/rtl/erasure/erasure.h | 50 ++++++++++++ ReflectionTemplateLib/rtl/inc/Method.h | 23 +----- 26 files changed, 362 insertions(+), 180 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/erasure/erasure.h diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 294f8f60..d090cd8d 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -69,22 +69,22 @@ namespace return *method; }(); - // static const rtl::RObject nodeObj = []() - // { - // std::optional Node = cxx::mirror().getRecord("Node"); - // if (!Node) { - // std::cerr << "[x] error: record 'Node' not found.\n"; - // std::abort(); - // } - - // auto [err, robj] = Node->create(); - // if (robj.isEmpty()) { - // std::cout << "[x] error: " << rtl::to_string(err) << "\n"; - // } - // return std::move(robj); - // }(); + static const rtl::RObject nodeObj = []() + { + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } + + auto [err, robj] = Node->create(); + if (robj.isEmpty()) { + std::cout << "[x] error: " << rtl::to_string(err) << "\n"; + } + return std::move(robj); + }(); } - + namespace { @@ -124,6 +124,26 @@ namespace return 0; }; + + static auto _test4 = []() + { + auto err = NodeSendMessage(nodeObj)(bm::g_longStr).err; + if (err != rtl::error::None) { + std::cout << "[01] error: " << rtl::to_string(err) << "\n"; + } + return 0; + }; + + + static auto _test5 = []() + { + auto err = NodeGetMessage(nodeObj)(bm::g_longStr).err; + if (err != rtl::error::None) { + std::cout << "[03] error: " << rtl::to_string(err) << "\n"; + } + return 0; + }; + static auto _new_line = []() { std::cout << std::endl; return 0; @@ -132,7 +152,7 @@ namespace -void RtlFunction_call_ReturnUnknown::typeVoid(benchmark::State& state) +void RtlFunction_call_ReturnUnknown::Void(benchmark::State& state) { static auto __= _new_line(); static auto _ = _test0(); @@ -143,7 +163,7 @@ void RtlFunction_call_ReturnUnknown::typeVoid(benchmark::State& state) } -void RtlFunction_call_ReturnUnknown::typeNonVoid(benchmark::State& state) +void RtlFunction_call_ReturnUnknown::NonVoid(benchmark::State& state) { static auto __= _new_line(); static auto _ = _test2(); @@ -154,7 +174,7 @@ void RtlFunction_call_ReturnUnknown::typeNonVoid(benchmark::State& state) } -void RtlFunction_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) +void RtlFunction_callMethod_ReturnUnknown::Void(benchmark::State& state) { static auto _ = _test1(); static bm::Node node; @@ -165,7 +185,7 @@ void RtlFunction_callMethod_ReturnUnknown::typeVoid(benchmark::State& state) } -void RtlFunction_callMethod_ReturnUnknown::typeNonVoid(benchmark::State& state) +void RtlFunction_callMethod_ReturnUnknown::NonVoid(benchmark::State& state) { static auto _ = _test3(); static bm::Node node; @@ -173,4 +193,24 @@ void RtlFunction_callMethod_ReturnUnknown::typeNonVoid(benchmark::State& state) { benchmark::DoNotOptimize(NodeGetMessage(node)(bm::g_longStr)); } +} + + +void RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void(benchmark::State& state) +{ + static auto _ = _test4(); + for (auto _ : state) + { + benchmark::DoNotOptimize(NodeSendMessage(nodeObj)(bm::g_longStr)); + } +} + + +void RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid(benchmark::State& state) +{ + static auto _ = _test5(); + for (auto _ : state) + { + benchmark::DoNotOptimize(NodeGetMessage(nodeObj)(bm::g_longStr)); + } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index cc986820..37e0e049 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -4,15 +4,19 @@ struct RtlFunction_call_ReturnUnknown { - static void typeVoid(benchmark::State& state); + static void Void(benchmark::State& state); - static void typeNonVoid(benchmark::State& state); + static void NonVoid(benchmark::State& state); }; struct RtlFunction_callMethod_ReturnUnknown { - static void typeVoid(benchmark::State& state); + static void Void(benchmark::State& state); - static void typeNonVoid(benchmark::State& state); + static void NonVoid(benchmark::State& state); + + static void erasedTarget_Void(benchmark::State& state); + + static void erasedTarget_NonVoid(benchmark::State& state); }; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 30de3b2c..0f177969 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -10,8 +10,8 @@ namespace { static auto _put_line = []() { - std::cout << "------------------------------------------" - "--------------------------------------------------" << std::endl; + std::cout << "----------------------------------------------" + "-------------------------------------------------------" << std::endl; return 0; }; diff --git a/RTLBenchmarkApp/src/StdFunction.cpp b/RTLBenchmarkApp/src/StdFunction.cpp index c8d5647c..23b10b65 100644 --- a/RTLBenchmarkApp/src/StdFunction.cpp +++ b/RTLBenchmarkApp/src/StdFunction.cpp @@ -36,10 +36,8 @@ namespace bm std::function GetMessage = [](bm::argStr_t& pMsg) { - //Testing. - return std::any(bm::getMessage(pMsg)); - // auto retMsg = bm::getMessage(pMsg); - // return retMsg; + auto retMsg = bm::getMessage(pMsg); + return retMsg; }; std::function NodeGetMessage = [](bm::Node pNode, bm::argStr_t& pMsg) diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index 1c2c145d..f0dbc2bb 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -17,8 +17,9 @@ BENCHMARK(StdFunction_callMethod::returnVoid); BENCHMARK(RtlFunction_call::returnVoid); BENCHMARK(RtlFunction_callMethod::returnVoid); -BENCHMARK(RtlFunction_call_ReturnUnknown::typeVoid); -BENCHMARK(RtlFunction_callMethod_ReturnUnknown::typeVoid); +BENCHMARK(RtlFunction_call_ReturnUnknown::Void); +BENCHMARK(RtlFunction_callMethod_ReturnUnknown::Void); +BENCHMARK(RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void); BENCHMARK(NativeCall::returnNonVoid); @@ -31,8 +32,9 @@ BENCHMARK(StdFunction_callMethod::returnNonVoid); BENCHMARK(RtlFunction_call::returnNonVoid); BENCHMARK(RtlFunction_callMethod::returnNonVoid); -BENCHMARK(RtlFunction_call_ReturnUnknown::typeNonVoid); -BENCHMARK(RtlFunction_callMethod_ReturnUnknown::typeNonVoid); +BENCHMARK(RtlFunction_call_ReturnUnknown::NonVoid); +BENCHMARK(RtlFunction_callMethod_ReturnUnknown::NonVoid); +BENCHMARK(RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid); namespace bm { diff --git a/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp index ffd62a06..bd10a2a5 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp @@ -82,7 +82,7 @@ namespace rtl_tests ASSERT_FALSE(book.isEmpty()); EXPECT_FALSE(setAuthor->hasSignature()); - auto [err1, ret] = (*setAuthor)(book)(book::AUTHOR); + auto [err1, ret] = setAuthor->bind(book).call(book::AUTHOR); EXPECT_TRUE(err1 == error::SignatureMismatch); ASSERT_TRUE(ret.isEmpty()); @@ -108,7 +108,7 @@ namespace rtl_tests ASSERT_FALSE(book.isEmpty()); EXPECT_FALSE(setAuthor->hasSignature()); - auto [err1, ret] = (*setAuthor)(book)(book::AUTHOR); + auto [err1, ret] = setAuthor->bind(book).call(book::AUTHOR); EXPECT_TRUE(err1 == error::SignatureMismatch); ASSERT_TRUE(ret.isEmpty()); @@ -134,7 +134,7 @@ namespace rtl_tests ASSERT_FALSE(book.isEmpty()); EXPECT_TRUE(getPublishedOn->hasSignature<>()); //empty template params checks for zero arguments. // Slower. bind<>().call() syntax is faster. - auto [err1, ret] = (*getPublishedOn)(book)(); + auto [err1, ret] = getPublishedOn->bind(book).call(); EXPECT_TRUE(err1 == error::None); ASSERT_FALSE(ret.isEmpty()); @@ -163,7 +163,7 @@ namespace rtl_tests ASSERT_FALSE(book.isEmpty()); EXPECT_TRUE(getPublishedOn->hasSignature<>()); //empty template params checks for zero arguments. - auto [err1, ret] = (*getPublishedOn)(book)(); + auto [err1, ret] = getPublishedOn->bind(book).call(); EXPECT_TRUE(err1 == error::None); ASSERT_FALSE(ret.isEmpty()); @@ -246,7 +246,7 @@ namespace rtl_tests ASSERT_FALSE(book.isEmpty()); EXPECT_TRUE(updateBookInfo->hasSignature<>()); //empty template params checks for zero arguments. - auto [err1, ret] = (*updateBookInfo)(book)(); + auto [err1, ret] = updateBookInfo->bind(book).call(); EXPECT_TRUE(err1 == error::None); ASSERT_TRUE(ret.isEmpty()); @@ -272,7 +272,7 @@ namespace rtl_tests ASSERT_FALSE(book.isEmpty()); EXPECT_TRUE(updateBookInfo->hasSignature<>()); //empty template params checks for zero arguments. - auto [err1, ret] = (*updateBookInfo)(book)(); + auto [err1, ret] = updateBookInfo->bind(book).call(); EXPECT_TRUE(err1 == error::None); ASSERT_TRUE(ret.isEmpty()); @@ -304,7 +304,7 @@ namespace rtl_tests std::string author = book::AUTHOR; const char* title = book::TITLE; - auto [err1, ret] = (*updateBookInfo)(book)(author, price, title); + auto [err1, ret] = updateBookInfo->bind(book).call(author, price, title); EXPECT_TRUE(err1 == error::None); ASSERT_TRUE(ret.isEmpty()); @@ -338,7 +338,7 @@ namespace rtl_tests std::string author = book::AUTHOR; const char* title = book::TITLE; - auto [err1, ret] = (*updateBookInfo)(book)(author, price, title); + auto [err1, ret] = updateBookInfo->bind(book).call(author, price, title); EXPECT_TRUE(err1 == error::None); ASSERT_TRUE(ret.isEmpty()); @@ -372,7 +372,7 @@ namespace rtl_tests std::string author = book::AUTHOR; const char* title = book::TITLE; - auto [err1, ret] = (*updateBookInfo)(book)(title, price, author); + auto [err1, ret] = updateBookInfo->bind(book).call(title, price, author); EXPECT_TRUE(err1 == error::None); ASSERT_TRUE(ret.isEmpty()); @@ -406,7 +406,7 @@ namespace rtl_tests std::string author = book::AUTHOR; const char* title = book::TITLE; - auto [err1, ret] = (*updateBookInfo)(book)(title, price, author); + auto [err1, ret] = updateBookInfo->bind(book).call(title, price, author); EXPECT_TRUE(err1 == error::None); ASSERT_TRUE(ret.isEmpty()); @@ -438,7 +438,7 @@ namespace rtl_tests //actual signature is 'const string', but we are passing 'string' as argument. which resolves to right call. //as long as any param_type in signature is not reference, const-qualifier do not matter. - auto [err1, ret] = (*addCopyrightTag)(book)(std::string(book::COPYRIGHT_TAG)); + auto [err1, ret] = addCopyrightTag->bind(book).call(std::string(book::COPYRIGHT_TAG)); EXPECT_TRUE(err1 == error::None); ASSERT_TRUE(ret.isEmpty()); @@ -470,7 +470,7 @@ namespace rtl_tests //actual signature is 'const string', but we are passing 'string' as argument. which resolves to right call. //as long as any param_type in signature is not reference, const-qualifier do not matter. - auto [err1, ret] = (*addCopyrightTag)(book)(std::string(book::COPYRIGHT_TAG)); + auto [err1, ret] = addCopyrightTag->bind(book).call(std::string(book::COPYRIGHT_TAG)); EXPECT_TRUE(err1 == error::None); ASSERT_TRUE(ret.isEmpty()); diff --git a/RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp index 87ba39ce..874c66d0 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp @@ -177,13 +177,13 @@ namespace rtl_tests EXPECT_TRUE(updateLastName->hasSignature()); { string_view lastName = "invalid_arg"; - auto [err, ret] = (*updateLastName)(person)(lastName); + auto [err, ret] = updateLastName->bind(person).call(lastName); EXPECT_TRUE(err == error::SignatureMismatch); ASSERT_TRUE(ret.isEmpty()); } { string lastName = person::LAST_NAME; - auto [err, ret] = (*updateLastName)(person)(lastName); + auto [err, ret] = updateLastName->bind(person).call(lastName); EXPECT_TRUE(err == error::None); ASSERT_TRUE(ret.isEmpty()); @@ -214,13 +214,13 @@ namespace rtl_tests EXPECT_TRUE(updateLastName->hasSignature()); { string_view lastName = "invalid_arg"; - auto [err, ret] = (*updateLastName)(person)(lastName); + auto [err, ret] = updateLastName->bind(person).call(lastName); EXPECT_TRUE(err == error::SignatureMismatch); ASSERT_TRUE(ret.isEmpty()); } { string lastName = person::LAST_NAME; - auto [err, ret] = (*updateLastName)(person)(lastName); + auto [err, ret] = updateLastName->bind(person).call(lastName); EXPECT_TRUE(err == error::None); ASSERT_TRUE(ret.isEmpty()); diff --git a/RTLTestRunApp/src/FunctionalityTests/CopyConstructorTests.cpp b/RTLTestRunApp/src/FunctionalityTests/CopyConstructorTests.cpp index a0de7709..86ba0331 100644 --- a/RTLTestRunApp/src/FunctionalityTests/CopyConstructorTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/CopyConstructorTests.cpp @@ -126,10 +126,10 @@ namespace rtl_tests EXPECT_TRUE(err0 == error::None); ASSERT_FALSE(book.isEmpty()); - auto [err1, ret1] = (*setAuthor)(book)(author); + auto [err1, ret1] = setAuthor->bind(book).call(author); EXPECT_TRUE(err1 == error::None); - auto [err2, ret2] = (*setDecription)(book)(description); + auto [err2, ret2] = setDecription->bind(book).call(description); EXPECT_TRUE(err1 == error::None); auto [err3, bookCopy] = book.clone(); @@ -168,10 +168,10 @@ namespace rtl_tests EXPECT_TRUE(err0 == error::None); ASSERT_FALSE(book.isEmpty()); - auto [err1, ret1] = (*setAuthor)(book)(author); + auto [err1, ret1] = setAuthor->bind(book).call(author); EXPECT_TRUE(err1 == error::None); - auto [err2, ret2] = (*setDecription)(book)(description); + auto [err2, ret2] = setDecription->bind(book).call(description); EXPECT_TRUE(err1 == error::None); auto [err3, bookCopy] = book.clone(); @@ -210,10 +210,10 @@ namespace rtl_tests EXPECT_TRUE(err0 == error::None); ASSERT_FALSE(book.isEmpty()); - auto [err1, ret1] = (*setAuthor)(book)(author); + auto [err1, ret1] = setAuthor->bind(book).call(author); EXPECT_TRUE(err1 == error::None); - auto [err2, ret2] = (*setDecription)(book)(description); + auto [err2, ret2] = setDecription->bind(book).call(description); EXPECT_TRUE(err1 == error::None); auto [err3, bookCopy] = book.clone(); @@ -252,10 +252,10 @@ namespace rtl_tests EXPECT_TRUE(err0 == error::None); ASSERT_FALSE(book.isEmpty()); - auto [err1, ret1] = (*setAuthor)(book)(author); + auto [err1, ret1] = setAuthor->bind(book).call(author); EXPECT_TRUE(err1 == error::None); - auto [err2, ret2] = (*setDecription)(book)(description); + auto [err2, ret2] = setDecription->bind(book).call(description); EXPECT_TRUE(err1 == error::None); auto [err3, bookCopy] = book.clone(); diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp index f8a80759..db6de258 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp @@ -121,7 +121,7 @@ namespace rtl_tests EXPECT_TRUE(err0 == error::None); ASSERT_FALSE(person.isEmpty()); { - auto [err, ret] = (*getDefaults)(person)(); + auto [err, ret] = getDefaults->bind(person).call(); EXPECT_TRUE(err == error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); @@ -168,7 +168,7 @@ namespace rtl_tests EXPECT_EQ(retStr, checkStr); } { - auto [err, ret] = (*getProfile)(person)(occupation, age); + auto [err, ret] = getProfile->bind(person).call(occupation, age); EXPECT_TRUE(err == error::None); ASSERT_FALSE(ret.isEmpty()); diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index e7eccd61..35023d85 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -29,12 +29,10 @@ namespace rtl::cache const dispatch::lambda_function& push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(erase::aware_function()); - erase::erased_function* erasure = &m_erasure_cache.back(); + m_erasure_cache.push_back(erase::aware_function(p_functor)); + m_cache.push_back(dispatch::lambda_function(p_functor, m_erasure_cache.back())); - m_cache.push_back(dispatch::lambda_function(p_functor, erasure)); p_functor.m_lambda = &m_cache.back(); - m_erasure_cache.back().m_function = m_cache.back().template get_hopper(); return m_cache.back(); diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index f2582276..f4200da9 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -30,12 +30,10 @@ namespace rtl::cache const dispatch::lambda_method& push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(erase::aware_method()); - erase::erased_method* erasure = &m_erasure_cache.back(); + m_erasure_cache.push_back(erase::aware_method(p_functor)); + m_cache.push_back(dispatch::lambda_method(p_functor, m_erasure_cache.back())); - m_cache.push_back(dispatch::lambda_method(p_functor, erasure)); p_functor.m_lambda = &m_cache.back(); - m_erasure_cache.back().m_method = m_cache.back().template get_hopper(); return m_cache.back(); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index c662b825..2b8a2001 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -43,17 +43,18 @@ namespace rtl::detail auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { - auto caller = functorId->template get_lambda_function<_args...>()->m_erasure; + const auto& erased = functorId->m_lambda->m_erasure; + const auto& caller = erased.to_erased_ret_function<_args...>(); if(functorId->m_lambda->is_void()) { - caller->hop_v(std::forward<_args>(params)...); + caller.hop_v(std::forward<_args>(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller->hop_r(std::forward<_args>(params)...), - caller->get_robject_id(), nullptr } + RObject{ caller.hop_r(std::forward<_args>(params)...), + caller.get_return_robj_id(), nullptr } }; } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 7654618e..55f9d9f9 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -23,7 +23,10 @@ namespace rtl::detail const _recordType& m_target; - template + template requires (std::is_same_v, RObject> == false) + constexpr Return operator()(_args&&...params) const noexcept; + + template requires (std::is_same_v, RObject> == true) constexpr Return operator()(_args&&...params) const noexcept; }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 0135bf47..cfa01062 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -187,26 +187,53 @@ namespace rtl::detail namespace rtl::detail { template - template + template requires (std::is_same_v, RObject> == false) ForceInline constexpr Return ErasedInvoker<_recordType>::operator()(_args&&...params) const noexcept { auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { - auto caller = functorId->template get_lambda_method<_recordType, _args...>()->m_erasure; + const auto& erased = functorId->m_lambda->m_erasure; + const auto& caller = erased.to_erased_ret_method<_recordType, _args...>(); if(functorId->m_lambda->is_void()) { - caller->hop_v(m_target, std::forward<_args>(params)...); + caller.hop_v(m_target, std::forward<_args>(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller->hop_r(m_target, std::forward<_args>(params)...), - caller->get_robject_id(), nullptr } + RObject{ caller.hop_r(m_target, std::forward<_args>(params)...), + caller.get_return_robj_id(), nullptr } }; } } else return { error::SignatureMismatch, RObject{} }; } + + + template + template requires (std::is_same_v, RObject> == true) + ForceInline constexpr Return ErasedInvoker<_recordType>::operator()(_args&&...params) const noexcept + { + auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + if (functorId) [[likely]] + { + const auto& erased = functorId->m_lambda->m_erasure; + const auto& caller = erased.to_erased_ret_function<_args...>(); + if (functorId->m_lambda->is_void()) + { + caller.hop_v(m_target, std::forward<_args>(params)...); + return { error::None, RObject{} }; + } + else + { + return{ error::None, + RObject{ caller.hop_r(m_target, std::forward<_args>(params)...), + caller.get_return_robj_id(), nullptr } + }; + } + } + else return { error::SignatureMismatch, RObject{} }; + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 15ec6e99..052f5772 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -13,27 +13,19 @@ #include "rtl_traits.h" #include "functor.h" +#include "erasure.h" namespace rtl::dispatch { struct lambda_base { - const functor& m_functor; - - const bool m_is_void; - -// protected: - - lambda_base(const functor& p_functor) noexcept - : m_functor(p_functor) - , m_is_void(p_functor.m_returnId == detail::TypeId::get()) - { } + constexpr bool is_void() const + { + return m_is_void; + } template using function_t = lambda_function; - - template - using method_t = lambda_method; template constexpr const function_t* to_function(std::size_t p_argsId) const @@ -45,6 +37,9 @@ namespace rtl::dispatch else return nullptr; } + template + using method_t = lambda_method; + template constexpr const method_t* to_method(std::size_t p_recordId, std::size_t p_argsId) const { @@ -56,33 +51,18 @@ namespace rtl::dispatch else return nullptr; } -// public: - GETTER_CREF(functor, _functor, m_functor); - constexpr bool is_void() const { - return m_is_void; - } - - template - constexpr bool is_returning() const - { - return (m_functor.m_returnId == detail::TypeId::get()); - } + lambda_base(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept + : m_is_void(p_functor.m_returnId == detail::TypeId::get()) + , m_functor(p_functor) + , m_erasure(p_erasure) + { } - template - constexpr bool is_signature() const - { - return (m_functor.m_signatureId == detail::TypeId...>>::get()); - } + const bool m_is_void; - template - constexpr bool is_member() const - { - return (m_functor.m_recordId == detail::TypeId::get() || - m_functor.m_recordId == detail::TypeId::get()); - } + const functor& m_functor; - friend detail::FunctorId; + const erase::erasure_base& m_erasure; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 2e62c42d..e1f4e097 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -24,13 +24,6 @@ namespace rtl::dispatch template using hopper_t = rtl::function; - erase::erased_function* m_erasure; - - lambda_function(const functor& p_functor, erase::erased_function* p_erasure) noexcept - : lambda_base(p_functor) - , m_erasure(p_erasure) - { } - template constexpr const hopper_t get_hopper(const std::size_t p_returnId = 0) const { @@ -41,5 +34,9 @@ namespace rtl::dispatch } return hopper_t(); } + + lambda_function(const functor& p_functor, const erase::erased_function& p_erasure) noexcept + : lambda_base(p_functor, p_erasure) + { } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 6e5c1cc6..3b673655 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -26,16 +26,6 @@ namespace rtl::dispatch template using hopper_t = rtl::method; - template - using hopper_ct = rtl::method; - - erase::erased_method* m_erasure; - - lambda_method(const functor& p_functor, erase::erased_method* p_erasure) noexcept - : lambda_base(p_functor) - , m_erasure(p_erasure) - { } - template requires (std::is_const_v == false) constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { @@ -47,6 +37,9 @@ namespace rtl::dispatch return hopper_t(); } + template + using hopper_ct = rtl::method; + template requires (std::is_const_v == true) constexpr const hopper_ct get_hopper(std::size_t p_returnId = 0) const { @@ -57,5 +50,9 @@ namespace rtl::dispatch } return hopper_ct(); } + + lambda_method(const functor& p_functor, const erase::erased_method& p_erasure) noexcept + : lambda_base(p_functor, p_erasure) + { } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index 5b4edf73..b7e46b22 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -31,7 +31,7 @@ namespace rtl } template - [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept//(noexcept_v) + [[nodiscard]] constexpr decltype(auto) operator()(const record_t& target, args_t&&...params) const noexcept//(noexcept_v) { //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (target.*m_functor)(std::forward(params)...); diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt index b2f4a6d3..c25d8afc 100644 --- a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -3,6 +3,7 @@ # Collect headers in this folder (absolute paths) set(LOCAL_HEADERS + "${CMAKE_CURRENT_SOURCE_DIR}/erasure.h" "${CMAKE_CURRENT_SOURCE_DIR}/erased_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/erased_function.h" diff --git a/ReflectionTemplateLib/rtl/erasure/aware_function.h b/ReflectionTemplateLib/rtl/erasure/aware_function.h index 80a3282d..4c4d3115 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_function.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_function.h @@ -13,7 +13,6 @@ #include #include "erased_function.h" -#include "rtl_constants.h" namespace rtl::erase { @@ -26,13 +25,13 @@ namespace rtl::erase using this_t = aware_function; - aware_function() - { - constexpr bool isConstCastSafe = (!traits::is_const_v); + constexpr static bool isConstCastSafe = (!traits::is_const_v); + aware_function(const dispatch::functor& p_functor) + : base_t(p_functor, detail::RObjectId::create(isConstCastSafe)) + { base_t::hopper_v = hop_v; base_t::hopper_r = hop_r; - base_t::robj_id = detail::RObjectId::create(isConstCastSafe); } constexpr static void hop_v(const base_t* p_this, signature_ts&&...params) noexcept @@ -62,8 +61,8 @@ namespace rtl::erase } else { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + using raw_ct = std::add_const_t>; + return std::any(raw_ct(std::forward(ret_v))); } } else return std::any(); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method.h b/ReflectionTemplateLib/rtl/erasure/aware_method.h index 6eee7ce6..0a7f7066 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method.h @@ -26,13 +26,15 @@ namespace rtl::erase rtl::method m_method; - aware_method() - { - constexpr bool isConstCastSafe = (!traits::is_const_v); + constexpr static bool isConstCastSafe = (!traits::is_const_v); + aware_method(const dispatch::functor& p_functor) + : base_t(p_functor, detail::RObjectId::create(isConstCastSafe)) + { base_t::hopper_v = hop_v; base_t::hopper_r = hop_r; - base_t::robj_id = detail::RObjectId::create(isConstCastSafe); + base_t::base_t::hopper_robj_v = hop_robj_v; + base_t::base_t::hopper_robj_r = hop_robj_r; } constexpr static void hop_v(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept @@ -44,6 +46,16 @@ namespace rtl::erase } } + constexpr static void hop_robj_v(const base_t::base_t* p_this, const rtl::RObject& p_target, signature_ts&&...params) noexcept + { + if constexpr (std::is_void_v) + { + const auto& target = p_target.view()->get(); + auto this_p = static_cast(p_this); + this_p->m_method(const_cast(target), std::forward(params)...); + } + } + ForceInline static std::any hop_r(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { if constexpr (!std::is_void_v) @@ -68,5 +80,31 @@ namespace rtl::erase } else return std::any(); } + + ForceInline static std::any hop_robj_r(const base_t::base_t* p_this, const rtl::RObject& p_target, signature_ts&&...params) noexcept + { + if constexpr (!std::is_void_v) + { + const auto& target = p_target.view()->get(); + auto this_p = static_cast(p_this); + auto&& ret_v = this_p->m_method(const_cast(target), std::forward(params)...); + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using rconst_t = std::add_const_t>; + return std::any(rconst_t(std::forward(ret_v))); + } + } + else return std::any(); + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h index 6c02f0af..971fdea7 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h @@ -29,36 +29,81 @@ namespace rtl::erase { constexpr bool isConstCastSafe = (!traits::is_const_v); - base_t::hopper = hopper; - base_t::robj_id = detail::RObjectId::create(isConstCastSafe); + base_t::hopper_v = hop_v; + base_t::hopper_r = hop_r; + base_t::base_t::hopper_robj_v = hop_robj_v; + base_t::base_t::hopper_robj_r = hop_robj_r; + base_t::base_t::return_obj_id = detail::RObjectId::create(isConstCastSafe); } - constexpr static void hopper(const base_t* p_this, std::optional& p_return, const record_t& p_target, signature_ts&&...params) noexcept + constexpr static void hop_v(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept { - auto this_p = static_cast(p_this); - - if constexpr (std::is_void_v) { + if constexpr (std::is_void_v) + { + auto this_p = static_cast(p_this); this_p->m_method(p_target, std::forward(params)...); } - else { + } + + constexpr static void hop_robj_v(const base_t::base_t* p_this, const rtl::RObject& p_target, signature_ts&&...params) noexcept + { + if constexpr (std::is_void_v) + { + const auto& target = p_target.view()->get(); + auto this_p = static_cast(p_this); + this_p->m_method(target, std::forward(params)...); + } + } + + ForceInline static std::any hop_r(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + { + if constexpr (!std::is_void_v) + { + auto this_p = static_cast(p_this); auto&& ret_v = this_p->m_method(p_target, std::forward(params)...); + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using rconst_t = std::add_const_t>; + return std::any(rconst_t(std::forward(ret_v))); + } + } + else return std::any(); + } + ForceInline static std::any hop_robj_r(const base_t::base_t* p_this, const rtl::RObject& p_target, signature_ts&&...params) noexcept + { + if constexpr (!std::is_void_v) + { + const auto& target = p_target.view()->get(); + auto this_p = static_cast(p_this); + auto&& ret_v = this_p->m_method(target, std::forward(params)...); if constexpr (std::is_pointer_v) { using raw_t = std::remove_pointer_t; - p_return.emplace(static_cast(ret_v)); + return std::any(static_cast(ret_v)); } else if constexpr (std::is_reference_v) { using raw_t = std::remove_cv_t>; - p_return.emplace(static_cast(&ret_v)); + return std::any(static_cast(&ret_v)); } else { using rconst_t = std::add_const_t>; - p_return.emplace(rconst_t(std::forward(ret_v))); + return std::any(rconst_t(std::forward(ret_v))); } } + else return std::any(); } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_function.h b/ReflectionTemplateLib/rtl/erasure/erased_function.h index 08a76e03..749451eb 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_function.h @@ -12,13 +12,12 @@ #pragma once #include "RObjectId.h" -#include "rtl_forward_decls.h" -#include "rtl_typeid.h" +#include "erasure.h" namespace rtl::erase { template - struct erased_function + struct erased_function : erasure_base { constexpr void hop_v(signature_ts&&...params) const noexcept { @@ -30,7 +29,15 @@ namespace rtl::erase return (*hopper_r)(this, std::forward(params)...); } - GETTER(detail::RObjectId, _robject_id, robj_id); + constexpr void hop_v(const RObject& p_robj, signature_ts&&...params) const noexcept + { + (*hopper_robj_v)(this, p_robj, std::forward(params)...); + } + + ForceInline std::any hop_r(const RObject& p_robj, signature_ts&&...params) const noexcept + { + return (*hopper_robj_r)(this, p_robj, std::forward(params)...); + } protected: @@ -40,10 +47,20 @@ namespace rtl::erase using functor_rt = std::any(*)(const this_t*, signature_ts&&...); + using func_ro_vt = void(*)(const this_t*, const RObject&, signature_ts&&...); + + using func_ro_rt = std::any(*)(const this_t*, const RObject&, signature_ts&&...); + functor_vt hopper_v = nullptr; functor_rt hopper_r = nullptr; - detail::RObjectId robj_id; + func_ro_vt hopper_robj_v = nullptr; + + func_ro_rt hopper_robj_r = nullptr; + + erased_function(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept + : erasure_base(p_functor, p_robj_id) + { } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method.h index 2a725312..75101af2 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method.h @@ -18,7 +18,7 @@ namespace rtl::erase { template - struct erased_method + struct erased_method : erased_function { constexpr void hop_v(const record_t& p_target, signature_ts&&...params) const noexcept { @@ -30,10 +30,10 @@ namespace rtl::erase return (*hopper_r)(this, p_target, std::forward(params)...); } - GETTER(detail::RObjectId, _robject_id, robj_id); - protected: + using base_t = erased_function; + using this_t = erased_method; using functor_vt = void(*)(const this_t*, const record_t& , signature_ts&&...); @@ -44,6 +44,8 @@ namespace rtl::erase functor_rt hopper_r = nullptr; - detail::RObjectId robj_id; + erased_method(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept + : base_t(p_functor, p_robj_id) + { } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure.h b/ReflectionTemplateLib/rtl/erasure/erasure.h new file mode 100644 index 00000000..02001436 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erasure.h @@ -0,0 +1,50 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "functor.h" +#include "RObjectId.h" + +namespace rtl::erase +{ + struct erasure_base + { + template + using function_t = erased_function; + + template + constexpr const function_t& to_erased_ret_function() const + { + return static_cast&>(*this); + } + + template + using method_t = erased_method; + + template + constexpr const method_t& to_erased_ret_method() const + { + return static_cast&>(*this); + } + + erasure_base(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept + : m_functor(p_functor) + , m_ret_obj_id(p_robj_id) + { } + + const dispatch::functor& m_functor; + + const detail::RObjectId m_ret_obj_id; + + GETTER(detail::RObjectId, _return_robj_id, m_ret_obj_id); + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index d298fb60..343cf22e 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -53,6 +53,9 @@ namespace rtl { using Function::bind; + template + constexpr const detail::FunctionCaller<_args...> operator()(_args&&...params) const noexcept = delete; + GETTER_BOOL(Const, (getQualifier() == detail::methodQ::Const)); template @@ -69,29 +72,11 @@ namespace rtl { const detail::NonConstInvoker<_signature...> bind(constCast&& pTarget) const; template - constexpr const detail::ErasedInvoker<_recordType> operator()(const _recordType& pTarget) const + constexpr const detail::ErasedInvoker<_recordType> operator()(_recordType&& pTarget) const { return detail::ErasedInvoker<_recordType>{ (*this), pTarget }; } - - /* @method: operator()(const RObject&) - @param: const RObject& (target object) - @return: lambda - * accepts 'pTarget', which contains the actual object on which the member-function functor associated with 'this' is invoked. - * returns a lambda, which forwards the call to 'call', finally invoking the associated non-static-member-function functor. - * provides syntax like, 'method(pTarget)(params...)', keeping the target & params seperate. - */ constexpr detail::DefaultInvoker<> operator()(const RObject& pTarget) const - { - return detail::DefaultInvoker<>{ this, &pTarget }; - } - - constexpr detail::NonConstInvoker<> operator()(constCast&& pTarget) const - { - return detail::NonConstInvoker<>{ this, &pTarget.m_target }; - } - - //friends :) friend Record; friend detail::CxxReflection; From 7cc85de39193bb99e6c3183f56c65bd8e0902bf3 Mon Sep 17 00:00:00 2001 From: neeraj Date: Fri, 3 Oct 2025 00:31:40 +0530 Subject: [PATCH 054/148] fix gcc/clang compile error. --- RTLBenchmarkApp/src/StandardCall.cpp | 2 +- RTLBenchmarkApp/src/StdFunction.cpp | 2 +- ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp | 2 +- ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 0f177969..f27a11b0 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -34,7 +34,7 @@ namespace bm extern std::function NodeSendMessage; - extern std::function GetMessage; + extern std::function GetMessage; extern std::function NodeGetMessage; } diff --git a/RTLBenchmarkApp/src/StdFunction.cpp b/RTLBenchmarkApp/src/StdFunction.cpp index 23b10b65..b258b02d 100644 --- a/RTLBenchmarkApp/src/StdFunction.cpp +++ b/RTLBenchmarkApp/src/StdFunction.cpp @@ -34,7 +34,7 @@ namespace bm pNode.sendMessage(pMsg); }; - std::function GetMessage = [](bm::argStr_t& pMsg) + std::function GetMessage = [](bm::argStr_t& pMsg) { auto retMsg = bm::getMessage(pMsg); return retMsg; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 2b8a2001..aa9f6822 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -44,7 +44,7 @@ namespace rtl::detail if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.to_erased_ret_function<_args...>(); + const auto& caller = erased.template to_erased_ret_function<_args...>(); if(functorId->m_lambda->is_void()) { caller.hop_v(std::forward<_args>(params)...); diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index cfa01062..284aedc1 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -194,7 +194,7 @@ namespace rtl::detail if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.to_erased_ret_method<_recordType, _args...>(); + const auto& caller = erased.template to_erased_ret_method<_recordType, _args...>(); if(functorId->m_lambda->is_void()) { caller.hop_v(m_target, std::forward<_args>(params)...); @@ -220,7 +220,7 @@ namespace rtl::detail if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.to_erased_ret_function<_args...>(); + const auto& caller = erased.template to_erased_ret_function<_args...>(); if (functorId->m_lambda->is_void()) { caller.hop_v(m_target, std::forward<_args>(params)...); From 40c76613fc6cd6ea4ab8cbc0c77b8d049efb2e3e Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 4 Oct 2025 00:34:39 +0530 Subject: [PATCH 055/148] interface refactored, tests added for known-type-calls. --- .../src/ReflectedCallKnownReturn.cpp | 12 +- .../src/ReflectedCallUnknownReturn.cpp | 8 +- RTLTestRunApp/src/CMakeLists.txt | 1 + .../StaticTypeCFunctionTests.cpp | 189 ++++++++++++++++++ .../rtl/detail/inc/FunctionCaller.h | 2 +- .../rtl/detail/inc/FunctionCaller.hpp | 50 ++--- .../rtl/detail/inc/MethodInvoker.hpp | 12 +- .../rtl/dispatch/rtl_function.h | 5 +- .../rtl/dispatch/rtl_method.h | 5 +- .../rtl/dispatch/rtl_method_const.h | 5 +- .../rtl/erasure/erased_function.h | 8 +- .../rtl/erasure/erased_method.h | 4 +- ReflectionTemplateLib/rtl/erasure/erasure.h | 6 +- ReflectionTemplateLib/rtl/inc/Function.h | 15 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 18 +- ReflectionTemplateLib/rtl/inc/Method.h | 4 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 2 +- ReflectionTemplateLib/rtl/inc/RObject.h | 2 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 2 +- 19 files changed, 263 insertions(+), 87 deletions(-) create mode 100644 RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index f03456ba..4d17b05c 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -28,7 +28,7 @@ namespace std::cerr << "[00] error: erase_function 'getMessage' not found."; std::abort(); } - return function->lambda().argsT().returnT(); + return function->to().argsT().returnT(); }(); static const rtl::function sendMessage = []() @@ -39,7 +39,7 @@ namespace std::cerr << "[01] error: erase_function 'sendMessage' not found."; std::abort(); } - return function->lambda().argsT().returnT(); + return function->to().argsT().returnT(); }(); static const rtl::method getMessageNode = []() @@ -55,7 +55,7 @@ namespace std::cerr << "[02] error: method 'Node::getMessage' not found."; std::abort(); } - return method->lambda().argsT().returnT(); + return method->to().argsT().returnT(); }(); static const rtl::method sendMessageNode = []() @@ -71,7 +71,7 @@ namespace std::cerr << "[3] error: method 'Node::sendMessage' not found."; std::abort(); } - return method->lambda().argsT().returnT(); + return method->to().argsT().returnT(); }(); } @@ -84,9 +84,9 @@ namespace }; template - static bool test(const T& lambda, int callerId) + static bool test(const T& to, int callerId) { - if (!lambda) { + if (!to) { std::cerr << "[" << callerId << "] error: functor not valid, return-type or signature mismatch."; std::abort(); } diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index d090cd8d..cb3a19c0 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -90,7 +90,7 @@ namespace { static auto _test0 = []() { - auto err = SendMessage()(bm::g_longStr).err; + auto err = SendMessage(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[00] error: " << rtl::to_string(err) << "\n"; } @@ -108,7 +108,7 @@ namespace static auto _test2 = []() { - auto err = GetMessage()(bm::g_longStr).err; + auto err = GetMessage(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[02] error: " << rtl::to_string(err) << "\n"; } @@ -158,7 +158,7 @@ void RtlFunction_call_ReturnUnknown::Void(benchmark::State& state) static auto _ = _test0(); for (auto _ : state) { - benchmark::DoNotOptimize(SendMessage()(bm::g_longStr)); + benchmark::DoNotOptimize(SendMessage(bm::g_longStr)); } } @@ -169,7 +169,7 @@ void RtlFunction_call_ReturnUnknown::NonVoid(benchmark::State& state) static auto _ = _test2(); for (auto _ : state) { - benchmark::DoNotOptimize(GetMessage()(bm::g_longStr)); + benchmark::DoNotOptimize(GetMessage(bm::g_longStr)); } } diff --git a/RTLTestRunApp/src/CMakeLists.txt b/RTLTestRunApp/src/CMakeLists.txt index e5d3fc3f..5e0400f4 100644 --- a/RTLTestRunApp/src/CMakeLists.txt +++ b/RTLTestRunApp/src/CMakeLists.txt @@ -6,6 +6,7 @@ project(RTLTestRunApp) # Create a variable containing the source files for your target set(LOCAL_SOURCES_0 "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/ClassMethodsTests.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeCFunctionTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/ConstMethodOverloadTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/ConstructorTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/CopyConstructorTests.cpp" diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp new file mode 100644 index 00000000..51c7d0cd --- /dev/null +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp @@ -0,0 +1,189 @@ + +#include +#include + +#include "TestMirrorProvider.h" +#include "GlobalTestUtils.h" + + +using namespace test_utils; +using namespace test_mirror; + +namespace rtl_tests +{ + TEST(StaticTypeQuery, get_namespace_function_types) + { + std::optional setReal = cxx::mirror().getFunction(str_complex, str_setReal); + ASSERT_TRUE(setReal); + { + EXPECT_TRUE(setReal->getNamespace() == str_complex); + EXPECT_TRUE(setReal->getFunctionName() == str_setReal); + { + rtl::function functor = setReal->to().argsT().returnT(); + ASSERT_TRUE(functor); + } { + rtl::function functor = setReal->to().argsT().returnT(); + ASSERT_FALSE(functor); + } + } + + std::optional setImaginary = cxx::mirror().getFunction(str_complex, str_setImaginary); + ASSERT_TRUE(setImaginary); + { + EXPECT_TRUE(setImaginary->getNamespace() == str_complex); + EXPECT_TRUE(setImaginary->getFunctionName() == str_setImaginary); + { + rtl::function functor = setImaginary->to().argsT().returnT(); + ASSERT_TRUE(functor); + } { + rtl::function functor = setImaginary->to().argsT().returnT(); + ASSERT_FALSE(functor); + } + } + } + + + TEST(StaticTypeQuery, namespace_function_execute_return) + { + std::optional getMagnitude = cxx::mirror().getFunction(str_complex, str_getMagnitude); + ASSERT_TRUE(getMagnitude); + + rtl::function get_magnitude = getMagnitude->to().argsT().returnT(); + ASSERT_TRUE(get_magnitude); + + std::optional setReal = cxx::mirror().getFunction(str_complex, str_setReal); + ASSERT_TRUE(setReal); + + rtl::function set_real = setReal->to().argsT().returnT(); + ASSERT_TRUE(set_real); + + std::optional setImaginary = cxx::mirror().getFunction(str_complex, str_setImaginary); + ASSERT_TRUE(setImaginary); + + rtl::function set_imaginary = setImaginary->to().argsT().returnT(); + ASSERT_TRUE(set_imaginary); + + set_real(g_real); + set_imaginary(g_imaginary); + + double retVal = get_magnitude(); + + double magnitude = abs(std::complex(g_real, g_imaginary)); + + EXPECT_DOUBLE_EQ(magnitude, retVal); + } + + + TEST(StaticTypeQuery, global_function_execute_return) + { + std::optional getComplexNumAsString = cxx::mirror().getFunction(str_getComplexNumAsString); + ASSERT_TRUE(getComplexNumAsString); + { + rtl::function get_complex_num_as_string = getComplexNumAsString->to().argsT().returnT(); + ASSERT_FALSE(get_complex_num_as_string); + } { + rtl::function get_complex_num_as_string = getComplexNumAsString->to().argsT().returnT(); + ASSERT_FALSE(get_complex_num_as_string); + } { + rtl::function get_complex_num_as_string = getComplexNumAsString->to().argsT().returnT(); + ASSERT_TRUE(get_complex_num_as_string); + + std::string ret_str = get_complex_num_as_string(); + + std::string complex_num_str = std::to_string(g_real) + "i" + std::to_string(g_imaginary); + + EXPECT_EQ(complex_num_str, ret_str); + } + } + + + //TEST(StaticTypeQuery, overloaded_function_execute_return) + //{ + // std::optional reverseString = cxx::mirror().getFunction(str_reverseString); + // ASSERT_TRUE(reverseString); + // { + // //STRA's type is 'consexpr const char*', function accepts 'string', + // //so type-casting in place as 'string' + // auto [err, ret] = reverseString->bind().call(string(STRA)); + // EXPECT_TRUE(err == rtl::error::None); + // ASSERT_FALSE(ret.isEmpty()); + // EXPECT_TRUE(ret.canViewAs()); + + // string retVal = ret.view()->get(); + // EXPECT_TRUE(retVal == STRA_REVERSE); + // } { + // //STRB's type is 'consexpr const char*', function accepts 'string', + // //so explicitly binding type in template (using bind<...>()) to enforce the type as 'string'. + // auto [err, ret] = reverseString->bind().call(STRB); + + // EXPECT_TRUE(err == rtl::error::None); + // ASSERT_FALSE(ret.isEmpty()); + // EXPECT_TRUE(ret.canViewAs()); + + // string retVal = ret.view()->get(); + // EXPECT_TRUE(retVal == STRB_REVERSE); + // } { + // auto [err, ret] = reverseString->bind().call(); + // EXPECT_TRUE(err == rtl::error::None); + // ASSERT_FALSE(ret.isEmpty()); + // EXPECT_TRUE(ret.canViewAs()); + // + // string retVal = ret.view()->get(); + // EXPECT_TRUE(retVal == REV_STR_VOID_RET); + // } + //} + + + //TEST(Reflecting_STL_class, std_string__call_reflected_method) + //{ + // optional stdStringClass = cxx::mirror().getRecord("std", "string"); + // ASSERT_TRUE(stdStringClass); + + // optional isStringEmpty = stdStringClass->getMethod("empty"); + // ASSERT_TRUE(isStringEmpty); + + // RObject reflected_str0 = rtl::reflect(std::string("")); //empty string. + // { + // auto [err, ret] = isStringEmpty->bind(reflected_str0).call(); + // EXPECT_TRUE(err == rtl::error::None); + // ASSERT_FALSE(ret.isEmpty()); + // EXPECT_TRUE(ret.canViewAs()); + // EXPECT_TRUE(ret.view()->get()); + // } + // RObject reflected_str1 = rtl::reflect(std::string("not_empty")); + // { + // auto [err, ret] = isStringEmpty->bind(reflected_str1).call(); + // EXPECT_TRUE(err == rtl::error::None); + // ASSERT_FALSE(ret.isEmpty()); + // EXPECT_TRUE(ret.canViewAs()); + // EXPECT_FALSE(ret.view()->get()); + // } + //} + + + //TEST(Reflecting_STL_class, std_string_view__call_reflected_method) + //{ + // optional stdStringClass = cxx::mirror().getRecord("std", "string_view"); + // ASSERT_TRUE(stdStringClass); + + // optional isStringEmpty = stdStringClass->getMethod("empty"); + // ASSERT_TRUE(isStringEmpty); + + // RObject reflected_str0 = rtl::reflect(""); //empty string. + // { + // auto [err, ret] = isStringEmpty->bind(reflected_str0).call(); + // EXPECT_TRUE(err == rtl::error::None); + // ASSERT_FALSE(ret.isEmpty()); + // EXPECT_TRUE(ret.canViewAs()); + // EXPECT_TRUE(ret.view()->get()); + // } + // RObject reflected_str1 = rtl::reflect("not_empty"); + // { + // auto [err, ret] = isStringEmpty->bind(reflected_str1).call(); + // EXPECT_TRUE(err == rtl::error::None); + // ASSERT_FALSE(ret.isEmpty()); + // EXPECT_TRUE(ret.canViewAs()); + // EXPECT_FALSE(ret.view()->get()); + // } + //} +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index ab3453a9..a1d1e89f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -16,7 +16,7 @@ namespace rtl::detail { template - struct FunctionCaller + struct ErasedCaller { const Function* m_function; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index aa9f6822..f27edcea 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -18,15 +18,16 @@ #include "erased_function.h" + namespace rtl::detail { template template - ForceInline Return FunctionCaller<_signature...>::call(_args&&...params) const noexcept + ForceInline Return ErasedCaller<_signature...>::call(_args&&...params) const noexcept { using Container = std::conditional_t...>, - FunctorContainer<_signature...>>; + FunctorContainer...>, + FunctorContainer<_signature...>>; const detail::FunctorId* functorId = m_function->hasFunctorId(Container::getContainerId()); if (functorId != nullptr) [[likely]] { @@ -34,27 +35,31 @@ namespace rtl::detail } return { error::SignatureMismatch, RObject{} }; } +} - template - template - ForceInline constexpr Return FunctionCaller<_signature...>::operator()(_args&&...params) const noexcept + +namespace rtl::detail +{ + template + template + ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept { - auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); + auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_ret_function<_args...>(); + const auto& caller = erased.template to_erased_ret_function(); if(functorId->m_lambda->is_void()) { - caller.hop_v(std::forward<_args>(params)...); + caller.hop_void(std::forward(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller.hop_r(std::forward<_args>(params)...), - caller.get_return_robj_id(), nullptr } + RObject{ caller.hop_return(std::forward(params)...), + caller.get_return_id(), nullptr } }; } } @@ -65,30 +70,29 @@ namespace rtl::detail namespace rtl::detail { - template - inline constexpr const HopFunction<_signature...> Hopper<>::argsT() const + template + inline constexpr const HopFunction Hopper<>::argsT() const { - const auto argsId = TypeId... >>::get(); + const auto argsId = TypeId... >>::get(); for (auto& functorId : m_functorIds) { - auto lambda = functorId.get_lambda_function<_signature...>(argsId); + auto lambda = functorId.get_lambda_function(argsId); if (lambda != nullptr) [[likely]] { return { lambda }; } } - return HopFunction<_signature...>(); + return HopFunction(); } - template - template - inline constexpr const function<_returnType(_signature...)> - HopFunction<_signature...>::returnT() const + template + template + inline constexpr const function HopFunction::returnT() const { - const auto retId = TypeId<_returnType>::get(); + const auto retId = TypeId::get(); if (m_lambda != nullptr) [[likely]] { - return m_lambda->template get_hopper<_returnType>(retId); + return m_lambda->template get_hopper(retId); } - return function<_returnType(_signature...)>(); + return function(); } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 284aedc1..884ba1e9 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -197,14 +197,14 @@ namespace rtl::detail const auto& caller = erased.template to_erased_ret_method<_recordType, _args...>(); if(functorId->m_lambda->is_void()) { - caller.hop_v(m_target, std::forward<_args>(params)...); + caller.hop_void(m_target, std::forward<_args>(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller.hop_r(m_target, std::forward<_args>(params)...), - caller.get_return_robj_id(), nullptr } + RObject{ caller.hop_return(m_target, std::forward<_args>(params)...), + caller.get_return_id(), nullptr } }; } } @@ -223,14 +223,14 @@ namespace rtl::detail const auto& caller = erased.template to_erased_ret_function<_args...>(); if (functorId->m_lambda->is_void()) { - caller.hop_v(m_target, std::forward<_args>(params)...); + caller.hop_void(m_target, std::forward<_args>(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller.hop_r(m_target, std::forward<_args>(params)...), - caller.get_return_robj_id(), nullptr } + RObject{ caller.hop_return(m_target, std::forward<_args>(params)...), + caller.get_return_id(), nullptr } }; } } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index f08071de..e06f0dab 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -30,7 +30,7 @@ namespace rtl } template - [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept // (noexcept_v) + [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept { //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (*m_functor)(std::forward(params)...); @@ -52,8 +52,5 @@ namespace rtl template static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - - //template - //static constexpr bool noexcept_v = noexcept(std::declval()(std::declval()...)); }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 0f60353a..4316cdc9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -31,7 +31,7 @@ namespace rtl } template - [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept //(noexcept_v) + [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept { //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (target.*m_functor)(std::forward(params)...); @@ -53,8 +53,5 @@ namespace rtl template static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - - //template - //static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index b7e46b22..90175568 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -31,7 +31,7 @@ namespace rtl } template - [[nodiscard]] constexpr decltype(auto) operator()(const record_t& target, args_t&&...params) const noexcept//(noexcept_v) + [[nodiscard]] constexpr decltype(auto) operator()(const record_t& target, args_t&&...params) const noexcept { //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (target.*m_functor)(std::forward(params)...); @@ -53,8 +53,5 @@ namespace rtl template static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; - - //template - //static constexpr bool noexcept_v = noexcept((std::declval().*std::declval())(std::declval()...)); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_function.h b/ReflectionTemplateLib/rtl/erasure/erased_function.h index 749451eb..b55645c8 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_function.h @@ -19,22 +19,22 @@ namespace rtl::erase template struct erased_function : erasure_base { - constexpr void hop_v(signature_ts&&...params) const noexcept + constexpr void hop_void(signature_ts&&...params) const noexcept { (*hopper_v)(this, std::forward(params)...); } - ForceInline std::any hop_r(signature_ts&&...params) const noexcept + ForceInline std::any hop_return(signature_ts&&...params) const noexcept { return (*hopper_r)(this, std::forward(params)...); } - constexpr void hop_v(const RObject& p_robj, signature_ts&&...params) const noexcept + constexpr void hop_void(const RObject& p_robj, signature_ts&&...params) const noexcept { (*hopper_robj_v)(this, p_robj, std::forward(params)...); } - ForceInline std::any hop_r(const RObject& p_robj, signature_ts&&...params) const noexcept + ForceInline std::any hop_return(const RObject& p_robj, signature_ts&&...params) const noexcept { return (*hopper_robj_r)(this, p_robj, std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method.h index 75101af2..39487f55 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method.h @@ -20,12 +20,12 @@ namespace rtl::erase template struct erased_method : erased_function { - constexpr void hop_v(const record_t& p_target, signature_ts&&...params) const noexcept + constexpr void hop_void(const record_t& p_target, signature_ts&&...params) const noexcept { (*hopper_v)(this, p_target, std::forward(params)...); } - ForceInline std::any hop_r(const record_t& p_target, signature_ts&&...params) const noexcept + ForceInline std::any hop_return(const record_t& p_target, signature_ts&&...params) const noexcept { return (*hopper_r)(this, p_target, std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/erasure/erasure.h b/ReflectionTemplateLib/rtl/erasure/erasure.h index 02001436..cb001113 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure.h @@ -38,13 +38,13 @@ namespace rtl::erase erasure_base(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept : m_functor(p_functor) - , m_ret_obj_id(p_robj_id) + , m_robj_id(p_robj_id) { } const dispatch::functor& m_functor; - const detail::RObjectId m_ret_obj_id; + const detail::RObjectId m_robj_id; - GETTER(detail::RObjectId, _return_robj_id, m_ret_obj_id); + GETTER(detail::RObjectId, _return_id, m_robj_id); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 6edd8c0d..8ba3bb43 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -88,23 +88,26 @@ namespace rtl { Function& operator=(Function&&) = default; Function& operator=(const Function&) = default; - constexpr detail::Hopper<> lambda() const; + constexpr detail::Hopper<> to() const; bool hasSignature() const; template bool hasSignature() const; - template - constexpr const detail::FunctionCaller<_args...> operator()(_args&&...params) const noexcept; - template - constexpr const detail::FunctionCaller<_signature...> bind() const noexcept; + constexpr const detail::ErasedCaller<_signature...> bind() const noexcept; + + template + constexpr rtl::Return operator()(_args&&...params) const noexcept + { + return detail::ErasedCaller<_args...>{ this }(std::forward<_args>(params)...); + } friend detail::CxxReflection; friend detail::ReflectionBuilder; template - friend class detail::FunctionCaller; + friend class detail::ErasedCaller; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 77dd5ec1..e63053eb 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -21,13 +21,13 @@ namespace rtl { template - inline constexpr const detail::FunctionCaller<_signature...> Function::bind() const noexcept + inline constexpr const detail::ErasedCaller<_signature...> Function::bind() const noexcept { - return detail::FunctionCaller<_signature...>{ this }; + return detail::ErasedCaller<_signature...>{ this }; } - inline constexpr detail::Hopper<> Function::lambda() const + inline constexpr detail::Hopper<> Function::to() const { return detail::Hopper<>{ m_functorIds }; } @@ -45,18 +45,6 @@ namespace rtl } -/* @method: operator()() - @param: variadic arguments. - @return: Return, possible error & return value of from the reflected call. - * if the arguments did not match with any overload, returns RObject with error::SignatureMismatch - * providing optional syntax, Function::call() does the exact same thing. -*/ template - inline constexpr const detail::FunctionCaller<_args...> Function::operator()(_args&& ...params) const noexcept - { - return detail::FunctionCaller<_args...>{ this }; - } - - /* @method: hasSignatureId() @param: const std::size_t& (signatureId to be found) @return: the index of the functor in the functor-table. diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 343cf22e..ba2cdde8 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -54,12 +54,12 @@ namespace rtl { using Function::bind; template - constexpr const detail::FunctionCaller<_args...> operator()(_args&&...params) const noexcept = delete; + constexpr const detail::ErasedCaller<_args...> operator()(_args&&...params) const noexcept = delete; GETTER_BOOL(Const, (getQualifier() == detail::methodQ::Const)); template - constexpr detail::Hopper<_recordType> lambda() const; + constexpr detail::Hopper<_recordType> to() const; //indicates if a particular set of arguments accepted by the functor associated with it. template diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 9e63f222..b415685d 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -30,7 +30,7 @@ namespace rtl template - inline constexpr detail::Hopper<_recordType> Method::lambda() const + inline constexpr detail::Hopper<_recordType> Method::to() const { return detail::Hopper<_recordType>{ getFunctorIds() }; } diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index b3b6a27a..a0e597aa 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -107,7 +107,7 @@ namespace rtl friend struct detail::RObjectBuilder; template - friend struct detail::FunctionCaller; + friend struct detail::ErasedCaller; template friend struct detail::ErasedInvoker; diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 08b1f8ac..9febcad4 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -54,7 +54,7 @@ namespace rtl class FunctorContainer; template - struct FunctionCaller; + struct ErasedCaller; template struct ErasedInvoker; From 551443eccb3274c03de6c291dffa2a7578812457 Mon Sep 17 00:00:00 2001 From: neeraj Date: Sat, 4 Oct 2025 00:42:55 +0530 Subject: [PATCH 056/148] fix gcc/clang compile error. --- ReflectionTemplateLib/rtl/inc/Function.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 8ba3bb43..18f505af 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -15,6 +15,7 @@ #include #include +#include "RObject.h" #include "FunctionCaller.h" namespace rtl { From 9a58d1ad1ede7743c481b272fefcda9ceaaa6d07 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 4 Oct 2025 17:43:27 +0530 Subject: [PATCH 057/148] static-dispatch test cases, const-method resolution. --- .../src/ReflectedCallKnownReturn.cpp | 8 +- .../StaticTypeCFunctionTests.cpp | 185 ++++++++---------- .../rtl/detail/inc/MethodInvoker.h | 17 +- .../rtl/detail/inc/MethodInvoker.hpp | 66 ++++--- .../rtl/dispatch/rtl_function.h | 4 - .../rtl/dispatch/rtl_method.h | 4 - .../rtl/dispatch/rtl_method_const.h | 4 - ReflectionTemplateLib/rtl/inc/Function.h | 3 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 7 +- ReflectionTemplateLib/rtl/inc/Method.h | 9 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 6 +- 11 files changed, 152 insertions(+), 161 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 4d17b05c..cd0c36fd 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -28,7 +28,7 @@ namespace std::cerr << "[00] error: erase_function 'getMessage' not found."; std::abort(); } - return function->to().argsT().returnT(); + return function->argsT().returnT(); }(); static const rtl::function sendMessage = []() @@ -39,7 +39,7 @@ namespace std::cerr << "[01] error: erase_function 'sendMessage' not found."; std::abort(); } - return function->to().argsT().returnT(); + return function->argsT().returnT(); }(); static const rtl::method getMessageNode = []() @@ -55,7 +55,7 @@ namespace std::cerr << "[02] error: method 'Node::getMessage' not found."; std::abort(); } - return method->to().argsT().returnT(); + return method->recordT().argsT().returnT(); }(); static const rtl::method sendMessageNode = []() @@ -71,7 +71,7 @@ namespace std::cerr << "[3] error: method 'Node::sendMessage' not found."; std::abort(); } - return method->to().argsT().returnT(); + return method->recordT().argsT().returnT(); }(); } diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp index 51c7d0cd..7a561d38 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp @@ -11,7 +11,7 @@ using namespace test_mirror; namespace rtl_tests { - TEST(StaticTypeQuery, get_namespace_function_types) + TEST(StaticTypeFunctionQuery, function_validation_with_given_signature) { std::optional setReal = cxx::mirror().getFunction(str_complex, str_setReal); ASSERT_TRUE(setReal); @@ -19,10 +19,10 @@ namespace rtl_tests EXPECT_TRUE(setReal->getNamespace() == str_complex); EXPECT_TRUE(setReal->getFunctionName() == str_setReal); { - rtl::function functor = setReal->to().argsT().returnT(); + rtl::function functor = setReal->argsT().returnT(); ASSERT_TRUE(functor); } { - rtl::function functor = setReal->to().argsT().returnT(); + rtl::function functor = setReal->argsT().returnT(); ASSERT_FALSE(functor); } } @@ -33,34 +33,34 @@ namespace rtl_tests EXPECT_TRUE(setImaginary->getNamespace() == str_complex); EXPECT_TRUE(setImaginary->getFunctionName() == str_setImaginary); { - rtl::function functor = setImaginary->to().argsT().returnT(); + rtl::function functor = setImaginary->argsT().returnT(); ASSERT_TRUE(functor); } { - rtl::function functor = setImaginary->to().argsT().returnT(); + rtl::function functor = setImaginary->argsT().returnT(); ASSERT_FALSE(functor); } } } - TEST(StaticTypeQuery, namespace_function_execute_return) + TEST(StaticTypeFunctionQuery, function_executation_with_given_signature) { std::optional getMagnitude = cxx::mirror().getFunction(str_complex, str_getMagnitude); ASSERT_TRUE(getMagnitude); - rtl::function get_magnitude = getMagnitude->to().argsT().returnT(); + rtl::function get_magnitude = getMagnitude->argsT<>().returnT(); ASSERT_TRUE(get_magnitude); std::optional setReal = cxx::mirror().getFunction(str_complex, str_setReal); ASSERT_TRUE(setReal); - rtl::function set_real = setReal->to().argsT().returnT(); + rtl::function set_real = setReal->argsT().returnT(); ASSERT_TRUE(set_real); std::optional setImaginary = cxx::mirror().getFunction(str_complex, str_setImaginary); ASSERT_TRUE(setImaginary); - rtl::function set_imaginary = setImaginary->to().argsT().returnT(); + rtl::function set_imaginary = setImaginary->argsT().returnT(); ASSERT_TRUE(set_imaginary); set_real(g_real); @@ -74,18 +74,18 @@ namespace rtl_tests } - TEST(StaticTypeQuery, global_function_execute_return) + TEST(StaticTypeFunctionQuery, global_function_executation_with_given_signature) { std::optional getComplexNumAsString = cxx::mirror().getFunction(str_getComplexNumAsString); ASSERT_TRUE(getComplexNumAsString); { - rtl::function get_complex_num_as_string = getComplexNumAsString->to().argsT().returnT(); + rtl::function get_complex_num_as_string = getComplexNumAsString->argsT<>().returnT(); ASSERT_FALSE(get_complex_num_as_string); } { - rtl::function get_complex_num_as_string = getComplexNumAsString->to().argsT().returnT(); + rtl::function get_complex_num_as_string = getComplexNumAsString->argsT<>().returnT(); ASSERT_FALSE(get_complex_num_as_string); } { - rtl::function get_complex_num_as_string = getComplexNumAsString->to().argsT().returnT(); + rtl::function get_complex_num_as_string = getComplexNumAsString->argsT<>().returnT(); ASSERT_TRUE(get_complex_num_as_string); std::string ret_str = get_complex_num_as_string(); @@ -97,93 +97,74 @@ namespace rtl_tests } - //TEST(StaticTypeQuery, overloaded_function_execute_return) - //{ - // std::optional reverseString = cxx::mirror().getFunction(str_reverseString); - // ASSERT_TRUE(reverseString); - // { - // //STRA's type is 'consexpr const char*', function accepts 'string', - // //so type-casting in place as 'string' - // auto [err, ret] = reverseString->bind().call(string(STRA)); - // EXPECT_TRUE(err == rtl::error::None); - // ASSERT_FALSE(ret.isEmpty()); - // EXPECT_TRUE(ret.canViewAs()); - - // string retVal = ret.view()->get(); - // EXPECT_TRUE(retVal == STRA_REVERSE); - // } { - // //STRB's type is 'consexpr const char*', function accepts 'string', - // //so explicitly binding type in template (using bind<...>()) to enforce the type as 'string'. - // auto [err, ret] = reverseString->bind().call(STRB); - - // EXPECT_TRUE(err == rtl::error::None); - // ASSERT_FALSE(ret.isEmpty()); - // EXPECT_TRUE(ret.canViewAs()); - - // string retVal = ret.view()->get(); - // EXPECT_TRUE(retVal == STRB_REVERSE); - // } { - // auto [err, ret] = reverseString->bind().call(); - // EXPECT_TRUE(err == rtl::error::None); - // ASSERT_FALSE(ret.isEmpty()); - // EXPECT_TRUE(ret.canViewAs()); - // - // string retVal = ret.view()->get(); - // EXPECT_TRUE(retVal == REV_STR_VOID_RET); - // } - //} - - - //TEST(Reflecting_STL_class, std_string__call_reflected_method) - //{ - // optional stdStringClass = cxx::mirror().getRecord("std", "string"); - // ASSERT_TRUE(stdStringClass); - - // optional isStringEmpty = stdStringClass->getMethod("empty"); - // ASSERT_TRUE(isStringEmpty); - - // RObject reflected_str0 = rtl::reflect(std::string("")); //empty string. - // { - // auto [err, ret] = isStringEmpty->bind(reflected_str0).call(); - // EXPECT_TRUE(err == rtl::error::None); - // ASSERT_FALSE(ret.isEmpty()); - // EXPECT_TRUE(ret.canViewAs()); - // EXPECT_TRUE(ret.view()->get()); - // } - // RObject reflected_str1 = rtl::reflect(std::string("not_empty")); - // { - // auto [err, ret] = isStringEmpty->bind(reflected_str1).call(); - // EXPECT_TRUE(err == rtl::error::None); - // ASSERT_FALSE(ret.isEmpty()); - // EXPECT_TRUE(ret.canViewAs()); - // EXPECT_FALSE(ret.view()->get()); - // } - //} - - - //TEST(Reflecting_STL_class, std_string_view__call_reflected_method) - //{ - // optional stdStringClass = cxx::mirror().getRecord("std", "string_view"); - // ASSERT_TRUE(stdStringClass); - - // optional isStringEmpty = stdStringClass->getMethod("empty"); - // ASSERT_TRUE(isStringEmpty); - - // RObject reflected_str0 = rtl::reflect(""); //empty string. - // { - // auto [err, ret] = isStringEmpty->bind(reflected_str0).call(); - // EXPECT_TRUE(err == rtl::error::None); - // ASSERT_FALSE(ret.isEmpty()); - // EXPECT_TRUE(ret.canViewAs()); - // EXPECT_TRUE(ret.view()->get()); - // } - // RObject reflected_str1 = rtl::reflect("not_empty"); - // { - // auto [err, ret] = isStringEmpty->bind(reflected_str1).call(); - // EXPECT_TRUE(err == rtl::error::None); - // ASSERT_FALSE(ret.isEmpty()); - // EXPECT_TRUE(ret.canViewAs()); - // EXPECT_FALSE(ret.view()->get()); - // } - //} + TEST(StaticTypeFunctionQuery, function_overload_resolution_with_given_signature) + { + std::optional reverseString = cxx::mirror().getFunction(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(STRA); + EXPECT_EQ(ret_str, STRA_REVERSE); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(STRB); + EXPECT_EQ(ret_str, STRB_REVERSE); + } { + rtl::function reverse_string = reverseString->argsT<>().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(); + EXPECT_EQ(ret_str, REV_STR_VOID_RET); + } + } + + + TEST(StaticTypeMethodQuery, std_string_call_reflected_method_empty) + { + std::optional stdStringClass = cxx::mirror().getRecord("std", "string"); + ASSERT_TRUE(stdStringClass); + + std::optional isStringEmpty = stdStringClass->getMethod("empty"); + ASSERT_TRUE(isStringEmpty); + + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + ASSERT_TRUE(is_empty); + + EXPECT_TRUE(is_empty(std::string(""))); + + EXPECT_FALSE(is_empty(std::string("not_empty"))); + + EXPECT_TRUE(is_empty("")); + + EXPECT_FALSE(is_empty("view_not_empty")); + } + + + TEST(StaticTypeMethodQuery, std_string_view_call_reflected_method_empty) + { + std::optional stdStringViewClass = cxx::mirror().getRecord("std", "string_view"); + ASSERT_TRUE(stdStringViewClass); + + std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); + ASSERT_TRUE(isStringEmpty); + + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + ASSERT_TRUE(is_empty); + + EXPECT_TRUE(is_empty(std::string(""))); + + EXPECT_FALSE(is_empty(std::string("not_empty"))); + + EXPECT_TRUE(is_empty(std::string_view(""))); + + EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))); + + EXPECT_TRUE(is_empty("")); + + EXPECT_FALSE(is_empty("view_not_empty")); + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 55f9d9f9..2b7d0dd1 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -89,21 +89,24 @@ namespace rtl::detail { namespace rtl::detail { - template + template struct HopMethod { - const dispatch::lambda_method<_recordType, _signature...>* m_lambda = nullptr; + const dispatch::lambda_method* m_lambda = nullptr; - template - constexpr const method<_returnType(_recordType::*)(_signature...)> returnT() const; + template requires (std::is_const_v == false) + constexpr const method returnT() const; + + template requires (std::is_const_v == true) + constexpr const method returnT() const; }; - template + template struct Hopper { const std::vector& m_functorIds; - template - constexpr HopMethod<_recordType, _signature...> argsT() const; + template + constexpr HopMethod argsT() const; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 884ba1e9..bfd6beef 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -152,58 +152,72 @@ namespace rtl::detail namespace rtl::detail { - template - template - inline constexpr HopMethod<_recordType, _signature...> Hopper<_recordType>::argsT() const + template + template + inline constexpr HopMethod Hopper::argsT() const { - const auto recId = TypeId<_recordType>::get(); - const auto argsId = TypeId...>>::get(); + const auto recId = TypeId::get(); + const auto argsId = TypeId...>>::get(); for (auto& functorId : m_functorIds) { - auto lambda = functorId.get_lambda_method<_recordType, _signature...>(recId, argsId); + auto lambda = functorId.get_lambda_method(recId, argsId); if (lambda != nullptr) [[likely]] { return { lambda }; } } - return HopMethod<_recordType, _signature...>(); + return HopMethod(); + } + + + template + template requires (std::is_const_v == false) + inline constexpr const method<_returnType(recordT::*)(signatureT...)> + HopMethod::returnT() const + { + if (m_lambda != nullptr) [[likely]] + { + const auto retId = TypeId<_returnType>::get(); + return m_lambda->template get_hopper<_returnType>(retId); + } + return method<_returnType(recordT::*)(signatureT...)>(); } - template - template - inline constexpr const method<_returnType(_recordType::*)(_signature...)> - HopMethod<_recordType, _signature...>::returnT() const + template + template requires (std::is_const_v == true) + inline constexpr const method<_returnType(recordT::*)(signatureT...) const> + HopMethod::returnT() const { if (m_lambda != nullptr) [[likely]] { const auto retId = TypeId<_returnType>::get(); return m_lambda->template get_hopper<_returnType>(retId); } - return method<_returnType(_recordType::*)(_signature...)>(); + return method<_returnType(recordT::*)(signatureT...) const>(); } } namespace rtl::detail { - template - template requires (std::is_same_v, RObject> == false) - ForceInline constexpr Return ErasedInvoker<_recordType>::operator()(_args&&...params) const noexcept + template + template requires (std::is_same_v, RObject> == false) + ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_ret_method<_recordType, _args...>(); + const auto& caller = erased.template to_erased_ret_method(); if(functorId->m_lambda->is_void()) { - caller.hop_void(m_target, std::forward<_args>(params)...); + caller.hop_void(m_target, std::forward(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller.hop_return(m_target, std::forward<_args>(params)...), + RObject{ caller.hop_return(m_target, std::forward(params)...), caller.get_return_id(), nullptr } }; } @@ -212,24 +226,24 @@ namespace rtl::detail } - template - template requires (std::is_same_v, RObject> == true) - ForceInline constexpr Return ErasedInvoker<_recordType>::operator()(_args&&...params) const noexcept + template + template requires (std::is_same_v, RObject> == true) + ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_ret_function<_args...>(); + const auto& caller = erased.template to_erased_ret_function(); if (functorId->m_lambda->is_void()) { - caller.hop_void(m_target, std::forward<_args>(params)...); + caller.hop_void(m_target, std::forward(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller.hop_return(m_target, std::forward<_args>(params)...), + RObject{ caller.hop_return(m_target, std::forward(params)...), caller.get_return_id(), nullptr } }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index e06f0dab..7470998b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -32,7 +32,6 @@ namespace rtl template [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept { - //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (*m_functor)(std::forward(params)...); } @@ -49,8 +48,5 @@ namespace rtl private: fptr_t m_functor = nullptr; - - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 4316cdc9..3ccc65da 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -33,7 +33,6 @@ namespace rtl template [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept { - //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (target.*m_functor)(std::forward(params)...); } @@ -50,8 +49,5 @@ namespace rtl private: fptr_t m_functor = nullptr; - - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index 90175568..d7a467ff 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -33,7 +33,6 @@ namespace rtl template [[nodiscard]] constexpr decltype(auto) operator()(const record_t& target, args_t&&...params) const noexcept { - //static_assert(is_args_t_ok, "Argument types don't match the expected signature."); return (target.*m_functor)(std::forward(params)...); } @@ -50,8 +49,5 @@ namespace rtl private: fptr_t m_functor = nullptr; - - template - static constexpr bool is_args_t_ok = std::is_same_v...>, std::tuple>; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 8ba3bb43..f6f70f2d 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -88,7 +88,8 @@ namespace rtl { Function& operator=(Function&&) = default; Function& operator=(const Function&) = default; - constexpr detail::Hopper<> to() const; + template + constexpr const detail::HopFunction argsT() const; bool hasSignature() const; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index e63053eb..b01f23c1 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -26,12 +26,13 @@ namespace rtl return detail::ErasedCaller<_signature...>{ this }; } - - inline constexpr detail::Hopper<> Function::to() const + template + inline constexpr const detail::HopFunction Function::argsT() const { - return detail::Hopper<>{ m_functorIds }; + return detail::Hopper<>{ m_functorIds }.argsT(); } + /* @method: hasSignature<...>() @param: set of arguments, explicitly specified as template parameter. @return: bool, if the functor associated with this object is of certain signature or not. diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index ba2cdde8..9e746680 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -51,15 +51,18 @@ namespace rtl { Method& operator=(Method&&) = default; Method& operator=(const Method&) = default; + GETTER_BOOL(Const, (getQualifier() == detail::methodQ::Const)); + using Function::bind; template constexpr const detail::ErasedCaller<_args...> operator()(_args&&...params) const noexcept = delete; - GETTER_BOOL(Const, (getQualifier() == detail::methodQ::Const)); + template + constexpr const detail::HopFunction argsT() const = delete; - template - constexpr detail::Hopper<_recordType> to() const; + template + constexpr detail::Hopper recordT() const; //indicates if a particular set of arguments accepted by the functor associated with it. template diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index b415685d..7f0ae7e6 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -29,10 +29,10 @@ namespace rtl } - template - inline constexpr detail::Hopper<_recordType> Method::to() const + template + inline constexpr detail::Hopper Method::recordT() const { - return detail::Hopper<_recordType>{ getFunctorIds() }; + return detail::Hopper{ getFunctorIds() }; } From 491cfed8d88abc400a075e8a24a7e2bc41af9f93 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 4 Oct 2025 23:59:32 +0530 Subject: [PATCH 058/148] strict-type-matching for static-typed dispatch, tests. --- RTLTestRunApp/src/CMakeLists.txt | 1 + ...Tests.cpp => StrictStaticTypeDispatch.cpp} | 75 +++++++++++-------- .../rtl/detail/inc/FunctionCaller.hpp | 4 +- .../rtl/detail/inc/MethodInvoker.hpp | 6 +- .../rtl/dispatch/functor_function.h | 2 +- .../rtl/dispatch/functor_method.h | 2 +- .../rtl/dispatch/functor_method_const.h | 2 +- ReflectionTemplateLib/rtl/rtl_traits.h | 10 +++ 8 files changed, 62 insertions(+), 40 deletions(-) rename RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/{StaticTypeCFunctionTests.cpp => StrictStaticTypeDispatch.cpp} (59%) diff --git a/RTLTestRunApp/src/CMakeLists.txt b/RTLTestRunApp/src/CMakeLists.txt index 5e0400f4..81ec3ddd 100644 --- a/RTLTestRunApp/src/CMakeLists.txt +++ b/RTLTestRunApp/src/CMakeLists.txt @@ -16,6 +16,7 @@ set(LOCAL_SOURCES_0 "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/PerfectForwardingTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/MoveConstructorTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/ReturnValueReflectionTest.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp" ) # Create a variable containing the source files for your target diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp similarity index 59% rename from RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp rename to RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp index 7a561d38..2ade857f 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StaticTypeCFunctionTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp @@ -11,7 +11,7 @@ using namespace test_mirror; namespace rtl_tests { - TEST(StaticTypeFunctionQuery, function_validation_with_given_signature) + TEST(StrictStaticTypeDispatch, namespace_function_validation_with_known_signature) { std::optional setReal = cxx::mirror().getFunction(str_complex, str_setReal); ASSERT_TRUE(setReal); @@ -43,7 +43,7 @@ namespace rtl_tests } - TEST(StaticTypeFunctionQuery, function_executation_with_given_signature) + TEST(StrictStaticTypeDispatch, namespace_function_call_with_known_signature) { std::optional getMagnitude = cxx::mirror().getFunction(str_complex, str_getMagnitude); ASSERT_TRUE(getMagnitude); @@ -74,21 +74,21 @@ namespace rtl_tests } - TEST(StaticTypeFunctionQuery, global_function_executation_with_given_signature) + TEST(StrictStaticTypeDispatch, global_function_call_with_known_signature) { - std::optional getComplexNumAsString = cxx::mirror().getFunction(str_getComplexNumAsString); - ASSERT_TRUE(getComplexNumAsString); + std::optional getComplexNumStr = cxx::mirror().getFunction(str_getComplexNumAsString); + ASSERT_TRUE(getComplexNumStr); { - rtl::function get_complex_num_as_string = getComplexNumAsString->argsT<>().returnT(); - ASSERT_FALSE(get_complex_num_as_string); + rtl::function get_complex_num_str = getComplexNumStr->argsT<>().returnT(); + ASSERT_FALSE(get_complex_num_str); } { - rtl::function get_complex_num_as_string = getComplexNumAsString->argsT<>().returnT(); - ASSERT_FALSE(get_complex_num_as_string); + rtl::function get_complex_num_str = getComplexNumStr->argsT<>().returnT(); + ASSERT_FALSE(get_complex_num_str); } { - rtl::function get_complex_num_as_string = getComplexNumAsString->argsT<>().returnT(); - ASSERT_TRUE(get_complex_num_as_string); + rtl::function get_complex_num_str = getComplexNumStr->argsT<>().returnT(); + ASSERT_TRUE(get_complex_num_str); - std::string ret_str = get_complex_num_as_string(); + std::string ret_str = get_complex_num_str(); std::string complex_num_str = std::to_string(g_real) + "i" + std::to_string(g_imaginary); @@ -97,12 +97,15 @@ namespace rtl_tests } - TEST(StaticTypeFunctionQuery, function_overload_resolution_with_given_signature) + TEST(StrictStaticTypeDispatch, overload_resolution_with_known_signatures) { std::optional reverseString = cxx::mirror().getFunction(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::function reverse_string = reverseString->argsT().returnT(); + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_FALSE(reverse_string); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(STRA); @@ -123,48 +126,56 @@ namespace rtl_tests } - TEST(StaticTypeMethodQuery, std_string_call_reflected_method_empty) + TEST(StrictStaticTypeDispatch, std_string_method_call_with_known_signature) { std::optional stdStringClass = cxx::mirror().getRecord("std", "string"); ASSERT_TRUE(stdStringClass); std::optional isStringEmpty = stdStringClass->getMethod("empty"); ASSERT_TRUE(isStringEmpty); + { + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + ASSERT_FALSE(is_empty); + } { + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + ASSERT_TRUE(is_empty); - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); - ASSERT_TRUE(is_empty); - - EXPECT_TRUE(is_empty(std::string(""))); + EXPECT_TRUE(is_empty(std::string(""))); - EXPECT_FALSE(is_empty(std::string("not_empty"))); + EXPECT_FALSE(is_empty(std::string("not_empty"))); - EXPECT_TRUE(is_empty("")); + EXPECT_TRUE(is_empty("")); - EXPECT_FALSE(is_empty("view_not_empty")); + EXPECT_FALSE(is_empty("view_not_empty")); + } } - TEST(StaticTypeMethodQuery, std_string_view_call_reflected_method_empty) + TEST(StrictStaticTypeDispatch, std_string_view_method_call_with_known_signature) { std::optional stdStringViewClass = cxx::mirror().getRecord("std", "string_view"); ASSERT_TRUE(stdStringViewClass); std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); ASSERT_TRUE(isStringEmpty); + { + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + ASSERT_FALSE(is_empty); + } { + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + ASSERT_TRUE(is_empty); - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); - ASSERT_TRUE(is_empty); - - EXPECT_TRUE(is_empty(std::string(""))); + EXPECT_TRUE(is_empty(std::string(""))); - EXPECT_FALSE(is_empty(std::string("not_empty"))); + EXPECT_FALSE(is_empty(std::string("not_empty"))); - EXPECT_TRUE(is_empty(std::string_view(""))); + EXPECT_TRUE(is_empty(std::string_view(""))); - EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))); + EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))); - EXPECT_TRUE(is_empty("")); + EXPECT_TRUE(is_empty("")); - EXPECT_FALSE(is_empty("view_not_empty")); + EXPECT_FALSE(is_empty("view_not_empty")); + } } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index f27edcea..9d8b9635 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -45,7 +45,7 @@ namespace rtl::detail template ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept { - auto functorId = m_function->getLambdaById(detail::TypeId... >>::get()); + auto functorId = m_function->getLambdaById(detail::TypeId>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; @@ -73,7 +73,7 @@ namespace rtl::detail template inline constexpr const HopFunction Hopper<>::argsT() const { - const auto argsId = TypeId... >>::get(); + const auto argsId = TypeId>::get(); for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_function(argsId); diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index bfd6beef..67a9c4d5 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -157,7 +157,7 @@ namespace rtl::detail inline constexpr HopMethod Hopper::argsT() const { const auto recId = TypeId::get(); - const auto argsId = TypeId...>>::get(); + const auto argsId = TypeId>::get(); for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_method(recId, argsId); @@ -204,7 +204,7 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == false) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + auto functorId = m_method.getLambdaById(detail::TypeId>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; @@ -230,7 +230,7 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == true) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId... >>::get()); + auto functorId = m_method.getLambdaById(detail::TypeId>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_function.h b/ReflectionTemplateLib/rtl/dispatch/functor_function.h index 0ce1b59c..60fbb3d1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_function.h @@ -33,7 +33,7 @@ namespace rtl::dispatch function_ptr(functor_t fptr) :m_functor(fptr) { m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId...>>::get(); + m_signatureId = detail::TypeId>::get(); m_returnStr = detail::TypeId::toString(); m_signatureStr = detail::TypeId::toString(); diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method.h b/ReflectionTemplateLib/rtl/dispatch/functor_method.h index 479e3ba5..07d44384 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_method.h @@ -37,7 +37,7 @@ namespace rtl::dispatch m_qualifier = detail::methodQ::NonConst; m_recordId = detail::TypeId::get(); m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId...>>::get(); + m_signatureId = detail::TypeId>::get(); m_returnStr = detail::TypeId::toString(); m_recordStr = detail::TypeId::toString(); diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h index 002c7794..662714e9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h @@ -37,7 +37,7 @@ namespace rtl::dispatch m_qualifier = detail::methodQ::Const; m_recordId = detail::TypeId::get(); m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId...>>::get(); + m_signatureId = detail::TypeId>::get(); m_returnStr = detail::TypeId::toString(); m_recordStr = detail::TypeId::toString(); diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index e1a53809..46b92387 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -142,4 +142,14 @@ namespace rtl return !(std::is_const_v || std::is_pointer_v || std::is_reference_v); } } +} + + +namespace rtl::traits +{ + template + using sign_t = std::tuple; + + template + using fwd_sign_t = std::tuple...>; } \ No newline at end of file From 6e5fa1312e41f50868ce0dd2e33c07926f1fa685 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 6 Oct 2025 21:05:39 +0530 Subject: [PATCH 059/148] std::function type-erasure, removed raw-fn-ptrs, flexible now. --- .../rtl/cache/cache_function_ptr.h | 8 +- .../rtl/cache/cache_lambda_function.h | 16 +- .../rtl/cache/cache_lambda_method.h | 16 +- .../rtl/cache/cache_method_ptr.h | 6 +- .../rtl/cache/cache_method_ptr_const.h | 8 +- ReflectionTemplateLib/rtl/dispatch/functor.h | 4 +- .../rtl/dispatch/functor_function.h | 8 +- .../rtl/dispatch/functor_method.h | 8 +- .../rtl/dispatch/functor_method_const.h | 10 +- ReflectionTemplateLib/rtl/dispatch/lambda.h | 24 ++- .../rtl/dispatch/lambda_function.h | 8 +- .../rtl/dispatch/lambda_method.h | 12 +- .../rtl/dispatch/rtl_function.h | 6 +- .../rtl/dispatch/rtl_method.h | 6 +- .../rtl/dispatch/rtl_method_const.h | 6 +- .../rtl/erasure/aware_function.h | 91 +++++---- .../rtl/erasure/aware_method.h | 168 ++++++++++------- .../rtl/erasure/aware_method_const.h | 173 +++++++++++------- .../rtl/erasure/erased_function.h | 85 +++++---- .../rtl/erasure/erased_method.h | 54 +++--- ReflectionTemplateLib/rtl/erasure/erasure.h | 18 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 26 +-- ReflectionTemplateLib/rtl/rtl_traits.h | 13 +- 23 files changed, 471 insertions(+), 303 deletions(-) diff --git a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index fd012ac2..137418cb 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -17,10 +17,10 @@ namespace rtl::cache { - template + template struct function_ptr { - using function_t = dispatch::function_ptr; + using function_t = dispatch::function_ptr; static const function_ptr& instance() { @@ -28,13 +28,13 @@ namespace rtl::cache return instance_; } - const dispatch::functor& push(return_t(*fptr)(signature_ts...), std::size_t lambda_index) const + const dispatch::functor& push(return_t(*fptr)(signature_t...), std::size_t lambda_index) const { m_cache.emplace_back(std::make_pair(fptr, lambda_index)); return m_cache.back().first; } - std::pair find(return_t(*fptr)(signature_ts...)) const + std::pair find(return_t(*fptr)(signature_t...)) const { for (auto& itr : m_cache) { diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index 35023d85..a22659ec 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -18,7 +18,7 @@ namespace rtl::cache { - template + template struct lambda_function { static const lambda_function& instance() @@ -27,13 +27,15 @@ namespace rtl::cache return instance_; } - const dispatch::lambda_function& push(const dispatch::functor& p_functor) const + const dispatch::lambda_function& push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(erase::aware_function(p_functor)); - m_cache.push_back(dispatch::lambda_function(p_functor, m_erasure_cache.back())); + m_erasure_cache.push_back(erase::aware_function(p_functor)); + + const erase::erasure_base& eb = m_erasure_cache.back(); + + m_cache.push_back(dispatch::lambda_function(p_functor, eb)); p_functor.m_lambda = &m_cache.back(); - m_erasure_cache.back().m_function = m_cache.back().template get_hopper(); return m_cache.back(); } @@ -46,8 +48,8 @@ namespace rtl::cache private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_cache; + mutable std::list> m_erasure_cache; lambda_function() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index f4200da9..6b48ccd8 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -19,7 +19,7 @@ namespace rtl::cache { - template + template struct lambda_method { static const lambda_method& instance() @@ -28,13 +28,15 @@ namespace rtl::cache return instance_; } - const dispatch::lambda_method& push(const dispatch::functor& p_functor) const + const dispatch::lambda_method& push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(erase::aware_method(p_functor)); - m_cache.push_back(dispatch::lambda_method(p_functor, m_erasure_cache.back())); + m_erasure_cache.push_back(erase::aware_method(p_functor)); + + const erase::erasure_base& eb = m_erasure_cache.back(); + + m_cache.push_back(dispatch::lambda_method(p_functor, eb)); p_functor.m_lambda = &m_cache.back(); - m_erasure_cache.back().m_method = m_cache.back().template get_hopper(); return m_cache.back(); } @@ -47,8 +49,8 @@ namespace rtl::cache private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_cache; + mutable std::list> m_erasure_cache; lambda_method() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h index bfe749f7..a53cd826 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h @@ -17,12 +17,12 @@ namespace rtl::cache { - template + template struct method_ptr { - using method_t = dispatch::method_ptr; + using method_t = dispatch::method_ptr; - using functor_t = return_t(record_t::*)(signature_ts...); + using functor_t = return_t(record_t::*)(signature_t...); static const method_ptr& instance() { diff --git a/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h index 3a548048..ba450254 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h @@ -17,12 +17,12 @@ namespace rtl::cache { - template - struct method_ptr + template + struct method_ptr { - using method_t = dispatch::method_ptr; + using method_t = dispatch::method_ptr; - using functor_t = return_t(record_t::*)(signature_ts...) const; + using functor_t = return_t(record_t::*)(signature_t...) const; static const method_ptr& instance() { diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index e079761d..3e743d08 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -37,10 +37,10 @@ namespace rtl::dispatch mutable const lambda_base* m_lambda = nullptr; - template + template friend struct cache::lambda_function; - template + template friend struct cache::lambda_method; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_function.h b/ReflectionTemplateLib/rtl/dispatch/functor_function.h index 60fbb3d1..7b5226fc 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_function.h @@ -15,10 +15,10 @@ namespace rtl::dispatch { - template + template struct function_ptr: public functor { - using functor_t = return_t(*)(signature_ts...); + using functor_t = return_t(*)(signature_t...); [[nodiscard]] constexpr auto f_ptr() const { @@ -33,10 +33,10 @@ namespace rtl::dispatch function_ptr(functor_t fptr) :m_functor(fptr) { m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId>::get(); + m_signatureId = detail::TypeId>::get(); m_returnStr = detail::TypeId::toString(); - m_signatureStr = detail::TypeId::toString(); + m_signatureStr = detail::TypeId::toString(); } private: diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method.h b/ReflectionTemplateLib/rtl/dispatch/functor_method.h index 07d44384..044962e1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_method.h @@ -17,10 +17,10 @@ namespace rtl::dispatch { - template + template struct method_ptr : public functor { - using functor_t = return_t(record_t::*)(signature_ts...); + using functor_t = return_t(record_t::*)(signature_t...); [[nodiscard]] constexpr auto f_ptr() const { @@ -37,11 +37,11 @@ namespace rtl::dispatch m_qualifier = detail::methodQ::NonConst; m_recordId = detail::TypeId::get(); m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId>::get(); + m_signatureId = detail::TypeId>::get(); m_returnStr = detail::TypeId::toString(); m_recordStr = detail::TypeId::toString(); - m_signatureStr = detail::TypeId::toString(); + m_signatureStr = detail::TypeId::toString(); } private: diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h index 662714e9..fa2ba98e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h @@ -17,10 +17,10 @@ namespace rtl::dispatch { - template - struct method_ptr : public functor + template + struct method_ptr : public functor { - using functor_t = return_t(record_t::*)(signature_ts...) const; + using functor_t = return_t(record_t::*)(signature_t...) const; [[nodiscard]] constexpr auto f_ptr() const { @@ -37,11 +37,11 @@ namespace rtl::dispatch m_qualifier = detail::methodQ::Const; m_recordId = detail::TypeId::get(); m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId>::get(); + m_signatureId = detail::TypeId>::get(); m_returnStr = detail::TypeId::toString(); m_recordStr = detail::TypeId::toString(); - m_signatureStr = detail::TypeId::toString(); + m_signatureStr = detail::TypeId::toString(); } private: diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda.h index 052f5772..78d4d389 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda.h @@ -27,12 +27,18 @@ namespace rtl::dispatch template using function_t = lambda_function; - template - constexpr const function_t* to_function(std::size_t p_argsId) const + template + constexpr const function_t& to_function() const + { + return static_cast&>(*this); + } + + template + constexpr const function_t* to_function(std::size_t p_argsId) const { if (p_argsId == 0 || p_argsId == m_functor.m_signatureId) [[likely]] { - return static_cast*>(this); + return static_cast*>(this); } else return nullptr; } @@ -40,13 +46,19 @@ namespace rtl::dispatch template using method_t = lambda_method; - template - constexpr const method_t* to_method(std::size_t p_recordId, std::size_t p_argsId) const + template + constexpr const method_t& to_method() const + { + return static_cast&>(*this); + } + + template + constexpr const method_t* to_method(std::size_t p_recordId, std::size_t p_argsId) const { if (p_recordId == 0 || p_argsId ==0 || (p_recordId == m_functor.m_recordId && p_argsId == m_functor.m_signatureId)) [[likely]] { - return static_cast*>(this); + return static_cast*>(this); } else return nullptr; } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index e1f4e097..f0bf0129 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -18,24 +18,24 @@ namespace rtl::dispatch { - template + template struct lambda_function: public lambda_base { template - using hopper_t = rtl::function; + using hopper_t = rtl::function; template constexpr const hopper_t get_hopper(const std::size_t p_returnId = 0) const { if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { - auto fptr = static_cast&>(m_functor).f_ptr(); + auto fptr = static_cast&>(m_functor).f_ptr(); return hopper_t(fptr); } return hopper_t(); } - lambda_function(const functor& p_functor, const erase::erased_function& p_erasure) noexcept + lambda_function(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept : lambda_base(p_functor, p_erasure) { } }; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 3b673655..84a8f14f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -20,38 +20,38 @@ namespace rtl::dispatch { - template + template struct lambda_method : public lambda_base { template - using hopper_t = rtl::method; + using hopper_t = rtl::method; template requires (std::is_const_v == false) constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { - auto fptr = static_cast&>(m_functor).f_ptr(); + auto fptr = static_cast&>(m_functor).f_ptr(); return hopper_t(fptr); } return hopper_t(); } template - using hopper_ct = rtl::method; + using hopper_ct = rtl::method; template requires (std::is_const_v == true) constexpr const hopper_ct get_hopper(std::size_t p_returnId = 0) const { if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] { - auto fptr = static_cast&>(m_functor).f_ptr(); + auto fptr = static_cast&>(m_functor).f_ptr(); return hopper_ct(fptr); } return hopper_ct(); } - lambda_method(const functor& p_functor, const erase::erased_method& p_erasure) noexcept + lambda_method(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept : lambda_base(p_functor, p_erasure) { } }; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index 7470998b..4b1e3c12 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -16,10 +16,10 @@ namespace rtl { - template - struct function + template + struct function { - using fptr_t = return_t(*)(signature_ts...); + using fptr_t = return_t(*)(signature_t...); constexpr auto f_ptr() const { return m_functor; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 3ccc65da..62555f69 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -17,10 +17,10 @@ namespace rtl { - template - struct method + template + struct method { - using fptr_t = return_t (record_t::*)(signature_ts...); + using fptr_t = return_t (record_t::*)(signature_t...); constexpr auto f_ptr() const { return m_functor; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index d7a467ff..7ecb247f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -17,10 +17,10 @@ namespace rtl { - template - struct method + template + struct method { - using fptr_t = return_t (record_t::*)(signature_ts...) const; + using fptr_t = return_t (record_t::*)(signature_t...) const; constexpr auto f_ptr() const { return m_functor; diff --git a/ReflectionTemplateLib/rtl/erasure/aware_function.h b/ReflectionTemplateLib/rtl/erasure/aware_function.h index 4c4d3115..4680cdab 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_function.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_function.h @@ -16,56 +16,75 @@ namespace rtl::erase { - template - struct aware_function : public erased_function + template + struct aware_function : public erased_hopper...> { - rtl::function m_function; - - using base_t = erased_function; - - using this_t = aware_function; + using base_t = erased_hopper...>; constexpr static bool isConstCastSafe = (!traits::is_const_v); aware_function(const dispatch::functor& p_functor) - : base_t(p_functor, detail::RObjectId::create(isConstCastSafe)) - { - base_t::hopper_v = hop_v; - base_t::hopper_r = hop_r; - } + : base_t( p_functor, + detail::RObjectId::create(isConstCastSafe), + aware_function::get_lambda_void(), + aware_function::get_lambda_any_return() ) + { } - constexpr static void hop_v(const base_t* p_this, signature_ts&&...params) noexcept + + template + constexpr static auto get_lambda_void() noexcept { - if constexpr (std::is_void_v) + return [](const base_t& eh, traits::normal_sign_t&&... params) { - auto this_p = static_cast(p_this); - this_p->m_function(std::forward(params)...); - } + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + { + auto fptr = eh.get_lambda() + .template to_function() + .template get_hopper() + .f_ptr(); + + (*fptr)(params...); + } + }; } - ForceInline static std::any hop_r(const base_t* p_this, signature_ts&&...params) noexcept + constexpr static auto get_lambda_any_return() noexcept { - auto this_p = static_cast(p_this); - if constexpr (!std::is_void_v) + return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto { - auto&& ret_v = this_p->m_function(std::forward(params)...); - if constexpr (std::is_pointer_v) - { - using raw_t = std::remove_pointer_t; - return std::any(static_cast(ret_v)); - } - else if constexpr (std::is_reference_v) - { - using raw_t = std::remove_cv_t>; - return std::any(static_cast(&ret_v)); - } - else + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) { - using raw_ct = std::add_const_t>; - return std::any(raw_ct(std::forward(ret_v))); + auto fptr = eh.get_lambda() + .template to_function() + .template get_hopper() + .f_ptr(); + + auto&& ret_v = (*fptr)(params...); + + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using raw_ct = std::add_const_t>; + return std::any(raw_ct(std::forward(ret_v))); + } } - } - else return std::any(); + else return std::any(); + }; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method.h b/ReflectionTemplateLib/rtl/erasure/aware_method.h index 0a7f7066..b8c17073 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method.h @@ -17,94 +17,136 @@ namespace rtl::erase { - template - struct aware_method : public erased_method + template + struct aware_method : public erased_method_hop...> { - using base_t = erased_method; + using base_t = erased_method_hop...>; - using this_t = aware_method; - - rtl::method m_method; + using this_t = aware_method; constexpr static bool isConstCastSafe = (!traits::is_const_v); aware_method(const dispatch::functor& p_functor) - : base_t(p_functor, detail::RObjectId::create(isConstCastSafe)) - { - base_t::hopper_v = hop_v; - base_t::hopper_r = hop_r; - base_t::base_t::hopper_robj_v = hop_robj_v; - base_t::base_t::hopper_robj_r = hop_robj_r; - } + : base_t( p_functor, + detail::RObjectId::create(isConstCastSafe), + aware_method::get_lambda_void(), + aware_method::get_lambda_any_ret(), + aware_method::get_lambda_void_robj(), + aware_method::get_lambda_any_ret_robj() ) + { } - constexpr static void hop_v(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + constexpr static auto get_lambda_void() noexcept { - if constexpr (std::is_void_v) + return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params) { - auto this_p = static_cast(p_this); - this_p->m_method(const_cast(p_target), std::forward(params)...); - } + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + { + auto mptr = eh.get_lambda() + .template to_method() + .template get_hopper() + .f_ptr(); + + (const_cast(p_target).*mptr)(params...); + } + }; } - constexpr static void hop_robj_v(const base_t::base_t* p_this, const rtl::RObject& p_target, signature_ts&&...params) noexcept + constexpr static auto get_lambda_void_robj() noexcept { - if constexpr (std::is_void_v) + return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params) { - const auto& target = p_target.view()->get(); - auto this_p = static_cast(p_this); - this_p->m_method(const_cast(target), std::forward(params)...); - } + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + { + auto mptr = eh.get_lambda() + .template to_method() + .template get_hopper() + .f_ptr(); + + const auto& target = p_target.view()->get(); + + (const_cast(target).*mptr)(params...); + } + }; } - ForceInline static std::any hop_r(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + constexpr static auto get_lambda_any_ret() noexcept { - if constexpr (!std::is_void_v) + return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { - auto this_p = static_cast(p_this); - auto&& ret_v = this_p->m_method(const_cast(p_target), std::forward(params)...); - if constexpr (std::is_pointer_v) - { - using raw_t = std::remove_pointer_t; - return std::any(static_cast(ret_v)); - } - else if constexpr (std::is_reference_v) - { - using raw_t = std::remove_cv_t>; - return std::any(static_cast(&ret_v)); - } - else + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + auto mptr = eh.get_lambda() + .template to_method() + .template get_hopper() + .f_ptr(); + + auto&& ret_v = (const_cast(p_target).*mptr)(params...); + + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using rconst_t = std::add_const_t>; + return std::any(rconst_t(std::forward(ret_v))); + } } - } - else return std::any(); + else return std::any(); + }; } - ForceInline static std::any hop_robj_r(const base_t::base_t* p_this, const rtl::RObject& p_target, signature_ts&&...params) noexcept + constexpr static auto get_lambda_any_ret_robj() noexcept { - if constexpr (!std::is_void_v) + return[](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { - const auto& target = p_target.view()->get(); - auto this_p = static_cast(p_this); - auto&& ret_v = this_p->m_method(const_cast(target), std::forward(params)...); - if constexpr (std::is_pointer_v) - { - using raw_t = std::remove_pointer_t; - return std::any(static_cast(ret_v)); - } - else if constexpr (std::is_reference_v) - { - using raw_t = std::remove_cv_t>; - return std::any(static_cast(&ret_v)); - } - else + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + auto mptr = eh.get_lambda() + .template to_method() + .template get_hopper() + .f_ptr(); + + const auto& target = p_target.view()->get(); + + auto&& ret_v = (const_cast(target).*mptr)(params...); + + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using rconst_t = std::add_const_t>; + return std::any(rconst_t(std::forward(ret_v))); + } } - } - else return std::any(); + else return std::any(); + }; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h index 971fdea7..b1edb19b 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h @@ -13,97 +13,140 @@ #include "RObjectId.h" #include "erased_method.h" +#include namespace rtl::erase { - template - struct aware_method : public erased_method + template + struct aware_method : public erased_method_hop...> { - using base_t = erased_method; + using base_t = erased_method_hop...>; - using this_t = aware_method; + using this_t = aware_method; - rtl::method m_method; + constexpr static bool isConstCastSafe = (!traits::is_const_v); - aware_method() - { - constexpr bool isConstCastSafe = (!traits::is_const_v); - - base_t::hopper_v = hop_v; - base_t::hopper_r = hop_r; - base_t::base_t::hopper_robj_v = hop_robj_v; - base_t::base_t::hopper_robj_r = hop_robj_r; - base_t::base_t::return_obj_id = detail::RObjectId::create(isConstCastSafe); - } + aware_method(const dispatch::functor& p_functor) + : base_t( p_functor, + detail::RObjectId::create(isConstCastSafe), + aware_method::get_lambda_void(), + aware_method::get_lambda_any_ret(), + aware_method::get_lambda_void_robj(), + aware_method::get_lambda_any_ret_robj() ) + { } - constexpr static void hop_v(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + constexpr static auto get_lambda_void() noexcept { - if constexpr (std::is_void_v) + return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params) { - auto this_p = static_cast(p_this); - this_p->m_method(p_target, std::forward(params)...); - } + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + { + auto mptr = eh.get_lambda() + .template to_method() + .template get_hopper() + .f_ptr(); + + (p_target.*mptr)(params...); + } + }; } - constexpr static void hop_robj_v(const base_t::base_t* p_this, const rtl::RObject& p_target, signature_ts&&...params) noexcept + constexpr static auto get_lambda_void_robj() noexcept { - if constexpr (std::is_void_v) + return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params) { - const auto& target = p_target.view()->get(); - auto this_p = static_cast(p_this); - this_p->m_method(target, std::forward(params)...); - } + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + { + auto mptr = eh.get_lambda() + .template to_method() + .template get_hopper() + .f_ptr(); + + const auto& target = p_target.view()->get(); + + (target.*mptr)(params...); + } + }; } - ForceInline static std::any hop_r(const base_t* p_this, const record_t& p_target, signature_ts&&...params) noexcept + constexpr static auto get_lambda_any_ret() noexcept { - if constexpr (!std::is_void_v) + return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { - auto this_p = static_cast(p_this); - auto&& ret_v = this_p->m_method(p_target, std::forward(params)...); - if constexpr (std::is_pointer_v) - { - using raw_t = std::remove_pointer_t; - return std::any(static_cast(ret_v)); - } - else if constexpr (std::is_reference_v) - { - using raw_t = std::remove_cv_t>; - return std::any(static_cast(&ret_v)); - } - else + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + auto mptr = eh.get_lambda() + .template to_method() + .template get_hopper() + .f_ptr(); + + auto&& ret_v = (const_cast(p_target).*mptr)(params...); + + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using rconst_t = std::add_const_t>; + return std::any(rconst_t(std::forward(ret_v))); + } } - } - else return std::any(); + else return std::any(); + }; } - ForceInline static std::any hop_robj_r(const base_t::base_t* p_this, const rtl::RObject& p_target, signature_ts&&...params) noexcept + constexpr static auto get_lambda_any_ret_robj() noexcept { - if constexpr (!std::is_void_v) + return[](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { - const auto& target = p_target.view()->get(); - auto this_p = static_cast(p_this); - auto&& ret_v = this_p->m_method(target, std::forward(params)...); - if constexpr (std::is_pointer_v) - { - using raw_t = std::remove_pointer_t; - return std::any(static_cast(ret_v)); - } - else if constexpr (std::is_reference_v) - { - using raw_t = std::remove_cv_t>; - return std::any(static_cast(&ret_v)); - } - else + constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); + constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); + + if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + auto mptr = eh.get_lambda() + .template to_method() + .template get_hopper() + .f_ptr(); + + const auto& target = p_target.view()->get(); + + auto&& ret_v = (const_cast(target).*mptr)(params...); + + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using rconst_t = std::add_const_t>; + return std::any(rconst_t(std::forward(ret_v))); + } } - } - else return std::any(); + else return std::any(); + }; } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_function.h b/ReflectionTemplateLib/rtl/erasure/erased_function.h index b55645c8..600e4e5e 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_function.h @@ -11,56 +11,79 @@ #pragma once -#include "RObjectId.h" +#include + #include "erasure.h" namespace rtl::erase { - template - struct erased_function : erasure_base + template + struct erased_hopper : public erasure_base { - constexpr void hop_void(signature_ts&&...params) const noexcept - { - (*hopper_v)(this, std::forward(params)...); - } - - ForceInline std::any hop_return(signature_ts&&...params) const noexcept - { - return (*hopper_r)(this, std::forward(params)...); - } + protected: - constexpr void hop_void(const RObject& p_robj, signature_ts&&...params) const noexcept - { - (*hopper_robj_v)(this, p_robj, std::forward(params)...); - } + using this_t = erased_hopper; - ForceInline std::any hop_return(const RObject& p_robj, signature_ts&&...params) const noexcept - { - return (*hopper_robj_r)(this, p_robj, std::forward(params)...); - } + using lambda_vt = std::function; - protected: + using lambda_rt = std::function; - using this_t = erased_function; + using lambda_robj_vt = std::function; - using functor_vt = void(*)(const this_t*, signature_ts&&...); + using lambda_robj_rt = std::function; - using functor_rt = std::any(*)(const this_t*, signature_ts&&...); + lambda_vt m_void_hop; - using func_ro_vt = void(*)(const this_t*, const RObject&, signature_ts&&...); + lambda_rt m_any_ret_hop; - using func_ro_rt = std::any(*)(const this_t*, const RObject&, signature_ts&&...); + lambda_robj_vt m_void_method_hop; - functor_vt hopper_v = nullptr; + lambda_robj_rt m_any_ret_method_hop; - functor_rt hopper_r = nullptr; + erased_hopper( const dispatch::functor& p_functor, + const detail::RObjectId& p_robj_id, + const lambda_vt& p_void_hop, + const lambda_rt& p_any_ret_hop ) noexcept - func_ro_vt hopper_robj_v = nullptr; + : erasure_base(p_functor, p_robj_id) + , m_void_hop(p_void_hop) + , m_any_ret_hop(p_any_ret_hop) + { } - func_ro_rt hopper_robj_r = nullptr; + erased_hopper( const dispatch::functor& p_functor, + const detail::RObjectId& p_robj_id, + const lambda_robj_vt& p_void_method_hop, + const lambda_robj_rt& p_any_ret_method_hop ) noexcept - erased_function(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept : erasure_base(p_functor, p_robj_id) + , m_void_method_hop(p_void_method_hop) + , m_any_ret_method_hop(p_any_ret_method_hop) { } + + public: + + template + constexpr void hop_void(args_t&&...params) const noexcept + { + m_void_hop(*this, std::forward(params)...); + } + + template + ForceInline std::any hop_return(args_t&&...params) const noexcept + { + return m_any_ret_hop(*this, std::forward(params)...); + } + + template + constexpr void hop_void(const RObject& p_robj, args_t&&...params) const noexcept + { + m_void_method_hop(*this, p_robj, std::forward(params)...); + } + + template + ForceInline std::any hop_return(const RObject& p_robj, args_t&&...params) const noexcept + { + return m_any_ret_method_hop(*this, p_robj, std::forward(params)...); + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method.h index 39487f55..d22f3811 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method.h @@ -12,40 +12,52 @@ #pragma once #include -#include "RObjectId.h" +#include + +#include "erased_function.h" #include "rtl_forward_decls.h" namespace rtl::erase { - template - struct erased_method : erased_function + template + class erased_method_hop : public erased_hopper { - constexpr void hop_void(const record_t& p_target, signature_ts&&...params) const noexcept - { - (*hopper_v)(this, p_target, std::forward(params)...); - } - - ForceInline std::any hop_return(const record_t& p_target, signature_ts&&...params) const noexcept - { - return (*hopper_r)(this, p_target, std::forward(params)...); - } + using base_t = erased_hopper; - protected: + using this_t = erased_method_hop; - using base_t = erased_function; + using lambda_vt = std::function; - using this_t = erased_method; + using lambda_rt = std::function; - using functor_vt = void(*)(const this_t*, const record_t& , signature_ts&&...); + lambda_vt m_void_hop; - using functor_rt = std::any(*)(const this_t*, const record_t& , signature_ts&&...); + lambda_rt m_any_ret_hop; - functor_vt hopper_v = nullptr; + protected: - functor_rt hopper_r = nullptr; + erased_method_hop( const dispatch::functor& p_functor, + const detail::RObjectId& p_robj_id, + const lambda_vt& p_void_hop, + const lambda_rt& p_any_ret_hop, + const base_t::lambda_robj_vt& p_void_robj_hop, + const base_t::lambda_robj_rt& p_any_ret_robj_hop ) noexcept - erased_method(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept - : base_t(p_functor, p_robj_id) + : base_t(p_functor, p_robj_id, p_void_robj_hop, p_any_ret_robj_hop) + , m_void_hop(p_void_hop) + , m_any_ret_hop(p_any_ret_hop) { } + + public: + + constexpr void hop_void(const record_t& p_target, normal_sign_t&&...params) const noexcept + { + m_void_hop(*this, p_target, std::forward(params)...); + } + + ForceInline std::any hop_return(const record_t& p_target, normal_sign_t&&...params) const noexcept + { + return m_any_ret_hop(*this, p_target, std::forward(params)...); + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure.h b/ReflectionTemplateLib/rtl/erasure/erasure.h index cb001113..8c841a10 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure.h @@ -19,21 +19,21 @@ namespace rtl::erase struct erasure_base { template - using function_t = erased_function; + using function_t = erased_hopper...>; - template - constexpr const function_t& to_erased_ret_function() const + template + constexpr const function_t& to_erased_ret_function() const { - return static_cast&>(*this); + return static_cast&>(*this); } template - using method_t = erased_method; + using method_t = erased_method_hop; - template - constexpr const method_t& to_erased_ret_method() const + template + constexpr const method_t& to_erased_ret_method() const { - return static_cast&>(*this); + return static_cast&>(*this); } erasure_base(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept @@ -46,5 +46,7 @@ namespace rtl::erase const detail::RObjectId m_robj_id; GETTER(detail::RObjectId, _return_id, m_robj_id); + + GETTER(dispatch::lambda_base, _lambda, (*m_functor.get_lambda())); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 9febcad4..41dee912 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -33,16 +33,16 @@ namespace rtl namespace erase { - template - struct erased_function; + template + struct erased_hopper; - template - struct erased_method; + template + struct erased_method_hop; - template + template struct aware_function; - template + template struct aware_method; } @@ -68,10 +68,10 @@ namespace rtl namespace cache { - template + template struct lambda_function; - template + template struct lambda_method; } @@ -81,19 +81,19 @@ namespace rtl struct lambda_base; - template + template struct lambda_function; - template + template struct lambda_method; - template + template struct function_ptr; - template + template struct method_ptr; - template + template struct const_method_ptr; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index 46b92387..0e14cab2 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -148,8 +148,19 @@ namespace rtl namespace rtl::traits { template - using sign_t = std::tuple; + using strict_sign_t = std::tuple; template using fwd_sign_t = std::tuple...>; + + template + struct normalized_t + { + using type = std::remove_const_t< + std::remove_pointer_t< + std::remove_reference_t > >; + }; + + template + using normal_sign_t = typename normalized_t::type; } \ No newline at end of file From 8eece0840ec091e18d706da38c631f513b87acf4 Mon Sep 17 00:00:00 2001 From: neeraj Date: Mon, 6 Oct 2025 21:33:12 +0530 Subject: [PATCH 060/148] fix gcc/clang compile error. --- .../rtl/erasure/erased_function.h | 54 +++++++++---------- .../rtl/erasure/erased_method.h | 28 +++++----- 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/ReflectionTemplateLib/rtl/erasure/erased_function.h b/ReflectionTemplateLib/rtl/erasure/erased_function.h index 600e4e5e..a67426ca 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_function.h @@ -20,8 +20,6 @@ namespace rtl::erase template struct erased_hopper : public erasure_base { - protected: - using this_t = erased_hopper; using lambda_vt = std::function; @@ -32,6 +30,32 @@ namespace rtl::erase using lambda_robj_rt = std::function; + template + constexpr void hop_void(args_t&&...params) const noexcept + { + m_void_hop(*this, std::forward(params)...); + } + + template + ForceInline std::any hop_return(args_t&&...params) const noexcept + { + return m_any_ret_hop(*this, std::forward(params)...); + } + + template + constexpr void hop_void(const RObject& p_robj, args_t&&...params) const noexcept + { + m_void_method_hop(*this, p_robj, std::forward(params)...); + } + + template + ForceInline std::any hop_return(const RObject& p_robj, args_t&&...params) const noexcept + { + return m_any_ret_method_hop(*this, p_robj, std::forward(params)...); + } + + protected: + lambda_vt m_void_hop; lambda_rt m_any_ret_hop; @@ -59,31 +83,5 @@ namespace rtl::erase , m_void_method_hop(p_void_method_hop) , m_any_ret_method_hop(p_any_ret_method_hop) { } - - public: - - template - constexpr void hop_void(args_t&&...params) const noexcept - { - m_void_hop(*this, std::forward(params)...); - } - - template - ForceInline std::any hop_return(args_t&&...params) const noexcept - { - return m_any_ret_hop(*this, std::forward(params)...); - } - - template - constexpr void hop_void(const RObject& p_robj, args_t&&...params) const noexcept - { - m_void_method_hop(*this, p_robj, std::forward(params)...); - } - - template - ForceInline std::any hop_return(const RObject& p_robj, args_t&&...params) const noexcept - { - return m_any_ret_method_hop(*this, p_robj, std::forward(params)...); - } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method.h index d22f3811..35accd25 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method.h @@ -20,7 +20,7 @@ namespace rtl::erase { template - class erased_method_hop : public erased_hopper + struct erased_method_hop : public erased_hopper { using base_t = erased_hopper; @@ -30,12 +30,22 @@ namespace rtl::erase using lambda_rt = std::function; - lambda_vt m_void_hop; + constexpr void hop_void(const record_t& p_target, normal_sign_t&&...params) const noexcept + { + m_void_hop(*this, p_target, std::forward(params)...); + } - lambda_rt m_any_ret_hop; + ForceInline std::any hop_return(const record_t& p_target, normal_sign_t&&...params) const noexcept + { + return m_any_ret_hop(*this, p_target, std::forward(params)...); + } protected: + lambda_vt m_void_hop; + + lambda_rt m_any_ret_hop; + erased_method_hop( const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id, const lambda_vt& p_void_hop, @@ -47,17 +57,5 @@ namespace rtl::erase , m_void_hop(p_void_hop) , m_any_ret_hop(p_any_ret_hop) { } - - public: - - constexpr void hop_void(const record_t& p_target, normal_sign_t&&...params) const noexcept - { - m_void_hop(*this, p_target, std::forward(params)...); - } - - ForceInline std::any hop_return(const record_t& p_target, normal_sign_t&&...params) const noexcept - { - return m_any_ret_hop(*this, p_target, std::forward(params)...); - } }; } \ No newline at end of file From 01554f88556326be421525e1cae495467a429c06 Mon Sep 17 00:00:00 2001 From: neeraj Date: Mon, 6 Oct 2025 23:01:02 +0530 Subject: [PATCH 061/148] minor improvements, renames, clean-up. --- .../rtl/detail/inc/FunctionCaller.h | 2 +- .../rtl/detail/inc/FunctionCaller.hpp | 6 ++--- .../rtl/detail/inc/MethodInvoker.hpp | 2 +- .../rtl/dispatch/CMakeLists.txt | 2 +- .../rtl/dispatch/{lambda.h => lambda_base.h} | 2 +- .../rtl/dispatch/lambda_function.h | 10 ++++++-- .../rtl/dispatch/lambda_method.h | 10 ++++++-- .../rtl/erasure/CMakeLists.txt | 6 ++--- .../rtl/erasure/aware_function.h | 12 +++------ .../rtl/erasure/aware_method.h | 23 ++++++++--------- .../rtl/erasure/aware_method_const.h | 25 ++++++++----------- .../{erased_function.h => erased_hopper.h} | 2 +- .../{erased_method.h => erased_method_hop.h} | 2 +- .../rtl/erasure/{erasure.h => erasure_base.h} | 12 ++++----- ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 2 +- 16 files changed, 61 insertions(+), 59 deletions(-) rename ReflectionTemplateLib/rtl/dispatch/{lambda.h => lambda_base.h} (99%) rename ReflectionTemplateLib/rtl/erasure/{erased_function.h => erased_hopper.h} (99%) rename ReflectionTemplateLib/rtl/erasure/{erased_method.h => erased_method_hop.h} (98%) rename ReflectionTemplateLib/rtl/erasure/{erasure.h => erasure_base.h} (75%) diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index a1d1e89f..a92ff327 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -18,7 +18,7 @@ namespace rtl::detail template struct ErasedCaller { - const Function* m_function; + const Function& m_function; template rtl::Return call(_args&&...) const noexcept; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 9d8b9635..9cc8f7ae 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -16,7 +16,7 @@ #include "FunctionCaller.h" #include "FunctorContainer.h" -#include "erased_function.h" +#include "erased_hopper.h" namespace rtl::detail @@ -29,7 +29,7 @@ namespace rtl::detail FunctorContainer...>, FunctorContainer<_signature...>>; - const detail::FunctorId* functorId = m_function->hasFunctorId(Container::getContainerId()); + const detail::FunctorId* functorId = m_function.hasFunctorId(Container::getContainerId()); if (functorId != nullptr) [[likely]] { return Container::template forwardCall<_args...>(*functorId, std::forward<_args>(params)...); } @@ -45,7 +45,7 @@ namespace rtl::detail template ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept { - auto functorId = m_function->getLambdaById(detail::TypeId>::get()); + auto functorId = m_function.getLambdaById(detail::TypeId>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 67a9c4d5..53d76b37 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -15,7 +15,7 @@ #include "RObject.h" #include "MethodInvoker.h" #include "MethodContainer.h" -#include "erased_method.h" +#include "erased_method_hop.h" namespace rtl::detail { diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index efec0dc1..335dcaea 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -9,7 +9,7 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/functor_function.h" "${CMAKE_CURRENT_SOURCE_DIR}/functor_method_const.h" - "${CMAKE_CURRENT_SOURCE_DIR}/lambda.h" + "${CMAKE_CURRENT_SOURCE_DIR}/lambda_base.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h similarity index 99% rename from ReflectionTemplateLib/rtl/dispatch/lambda.h rename to ReflectionTemplateLib/rtl/dispatch/lambda_base.h index 78d4d389..a058c43b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -13,7 +13,7 @@ #include "rtl_traits.h" #include "functor.h" -#include "erasure.h" +#include "erasure_base.h" namespace rtl::dispatch { diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index f0bf0129..81844295 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -11,10 +11,10 @@ #pragma once -#include "lambda.h" +#include "lambda_base.h" #include "rtl_function.h" #include "functor_function.h" -#include "erased_function.h" +#include "erased_hopper.h" namespace rtl::dispatch { @@ -24,6 +24,12 @@ namespace rtl::dispatch template using hopper_t = rtl::function; + template + constexpr decltype(auto) get_functor(const std::size_t p_returnId = 0) const + { + return static_cast&>(m_functor).f_ptr(); + } + template constexpr const hopper_t get_hopper(const std::size_t p_returnId = 0) const { diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 84a8f14f..c4e9f84a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -11,9 +11,9 @@ #pragma once -#include "lambda.h" +#include "lambda_base.h" #include "rtl_method.h" -#include "erased_method.h" +#include "erased_method_hop.h" #include "functor_method.h" #include "rtl_method_const.h" @@ -26,6 +26,12 @@ namespace rtl::dispatch template using hopper_t = rtl::method; + template + constexpr decltype(auto) get_functor(std::size_t p_returnId = 0) const + { + return static_cast&>(m_functor).f_ptr(); + } + template requires (std::is_const_v == false) constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt index c25d8afc..44d9137e 100644 --- a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -3,9 +3,9 @@ # Collect headers in this folder (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/erasure.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erased_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erased_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erasure_base.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erased_hopper.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erased_method_hop.h" "${CMAKE_CURRENT_SOURCE_DIR}/aware_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/aware_function.h" diff --git a/ReflectionTemplateLib/rtl/erasure/aware_function.h b/ReflectionTemplateLib/rtl/erasure/aware_function.h index 4680cdab..ed08df73 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_function.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_function.h @@ -12,7 +12,7 @@ #pragma once #include -#include "erased_function.h" +#include "erased_hopper.h" namespace rtl::erase { @@ -30,11 +30,9 @@ namespace rtl::erase aware_function::get_lambda_any_return() ) { } - - template constexpr static auto get_lambda_void() noexcept { - return [](const base_t& eh, traits::normal_sign_t&&... params) + return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto { constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -43,8 +41,7 @@ namespace rtl::erase { auto fptr = eh.get_lambda() .template to_function() - .template get_hopper() - .f_ptr(); + .template get_functor(); (*fptr)(params...); } @@ -62,8 +59,7 @@ namespace rtl::erase { auto fptr = eh.get_lambda() .template to_function() - .template get_hopper() - .f_ptr(); + .template get_functor(); auto&& ret_v = (*fptr)(params...); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method.h b/ReflectionTemplateLib/rtl/erasure/aware_method.h index b8c17073..3d033d68 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method.h @@ -11,10 +11,11 @@ #pragma once -#include "RObjectId.h" -#include "erased_method.h" #include +#include "RObjectId.h" +#include "erased_method_hop.h" + namespace rtl::erase { template @@ -37,7 +38,7 @@ namespace rtl::erase constexpr static auto get_lambda_void() noexcept { - return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params) + return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -46,8 +47,7 @@ namespace rtl::erase { auto mptr = eh.get_lambda() .template to_method() - .template get_hopper() - .f_ptr(); + .template get_functor(); (const_cast(p_target).*mptr)(params...); } @@ -56,7 +56,7 @@ namespace rtl::erase constexpr static auto get_lambda_void_robj() noexcept { - return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params) + return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -65,8 +65,7 @@ namespace rtl::erase { auto mptr = eh.get_lambda() .template to_method() - .template get_hopper() - .f_ptr(); + .template get_functor(); const auto& target = p_target.view()->get(); @@ -86,8 +85,7 @@ namespace rtl::erase { auto mptr = eh.get_lambda() .template to_method() - .template get_hopper() - .f_ptr(); + .template get_functor(); auto&& ret_v = (const_cast(p_target).*mptr)(params...); @@ -113,7 +111,7 @@ namespace rtl::erase constexpr static auto get_lambda_any_ret_robj() noexcept { - return[](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto + return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -122,8 +120,7 @@ namespace rtl::erase { auto mptr = eh.get_lambda() .template to_method() - .template get_hopper() - .f_ptr(); + .template get_functor(); const auto& target = p_target.view()->get(); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h index b1edb19b..4055c840 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_method_const.h @@ -11,10 +11,11 @@ #pragma once -#include "RObjectId.h" -#include "erased_method.h" #include +#include "RObjectId.h" +#include "erased_method_hop.h" + namespace rtl::erase { template @@ -37,7 +38,7 @@ namespace rtl::erase constexpr static auto get_lambda_void() noexcept { - return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params) + return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -46,8 +47,7 @@ namespace rtl::erase { auto mptr = eh.get_lambda() .template to_method() - .template get_hopper() - .f_ptr(); + .template get_functor(); (p_target.*mptr)(params...); } @@ -56,7 +56,7 @@ namespace rtl::erase constexpr static auto get_lambda_void_robj() noexcept { - return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params) + return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -65,8 +65,7 @@ namespace rtl::erase { auto mptr = eh.get_lambda() .template to_method() - .template get_hopper() - .f_ptr(); + .template get_functor(); const auto& target = p_target.view()->get(); @@ -86,10 +85,9 @@ namespace rtl::erase { auto mptr = eh.get_lambda() .template to_method() - .template get_hopper() - .f_ptr(); + .template get_functor(); - auto&& ret_v = (const_cast(p_target).*mptr)(params...); + auto&& ret_v = (p_target.*mptr)(params...); if constexpr (std::is_pointer_v) { @@ -122,12 +120,11 @@ namespace rtl::erase { auto mptr = eh.get_lambda() .template to_method() - .template get_hopper() - .f_ptr(); + .template get_functor(); const auto& target = p_target.view()->get(); - auto&& ret_v = (const_cast(target).*mptr)(params...); + auto&& ret_v = (target.*mptr)(params...); if constexpr (std::is_pointer_v) { diff --git a/ReflectionTemplateLib/rtl/erasure/erased_function.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h similarity index 99% rename from ReflectionTemplateLib/rtl/erasure/erased_function.h rename to ReflectionTemplateLib/rtl/erasure/erased_hopper.h index a67426ca..e61bf921 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_function.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h @@ -13,7 +13,7 @@ #include -#include "erasure.h" +#include "erasure_base.h" namespace rtl::erase { diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method.h b/ReflectionTemplateLib/rtl/erasure/erased_method_hop.h similarity index 98% rename from ReflectionTemplateLib/rtl/erasure/erased_method.h rename to ReflectionTemplateLib/rtl/erasure/erased_method_hop.h index 35accd25..c737d190 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_method_hop.h @@ -14,7 +14,7 @@ #include #include -#include "erased_function.h" +#include "erased_hopper.h" #include "rtl_forward_decls.h" namespace rtl::erase diff --git a/ReflectionTemplateLib/rtl/erasure/erasure.h b/ReflectionTemplateLib/rtl/erasure/erasure_base.h similarity index 75% rename from ReflectionTemplateLib/rtl/erasure/erasure.h rename to ReflectionTemplateLib/rtl/erasure/erasure_base.h index 8c841a10..57766600 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure_base.h @@ -19,21 +19,21 @@ namespace rtl::erase struct erasure_base { template - using function_t = erased_hopper...>; + using ehop_t = erased_hopper...>; template - constexpr const function_t& to_erased_ret_function() const + constexpr const ehop_t& to_erased_ret_function() const { - return static_cast&>(*this); + return static_cast&>(*this); } template - using method_t = erased_method_hop; + using ehop_mt = erased_method_hop; template - constexpr const method_t& to_erased_ret_method() const + constexpr const ehop_mt& to_erased_ret_method() const { - return static_cast&>(*this); + return static_cast&>(*this); } erasure_base(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 3a5ea646..0d35f0b2 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -103,7 +103,7 @@ namespace rtl { template constexpr rtl::Return operator()(_args&&...params) const noexcept { - return detail::ErasedCaller<_args...>{ this }(std::forward<_args>(params)...); + return detail::ErasedCaller<_args...>{ (*this) }(std::forward<_args>(params)...); } friend detail::CxxReflection; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index b01f23c1..d3c2dd6e 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -23,7 +23,7 @@ namespace rtl template inline constexpr const detail::ErasedCaller<_signature...> Function::bind() const noexcept { - return detail::ErasedCaller<_signature...>{ this }; + return detail::ErasedCaller<_signature...>{ (*this) }; } template From 66725cc0b60fbe0e38874aa30a0899d9f989adac Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 7 Oct 2025 00:52:44 +0530 Subject: [PATCH 062/148] bug fix, general refactor, renames. --- .../rtl/cache/cache_lambda_function.h | 8 ++--- .../rtl/cache/cache_lambda_method.h | 10 +++--- .../rtl/detail/inc/FunctionCaller.hpp | 3 +- .../rtl/detail/inc/MethodInvoker.hpp | 6 ++-- .../rtl/dispatch/lambda_method.h | 2 +- .../rtl/erasure/CMakeLists.txt | 8 ++--- .../{aware_function.h => aware_hopper.h} | 12 ++++--- .../{aware_method.h => aware_hopper_rec.h} | 24 ++++++++------ ...ethod_const.h => aware_hopper_rec_const.h} | 24 ++++++++------ .../rtl/erasure/erased_hopper.h | 2 +- ...rased_method_hop.h => erased_hopper_rec.h} | 18 ++++++----- .../rtl/erasure/erasure_base.h | 10 +++--- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 32 +++++++++---------- 13 files changed, 85 insertions(+), 74 deletions(-) rename ReflectionTemplateLib/rtl/erasure/{aware_function.h => aware_hopper.h} (89%) rename ReflectionTemplateLib/rtl/erasure/{aware_method.h => aware_hopper_rec.h} (87%) rename ReflectionTemplateLib/rtl/erasure/{aware_method_const.h => aware_hopper_rec_const.h} (87%) rename ReflectionTemplateLib/rtl/erasure/{erased_method_hop.h => erased_hopper_rec.h} (76%) diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index a22659ec..b95047f9 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -14,7 +14,7 @@ #include #include "lambda_function.h" -#include "aware_function.h" +#include "aware_hopper.h" namespace rtl::cache { @@ -29,9 +29,9 @@ namespace rtl::cache const dispatch::lambda_function& push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(erase::aware_function(p_functor)); + m_erasure_cache.push_back(dispatch::erase::aware_hopper(p_functor)); - const erase::erasure_base& eb = m_erasure_cache.back(); + const dispatch::erase::erasure_base& eb = m_erasure_cache.back(); m_cache.push_back(dispatch::lambda_function(p_functor, eb)); @@ -49,7 +49,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_function() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index 6b48ccd8..0404571b 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -13,9 +13,9 @@ #include -#include "aware_method.h" #include "lambda_method.h" -#include "aware_method_const.h" +#include "aware_hopper_rec.h" +#include "aware_hopper_rec_const.h" namespace rtl::cache { @@ -30,9 +30,9 @@ namespace rtl::cache const dispatch::lambda_method& push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(erase::aware_method(p_functor)); + m_erasure_cache.push_back(dispatch::erase::aware_hopper_rec(p_functor)); - const erase::erasure_base& eb = m_erasure_cache.back(); + const dispatch::erase::erasure_base& eb = m_erasure_cache.back(); m_cache.push_back(dispatch::lambda_method(p_functor, eb)); @@ -50,7 +50,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_method() = default; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 9cc8f7ae..ba2b20ec 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -49,7 +49,7 @@ namespace rtl::detail if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_ret_function(); + const auto& caller = erased.template to_erased_return(); if(functorId->m_lambda->is_void()) { caller.hop_void(std::forward(params)...); @@ -84,7 +84,6 @@ namespace rtl::detail return HopFunction(); } - template template inline constexpr const function HopFunction::returnT() const diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 53d76b37..7f123aab 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -15,7 +15,7 @@ #include "RObject.h" #include "MethodInvoker.h" #include "MethodContainer.h" -#include "erased_method_hop.h" +#include "erased_hopper_rec.h" namespace rtl::detail { @@ -208,7 +208,7 @@ namespace rtl::detail if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_ret_method(); + const auto& caller = erased.template to_erased_return_rec(); if(functorId->m_lambda->is_void()) { caller.hop_void(m_target, std::forward(params)...); @@ -234,7 +234,7 @@ namespace rtl::detail if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_ret_function(); + const auto& caller = erased.template to_erased_return(); if (functorId->m_lambda->is_void()) { caller.hop_void(m_target, std::forward(params)...); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index c4e9f84a..41308083 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -13,7 +13,7 @@ #include "lambda_base.h" #include "rtl_method.h" -#include "erased_method_hop.h" +#include "erased_hopper_rec.h" #include "functor_method.h" #include "rtl_method_const.h" diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt index 44d9137e..a4623933 100644 --- a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -5,11 +5,11 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/erasure_base.h" "${CMAKE_CURRENT_SOURCE_DIR}/erased_hopper.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erased_method_hop.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erased_hopper_rec.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_method_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_hopper.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_hopper_rec.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_hopper_rec_const.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/erasure/aware_function.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h similarity index 89% rename from ReflectionTemplateLib/rtl/erasure/aware_function.h rename to ReflectionTemplateLib/rtl/erasure/aware_hopper.h index ed08df73..559e6af5 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_function.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h @@ -14,26 +14,27 @@ #include #include "erased_hopper.h" -namespace rtl::erase +namespace rtl::dispatch::erase { template - struct aware_function : public erased_hopper...> + struct aware_hopper : public erased_hopper...> { using base_t = erased_hopper...>; constexpr static bool isConstCastSafe = (!traits::is_const_v); - aware_function(const dispatch::functor& p_functor) + aware_hopper(const dispatch::functor& p_functor) : base_t( p_functor, detail::RObjectId::create(isConstCastSafe), - aware_function::get_lambda_void(), - aware_function::get_lambda_any_return() ) + aware_hopper::get_lambda_void(), + aware_hopper::get_lambda_any_return() ) { } constexpr static auto get_lambda_void() noexcept { return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -52,6 +53,7 @@ namespace rtl::erase { return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h similarity index 87% rename from ReflectionTemplateLib/rtl/erasure/aware_method.h rename to ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h index 3d033d68..9de21594 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h @@ -14,32 +14,33 @@ #include #include "RObjectId.h" -#include "erased_method_hop.h" +#include "erased_hopper_rec.h" -namespace rtl::erase +namespace rtl::dispatch::erase { template - struct aware_method : public erased_method_hop...> + struct aware_hopper_rec : public erased_hopper_rec...> { - using base_t = erased_method_hop...>; + using base_t = erased_hopper_rec...>; - using this_t = aware_method; + using this_t = aware_hopper_rec; constexpr static bool isConstCastSafe = (!traits::is_const_v); - aware_method(const dispatch::functor& p_functor) + aware_hopper_rec(const dispatch::functor& p_functor) : base_t( p_functor, detail::RObjectId::create(isConstCastSafe), - aware_method::get_lambda_void(), - aware_method::get_lambda_any_ret(), - aware_method::get_lambda_void_robj(), - aware_method::get_lambda_any_ret_robj() ) + aware_hopper_rec::get_lambda_void(), + aware_hopper_rec::get_lambda_any_ret(), + aware_hopper_rec::get_lambda_void_robj(), + aware_hopper_rec::get_lambda_any_ret_robj() ) { } constexpr static auto get_lambda_void() noexcept { return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -58,6 +59,7 @@ namespace rtl::erase { return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -78,6 +80,7 @@ namespace rtl::erase { return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -113,6 +116,7 @@ namespace rtl::erase { return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h similarity index 87% rename from ReflectionTemplateLib/rtl/erasure/aware_method_const.h rename to ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h index 4055c840..d4ff07cb 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_method_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h @@ -14,32 +14,33 @@ #include #include "RObjectId.h" -#include "erased_method_hop.h" +#include "erased_hopper_rec.h" -namespace rtl::erase +namespace rtl::dispatch::erase { template - struct aware_method : public erased_method_hop...> + struct aware_hopper_rec : public erased_hopper_rec...> { - using base_t = erased_method_hop...>; + using base_t = erased_hopper_rec...>; - using this_t = aware_method; + using this_t = aware_hopper_rec; constexpr static bool isConstCastSafe = (!traits::is_const_v); - aware_method(const dispatch::functor& p_functor) + aware_hopper_rec(const dispatch::functor& p_functor) : base_t( p_functor, detail::RObjectId::create(isConstCastSafe), - aware_method::get_lambda_void(), - aware_method::get_lambda_any_ret(), - aware_method::get_lambda_void_robj(), - aware_method::get_lambda_any_ret_robj() ) + aware_hopper_rec::get_lambda_void(), + aware_hopper_rec::get_lambda_any_ret(), + aware_hopper_rec::get_lambda_void_robj(), + aware_hopper_rec::get_lambda_any_ret_robj() ) { } constexpr static auto get_lambda_void() noexcept { return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -58,6 +59,7 @@ namespace rtl::erase { return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -78,6 +80,7 @@ namespace rtl::erase { return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); @@ -113,6 +116,7 @@ namespace rtl::erase { return[](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { + //TODO: handle these kind of overloads. constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h index e61bf921..d49beef3 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h @@ -15,7 +15,7 @@ #include "erasure_base.h" -namespace rtl::erase +namespace rtl::dispatch::erase { template struct erased_hopper : public erasure_base diff --git a/ReflectionTemplateLib/rtl/erasure/erased_method_hop.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h similarity index 76% rename from ReflectionTemplateLib/rtl/erasure/erased_method_hop.h rename to ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h index c737d190..af11d373 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_method_hop.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h @@ -17,27 +17,29 @@ #include "erased_hopper.h" #include "rtl_forward_decls.h" -namespace rtl::erase +namespace rtl::dispatch::erase { template - struct erased_method_hop : public erased_hopper + struct erased_hopper_rec : public erased_hopper { using base_t = erased_hopper; - using this_t = erased_method_hop; + using this_t = erased_hopper_rec; using lambda_vt = std::function; using lambda_rt = std::function; - constexpr void hop_void(const record_t& p_target, normal_sign_t&&...params) const noexcept + template + constexpr void hop_void(const record_t& p_target, args_t&&...params) const noexcept { - m_void_hop(*this, p_target, std::forward(params)...); + m_void_hop(*this, p_target, std::forward(params)...); } - ForceInline std::any hop_return(const record_t& p_target, normal_sign_t&&...params) const noexcept + template + ForceInline std::any hop_return(const record_t& p_target, args_t&&...params) const noexcept { - return m_any_ret_hop(*this, p_target, std::forward(params)...); + return m_any_ret_hop(*this, p_target, std::forward(params)...); } protected: @@ -46,7 +48,7 @@ namespace rtl::erase lambda_rt m_any_ret_hop; - erased_method_hop( const dispatch::functor& p_functor, + erased_hopper_rec( const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id, const lambda_vt& p_void_hop, const lambda_rt& p_any_ret_hop, diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_base.h b/ReflectionTemplateLib/rtl/erasure/erasure_base.h index 57766600..3d179609 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_base.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure_base.h @@ -14,7 +14,7 @@ #include "functor.h" #include "RObjectId.h" -namespace rtl::erase +namespace rtl::dispatch::erase { struct erasure_base { @@ -22,18 +22,18 @@ namespace rtl::erase using ehop_t = erased_hopper...>; template - constexpr const ehop_t& to_erased_ret_function() const + constexpr const ehop_t& to_erased_return() const { return static_cast&>(*this); } template - using ehop_mt = erased_method_hop; + using ehop_rt = erased_hopper_rec...>; template - constexpr const ehop_mt& to_erased_ret_method() const + constexpr const ehop_rt& to_erased_return_rec() const { - return static_cast&>(*this); + return static_cast&>(*this); } erasure_base(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 41dee912..89bc23f3 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -31,22 +31,7 @@ namespace rtl template struct method; - namespace erase - { - template - struct erased_hopper; - - template - struct erased_method_hop; - - template - struct aware_function; - - template - struct aware_method; - } - - namespace detail + namespace detail { struct FunctorId; @@ -95,5 +80,20 @@ namespace rtl template struct const_method_ptr; + + namespace erase + { + template + struct erased_hopper; + + template + struct erased_hopper_rec; + + template + struct aware_hopper; + + template + struct aware_hopper_rec; + } } } \ No newline at end of file From 0410f866954e89fa2874b85ae0b0d1e03b6a4040 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 7 Oct 2025 12:41:40 +0530 Subject: [PATCH 063/148] cv/ref/ptr/qualifier based overload test setup. --- CxxTestProps/inc/Complex.h | 20 --- CxxTestProps/inc/ComplexStrings.h | 33 +++++ CxxTestProps/src/CMakeLists.txt | 4 +- CxxTestProps/src/Complex.cpp | 58 --------- CxxTestProps/src/ComplexStrings.cpp | 122 ++++++++++++++++++ CxxTestRegistration/CMakeLists.txt | 1 + CxxTestRegistration/src/CMakeLists.txt | 5 - .../src/TestMirrorProvider.cpp | 10 +- CxxTestUtils/CMakeLists.txt | 1 + CxxTestUtils/inc/GlobalTestUtils.h | 11 ++ CxxTestUtils/src/CMakeLists.txt | 12 -- .../CxxMirrorTests/CxxMirrorThreadingTest.cpp | 2 +- .../NameSpaceGlobalsTests.cpp | 15 ++- .../StrictStaticTypeDispatch.cpp | 12 +- 14 files changed, 198 insertions(+), 108 deletions(-) delete mode 100644 CxxTestProps/inc/Complex.h create mode 100644 CxxTestProps/inc/ComplexStrings.h delete mode 100644 CxxTestProps/src/Complex.cpp create mode 100644 CxxTestProps/src/ComplexStrings.cpp diff --git a/CxxTestProps/inc/Complex.h b/CxxTestProps/inc/Complex.h deleted file mode 100644 index 40441aa2..00000000 --- a/CxxTestProps/inc/Complex.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -std::string getComplexNumAsString(); - -std::string reverseString(); - -std::string reverseString(std::string pStr); - -std::string reverseString(const char* pStr); - -namespace complex -{ - double getMagnitude(); - - void setReal(double pNum); - - void setImaginary(double pNum); -} \ No newline at end of file diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/ComplexStrings.h new file mode 100644 index 00000000..5f613b94 --- /dev/null +++ b/CxxTestProps/inc/ComplexStrings.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +std::string getComplexNumAsString(); + +std::string reverseString(); + +std::string reverseString(const char* pStr); + +std::string reverseString(std::string pStr); // (1) by value + +std::string reverseString(std::string& pStr); // (2) lvalue ref + +std::string reverseString(const std::string& pStr); // (3) const lvalue ref + +std::string reverseString(std::string&& pStr); // (4) rvalue ref + +std::string reverseString(const std::string&& pStr); // (5) const rvalue ref + +std::string reverseString(std::string* pStr); // (6) pointer + +std::string reverseString(const std::string* pStr); // (7) pointer to const + + +namespace complex +{ + double getMagnitude(); + + void setReal(double pNum); + + void setImaginary(double pNum); +} \ No newline at end of file diff --git a/CxxTestProps/src/CMakeLists.txt b/CxxTestProps/src/CMakeLists.txt index 56de8e88..513cbce0 100644 --- a/CxxTestProps/src/CMakeLists.txt +++ b/CxxTestProps/src/CMakeLists.txt @@ -1,20 +1,20 @@ # Create a variable containing the source files for your target set(LOCAL_SOURCES "${CMAKE_CURRENT_LIST_DIR}/Book.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Complex.cpp" "${CMAKE_CURRENT_LIST_DIR}/Date.cpp" "${CMAKE_CURRENT_LIST_DIR}/Person.cpp" "${CMAKE_CURRENT_LIST_DIR}/Animal.cpp" "${CMAKE_CURRENT_LIST_DIR}/Library.cpp" + "${CMAKE_CURRENT_LIST_DIR}/ComplexStrings.cpp" ) SET(LOCAL_HEADERS "${PROJECT_SOURCE_DIR}/inc/Book.h" - "${PROJECT_SOURCE_DIR}/inc/Complex.h" "${PROJECT_SOURCE_DIR}/inc/Date.h" "${PROJECT_SOURCE_DIR}/inc/Animal.h" "${PROJECT_SOURCE_DIR}/inc/Person.h" "${PROJECT_SOURCE_DIR}/inc/Library.h" + "${PROJECT_SOURCE_DIR}/inc/ComplexStrings.h" ) # Add any additional source files if needed diff --git a/CxxTestProps/src/Complex.cpp b/CxxTestProps/src/Complex.cpp deleted file mode 100644 index 9c9315e4..00000000 --- a/CxxTestProps/src/Complex.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -#include -#include - -#include "Complex.h" - -namespace test_utils { - - const char* REV_STR_VOID_RET = "func_reverseString(void)->[return_str]"; -} - -std::string reverseString() -{ - return test_utils::REV_STR_VOID_RET; -} - - -std::string reverseString(std::string pStr) -{ - std::string retStr = pStr; - std::reverse(retStr.begin(), retStr.end()); - return retStr; -} - - -std::string reverseString(const char* pStr) -{ - std::string retStr = pStr; - std::reverse(retStr.begin(), retStr.end()); - return retStr; -} - - -namespace complex -{ - static double g_imgNumber; - static double g_realNumber; - - double getMagnitude() - { - std::complex z(g_realNumber, g_imgNumber); - return std::abs(z); - } - - void setReal(double pNum) { - g_realNumber = pNum; - } - - void setImaginary(double pNum) { - g_imgNumber = pNum; - } -} - - -std::string getComplexNumAsString() -{ - return std::to_string(complex::g_realNumber) + "i" + (std::to_string(complex::g_imgNumber)); -} diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/ComplexStrings.cpp new file mode 100644 index 00000000..46646998 --- /dev/null +++ b/CxxTestProps/src/ComplexStrings.cpp @@ -0,0 +1,122 @@ + +#include +#include + +#include "ComplexStrings.h" + +namespace test_utils { + + const char* SUFFIX_ARG_void = "_arg_void"; + const char* SUFFIX_ARG_const_char_ptr = "_arg_const_char_*"; + + const char* SUFFIX_ARG_std_string = "_arg_std::string"; + + const char* SUFFIX_ARG_std_string_ptr = "_arg_std::string*"; + const char* SUFFIX_ARG_std_string_cptr = "_arg_const_std::string*"; + + const char* SUFFIX_ARG_std_string_lvref = "_arg_std::string&"; + const char* SUFFIX_ARG_std_string_clvref = "_arg_const_std::string&"; + + const char* SUFFIX_ARG_std_string_rvref = "_arg_std::string&&"; + const char* SUFFIX_ARG_std_string_crvref = "_arg_const_std::string&&"; + + const char* REV_STR_VOID_RET = "func_reverseString(void)->[return_str]"; +} + +using namespace test_utils; + +std::string reverseString() +{ + return std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; +} + + +std::string reverseString(const char* pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_const_char_ptr; +} + + +std::string reverseString(std::string pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string; +} + + +std::string reverseString(std::string& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_lvref; +} + + +std::string reverseString(std::string&& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_rvref; +} + + +std::string reverseString(const std::string& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_clvref; +} + + +std::string reverseString(const std::string&& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_crvref; +} + + +std::string reverseString(std::string* pStr) +{ + std::string retStr = *pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_ptr; +} + + +std::string reverseString(const std::string* pStr) +{ + std::string retStr = *pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_cptr; +} + + +namespace complex +{ + static double g_imgNumber; + static double g_realNumber; + + double getMagnitude() + { + std::complex z(g_realNumber, g_imgNumber); + return std::abs(z); + } + + void setReal(double pNum) { + g_realNumber = pNum; + } + + void setImaginary(double pNum) { + g_imgNumber = pNum; + } +} + + +std::string getComplexNumAsString() +{ + return std::to_string(complex::g_realNumber) + "i" + (std::to_string(complex::g_imgNumber)); +} diff --git a/CxxTestRegistration/CMakeLists.txt b/CxxTestRegistration/CMakeLists.txt index fe4d4a19..755304eb 100644 --- a/CxxTestRegistration/CMakeLists.txt +++ b/CxxTestRegistration/CMakeLists.txt @@ -16,6 +16,7 @@ INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/CxxTestUtils/inc") INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/CxxTestProps/inc") +TARGET_LINK_LIBRARIES(${CXX_LIB_NAME} CxxTestProps) TARGET_LINK_LIBRARIES(${CXX_LIB_NAME} ReflectionTemplateLib) # Add the source directory diff --git a/CxxTestRegistration/src/CMakeLists.txt b/CxxTestRegistration/src/CMakeLists.txt index 4592f47c..f021f09a 100644 --- a/CxxTestRegistration/src/CMakeLists.txt +++ b/CxxTestRegistration/src/CMakeLists.txt @@ -10,11 +10,6 @@ set(LOCAL_SOURCES SET(LOCAL_HEADERS "${PROJECT_SOURCE_DIR}/inc/TestMirrorProvider.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Book.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Complex.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Date.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Person.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Animal.h" ) # Add any additional source files if needed diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 5388abea..75f74572 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -10,7 +10,7 @@ #include "Date.h" #include "Book.h" #include "Person.h" -#include "Complex.h" +#include "ComplexStrings.h" #include "Animal.h" #include "Library.h" @@ -87,6 +87,14 @@ namespace test_mirror // Overloaded function, takes 'const char*' arguments. rtl::type().function(str_reverseString).build(reverseString), + // numereous other overloads. + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), diff --git a/CxxTestUtils/CMakeLists.txt b/CxxTestUtils/CMakeLists.txt index bca425cc..c92ffa61 100644 --- a/CxxTestUtils/CMakeLists.txt +++ b/CxxTestUtils/CMakeLists.txt @@ -15,6 +15,7 @@ ADD_LIBRARY(${PROJECT_NAME} STATIC "") INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/CxxTestProps/inc") +TARGET_LINK_LIBRARIES(${CXX_LIB_NAME} CxxTestProps) TARGET_LINK_LIBRARIES(${CXX_LIB_NAME} ReflectionTemplateLib) # Add the source directory diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index c1fdda10..a2d1d4d4 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -10,6 +10,17 @@ Provides interface for Testing/Comparing the global functions & types (may or no */ namespace test_utils { + extern const char* SUFFIX_ARG_void; + extern const char* SUFFIX_ARG_const_char_ptr; + + extern const char* SUFFIX_ARG_std_string; + extern const char* SUFFIX_ARG_std_string_ptr; + extern const char* SUFFIX_ARG_std_string_lvref; + extern const char* SUFFIX_ARG_std_string_clvref; + extern const char* SUFFIX_ARG_std_string_cptr; + extern const char* SUFFIX_ARG_std_string_rvref; + extern const char* SUFFIX_ARG_std_string_crvref; + extern const char* REV_STR_VOID_RET; static constexpr double g_real = 3.92; diff --git a/CxxTestUtils/src/CMakeLists.txt b/CxxTestUtils/src/CMakeLists.txt index f24a709c..e68f9522 100644 --- a/CxxTestUtils/src/CMakeLists.txt +++ b/CxxTestUtils/src/CMakeLists.txt @@ -10,12 +10,6 @@ set(LOCAL_SOURCES "${CMAKE_CURRENT_LIST_DIR}/TestUtilsDate.cpp" "${CMAKE_CURRENT_LIST_DIR}/TestUtilsPerson.cpp" "${CMAKE_CURRENT_LIST_DIR}/TestUtilsAnimal.cpp" - "${CMAKE_SOURCE_DIR}/CxxTestProps/src/Book.cpp" - "${CMAKE_SOURCE_DIR}/CxxTestProps/src/Complex.cpp" - "${CMAKE_SOURCE_DIR}/CxxTestProps/src/Date.cpp" - "${CMAKE_SOURCE_DIR}/CxxTestProps/src/Person.cpp" - "${CMAKE_SOURCE_DIR}/CxxTestProps/src/Animal.cpp" - "${CMAKE_SOURCE_DIR}/CxxTestProps/src/Library.cpp" ) SET(LOCAL_HEADERS @@ -25,12 +19,6 @@ SET(LOCAL_HEADERS "${PROJECT_SOURCE_DIR}/inc/GlobalTestUtils.h" "${PROJECT_SOURCE_DIR}/inc/TestUtilsPerson.h" "${PROJECT_SOURCE_DIR}/inc/TestUtilsAnimal.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Book.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Complex.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Date.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Person.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Animal.h" - "${CMAKE_SOURCE_DIR}/CxxTestProps/inc/Library.h" ) # Add any additional source files if needed diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp index c3246388..e7c70cc6 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp @@ -10,7 +10,7 @@ #include "../../CxxTestProps/inc/Animal.h" #include "../../CxxTestProps/inc/Person.h" #include "../../CxxTestProps/inc/Library.h" -#include "../../CxxTestProps/inc/Complex.h" +#include "../../CxxTestProps/inc/ComplexStrings.h" #include "../MyReflectionTests/MyReflectingType.h" #include "TestUtilsBook.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp index b236aa79..92d2cdf7 100644 --- a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp @@ -218,8 +218,9 @@ namespace rtl_tests ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); - string retVal = ret.view()->get(); - EXPECT_TRUE(retVal == STRA_REVERSE); + string retStr = ret.view()->get(); + auto expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(retStr, expStr); } { //STRB's type is 'consexpr const char*', function accepts 'string', //so explicitly binding type in template (using bind<...>()) to enforce the type as 'string'. @@ -229,16 +230,18 @@ namespace rtl_tests ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); - string retVal = ret.view()->get(); - EXPECT_TRUE(retVal == STRB_REVERSE); + string retStr = ret.view()->get(); + auto expStr = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(retStr, expStr); } { auto [err, ret] = reverseString->bind().call(); EXPECT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); - string retVal = ret.view()->get(); - EXPECT_TRUE(retVal == REV_STR_VOID_RET); + string retStr = ret.view()->get(); + auto expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + EXPECT_EQ(retStr, expStr); } } diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp index 2ade857f..5d5512a2 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp @@ -104,24 +104,30 @@ namespace rtl_tests { rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_FALSE(reverse_string); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_FALSE(reverse_string); } { rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(STRA); - EXPECT_EQ(ret_str, STRA_REVERSE); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(STRB); - EXPECT_EQ(ret_str, STRB_REVERSE); + auto exp_str = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT<>().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(); - EXPECT_EQ(ret_str, REV_STR_VOID_RET); + auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + EXPECT_EQ(ret_str, exp_str); } } From 51720da5cfb5adcdb67cef02f5eee184a346c176 Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 7 Oct 2025 16:27:31 +0530 Subject: [PATCH 064/148] clang/gcc compile error fix. --- CxxTestRegistration/CMakeLists.txt | 1 + .../src/TestMirrorProvider.cpp | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CxxTestRegistration/CMakeLists.txt b/CxxTestRegistration/CMakeLists.txt index 755304eb..64ce7ca9 100644 --- a/CxxTestRegistration/CMakeLists.txt +++ b/CxxTestRegistration/CMakeLists.txt @@ -15,6 +15,7 @@ ADD_LIBRARY(${PROJECT_NAME} STATIC "") INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/CxxTestUtils/inc") INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/CxxTestProps/inc") +INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/ReflectionTemplateLib/rtl/inc") TARGET_LINK_LIBRARIES(${CXX_LIB_NAME} CxxTestProps) TARGET_LINK_LIBRARIES(${CXX_LIB_NAME} ReflectionTemplateLib) diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 75f74572..a59fdeea 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -88,12 +88,27 @@ namespace test_mirror rtl::type().function(str_reverseString).build(reverseString), // numereous other overloads. - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), + #if defined(__GNUC__) && !defined(__clang__) + rtl::type().function(str_reverseString) + .build(static_cast(reverseString)), + rtl::type().function(str_reverseString) + .build(static_cast(reverseString)), + rtl::type().function(str_reverseString) + .build(static_cast(reverseString)), + rtl::type().function(str_reverseString) + .build(static_cast(reverseString)), + rtl::type().function(str_reverseString) + .build(static_cast(reverseString)), + rtl::type().function(str_reverseString) + .build(static_cast(reverseString)), + #else + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), + #endif // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), From e592836f65402ee42ba0e9f3066bd70e258b6b3f Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 7 Oct 2025 21:14:47 +0530 Subject: [PATCH 065/148] cvq/ref/ptr strict overload resolution tests --- .../src/TestMirrorProvider.cpp | 19 ++--- .../StrictStaticTypeDispatch.cpp | 69 +++++++++++++++++++ .../rtl/detail/inc/FunctionCaller.hpp | 4 +- .../rtl/detail/inc/MethodInvoker.hpp | 6 +- ReflectionTemplateLib/rtl/rtl_traits.h | 2 +- 5 files changed, 86 insertions(+), 14 deletions(-) diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index a59fdeea..c9bc95b8 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -89,14 +89,17 @@ namespace test_mirror // numereous other overloads. #if defined(__GNUC__) && !defined(__clang__) + /* + GCC here fails to automatically resolve the correct overloaded functor + when both a non-const lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: + + static_cast(reverseString) + */ rtl::type().function(str_reverseString) .build(static_cast(reverseString)), rtl::type().function(str_reverseString) .build(static_cast(reverseString)), - rtl::type().function(str_reverseString) - .build(static_cast(reverseString)), - rtl::type().function(str_reverseString) - .build(static_cast(reverseString)), rtl::type().function(str_reverseString) .build(static_cast(reverseString)), rtl::type().function(str_reverseString) @@ -104,11 +107,11 @@ namespace test_mirror #else rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), #endif + rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), @@ -226,11 +229,11 @@ namespace test_mirror #if defined(__GNUC__) && !defined(__clang__) /* - GCC fails to automatically resolve the correct overloaded functor + GCC here fails to automatically resolve the correct overloaded functor when both a non-const lvalue reference and an rvalue overload exist. To disambiguate, explicitly cast the member function pointer, e.g.: - static_cast(&Animal::setAnimalName); + static_cast(&Animal::setAnimalName) */ rtl::type().member() .method(animal::str_setAnimalName) diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp index 5d5512a2..7c530378 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp @@ -132,6 +132,75 @@ namespace rtl_tests } + TEST(StrictStaticTypeDispatch, lvalue_ref_overload_resolution_with_known_signatures) + { + std::optional reverseString = cxx::mirror().getFunction(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string lv_str = STRA; + std::string ret_str = reverse_string(lv_str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_lvref; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + const std::string lv_str = STRA; + std::string ret_str = reverse_string(lv_str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_clvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeDispatch, rvalue_ref_overload_resolution_with_known_signatures) + { + std::optional reverseString = cxx::mirror().getFunction(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_rvref; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_crvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeDispatch, ptr_and_const_ptr_overload_resolution_with_known_signatures) + { + std::string str = STRA; + std::optional reverseString = cxx::mirror().getFunction(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(&str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(&str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + EXPECT_EQ(ret_str, exp_str); + } + } + + TEST(StrictStaticTypeDispatch, std_string_method_call_with_known_signature) { std::optional stdStringClass = cxx::mirror().getRecord("std", "string"); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index ba2b20ec..63105563 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -45,7 +45,7 @@ namespace rtl::detail template ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept { - auto functorId = m_function.getLambdaById(detail::TypeId>::get()); + auto functorId = m_function.getLambdaById(detail::TypeId>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; @@ -73,7 +73,7 @@ namespace rtl::detail template inline constexpr const HopFunction Hopper<>::argsT() const { - const auto argsId = TypeId>::get(); + const auto argsId = TypeId>::get(); for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_function(argsId); diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 7f123aab..af218925 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -157,7 +157,7 @@ namespace rtl::detail inline constexpr HopMethod Hopper::argsT() const { const auto recId = TypeId::get(); - const auto argsId = TypeId>::get(); + const auto argsId = TypeId>::get(); for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_method(recId, argsId); @@ -204,7 +204,7 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == false) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId>::get()); + auto functorId = m_method.getLambdaById(detail::TypeId>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; @@ -230,7 +230,7 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == true) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId>::get()); + auto functorId = m_method.getLambdaById(detail::TypeId>::get()); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index 0e14cab2..0db52e1a 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -151,7 +151,7 @@ namespace rtl::traits using strict_sign_t = std::tuple; template - using fwd_sign_t = std::tuple...>; + using fuzzy_sign_t = std::tuple...>; template struct normalized_t From ceb72f19abc4984b9a610c2eeacc35c60f97dc00 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 8 Oct 2025 08:29:21 +0530 Subject: [PATCH 066/148] added missing equality check in tests. --- .../TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index 63d72bde..d694a5c9 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -28,6 +28,7 @@ namespace rtl_tests const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString(std::string(STRA)); @@ -37,6 +38,7 @@ namespace rtl_tests const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(retStr, expStr); } { std::string str = STRA; auto [err, robj] = reverseString(&str); @@ -47,6 +49,7 @@ namespace rtl_tests const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + EXPECT_EQ(retStr, expStr); } { const std::string str = STRA; auto [err, robj] = reverseString(&str); @@ -57,6 +60,7 @@ namespace rtl_tests const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + EXPECT_EQ(retStr, expStr); } } } \ No newline at end of file From b1be57adff7a44321f2f5064768fc467392af92c Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 8 Oct 2025 13:38:01 +0530 Subject: [PATCH 067/148] ptr overload enabled, const&& overload unsupported now. --- .../src/TestMirrorProvider.cpp | 12 ++-- RTLTestRunApp/src/CMakeLists.txt | 1 + .../StrictStaticTypeDispatch.cpp | 26 ++++---- .../BasicTypeErasedDispatch.cpp | 62 +++++++++++++++++++ ReflectionTemplateLib/rtl/builder/Reflect.h | 6 +- .../rtl/erasure/aware_hopper.h | 6 +- .../rtl/erasure/aware_hopper_rec.h | 12 ++-- .../rtl/erasure/aware_hopper_rec_const.h | 12 ++-- ReflectionTemplateLib/rtl/rtl_traits.h | 24 ++++--- 9 files changed, 107 insertions(+), 54 deletions(-) create mode 100644 RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index c9bc95b8..ecaaae76 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -91,27 +91,23 @@ namespace test_mirror #if defined(__GNUC__) && !defined(__clang__) /* GCC here fails to automatically resolve the correct overloaded functor - when both a non-const lvalue reference and an rvalue overload exist. + when both a lvalue reference and an rvalue overload exist. To disambiguate, explicitly cast the function pointer, e.g.: static_cast(reverseString) */ rtl::type().function(str_reverseString) .build(static_cast(reverseString)), - rtl::type().function(str_reverseString) - .build(static_cast(reverseString)), rtl::type().function(str_reverseString) .build(static_cast(reverseString)), - rtl::type().function(str_reverseString) - .build(static_cast(reverseString)), #else rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), + //rtl::type().function(str_reverseString).build(reverseString), //compile-error, not allowed by RTL. #endif rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), @@ -230,7 +226,7 @@ namespace test_mirror #if defined(__GNUC__) && !defined(__clang__) /* GCC here fails to automatically resolve the correct overloaded functor - when both a non-const lvalue reference and an rvalue overload exist. + when both a lvalue reference and an rvalue overload exist. To disambiguate, explicitly cast the member function pointer, e.g.: static_cast(&Animal::setAnimalName) diff --git a/RTLTestRunApp/src/CMakeLists.txt b/RTLTestRunApp/src/CMakeLists.txt index 81ec3ddd..136e1497 100644 --- a/RTLTestRunApp/src/CMakeLists.txt +++ b/RTLTestRunApp/src/CMakeLists.txt @@ -16,6 +16,7 @@ set(LOCAL_SOURCES_0 "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/PerfectForwardingTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/MoveConstructorTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/ReturnValueReflectionTest.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp" ) diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp index 7c530378..a4c15969 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp @@ -20,10 +20,10 @@ namespace rtl_tests EXPECT_TRUE(setReal->getFunctionName() == str_setReal); { rtl::function functor = setReal->argsT().returnT(); - ASSERT_TRUE(functor); + EXPECT_TRUE(functor); } { rtl::function functor = setReal->argsT().returnT(); - ASSERT_FALSE(functor); + EXPECT_FALSE(functor); } } @@ -34,10 +34,10 @@ namespace rtl_tests EXPECT_TRUE(setImaginary->getFunctionName() == str_setImaginary); { rtl::function functor = setImaginary->argsT().returnT(); - ASSERT_TRUE(functor); + EXPECT_TRUE(functor); } { rtl::function functor = setImaginary->argsT().returnT(); - ASSERT_FALSE(functor); + EXPECT_FALSE(functor); } } } @@ -80,10 +80,10 @@ namespace rtl_tests ASSERT_TRUE(getComplexNumStr); { rtl::function get_complex_num_str = getComplexNumStr->argsT<>().returnT(); - ASSERT_FALSE(get_complex_num_str); + EXPECT_FALSE(get_complex_num_str); } { rtl::function get_complex_num_str = getComplexNumStr->argsT<>().returnT(); - ASSERT_FALSE(get_complex_num_str); + EXPECT_FALSE(get_complex_num_str); } { rtl::function get_complex_num_str = getComplexNumStr->argsT<>().returnT(); ASSERT_TRUE(get_complex_num_str); @@ -103,10 +103,10 @@ namespace rtl_tests ASSERT_TRUE(reverseString); { rtl::function reverse_string = reverseString->argsT().returnT(); - ASSERT_FALSE(reverse_string); + EXPECT_FALSE(reverse_string); } { rtl::function reverse_string = reverseString->argsT().returnT(); - ASSERT_FALSE(reverse_string); + EXPECT_FALSE(reverse_string); } { rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_TRUE(reverse_string); @@ -169,11 +169,7 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); - ASSERT_TRUE(reverse_string); - - std::string ret_str = reverse_string(STRA); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_crvref; - EXPECT_EQ(ret_str, exp_str); + EXPECT_FALSE(reverse_string); } } @@ -210,7 +206,7 @@ namespace rtl_tests ASSERT_TRUE(isStringEmpty); { rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); - ASSERT_FALSE(is_empty); + EXPECT_FALSE(is_empty); } { rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); ASSERT_TRUE(is_empty); @@ -235,7 +231,7 @@ namespace rtl_tests ASSERT_TRUE(isStringEmpty); { rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); - ASSERT_FALSE(is_empty); + EXPECT_FALSE(is_empty); } { rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); ASSERT_TRUE(is_empty); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp new file mode 100644 index 00000000..63d72bde --- /dev/null +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -0,0 +1,62 @@ + +#include +#include + +#include "TestMirrorProvider.h" +#include "GlobalTestUtils.h" + +using namespace test_utils; +using namespace test_mirror; + +namespace rtl_tests +{ + TEST(BasicTypeErasedDispatch, default_resolutions_to_call_by_value_overloads) + { + auto reverseStringOpt = cxx::mirror().getFunction(str_reverseString); + ASSERT_TRUE(reverseStringOpt); + + rtl::Function reverseString = *reverseStringOpt; + { + auto [err, robj] = reverseString(const_cast(STRA)); + EXPECT_TRUE(err == rtl::error::SignatureMismatch); + } { + auto [err, robj] = reverseString(STRA); + + EXPECT_TRUE(err == rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + } { + auto [err, robj] = reverseString(std::string(STRA)); + + EXPECT_TRUE(err == rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + } { + std::string str = STRA; + auto [err, robj] = reverseString(&str); + + EXPECT_TRUE(err == rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + } { + const std::string str = STRA; + auto [err, robj] = reverseString(&str); + + EXPECT_TRUE(err == rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + } + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/Reflect.h b/ReflectionTemplateLib/rtl/builder/Reflect.h index 3d7f37e8..9f6fc62e 100644 --- a/ReflectionTemplateLib/rtl/builder/Reflect.h +++ b/ReflectionTemplateLib/rtl/builder/Reflect.h @@ -79,7 +79,11 @@ namespace rtl } template - constexpr const builder::Builder function(const std::string_view pFunction) { + constexpr const builder::Builder function(const std::string_view pFunction) + { + constexpr bool hasConstRValueRef = ((std::is_const_v> && std::is_rvalue_reference_v<_signature>) || ...); + static_assert(!hasConstRValueRef, "Registration of functions with 'const T&&' parameters is not allowed."); + return ns().function<_signature...>(pFunction); } }; diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h index 559e6af5..67a5753c 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h @@ -35,10 +35,9 @@ namespace rtl::dispatch::erase return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (std::is_void_v && !is_any_rvref) { auto fptr = eh.get_lambda() .template to_function() @@ -54,10 +53,9 @@ namespace rtl::dispatch::erase return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (!std::is_void_v && !is_any_rvref) { auto fptr = eh.get_lambda() .template to_function() diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h index 9de21594..6d8d99e4 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h @@ -41,10 +41,9 @@ namespace rtl::dispatch::erase return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (std::is_void_v && !is_any_rvref) { auto mptr = eh.get_lambda() .template to_method() @@ -60,10 +59,9 @@ namespace rtl::dispatch::erase return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (std::is_void_v && !is_any_rvref) { auto mptr = eh.get_lambda() .template to_method() @@ -81,10 +79,9 @@ namespace rtl::dispatch::erase return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (!std::is_void_v && !is_any_rvref) { auto mptr = eh.get_lambda() .template to_method() @@ -117,10 +114,9 @@ namespace rtl::dispatch::erase return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (!std::is_void_v && !is_any_rvref) { auto mptr = eh.get_lambda() .template to_method() diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h index d4ff07cb..19588daa 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h @@ -41,10 +41,9 @@ namespace rtl::dispatch::erase return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (std::is_void_v && !is_any_rvref) { auto mptr = eh.get_lambda() .template to_method() @@ -60,10 +59,9 @@ namespace rtl::dispatch::erase return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (std::is_void_v && !is_any_rvref) { auto mptr = eh.get_lambda() .template to_method() @@ -81,10 +79,9 @@ namespace rtl::dispatch::erase return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (!std::is_void_v && !is_any_rvref) { auto mptr = eh.get_lambda() .template to_method() @@ -117,10 +114,9 @@ namespace rtl::dispatch::erase return[](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { //TODO: handle these kind of overloads. - constexpr bool is_any_ptr = ((traits::is_raw_ptr_v || ...)); constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - if constexpr (!std::is_void_v && !is_any_ptr && !is_any_rvref) + if constexpr (!std::is_void_v && !is_any_rvref) { auto mptr = eh.get_lambda() .template to_method() diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index 0db52e1a..c091ea5f 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -147,20 +147,24 @@ namespace rtl namespace rtl::traits { - template - using strict_sign_t = std::tuple; - - template - using fuzzy_sign_t = std::tuple...>; - template - struct normalized_t + class normalized_t { - using type = std::remove_const_t< - std::remove_pointer_t< - std::remove_reference_t > >; + using no_ref_t = std::remove_reference_t; + + public: + using type = std::conditional_t< std::is_pointer_v, + std::remove_const_t, // strip top-level const of pointer + std::remove_const_t // strip const and reference for non-pointers + >; }; template using normal_sign_t = typename normalized_t::type; + + template + using fuzzy_sign_t = std::tuple...>; + + template + using strict_sign_t = std::tuple; } \ No newline at end of file From 048c6814dfb12e0f818ce29f1fd03bb175131591 Mon Sep 17 00:00:00 2001 From: neeraj Date: Wed, 8 Oct 2025 13:47:24 +0530 Subject: [PATCH 068/148] clang/gcc compile error fix. --- CxxTestRegistration/src/TestMirrorProvider.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index ecaaae76..b010d6e6 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -98,16 +98,17 @@ namespace test_mirror */ rtl::type().function(str_reverseString) .build(static_cast(reverseString)), + rtl::type().function(str_reverseString) + .build(static_cast(reverseString)), rtl::type().function(str_reverseString) .build(static_cast(reverseString)), #else rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), - //rtl::type().function(str_reverseString).build(reverseString), //compile-error, not allowed by RTL. + rtl::type().function(str_reverseString).build(reverseString), #endif rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), From 5f810f4e42ef6e46ad200e2346715d04ead10924 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 8 Oct 2025 15:09:13 +0530 Subject: [PATCH 069/148] minor equality bug fix in test-case. --- .../BasicTypeErasedDispatch.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index d694a5c9..53d69056 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -27,7 +27,7 @@ namespace rtl_tests EXPECT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString(std::string(STRA)); @@ -61,6 +61,16 @@ namespace rtl_tests const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString(); + + EXPECT_TRUE(err == rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + EXPECT_EQ(retStr, expStr); } } } \ No newline at end of file From ae8bf7c8e586fa73858a2be193fe6e4b1f18c54f Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 9 Oct 2025 10:35:28 +0530 Subject: [PATCH 070/148] ref/cref/by-value implicit resolution, added error::RefOverloadAmbiguity. --- CxxTestProps/inc/ComplexStrings.h | 6 ++-- CxxTestProps/src/ComplexStrings.cpp | 19 ++++++----- .../src/TestMirrorProvider.cpp | 1 + CxxTestUtils/inc/GlobalTestUtils.h | 2 +- .../BasicTypeErasedDispatch.cpp | 34 +++++++++++++++---- .../rtl/detail/inc/FunctionCaller.hpp | 16 ++++----- .../rtl/detail/inc/MethodInvoker.hpp | 22 ++++++------ ReflectionTemplateLib/rtl/dispatch/functor.h | 25 ++++++++++---- .../rtl/dispatch/functor_function.h | 5 ++- .../rtl/dispatch/functor_method.h | 8 +++-- .../rtl/dispatch/functor_method_const.h | 6 +++- .../rtl/dispatch/lambda_base.h | 10 ++++-- ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 25 +++++++++++--- ReflectionTemplateLib/rtl/rtl_errors.h | 2 ++ ReflectionTemplateLib/rtl/rtl_traits.h | 28 ++++++--------- 16 files changed, 137 insertions(+), 74 deletions(-) diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/ComplexStrings.h index 5f613b94..12edd1a3 100644 --- a/CxxTestProps/inc/ComplexStrings.h +++ b/CxxTestProps/inc/ComplexStrings.h @@ -16,11 +16,11 @@ std::string reverseString(const std::string& pStr); // (3) const lvalue re std::string reverseString(std::string&& pStr); // (4) rvalue ref -std::string reverseString(const std::string&& pStr); // (5) const rvalue ref +std::string reverseString(std::string* pStr); // (5) pointer -std::string reverseString(std::string* pStr); // (6) pointer +std::string reverseString(const std::string* pStr); // (6) pointer to const -std::string reverseString(const std::string* pStr); // (7) pointer to const +std::string reverseString(const std::string_view& pStr); namespace complex diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/ComplexStrings.cpp index 46646998..ec23c9ec 100644 --- a/CxxTestProps/src/ComplexStrings.cpp +++ b/CxxTestProps/src/ComplexStrings.cpp @@ -18,9 +18,10 @@ namespace test_utils { const char* SUFFIX_ARG_std_string_clvref = "_arg_const_std::string&"; const char* SUFFIX_ARG_std_string_rvref = "_arg_std::string&&"; - const char* SUFFIX_ARG_std_string_crvref = "_arg_const_std::string&&"; const char* REV_STR_VOID_RET = "func_reverseString(void)->[return_str]"; + + const char* SUFFIX_ARG_std_string_view_clvref = "_arg_const_std::string_view&"; } using namespace test_utils; @@ -71,14 +72,6 @@ std::string reverseString(const std::string& pStr) } -std::string reverseString(const std::string&& pStr) -{ - std::string retStr = pStr; - std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_crvref; -} - - std::string reverseString(std::string* pStr) { std::string retStr = *pStr; @@ -95,6 +88,14 @@ std::string reverseString(const std::string* pStr) } +std::string reverseString(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref; +} + + namespace complex { static double g_imgNumber; diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index b010d6e6..610fa9cb 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -109,6 +109,7 @@ namespace test_mirror #endif rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_reverseString).build(reverseString), // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index a2d1d4d4..00ded969 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -19,7 +19,7 @@ namespace test_utils { extern const char* SUFFIX_ARG_std_string_clvref; extern const char* SUFFIX_ARG_std_string_cptr; extern const char* SUFFIX_ARG_std_string_rvref; - extern const char* SUFFIX_ARG_std_string_crvref; + extern const char* SUFFIX_ARG_std_string_view_clvref; extern const char* REV_STR_VOID_RET; diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index 53d69056..76ed1738 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -10,7 +10,7 @@ using namespace test_mirror; namespace rtl_tests { - TEST(BasicTypeErasedDispatch, default_resolutions_to_call_by_value_overloads) + TEST(BasicTypeErasedDispatch, implicit_resolutions_to_call_by_value_overloads) { auto reverseStringOpt = cxx::mirror().getFunction(str_reverseString); ASSERT_TRUE(reverseStringOpt); @@ -18,11 +18,11 @@ namespace rtl_tests rtl::Function reverseString = *reverseStringOpt; { auto [err, robj] = reverseString(const_cast(STRA)); - EXPECT_TRUE(err == rtl::error::SignatureMismatch); + EXPECT_EQ(err, rtl::error::SignatureMismatch); } { auto [err, robj] = reverseString(STRA); - EXPECT_TRUE(err == rtl::error::None); + EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -32,7 +32,7 @@ namespace rtl_tests } { auto [err, robj] = reverseString(std::string(STRA)); - EXPECT_TRUE(err == rtl::error::None); + EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -43,7 +43,7 @@ namespace rtl_tests std::string str = STRA; auto [err, robj] = reverseString(&str); - EXPECT_TRUE(err == rtl::error::None); + EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -54,7 +54,7 @@ namespace rtl_tests const std::string str = STRA; auto [err, robj] = reverseString(&str); - EXPECT_TRUE(err == rtl::error::None); + EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -64,7 +64,7 @@ namespace rtl_tests } { auto [err, robj] = reverseString(); - EXPECT_TRUE(err == rtl::error::None); + EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -73,4 +73,24 @@ namespace rtl_tests EXPECT_EQ(retStr, expStr); } } + + + TEST(BasicTypeErasedDispatch, implicit_resolution_to_const_lvalue_ref_overload) + { + auto reverseStringOpt = cxx::mirror().getFunction(str_reverseString); + ASSERT_TRUE(reverseStringOpt); + + rtl::Function reverseString = *reverseStringOpt; + { + std::string_view str = STRA; + auto [err, robj] = reverseString(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(retStr, expStr); + } + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 63105563..1fdc1df1 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -45,12 +45,12 @@ namespace rtl::detail template ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept { - auto functorId = m_function.getLambdaById(detail::TypeId>::get()); - if (functorId) [[likely]] + auto functorId = m_function.getLambdaById(detail::TypeId>::get()); + if (functorId.first) [[likely]] { - const auto& erased = functorId->m_lambda->m_erasure; + const auto& erased = functorId.first->m_lambda->m_erasure; const auto& caller = erased.template to_erased_return(); - if(functorId->m_lambda->is_void()) + if (functorId.first->m_lambda->is_void()) { caller.hop_void(std::forward(params)...); return { error::None, RObject{} }; @@ -59,11 +59,11 @@ namespace rtl::detail { return{ error::None, RObject{ caller.hop_return(std::forward(params)...), - caller.get_return_id(), nullptr } - }; + caller.get_return_id(), nullptr } + }; } } - else return { error::SignatureMismatch, RObject{} }; + else return { (functorId.second ? error::RefOverloadAmbiguity : error::SignatureMismatch), RObject{} }; } } @@ -73,7 +73,7 @@ namespace rtl::detail template inline constexpr const HopFunction Hopper<>::argsT() const { - const auto argsId = TypeId>::get(); + const auto argsId = TypeId>::get(); for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_function(argsId); diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index af218925..df89fad4 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -157,7 +157,7 @@ namespace rtl::detail inline constexpr HopMethod Hopper::argsT() const { const auto recId = TypeId::get(); - const auto argsId = TypeId>::get(); + const auto argsId = TypeId>::get(); for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_method(recId, argsId); @@ -204,12 +204,12 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == false) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId>::get()); - if (functorId) [[likely]] + auto functorId = m_method.getLambdaById(detail::TypeId>::get()); + if (functorId.first) [[likely]] { - const auto& erased = functorId->m_lambda->m_erasure; + const auto& erased = functorId.first->m_lambda->m_erasure; const auto& caller = erased.template to_erased_return_rec(); - if(functorId->m_lambda->is_void()) + if(functorId.first->m_lambda->is_void()) { caller.hop_void(m_target, std::forward(params)...); return { error::None, RObject{} }; @@ -222,7 +222,7 @@ namespace rtl::detail }; } } - else return { error::SignatureMismatch, RObject{} }; + else return { (functorId.second ? error::RefOverloadAmbiguity : error::SignatureMismatch), RObject{} }; } @@ -230,12 +230,12 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == true) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId>::get()); - if (functorId) [[likely]] + auto functorId = m_method.getLambdaById(detail::TypeId>::get()); + if (functorId.first) [[likely]] { - const auto& erased = functorId->m_lambda->m_erasure; + const auto& erased = functorId.first->m_lambda->m_erasure; const auto& caller = erased.template to_erased_return(); - if (functorId->m_lambda->is_void()) + if (functorId.first->m_lambda->is_void()) { caller.hop_void(m_target, std::forward(params)...); return { error::None, RObject{} }; @@ -248,6 +248,6 @@ namespace rtl::detail }; } } - else return { error::SignatureMismatch, RObject{} }; + else return { (functorId.second ? error::RefOverloadAmbiguity : error::SignatureMismatch), RObject{} }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 3e743d08..1591d40f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -19,24 +19,37 @@ namespace rtl::dispatch { struct functor { - std::size_t m_recordId = detail::TypeId<>::None; - std::size_t m_returnId = detail::TypeId<>::None; - std::size_t m_signatureId = detail::TypeId<>::None; + GETTER_CPTR(lambda_base, _lambda, m_lambda) + + protected: std::string m_recordStr; std::string m_returnStr; std::string m_signatureStr; - std::vector m_argumentsId = {}; + std::size_t m_recordId = detail::TypeId<>::None; + std::size_t m_returnId = detail::TypeId<>::None; - detail::methodQ m_qualifier = detail::methodQ::None; + std::size_t m_normal_signId = detail::TypeId<>::None; + std::size_t m_strict_signId = detail::TypeId<>::None; - GETTER_CPTR(lambda_base, _lambda, m_lambda) + bool m_is_any_ncref = false; + std::vector m_argumentsId = {}; + + detail::methodQ m_qualifier = detail::methodQ::None; private: mutable const lambda_base* m_lambda = nullptr; + friend lambda_base; + + template + friend struct lambda_function; + + template + friend struct lambda_method; + template friend struct cache::lambda_function; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_function.h b/ReflectionTemplateLib/rtl/dispatch/functor_function.h index 7b5226fc..60e16d0e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_function.h @@ -33,8 +33,11 @@ namespace rtl::dispatch function_ptr(functor_t fptr) :m_functor(fptr) { m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId>::get(); + m_is_any_ncref = (traits::is_nonconst_ref_v || ...); + m_normal_signId = detail::TypeId>::get(); + m_strict_signId = detail::TypeId>::get(); + m_returnStr = detail::TypeId::toString(); m_signatureStr = detail::TypeId::toString(); } diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method.h b/ReflectionTemplateLib/rtl/dispatch/functor_method.h index 044962e1..e08610ba 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_method.h @@ -35,9 +35,13 @@ namespace rtl::dispatch method_ptr(functor_t fptr) :m_functor(fptr) { m_qualifier = detail::methodQ::NonConst; + m_recordId = detail::TypeId::get(); m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId>::get(); + + m_is_any_ncref = (traits::is_nonconst_ref_v || ...); + m_normal_signId = detail::TypeId>::get(); + m_strict_signId = detail::TypeId>::get(); m_returnStr = detail::TypeId::toString(); m_recordStr = detail::TypeId::toString(); @@ -46,6 +50,6 @@ namespace rtl::dispatch private: - functor_t m_functor; + const functor_t m_functor; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h index fa2ba98e..30066fcc 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h @@ -35,9 +35,13 @@ namespace rtl::dispatch method_ptr(functor_t fptr) :m_functor(fptr) { m_qualifier = detail::methodQ::Const; + m_recordId = detail::TypeId::get(); m_returnId = detail::TypeId::get(); - m_signatureId = detail::TypeId>::get(); + + m_is_any_ncref = (traits::is_nonconst_ref_v || ...); + m_normal_signId = detail::TypeId>::get(); + m_strict_signId = detail::TypeId>::get(); m_returnStr = detail::TypeId::toString(); m_recordStr = detail::TypeId::toString(); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index a058c43b..1f87886a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -36,7 +36,7 @@ namespace rtl::dispatch template constexpr const function_t* to_function(std::size_t p_argsId) const { - if (p_argsId == 0 || p_argsId == m_functor.m_signatureId) [[likely]] + if (p_argsId == 0 || p_argsId == m_functor.m_strict_signId) [[likely]] { return static_cast*>(this); } @@ -56,7 +56,7 @@ namespace rtl::dispatch constexpr const method_t* to_method(std::size_t p_recordId, std::size_t p_argsId) const { if (p_recordId == 0 || p_argsId ==0 || - (p_recordId == m_functor.m_recordId && p_argsId == m_functor.m_signatureId)) [[likely]] + (p_recordId == m_functor.m_recordId && p_argsId == m_functor.m_strict_signId)) [[likely]] { return static_cast*>(this); } @@ -64,6 +64,12 @@ namespace rtl::dispatch } GETTER_CREF(functor, _functor, m_functor); + + GETTER_BOOL(_any_ncref, m_functor.m_is_any_ncref) + + GETTER(std::size_t, _strict_sign_id, m_functor.m_strict_signId) + + GETTER(std::size_t, _normal_sign_id, m_functor.m_normal_signId) lambda_base(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept : m_is_void(p_functor.m_returnId == detail::TypeId::get()) diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 0d35f0b2..6df9707c 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -68,7 +68,7 @@ namespace rtl { const detail::FunctorId* hasFunctorId(const std::size_t pSignatureId) const; - const detail::FunctorId* getLambdaById(const std::size_t pSignatureId) const; + std::pair getLambdaById(const std::size_t pSignatureId) const; GETTER(detail::methodQ, Qualifier, m_qualifier); diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index d3c2dd6e..0ff03db9 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -76,14 +76,31 @@ namespace rtl } - ForceInline const detail::FunctorId* Function::getLambdaById(const std::size_t pSignatureId) const + ForceInline std::pair Function::getLambdaById(const std::size_t pSignatureId) const { //simple linear-search, efficient for small set of elements. for (const auto& functorId : m_functorIds) { - if (pSignatureId == functorId.m_lambda->m_functor.m_signatureId) [[likely]] { - return &functorId; + if (pSignatureId == functorId.m_lambda->get_strict_sign_id()) [[likely]] { + return { &functorId, false }; } } - return nullptr; + + std::size_t index = rtl::index_none; + for (int i = 0; i < m_functorIds.size(); i++) + { + if (pSignatureId == m_functorIds[i].m_lambda->get_normal_sign_id()) [[likely]] { + if (index == rtl::index_none) { + index = i; + } + else return { nullptr, true }; + } + } + + if (index != rtl::index_none) + { + auto isAnyNonConstRefInArgsT = (m_functorIds[index].m_lambda->is_any_ncref()); + return { (isAnyNonConstRefInArgsT ? nullptr : &m_functorIds[index]), isAnyNonConstRefInArgsT }; + } + return { nullptr, false }; } } diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index 153008c3..1e091850 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -23,6 +23,8 @@ namespace rtl TargetMismatch, SignatureMismatch, + RefOverloadAmbiguity, + CloningDisabled, //Used only in case of cloning is disabled e.g, unregistered type. FunctionNotRegistered, //Not used by RTL at all, for external purpose only. diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index c091ea5f..7ebfdf9f 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -127,9 +127,9 @@ namespace rtl namespace traits { - template - concept has_constructor = requires(Args&&... args) { - T{ std::forward(args)... }; + template + concept has_constructor = requires(signatureT&&... args) { + T{ std::forward(args)... }; }; template @@ -148,23 +148,15 @@ namespace rtl namespace rtl::traits { template - class normalized_t - { - using no_ref_t = std::remove_reference_t; - - public: - using type = std::conditional_t< std::is_pointer_v, - std::remove_const_t, // strip top-level const of pointer - std::remove_const_t // strip const and reference for non-pointers - >; - }; - - template - using normal_sign_t = typename normalized_t::type; + using normal_sign_t = std::remove_const_t>; template - using fuzzy_sign_t = std::tuple...>; + using normal_sign_id_t = std::tuple...>; template - using strict_sign_t = std::tuple; + using strict_sign_id_t = std::tuple; + + template + inline constexpr bool is_nonconst_ref_v = ((std::is_lvalue_reference_v || std::is_rvalue_reference_v) && + !std::is_const_v>); } \ No newline at end of file From 9bab1c8e1f5d7a921b98498a02fe7847af6ea095 Mon Sep 17 00:00:00 2001 From: neeraj Date: Thu, 9 Oct 2025 14:26:54 +0530 Subject: [PATCH 071/148] minor improvements, more test-case. --- CxxTestProps/inc/ComplexStrings.h | 19 +++-- CxxTestProps/src/ComplexStrings.cpp | 66 ++++++++++++----- .../src/TestMirrorProvider.cpp | 6 ++ CxxTestUtils/inc/GlobalTestUtils.h | 9 ++- .../BasicTypeErasedDispatch.cpp | 71 +++++++++++++++++-- .../rtl/detail/inc/FunctorId.h | 3 +- .../rtl/erasure/erasure_base.h | 5 +- ReflectionTemplateLib/rtl/inc/Function.h | 9 +-- ReflectionTemplateLib/rtl/inc/Function.hpp | 2 +- ReflectionTemplateLib/rtl/rtl_constants.h | 10 +-- ReflectionTemplateLib/rtl/rtl_traits.h | 2 +- 11 files changed, 158 insertions(+), 44 deletions(-) diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/ComplexStrings.h index 12edd1a3..0fdffdae 100644 --- a/CxxTestProps/inc/ComplexStrings.h +++ b/CxxTestProps/inc/ComplexStrings.h @@ -2,6 +2,15 @@ #include +namespace complex +{ + double getMagnitude(); + + void setReal(double pNum); + + void setImaginary(double pNum); +} + std::string getComplexNumAsString(); std::string reverseString(); @@ -22,12 +31,10 @@ std::string reverseString(const std::string* pStr); // (6) pointer to const std::string reverseString(const std::string_view& pStr); +std::string revStrOverloadValRef(std::string_view pStr); -namespace complex -{ - double getMagnitude(); +std::string revStrOverloadValRef(std::string_view& pStr); - void setReal(double pNum); +std::string revStrOverloadValCRef(std::string_view pStr); - void setImaginary(double pNum); -} \ No newline at end of file +std::string revStrOverloadValCRef(const std::string_view& pStr); \ No newline at end of file diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/ComplexStrings.cpp index ec23c9ec..f2158c64 100644 --- a/CxxTestProps/src/ComplexStrings.cpp +++ b/CxxTestProps/src/ComplexStrings.cpp @@ -4,6 +4,31 @@ #include "ComplexStrings.h" +namespace complex +{ + static double g_imgNumber; + static double g_realNumber; + + double getMagnitude() + { + std::complex z(g_realNumber, g_imgNumber); + return std::abs(z); + } + + void setReal(double pNum) { + g_realNumber = pNum; + } + + void setImaginary(double pNum) { + g_imgNumber = pNum; + } +} + +std::string getComplexNumAsString() +{ + return std::to_string(complex::g_realNumber) + "i" + (std::to_string(complex::g_imgNumber)); +} + namespace test_utils { const char* SUFFIX_ARG_void = "_arg_void"; @@ -21,6 +46,8 @@ namespace test_utils { const char* REV_STR_VOID_RET = "func_reverseString(void)->[return_str]"; + const char* SUFFIX_ARG_std_string_view = "_arg_std::string_view"; + const char* SUFFIX_ARG_std_string_view_lvref = "_arg_std::string_view&"; const char* SUFFIX_ARG_std_string_view_clvref = "_arg_const_std::string_view&"; } @@ -96,28 +123,33 @@ std::string reverseString(const std::string_view& pStr) } -namespace complex +std::string revStrOverloadValCRef(std::string_view pStr) { - static double g_imgNumber; - static double g_realNumber; - - double getMagnitude() - { - std::complex z(g_realNumber, g_imgNumber); - return std::abs(z); - } + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view; +} - void setReal(double pNum) { - g_realNumber = pNum; - } - void setImaginary(double pNum) { - g_imgNumber = pNum; - } +std::string revStrOverloadValCRef(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref; } -std::string getComplexNumAsString() +std::string revStrOverloadValRef(std::string_view pStr) { - return std::to_string(complex::g_realNumber) + "i" + (std::to_string(complex::g_imgNumber)); + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view; } + + +std::string revStrOverloadValRef(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref; +} \ No newline at end of file diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 610fa9cb..06049757 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -1,6 +1,7 @@ #include #include +#include #include "TestMirrorProvider.h" #include "CxxMirrorToJson.h" @@ -17,6 +18,7 @@ /* TestUtils, provides the interface to test/compare reflected type objects with actual objects (created via strict typing) without exposing the actual type objects to "CxxReflectionTests" project.*/ +#include "Reflect.h" #include "TestUtilsBook.h" #include "TestUtilsDate.h" #include "TestUtilsPerson.h" @@ -110,6 +112,10 @@ namespace test_mirror rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), + rtl::type().function(str_revStrOverloadValRef).build(revStrOverloadValRef), + rtl::type().function(str_revStrOverloadValRef).build(revStrOverloadValRef), + rtl::type().function(str_revStrOverloadValCRef).build(revStrOverloadValCRef), + rtl::type().function(str_revStrOverloadValCRef).build(revStrOverloadValCRef), // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index 00ded969..9f90115c 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -15,10 +15,13 @@ namespace test_utils { extern const char* SUFFIX_ARG_std_string; extern const char* SUFFIX_ARG_std_string_ptr; - extern const char* SUFFIX_ARG_std_string_lvref; - extern const char* SUFFIX_ARG_std_string_clvref; extern const char* SUFFIX_ARG_std_string_cptr; + extern const char* SUFFIX_ARG_std_string_lvref; extern const char* SUFFIX_ARG_std_string_rvref; + extern const char* SUFFIX_ARG_std_string_clvref; + + extern const char* SUFFIX_ARG_std_string_view; + extern const char* SUFFIX_ARG_std_string_view_lvref; extern const char* SUFFIX_ARG_std_string_view_clvref; extern const char* REV_STR_VOID_RET; @@ -33,6 +36,8 @@ namespace test_utils { static constexpr const char* STRB_REVERSE = "noitcelfeRxxc"; static constexpr const char* str_reverseString = "reverseString"; + static constexpr const char* str_revStrOverloadValRef = "revStrOverloadValRef"; + static constexpr const char* str_revStrOverloadValCRef = "revStrOverloadValCRef"; static constexpr const char* str_getComplexNumAsString = "getComplexNumAsString"; static constexpr const char* str_complex = "complex"; diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index 76ed1738..f79ee24a 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -1,6 +1,7 @@ #include #include +#include #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" @@ -75,15 +76,35 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, implicit_resolution_to_const_lvalue_ref_overload) + TEST(BasicTypeErasedDispatch, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) { - auto reverseStringOpt = cxx::mirror().getFunction(str_reverseString); - ASSERT_TRUE(reverseStringOpt); + auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); + ASSERT_TRUE(revStrOverloadValCRefOpt); - rtl::Function reverseString = *reverseStringOpt; + rtl::Function revStrOverloadValCRef = *revStrOverloadValCRefOpt; { std::string_view str = STRA; - auto [err, robj] = reverseString(str); + auto [err, robj] = revStrOverloadValCRef(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(retStr, expStr); + } + } + + + TEST(BasicTypeErasedDispatch, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) + { + auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); + ASSERT_TRUE(revStrOverloadValCRefOpt); + + rtl::Function revStrOverloadValCRef = *revStrOverloadValCRefOpt; + { + std::string_view str = STRA; + auto [err, robj] = revStrOverloadValCRef.bind().call(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -93,4 +114,44 @@ namespace rtl_tests EXPECT_EQ(retStr, expStr); } } + + + TEST(BasicTypeErasedDispatch, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) + { + auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); + ASSERT_TRUE(revStrOverloadValRefOpt); + + rtl::Function revStrOverloadValRef = *revStrOverloadValRefOpt; + { + std::string_view str = STRA; + auto [err, robj] = revStrOverloadValRef(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(retStr, expStr); + } + } + + + TEST(BasicTypeErasedDispatch, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) + { + auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); + ASSERT_TRUE(revStrOverloadValRefOpt); + + rtl::Function revStrOverloadValRef = *revStrOverloadValRefOpt; + { + std::string_view str = STRA; + auto [err, robj] = revStrOverloadValRef.bind().call(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(retStr, expStr); + } + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index ce30dd96..572989fa 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -11,6 +11,7 @@ #pragma once +#include "rtl_constants.h" #include "rtl_forward_decls.h" namespace rtl::detail @@ -45,7 +46,7 @@ namespace rtl::detail GETTER(std::size_t, ReturnId, m_returnId); GETTER(std::size_t, RecordId, m_recordId); GETTER(std::size_t, SignatureId, m_containerId) - GETTER(std::string, SignatureStr, m_signature) + GETTER_CREF(std::string, SignatureStr, m_signature) /* @method: getHashCode() diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_base.h b/ReflectionTemplateLib/rtl/erasure/erasure_base.h index 3d179609..3944a2b8 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_base.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure_base.h @@ -13,6 +13,7 @@ #include "functor.h" #include "RObjectId.h" +#include "rtl_constants.h" namespace rtl::dispatch::erase { @@ -45,8 +46,8 @@ namespace rtl::dispatch::erase const detail::RObjectId m_robj_id; - GETTER(detail::RObjectId, _return_id, m_robj_id); + GETTER_CREF(detail::RObjectId, _return_id, m_robj_id); - GETTER(dispatch::lambda_base, _lambda, (*m_functor.get_lambda())); + GETTER_CREF(dispatch::lambda_base, _lambda, (*m_functor.get_lambda())); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 6df9707c..5ba2468f 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -17,6 +17,7 @@ #include "RObject.h" #include "FunctionCaller.h" +#include "rtl_constants.h" namespace rtl { @@ -77,11 +78,11 @@ namespace rtl { public: //simple inlined getters. - GETTER(std::string, RecordName, m_record); - GETTER(std::string, Namespace, m_namespace); - GETTER(std::string, FunctionName, m_function); GETTER(std::size_t, RecordTypeId, m_recordTypeId); - GETTER(std::vector, Functors, m_functorIds); + GETTER_CREF(std::string, RecordName, m_record); + GETTER_CREF(std::string, Namespace, m_namespace); + GETTER_CREF(std::string, FunctionName, m_function); + GETTER_CREF(std::vector, Functors, m_functorIds); Function() = default; Function(Function&&) = default; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 0ff03db9..2d5a03c6 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -15,7 +15,7 @@ #include "FunctionCaller.hpp" #include "RObject.h" #include "rtl_constants.h" -#include "rtl_errors.h" +#include "lambda_base.h" namespace rtl diff --git a/ReflectionTemplateLib/rtl/rtl_constants.h b/ReflectionTemplateLib/rtl/rtl_constants.h index 9ee16c65..eca9ef30 100644 --- a/ReflectionTemplateLib/rtl/rtl_constants.h +++ b/ReflectionTemplateLib/rtl/rtl_constants.h @@ -143,28 +143,28 @@ namespace rtl::detail } #define GETTER(_varType, _name, _var) \ - inline constexpr const _varType& get##_name() const { \ + inline constexpr const _varType get##_name() const { \ return _var; \ } #define GETTER_REF(_varType, _name, _var) \ - inline _varType& get##_name() const { \ + inline constexpr _varType& get##_name() const { \ return _var; \ } #define GETTER_CPTR(_varType, _name, _var) \ - constexpr inline const _varType* get##_name() const { \ + inline constexpr const _varType* get##_name() const { \ return _var; \ } #define GETTER_CREF(_varType, _name, _var) \ - inline const _varType& get##_name() const { \ + inline constexpr const _varType& get##_name() const { \ return _var; \ } #define GETTER_BOOL(_name, _var) \ - inline const bool is##_name() const { \ + inline constexpr const bool is##_name() const { \ return _var; \ } diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index 7ebfdf9f..63562a5e 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -158,5 +158,5 @@ namespace rtl::traits template inline constexpr bool is_nonconst_ref_v = ((std::is_lvalue_reference_v || std::is_rvalue_reference_v) && - !std::is_const_v>); + !std::is_const_v>); } \ No newline at end of file From 58f70e2098b6169c8bbe1eee45bd3c98098f68e3 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 9 Oct 2025 16:30:03 +0530 Subject: [PATCH 072/148] more test-cases added. --- CxxTestProps/inc/ComplexStrings.h | 10 +- CxxTestProps/src/ComplexStrings.cpp | 26 ++- .../src/TestMirrorProvider.cpp | 13 +- CxxTestUtils/inc/GlobalTestUtils.h | 5 + .../ReflectionOpErrorCodeTests.cpp | 4 + .../BasicTypeErasedDispatch.cpp | 160 ++++++++++++++++++ .../rtl/detail/inc/FunctionCaller.hpp | 2 +- .../rtl/detail/inc/MethodInvoker.hpp | 4 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 2 +- ReflectionTemplateLib/rtl/rtl_errors.h | 4 +- 10 files changed, 219 insertions(+), 11 deletions(-) diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/ComplexStrings.h index 0fdffdae..e1c0365e 100644 --- a/CxxTestProps/inc/ComplexStrings.h +++ b/CxxTestProps/inc/ComplexStrings.h @@ -29,7 +29,9 @@ std::string reverseString(std::string* pStr); // (5) pointer std::string reverseString(const std::string* pStr); // (6) pointer to const -std::string reverseString(const std::string_view& pStr); +std::string revStrConstRefArg(const std::string_view& pStr); + +std::string revStrNonConstRefArg(std::string_view& pStr); std::string revStrOverloadValRef(std::string_view pStr); @@ -37,4 +39,8 @@ std::string revStrOverloadValRef(std::string_view& pStr); std::string revStrOverloadValCRef(std::string_view pStr); -std::string revStrOverloadValCRef(const std::string_view& pStr); \ No newline at end of file +std::string revStrOverloadValCRef(const std::string_view& pStr); + +std::string revStrOverloadRefAndCRef(std::string_view& pStr); + +std::string revStrOverloadRefAndCRef(const std::string_view& pStr); \ No newline at end of file diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/ComplexStrings.cpp index f2158c64..57211ea1 100644 --- a/CxxTestProps/src/ComplexStrings.cpp +++ b/CxxTestProps/src/ComplexStrings.cpp @@ -115,7 +115,7 @@ std::string reverseString(const std::string* pStr) } -std::string reverseString(const std::string_view& pStr) +std::string revStrConstRefArg(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -123,6 +123,14 @@ std::string reverseString(const std::string_view& pStr) } +std::string revStrNonConstRefArg(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref; +} + + std::string revStrOverloadValCRef(std::string_view pStr) { std::string retStr(pStr); @@ -152,4 +160,20 @@ std::string revStrOverloadValRef(std::string_view& pStr) std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); return retStr + SUFFIX_ARG_std_string_view_lvref; +} + + +std::string revStrOverloadRefAndCRef(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref; +} + + +std::string revStrOverloadRefAndCRef(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref; } \ No newline at end of file diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 06049757..571ff5a9 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -111,12 +111,19 @@ namespace test_mirror #endif rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), + + rtl::type().function(str_revStrConstRefArg).build(revStrConstRefArg), + rtl::type().function(str_revStrNonConstRefArg).build(revStrNonConstRefArg), + rtl::type().function(str_revStrOverloadValRef).build(revStrOverloadValRef), rtl::type().function(str_revStrOverloadValRef).build(revStrOverloadValRef), + rtl::type().function(str_revStrOverloadValCRef).build(revStrOverloadValCRef), rtl::type().function(str_revStrOverloadValCRef).build(revStrOverloadValCRef), + rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), + rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), + // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), @@ -291,7 +298,7 @@ namespace test_mirror namespace test_mirror { - //Optional setup for accessing registered types via unique-ids. + //Optional setup for accessing registered types via unique-ids. (for Testing-Purposes only, not required by RTL). std::size_t reflected_id::book = rtl::detail::TypeId::get(); std::size_t reflected_id::person = rtl::detail::TypeId::get(); std::size_t reflected_id::animal = rtl::detail::TypeId::get(); @@ -306,7 +313,7 @@ namespace test_mirror std::size_t reflected_id::std_string = rtl::detail::TypeId::get(); std::size_t reflected_id::std_string_view = rtl::detail::TypeId::get(); - //Optional setup - mapping unique-ids to string type-names (for Testing-Purposes only). + //Optional setup - mapping unique-ids to string type-names (for Testing-Purposes only, not required by RTL). const std::size_t reflected_id::getRecordIdFor(const std::string& pRecordName) { static std::unordered_map nameIdMap( diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index 9f90115c..4cc43f96 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -36,12 +36,17 @@ namespace test_utils { static constexpr const char* STRB_REVERSE = "noitcelfeRxxc"; static constexpr const char* str_reverseString = "reverseString"; + static constexpr const char* str_revStrConstRefArg = "revStrConstRefArg"; + static constexpr const char* str_revStrNonConstRefArg = "revStrNonConstRefArg"; static constexpr const char* str_revStrOverloadValRef = "revStrOverloadValRef"; static constexpr const char* str_revStrOverloadValCRef = "revStrOverloadValCRef"; + static constexpr const char* str_revStrOverloadValRefAndCRef = "revStrOverloadValRefAndCRef"; + static constexpr const char* str_getComplexNumAsString = "getComplexNumAsString"; static constexpr const char* str_complex = "complex"; static constexpr const char* str_setReal = "setReal"; + static constexpr const char* str_setImaginary = "setImaginary"; static constexpr const char* str_getMagnitude = "getMagnitude"; } \ No newline at end of file diff --git a/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp index 0fbbd762..c8416f4e 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp @@ -7,6 +7,10 @@ * rtl::error::ConstOverloadMissing * rtl::error::NonConstOverloadMissing * rtl::error::ConstCallViolation +* +* Covered in BasicTypeErasedDispatch.cpp +* rtl::error::ExplicitRefBindingRequired +* * and, * rtl::error::FunctionNotRegistered, is not internally used by RTL. * Function/Method objects are returned wrapped in std::optional<>, which will diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index f79ee24a..8c1ca284 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -84,6 +84,12 @@ namespace rtl_tests rtl::Function revStrOverloadValCRef = *revStrOverloadValCRefOpt; { std::string_view str = STRA; + + // Both by-value (T) and const-ref (const T&) overloads exist. + // RTL chooses the safe by-value overload implicitly. The const-ref + // path requires explicit binding only to disambiguate intent. + // Note: If only const T& existed (no by-value overload), RTL would + // call it implicitly, since binding to const-ref cannot mutate the caller. auto [err, robj] = revStrOverloadValCRef(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -104,6 +110,11 @@ namespace rtl_tests rtl::Function revStrOverloadValCRef = *revStrOverloadValCRefOpt; { std::string_view str = STRA; + + // Explicitly selecting the const-ref overload using .bind(). + // Required only when a by-value overload exists to resolve ambiguity. + // If no by-value overload were present, implicit resolution to const-ref + // would have worked automatically, because const-ref cannot mutate. auto [err, robj] = revStrOverloadValCRef.bind().call(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -124,6 +135,13 @@ namespace rtl_tests rtl::Function revStrOverloadValRef = *revStrOverloadValRefOpt; { std::string_view str = STRA; + + // Here both by-value (T) and non-const ref (T&) overloads exist. + // Unlike in static C++, where such a situation causes ambiguity and + // requires an explicit static_cast, RTL prioritizes the safe-by-value + // overload automatically since it guarantees no mutation. + // The non-const ref overload remains accessible only through explicit + // binding to preserve mutability intent. auto [err, robj] = revStrOverloadValRef(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -144,6 +162,11 @@ namespace rtl_tests rtl::Function revStrOverloadValRef = *revStrOverloadValRefOpt; { std::string_view str = STRA; + + // Explicitly selecting the non-const ref overload. + // Even though the by-value overload is preferred implicitly for safety, + // the user can override that choice by binding explicitly as T&, + // signaling the intent to allow mutation through reflection. auto [err, robj] = revStrOverloadValRef.bind().call(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -154,4 +177,141 @@ namespace rtl_tests EXPECT_EQ(retStr, expStr); } } + + + + // ----------------------------------------------------------------------------- + // Tests implicit vs explicit binding behavior for reference arguments in RTL. + // Demonstrates RTL's intentional design choice: non-const refs require explicit + // opt-in binding to prevent unintended mutation through reflection. + // ----------------------------------------------------------------------------- + TEST(BasicTypeErasedDispatch, calling_non_overloaded_non_const_ref_argument) + { + auto revStrNonConstRefArgOpt = cxx::mirror().getFunction(str_revStrNonConstRefArg); + ASSERT_TRUE(revStrNonConstRefArgOpt); + + std::string_view str = STRA; + rtl::Function revStrNonConstRefArg = *revStrNonConstRefArgOpt; + + // ------------------------------------------------------------------------- + // Case 1: Implicit call with a value (or perfectly forwarded lvalue) + // ------------------------------------------------------------------------- + // Even though 'str' is an lvalue and forwarding is perfect, RTL enforces + // semantic safety: calls that may mutate user data (T&) require explicit + // intent. Hence, the dispatcher returns ExplicitRefBindingRequired instead + // of silently binding to a non-const lvalue reference. + // ------------------------------------------------------------------------- + { + auto [err, robj] = revStrNonConstRefArg(str); + EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + } + + // ------------------------------------------------------------------------- + // Case 2: Explicitly binding as std::string_view& + // ------------------------------------------------------------------------- + // By calling .bind(), the user explicitly signals willingness to let + // the function modify the argument. This re-enables the T& call path and + // executes successfully, producing the expected result. + // ------------------------------------------------------------------------- + { + auto [err, robj] = revStrNonConstRefArg.bind().call(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(retStr, expStr); + } + } + + + // ----------------------------------------------------------------------------- + // Tests implicit binding for const-reference arguments. + // Since const-ref parameters cannot mutate caller data, RTL allows implicit + // binding without requiring an explicit .bind() call. + // ----------------------------------------------------------------------------- + TEST(BasicTypeErasedDispatch, calling_non_overloaded_const_ref_argument) + { + auto revStrConstRefArgOpt = cxx::mirror().getFunction(str_revStrConstRefArg); + ASSERT_TRUE(revStrConstRefArgOpt); + + std::string_view str = STRA; + rtl::Function revStrConstRefArg = *revStrConstRefArgOpt; + + // ------------------------------------------------------------------------- + // Case: Implicitly binding to const-ref parameter + // ------------------------------------------------------------------------- + // Safe by C++ semantics temporaries and values can bind to const& freely. + // RTL mirrors this rule at runtime, so the call proceeds without requiring + // explicit binding and executes successfully. + // ------------------------------------------------------------------------- + { + auto [err, robj] = revStrConstRefArg(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(retStr, expStr); + } + } + + + TEST(BasicTypeErasedDispatch, implicit_resolution_to_ambiguous_ref_and_cref_overload) + { + auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + + rtl::Function revStrOverloadValRefNCref = *revStrOverloadValRefNCrefOpt; + { + std::string_view str = STRA; + + // Both T& and const T& overloads are viable for an lvalue argument. + // RTL avoids implicit ambiguity by requiring explicit ref binding + // when mutation is possible (non-const ref path). + auto [err, robj] = revStrOverloadValRefNCref(str); + EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + } + } + + + TEST(BasicTypeErasedDispatch, explicit_resolution_to_ambiguous_ref_and_cref_overload) + { + auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + + std::string_view str = STRA; + rtl::Function revStrOverloadValRefNCref = *revStrOverloadValRefNCrefOpt; + { + // Explicitly selecting the non-const ref overload. + // Caller signals intent to allow mutation by binding as T&. + auto [err, robj] = revStrOverloadValRefNCref.bind().call(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(retStr, expStr); + } + { + // Explicitly selecting the const ref overload. + // Note: If only 'const T&' existed, RTL would have resolved it implicitly. + // But since both 'T&' and 'const T&' overloads are available, + // RTL treats the situation as ambiguous and requires explicit selection + // to avoid guessing the user's intent regarding mutability. + auto [err, robj] = revStrOverloadValRefNCref.bind().call(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(retStr, expStr); + } + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 1fdc1df1..6dd31c57 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -63,7 +63,7 @@ namespace rtl::detail }; } } - else return { (functorId.second ? error::RefOverloadAmbiguity : error::SignatureMismatch), RObject{} }; + else return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index df89fad4..4706d18b 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -222,7 +222,7 @@ namespace rtl::detail }; } } - else return { (functorId.second ? error::RefOverloadAmbiguity : error::SignatureMismatch), RObject{} }; + else return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; } @@ -248,6 +248,6 @@ namespace rtl::detail }; } } - else return { (functorId.second ? error::RefOverloadAmbiguity : error::SignatureMismatch), RObject{} }; + else return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 2d5a03c6..01be5f19 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -99,7 +99,7 @@ namespace rtl if (index != rtl::index_none) { auto isAnyNonConstRefInArgsT = (m_functorIds[index].m_lambda->is_any_ncref()); - return { (isAnyNonConstRefInArgsT ? nullptr : &m_functorIds[index]), isAnyNonConstRefInArgsT }; + return { (isAnyNonConstRefInArgsT ? nullptr:&m_functorIds[index]), isAnyNonConstRefInArgsT }; } return { nullptr, false }; } diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index 1e091850..8c6f0530 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -23,7 +23,7 @@ namespace rtl TargetMismatch, SignatureMismatch, - RefOverloadAmbiguity, + ExplicitRefBindingRequired, CloningDisabled, //Used only in case of cloning is disabled e.g, unregistered type. FunctionNotRegistered, //Not used by RTL at all, for external purpose only. @@ -48,6 +48,8 @@ namespace rtl return "Empty instance: RObject does not hold any reflected object"; case error::SignatureMismatch: return "Signature mismatch: Function parameters do not match the expected signature"; + case error::ExplicitRefBindingRequired: + return "Explicit reference binding required for correct overload resolution"; case error::CloningDisabled: return "Type not registered: The requested type is not explicitly registered in the Reflection system"; case error::FunctionNotRegistered: From 949f66b988137af101c86bd88b72d50f88146ef6 Mon Sep 17 00:00:00 2001 From: neeraj Date: Thu, 9 Oct 2025 22:12:50 +0530 Subject: [PATCH 073/148] minor optimizations & benchmarking tweaks. --- RTLBenchmarkApp/src/BenchMark.cpp | 8 ++- .../rtl/detail/inc/FunctionCaller.hpp | 4 +- .../rtl/detail/inc/MethodInvoker.hpp | 4 +- ReflectionTemplateLib/rtl/inc/Method.h | 1 - run_benchmarks.sh | 54 ++++++++++++++----- 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/RTLBenchmarkApp/src/BenchMark.cpp b/RTLBenchmarkApp/src/BenchMark.cpp index 2b1ef9f1..a631aa3c 100644 --- a/RTLBenchmarkApp/src/BenchMark.cpp +++ b/RTLBenchmarkApp/src/BenchMark.cpp @@ -35,18 +35,22 @@ namespace bm retStr_t getMessage(argStr_t pMsg) noexcept { + retStr_t retStr; if(g_work_load){ g_work_done = perform_work(pMsg); + retStr = g_work_done->c_str(); } - return retStr_t(g_work_done->c_str()); + return retStr; } retStr_t Node::getMessage(argStr_t pMsg) noexcept { + retStr_t retStr; if(g_work_load){ g_work_done = perform_work(pMsg); + retStr = g_work_done->c_str(); } - return retStr_t(g_work_done->c_str()); + return retStr; } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 6dd31c57..dbb03b6c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -63,7 +63,9 @@ namespace rtl::detail }; } } - else return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; + else [[unlikely]] { + return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; + } } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 4706d18b..8b54d2ce 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -222,7 +222,9 @@ namespace rtl::detail }; } } - else return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; + else [[unlikely]] { + return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; + } } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 9e746680..efcff637 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -13,7 +13,6 @@ #include -#include "RObject.h" #include "Function.h" #include "MethodInvoker.h" diff --git a/run_benchmarks.sh b/run_benchmarks.sh index f2f11c4d..f1be44c6 100755 --- a/run_benchmarks.sh +++ b/run_benchmarks.sh @@ -1,6 +1,9 @@ #!/bin/bash -# Config +# =========================== +# RTL Benchmark Runner Script +# =========================== + BINARY="./bin/RTLBenchmarkApp" LOGFILE="./benchmark_runs.log" @@ -12,21 +15,44 @@ echo "Binary: $BINARY" | tee -a "$LOGFILE" echo "Log: $LOGFILE" | tee -a "$LOGFILE" echo "===================================" | tee -a "$LOGFILE" -# First handle scale=0, 10 times -SCALE=0 -for i in $(seq 1 10); do - echo ">>> Run $i: workload scale = $SCALE" | tee -a "$LOGFILE" - "$BINARY" "$SCALE" >> "$LOGFILE" 2>&1 - echo "-----------------------------------" | tee -a "$LOGFILE" -done - -# Now handle scales 25, 50, ... 200, each 5 times -for SCALE in $(seq 25 25 200); do - for i in $(seq 1 5); do - echo ">>> Run $i: workload scale = $SCALE" | tee -a "$LOGFILE" - "$BINARY" "$SCALE" >> "$LOGFILE" 2>&1 +# Helper: run workload N times +run_benchmark() { + local scale=$1 + local reps=$2 + for i in $(seq 1 "$reps"); do + echo "[$(date '+%Y-%m-%d %H:%M:%S')] >>> Run $i: workload scale = $scale" | tee -a "$LOGFILE" + if ! "$BINARY" "$scale" >> "$LOGFILE" 2>&1; then + echo "[ERROR] Binary failed at scale=$scale (run $i)" | tee -a "$LOGFILE" + fi echo "-----------------------------------" | tee -a "$LOGFILE" done +} + +# --------------------------- +# Phase 1: Baseline runs (scale 0, 10 reps) +# --------------------------- +run_benchmark 0 10 + +# --------------------------- +# Phase 2: Scales 1 → 50 +# --------------------------- +SCALES_PHASE2=(1 5 10 15 20 25 30 35 40 45 50) +for SCALE in "${SCALES_PHASE2[@]}"; do + run_benchmark "$SCALE" 5 +done + +# --------------------------- +# Phase 3: Scales 58 → 90 (step 8) +# --------------------------- +for SCALE in $(seq 58 8 90); do + run_benchmark "$SCALE" 5 +done + +# --------------------------- +# Phase 4: Final higher scales +# --------------------------- +for SCALE in 100 120 150; do + run_benchmark "$SCALE" 5 done echo "All benchmarks completed." | tee -a "$LOGFILE" From b98c1cb31046b535f55eee4022d60f27036e6e40 Mon Sep 17 00:00:00 2001 From: neeraj Date: Thu, 9 Oct 2025 22:49:50 +0530 Subject: [PATCH 074/148] adding latest benchmarks logs. --- text-benchmark-logs/benchmark_runs.log | 5150 ++++++++++++++++++++++++ 1 file changed, 5150 insertions(+) create mode 100644 text-benchmark-logs/benchmark_runs.log diff --git a/text-benchmark-logs/benchmark_runs.log b/text-benchmark-logs/benchmark_runs.log new file mode 100644 index 00000000..fb3506bd --- /dev/null +++ b/text-benchmark-logs/benchmark_runs.log @@ -0,0 +1,5150 @@ +Starting benchmark runs... +Binary: ./bin/RTLBenchmarkApp +Log: ./benchmark_runs.log +=================================== +[2025-10-09 22:16:17] >>> Run 1: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:16:17+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.14, 0.76, 0.94 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.615 ns 0.614 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488371014 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683556568 + +StdFunction_call::returnVoid 1.49 ns 1.49 ns 470596629 +StdFunction_callMethod::returnVoid 1.86 ns 1.86 ns 376392993 + +RtlFunction_call::returnVoid 1.25 ns 1.25 ns 570174699 +RtlFunction_callMethod::returnVoid 1.45 ns 1.45 ns 486118183 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201243535 +RtlFunction_callMethod_ReturnUnknown::Void 3.24 ns 3.23 ns 221225444 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.93 ns 3.93 ns 179544125 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.693 ns 0.693 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.09 ns 1.09 ns 649459865 +NativeFunctionPtr_callMethod::returnNonVoid 1.50 ns 1.50 ns 481407569 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427191529 +StdFunction_callMethod::returnNonVoid 1.78 ns 1.78 ns 372485231 + +RtlFunction_call::returnNonVoid 1.39 ns 1.39 ns 528064222 +RtlFunction_callMethod::returnNonVoid 1.59 ns 1.59 ns 427333237 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50786184 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.3 ns 13.3 ns 53298525 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47909277 +----------------------------------- +[2025-10-09 22:16:35] >>> Run 2: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:16:35+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.33, 0.77, 0.94 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.540 ns 0.540 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 487948937 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683488850 + +StdFunction_call::returnVoid 1.47 ns 1.47 ns 488617891 +StdFunction_callMethod::returnVoid 1.85 ns 1.85 ns 377645764 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569768981 +RtlFunction_callMethod::returnVoid 1.45 ns 1.45 ns 483937345 + +RtlFunction_call_ReturnUnknown::Void 3.49 ns 3.49 ns 201075618 +RtlFunction_callMethod_ReturnUnknown::Void 3.18 ns 3.18 ns 220548820 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.89 ns 3.89 ns 179320699 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.694 ns 0.694 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.10 ns 1.10 ns 647073593 +NativeFunctionPtr_callMethod::returnNonVoid 1.50 ns 1.50 ns 492913179 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427278526 +StdFunction_callMethod::returnNonVoid 1.84 ns 1.84 ns 391027228 + +RtlFunction_call::returnNonVoid 1.41 ns 1.41 ns 486150854 +RtlFunction_callMethod::returnNonVoid 1.62 ns 1.62 ns 460145276 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50781975 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.4 ns 13.4 ns 52916421 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.7 ns 14.7 ns 46665825 +----------------------------------- +[2025-10-09 22:16:52] >>> Run 3: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:16:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.52, 0.79, 0.95 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.537 ns 0.537 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 486916993 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683124349 + +StdFunction_call::returnVoid 1.48 ns 1.48 ns 472661856 +StdFunction_callMethod::returnVoid 1.85 ns 1.85 ns 380898454 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569145309 +RtlFunction_callMethod::returnVoid 1.47 ns 1.47 ns 488608846 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201221095 +RtlFunction_callMethod_ReturnUnknown::Void 3.16 ns 3.16 ns 219108881 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.92 ns 3.92 ns 179754192 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.693 ns 0.692 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.10 ns 1.10 ns 639080262 +NativeFunctionPtr_callMethod::returnNonVoid 1.53 ns 1.53 ns 482602667 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427317043 +StdFunction_callMethod::returnNonVoid 1.80 ns 1.80 ns 396879318 + +RtlFunction_call::returnNonVoid 1.41 ns 1.41 ns 498559192 +RtlFunction_callMethod::returnNonVoid 1.57 ns 1.57 ns 449206328 + +RtlFunction_call_ReturnUnknown::NonVoid 13.7 ns 13.7 ns 49813322 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 53497529 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.7 ns 14.7 ns 47741737 +----------------------------------- +[2025-10-09 22:17:10] >>> Run 4: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:17:10+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.63, 0.80, 0.95 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.540 ns 0.539 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488327143 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683830386 + +StdFunction_call::returnVoid 1.46 ns 1.46 ns 486442061 +StdFunction_callMethod::returnVoid 1.88 ns 1.88 ns 371827284 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 570108800 +RtlFunction_callMethod::returnVoid 1.46 ns 1.46 ns 482174568 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201414001 +RtlFunction_callMethod_ReturnUnknown::Void 3.18 ns 3.18 ns 219417993 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.88 ns 3.88 ns 179104676 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.694 ns 0.694 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.08 ns 1.08 ns 641935885 +NativeFunctionPtr_callMethod::returnNonVoid 1.56 ns 1.55 ns 442554688 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427559456 +StdFunction_callMethod::returnNonVoid 1.83 ns 1.83 ns 393616857 + +RtlFunction_call::returnNonVoid 1.44 ns 1.44 ns 462588664 +RtlFunction_callMethod::returnNonVoid 1.55 ns 1.55 ns 443460688 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 51342305 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.3 ns 13.3 ns 53292826 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47789473 +----------------------------------- +[2025-10-09 22:17:27] >>> Run 5: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:17:27+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.73, 0.81, 0.95 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.614 ns 0.614 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488465535 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 682376940 + +StdFunction_call::returnVoid 1.47 ns 1.47 ns 486399948 +StdFunction_callMethod::returnVoid 1.85 ns 1.85 ns 380599795 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569979525 +RtlFunction_callMethod::returnVoid 1.45 ns 1.45 ns 480584216 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201218265 +RtlFunction_callMethod_ReturnUnknown::Void 3.20 ns 3.20 ns 218513145 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.90 ns 3.90 ns 180411390 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.692 ns 0.692 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.09 ns 1.09 ns 639172235 +NativeFunctionPtr_callMethod::returnNonVoid 1.46 ns 1.46 ns 501201889 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427402144 +StdFunction_callMethod::returnNonVoid 1.79 ns 1.79 ns 392583620 + +RtlFunction_call::returnNonVoid 1.34 ns 1.34 ns 518974309 +RtlFunction_callMethod::returnNonVoid 1.58 ns 1.58 ns 447407186 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50810272 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 53697288 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47745107 +----------------------------------- +[2025-10-09 22:17:45] >>> Run 6: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:17:45+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.79, 0.83, 0.95 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.538 ns 0.538 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488628989 +NativeFunctionPtr_callMethod::returnVoid 1.03 ns 1.02 ns 684056697 + +StdFunction_call::returnVoid 1.46 ns 1.46 ns 482074155 +StdFunction_callMethod::returnVoid 1.84 ns 1.84 ns 379683455 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 570148014 +RtlFunction_callMethod::returnVoid 1.45 ns 1.45 ns 486200457 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201269021 +RtlFunction_callMethod_ReturnUnknown::Void 3.22 ns 3.22 ns 220434176 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.90 ns 3.90 ns 178941515 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.694 ns 0.694 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.10 ns 1.10 ns 640033156 +NativeFunctionPtr_callMethod::returnNonVoid 1.53 ns 1.53 ns 484321550 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427395695 +StdFunction_callMethod::returnNonVoid 1.79 ns 1.79 ns 383213510 + +RtlFunction_call::returnNonVoid 1.39 ns 1.39 ns 498672448 +RtlFunction_callMethod::returnNonVoid 1.55 ns 1.55 ns 447413397 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50494352 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 53438544 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47358599 +----------------------------------- +[2025-10-09 22:18:03] >>> Run 7: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:18:03+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.85, 0.84, 0.95 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.534 ns 0.534 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.44 ns 1.43 ns 487373256 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 684129923 + +StdFunction_call::returnVoid 1.49 ns 1.49 ns 486533392 +StdFunction_callMethod::returnVoid 1.87 ns 1.87 ns 372226528 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 570130359 +RtlFunction_callMethod::returnVoid 1.50 ns 1.49 ns 488476787 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201265803 +RtlFunction_callMethod_ReturnUnknown::Void 3.19 ns 3.19 ns 219574993 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.92 ns 3.92 ns 179946597 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.692 ns 0.692 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.08 ns 1.08 ns 636786202 +NativeFunctionPtr_callMethod::returnNonVoid 1.50 ns 1.50 ns 438081296 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427138506 +StdFunction_callMethod::returnNonVoid 1.81 ns 1.81 ns 368043984 + +RtlFunction_call::returnNonVoid 1.43 ns 1.43 ns 490343930 +RtlFunction_callMethod::returnNonVoid 1.65 ns 1.65 ns 428580493 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50492376 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 52986296 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.7 ns 14.7 ns 47036220 +----------------------------------- +[2025-10-09 22:18:20] >>> Run 8: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:18:20+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.89, 0.85, 0.95 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.536 ns 0.536 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488721454 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683970735 + +StdFunction_call::returnVoid 1.44 ns 1.44 ns 479849742 +StdFunction_callMethod::returnVoid 1.85 ns 1.85 ns 376284530 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569899714 +RtlFunction_callMethod::returnVoid 1.46 ns 1.46 ns 477113064 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.47 ns 201269015 +RtlFunction_callMethod_ReturnUnknown::Void 3.20 ns 3.20 ns 222216957 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.89 ns 3.89 ns 180306431 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.694 ns 0.694 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.10 ns 1.10 ns 647589992 +NativeFunctionPtr_callMethod::returnNonVoid 1.46 ns 1.46 ns 486880203 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427281796 +StdFunction_callMethod::returnNonVoid 1.79 ns 1.79 ns 378599554 + +RtlFunction_call::returnNonVoid 1.42 ns 1.42 ns 493358927 +RtlFunction_callMethod::returnNonVoid 1.55 ns 1.55 ns 422127463 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50826607 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.3 ns 13.3 ns 53224105 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47061421 +----------------------------------- +[2025-10-09 22:18:38] >>> Run 9: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:18:38+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.92, 0.86, 0.96 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.614 ns 0.614 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488251170 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 682497941 + +StdFunction_call::returnVoid 1.45 ns 1.45 ns 475925971 +StdFunction_callMethod::returnVoid 1.88 ns 1.88 ns 377354115 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 570115463 +RtlFunction_callMethod::returnVoid 1.46 ns 1.46 ns 480603254 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 200777871 +RtlFunction_callMethod_ReturnUnknown::Void 3.19 ns 3.19 ns 214825856 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.90 ns 3.90 ns 179384624 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.693 ns 0.693 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.08 ns 1.08 ns 632628408 +NativeFunctionPtr_callMethod::returnNonVoid 1.50 ns 1.50 ns 491783053 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427586231 +StdFunction_callMethod::returnNonVoid 1.82 ns 1.82 ns 388424012 + +RtlFunction_call::returnNonVoid 1.37 ns 1.37 ns 507299706 +RtlFunction_callMethod::returnNonVoid 1.55 ns 1.55 ns 446340209 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 51035639 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.3 ns 13.3 ns 53646607 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47338426 +----------------------------------- +[2025-10-09 22:18:55] >>> Run 10: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-10-09T22:18:55+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.94, 0.86, 0.96 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 0.541 ns 0.541 ns 1000000000 + +NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488253694 +NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683995671 + +StdFunction_call::returnVoid 1.47 ns 1.47 ns 482164541 +StdFunction_callMethod::returnVoid 1.86 ns 1.86 ns 378821155 + +RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569848625 +RtlFunction_callMethod::returnVoid 1.48 ns 1.48 ns 471901482 + +RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201189833 +RtlFunction_callMethod_ReturnUnknown::Void 3.19 ns 3.19 ns 217482610 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.92 ns 3.92 ns 178990707 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 0.692 ns 0.692 ns 1000000000 + +NativeFunctionPtr_call::returnNonVoid 1.09 ns 1.09 ns 635090027 +NativeFunctionPtr_callMethod::returnNonVoid 1.51 ns 1.51 ns 497893190 + +StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427655543 +StdFunction_callMethod::returnNonVoid 1.86 ns 1.86 ns 367002436 + +RtlFunction_call::returnNonVoid 1.41 ns 1.40 ns 489489712 +RtlFunction_callMethod::returnNonVoid 1.59 ns 1.59 ns 459390527 + +RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 51251170 +RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 52169372 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47420606 +----------------------------------- +[2025-10-09 22:19:13] >>> Run 1: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-10-09T22:19:13+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.96, 0.87, 0.96 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 14.9 ns 14.9 ns 46377011 + +NativeFunctionPtr_call::returnVoid 15.3 ns 15.3 ns 46227161 +NativeFunctionPtr_callMethod::returnVoid 14.9 ns 14.9 ns 46573202 + +StdFunction_call::returnVoid 15.2 ns 15.2 ns 44104419 +StdFunction_callMethod::returnVoid 15.8 ns 15.8 ns 42962369 + +RtlFunction_call::returnVoid 15.3 ns 15.3 ns 44274191 +RtlFunction_callMethod::returnVoid 15.9 ns 15.9 ns 43477860 + +RtlFunction_call_ReturnUnknown::Void 17.3 ns 17.3 ns 39575146 +RtlFunction_callMethod_ReturnUnknown::Void 17.2 ns 17.2 ns 40222647 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 18.4 ns 18.4 ns 38292662 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 20.9 ns 20.9 ns 33583339 + +NativeFunctionPtr_call::returnNonVoid 20.9 ns 20.9 ns 33634347 +NativeFunctionPtr_callMethod::returnNonVoid 21.1 ns 21.1 ns 33426262 + +StdFunction_call::returnNonVoid 21.1 ns 21.1 ns 33175655 +StdFunction_callMethod::returnNonVoid 21.5 ns 21.5 ns 32364270 + +RtlFunction_call::returnNonVoid 20.9 ns 20.9 ns 33520163 +RtlFunction_callMethod::returnNonVoid 21.1 ns 21.1 ns 33143282 + +RtlFunction_call_ReturnUnknown::NonVoid 31.0 ns 31.0 ns 22528741 +RtlFunction_callMethod_ReturnUnknown::NonVoid 30.3 ns 30.3 ns 23194476 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 32.1 ns 32.1 ns 21788728 +----------------------------------- +[2025-10-09 22:19:31] >>> Run 2: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-10-09T22:19:31+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.97, 0.88, 0.96 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 14.9 ns 14.9 ns 45364596 + +NativeFunctionPtr_call::returnVoid 15.2 ns 15.2 ns 45419462 +NativeFunctionPtr_callMethod::returnVoid 14.9 ns 14.9 ns 47051088 + +StdFunction_call::returnVoid 15.2 ns 15.2 ns 46669479 +StdFunction_callMethod::returnVoid 15.4 ns 15.4 ns 46292177 + +RtlFunction_call::returnVoid 14.9 ns 14.9 ns 45293244 +RtlFunction_callMethod::returnVoid 15.2 ns 15.2 ns 45851894 + +RtlFunction_call_ReturnUnknown::Void 17.4 ns 17.4 ns 40152888 +RtlFunction_callMethod_ReturnUnknown::Void 16.7 ns 16.7 ns 41324147 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 18.6 ns 18.6 ns 37723786 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 20.5 ns 20.5 ns 33954277 + +NativeFunctionPtr_call::returnNonVoid 20.5 ns 20.5 ns 34120413 +NativeFunctionPtr_callMethod::returnNonVoid 20.7 ns 20.7 ns 33907841 + +StdFunction_call::returnNonVoid 20.7 ns 20.7 ns 33879555 +StdFunction_callMethod::returnNonVoid 21.3 ns 21.3 ns 33117134 + +RtlFunction_call::returnNonVoid 20.5 ns 20.5 ns 34127782 +RtlFunction_callMethod::returnNonVoid 20.8 ns 20.7 ns 33948897 + +RtlFunction_call_ReturnUnknown::NonVoid 30.7 ns 30.7 ns 22524742 +RtlFunction_callMethod_ReturnUnknown::NonVoid 30.2 ns 30.2 ns 23134209 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 32.0 ns 32.0 ns 21910277 +----------------------------------- +[2025-10-09 22:19:50] >>> Run 3: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-10-09T22:19:50+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800.538 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.98, 0.89, 0.96 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 14.9 ns 14.9 ns 46873996 + +NativeFunctionPtr_call::returnVoid 15.1 ns 15.1 ns 44823182 +NativeFunctionPtr_callMethod::returnVoid 15.1 ns 15.1 ns 45050872 + +StdFunction_call::returnVoid 15.0 ns 15.0 ns 44965311 +StdFunction_callMethod::returnVoid 15.3 ns 15.3 ns 44736020 + +RtlFunction_call::returnVoid 15.2 ns 15.2 ns 44511657 +RtlFunction_callMethod::returnVoid 15.2 ns 15.2 ns 44209779 + +RtlFunction_call_ReturnUnknown::Void 17.4 ns 17.4 ns 39971998 +RtlFunction_callMethod_ReturnUnknown::Void 16.9 ns 16.9 ns 41038287 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 18.4 ns 18.4 ns 37834095 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 20.4 ns 20.4 ns 34202626 + +NativeFunctionPtr_call::returnNonVoid 20.5 ns 20.5 ns 33922978 +NativeFunctionPtr_callMethod::returnNonVoid 20.6 ns 20.6 ns 33861275 + +StdFunction_call::returnNonVoid 20.7 ns 20.6 ns 33733127 +StdFunction_callMethod::returnNonVoid 21.2 ns 21.2 ns 32740293 + +RtlFunction_call::returnNonVoid 20.5 ns 20.5 ns 34084806 +RtlFunction_callMethod::returnNonVoid 20.7 ns 20.7 ns 33685938 + +RtlFunction_call_ReturnUnknown::NonVoid 31.0 ns 31.0 ns 22831560 +RtlFunction_callMethod_ReturnUnknown::NonVoid 30.1 ns 30.1 ns 23205483 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 31.8 ns 31.8 ns 21996772 +----------------------------------- +[2025-10-09 22:20:08] >>> Run 4: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-10-09T22:20:08+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.98, 0.90, 0.97 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 15.2 ns 15.2 ns 45936420 + +NativeFunctionPtr_call::returnVoid 15.5 ns 15.5 ns 46014580 +NativeFunctionPtr_callMethod::returnVoid 15.2 ns 15.2 ns 46535315 + +StdFunction_call::returnVoid 15.7 ns 15.7 ns 43251339 +StdFunction_callMethod::returnVoid 15.5 ns 15.5 ns 45041025 + +RtlFunction_call::returnVoid 15.0 ns 15.0 ns 45953264 +RtlFunction_callMethod::returnVoid 15.3 ns 15.3 ns 45516230 + +RtlFunction_call_ReturnUnknown::Void 18.2 ns 18.1 ns 38688796 +RtlFunction_callMethod_ReturnUnknown::Void 17.3 ns 17.3 ns 40375966 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 19.0 ns 19.0 ns 36862004 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 20.7 ns 20.7 ns 33888048 + +NativeFunctionPtr_call::returnNonVoid 20.6 ns 20.6 ns 33781492 +NativeFunctionPtr_callMethod::returnNonVoid 20.9 ns 20.9 ns 33739016 + +StdFunction_call::returnNonVoid 20.9 ns 20.9 ns 33638683 +StdFunction_callMethod::returnNonVoid 21.4 ns 21.4 ns 32675071 + +RtlFunction_call::returnNonVoid 20.6 ns 20.6 ns 33859486 +RtlFunction_callMethod::returnNonVoid 20.8 ns 20.8 ns 33657521 + +RtlFunction_call_ReturnUnknown::NonVoid 31.1 ns 31.1 ns 22420373 +RtlFunction_callMethod_ReturnUnknown::NonVoid 30.4 ns 30.4 ns 23120348 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 31.9 ns 31.9 ns 21854003 +----------------------------------- +[2025-10-09 22:20:27] >>> Run 5: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-10-09T22:20:27+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.99, 0.91, 0.97 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 15.0 ns 15.0 ns 47279898 + +NativeFunctionPtr_call::returnVoid 15.3 ns 15.3 ns 45516981 +NativeFunctionPtr_callMethod::returnVoid 14.7 ns 14.7 ns 46513819 + +StdFunction_call::returnVoid 15.3 ns 15.3 ns 43850329 +StdFunction_callMethod::returnVoid 15.3 ns 15.3 ns 45168901 + +RtlFunction_call::returnVoid 15.1 ns 15.1 ns 46343637 +RtlFunction_callMethod::returnVoid 15.2 ns 15.2 ns 45176454 + +RtlFunction_call_ReturnUnknown::Void 16.9 ns 16.9 ns 40920690 +RtlFunction_callMethod_ReturnUnknown::Void 16.5 ns 16.5 ns 41926933 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 17.6 ns 17.6 ns 39234606 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 17.8 ns 17.8 ns 39112695 + +NativeFunctionPtr_call::returnNonVoid 17.4 ns 17.4 ns 40026410 +NativeFunctionPtr_callMethod::returnNonVoid 17.4 ns 17.4 ns 40676047 + +StdFunction_call::returnNonVoid 17.7 ns 17.7 ns 39540814 +StdFunction_callMethod::returnNonVoid 17.9 ns 17.9 ns 39049909 + +RtlFunction_call::returnNonVoid 17.5 ns 17.5 ns 40321431 +RtlFunction_callMethod::returnNonVoid 17.5 ns 17.5 ns 40188358 + +RtlFunction_call_ReturnUnknown::NonVoid 31.2 ns 31.2 ns 22400691 +RtlFunction_callMethod_ReturnUnknown::NonVoid 30.3 ns 30.3 ns 23233990 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 32.2 ns 32.2 ns 21865009 +----------------------------------- +[2025-10-09 22:20:45] >>> Run 1: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-10-09T22:20:45+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.99, 0.91, 0.97 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 94.5 ns 94.5 ns 7418436 + +NativeFunctionPtr_call::returnVoid 95.1 ns 95.1 ns 7390751 +NativeFunctionPtr_callMethod::returnVoid 95.0 ns 95.0 ns 7346151 + +StdFunction_call::returnVoid 94.8 ns 94.8 ns 7370630 +StdFunction_callMethod::returnVoid 95.5 ns 95.5 ns 7345019 + +RtlFunction_call::returnVoid 94.7 ns 94.7 ns 7380097 +RtlFunction_callMethod::returnVoid 95.1 ns 95.1 ns 7341998 + +RtlFunction_call_ReturnUnknown::Void 97.3 ns 97.3 ns 7191391 +RtlFunction_callMethod_ReturnUnknown::Void 97.4 ns 97.4 ns 7181504 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 98.1 ns 98.1 ns 7142112 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 101 ns 101 ns 6891130 + +NativeFunctionPtr_call::returnNonVoid 102 ns 102 ns 6857124 +NativeFunctionPtr_callMethod::returnNonVoid 102 ns 102 ns 6822722 + +StdFunction_call::returnNonVoid 102 ns 102 ns 6809837 +StdFunction_callMethod::returnNonVoid 104 ns 104 ns 6735489 + +RtlFunction_call::returnNonVoid 102 ns 102 ns 6782573 +RtlFunction_callMethod::returnNonVoid 103 ns 103 ns 6813078 + +RtlFunction_call_ReturnUnknown::NonVoid 115 ns 115 ns 6059851 +RtlFunction_callMethod_ReturnUnknown::NonVoid 114 ns 114 ns 6160387 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 117 ns 117 ns 6008395 +----------------------------------- +[2025-10-09 22:21:01] >>> Run 2: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-10-09T22:21:01+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.92, 0.97 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 97.0 ns 97.0 ns 7226382 + +NativeFunctionPtr_call::returnVoid 97.3 ns 97.3 ns 7197759 +NativeFunctionPtr_callMethod::returnVoid 97.1 ns 97.1 ns 7187773 + +StdFunction_call::returnVoid 97.2 ns 97.2 ns 7194186 +StdFunction_callMethod::returnVoid 97.5 ns 97.4 ns 7242579 + +RtlFunction_call::returnVoid 97.1 ns 97.0 ns 7223246 +RtlFunction_callMethod::returnVoid 97.6 ns 97.6 ns 7205800 + +RtlFunction_call_ReturnUnknown::Void 101 ns 101 ns 6977400 +RtlFunction_callMethod_ReturnUnknown::Void 99.8 ns 99.7 ns 7045819 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 101 ns 101 ns 6968577 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 115 ns 115 ns 6022471 + +NativeFunctionPtr_call::returnNonVoid 116 ns 116 ns 6055445 +NativeFunctionPtr_callMethod::returnNonVoid 117 ns 117 ns 5980019 + +StdFunction_call::returnNonVoid 116 ns 116 ns 6086357 +StdFunction_callMethod::returnNonVoid 117 ns 117 ns 6012413 + +RtlFunction_call::returnNonVoid 115 ns 115 ns 6051125 +RtlFunction_callMethod::returnNonVoid 116 ns 116 ns 6037378 + +RtlFunction_call_ReturnUnknown::NonVoid 122 ns 122 ns 5731702 +RtlFunction_callMethod_ReturnUnknown::NonVoid 122 ns 122 ns 5752072 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 122 ns 122 ns 5746437 +----------------------------------- +[2025-10-09 22:21:17] >>> Run 3: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-10-09T22:21:17+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.92, 0.97 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 94.6 ns 94.6 ns 7392390 + +NativeFunctionPtr_call::returnVoid 95.2 ns 95.2 ns 7402546 +NativeFunctionPtr_callMethod::returnVoid 94.6 ns 94.5 ns 7392864 + +StdFunction_call::returnVoid 95.7 ns 95.7 ns 7014386 +StdFunction_callMethod::returnVoid 95.7 ns 95.7 ns 7236493 + +RtlFunction_call::returnVoid 94.8 ns 94.8 ns 7043913 +RtlFunction_callMethod::returnVoid 95.4 ns 95.4 ns 7406849 + +RtlFunction_call_ReturnUnknown::Void 97.2 ns 97.2 ns 7238799 +RtlFunction_callMethod_ReturnUnknown::Void 97.5 ns 97.5 ns 7273749 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 98.6 ns 98.6 ns 7118704 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 102 ns 102 ns 6900135 + +NativeFunctionPtr_call::returnNonVoid 102 ns 102 ns 6859439 +NativeFunctionPtr_callMethod::returnNonVoid 103 ns 103 ns 6769500 + +StdFunction_call::returnNonVoid 102 ns 102 ns 6885850 +StdFunction_callMethod::returnNonVoid 103 ns 103 ns 6797639 + +RtlFunction_call::returnNonVoid 102 ns 102 ns 6840686 +RtlFunction_callMethod::returnNonVoid 102 ns 102 ns 6839947 + +RtlFunction_call_ReturnUnknown::NonVoid 115 ns 115 ns 6111142 +RtlFunction_callMethod_ReturnUnknown::NonVoid 115 ns 115 ns 6134532 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 116 ns 116 ns 6031459 +----------------------------------- +[2025-10-09 22:21:34] >>> Run 4: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-10-09T22:21:34+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.93, 0.97 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 94.2 ns 94.2 ns 7449867 + +NativeFunctionPtr_call::returnVoid 94.2 ns 94.2 ns 7395615 +NativeFunctionPtr_callMethod::returnVoid 94.1 ns 94.1 ns 7419278 + +StdFunction_call::returnVoid 94.7 ns 94.7 ns 7430858 +StdFunction_callMethod::returnVoid 94.5 ns 94.5 ns 7383366 + +RtlFunction_call::returnVoid 94.2 ns 94.2 ns 7446366 +RtlFunction_callMethod::returnVoid 94.8 ns 94.7 ns 7317785 + +RtlFunction_call_ReturnUnknown::Void 96.5 ns 96.5 ns 7199741 +RtlFunction_callMethod_ReturnUnknown::Void 97.0 ns 97.0 ns 7224357 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 97.6 ns 97.6 ns 7232105 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 102 ns 102 ns 6935311 + +NativeFunctionPtr_call::returnNonVoid 101 ns 101 ns 6876300 +NativeFunctionPtr_callMethod::returnNonVoid 102 ns 102 ns 6817570 + +StdFunction_call::returnNonVoid 101 ns 101 ns 6894995 +StdFunction_callMethod::returnNonVoid 102 ns 102 ns 6778790 + +RtlFunction_call::returnNonVoid 102 ns 102 ns 6788073 +RtlFunction_callMethod::returnNonVoid 102 ns 102 ns 6808113 + +RtlFunction_call_ReturnUnknown::NonVoid 114 ns 114 ns 6124217 +RtlFunction_callMethod_ReturnUnknown::NonVoid 114 ns 114 ns 6138453 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 115 ns 115 ns 6092982 +----------------------------------- +[2025-10-09 22:21:50] >>> Run 5: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-10-09T22:21:50+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.93, 0.98 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 95.8 ns 95.8 ns 7289186 + +NativeFunctionPtr_call::returnVoid 96.2 ns 96.2 ns 7258317 +NativeFunctionPtr_callMethod::returnVoid 95.7 ns 95.7 ns 7161040 + +StdFunction_call::returnVoid 96.3 ns 96.3 ns 7229461 +StdFunction_callMethod::returnVoid 96.4 ns 96.4 ns 7222625 + +RtlFunction_call::returnVoid 96.1 ns 96.1 ns 7281092 +RtlFunction_callMethod::returnVoid 96.4 ns 96.4 ns 7292384 + +RtlFunction_call_ReturnUnknown::Void 98.9 ns 98.9 ns 7025539 +RtlFunction_callMethod_ReturnUnknown::Void 98.6 ns 98.6 ns 7003241 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 99.6 ns 99.6 ns 6962430 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 114 ns 114 ns 6159916 + +NativeFunctionPtr_call::returnNonVoid 114 ns 114 ns 6109376 +NativeFunctionPtr_callMethod::returnNonVoid 115 ns 115 ns 6111122 + +StdFunction_call::returnNonVoid 114 ns 114 ns 6186801 +StdFunction_callMethod::returnNonVoid 115 ns 114 ns 6135953 + +RtlFunction_call::returnNonVoid 114 ns 114 ns 6181904 +RtlFunction_callMethod::returnNonVoid 115 ns 115 ns 6085080 + +RtlFunction_call_ReturnUnknown::NonVoid 120 ns 120 ns 5848705 +RtlFunction_callMethod_ReturnUnknown::NonVoid 120 ns 120 ns 5853140 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 120 ns 120 ns 5823569 +----------------------------------- +[2025-10-09 22:22:06] >>> Run 1: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-10-09T22:22:06+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.94, 0.98 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 163 ns 163 ns 4298789 + +NativeFunctionPtr_call::returnVoid 164 ns 164 ns 4263251 +NativeFunctionPtr_callMethod::returnVoid 163 ns 163 ns 4266147 + +StdFunction_call::returnVoid 164 ns 163 ns 4266550 +StdFunction_callMethod::returnVoid 164 ns 164 ns 4338164 + +RtlFunction_call::returnVoid 162 ns 162 ns 4317041 +RtlFunction_callMethod::returnVoid 164 ns 164 ns 4294553 + +RtlFunction_call_ReturnUnknown::Void 172 ns 172 ns 4090212 +RtlFunction_callMethod_ReturnUnknown::Void 169 ns 169 ns 4160670 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 170 ns 170 ns 4147575 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 186 ns 186 ns 3767569 + +NativeFunctionPtr_call::returnNonVoid 186 ns 186 ns 3773120 +NativeFunctionPtr_callMethod::returnNonVoid 187 ns 187 ns 3782427 + +StdFunction_call::returnNonVoid 185 ns 185 ns 3785312 +StdFunction_callMethod::returnNonVoid 185 ns 185 ns 3760167 + +RtlFunction_call::returnNonVoid 187 ns 187 ns 3753484 +RtlFunction_callMethod::returnNonVoid 187 ns 187 ns 3712101 + +RtlFunction_call_ReturnUnknown::NonVoid 198 ns 198 ns 3548465 +RtlFunction_callMethod_ReturnUnknown::NonVoid 199 ns 199 ns 3560529 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 200 ns 200 ns 3499395 +----------------------------------- +[2025-10-09 22:22:24] >>> Run 2: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-10-09T22:22:24+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.94, 0.98 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 161 ns 161 ns 4352473 + +NativeFunctionPtr_call::returnVoid 162 ns 162 ns 4341961 +NativeFunctionPtr_callMethod::returnVoid 162 ns 162 ns 4336860 + +StdFunction_call::returnVoid 162 ns 162 ns 4334729 +StdFunction_callMethod::returnVoid 162 ns 162 ns 4311518 + +RtlFunction_call::returnVoid 161 ns 161 ns 4438099 +RtlFunction_callMethod::returnVoid 162 ns 162 ns 4285776 + +RtlFunction_call_ReturnUnknown::Void 163 ns 163 ns 4279712 +RtlFunction_callMethod_ReturnUnknown::Void 165 ns 165 ns 4325532 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 165 ns 165 ns 4217999 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 183 ns 183 ns 3873571 + +NativeFunctionPtr_call::returnNonVoid 185 ns 185 ns 3800985 +NativeFunctionPtr_callMethod::returnNonVoid 185 ns 185 ns 3798297 + +StdFunction_call::returnNonVoid 184 ns 184 ns 3769904 +StdFunction_callMethod::returnNonVoid 184 ns 184 ns 3760250 + +RtlFunction_call::returnNonVoid 185 ns 185 ns 3777362 +RtlFunction_callMethod::returnNonVoid 185 ns 185 ns 3758805 + +RtlFunction_call_ReturnUnknown::NonVoid 193 ns 193 ns 3616444 +RtlFunction_callMethod_ReturnUnknown::NonVoid 193 ns 193 ns 3650560 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 194 ns 194 ns 3603472 +----------------------------------- +[2025-10-09 22:22:42] >>> Run 3: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-10-09T22:22:42+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.95, 0.98 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 163 ns 163 ns 4313760 + +NativeFunctionPtr_call::returnVoid 169 ns 169 ns 4323834 +NativeFunctionPtr_callMethod::returnVoid 173 ns 173 ns 4056268 + +StdFunction_call::returnVoid 174 ns 174 ns 3992048 +StdFunction_callMethod::returnVoid 175 ns 175 ns 3985300 + +RtlFunction_call::returnVoid 174 ns 174 ns 4034475 +RtlFunction_callMethod::returnVoid 176 ns 176 ns 4013620 + +RtlFunction_call_ReturnUnknown::Void 178 ns 178 ns 3938442 +RtlFunction_callMethod_ReturnUnknown::Void 177 ns 177 ns 3958103 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 180 ns 180 ns 3886562 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 205 ns 205 ns 3436696 + +NativeFunctionPtr_call::returnNonVoid 205 ns 205 ns 3415528 +NativeFunctionPtr_callMethod::returnNonVoid 206 ns 206 ns 3402008 + +StdFunction_call::returnNonVoid 205 ns 205 ns 3420366 +StdFunction_callMethod::returnNonVoid 206 ns 206 ns 3422671 + +RtlFunction_call::returnNonVoid 205 ns 205 ns 3419467 +RtlFunction_callMethod::returnNonVoid 205 ns 205 ns 3409997 + +RtlFunction_call_ReturnUnknown::NonVoid 212 ns 212 ns 3317595 +RtlFunction_callMethod_ReturnUnknown::NonVoid 213 ns 213 ns 3310747 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 213 ns 213 ns 3293147 +----------------------------------- +[2025-10-09 22:23:00] >>> Run 4: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-10-09T22:23:00+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.95, 0.98 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 160 ns 160 ns 4338148 + +NativeFunctionPtr_call::returnVoid 160 ns 160 ns 4383707 +NativeFunctionPtr_callMethod::returnVoid 160 ns 160 ns 4352305 + +StdFunction_call::returnVoid 160 ns 160 ns 4381519 +StdFunction_callMethod::returnVoid 161 ns 161 ns 4336371 + +RtlFunction_call::returnVoid 162 ns 162 ns 4389675 +RtlFunction_callMethod::returnVoid 163 ns 163 ns 4327396 + +RtlFunction_call_ReturnUnknown::Void 164 ns 164 ns 4284776 +RtlFunction_callMethod_ReturnUnknown::Void 163 ns 163 ns 4265542 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 165 ns 165 ns 4258095 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 184 ns 184 ns 3777902 + +NativeFunctionPtr_call::returnNonVoid 186 ns 186 ns 3757189 +NativeFunctionPtr_callMethod::returnNonVoid 187 ns 187 ns 3805745 + +StdFunction_call::returnNonVoid 185 ns 185 ns 3792834 +StdFunction_callMethod::returnNonVoid 185 ns 185 ns 3800689 + +RtlFunction_call::returnNonVoid 185 ns 185 ns 3768244 +RtlFunction_callMethod::returnNonVoid 185 ns 185 ns 3814454 + +RtlFunction_call_ReturnUnknown::NonVoid 193 ns 193 ns 3603154 +RtlFunction_callMethod_ReturnUnknown::NonVoid 192 ns 192 ns 3654448 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 193 ns 193 ns 3610658 +----------------------------------- +[2025-10-09 22:23:18] >>> Run 5: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-10-09T22:23:18+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4894.5 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.95, 0.98 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 161 ns 161 ns 4380340 + +NativeFunctionPtr_call::returnVoid 161 ns 161 ns 4326537 +NativeFunctionPtr_callMethod::returnVoid 160 ns 160 ns 4360434 + +StdFunction_call::returnVoid 161 ns 161 ns 4372515 +StdFunction_callMethod::returnVoid 162 ns 162 ns 4311332 + +RtlFunction_call::returnVoid 162 ns 162 ns 4336826 +RtlFunction_callMethod::returnVoid 163 ns 163 ns 4326481 + +RtlFunction_call_ReturnUnknown::Void 164 ns 164 ns 4265133 +RtlFunction_callMethod_ReturnUnknown::Void 163 ns 163 ns 4288142 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 165 ns 165 ns 4234347 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 185 ns 185 ns 3782088 + +NativeFunctionPtr_call::returnNonVoid 184 ns 184 ns 3818566 +NativeFunctionPtr_callMethod::returnNonVoid 185 ns 185 ns 3801545 + +StdFunction_call::returnNonVoid 183 ns 183 ns 3814381 +StdFunction_callMethod::returnNonVoid 183 ns 183 ns 3859080 + +RtlFunction_call::returnNonVoid 184 ns 184 ns 3775139 +RtlFunction_callMethod::returnNonVoid 184 ns 184 ns 3824835 + +RtlFunction_call_ReturnUnknown::NonVoid 193 ns 193 ns 3623645 +RtlFunction_callMethod_ReturnUnknown::NonVoid 193 ns 193 ns 3640925 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 193 ns 193 ns 3616590 +----------------------------------- +[2025-10-09 22:23:36] >>> Run 1: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-10-09T22:23:36+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.96, 0.99 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 215 ns 215 ns 3263479 + +NativeFunctionPtr_call::returnVoid 214 ns 214 ns 3257184 +NativeFunctionPtr_callMethod::returnVoid 215 ns 215 ns 3264358 + +StdFunction_call::returnVoid 215 ns 215 ns 3266358 +StdFunction_callMethod::returnVoid 214 ns 214 ns 3275751 + +RtlFunction_call::returnVoid 215 ns 215 ns 3263733 +RtlFunction_callMethod::returnVoid 214 ns 214 ns 3280003 + +RtlFunction_call_ReturnUnknown::Void 214 ns 214 ns 3266284 +RtlFunction_callMethod_ReturnUnknown::Void 216 ns 216 ns 3227711 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 216 ns 215 ns 3264294 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 252 ns 252 ns 2775280 + +NativeFunctionPtr_call::returnNonVoid 250 ns 250 ns 2769552 +NativeFunctionPtr_callMethod::returnNonVoid 251 ns 251 ns 2763279 + +StdFunction_call::returnNonVoid 251 ns 251 ns 2820619 +StdFunction_callMethod::returnNonVoid 253 ns 253 ns 2766906 + +RtlFunction_call::returnNonVoid 251 ns 251 ns 2779699 +RtlFunction_callMethod::returnNonVoid 251 ns 251 ns 2801031 + +RtlFunction_call_ReturnUnknown::NonVoid 259 ns 259 ns 2700620 +RtlFunction_callMethod_ReturnUnknown::NonVoid 257 ns 257 ns 2712626 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 261 ns 261 ns 2685860 +----------------------------------- +[2025-10-09 22:23:55] >>> Run 2: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-10-09T22:23:55+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.96, 0.99 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 210 ns 210 ns 3328631 + +NativeFunctionPtr_call::returnVoid 209 ns 209 ns 3337881 +NativeFunctionPtr_callMethod::returnVoid 210 ns 210 ns 3358665 + +StdFunction_call::returnVoid 209 ns 209 ns 3334221 +StdFunction_callMethod::returnVoid 208 ns 208 ns 3358880 + +RtlFunction_call::returnVoid 209 ns 209 ns 3332189 +RtlFunction_callMethod::returnVoid 210 ns 210 ns 3341235 + +RtlFunction_call_ReturnUnknown::Void 211 ns 211 ns 3318858 +RtlFunction_callMethod_ReturnUnknown::Void 210 ns 210 ns 3315392 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 210 ns 210 ns 3345894 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 248 ns 248 ns 2811463 + +NativeFunctionPtr_call::returnNonVoid 248 ns 248 ns 2837510 +NativeFunctionPtr_callMethod::returnNonVoid 248 ns 248 ns 2823747 + +StdFunction_call::returnNonVoid 248 ns 248 ns 2829500 +StdFunction_callMethod::returnNonVoid 246 ns 246 ns 2846223 + +RtlFunction_call::returnNonVoid 249 ns 249 ns 2825214 +RtlFunction_callMethod::returnNonVoid 249 ns 249 ns 2838485 + +RtlFunction_call_ReturnUnknown::NonVoid 256 ns 256 ns 2743765 +RtlFunction_callMethod_ReturnUnknown::NonVoid 254 ns 254 ns 2754043 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 256 ns 256 ns 2746382 +----------------------------------- +[2025-10-09 22:24:14] >>> Run 3: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-10-09T22:24:14+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800.265 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.96, 0.99 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 207 ns 207 ns 3378932 + +NativeFunctionPtr_call::returnVoid 208 ns 208 ns 3354717 +NativeFunctionPtr_callMethod::returnVoid 208 ns 208 ns 3358316 + +StdFunction_call::returnVoid 208 ns 208 ns 3370362 +StdFunction_callMethod::returnVoid 208 ns 208 ns 3366749 + +RtlFunction_call::returnVoid 208 ns 208 ns 3392121 +RtlFunction_callMethod::returnVoid 209 ns 208 ns 3363052 + +RtlFunction_call_ReturnUnknown::Void 210 ns 210 ns 3340887 +RtlFunction_callMethod_ReturnUnknown::Void 209 ns 209 ns 3359366 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 210 ns 210 ns 3324467 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 246 ns 245 ns 2863116 + +NativeFunctionPtr_call::returnNonVoid 247 ns 247 ns 2854025 +NativeFunctionPtr_callMethod::returnNonVoid 245 ns 245 ns 2838441 + +StdFunction_call::returnNonVoid 225 ns 225 ns 3205357 +StdFunction_callMethod::returnNonVoid 246 ns 246 ns 2873877 + +RtlFunction_call::returnNonVoid 245 ns 245 ns 2834809 +RtlFunction_callMethod::returnNonVoid 246 ns 246 ns 2865471 + +RtlFunction_call_ReturnUnknown::NonVoid 254 ns 254 ns 2764367 +RtlFunction_callMethod_ReturnUnknown::NonVoid 253 ns 253 ns 2758970 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 254 ns 254 ns 2738846 +----------------------------------- +[2025-10-09 22:24:34] >>> Run 4: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-10-09T22:24:34+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4878.67 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.97, 0.99 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 189 ns 189 ns 3726055 + +NativeFunctionPtr_call::returnVoid 189 ns 189 ns 3727086 +NativeFunctionPtr_callMethod::returnVoid 188 ns 188 ns 3698951 + +StdFunction_call::returnVoid 188 ns 188 ns 3742233 +StdFunction_callMethod::returnVoid 190 ns 190 ns 3687148 + +RtlFunction_call::returnVoid 188 ns 188 ns 3712470 +RtlFunction_callMethod::returnVoid 189 ns 189 ns 3703809 + +RtlFunction_call_ReturnUnknown::Void 192 ns 192 ns 3651160 +RtlFunction_callMethod_ReturnUnknown::Void 191 ns 191 ns 3649884 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 191 ns 191 ns 3616240 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 219 ns 219 ns 3185509 + +NativeFunctionPtr_call::returnNonVoid 221 ns 221 ns 3198363 +NativeFunctionPtr_callMethod::returnNonVoid 222 ns 222 ns 3120890 + +StdFunction_call::returnNonVoid 218 ns 218 ns 3203607 +StdFunction_callMethod::returnNonVoid 223 ns 223 ns 3140770 + +RtlFunction_call::returnNonVoid 217 ns 217 ns 3176653 +RtlFunction_callMethod::returnNonVoid 220 ns 220 ns 3169054 + +RtlFunction_call_ReturnUnknown::NonVoid 226 ns 226 ns 3107784 +RtlFunction_callMethod_ReturnUnknown::NonVoid 226 ns 226 ns 3107618 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 233 ns 233 ns 2982875 +----------------------------------- +[2025-10-09 22:24:52] >>> Run 5: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-10-09T22:24:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.97, 0.99 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 187 ns 187 ns 3765076 + +NativeFunctionPtr_call::returnVoid 188 ns 188 ns 3749209 +NativeFunctionPtr_callMethod::returnVoid 187 ns 187 ns 3738778 + +StdFunction_call::returnVoid 187 ns 187 ns 3736466 +StdFunction_callMethod::returnVoid 187 ns 187 ns 3734846 + +RtlFunction_call::returnVoid 187 ns 187 ns 3743346 +RtlFunction_callMethod::returnVoid 188 ns 188 ns 3740283 + +RtlFunction_call_ReturnUnknown::Void 191 ns 191 ns 3682864 +RtlFunction_callMethod_ReturnUnknown::Void 189 ns 189 ns 3704235 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 190 ns 190 ns 3669759 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 215 ns 215 ns 3257739 + +NativeFunctionPtr_call::returnNonVoid 216 ns 216 ns 3252243 +NativeFunctionPtr_callMethod::returnNonVoid 217 ns 217 ns 3255339 + +StdFunction_call::returnNonVoid 217 ns 217 ns 3245694 +StdFunction_callMethod::returnNonVoid 216 ns 216 ns 3243823 + +RtlFunction_call::returnNonVoid 215 ns 215 ns 3248934 +RtlFunction_callMethod::returnNonVoid 217 ns 217 ns 3244121 + +RtlFunction_call_ReturnUnknown::NonVoid 224 ns 224 ns 3119429 +RtlFunction_callMethod_ReturnUnknown::NonVoid 224 ns 224 ns 3089270 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 224 ns 224 ns 3120259 +----------------------------------- +[2025-10-09 22:25:11] >>> Run 1: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-10-09T22:25:11+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.97, 0.99 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 273 ns 273 ns 2520910 + +NativeFunctionPtr_call::returnVoid 282 ns 282 ns 2569459 +NativeFunctionPtr_callMethod::returnVoid 304 ns 304 ns 2305232 + +StdFunction_call::returnVoid 305 ns 305 ns 2290417 +StdFunction_callMethod::returnVoid 302 ns 302 ns 2325541 + +RtlFunction_call::returnVoid 306 ns 306 ns 2300150 +RtlFunction_callMethod::returnVoid 304 ns 304 ns 2297397 + +RtlFunction_call_ReturnUnknown::Void 306 ns 306 ns 2296714 +RtlFunction_callMethod_ReturnUnknown::Void 303 ns 303 ns 2299905 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 308 ns 308 ns 2275076 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 362 ns 362 ns 1926616 + +NativeFunctionPtr_call::returnNonVoid 365 ns 364 ns 1919201 +NativeFunctionPtr_callMethod::returnNonVoid 365 ns 365 ns 1922395 + +StdFunction_call::returnNonVoid 365 ns 365 ns 1914669 +StdFunction_callMethod::returnNonVoid 358 ns 358 ns 1951810 + +RtlFunction_call::returnNonVoid 364 ns 364 ns 1914637 +RtlFunction_callMethod::returnNonVoid 364 ns 364 ns 1911739 + +RtlFunction_call_ReturnUnknown::NonVoid 367 ns 367 ns 1909904 +RtlFunction_callMethod_ReturnUnknown::NonVoid 365 ns 365 ns 1909608 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 372 ns 372 ns 1883925 +----------------------------------- +[2025-10-09 22:25:32] >>> Run 2: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-10-09T22:25:32+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4885.33 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.97, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 271 ns 271 ns 2569273 + +NativeFunctionPtr_call::returnVoid 279 ns 279 ns 2508346 +NativeFunctionPtr_callMethod::returnVoid 279 ns 279 ns 2495543 + +StdFunction_call::returnVoid 282 ns 282 ns 2512583 +StdFunction_callMethod::returnVoid 282 ns 282 ns 2497604 + +RtlFunction_call::returnVoid 280 ns 280 ns 2474996 +RtlFunction_callMethod::returnVoid 281 ns 281 ns 2501878 + +RtlFunction_call_ReturnUnknown::Void 277 ns 277 ns 2527419 +RtlFunction_callMethod_ReturnUnknown::Void 278 ns 278 ns 2513950 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 277 ns 276 ns 2557708 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 316 ns 316 ns 2227704 + +NativeFunctionPtr_call::returnNonVoid 331 ns 331 ns 2117397 +NativeFunctionPtr_callMethod::returnNonVoid 331 ns 331 ns 2122544 + +StdFunction_call::returnNonVoid 329 ns 329 ns 2115896 +StdFunction_callMethod::returnNonVoid 329 ns 329 ns 2138305 + +RtlFunction_call::returnNonVoid 330 ns 330 ns 2112556 +RtlFunction_callMethod::returnNonVoid 330 ns 330 ns 2130792 + +RtlFunction_call_ReturnUnknown::NonVoid 322 ns 322 ns 2187407 +RtlFunction_callMethod_ReturnUnknown::NonVoid 321 ns 321 ns 2176270 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 320 ns 320 ns 2157920 +----------------------------------- +[2025-10-09 22:25:53] >>> Run 3: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-10-09T22:25:53+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4853.88 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.98, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 303 ns 303 ns 2303932 + +NativeFunctionPtr_call::returnVoid 305 ns 305 ns 2311103 +NativeFunctionPtr_callMethod::returnVoid 304 ns 304 ns 2311627 + +StdFunction_call::returnVoid 303 ns 303 ns 2304338 +StdFunction_callMethod::returnVoid 304 ns 304 ns 2302618 + +RtlFunction_call::returnVoid 303 ns 303 ns 2280795 +RtlFunction_callMethod::returnVoid 304 ns 303 ns 2299138 + +RtlFunction_call_ReturnUnknown::Void 318 ns 318 ns 2199731 +RtlFunction_callMethod_ReturnUnknown::Void 313 ns 313 ns 2238511 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 318 ns 318 ns 2207818 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 361 ns 361 ns 1925454 + +NativeFunctionPtr_call::returnNonVoid 364 ns 364 ns 1914876 +NativeFunctionPtr_callMethod::returnNonVoid 364 ns 364 ns 1918846 + +StdFunction_call::returnNonVoid 364 ns 364 ns 1911425 +StdFunction_callMethod::returnNonVoid 364 ns 364 ns 1923711 + +RtlFunction_call::returnNonVoid 363 ns 363 ns 1926305 +RtlFunction_callMethod::returnNonVoid 364 ns 364 ns 1918944 + +RtlFunction_call_ReturnUnknown::NonVoid 371 ns 371 ns 1889184 +RtlFunction_callMethod_ReturnUnknown::NonVoid 374 ns 374 ns 1883084 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 371 ns 371 ns 1879894 +----------------------------------- +[2025-10-09 22:26:14] >>> Run 4: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-10-09T22:26:14+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.98, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 272 ns 272 ns 2540691 + +NativeFunctionPtr_call::returnVoid 274 ns 274 ns 2593245 +NativeFunctionPtr_callMethod::returnVoid 275 ns 275 ns 2556586 + +StdFunction_call::returnVoid 274 ns 274 ns 2558445 +StdFunction_callMethod::returnVoid 274 ns 274 ns 2543576 + +RtlFunction_call::returnVoid 275 ns 275 ns 2539357 +RtlFunction_callMethod::returnVoid 275 ns 275 ns 2561621 + +RtlFunction_call_ReturnUnknown::Void 281 ns 281 ns 2506532 +RtlFunction_callMethod_ReturnUnknown::Void 275 ns 275 ns 2503188 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 276 ns 276 ns 2546862 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 315 ns 315 ns 2203523 + +NativeFunctionPtr_call::returnNonVoid 317 ns 317 ns 2202686 +NativeFunctionPtr_callMethod::returnNonVoid 320 ns 320 ns 2189183 + +StdFunction_call::returnNonVoid 319 ns 319 ns 2209198 +StdFunction_callMethod::returnNonVoid 319 ns 319 ns 2219351 + +RtlFunction_call::returnNonVoid 317 ns 317 ns 2199084 +RtlFunction_callMethod::returnNonVoid 319 ns 319 ns 2214805 + +RtlFunction_call_ReturnUnknown::NonVoid 320 ns 320 ns 2177273 +RtlFunction_callMethod_ReturnUnknown::NonVoid 323 ns 323 ns 2161121 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 324 ns 324 ns 2142259 +----------------------------------- +[2025-10-09 22:26:35] >>> Run 5: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-10-09T22:26:35+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.98, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 269 ns 269 ns 2614274 + +NativeFunctionPtr_call::returnVoid 268 ns 268 ns 2604691 +NativeFunctionPtr_callMethod::returnVoid 269 ns 269 ns 2587066 + +StdFunction_call::returnVoid 269 ns 269 ns 2606229 +StdFunction_callMethod::returnVoid 270 ns 270 ns 2614556 + +RtlFunction_call::returnVoid 269 ns 269 ns 2617864 +RtlFunction_callMethod::returnVoid 269 ns 269 ns 2586264 + +RtlFunction_call_ReturnUnknown::Void 277 ns 277 ns 2535614 +RtlFunction_callMethod_ReturnUnknown::Void 276 ns 276 ns 2567940 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 284 ns 284 ns 2485045 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 314 ns 314 ns 2231644 + +NativeFunctionPtr_call::returnNonVoid 315 ns 315 ns 2226538 +NativeFunctionPtr_callMethod::returnNonVoid 315 ns 315 ns 2227936 + +StdFunction_call::returnNonVoid 313 ns 313 ns 2237189 +StdFunction_callMethod::returnNonVoid 316 ns 316 ns 2224588 + +RtlFunction_call::returnNonVoid 315 ns 315 ns 2223037 +RtlFunction_callMethod::returnNonVoid 314 ns 314 ns 2213917 + +RtlFunction_call_ReturnUnknown::NonVoid 339 ns 339 ns 2061326 +RtlFunction_callMethod_ReturnUnknown::NonVoid 324 ns 324 ns 2180645 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 339 ns 339 ns 2061094 +----------------------------------- +[2025-10-09 22:26:55] >>> Run 1: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-10-09T22:26:55+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.98, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 300 ns 300 ns 2338117 + +NativeFunctionPtr_call::returnVoid 298 ns 298 ns 2355296 +NativeFunctionPtr_callMethod::returnVoid 298 ns 298 ns 2320772 + +StdFunction_call::returnVoid 297 ns 297 ns 2362909 +StdFunction_callMethod::returnVoid 299 ns 299 ns 2355840 + +RtlFunction_call::returnVoid 297 ns 297 ns 2338452 +RtlFunction_callMethod::returnVoid 298 ns 298 ns 2343060 + +RtlFunction_call_ReturnUnknown::Void 306 ns 306 ns 2271939 +RtlFunction_callMethod_ReturnUnknown::Void 304 ns 304 ns 2318101 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 306 ns 306 ns 2305028 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 362 ns 362 ns 1947425 + +NativeFunctionPtr_call::returnNonVoid 361 ns 360 ns 1928345 +NativeFunctionPtr_callMethod::returnNonVoid 363 ns 363 ns 1913332 + +StdFunction_call::returnNonVoid 362 ns 362 ns 1944195 +StdFunction_callMethod::returnNonVoid 364 ns 364 ns 1935312 + +RtlFunction_call::returnNonVoid 363 ns 363 ns 1936550 +RtlFunction_callMethod::returnNonVoid 363 ns 363 ns 1924690 + +RtlFunction_call_ReturnUnknown::NonVoid 372 ns 372 ns 1863292 +RtlFunction_callMethod_ReturnUnknown::NonVoid 373 ns 373 ns 1854535 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 374 ns 373 ns 1862070 +----------------------------------- +[2025-10-09 22:27:17] >>> Run 2: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-10-09T22:27:17+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.19, 1.03, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 343 ns 343 ns 2061132 + +NativeFunctionPtr_call::returnVoid 337 ns 336 ns 2068643 +NativeFunctionPtr_callMethod::returnVoid 337 ns 337 ns 2052308 + +StdFunction_call::returnVoid 337 ns 337 ns 2083873 +StdFunction_callMethod::returnVoid 334 ns 334 ns 2106632 + +RtlFunction_call::returnVoid 300 ns 300 ns 2208447 +RtlFunction_callMethod::returnVoid 299 ns 299 ns 2329548 + +RtlFunction_call_ReturnUnknown::Void 305 ns 305 ns 2274547 +RtlFunction_callMethod_ReturnUnknown::Void 302 ns 302 ns 2306504 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 305 ns 305 ns 2297009 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 366 ns 366 ns 1912241 + +NativeFunctionPtr_call::returnNonVoid 364 ns 364 ns 1916331 +NativeFunctionPtr_callMethod::returnNonVoid 367 ns 367 ns 1913166 + +StdFunction_call::returnNonVoid 366 ns 366 ns 1922189 +StdFunction_callMethod::returnNonVoid 362 ns 362 ns 1933790 + +RtlFunction_call::returnNonVoid 366 ns 366 ns 1924279 +RtlFunction_callMethod::returnNonVoid 365 ns 365 ns 1924374 + +RtlFunction_call_ReturnUnknown::NonVoid 373 ns 373 ns 1882074 +RtlFunction_callMethod_ReturnUnknown::NonVoid 373 ns 373 ns 1883708 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 375 ns 375 ns 1872075 +----------------------------------- +[2025-10-09 22:27:39] >>> Run 3: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-10-09T22:27:39+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.13, 1.03, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 298 ns 298 ns 2324259 + +NativeFunctionPtr_call::returnVoid 302 ns 302 ns 2318675 +NativeFunctionPtr_callMethod::returnVoid 299 ns 299 ns 2346754 + +StdFunction_call::returnVoid 299 ns 299 ns 2336837 +StdFunction_callMethod::returnVoid 300 ns 300 ns 2347785 + +RtlFunction_call::returnVoid 301 ns 301 ns 2346448 +RtlFunction_callMethod::returnVoid 300 ns 300 ns 2342174 + +RtlFunction_call_ReturnUnknown::Void 310 ns 310 ns 2256901 +RtlFunction_callMethod_ReturnUnknown::Void 312 ns 312 ns 2277142 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 311 ns 311 ns 2222204 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 361 ns 361 ns 1917143 + +NativeFunctionPtr_call::returnNonVoid 364 ns 364 ns 1907259 +NativeFunctionPtr_callMethod::returnNonVoid 365 ns 365 ns 1912708 + +StdFunction_call::returnNonVoid 366 ns 366 ns 1937138 +StdFunction_callMethod::returnNonVoid 367 ns 367 ns 1919569 + +RtlFunction_call::returnNonVoid 369 ns 369 ns 1874180 +RtlFunction_callMethod::returnNonVoid 362 ns 362 ns 1915226 + +RtlFunction_call_ReturnUnknown::NonVoid 372 ns 372 ns 1891945 +RtlFunction_callMethod_ReturnUnknown::NonVoid 373 ns 373 ns 1876384 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 372 ns 372 ns 1887359 +----------------------------------- +[2025-10-09 22:28:00] >>> Run 4: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-10-09T22:28:00+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.09, 1.03, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 296 ns 296 ns 2350217 + +NativeFunctionPtr_call::returnVoid 296 ns 296 ns 2340079 +NativeFunctionPtr_callMethod::returnVoid 296 ns 296 ns 2357817 + +StdFunction_call::returnVoid 298 ns 298 ns 2371125 +StdFunction_callMethod::returnVoid 298 ns 298 ns 2344992 + +RtlFunction_call::returnVoid 296 ns 296 ns 2353660 +RtlFunction_callMethod::returnVoid 297 ns 297 ns 2337540 + +RtlFunction_call_ReturnUnknown::Void 303 ns 303 ns 2319549 +RtlFunction_callMethod_ReturnUnknown::Void 301 ns 301 ns 2323886 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 304 ns 304 ns 2332608 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 362 ns 361 ns 1946177 + +NativeFunctionPtr_call::returnNonVoid 363 ns 363 ns 1947334 +NativeFunctionPtr_callMethod::returnNonVoid 362 ns 362 ns 1924561 + +StdFunction_call::returnNonVoid 359 ns 359 ns 1941891 +StdFunction_callMethod::returnNonVoid 362 ns 362 ns 1935593 + +RtlFunction_call::returnNonVoid 360 ns 359 ns 1930723 +RtlFunction_callMethod::returnNonVoid 361 ns 361 ns 1948673 + +RtlFunction_call_ReturnUnknown::NonVoid 372 ns 372 ns 1893811 +RtlFunction_callMethod_ReturnUnknown::NonVoid 371 ns 371 ns 1880068 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 372 ns 372 ns 1894361 +----------------------------------- +[2025-10-09 22:28:21] >>> Run 5: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-10-09T22:28:21+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.07, 1.02, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 304 ns 304 ns 2320564 + +NativeFunctionPtr_call::returnVoid 305 ns 305 ns 2314315 +NativeFunctionPtr_callMethod::returnVoid 308 ns 308 ns 2306194 + +StdFunction_call::returnVoid 306 ns 306 ns 2268882 +StdFunction_callMethod::returnVoid 303 ns 303 ns 2330974 + +RtlFunction_call::returnVoid 305 ns 305 ns 2291288 +RtlFunction_callMethod::returnVoid 304 ns 304 ns 2296612 + +RtlFunction_call_ReturnUnknown::Void 310 ns 310 ns 2255425 +RtlFunction_callMethod_ReturnUnknown::Void 307 ns 307 ns 2273163 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 310 ns 310 ns 2271135 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 367 ns 367 ns 1904923 + +NativeFunctionPtr_call::returnNonVoid 372 ns 372 ns 1907990 +NativeFunctionPtr_callMethod::returnNonVoid 372 ns 372 ns 1898216 + +StdFunction_call::returnNonVoid 370 ns 370 ns 1878913 +StdFunction_callMethod::returnNonVoid 370 ns 370 ns 1895647 + +RtlFunction_call::returnNonVoid 369 ns 369 ns 1891638 +RtlFunction_callMethod::returnNonVoid 372 ns 372 ns 1901882 + +RtlFunction_call_ReturnUnknown::NonVoid 378 ns 378 ns 1859020 +RtlFunction_callMethod_ReturnUnknown::NonVoid 376 ns 376 ns 1865751 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 379 ns 379 ns 1848271 +----------------------------------- +[2025-10-09 22:28:43] >>> Run 1: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-10-09T22:28:43+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.02, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 375 ns 375 ns 1862003 + +NativeFunctionPtr_call::returnVoid 375 ns 375 ns 1858998 +NativeFunctionPtr_callMethod::returnVoid 377 ns 377 ns 1863926 + +StdFunction_call::returnVoid 375 ns 375 ns 1854774 +StdFunction_callMethod::returnVoid 378 ns 378 ns 1858140 + +RtlFunction_call::returnVoid 376 ns 376 ns 1861100 +RtlFunction_callMethod::returnVoid 376 ns 376 ns 1861280 + +RtlFunction_call_ReturnUnknown::Void 377 ns 377 ns 1848987 +RtlFunction_callMethod_ReturnUnknown::Void 378 ns 378 ns 1856361 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 380 ns 380 ns 1839194 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 444 ns 444 ns 1583671 + +NativeFunctionPtr_call::returnNonVoid 440 ns 440 ns 1589570 +NativeFunctionPtr_callMethod::returnNonVoid 440 ns 440 ns 1588032 + +StdFunction_call::returnNonVoid 441 ns 441 ns 1590750 +StdFunction_callMethod::returnNonVoid 442 ns 442 ns 1589307 + +RtlFunction_call::returnNonVoid 441 ns 441 ns 1589175 +RtlFunction_callMethod::returnNonVoid 444 ns 444 ns 1586771 + +RtlFunction_call_ReturnUnknown::NonVoid 493 ns 493 ns 1363464 +RtlFunction_callMethod_ReturnUnknown::NonVoid 455 ns 455 ns 1539028 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 457 ns 457 ns 1531875 +----------------------------------- +[2025-10-09 22:29:06] >>> Run 2: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-10-09T22:29:06+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 394 ns 394 ns 1780206 + +NativeFunctionPtr_call::returnVoid 394 ns 394 ns 1770515 +NativeFunctionPtr_callMethod::returnVoid 395 ns 395 ns 1774757 + +StdFunction_call::returnVoid 393 ns 393 ns 1774702 +StdFunction_callMethod::returnVoid 392 ns 392 ns 1790215 + +RtlFunction_call::returnVoid 395 ns 395 ns 1777944 +RtlFunction_callMethod::returnVoid 396 ns 396 ns 1767421 + +RtlFunction_call_ReturnUnknown::Void 395 ns 395 ns 1768723 +RtlFunction_callMethod_ReturnUnknown::Void 395 ns 395 ns 1766669 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 381 ns 380 ns 1769593 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 421 ns 421 ns 1660930 + +NativeFunctionPtr_call::returnNonVoid 420 ns 420 ns 1668362 +NativeFunctionPtr_callMethod::returnNonVoid 421 ns 421 ns 1665328 + +StdFunction_call::returnNonVoid 418 ns 418 ns 1669473 +StdFunction_callMethod::returnNonVoid 420 ns 420 ns 1673333 + +RtlFunction_call::returnNonVoid 422 ns 422 ns 1661673 +RtlFunction_callMethod::returnNonVoid 421 ns 421 ns 1657094 + +RtlFunction_call_ReturnUnknown::NonVoid 426 ns 426 ns 1643063 +RtlFunction_callMethod_ReturnUnknown::NonVoid 427 ns 427 ns 1646820 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 429 ns 429 ns 1626103 +----------------------------------- +[2025-10-09 22:29:29] >>> Run 3: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-10-09T22:29:29+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 393 ns 393 ns 1776209 + +NativeFunctionPtr_call::returnVoid 393 ns 393 ns 1780927 +NativeFunctionPtr_callMethod::returnVoid 395 ns 395 ns 1773879 + +StdFunction_call::returnVoid 395 ns 395 ns 1778780 +StdFunction_callMethod::returnVoid 393 ns 393 ns 1782892 + +RtlFunction_call::returnVoid 394 ns 394 ns 1775635 +RtlFunction_callMethod::returnVoid 395 ns 395 ns 1765210 + +RtlFunction_call_ReturnUnknown::Void 396 ns 396 ns 1761114 +RtlFunction_callMethod_ReturnUnknown::Void 395 ns 395 ns 1768030 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 397 ns 397 ns 1758820 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 469 ns 469 ns 1487199 + +NativeFunctionPtr_call::returnNonVoid 471 ns 470 ns 1487718 +NativeFunctionPtr_callMethod::returnNonVoid 472 ns 472 ns 1485276 + +StdFunction_call::returnNonVoid 469 ns 469 ns 1495580 +StdFunction_callMethod::returnNonVoid 480 ns 480 ns 1476257 + +RtlFunction_call::returnNonVoid 473 ns 473 ns 1484166 +RtlFunction_callMethod::returnNonVoid 472 ns 472 ns 1477993 + +RtlFunction_call_ReturnUnknown::NonVoid 478 ns 478 ns 1464224 +RtlFunction_callMethod_ReturnUnknown::NonVoid 478 ns 478 ns 1460289 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 478 ns 478 ns 1460410 +----------------------------------- +[2025-10-09 22:29:52] >>> Run 4: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-10-09T22:29:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 361 ns 361 ns 1940795 + +NativeFunctionPtr_call::returnVoid 361 ns 361 ns 1930440 +NativeFunctionPtr_callMethod::returnVoid 361 ns 361 ns 1955461 + +StdFunction_call::returnVoid 359 ns 359 ns 1927669 +StdFunction_callMethod::returnVoid 362 ns 362 ns 1933320 + +RtlFunction_call::returnVoid 360 ns 360 ns 1937323 +RtlFunction_callMethod::returnVoid 371 ns 371 ns 1933598 + +RtlFunction_call_ReturnUnknown::Void 405 ns 404 ns 1693301 +RtlFunction_callMethod_ReturnUnknown::Void 403 ns 403 ns 1736508 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 410 ns 410 ns 1702735 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 471 ns 471 ns 1479714 + +NativeFunctionPtr_call::returnNonVoid 474 ns 474 ns 1478273 +NativeFunctionPtr_callMethod::returnNonVoid 478 ns 478 ns 1468965 + +StdFunction_call::returnNonVoid 475 ns 475 ns 1467770 +StdFunction_callMethod::returnNonVoid 475 ns 475 ns 1470489 + +RtlFunction_call::returnNonVoid 475 ns 475 ns 1470438 +RtlFunction_callMethod::returnNonVoid 481 ns 481 ns 1456197 + +RtlFunction_call_ReturnUnknown::NonVoid 487 ns 487 ns 1435053 +RtlFunction_callMethod_ReturnUnknown::NonVoid 484 ns 484 ns 1438840 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 496 ns 496 ns 1392810 +----------------------------------- +[2025-10-09 22:30:15] >>> Run 5: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-10-09T22:30:15+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 360 ns 360 ns 1941073 + +NativeFunctionPtr_call::returnVoid 362 ns 362 ns 1934866 +NativeFunctionPtr_callMethod::returnVoid 362 ns 362 ns 1929133 + +StdFunction_call::returnVoid 363 ns 363 ns 1938397 +StdFunction_callMethod::returnVoid 362 ns 362 ns 1919071 + +RtlFunction_call::returnVoid 362 ns 362 ns 1941842 +RtlFunction_callMethod::returnVoid 363 ns 363 ns 1916383 + +RtlFunction_call_ReturnUnknown::Void 365 ns 365 ns 1907408 +RtlFunction_callMethod_ReturnUnknown::Void 363 ns 363 ns 1923142 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 365 ns 365 ns 1932398 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 429 ns 429 ns 1635609 + +NativeFunctionPtr_call::returnNonVoid 431 ns 431 ns 1633937 +NativeFunctionPtr_callMethod::returnNonVoid 421 ns 421 ns 1663536 + +StdFunction_call::returnNonVoid 430 ns 430 ns 1635257 +StdFunction_callMethod::returnNonVoid 420 ns 420 ns 1666612 + +RtlFunction_call::returnNonVoid 430 ns 430 ns 1628640 +RtlFunction_callMethod::returnNonVoid 420 ns 420 ns 1659967 + +RtlFunction_call_ReturnUnknown::NonVoid 443 ns 443 ns 1577000 +RtlFunction_callMethod_ReturnUnknown::NonVoid 429 ns 429 ns 1631922 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 432 ns 432 ns 1626032 +----------------------------------- +[2025-10-09 22:30:38] >>> Run 1: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-10-09T22:30:38+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 683 ns 683 ns 1024747 + +NativeFunctionPtr_call::returnVoid 681 ns 681 ns 1031950 +NativeFunctionPtr_callMethod::returnVoid 682 ns 682 ns 1021311 + +StdFunction_call::returnVoid 681 ns 681 ns 1025739 +StdFunction_callMethod::returnVoid 685 ns 685 ns 1024940 + +RtlFunction_call::returnVoid 671 ns 671 ns 1047757 +RtlFunction_callMethod::returnVoid 673 ns 673 ns 1042146 + +RtlFunction_call_ReturnUnknown::Void 685 ns 685 ns 1002530 +RtlFunction_callMethod_ReturnUnknown::Void 683 ns 683 ns 1025495 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 684 ns 684 ns 1028604 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 779 ns 779 ns 902122 + +NativeFunctionPtr_call::returnNonVoid 810 ns 810 ns 900341 +NativeFunctionPtr_callMethod::returnNonVoid 803 ns 803 ns 835135 + +StdFunction_call::returnNonVoid 776 ns 776 ns 900075 +StdFunction_callMethod::returnNonVoid 780 ns 779 ns 901231 + +RtlFunction_call::returnNonVoid 779 ns 779 ns 900202 +RtlFunction_callMethod::returnNonVoid 777 ns 777 ns 901870 + +RtlFunction_call_ReturnUnknown::NonVoid 797 ns 797 ns 879234 +RtlFunction_callMethod_ReturnUnknown::NonVoid 799 ns 799 ns 879126 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 798 ns 798 ns 877726 +----------------------------------- +[2025-10-09 22:30:54] >>> Run 2: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-10-09T22:30:54+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.34, 1.09, 1.03 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 690 ns 690 ns 1010752 + +NativeFunctionPtr_call::returnVoid 686 ns 686 ns 1016034 +NativeFunctionPtr_callMethod::returnVoid 685 ns 685 ns 1012362 + +StdFunction_call::returnVoid 687 ns 687 ns 1015099 +StdFunction_callMethod::returnVoid 688 ns 688 ns 1022024 + +RtlFunction_call::returnVoid 688 ns 688 ns 1019452 +RtlFunction_callMethod::returnVoid 685 ns 685 ns 1025522 + +RtlFunction_call_ReturnUnknown::Void 696 ns 696 ns 999232 +RtlFunction_callMethod_ReturnUnknown::Void 691 ns 691 ns 1015509 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 693 ns 693 ns 1012501 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 785 ns 785 ns 893087 + +NativeFunctionPtr_call::returnNonVoid 779 ns 779 ns 897872 +NativeFunctionPtr_callMethod::returnNonVoid 776 ns 776 ns 900682 + +StdFunction_call::returnNonVoid 777 ns 777 ns 900615 +StdFunction_callMethod::returnNonVoid 775 ns 775 ns 904093 + +RtlFunction_call::returnNonVoid 775 ns 775 ns 900935 +RtlFunction_callMethod::returnNonVoid 775 ns 775 ns 901345 + +RtlFunction_call_ReturnUnknown::NonVoid 789 ns 789 ns 886938 +RtlFunction_callMethod_ReturnUnknown::NonVoid 799 ns 799 ns 878579 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 800 ns 800 ns 874472 +----------------------------------- +[2025-10-09 22:31:09] >>> Run 3: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-10-09T22:31:09+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.27, 1.08, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 717 ns 717 ns 984558 + +NativeFunctionPtr_call::returnVoid 718 ns 718 ns 972954 +NativeFunctionPtr_callMethod::returnVoid 716 ns 716 ns 979919 + +StdFunction_call::returnVoid 718 ns 718 ns 960825 +StdFunction_callMethod::returnVoid 721 ns 721 ns 974166 + +RtlFunction_call::returnVoid 719 ns 719 ns 977272 +RtlFunction_callMethod::returnVoid 717 ns 717 ns 975161 + +RtlFunction_call_ReturnUnknown::Void 729 ns 729 ns 963392 +RtlFunction_callMethod_ReturnUnknown::Void 723 ns 723 ns 965541 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 710 ns 709 ns 984115 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 805 ns 805 ns 867056 + +NativeFunctionPtr_call::returnNonVoid 803 ns 803 ns 870656 +NativeFunctionPtr_callMethod::returnNonVoid 805 ns 805 ns 871527 + +StdFunction_call::returnNonVoid 807 ns 807 ns 869225 +StdFunction_callMethod::returnNonVoid 794 ns 793 ns 879346 + +RtlFunction_call::returnNonVoid 804 ns 804 ns 869666 +RtlFunction_callMethod::returnNonVoid 804 ns 804 ns 870562 + +RtlFunction_call_ReturnUnknown::NonVoid 813 ns 813 ns 860837 +RtlFunction_callMethod_ReturnUnknown::NonVoid 818 ns 818 ns 853952 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 820 ns 820 ns 855449 +----------------------------------- +[2025-10-09 22:31:25] >>> Run 4: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-10-09T22:31:25+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.21, 1.08, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 677 ns 677 ns 1030590 + +NativeFunctionPtr_call::returnVoid 680 ns 680 ns 1012390 +NativeFunctionPtr_callMethod::returnVoid 679 ns 679 ns 1028254 + +StdFunction_call::returnVoid 681 ns 681 ns 1028605 +StdFunction_callMethod::returnVoid 683 ns 683 ns 1021847 + +RtlFunction_call::returnVoid 680 ns 680 ns 1025142 +RtlFunction_callMethod::returnVoid 679 ns 679 ns 1027089 + +RtlFunction_call_ReturnUnknown::Void 694 ns 694 ns 1005031 +RtlFunction_callMethod_ReturnUnknown::Void 690 ns 690 ns 1015221 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 690 ns 690 ns 1016998 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 772 ns 772 ns 907121 + +NativeFunctionPtr_call::returnNonVoid 773 ns 773 ns 907194 +NativeFunctionPtr_callMethod::returnNonVoid 771 ns 771 ns 904318 + +StdFunction_call::returnNonVoid 774 ns 774 ns 904984 +StdFunction_callMethod::returnNonVoid 775 ns 775 ns 892394 + +RtlFunction_call::returnNonVoid 771 ns 771 ns 907135 +RtlFunction_callMethod::returnNonVoid 771 ns 771 ns 909602 + +RtlFunction_call_ReturnUnknown::NonVoid 792 ns 792 ns 885728 +RtlFunction_callMethod_ReturnUnknown::NonVoid 801 ns 801 ns 876551 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 803 ns 803 ns 871792 +----------------------------------- +[2025-10-09 22:31:41] >>> Run 5: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-10-09T22:31:41+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.16, 1.08, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 678 ns 678 ns 1030229 + +NativeFunctionPtr_call::returnVoid 682 ns 682 ns 1028955 +NativeFunctionPtr_callMethod::returnVoid 680 ns 680 ns 1024874 + +StdFunction_call::returnVoid 680 ns 680 ns 1035697 +StdFunction_callMethod::returnVoid 682 ns 682 ns 1027575 + +RtlFunction_call::returnVoid 679 ns 679 ns 1034510 +RtlFunction_callMethod::returnVoid 682 ns 682 ns 1025157 + +RtlFunction_call_ReturnUnknown::Void 691 ns 691 ns 1017271 +RtlFunction_callMethod_ReturnUnknown::Void 689 ns 689 ns 1014372 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 687 ns 687 ns 1018986 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 780 ns 780 ns 893173 + +NativeFunctionPtr_call::returnNonVoid 781 ns 781 ns 895297 +NativeFunctionPtr_callMethod::returnNonVoid 780 ns 780 ns 885395 + +StdFunction_call::returnNonVoid 780 ns 780 ns 895356 +StdFunction_callMethod::returnNonVoid 786 ns 786 ns 891045 + +RtlFunction_call::returnNonVoid 782 ns 781 ns 895682 +RtlFunction_callMethod::returnNonVoid 780 ns 780 ns 898162 + +RtlFunction_call_ReturnUnknown::NonVoid 796 ns 796 ns 880495 +RtlFunction_callMethod_ReturnUnknown::NonVoid 802 ns 802 ns 870804 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 805 ns 805 ns 869103 +----------------------------------- +[2025-10-09 22:31:56] >>> Run 1: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-10-09T22:31:56+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.12, 1.07, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 756 ns 756 ns 926102 + +NativeFunctionPtr_call::returnVoid 761 ns 761 ns 918536 +NativeFunctionPtr_callMethod::returnVoid 762 ns 762 ns 921185 + +StdFunction_call::returnVoid 758 ns 758 ns 923567 +StdFunction_callMethod::returnVoid 758 ns 758 ns 925007 + +RtlFunction_call::returnVoid 760 ns 760 ns 923296 +RtlFunction_callMethod::returnVoid 761 ns 761 ns 917046 + +RtlFunction_call_ReturnUnknown::Void 770 ns 770 ns 909624 +RtlFunction_callMethod_ReturnUnknown::Void 779 ns 778 ns 896321 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 778 ns 778 ns 898624 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 866 ns 866 ns 799845 + +NativeFunctionPtr_call::returnNonVoid 870 ns 870 ns 804887 +NativeFunctionPtr_callMethod::returnNonVoid 874 ns 874 ns 802180 + +StdFunction_call::returnNonVoid 868 ns 868 ns 805459 +StdFunction_callMethod::returnNonVoid 864 ns 864 ns 807214 + +RtlFunction_call::returnNonVoid 871 ns 871 ns 798744 +RtlFunction_callMethod::returnNonVoid 870 ns 870 ns 804203 + +RtlFunction_call_ReturnUnknown::NonVoid 886 ns 886 ns 792012 +RtlFunction_callMethod_ReturnUnknown::NonVoid 888 ns 888 ns 787808 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 895 ns 895 ns 780923 +----------------------------------- +[2025-10-09 22:32:12] >>> Run 2: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-10-09T22:32:12+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.09, 1.07, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 767 ns 767 ns 911387 + +NativeFunctionPtr_call::returnVoid 769 ns 769 ns 907143 +NativeFunctionPtr_callMethod::returnVoid 771 ns 771 ns 912114 + +StdFunction_call::returnVoid 768 ns 767 ns 907714 +StdFunction_callMethod::returnVoid 773 ns 773 ns 904032 + +RtlFunction_call::returnVoid 771 ns 771 ns 907825 +RtlFunction_callMethod::returnVoid 770 ns 770 ns 910243 + +RtlFunction_call_ReturnUnknown::Void 776 ns 776 ns 905365 +RtlFunction_callMethod_ReturnUnknown::Void 783 ns 783 ns 891957 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 783 ns 783 ns 894958 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 898 ns 898 ns 783301 + +NativeFunctionPtr_call::returnNonVoid 898 ns 898 ns 780964 +NativeFunctionPtr_callMethod::returnNonVoid 900 ns 900 ns 782415 + +StdFunction_call::returnNonVoid 899 ns 899 ns 774099 +StdFunction_callMethod::returnNonVoid 904 ns 904 ns 776048 + +RtlFunction_call::returnNonVoid 900 ns 900 ns 775668 +RtlFunction_callMethod::returnNonVoid 900 ns 900 ns 781529 + +RtlFunction_call_ReturnUnknown::NonVoid 920 ns 920 ns 762014 +RtlFunction_callMethod_ReturnUnknown::NonVoid 918 ns 918 ns 762473 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 918 ns 918 ns 761633 +----------------------------------- +[2025-10-09 22:32:28] >>> Run 3: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-10-09T22:32:28+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.07, 1.06, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 774 ns 774 ns 904501 + +NativeFunctionPtr_call::returnVoid 782 ns 782 ns 893850 +NativeFunctionPtr_callMethod::returnVoid 782 ns 782 ns 897541 + +StdFunction_call::returnVoid 782 ns 782 ns 884219 +StdFunction_callMethod::returnVoid 771 ns 771 ns 905848 + +RtlFunction_call::returnVoid 783 ns 783 ns 897668 +RtlFunction_callMethod::returnVoid 781 ns 781 ns 895090 + +RtlFunction_call_ReturnUnknown::Void 780 ns 780 ns 898020 +RtlFunction_callMethod_ReturnUnknown::Void 785 ns 785 ns 895232 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 790 ns 790 ns 886672 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 902 ns 902 ns 777862 + +NativeFunctionPtr_call::returnNonVoid 906 ns 906 ns 771483 +NativeFunctionPtr_callMethod::returnNonVoid 909 ns 908 ns 770677 + +StdFunction_call::returnNonVoid 910 ns 910 ns 771651 +StdFunction_callMethod::returnNonVoid 896 ns 896 ns 781756 + +RtlFunction_call::returnNonVoid 907 ns 907 ns 772768 +RtlFunction_callMethod::returnNonVoid 905 ns 905 ns 765665 + +RtlFunction_call_ReturnUnknown::NonVoid 911 ns 911 ns 766856 +RtlFunction_callMethod_ReturnUnknown::NonVoid 919 ns 919 ns 765357 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 916 ns 916 ns 764862 +----------------------------------- +[2025-10-09 22:32:44] >>> Run 4: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-10-09T22:32:44+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.05, 1.06, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 759 ns 759 ns 923624 + +NativeFunctionPtr_call::returnVoid 760 ns 760 ns 921711 +NativeFunctionPtr_callMethod::returnVoid 761 ns 761 ns 917719 + +StdFunction_call::returnVoid 756 ns 755 ns 920127 +StdFunction_callMethod::returnVoid 760 ns 760 ns 924480 + +RtlFunction_call::returnVoid 760 ns 760 ns 921583 +RtlFunction_callMethod::returnVoid 762 ns 762 ns 917381 + +RtlFunction_call_ReturnUnknown::Void 771 ns 771 ns 904689 +RtlFunction_callMethod_ReturnUnknown::Void 769 ns 769 ns 910101 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 770 ns 770 ns 909102 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 868 ns 868 ns 807221 + +NativeFunctionPtr_call::returnNonVoid 868 ns 868 ns 805695 +NativeFunctionPtr_callMethod::returnNonVoid 868 ns 867 ns 803711 + +StdFunction_call::returnNonVoid 866 ns 866 ns 806829 +StdFunction_callMethod::returnNonVoid 869 ns 869 ns 803810 + +RtlFunction_call::returnNonVoid 867 ns 867 ns 804933 +RtlFunction_callMethod::returnNonVoid 868 ns 867 ns 805070 + +RtlFunction_call_ReturnUnknown::NonVoid 885 ns 885 ns 789841 +RtlFunction_callMethod_ReturnUnknown::NonVoid 885 ns 885 ns 790502 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 883 ns 883 ns 793804 +----------------------------------- +[2025-10-09 22:33:00] >>> Run 5: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-10-09T22:33:00+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.05, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 754 ns 754 ns 927477 + +NativeFunctionPtr_call::returnVoid 755 ns 755 ns 930677 +NativeFunctionPtr_callMethod::returnVoid 755 ns 755 ns 929205 + +StdFunction_call::returnVoid 750 ns 750 ns 931061 +StdFunction_callMethod::returnVoid 756 ns 756 ns 925171 + +RtlFunction_call::returnVoid 753 ns 753 ns 930525 +RtlFunction_callMethod::returnVoid 755 ns 755 ns 925200 + +RtlFunction_call_ReturnUnknown::Void 766 ns 766 ns 913707 +RtlFunction_callMethod_ReturnUnknown::Void 763 ns 763 ns 913366 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 771 ns 771 ns 910654 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 860 ns 860 ns 814438 + +NativeFunctionPtr_call::returnNonVoid 860 ns 860 ns 817263 +NativeFunctionPtr_callMethod::returnNonVoid 859 ns 859 ns 814168 + +StdFunction_call::returnNonVoid 859 ns 859 ns 814257 +StdFunction_callMethod::returnNonVoid 858 ns 858 ns 813961 + +RtlFunction_call::returnNonVoid 859 ns 859 ns 813742 +RtlFunction_callMethod::returnNonVoid 859 ns 859 ns 818402 + +RtlFunction_call_ReturnUnknown::NonVoid 886 ns 886 ns 787918 +RtlFunction_callMethod_ReturnUnknown::NonVoid 887 ns 887 ns 790058 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 888 ns 888 ns 785851 +----------------------------------- +[2025-10-09 22:33:16] >>> Run 1: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-10-09T22:33:16+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 1.05, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 866 ns 866 ns 809157 + +NativeFunctionPtr_call::returnVoid 869 ns 869 ns 804129 +NativeFunctionPtr_callMethod::returnVoid 868 ns 868 ns 808091 + +StdFunction_call::returnVoid 869 ns 869 ns 804521 +StdFunction_callMethod::returnVoid 867 ns 867 ns 805994 + +RtlFunction_call::returnVoid 868 ns 868 ns 806034 +RtlFunction_callMethod::returnVoid 869 ns 869 ns 805939 + +RtlFunction_call_ReturnUnknown::Void 866 ns 866 ns 808584 +RtlFunction_callMethod_ReturnUnknown::Void 871 ns 871 ns 802708 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 877 ns 877 ns 800314 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1012 ns 1012 ns 693687 + +NativeFunctionPtr_call::returnNonVoid 1014 ns 1014 ns 691382 +NativeFunctionPtr_callMethod::returnNonVoid 1011 ns 1011 ns 692979 + +StdFunction_call::returnNonVoid 1013 ns 1013 ns 690350 +StdFunction_callMethod::returnNonVoid 1012 ns 1012 ns 691672 + +RtlFunction_call::returnNonVoid 1014 ns 1014 ns 691463 +RtlFunction_callMethod::returnNonVoid 1011 ns 1011 ns 694030 + +RtlFunction_call_ReturnUnknown::NonVoid 1027 ns 1027 ns 682217 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1029 ns 1029 ns 679886 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1036 ns 1036 ns 675673 +----------------------------------- +[2025-10-09 22:33:32] >>> Run 2: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-10-09T22:33:32+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.05, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 828 ns 828 ns 844001 + +NativeFunctionPtr_call::returnVoid 834 ns 834 ns 840215 +NativeFunctionPtr_callMethod::returnVoid 834 ns 834 ns 837732 + +StdFunction_call::returnVoid 835 ns 835 ns 838406 +StdFunction_callMethod::returnVoid 832 ns 832 ns 842586 + +RtlFunction_call::returnVoid 833 ns 833 ns 840219 +RtlFunction_callMethod::returnVoid 835 ns 834 ns 839874 + +RtlFunction_call_ReturnUnknown::Void 834 ns 834 ns 837088 +RtlFunction_callMethod_ReturnUnknown::Void 834 ns 834 ns 836092 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 852 ns 852 ns 820915 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 990 ns 990 ns 706808 + +NativeFunctionPtr_call::returnNonVoid 992 ns 992 ns 706543 +NativeFunctionPtr_callMethod::returnNonVoid 991 ns 991 ns 706313 + +StdFunction_call::returnNonVoid 991 ns 991 ns 705794 +StdFunction_callMethod::returnNonVoid 995 ns 995 ns 703058 + +RtlFunction_call::returnNonVoid 992 ns 992 ns 705367 +RtlFunction_callMethod::returnNonVoid 992 ns 991 ns 705893 + +RtlFunction_call_ReturnUnknown::NonVoid 1013 ns 1013 ns 690644 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1014 ns 1014 ns 689561 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1017 ns 1017 ns 688660 +----------------------------------- +[2025-10-09 22:33:48] >>> Run 3: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-10-09T22:33:48+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.04, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 834 ns 834 ns 837333 + +NativeFunctionPtr_call::returnVoid 840 ns 840 ns 836001 +NativeFunctionPtr_callMethod::returnVoid 836 ns 836 ns 836723 + +StdFunction_call::returnVoid 836 ns 836 ns 837552 +StdFunction_callMethod::returnVoid 844 ns 844 ns 828047 + +RtlFunction_call::returnVoid 837 ns 837 ns 836533 +RtlFunction_callMethod::returnVoid 837 ns 837 ns 835148 + +RtlFunction_call_ReturnUnknown::Void 840 ns 840 ns 832909 +RtlFunction_callMethod_ReturnUnknown::Void 850 ns 850 ns 821781 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 861 ns 861 ns 812181 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 992 ns 992 ns 706173 + +NativeFunctionPtr_call::returnNonVoid 998 ns 998 ns 702016 +NativeFunctionPtr_callMethod::returnNonVoid 998 ns 998 ns 702496 + +StdFunction_call::returnNonVoid 998 ns 998 ns 702002 +StdFunction_callMethod::returnNonVoid 999 ns 999 ns 702186 + +RtlFunction_call::returnNonVoid 998 ns 998 ns 701652 +RtlFunction_callMethod::returnNonVoid 999 ns 999 ns 701933 + +RtlFunction_call_ReturnUnknown::NonVoid 1022 ns 1022 ns 683428 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1015 ns 1015 ns 689908 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1023 ns 1023 ns 684003 +----------------------------------- +[2025-10-09 22:34:04] >>> Run 4: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-10-09T22:34:04+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.04, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 860 ns 860 ns 811771 + +NativeFunctionPtr_call::returnVoid 861 ns 861 ns 811896 +NativeFunctionPtr_callMethod::returnVoid 862 ns 862 ns 809499 + +StdFunction_call::returnVoid 863 ns 863 ns 810522 +StdFunction_callMethod::returnVoid 870 ns 869 ns 804066 + +RtlFunction_call::returnVoid 863 ns 863 ns 813219 +RtlFunction_callMethod::returnVoid 863 ns 863 ns 812608 + +RtlFunction_call_ReturnUnknown::Void 859 ns 859 ns 813712 +RtlFunction_callMethod_ReturnUnknown::Void 876 ns 876 ns 799429 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 881 ns 881 ns 795613 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1007 ns 1007 ns 696038 + +NativeFunctionPtr_call::returnNonVoid 1013 ns 1013 ns 691469 +NativeFunctionPtr_callMethod::returnNonVoid 1011 ns 1011 ns 691744 + +StdFunction_call::returnNonVoid 1015 ns 1015 ns 690018 +StdFunction_callMethod::returnNonVoid 1011 ns 1011 ns 692145 + +RtlFunction_call::returnNonVoid 1012 ns 1012 ns 692785 +RtlFunction_callMethod::returnNonVoid 1010 ns 1010 ns 692879 + +RtlFunction_call_ReturnUnknown::NonVoid 1031 ns 1031 ns 679524 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1024 ns 1023 ns 683812 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1032 ns 1032 ns 678159 +----------------------------------- +[2025-10-09 22:34:20] >>> Run 5: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-10-09T22:34:20+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.04, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 840 ns 840 ns 832360 + +NativeFunctionPtr_call::returnVoid 844 ns 844 ns 830015 +NativeFunctionPtr_callMethod::returnVoid 845 ns 845 ns 829703 + +StdFunction_call::returnVoid 845 ns 845 ns 829638 +StdFunction_callMethod::returnVoid 840 ns 840 ns 835607 + +RtlFunction_call::returnVoid 844 ns 844 ns 826581 +RtlFunction_callMethod::returnVoid 844 ns 844 ns 829324 + +RtlFunction_call_ReturnUnknown::Void 837 ns 837 ns 834891 +RtlFunction_callMethod_ReturnUnknown::Void 844 ns 844 ns 829558 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 855 ns 855 ns 820735 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 968 ns 968 ns 722959 + +NativeFunctionPtr_call::returnNonVoid 972 ns 972 ns 721065 +NativeFunctionPtr_callMethod::returnNonVoid 972 ns 972 ns 720746 + +StdFunction_call::returnNonVoid 972 ns 972 ns 720795 +StdFunction_callMethod::returnNonVoid 967 ns 967 ns 723954 + +RtlFunction_call::returnNonVoid 971 ns 971 ns 719967 +RtlFunction_callMethod::returnNonVoid 972 ns 972 ns 720005 + +RtlFunction_call_ReturnUnknown::NonVoid 987 ns 987 ns 709286 +RtlFunction_callMethod_ReturnUnknown::NonVoid 980 ns 980 ns 715900 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 989 ns 988 ns 708690 +----------------------------------- +[2025-10-09 22:34:36] >>> Run 1: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-10-09T22:34:36+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.04, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 925 ns 925 ns 756744 + +NativeFunctionPtr_call::returnVoid 924 ns 924 ns 757546 +NativeFunctionPtr_callMethod::returnVoid 925 ns 925 ns 756714 + +StdFunction_call::returnVoid 925 ns 925 ns 757808 +StdFunction_callMethod::returnVoid 928 ns 928 ns 756162 + +RtlFunction_call::returnVoid 923 ns 923 ns 758543 +RtlFunction_callMethod::returnVoid 925 ns 925 ns 756594 + +RtlFunction_call_ReturnUnknown::Void 933 ns 933 ns 749852 +RtlFunction_callMethod_ReturnUnknown::Void 927 ns 927 ns 754843 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 938 ns 938 ns 746632 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1056 ns 1056 ns 660848 + +NativeFunctionPtr_call::returnNonVoid 1054 ns 1054 ns 663610 +NativeFunctionPtr_callMethod::returnNonVoid 1053 ns 1053 ns 664580 + +StdFunction_call::returnNonVoid 1055 ns 1055 ns 661895 +StdFunction_callMethod::returnNonVoid 1055 ns 1055 ns 662731 + +RtlFunction_call::returnNonVoid 1054 ns 1054 ns 664913 +RtlFunction_callMethod::returnNonVoid 1055 ns 1055 ns 664932 + +RtlFunction_call_ReturnUnknown::NonVoid 1084 ns 1084 ns 645326 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1085 ns 1085 ns 644799 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1085 ns 1084 ns 645482 +----------------------------------- +[2025-10-09 22:34:52] >>> Run 2: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-10-09T22:34:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.03, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 907 ns 907 ns 771423 + +NativeFunctionPtr_call::returnVoid 911 ns 911 ns 769454 +NativeFunctionPtr_callMethod::returnVoid 911 ns 910 ns 768672 + +StdFunction_call::returnVoid 909 ns 909 ns 769736 +StdFunction_callMethod::returnVoid 910 ns 910 ns 769969 + +RtlFunction_call::returnVoid 910 ns 910 ns 767614 +RtlFunction_callMethod::returnVoid 911 ns 911 ns 769431 + +RtlFunction_call_ReturnUnknown::Void 916 ns 916 ns 765503 +RtlFunction_callMethod_ReturnUnknown::Void 911 ns 911 ns 769526 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 918 ns 918 ns 763819 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1067 ns 1067 ns 656515 + +NativeFunctionPtr_call::returnNonVoid 1071 ns 1071 ns 653572 +NativeFunctionPtr_callMethod::returnNonVoid 1069 ns 1069 ns 654981 + +StdFunction_call::returnNonVoid 1072 ns 1072 ns 653906 +StdFunction_callMethod::returnNonVoid 1070 ns 1070 ns 654678 + +RtlFunction_call::returnNonVoid 1069 ns 1069 ns 654802 +RtlFunction_callMethod::returnNonVoid 1071 ns 1071 ns 654057 + +RtlFunction_call_ReturnUnknown::NonVoid 1084 ns 1084 ns 645423 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1085 ns 1085 ns 645445 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1086 ns 1086 ns 643595 +----------------------------------- +[2025-10-09 22:35:08] >>> Run 3: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-10-09T22:35:08+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.03, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 910 ns 910 ns 767785 + +NativeFunctionPtr_call::returnVoid 913 ns 913 ns 767341 +NativeFunctionPtr_callMethod::returnVoid 914 ns 914 ns 767157 + +StdFunction_call::returnVoid 913 ns 913 ns 767217 +StdFunction_callMethod::returnVoid 916 ns 915 ns 766123 + +RtlFunction_call::returnVoid 914 ns 913 ns 767388 +RtlFunction_callMethod::returnVoid 916 ns 916 ns 765652 + +RtlFunction_call_ReturnUnknown::Void 915 ns 915 ns 766052 +RtlFunction_callMethod_ReturnUnknown::Void 915 ns 914 ns 767732 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 915 ns 915 ns 767030 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1033 ns 1033 ns 677004 + +NativeFunctionPtr_call::returnNonVoid 1039 ns 1039 ns 675264 +NativeFunctionPtr_callMethod::returnNonVoid 1037 ns 1037 ns 675643 + +StdFunction_call::returnNonVoid 1038 ns 1038 ns 675230 +StdFunction_callMethod::returnNonVoid 1037 ns 1037 ns 675307 + +RtlFunction_call::returnNonVoid 1038 ns 1038 ns 672573 +RtlFunction_callMethod::returnNonVoid 1039 ns 1038 ns 674737 + +RtlFunction_call_ReturnUnknown::NonVoid 1053 ns 1053 ns 664901 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1046 ns 1045 ns 669741 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1047 ns 1046 ns 669072 +----------------------------------- +[2025-10-09 22:35:24] >>> Run 4: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-10-09T22:35:24+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.03, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 983 ns 982 ns 711381 + +NativeFunctionPtr_call::returnVoid 976 ns 976 ns 717755 +NativeFunctionPtr_callMethod::returnVoid 976 ns 976 ns 717214 + +StdFunction_call::returnVoid 978 ns 978 ns 716311 +StdFunction_callMethod::returnVoid 960 ns 960 ns 726226 + +RtlFunction_call::returnVoid 975 ns 975 ns 717093 +RtlFunction_callMethod::returnVoid 977 ns 976 ns 716878 + +RtlFunction_call_ReturnUnknown::Void 960 ns 960 ns 727671 +RtlFunction_callMethod_ReturnUnknown::Void 964 ns 964 ns 725591 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 970 ns 969 ns 719357 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1104 ns 1104 ns 633453 + +NativeFunctionPtr_call::returnNonVoid 1086 ns 1086 ns 643041 +NativeFunctionPtr_callMethod::returnNonVoid 1086 ns 1086 ns 643635 + +StdFunction_call::returnNonVoid 1087 ns 1087 ns 644609 +StdFunction_callMethod::returnNonVoid 1083 ns 1083 ns 645401 + +RtlFunction_call::returnNonVoid 1086 ns 1086 ns 644157 +RtlFunction_callMethod::returnNonVoid 1085 ns 1085 ns 643034 + +RtlFunction_call_ReturnUnknown::NonVoid 1093 ns 1092 ns 641167 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1092 ns 1092 ns 640012 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1091 ns 1091 ns 641847 +----------------------------------- +[2025-10-09 22:35:41] >>> Run 5: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-10-09T22:35:41+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.03, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 901 ns 901 ns 776903 + +NativeFunctionPtr_call::returnVoid 907 ns 907 ns 770209 +NativeFunctionPtr_callMethod::returnVoid 907 ns 907 ns 769710 + +StdFunction_call::returnVoid 907 ns 907 ns 768412 +StdFunction_callMethod::returnVoid 905 ns 905 ns 772351 + +RtlFunction_call::returnVoid 906 ns 906 ns 770224 +RtlFunction_callMethod::returnVoid 909 ns 909 ns 771678 + +RtlFunction_call_ReturnUnknown::Void 913 ns 913 ns 767049 +RtlFunction_callMethod_ReturnUnknown::Void 916 ns 916 ns 765685 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 922 ns 922 ns 759992 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1029 ns 1029 ns 680497 + +NativeFunctionPtr_call::returnNonVoid 1032 ns 1032 ns 677650 +NativeFunctionPtr_callMethod::returnNonVoid 1033 ns 1033 ns 676900 + +StdFunction_call::returnNonVoid 1036 ns 1035 ns 676858 +StdFunction_callMethod::returnNonVoid 1036 ns 1035 ns 675873 + +RtlFunction_call::returnNonVoid 1035 ns 1035 ns 676220 +RtlFunction_callMethod::returnNonVoid 1037 ns 1037 ns 676462 + +RtlFunction_call_ReturnUnknown::NonVoid 1059 ns 1059 ns 662541 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1058 ns 1058 ns 661582 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1059 ns 1059 ns 661306 +----------------------------------- +[2025-10-09 22:35:57] >>> Run 1: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-10-09T22:35:57+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1071.83 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1017 ns 1017 ns 688223 + +NativeFunctionPtr_call::returnVoid 1017 ns 1017 ns 689065 +NativeFunctionPtr_callMethod::returnVoid 1016 ns 1016 ns 689482 + +StdFunction_call::returnVoid 1017 ns 1017 ns 689150 +StdFunction_callMethod::returnVoid 1020 ns 1019 ns 686631 + +RtlFunction_call::returnVoid 1017 ns 1017 ns 689619 +RtlFunction_callMethod::returnVoid 1016 ns 1016 ns 688181 + +RtlFunction_call_ReturnUnknown::Void 1022 ns 1022 ns 685431 +RtlFunction_callMethod_ReturnUnknown::Void 1022 ns 1022 ns 685152 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1023 ns 1023 ns 681943 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1186 ns 1186 ns 590484 + +NativeFunctionPtr_call::returnNonVoid 1185 ns 1185 ns 591072 +NativeFunctionPtr_callMethod::returnNonVoid 1185 ns 1185 ns 590879 + +StdFunction_call::returnNonVoid 1186 ns 1186 ns 590813 +StdFunction_callMethod::returnNonVoid 1190 ns 1190 ns 587526 + +RtlFunction_call::returnNonVoid 1185 ns 1185 ns 589054 +RtlFunction_callMethod::returnNonVoid 1185 ns 1185 ns 590356 + +RtlFunction_call_ReturnUnknown::NonVoid 1205 ns 1205 ns 580445 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1204 ns 1204 ns 581492 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1207 ns 1206 ns 579706 +----------------------------------- +[2025-10-09 22:36:13] >>> Run 2: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-10-09T22:36:13+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1020 ns 1020 ns 686146 + +NativeFunctionPtr_call::returnVoid 1022 ns 1022 ns 685871 +NativeFunctionPtr_callMethod::returnVoid 1023 ns 1022 ns 684704 + +StdFunction_call::returnVoid 1024 ns 1024 ns 684907 +StdFunction_callMethod::returnVoid 1024 ns 1023 ns 683217 + +RtlFunction_call::returnVoid 1021 ns 1021 ns 686029 +RtlFunction_callMethod::returnVoid 1022 ns 1021 ns 685508 + +RtlFunction_call_ReturnUnknown::Void 1026 ns 1026 ns 682906 +RtlFunction_callMethod_ReturnUnknown::Void 1027 ns 1027 ns 682324 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1028 ns 1028 ns 680506 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1193 ns 1193 ns 587243 + +NativeFunctionPtr_call::returnNonVoid 1191 ns 1190 ns 587438 +NativeFunctionPtr_callMethod::returnNonVoid 1191 ns 1191 ns 587449 + +StdFunction_call::returnNonVoid 1192 ns 1191 ns 588016 +StdFunction_callMethod::returnNonVoid 1192 ns 1192 ns 587654 + +RtlFunction_call::returnNonVoid 1191 ns 1191 ns 587588 +RtlFunction_callMethod::returnNonVoid 1191 ns 1190 ns 585562 + +RtlFunction_call_ReturnUnknown::NonVoid 1209 ns 1209 ns 579108 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1204 ns 1204 ns 581221 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1211 ns 1211 ns 578505 +----------------------------------- +[2025-10-09 22:36:30] >>> Run 3: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-10-09T22:36:30+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1057 ns 1057 ns 662676 + +NativeFunctionPtr_call::returnVoid 1057 ns 1057 ns 662479 +NativeFunctionPtr_callMethod::returnVoid 1057 ns 1057 ns 662618 + +StdFunction_call::returnVoid 1056 ns 1056 ns 661366 +StdFunction_callMethod::returnVoid 1055 ns 1055 ns 664957 + +RtlFunction_call::returnVoid 1057 ns 1057 ns 661655 +RtlFunction_callMethod::returnVoid 1056 ns 1056 ns 663351 + +RtlFunction_call_ReturnUnknown::Void 1061 ns 1060 ns 661005 +RtlFunction_callMethod_ReturnUnknown::Void 1056 ns 1056 ns 663085 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1060 ns 1060 ns 661394 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1222 ns 1222 ns 573160 + +NativeFunctionPtr_call::returnNonVoid 1222 ns 1222 ns 573052 +NativeFunctionPtr_callMethod::returnNonVoid 1223 ns 1222 ns 572696 + +StdFunction_call::returnNonVoid 1223 ns 1223 ns 571572 +StdFunction_callMethod::returnNonVoid 1222 ns 1222 ns 573104 + +RtlFunction_call::returnNonVoid 1223 ns 1223 ns 572700 +RtlFunction_callMethod::returnNonVoid 1222 ns 1222 ns 573468 + +RtlFunction_call_ReturnUnknown::NonVoid 1235 ns 1235 ns 567072 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1235 ns 1234 ns 567330 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1238 ns 1238 ns 565464 +----------------------------------- +[2025-10-09 22:36:46] >>> Run 4: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-10-09T22:36:46+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1016 ns 1015 ns 688702 + +NativeFunctionPtr_call::returnVoid 1017 ns 1016 ns 687175 +NativeFunctionPtr_callMethod::returnVoid 1017 ns 1017 ns 687586 + +StdFunction_call::returnVoid 1018 ns 1017 ns 689533 +StdFunction_callMethod::returnVoid 1022 ns 1021 ns 686748 + +RtlFunction_call::returnVoid 1017 ns 1017 ns 687457 +RtlFunction_callMethod::returnVoid 1018 ns 1017 ns 687584 + +RtlFunction_call_ReturnUnknown::Void 1024 ns 1024 ns 684873 +RtlFunction_callMethod_ReturnUnknown::Void 1022 ns 1022 ns 684522 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1026 ns 1026 ns 683416 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1145 ns 1145 ns 611880 + +NativeFunctionPtr_call::returnNonVoid 1144 ns 1144 ns 611850 +NativeFunctionPtr_callMethod::returnNonVoid 1148 ns 1147 ns 610908 + +StdFunction_call::returnNonVoid 1146 ns 1146 ns 610474 +StdFunction_callMethod::returnNonVoid 1149 ns 1149 ns 610191 + +RtlFunction_call::returnNonVoid 1145 ns 1145 ns 611206 +RtlFunction_callMethod::returnNonVoid 1145 ns 1145 ns 610365 + +RtlFunction_call_ReturnUnknown::NonVoid 1168 ns 1168 ns 599252 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1162 ns 1162 ns 602772 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1168 ns 1168 ns 599755 +----------------------------------- +[2025-10-09 22:37:03] >>> Run 5: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-10-09T22:37:03+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1014 ns 1014 ns 690854 + +NativeFunctionPtr_call::returnVoid 1018 ns 1018 ns 688026 +NativeFunctionPtr_callMethod::returnVoid 1018 ns 1018 ns 681535 + +StdFunction_call::returnVoid 1019 ns 1019 ns 685012 +StdFunction_callMethod::returnVoid 1021 ns 1021 ns 686342 + +RtlFunction_call::returnVoid 1017 ns 1017 ns 689481 +RtlFunction_callMethod::returnVoid 1016 ns 1016 ns 689388 + +RtlFunction_call_ReturnUnknown::Void 1024 ns 1024 ns 677009 +RtlFunction_callMethod_ReturnUnknown::Void 1023 ns 1023 ns 683703 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1029 ns 1029 ns 680827 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1188 ns 1188 ns 589325 + +NativeFunctionPtr_call::returnNonVoid 1189 ns 1189 ns 589444 +NativeFunctionPtr_callMethod::returnNonVoid 1188 ns 1188 ns 589075 + +StdFunction_call::returnNonVoid 1190 ns 1189 ns 588550 +StdFunction_callMethod::returnNonVoid 1191 ns 1191 ns 588850 + +RtlFunction_call::returnNonVoid 1188 ns 1188 ns 589155 +RtlFunction_callMethod::returnNonVoid 1190 ns 1190 ns 589574 + +RtlFunction_call_ReturnUnknown::NonVoid 1210 ns 1210 ns 578489 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1209 ns 1209 ns 579083 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1211 ns 1210 ns 579422 +----------------------------------- +[2025-10-09 22:37:19] >>> Run 1: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-10-09T22:37:19+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1600 ns 1600 ns 436385 + +NativeFunctionPtr_call::returnVoid 1604 ns 1604 ns 436230 +NativeFunctionPtr_callMethod::returnVoid 1603 ns 1602 ns 436650 + +StdFunction_call::returnVoid 1607 ns 1606 ns 437326 +StdFunction_callMethod::returnVoid 1604 ns 1604 ns 436121 + +RtlFunction_call::returnVoid 1602 ns 1602 ns 436830 +RtlFunction_callMethod::returnVoid 1602 ns 1602 ns 436999 + +RtlFunction_call_ReturnUnknown::Void 1631 ns 1631 ns 429057 +RtlFunction_callMethod_ReturnUnknown::Void 1603 ns 1602 ns 436413 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1648 ns 1648 ns 424915 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1760 ns 1760 ns 397933 + +NativeFunctionPtr_call::returnNonVoid 1760 ns 1760 ns 397613 +NativeFunctionPtr_callMethod::returnNonVoid 1761 ns 1761 ns 397339 + +StdFunction_call::returnNonVoid 1763 ns 1763 ns 397079 +StdFunction_callMethod::returnNonVoid 1766 ns 1766 ns 396389 + +RtlFunction_call::returnNonVoid 1760 ns 1760 ns 397778 +RtlFunction_callMethod::returnNonVoid 1760 ns 1760 ns 397708 + +RtlFunction_call_ReturnUnknown::NonVoid 1814 ns 1814 ns 385836 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1800 ns 1800 ns 388585 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1785 ns 1784 ns 392294 +----------------------------------- +[2025-10-09 22:37:37] >>> Run 2: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-10-09T22:37:37+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1613 ns 1613 ns 433621 + +NativeFunctionPtr_call::returnVoid 1619 ns 1618 ns 432916 +NativeFunctionPtr_callMethod::returnVoid 1615 ns 1615 ns 433261 + +StdFunction_call::returnVoid 1615 ns 1615 ns 433326 +StdFunction_callMethod::returnVoid 1619 ns 1619 ns 432547 + +RtlFunction_call::returnVoid 1616 ns 1616 ns 433581 +RtlFunction_callMethod::returnVoid 1614 ns 1614 ns 433431 + +RtlFunction_call_ReturnUnknown::Void 1623 ns 1623 ns 430795 +RtlFunction_callMethod_ReturnUnknown::Void 1618 ns 1618 ns 432710 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1624 ns 1624 ns 431140 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1802 ns 1802 ns 388594 + +NativeFunctionPtr_call::returnNonVoid 1799 ns 1798 ns 389146 +NativeFunctionPtr_callMethod::returnNonVoid 1799 ns 1799 ns 389238 + +StdFunction_call::returnNonVoid 1801 ns 1801 ns 388945 +StdFunction_callMethod::returnNonVoid 1805 ns 1805 ns 388052 + +RtlFunction_call::returnNonVoid 1799 ns 1799 ns 389035 +RtlFunction_callMethod::returnNonVoid 1799 ns 1799 ns 388790 + +RtlFunction_call_ReturnUnknown::NonVoid 1828 ns 1828 ns 382853 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1832 ns 1832 ns 383383 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1829 ns 1829 ns 382548 +----------------------------------- +[2025-10-09 22:37:55] >>> Run 3: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-10-09T22:37:55+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1618 ns 1618 ns 432405 + +NativeFunctionPtr_call::returnVoid 1620 ns 1620 ns 432224 +NativeFunctionPtr_callMethod::returnVoid 1618 ns 1617 ns 432408 + +StdFunction_call::returnVoid 1619 ns 1619 ns 432761 +StdFunction_callMethod::returnVoid 1621 ns 1621 ns 431805 + +RtlFunction_call::returnVoid 1618 ns 1618 ns 432749 +RtlFunction_callMethod::returnVoid 1618 ns 1618 ns 432757 + +RtlFunction_call_ReturnUnknown::Void 1627 ns 1627 ns 430553 +RtlFunction_callMethod_ReturnUnknown::Void 1637 ns 1636 ns 427801 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1625 ns 1624 ns 431362 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1804 ns 1804 ns 388076 + +NativeFunctionPtr_call::returnNonVoid 1803 ns 1803 ns 388011 +NativeFunctionPtr_callMethod::returnNonVoid 1804 ns 1803 ns 388212 + +StdFunction_call::returnNonVoid 1805 ns 1804 ns 387668 +StdFunction_callMethod::returnNonVoid 1808 ns 1808 ns 387071 + +RtlFunction_call::returnNonVoid 1803 ns 1803 ns 388011 +RtlFunction_callMethod::returnNonVoid 1804 ns 1804 ns 388127 + +RtlFunction_call_ReturnUnknown::NonVoid 1827 ns 1827 ns 383173 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1823 ns 1823 ns 384070 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1827 ns 1827 ns 383220 +----------------------------------- +[2025-10-09 22:38:13] >>> Run 4: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-10-09T22:38:13+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1848.59 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1617 ns 1617 ns 432860 + +NativeFunctionPtr_call::returnVoid 1617 ns 1617 ns 432688 +NativeFunctionPtr_callMethod::returnVoid 1615 ns 1615 ns 433493 + +StdFunction_call::returnVoid 1615 ns 1615 ns 433467 +StdFunction_callMethod::returnVoid 1623 ns 1622 ns 431721 + +RtlFunction_call::returnVoid 1615 ns 1615 ns 433383 +RtlFunction_callMethod::returnVoid 1615 ns 1615 ns 433324 + +RtlFunction_call_ReturnUnknown::Void 1623 ns 1623 ns 431084 +RtlFunction_callMethod_ReturnUnknown::Void 1614 ns 1614 ns 433944 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1621 ns 1620 ns 432351 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1803 ns 1803 ns 388501 + +NativeFunctionPtr_call::returnNonVoid 1801 ns 1801 ns 388522 +NativeFunctionPtr_callMethod::returnNonVoid 1800 ns 1800 ns 388728 + +StdFunction_call::returnNonVoid 1803 ns 1803 ns 388057 +StdFunction_callMethod::returnNonVoid 1807 ns 1807 ns 386892 + +RtlFunction_call::returnNonVoid 1801 ns 1801 ns 388940 +RtlFunction_callMethod::returnNonVoid 1802 ns 1801 ns 388635 + +RtlFunction_call_ReturnUnknown::NonVoid 1827 ns 1827 ns 383400 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1821 ns 1821 ns 384418 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1830 ns 1830 ns 382810 +----------------------------------- +[2025-10-09 22:38:31] >>> Run 5: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-10-09T22:38:31+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1140.79 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1603 ns 1602 ns 436929 + +NativeFunctionPtr_call::returnVoid 1602 ns 1601 ns 436985 +NativeFunctionPtr_callMethod::returnVoid 1600 ns 1600 ns 437146 + +StdFunction_call::returnVoid 1600 ns 1600 ns 434586 +StdFunction_callMethod::returnVoid 1605 ns 1605 ns 436545 + +RtlFunction_call::returnVoid 1604 ns 1603 ns 437626 +RtlFunction_callMethod::returnVoid 1600 ns 1600 ns 437431 + +RtlFunction_call_ReturnUnknown::Void 1611 ns 1611 ns 435485 +RtlFunction_callMethod_ReturnUnknown::Void 1602 ns 1602 ns 437140 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1609 ns 1608 ns 435371 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1758 ns 1757 ns 398110 + +NativeFunctionPtr_call::returnNonVoid 1758 ns 1758 ns 398283 +NativeFunctionPtr_callMethod::returnNonVoid 1762 ns 1762 ns 398076 + +StdFunction_call::returnNonVoid 1763 ns 1762 ns 397384 +StdFunction_callMethod::returnNonVoid 1768 ns 1768 ns 396828 + +RtlFunction_call::returnNonVoid 1759 ns 1759 ns 398057 +RtlFunction_callMethod::returnNonVoid 1761 ns 1761 ns 398049 + +RtlFunction_call_ReturnUnknown::NonVoid 1783 ns 1783 ns 392427 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1779 ns 1778 ns 393989 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1782 ns 1782 ns 392158 +----------------------------------- +[2025-10-09 22:38:48] >>> Run 1: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-10-09T22:38:48+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1690 ns 1690 ns 413456 + +NativeFunctionPtr_call::returnVoid 1695 ns 1694 ns 413568 +NativeFunctionPtr_callMethod::returnVoid 1691 ns 1690 ns 414074 + +StdFunction_call::returnVoid 1692 ns 1692 ns 414083 +StdFunction_callMethod::returnVoid 1694 ns 1694 ns 413416 + +RtlFunction_call::returnVoid 1692 ns 1692 ns 413887 +RtlFunction_callMethod::returnVoid 1691 ns 1691 ns 414207 + +RtlFunction_call_ReturnUnknown::Void 1698 ns 1698 ns 412184 +RtlFunction_callMethod_ReturnUnknown::Void 1690 ns 1690 ns 411539 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1696 ns 1696 ns 412729 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1914 ns 1914 ns 366023 + +NativeFunctionPtr_call::returnNonVoid 1911 ns 1910 ns 366512 +NativeFunctionPtr_callMethod::returnNonVoid 1913 ns 1913 ns 366399 + +StdFunction_call::returnNonVoid 1915 ns 1915 ns 365932 +StdFunction_callMethod::returnNonVoid 1919 ns 1919 ns 364599 + +RtlFunction_call::returnNonVoid 1911 ns 1911 ns 366396 +RtlFunction_callMethod::returnNonVoid 1915 ns 1914 ns 365912 + +RtlFunction_call_ReturnUnknown::NonVoid 1940 ns 1939 ns 360998 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1934 ns 1934 ns 361624 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1938 ns 1938 ns 359495 +----------------------------------- +[2025-10-09 22:39:06] >>> Run 2: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-10-09T22:39:06+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1681 ns 1680 ns 415852 + +NativeFunctionPtr_call::returnVoid 1681 ns 1681 ns 405148 +NativeFunctionPtr_callMethod::returnVoid 1680 ns 1680 ns 416822 + +StdFunction_call::returnVoid 1679 ns 1679 ns 417233 +StdFunction_callMethod::returnVoid 1683 ns 1683 ns 416139 + +RtlFunction_call::returnVoid 1679 ns 1679 ns 417327 +RtlFunction_callMethod::returnVoid 1680 ns 1680 ns 416365 + +RtlFunction_call_ReturnUnknown::Void 1687 ns 1686 ns 415109 +RtlFunction_callMethod_ReturnUnknown::Void 1679 ns 1679 ns 416907 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1683 ns 1683 ns 415653 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1870 ns 1870 ns 374302 + +NativeFunctionPtr_call::returnNonVoid 1871 ns 1871 ns 374375 +NativeFunctionPtr_callMethod::returnNonVoid 1871 ns 1871 ns 373993 + +StdFunction_call::returnNonVoid 1873 ns 1873 ns 373579 +StdFunction_callMethod::returnNonVoid 1875 ns 1875 ns 373470 + +RtlFunction_call::returnNonVoid 1869 ns 1869 ns 374406 +RtlFunction_callMethod::returnNonVoid 1871 ns 1870 ns 374098 + +RtlFunction_call_ReturnUnknown::NonVoid 1898 ns 1898 ns 368169 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1891 ns 1891 ns 370428 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1897 ns 1897 ns 367942 +----------------------------------- +[2025-10-09 22:39:24] >>> Run 3: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-10-09T22:39:24+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1682 ns 1682 ns 415896 + +NativeFunctionPtr_call::returnVoid 1683 ns 1683 ns 415946 +NativeFunctionPtr_callMethod::returnVoid 1681 ns 1681 ns 416150 + +StdFunction_call::returnVoid 1683 ns 1683 ns 416123 +StdFunction_callMethod::returnVoid 1683 ns 1683 ns 416331 + +RtlFunction_call::returnVoid 1682 ns 1682 ns 416179 +RtlFunction_callMethod::returnVoid 1683 ns 1683 ns 415128 + +RtlFunction_call_ReturnUnknown::Void 1691 ns 1691 ns 413901 +RtlFunction_callMethod_ReturnUnknown::Void 1684 ns 1684 ns 416111 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1690 ns 1689 ns 415003 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1874 ns 1873 ns 373708 + +NativeFunctionPtr_call::returnNonVoid 1876 ns 1875 ns 373210 +NativeFunctionPtr_callMethod::returnNonVoid 1875 ns 1875 ns 373554 + +StdFunction_call::returnNonVoid 1878 ns 1878 ns 373119 +StdFunction_callMethod::returnNonVoid 1877 ns 1876 ns 372692 + +RtlFunction_call::returnNonVoid 1874 ns 1874 ns 373273 +RtlFunction_callMethod::returnNonVoid 1874 ns 1874 ns 373279 + +RtlFunction_call_ReturnUnknown::NonVoid 1898 ns 1898 ns 368554 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1893 ns 1893 ns 369625 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1900 ns 1900 ns 368374 +----------------------------------- +[2025-10-09 22:39:42] >>> Run 4: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-10-09T22:39:42+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1693 ns 1693 ns 412694 + +NativeFunctionPtr_call::returnVoid 1695 ns 1695 ns 412741 +NativeFunctionPtr_callMethod::returnVoid 1694 ns 1694 ns 413429 + +StdFunction_call::returnVoid 1693 ns 1693 ns 413657 +StdFunction_callMethod::returnVoid 1698 ns 1698 ns 412501 + +RtlFunction_call::returnVoid 1693 ns 1693 ns 413448 +RtlFunction_callMethod::returnVoid 1694 ns 1694 ns 413417 + +RtlFunction_call_ReturnUnknown::Void 1705 ns 1704 ns 410623 +RtlFunction_callMethod_ReturnUnknown::Void 1696 ns 1696 ns 412685 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1702 ns 1702 ns 411282 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1918 ns 1918 ns 365470 + +NativeFunctionPtr_call::returnNonVoid 1921 ns 1921 ns 364815 +NativeFunctionPtr_callMethod::returnNonVoid 1921 ns 1921 ns 364317 + +StdFunction_call::returnNonVoid 1923 ns 1923 ns 363918 +StdFunction_callMethod::returnNonVoid 1923 ns 1923 ns 363502 + +RtlFunction_call::returnNonVoid 1920 ns 1920 ns 364545 +RtlFunction_callMethod::returnNonVoid 1921 ns 1921 ns 364450 + +RtlFunction_call_ReturnUnknown::NonVoid 1947 ns 1947 ns 359754 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1937 ns 1937 ns 361172 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1946 ns 1946 ns 359430 +----------------------------------- +[2025-10-09 22:40:00] >>> Run 5: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-10-09T22:40:00+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1676 ns 1676 ns 417519 + +NativeFunctionPtr_call::returnVoid 1679 ns 1679 ns 417046 +NativeFunctionPtr_callMethod::returnVoid 1677 ns 1676 ns 417618 + +StdFunction_call::returnVoid 1675 ns 1675 ns 417300 +StdFunction_callMethod::returnVoid 1680 ns 1680 ns 415928 + +RtlFunction_call::returnVoid 1676 ns 1676 ns 418188 +RtlFunction_callMethod::returnVoid 1677 ns 1676 ns 417493 + +RtlFunction_call_ReturnUnknown::Void 1687 ns 1687 ns 414584 +RtlFunction_callMethod_ReturnUnknown::Void 1684 ns 1684 ns 415970 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1689 ns 1689 ns 414604 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1872 ns 1871 ns 374658 + +NativeFunctionPtr_call::returnNonVoid 1870 ns 1870 ns 374480 +NativeFunctionPtr_callMethod::returnNonVoid 1869 ns 1869 ns 374314 + +StdFunction_call::returnNonVoid 1872 ns 1872 ns 373200 +StdFunction_callMethod::returnNonVoid 1877 ns 1877 ns 373379 + +RtlFunction_call::returnNonVoid 1870 ns 1870 ns 374416 +RtlFunction_callMethod::returnNonVoid 1869 ns 1869 ns 374204 + +RtlFunction_call_ReturnUnknown::NonVoid 1902 ns 1902 ns 368492 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1892 ns 1892 ns 370016 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1900 ns 1900 ns 368252 +----------------------------------- +[2025-10-09 22:40:18] >>> Run 1: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-10-09T22:40:18+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1765 ns 1764 ns 396103 + +NativeFunctionPtr_call::returnVoid 1767 ns 1767 ns 396034 +NativeFunctionPtr_callMethod::returnVoid 1766 ns 1766 ns 396530 + +StdFunction_call::returnVoid 1765 ns 1765 ns 396669 +StdFunction_callMethod::returnVoid 1772 ns 1772 ns 395166 + +RtlFunction_call::returnVoid 1764 ns 1764 ns 396604 +RtlFunction_callMethod::returnVoid 1766 ns 1765 ns 396195 + +RtlFunction_call_ReturnUnknown::Void 1772 ns 1772 ns 395162 +RtlFunction_callMethod_ReturnUnknown::Void 1767 ns 1767 ns 396402 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1772 ns 1772 ns 394985 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2018 ns 2018 ns 346687 + +NativeFunctionPtr_call::returnNonVoid 2017 ns 2017 ns 346410 +NativeFunctionPtr_callMethod::returnNonVoid 2019 ns 2018 ns 346463 + +StdFunction_call::returnNonVoid 2022 ns 2022 ns 346385 +StdFunction_callMethod::returnNonVoid 2023 ns 2023 ns 346094 + +RtlFunction_call::returnNonVoid 2018 ns 2018 ns 347016 +RtlFunction_callMethod::returnNonVoid 2018 ns 2018 ns 346613 + +RtlFunction_call_ReturnUnknown::NonVoid 2043 ns 2043 ns 342739 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2038 ns 2038 ns 343160 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2046 ns 2045 ns 341702 +----------------------------------- +[2025-10-09 22:40:36] >>> Run 2: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-10-09T22:40:36+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1135.34 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1761 ns 1760 ns 397427 + +NativeFunctionPtr_call::returnVoid 1761 ns 1761 ns 397592 +NativeFunctionPtr_callMethod::returnVoid 1759 ns 1759 ns 396975 + +StdFunction_call::returnVoid 1759 ns 1759 ns 397680 +StdFunction_callMethod::returnVoid 1765 ns 1765 ns 397152 + +RtlFunction_call::returnVoid 1759 ns 1758 ns 397971 +RtlFunction_callMethod::returnVoid 1759 ns 1759 ns 397676 + +RtlFunction_call_ReturnUnknown::Void 1767 ns 1767 ns 396426 +RtlFunction_callMethod_ReturnUnknown::Void 1759 ns 1758 ns 398399 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1763 ns 1762 ns 397242 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1978 ns 1977 ns 354040 + +NativeFunctionPtr_call::returnNonVoid 1969 ns 1968 ns 355603 +NativeFunctionPtr_callMethod::returnNonVoid 1969 ns 1969 ns 355704 + +StdFunction_call::returnNonVoid 1971 ns 1971 ns 353677 +StdFunction_callMethod::returnNonVoid 1975 ns 1975 ns 354680 + +RtlFunction_call::returnNonVoid 1970 ns 1970 ns 355759 +RtlFunction_callMethod::returnNonVoid 1969 ns 1969 ns 355124 + +RtlFunction_call_ReturnUnknown::NonVoid 2003 ns 2003 ns 349397 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1998 ns 1998 ns 350705 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2009 ns 2009 ns 349110 +----------------------------------- +[2025-10-09 22:40:55] >>> Run 3: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-10-09T22:40:55+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1756 ns 1755 ns 398587 + +NativeFunctionPtr_call::returnVoid 1757 ns 1757 ns 398159 +NativeFunctionPtr_callMethod::returnVoid 1755 ns 1755 ns 398777 + +StdFunction_call::returnVoid 1756 ns 1756 ns 398645 +StdFunction_callMethod::returnVoid 1761 ns 1761 ns 398296 + +RtlFunction_call::returnVoid 1756 ns 1756 ns 398762 +RtlFunction_callMethod::returnVoid 1759 ns 1758 ns 398916 + +RtlFunction_call_ReturnUnknown::Void 1763 ns 1763 ns 396837 +RtlFunction_callMethod_ReturnUnknown::Void 1757 ns 1757 ns 398736 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1763 ns 1762 ns 397320 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1971 ns 1970 ns 356090 + +NativeFunctionPtr_call::returnNonVoid 1967 ns 1966 ns 356192 +NativeFunctionPtr_callMethod::returnNonVoid 1967 ns 1966 ns 356038 + +StdFunction_call::returnNonVoid 1971 ns 1971 ns 353175 +StdFunction_callMethod::returnNonVoid 1971 ns 1971 ns 354723 + +RtlFunction_call::returnNonVoid 1970 ns 1970 ns 355458 +RtlFunction_callMethod::returnNonVoid 1967 ns 1967 ns 355902 + +RtlFunction_call_ReturnUnknown::NonVoid 1996 ns 1996 ns 351337 +RtlFunction_callMethod_ReturnUnknown::NonVoid 1989 ns 1989 ns 352047 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2000 ns 2000 ns 350827 +----------------------------------- +[2025-10-09 22:41:13] >>> Run 4: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-10-09T22:41:13+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1774 ns 1774 ns 394692 + +NativeFunctionPtr_call::returnVoid 1778 ns 1778 ns 394712 +NativeFunctionPtr_callMethod::returnVoid 1773 ns 1773 ns 394819 + +StdFunction_call::returnVoid 1774 ns 1774 ns 394600 +StdFunction_callMethod::returnVoid 1785 ns 1784 ns 392790 + +RtlFunction_call::returnVoid 1773 ns 1773 ns 394658 +RtlFunction_callMethod::returnVoid 1775 ns 1775 ns 394979 + +RtlFunction_call_ReturnUnknown::Void 1786 ns 1785 ns 392102 +RtlFunction_callMethod_ReturnUnknown::Void 1779 ns 1779 ns 393901 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1782 ns 1782 ns 393097 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2034 ns 2034 ns 344484 + +NativeFunctionPtr_call::returnNonVoid 2030 ns 2030 ns 344790 +NativeFunctionPtr_callMethod::returnNonVoid 2032 ns 2032 ns 344393 + +StdFunction_call::returnNonVoid 2034 ns 2034 ns 342985 +StdFunction_callMethod::returnNonVoid 2040 ns 2040 ns 343340 + +RtlFunction_call::returnNonVoid 2034 ns 2033 ns 344828 +RtlFunction_callMethod::returnNonVoid 2030 ns 2030 ns 344623 + +RtlFunction_call_ReturnUnknown::NonVoid 2065 ns 2065 ns 339605 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2055 ns 2054 ns 340562 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2066 ns 2066 ns 339528 +----------------------------------- +[2025-10-09 22:41:31] >>> Run 5: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-10-09T22:41:31+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1759 ns 1759 ns 398238 + +NativeFunctionPtr_call::returnVoid 1761 ns 1761 ns 397991 +NativeFunctionPtr_callMethod::returnVoid 1760 ns 1759 ns 397731 + +StdFunction_call::returnVoid 1759 ns 1759 ns 397634 +StdFunction_callMethod::returnVoid 1769 ns 1769 ns 395694 + +RtlFunction_call::returnVoid 1760 ns 1759 ns 398155 +RtlFunction_callMethod::returnVoid 1760 ns 1760 ns 397884 + +RtlFunction_call_ReturnUnknown::Void 1768 ns 1767 ns 395892 +RtlFunction_callMethod_ReturnUnknown::Void 1761 ns 1761 ns 397262 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1772 ns 1771 ns 395650 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 1977 ns 1977 ns 353581 + +NativeFunctionPtr_call::returnNonVoid 1975 ns 1975 ns 354607 +NativeFunctionPtr_callMethod::returnNonVoid 1975 ns 1975 ns 354429 + +StdFunction_call::returnNonVoid 1977 ns 1977 ns 354100 +StdFunction_callMethod::returnNonVoid 1990 ns 1990 ns 351306 + +RtlFunction_call::returnNonVoid 1974 ns 1974 ns 354710 +RtlFunction_callMethod::returnNonVoid 1974 ns 1974 ns 354700 + +RtlFunction_call_ReturnUnknown::NonVoid 2009 ns 2008 ns 348830 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2000 ns 2000 ns 349537 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2004 ns 2004 ns 349186 +----------------------------------- +[2025-10-09 22:41:49] >>> Run 1: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-10-09T22:41:49+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1825 ns 1825 ns 382826 + +NativeFunctionPtr_call::returnVoid 1828 ns 1828 ns 382809 +NativeFunctionPtr_callMethod::returnVoid 1828 ns 1828 ns 382836 + +StdFunction_call::returnVoid 1829 ns 1829 ns 383031 +StdFunction_callMethod::returnVoid 1827 ns 1827 ns 383073 + +RtlFunction_call::returnVoid 1827 ns 1827 ns 383289 +RtlFunction_callMethod::returnVoid 1827 ns 1827 ns 383090 + +RtlFunction_call_ReturnUnknown::Void 1833 ns 1833 ns 382184 +RtlFunction_callMethod_ReturnUnknown::Void 1831 ns 1831 ns 382123 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1831 ns 1831 ns 382028 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2058 ns 2058 ns 339842 + +NativeFunctionPtr_call::returnNonVoid 2060 ns 2060 ns 339863 +NativeFunctionPtr_callMethod::returnNonVoid 2060 ns 2060 ns 339965 + +StdFunction_call::returnNonVoid 2061 ns 2061 ns 339854 +StdFunction_callMethod::returnNonVoid 2059 ns 2059 ns 340183 + +RtlFunction_call::returnNonVoid 2060 ns 2060 ns 339724 +RtlFunction_callMethod::returnNonVoid 2060 ns 2060 ns 339734 + +RtlFunction_call_ReturnUnknown::NonVoid 2081 ns 2080 ns 336513 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2072 ns 2072 ns 337885 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2076 ns 2076 ns 337164 +----------------------------------- +[2025-10-09 22:42:08] >>> Run 2: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-10-09T22:42:08+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.08, 1.02, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1835 ns 1834 ns 381565 + +NativeFunctionPtr_call::returnVoid 1833 ns 1833 ns 381819 +NativeFunctionPtr_callMethod::returnVoid 1825 ns 1825 ns 382935 + +StdFunction_call::returnVoid 1826 ns 1826 ns 383228 +StdFunction_callMethod::returnVoid 1831 ns 1831 ns 382737 + +RtlFunction_call::returnVoid 1826 ns 1825 ns 383644 +RtlFunction_callMethod::returnVoid 1823 ns 1823 ns 383323 + +RtlFunction_call_ReturnUnknown::Void 1831 ns 1830 ns 382699 +RtlFunction_callMethod_ReturnUnknown::Void 1826 ns 1826 ns 383607 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1831 ns 1831 ns 381873 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2059 ns 2059 ns 340004 + +NativeFunctionPtr_call::returnNonVoid 2064 ns 2064 ns 338970 +NativeFunctionPtr_callMethod::returnNonVoid 2064 ns 2064 ns 339262 + +StdFunction_call::returnNonVoid 2065 ns 2065 ns 339070 +StdFunction_callMethod::returnNonVoid 2071 ns 2071 ns 338202 + +RtlFunction_call::returnNonVoid 2063 ns 2063 ns 339252 +RtlFunction_callMethod::returnNonVoid 2064 ns 2064 ns 339093 + +RtlFunction_call_ReturnUnknown::NonVoid 2086 ns 2086 ns 335254 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2078 ns 2078 ns 336857 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2085 ns 2085 ns 335233 +----------------------------------- +[2025-10-09 22:42:26] >>> Run 3: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-10-09T22:42:26+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 1.02, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1848 ns 1848 ns 378323 + +NativeFunctionPtr_call::returnVoid 1850 ns 1850 ns 378621 +NativeFunctionPtr_callMethod::returnVoid 1845 ns 1845 ns 379576 + +StdFunction_call::returnVoid 1846 ns 1846 ns 379452 +StdFunction_callMethod::returnVoid 1851 ns 1851 ns 378151 + +RtlFunction_call::returnVoid 1846 ns 1846 ns 379187 +RtlFunction_callMethod::returnVoid 1846 ns 1846 ns 379242 + +RtlFunction_call_ReturnUnknown::Void 1859 ns 1859 ns 376224 +RtlFunction_callMethod_ReturnUnknown::Void 1854 ns 1854 ns 377715 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1861 ns 1860 ns 376177 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2076 ns 2076 ns 337143 + +NativeFunctionPtr_call::returnNonVoid 2078 ns 2077 ns 337457 +NativeFunctionPtr_callMethod::returnNonVoid 2077 ns 2077 ns 337143 + +StdFunction_call::returnNonVoid 2077 ns 2076 ns 336986 +StdFunction_callMethod::returnNonVoid 2083 ns 2083 ns 336041 + +RtlFunction_call::returnNonVoid 2076 ns 2076 ns 337229 +RtlFunction_callMethod::returnNonVoid 2078 ns 2077 ns 336822 + +RtlFunction_call_ReturnUnknown::NonVoid 2120 ns 2119 ns 330714 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2102 ns 2102 ns 332859 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2116 ns 2116 ns 330867 +----------------------------------- +[2025-10-09 22:42:44] >>> Run 4: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-10-09T22:42:44+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1873 ns 1873 ns 373623 + +NativeFunctionPtr_call::returnVoid 1877 ns 1877 ns 372676 +NativeFunctionPtr_callMethod::returnVoid 1874 ns 1874 ns 373712 + +StdFunction_call::returnVoid 1874 ns 1874 ns 373609 +StdFunction_callMethod::returnVoid 1877 ns 1877 ns 372992 + +RtlFunction_call::returnVoid 1875 ns 1875 ns 373439 +RtlFunction_callMethod::returnVoid 1873 ns 1873 ns 373683 + +RtlFunction_call_ReturnUnknown::Void 1881 ns 1881 ns 372270 +RtlFunction_callMethod_ReturnUnknown::Void 1874 ns 1874 ns 373602 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1881 ns 1881 ns 371886 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2151 ns 2151 ns 325389 + +NativeFunctionPtr_call::returnNonVoid 2156 ns 2155 ns 324646 +NativeFunctionPtr_callMethod::returnNonVoid 2155 ns 2155 ns 324623 + +StdFunction_call::returnNonVoid 2157 ns 2156 ns 324551 +StdFunction_callMethod::returnNonVoid 2162 ns 2161 ns 323798 + +RtlFunction_call::returnNonVoid 2155 ns 2155 ns 324812 +RtlFunction_callMethod::returnNonVoid 2156 ns 2156 ns 324764 + +RtlFunction_call_ReturnUnknown::NonVoid 2179 ns 2179 ns 321245 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2174 ns 2174 ns 321847 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2183 ns 2183 ns 320763 +----------------------------------- +[2025-10-09 22:43:03] >>> Run 5: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-10-09T22:43:03+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1826 ns 1825 ns 382952 + +NativeFunctionPtr_call::returnVoid 1828 ns 1828 ns 383457 +NativeFunctionPtr_callMethod::returnVoid 1827 ns 1827 ns 383968 + +StdFunction_call::returnVoid 1825 ns 1825 ns 383632 +StdFunction_callMethod::returnVoid 1829 ns 1829 ns 382087 + +RtlFunction_call::returnVoid 1826 ns 1825 ns 383082 +RtlFunction_callMethod::returnVoid 1825 ns 1825 ns 382945 + +RtlFunction_call_ReturnUnknown::Void 1829 ns 1829 ns 382941 +RtlFunction_callMethod_ReturnUnknown::Void 1825 ns 1825 ns 383782 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1830 ns 1830 ns 382649 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2057 ns 2057 ns 340422 + +NativeFunctionPtr_call::returnNonVoid 2062 ns 2062 ns 339517 +NativeFunctionPtr_callMethod::returnNonVoid 2062 ns 2062 ns 339289 + +StdFunction_call::returnNonVoid 2063 ns 2063 ns 339492 +StdFunction_callMethod::returnNonVoid 2064 ns 2064 ns 339182 + +RtlFunction_call::returnNonVoid 2061 ns 2061 ns 339423 +RtlFunction_callMethod::returnNonVoid 2062 ns 2062 ns 339404 + +RtlFunction_call_ReturnUnknown::NonVoid 2082 ns 2082 ns 335859 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2077 ns 2077 ns 336963 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2084 ns 2083 ns 336077 +----------------------------------- +[2025-10-09 22:43:21] >>> Run 1: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-10-09T22:43:21+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1915 ns 1914 ns 365590 + +NativeFunctionPtr_call::returnVoid 1917 ns 1917 ns 365411 +NativeFunctionPtr_callMethod::returnVoid 1916 ns 1915 ns 365174 + +StdFunction_call::returnVoid 1915 ns 1915 ns 365658 +StdFunction_callMethod::returnVoid 1919 ns 1919 ns 365034 + +RtlFunction_call::returnVoid 1916 ns 1916 ns 365570 +RtlFunction_callMethod::returnVoid 1917 ns 1916 ns 365394 + +RtlFunction_call_ReturnUnknown::Void 1925 ns 1925 ns 364387 +RtlFunction_callMethod_ReturnUnknown::Void 1925 ns 1925 ns 363779 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1930 ns 1930 ns 362633 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2222 ns 2222 ns 314861 + +NativeFunctionPtr_call::returnNonVoid 2220 ns 2220 ns 315456 +NativeFunctionPtr_callMethod::returnNonVoid 2220 ns 2219 ns 315353 + +StdFunction_call::returnNonVoid 2223 ns 2222 ns 314941 +StdFunction_callMethod::returnNonVoid 2225 ns 2225 ns 314549 + +RtlFunction_call::returnNonVoid 2221 ns 2220 ns 315626 +RtlFunction_callMethod::returnNonVoid 2222 ns 2222 ns 315388 + +RtlFunction_call_ReturnUnknown::NonVoid 2249 ns 2248 ns 311471 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2242 ns 2241 ns 312265 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2248 ns 2248 ns 310921 +----------------------------------- +[2025-10-09 22:43:40] >>> Run 2: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-10-09T22:43:40+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1950 ns 1950 ns 358882 + +NativeFunctionPtr_call::returnVoid 1933 ns 1933 ns 361914 +NativeFunctionPtr_callMethod::returnVoid 1934 ns 1933 ns 360542 + +StdFunction_call::returnVoid 1934 ns 1934 ns 362422 +StdFunction_callMethod::returnVoid 1923 ns 1922 ns 364490 + +RtlFunction_call::returnVoid 1932 ns 1932 ns 361923 +RtlFunction_callMethod::returnVoid 1937 ns 1937 ns 362152 + +RtlFunction_call_ReturnUnknown::Void 1923 ns 1923 ns 364112 +RtlFunction_callMethod_ReturnUnknown::Void 1919 ns 1919 ns 365375 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1920 ns 1920 ns 364660 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2216 ns 2216 ns 316147 + +NativeFunctionPtr_call::returnNonVoid 2187 ns 2187 ns 319749 +NativeFunctionPtr_callMethod::returnNonVoid 2185 ns 2185 ns 320097 + +StdFunction_call::returnNonVoid 2187 ns 2187 ns 318705 +StdFunction_callMethod::returnNonVoid 2185 ns 2184 ns 320225 + +RtlFunction_call::returnNonVoid 2192 ns 2191 ns 320106 +RtlFunction_callMethod::returnNonVoid 2187 ns 2187 ns 320212 + +RtlFunction_call_ReturnUnknown::NonVoid 2208 ns 2207 ns 317529 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2197 ns 2197 ns 318468 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2208 ns 2208 ns 317680 +----------------------------------- +[2025-10-09 22:43:58] >>> Run 3: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-10-09T22:43:58+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.01, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1933 ns 1933 ns 361796 + +NativeFunctionPtr_call::returnVoid 1939 ns 1938 ns 361665 +NativeFunctionPtr_callMethod::returnVoid 1934 ns 1933 ns 362333 + +StdFunction_call::returnVoid 1937 ns 1936 ns 362278 +StdFunction_callMethod::returnVoid 1936 ns 1936 ns 361500 + +RtlFunction_call::returnVoid 1934 ns 1933 ns 362382 +RtlFunction_callMethod::returnVoid 1933 ns 1933 ns 360283 + +RtlFunction_call_ReturnUnknown::Void 1941 ns 1941 ns 360321 +RtlFunction_callMethod_ReturnUnknown::Void 1941 ns 1941 ns 361662 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1942 ns 1941 ns 360918 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2201 ns 2201 ns 318760 + +NativeFunctionPtr_call::returnNonVoid 2194 ns 2194 ns 318782 +NativeFunctionPtr_callMethod::returnNonVoid 2198 ns 2198 ns 318698 + +StdFunction_call::returnNonVoid 2198 ns 2198 ns 318178 +StdFunction_callMethod::returnNonVoid 2205 ns 2205 ns 317905 + +RtlFunction_call::returnNonVoid 2196 ns 2195 ns 318521 +RtlFunction_callMethod::returnNonVoid 2198 ns 2198 ns 318881 + +RtlFunction_call_ReturnUnknown::NonVoid 2231 ns 2231 ns 313880 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2220 ns 2220 ns 315109 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2227 ns 2227 ns 312692 +----------------------------------- +[2025-10-09 22:44:17] >>> Run 4: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-10-09T22:44:17+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1915 ns 1914 ns 365356 + +NativeFunctionPtr_call::returnVoid 1919 ns 1919 ns 363376 +NativeFunctionPtr_callMethod::returnVoid 1916 ns 1916 ns 365649 + +StdFunction_call::returnVoid 1919 ns 1919 ns 365532 +StdFunction_callMethod::returnVoid 1919 ns 1919 ns 364911 + +RtlFunction_call::returnVoid 1918 ns 1918 ns 365585 +RtlFunction_callMethod::returnVoid 1916 ns 1916 ns 364302 + +RtlFunction_call_ReturnUnknown::Void 1924 ns 1924 ns 364010 +RtlFunction_callMethod_ReturnUnknown::Void 1921 ns 1921 ns 364316 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1924 ns 1924 ns 363660 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2178 ns 2177 ns 320166 + +NativeFunctionPtr_call::returnNonVoid 2178 ns 2178 ns 321284 +NativeFunctionPtr_callMethod::returnNonVoid 2179 ns 2178 ns 320312 + +StdFunction_call::returnNonVoid 2179 ns 2179 ns 321510 +StdFunction_callMethod::returnNonVoid 2190 ns 2190 ns 320512 + +RtlFunction_call::returnNonVoid 2179 ns 2179 ns 321585 +RtlFunction_callMethod::returnNonVoid 2181 ns 2181 ns 321088 + +RtlFunction_call_ReturnUnknown::NonVoid 2209 ns 2209 ns 316939 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2206 ns 2206 ns 317901 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2213 ns 2213 ns 316659 +----------------------------------- +[2025-10-09 22:44:35] >>> Run 5: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-10-09T22:44:35+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 799.718 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 1931 ns 1931 ns 363432 + +NativeFunctionPtr_call::returnVoid 1926 ns 1926 ns 363081 +NativeFunctionPtr_callMethod::returnVoid 1929 ns 1928 ns 361320 + +StdFunction_call::returnVoid 1926 ns 1925 ns 363575 +StdFunction_callMethod::returnVoid 1928 ns 1928 ns 363309 + +RtlFunction_call::returnVoid 1925 ns 1925 ns 361987 +RtlFunction_callMethod::returnVoid 1926 ns 1926 ns 363698 + +RtlFunction_call_ReturnUnknown::Void 1938 ns 1938 ns 361939 +RtlFunction_callMethod_ReturnUnknown::Void 1927 ns 1927 ns 363365 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1935 ns 1935 ns 362379 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2226 ns 2226 ns 314431 + +NativeFunctionPtr_call::returnNonVoid 2235 ns 2235 ns 313549 +NativeFunctionPtr_callMethod::returnNonVoid 2232 ns 2232 ns 313726 + +StdFunction_call::returnNonVoid 2237 ns 2237 ns 313224 +StdFunction_callMethod::returnNonVoid 2234 ns 2233 ns 313533 + +RtlFunction_call::returnNonVoid 2235 ns 2235 ns 313494 +RtlFunction_callMethod::returnNonVoid 2232 ns 2231 ns 313624 + +RtlFunction_call_ReturnUnknown::NonVoid 2248 ns 2248 ns 311433 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2244 ns 2244 ns 310568 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2250 ns 2250 ns 311259 +----------------------------------- +[2025-10-09 22:44:54] >>> Run 1: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-10-09T22:44:54+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 2127 ns 2126 ns 327584 + +NativeFunctionPtr_call::returnVoid 2126 ns 2126 ns 329705 +NativeFunctionPtr_callMethod::returnVoid 2127 ns 2127 ns 329783 + +StdFunction_call::returnVoid 2124 ns 2123 ns 329620 +StdFunction_callMethod::returnVoid 2135 ns 2135 ns 328409 + +RtlFunction_call::returnVoid 2124 ns 2124 ns 329789 +RtlFunction_callMethod::returnVoid 2127 ns 2127 ns 329843 + +RtlFunction_call_ReturnUnknown::Void 2136 ns 2136 ns 327334 +RtlFunction_callMethod_ReturnUnknown::Void 2130 ns 2129 ns 329277 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2134 ns 2134 ns 328114 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2575 ns 2575 ns 272452 + +NativeFunctionPtr_call::returnNonVoid 2567 ns 2567 ns 272643 +NativeFunctionPtr_callMethod::returnNonVoid 2572 ns 2571 ns 272647 + +StdFunction_call::returnNonVoid 2571 ns 2570 ns 272249 +StdFunction_callMethod::returnNonVoid 2576 ns 2575 ns 271922 + +RtlFunction_call::returnNonVoid 2567 ns 2567 ns 272553 +RtlFunction_callMethod::returnNonVoid 2568 ns 2568 ns 272648 + +RtlFunction_call_ReturnUnknown::NonVoid 2605 ns 2605 ns 267798 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2600 ns 2600 ns 269023 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2610 ns 2610 ns 266981 +----------------------------------- +[2025-10-09 22:45:13] >>> Run 2: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-10-09T22:45:13+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 2146 ns 2145 ns 326094 + +NativeFunctionPtr_call::returnVoid 2148 ns 2147 ns 323370 +NativeFunctionPtr_callMethod::returnVoid 2144 ns 2144 ns 326373 + +StdFunction_call::returnVoid 2146 ns 2146 ns 326429 +StdFunction_callMethod::returnVoid 2145 ns 2145 ns 326412 + +RtlFunction_call::returnVoid 2146 ns 2146 ns 326763 +RtlFunction_callMethod::returnVoid 2144 ns 2144 ns 326623 + +RtlFunction_call_ReturnUnknown::Void 2128 ns 2128 ns 329583 +RtlFunction_callMethod_ReturnUnknown::Void 2118 ns 2117 ns 330471 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2133 ns 2133 ns 329135 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2599 ns 2599 ns 269327 + +NativeFunctionPtr_call::returnNonVoid 2604 ns 2604 ns 269268 +NativeFunctionPtr_callMethod::returnNonVoid 2601 ns 2601 ns 269194 + +StdFunction_call::returnNonVoid 2610 ns 2609 ns 268917 +StdFunction_callMethod::returnNonVoid 2603 ns 2603 ns 268866 + +RtlFunction_call::returnNonVoid 2604 ns 2604 ns 269245 +RtlFunction_callMethod::returnNonVoid 2601 ns 2601 ns 269132 + +RtlFunction_call_ReturnUnknown::NonVoid 2608 ns 2607 ns 268916 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2595 ns 2595 ns 269755 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2602 ns 2602 ns 269447 +----------------------------------- +[2025-10-09 22:45:33] >>> Run 3: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-10-09T22:45:33+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.00, 1.00 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 2132 ns 2132 ns 328161 + +NativeFunctionPtr_call::returnVoid 2135 ns 2135 ns 327953 +NativeFunctionPtr_callMethod::returnVoid 2132 ns 2132 ns 328259 + +StdFunction_call::returnVoid 2132 ns 2132 ns 328345 +StdFunction_callMethod::returnVoid 2136 ns 2136 ns 327576 + +RtlFunction_call::returnVoid 2132 ns 2131 ns 328339 +RtlFunction_callMethod::returnVoid 2131 ns 2131 ns 328277 + +RtlFunction_call_ReturnUnknown::Void 2141 ns 2141 ns 326811 +RtlFunction_callMethod_ReturnUnknown::Void 2133 ns 2132 ns 328303 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2138 ns 2138 ns 327370 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2576 ns 2576 ns 271756 + +NativeFunctionPtr_call::returnNonVoid 2575 ns 2575 ns 271997 +NativeFunctionPtr_callMethod::returnNonVoid 2576 ns 2576 ns 271924 + +StdFunction_call::returnNonVoid 2578 ns 2577 ns 271665 +StdFunction_callMethod::returnNonVoid 2580 ns 2579 ns 271431 + +RtlFunction_call::returnNonVoid 2580 ns 2580 ns 268885 +RtlFunction_callMethod::returnNonVoid 2582 ns 2581 ns 271163 + +RtlFunction_call_ReturnUnknown::NonVoid 2612 ns 2611 ns 268093 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2609 ns 2608 ns 268677 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2609 ns 2609 ns 268332 +----------------------------------- +[2025-10-09 22:45:52] >>> Run 4: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-10-09T22:45:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.08, 1.02, 1.01 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 2117 ns 2116 ns 330320 + +NativeFunctionPtr_call::returnVoid 2116 ns 2115 ns 330510 +NativeFunctionPtr_callMethod::returnVoid 2116 ns 2115 ns 330810 + +StdFunction_call::returnVoid 2115 ns 2114 ns 330719 +StdFunction_callMethod::returnVoid 2120 ns 2120 ns 330247 + +RtlFunction_call::returnVoid 2163 ns 2163 ns 330721 +RtlFunction_callMethod::returnVoid 2112 ns 2112 ns 331151 + +RtlFunction_call_ReturnUnknown::Void 2123 ns 2122 ns 330134 +RtlFunction_callMethod_ReturnUnknown::Void 2115 ns 2114 ns 330945 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2119 ns 2119 ns 328815 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2537 ns 2537 ns 275748 + +NativeFunctionPtr_call::returnNonVoid 2536 ns 2535 ns 276027 +NativeFunctionPtr_callMethod::returnNonVoid 2535 ns 2535 ns 276198 + +StdFunction_call::returnNonVoid 2538 ns 2538 ns 275897 +StdFunction_callMethod::returnNonVoid 2541 ns 2540 ns 275598 + +RtlFunction_call::returnNonVoid 2536 ns 2535 ns 276112 +RtlFunction_callMethod::returnNonVoid 2536 ns 2535 ns 276031 + +RtlFunction_call_ReturnUnknown::NonVoid 2565 ns 2564 ns 272802 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2560 ns 2559 ns 273419 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2608 ns 2608 ns 273229 +----------------------------------- +[2025-10-09 22:46:11] >>> Run 5: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-10-09T22:46:11+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.32, 1.08, 1.03 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 2185 ns 2185 ns 311510 + +NativeFunctionPtr_call::returnVoid 2184 ns 2184 ns 324186 +NativeFunctionPtr_callMethod::returnVoid 2159 ns 2159 ns 324695 + +StdFunction_call::returnVoid 2160 ns 2160 ns 324530 +StdFunction_callMethod::returnVoid 2163 ns 2163 ns 323744 + +RtlFunction_call::returnVoid 2158 ns 2158 ns 324315 +RtlFunction_callMethod::returnVoid 2160 ns 2159 ns 324420 + +RtlFunction_call_ReturnUnknown::Void 2163 ns 2163 ns 323559 +RtlFunction_callMethod_ReturnUnknown::Void 2155 ns 2155 ns 324663 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2165 ns 2165 ns 323713 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 2584 ns 2584 ns 270900 + +NativeFunctionPtr_call::returnNonVoid 2587 ns 2587 ns 270723 +NativeFunctionPtr_callMethod::returnNonVoid 2587 ns 2587 ns 270727 + +StdFunction_call::returnNonVoid 2588 ns 2587 ns 270520 +StdFunction_callMethod::returnNonVoid 2589 ns 2589 ns 270335 + +RtlFunction_call::returnNonVoid 2585 ns 2584 ns 270667 +RtlFunction_callMethod::returnNonVoid 2590 ns 2589 ns 270591 + +RtlFunction_call_ReturnUnknown::NonVoid 2614 ns 2614 ns 267845 +RtlFunction_callMethod_ReturnUnknown::NonVoid 2608 ns 2607 ns 268680 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2620 ns 2619 ns 267332 +----------------------------------- +[2025-10-09 22:46:30] >>> Run 1: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-10-09T22:46:30+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.23, 1.07, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 3499 ns 3499 ns 199937 + +NativeFunctionPtr_call::returnVoid 3501 ns 3501 ns 199944 +NativeFunctionPtr_callMethod::returnVoid 3500 ns 3499 ns 200076 + +StdFunction_call::returnVoid 3500 ns 3499 ns 200104 +StdFunction_callMethod::returnVoid 3507 ns 3506 ns 199590 + +RtlFunction_call::returnVoid 3499 ns 3499 ns 199992 +RtlFunction_callMethod::returnVoid 3499 ns 3498 ns 200046 + +RtlFunction_call_ReturnUnknown::Void 3506 ns 3506 ns 199699 +RtlFunction_callMethod_ReturnUnknown::Void 3504 ns 3503 ns 199923 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3509 ns 3508 ns 199515 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 3969 ns 3968 ns 176496 + +NativeFunctionPtr_call::returnNonVoid 3968 ns 3968 ns 176502 +NativeFunctionPtr_callMethod::returnNonVoid 3968 ns 3968 ns 176426 + +StdFunction_call::returnNonVoid 3969 ns 3969 ns 176325 +StdFunction_callMethod::returnNonVoid 3976 ns 3976 ns 176121 + +RtlFunction_call::returnNonVoid 3967 ns 3967 ns 176388 +RtlFunction_callMethod::returnNonVoid 3969 ns 3968 ns 176396 + +RtlFunction_call_ReturnUnknown::NonVoid 4011 ns 4010 ns 174538 +RtlFunction_callMethod_ReturnUnknown::NonVoid 3993 ns 3993 ns 175317 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 3998 ns 3998 ns 175120 +----------------------------------- +[2025-10-09 22:46:53] >>> Run 2: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-10-09T22:46:53+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.15, 1.07, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 3487 ns 3487 ns 200624 + +NativeFunctionPtr_call::returnVoid 3487 ns 3487 ns 200797 +NativeFunctionPtr_callMethod::returnVoid 3485 ns 3485 ns 200903 + +StdFunction_call::returnVoid 3485 ns 3485 ns 200885 +StdFunction_callMethod::returnVoid 3492 ns 3492 ns 200459 + +RtlFunction_call::returnVoid 3486 ns 3485 ns 200836 +RtlFunction_callMethod::returnVoid 3485 ns 3484 ns 200811 + +RtlFunction_call_ReturnUnknown::Void 3498 ns 3497 ns 200154 +RtlFunction_callMethod_ReturnUnknown::Void 3492 ns 3492 ns 200479 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3495 ns 3495 ns 200337 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 3957 ns 3956 ns 176928 + +NativeFunctionPtr_call::returnNonVoid 3953 ns 3953 ns 177062 +NativeFunctionPtr_callMethod::returnNonVoid 3953 ns 3953 ns 176987 + +StdFunction_call::returnNonVoid 3957 ns 3956 ns 176999 +StdFunction_callMethod::returnNonVoid 3966 ns 3966 ns 176485 + +RtlFunction_call::returnNonVoid 3954 ns 3954 ns 176831 +RtlFunction_callMethod::returnNonVoid 3953 ns 3953 ns 177027 + +RtlFunction_call_ReturnUnknown::NonVoid 3990 ns 3989 ns 175588 +RtlFunction_callMethod_ReturnUnknown::NonVoid 3985 ns 3985 ns 175753 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 3992 ns 3991 ns 175344 +----------------------------------- +[2025-10-09 22:47:15] >>> Run 3: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-10-09T22:47:15+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.11, 1.06, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 3486 ns 3486 ns 200956 + +NativeFunctionPtr_call::returnVoid 3487 ns 3486 ns 200747 +NativeFunctionPtr_callMethod::returnVoid 3484 ns 3484 ns 200875 + +StdFunction_call::returnVoid 3485 ns 3484 ns 200789 +StdFunction_callMethod::returnVoid 3488 ns 3487 ns 200722 + +RtlFunction_call::returnVoid 3485 ns 3485 ns 200870 +RtlFunction_callMethod::returnVoid 3487 ns 3487 ns 200780 + +RtlFunction_call_ReturnUnknown::Void 3495 ns 3495 ns 200222 +RtlFunction_callMethod_ReturnUnknown::Void 3486 ns 3486 ns 200746 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3488 ns 3488 ns 200524 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 3963 ns 3962 ns 176670 + +NativeFunctionPtr_call::returnNonVoid 3954 ns 3954 ns 177006 +NativeFunctionPtr_callMethod::returnNonVoid 3955 ns 3954 ns 177009 + +StdFunction_call::returnNonVoid 3956 ns 3956 ns 177000 +StdFunction_callMethod::returnNonVoid 3957 ns 3957 ns 176882 + +RtlFunction_call::returnNonVoid 3953 ns 3953 ns 177049 +RtlFunction_callMethod::returnNonVoid 3955 ns 3954 ns 177008 + +RtlFunction_call_ReturnUnknown::NonVoid 3986 ns 3986 ns 175626 +RtlFunction_callMethod_ReturnUnknown::NonVoid 3981 ns 3980 ns 175785 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 3991 ns 3990 ns 175430 +----------------------------------- +[2025-10-09 22:47:37] >>> Run 4: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-10-09T22:47:37+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.08, 1.06, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 3549 ns 3549 ns 197165 + +NativeFunctionPtr_call::returnVoid 3549 ns 3548 ns 197318 +NativeFunctionPtr_callMethod::returnVoid 3546 ns 3546 ns 197387 + +StdFunction_call::returnVoid 3546 ns 3546 ns 197389 +StdFunction_callMethod::returnVoid 3551 ns 3551 ns 197181 + +RtlFunction_call::returnVoid 3546 ns 3546 ns 197414 +RtlFunction_callMethod::returnVoid 3546 ns 3545 ns 197496 + +RtlFunction_call_ReturnUnknown::Void 3555 ns 3554 ns 196865 +RtlFunction_callMethod_ReturnUnknown::Void 3558 ns 3557 ns 196840 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3562 ns 3561 ns 196448 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 4075 ns 4075 ns 171802 + +NativeFunctionPtr_call::returnNonVoid 4074 ns 4074 ns 171810 +NativeFunctionPtr_callMethod::returnNonVoid 4074 ns 4074 ns 171823 + +StdFunction_call::returnNonVoid 4078 ns 4077 ns 171735 +StdFunction_callMethod::returnNonVoid 4080 ns 4080 ns 171580 + +RtlFunction_call::returnNonVoid 4074 ns 4074 ns 171809 +RtlFunction_callMethod::returnNonVoid 4075 ns 4075 ns 171782 + +RtlFunction_call_ReturnUnknown::NonVoid 4112 ns 4112 ns 170240 +RtlFunction_callMethod_ReturnUnknown::NonVoid 4104 ns 4103 ns 170511 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 4110 ns 4109 ns 170348 +----------------------------------- +[2025-10-09 22:48:00] >>> Run 5: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-10-09T22:48:00+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.05, 1.05, 1.02 +----------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +----------------------------------------------------------------------------------------------------- +NativeCall::returnVoid 3501 ns 3501 ns 200070 + +NativeFunctionPtr_call::returnVoid 3502 ns 3502 ns 199961 +NativeFunctionPtr_callMethod::returnVoid 3500 ns 3499 ns 200004 + +StdFunction_call::returnVoid 3500 ns 3499 ns 200110 +StdFunction_callMethod::returnVoid 3503 ns 3503 ns 199929 + +RtlFunction_call::returnVoid 3498 ns 3498 ns 200098 +RtlFunction_callMethod::returnVoid 3498 ns 3498 ns 200061 + +RtlFunction_call_ReturnUnknown::Void 3518 ns 3518 ns 199005 +RtlFunction_callMethod_ReturnUnknown::Void 3507 ns 3507 ns 199664 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3513 ns 3513 ns 199195 +----------------------------------------------------------------------------------------------------- +NativeCall::returnNonVoid 3974 ns 3973 ns 176195 + +NativeFunctionPtr_call::returnNonVoid 3970 ns 3970 ns 176307 +NativeFunctionPtr_callMethod::returnNonVoid 3970 ns 3970 ns 176351 + +StdFunction_call::returnNonVoid 3974 ns 3973 ns 176208 +StdFunction_callMethod::returnNonVoid 3984 ns 3984 ns 175710 + +RtlFunction_call::returnNonVoid 3971 ns 3971 ns 176261 +RtlFunction_callMethod::returnNonVoid 3971 ns 3971 ns 176279 + +RtlFunction_call_ReturnUnknown::NonVoid 4010 ns 4010 ns 174663 +RtlFunction_callMethod_ReturnUnknown::NonVoid 4004 ns 4003 ns 174832 +RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 4006 ns 4006 ns 174751 +----------------------------------- +All benchmarks completed. From 2de39de4eef2ef29c24bbd150cea501629c4be8e Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 10 Oct 2025 14:46:28 +0530 Subject: [PATCH 075/148] more test cases. --- CxxTestProps/inc/ComplexStrings.h | 2 + CxxTestProps/src/ComplexStrings.cpp | 9 ++ .../src/TestMirrorProvider.cpp | 3 +- CxxTestUtils/inc/GlobalTestUtils.h | 4 +- .../StrictStaticTypeDispatch.cpp | 106 ++++++++++++++++++ .../BasicTypeErasedDispatch.cpp | 26 ++++- 6 files changed, 146 insertions(+), 4 deletions(-) diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/ComplexStrings.h index e1c0365e..33d68517 100644 --- a/CxxTestProps/inc/ComplexStrings.h +++ b/CxxTestProps/inc/ComplexStrings.h @@ -33,6 +33,8 @@ std::string revStrConstRefArg(const std::string_view& pStr); std::string revStrNonConstRefArg(std::string_view& pStr); +std::string revStrRValueRefArg(std::string_view&& pStr); + std::string revStrOverloadValRef(std::string_view pStr); std::string revStrOverloadValRef(std::string_view& pStr); diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/ComplexStrings.cpp index 57211ea1..58a864fb 100644 --- a/CxxTestProps/src/ComplexStrings.cpp +++ b/CxxTestProps/src/ComplexStrings.cpp @@ -48,6 +48,7 @@ namespace test_utils { const char* SUFFIX_ARG_std_string_view = "_arg_std::string_view"; const char* SUFFIX_ARG_std_string_view_lvref = "_arg_std::string_view&"; + const char* SUFFIX_ARG_std_string_view_rvref = "_arg_std::string_view&&"; const char* SUFFIX_ARG_std_string_view_clvref = "_arg_const_std::string_view&"; } @@ -123,6 +124,14 @@ std::string revStrConstRefArg(const std::string_view& pStr) } +std::string revStrRValueRefArg(std::string_view&& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_rvref; +} + + std::string revStrNonConstRefArg(std::string_view& pStr) { std::string retStr(pStr); diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 571ff5a9..14f0cc68 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -112,8 +112,9 @@ namespace test_mirror rtl::type().function(str_reverseString).build(reverseString), rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_revStrConstRefArg).build(revStrConstRefArg), rtl::type().function(str_revStrNonConstRefArg).build(revStrNonConstRefArg), + rtl::type().function(str_revStrRValueRefArg).build(revStrRValueRefArg), + rtl::type().function(str_revStrConstRefArg).build(revStrConstRefArg), rtl::type().function(str_revStrOverloadValRef).build(revStrOverloadValRef), rtl::type().function(str_revStrOverloadValRef).build(revStrOverloadValRef), diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index 4cc43f96..f00e4482 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -22,6 +22,7 @@ namespace test_utils { extern const char* SUFFIX_ARG_std_string_view; extern const char* SUFFIX_ARG_std_string_view_lvref; + extern const char* SUFFIX_ARG_std_string_view_rvref; extern const char* SUFFIX_ARG_std_string_view_clvref; extern const char* REV_STR_VOID_RET; @@ -35,8 +36,9 @@ namespace test_utils { static constexpr const char* STRB = "cxxReflection"; static constexpr const char* STRB_REVERSE = "noitcelfeRxxc"; - static constexpr const char* str_reverseString = "reverseString"; + static constexpr const char* str_reverseString = "reverseString"; static constexpr const char* str_revStrConstRefArg = "revStrConstRefArg"; + static constexpr const char* str_revStrRValueRefArg = "revStrRValueRefArg"; static constexpr const char* str_revStrNonConstRefArg = "revStrNonConstRefArg"; static constexpr const char* str_revStrOverloadValRef = "revStrOverloadValRef"; static constexpr const char* str_revStrOverloadValCRef = "revStrOverloadValCRef"; diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp index a4c15969..37d51c89 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp @@ -249,4 +249,110 @@ namespace rtl_tests EXPECT_FALSE(is_empty("view_not_empty")); } } + + + TEST(StrictStaticTypeDispatch, distinct_functions_with_ref_args_call_with_known_signature) + { + std::string str = STRA; + { + std::optional reverseString = cxx::mirror().getFunction(str_revStrConstRefArg); + ASSERT_TRUE(reverseString); + + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(ret_str, exp_str); + } { + std::optional reverseString = cxx::mirror().getFunction(str_revStrNonConstRefArg); + ASSERT_TRUE(reverseString); + + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + auto lvstr = std::string_view(str); + std::string ret_str = reverse_string(lvstr); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(ret_str, exp_str); + } { + std::optional reverseString = cxx::mirror().getFunction(str_revStrRValueRefArg); + ASSERT_TRUE(reverseString); + + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(str)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeDispatch, overloads_with_ref_and_value_args_call_with_known_signature) + { + std::optional reverseString = cxx::mirror().getFunction(str_revStrOverloadValRef); + ASSERT_TRUE(reverseString); + { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string_view str = STRA; + std::string ret_str = reverse_string(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeDispatch, overloads_with_const_ref_and_value_args_call_with_known_signature) + { + std::optional reverseString = cxx::mirror().getFunction(str_revStrOverloadValCRef); + ASSERT_TRUE(reverseString); + { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeDispatch, overloads_with_ref_and_const_ref_args_call_with_known_signature) + { + std::optional reverseString = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(reverseString); + { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string_view str = STRA; + std::string ret_str = reverse_string(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::function reverse_string = reverseString->argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(ret_str, exp_str); + } + } } \ No newline at end of file diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index 8c1ca284..f1179611 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -261,6 +261,29 @@ namespace rtl_tests } + TEST(BasicTypeErasedDispatch, calling_non_overloaded_rvalue_ref_argument) + { + auto revStrRValueRefArgOpt = cxx::mirror().getFunction(str_revStrRValueRefArg); + ASSERT_TRUE(revStrRValueRefArgOpt); + + rtl::Function revStrRValueRefArg = *revStrRValueRefArgOpt; + { + auto [err, robj] = revStrRValueRefArg(std::string_view(STRA)); + EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + } { + auto [err, robj] = revStrRValueRefArg.bind().call(std::string_view(STRA)); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + EXPECT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + EXPECT_EQ(retStr, expStr); + } + } + + TEST(BasicTypeErasedDispatch, implicit_resolution_to_ambiguous_ref_and_cref_overload) { auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); @@ -297,8 +320,7 @@ namespace rtl_tests const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; EXPECT_EQ(retStr, expStr); - } - { + } { // Explicitly selecting the const ref overload. // Note: If only 'const T&' existed, RTL would have resolved it implicitly. // But since both 'T&' and 'const T&' overloads are available, From 953b13ccdf30e8f1b5005bc99d170ce704b3f99f Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 10 Oct 2025 15:14:33 +0530 Subject: [PATCH 076/148] few better renames. --- .../src/ReflectedCallKnownReturn.cpp | 8 ++++---- .../src/ReflectedCallKnownReturn.h | 4 ++-- .../src/ReflectedCallUnknownReturn.cpp | 12 +++++------ .../src/ReflectedCallUnknownReturn.h | 8 ++++---- RTLBenchmarkApp/src/main.cpp | 20 +++++++++---------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index cd0c36fd..7c20cfe7 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -139,7 +139,7 @@ void NativeFunctionPtr_callMethod::returnVoid(benchmark::State& state) -void RtlFunction_call::returnNonVoid(benchmark::State &state) +void RtlStaticTyped_call::returnNonVoid(benchmark::State &state) { static auto _ = _new_line(); static auto is_ok = test(getMessage, 3); @@ -149,7 +149,7 @@ void RtlFunction_call::returnNonVoid(benchmark::State &state) } } -void RtlFunction_callMethod::returnNonVoid(benchmark::State& state) +void RtlStaticTyped_callMethod::returnNonVoid(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(getMessageNode, 4); @@ -159,7 +159,7 @@ void RtlFunction_callMethod::returnNonVoid(benchmark::State& state) } } -void RtlFunction_call::returnVoid(benchmark::State& state) +void RtlStaticTyped_call::returnVoid(benchmark::State& state) { static auto _ = _new_line(); static auto is_ok = test(sendMessage, 0); @@ -170,7 +170,7 @@ void RtlFunction_call::returnVoid(benchmark::State& state) } } -void RtlFunction_callMethod::returnVoid(benchmark::State& state) +void RtlStaticTyped_callMethod::returnVoid(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(sendMessageNode, 5); diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index 6e369771..9469905f 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -2,7 +2,7 @@ #include -struct RtlFunction_call +struct RtlStaticTyped_call { static void returnVoid(benchmark::State& state); @@ -26,7 +26,7 @@ struct NativeFunctionPtr_callMethod }; -struct RtlFunction_callMethod +struct RtlStaticTyped_callMethod { static void returnVoid(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index cb3a19c0..d59d27a8 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -152,7 +152,7 @@ namespace -void RtlFunction_call_ReturnUnknown::Void(benchmark::State& state) +void RtlErasedType_call_unknownReturn::Void(benchmark::State& state) { static auto __= _new_line(); static auto _ = _test0(); @@ -163,7 +163,7 @@ void RtlFunction_call_ReturnUnknown::Void(benchmark::State& state) } -void RtlFunction_call_ReturnUnknown::NonVoid(benchmark::State& state) +void RtlErasedType_call_unknownReturn::NonVoid(benchmark::State& state) { static auto __= _new_line(); static auto _ = _test2(); @@ -174,7 +174,7 @@ void RtlFunction_call_ReturnUnknown::NonVoid(benchmark::State& state) } -void RtlFunction_callMethod_ReturnUnknown::Void(benchmark::State& state) +void RtlErasedType_callMethod_unknownReturn::Void(benchmark::State& state) { static auto _ = _test1(); static bm::Node node; @@ -185,7 +185,7 @@ void RtlFunction_callMethod_ReturnUnknown::Void(benchmark::State& state) } -void RtlFunction_callMethod_ReturnUnknown::NonVoid(benchmark::State& state) +void RtlErasedType_callMethod_unknownReturn::NonVoid(benchmark::State& state) { static auto _ = _test3(); static bm::Node node; @@ -196,7 +196,7 @@ void RtlFunction_callMethod_ReturnUnknown::NonVoid(benchmark::State& state) } -void RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void(benchmark::State& state) +void RtlErasedType_callMethod_unknownReturn::unknownTarget_Void(benchmark::State& state) { static auto _ = _test4(); for (auto _ : state) @@ -206,7 +206,7 @@ void RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void(benchmark::State& s } -void RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid(benchmark::State& state) +void RtlErasedType_callMethod_unknownReturn::unknownTarget_NonVoid(benchmark::State& state) { static auto _ = _test5(); for (auto _ : state) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index 37e0e049..299bbb00 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -2,7 +2,7 @@ #include -struct RtlFunction_call_ReturnUnknown +struct RtlErasedType_call_unknownReturn { static void Void(benchmark::State& state); @@ -10,13 +10,13 @@ struct RtlFunction_call_ReturnUnknown }; -struct RtlFunction_callMethod_ReturnUnknown +struct RtlErasedType_callMethod_unknownReturn { static void Void(benchmark::State& state); static void NonVoid(benchmark::State& state); - static void erasedTarget_Void(benchmark::State& state); + static void unknownTarget_Void(benchmark::State& state); - static void erasedTarget_NonVoid(benchmark::State& state); + static void unknownTarget_NonVoid(benchmark::State& state); }; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index f0dbc2bb..e6897bb2 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -14,12 +14,12 @@ BENCHMARK(NativeFunctionPtr_callMethod::returnVoid); BENCHMARK(StdFunction_call::returnVoid); BENCHMARK(StdFunction_callMethod::returnVoid); -BENCHMARK(RtlFunction_call::returnVoid); -BENCHMARK(RtlFunction_callMethod::returnVoid); +BENCHMARK(RtlStaticTyped_call::returnVoid); +BENCHMARK(RtlStaticTyped_callMethod::returnVoid); -BENCHMARK(RtlFunction_call_ReturnUnknown::Void); -BENCHMARK(RtlFunction_callMethod_ReturnUnknown::Void); -BENCHMARK(RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void); +BENCHMARK(RtlErasedType_call_unknownReturn::Void); +BENCHMARK(RtlErasedType_callMethod_unknownReturn::Void); +BENCHMARK(RtlErasedType_callMethod_unknownReturn::unknownTarget_Void); BENCHMARK(NativeCall::returnNonVoid); @@ -29,12 +29,12 @@ BENCHMARK(NativeFunctionPtr_callMethod::returnNonVoid); BENCHMARK(StdFunction_call::returnNonVoid); BENCHMARK(StdFunction_callMethod::returnNonVoid); -BENCHMARK(RtlFunction_call::returnNonVoid); -BENCHMARK(RtlFunction_callMethod::returnNonVoid); +BENCHMARK(RtlStaticTyped_call::returnNonVoid); +BENCHMARK(RtlStaticTyped_callMethod::returnNonVoid); -BENCHMARK(RtlFunction_call_ReturnUnknown::NonVoid); -BENCHMARK(RtlFunction_callMethod_ReturnUnknown::NonVoid); -BENCHMARK(RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid); +BENCHMARK(RtlErasedType_call_unknownReturn::NonVoid); +BENCHMARK(RtlErasedType_callMethod_unknownReturn::NonVoid); +BENCHMARK(RtlErasedType_callMethod_unknownReturn::unknownTarget_NonVoid); namespace bm { From 6650dfba90849e51d9102bd3a27d44b3fd406705 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 10 Oct 2025 20:28:20 +0530 Subject: [PATCH 077/148] bind() syntax enabled for new-dispatch-path design. --- .../src/ReflectedCallUnknownReturn.cpp | 12 +-- .../src/ReflectedCallUnknownReturn.h | 16 ++-- RTLBenchmarkApp/src/StandardCall.cpp | 2 +- RTLBenchmarkApp/src/main.cpp | 12 +-- .../BasicTypeErasedDispatch.cpp | 8 +- .../rtl/detail/inc/FunctionCaller.h | 7 +- .../rtl/detail/inc/FunctionCaller.hpp | 89 ++++++++++++------- .../rtl/detail/inc/MethodInvoker.hpp | 4 +- .../rtl/erasure/aware_hopper.h | 14 +-- .../rtl/erasure/aware_hopper_rec.h | 28 ++---- .../rtl/erasure/aware_hopper_rec_const.h | 28 ++---- ReflectionTemplateLib/rtl/inc/Function.h | 12 +-- ReflectionTemplateLib/rtl/inc/Function.hpp | 20 ++++- ReflectionTemplateLib/rtl/inc/Method.h | 2 +- ReflectionTemplateLib/rtl/inc/RObject.h | 2 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 2 +- 16 files changed, 135 insertions(+), 123 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index d59d27a8..2a5be259 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -152,7 +152,7 @@ namespace -void RtlErasedType_call_unknownReturn::Void(benchmark::State& state) +void RtlErasedReturnType_call::returnVoid(benchmark::State& state) { static auto __= _new_line(); static auto _ = _test0(); @@ -163,7 +163,7 @@ void RtlErasedType_call_unknownReturn::Void(benchmark::State& state) } -void RtlErasedType_call_unknownReturn::NonVoid(benchmark::State& state) +void RtlErasedReturnType_call::returnNonVoid(benchmark::State& state) { static auto __= _new_line(); static auto _ = _test2(); @@ -174,7 +174,7 @@ void RtlErasedType_call_unknownReturn::NonVoid(benchmark::State& state) } -void RtlErasedType_callMethod_unknownReturn::Void(benchmark::State& state) +void RtlErasedReturnType_callMethod::returnVoid(benchmark::State& state) { static auto _ = _test1(); static bm::Node node; @@ -185,7 +185,7 @@ void RtlErasedType_callMethod_unknownReturn::Void(benchmark::State& state) } -void RtlErasedType_callMethod_unknownReturn::NonVoid(benchmark::State& state) +void RtlErasedReturnType_callMethod::returnNonVoid(benchmark::State& state) { static auto _ = _test3(); static bm::Node node; @@ -196,7 +196,7 @@ void RtlErasedType_callMethod_unknownReturn::NonVoid(benchmark::State& state) } -void RtlErasedType_callMethod_unknownReturn::unknownTarget_Void(benchmark::State& state) +void RtlErasedReturnType_callMethod::unknownTarget_returnVoid(benchmark::State& state) { static auto _ = _test4(); for (auto _ : state) @@ -206,7 +206,7 @@ void RtlErasedType_callMethod_unknownReturn::unknownTarget_Void(benchmark::State } -void RtlErasedType_callMethod_unknownReturn::unknownTarget_NonVoid(benchmark::State& state) +void RtlErasedReturnType_callMethod::unknownTarget_returnNonVoid(benchmark::State& state) { static auto _ = _test5(); for (auto _ : state) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index 299bbb00..86f271b9 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -2,21 +2,21 @@ #include -struct RtlErasedType_call_unknownReturn +struct RtlErasedReturnType_call { - static void Void(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void NonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); }; -struct RtlErasedType_callMethod_unknownReturn +struct RtlErasedReturnType_callMethod { - static void Void(benchmark::State& state); + static void returnVoid(benchmark::State& state); - static void NonVoid(benchmark::State& state); + static void returnNonVoid(benchmark::State& state); - static void unknownTarget_Void(benchmark::State& state); + static void unknownTarget_returnVoid(benchmark::State& state); - static void unknownTarget_NonVoid(benchmark::State& state); + static void unknownTarget_returnNonVoid(benchmark::State& state); }; \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index f27a11b0..f5f93297 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -10,7 +10,7 @@ namespace { static auto _put_line = []() { - std::cout << "----------------------------------------------" + std::cout << "-----------------------------------------------" "-------------------------------------------------------" << std::endl; return 0; }; diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index e6897bb2..1cae31f9 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -17,9 +17,9 @@ BENCHMARK(StdFunction_callMethod::returnVoid); BENCHMARK(RtlStaticTyped_call::returnVoid); BENCHMARK(RtlStaticTyped_callMethod::returnVoid); -BENCHMARK(RtlErasedType_call_unknownReturn::Void); -BENCHMARK(RtlErasedType_callMethod_unknownReturn::Void); -BENCHMARK(RtlErasedType_callMethod_unknownReturn::unknownTarget_Void); +BENCHMARK(RtlErasedReturnType_call::returnVoid); +BENCHMARK(RtlErasedReturnType_callMethod::returnVoid); +BENCHMARK(RtlErasedReturnType_callMethod::unknownTarget_returnVoid); BENCHMARK(NativeCall::returnNonVoid); @@ -32,9 +32,9 @@ BENCHMARK(StdFunction_callMethod::returnNonVoid); BENCHMARK(RtlStaticTyped_call::returnNonVoid); BENCHMARK(RtlStaticTyped_callMethod::returnNonVoid); -BENCHMARK(RtlErasedType_call_unknownReturn::NonVoid); -BENCHMARK(RtlErasedType_callMethod_unknownReturn::NonVoid); -BENCHMARK(RtlErasedType_callMethod_unknownReturn::unknownTarget_NonVoid); +BENCHMARK(RtlErasedReturnType_call::returnNonVoid); +BENCHMARK(RtlErasedReturnType_callMethod::returnNonVoid); +BENCHMARK(RtlErasedReturnType_callMethod::unknownTarget_returnNonVoid); namespace bm { diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index f1179611..8a03e59c 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -115,7 +115,7 @@ namespace rtl_tests // Required only when a by-value overload exists to resolve ambiguity. // If no by-value overload were present, implicit resolution to const-ref // would have worked automatically, because const-ref cannot mutate. - auto [err, robj] = revStrOverloadValCRef.bind().call(str); + auto [err, robj] = revStrOverloadValCRef.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -167,7 +167,7 @@ namespace rtl_tests // Even though the by-value overload is preferred implicitly for safety, // the user can override that choice by binding explicitly as T&, // signaling the intent to allow mutation through reflection. - auto [err, robj] = revStrOverloadValRef.bind().call(str); + auto [err, robj] = revStrOverloadValRef.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -214,7 +214,7 @@ namespace rtl_tests // executes successfully, producing the expected result. // ------------------------------------------------------------------------- { - auto [err, robj] = revStrNonConstRefArg.bind().call(str); + auto [err, robj] = revStrNonConstRefArg.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -271,7 +271,7 @@ namespace rtl_tests auto [err, robj] = revStrRValueRefArg(std::string_view(STRA)); EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); } { - auto [err, robj] = revStrRValueRefArg.bind().call(std::string_view(STRA)); + auto [err, robj] = revStrRValueRefArg.bind()(std::string_view(STRA)); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index a92ff327..20ba8b07 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -15,7 +15,7 @@ namespace rtl::detail { - template + template struct ErasedCaller { const Function& m_function; @@ -23,7 +23,10 @@ namespace rtl::detail template rtl::Return call(_args&&...) const noexcept; - template + template requires (is_binding_v == false) + constexpr rtl::Return operator()(_args&&...params) const noexcept; + + template requires (is_binding_v == true) constexpr rtl::Return operator()(_args&&...params) const noexcept; }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index dbb03b6c..7ad0cddb 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -21,9 +21,9 @@ namespace rtl::detail { - template + template template - ForceInline Return ErasedCaller<_signature...>::call(_args&&...params) const noexcept + ForceInline Return ErasedCaller::call(_args&&...params) const noexcept { using Container = std::conditional_t...>, @@ -38,19 +38,45 @@ namespace rtl::detail } - namespace rtl::detail { template - template - ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept + inline constexpr const HopFunction Hopper<>::argsT() const { - auto functorId = m_function.getLambdaById(detail::TypeId>::get()); - if (functorId.first) [[likely]] + const auto argsId = TypeId>::get(); + for (auto& functorId : m_functorIds) { - const auto& erased = functorId.first->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_return(); - if (functorId.first->m_lambda->is_void()) + auto lambda = functorId.get_lambda_function(argsId); + if (lambda != nullptr) [[likely]] { + return { lambda }; + } + } + return HopFunction(); + } + + + template + template + inline constexpr const function HopFunction::returnT() const + { + const auto retId = TypeId::get(); + if (m_lambda != nullptr) [[likely]] { + return m_lambda->template get_hopper(retId); + } + return function(); + } + + + template + template requires (is_binding_v == true) + ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept + { + auto functorId = m_function.getLambdaByStrictId(detail::TypeId>::get()); + if (functorId) [[likely]] + { + const auto& erased = functorId->m_lambda->m_erasure; + const auto& caller = erased.template to_erased_return(); + if (functorId->m_lambda->is_void()) { caller.hop_void(std::forward(params)...); return { error::None, RObject{} }; @@ -64,36 +90,35 @@ namespace rtl::detail } } else [[unlikely]] { - return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; + return { error::SignatureMismatch, RObject{} }; } } -} -namespace rtl::detail -{ - template - inline constexpr const HopFunction Hopper<>::argsT() const + template + template requires (is_binding_v == false) + ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept { - const auto argsId = TypeId>::get(); - for (auto& functorId : m_functorIds) + auto functorId = m_function.getLambdaByNormalId(detail::TypeId>::get()); + if (functorId.first) [[likely]] { - auto lambda = functorId.get_lambda_function(argsId); - if (lambda != nullptr) [[likely]] { - return { lambda }; + const auto& erased = functorId.first->m_lambda->m_erasure; + const auto& caller = erased.template to_erased_return(); + if (functorId.first->m_lambda->is_void()) + { + caller.hop_void(std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return{ error::None, + RObject{ caller.hop_return(std::forward(params)...), + caller.get_return_id(), nullptr } + }; } } - return HopFunction(); - } - - template - template - inline constexpr const function HopFunction::returnT() const - { - const auto retId = TypeId::get(); - if (m_lambda != nullptr) [[likely]] { - return m_lambda->template get_hopper(retId); + else [[unlikely]] { + return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; } - return function(); } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 8b54d2ce..ce3d339f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -204,7 +204,7 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == false) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId>::get()); + auto functorId = m_method.getLambdaByNormalId(detail::TypeId>::get()); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; @@ -232,7 +232,7 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == true) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaById(detail::TypeId>::get()); + auto functorId = m_method.getLambdaByNormalId(detail::TypeId>::get()); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h index 67a5753c..57f0b3ee 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h @@ -34,16 +34,13 @@ namespace rtl::dispatch::erase { return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (std::is_void_v && !is_any_rvref) + if constexpr (std::is_void_v) { auto fptr = eh.get_lambda() .template to_function() .template get_functor(); - (*fptr)(params...); + (*fptr)(std::forward(params)...); } }; } @@ -52,16 +49,13 @@ namespace rtl::dispatch::erase { return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (!std::is_void_v && !is_any_rvref) + if constexpr (!std::is_void_v) { auto fptr = eh.get_lambda() .template to_function() .template get_functor(); - auto&& ret_v = (*fptr)(params...); + auto&& ret_v = (*fptr)(std::forward(params)...); if constexpr (std::is_pointer_v) { diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h index 6d8d99e4..e6a62325 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h @@ -40,16 +40,13 @@ namespace rtl::dispatch::erase { return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (std::is_void_v && !is_any_rvref) + if constexpr (std::is_void_v) { auto mptr = eh.get_lambda() .template to_method() .template get_functor(); - (const_cast(p_target).*mptr)(params...); + (const_cast(p_target).*mptr)(std::forward(params)...); } }; } @@ -58,10 +55,7 @@ namespace rtl::dispatch::erase { return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (std::is_void_v && !is_any_rvref) + if constexpr (std::is_void_v) { auto mptr = eh.get_lambda() .template to_method() @@ -69,7 +63,7 @@ namespace rtl::dispatch::erase const auto& target = p_target.view()->get(); - (const_cast(target).*mptr)(params...); + (const_cast(target).*mptr)(std::forward(params)...); } }; } @@ -78,16 +72,13 @@ namespace rtl::dispatch::erase { return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (!std::is_void_v && !is_any_rvref) + if constexpr (!std::is_void_v) { auto mptr = eh.get_lambda() .template to_method() .template get_functor(); - auto&& ret_v = (const_cast(p_target).*mptr)(params...); + auto&& ret_v = (const_cast(p_target).*mptr)(std::forward(params)...); if constexpr (std::is_pointer_v) { @@ -113,10 +104,7 @@ namespace rtl::dispatch::erase { return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (!std::is_void_v && !is_any_rvref) + if constexpr (!std::is_void_v) { auto mptr = eh.get_lambda() .template to_method() @@ -124,7 +112,7 @@ namespace rtl::dispatch::erase const auto& target = p_target.view()->get(); - auto&& ret_v = (const_cast(target).*mptr)(params...); + auto&& ret_v = (const_cast(target).*mptr)(std::forward(params)...); if constexpr (std::is_pointer_v) { diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h index 19588daa..151702d9 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h @@ -40,16 +40,13 @@ namespace rtl::dispatch::erase { return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (std::is_void_v && !is_any_rvref) + if constexpr (std::is_void_v) { auto mptr = eh.get_lambda() .template to_method() .template get_functor(); - (p_target.*mptr)(params...); + (p_target.*mptr)(std::forward(params)...); } }; } @@ -58,10 +55,7 @@ namespace rtl::dispatch::erase { return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (std::is_void_v && !is_any_rvref) + if constexpr (std::is_void_v) { auto mptr = eh.get_lambda() .template to_method() @@ -69,7 +63,7 @@ namespace rtl::dispatch::erase const auto& target = p_target.view()->get(); - (target.*mptr)(params...); + (target.*mptr)(std::forward(params)...); } }; } @@ -78,16 +72,13 @@ namespace rtl::dispatch::erase { return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (!std::is_void_v && !is_any_rvref) + if constexpr (!std::is_void_v) { auto mptr = eh.get_lambda() .template to_method() .template get_functor(); - auto&& ret_v = (p_target.*mptr)(params...); + auto&& ret_v = (p_target.*mptr)(std::forward(params)...); if constexpr (std::is_pointer_v) { @@ -113,10 +104,7 @@ namespace rtl::dispatch::erase { return[](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { - //TODO: handle these kind of overloads. - constexpr bool is_any_rvref = ((std::is_rvalue_reference_v || ...)); - - if constexpr (!std::is_void_v && !is_any_rvref) + if constexpr (!std::is_void_v) { auto mptr = eh.get_lambda() .template to_method() @@ -124,7 +112,7 @@ namespace rtl::dispatch::erase const auto& target = p_target.view()->get(); - auto&& ret_v = (target.*mptr)(params...); + auto&& ret_v = (target.*mptr)(std::forward(params)...); if constexpr (std::is_pointer_v) { diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 5ba2468f..d9716f3f 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -69,7 +69,9 @@ namespace rtl { const detail::FunctorId* hasFunctorId(const std::size_t pSignatureId) const; - std::pair getLambdaById(const std::size_t pSignatureId) const; + std::pair getLambdaByNormalId(const std::size_t pSignatureId) const; + + const detail::FunctorId* getLambdaByStrictId(const std::size_t pSignatureId) const; GETTER(detail::methodQ, Qualifier, m_qualifier); @@ -99,18 +101,18 @@ namespace rtl { bool hasSignature() const; template - constexpr const detail::ErasedCaller<_signature...> bind() const noexcept; + constexpr const detail::ErasedCaller bind() const noexcept; template constexpr rtl::Return operator()(_args&&...params) const noexcept { - return detail::ErasedCaller<_args...>{ (*this) }(std::forward<_args>(params)...); + return detail::ErasedCaller{ (*this) }(std::forward<_args>(params)...); } friend detail::CxxReflection; friend detail::ReflectionBuilder; - template - friend class detail::ErasedCaller; + template + friend struct detail::ErasedCaller; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 01be5f19..aa6fa0be 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -21,9 +21,9 @@ namespace rtl { template - inline constexpr const detail::ErasedCaller<_signature...> Function::bind() const noexcept + inline constexpr const detail::ErasedCaller Function::bind() const noexcept { - return detail::ErasedCaller<_signature...>{ (*this) }; + return detail::ErasedCaller{ (*this) }; } template @@ -76,7 +76,19 @@ namespace rtl } - ForceInline std::pair Function::getLambdaById(const std::size_t pSignatureId) const + ForceInline const detail::FunctorId* Function::getLambdaByStrictId(const std::size_t pSignatureId) const + { + //simple linear-search, efficient for small set of elements. + for (const auto& functorId : m_functorIds) { + if (pSignatureId == functorId.m_lambda->get_strict_sign_id()) [[likely]] { + return &functorId; + } + } + return nullptr; + } + + + inline std::pair Function::getLambdaByNormalId(const std::size_t pSignatureId) const { //simple linear-search, efficient for small set of elements. for (const auto& functorId : m_functorIds) { @@ -99,7 +111,7 @@ namespace rtl if (index != rtl::index_none) { auto isAnyNonConstRefInArgsT = (m_functorIds[index].m_lambda->is_any_ncref()); - return { (isAnyNonConstRefInArgsT ? nullptr:&m_functorIds[index]), isAnyNonConstRefInArgsT }; + return { (isAnyNonConstRefInArgsT ? nullptr : &m_functorIds[index]), isAnyNonConstRefInArgsT }; } return { nullptr, false }; } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index efcff637..7f76aeac 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -55,7 +55,7 @@ namespace rtl { using Function::bind; template - constexpr const detail::ErasedCaller<_args...> operator()(_args&&...params) const noexcept = delete; + constexpr const detail::ErasedCaller operator()(_args&&...params) const noexcept = delete; template constexpr const detail::HopFunction argsT() const = delete; diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index a0e597aa..17598648 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -106,7 +106,7 @@ namespace rtl template friend struct detail::RObjectBuilder; - template + template friend struct detail::ErasedCaller; template diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 89bc23f3..1344f1fa 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -38,7 +38,7 @@ namespace rtl template class FunctorContainer; - template + template struct ErasedCaller; template From bce323231b94a8f7c093db51210e31488b272511 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 10 Oct 2025 23:28:34 +0530 Subject: [PATCH 078/148] new-dispatch-path integration, wip. --- RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp | 4 ++-- RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp | 2 +- .../src/FunctionalityTests/NameSpaceGlobalsTests.cpp | 4 ++-- .../src/FunctionalityTests/PerfectForwardingTests.cpp | 4 ++-- .../TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp index d6f62f6e..1a5387d1 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp @@ -153,7 +153,7 @@ namespace rtl_tests constexpr const char* cstr = "Reflection Template Library C++"; // Need to forward as 'const char*' - auto [err, ret] = cstrLen->bind().call(cstr); + auto [err, ret] = cstrLen->bind()(cstr); ASSERT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); @@ -168,7 +168,7 @@ namespace rtl_tests } { // Case 3: string literal (deduces as const char[N], here const char[32]) // Must explicitly forward as 'const char*'. - auto [err, ret] = cstrLen->bind().call("Reflection Template Library C++"); + auto [err, ret] = cstrLen->bind()("Reflection Template Library C++"); ASSERT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); diff --git a/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp index bd10a2a5..319807b3 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp @@ -133,7 +133,7 @@ namespace rtl_tests EXPECT_TRUE(err0 == error::None); ASSERT_FALSE(book.isEmpty()); EXPECT_TRUE(getPublishedOn->hasSignature<>()); //empty template params checks for zero arguments. - // Slower. bind<>().call() syntax is faster. + auto [err1, ret] = getPublishedOn->bind(book).call(); EXPECT_TRUE(err1 == error::None); diff --git a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp index 92d2cdf7..176541a9 100644 --- a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp @@ -182,7 +182,7 @@ namespace rtl_tests //Instead we can explicitly specify the types as template parameter, //like, (*setReal).operator()(g_real); //or we can use the bind<...>().call(), specifying type as template param, like, - auto [err, robj] = setReal->bind().call(g_real); + auto [err, robj] = setReal->bind()(g_real); EXPECT_TRUE(err == rtl::error::SignatureMismatch); ASSERT_TRUE(robj.isEmpty()); @@ -224,7 +224,7 @@ namespace rtl_tests } { //STRB's type is 'consexpr const char*', function accepts 'string', //so explicitly binding type in template (using bind<...>()) to enforce the type as 'string'. - auto [err, ret] = reverseString->bind().call(STRB); + auto [err, ret] = reverseString->bind()(STRB); EXPECT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); diff --git a/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp b/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp index ac4dd880..5b3aeab8 100644 --- a/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp @@ -322,7 +322,7 @@ namespace rtl_tests EXPECT_TRUE(isValid); const auto zookeeper = std::string(animal::ZOO_KEEPER); - auto [err, ret] = updateZooKeeper->bind().call(zookeeper); + auto [err, ret] = updateZooKeeper->bind()(zookeeper); EXPECT_TRUE(err == error::None); ASSERT_FALSE(ret.isEmpty()); @@ -350,7 +350,7 @@ namespace rtl_tests EXPECT_TRUE(isValid); auto zookeeper = std::string(animal::ZOO_KEEPER); - auto [err, ret] = updateZooKeeper->bind().call(zookeeper); + auto [err, ret] = updateZooKeeper->bind()(zookeeper); EXPECT_TRUE(err == error::None); ASSERT_FALSE(ret.isEmpty()); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index 8a03e59c..12721048 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -312,7 +312,7 @@ namespace rtl_tests { // Explicitly selecting the non-const ref overload. // Caller signals intent to allow mutation by binding as T&. - auto [err, robj] = revStrOverloadValRefNCref.bind().call(str); + auto [err, robj] = revStrOverloadValRefNCref.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); @@ -326,7 +326,7 @@ namespace rtl_tests // But since both 'T&' and 'const T&' overloads are available, // RTL treats the situation as ambiguous and requires explicit selection // to avoid guessing the user's intent regarding mutability. - auto [err, robj] = revStrOverloadValRefNCref.bind().call(str); + auto [err, robj] = revStrOverloadValRefNCref.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); EXPECT_TRUE(robj.canViewAs()); From 78bab98cb5f0f071f80c2b6ab3ad187c6fd9eb15 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 11 Oct 2025 12:21:50 +0530 Subject: [PATCH 079/148] improved unique-type-id for new dispatch design. --- .../rtl/detail/inc/FunctionCaller.hpp | 8 +++--- .../rtl/detail/inc/MethodInvoker.hpp | 12 ++++----- ReflectionTemplateLib/rtl/dispatch/functor.h | 9 +++---- .../rtl/dispatch/functor_function.h | 6 ++--- .../rtl/dispatch/functor_method.h | 8 +++--- .../rtl/dispatch/functor_method_const.h | 8 +++--- .../rtl/dispatch/lambda_base.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 12 ++++----- ReflectionTemplateLib/rtl/rtl_traits.h | 26 +++++++++++++++++-- 10 files changed, 56 insertions(+), 37 deletions(-) diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 7ad0cddb..2c43d2e5 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -43,7 +43,7 @@ namespace rtl::detail template inline constexpr const HopFunction Hopper<>::argsT() const { - const auto argsId = TypeId>::get(); + const auto argsId = traits::uid>::value; for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_function(argsId); @@ -59,7 +59,7 @@ namespace rtl::detail template inline constexpr const function HopFunction::returnT() const { - const auto retId = TypeId::get(); + const auto retId = traits::uid::value; if (m_lambda != nullptr) [[likely]] { return m_lambda->template get_hopper(retId); } @@ -71,7 +71,7 @@ namespace rtl::detail template requires (is_binding_v == true) ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept { - auto functorId = m_function.getLambdaByStrictId(detail::TypeId>::get()); + auto functorId = m_function.getLambdaByStrictId(traits::uid>::value); if (functorId) [[likely]] { const auto& erased = functorId->m_lambda->m_erasure; @@ -99,7 +99,7 @@ namespace rtl::detail template requires (is_binding_v == false) ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept { - auto functorId = m_function.getLambdaByNormalId(detail::TypeId>::get()); + auto functorId = m_function.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index ce3d339f..1615827b 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -156,8 +156,8 @@ namespace rtl::detail template inline constexpr HopMethod Hopper::argsT() const { - const auto recId = TypeId::get(); - const auto argsId = TypeId>::get(); + const auto recId = traits::uid::value; + const auto argsId = traits::uid>::value; for (auto& functorId : m_functorIds) { auto lambda = functorId.get_lambda_method(recId, argsId); @@ -176,7 +176,7 @@ namespace rtl::detail { if (m_lambda != nullptr) [[likely]] { - const auto retId = TypeId<_returnType>::get(); + const auto retId = traits::uid<_returnType>::value; return m_lambda->template get_hopper<_returnType>(retId); } return method<_returnType(recordT::*)(signatureT...)>(); @@ -190,7 +190,7 @@ namespace rtl::detail { if (m_lambda != nullptr) [[likely]] { - const auto retId = TypeId<_returnType>::get(); + const auto retId = traits::uid<_returnType>::value; return m_lambda->template get_hopper<_returnType>(retId); } return method<_returnType(recordT::*)(signatureT...) const>(); @@ -204,7 +204,7 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == false) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaByNormalId(detail::TypeId>::get()); + auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; @@ -232,7 +232,7 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == true) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { - auto functorId = m_method.getLambdaByNormalId(detail::TypeId>::get()); + auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 1591d40f..28d22b52 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -11,7 +11,6 @@ #pragma once -#include "rtl_typeid.h" #include "rtl_constants.h" #include "rtl_forward_decls.h" @@ -27,11 +26,11 @@ namespace rtl::dispatch std::string m_returnStr; std::string m_signatureStr; - std::size_t m_recordId = detail::TypeId<>::None; - std::size_t m_returnId = detail::TypeId<>::None; + traits::uid_t m_recordId = traits::uid<>::none; + traits::uid_t m_returnId = traits::uid<>::none; - std::size_t m_normal_signId = detail::TypeId<>::None; - std::size_t m_strict_signId = detail::TypeId<>::None; + traits::uid_t m_normal_signId = traits::uid<>::none; + traits::uid_t m_strict_signId = traits::uid<>::none; bool m_is_any_ncref = false; std::vector m_argumentsId = {}; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_function.h b/ReflectionTemplateLib/rtl/dispatch/functor_function.h index 60e16d0e..eed48ec5 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_function.h @@ -32,11 +32,11 @@ namespace rtl::dispatch function_ptr(functor_t fptr) :m_functor(fptr) { - m_returnId = detail::TypeId::get(); + m_returnId = traits::uid::value; m_is_any_ncref = (traits::is_nonconst_ref_v || ...); - m_normal_signId = detail::TypeId>::get(); - m_strict_signId = detail::TypeId>::get(); + m_normal_signId = traits::uid>::value; + m_strict_signId = traits::uid>::value; m_returnStr = detail::TypeId::toString(); m_signatureStr = detail::TypeId::toString(); diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method.h b/ReflectionTemplateLib/rtl/dispatch/functor_method.h index e08610ba..5b30dca9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_method.h @@ -36,12 +36,12 @@ namespace rtl::dispatch { m_qualifier = detail::methodQ::NonConst; - m_recordId = detail::TypeId::get(); - m_returnId = detail::TypeId::get(); + m_returnId = traits::uid::value; + m_recordId = traits::uid::value; m_is_any_ncref = (traits::is_nonconst_ref_v || ...); - m_normal_signId = detail::TypeId>::get(); - m_strict_signId = detail::TypeId>::get(); + m_normal_signId = traits::uid>::value; + m_strict_signId = traits::uid>::value; m_returnStr = detail::TypeId::toString(); m_recordStr = detail::TypeId::toString(); diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h index 30066fcc..5defc46c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h @@ -36,12 +36,12 @@ namespace rtl::dispatch { m_qualifier = detail::methodQ::Const; - m_recordId = detail::TypeId::get(); - m_returnId = detail::TypeId::get(); + m_returnId = traits::uid::value; + m_recordId = traits::uid::value; m_is_any_ncref = (traits::is_nonconst_ref_v || ...); - m_normal_signId = detail::TypeId>::get(); - m_strict_signId = detail::TypeId>::get(); + m_normal_signId = traits::uid>::value; + m_strict_signId = traits::uid>::value; m_returnStr = detail::TypeId::toString(); m_recordStr = detail::TypeId::toString(); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index 1f87886a..b218cff5 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -72,7 +72,7 @@ namespace rtl::dispatch GETTER(std::size_t, _normal_sign_id, m_functor.m_normal_signId) lambda_base(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept - : m_is_void(p_functor.m_returnId == detail::TypeId::get()) + : m_is_void(p_functor.m_returnId == traits::uid::value) , m_functor(p_functor) , m_erasure(p_erasure) { } diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index d9716f3f..6bb796a0 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -71,7 +71,7 @@ namespace rtl { std::pair getLambdaByNormalId(const std::size_t pSignatureId) const; - const detail::FunctorId* getLambdaByStrictId(const std::size_t pSignatureId) const; + constexpr const detail::FunctorId* getLambdaByStrictId(const std::size_t pSignatureId) const; GETTER(detail::methodQ, Qualifier, m_qualifier); diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index aa6fa0be..1cf054e2 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -76,7 +76,7 @@ namespace rtl } - ForceInline const detail::FunctorId* Function::getLambdaByStrictId(const std::size_t pSignatureId) const + inline constexpr const detail::FunctorId* Function::getLambdaByStrictId(const std::size_t pSignatureId) const { //simple linear-search, efficient for small set of elements. for (const auto& functorId : m_functorIds) { @@ -88,13 +88,11 @@ namespace rtl } - inline std::pair Function::getLambdaByNormalId(const std::size_t pSignatureId) const + ForceInline std::pair Function::getLambdaByNormalId(const std::size_t pSignatureId) const { - //simple linear-search, efficient for small set of elements. - for (const auto& functorId : m_functorIds) { - if (pSignatureId == functorId.m_lambda->get_strict_sign_id()) [[likely]] { - return { &functorId, false }; - } + const detail::FunctorId* functorId = getLambdaByStrictId(pSignatureId); + if (functorId != nullptr) { + return { functorId, false }; } std::size_t index = rtl::index_none; diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index 63562a5e..f1de9ae9 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -147,7 +147,29 @@ namespace rtl namespace rtl::traits { - template + using uid_t = std::uintptr_t; + + // Returns an opaque, unique identifier per type T. + // Must only be compared or hashed - never interpreted numerically. + template + class uid + { + static constexpr uid_t get() noexcept + { + if constexpr (!std::is_same_v) { + static const int unique_tag; + return reinterpret_cast(&unique_tag); + } + return 0; + } + + public: + + static constexpr uid_t none = 0; + static inline const uid_t value = get(); + }; + + template using normal_sign_t = std::remove_const_t>; template @@ -156,7 +178,7 @@ namespace rtl::traits template using strict_sign_id_t = std::tuple; - template + template inline constexpr bool is_nonconst_ref_v = ((std::is_lvalue_reference_v || std::is_rvalue_reference_v) && !std::is_const_v>); } \ No newline at end of file From f3f086e86772707af5beccf252cce82d7e1c03ac Mon Sep 17 00:00:00 2001 From: neeraj Date: Sat, 11 Oct 2025 13:23:28 +0530 Subject: [PATCH 080/148] fix gcc/clang compile error. --- ReflectionTemplateLib/rtl/rtl_traits.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index f1de9ae9..f91ccbea 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -154,10 +154,14 @@ namespace rtl::traits template class uid { - static constexpr uid_t get() noexcept + static + #if __cpp_static_local_constexpr >= 202306L + constexpr + #endif + uid_t get() noexcept { if constexpr (!std::is_same_v) { - static const int unique_tag; + static const int unique_tag = 0; return reinterpret_cast(&unique_tag); } return 0; From ac65b04f50c90614871782affd1239b2c2e9e280 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sun, 12 Oct 2025 12:24:51 +0530 Subject: [PATCH 081/148] better callable interface, wip. --- README.md | 4 +- .../BasicTypeErasedDispatch.cpp | 21 ++++++ .../rtl/dispatch/CMakeLists.txt | 1 + .../rtl/dispatch/rtl_function_erased_return.h | 66 +++++++++++++++++++ ReflectionTemplateLib/rtl/inc/Function.hpp | 2 +- ReflectionTemplateLib/rtl/inc/RObject.h | 3 + ReflectionTemplateLib/rtl/rtl_errors.h | 3 + ReflectionTemplateLib/rtl/rtl_forward_decls.h | 2 +- 8 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h diff --git a/README.md b/README.md index 65f79607..ebf5c88a 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ auto cxx_mirror = rtl::CxxMirror({ With just this much, you’ve registered your types and unlocked full runtime reflection. The `cxx_mirror` object is your gateway to query, introspect, and instantiate types at runtime — all without compile-time knowledge of those types, without strict static coupling. -***Without reflection:*** +**Without reflection:** ```c++ Person p("John", 42); @@ -55,7 +55,7 @@ p.setAge(43); std::cout << p.getName(); ``` -***With reflection:*** +**With reflection:** ```c++ // Look up the class by name diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index 12721048..0a0e485b 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -6,11 +6,32 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" +#include + using namespace test_utils; using namespace test_mirror; namespace rtl_tests { + TEST(BasicTypeErasedDispatch, invalid_erased_return_rtl_function) + { + { + rtl::function erased_ret_func; + EXPECT_FALSE(erased_ret_func); + + auto [err, robj] = erased_ret_func(); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + rtl::function erased_ret_func; + EXPECT_FALSE(erased_ret_func); + + auto [err, robj] = erased_ret_func(0); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } + } + TEST(BasicTypeErasedDispatch, implicit_resolutions_to_call_by_value_overloads) { auto reverseStringOpt = cxx::mirror().getFunction(str_reverseString); diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 335dcaea..490c4847 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -15,6 +15,7 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function_erased_return.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const.h" ) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h new file mode 100644 index 00000000..d4cccb5c --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -0,0 +1,66 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_forward_decls.h" +#include "lambda_base.h" + +namespace rtl +{ + template + struct function + { + constexpr operator bool() const { + return (!m_any_hop.empty() || !m_void_hop.empty()); + } + + template + [[nodiscard]] + Return operator()(args_t&&...params) const noexcept + { + if (!m_void_hop.empty()) + { + auto& lambda_f = (m_void_hop[0].second); + auto& lambda_b = *(m_void_hop[0].first); + + lambda_f(lambda_b, std::forward(params)...); + return { error::None, RObject{} }; + } + else if (!m_any_hop.empty()) { + + auto& lambda_f = (m_any_hop[0].second); + auto& lambda_b = *(m_any_hop[0].first); + + return{ error::None, + RObject{ lambda_f(lambda_b, std::forward(params)...), + m_robj_id, nullptr} + }; + } + else [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + } + + private: + + using lambda_vt = std::function; + + using lambda_rt = std::function; + + std::vector> m_any_hop = {}; + + std::vector> m_void_hop = {}; + + detail::RObjectId m_robj_id = {}; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 1cf054e2..b2b76d63 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -33,7 +33,7 @@ namespace rtl } - /* @method: hasSignature<...>() +/* @method: hasSignature<...>() @param: set of arguments, explicitly specified as template parameter. @return: bool, if the functor associated with this object is of certain signature or not. * a single 'Function' object can be associated with multiple overloads of same function. diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index 17598648..4d3a48a2 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -111,6 +111,9 @@ namespace rtl template friend struct detail::ErasedInvoker; + + template + friend struct function; }; struct [[nodiscard]] Return { diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index 8c6f0530..aaa734b5 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -19,6 +19,7 @@ namespace rtl { None, EmptyRObject, + InvalidCaller, NotWrapperType, TargetMismatch, @@ -46,6 +47,8 @@ namespace rtl return "No error (operation successful)"; case error::EmptyRObject: return "Empty instance: RObject does not hold any reflected object"; + case error::InvalidCaller: + return "Invalid callable: rtl::function/rtl::method object bieng used is empty."; case error::SignatureMismatch: return "Signature mismatch: Function parameters do not match the expected signature"; case error::ExplicitRefBindingRequired: diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 1344f1fa..dacdfc8a 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -25,7 +25,7 @@ namespace rtl class CxxMirror; - template + template struct function; template From 2cb0562303ce3454b8a7e56fa3cfd451d1b8b347 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 13 Oct 2025 00:16:46 +0530 Subject: [PATCH 082/148] better callable interface, wip. --- .../BasicTypeErasedDispatch.cpp | 15 +++- .../rtl/dispatch/lambda_base.h | 6 +- .../rtl/dispatch/rtl_function_erased_return.h | 87 ++++++++++++++----- .../rtl/erasure/aware_hopper.h | 14 ++- .../rtl/erasure/aware_hopper_rec.h | 30 +++---- .../rtl/erasure/aware_hopper_rec_const.h | 30 +++---- .../rtl/erasure/erased_hopper.h | 18 ++-- .../rtl/erasure/erased_hopper_rec.h | 14 ++- 8 files changed, 124 insertions(+), 90 deletions(-) diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index 0a0e485b..de31a3ed 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -22,13 +22,22 @@ namespace rtl_tests auto [err, robj] = erased_ret_func(); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); - } { - rtl::function erased_ret_func; - EXPECT_FALSE(erased_ret_func); + } + rtl::function erased_ret_func; + EXPECT_FALSE(erased_ret_func); + { auto [err, robj] = erased_ret_func(0); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = erased_ret_func.call(0); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = erased_ret_func.call(0); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); } } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index b218cff5..72515df7 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -63,13 +63,13 @@ namespace rtl::dispatch else return nullptr; } - GETTER_CREF(functor, _functor, m_functor); + GETTER_CREF(functor, _functor, m_functor) GETTER_BOOL(_any_ncref, m_functor.m_is_any_ncref) - GETTER(std::size_t, _strict_sign_id, m_functor.m_strict_signId) + GETTER(traits::uid_t, _strict_sign_id, m_functor.m_strict_signId) - GETTER(std::size_t, _normal_sign_id, m_functor.m_normal_signId) + GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_signId) lambda_base(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept : m_is_void(p_functor.m_returnId == traits::uid::value) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index d4cccb5c..275a348b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -17,50 +17,93 @@ namespace rtl { - template - struct function + template + struct function { constexpr operator bool() const { - return (!m_any_hop.empty() || !m_void_hop.empty()); + return (!m_lambda.empty()); } template [[nodiscard]] - Return operator()(args_t&&...params) const noexcept + constexpr Return operator()(args_t&&...params) const noexcept { - if (!m_void_hop.empty()) + if (m_lambda.empty()) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + if (m_lambda[call_by::value] == nullptr && + (m_lambda.size() > call_by::ref || + m_lambda[call_by::cref]->is_any_ncref()) ) [[unlikely]] { - auto& lambda_f = (m_void_hop[0].second); - auto& lambda_b = *(m_void_hop[0].first); + return { error::ExplicitRefBindingRequired, RObject{} }; + } - lambda_f(lambda_b, std::forward(params)...); + auto index = (m_lambda[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (m_lambda[index]->is_void()) + { + m_void_hop[index](*m_lambda[index], std::forward(params)...); return { error::None, RObject{} }; } - else if (!m_any_hop.empty()) { - - auto& lambda_f = (m_any_hop[0].second); - auto& lambda_b = *(m_any_hop[0].first); + else { - return{ error::None, - RObject{ lambda_f(lambda_b, std::forward(params)...), - m_robj_id, nullptr} + return{ error::None, + RObject{ m_any_hop[index](*m_lambda[index], std::forward(params)...), + m_robj_id, nullptr } }; } - else [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + } + + + template + requires (std::is_same_v, std::tuple> == true) + [[nodiscard]] + constexpr Return call(args_t&&...params) const noexcept + { + auto signature_id = traits::uid>::value; + for (int index = 0; index < m_lambda.size(); index++) + { + if (signature_id == m_lambda[index]->get_strict_sign_id()) + { + if (m_lambda[index]->is_void()) + { + m_void_hop[index](*m_lambda[index], std::forward(params)...); + return { error::None, RObject{} }; + } + else { + + return{ error::None, + RObject{ m_any_hop[index](*m_lambda[index], std::forward(params)...), + m_robj_id, nullptr } + }; + } + } } + return { error::InvalidCaller, RObject{} }; } private: - using lambda_vt = std::function; + using lambda_vt = std::function; + + using lambda_rt = std::function; - using lambda_rt = std::function; + detail::RObjectId m_robj_id = {}; - std::vector> m_any_hop = {}; + std::vector m_any_hop = {}; - std::vector> m_void_hop = {}; + std::vector m_void_hop = {}; - detail::RObjectId m_robj_id = {}; + std::vector m_lambda = {}; + + enum call_by + { + value = 0, + cref = 1, + ref = 2 + }; + + static_assert((!std::is_reference_v && ...), + "function: any type cannot be reference here"); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h index 57f0b3ee..9326e7e4 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h @@ -32,13 +32,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_void() noexcept { - return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto + return [](const lambda_base& lambda, traits::normal_sign_t&&... params)-> auto { if constexpr (std::is_void_v) { - auto fptr = eh.get_lambda() - .template to_function() - .template get_functor(); + auto fptr = lambda.template to_function() + .template get_functor(); (*fptr)(std::forward(params)...); } @@ -47,13 +46,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_any_return() noexcept { - return [](const base_t& eh, traits::normal_sign_t&&... params)-> auto + return [](const lambda_base& lambda, traits::normal_sign_t&&... params)-> auto { if constexpr (!std::is_void_v) { - auto fptr = eh.get_lambda() - .template to_function() - .template get_functor(); + auto fptr = lambda.template to_function() + .template get_functor(); auto&& ret_v = (*fptr)(std::forward(params)...); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h index e6a62325..604f0450 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h @@ -23,8 +23,6 @@ namespace rtl::dispatch::erase { using base_t = erased_hopper_rec...>; - using this_t = aware_hopper_rec; - constexpr static bool isConstCastSafe = (!traits::is_const_v); aware_hopper_rec(const dispatch::functor& p_functor) @@ -38,13 +36,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_void() noexcept { - return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto + return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { if constexpr (std::is_void_v) { - auto mptr = eh.get_lambda() - .template to_method() - .template get_functor(); + auto mptr = lambda.template to_method() + .template get_functor(); (const_cast(p_target).*mptr)(std::forward(params)...); } @@ -53,13 +50,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_void_robj() noexcept { - return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { if constexpr (std::is_void_v) { - auto mptr = eh.get_lambda() - .template to_method() - .template get_functor(); + auto mptr = lambda.template to_method() + .template get_functor(); const auto& target = p_target.view()->get(); @@ -70,13 +66,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_any_ret() noexcept { - return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto + return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { if constexpr (!std::is_void_v) { - auto mptr = eh.get_lambda() - .template to_method() - .template get_functor(); + auto mptr = lambda.template to_method() + .template get_functor(); auto&& ret_v = (const_cast(p_target).*mptr)(std::forward(params)...); @@ -102,13 +97,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_any_ret_robj() noexcept { - return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { if constexpr (!std::is_void_v) { - auto mptr = eh.get_lambda() - .template to_method() - .template get_functor(); + auto mptr = lambda.template to_method() + .template get_functor(); const auto& target = p_target.view()->get(); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h index 151702d9..e68290f3 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h @@ -23,8 +23,6 @@ namespace rtl::dispatch::erase { using base_t = erased_hopper_rec...>; - using this_t = aware_hopper_rec; - constexpr static bool isConstCastSafe = (!traits::is_const_v); aware_hopper_rec(const dispatch::functor& p_functor) @@ -38,13 +36,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_void() noexcept { - return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&... params)-> auto + return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { if constexpr (std::is_void_v) { - auto mptr = eh.get_lambda() - .template to_method() - .template get_functor(); + auto mptr = lambda.template to_method() + .template get_functor(); (p_target.*mptr)(std::forward(params)...); } @@ -53,13 +50,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_void_robj() noexcept { - return [](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { if constexpr (std::is_void_v) { - auto mptr = eh.get_lambda() - .template to_method() - .template get_functor(); + auto mptr = lambda.template to_method() + .template get_functor(); const auto& target = p_target.view()->get(); @@ -70,13 +66,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_any_ret() noexcept { - return [](const base_t& eh, const record_t& p_target, traits::normal_sign_t&&...params)-> auto + return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { if constexpr (!std::is_void_v) { - auto mptr = eh.get_lambda() - .template to_method() - .template get_functor(); + auto mptr = lambda.template to_method() + .template get_functor(); auto&& ret_v = (p_target.*mptr)(std::forward(params)...); @@ -102,13 +97,12 @@ namespace rtl::dispatch::erase constexpr static auto get_lambda_any_ret_robj() noexcept { - return[](const base_t::base_t& eh, const RObject& p_target, traits::normal_sign_t&&... params)-> auto + return[](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { if constexpr (!std::is_void_v) { - auto mptr = eh.get_lambda() - .template to_method() - .template get_functor(); + auto mptr = lambda.template to_method() + .template get_functor(); const auto& target = p_target.view()->get(); diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h index d49beef3..bec05b2c 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h @@ -20,38 +20,36 @@ namespace rtl::dispatch::erase template struct erased_hopper : public erasure_base { - using this_t = erased_hopper; + using lambda_vt = std::function; - using lambda_vt = std::function; + using lambda_rt = std::function; - using lambda_rt = std::function; + using lambda_robj_vt = std::function; - using lambda_robj_vt = std::function; - - using lambda_robj_rt = std::function; + using lambda_robj_rt = std::function; template constexpr void hop_void(args_t&&...params) const noexcept { - m_void_hop(*this, std::forward(params)...); + m_void_hop(get_lambda(), std::forward(params)...); } template ForceInline std::any hop_return(args_t&&...params) const noexcept { - return m_any_ret_hop(*this, std::forward(params)...); + return m_any_ret_hop(get_lambda(), std::forward(params)...); } template constexpr void hop_void(const RObject& p_robj, args_t&&...params) const noexcept { - m_void_method_hop(*this, p_robj, std::forward(params)...); + m_void_method_hop(get_lambda(), p_robj, std::forward(params)...); } template ForceInline std::any hop_return(const RObject& p_robj, args_t&&...params) const noexcept { - return m_any_ret_method_hop(*this, p_robj, std::forward(params)...); + return m_any_ret_method_hop(get_lambda(), p_robj, std::forward(params)...); } protected: diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h index af11d373..333ae826 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h @@ -22,24 +22,20 @@ namespace rtl::dispatch::erase template struct erased_hopper_rec : public erased_hopper { - using base_t = erased_hopper; - - using this_t = erased_hopper_rec; - - using lambda_vt = std::function; + using lambda_vt = std::function; - using lambda_rt = std::function; + using lambda_rt = std::function; template constexpr void hop_void(const record_t& p_target, args_t&&...params) const noexcept { - m_void_hop(*this, p_target, std::forward(params)...); + m_void_hop(erasure_base::get_lambda(), p_target, std::forward(params)...); } template ForceInline std::any hop_return(const record_t& p_target, args_t&&...params) const noexcept { - return m_any_ret_hop(*this, p_target, std::forward(params)...); + return m_any_ret_hop(erasure_base::get_lambda(), p_target, std::forward(params)...); } protected: @@ -48,6 +44,8 @@ namespace rtl::dispatch::erase lambda_rt m_any_ret_hop; + using base_t = erased_hopper; + erased_hopper_rec( const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id, const lambda_vt& p_void_hop, From 097b08941315787fb7cd3bf7ca63d023b75bc6da Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 13 Oct 2025 13:54:36 +0530 Subject: [PATCH 083/148] better callable interface, wip. --- .../rtl/detail/inc/FunctionCaller.h | 7 +- .../rtl/detail/inc/FunctionCaller.hpp | 67 +++++++++++----- .../rtl/detail/inc/MethodInvoker.h | 2 + .../rtl/detail/inc/MethodInvoker.hpp | 78 ++++++++++++------- .../rtl/dispatch/lambda_base.h | 4 +- 5 files changed, 112 insertions(+), 46 deletions(-) diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 20ba8b07..daa3bf4e 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -39,7 +39,12 @@ namespace rtl::detail { const dispatch::lambda_function<_signature...>* m_lambda = nullptr; - template + std::vector m_lambdaRefOverloads = {}; + + template requires (std::is_same_v<_returnType, rtl::Return>) + constexpr const function<_returnType(_signature...)> returnT() const; + + template requires (!std::is_same_v<_returnType, rtl::Return>) constexpr const function<_returnType(_signature...)> returnT() const; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 2c43d2e5..c0a7ef13 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -40,23 +40,54 @@ namespace rtl::detail namespace rtl::detail { - template - inline constexpr const HopFunction Hopper<>::argsT() const + template + inline constexpr const HopFunction Hopper<>::argsT() const { - const auto argsId = traits::uid>::value; + auto strictArgsId = traits::uid>::value; + auto normalArgsId = traits::uid>::value; + + const dispatch::lambda_function* lambda = nullptr; + std::vector refOverloads = { nullptr }; + + for (auto& functorId : m_functorIds) + { + if (!lambda && strictArgsId == functorId.m_lambda->get_strict_sign_id()) { + lambda = &(functorId.m_lambda->to_function()); + } + if (normalArgsId == functorId.m_lambda->get_normal_sign_id()) + { + if (normalArgsId == functorId.m_lambda->get_strict_sign_id()) { + refOverloads[0] = functorId.m_lambda; + } + else if (!functorId.m_lambda->is_any_ncref()) { + refOverloads.push_back(functorId.m_lambda); + } + } + } for (auto& functorId : m_functorIds) { - auto lambda = functorId.get_lambda_function(argsId); - if (lambda != nullptr) [[likely]] { - return { lambda }; + if (normalArgsId == functorId.m_lambda->get_normal_sign_id() && functorId.m_lambda->is_any_ncref()) { + refOverloads.push_back(functorId.m_lambda); } } - return HopFunction(); + return { lambda, refOverloads }; + } + + + template + template requires (std::is_same_v) + inline constexpr const function HopFunction::returnT() const + { + const auto retId = traits::uid::value; + if (m_lambda != nullptr) [[likely]] { + return m_lambda->template get_hopper(retId); + } + return function(); } template - template + template requires (!std::is_same_v) inline constexpr const function HopFunction::returnT() const { const auto retId = traits::uid::value; @@ -68,8 +99,8 @@ namespace rtl::detail template - template requires (is_binding_v == true) - ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept + template requires (is_binding_v == true) + ForceInline constexpr Return ErasedCaller::operator()(args_t&&...params) const noexcept { auto functorId = m_function.getLambdaByStrictId(traits::uid>::value); if (functorId) [[likely]] @@ -78,13 +109,13 @@ namespace rtl::detail const auto& caller = erased.template to_erased_return(); if (functorId->m_lambda->is_void()) { - caller.hop_void(std::forward(params)...); + caller.hop_void(std::forward(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller.hop_return(std::forward(params)...), + RObject{ caller.hop_return(std::forward(params)...), caller.get_return_id(), nullptr } }; } @@ -96,23 +127,23 @@ namespace rtl::detail template - template requires (is_binding_v == false) - ForceInline constexpr Return ErasedCaller::operator()(argsT&&...params) const noexcept + template requires (is_binding_v == false) + ForceInline constexpr Return ErasedCaller::operator()(args_t&&...params) const noexcept { - auto functorId = m_function.getLambdaByNormalId(traits::uid>::value); + auto functorId = m_function.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_return(); + const auto& caller = erased.template to_erased_return(); if (functorId.first->m_lambda->is_void()) { - caller.hop_void(std::forward(params)...); + caller.hop_void(std::forward(params)...); return { error::None, RObject{} }; } else { return{ error::None, - RObject{ caller.hop_return(std::forward(params)...), + RObject{ caller.hop_return(std::forward(params)...), caller.get_return_id(), nullptr } }; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 2b7d0dd1..06377420 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -94,6 +94,8 @@ namespace rtl::detail { const dispatch::lambda_method* m_lambda = nullptr; + std::vector m_lambdaRefOverloads = {}; + template requires (std::is_const_v == false) constexpr const method returnT() const; diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 1615827b..33e8f37c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -152,63 +152,89 @@ namespace rtl::detail namespace rtl::detail { - template - template - inline constexpr HopMethod Hopper::argsT() const + template + template + inline constexpr HopMethod Hopper::argsT() const { - const auto recId = traits::uid::value; - const auto argsId = traits::uid>::value; + auto recordId = traits::uid::value; + auto strictArgsId = traits::uid>::value; + auto normalArgsId = traits::uid>::value; + + const dispatch::lambda_method* lambda = nullptr; + std::vector refOverloads = { nullptr }; + for (auto& functorId : m_functorIds) { - auto lambda = functorId.get_lambda_method(recId, argsId); - if (lambda != nullptr) [[likely]] { - return { lambda }; + if (recordId != functorId.m_lambda->get_record_id()) { + continue; + } + if (!lambda && strictArgsId == functorId.m_lambda->get_strict_sign_id()) + { + lambda = &(functorId.m_lambda->to_method()); + } + if (normalArgsId == functorId.m_lambda->get_normal_sign_id()) + { + if (normalArgsId == functorId.m_lambda->get_strict_sign_id()) { + refOverloads[0] = functorId.m_lambda; + } + else if (!functorId.m_lambda->is_any_ncref()) { + refOverloads.push_back(functorId.m_lambda); + } + } + } + for (auto& functorId : m_functorIds) + { + if (recordId == functorId.m_lambda->get_record_id() && + normalArgsId == functorId.m_lambda->get_normal_sign_id() && + functorId.m_lambda->is_any_ncref()) + { + refOverloads.push_back(functorId.m_lambda); } } - return HopMethod(); + return { lambda, refOverloads }; } - template - template requires (std::is_const_v == false) - inline constexpr const method<_returnType(recordT::*)(signatureT...)> - HopMethod::returnT() const + template + template requires (std::is_const_v == false) + inline constexpr const method<_returnType(record_t::*)(args_t...)> + HopMethod::returnT() const { if (m_lambda != nullptr) [[likely]] { const auto retId = traits::uid<_returnType>::value; return m_lambda->template get_hopper<_returnType>(retId); } - return method<_returnType(recordT::*)(signatureT...)>(); + return method<_returnType(record_t::*)(args_t...)>(); } - template - template requires (std::is_const_v == true) - inline constexpr const method<_returnType(recordT::*)(signatureT...) const> - HopMethod::returnT() const + template + template requires (std::is_const_v == true) + inline constexpr const method<_returnType(record_t::*)(args_t...) const> + HopMethod::returnT() const { if (m_lambda != nullptr) [[likely]] { const auto retId = traits::uid<_returnType>::value; return m_lambda->template get_hopper<_returnType>(retId); } - return method<_returnType(recordT::*)(signatureT...) const>(); + return method<_returnType(record_t::*)(args_t...) const>(); } } namespace rtl::detail { - template - template requires (std::is_same_v, RObject> == false) - ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept + template + template requires (std::is_same_v, RObject> == false) + ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_return_rec(); + const auto& caller = erased.template to_erased_return_rec(); if(functorId.first->m_lambda->is_void()) { caller.hop_void(m_target, std::forward(params)...); @@ -228,9 +254,9 @@ namespace rtl::detail } - template - template requires (std::is_same_v, RObject> == true) - ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept + template + template requires (std::is_same_v, RObject> == true) + ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index 72515df7..afdf7199 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -66,7 +66,9 @@ namespace rtl::dispatch GETTER_CREF(functor, _functor, m_functor) GETTER_BOOL(_any_ncref, m_functor.m_is_any_ncref) - + + GETTER(traits::uid_t, _record_id, m_functor.m_recordId) + GETTER(traits::uid_t, _strict_sign_id, m_functor.m_strict_signId) GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_signId) From c5b27466d8b0d7de3140b2985df97634495230c6 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 13 Oct 2025 16:50:34 +0530 Subject: [PATCH 084/148] callable integration, tests failing, wip. --- .../src/ReflectedCallUnknownReturn.cpp | 8 +- .../rtl/cache/cache_function_ptr.h | 6 +- .../rtl/cache/cache_method_ptr.h | 6 +- .../rtl/cache/cache_method_ptr_const.h | 4 +- .../rtl/detail/inc/FunctionCaller.h | 2 +- .../rtl/detail/inc/FunctionCaller.hpp | 80 ++++++++++--------- .../rtl/detail/inc/MethodInvoker.hpp | 48 ++++++----- .../rtl/dispatch/CMakeLists.txt | 6 +- .../{functor_function.h => function_ptr.h} | 0 .../rtl/dispatch/lambda_function.h | 2 +- .../rtl/dispatch/lambda_method.h | 2 +- .../{functor_method.h => method_ptr.h} | 0 ...ctor_method_const.h => method_ptr_const.h} | 0 .../rtl/dispatch/rtl_function_erased_return.h | 40 ++++++---- .../rtl/erasure/aware_hopper_rec.h | 8 +- .../rtl/erasure/aware_hopper_rec_const.h | 8 +- .../rtl/erasure/erased_hopper.h | 37 +++------ .../rtl/erasure/erased_hopper_rec.h | 14 +--- 18 files changed, 132 insertions(+), 139 deletions(-) rename ReflectionTemplateLib/rtl/dispatch/{functor_function.h => function_ptr.h} (100%) rename ReflectionTemplateLib/rtl/dispatch/{functor_method.h => method_ptr.h} (100%) rename ReflectionTemplateLib/rtl/dispatch/{functor_method_const.h => method_ptr_const.h} (100%) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 2a5be259..18395212 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -17,24 +17,24 @@ namespace cxx namespace { - static rtl::Function GetMessage = []() + static rtl::function GetMessage = []() { std::optional function = cxx::mirror().getFunction("getMessage"); if (!function) { std::cerr << "[0] error: erase_function 'getMessage' not found.\n"; std::abort(); } - return *function; + return function->argsT().returnT(); }(); - static rtl::Function SendMessage = []() + static rtl::function SendMessage = []() { std::optional function = cxx::mirror().getFunction("sendMessage"); if (!function) { std::cerr << "[1] error: erase_function 'sendMessage' not found.\n"; std::abort(); } - return *function; + return function->argsT().returnT(); }(); static rtl::Method NodeGetMessage = []() diff --git a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index 137418cb..2d827eed 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -13,7 +13,7 @@ #include -#include "functor_function.h" +#include "function_ptr.h" namespace rtl::cache { @@ -34,7 +34,7 @@ namespace rtl::cache return m_cache.back().first; } - std::pair find(return_t(*fptr)(signature_t...)) const + std::pair find(return_t(*fptr)(signature_t...)) const { for (auto& itr : m_cache) { @@ -54,7 +54,7 @@ namespace rtl::cache private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; function_ptr() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h index a53cd826..8fd115e2 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr.h @@ -13,7 +13,7 @@ #include -#include "functor_method.h" +#include "method_ptr.h" namespace rtl::cache { @@ -36,7 +36,7 @@ namespace rtl::cache return m_cache.back().first; } - std::pair find(functor_t fptr) const + std::pair find(functor_t fptr) const { for (auto& itr : m_cache) { @@ -56,7 +56,7 @@ namespace rtl::cache private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; method_ptr() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h b/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h index ba450254..2fb9a1a0 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h +++ b/ReflectionTemplateLib/rtl/cache/cache_method_ptr_const.h @@ -13,7 +13,7 @@ #include -#include "functor_method_const.h" +#include "method_ptr_const.h" namespace rtl::cache { @@ -56,7 +56,7 @@ namespace rtl::cache private: // No reallocation occurs; original objects stay intact - mutable std::list> m_cache; + mutable std::list> m_cache; method_ptr() = default; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index daa3bf4e..34c4f78d 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -42,7 +42,7 @@ namespace rtl::detail std::vector m_lambdaRefOverloads = {}; template requires (std::is_same_v<_returnType, rtl::Return>) - constexpr const function<_returnType(_signature...)> returnT() const; + constexpr function returnT() const; template requires (!std::is_same_v<_returnType, rtl::Return>) constexpr const function<_returnType(_signature...)> returnT() const; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index c0a7ef13..b44abd43 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -17,7 +17,7 @@ #include "FunctorContainer.h" #include "erased_hopper.h" - +#include "rtl_function_erased_return.h" namespace rtl::detail { @@ -76,13 +76,17 @@ namespace rtl::detail template template requires (std::is_same_v) - inline constexpr const function HopFunction::returnT() const + inline constexpr function HopFunction::returnT() const { - const auto retId = traits::uid::value; - if (m_lambda != nullptr) [[likely]] { - return m_lambda->template get_hopper(retId); + function...)> erasedReturnFunc; + for (auto lambda : m_lambdaRefOverloads) + { + auto eret = lambda->m_erasure.to_erased_return...>(); + erasedReturnFunc.get_vhop().push_back(eret.get_void_hopper()); + erasedReturnFunc.get_rhop().push_back(eret.get_return_hopper()); + erasedReturnFunc.m_lambda.push_back(lambda); } - return function(); + return erasedReturnFunc; } @@ -102,27 +106,27 @@ namespace rtl::detail template requires (is_binding_v == true) ForceInline constexpr Return ErasedCaller::operator()(args_t&&...params) const noexcept { - auto functorId = m_function.getLambdaByStrictId(traits::uid>::value); - if (functorId) [[likely]] - { - const auto& erased = functorId->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_return(); - if (functorId->m_lambda->is_void()) - { - caller.hop_void(std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - return{ error::None, - RObject{ caller.hop_return(std::forward(params)...), - caller.get_return_id(), nullptr } - }; - } - } - else [[unlikely]] { + //auto functorId = m_function.getLambdaByStrictId(traits::uid>::value); + //if (functorId) [[likely]] + //{ + // const auto& erased = functorId->m_lambda->m_erasure; + // const auto& caller = erased.template to_erased_return(); + // if (functorId->m_lambda->is_void()) + // { + // caller.hop_void(std::forward(params)...); + // return { error::None, RObject{} }; + // } + // else + // { + // return{ error::None, + // RObject{ caller.hop_return(std::forward(params)...), + // caller.get_return_id(), nullptr } + // }; + // } + //} + //else [[unlikely]] { return { error::SignatureMismatch, RObject{} }; - } + //} } @@ -130,23 +134,25 @@ namespace rtl::detail template requires (is_binding_v == false) ForceInline constexpr Return ErasedCaller::operator()(args_t&&...params) const noexcept { + return { error::InvalidCaller, RObject{} }; + auto functorId = m_function.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; const auto& caller = erased.template to_erased_return(); - if (functorId.first->m_lambda->is_void()) - { - caller.hop_void(std::forward(params)...); + //if (functorId.first->m_lambda->is_void()) + //{ + // caller.hop_void(std::forward(params)...); return { error::None, RObject{} }; - } - else - { - return{ error::None, - RObject{ caller.hop_return(std::forward(params)...), - caller.get_return_id(), nullptr } - }; - } + //} + //else + //{ + // return{ error::None, + // RObject{ caller.hop_return(std::forward(params)...), + // caller.get_return_id(), nullptr } + // }; + //} } else [[unlikely]] { return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 33e8f37c..e855c906 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -230,23 +230,25 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == false) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { + return { error::InvalidCaller, RObject{} }; + auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; const auto& caller = erased.template to_erased_return_rec(); - if(functorId.first->m_lambda->is_void()) - { - caller.hop_void(m_target, std::forward(params)...); + //if(functorId.first->m_lambda->is_void()) + //{ + // caller.hop_void(m_target, std::forward(params)...); return { error::None, RObject{} }; - } - else - { - return{ error::None, - RObject{ caller.hop_return(m_target, std::forward(params)...), - caller.get_return_id(), nullptr } - }; - } + //} + //else + //{ + // return{ error::None, + // RObject{ caller.hop_return(m_target, std::forward(params)...), + // caller.get_return_id(), nullptr } + // }; + //} } else [[unlikely]] { return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; @@ -258,23 +260,25 @@ namespace rtl::detail template requires (std::is_same_v, RObject> == true) ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept { + return { error::InvalidCaller, RObject{} }; + auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { const auto& erased = functorId.first->m_lambda->m_erasure; const auto& caller = erased.template to_erased_return(); - if (functorId.first->m_lambda->is_void()) - { - caller.hop_void(m_target, std::forward(params)...); + //if (functorId.first->m_lambda->is_void()) + //{ + // caller.hop_void(m_target, std::forward(params)...); return { error::None, RObject{} }; - } - else - { - return{ error::None, - RObject{ caller.hop_return(m_target, std::forward(params)...), - caller.get_return_id(), nullptr } - }; - } + //} + //else + //{ + // return{ error::None, + // RObject{ caller.hop_return(m_target, std::forward(params)...), + // caller.get_return_id(), nullptr } + // }; + //} } else return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 490c4847..753757da 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -5,9 +5,9 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/functor.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor_method.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/functor_method_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/method_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/function_ptr.h" + "${CMAKE_CURRENT_SOURCE_DIR}/method_ptr_const.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_base.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_function.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/functor_function.h rename to ReflectionTemplateLib/rtl/dispatch/function_ptr.h diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 81844295..e636a8a5 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -13,7 +13,7 @@ #include "lambda_base.h" #include "rtl_function.h" -#include "functor_function.h" +#include "function_ptr.h" #include "erased_hopper.h" namespace rtl::dispatch diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 41308083..2ba89b77 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -14,7 +14,7 @@ #include "lambda_base.h" #include "rtl_method.h" #include "erased_hopper_rec.h" -#include "functor_method.h" +#include "method_ptr.h" #include "rtl_method_const.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/functor_method.h rename to ReflectionTemplateLib/rtl/dispatch/method_ptr.h diff --git a/ReflectionTemplateLib/rtl/dispatch/functor_method_const.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/functor_method_const.h rename to ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index 275a348b..746ec5ed 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -33,7 +33,7 @@ namespace rtl } if (m_lambda[call_by::value] == nullptr && - (m_lambda.size() > call_by::ref || + (m_lambda.size() > call_by::ncref || m_lambda[call_by::cref]->is_any_ncref()) ) [[unlikely]] { return { error::ExplicitRefBindingRequired, RObject{} }; @@ -42,14 +42,15 @@ namespace rtl auto index = (m_lambda[call_by::value] != nullptr ? call_by::value : call_by::cref); if (m_lambda[index]->is_void()) { - m_void_hop[index](*m_lambda[index], std::forward(params)...); + m_void_hop[index] (*m_lambda[index], std::forward(params)...); return { error::None, RObject{} }; } - else { - + else + { return{ error::None, - RObject{ m_any_hop[index](*m_lambda[index], std::forward(params)...), - m_robj_id, nullptr } + RObject{ m_any_hop[index] (*m_lambda[index], std::forward(params)...), + m_robj_id, nullptr + } }; } } @@ -67,14 +68,15 @@ namespace rtl { if (m_lambda[index]->is_void()) { - m_void_hop[index](*m_lambda[index], std::forward(params)...); + m_void_hop[index] (*m_lambda[index], std::forward(params)...); return { error::None, RObject{} }; } - else { - + else + { return{ error::None, - RObject{ m_any_hop[index](*m_lambda[index], std::forward(params)...), - m_robj_id, nullptr } + RObject{ m_any_hop[index] (*m_lambda[index], std::forward(params)...), + m_robj_id, nullptr + } }; } } @@ -82,7 +84,7 @@ namespace rtl return { error::InvalidCaller, RObject{} }; } - private: + //private: using lambda_vt = std::function; @@ -94,15 +96,23 @@ namespace rtl std::vector m_void_hop = {}; - std::vector m_lambda = {}; + std::vector m_lambda = {}; enum call_by { value = 0, - cref = 1, - ref = 2 + cref = 1, //const ref. + ncref = 2 //non-const ref. }; + std::vector& get_rhop() { + return m_any_hop; + } + + std::vector& get_vhop() { + return m_void_hop; + } + static_assert((!std::is_reference_v && ...), "function: any type cannot be reference here"); }; diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h index 604f0450..7d9e13fb 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h @@ -87,8 +87,8 @@ namespace rtl::dispatch::erase } else { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + using craw_t = std::add_const_t>; + return std::any(craw_t(std::forward(ret_v))); } } else return std::any(); @@ -120,8 +120,8 @@ namespace rtl::dispatch::erase } else { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + using craw_t = std::add_const_t>; + return std::any(craw_t(std::forward(ret_v))); } } else return std::any(); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h index e68290f3..2deabe65 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h @@ -87,8 +87,8 @@ namespace rtl::dispatch::erase } else { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + using craw_t = std::add_const_t>; + return std::any(craw_t(std::forward(ret_v))); } } else return std::any(); @@ -120,8 +120,8 @@ namespace rtl::dispatch::erase } else { - using rconst_t = std::add_const_t>; - return std::any(rconst_t(std::forward(ret_v))); + using craw_t = std::add_const_t>; + return std::any(craw_t(std::forward(ret_v))); } } else return std::any(); diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h index bec05b2c..0eccc66b 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h @@ -17,40 +17,21 @@ namespace rtl::dispatch::erase { - template + template struct erased_hopper : public erasure_base { - using lambda_vt = std::function; + using lambda_vt = std::function; - using lambda_rt = std::function; + using lambda_rt = std::function; - using lambda_robj_vt = std::function; + using lambda_robj_vt = std::function; - using lambda_robj_rt = std::function; + using lambda_robj_rt = std::function; - template - constexpr void hop_void(args_t&&...params) const noexcept - { - m_void_hop(get_lambda(), std::forward(params)...); - } - - template - ForceInline std::any hop_return(args_t&&...params) const noexcept - { - return m_any_ret_hop(get_lambda(), std::forward(params)...); - } - - template - constexpr void hop_void(const RObject& p_robj, args_t&&...params) const noexcept - { - m_void_method_hop(get_lambda(), p_robj, std::forward(params)...); - } - - template - ForceInline std::any hop_return(const RObject& p_robj, args_t&&...params) const noexcept - { - return m_any_ret_method_hop(get_lambda(), p_robj, std::forward(params)...); - } + GETTER(lambda_vt, _void_hopper, m_void_hop) + GETTER(lambda_rt, _return_hopper, m_any_ret_hop) + GETTER(lambda_robj_vt, _void_method_hopper, m_void_method_hop) + GETTER(lambda_robj_rt, _return_method_hopper, m_any_ret_method_hop) protected: diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h index 333ae826..36ca73fa 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h @@ -26,17 +26,9 @@ namespace rtl::dispatch::erase using lambda_rt = std::function; - template - constexpr void hop_void(const record_t& p_target, args_t&&...params) const noexcept - { - m_void_hop(erasure_base::get_lambda(), p_target, std::forward(params)...); - } - - template - ForceInline std::any hop_return(const record_t& p_target, args_t&&...params) const noexcept - { - return m_any_ret_hop(erasure_base::get_lambda(), p_target, std::forward(params)...); - } + GETTER(lambda_vt, _void_hopper, m_void_hop) + + GETTER(lambda_rt, _return_hopper, m_any_ret_hop) protected: From f7649b9c097bcb8438e494f7031f3e049f3d8927 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 14 Oct 2025 16:38:12 +0530 Subject: [PATCH 085/148] return-erased rtl::function integrated, tetsed. wip. --- .../CxxMirrorTests/CxxMirrorObjectTest.cpp | 10 +- .../NameSpaceGlobalsTests.cpp | 17 +- .../BasicTypeErasedDispatch.cpp | 479 ++++++++++++------ .../rtl/detail/inc/FunctionCaller.hpp | 31 +- .../rtl/detail/src/CxxReflection.cpp | 2 + .../rtl/dispatch/function_ptr.h | 1 + ReflectionTemplateLib/rtl/dispatch/functor.h | 5 + .../rtl/dispatch/lambda_base.h | 14 +- .../rtl/dispatch/lambda_method.h | 4 +- .../rtl/dispatch/method_ptr.h | 1 + .../rtl/dispatch/method_ptr_const.h | 1 + .../rtl/dispatch/rtl_function_erased_return.h | 107 ++-- .../rtl/erasure/aware_hopper.h | 6 +- .../rtl/erasure/aware_hopper_rec.h | 12 +- .../rtl/erasure/aware_hopper_rec_const.h | 12 +- .../rtl/erasure/erased_hopper.h | 36 +- .../rtl/erasure/erased_hopper_rec.h | 20 +- .../rtl/erasure/erasure_base.h | 8 +- ReflectionTemplateLib/rtl/rtl_errors.h | 3 + ReflectionTemplateLib/rtl/rtl_typeid.h | 28 +- 20 files changed, 528 insertions(+), 269 deletions(-) diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp index 1a5387d1..58d4be4e 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorObjectTest.cpp @@ -132,11 +132,13 @@ namespace rtl_tests std::optional cstrLen = cxxMirror.getFunction("strlen"); ASSERT_TRUE(cstrLen); + rtl::function cstrlen_fn = cstrLen->argsT().returnT<>(); + EXPECT_TRUE(cstrlen_fn); { // Case 1: normal pointer (deduces as 'const char*') const char* cstr = "Reflection Template Library C++"; - auto [err, ret] = cstrLen->bind().call(cstr); + auto [err, ret] = cstrlen_fn(cstr); ASSERT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); @@ -152,8 +154,7 @@ namespace rtl_tests // Case 2: constexpr top-level const (deduces as 'const char* const&') constexpr const char* cstr = "Reflection Template Library C++"; - // Need to forward as 'const char*' - auto [err, ret] = cstrLen->bind()(cstr); + auto [err, ret] = cstrlen_fn(cstr); ASSERT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); @@ -167,8 +168,7 @@ namespace rtl_tests EXPECT_EQ(rlen, clen); } { // Case 3: string literal (deduces as const char[N], here const char[32]) - // Must explicitly forward as 'const char*'. - auto [err, ret] = cstrLen->bind()("Reflection Template Library C++"); + auto [err, ret] = cstrlen_fn("Reflection Template Library C++"); ASSERT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); diff --git a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp index 176541a9..f4be6a82 100644 --- a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp @@ -208,12 +208,15 @@ namespace rtl_tests TEST(GlobalFunction, overloaded_function_execute_return) { - optional reverseString = cxx::mirror().getFunction(str_reverseString); + optional reverseStringOpt = cxx::mirror().getFunction(str_reverseString); + ASSERT_TRUE(reverseStringOpt); + + rtl::function reverseString = reverseStringOpt->argsT().returnT<>(); ASSERT_TRUE(reverseString); { - //STRA's type is 'consexpr const char*', function accepts 'string', + //STRA's type is 'const char*', function accepts 'string', //so type-casting in place as 'string' - auto [err, ret] = reverseString->bind().call(string(STRA)); + auto [err, ret] = reverseString(STRA); EXPECT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); @@ -222,9 +225,9 @@ namespace rtl_tests auto expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; EXPECT_EQ(retStr, expStr); } { - //STRB's type is 'consexpr const char*', function accepts 'string', + //STRB's type is 'const char*', function accepts 'string', //so explicitly binding type in template (using bind<...>()) to enforce the type as 'string'. - auto [err, ret] = reverseString->bind()(STRB); + auto [err, ret] = reverseString(STRB); EXPECT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); @@ -234,7 +237,9 @@ namespace rtl_tests auto expStr = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; EXPECT_EQ(retStr, expStr); } { - auto [err, ret] = reverseString->bind().call(); + rtl::function reverseStr = reverseStringOpt->argsT<>().returnT<>(); + + auto [err, ret] = reverseStr(); EXPECT_TRUE(err == rtl::error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index de31a3ed..360b291d 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -6,8 +6,6 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" -#include - using namespace test_utils; using namespace test_mirror; @@ -31,77 +29,170 @@ namespace rtl_tests EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } { - auto [err, robj] = erased_ret_func.call(0); + auto [err, robj] = erased_ret_func.bind()(0); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } { - auto [err, robj] = erased_ret_func.call(0); + auto [err, robj] = erased_ret_func.bind()(0); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } } + TEST(BasicTypeErasedDispatch, implicit_resolutions_to_call_by_value_overloads) { - auto reverseStringOpt = cxx::mirror().getFunction(str_reverseString); - ASSERT_TRUE(reverseStringOpt); - - rtl::Function reverseString = *reverseStringOpt; + auto reverseStrOpt = cxx::mirror().getFunction(str_reverseString); + ASSERT_TRUE(reverseStrOpt); + EXPECT_FALSE(reverseStrOpt->hasSignature()); { - auto [err, robj] = reverseString(const_cast(STRA)); - EXPECT_EQ(err, rtl::error::SignatureMismatch); - } { - auto [err, robj] = reverseString(STRA); - - EXPECT_EQ(err, rtl::error::None); - ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); - - const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; - EXPECT_EQ(retStr, expStr); - } { - auto [err, robj] = reverseString(std::string(STRA)); - - EXPECT_EQ(err, rtl::error::None); - ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); - - const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; - EXPECT_EQ(retStr, expStr); - } { - std::string str = STRA; - auto [err, robj] = reverseString(&str); - - EXPECT_EQ(err, rtl::error::None); - ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); - - const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; - EXPECT_EQ(retStr, expStr); - } { - const std::string str = STRA; - auto [err, robj] = reverseString(&str); - - EXPECT_EQ(err, rtl::error::None); - ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); - - const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; - EXPECT_EQ(retStr, expStr); - } { - auto [err, robj] = reverseString(); - - EXPECT_EQ(err, rtl::error::None); - ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); - - const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; - EXPECT_EQ(retStr, expStr); + rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + EXPECT_FALSE(reverseString); + { + auto [err, robj] = reverseString(const_cast(STRA)); + + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = reverseString.bind()(const_cast(STRA)); + + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind()(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind()(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); + { + std::string str = STRA; + auto [err, robj] = reverseString(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + EXPECT_EQ(retStr, expStr); + } { + std::string str = STRA; + auto [err, robj] = reverseString.bind()(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); + { + const std::string str = STRA; + auto [err, robj] = reverseString(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + EXPECT_EQ(retStr, expStr); + } { + const std::string str = STRA; + auto [err, robj] = reverseString.bind()(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature<>()); + { + rtl::function reverseString = reverseStrOpt->argsT<>().returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind()(); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + EXPECT_EQ(retStr, expStr); + } } } @@ -111,19 +202,37 @@ namespace rtl_tests auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); ASSERT_TRUE(revStrOverloadValCRefOpt); - rtl::Function revStrOverloadValCRef = *revStrOverloadValCRefOpt; - { - std::string_view str = STRA; + EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); - // Both by-value (T) and const-ref (const T&) overloads exist. + // Both by-value (T) and const-ref (const T&) overloads exist. + EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + std::string_view str = STRA; + + rtl::function reverseString = revStrOverloadValCRefOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); + { // RTL chooses the safe by-value overload implicitly. The const-ref // path requires explicit binding only to disambiguate intent. // Note: If only const T& existed (no by-value overload), RTL would // call it implicitly, since binding to const-ref cannot mutate the caller. - auto [err, robj] = revStrOverloadValCRef(str); + auto [err, robj] = reverseString(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(retStr, expStr); + } { + // explicit call by value resolution. + auto [err, robj] = reverseString.bind()(str); + EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; @@ -137,22 +246,34 @@ namespace rtl_tests auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); ASSERT_TRUE(revStrOverloadValCRefOpt); - rtl::Function revStrOverloadValCRef = *revStrOverloadValCRefOpt; - { - std::string_view str = STRA; + EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + + // Both by-value (T) and const-ref (const T&) overloads exist. + EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + std::string_view str = STRA; + rtl::function reverseString = revStrOverloadValCRefOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); + { // Explicitly selecting the const-ref overload using .bind(). - // Required only when a by-value overload exists to resolve ambiguity. // If no by-value overload were present, implicit resolution to const-ref // would have worked automatically, because const-ref cannot mutate. - auto [err, robj] = revStrOverloadValCRef.bind()(str); + auto [err, robj] = reverseString.bind()(str); + EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind()(str); + + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + ASSERT_TRUE(robj.isEmpty()); } } @@ -162,20 +283,33 @@ namespace rtl_tests auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); ASSERT_TRUE(revStrOverloadValRefOpt); - rtl::Function revStrOverloadValRef = *revStrOverloadValRefOpt; + EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + + // Here both by-value (T) and non-const ref (T&) overloads exist. + EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + std::string_view str = STRA; + + rtl::function reverseString = revStrOverloadValRefOpt->argsT().returnT<>(); { - std::string_view str = STRA; - - // Here both by-value (T) and non-const ref (T&) overloads exist. - // Unlike in static C++, where such a situation causes ambiguity and - // requires an explicit static_cast, RTL prioritizes the safe-by-value - // overload automatically since it guarantees no mutation. - // The non-const ref overload remains accessible only through explicit - // binding to preserve mutability intent. - auto [err, robj] = revStrOverloadValRef(str); + // Here also, RTL prioritizes the safe-by-value overload automatically + // since it guarantees no mutation. The non-const ref overload remains + // accessible only through explicit binding to preserve mutability intent. + auto [err, robj] = reverseString(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(retStr, expStr); + } { + // explicit call by value resolution. + auto [err, robj] = reverseString.bind()(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; @@ -188,67 +322,72 @@ namespace rtl_tests { auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); ASSERT_TRUE(revStrOverloadValRefOpt); + + EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + + // Here both by-value (T) and non-const ref (T&) overloads exist. + EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + std::string_view str = STRA; - rtl::Function revStrOverloadValRef = *revStrOverloadValRefOpt; + rtl::function reverseString = revStrOverloadValRefOpt->argsT().returnT<>(); { - std::string_view str = STRA; - // Explicitly selecting the non-const ref overload. // Even though the by-value overload is preferred implicitly for safety, // the user can override that choice by binding explicitly as T&, // signaling the intent to allow mutation through reflection. - auto [err, robj] = revStrOverloadValRef.bind()(str); + auto [err, robj] = reverseString.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind()(str); + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + ASSERT_TRUE(robj.isEmpty()); } } - - // ----------------------------------------------------------------------------- - // Tests implicit vs explicit binding behavior for reference arguments in RTL. - // Demonstrates RTL's intentional design choice: non-const refs require explicit - // opt-in binding to prevent unintended mutation through reflection. - // ----------------------------------------------------------------------------- TEST(BasicTypeErasedDispatch, calling_non_overloaded_non_const_ref_argument) { auto revStrNonConstRefArgOpt = cxx::mirror().getFunction(str_revStrNonConstRefArg); ASSERT_TRUE(revStrNonConstRefArgOpt); + EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + + // Here no overloads exists, only non-const ref (T&) argument. + EXPECT_TRUE(revStrNonConstRefArgOpt->hasSignature()); std::string_view str = STRA; - rtl::Function revStrNonConstRefArg = *revStrNonConstRefArgOpt; - - // ------------------------------------------------------------------------- - // Case 1: Implicit call with a value (or perfectly forwarded lvalue) - // ------------------------------------------------------------------------- - // Even though 'str' is an lvalue and forwarding is perfect, RTL enforces - // semantic safety: calls that may mutate user data (T&) require explicit - // intent. Hence, the dispatcher returns ExplicitRefBindingRequired instead - // of silently binding to a non-const lvalue reference. - // ------------------------------------------------------------------------- - { - auto [err, robj] = revStrNonConstRefArg(str); - EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); - } - // ------------------------------------------------------------------------- - // Case 2: Explicitly binding as std::string_view& - // ------------------------------------------------------------------------- - // By calling .bind(), the user explicitly signals willingness to let - // the function modify the argument. This re-enables the T& call path and - // executes successfully, producing the expected result. - // ------------------------------------------------------------------------- + rtl::function reverseString = revStrNonConstRefArgOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); + + // Calls that may mutate user data (T&) require explicit intent. + // Hence, the dispatcher returns 'ExplicitRefBindingRequired' error. + // Since no call by value overload exists. { - auto [err, robj] = revStrNonConstRefArg.bind()(str); + auto [err, robj] = reverseString(str); + EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + } { + // expected non-const ref binding. + auto [err, robj] = reverseString.bind()(str); + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + } { + // By calling .bind(), the user explicitly signals willingness to let + // the function modify the argument. This re-enables the T& call path and + // executes successfully, producing the expected result. + auto [err, robj] = reverseString.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; @@ -257,36 +396,51 @@ namespace rtl_tests } - // ----------------------------------------------------------------------------- - // Tests implicit binding for const-reference arguments. - // Since const-ref parameters cannot mutate caller data, RTL allows implicit - // binding without requiring an explicit .bind() call. - // ----------------------------------------------------------------------------- TEST(BasicTypeErasedDispatch, calling_non_overloaded_const_ref_argument) { auto revStrConstRefArgOpt = cxx::mirror().getFunction(str_revStrConstRefArg); ASSERT_TRUE(revStrConstRefArgOpt); + EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + + // Here no overloads exists, only non-const ref (T&) argument. + EXPECT_TRUE(revStrConstRefArgOpt->hasSignature()); std::string_view str = STRA; - rtl::Function revStrConstRefArg = *revStrConstRefArgOpt; - - // ------------------------------------------------------------------------- - // Case: Implicitly binding to const-ref parameter - // ------------------------------------------------------------------------- - // Safe by C++ semantics temporaries and values can bind to const& freely. - // RTL mirrors this rule at runtime, so the call proceeds without requiring - // explicit binding and executes successfully. - // ------------------------------------------------------------------------- + + rtl::function reverseString = revStrConstRefArgOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); { - auto [err, robj] = revStrConstRefArg(str); + // This call resolves to the const-ref overload (no other overloads exist), + // so the argument is implicitly bound as a const reference. + auto [err, robj] = reverseString(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; EXPECT_EQ(retStr, expStr); + } { + // explicit binding must also behave the same way. + auto [err, robj] = reverseString.bind()(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(retStr, expStr); + } { + // explicit binding to non-const ref returns error. + auto [err, robj] = reverseString.bind()(str); + + // expected 'const T&' + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + ASSERT_TRUE(robj.isEmpty()); } } @@ -296,16 +450,24 @@ namespace rtl_tests auto revStrRValueRefArgOpt = cxx::mirror().getFunction(str_revStrRValueRefArg); ASSERT_TRUE(revStrRValueRefArgOpt); - rtl::Function revStrRValueRefArg = *revStrRValueRefArgOpt; + EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + + // Here no overloads exists, only non-const ref (T&) argument. + EXPECT_TRUE(revStrRValueRefArgOpt->hasSignature()); + + rtl::function reverseString = revStrRValueRefArgOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); { - auto [err, robj] = revStrRValueRefArg(std::string_view(STRA)); + auto [err, robj] = reverseString(std::string_view(STRA)); EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); } { - auto [err, robj] = revStrRValueRefArg.bind()(std::string_view(STRA)); + auto [err, robj] = reverseString.bind()(std::string_view(STRA)); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; @@ -319,15 +481,28 @@ namespace rtl_tests auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(revStrOverloadValRefNCrefOpt); - rtl::Function revStrOverloadValRefNCref = *revStrOverloadValRefNCrefOpt; - { - std::string_view str = STRA; + EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). + EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + std::string_view str = STRA; + + rtl::function reverseString = revStrOverloadValRefNCrefOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); + { // Both T& and const T& overloads are viable for an lvalue argument. // RTL avoids implicit ambiguity by requiring explicit ref binding // when mutation is possible (non-const ref path). - auto [err, robj] = revStrOverloadValRefNCref(str); + auto [err, robj] = reverseString(str); EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + } { + auto [err, robj] = reverseString.bind()(str); + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + } { + auto [err, robj] = reverseString.bind()(str); + EXPECT_EQ(err, rtl::error::RefBindingMismatch); } } @@ -337,15 +512,23 @@ namespace rtl_tests auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + + // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). + EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); std::string_view str = STRA; - rtl::Function revStrOverloadValRefNCref = *revStrOverloadValRefNCrefOpt; + + rtl::function reverseString = revStrOverloadValRefNCrefOpt->argsT().returnT<>(); + EXPECT_TRUE(reverseString); { // Explicitly selecting the non-const ref overload. // Caller signals intent to allow mutation by binding as T&. - auto [err, robj] = revStrOverloadValRefNCref.bind()(str); + auto [err, robj] = reverseString.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; @@ -356,10 +539,10 @@ namespace rtl_tests // But since both 'T&' and 'const T&' overloads are available, // RTL treats the situation as ambiguous and requires explicit selection // to avoid guessing the user's intent regarding mutability. - auto [err, robj] = revStrOverloadValRefNCref.bind()(str); + auto [err, robj] = reverseString.bind()(str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); - EXPECT_TRUE(robj.canViewAs()); + ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index b44abd43..e0373da6 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -51,6 +51,9 @@ namespace rtl::detail for (auto& functorId : m_functorIds) { + auto ssignId = functorId.m_lambda->get_strict_sign_id(); + auto nsignId = functorId.m_lambda->get_normal_sign_id(); + if (!lambda && strictArgsId == functorId.m_lambda->get_strict_sign_id()) { lambda = &(functorId.m_lambda->to_function()); } @@ -78,13 +81,33 @@ namespace rtl::detail template requires (std::is_same_v) inline constexpr function HopFunction::returnT() const { + bool isRetTypeVoid = false; function...)> erasedReturnFunc; + for (auto lambda : m_lambdaRefOverloads) { - auto eret = lambda->m_erasure.to_erased_return...>(); - erasedReturnFunc.get_vhop().push_back(eret.get_void_hopper()); - erasedReturnFunc.get_rhop().push_back(eret.get_return_hopper()); - erasedReturnFunc.m_lambda.push_back(lambda); + erasedReturnFunc.m_lambdas.push_back(lambda); + if (lambda) + { + auto eret = lambda->m_erasure.to_erased_return...>(); + if (lambda->is_void()) { + erasedReturnFunc.get_vhop().push_back(eret.get_void_hopper()); + isRetTypeVoid = true; + } + else { + erasedReturnFunc.get_rhop().push_back(eret.get_return_hopper()); + } + } + else { + erasedReturnFunc.get_vhop().push_back(nullptr); + erasedReturnFunc.get_rhop().push_back(nullptr); + } + } + if (isRetTypeVoid) { + erasedReturnFunc.get_rhop().clear(); + } + else { + erasedReturnFunc.get_vhop().clear(); } return erasedReturnFunc; } diff --git a/ReflectionTemplateLib/rtl/detail/src/CxxReflection.cpp b/ReflectionTemplateLib/rtl/detail/src/CxxReflection.cpp index cfc2683c..48849bb5 100644 --- a/ReflectionTemplateLib/rtl/detail/src/CxxReflection.cpp +++ b/ReflectionTemplateLib/rtl/detail/src/CxxReflection.cpp @@ -51,6 +51,7 @@ namespace rtl { else { const auto& function = itr->second; //if the function is already present, add its 'FunctorId' as overload. + // TODO: Make sure every overload has identical return type/id. function.addOverload(pFunction); } } @@ -73,6 +74,7 @@ namespace rtl { else { const auto& function = itr->second; //if the method is already present, add as overload. + // TODO: Make sure every overload has identical return type/id. function.addOverload(pFunction); } } diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index eed48ec5..79dc01cf 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -33,6 +33,7 @@ namespace rtl::dispatch function_ptr(functor_t fptr) :m_functor(fptr) { m_returnId = traits::uid::value; + m_is_void = (m_returnId == traits::uid::value); m_is_any_ncref = (traits::is_nonconst_ref_v || ...); m_normal_signId = traits::uid>::value; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 28d22b52..7385e093 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -18,6 +18,10 @@ namespace rtl::dispatch { struct functor { + constexpr bool is_void() const { + return m_is_void; + } + GETTER_CPTR(lambda_base, _lambda, m_lambda) protected: @@ -32,6 +36,7 @@ namespace rtl::dispatch traits::uid_t m_normal_signId = traits::uid<>::none; traits::uid_t m_strict_signId = traits::uid<>::none; + bool m_is_void = false; bool m_is_any_ncref = false; std::vector m_argumentsId = {}; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index afdf7199..593c3a20 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -19,11 +19,6 @@ namespace rtl::dispatch { struct lambda_base { - constexpr bool is_void() const - { - return m_is_void; - } - template using function_t = lambda_function; @@ -72,15 +67,16 @@ namespace rtl::dispatch GETTER(traits::uid_t, _strict_sign_id, m_functor.m_strict_signId) GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_signId) + + constexpr bool is_void() const { + return m_functor.m_is_void; + } lambda_base(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept - : m_is_void(p_functor.m_returnId == traits::uid::value) - , m_functor(p_functor) + : m_functor(p_functor) , m_erasure(p_erasure) { } - const bool m_is_void; - const functor& m_functor; const erase::erasure_base& m_erasure; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 2ba89b77..253aa2cf 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -32,7 +32,7 @@ namespace rtl::dispatch return static_cast&>(m_functor).f_ptr(); } - template requires (std::is_const_v == false) + template requires (!std::is_const_v) constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] @@ -46,7 +46,7 @@ namespace rtl::dispatch template using hopper_ct = rtl::method; - template requires (std::is_const_v == true) + template requires (std::is_const_v) constexpr const hopper_ct get_hopper(std::size_t p_returnId = 0) const { if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 5b30dca9..b697fe08 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -37,6 +37,7 @@ namespace rtl::dispatch m_qualifier = detail::methodQ::NonConst; m_returnId = traits::uid::value; + m_is_void = (m_returnId == traits::uid::value); m_recordId = traits::uid::value; m_is_any_ncref = (traits::is_nonconst_ref_v || ...); diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h index 5defc46c..a8bd46e4 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h @@ -37,6 +37,7 @@ namespace rtl::dispatch m_qualifier = detail::methodQ::Const; m_returnId = traits::uid::value; + m_is_void = (m_returnId == traits::uid::value); m_recordId = traits::uid::value; m_is_any_ncref = (traits::is_nonconst_ref_v || ...); diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index 746ec5ed..b0176dcd 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -20,68 +20,91 @@ namespace rtl template struct function { - constexpr operator bool() const { - return (!m_lambda.empty()); - } - template - [[nodiscard]] + requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] constexpr Return operator()(args_t&&...params) const noexcept { - if (m_lambda.empty()) [[unlikely]] { + if (!(*this)) [[unlikely]] { return { error::InvalidCaller, RObject{} }; } - if (m_lambda[call_by::value] == nullptr && - (m_lambda.size() > call_by::ncref || - m_lambda[call_by::cref]->is_any_ncref()) ) [[unlikely]] - { + if (must_bind_refs()) [[unlikely]] { return { error::ExplicitRefBindingRequired, RObject{} }; } - auto index = (m_lambda[call_by::value] != nullptr ? call_by::value : call_by::cref); - if (m_lambda[index]->is_void()) + auto index = (m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (m_lambdas[index]->is_void()) { - m_void_hop[index] (*m_lambda[index], std::forward(params)...); + m_vhop[index] (*m_lambdas[index], std::forward(params)...); return { error::None, RObject{} }; } else { - return{ error::None, - RObject{ m_any_hop[index] (*m_lambda[index], std::forward(params)...), - m_robj_id, nullptr - } + return { error::None, + RObject{ m_rhop[index] (*m_lambdas[index], std::forward(params)...), + m_lambdas.back()->m_erasure.m_return_id, nullptr + } }; } } - template - requires (std::is_same_v, std::tuple> == true) - [[nodiscard]] - constexpr Return call(args_t&&...params) const noexcept + template + struct perfect_fwd { - auto signature_id = traits::uid>::value; - for (int index = 0; index < m_lambda.size(); index++) + const function& fn; + + template + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept { - if (signature_id == m_lambda[index]->get_strict_sign_id()) + if (!fn) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + auto signature_id = traits::uid>::value; + for (int index = 0; index < fn.m_lambdas.size(); index++) { - if (m_lambda[index]->is_void()) - { - m_void_hop[index] (*m_lambda[index], std::forward(params)...); - return { error::None, RObject{} }; - } - else + if (fn.m_lambdas[index] != nullptr) { - return{ error::None, - RObject{ m_any_hop[index] (*m_lambda[index], std::forward(params)...), - m_robj_id, nullptr - } - }; + if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) + { + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index] (*(fn.m_lambdas[index]), std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ fn.m_rhop[index] (*(fn.m_lambdas[index]), std::forward(params)...), + fn.m_lambdas.back()->m_erasure.m_return_id, nullptr + } + }; + } + } } } + return { error::RefBindingMismatch, RObject{} }; } - return { error::InvalidCaller, RObject{} }; + }; + + + template + requires (std::is_same_v, std::tuple>) + [[nodiscard]] + constexpr const perfect_fwd bind() const noexcept { + return perfect_fwd{ *this }; + } + + constexpr operator bool() const noexcept { + return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } + + constexpr bool must_bind_refs() const noexcept { + return (m_lambdas[call_by::value] == nullptr && + (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); } //private: @@ -90,13 +113,11 @@ namespace rtl using lambda_rt = std::function; - detail::RObjectId m_robj_id = {}; - - std::vector m_any_hop = {}; + std::vector m_rhop = {}; - std::vector m_void_hop = {}; + std::vector m_vhop = {}; - std::vector m_lambda = {}; + std::vector m_lambdas = {}; enum call_by { @@ -106,11 +127,11 @@ namespace rtl }; std::vector& get_rhop() { - return m_any_hop; + return m_rhop; } std::vector& get_vhop() { - return m_void_hop; + return m_vhop; } static_assert((!std::is_reference_v && ...), diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h index 9326e7e4..e8441bd5 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h @@ -25,9 +25,9 @@ namespace rtl::dispatch::erase aware_hopper(const dispatch::functor& p_functor) : base_t( p_functor, - detail::RObjectId::create(isConstCastSafe), - aware_hopper::get_lambda_void(), - aware_hopper::get_lambda_any_return() ) + p_functor.is_void() ? aware_hopper::get_lambda_void() : nullptr, + !p_functor.is_void() ? aware_hopper::get_lambda_any_return() : nullptr, + detail::RObjectId::create(isConstCastSafe) ) { } constexpr static auto get_lambda_void() noexcept diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h index 7d9e13fb..72fbe28a 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h @@ -26,12 +26,12 @@ namespace rtl::dispatch::erase constexpr static bool isConstCastSafe = (!traits::is_const_v); aware_hopper_rec(const dispatch::functor& p_functor) - : base_t( p_functor, - detail::RObjectId::create(isConstCastSafe), - aware_hopper_rec::get_lambda_void(), - aware_hopper_rec::get_lambda_any_ret(), - aware_hopper_rec::get_lambda_void_robj(), - aware_hopper_rec::get_lambda_any_ret_robj() ) + : base_t( p_functor, + p_functor.is_void() ? aware_hopper_rec::get_lambda_void() : nullptr, + !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret() : nullptr, + p_functor.is_void() ? aware_hopper_rec::get_lambda_void_robj() : nullptr, + !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret_robj() : nullptr, + detail::RObjectId::create(isConstCastSafe) ) { } constexpr static auto get_lambda_void() noexcept diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h index 2deabe65..e0440bba 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h @@ -26,12 +26,12 @@ namespace rtl::dispatch::erase constexpr static bool isConstCastSafe = (!traits::is_const_v); aware_hopper_rec(const dispatch::functor& p_functor) - : base_t( p_functor, - detail::RObjectId::create(isConstCastSafe), - aware_hopper_rec::get_lambda_void(), - aware_hopper_rec::get_lambda_any_ret(), - aware_hopper_rec::get_lambda_void_robj(), - aware_hopper_rec::get_lambda_any_ret_robj() ) + : base_t( p_functor, + p_functor.is_void() ? aware_hopper_rec::get_lambda_void() : nullptr, + !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret() : nullptr, + p_functor.is_void() ? aware_hopper_rec::get_lambda_void_robj() : nullptr, + !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret_robj() : nullptr, + detail::RObjectId::create(isConstCastSafe)) { } constexpr static auto get_lambda_void() noexcept diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h index 0eccc66b..b37c423f 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h @@ -28,39 +28,39 @@ namespace rtl::dispatch::erase using lambda_robj_rt = std::function; - GETTER(lambda_vt, _void_hopper, m_void_hop) - GETTER(lambda_rt, _return_hopper, m_any_ret_hop) - GETTER(lambda_robj_vt, _void_method_hopper, m_void_method_hop) - GETTER(lambda_robj_rt, _return_method_hopper, m_any_ret_method_hop) + GETTER_CREF(lambda_vt, _void_hopper, m_vhopper) + GETTER_CREF(lambda_rt, _return_hopper, m_rhopper) + GETTER_CREF(lambda_robj_vt, _void_method_hopper, m_vmhopper) + GETTER_CREF(lambda_robj_rt, _return_method_hopper, m_rmhopper) protected: - lambda_vt m_void_hop; + lambda_vt m_vhopper; - lambda_rt m_any_ret_hop; + lambda_rt m_rhopper; - lambda_robj_vt m_void_method_hop; + lambda_robj_vt m_vmhopper; - lambda_robj_rt m_any_ret_method_hop; + lambda_robj_rt m_rmhopper; erased_hopper( const dispatch::functor& p_functor, - const detail::RObjectId& p_robj_id, const lambda_vt& p_void_hop, - const lambda_rt& p_any_ret_hop ) noexcept + const lambda_rt& p_any_ret_hop, + const detail::RObjectId& p_ret_id ) noexcept - : erasure_base(p_functor, p_robj_id) - , m_void_hop(p_void_hop) - , m_any_ret_hop(p_any_ret_hop) + : erasure_base(p_functor, p_ret_id) + , m_vhopper(p_void_hop) + , m_rhopper(p_any_ret_hop) { } erased_hopper( const dispatch::functor& p_functor, - const detail::RObjectId& p_robj_id, const lambda_robj_vt& p_void_method_hop, - const lambda_robj_rt& p_any_ret_method_hop ) noexcept + const lambda_robj_rt& p_any_ret_method_hop, + const detail::RObjectId& p_ret_id ) noexcept - : erasure_base(p_functor, p_robj_id) - , m_void_method_hop(p_void_method_hop) - , m_any_ret_method_hop(p_any_ret_method_hop) + : erasure_base(p_functor, p_ret_id) + , m_vmhopper(p_void_method_hop) + , m_rmhopper(p_any_ret_method_hop) { } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h index 36ca73fa..03ae69a4 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h @@ -26,28 +26,28 @@ namespace rtl::dispatch::erase using lambda_rt = std::function; - GETTER(lambda_vt, _void_hopper, m_void_hop) + GETTER(lambda_vt, _void_hopper, m_vhopper) - GETTER(lambda_rt, _return_hopper, m_any_ret_hop) + GETTER(lambda_rt, _return_hopper, m_rhopper) protected: - lambda_vt m_void_hop; + lambda_vt m_vhopper; - lambda_rt m_any_ret_hop; + lambda_rt m_rhopper; using base_t = erased_hopper; - erased_hopper_rec( const dispatch::functor& p_functor, - const detail::RObjectId& p_robj_id, + erased_hopper_rec( const dispatch::functor& p_functor, const lambda_vt& p_void_hop, const lambda_rt& p_any_ret_hop, const base_t::lambda_robj_vt& p_void_robj_hop, - const base_t::lambda_robj_rt& p_any_ret_robj_hop ) noexcept + const base_t::lambda_robj_rt& p_any_ret_robj_hop, + const detail::RObjectId& p_ret_id ) noexcept - : base_t(p_functor, p_robj_id, p_void_robj_hop, p_any_ret_robj_hop) - , m_void_hop(p_void_hop) - , m_any_ret_hop(p_any_ret_hop) + : base_t(p_functor, p_void_robj_hop, p_any_ret_robj_hop, p_ret_id) + , m_vhopper(p_void_hop) + , m_rhopper(p_any_ret_hop) { } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_base.h b/ReflectionTemplateLib/rtl/erasure/erasure_base.h index 3944a2b8..00b3c369 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_base.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure_base.h @@ -37,16 +37,16 @@ namespace rtl::dispatch::erase return static_cast&>(*this); } - erasure_base(const dispatch::functor& p_functor, const detail::RObjectId& p_robj_id) noexcept + erasure_base(const dispatch::functor& p_functor, const detail::RObjectId& p_ret_id) noexcept : m_functor(p_functor) - , m_robj_id(p_robj_id) + , m_return_id(p_ret_id) { } const dispatch::functor& m_functor; - const detail::RObjectId m_robj_id; + const detail::RObjectId m_return_id; - GETTER_CREF(detail::RObjectId, _return_id, m_robj_id); + GETTER_CREF(detail::RObjectId, _return_id, m_return_id); GETTER_CREF(dispatch::lambda_base, _lambda, (*m_functor.get_lambda())); }; diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index aaa734b5..da12a345 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -24,6 +24,7 @@ namespace rtl TargetMismatch, SignatureMismatch, + RefBindingMismatch, ExplicitRefBindingRequired, CloningDisabled, //Used only in case of cloning is disabled e.g, unregistered type. @@ -51,6 +52,8 @@ namespace rtl return "Invalid callable: rtl::function/rtl::method object bieng used is empty."; case error::SignatureMismatch: return "Signature mismatch: Function parameters do not match the expected signature"; + case error::RefBindingMismatch: + return "Reference binding mismatch: Argument references do not match the expected parameter bindings"; case error::ExplicitRefBindingRequired: return "Explicit reference binding required for correct overload resolution"; case error::CloningDisabled: diff --git a/ReflectionTemplateLib/rtl/rtl_typeid.h b/ReflectionTemplateLib/rtl/rtl_typeid.h index fa5158f4..88f7697c 100644 --- a/ReflectionTemplateLib/rtl/rtl_typeid.h +++ b/ReflectionTemplateLib/rtl/rtl_typeid.h @@ -68,11 +68,11 @@ namespace rtl { if constexpr (std::is_same_v<_type, void>) { return std::string("void"); } - if constexpr (std::is_same_v<_type, std::string>) { - return std::string("std::string"); + if constexpr (std::is_same_v<_type, std::string*>) { + return std::string("std::string*"); } - if constexpr (std::is_same_v<_type, const std::string>) { - return std::string("const std::string"); + if constexpr (std::is_same_v<_type, const std::string*>) { + return std::string("const std::string*"); } if constexpr (std::is_same_v<_type, std::string&>) { return std::string("std::string&"); @@ -81,7 +81,25 @@ namespace rtl { return std::string("const std::string&"); } if constexpr (std::is_same_v<_type, std::string&&>) { - return std::string("const std::string&&"); + return std::string("std::string&&"); + } + if constexpr (std::is_same_v<_type, const std::string>) { + return std::string("const std::string"); + } + if constexpr (std::is_same_v<_type, std::string>) { + return std::string("std::string"); + } + if constexpr (std::is_same_v<_type, std::string_view&>) { + return std::string("std::string_view&"); + } + if constexpr (std::is_same_v<_type, const std::string_view&>) { + return std::string("const std::string_view&"); + } + if constexpr (std::is_same_v<_type, std::string_view&&>) { + return std::string("std::string_view&&"); + } + if constexpr (std::is_same_v<_type, const std::string_view>) { + return std::string("const std::string_view"); } if constexpr (std::is_same_v<_type, std::string_view>) { return std::string("std::string_view"); From 9e3fb9af5847551b2fa752c991102d0bd7314809 Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 14 Oct 2025 17:04:13 +0530 Subject: [PATCH 086/148] fix gcc/clang compile error. --- ReflectionTemplateLib/rtl/erasure/aware_hopper.h | 4 ++-- ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h | 8 ++++---- .../rtl/erasure/aware_hopper_rec_const.h | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h index e8441bd5..f557e5c8 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h @@ -25,8 +25,8 @@ namespace rtl::dispatch::erase aware_hopper(const dispatch::functor& p_functor) : base_t( p_functor, - p_functor.is_void() ? aware_hopper::get_lambda_void() : nullptr, - !p_functor.is_void() ? aware_hopper::get_lambda_any_return() : nullptr, + p_functor.is_void() ? aware_hopper::get_lambda_void() : decltype(aware_hopper::get_lambda_void()){}, + !p_functor.is_void() ? aware_hopper::get_lambda_any_return() : decltype(aware_hopper::get_lambda_any_return()){}, detail::RObjectId::create(isConstCastSafe) ) { } diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h index 72fbe28a..8c702b19 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h @@ -27,10 +27,10 @@ namespace rtl::dispatch::erase aware_hopper_rec(const dispatch::functor& p_functor) : base_t( p_functor, - p_functor.is_void() ? aware_hopper_rec::get_lambda_void() : nullptr, - !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret() : nullptr, - p_functor.is_void() ? aware_hopper_rec::get_lambda_void_robj() : nullptr, - !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret_robj() : nullptr, + p_functor.is_void() ? aware_hopper_rec::get_lambda_void() : decltype(aware_hopper_rec::get_lambda_void()){}, + !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret() : decltype(aware_hopper_rec::get_lambda_any_ret()){}, + p_functor.is_void() ? aware_hopper_rec::get_lambda_void_robj() : decltype(aware_hopper_rec::get_lambda_void_robj()){}, + !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret_robj() : decltype(aware_hopper_rec::get_lambda_any_ret_robj()){}, detail::RObjectId::create(isConstCastSafe) ) { } diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h index e0440bba..aa62e848 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h @@ -27,11 +27,11 @@ namespace rtl::dispatch::erase aware_hopper_rec(const dispatch::functor& p_functor) : base_t( p_functor, - p_functor.is_void() ? aware_hopper_rec::get_lambda_void() : nullptr, - !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret() : nullptr, - p_functor.is_void() ? aware_hopper_rec::get_lambda_void_robj() : nullptr, - !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret_robj() : nullptr, - detail::RObjectId::create(isConstCastSafe)) + p_functor.is_void() ? aware_hopper_rec::get_lambda_void() : decltype(aware_hopper_rec::get_lambda_void()){}, + !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret() : decltype(aware_hopper_rec::get_lambda_any_ret()){}, + p_functor.is_void() ? aware_hopper_rec::get_lambda_void_robj() : decltype(aware_hopper_rec::get_lambda_void_robj()){}, + !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret_robj() : decltype(aware_hopper_rec::get_lambda_any_ret_robj()){}, + detail::RObjectId::create(isConstCastSafe) ) { } constexpr static auto get_lambda_void() noexcept From a9ee96032b927682a1bbb6313769a48679e836ed Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 14 Oct 2025 22:28:35 +0530 Subject: [PATCH 087/148] minor refactor --- .../rtl/detail/inc/FunctionCaller.hpp | 33 ++++++++--------- .../rtl/detail/inc/FunctorId.h | 2 +- .../rtl/detail/inc/MethodInvoker.hpp | 35 +++++++++---------- .../rtl/dispatch/lambda_base.h | 10 +++--- .../rtl/dispatch/rtl_function_erased_return.h | 24 +++++++------ ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 6 ++-- ReflectionTemplateLib/rtl/inc/Record.h | 2 +- ReflectionTemplateLib/rtl/rtl_constants.h | 8 +++-- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 3 ++ 10 files changed, 68 insertions(+), 57 deletions(-) diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index e0373da6..8cdd72c3 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -46,34 +46,35 @@ namespace rtl::detail auto strictArgsId = traits::uid>::value; auto normalArgsId = traits::uid>::value; - const dispatch::lambda_function* lambda = nullptr; + const dispatch::lambda_function* lambda_fn = nullptr; std::vector refOverloads = { nullptr }; for (auto& functorId : m_functorIds) { - auto ssignId = functorId.m_lambda->get_strict_sign_id(); - auto nsignId = functorId.m_lambda->get_normal_sign_id(); - - if (!lambda && strictArgsId == functorId.m_lambda->get_strict_sign_id()) { - lambda = &(functorId.m_lambda->to_function()); + auto& lambda = functorId.get_lambda(); + if (!lambda_fn && strictArgsId == lambda.get_strict_sign_id()) { + lambda_fn = &(lambda.to_function()); } - if (normalArgsId == functorId.m_lambda->get_normal_sign_id()) + if (normalArgsId == lambda.get_normal_sign_id()) { - if (normalArgsId == functorId.m_lambda->get_strict_sign_id()) { - refOverloads[0] = functorId.m_lambda; + if (normalArgsId == lambda.get_strict_sign_id()) { + refOverloads[0] = λ } - else if (!functorId.m_lambda->is_any_ncref()) { - refOverloads.push_back(functorId.m_lambda); + else if (!lambda.is_any_ncref()) { + refOverloads.push_back(&lambda); } } } + for (auto& functorId : m_functorIds) { - if (normalArgsId == functorId.m_lambda->get_normal_sign_id() && functorId.m_lambda->is_any_ncref()) { - refOverloads.push_back(functorId.m_lambda); + auto& lambda = functorId.get_lambda(); + if (normalArgsId == lambda.get_normal_sign_id() && lambda.is_any_ncref()) { + refOverloads.push_back(&lambda); } } - return { lambda, refOverloads }; + + return { lambda_fn, refOverloads }; } @@ -86,10 +87,10 @@ namespace rtl::detail for (auto lambda : m_lambdaRefOverloads) { - erasedReturnFunc.m_lambdas.push_back(lambda); + erasedReturnFunc.get_overloads().push_back(lambda); if (lambda) { - auto eret = lambda->m_erasure.to_erased_return...>(); + auto eret = lambda->get_unerasure().to_erased_return...>(); if (lambda->is_void()) { erasedReturnFunc.get_vhop().push_back(eret.get_void_hopper()); isRetTypeVoid = true; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h index 572989fa..5b1dbb0b 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctorId.h @@ -47,7 +47,7 @@ namespace rtl::detail GETTER(std::size_t, RecordId, m_recordId); GETTER(std::size_t, SignatureId, m_containerId) GETTER_CREF(std::string, SignatureStr, m_signature) - + GETTER_CREF(dispatch::lambda_base, _lambda, (*m_lambda)) /* @method: getHashCode() @return: std::size_t (a unique hash-code for a functor) diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index e855c906..2c9d95c6 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -160,38 +160,37 @@ namespace rtl::detail auto strictArgsId = traits::uid>::value; auto normalArgsId = traits::uid>::value; - const dispatch::lambda_method* lambda = nullptr; + const dispatch::lambda_method* lambda_fn = nullptr; std::vector refOverloads = { nullptr }; for (auto& functorId : m_functorIds) { - if (recordId != functorId.m_lambda->get_record_id()) { + auto& lambda = functorId.get_lambda(); + if (recordId != lambda.get_record_id()) { continue; } - if (!lambda && strictArgsId == functorId.m_lambda->get_strict_sign_id()) - { - lambda = &(functorId.m_lambda->to_method()); + if (!lambda_fn && strictArgsId == lambda.get_strict_sign_id()) { + lambda_fn = &(lambda.to_method()); } - if (normalArgsId == functorId.m_lambda->get_normal_sign_id()) + if (normalArgsId == lambda.get_normal_sign_id()) { - if (normalArgsId == functorId.m_lambda->get_strict_sign_id()) { - refOverloads[0] = functorId.m_lambda; + if (normalArgsId == lambda.get_strict_sign_id()) { + refOverloads[0] = λ } - else if (!functorId.m_lambda->is_any_ncref()) { - refOverloads.push_back(functorId.m_lambda); + else if (!lambda.is_any_ncref()) { + refOverloads.push_back(&lambda); } } } for (auto& functorId : m_functorIds) { - if (recordId == functorId.m_lambda->get_record_id() && - normalArgsId == functorId.m_lambda->get_normal_sign_id() && - functorId.m_lambda->is_any_ncref()) - { - refOverloads.push_back(functorId.m_lambda); + auto& lambda = functorId.get_lambda(); + if (recordId == lambda.get_record_id() && + normalArgsId == lambda.get_normal_sign_id() && lambda.is_any_ncref()) { + refOverloads.push_back(&lambda); } } - return { lambda, refOverloads }; + return { lambda_fn, refOverloads }; } @@ -235,7 +234,7 @@ namespace rtl::detail auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { - const auto& erased = functorId.first->m_lambda->m_erasure; + const auto& erased = functorId.first->m_lambda->get_unerasure(); const auto& caller = erased.template to_erased_return_rec(); //if(functorId.first->m_lambda->is_void()) //{ @@ -265,7 +264,7 @@ namespace rtl::detail auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); if (functorId.first) [[likely]] { - const auto& erased = functorId.first->m_lambda->m_erasure; + const auto& erased = functorId.first->m_lambda->get_unerasure(); const auto& caller = erased.template to_erased_return(); //if (functorId.first->m_lambda->is_void()) //{ diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index 593c3a20..3ca7519e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -58,8 +58,14 @@ namespace rtl::dispatch else return nullptr; } + GETTER_BOOL(_void, m_functor.m_is_void) + GETTER_CREF(functor, _functor, m_functor) + GETTER_CREF(erase::erasure_base, _unerasure, m_erasure) + + GETTER_CREF(detail::RObjectId, _return_id, m_erasure.m_return_id); + GETTER_BOOL(_any_ncref, m_functor.m_is_any_ncref) GETTER(traits::uid_t, _record_id, m_functor.m_recordId) @@ -67,10 +73,6 @@ namespace rtl::dispatch GETTER(traits::uid_t, _strict_sign_id, m_functor.m_strict_signId) GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_signId) - - constexpr bool is_void() const { - return m_functor.m_is_void; - } lambda_base(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept : m_functor(p_functor) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index b0176dcd..ee03e42e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -43,7 +43,7 @@ namespace rtl { return { error::None, RObject{ m_rhop[index] (*m_lambdas[index], std::forward(params)...), - m_lambdas.back()->m_erasure.m_return_id, nullptr + m_lambdas.back()->get_return_id(), nullptr } }; } @@ -79,7 +79,7 @@ namespace rtl { return { error::None, RObject{ fn.m_rhop[index] (*(fn.m_lambdas[index]), std::forward(params)...), - fn.m_lambdas.back()->m_erasure.m_return_id, nullptr + fn.m_lambdas.back()->get_return_id(), nullptr } }; } @@ -107,7 +107,7 @@ namespace rtl (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); } - //private: + private: using lambda_vt = std::function; @@ -126,15 +126,17 @@ namespace rtl ncref = 2 //non-const ref. }; - std::vector& get_rhop() { - return m_rhop; - } - - std::vector& get_vhop() { - return m_vhop; - } - + GETTER_REF(std::vector, _rhop, m_rhop) + GETTER_REF(std::vector, _vhop, m_vhop) + GETTER_REF(std::vector, _overloads, m_lambdas) + static_assert((!std::is_reference_v && ...), "function: any type cannot be reference here"); + + //template + //friend struct detail::Hopper; + + template + friend struct detail::HopFunction; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 6bb796a0..f75b9b66 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -75,7 +75,7 @@ namespace rtl { GETTER(detail::methodQ, Qualifier, m_qualifier); - GETTER_REF(std::vector, FunctorIds, m_functorIds) + GETTER_REF_C(std::vector, FunctorIds, m_functorIds) public: diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index b2b76d63..38453edb 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -80,7 +80,7 @@ namespace rtl { //simple linear-search, efficient for small set of elements. for (const auto& functorId : m_functorIds) { - if (pSignatureId == functorId.m_lambda->get_strict_sign_id()) [[likely]] { + if (pSignatureId == functorId.get_lambda().get_strict_sign_id()) [[likely]] { return &functorId; } } @@ -98,7 +98,7 @@ namespace rtl std::size_t index = rtl::index_none; for (int i = 0; i < m_functorIds.size(); i++) { - if (pSignatureId == m_functorIds[i].m_lambda->get_normal_sign_id()) [[likely]] { + if (pSignatureId == m_functorIds[i].get_lambda().get_normal_sign_id()) [[likely]] { if (index == rtl::index_none) { index = i; } @@ -108,7 +108,7 @@ namespace rtl if (index != rtl::index_none) { - auto isAnyNonConstRefInArgsT = (m_functorIds[index].m_lambda->is_any_ncref()); + auto isAnyNonConstRefInArgsT = (m_functorIds[index].get_lambda().is_any_ncref()); return { (isAnyNonConstRefInArgsT ? nullptr : &m_functorIds[index]), isAnyNonConstRefInArgsT }; } return { nullptr, false }; diff --git a/ReflectionTemplateLib/rtl/inc/Record.h b/ReflectionTemplateLib/rtl/inc/Record.h index b6d9fb81..f5293425 100644 --- a/ReflectionTemplateLib/rtl/inc/Record.h +++ b/ReflectionTemplateLib/rtl/inc/Record.h @@ -53,7 +53,7 @@ namespace rtl { { } - GETTER_REF(MethodMap, FunctionsMap, m_methods) + GETTER_REF_C(MethodMap, FunctionsMap, m_methods) public: diff --git a/ReflectionTemplateLib/rtl/rtl_constants.h b/ReflectionTemplateLib/rtl/rtl_constants.h index eca9ef30..7e999cb2 100644 --- a/ReflectionTemplateLib/rtl/rtl_constants.h +++ b/ReflectionTemplateLib/rtl/rtl_constants.h @@ -147,12 +147,16 @@ namespace rtl::detail return _var; \ } +#define GETTER_REF_C(_varType, _name, _var) \ + inline constexpr _varType& get##_name() const { \ + return _var; \ + } + #define GETTER_REF(_varType, _name, _var) \ - inline constexpr _varType& get##_name() const { \ + inline constexpr _varType& get##_name() { \ return _var; \ } - #define GETTER_CPTR(_varType, _name, _var) \ inline constexpr const _varType* get##_name() const { \ return _var; \ diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index dacdfc8a..640c643b 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -49,6 +49,9 @@ namespace rtl template struct Hopper; + + template + struct HopFunction; } namespace cache From f298e110a79a86a40274716b49e97cec475b3075 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 14 Oct 2025 23:14:09 +0530 Subject: [PATCH 088/148] refactor, better syntax for rtl::method --- RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp | 4 ++-- .../StrictStaticTypeDispatch.cpp | 8 ++++---- ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h | 4 ++-- .../rtl/detail/inc/MethodInvoker.hpp | 12 ++++++------ ReflectionTemplateLib/rtl/dispatch/lambda_method.h | 4 ++-- ReflectionTemplateLib/rtl/dispatch/rtl_method.h | 2 +- .../rtl/dispatch/rtl_method_const.h | 2 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 7c20cfe7..6837cdc0 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -42,7 +42,7 @@ namespace return function->argsT().returnT(); }(); - static const rtl::method getMessageNode = []() + static const rtl::method getMessageNode = []() { std::optional Node = cxx::mirror().getRecord("Node"); if (!Node) { @@ -58,7 +58,7 @@ namespace return method->recordT().argsT().returnT(); }(); - static const rtl::method sendMessageNode = []() + static const rtl::method sendMessageNode = []() { std::optional Node = cxx::mirror().getRecord("Node"); if (!Node) { diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp index 37d51c89..2a30f540 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp @@ -205,10 +205,10 @@ namespace rtl_tests std::optional isStringEmpty = stdStringClass->getMethod("empty"); ASSERT_TRUE(isStringEmpty); { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); EXPECT_FALSE(is_empty); } { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); ASSERT_TRUE(is_empty); EXPECT_TRUE(is_empty(std::string(""))); @@ -230,10 +230,10 @@ namespace rtl_tests std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); ASSERT_TRUE(isStringEmpty); { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); EXPECT_FALSE(is_empty); } { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); ASSERT_TRUE(is_empty); EXPECT_TRUE(is_empty(std::string(""))); diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 06377420..184de12f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -97,10 +97,10 @@ namespace rtl::detail std::vector m_lambdaRefOverloads = {}; template requires (std::is_const_v == false) - constexpr const method returnT() const; + constexpr const method returnT() const; template requires (std::is_const_v == true) - constexpr const method returnT() const; + constexpr const method returnT() const; }; template diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 2c9d95c6..b9a423f4 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -196,29 +196,29 @@ namespace rtl::detail template template requires (std::is_const_v == false) - inline constexpr const method<_returnType(record_t::*)(args_t...)> - HopMethod::returnT() const + inline constexpr const method + HopMethod::returnT() const { if (m_lambda != nullptr) [[likely]] { const auto retId = traits::uid<_returnType>::value; return m_lambda->template get_hopper<_returnType>(retId); } - return method<_returnType(record_t::*)(args_t...)>(); + return method(); } template template requires (std::is_const_v == true) - inline constexpr const method<_returnType(record_t::*)(args_t...) const> - HopMethod::returnT() const + inline constexpr const method + HopMethod::returnT() const { if (m_lambda != nullptr) [[likely]] { const auto retId = traits::uid<_returnType>::value; return m_lambda->template get_hopper<_returnType>(retId); } - return method<_returnType(record_t::*)(args_t...) const>(); + return method(); } } diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 253aa2cf..5601e349 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -24,7 +24,7 @@ namespace rtl::dispatch struct lambda_method : public lambda_base { template - using hopper_t = rtl::method; + using hopper_t = rtl::method; template constexpr decltype(auto) get_functor(std::size_t p_returnId = 0) const @@ -44,7 +44,7 @@ namespace rtl::dispatch } template - using hopper_ct = rtl::method; + using hopper_ct = rtl::method; template requires (std::is_const_v) constexpr const hopper_ct get_hopper(std::size_t p_returnId = 0) const diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 62555f69..a37ead26 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -18,7 +18,7 @@ namespace rtl { template - struct method + struct method { using fptr_t = return_t (record_t::*)(signature_t...); diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index 7ecb247f..734e9de4 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -18,7 +18,7 @@ namespace rtl { template - struct method + struct method { using fptr_t = return_t (record_t::*)(signature_t...) const; diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 640c643b..dfb1259a 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -28,7 +28,7 @@ namespace rtl template struct function; - template + template struct method; namespace detail From adc3b8cd1411a3630e5c0ca76ee7571c0acf5e70 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 15 Oct 2025 12:59:57 +0530 Subject: [PATCH 089/148] return-erased rtl::method<> impl, wip. --- .../BasicTypeErasedDispatch.cpp | 41 ++++- .../rtl/dispatch/CMakeLists.txt | 3 +- .../rtl/dispatch/rtl_function_erased_return.h | 161 +++++++++-------- .../rtl/dispatch/rtl_method_erased_return.h | 167 ++++++++++++++++++ ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/inc/Method.h | 6 +- ReflectionTemplateLib/rtl/inc/RObject.h | 13 +- 7 files changed, 301 insertions(+), 92 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp index 360b291d..cdfdee46 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp @@ -6,6 +6,8 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" +#include + using namespace test_utils; using namespace test_mirror; @@ -14,26 +16,49 @@ namespace rtl_tests TEST(BasicTypeErasedDispatch, invalid_erased_return_rtl_function) { { - rtl::function erased_ret_func; - EXPECT_FALSE(erased_ret_func); + rtl::function erased_ret_fn; + EXPECT_FALSE(erased_ret_fn); + + auto [err, robj] = erased_ret_fn(); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + rtl::method erased_ret_mt; + EXPECT_FALSE(erased_ret_mt); + + auto [err, robj] = erased_ret_mt(0)(); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } - auto [err, robj] = erased_ret_func(); + rtl::function erased_ret_fn; + EXPECT_FALSE(erased_ret_fn); + { + auto [err, robj] = erased_ret_fn(0); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = erased_ret_fn.bind()(0); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = erased_ret_fn.bind()(0); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } - rtl::function erased_ret_func; - EXPECT_FALSE(erased_ret_func); + rtl::method erased_ret_mt; + EXPECT_FALSE(erased_ret_mt); { - auto [err, robj] = erased_ret_func(0); + auto [err, robj] = erased_ret_mt('a')(0); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } { - auto [err, robj] = erased_ret_func.bind()(0); + auto [err, robj] = erased_ret_mt.bind('a')(0); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } { - auto [err, robj] = erased_ret_func.bind()(0); + auto [err, robj] = erased_ret_mt.bind('a')(0); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 753757da..a3fc55a9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -15,7 +15,8 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function_erased_return.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_return.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function_erased_return.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const.h" ) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index ee03e42e..7b4999d4 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -20,35 +20,16 @@ namespace rtl template struct function { - template - requires (sizeof...(args_t) == sizeof...(signature_t)) - [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] - constexpr Return operator()(args_t&&...params) const noexcept + enum call_by { - if (!(*this)) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; - } - - if (must_bind_refs()) [[unlikely]] { - return { error::ExplicitRefBindingRequired, RObject{} }; - } - - auto index = (m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); - if (m_lambdas[index]->is_void()) - { - m_vhop[index] (*m_lambdas[index], std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - return { error::None, - RObject{ m_rhop[index] (*m_lambdas[index], std::forward(params)...), - m_lambdas.back()->get_return_id(), nullptr - } - }; - } - } + value = 0, + cref = 1, //const ref. + ncref = 2 //non-const ref. + }; + template + requires (sizeof...(args_t) == sizeof...(signature_t)) + constexpr Return operator()(args_t&&...params) const noexcept; template struct perfect_fwd @@ -56,44 +37,11 @@ namespace rtl const function& fn; template - [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] - constexpr Return operator()(args_t&&...params) const noexcept - { - if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; - } - - auto signature_id = traits::uid>::value; - for (int index = 0; index < fn.m_lambdas.size(); index++) - { - if (fn.m_lambdas[index] != nullptr) - { - if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) - { - if (fn.m_lambdas[index]->is_void()) - { - fn.m_vhop[index] (*(fn.m_lambdas[index]), std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - return { error::None, - RObject{ fn.m_rhop[index] (*(fn.m_lambdas[index]), std::forward(params)...), - fn.m_lambdas.back()->get_return_id(), nullptr - } - }; - } - } - } - } - return { error::RefBindingMismatch, RObject{} }; - } + constexpr Return operator()(args_t&&...params) const noexcept; }; - template requires (std::is_same_v, std::tuple>) - [[nodiscard]] constexpr const perfect_fwd bind() const noexcept { return perfect_fwd{ *this }; } @@ -119,24 +67,89 @@ namespace rtl std::vector m_lambdas = {}; - enum call_by - { - value = 0, - cref = 1, //const ref. - ncref = 2 //non-const ref. - }; - GETTER_REF(std::vector, _rhop, m_rhop) GETTER_REF(std::vector, _vhop, m_vhop) GETTER_REF(std::vector, _overloads, m_lambdas) + template + friend struct detail::HopFunction; + static_assert((!std::is_reference_v && ...), - "function: any type cannot be reference here"); + "rtl::function<...>: any type cannot be specified as reference here"); + }; +} - //template - //friend struct detail::Hopper; - template - friend struct detail::HopFunction; - }; +namespace rtl +{ + template + template + requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + ForceInline constexpr Return function::operator()(args_t&&...params) const noexcept + { + if (!(*this)) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + if (must_bind_refs()) [[unlikely]] { + return { error::ExplicitRefBindingRequired, RObject{} }; + } + + auto index = (m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (m_lambdas[index]->is_void()) + { + m_vhop[index](*m_lambdas[index], std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ m_rhop[index](*m_lambdas[index], std::forward(params)...), + m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } +} + + +namespace rtl +{ + template + template + template + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + ForceInline constexpr Return + function::perfect_fwd::operator()(args_t&&...params) const noexcept + { + if (!fn) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + auto signature_id = traits::uid>::value; + for (int index = 0; index < fn.m_lambdas.size(); index++) + { + if (fn.m_lambdas[index] != nullptr) + { + if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) + { + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index](*fn.m_lambdas[index], std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ fn.m_rhop[index](*fn.m_lambdas[index], std::forward(params)...), + fn.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + } + } + return { error::RefBindingMismatch, RObject{} }; + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h new file mode 100644 index 00000000..d8bd57c5 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -0,0 +1,167 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_forward_decls.h" +#include "lambda_base.h" + +namespace rtl +{ + template + struct method + { + enum call_by + { + value = 0, + cref = 1, //const ref. + ncref = 2 //non-const ref. + }; + + struct invoker + { + const record_t& target; + const method& mt; + + template + requires (sizeof...(args_t) == sizeof...(signature_t)) + constexpr Return operator()(args_t&&...params) const noexcept; + }; + + template + struct perfect_fwd + { + const record_t& target; + const method& mt; + + template + constexpr Return operator()(args_t&&...params) const noexcept; + }; + + constexpr invoker operator()(const record_t& p_target) const noexcept { + return invoker{ p_target, *this }; + } + + template + requires (std::is_same_v, std::tuple>) + constexpr const perfect_fwd bind(const record_t& p_target) const noexcept { + return perfect_fwd{ p_target, *this }; + } + + constexpr operator bool() const noexcept { + return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } + + constexpr bool must_bind_refs() const noexcept { + return (m_lambdas[call_by::value] == nullptr && + (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); + } + + private: + + using lambda_vt = std::function; + + using lambda_rt = std::function; + + std::vector m_rhop = {}; + + std::vector m_vhop = {}; + + std::vector m_lambdas = {}; + + GETTER_REF(std::vector, _rhop, m_rhop) + GETTER_REF(std::vector, _vhop, m_vhop) + GETTER_REF(std::vector, _overloads, m_lambdas) + + template + friend struct HopMethod; + + static_assert((!std::is_reference_v && ...), + "rtl::method<...>: any type cannot be specified as reference here."); + }; +} + + +namespace rtl +{ + template + template + requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + ForceInline constexpr Return + method::invoker::operator()(args_t&&...params) const noexcept + { + if (!mt) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + if (mt.must_bind_refs()) [[unlikely]] { + return { error::ExplicitRefBindingRequired, RObject{} }; + } + + auto index = (mt.m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (mt.m_lambdas[index]->is_void()) + { + mt.m_vhop[index] (*(mt.m_lambdas[index]), target, std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ mt.m_rhop[index] (*(mt.m_lambdas[index]), target, std::forward(params)...), + mt.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } +} + + +namespace rtl +{ + template + template + template + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + ForceInline constexpr Return + method::perfect_fwd::operator()(args_t&&...params) const noexcept + { + if (!mt) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + auto signature_id = traits::uid>::value; + for (int index = 0; index < mt.m_lambdas.size(); index++) + { + if (mt.m_lambdas[index] != nullptr) + { + if (signature_id == mt.m_lambdas[index]->get_strict_sign_id()) + { + if (mt.m_lambdas[index]->is_void()) + { + mt.m_vhop[index] (*mt.m_lambdas[index], target, std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ mt.m_rhop[index] (*mt.m_lambdas[index], target, std::forward(params)...), + mt.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + } + } + return { error::RefBindingMismatch, RObject{} }; + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index f75b9b66..97390eab 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -112,7 +112,7 @@ namespace rtl { friend detail::CxxReflection; friend detail::ReflectionBuilder; - template + template friend struct detail::ErasedCaller; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 7f76aeac..58e1da47 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -82,13 +82,13 @@ namespace rtl { friend Record; friend detail::CxxReflection; - template + template friend struct detail::DefaultInvoker; - template + template friend struct detail::NonConstInvoker; - template + template friend struct detail::ErasedInvoker; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/RObject.h b/ReflectionTemplateLib/rtl/inc/RObject.h index 4d3a48a2..78575c16 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.h +++ b/ReflectionTemplateLib/rtl/inc/RObject.h @@ -100,20 +100,23 @@ namespace rtl friend CxxMirror; friend detail::RObjExtractor; - template + template friend struct detail::RObjectUPtr; - template + template friend struct detail::RObjectBuilder; - template + template friend struct detail::ErasedCaller; - template + template friend struct detail::ErasedInvoker; - template + template friend struct function; + + template + friend struct method; }; struct [[nodiscard]] Return { From 1e9cd9f85750c9ecb39687179f734a3ca6d2d191 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 15 Oct 2025 18:52:14 +0530 Subject: [PATCH 090/148] return-erased rtl::method<> integration, wip. --- .../src/ReflectedCallUnknownReturn.cpp | 74 ++++++++--- .../NameSpaceGlobalsTests.cpp | 18 ++- .../rtl/detail/inc/FunctionCaller.hpp | 24 ++-- .../rtl/detail/inc/MethodInvoker.h | 28 ++-- .../rtl/detail/inc/MethodInvoker.hpp | 122 +++++++++++++----- .../rtl/dispatch/rtl_method_erased_return.h | 2 +- 6 files changed, 184 insertions(+), 84 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 18395212..e5c8893d 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -37,7 +37,41 @@ namespace return function->argsT().returnT(); }(); - static rtl::Method NodeGetMessage = []() + + static rtl::method NodeGetMessage = []() + { + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } + + std::optional method = Node->getMethod("getMessage"); + if (!method) { + std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; + std::abort(); + } + return method->recordT().argsT().returnT<>(); + }(); + + static rtl::method NodeSendMessage = []() + { + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } + + std::optional method = Node->getMethod("sendMessage"); + if (!method) { + std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; + std::abort(); + } + return method->recordT().argsT().returnT<>(); + }(); + + + static rtl::Method ErasedTargetGetMessage = []() { std::optional Node = cxx::mirror().getRecord("Node"); if (!Node) { @@ -53,7 +87,7 @@ namespace return *method; }(); - static rtl::Method NodeSendMessage = []() + static rtl::Method ErasedTargetSendMessage = []() { std::optional Node = cxx::mirror().getRecord("Node"); if (!Node) { @@ -69,20 +103,20 @@ namespace return *method; }(); - static const rtl::RObject nodeObj = []() - { - std::optional Node = cxx::mirror().getRecord("Node"); - if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; - std::abort(); - } - - auto [err, robj] = Node->create(); - if (robj.isEmpty()) { - std::cout << "[x] error: " << rtl::to_string(err) << "\n"; - } - return std::move(robj); - }(); + static const rtl::RObject nodeObj = []() + { + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } + + auto [err, robj] = Node->create(); + if (robj.isEmpty()) { + std::cout << "[x] error: " << rtl::to_string(err) << "\n"; + } + return std::move(robj); + }(); } @@ -127,7 +161,7 @@ namespace static auto _test4 = []() { - auto err = NodeSendMessage(nodeObj)(bm::g_longStr).err; + auto err = ErasedTargetSendMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[01] error: " << rtl::to_string(err) << "\n"; } @@ -137,7 +171,7 @@ namespace static auto _test5 = []() { - auto err = NodeGetMessage(nodeObj)(bm::g_longStr).err; + auto err = ErasedTargetGetMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { std::cout << "[03] error: " << rtl::to_string(err) << "\n"; } @@ -201,7 +235,7 @@ void RtlErasedReturnType_callMethod::unknownTarget_returnVoid(benchmark::State& static auto _ = _test4(); for (auto _ : state) { - benchmark::DoNotOptimize(NodeSendMessage(nodeObj)(bm::g_longStr)); + benchmark::DoNotOptimize(ErasedTargetSendMessage(nodeObj)(bm::g_longStr)); } } @@ -211,6 +245,6 @@ void RtlErasedReturnType_callMethod::unknownTarget_returnNonVoid(benchmark::Stat static auto _ = _test5(); for (auto _ : state) { - benchmark::DoNotOptimize(NodeGetMessage(nodeObj)(bm::g_longStr)); + benchmark::DoNotOptimize(ErasedTargetGetMessage(nodeObj)(bm::g_longStr)); } } \ No newline at end of file diff --git a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp index f4be6a82..7f2d6560 100644 --- a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp @@ -172,19 +172,17 @@ namespace rtl_tests TEST(FunctionInNameSpace, execute_with_wrong_signature) { - optional setReal = cxx::mirror().getFunction(str_complex, str_setReal); - ASSERT_TRUE(setReal); + optional setRealOpt = cxx::mirror().getFunction(str_complex, str_setReal); + ASSERT_TRUE(setRealOpt); - EXPECT_TRUE(setReal->hasSignature()); - EXPECT_FALSE(setReal->hasSignature()); + EXPECT_TRUE(setRealOpt->hasSignature()); + EXPECT_FALSE(setRealOpt->hasSignature()); - //g_real's type is "const double", so can't be passed directly to setReal. - //Instead we can explicitly specify the types as template parameter, - //like, (*setReal).operator()(g_real); - //or we can use the bind<...>().call(), specifying type as template param, like, - auto [err, robj] = setReal->bind()(g_real); + rtl::function setReal_bad_fn = setRealOpt->argsT().returnT<>(); + EXPECT_FALSE(setReal_bad_fn); - EXPECT_TRUE(err == rtl::error::SignatureMismatch); + auto [err, robj] = setReal_bad_fn(g_real); + EXPECT_EQ(err, rtl::error::InvalidCaller); ASSERT_TRUE(robj.isEmpty()); } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 8cdd72c3..3b5e925e 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -40,6 +40,18 @@ namespace rtl::detail namespace rtl::detail { + template + template requires (!std::is_same_v) + inline constexpr const function HopFunction::returnT() const + { + const auto retId = traits::uid::value; + if (m_lambda != nullptr) { + return m_lambda->template get_hopper(retId); + } + return function(); + } + + template inline constexpr const HopFunction Hopper<>::argsT() const { @@ -114,18 +126,6 @@ namespace rtl::detail } - template - template requires (!std::is_same_v) - inline constexpr const function HopFunction::returnT() const - { - const auto retId = traits::uid::value; - if (m_lambda != nullptr) [[likely]] { - return m_lambda->template get_hopper(retId); - } - return function(); - } - - template template requires (is_binding_v == true) ForceInline constexpr Return ErasedCaller::operator()(args_t&&...params) const noexcept diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 184de12f..551f3942 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -89,26 +89,36 @@ namespace rtl::detail { namespace rtl::detail { - template + template struct HopMethod { - const dispatch::lambda_method* m_lambda = nullptr; + const dispatch::lambda_method* m_lambda = nullptr; std::vector m_lambdaRefOverloads = {}; - template requires (std::is_const_v == false) - constexpr const method returnT() const; + template + requires (!std::is_const_v && std::is_same_v) + constexpr const method returnT() const; - template requires (std::is_const_v == true) - constexpr const method returnT() const; + template + requires (!std::is_const_v && !std::is_same_v) + constexpr const method returnT() const; + + template + requires (std::is_const_v && std::is_same_v) + constexpr const method returnT() const; + + template + requires (std::is_const_v && !std::is_same_v) + constexpr const method returnT() const; }; - template + template struct Hopper { const std::vector& m_functorIds; - template - constexpr HopMethod argsT() const; + template + constexpr HopMethod argsT() const; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index b9a423f4..c342a062 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -17,6 +17,8 @@ #include "MethodContainer.h" #include "erased_hopper_rec.h" +#include "rtl_method_erased_return.h" + namespace rtl::detail { /* @method: call() @@ -152,6 +154,90 @@ namespace rtl::detail namespace rtl::detail { + + template + template + requires (!std::is_const_v && !std::is_same_v) + inline constexpr const + method HopMethod::returnT() const + { + if (m_lambda != nullptr) + { + const auto retId = traits::uid::value; + return m_lambda->template get_hopper(retId); + } + return method(); + } + + + template + template + requires (std::is_const_v && !std::is_same_v) + inline constexpr const + method HopMethod::returnT() const + { + if (m_lambda != nullptr) + { + const auto retId = traits::uid::value; + return m_lambda->template get_hopper(retId); + } + return method(); + } + + + template + template + requires (std::is_const_v && std::is_same_v) + inline constexpr const + method HopMethod::returnT() const + { + if (m_lambda != nullptr) + { + const auto retId = traits::uid::value; + return m_lambda->template get_hopper(retId); + } + return method(); + } + + + template + template + requires (!std::is_const_v && std::is_same_v) + inline constexpr const + method HopMethod::returnT() const + { + bool isRetTypeVoid = false; + method...)> erasedReturnMthd; + + for (auto lambda : m_lambdaRefOverloads) + { + erasedReturnMthd.get_overloads().push_back(lambda); + if (lambda) + { + auto eret = lambda->get_unerasure().to_erased_return_rec...>(); + if (lambda->is_void()) { + erasedReturnMthd.get_vhop().push_back(eret.get_void_hopper()); + isRetTypeVoid = true; + } + else { + erasedReturnMthd.get_rhop().push_back(eret.get_return_hopper()); + } + } + else { + erasedReturnMthd.get_vhop().push_back(nullptr); + erasedReturnMthd.get_rhop().push_back(nullptr); + } + } + if (isRetTypeVoid) { + erasedReturnMthd.get_rhop().clear(); + } + else { + erasedReturnMthd.get_vhop().clear(); + } + return erasedReturnMthd; + } + + template template inline constexpr HopMethod Hopper::argsT() const @@ -160,7 +246,7 @@ namespace rtl::detail auto strictArgsId = traits::uid>::value; auto normalArgsId = traits::uid>::value; - const dispatch::lambda_method* lambda_fn = nullptr; + const dispatch::lambda_method* lambda_mt = nullptr; std::vector refOverloads = { nullptr }; for (auto& functorId : m_functorIds) @@ -169,8 +255,8 @@ namespace rtl::detail if (recordId != lambda.get_record_id()) { continue; } - if (!lambda_fn && strictArgsId == lambda.get_strict_sign_id()) { - lambda_fn = &(lambda.to_method()); + if (!lambda_mt && strictArgsId == lambda.get_strict_sign_id()) { + lambda_mt = &(lambda.to_method()); } if (normalArgsId == lambda.get_normal_sign_id()) { @@ -190,35 +276,7 @@ namespace rtl::detail refOverloads.push_back(&lambda); } } - return { lambda_fn, refOverloads }; - } - - - template - template requires (std::is_const_v == false) - inline constexpr const method - HopMethod::returnT() const - { - if (m_lambda != nullptr) [[likely]] - { - const auto retId = traits::uid<_returnType>::value; - return m_lambda->template get_hopper<_returnType>(retId); - } - return method(); - } - - - template - template requires (std::is_const_v == true) - inline constexpr const method - HopMethod::returnT() const - { - if (m_lambda != nullptr) [[likely]] - { - const auto retId = traits::uid<_returnType>::value; - return m_lambda->template get_hopper<_returnType>(retId); - } - return method(); + return { lambda_mt, refOverloads }; } } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h index d8bd57c5..66ae2939 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -83,7 +83,7 @@ namespace rtl GETTER_REF(std::vector, _overloads, m_lambdas) template - friend struct HopMethod; + friend struct detail::HopMethod; static_assert((!std::is_reference_v && ...), "rtl::method<...>: any type cannot be specified as reference here."); From 7c40831112cfa396c58c47247c1e13d4767ea1a8 Mon Sep 17 00:00:00 2001 From: neeraj Date: Wed, 15 Oct 2025 21:42:42 +0530 Subject: [PATCH 091/148] function-defs inside struct now, nested template err fix(clang-19) --- .../rtl/dispatch/rtl_function_erased_return.h | 142 ++++++++---------- .../rtl/dispatch/rtl_method_erased_return.h | 139 ++++++++--------- 2 files changed, 120 insertions(+), 161 deletions(-) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index 7b4999d4..4224bc00 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -27,19 +27,74 @@ namespace rtl ncref = 2 //non-const ref. }; - template - requires (sizeof...(args_t) == sizeof...(signature_t)) - constexpr Return operator()(args_t&&...params) const noexcept; - template struct perfect_fwd { const function& fn; - + template - constexpr Return operator()(args_t&&...params) const noexcept; + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept + { + if (!fn) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + auto signature_id = traits::uid>::value; + for (int index = 0; index < fn.m_lambdas.size(); index++) + { + if (fn.m_lambdas[index] != nullptr) + { + if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) + { + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index](*fn.m_lambdas[index], std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ fn.m_rhop[index](*fn.m_lambdas[index], std::forward(params)...), + fn.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + } + } + return { error::RefBindingMismatch, RObject{} }; + } }; + template requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept + { + if (!(*this)) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + if (must_bind_refs()) [[unlikely]] { + return { error::ExplicitRefBindingRequired, RObject{} }; + } + + auto index = (m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (m_lambdas[index]->is_void()) + { + m_vhop[index](*m_lambdas[index], std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ m_rhop[index](*m_lambdas[index], std::forward(params)...), + m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + template requires (std::is_same_v, std::tuple>) constexpr const perfect_fwd bind() const noexcept { @@ -77,79 +132,4 @@ namespace rtl static_assert((!std::is_reference_v && ...), "rtl::function<...>: any type cannot be specified as reference here"); }; -} - - -namespace rtl -{ - template - template - requires (sizeof...(args_t) == sizeof...(signature_t)) - [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] - ForceInline constexpr Return function::operator()(args_t&&...params) const noexcept - { - if (!(*this)) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; - } - - if (must_bind_refs()) [[unlikely]] { - return { error::ExplicitRefBindingRequired, RObject{} }; - } - - auto index = (m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); - if (m_lambdas[index]->is_void()) - { - m_vhop[index](*m_lambdas[index], std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - return { error::None, - RObject{ m_rhop[index](*m_lambdas[index], std::forward(params)...), - m_lambdas.back()->get_return_id(), nullptr - } - }; - } - } -} - - -namespace rtl -{ - template - template - template - [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] - ForceInline constexpr Return - function::perfect_fwd::operator()(args_t&&...params) const noexcept - { - if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; - } - - auto signature_id = traits::uid>::value; - for (int index = 0; index < fn.m_lambdas.size(); index++) - { - if (fn.m_lambdas[index] != nullptr) - { - if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) - { - if (fn.m_lambdas[index]->is_void()) - { - fn.m_vhop[index](*fn.m_lambdas[index], std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - return { error::None, - RObject{ fn.m_rhop[index](*fn.m_lambdas[index], std::forward(params)...), - fn.m_lambdas.back()->get_return_id(), nullptr - } - }; - } - } - } - } - return { error::RefBindingMismatch, RObject{} }; - } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h index 66ae2939..b9303ebd 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -32,9 +32,33 @@ namespace rtl const record_t& target; const method& mt; - template - requires (sizeof...(args_t) == sizeof...(signature_t)) - constexpr Return operator()(args_t&&...params) const noexcept; + template requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept + { + if (!mt) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + if (mt.must_bind_refs()) [[unlikely]] { + return { error::ExplicitRefBindingRequired, RObject{} }; + } + + auto index = (mt.m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (mt.m_lambdas[index]->is_void()) + { + mt.m_vhop[index] (*(mt.m_lambdas[index]), target, std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ mt.m_rhop[index] (*(mt.m_lambdas[index]), target, std::forward(params)...), + mt.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } }; template @@ -44,7 +68,38 @@ namespace rtl const method& mt; template - constexpr Return operator()(args_t&&...params) const noexcept; + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept + { + if (!mt) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + auto signature_id = traits::uid>::value; + for (int index = 0; index < mt.m_lambdas.size(); index++) + { + if (mt.m_lambdas[index] != nullptr) + { + if (signature_id == mt.m_lambdas[index]->get_strict_sign_id()) + { + if (mt.m_lambdas[index]->is_void()) + { + mt.m_vhop[index] (*mt.m_lambdas[index], target, std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ mt.m_rhop[index] (*mt.m_lambdas[index], target, std::forward(params)...), + mt.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + } + } + return { error::RefBindingMismatch, RObject{} }; + } }; constexpr invoker operator()(const record_t& p_target) const noexcept { @@ -88,80 +143,4 @@ namespace rtl static_assert((!std::is_reference_v && ...), "rtl::method<...>: any type cannot be specified as reference here."); }; -} - - -namespace rtl -{ - template - template - requires (sizeof...(args_t) == sizeof...(signature_t)) - [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] - ForceInline constexpr Return - method::invoker::operator()(args_t&&...params) const noexcept - { - if (!mt) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; - } - - if (mt.must_bind_refs()) [[unlikely]] { - return { error::ExplicitRefBindingRequired, RObject{} }; - } - - auto index = (mt.m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); - if (mt.m_lambdas[index]->is_void()) - { - mt.m_vhop[index] (*(mt.m_lambdas[index]), target, std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - return { error::None, - RObject{ mt.m_rhop[index] (*(mt.m_lambdas[index]), target, std::forward(params)...), - mt.m_lambdas.back()->get_return_id(), nullptr - } - }; - } - } -} - - -namespace rtl -{ - template - template - template - [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] - ForceInline constexpr Return - method::perfect_fwd::operator()(args_t&&...params) const noexcept - { - if (!mt) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; - } - - auto signature_id = traits::uid>::value; - for (int index = 0; index < mt.m_lambdas.size(); index++) - { - if (mt.m_lambdas[index] != nullptr) - { - if (signature_id == mt.m_lambdas[index]->get_strict_sign_id()) - { - if (mt.m_lambdas[index]->is_void()) - { - mt.m_vhop[index] (*mt.m_lambdas[index], target, std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - return { error::None, - RObject{ mt.m_rhop[index] (*mt.m_lambdas[index], target, std::forward(params)...), - mt.m_lambdas.back()->get_return_id(), nullptr - } - }; - } - } - } - } - return { error::RefBindingMismatch, RObject{} }; - } } \ No newline at end of file From 31110b6763a133c8a6a725041cf3f93f95dacbb6 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 16 Oct 2025 12:27:33 +0530 Subject: [PATCH 092/148] rtl::method static-type dispatch tests. --- CxxTestProps/inc/ComplexStrings.h | 40 +- CxxTestProps/src/ComplexStrings.cpp | 135 +++++ CxxTestRegistration/inc/TestMirrorProvider.h | 1 + .../src/TestMirrorProvider.cpp | 51 +- CxxTestUtils/inc/GlobalTestUtils.h | 2 + .../src/ReflectedCallKnownReturn.cpp | 4 +- .../src/ReflectedCallUnknownReturn.cpp | 30 +- RTLTestRunApp/src/CMakeLists.txt | 6 +- ... => StrictStaticTypeDispatch_Function.cpp} | 76 +-- .../StrictStaticTypeDispatch_Method.cpp | 303 ++++++++++ ...p => BasicTypeErasedDispatch_Function.cpp} | 47 +- .../BasicTypeErasedDispatch_Method.cpp | 552 ++++++++++++++++++ .../rtl/dispatch/rtl_function.h | 3 +- .../rtl/dispatch/rtl_method.h | 18 +- 14 files changed, 1142 insertions(+), 126 deletions(-) rename RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/{StrictStaticTypeDispatch.cpp => StrictStaticTypeDispatch_Function.cpp} (80%) create mode 100644 RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp rename RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/{BasicTypeErasedDispatch.cpp => BasicTypeErasedDispatch_Function.cpp} (92%) create mode 100644 RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/ComplexStrings.h index 33d68517..cd7753dc 100644 --- a/CxxTestProps/inc/ComplexStrings.h +++ b/CxxTestProps/inc/ComplexStrings.h @@ -45,4 +45,42 @@ std::string revStrOverloadValCRef(const std::string_view& pStr); std::string revStrOverloadRefAndCRef(std::string_view& pStr); -std::string revStrOverloadRefAndCRef(const std::string_view& pStr); \ No newline at end of file +std::string revStrOverloadRefAndCRef(const std::string_view& pStr); + + +struct StringUtil +{ + std::string reverseString(); + + std::string reverseString(const char* pStr); + + std::string reverseString(std::string pStr); // (1) by value + + std::string reverseString(std::string& pStr); // (2) lvalue ref + + std::string reverseString(const std::string& pStr); // (3) const lvalue ref + + std::string reverseString(std::string&& pStr); // (4) rvalue ref + + std::string reverseString(std::string* pStr); // (5) pointer + + std::string reverseString(const std::string* pStr); // (6) pointer to const + + std::string revStrConstRefArg(const std::string_view& pStr); + + std::string revStrNonConstRefArg(std::string_view& pStr); + + std::string revStrRValueRefArg(std::string_view&& pStr); + + std::string revStrOverloadValRef(std::string_view pStr); + + std::string revStrOverloadValRef(std::string_view& pStr); + + std::string revStrOverloadValCRef(std::string_view pStr); + + std::string revStrOverloadValCRef(const std::string_view& pStr); + + std::string revStrOverloadRefAndCRef(std::string_view& pStr); + + std::string revStrOverloadRefAndCRef(const std::string_view& pStr); +}; diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/ComplexStrings.cpp index 58a864fb..b385e515 100644 --- a/CxxTestProps/src/ComplexStrings.cpp +++ b/CxxTestProps/src/ComplexStrings.cpp @@ -181,6 +181,141 @@ std::string revStrOverloadRefAndCRef(std::string_view& pStr) std::string revStrOverloadRefAndCRef(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref; +} + +//---------------------------StringUtil-------------------------------- + +std::string StringUtil::reverseString() +{ + return std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; +} + + +std::string StringUtil::reverseString(const char* pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_const_char_ptr; +} + + +std::string StringUtil::reverseString(std::string pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string; +} + + +std::string StringUtil::reverseString(std::string& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_lvref; +} + + +std::string StringUtil::reverseString(std::string&& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_rvref; +} + + +std::string StringUtil::reverseString(const std::string& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_clvref; +} + + +std::string StringUtil::reverseString(std::string* pStr) +{ + std::string retStr = *pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_ptr; +} + + +std::string StringUtil::reverseString(const std::string* pStr) +{ + std::string retStr = *pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_cptr; +} + + +std::string StringUtil::revStrConstRefArg(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref; +} + + +std::string StringUtil::revStrRValueRefArg(std::string_view&& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_rvref; +} + + +std::string StringUtil::revStrNonConstRefArg(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref; +} + + +std::string StringUtil::revStrOverloadValCRef(std::string_view pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view; +} + + +std::string StringUtil::revStrOverloadValCRef(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref; +} + + +std::string StringUtil::revStrOverloadValRef(std::string_view pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view; +} + + +std::string StringUtil::revStrOverloadValRef(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref; +} + + +std::string StringUtil::revStrOverloadRefAndCRef(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref; +} + + +std::string StringUtil::revStrOverloadRefAndCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); diff --git a/CxxTestRegistration/inc/TestMirrorProvider.h b/CxxTestRegistration/inc/TestMirrorProvider.h index d71113f4..bb389737 100644 --- a/CxxTestRegistration/inc/TestMirrorProvider.h +++ b/CxxTestRegistration/inc/TestMirrorProvider.h @@ -20,6 +20,7 @@ namespace test_mirror static std::size_t person; static std::size_t library; static std::size_t calender; + static std::size_t string_util; static std::size_t char_t; static std::size_t int_t; diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 14f0cc68..8174b95a 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -125,6 +125,53 @@ namespace test_mirror rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), + rtl::type().record(StringUtil_struct).build(), + + // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. + rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + + // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. + rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + + // Overloaded function, takes 'const char*' arguments. + rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + + // numereous other overloads. + #if defined(__GNUC__) && !defined(__clang__) + /* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: + + static_cast(reverseString) + */ + rtl::type().member().method(str_reverseString) + .build(static_cast(&StringUtil::reverseString)), + rtl::type().member().method(str_reverseString) + .build(static_cast(&StringUtil::reverseString)), + rtl::type().member().method(str_reverseString) + .build(static_cast(&StringUtil::reverseString)), + #else + rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + #endif + rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + + rtl::type().member().method(str_revStrNonConstRefArg).build(&StringUtil::revStrNonConstRefArg), + rtl::type().member().method(str_revStrRValueRefArg).build(&StringUtil::revStrRValueRefArg), + rtl::type().member().method(str_revStrConstRefArg).build(&StringUtil::revStrConstRefArg), + + rtl::type().member().method(str_revStrOverloadValRef).build(&StringUtil::revStrOverloadValRef), + rtl::type().member().method(str_revStrOverloadValRef).build(&StringUtil::revStrOverloadValRef), + + rtl::type().member().method(str_revStrOverloadValCRef).build(&StringUtil::revStrOverloadValCRef), + rtl::type().member().method(str_revStrOverloadValCRef).build(&StringUtil::revStrOverloadValCRef), + + rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringUtil::revStrOverloadRefAndCRef), + rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringUtil::revStrOverloadRefAndCRef), + // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), @@ -308,6 +355,7 @@ namespace test_mirror std::size_t reflected_id::date = rtl::detail::TypeId::get(); std::size_t reflected_id::event = rtl::detail::TypeId::get(); std::size_t reflected_id::calender = rtl::detail::TypeId::get(); + std::size_t reflected_id::string_util = rtl::detail::TypeId::get(); std::size_t reflected_id::int_t = rtl::detail::TypeId::get(); std::size_t reflected_id::char_t = rtl::detail::TypeId::get(); @@ -330,7 +378,8 @@ namespace test_mirror { animal::class_, animal }, { person::class_, person }, { library::class_, library }, - { calender::struct_, calender } + { calender::struct_, calender }, + { StringUtil_struct, string_util } }); const auto& itr = nameIdMap.find(pRecordName); diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index f00e4482..566aeeae 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -36,6 +36,8 @@ namespace test_utils { static constexpr const char* STRB = "cxxReflection"; static constexpr const char* STRB_REVERSE = "noitcelfeRxxc"; + constexpr static const char* StringUtil_struct = "StringUtil"; + static constexpr const char* str_reverseString = "reverseString"; static constexpr const char* str_revStrConstRefArg = "revStrConstRefArg"; static constexpr const char* str_revStrRValueRefArg = "revStrRValueRefArg"; diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 6837cdc0..2d4c376b 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -155,7 +155,7 @@ void RtlStaticTyped_callMethod::returnNonVoid(benchmark::State& state) static auto is_ok = test(getMessageNode, 4); for (auto _ : state) { - benchmark::DoNotOptimize(getMessageNode(nodeObj, bm::g_longStr)); + benchmark::DoNotOptimize(getMessageNode(nodeObj)(bm::g_longStr)); } } @@ -176,7 +176,7 @@ void RtlStaticTyped_callMethod::returnVoid(benchmark::State& state) static auto is_ok = test(sendMessageNode, 5); for (auto _ : state) { - sendMessageNode(nodeObj, bm::g_longStr); + sendMessageNode(nodeObj)(bm::g_longStr); benchmark::DoNotOptimize(bm::g_work_done->c_str()); } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index e5c8893d..b785d08f 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -113,12 +113,12 @@ namespace auto [err, robj] = Node->create(); if (robj.isEmpty()) { - std::cout << "[x] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[x] error: " << rtl::to_string(err) << "\n"; } return std::move(robj); }(); } - + namespace { @@ -126,7 +126,7 @@ namespace { auto err = SendMessage(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[00] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[00] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -135,7 +135,7 @@ namespace { auto err = NodeSendMessage(bm::Node())(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[01] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[01] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -144,7 +144,7 @@ namespace { auto err = GetMessage(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[02] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[02] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -153,7 +153,7 @@ namespace { auto err = NodeGetMessage(bm::Node())(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[03] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[03] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -163,7 +163,7 @@ namespace { auto err = ErasedTargetSendMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[01] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[01] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -173,13 +173,13 @@ namespace { auto err = ErasedTargetGetMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { - std::cout << "[03] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[03] error: " << rtl::to_string(err) << "\n"; } return 0; }; static auto _new_line = []() { - std::cout << std::endl; + std::cerr << std::endl; return 0; }; } @@ -192,7 +192,7 @@ void RtlErasedReturnType_call::returnVoid(benchmark::State& state) static auto _ = _test0(); for (auto _ : state) { - benchmark::DoNotOptimize(SendMessage(bm::g_longStr)); + benchmark::DoNotOptimize(SendMessage(bm::g_longStr).err); } } @@ -203,7 +203,7 @@ void RtlErasedReturnType_call::returnNonVoid(benchmark::State& state) static auto _ = _test2(); for (auto _ : state) { - benchmark::DoNotOptimize(GetMessage(bm::g_longStr)); + benchmark::DoNotOptimize(GetMessage(bm::g_longStr).err); } } @@ -214,7 +214,7 @@ void RtlErasedReturnType_callMethod::returnVoid(benchmark::State& state) static bm::Node node; for (auto _ : state) { - benchmark::DoNotOptimize(NodeSendMessage(node)(bm::g_longStr)); + benchmark::DoNotOptimize(NodeSendMessage(node)(bm::g_longStr).err); } } @@ -225,7 +225,7 @@ void RtlErasedReturnType_callMethod::returnNonVoid(benchmark::State& state) static bm::Node node; for (auto _ : state) { - benchmark::DoNotOptimize(NodeGetMessage(node)(bm::g_longStr)); + benchmark::DoNotOptimize(NodeGetMessage(node)(bm::g_longStr).err); } } @@ -235,7 +235,7 @@ void RtlErasedReturnType_callMethod::unknownTarget_returnVoid(benchmark::State& static auto _ = _test4(); for (auto _ : state) { - benchmark::DoNotOptimize(ErasedTargetSendMessage(nodeObj)(bm::g_longStr)); + benchmark::DoNotOptimize(ErasedTargetSendMessage(nodeObj)(bm::g_longStr).err); } } @@ -245,6 +245,6 @@ void RtlErasedReturnType_callMethod::unknownTarget_returnNonVoid(benchmark::Stat static auto _ = _test5(); for (auto _ : state) { - benchmark::DoNotOptimize(ErasedTargetGetMessage(nodeObj)(bm::g_longStr)); + benchmark::DoNotOptimize(ErasedTargetGetMessage(nodeObj)(bm::g_longStr).err); } } \ No newline at end of file diff --git a/RTLTestRunApp/src/CMakeLists.txt b/RTLTestRunApp/src/CMakeLists.txt index 136e1497..3a8c2c15 100644 --- a/RTLTestRunApp/src/CMakeLists.txt +++ b/RTLTestRunApp/src/CMakeLists.txt @@ -16,8 +16,10 @@ set(LOCAL_SOURCES_0 "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/PerfectForwardingTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/MoveConstructorTests.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/ReturnValueReflectionTest.cpp" - "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp" - "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp" ) # Create a variable containing the source files for your target diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp similarity index 80% rename from RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp rename to RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp index 2a30f540..7daea564 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp @@ -11,7 +11,7 @@ using namespace test_mirror; namespace rtl_tests { - TEST(StrictStaticTypeDispatch, namespace_function_validation_with_known_signature) + TEST(StrictStaticTypeRtl_function, namespace_fn_validation_with_known_signature) { std::optional setReal = cxx::mirror().getFunction(str_complex, str_setReal); ASSERT_TRUE(setReal); @@ -43,7 +43,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, namespace_function_call_with_known_signature) + TEST(StrictStaticTypeRtl_function, namespace_fn_call_with_known_signature) { std::optional getMagnitude = cxx::mirror().getFunction(str_complex, str_getMagnitude); ASSERT_TRUE(getMagnitude); @@ -74,7 +74,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, global_function_call_with_known_signature) + TEST(StrictStaticTypeRtl_function, global_fn_call_with_known_signature) { std::optional getComplexNumStr = cxx::mirror().getFunction(str_getComplexNumAsString); ASSERT_TRUE(getComplexNumStr); @@ -97,7 +97,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, overload_resolution_with_known_signatures) + TEST(StrictStaticTypeRtl_function, overload_resolution_with_known_signatures) { std::optional reverseString = cxx::mirror().getFunction(str_reverseString); ASSERT_TRUE(reverseString); @@ -132,7 +132,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, lvalue_ref_overload_resolution_with_known_signatures) + TEST(StrictStaticTypeRtl_function, lvalue_ref_overload_resolution_with_known_signatures) { std::optional reverseString = cxx::mirror().getFunction(str_reverseString); ASSERT_TRUE(reverseString); @@ -156,7 +156,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, rvalue_ref_overload_resolution_with_known_signatures) + TEST(StrictStaticTypeRtl_function, rvalue_ref_overload_resolution_with_known_signatures) { std::optional reverseString = cxx::mirror().getFunction(str_reverseString); ASSERT_TRUE(reverseString); @@ -174,7 +174,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, ptr_and_const_ptr_overload_resolution_with_known_signatures) + TEST(StrictStaticTypeRtl_function, ptr_and_const_ptr_overload_resolution_with_known_signatures) { std::string str = STRA; std::optional reverseString = cxx::mirror().getFunction(str_reverseString); @@ -197,61 +197,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, std_string_method_call_with_known_signature) - { - std::optional stdStringClass = cxx::mirror().getRecord("std", "string"); - ASSERT_TRUE(stdStringClass); - - std::optional isStringEmpty = stdStringClass->getMethod("empty"); - ASSERT_TRUE(isStringEmpty); - { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); - EXPECT_FALSE(is_empty); - } { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); - ASSERT_TRUE(is_empty); - - EXPECT_TRUE(is_empty(std::string(""))); - - EXPECT_FALSE(is_empty(std::string("not_empty"))); - - EXPECT_TRUE(is_empty("")); - - EXPECT_FALSE(is_empty("view_not_empty")); - } - } - - - TEST(StrictStaticTypeDispatch, std_string_view_method_call_with_known_signature) - { - std::optional stdStringViewClass = cxx::mirror().getRecord("std", "string_view"); - ASSERT_TRUE(stdStringViewClass); - - std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); - ASSERT_TRUE(isStringEmpty); - { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); - EXPECT_FALSE(is_empty); - } { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); - ASSERT_TRUE(is_empty); - - EXPECT_TRUE(is_empty(std::string(""))); - - EXPECT_FALSE(is_empty(std::string("not_empty"))); - - EXPECT_TRUE(is_empty(std::string_view(""))); - - EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))); - - EXPECT_TRUE(is_empty("")); - - EXPECT_FALSE(is_empty("view_not_empty")); - } - } - - - TEST(StrictStaticTypeDispatch, distinct_functions_with_ref_args_call_with_known_signature) + TEST(StrictStaticTypeRtl_function, distinct_functions_with_ref_args_call_with_known_signature) { std::string str = STRA; { @@ -289,7 +235,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, overloads_with_ref_and_value_args_call_with_known_signature) + TEST(StrictStaticTypeRtl_function, overloads_with_ref_and_value_args_call_with_known_signature) { std::optional reverseString = cxx::mirror().getFunction(str_revStrOverloadValRef); ASSERT_TRUE(reverseString); @@ -312,7 +258,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, overloads_with_const_ref_and_value_args_call_with_known_signature) + TEST(StrictStaticTypeRtl_function, overloads_with_const_ref_and_value_args_call_with_known_signature) { std::optional reverseString = cxx::mirror().getFunction(str_revStrOverloadValCRef); ASSERT_TRUE(reverseString); @@ -334,7 +280,7 @@ namespace rtl_tests } - TEST(StrictStaticTypeDispatch, overloads_with_ref_and_const_ref_args_call_with_known_signature) + TEST(StrictStaticTypeRtl_function, overloads_with_ref_and_const_ref_args_call_with_known_signature) { std::optional reverseString = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(reverseString); diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp new file mode 100644 index 00000000..301f17d1 --- /dev/null +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -0,0 +1,303 @@ + +#include +#include + +#include "TestMirrorProvider.h" +#include "GlobalTestUtils.h" +#include "..\CxxTestProps\inc\ComplexStrings.h" + +using namespace test_utils; +using namespace test_mirror; + +namespace rtl_tests +{ + TEST(StrictStaticTypeRtl_method, overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringUtil())(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringUtil())(STRB); + auto exp_str = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT().argsT<>().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringUtil())(); + auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_method, lvalue_ref_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + ASSERT_TRUE(optStringUtil); + + StringUtil target; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string lv_str = STRA; + std::string ret_str = reverse_string(target)(lv_str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_lvref; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + const std::string lv_str = STRA; + std::string ret_str = reverse_string(target)(lv_str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_clvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_method, rvalue_ref_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + ASSERT_TRUE(optStringUtil); + + StringUtil target; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_rvref; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + EXPECT_FALSE(reverse_string); + } + } + + + TEST(StrictStaticTypeRtl_method, ptr_and_const_ptr_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + ASSERT_TRUE(optStringUtil); + + StringUtil target; + std::string str = STRA; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(&str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(&str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_method, std_string_method_call_with_known_signature) + { + std::optional stdStringClass = cxx::mirror().getRecord("std", "string"); + ASSERT_TRUE(stdStringClass); + + std::optional isStringEmpty = stdStringClass->getMethod("empty"); + ASSERT_TRUE(isStringEmpty); + { + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + EXPECT_FALSE(is_empty); + } { + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + ASSERT_TRUE(is_empty); + + EXPECT_TRUE(is_empty(std::string(""))); + + EXPECT_FALSE(is_empty(std::string("not_empty"))); + + EXPECT_TRUE(is_empty("")); + + EXPECT_FALSE(is_empty("view_not_empty")); + } + } + + + TEST(StrictStaticTypeRtl_method, std_string_view_method_call_with_known_signature) + { + std::optional stdStringViewClass = cxx::mirror().getRecord("std", "string_view"); + ASSERT_TRUE(stdStringViewClass); + + std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); + ASSERT_TRUE(isStringEmpty); + { + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + EXPECT_FALSE(is_empty); + } { + rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + ASSERT_TRUE(is_empty); + + EXPECT_TRUE(is_empty(std::string(""))); + + EXPECT_FALSE(is_empty(std::string("not_empty"))); + + EXPECT_TRUE(is_empty(std::string_view(""))); + + EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))); + + EXPECT_TRUE(is_empty("")); + + EXPECT_FALSE(is_empty("view_not_empty")); + } + } + + + TEST(StrictStaticTypeRtl_method, distinct_functions_with_ref_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + ASSERT_TRUE(optStringUtil); + + StringUtil target; + std::string str = STRA; + { + std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); + ASSERT_TRUE(reverseString); + + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(ret_str, exp_str); + } { + std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); + ASSERT_TRUE(reverseString); + + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + auto lvstr = std::string_view(str); + std::string ret_str = reverse_string(target)(lvstr); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(ret_str, exp_str); + } { + std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); + ASSERT_TRUE(reverseString); + + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(str)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_method, overloads_with_ref_and_value_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + ASSERT_TRUE(optStringUtil); + + StringUtil target; + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string_view str = STRA; + std::string ret_str = reverse_string(target)(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_method, overloads_with_const_ref_and_value_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + ASSERT_TRUE(optStringUtil); + + StringUtil target; + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_method, overloads_with_ref_and_const_ref_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + ASSERT_TRUE(optStringUtil); + + StringUtil target; + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string_view str = STRA; + std::string ret_str = reverse_string(target)(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(ret_str, exp_str); + } + } +} \ No newline at end of file diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp similarity index 92% rename from RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp rename to RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp index cdfdee46..4d4bf5e8 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp @@ -6,14 +6,12 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" -#include - using namespace test_utils; using namespace test_mirror; namespace rtl_tests { - TEST(BasicTypeErasedDispatch, invalid_erased_return_rtl_function) + TEST(BasicTypeErasedRtl_function, invalid_erased_return_rtl_function) { { rtl::function erased_ret_fn; @@ -22,13 +20,6 @@ namespace rtl_tests auto [err, robj] = erased_ret_fn(); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); - } { - rtl::method erased_ret_mt; - EXPECT_FALSE(erased_ret_mt); - - auto [err, robj] = erased_ret_mt(0)(); - EXPECT_EQ(err, rtl::error::InvalidCaller); - EXPECT_TRUE(robj.isEmpty()); } rtl::function erased_ret_fn; @@ -46,26 +37,10 @@ namespace rtl_tests EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } - - rtl::method erased_ret_mt; - EXPECT_FALSE(erased_ret_mt); - { - auto [err, robj] = erased_ret_mt('a')(0); - EXPECT_EQ(err, rtl::error::InvalidCaller); - EXPECT_TRUE(robj.isEmpty()); - } { - auto [err, robj] = erased_ret_mt.bind('a')(0); - EXPECT_EQ(err, rtl::error::InvalidCaller); - EXPECT_TRUE(robj.isEmpty()); - } { - auto [err, robj] = erased_ret_mt.bind('a')(0); - EXPECT_EQ(err, rtl::error::InvalidCaller); - EXPECT_TRUE(robj.isEmpty()); - } } - TEST(BasicTypeErasedDispatch, implicit_resolutions_to_call_by_value_overloads) + TEST(BasicTypeErasedRtl_function, implicit_resolutions_to_call_by_value_overloads) { auto reverseStrOpt = cxx::mirror().getFunction(str_reverseString); ASSERT_TRUE(reverseStrOpt); @@ -222,7 +197,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) + TEST(BasicTypeErasedRtl_function, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) { auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); ASSERT_TRUE(revStrOverloadValCRefOpt); @@ -266,7 +241,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) + TEST(BasicTypeErasedRtl_function, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) { auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); ASSERT_TRUE(revStrOverloadValCRefOpt); @@ -303,7 +278,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) + TEST(BasicTypeErasedRtl_function, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) { auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); ASSERT_TRUE(revStrOverloadValRefOpt); @@ -343,7 +318,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) + TEST(BasicTypeErasedRtl_function, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) { auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); ASSERT_TRUE(revStrOverloadValRefOpt); @@ -378,7 +353,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, calling_non_overloaded_non_const_ref_argument) + TEST(BasicTypeErasedRtl_function, calling_non_overloaded_non_const_ref_argument) { auto revStrNonConstRefArgOpt = cxx::mirror().getFunction(str_revStrNonConstRefArg); ASSERT_TRUE(revStrNonConstRefArgOpt); @@ -421,7 +396,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, calling_non_overloaded_const_ref_argument) + TEST(BasicTypeErasedRtl_function, calling_non_overloaded_const_ref_argument) { auto revStrConstRefArgOpt = cxx::mirror().getFunction(str_revStrConstRefArg); ASSERT_TRUE(revStrConstRefArgOpt); @@ -470,7 +445,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, calling_non_overloaded_rvalue_ref_argument) + TEST(BasicTypeErasedRtl_function, calling_non_overloaded_rvalue_ref_argument) { auto revStrRValueRefArgOpt = cxx::mirror().getFunction(str_revStrRValueRefArg); ASSERT_TRUE(revStrRValueRefArgOpt); @@ -501,7 +476,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, implicit_resolution_to_ambiguous_ref_and_cref_overload) + TEST(BasicTypeErasedRtl_function, implicit_resolution_to_ambiguous_ref_and_cref_overload) { auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(revStrOverloadValRefNCrefOpt); @@ -532,7 +507,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedDispatch, explicit_resolution_to_ambiguous_ref_and_cref_overload) + TEST(BasicTypeErasedRtl_function, explicit_resolution_to_ambiguous_ref_and_cref_overload) { auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(revStrOverloadValRefNCrefOpt); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp new file mode 100644 index 00000000..2d09e602 --- /dev/null +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -0,0 +1,552 @@ + +#include +#include +#include + +#include "TestMirrorProvider.h" +#include "GlobalTestUtils.h" + +using namespace test_utils; +using namespace test_mirror; + +namespace rtl_tests +{ + TEST(BasicTypeErasedRtl_method, invalid_erased_return_rtl_function) + { + { + rtl::method erased_ret_mt; + EXPECT_FALSE(erased_ret_mt); + + auto [err, robj] = erased_ret_mt(0)(); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } + + rtl::method erased_ret_mt; + EXPECT_FALSE(erased_ret_mt); + { + auto [err, robj] = erased_ret_mt('a')(0); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = erased_ret_mt.bind('a')(0); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = erased_ret_mt.bind('a')(0); + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } + } + + + //TEST(BasicTypeErasedRtl_method, implicit_resolutions_to_call_by_value_overloads) + //{ + // auto reverseStrOpt = cxx::mirror().getFunction(str_reverseString); + // ASSERT_TRUE(reverseStrOpt); + // EXPECT_FALSE(reverseStrOpt->hasSignature()); + // { + // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + // EXPECT_FALSE(reverseString); + // { + // auto [err, robj] = reverseString(const_cast(STRA)); + + // EXPECT_EQ(err, rtl::error::InvalidCaller); + // EXPECT_TRUE(robj.isEmpty()); + // } { + // auto [err, robj] = reverseString.bind()(const_cast(STRA)); + + // EXPECT_EQ(err, rtl::error::InvalidCaller); + // EXPECT_TRUE(robj.isEmpty()); + // } + // } + // EXPECT_TRUE(reverseStrOpt->hasSignature()); + // { + // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // auto [err, robj] = reverseString(STRA); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + // EXPECT_EQ(retStr, expStr); + // } { + // auto [err, robj] = reverseString.bind()(STRA); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + // EXPECT_EQ(retStr, expStr); + // } + // } + // EXPECT_TRUE(reverseStrOpt->hasSignature()); + // { + // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // auto [err, robj] = reverseString(STRA); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + // EXPECT_EQ(retStr, expStr); + // } { + // auto [err, robj] = reverseString.bind()(STRA); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + // EXPECT_EQ(retStr, expStr); + // } + // } + // EXPECT_TRUE(reverseStrOpt->hasSignature()); + // { + // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // std::string str = STRA; + // auto [err, robj] = reverseString(&str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + // EXPECT_EQ(retStr, expStr); + // } { + // std::string str = STRA; + // auto [err, robj] = reverseString.bind()(&str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + // EXPECT_EQ(retStr, expStr); + // } + // } + // EXPECT_TRUE(reverseStrOpt->hasSignature()); + // { + // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // const std::string str = STRA; + // auto [err, robj] = reverseString(&str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + // EXPECT_EQ(retStr, expStr); + // } { + // const std::string str = STRA; + // auto [err, robj] = reverseString.bind()(&str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + // EXPECT_EQ(retStr, expStr); + // } + // } + // EXPECT_TRUE(reverseStrOpt->hasSignature<>()); + // { + // rtl::function reverseString = reverseStrOpt->argsT<>().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // auto [err, robj] = reverseString(); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + // EXPECT_EQ(retStr, expStr); + // } { + // auto [err, robj] = reverseString.bind()(); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + // EXPECT_EQ(retStr, expStr); + // } + // } + //} + + + //TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) + //{ + // auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); + // ASSERT_TRUE(revStrOverloadValCRefOpt); + + // EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + // EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + + // // Both by-value (T) and const-ref (const T&) overloads exist. + // EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + // EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + // std::string_view str = STRA; + + // rtl::function reverseString = revStrOverloadValCRefOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // // RTL chooses the safe by-value overload implicitly. The const-ref + // // path requires explicit binding only to disambiguate intent. + // // Note: If only const T& existed (no by-value overload), RTL would + // // call it implicitly, since binding to const-ref cannot mutate the caller. + // auto [err, robj] = reverseString(str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + // EXPECT_EQ(retStr, expStr); + // } { + // // explicit call by value resolution. + // auto [err, robj] = reverseString.bind()(str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + // EXPECT_EQ(retStr, expStr); + // } + //} + + + //TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) + //{ + // auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); + // ASSERT_TRUE(revStrOverloadValCRefOpt); + + // EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + // EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + // + // // Both by-value (T) and const-ref (const T&) overloads exist. + // EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + // EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + // std::string_view str = STRA; + + // rtl::function reverseString = revStrOverloadValCRefOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // // Explicitly selecting the const-ref overload using .bind(). + // // If no by-value overload were present, implicit resolution to const-ref + // // would have worked automatically, because const-ref cannot mutate. + // auto [err, robj] = reverseString.bind()(str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + // EXPECT_EQ(retStr, expStr); + // } { + // auto [err, robj] = reverseString.bind()(str); + + // EXPECT_EQ(err, rtl::error::RefBindingMismatch); + // ASSERT_TRUE(robj.isEmpty()); + // } + //} + + + //TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) + //{ + // auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); + // ASSERT_TRUE(revStrOverloadValRefOpt); + + // EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + // EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + // + // // Here both by-value (T) and non-const ref (T&) overloads exist. + // EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + // EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + // std::string_view str = STRA; + + // rtl::function reverseString = revStrOverloadValRefOpt->argsT().returnT<>(); + // { + // // Here also, RTL prioritizes the safe-by-value overload automatically + // // since it guarantees no mutation. The non-const ref overload remains + // // accessible only through explicit binding to preserve mutability intent. + // auto [err, robj] = reverseString(str); + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + // EXPECT_EQ(retStr, expStr); + // } { + // // explicit call by value resolution. + // auto [err, robj] = reverseString.bind()(str); + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + // EXPECT_EQ(retStr, expStr); + // } + //} + + + //TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) + //{ + // auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); + // ASSERT_TRUE(revStrOverloadValRefOpt); + // + // EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + // EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + // + // // Here both by-value (T) and non-const ref (T&) overloads exist. + // EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + // EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + // std::string_view str = STRA; + + // rtl::function reverseString = revStrOverloadValRefOpt->argsT().returnT<>(); + // { + // // Explicitly selecting the non-const ref overload. + // // Even though the by-value overload is preferred implicitly for safety, + // // the user can override that choice by binding explicitly as T&, + // // signaling the intent to allow mutation through reflection. + // auto [err, robj] = reverseString.bind()(str); + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + // EXPECT_EQ(retStr, expStr); + // } { + // auto [err, robj] = reverseString.bind()(str); + // EXPECT_EQ(err, rtl::error::RefBindingMismatch); + // ASSERT_TRUE(robj.isEmpty()); + // } + //} + + + //TEST(BasicTypeErasedRtl_method, calling_non_overloaded_non_const_ref_argument) + //{ + // auto revStrNonConstRefArgOpt = cxx::mirror().getFunction(str_revStrNonConstRefArg); + // ASSERT_TRUE(revStrNonConstRefArgOpt); + + // EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + // EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + // EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + + // // Here no overloads exists, only non-const ref (T&) argument. + // EXPECT_TRUE(revStrNonConstRefArgOpt->hasSignature()); + // std::string_view str = STRA; + + // rtl::function reverseString = revStrNonConstRefArgOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + + // // Calls that may mutate user data (T&) require explicit intent. + // // Hence, the dispatcher returns 'ExplicitRefBindingRequired' error. + // // Since no call by value overload exists. + // { + // auto [err, robj] = reverseString(str); + // EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + // } { + // // expected non-const ref binding. + // auto [err, robj] = reverseString.bind()(str); + // EXPECT_EQ(err, rtl::error::RefBindingMismatch); + // } { + // // By calling .bind(), the user explicitly signals willingness to let + // // the function modify the argument. This re-enables the T& call path and + // // executes successfully, producing the expected result. + // auto [err, robj] = reverseString.bind()(str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + // EXPECT_EQ(retStr, expStr); + // } + //} + + + //TEST(BasicTypeErasedRtl_method, calling_non_overloaded_const_ref_argument) + //{ + // auto revStrConstRefArgOpt = cxx::mirror().getFunction(str_revStrConstRefArg); + // ASSERT_TRUE(revStrConstRefArgOpt); + + // EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + // EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + // EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + + // // Here no overloads exists, only non-const ref (T&) argument. + // EXPECT_TRUE(revStrConstRefArgOpt->hasSignature()); + // std::string_view str = STRA; + + // rtl::function reverseString = revStrConstRefArgOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // // This call resolves to the const-ref overload (no other overloads exist), + // // so the argument is implicitly bound as a const reference. + // auto [err, robj] = reverseString(str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + // EXPECT_EQ(retStr, expStr); + // } { + // // explicit binding must also behave the same way. + // auto [err, robj] = reverseString.bind()(str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + // EXPECT_EQ(retStr, expStr); + // } { + // // explicit binding to non-const ref returns error. + // auto [err, robj] = reverseString.bind()(str); + + // // expected 'const T&' + // EXPECT_EQ(err, rtl::error::RefBindingMismatch); + // ASSERT_TRUE(robj.isEmpty()); + // } + //} + + + //TEST(BasicTypeErasedRtl_method, calling_non_overloaded_rvalue_ref_argument) + //{ + // auto revStrRValueRefArgOpt = cxx::mirror().getFunction(str_revStrRValueRefArg); + // ASSERT_TRUE(revStrRValueRefArgOpt); + + // EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + // EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + // EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + // + // // Here no overloads exists, only non-const ref (T&) argument. + // EXPECT_TRUE(revStrRValueRefArgOpt->hasSignature()); + + // rtl::function reverseString = revStrRValueRefArgOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // auto [err, robj] = reverseString(std::string_view(STRA)); + // EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + // } { + // auto [err, robj] = reverseString.bind()(std::string_view(STRA)); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + // EXPECT_EQ(retStr, expStr); + // } + //} + + + //TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_ref_and_cref_overload) + //{ + // auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); + // ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + + // EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + // EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + + // // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). + // EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + // EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + // std::string_view str = STRA; + + // rtl::function reverseString = revStrOverloadValRefNCrefOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // // Both T& and const T& overloads are viable for an lvalue argument. + // // RTL avoids implicit ambiguity by requiring explicit ref binding + // // when mutation is possible (non-const ref path). + // auto [err, robj] = reverseString(str); + // EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + // } { + // auto [err, robj] = reverseString.bind()(str); + // EXPECT_EQ(err, rtl::error::RefBindingMismatch); + // } { + // auto [err, robj] = reverseString.bind()(str); + // EXPECT_EQ(err, rtl::error::RefBindingMismatch); + // } + //} + + + //TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_ref_and_cref_overload) + //{ + // auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); + // ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + + // EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + // EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + + // // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). + // EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + // EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + // std::string_view str = STRA; + + // rtl::function reverseString = revStrOverloadValRefNCrefOpt->argsT().returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // // Explicitly selecting the non-const ref overload. + // // Caller signals intent to allow mutation by binding as T&. + // auto [err, robj] = reverseString.bind()(str); + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + // EXPECT_EQ(retStr, expStr); + // } { + // // Explicitly selecting the const ref overload. + // // Note: If only 'const T&' existed, RTL would have resolved it implicitly. + // // But since both 'T&' and 'const T&' overloads are available, + // // RTL treats the situation as ambiguous and requires explicit selection + // // to avoid guessing the user's intent regarding mutability. + // auto [err, robj] = reverseString.bind()(str); + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + // EXPECT_EQ(retStr, expStr); + // } + //} +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index 4b1e3c12..6d6fe61a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -30,7 +30,8 @@ namespace rtl } template - [[nodiscard]] constexpr decltype(auto) operator()(args_t&&...params) const noexcept + [[nodiscard]] [[gnu::hot]] + constexpr decltype(auto) operator()(args_t&&...params) const noexcept { return (*m_functor)(std::forward(params)...); } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index a37ead26..7abb3f3b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -30,10 +30,22 @@ namespace rtl return (m_functor != nullptr); } - template - [[nodiscard]] constexpr decltype(auto) operator()(record_t& target, args_t&&...params) const noexcept + struct invoker { - return (target.*m_functor)(std::forward(params)...); + fptr_t functor; + const record_t& target; + + template + requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] + constexpr decltype(auto) operator()(args_t&&...params) const noexcept + { + return (const_cast(target).*functor)(std::forward(params)...); + } + }; + + constexpr const invoker operator()(const record_t& p_target) const noexcept { + return invoker{ m_functor, p_target }; } method(fptr_t p_functor) : m_functor(p_functor) From 2fcfd2b650b34c2a406d92cbd986982f39870584 Mon Sep 17 00:00:00 2001 From: neeraj Date: Thu, 16 Oct 2025 12:39:50 +0530 Subject: [PATCH 093/148] fix header include error clang/gcc --- .../StrictStaticTypeDispatch_Method.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp index 301f17d1..82c87670 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -4,7 +4,7 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" -#include "..\CxxTestProps\inc\ComplexStrings.h" +#include "../CxxTestProps/inc/ComplexStrings.h" using namespace test_utils; using namespace test_mirror; From e1db2c5cdaf8f4c79cd7e3ce8c2c2781ffac85c1 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 16 Oct 2025 15:40:18 +0530 Subject: [PATCH 094/148] return-erased rtl::method tests added. --- CxxTestProps/inc/ComplexStrings.h | 2 + .../src/TestMirrorProvider.cpp | 4 +- CxxTestUtils/inc/GlobalTestUtils.h | 2 - .../StrictStaticTypeDispatch_Method.cpp | 16 +- .../BasicTypeErasedDispatch_Method.cpp | 1089 +++++++++-------- .../rtl/dispatch/rtl_method.h | 1 + 6 files changed, 593 insertions(+), 521 deletions(-) diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/ComplexStrings.h index cd7753dc..9c83d736 100644 --- a/CxxTestProps/inc/ComplexStrings.h +++ b/CxxTestProps/inc/ComplexStrings.h @@ -50,6 +50,8 @@ std::string revStrOverloadRefAndCRef(const std::string_view& pStr); struct StringUtil { + constexpr static const char* struct_ = "StringUtil"; + std::string reverseString(); std::string reverseString(const char* pStr); diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 8174b95a..6d0a42c3 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -125,7 +125,7 @@ namespace test_mirror rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), - rtl::type().record(StringUtil_struct).build(), + rtl::type().record(StringUtil::struct_).build(), // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), @@ -379,7 +379,7 @@ namespace test_mirror { person::class_, person }, { library::class_, library }, { calender::struct_, calender }, - { StringUtil_struct, string_util } + { StringUtil::struct_, string_util } }); const auto& itr = nameIdMap.find(pRecordName); diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index 566aeeae..f00e4482 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -36,8 +36,6 @@ namespace test_utils { static constexpr const char* STRB = "cxxReflection"; static constexpr const char* STRB_REVERSE = "noitcelfeRxxc"; - constexpr static const char* StringUtil_struct = "StringUtil"; - static constexpr const char* str_reverseString = "reverseString"; static constexpr const char* str_revStrConstRefArg = "revStrConstRefArg"; static constexpr const char* str_revStrRValueRefArg = "revStrRValueRefArg"; diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp index 82c87670..b596bee2 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -13,7 +13,7 @@ namespace rtl_tests { TEST(StrictStaticTypeRtl_method, overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); @@ -51,7 +51,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, lvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); StringUtil target; @@ -79,7 +79,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, rvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); StringUtil target; @@ -101,7 +101,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, ptr_and_const_ptr_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); StringUtil target; @@ -182,7 +182,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, distinct_functions_with_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); StringUtil target; @@ -224,7 +224,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); StringUtil target; @@ -251,7 +251,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_const_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); StringUtil target; @@ -277,7 +277,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_ref_and_const_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil_struct); + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); StringUtil target; diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp index 2d09e602..cdc7559c 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -5,6 +5,7 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" +#include "../CxxTestProps/inc/ComplexStrings.h" using namespace test_utils; using namespace test_mirror; @@ -40,513 +41,583 @@ namespace rtl_tests } - //TEST(BasicTypeErasedRtl_method, implicit_resolutions_to_call_by_value_overloads) - //{ - // auto reverseStrOpt = cxx::mirror().getFunction(str_reverseString); - // ASSERT_TRUE(reverseStrOpt); - // EXPECT_FALSE(reverseStrOpt->hasSignature()); - // { - // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); - // EXPECT_FALSE(reverseString); - // { - // auto [err, robj] = reverseString(const_cast(STRA)); - - // EXPECT_EQ(err, rtl::error::InvalidCaller); - // EXPECT_TRUE(robj.isEmpty()); - // } { - // auto [err, robj] = reverseString.bind()(const_cast(STRA)); - - // EXPECT_EQ(err, rtl::error::InvalidCaller); - // EXPECT_TRUE(robj.isEmpty()); - // } - // } - // EXPECT_TRUE(reverseStrOpt->hasSignature()); - // { - // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // auto [err, robj] = reverseString(STRA); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; - // EXPECT_EQ(retStr, expStr); - // } { - // auto [err, robj] = reverseString.bind()(STRA); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; - // EXPECT_EQ(retStr, expStr); - // } - // } - // EXPECT_TRUE(reverseStrOpt->hasSignature()); - // { - // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // auto [err, robj] = reverseString(STRA); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; - // EXPECT_EQ(retStr, expStr); - // } { - // auto [err, robj] = reverseString.bind()(STRA); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; - // EXPECT_EQ(retStr, expStr); - // } - // } - // EXPECT_TRUE(reverseStrOpt->hasSignature()); - // { - // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // std::string str = STRA; - // auto [err, robj] = reverseString(&str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; - // EXPECT_EQ(retStr, expStr); - // } { - // std::string str = STRA; - // auto [err, robj] = reverseString.bind()(&str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; - // EXPECT_EQ(retStr, expStr); - // } - // } - // EXPECT_TRUE(reverseStrOpt->hasSignature()); - // { - // rtl::function reverseString = reverseStrOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // const std::string str = STRA; - // auto [err, robj] = reverseString(&str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; - // EXPECT_EQ(retStr, expStr); - // } { - // const std::string str = STRA; - // auto [err, robj] = reverseString.bind()(&str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; - // EXPECT_EQ(retStr, expStr); - // } - // } - // EXPECT_TRUE(reverseStrOpt->hasSignature<>()); - // { - // rtl::function reverseString = reverseStrOpt->argsT<>().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // auto [err, robj] = reverseString(); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; - // EXPECT_EQ(retStr, expStr); - // } { - // auto [err, robj] = reverseString.bind()(); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; - // EXPECT_EQ(retStr, expStr); - // } - // } - //} - - - //TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) - //{ - // auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); - // ASSERT_TRUE(revStrOverloadValCRefOpt); - - // EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); - // EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); - - // // Both by-value (T) and const-ref (const T&) overloads exist. - // EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); - // EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); - // std::string_view str = STRA; - - // rtl::function reverseString = revStrOverloadValCRefOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // // RTL chooses the safe by-value overload implicitly. The const-ref - // // path requires explicit binding only to disambiguate intent. - // // Note: If only const T& existed (no by-value overload), RTL would - // // call it implicitly, since binding to const-ref cannot mutate the caller. - // auto [err, robj] = reverseString(str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; - // EXPECT_EQ(retStr, expStr); - // } { - // // explicit call by value resolution. - // auto [err, robj] = reverseString.bind()(str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; - // EXPECT_EQ(retStr, expStr); - // } - //} - - - //TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) - //{ - // auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); - // ASSERT_TRUE(revStrOverloadValCRefOpt); - - // EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); - // EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); - // - // // Both by-value (T) and const-ref (const T&) overloads exist. - // EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); - // EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); - // std::string_view str = STRA; - - // rtl::function reverseString = revStrOverloadValCRefOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // // Explicitly selecting the const-ref overload using .bind(). - // // If no by-value overload were present, implicit resolution to const-ref - // // would have worked automatically, because const-ref cannot mutate. - // auto [err, robj] = reverseString.bind()(str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; - // EXPECT_EQ(retStr, expStr); - // } { - // auto [err, robj] = reverseString.bind()(str); - - // EXPECT_EQ(err, rtl::error::RefBindingMismatch); - // ASSERT_TRUE(robj.isEmpty()); - // } - //} - - - //TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) - //{ - // auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); - // ASSERT_TRUE(revStrOverloadValRefOpt); - - // EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); - // EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); - // - // // Here both by-value (T) and non-const ref (T&) overloads exist. - // EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); - // EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); - // std::string_view str = STRA; - - // rtl::function reverseString = revStrOverloadValRefOpt->argsT().returnT<>(); - // { - // // Here also, RTL prioritizes the safe-by-value overload automatically - // // since it guarantees no mutation. The non-const ref overload remains - // // accessible only through explicit binding to preserve mutability intent. - // auto [err, robj] = reverseString(str); - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; - // EXPECT_EQ(retStr, expStr); - // } { - // // explicit call by value resolution. - // auto [err, robj] = reverseString.bind()(str); - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; - // EXPECT_EQ(retStr, expStr); - // } - //} - - - //TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) - //{ - // auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); - // ASSERT_TRUE(revStrOverloadValRefOpt); - // - // EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); - // EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); - // - // // Here both by-value (T) and non-const ref (T&) overloads exist. - // EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); - // EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); - // std::string_view str = STRA; - - // rtl::function reverseString = revStrOverloadValRefOpt->argsT().returnT<>(); - // { - // // Explicitly selecting the non-const ref overload. - // // Even though the by-value overload is preferred implicitly for safety, - // // the user can override that choice by binding explicitly as T&, - // // signaling the intent to allow mutation through reflection. - // auto [err, robj] = reverseString.bind()(str); - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; - // EXPECT_EQ(retStr, expStr); - // } { - // auto [err, robj] = reverseString.bind()(str); - // EXPECT_EQ(err, rtl::error::RefBindingMismatch); - // ASSERT_TRUE(robj.isEmpty()); - // } - //} - - - //TEST(BasicTypeErasedRtl_method, calling_non_overloaded_non_const_ref_argument) - //{ - // auto revStrNonConstRefArgOpt = cxx::mirror().getFunction(str_revStrNonConstRefArg); - // ASSERT_TRUE(revStrNonConstRefArgOpt); - - // EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); - // EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); - // EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); - - // // Here no overloads exists, only non-const ref (T&) argument. - // EXPECT_TRUE(revStrNonConstRefArgOpt->hasSignature()); - // std::string_view str = STRA; - - // rtl::function reverseString = revStrNonConstRefArgOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - - // // Calls that may mutate user data (T&) require explicit intent. - // // Hence, the dispatcher returns 'ExplicitRefBindingRequired' error. - // // Since no call by value overload exists. - // { - // auto [err, robj] = reverseString(str); - // EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); - // } { - // // expected non-const ref binding. - // auto [err, robj] = reverseString.bind()(str); - // EXPECT_EQ(err, rtl::error::RefBindingMismatch); - // } { - // // By calling .bind(), the user explicitly signals willingness to let - // // the function modify the argument. This re-enables the T& call path and - // // executes successfully, producing the expected result. - // auto [err, robj] = reverseString.bind()(str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; - // EXPECT_EQ(retStr, expStr); - // } - //} - - - //TEST(BasicTypeErasedRtl_method, calling_non_overloaded_const_ref_argument) - //{ - // auto revStrConstRefArgOpt = cxx::mirror().getFunction(str_revStrConstRefArg); - // ASSERT_TRUE(revStrConstRefArgOpt); - - // EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); - // EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); - // EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); - - // // Here no overloads exists, only non-const ref (T&) argument. - // EXPECT_TRUE(revStrConstRefArgOpt->hasSignature()); - // std::string_view str = STRA; - - // rtl::function reverseString = revStrConstRefArgOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // // This call resolves to the const-ref overload (no other overloads exist), - // // so the argument is implicitly bound as a const reference. - // auto [err, robj] = reverseString(str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; - // EXPECT_EQ(retStr, expStr); - // } { - // // explicit binding must also behave the same way. - // auto [err, robj] = reverseString.bind()(str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; - // EXPECT_EQ(retStr, expStr); - // } { - // // explicit binding to non-const ref returns error. - // auto [err, robj] = reverseString.bind()(str); - - // // expected 'const T&' - // EXPECT_EQ(err, rtl::error::RefBindingMismatch); - // ASSERT_TRUE(robj.isEmpty()); - // } - //} - - - //TEST(BasicTypeErasedRtl_method, calling_non_overloaded_rvalue_ref_argument) - //{ - // auto revStrRValueRefArgOpt = cxx::mirror().getFunction(str_revStrRValueRefArg); - // ASSERT_TRUE(revStrRValueRefArgOpt); - - // EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); - // EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); - // EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); - // - // // Here no overloads exists, only non-const ref (T&) argument. - // EXPECT_TRUE(revStrRValueRefArgOpt->hasSignature()); - - // rtl::function reverseString = revStrRValueRefArgOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // auto [err, robj] = reverseString(std::string_view(STRA)); - // EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); - // } { - // auto [err, robj] = reverseString.bind()(std::string_view(STRA)); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; - // EXPECT_EQ(retStr, expStr); - // } - //} - - - //TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_ref_and_cref_overload) - //{ - // auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); - // ASSERT_TRUE(revStrOverloadValRefNCrefOpt); - - // EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); - // EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); - - // // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). - // EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); - // EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); - // std::string_view str = STRA; - - // rtl::function reverseString = revStrOverloadValRefNCrefOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // // Both T& and const T& overloads are viable for an lvalue argument. - // // RTL avoids implicit ambiguity by requiring explicit ref binding - // // when mutation is possible (non-const ref path). - // auto [err, robj] = reverseString(str); - // EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); - // } { - // auto [err, robj] = reverseString.bind()(str); - // EXPECT_EQ(err, rtl::error::RefBindingMismatch); - // } { - // auto [err, robj] = reverseString.bind()(str); - // EXPECT_EQ(err, rtl::error::RefBindingMismatch); - // } - //} - - - //TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_ref_and_cref_overload) - //{ - // auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); - // ASSERT_TRUE(revStrOverloadValRefNCrefOpt); - - // EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); - // EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); - - // // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). - // EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); - // EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); - // std::string_view str = STRA; - - // rtl::function reverseString = revStrOverloadValRefNCrefOpt->argsT().returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // // Explicitly selecting the non-const ref overload. - // // Caller signals intent to allow mutation by binding as T&. - // auto [err, robj] = reverseString.bind()(str); - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; - // EXPECT_EQ(retStr, expStr); - // } { - // // Explicitly selecting the const ref overload. - // // Note: If only 'const T&' existed, RTL would have resolved it implicitly. - // // But since both 'T&' and 'const T&' overloads are available, - // // RTL treats the situation as ambiguous and requires explicit selection - // // to avoid guessing the user's intent regarding mutability. - // auto [err, robj] = reverseString.bind()(str); - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; - // EXPECT_EQ(retStr, expStr); - // } - //} + TEST(BasicTypeErasedRtl_method, implicit_resolutions_to_call_by_value_overloads) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto reverseStrOpt = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseStrOpt); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + { + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_FALSE(reverseString); + { + auto [err, robj] = reverseString(StringUtil())(const_cast(STRA)); + + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = reverseString.bind(StringUtil())(const_cast(STRA)); + + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(StringUtil())(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind(StringUtil())(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(StringUtil())(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind(StringUtil())(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + std::string str = STRA; + auto [err, robj] = reverseString(StringUtil())(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + EXPECT_EQ(retStr, expStr); + } { + std::string str = STRA; + auto [err, robj] = reverseString.bind(StringUtil())(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + const std::string str = STRA; + auto [err, robj] = reverseString(StringUtil())(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + EXPECT_EQ(retStr, expStr); + } { + const std::string str = STRA; + auto [err, robj] = reverseString.bind(StringUtil())(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature<>()); + { + rtl::method reverseString = reverseStrOpt->recordT() + .argsT<>() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(StringUtil())(); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind(StringUtil())(); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + EXPECT_EQ(retStr, expStr); + } + } + } + + + TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrOverloadValCRefOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); + ASSERT_TRUE(revStrOverloadValCRefOpt); + + EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + + // Both by-value (T) and const-ref (const T&) overloads exist. + EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + + StringUtil target; + std::string_view str = STRA; + rtl::method reverseString = revStrOverloadValCRefOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + // RTL chooses the safe by-value overload implicitly. The const-ref + // path requires explicit binding only to disambiguate intent. + // Note: If only const T& existed (no by-value overload), RTL would + // call it implicitly, since binding to const-ref cannot mutate the caller. + auto [err, robj] = reverseString(target)(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(retStr, expStr); + } { + // explicit call by value resolution. + auto [err, robj] = reverseString.bind(target)(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(retStr, expStr); + } + } + + + TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrOverloadValCRefOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); + ASSERT_TRUE(revStrOverloadValCRefOpt); + + EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + + // Both by-value (T) and const-ref (const T&) overloads exist. + EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + + StringUtil target; + std::string_view str = STRA; + rtl::method reverseString = revStrOverloadValCRefOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + // Explicitly selecting the const-ref overload using .bind(). + // If no by-value overload were present, implicit resolution to const-ref + // would have worked automatically, because const-ref cannot mutate. + auto [err, robj] = reverseString.bind(target)(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind(target)(str); + + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + ASSERT_TRUE(robj.isEmpty()); + } + } + + + TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrOverloadValRefOpt = optStringUtil->getMethod(str_revStrOverloadValRef); + ASSERT_TRUE(revStrOverloadValRefOpt); + + EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + + // Here both by-value (T) and non-const ref (T&) overloads exist. + EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + + StringUtil target; + std::string_view str = STRA; + rtl::method reverseString = revStrOverloadValRefOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + // Here also, RTL prioritizes the safe-by-value overload automatically + // since it guarantees no mutation. The non-const ref overload remains + // accessible only through explicit binding to preserve mutability intent. + auto [err, robj] = reverseString(target)(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(retStr, expStr); + } { + // explicit call by value resolution. + auto [err, robj] = reverseString.bind(target)(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + EXPECT_EQ(retStr, expStr); + } + } + + + TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrOverloadValRefOpt = optStringUtil->getMethod(str_revStrOverloadValRef); + ASSERT_TRUE(revStrOverloadValRefOpt); + + EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + + // Here both by-value (T) and non-const ref (T&) overloads exist. + EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + + StringUtil target; + std::string_view str = STRA; + rtl::method reverseString = revStrOverloadValRefOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + // Explicitly selecting the non-const ref overload. + // Even though the by-value overload is preferred implicitly for safety, + // the user can override that choice by binding explicitly as T&, + // signaling the intent to allow mutation through reflection. + auto [err, robj] = reverseString.bind(target)(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind(target)(str); + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + ASSERT_TRUE(robj.isEmpty()); + } + } + + + TEST(BasicTypeErasedRtl_method, calling_non_overloaded_non_const_ref_argument) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrNonConstRefArgOpt = optStringUtil->getMethod(str_revStrNonConstRefArg); + ASSERT_TRUE(revStrNonConstRefArgOpt); + + EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + + // Here no overloads exists, only non-const ref (T&) argument. + EXPECT_TRUE(revStrNonConstRefArgOpt->hasSignature()); + + StringUtil target; + std::string_view str = STRA; + rtl::method reverseString = revStrNonConstRefArgOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + // Calls that may mutate user data (T&) require explicit intent. + // Hence, the dispatcher returns 'ExplicitRefBindingRequired' error. + // Since no call by value overload exists. + { + auto [err, robj] = reverseString(target)(str); + EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + } { + // expected non-const ref binding. + auto [err, robj] = reverseString.bind(target)(str); + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + } { + // By calling .bind(), the user explicitly signals willingness to let + // the function modify the argument. This re-enables the T& call path and + // executes successfully, producing the expected result. + auto [err, robj] = reverseString.bind(target)(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(retStr, expStr); + } + } + + + TEST(BasicTypeErasedRtl_method, calling_non_overloaded_const_ref_argument) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrConstRefArgOpt = optStringUtil->getMethod(str_revStrConstRefArg); + ASSERT_TRUE(revStrConstRefArgOpt); + + EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + + // Here no overloads exists, only non-const ref (T&) argument. + EXPECT_TRUE(revStrConstRefArgOpt->hasSignature()); + + StringUtil target; + std::string_view str = STRA; + rtl::method reverseString = revStrConstRefArgOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + // This call resolves to the const-ref overload (no other overloads exist), + // so the argument is implicitly bound as a const reference. + auto [err, robj] = reverseString(target)(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(retStr, expStr); + } { + // explicit binding must also behave the same way. + auto [err, robj] = reverseString.bind(target)(str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(retStr, expStr); + } { + // explicit binding to non-const ref returns error. + auto [err, robj] = reverseString.bind(target)(str); + + // expected 'const T&' + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + ASSERT_TRUE(robj.isEmpty()); + } + } + + + TEST(BasicTypeErasedRtl_method, calling_non_overloaded_rvalue_ref_argument) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrRValueRefArgOpt = optStringUtil->getMethod(str_revStrRValueRefArg); + ASSERT_TRUE(revStrRValueRefArgOpt); + + EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + + // Here no overloads exists, only non-const ref (T&) argument. + EXPECT_TRUE(revStrRValueRefArgOpt->hasSignature()); + + StringUtil target; + rtl::method reverseString = revStrRValueRefArgOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(target)(std::string_view(STRA)); + EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + } { + auto [err, robj] = reverseString.bind(target)(std::string_view(STRA)); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + EXPECT_EQ(retStr, expStr); + } + } + + + TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_ref_and_cref_overload) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrOverloadValRefNCrefOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + + EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + + // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). + EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + + StringUtil target; + std::string_view str = STRA; + rtl::method reverseString = revStrOverloadValRefNCrefOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + // Both T& and const T& overloads are viable for an lvalue argument. + // RTL avoids implicit ambiguity by requiring explicit ref binding + // when mutation is possible (non-const ref path). + auto [err, robj] = reverseString(target)(str); + EXPECT_EQ(err, rtl::error::ExplicitRefBindingRequired); + } { + auto [err, robj] = reverseString.bind(target)(str); + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + } { + auto [err, robj] = reverseString.bind(target)(str); + EXPECT_EQ(err, rtl::error::RefBindingMismatch); + } + } + + + TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_ref_and_cref_overload) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + ASSERT_TRUE(optStringUtil); + + auto revStrOverloadValRefNCrefOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + + EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + + // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). + EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + + StringUtil target; + std::string_view str = STRA; + rtl::method reverseString = revStrOverloadValRefNCrefOpt->recordT() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + // Explicitly selecting the non-const ref overload. + // Caller signals intent to allow mutation by binding as T&. + auto [err, robj] = reverseString.bind(target)(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + EXPECT_EQ(retStr, expStr); + } { + // Explicitly selecting the const ref overload. + // Note: If only 'const T&' existed, RTL would have resolved it implicitly. + // But since both 'T&' and 'const T&' overloads are available, + // RTL treats the situation as ambiguous and requires explicit selection + // to avoid guessing the user's intent regarding mutability. + auto [err, robj] = reverseString.bind(target)(str); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + EXPECT_EQ(retStr, expStr); + } + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 7abb3f3b..5ca7d370 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -44,6 +44,7 @@ namespace rtl } }; + [[gnu::hot]] constexpr const invoker operator()(const record_t& p_target) const noexcept { return invoker{ m_functor, p_target }; } From f6f282f42d6c46551752c7f1a7e882b8c8f0857d Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 17 Oct 2025 00:49:11 +0530 Subject: [PATCH 095/148] minor improvement/refactor/formatting. --- .../StrictStaticTypeDispatch_Method.cpp | 96 +++++++--- .../BasicTypeErasedDispatch_Method.cpp | 164 +++++++++--------- .../rtl/cache/cache_lambda_function.h | 2 +- .../rtl/cache/cache_lambda_method.h | 2 +- .../rtl/dispatch/function_ptr.h | 6 +- ReflectionTemplateLib/rtl/dispatch/functor.h | 12 +- .../rtl/dispatch/method_ptr.h | 6 +- .../rtl/dispatch/method_ptr_const.h | 6 +- .../rtl/dispatch/rtl_method_erased_return.h | 62 ++++--- 9 files changed, 206 insertions(+), 150 deletions(-) diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp index b596bee2..3d7cba39 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -19,27 +19,37 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringUtil())(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringUtil())(STRB); auto exp_str = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT().argsT<>().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT<>() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringUtil())(); @@ -58,7 +68,9 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string lv_str = STRA; @@ -66,7 +78,9 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_lvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); const std::string lv_str = STRA; @@ -86,14 +100,18 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_rvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } } @@ -109,14 +127,18 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(&str); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(&str); @@ -134,10 +156,14 @@ namespace rtl_tests std::optional isStringEmpty = stdStringClass->getMethod("empty"); ASSERT_TRUE(isStringEmpty); { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + rtl::method is_empty = isStringEmpty->recordT() + .argsT<>() + .returnT(); EXPECT_FALSE(is_empty); } { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + rtl::method is_empty = isStringEmpty->recordT() + .argsT<>() + .returnT(); ASSERT_TRUE(is_empty); EXPECT_TRUE(is_empty(std::string(""))); @@ -159,10 +185,14 @@ namespace rtl_tests std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); ASSERT_TRUE(isStringEmpty); { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + rtl::method is_empty = isStringEmpty->recordT() + .argsT<>() + .returnT(); EXPECT_FALSE(is_empty); } { - rtl::method is_empty = isStringEmpty->recordT().argsT<>().returnT(); + rtl::method is_empty = isStringEmpty->recordT() + .argsT<>() + .returnT(); ASSERT_TRUE(is_empty); EXPECT_TRUE(is_empty(std::string(""))); @@ -191,7 +221,9 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(str); @@ -201,7 +233,9 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); auto lvstr = std::string_view(str); @@ -212,7 +246,9 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(str)); @@ -231,14 +267,18 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string_view str = STRA; @@ -258,14 +298,18 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); @@ -284,7 +328,9 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string_view str = STRA; @@ -292,7 +338,9 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT().argsT().returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp index cdc7559c..a0c5b6a5 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -46,7 +46,7 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto reverseStrOpt = optStringUtil->getMethod(str_reverseString); + std::optional reverseStrOpt = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseStrOpt); EXPECT_FALSE(reverseStrOpt->hasSignature()); { @@ -218,21 +218,21 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrOverloadValCRefOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); - ASSERT_TRUE(revStrOverloadValCRefOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); - EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Both by-value (T) and const-ref (const T&) overloads exist. - EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); - EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; std::string_view str = STRA; - rtl::method reverseString = revStrOverloadValCRefOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // RTL chooses the safe by-value overload implicitly. The const-ref @@ -268,21 +268,21 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrOverloadValCRefOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); - ASSERT_TRUE(revStrOverloadValCRefOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); - EXPECT_FALSE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Both by-value (T) and const-ref (const T&) overloads exist. - EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); - EXPECT_TRUE(revStrOverloadValCRefOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; std::string_view str = STRA; - rtl::method reverseString = revStrOverloadValCRefOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Explicitly selecting the const-ref overload using .bind(). @@ -311,21 +311,21 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrOverloadValRefOpt = optStringUtil->getMethod(str_revStrOverloadValRef); - ASSERT_TRUE(revStrOverloadValRefOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRef); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); - EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Here both by-value (T) and non-const ref (T&) overloads exist. - EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); - EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; std::string_view str = STRA; - rtl::method reverseString = revStrOverloadValRefOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Here also, RTL prioritizes the safe-by-value overload automatically @@ -358,21 +358,21 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrOverloadValRefOpt = optStringUtil->getMethod(str_revStrOverloadValRef); - ASSERT_TRUE(revStrOverloadValRefOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRef); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); - EXPECT_FALSE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Here both by-value (T) and non-const ref (T&) overloads exist. - EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); - EXPECT_TRUE(revStrOverloadValRefOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; std::string_view str = STRA; - rtl::method reverseString = revStrOverloadValRefOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Explicitly selecting the non-const ref overload. @@ -400,21 +400,21 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrNonConstRefArgOpt = optStringUtil->getMethod(str_revStrNonConstRefArg); - ASSERT_TRUE(revStrNonConstRefArgOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrNonConstRefArg); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); - EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); - EXPECT_FALSE(revStrNonConstRefArgOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Here no overloads exists, only non-const ref (T&) argument. - EXPECT_TRUE(revStrNonConstRefArgOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; std::string_view str = STRA; - rtl::method reverseString = revStrNonConstRefArgOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); // Calls that may mutate user data (T&) require explicit intent. // Hence, the dispatcher returns 'ExplicitRefBindingRequired' error. @@ -448,21 +448,21 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrConstRefArgOpt = optStringUtil->getMethod(str_revStrConstRefArg); - ASSERT_TRUE(revStrConstRefArgOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrConstRefArg); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); - EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); - EXPECT_FALSE(revStrConstRefArgOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Here no overloads exists, only non-const ref (T&) argument. - EXPECT_TRUE(revStrConstRefArgOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; std::string_view str = STRA; - rtl::method reverseString = revStrConstRefArgOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // This call resolves to the const-ref overload (no other overloads exist), @@ -503,20 +503,20 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrRValueRefArgOpt = optStringUtil->getMethod(str_revStrRValueRefArg); - ASSERT_TRUE(revStrRValueRefArgOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrRValueRefArg); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); - EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); - EXPECT_FALSE(revStrRValueRefArgOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Here no overloads exists, only non-const ref (T&) argument. - EXPECT_TRUE(revStrRValueRefArgOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; - rtl::method reverseString = revStrRValueRefArgOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { auto [err, robj] = reverseString(target)(std::string_view(STRA)); @@ -540,21 +540,21 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrOverloadValRefNCrefOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); - ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); - EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). - EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); - EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; std::string_view str = STRA; - rtl::method reverseString = revStrOverloadValRefNCrefOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Both T& and const T& overloads are viable for an lvalue argument. @@ -577,21 +577,21 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); ASSERT_TRUE(optStringUtil); - auto revStrOverloadValRefNCrefOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); - ASSERT_TRUE(revStrOverloadValRefNCrefOpt); + std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(reverseStrOpt); - EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); - EXPECT_FALSE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + EXPECT_FALSE(reverseStrOpt->hasSignature()); // Here distinct overloads exists, with non-const ref (T&) and const-ref (const T&). - EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); - EXPECT_TRUE(revStrOverloadValRefNCrefOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); + EXPECT_TRUE(reverseStrOpt->hasSignature()); StringUtil target; std::string_view str = STRA; - rtl::method reverseString = revStrOverloadValRefNCrefOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Explicitly selecting the non-const ref overload. diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index b95047f9..cb1309ee 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -35,7 +35,7 @@ namespace rtl::cache m_cache.push_back(dispatch::lambda_function(p_functor, eb)); - p_functor.m_lambda = &m_cache.back(); + p_functor.set_lambda(&m_cache.back()); return m_cache.back(); } diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index 0404571b..407e7114 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -36,7 +36,7 @@ namespace rtl::cache m_cache.push_back(dispatch::lambda_method(p_functor, eb)); - p_functor.m_lambda = &m_cache.back(); + p_functor.set_lambda(&m_cache.back()); return m_cache.back(); } diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index 79dc01cf..e7762b94 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -20,13 +20,11 @@ namespace rtl::dispatch { using functor_t = return_t(*)(signature_t...); - [[nodiscard]] constexpr auto f_ptr() const - { + constexpr auto f_ptr() const { return m_functor; } - constexpr bool is_same(functor_t fptr) const - { + constexpr bool is_same(functor_t fptr) const { return (fptr == m_functor); } diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 7385e093..b674ff4e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -44,20 +44,24 @@ namespace rtl::dispatch private: + constexpr void set_lambda(const lambda_base* p_lambda) const { + m_lambda = p_lambda; + } + mutable const lambda_base* m_lambda = nullptr; friend lambda_base; - template + template friend struct lambda_function; - template + template friend struct lambda_method; - template + template friend struct cache::lambda_function; - template + template friend struct cache::lambda_method; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index b697fe08..89c9c45b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -22,13 +22,11 @@ namespace rtl::dispatch { using functor_t = return_t(record_t::*)(signature_t...); - [[nodiscard]] constexpr auto f_ptr() const - { + constexpr auto f_ptr() const { return m_functor; } - constexpr bool is_same(functor_t fptr) const - { + constexpr bool is_same(functor_t fptr) const { return (fptr == m_functor); } diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h index a8bd46e4..3386381d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h @@ -22,13 +22,11 @@ namespace rtl::dispatch { using functor_t = return_t(record_t::*)(signature_t...) const; - [[nodiscard]] constexpr auto f_ptr() const - { + constexpr auto f_ptr() const { return m_functor; } - constexpr bool is_same(functor_t fptr) const - { + constexpr bool is_same(functor_t fptr) const { return (fptr == m_functor); } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h index b9303ebd..6dd74279 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -20,41 +20,34 @@ namespace rtl template struct method { - enum call_by - { - value = 0, - cref = 1, //const ref. - ncref = 2 //non-const ref. - }; - struct invoker { const record_t& target; - const method& mt; + const method& fn; template requires (sizeof...(args_t) == sizeof...(signature_t)) [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] constexpr Return operator()(args_t&&...params) const noexcept { - if (!mt) [[unlikely]] { + if (!fn) [[unlikely]] { return { error::InvalidCaller, RObject{} }; } - if (mt.must_bind_refs()) [[unlikely]] { + if (fn.must_bind_refs()) [[unlikely]] { return { error::ExplicitRefBindingRequired, RObject{} }; } - auto index = (mt.m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); - if (mt.m_lambdas[index]->is_void()) + auto index = (fn.m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (fn.m_lambdas[index]->is_void()) { - mt.m_vhop[index] (*(mt.m_lambdas[index]), target, std::forward(params)...); + fn.m_vhop[index] (*(fn.m_lambdas[index]), target, std::forward(params)...); return { error::None, RObject{} }; } else { return { error::None, - RObject{ mt.m_rhop[index] (*(mt.m_lambdas[index]), target, std::forward(params)...), - mt.m_lambdas.back()->get_return_id(), nullptr + RObject{ fn.m_rhop[index] (*(fn.m_lambdas[index]), target, std::forward(params)...), + fn.m_lambdas.back()->get_return_id(), nullptr } }; } @@ -65,33 +58,33 @@ namespace rtl struct perfect_fwd { const record_t& target; - const method& mt; + const method& fn; template [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] constexpr Return operator()(args_t&&...params) const noexcept { - if (!mt) [[unlikely]] { + if (!fn) [[unlikely]] { return { error::InvalidCaller, RObject{} }; } auto signature_id = traits::uid>::value; - for (int index = 0; index < mt.m_lambdas.size(); index++) + for (int index = 0; index < fn.m_lambdas.size(); index++) { - if (mt.m_lambdas[index] != nullptr) + if (fn.m_lambdas[index] != nullptr) { - if (signature_id == mt.m_lambdas[index]->get_strict_sign_id()) + if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) { - if (mt.m_lambdas[index]->is_void()) + if (fn.m_lambdas[index]->is_void()) { - mt.m_vhop[index] (*mt.m_lambdas[index], target, std::forward(params)...); + fn.m_vhop[index] (*fn.m_lambdas[index], target, std::forward(params)...); return { error::None, RObject{} }; } else { return { error::None, - RObject{ mt.m_rhop[index] (*mt.m_lambdas[index], target, std::forward(params)...), - mt.m_lambdas.back()->get_return_id(), nullptr + RObject{ fn.m_rhop[index] (*fn.m_lambdas[index], target, std::forward(params)...), + fn.m_lambdas.back()->get_return_id(), nullptr } }; } @@ -102,13 +95,23 @@ namespace rtl } }; - constexpr invoker operator()(const record_t& p_target) const noexcept { + constexpr invoker operator()(record_t& p_target) const noexcept { return invoker{ p_target, *this }; } + constexpr invoker operator()(record_t&& p_target) const noexcept { + return invoker{ p_target, *this }; + } + + template + requires (std::is_same_v, std::tuple>) + constexpr const perfect_fwd bind(record_t& p_target) const noexcept { + return perfect_fwd{ p_target, *this }; + } + template requires (std::is_same_v, std::tuple>) - constexpr const perfect_fwd bind(const record_t& p_target) const noexcept { + constexpr const perfect_fwd bind(record_t&& p_target) const noexcept { return perfect_fwd{ p_target, *this }; } @@ -121,6 +124,13 @@ namespace rtl (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); } + enum call_by + { + value = 0, + cref = 1, //const ref. + ncref = 2 //non-const ref. + }; + private: using lambda_vt = std::function; From 6b5c0adbe8ee88abb290b9c2e95fa7d688768d30 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 17 Oct 2025 15:34:07 +0530 Subject: [PATCH 096/148] rtl::method test cases added. --- CxxTestProps/inc/ComplexStrings.h | 46 ++- CxxTestProps/src/ComplexStrings.cpp | 173 ++++++++- CxxTestRegistration/inc/TestMirrorProvider.h | 3 +- .../src/TestMirrorProvider.cpp | 103 +++-- CxxTestUtils/inc/GlobalTestUtils.h | 1 + RTLTestRunApp/src/CMakeLists.txt | 1 + .../StrictStaticTypeDispatch_ConstMethod.cpp | 361 ++++++++++++++++++ .../StrictStaticTypeDispatch_Method.cpp | 228 +++++------ .../BasicTypeErasedDispatch_Method.cpp | 152 ++++---- .../rtl/dispatch/CMakeLists.txt | 1 + .../rtl/dispatch/rtl_function_erased_return.h | 68 ++-- .../rtl/dispatch/rtl_method.h | 7 +- .../rtl/dispatch/rtl_method_const.h | 23 +- .../dispatch/rtl_method_const_erased_return.h | 146 +++++++ .../rtl/dispatch/rtl_method_erased_return.h | 4 +- 15 files changed, 1011 insertions(+), 306 deletions(-) create mode 100644 RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/ComplexStrings.h index 9c83d736..93bea1cd 100644 --- a/CxxTestProps/inc/ComplexStrings.h +++ b/CxxTestProps/inc/ComplexStrings.h @@ -48,9 +48,10 @@ std::string revStrOverloadRefAndCRef(std::string_view& pStr); std::string revStrOverloadRefAndCRef(const std::string_view& pStr); -struct StringUtil +// 'StringM' - String-Mutable, all methods are non-const. +struct StringM { - constexpr static const char* struct_ = "StringUtil"; + constexpr static const char* struct_ = "StringM"; std::string reverseString(); @@ -86,3 +87,44 @@ struct StringUtil std::string revStrOverloadRefAndCRef(const std::string_view& pStr); }; + + +// 'StringC' - String-Const, all methods are const. +struct StringC +{ + constexpr static const char* struct_ = "StringC"; + + std::string reverseString() const; + + std::string reverseString(const char* pStr) const; + + std::string reverseString(std::string pStr) const; // (1) by value + + std::string reverseString(std::string& pStr) const; // (2) lvalue ref + + std::string reverseString(const std::string& pStr) const; // (3) const lvalue ref + + std::string reverseString(std::string&& pStr) const; // (4) rvalue ref + + std::string reverseString(std::string* pStr) const; // (5) pointer + + std::string reverseString(const std::string* pStr) const; // (6) pointer to const + + std::string revStrConstRefArg(const std::string_view& pStr) const; + + std::string revStrNonConstRefArg(std::string_view& pStr) const; + + std::string revStrRValueRefArg(std::string_view&& pStr) const; + + std::string revStrOverloadValRef(std::string_view pStr) const; + + std::string revStrOverloadValRef(std::string_view& pStr) const; + + std::string revStrOverloadValCRef(std::string_view pStr) const; + + std::string revStrOverloadValCRef(const std::string_view& pStr) const; + + std::string revStrOverloadRefAndCRef(std::string_view& pStr) const; + + std::string revStrOverloadRefAndCRef(const std::string_view& pStr) const; +}; \ No newline at end of file diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/ComplexStrings.cpp index b385e515..ed6289c9 100644 --- a/CxxTestProps/src/ComplexStrings.cpp +++ b/CxxTestProps/src/ComplexStrings.cpp @@ -31,6 +31,7 @@ std::string getComplexNumAsString() namespace test_utils { + const char* SUFFIX_const = "_const"; const char* SUFFIX_ARG_void = "_arg_void"; const char* SUFFIX_ARG_const_char_ptr = "_arg_const_char_*"; @@ -187,15 +188,15 @@ std::string revStrOverloadRefAndCRef(const std::string_view& pStr) return retStr + SUFFIX_ARG_std_string_view_clvref; } -//---------------------------StringUtil-------------------------------- +//---------------------------StringM-------------------------------- -std::string StringUtil::reverseString() +std::string StringM::reverseString() { return std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; } -std::string StringUtil::reverseString(const char* pStr) +std::string StringM::reverseString(const char* pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -203,7 +204,7 @@ std::string StringUtil::reverseString(const char* pStr) } -std::string StringUtil::reverseString(std::string pStr) +std::string StringM::reverseString(std::string pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -211,7 +212,7 @@ std::string StringUtil::reverseString(std::string pStr) } -std::string StringUtil::reverseString(std::string& pStr) +std::string StringM::reverseString(std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -219,7 +220,7 @@ std::string StringUtil::reverseString(std::string& pStr) } -std::string StringUtil::reverseString(std::string&& pStr) +std::string StringM::reverseString(std::string&& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -227,7 +228,7 @@ std::string StringUtil::reverseString(std::string&& pStr) } -std::string StringUtil::reverseString(const std::string& pStr) +std::string StringM::reverseString(const std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -235,7 +236,7 @@ std::string StringUtil::reverseString(const std::string& pStr) } -std::string StringUtil::reverseString(std::string* pStr) +std::string StringM::reverseString(std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); @@ -243,7 +244,7 @@ std::string StringUtil::reverseString(std::string* pStr) } -std::string StringUtil::reverseString(const std::string* pStr) +std::string StringM::reverseString(const std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); @@ -251,7 +252,7 @@ std::string StringUtil::reverseString(const std::string* pStr) } -std::string StringUtil::revStrConstRefArg(const std::string_view& pStr) +std::string StringM::revStrConstRefArg(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -259,7 +260,7 @@ std::string StringUtil::revStrConstRefArg(const std::string_view& pStr) } -std::string StringUtil::revStrRValueRefArg(std::string_view&& pStr) +std::string StringM::revStrRValueRefArg(std::string_view&& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -267,7 +268,7 @@ std::string StringUtil::revStrRValueRefArg(std::string_view&& pStr) } -std::string StringUtil::revStrNonConstRefArg(std::string_view& pStr) +std::string StringM::revStrNonConstRefArg(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -275,7 +276,7 @@ std::string StringUtil::revStrNonConstRefArg(std::string_view& pStr) } -std::string StringUtil::revStrOverloadValCRef(std::string_view pStr) +std::string StringM::revStrOverloadValCRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -283,7 +284,7 @@ std::string StringUtil::revStrOverloadValCRef(std::string_view pStr) } -std::string StringUtil::revStrOverloadValCRef(const std::string_view& pStr) +std::string StringM::revStrOverloadValCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -291,7 +292,7 @@ std::string StringUtil::revStrOverloadValCRef(const std::string_view& pStr) } -std::string StringUtil::revStrOverloadValRef(std::string_view pStr) +std::string StringM::revStrOverloadValRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -299,7 +300,7 @@ std::string StringUtil::revStrOverloadValRef(std::string_view pStr) } -std::string StringUtil::revStrOverloadValRef(std::string_view& pStr) +std::string StringM::revStrOverloadValRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -307,7 +308,7 @@ std::string StringUtil::revStrOverloadValRef(std::string_view& pStr) } -std::string StringUtil::revStrOverloadRefAndCRef(std::string_view& pStr) +std::string StringM::revStrOverloadRefAndCRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -315,9 +316,145 @@ std::string StringUtil::revStrOverloadRefAndCRef(std::string_view& pStr) } -std::string StringUtil::revStrOverloadRefAndCRef(const std::string_view& pStr) +std::string StringM::revStrOverloadRefAndCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); return retStr + SUFFIX_ARG_std_string_view_clvref; +} + + +//---------------------------StringC-------------------------------- + +std::string StringC::reverseString() const +{ + return std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void + SUFFIX_const; +} + + +std::string StringC::reverseString(const char* pStr) const +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_const_char_ptr + SUFFIX_const; +} + + +std::string StringC::reverseString(std::string pStr) const +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string + SUFFIX_const; +} + + +std::string StringC::reverseString(std::string& pStr) const +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_lvref + SUFFIX_const; +} + + +std::string StringC::reverseString(std::string&& pStr) const +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_rvref + SUFFIX_const; +} + + +std::string StringC::reverseString(const std::string& pStr) const +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_clvref + SUFFIX_const; +} + + +std::string StringC::reverseString(std::string* pStr) const +{ + std::string retStr = *pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_ptr + SUFFIX_const; +} + + +std::string StringC::reverseString(const std::string* pStr) const +{ + std::string retStr = *pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_cptr + SUFFIX_const; +} + + +std::string StringC::revStrConstRefArg(const std::string_view& pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; +} + + +std::string StringC::revStrRValueRefArg(std::string_view&& pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_rvref + SUFFIX_const; +} + + +std::string StringC::revStrNonConstRefArg(std::string_view& pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; +} + + +std::string StringC::revStrOverloadValCRef(std::string_view pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view + SUFFIX_const; +} + + +std::string StringC::revStrOverloadValCRef(const std::string_view& pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; +} + + +std::string StringC::revStrOverloadValRef(std::string_view pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view + SUFFIX_const; +} + + +std::string StringC::revStrOverloadValRef(std::string_view& pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; +} + + +std::string StringC::revStrOverloadRefAndCRef(std::string_view& pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; +} + + +std::string StringC::revStrOverloadRefAndCRef(const std::string_view& pStr) const +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; } \ No newline at end of file diff --git a/CxxTestRegistration/inc/TestMirrorProvider.h b/CxxTestRegistration/inc/TestMirrorProvider.h index bb389737..eb839e53 100644 --- a/CxxTestRegistration/inc/TestMirrorProvider.h +++ b/CxxTestRegistration/inc/TestMirrorProvider.h @@ -20,7 +20,8 @@ namespace test_mirror static std::size_t person; static std::size_t library; static std::size_t calender; - static std::size_t string_util; + static std::size_t string_m; + static std::size_t string_c; static std::size_t char_t; static std::size_t int_t; diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 6d0a42c3..f1546eeb 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -125,16 +125,16 @@ namespace test_mirror rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), - rtl::type().record(StringUtil::struct_).build(), + rtl::type().record(StringM::struct_).build(), // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. - rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + rtl::type().member().method(str_reverseString).build(&StringM::reverseString), // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. - rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + rtl::type().member().method(str_reverseString).build(&StringM::reverseString), // Overloaded function, takes 'const char*' arguments. - rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + rtl::type().member().method(str_reverseString).build(&StringM::reverseString), // numereous other overloads. #if defined(__GNUC__) && !defined(__clang__) @@ -145,32 +145,80 @@ namespace test_mirror static_cast(reverseString) */ - rtl::type().member().method(str_reverseString) - .build(static_cast(&StringUtil::reverseString)), - rtl::type().member().method(str_reverseString) - .build(static_cast(&StringUtil::reverseString)), - rtl::type().member().method(str_reverseString) - .build(static_cast(&StringUtil::reverseString)), + rtl::type().member().method(str_reverseString) + .build(static_cast(&StringM::reverseString)), + rtl::type().member().method(str_reverseString) + .build(static_cast(&StringM::reverseString)), + rtl::type().member().method(str_reverseString) + .build(static_cast(&StringM::reverseString)), #else - rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), - rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), - rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + rtl::type().member().method(str_reverseString).build(&StringM::reverseString), + rtl::type().member().method(str_reverseString).build(&StringM::reverseString), + rtl::type().member().method(str_reverseString).build(&StringM::reverseString), #endif - rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), - rtl::type().member().method(str_reverseString).build(&StringUtil::reverseString), + rtl::type().member().method(str_reverseString).build(&StringM::reverseString), + rtl::type().member().method(str_reverseString).build(&StringM::reverseString), - rtl::type().member().method(str_revStrNonConstRefArg).build(&StringUtil::revStrNonConstRefArg), - rtl::type().member().method(str_revStrRValueRefArg).build(&StringUtil::revStrRValueRefArg), - rtl::type().member().method(str_revStrConstRefArg).build(&StringUtil::revStrConstRefArg), + rtl::type().member().method(str_revStrNonConstRefArg).build(&StringM::revStrNonConstRefArg), + rtl::type().member().method(str_revStrRValueRefArg).build(&StringM::revStrRValueRefArg), + rtl::type().member().method(str_revStrConstRefArg).build(&StringM::revStrConstRefArg), - rtl::type().member().method(str_revStrOverloadValRef).build(&StringUtil::revStrOverloadValRef), - rtl::type().member().method(str_revStrOverloadValRef).build(&StringUtil::revStrOverloadValRef), + rtl::type().member().method(str_revStrOverloadValRef).build(&StringM::revStrOverloadValRef), + rtl::type().member().method(str_revStrOverloadValRef).build(&StringM::revStrOverloadValRef), - rtl::type().member().method(str_revStrOverloadValCRef).build(&StringUtil::revStrOverloadValCRef), - rtl::type().member().method(str_revStrOverloadValCRef).build(&StringUtil::revStrOverloadValCRef), + rtl::type().member().method(str_revStrOverloadValCRef).build(&StringM::revStrOverloadValCRef), + rtl::type().member().method(str_revStrOverloadValCRef).build(&StringM::revStrOverloadValCRef), + + rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringM::revStrOverloadRefAndCRef), + rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringM::revStrOverloadRefAndCRef), + + rtl::type().record(StringC::struct_).build(), + + // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. + rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + + // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. + rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + + // Overloaded function, takes 'const char*' arguments. + rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + + // numereous other overloads. + #if defined(__GNUC__) && !defined(__clang__) + /* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: + + static_cast(reverseString) + */ + rtl::type().member().methodConst(str_reverseString) + .build(static_cast(&StringM::reverseString)), + rtl::type().member().methodConst(str_reverseString) + .build(static_cast(&StringM::reverseString)), + rtl::type().member().methodConst(str_reverseString) + .build(static_cast(&StringC::reverseString)), + #else + rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + #endif + rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + + rtl::type().member().methodConst(str_revStrNonConstRefArg).build(&StringC::revStrNonConstRefArg), + rtl::type().member().methodConst(str_revStrRValueRefArg).build(&StringC::revStrRValueRefArg), + rtl::type().member().methodConst(str_revStrConstRefArg).build(&StringC::revStrConstRefArg), + + rtl::type().member().methodConst(str_revStrOverloadValRef).build(&StringC::revStrOverloadValRef), + rtl::type().member().methodConst(str_revStrOverloadValRef).build(&StringC::revStrOverloadValRef), + + rtl::type().member().methodConst(str_revStrOverloadValCRef).build(&StringC::revStrOverloadValCRef), + rtl::type().member().methodConst(str_revStrOverloadValCRef).build(&StringC::revStrOverloadValCRef), + + rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StringC::revStrOverloadRefAndCRef), + rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StringC::revStrOverloadRefAndCRef), - rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringUtil::revStrOverloadRefAndCRef), - rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringUtil::revStrOverloadRefAndCRef), // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), @@ -182,7 +230,6 @@ namespace test_mirror rtl::type().ns(str_complex).function(str_setImaginary).build(complex::setImaginary), rtl::type().ns(str_complex).function(str_getMagnitude).build(complex::getMagnitude), - /* ----------------------------------------------------------------------------------------------------------- Registering user defined types. class/struct- generally termed as 'Record' as per LLVM's naming convention ----------------------------------------------------------------------------------------------------------- */ @@ -355,7 +402,8 @@ namespace test_mirror std::size_t reflected_id::date = rtl::detail::TypeId::get(); std::size_t reflected_id::event = rtl::detail::TypeId::get(); std::size_t reflected_id::calender = rtl::detail::TypeId::get(); - std::size_t reflected_id::string_util = rtl::detail::TypeId::get(); + std::size_t reflected_id::string_m = rtl::detail::TypeId::get(); + std::size_t reflected_id::string_c = rtl::detail::TypeId::get(); std::size_t reflected_id::int_t = rtl::detail::TypeId::get(); std::size_t reflected_id::char_t = rtl::detail::TypeId::get(); @@ -379,7 +427,8 @@ namespace test_mirror { person::class_, person }, { library::class_, library }, { calender::struct_, calender }, - { StringUtil::struct_, string_util } + { StringM::struct_, string_m }, + { StringC::struct_, string_c } }); const auto& itr = nameIdMap.find(pRecordName); diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index f00e4482..fcd472ed 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -10,6 +10,7 @@ Provides interface for Testing/Comparing the global functions & types (may or no */ namespace test_utils { + extern const char* SUFFIX_const; extern const char* SUFFIX_ARG_void; extern const char* SUFFIX_ARG_const_char_ptr; diff --git a/RTLTestRunApp/src/CMakeLists.txt b/RTLTestRunApp/src/CMakeLists.txt index 3a8c2c15..02d4f2b7 100644 --- a/RTLTestRunApp/src/CMakeLists.txt +++ b/RTLTestRunApp/src/CMakeLists.txt @@ -20,6 +20,7 @@ set(LOCAL_SOURCES_0 "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp" ) # Create a variable containing the source files for your target diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp new file mode 100644 index 00000000..64cf234d --- /dev/null +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp @@ -0,0 +1,361 @@ + +#include +#include + +#include "TestMirrorProvider.h" +#include "GlobalTestUtils.h" +#include "../CxxTestProps/inc/ComplexStrings.h" + +using namespace test_utils; +using namespace test_mirror; + +namespace rtl_tests +{ + TEST(StrictStaticTypeRtl_const_method, overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringC())(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringC())(STRB); + auto exp_str = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT<>() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringC())(); + auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_const_method, lvalue_ref_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + ASSERT_TRUE(optStringUtil); + + StringC target; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string lv_str = STRA; + std::string ret_str = reverse_string(target)(lv_str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_lvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + const std::string lv_str = STRA; + std::string ret_str = reverse_string(target)(lv_str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_clvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_const_method, rvalue_ref_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + ASSERT_TRUE(optStringUtil); + + StringC target; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_rvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } + } + + + TEST(StrictStaticTypeRtl_const_method, ptr_and_const_ptr_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + ASSERT_TRUE(optStringUtil); + + StringC target; + std::string str = STRA; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(&str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(&str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_const_method, std_string_method_call_with_known_signature) + { + std::optional stdStringClass = cxx::mirror().getRecord("std", "string"); + ASSERT_TRUE(stdStringClass); + + std::optional isStringEmpty = stdStringClass->getMethod("empty"); + ASSERT_TRUE(isStringEmpty); + { + rtl::method is_empty = isStringEmpty->recordT() + .argsT<>() + .returnT(); + EXPECT_FALSE(is_empty); + } { + rtl::method is_empty = isStringEmpty->recordT() + .argsT<>() + .returnT(); + ASSERT_TRUE(is_empty); + + EXPECT_TRUE(is_empty(std::string(""))()); + + EXPECT_FALSE(is_empty(std::string("not_empty"))()); + + EXPECT_TRUE(is_empty("")()); + + EXPECT_FALSE(is_empty("view_not_empty")()); + } + } + + + TEST(StrictStaticTypeRtl_const_method, std_string_view_method_call_with_known_signature) + { + std::optional stdStringViewClass = cxx::mirror().getRecord("std", "string_view"); + ASSERT_TRUE(stdStringViewClass); + + std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); + ASSERT_TRUE(isStringEmpty); + { + rtl::method is_empty = isStringEmpty->recordT() + .argsT<>() + .returnT(); + EXPECT_FALSE(is_empty); + } { + rtl::method is_empty = isStringEmpty->recordT() + .argsT<>() + .returnT(); + ASSERT_TRUE(is_empty); + + EXPECT_TRUE(is_empty(std::string(""))()); + + EXPECT_FALSE(is_empty(std::string("not_empty"))()); + + EXPECT_TRUE(is_empty(std::string_view(""))()); + + EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))()); + + EXPECT_TRUE(is_empty("")()); + + EXPECT_FALSE(is_empty("view_not_empty")()); + } + } + + + TEST(StrictStaticTypeRtl_const_method, distinct_functions_with_ref_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + ASSERT_TRUE(optStringUtil); + + StringC target; + std::string str = STRA; + { + std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); + ASSERT_TRUE(reverseString); + + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); + ASSERT_TRUE(reverseString); + + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + auto lvstr = std::string_view(str); + std::string ret_str = reverse_string(target)(lvstr); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); + ASSERT_TRUE(reverseString); + + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(str)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_const_method, overloads_with_ref_and_value_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + ASSERT_TRUE(optStringUtil); + + StringC target; + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string_view str = STRA; + std::string ret_str = reverse_string(target)(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_const_method, overloads_with_const_ref_and_value_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + ASSERT_TRUE(optStringUtil); + + StringC target; + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_const_method, overloads_with_ref_and_const_ref_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + ASSERT_TRUE(optStringUtil); + + StringC target; + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string_view str = STRA; + std::string ret_str = reverse_string(target)(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(target)(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } + } +} \ No newline at end of file diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp index 3d7cba39..f60e5548 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -13,46 +13,56 @@ namespace rtl_tests { TEST(StrictStaticTypeRtl_method, overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringUtil())(STRA); + std::string ret_str = reverse_string(StringM())(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringUtil())(STRB); + std::string ret_str = reverse_string(StringM())(STRB); auto exp_str = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() - .argsT<>() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT<>() + .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringUtil())(); + std::string ret_str = reverse_string(StringM())(); auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; EXPECT_EQ(ret_str, exp_str); } @@ -61,16 +71,16 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, lvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); - StringUtil target; + StringM target; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string lv_str = STRA; @@ -78,9 +88,9 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_lvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); const std::string lv_str = STRA; @@ -93,25 +103,25 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, rvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); - StringUtil target; + StringM target; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_rvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } } @@ -119,26 +129,26 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, ptr_and_const_ptr_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); - StringUtil target; + StringM target; std::string str = STRA; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(&str); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(&str); @@ -148,82 +158,20 @@ namespace rtl_tests } - TEST(StrictStaticTypeRtl_method, std_string_method_call_with_known_signature) - { - std::optional stdStringClass = cxx::mirror().getRecord("std", "string"); - ASSERT_TRUE(stdStringClass); - - std::optional isStringEmpty = stdStringClass->getMethod("empty"); - ASSERT_TRUE(isStringEmpty); - { - rtl::method is_empty = isStringEmpty->recordT() - .argsT<>() - .returnT(); - EXPECT_FALSE(is_empty); - } { - rtl::method is_empty = isStringEmpty->recordT() - .argsT<>() - .returnT(); - ASSERT_TRUE(is_empty); - - EXPECT_TRUE(is_empty(std::string(""))); - - EXPECT_FALSE(is_empty(std::string("not_empty"))); - - EXPECT_TRUE(is_empty("")); - - EXPECT_FALSE(is_empty("view_not_empty")); - } - } - - - TEST(StrictStaticTypeRtl_method, std_string_view_method_call_with_known_signature) - { - std::optional stdStringViewClass = cxx::mirror().getRecord("std", "string_view"); - ASSERT_TRUE(stdStringViewClass); - - std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); - ASSERT_TRUE(isStringEmpty); - { - rtl::method is_empty = isStringEmpty->recordT() - .argsT<>() - .returnT(); - EXPECT_FALSE(is_empty); - } { - rtl::method is_empty = isStringEmpty->recordT() - .argsT<>() - .returnT(); - ASSERT_TRUE(is_empty); - - EXPECT_TRUE(is_empty(std::string(""))); - - EXPECT_FALSE(is_empty(std::string("not_empty"))); - - EXPECT_TRUE(is_empty(std::string_view(""))); - - EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))); - - EXPECT_TRUE(is_empty("")); - - EXPECT_FALSE(is_empty("view_not_empty")); - } - } - - TEST(StrictStaticTypeRtl_method, distinct_functions_with_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); - StringUtil target; + StringM target; std::string str = STRA; { std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(str); @@ -233,9 +181,9 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); auto lvstr = std::string_view(str); @@ -246,9 +194,9 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(str)); @@ -260,25 +208,25 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); - StringUtil target; + StringM target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string_view str = STRA; @@ -291,25 +239,25 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_const_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); - StringUtil target; + StringM target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); @@ -321,16 +269,16 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_ref_and_const_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); - StringUtil target; + StringM target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string_view str = STRA; @@ -338,9 +286,9 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->recordT() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp index a0c5b6a5..f8907e87 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -43,24 +43,24 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, implicit_resolutions_to_call_by_value_overloads) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseStrOpt); EXPECT_FALSE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_FALSE(reverseString); { - auto [err, robj] = reverseString(StringUtil())(const_cast(STRA)); + auto [err, robj] = reverseString(StringM())(const_cast(STRA)); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } { - auto [err, robj] = reverseString.bind(StringUtil())(const_cast(STRA)); + auto [err, robj] = reverseString.bind(StringM())(const_cast(STRA)); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); @@ -68,12 +68,12 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { - auto [err, robj] = reverseString(StringUtil())(STRA); + auto [err, robj] = reverseString(StringM())(STRA); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -83,7 +83,7 @@ namespace rtl_tests std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; EXPECT_EQ(retStr, expStr); } { - auto [err, robj] = reverseString.bind(StringUtil())(STRA); + auto [err, robj] = reverseString.bind(StringM())(STRA); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -96,12 +96,12 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { - auto [err, robj] = reverseString(StringUtil())(STRA); + auto [err, robj] = reverseString(StringM())(STRA); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -111,7 +111,7 @@ namespace rtl_tests std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; EXPECT_EQ(retStr, expStr); } { - auto [err, robj] = reverseString.bind(StringUtil())(STRA); + auto [err, robj] = reverseString.bind(StringM())(STRA); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -124,13 +124,13 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { std::string str = STRA; - auto [err, robj] = reverseString(StringUtil())(&str); + auto [err, robj] = reverseString(StringM())(&str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -141,7 +141,7 @@ namespace rtl_tests EXPECT_EQ(retStr, expStr); } { std::string str = STRA; - auto [err, robj] = reverseString.bind(StringUtil())(&str); + auto [err, robj] = reverseString.bind(StringM())(&str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -154,13 +154,13 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { const std::string str = STRA; - auto [err, robj] = reverseString(StringUtil())(&str); + auto [err, robj] = reverseString(StringM())(&str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -171,7 +171,7 @@ namespace rtl_tests EXPECT_EQ(retStr, expStr); } { const std::string str = STRA; - auto [err, robj] = reverseString.bind(StringUtil())(&str); + auto [err, robj] = reverseString.bind(StringM())(&str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -184,12 +184,12 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature<>()); { - rtl::method reverseString = reverseStrOpt->recordT() - .argsT<>() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT<>() + .returnT<>(); EXPECT_TRUE(reverseString); { - auto [err, robj] = reverseString(StringUtil())(); + auto [err, robj] = reverseString(StringM())(); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -199,7 +199,7 @@ namespace rtl_tests std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; EXPECT_EQ(retStr, expStr); } { - auto [err, robj] = reverseString.bind(StringUtil())(); + auto [err, robj] = reverseString.bind(StringM())(); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -215,7 +215,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); @@ -228,11 +228,11 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; + StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // RTL chooses the safe by-value overload implicitly. The const-ref @@ -265,7 +265,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); @@ -278,11 +278,11 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; + StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Explicitly selecting the const-ref overload using .bind(). @@ -308,7 +308,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRef); @@ -321,11 +321,11 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; + StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Here also, RTL prioritizes the safe-by-value overload automatically @@ -355,7 +355,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRef); @@ -368,11 +368,11 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; + StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Explicitly selecting the non-const ref overload. @@ -397,7 +397,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, calling_non_overloaded_non_const_ref_argument) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrNonConstRefArg); @@ -410,11 +410,11 @@ namespace rtl_tests // Here no overloads exists, only non-const ref (T&) argument. EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; + StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); // Calls that may mutate user data (T&) require explicit intent. // Hence, the dispatcher returns 'ExplicitRefBindingRequired' error. @@ -445,7 +445,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, calling_non_overloaded_const_ref_argument) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrConstRefArg); @@ -458,11 +458,11 @@ namespace rtl_tests // Here no overloads exists, only non-const ref (T&) argument. EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; + StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // This call resolves to the const-ref overload (no other overloads exist), @@ -500,7 +500,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, calling_non_overloaded_rvalue_ref_argument) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrRValueRefArg); @@ -513,10 +513,10 @@ namespace rtl_tests // Here no overloads exists, only non-const ref (T&) argument. EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + StringM target; + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { auto [err, robj] = reverseString(target)(std::string_view(STRA)); @@ -537,7 +537,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_ref_and_cref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); @@ -550,11 +550,11 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; + StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Both T& and const T& overloads are viable for an lvalue argument. @@ -574,7 +574,7 @@ namespace rtl_tests TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_ref_and_cref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringUtil::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); @@ -587,11 +587,11 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringUtil target; + StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt->recordT() + .argsT() + .returnT<>(); EXPECT_TRUE(reverseString); { // Explicitly selecting the non-const ref overload. diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index a3fc55a9..2705efc1 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -16,6 +16,7 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_return.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const_erased_return.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function_erased_return.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const.h" ) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index 4224bc00..d97efea2 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -20,12 +20,33 @@ namespace rtl template struct function { - enum call_by + template requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept { - value = 0, - cref = 1, //const ref. - ncref = 2 //non-const ref. - }; + if (!(*this)) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + if (must_bind_refs()) [[unlikely]] { + return { error::ExplicitRefBindingRequired, RObject{} }; + } + + auto index = (m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (m_lambdas[index]->is_void()) + { + m_vhop[index](*m_lambdas[index], std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ m_rhop[index](*m_lambdas[index], std::forward(params)...), + m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } template struct perfect_fwd @@ -57,7 +78,7 @@ namespace rtl return { error::None, RObject{ fn.m_rhop[index](*fn.m_lambdas[index], std::forward(params)...), fn.m_lambdas.back()->get_return_id(), nullptr - } + } }; } } @@ -67,34 +88,6 @@ namespace rtl } }; - template requires (sizeof...(args_t) == sizeof...(signature_t)) - [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] - constexpr Return operator()(args_t&&...params) const noexcept - { - if (!(*this)) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; - } - - if (must_bind_refs()) [[unlikely]] { - return { error::ExplicitRefBindingRequired, RObject{} }; - } - - auto index = (m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); - if (m_lambdas[index]->is_void()) - { - m_vhop[index](*m_lambdas[index], std::forward(params)...); - return { error::None, RObject{} }; - } - else - { - return { error::None, - RObject{ m_rhop[index](*m_lambdas[index], std::forward(params)...), - m_lambdas.back()->get_return_id(), nullptr - } - }; - } - } - template requires (std::is_same_v, std::tuple>) constexpr const perfect_fwd bind() const noexcept { @@ -110,6 +103,13 @@ namespace rtl (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); } + enum call_by + { + value = 0, + cref = 1, //const ref. + ncref = 2 //non-const ref. + }; + private: using lambda_vt = std::function; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 5ca7d370..ec232ddc 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -45,7 +45,12 @@ namespace rtl }; [[gnu::hot]] - constexpr const invoker operator()(const record_t& p_target) const noexcept { + constexpr const invoker operator()(record_t& p_target) const noexcept { + return invoker{ m_functor, p_target }; + } + + [[gnu::hot]] + constexpr const invoker operator()(record_t&& p_target) const noexcept { return invoker{ m_functor, p_target }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index 734e9de4..8cf6a054 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -18,9 +18,9 @@ namespace rtl { template - struct method + struct method { - using fptr_t = return_t (record_t::*)(signature_t...) const; + using fptr_t = return_t(record_t::*)(signature_t...) const; constexpr auto f_ptr() const { return m_functor; @@ -30,10 +30,23 @@ namespace rtl return (m_functor != nullptr); } - template - [[nodiscard]] constexpr decltype(auto) operator()(const record_t& target, args_t&&...params) const noexcept + struct invoker { - return (target.*m_functor)(std::forward(params)...); + fptr_t functor; + const record_t& target; + + template + requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] + constexpr decltype(auto) operator()(args_t&&...params) const noexcept + { + return (target.*functor)(std::forward(params)...); + } + }; + + [[gnu::hot]] + constexpr const invoker operator()(const record_t& p_target) const noexcept { + return invoker{ m_functor, p_target }; } method(fptr_t p_functor) : m_functor(p_functor) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h new file mode 100644 index 00000000..bd7ebca0 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h @@ -0,0 +1,146 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_forward_decls.h" +#include "lambda_base.h" + +namespace rtl +{ + template + struct method + { + struct invoker + { + record_t& target; + const method& fn; + + template requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept + { + if (!fn) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + if (fn.must_bind_refs()) [[unlikely]] { + return { error::ExplicitRefBindingRequired, RObject{} }; + } + + auto index = (fn.m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index] (*(fn.m_lambdas[index]), target, std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ fn.m_rhop[index] (*(fn.m_lambdas[index]), target, std::forward(params)...), + fn.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + }; + + template + struct perfect_fwd + { + const record_t& target; + const method& fn; + + template + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept + { + if (!fn) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + auto signature_id = traits::uid>::value; + for (int index = 0; index < fn.m_lambdas.size(); index++) + { + if (fn.m_lambdas[index] != nullptr) + { + if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) + { + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index] (*fn.m_lambdas[index], target, std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ fn.m_rhop[index] (*fn.m_lambdas[index], target, std::forward(params)...), + fn.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + } + } + return { error::RefBindingMismatch, RObject{} }; + } + }; + + constexpr invoker operator()(record_t& p_target) const noexcept { + return invoker{ p_target, *this }; + } + + template + requires (std::is_same_v, std::tuple>) + constexpr const perfect_fwd bind(record_t& p_target) const noexcept { + return perfect_fwd{ p_target, *this }; + } + + constexpr operator bool() const noexcept { + return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } + + constexpr bool must_bind_refs() const noexcept { + return (m_lambdas[call_by::value] == nullptr && + (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); + } + + enum call_by + { + value = 0, + cref = 1, //const ref. + ncref = 2 //non-const ref. + }; + + private: + + using lambda_vt = std::function; + + using lambda_rt = std::function; + + std::vector m_rhop = {}; + + std::vector m_vhop = {}; + + std::vector m_lambdas = {}; + + GETTER_REF(std::vector, _rhop, m_rhop) + GETTER_REF(std::vector, _vhop, m_vhop) + GETTER_REF(std::vector, _overloads, m_lambdas) + + template + friend struct detail::HopMethod; + + static_assert((!std::is_reference_v && ...), + "rtl::method<...>: any type cannot be specified as reference here."); + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h index 6dd74279..60522c2f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -48,7 +48,7 @@ namespace rtl return { error::None, RObject{ fn.m_rhop[index] (*(fn.m_lambdas[index]), target, std::forward(params)...), fn.m_lambdas.back()->get_return_id(), nullptr - } + } }; } } @@ -85,7 +85,7 @@ namespace rtl return { error::None, RObject{ fn.m_rhop[index] (*fn.m_lambdas[index], target, std::forward(params)...), fn.m_lambdas.back()->get_return_id(), nullptr - } + } }; } } From 4b36853af87e75fae3bb57e3f6532773b2cad76d Mon Sep 17 00:00:00 2001 From: neeraj Date: Fri, 17 Oct 2025 19:36:15 +0530 Subject: [PATCH 097/148] fixed gcc overload resolution error while registration. --- CxxTestRegistration/src/TestMirrorProvider.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index f1546eeb..65f13497 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -193,9 +193,9 @@ namespace test_mirror static_cast(reverseString) */ rtl::type().member().methodConst(str_reverseString) - .build(static_cast(&StringM::reverseString)), + .build(static_cast(&StringC::reverseString)), rtl::type().member().methodConst(str_reverseString) - .build(static_cast(&StringM::reverseString)), + .build(static_cast(&StringC::reverseString)), rtl::type().member().methodConst(str_reverseString) .build(static_cast(&StringC::reverseString)), #else From 541e1a15096793d1fac0492a925f513a89a0f89c Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 18 Oct 2025 00:24:28 +0530 Subject: [PATCH 098/148] test case additions, minor refactor/renaming. --- CxxTestProps/src/ComplexStrings.cpp | 126 +++++------ CxxTestUtils/inc/GlobalTestUtils.h | 28 +-- .../src/ReflectedCallKnownReturn.cpp | 4 +- .../src/ReflectedCallUnknownReturn.cpp | 4 +- .../NameSpaceGlobalsTests.cpp | 6 +- .../StrictStaticTypeDispatch_ConstMethod.cpp | 212 +++++++++++------- .../StrictStaticTypeDispatch_Function.cpp | 34 +-- .../StrictStaticTypeDispatch_Method.cpp | 115 ++++++---- .../BasicTypeErasedDispatch_Function.cpp | 44 ++-- .../BasicTypeErasedDispatch_Method.cpp | 74 +++--- ReflectionTemplateLib/rtl/inc/Method.h | 2 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 2 +- 12 files changed, 367 insertions(+), 284 deletions(-) diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/ComplexStrings.cpp index ed6289c9..055b7c79 100644 --- a/CxxTestProps/src/ComplexStrings.cpp +++ b/CxxTestProps/src/ComplexStrings.cpp @@ -31,33 +31,33 @@ std::string getComplexNumAsString() namespace test_utils { + const char* SUFFIX_void = "_void"; const char* SUFFIX_const = "_const"; - const char* SUFFIX_ARG_void = "_arg_void"; - const char* SUFFIX_ARG_const_char_ptr = "_arg_const_char_*"; + const char* SUFFIX_const_char_ptr = "_const_char_*"; - const char* SUFFIX_ARG_std_string = "_arg_std::string"; + const char* SUFFIX_std_string = "_std::string"; - const char* SUFFIX_ARG_std_string_ptr = "_arg_std::string*"; - const char* SUFFIX_ARG_std_string_cptr = "_arg_const_std::string*"; + const char* SUFFIX_std_string_ptr = "_std::string*"; + const char* SUFFIX_std_string_cptr = "_const_std::string*"; - const char* SUFFIX_ARG_std_string_lvref = "_arg_std::string&"; - const char* SUFFIX_ARG_std_string_clvref = "_arg_const_std::string&"; + const char* SUFFIX_std_string_lvref = "_std::string&"; + const char* SUFFIX_std_string_clvref = "_const_std::string&"; - const char* SUFFIX_ARG_std_string_rvref = "_arg_std::string&&"; + const char* SUFFIX_std_string_rvref = "_std::string&&"; const char* REV_STR_VOID_RET = "func_reverseString(void)->[return_str]"; - const char* SUFFIX_ARG_std_string_view = "_arg_std::string_view"; - const char* SUFFIX_ARG_std_string_view_lvref = "_arg_std::string_view&"; - const char* SUFFIX_ARG_std_string_view_rvref = "_arg_std::string_view&&"; - const char* SUFFIX_ARG_std_string_view_clvref = "_arg_const_std::string_view&"; + const char* SUFFIX_std_string_view = "_arg_std::string_view"; + const char* SUFFIX_std_string_view_lvref = "_arg_std::string_view&"; + const char* SUFFIX_std_string_view_rvref = "_arg_std::string_view&&"; + const char* SUFFIX_std_string_view_clvref = "_arg_const_std::string_view&"; } using namespace test_utils; std::string reverseString() { - return std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + return std::string(REV_STR_VOID_RET) + SUFFIX_void; } @@ -65,7 +65,7 @@ std::string reverseString(const char* pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_const_char_ptr; + return retStr + SUFFIX_const_char_ptr; } @@ -73,7 +73,7 @@ std::string reverseString(std::string pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string; + return retStr + SUFFIX_std_string; } @@ -81,7 +81,7 @@ std::string reverseString(std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_lvref; + return retStr + SUFFIX_std_string_lvref; } @@ -89,7 +89,7 @@ std::string reverseString(std::string&& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_rvref; + return retStr + SUFFIX_std_string_rvref; } @@ -97,7 +97,7 @@ std::string reverseString(const std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_clvref; + return retStr + SUFFIX_std_string_clvref; } @@ -105,7 +105,7 @@ std::string reverseString(std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_ptr; + return retStr + SUFFIX_std_string_ptr; } @@ -113,7 +113,7 @@ std::string reverseString(const std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_cptr; + return retStr + SUFFIX_std_string_cptr; } @@ -121,7 +121,7 @@ std::string revStrConstRefArg(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref; + return retStr + SUFFIX_std_string_view_clvref; } @@ -129,7 +129,7 @@ std::string revStrRValueRefArg(std::string_view&& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_rvref; + return retStr + SUFFIX_std_string_view_rvref; } @@ -137,7 +137,7 @@ std::string revStrNonConstRefArg(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref; + return retStr + SUFFIX_std_string_view_lvref; } @@ -145,7 +145,7 @@ std::string revStrOverloadValCRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view; + return retStr + SUFFIX_std_string_view; } @@ -153,7 +153,7 @@ std::string revStrOverloadValCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref; + return retStr + SUFFIX_std_string_view_clvref; } @@ -161,7 +161,7 @@ std::string revStrOverloadValRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view; + return retStr + SUFFIX_std_string_view; } @@ -169,7 +169,7 @@ std::string revStrOverloadValRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref; + return retStr + SUFFIX_std_string_view_lvref; } @@ -177,7 +177,7 @@ std::string revStrOverloadRefAndCRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref; + return retStr + SUFFIX_std_string_view_lvref; } @@ -185,14 +185,14 @@ std::string revStrOverloadRefAndCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref; + return retStr + SUFFIX_std_string_view_clvref; } //---------------------------StringM-------------------------------- std::string StringM::reverseString() { - return std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + return std::string(REV_STR_VOID_RET) + SUFFIX_void; } @@ -200,7 +200,7 @@ std::string StringM::reverseString(const char* pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_const_char_ptr; + return retStr + SUFFIX_const_char_ptr; } @@ -208,7 +208,7 @@ std::string StringM::reverseString(std::string pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string; + return retStr + SUFFIX_std_string; } @@ -216,7 +216,7 @@ std::string StringM::reverseString(std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_lvref; + return retStr + SUFFIX_std_string_lvref; } @@ -224,7 +224,7 @@ std::string StringM::reverseString(std::string&& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_rvref; + return retStr + SUFFIX_std_string_rvref; } @@ -232,7 +232,7 @@ std::string StringM::reverseString(const std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_clvref; + return retStr + SUFFIX_std_string_clvref; } @@ -240,7 +240,7 @@ std::string StringM::reverseString(std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_ptr; + return retStr + SUFFIX_std_string_ptr; } @@ -248,7 +248,7 @@ std::string StringM::reverseString(const std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_cptr; + return retStr + SUFFIX_std_string_cptr; } @@ -256,7 +256,7 @@ std::string StringM::revStrConstRefArg(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref; + return retStr + SUFFIX_std_string_view_clvref; } @@ -264,7 +264,7 @@ std::string StringM::revStrRValueRefArg(std::string_view&& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_rvref; + return retStr + SUFFIX_std_string_view_rvref; } @@ -272,7 +272,7 @@ std::string StringM::revStrNonConstRefArg(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref; + return retStr + SUFFIX_std_string_view_lvref; } @@ -280,7 +280,7 @@ std::string StringM::revStrOverloadValCRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view; + return retStr + SUFFIX_std_string_view; } @@ -288,7 +288,7 @@ std::string StringM::revStrOverloadValCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref; + return retStr + SUFFIX_std_string_view_clvref; } @@ -296,7 +296,7 @@ std::string StringM::revStrOverloadValRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view; + return retStr + SUFFIX_std_string_view; } @@ -304,7 +304,7 @@ std::string StringM::revStrOverloadValRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref; + return retStr + SUFFIX_std_string_view_lvref; } @@ -312,7 +312,7 @@ std::string StringM::revStrOverloadRefAndCRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref; + return retStr + SUFFIX_std_string_view_lvref; } @@ -320,7 +320,7 @@ std::string StringM::revStrOverloadRefAndCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref; + return retStr + SUFFIX_std_string_view_clvref; } @@ -328,7 +328,7 @@ std::string StringM::revStrOverloadRefAndCRef(const std::string_view& pStr) std::string StringC::reverseString() const { - return std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void + SUFFIX_const; + return std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_const; } @@ -336,7 +336,7 @@ std::string StringC::reverseString(const char* pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_const_char_ptr + SUFFIX_const; + return retStr + SUFFIX_const_char_ptr + SUFFIX_const; } @@ -344,7 +344,7 @@ std::string StringC::reverseString(std::string pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string + SUFFIX_const; + return retStr + SUFFIX_std_string + SUFFIX_const; } @@ -352,7 +352,7 @@ std::string StringC::reverseString(std::string& pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_lvref + SUFFIX_const; + return retStr + SUFFIX_std_string_lvref + SUFFIX_const; } @@ -360,7 +360,7 @@ std::string StringC::reverseString(std::string&& pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_rvref + SUFFIX_const; + return retStr + SUFFIX_std_string_rvref + SUFFIX_const; } @@ -368,7 +368,7 @@ std::string StringC::reverseString(const std::string& pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_clvref + SUFFIX_const; + return retStr + SUFFIX_std_string_clvref + SUFFIX_const; } @@ -376,7 +376,7 @@ std::string StringC::reverseString(std::string* pStr) const { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_ptr + SUFFIX_const; + return retStr + SUFFIX_std_string_ptr + SUFFIX_const; } @@ -384,7 +384,7 @@ std::string StringC::reverseString(const std::string* pStr) const { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_cptr + SUFFIX_const; + return retStr + SUFFIX_std_string_cptr + SUFFIX_const; } @@ -392,7 +392,7 @@ std::string StringC::revStrConstRefArg(const std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + return retStr + SUFFIX_std_string_view_clvref + SUFFIX_const; } @@ -400,7 +400,7 @@ std::string StringC::revStrRValueRefArg(std::string_view&& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_rvref + SUFFIX_const; + return retStr + SUFFIX_std_string_view_rvref + SUFFIX_const; } @@ -408,7 +408,7 @@ std::string StringC::revStrNonConstRefArg(std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + return retStr + SUFFIX_std_string_view_lvref + SUFFIX_const; } @@ -416,7 +416,7 @@ std::string StringC::revStrOverloadValCRef(std::string_view pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view + SUFFIX_const; + return retStr + SUFFIX_std_string_view + SUFFIX_const; } @@ -424,7 +424,7 @@ std::string StringC::revStrOverloadValCRef(const std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + return retStr + SUFFIX_std_string_view_clvref + SUFFIX_const; } @@ -432,7 +432,7 @@ std::string StringC::revStrOverloadValRef(std::string_view pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view + SUFFIX_const; + return retStr + SUFFIX_std_string_view + SUFFIX_const; } @@ -440,7 +440,7 @@ std::string StringC::revStrOverloadValRef(std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + return retStr + SUFFIX_std_string_view_lvref + SUFFIX_const; } @@ -448,7 +448,7 @@ std::string StringC::revStrOverloadRefAndCRef(std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + return retStr + SUFFIX_std_string_view_lvref + SUFFIX_const; } @@ -456,5 +456,5 @@ std::string StringC::revStrOverloadRefAndCRef(const std::string_view& pStr) cons { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); - return retStr + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + return retStr + SUFFIX_std_string_view_clvref + SUFFIX_const; } \ No newline at end of file diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index fcd472ed..b1bf09b0 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -11,20 +11,20 @@ Provides interface for Testing/Comparing the global functions & types (may or no namespace test_utils { extern const char* SUFFIX_const; - extern const char* SUFFIX_ARG_void; - extern const char* SUFFIX_ARG_const_char_ptr; - - extern const char* SUFFIX_ARG_std_string; - extern const char* SUFFIX_ARG_std_string_ptr; - extern const char* SUFFIX_ARG_std_string_cptr; - extern const char* SUFFIX_ARG_std_string_lvref; - extern const char* SUFFIX_ARG_std_string_rvref; - extern const char* SUFFIX_ARG_std_string_clvref; - - extern const char* SUFFIX_ARG_std_string_view; - extern const char* SUFFIX_ARG_std_string_view_lvref; - extern const char* SUFFIX_ARG_std_string_view_rvref; - extern const char* SUFFIX_ARG_std_string_view_clvref; + extern const char* SUFFIX_void; + extern const char* SUFFIX_const_char_ptr; + + extern const char* SUFFIX_std_string; + extern const char* SUFFIX_std_string_ptr; + extern const char* SUFFIX_std_string_cptr; + extern const char* SUFFIX_std_string_lvref; + extern const char* SUFFIX_std_string_rvref; + extern const char* SUFFIX_std_string_clvref; + + extern const char* SUFFIX_std_string_view; + extern const char* SUFFIX_std_string_view_lvref; + extern const char* SUFFIX_std_string_view_rvref; + extern const char* SUFFIX_std_string_view_clvref; extern const char* REV_STR_VOID_RET; diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 2d4c376b..6016e541 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -55,7 +55,7 @@ namespace std::cerr << "[02] error: method 'Node::getMessage' not found."; std::abort(); } - return method->recordT().argsT().returnT(); + return method->targetT().argsT().returnT(); }(); static const rtl::method sendMessageNode = []() @@ -71,7 +71,7 @@ namespace std::cerr << "[3] error: method 'Node::sendMessage' not found."; std::abort(); } - return method->recordT().argsT().returnT(); + return method->targetT().argsT().returnT(); }(); } diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index b785d08f..d104c724 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -51,7 +51,7 @@ namespace std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; std::abort(); } - return method->recordT().argsT().returnT<>(); + return method->targetT().argsT().returnT<>(); }(); static rtl::method NodeSendMessage = []() @@ -67,7 +67,7 @@ namespace std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; std::abort(); } - return method->recordT().argsT().returnT<>(); + return method->targetT().argsT().returnT<>(); }(); diff --git a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp index 7f2d6560..8b277ff9 100644 --- a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp @@ -220,7 +220,7 @@ namespace rtl_tests EXPECT_TRUE(ret.canViewAs()); string retStr = ret.view()->get(); - auto expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + auto expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; EXPECT_EQ(retStr, expStr); } { //STRB's type is 'const char*', function accepts 'string', @@ -232,7 +232,7 @@ namespace rtl_tests EXPECT_TRUE(ret.canViewAs()); string retStr = ret.view()->get(); - auto expStr = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; + auto expStr = std::string(STRB_REVERSE) + SUFFIX_std_string; EXPECT_EQ(retStr, expStr); } { rtl::function reverseStr = reverseStringOpt->argsT<>().returnT<>(); @@ -243,7 +243,7 @@ namespace rtl_tests EXPECT_TRUE(ret.canViewAs()); string retStr = ret.view()->get(); - auto expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + auto expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(retStr, expStr); } } diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp index 64cf234d..f0c38898 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp @@ -11,6 +11,39 @@ using namespace test_mirror; namespace rtl_tests { + TEST(StrictStaticTypeRtl_const_method, std_string_view_method_call_with_known_signature) + { + std::optional stdStringViewClass = cxx::mirror().getRecord("std", "string_view"); + ASSERT_TRUE(stdStringViewClass); + + std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); + ASSERT_TRUE(isStringEmpty); + { + rtl::method is_empty = isStringEmpty->targetT() + .argsT<>() + .returnT(); + EXPECT_FALSE(is_empty); + } { + rtl::method is_empty = isStringEmpty->targetT() + .argsT<>() + .returnT(); + ASSERT_TRUE(is_empty); + + EXPECT_TRUE(is_empty(std::string(""))()); + + EXPECT_FALSE(is_empty(std::string("not_empty"))()); + + EXPECT_TRUE(is_empty(std::string_view(""))()); + + EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))()); + + EXPECT_TRUE(is_empty("")()); + + EXPECT_FALSE(is_empty("view_not_empty")()); + } + } + + TEST(StrictStaticTypeRtl_const_method, overload_resolution_with_known_signatures) { std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); @@ -19,51 +52,51 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringC())(STRA); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr + SUFFIX_const; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringC())(STRB); - auto exp_str = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string + SUFFIX_const; + auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT<>() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringC())(); - auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void + SUFFIX_const; + auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } } @@ -74,28 +107,59 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); ASSERT_TRUE(optStringUtil); - StringC target; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + //argument lvalue-ref. + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - + //non-const target + StringC target; std::string lv_str = STRA; std::string ret_str = reverse_string(target)(lv_str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_lvref + SUFFIX_const; + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_lvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + //argument const-lvalue-ref. + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - + //non-const target + StringC target; const std::string lv_str = STRA; std::string ret_str = reverse_string(target)(lv_str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_clvref + SUFFIX_const; + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_clvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + //argument lvalue-ref. + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + //const target. + const StringC target; + std::string lv_str = STRA; + std::string ret_str = reverse_string(target)(lv_str); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_lvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + //argument const-lvalue-ref. + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + //const target. + const StringC target; + const std::string lv_str = STRA; + std::string ret_str = reverse_string(target)(lv_str); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_clvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } } @@ -106,20 +170,32 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); ASSERT_TRUE(optStringUtil); - StringC target; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(target)(STRA); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_rvref + SUFFIX_const; - EXPECT_EQ(ret_str, exp_str); + { + //non-const target. + StringC target; + std::string ret_str = reverse_string(target)(STRA); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_rvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + //const-target + const StringC target; + std::string ret_str = reverse_string(target)(STRA); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_rvref + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); @@ -137,22 +213,22 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(&str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr + SUFFIX_const; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(&str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr + SUFFIX_const; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } } @@ -166,12 +242,12 @@ namespace rtl_tests std::optional isStringEmpty = stdStringClass->getMethod("empty"); ASSERT_TRUE(isStringEmpty); { - rtl::method is_empty = isStringEmpty->recordT() + rtl::method is_empty = isStringEmpty->targetT() .argsT<>() .returnT(); EXPECT_FALSE(is_empty); } { - rtl::method is_empty = isStringEmpty->recordT() + rtl::method is_empty = isStringEmpty->targetT() .argsT<>() .returnT(); ASSERT_TRUE(is_empty); @@ -187,39 +263,6 @@ namespace rtl_tests } - TEST(StrictStaticTypeRtl_const_method, std_string_view_method_call_with_known_signature) - { - std::optional stdStringViewClass = cxx::mirror().getRecord("std", "string_view"); - ASSERT_TRUE(stdStringViewClass); - - std::optional isStringEmpty = stdStringViewClass->getMethod("empty"); - ASSERT_TRUE(isStringEmpty); - { - rtl::method is_empty = isStringEmpty->recordT() - .argsT<>() - .returnT(); - EXPECT_FALSE(is_empty); - } { - rtl::method is_empty = isStringEmpty->recordT() - .argsT<>() - .returnT(); - ASSERT_TRUE(is_empty); - - EXPECT_TRUE(is_empty(std::string(""))()); - - EXPECT_FALSE(is_empty(std::string("not_empty"))()); - - EXPECT_TRUE(is_empty(std::string_view(""))()); - - EXPECT_FALSE(is_empty(std::string_view("view_not_empty"))()); - - EXPECT_TRUE(is_empty("")()); - - EXPECT_FALSE(is_empty("view_not_empty")()); - } - } - - TEST(StrictStaticTypeRtl_const_method, distinct_functions_with_ref_args_call_with_known_signature) { std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); @@ -231,38 +274,42 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); + StringC target; std::string ret_str = reverse_string(target)(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); auto lvstr = std::string_view(str); std::string ret_str = reverse_string(target)(lvstr); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(str)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref + SUFFIX_const; + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_rvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } } @@ -277,23 +324,24 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view + SUFFIX_const; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - + std::string_view str = STRA; std::string ret_str = reverse_string(target)(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } } @@ -308,22 +356,22 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - + std::string ret_str = reverse_string(target)(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view + SUFFIX_const; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } } @@ -338,23 +386,23 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string_view str = STRA; std::string ret_str = reverse_string(target)(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref + SUFFIX_const; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref + SUFFIX_const; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } } diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp index 7daea564..c5d96267 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp @@ -112,21 +112,21 @@ namespace rtl_tests ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(STRA); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(STRB); - auto exp_str = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; + auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string; EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT<>().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(); - auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(ret_str, exp_str); } } @@ -142,7 +142,7 @@ namespace rtl_tests std::string lv_str = STRA; std::string ret_str = reverse_string(lv_str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_lvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_lvref; EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); @@ -150,7 +150,7 @@ namespace rtl_tests const std::string lv_str = STRA; std::string ret_str = reverse_string(lv_str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_clvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_clvref; EXPECT_EQ(ret_str, exp_str); } } @@ -165,7 +165,7 @@ namespace rtl_tests ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(STRA); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_rvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_rvref; EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); @@ -184,14 +184,14 @@ namespace rtl_tests ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(&str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(&str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; EXPECT_EQ(ret_str, exp_str); } } @@ -208,7 +208,7 @@ namespace rtl_tests ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(ret_str, exp_str); } { std::optional reverseString = cxx::mirror().getFunction(str_revStrNonConstRefArg); @@ -219,7 +219,7 @@ namespace rtl_tests auto lvstr = std::string_view(str); std::string ret_str = reverse_string(lvstr); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } { std::optional reverseString = cxx::mirror().getFunction(str_revStrRValueRefArg); @@ -229,7 +229,7 @@ namespace rtl_tests ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(std::string_view(str)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_rvref; EXPECT_EQ(ret_str, exp_str); } } @@ -244,7 +244,7 @@ namespace rtl_tests ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); @@ -252,7 +252,7 @@ namespace rtl_tests std::string_view str = STRA; std::string ret_str = reverse_string(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } } @@ -267,14 +267,14 @@ namespace rtl_tests ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(ret_str, exp_str); } } @@ -290,14 +290,14 @@ namespace rtl_tests std::string_view str = STRA; std::string ret_str = reverse_string(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } { rtl::function reverse_string = reverseString->argsT().returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(ret_str, exp_str); } } diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp index f60e5548..8b7c417b 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -19,51 +19,51 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringM())(STRA); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringM())(STRB); - auto exp_str = std::string(STRB_REVERSE) + SUFFIX_ARG_std_string; + auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT<>() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(StringM())(); - auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(ret_str, exp_str); } } @@ -74,28 +74,63 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); + //non-const target. StringM target; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + //argument lvalue-ref + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - std::string lv_str = STRA; std::string ret_str = reverse_string(target)(lv_str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_lvref; + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_lvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + //argument const-lvalue-ref + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); const std::string lv_str = STRA; std::string ret_str = reverse_string(target)(lv_str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_clvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_clvref; + EXPECT_EQ(ret_str, exp_str); + } { + //argument lvalue-ref + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + //const-target. + const StringM& c_target = target; + std::string lv_str = STRA; + + // compile error - + // std::string ret_str = reverse_string(const_target)(lv_str); + std::string ret_str = reverse_string(const_cast(c_target))(lv_str); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_lvref; + EXPECT_EQ(ret_str, exp_str); + } { + //argument const-lvalue-ref + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + //const-target. + const StringM& c_target = target; + std::string lv_str = STRA; + + // compile error - + // std::string ret_str = reverse_string(c_target)(lv_str); + std::string ret_str = reverse_string(const_cast(c_target))(lv_str); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_clvref; EXPECT_EQ(ret_str, exp_str); } } @@ -110,16 +145,16 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(STRA); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_rvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_rvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); @@ -137,22 +172,22 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(&str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(&str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; EXPECT_EQ(ret_str, exp_str); } } @@ -169,38 +204,38 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(ret_str, exp_str); } { std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); auto lvstr = std::string_view(str); std::string ret_str = reverse_string(target)(lvstr); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } { std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(str)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_rvref; EXPECT_EQ(ret_str, exp_str); } } @@ -215,23 +250,23 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string_view str = STRA; std::string ret_str = reverse_string(target)(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } } @@ -246,22 +281,22 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(ret_str, exp_str); } } @@ -276,23 +311,23 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string_view str = STRA; std::string ret_str = reverse_string(target)(str); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->recordT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(target)(std::string_view(STRA)); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(ret_str, exp_str); } } diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp index 4d4bf5e8..352c51ad 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp @@ -72,7 +72,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind()(STRA); @@ -82,7 +82,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; EXPECT_EQ(retStr, expStr); } } @@ -98,7 +98,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind()(STRA); @@ -108,7 +108,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; EXPECT_EQ(retStr, expStr); } } @@ -125,7 +125,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; EXPECT_EQ(retStr, expStr); } { std::string str = STRA; @@ -136,7 +136,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; EXPECT_EQ(retStr, expStr); } } @@ -153,7 +153,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; EXPECT_EQ(retStr, expStr); } { const std::string str = STRA; @@ -164,7 +164,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; EXPECT_EQ(retStr, expStr); } } @@ -180,7 +180,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind()(); @@ -190,7 +190,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(retStr, expStr); } } @@ -224,7 +224,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(retStr, expStr); } { // explicit call by value resolution. @@ -235,7 +235,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(retStr, expStr); } } @@ -267,7 +267,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind()(str); @@ -302,7 +302,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(retStr, expStr); } { // explicit call by value resolution. @@ -312,7 +312,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(retStr, expStr); } } @@ -343,7 +343,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind()(str); @@ -390,7 +390,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(retStr, expStr); } } @@ -421,7 +421,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(retStr, expStr); } { // explicit binding must also behave the same way. @@ -432,7 +432,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(retStr, expStr); } { // explicit binding to non-const ref returns error. @@ -470,7 +470,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_rvref; EXPECT_EQ(retStr, expStr); } } @@ -531,7 +531,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(retStr, expStr); } { // Explicitly selecting the const ref overload. @@ -545,7 +545,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(retStr, expStr); } } diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp index f8907e87..e441091c 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -50,7 +50,7 @@ namespace rtl_tests ASSERT_TRUE(reverseStrOpt); EXPECT_FALSE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_FALSE(reverseString); @@ -68,7 +68,7 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -80,7 +80,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind(StringM())(STRA); @@ -90,13 +90,13 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_const_char_ptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; EXPECT_EQ(retStr, expStr); } } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -108,7 +108,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind(StringM())(STRA); @@ -118,13 +118,13 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; EXPECT_EQ(retStr, expStr); } } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -137,7 +137,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; EXPECT_EQ(retStr, expStr); } { std::string str = STRA; @@ -148,13 +148,13 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_ptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; EXPECT_EQ(retStr, expStr); } } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -167,7 +167,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; EXPECT_EQ(retStr, expStr); } { const std::string str = STRA; @@ -178,13 +178,13 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_cptr; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; EXPECT_EQ(retStr, expStr); } } EXPECT_TRUE(reverseStrOpt->hasSignature<>()); { - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT<>() .returnT<>(); EXPECT_TRUE(reverseString); @@ -196,7 +196,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind(StringM())(); @@ -206,7 +206,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_ARG_void; + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(retStr, expStr); } } @@ -230,7 +230,7 @@ namespace rtl_tests StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -246,7 +246,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(retStr, expStr); } { // explicit call by value resolution. @@ -257,7 +257,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(retStr, expStr); } } @@ -280,7 +280,7 @@ namespace rtl_tests StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -295,7 +295,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind(target)(str); @@ -323,7 +323,7 @@ namespace rtl_tests StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -337,7 +337,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(retStr, expStr); } { // explicit call by value resolution. @@ -347,7 +347,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(retStr, expStr); } } @@ -370,7 +370,7 @@ namespace rtl_tests StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -385,7 +385,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(retStr, expStr); } { auto [err, robj] = reverseString.bind(target)(str); @@ -412,7 +412,7 @@ namespace rtl_tests StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -437,7 +437,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(retStr, expStr); } } @@ -460,7 +460,7 @@ namespace rtl_tests StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -474,7 +474,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(retStr, expStr); } { // explicit binding must also behave the same way. @@ -485,7 +485,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(retStr, expStr); } { // explicit binding to non-const ref returns error. @@ -514,7 +514,7 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); StringM target; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -529,7 +529,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_rvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_rvref; EXPECT_EQ(retStr, expStr); } } @@ -552,7 +552,7 @@ namespace rtl_tests StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -589,7 +589,7 @@ namespace rtl_tests StringM target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->recordT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -602,7 +602,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_lvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(retStr, expStr); } { // Explicitly selecting the const ref overload. @@ -616,7 +616,7 @@ namespace rtl_tests ASSERT_TRUE(robj.canViewAs()); const std::string& retStr = robj.view()->get(); - std::string expStr = std::string(STRA_REVERSE) + SUFFIX_ARG_std_string_view_clvref; + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref; EXPECT_EQ(retStr, expStr); } } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 58e1da47..04f7b75b 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -61,7 +61,7 @@ namespace rtl { constexpr const detail::HopFunction argsT() const = delete; template - constexpr detail::Hopper recordT() const; + constexpr detail::Hopper targetT() const; //indicates if a particular set of arguments accepted by the functor associated with it. template diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 7f0ae7e6..1542c1eb 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -30,7 +30,7 @@ namespace rtl template - inline constexpr detail::Hopper Method::recordT() const + inline constexpr detail::Hopper Method::targetT() const { return detail::Hopper{ getFunctorIds() }; } From ea0b4fd769c9cae5a6c91e813eba0c685ea76ad0 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 20 Oct 2025 20:46:31 +0530 Subject: [PATCH 099/148] design improvements, phasing old one out. --- CxxTestProps/inc/Complex.h | 10 + .../inc/{ComplexStrings.h => StringOps.h} | 22 +-- CxxTestProps/src/CMakeLists.txt | 6 +- CxxTestProps/src/Complex.cpp | 29 +++ CxxTestProps/src/Complex.h | 0 .../src/{ComplexStrings.cpp => StringOps.cpp} | 36 +--- .../src/TestMirrorProvider.cpp | 3 +- RTLTestRunApp/src/CMakeLists.txt | 3 + .../CxxMirrorTests/CxxMirrorThreadingTest.cpp | 3 +- .../StrictStaticTypeDispatch_ConstMethod.cpp | 3 +- .../StrictStaticTypeDispatch_Method.cpp | 2 +- .../StrictStaticTypeDispatch_StaticMethod.cpp | 0 .../BasicTypeErasedDispatch_ConstMethod.cpp | 0 .../BasicTypeErasedDispatch_Method.cpp | 2 +- .../BasicTypeErasedDispatch_StaticMethod.cpp | 0 .../rtl/builder/ReflectionBuilder.hpp | 14 +- .../rtl/builder/SetupFunction.h | 2 +- .../rtl/builder/SetupFunction.hpp | 40 ++-- .../rtl/builder/SetupMethod.h | 4 +- .../rtl/builder/SetupMethod.hpp | 99 +++------- .../rtl/cache/cache_lambda_function.h | 12 +- .../rtl/cache/cache_lambda_method.h | 12 +- .../rtl/detail/inc/FunctionCaller.h | 16 +- .../rtl/detail/inc/FunctionCaller.hpp | 139 +++++--------- .../rtl/detail/inc/MethodInvoker.h | 31 ++- .../rtl/detail/inc/MethodInvoker.hpp | 176 +++++------------- .../rtl/dispatch/function_ptr.h | 2 +- ReflectionTemplateLib/rtl/dispatch/functor.h | 23 ++- .../rtl/dispatch/lambda_base.h | 17 +- .../rtl/dispatch/lambda_function.h | 2 +- .../rtl/dispatch/lambda_method.h | 8 +- .../rtl/dispatch/method_ptr.h | 2 +- .../rtl/dispatch/method_ptr_const.h | 2 +- .../rtl/dispatch/rtl_function_erased_return.h | 2 +- .../dispatch/rtl_method_const_erased_return.h | 2 +- .../rtl/dispatch/rtl_method_erased_return.h | 2 +- .../rtl/erasure/aware_hopper.h | 6 +- .../rtl/erasure/aware_hopper_rec.h | 6 +- .../rtl/erasure/aware_hopper_rec_const.h | 6 +- .../rtl/erasure/erased_hopper.h | 24 +-- .../rtl/erasure/erased_hopper_rec.h | 18 +- .../rtl/erasure/erasure_base.h | 14 +- ReflectionTemplateLib/rtl/inc/CMakeLists.txt | 2 + ReflectionTemplateLib/rtl/inc/Function.h | 11 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 34 ++-- ReflectionTemplateLib/rtl/inc/Method.h | 4 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 2 +- ReflectionTemplateLib/rtl/inc/RObject.hpp | 2 +- ReflectionTemplateLib/rtl/inc/Record.h | 3 +- ReflectionTemplateLib/rtl/inc/type_meta.h | 79 ++++++++ ReflectionTemplateLib/rtl/inc/type_meta.hpp | 84 +++++++++ ReflectionTemplateLib/rtl/rtl_forward_decls.h | 27 +-- ReflectionTemplateLib/rtl/src/Function.cpp | 8 +- 53 files changed, 526 insertions(+), 530 deletions(-) create mode 100644 CxxTestProps/inc/Complex.h rename CxxTestProps/inc/{ComplexStrings.h => StringOps.h} (84%) create mode 100644 CxxTestProps/src/Complex.cpp create mode 100644 CxxTestProps/src/Complex.h rename CxxTestProps/src/{ComplexStrings.cpp => StringOps.cpp} (92%) create mode 100644 RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp create mode 100644 RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_ConstMethod.cpp create mode 100644 RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp create mode 100644 ReflectionTemplateLib/rtl/inc/type_meta.h create mode 100644 ReflectionTemplateLib/rtl/inc/type_meta.hpp diff --git a/CxxTestProps/inc/Complex.h b/CxxTestProps/inc/Complex.h new file mode 100644 index 00000000..680d6b44 --- /dev/null +++ b/CxxTestProps/inc/Complex.h @@ -0,0 +1,10 @@ +#pragma once + +namespace complex +{ + double getMagnitude(); + + void setReal(double pNum); + + void setImaginary(double pNum); +} \ No newline at end of file diff --git a/CxxTestProps/inc/ComplexStrings.h b/CxxTestProps/inc/StringOps.h similarity index 84% rename from CxxTestProps/inc/ComplexStrings.h rename to CxxTestProps/inc/StringOps.h index 93bea1cd..95600a25 100644 --- a/CxxTestProps/inc/ComplexStrings.h +++ b/CxxTestProps/inc/StringOps.h @@ -2,15 +2,7 @@ #include -namespace complex -{ - double getMagnitude(); - - void setReal(double pNum); - - void setImaginary(double pNum); -} - +// C-style/free-functions. std::string getComplexNumAsString(); std::string reverseString(); @@ -98,17 +90,17 @@ struct StringC std::string reverseString(const char* pStr) const; - std::string reverseString(std::string pStr) const; // (1) by value + std::string reverseString(std::string pStr) const; // (1) by value - std::string reverseString(std::string& pStr) const; // (2) lvalue ref + std::string reverseString(std::string& pStr) const; // (2) lvalue ref - std::string reverseString(const std::string& pStr) const; // (3) const lvalue ref + std::string reverseString(const std::string& pStr) const; // (3) const lvalue ref - std::string reverseString(std::string&& pStr) const; // (4) rvalue ref + std::string reverseString(std::string&& pStr) const; // (4) rvalue ref - std::string reverseString(std::string* pStr) const; // (5) pointer + std::string reverseString(std::string* pStr) const; // (5) pointer - std::string reverseString(const std::string* pStr) const; // (6) pointer to const + std::string reverseString(const std::string* pStr) const; // (6) pointer to const std::string revStrConstRefArg(const std::string_view& pStr) const; diff --git a/CxxTestProps/src/CMakeLists.txt b/CxxTestProps/src/CMakeLists.txt index 513cbce0..c8f47d7f 100644 --- a/CxxTestProps/src/CMakeLists.txt +++ b/CxxTestProps/src/CMakeLists.txt @@ -5,7 +5,8 @@ set(LOCAL_SOURCES "${CMAKE_CURRENT_LIST_DIR}/Person.cpp" "${CMAKE_CURRENT_LIST_DIR}/Animal.cpp" "${CMAKE_CURRENT_LIST_DIR}/Library.cpp" - "${CMAKE_CURRENT_LIST_DIR}/ComplexStrings.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Complex.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StringOps.cpp" ) SET(LOCAL_HEADERS @@ -14,7 +15,8 @@ SET(LOCAL_HEADERS "${PROJECT_SOURCE_DIR}/inc/Animal.h" "${PROJECT_SOURCE_DIR}/inc/Person.h" "${PROJECT_SOURCE_DIR}/inc/Library.h" - "${PROJECT_SOURCE_DIR}/inc/ComplexStrings.h" + "${PROJECT_SOURCE_DIR}/inc/Complex.h" + "${PROJECT_SOURCE_DIR}/inc/StringOps.h" ) # Add any additional source files if needed diff --git a/CxxTestProps/src/Complex.cpp b/CxxTestProps/src/Complex.cpp new file mode 100644 index 00000000..d70b4ad3 --- /dev/null +++ b/CxxTestProps/src/Complex.cpp @@ -0,0 +1,29 @@ + +#include + +#include "Complex.h" + +namespace complex +{ + static double g_imgNumber; + static double g_realNumber; + + double getMagnitude() + { + std::complex z(g_realNumber, g_imgNumber); + return std::abs(z); + } + + void setReal(double pNum) { + g_realNumber = pNum; + } + + void setImaginary(double pNum) { + g_imgNumber = pNum; + } +} + +std::string getComplexNumAsString() +{ + return std::to_string(complex::g_realNumber) + "i" + (std::to_string(complex::g_imgNumber)); +} \ No newline at end of file diff --git a/CxxTestProps/src/Complex.h b/CxxTestProps/src/Complex.h new file mode 100644 index 00000000..e69de29b diff --git a/CxxTestProps/src/ComplexStrings.cpp b/CxxTestProps/src/StringOps.cpp similarity index 92% rename from CxxTestProps/src/ComplexStrings.cpp rename to CxxTestProps/src/StringOps.cpp index 055b7c79..67dc0bd7 100644 --- a/CxxTestProps/src/ComplexStrings.cpp +++ b/CxxTestProps/src/StringOps.cpp @@ -1,33 +1,7 @@ -#include #include -#include "ComplexStrings.h" - -namespace complex -{ - static double g_imgNumber; - static double g_realNumber; - - double getMagnitude() - { - std::complex z(g_realNumber, g_imgNumber); - return std::abs(z); - } - - void setReal(double pNum) { - g_realNumber = pNum; - } - - void setImaginary(double pNum) { - g_imgNumber = pNum; - } -} - -std::string getComplexNumAsString() -{ - return std::to_string(complex::g_realNumber) + "i" + (std::to_string(complex::g_imgNumber)); -} +#include "StringOps.h" namespace test_utils { @@ -47,10 +21,10 @@ namespace test_utils { const char* REV_STR_VOID_RET = "func_reverseString(void)->[return_str]"; - const char* SUFFIX_std_string_view = "_arg_std::string_view"; - const char* SUFFIX_std_string_view_lvref = "_arg_std::string_view&"; - const char* SUFFIX_std_string_view_rvref = "_arg_std::string_view&&"; - const char* SUFFIX_std_string_view_clvref = "_arg_const_std::string_view&"; + const char* SUFFIX_std_string_view = "_std::string_view"; + const char* SUFFIX_std_string_view_lvref = "_std::string_view&"; + const char* SUFFIX_std_string_view_rvref = "_std::string_view&&"; + const char* SUFFIX_std_string_view_clvref = "_const_std::string_view&"; } using namespace test_utils; diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 65f13497..7a15904b 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -11,7 +11,8 @@ #include "Date.h" #include "Book.h" #include "Person.h" -#include "ComplexStrings.h" +#include "Complex.h" +#include "StringOps.h" #include "Animal.h" #include "Library.h" diff --git a/RTLTestRunApp/src/CMakeLists.txt b/RTLTestRunApp/src/CMakeLists.txt index 02d4f2b7..087bb12a 100644 --- a/RTLTestRunApp/src/CMakeLists.txt +++ b/RTLTestRunApp/src/CMakeLists.txt @@ -19,8 +19,11 @@ set(LOCAL_SOURCES_0 "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_ConstMethod.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp" "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp" + "${CMAKE_CURRENT_LIST_DIR}/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp" ) # Create a variable containing the source files for your target diff --git a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp index e7c70cc6..f0969bfa 100644 --- a/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp +++ b/RTLTestRunApp/src/CxxMirrorTests/CxxMirrorThreadingTest.cpp @@ -10,7 +10,8 @@ #include "../../CxxTestProps/inc/Animal.h" #include "../../CxxTestProps/inc/Person.h" #include "../../CxxTestProps/inc/Library.h" -#include "../../CxxTestProps/inc/ComplexStrings.h" +#include "../../CxxTestProps/inc/Complex.h" +#include "../../CxxTestProps/inc/StringOps.h" #include "../MyReflectionTests/MyReflectingType.h" #include "TestUtilsBook.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp index f0c38898..d0268263 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp @@ -4,7 +4,7 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" -#include "../CxxTestProps/inc/ComplexStrings.h" +#include "../CxxTestProps/inc/StringOps.h" using namespace test_utils; using namespace test_mirror; @@ -178,7 +178,6 @@ namespace rtl_tests .argsT() .returnT(); ASSERT_TRUE(reverse_string); - { //non-const target. StringC target; diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp index 8b7c417b..2f198244 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -4,7 +4,7 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" -#include "../CxxTestProps/inc/ComplexStrings.h" +#include "../CxxTestProps/inc/StringOps.h" using namespace test_utils; using namespace test_mirror; diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp new file mode 100644 index 00000000..e69de29b diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_ConstMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_ConstMethod.cpp new file mode 100644 index 00000000..e69de29b diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp index e441091c..50e88ce2 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -5,7 +5,7 @@ #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" -#include "../CxxTestProps/inc/ComplexStrings.h" +#include "../CxxTestProps/inc/StringOps.h" using namespace test_utils; using namespace test_mirror; diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp new file mode 100644 index 00000000..e69de29b diff --git a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp index f6712332..f4e2af04 100644 --- a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp @@ -42,8 +42,8 @@ namespace rtl::detail inline const Function ReflectionBuilder::buildFunctor(_returnType(*pFunctor)(_signature...)) const { using Container = FunctorContainer< traits::remove_const_if_not_reference<_signature>...>; - const FunctorId& functorId = Container::template addFunctor<_returnType, _signature...>(pFunctor, m_recordId); - return Function(m_namespace, m_record, m_function, functorId, m_recordId, methodQ::None); + auto [typeMeta, functorId] = Container::template addFunctor<_returnType, _signature...>(pFunctor, m_recordId); + return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, methodQ::None); } @@ -58,8 +58,8 @@ namespace rtl::detail inline const Function ReflectionBuilder::buildMethodFunctor(_returnType(_recordType::* pFunctor)(_signature...)) const { using Container = MethodContainer...>; - const FunctorId& functorId = Container::template addFunctor<_recordType, _returnType, _signature...>(pFunctor); - return Function(m_namespace, m_record, m_function, functorId, m_recordId, methodQ::NonConst); + auto [typeMeta, functorId] = Container::template addFunctor<_recordType, _returnType, _signature...>(pFunctor); + return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, methodQ::NonConst); } @@ -74,8 +74,8 @@ namespace rtl::detail inline const Function ReflectionBuilder::buildMethodFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) const { using Container = MethodContainer...>; - const FunctorId& functorId = Container::template addFunctor<_recordType, _returnType, _signature...>(pFunctor); - return Function(m_namespace, m_record, m_function, functorId, m_recordId, methodQ::Const); + auto [typeMeta, functorId] = Container::template addFunctor<_recordType, _returnType, _signature...>(pFunctor); + return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, methodQ::Const); } @@ -90,7 +90,7 @@ namespace rtl::detail using Container = FunctorContainer < rtl::alloc, FunctorId, traits::remove_const_if_not_reference<_ctorSignature>... > ; const FunctorId& functorId = Container::template addConstructor<_recordType, _ctorSignature...>(); const FunctorId& copyCtorId = traits::Cloner::template addCopyConstructor<_recordType, RObject, alloc>(); - const Function& ctorFunction = Function(m_namespace, m_record, m_function, functorId, m_recordId, methodQ::None); + const Function& ctorFunction = Function(m_namespace, m_record, m_function, rtl::type_meta(), functorId, m_recordId, methodQ::None); ctorFunction.getFunctorIds().push_back(copyCtorId); return ctorFunction; diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.h b/ReflectionTemplateLib/rtl/builder/SetupFunction.h index 33dee711..c29d99fc 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.h +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.h @@ -42,6 +42,6 @@ namespace rtl::detail protected: template - static const detail::FunctorId addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId); + static std::pair addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index d8236545..e5288f1a 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -13,8 +13,7 @@ #include -#include "cache_function_ptr.h" -#include "cache_lambda_function.h" +#include "type_meta.hpp" #include "SetupFunction.h" #include "RObjectBuilder.hpp" @@ -91,19 +90,11 @@ namespace rtl * thread safe, multiple functors can be registered simultaneously. */ template template - inline const detail::FunctorId SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) + inline std::pair SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) { - const dispatch::lambda_base* lambdaPtr = nullptr; - - const auto& updateIndex = [&](std::size_t pIndex)-> void - { - auto& lambdaCache = cache::lambda_function<_returnType, _signature...>::instance(); - auto& functorCache = cache::function_ptr<_returnType, _signature...>::instance(); - - auto& functor = functorCache.push(pFunctor, pIndex); - auto& lambda = lambdaCache.push(functor); - - lambdaPtr = λ + rtl::type_meta typeMeta; + const auto& updateIndex = [&](std::size_t pIndex)-> void { + typeMeta = rtl::type_meta::add_function(pFunctor, pIndex); }; const auto& getIndex = [&]()-> std::size_t @@ -111,7 +102,7 @@ namespace rtl auto& functorCache = cache::function_ptr<_returnType, _signature...>::instance(); auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->get_lambda(); + typeMeta = rtl::type_meta(*functor); } return lambdaIndex; }; @@ -122,14 +113,17 @@ namespace rtl auto lambdaIndex = _derivedType::pushBack(getCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. - return detail::FunctorId{ - - lambdaIndex, - returnId, - pRecordId, - _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_returnType>(), - lambdaPtr + return { + typeMeta, + FunctorId + { + lambdaIndex, + returnId, + pRecordId, + _derivedType::getContainerId(), + _derivedType::template getSignatureStr<_returnType>(), + &(typeMeta.get_lambda()) + } }; } } diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.h b/ReflectionTemplateLib/rtl/builder/SetupMethod.h index 7e2dc220..f6a1f858 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.h +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.h @@ -49,9 +49,9 @@ namespace rtl::detail { protected: template - static const detail::FunctorId addFunctor(_returnType(_recordType::* pFunctor)(_signature...)); + static std::pair addFunctor(_returnType(_recordType::* pFunctor)(_signature...)); template - static const detail::FunctorId addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const); + static std::pair addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 52b1ee85..77e1d48c 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -18,9 +18,7 @@ #include "SetupMethod.h" #include "RObjectBuilder.hpp" -#include "cache_lambda_method.h" -#include "cache_method_ptr.h" -#include "cache_method_ptr_const.h" +#include "type_meta.hpp" #include "FunctorId.hpp" @@ -166,18 +164,12 @@ namespace rtl::detail * thread safe, multiple functors can be registered simultaneously. */ template template - inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) + inline std::pair SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...)) { - const dispatch::lambda_base* lambdaPtr = nullptr; + rtl::type_meta typeMeta; const auto& updateIndex = [&](std::size_t pIndex)-> void { - auto& lambdaCache = cache::lambda_method<_recordType, _returnType, _signature...>::instance(); - auto& functorCache = cache::method_ptr<_recordType, _returnType, _signature...>::instance(); - - auto& functor = functorCache.push(pFunctor, pIndex); - auto& lambda = lambdaCache.push(functor); - - lambdaPtr = λ + typeMeta = rtl::type_meta::add_method(pFunctor, pIndex); }; const auto& getIndex = [&]()-> std::size_t @@ -186,7 +178,7 @@ namespace rtl::detail auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->get_lambda(); + typeMeta = rtl::type_meta(*functor); } return lambdaIndex; }; @@ -195,34 +187,20 @@ namespace rtl::detail const std::size_t retTypeId = TypeId>::get(); //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. - if constexpr (std::is_same_v<_returnType, void>) - { - auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); - //construct the hash-key 'FunctorId' and return. - return detail::FunctorId{ - - lambdaIndex, - retTypeId, - TypeId<_recordType>::get(), - _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), - lambdaPtr - }; - } - else - { - auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); - //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { - + auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + //construct the hash-key 'FunctorId' and return. + return { + typeMeta, + FunctorId + { lambdaIndex, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - lambdaPtr - }; - } + &(typeMeta.get_lambda()) + } + }; } @@ -237,18 +215,11 @@ namespace rtl::detail * thread safe, multiple functors can be registered simultaneously. */ template template - inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) + inline std::pair SetupMethod<_derivedType>::addFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) { - const dispatch::lambda_base* lambdaPtr = nullptr; - const auto& updateIndex = [&](std::size_t pIndex)-> void - { - auto& lambdaCache = cache::lambda_method<_recordType, _returnType, _signature...>::instance(); - auto& functorCache = cache::method_ptr::instance(); - - auto& functor = functorCache.push(pFunctor, pIndex); - auto& lambda = lambdaCache.push(functor); - - lambdaPtr = λ + rtl::type_meta typeMeta; + const auto& updateIndex = [&](std::size_t pIndex)-> void { + typeMeta = rtl::type_meta::add_method(pFunctor, pIndex); }; const auto& getIndex = [&]()-> std::size_t @@ -257,7 +228,7 @@ namespace rtl::detail auto [functor, lambdaIndex] = functorCache.find(pFunctor); if (lambdaIndex != rtl::index_none) { - lambdaPtr = functor->get_lambda(); + typeMeta = rtl::type_meta(*functor); } return lambdaIndex; }; @@ -266,34 +237,20 @@ namespace rtl::detail const std::size_t retTypeId = TypeId>::get(); //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. - if constexpr (std::is_same_v<_returnType, void>) - { - auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); - - //construct the hash-key 'FunctorId' and return. - return detail::FunctorId { - - lambdaIndex, - retTypeId, - TypeId<_recordType>::get(), - _derivedType::getContainerId(), - _derivedType::template getSignatureStr<_recordType, _returnType>(), - lambdaPtr - }; - } - else - { - auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); - //construct the hash-key 'FunctorId' and return. - return detail::FunctorId{ + auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); + //construct the hash-key 'FunctorId' and return. + return { + typeMeta, + FunctorId + { lambdaIndex, retTypeId, TypeId<_recordType>::get(), _derivedType::getContainerId(), _derivedType::template getSignatureStr<_recordType, _returnType>(), - lambdaPtr - }; - } + &(typeMeta.get_lambda()) + } + }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index cb1309ee..97e1c6d5 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -27,17 +27,15 @@ namespace rtl::cache return instance_; } - const dispatch::lambda_function& push(const dispatch::functor& p_functor) const + std::pair push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(dispatch::erase::aware_hopper(p_functor)); + m_erasure_cache.push_back(dispatch::aware_hopper(p_functor)); - const dispatch::erase::erasure_base& eb = m_erasure_cache.back(); + const dispatch::erased_fnbase& eb = m_erasure_cache.back(); m_cache.push_back(dispatch::lambda_function(p_functor, eb)); - p_functor.set_lambda(&m_cache.back()); - - return m_cache.back(); + return { &m_cache.back(), &m_erasure_cache.back() }; } lambda_function(lambda_function&&) = delete; @@ -49,7 +47,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_function() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index 407e7114..ae86aeca 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -28,17 +28,15 @@ namespace rtl::cache return instance_; } - const dispatch::lambda_method& push(const dispatch::functor& p_functor) const + std::pair push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(dispatch::erase::aware_hopper_rec(p_functor)); + m_erasure_cache.push_back(dispatch::aware_hopper_rec(p_functor)); - const dispatch::erase::erasure_base& eb = m_erasure_cache.back(); + const dispatch::erased_fnbase& eb = m_erasure_cache.back(); m_cache.push_back(dispatch::lambda_method(p_functor, eb)); - p_functor.set_lambda(&m_cache.back()); - - return m_cache.back(); + return { &m_cache.back(), &m_erasure_cache.back() }; } lambda_method(lambda_method&&) = delete; @@ -50,7 +48,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_method() = default; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 34c4f78d..1c4807db 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -24,10 +24,16 @@ namespace rtl::detail rtl::Return call(_args&&...) const noexcept; template requires (is_binding_v == false) - constexpr rtl::Return operator()(_args&&...params) const noexcept; + constexpr rtl::Return operator()(_args&&...params) const noexcept + { + return { error::InvalidCaller, RObject{} }; + } template requires (is_binding_v == true) - constexpr rtl::Return operator()(_args&&...params) const noexcept; + constexpr rtl::Return operator()(_args&&...params) const noexcept + { + return { error::SignatureMismatch, RObject{} }; + } }; } @@ -37,9 +43,9 @@ namespace rtl::detail template struct HopFunction { - const dispatch::lambda_function<_signature...>* m_lambda = nullptr; + rtl::type_meta m_argsTfnMeta; - std::vector m_lambdaRefOverloads = {}; + std::vector m_overloadsFnMeta = {}; template requires (std::is_same_v<_returnType, rtl::Return>) constexpr function returnT() const; @@ -52,7 +58,7 @@ namespace rtl::detail template<> struct Hopper<> { - const std::vector& m_functorIds; + const std::vector& m_functorsMeta; template constexpr const HopFunction<_signature...> argsT() const; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 3b5e925e..eddcdc7f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -45,8 +45,11 @@ namespace rtl::detail inline constexpr const function HopFunction::returnT() const { const auto retId = traits::uid::value; - if (m_lambda != nullptr) { - return m_lambda->template get_hopper(retId); + if (!m_argsTfnMeta.is_empty()) + { + return m_argsTfnMeta.get_lambda() + .template to_function() + .template get_hopper(retId); } return function(); } @@ -58,35 +61,37 @@ namespace rtl::detail auto strictArgsId = traits::uid>::value; auto normalArgsId = traits::uid>::value; - const dispatch::lambda_function* lambda_fn = nullptr; - std::vector refOverloads = { nullptr }; + rtl::type_meta argsTfnMeta; + //initializing pos '0' with empty 'type_meta'. + std::vector overloadsFnMeta = { rtl::type_meta() }; - for (auto& functorId : m_functorIds) + for (auto& fnMeta : m_functorsMeta) { - auto& lambda = functorId.get_lambda(); - if (!lambda_fn && strictArgsId == lambda.get_strict_sign_id()) { - lambda_fn = &(lambda.to_function()); + if (argsTfnMeta.is_empty() && strictArgsId == fnMeta.get_strict_args_id()) { + argsTfnMeta = fnMeta; } - if (normalArgsId == lambda.get_normal_sign_id()) + if (normalArgsId == fnMeta.get_normal_args_id()) { - if (normalArgsId == lambda.get_strict_sign_id()) { - refOverloads[0] = λ + if (normalArgsId == fnMeta.get_strict_args_id()) { + // same normal & strict ids, means no refs exists in target function's signature + // target's function signature is call by value, always at pos '0'. + // if doesn't exists, this pos is occupied by an empty 'type_meta'. + overloadsFnMeta[0] = fnMeta; } - else if (!lambda.is_any_ncref()) { - refOverloads.push_back(&lambda); + else if (!fnMeta.is_any_arg_ncref()) { + // its a const-ref-overload with no non-const-ref in signature, added from pos '1' onwards. + overloadsFnMeta.push_back(fnMeta); } } } - for (auto& functorId : m_functorIds) - { - auto& lambda = functorId.get_lambda(); - if (normalArgsId == lambda.get_normal_sign_id() && lambda.is_any_ncref()) { - refOverloads.push_back(&lambda); + for (auto& fnMeta : m_functorsMeta) { + if (normalArgsId == fnMeta.get_normal_args_id() && fnMeta.is_any_arg_ncref()) { + // any remaining overload, const/non-const ref added from pos '1' onwards. + overloadsFnMeta.push_back(fnMeta); } } - - return { lambda_fn, refOverloads }; + return { argsTfnMeta, overloadsFnMeta }; } @@ -94,92 +99,36 @@ namespace rtl::detail template requires (std::is_same_v) inline constexpr function HopFunction::returnT() const { - bool isRetTypeVoid = false; - function...)> erasedReturnFunc; + bool isReturnTvoid = false; + function...)> erasedRetHop; - for (auto lambda : m_lambdaRefOverloads) - { - erasedReturnFunc.get_overloads().push_back(lambda); - if (lambda) + for (auto& fnMeta : m_overloadsFnMeta) + { + if (!fnMeta.is_empty()) { - auto eret = lambda->get_unerasure().to_erased_return...>(); - if (lambda->is_void()) { - erasedReturnFunc.get_vhop().push_back(eret.get_void_hopper()); - isRetTypeVoid = true; + auto erasedRetFn = fnMeta.get_erased_lambda() + .template to_erased_return...>(); + if (fnMeta.is_void()) { + isReturnTvoid = true; + erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); } else { - erasedReturnFunc.get_rhop().push_back(eret.get_return_hopper()); + erasedRetHop.get_rhop().push_back(erasedRetFn.get_return_hopper()); } + erasedRetHop.get_overloads().push_back(&fnMeta.get_lambda()); } else { - erasedReturnFunc.get_vhop().push_back(nullptr); - erasedReturnFunc.get_rhop().push_back(nullptr); + erasedRetHop.get_vhop().push_back(nullptr); + erasedRetHop.get_rhop().push_back(nullptr); + erasedRetHop.get_overloads().push_back(nullptr); } } - if (isRetTypeVoid) { - erasedReturnFunc.get_rhop().clear(); + if (isReturnTvoid) { + erasedRetHop.get_rhop().clear(); } else { - erasedReturnFunc.get_vhop().clear(); - } - return erasedReturnFunc; - } - - - template - template requires (is_binding_v == true) - ForceInline constexpr Return ErasedCaller::operator()(args_t&&...params) const noexcept - { - //auto functorId = m_function.getLambdaByStrictId(traits::uid>::value); - //if (functorId) [[likely]] - //{ - // const auto& erased = functorId->m_lambda->m_erasure; - // const auto& caller = erased.template to_erased_return(); - // if (functorId->m_lambda->is_void()) - // { - // caller.hop_void(std::forward(params)...); - // return { error::None, RObject{} }; - // } - // else - // { - // return{ error::None, - // RObject{ caller.hop_return(std::forward(params)...), - // caller.get_return_id(), nullptr } - // }; - // } - //} - //else [[unlikely]] { - return { error::SignatureMismatch, RObject{} }; - //} - } - - - template - template requires (is_binding_v == false) - ForceInline constexpr Return ErasedCaller::operator()(args_t&&...params) const noexcept - { - return { error::InvalidCaller, RObject{} }; - - auto functorId = m_function.getLambdaByNormalId(traits::uid>::value); - if (functorId.first) [[likely]] - { - const auto& erased = functorId.first->m_lambda->m_erasure; - const auto& caller = erased.template to_erased_return(); - //if (functorId.first->m_lambda->is_void()) - //{ - // caller.hop_void(std::forward(params)...); - return { error::None, RObject{} }; - //} - //else - //{ - // return{ error::None, - // RObject{ caller.hop_return(std::forward(params)...), - // caller.get_return_id(), nullptr } - // }; - //} - } - else [[unlikely]] { - return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; + erasedRetHop.get_vhop().clear(); } + return erasedRetHop; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 551f3942..cefd1e73 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -13,6 +13,7 @@ #include "rtl_typeid.h" #include "rtl_forward_decls.h" +#include "type_meta.h" namespace rtl::detail { @@ -24,10 +25,16 @@ namespace rtl::detail const _recordType& m_target; template requires (std::is_same_v, RObject> == false) - constexpr Return operator()(_args&&...params) const noexcept; + constexpr Return operator()(_args&&...params) const noexcept + { + return { error::InvalidCaller, RObject{} }; + } template requires (std::is_same_v, RObject> == true) - constexpr Return operator()(_args&&...params) const noexcept; + constexpr Return operator()(_args&&...params) const noexcept + { + return { error::InvalidCaller, RObject{} }; + } }; } @@ -92,31 +99,23 @@ namespace rtl::detail template struct HopMethod { - const dispatch::lambda_method* m_lambda = nullptr; + rtl::type_meta m_argsTfnMeta; - std::vector m_lambdaRefOverloads = {}; - - template - requires (!std::is_const_v && std::is_same_v) - constexpr const method returnT() const; + std::vector m_overloadsFnMeta = {}; template - requires (!std::is_const_v && !std::is_same_v) + requires (!std::is_same_v) constexpr const method returnT() const; template - requires (std::is_const_v && std::is_same_v) - constexpr const method returnT() const; - - template - requires (std::is_const_v && !std::is_same_v) - constexpr const method returnT() const; + requires (std::is_same_v) + constexpr const method returnT() const; }; template struct Hopper { - const std::vector& m_functorIds; + const std::vector& m_functorsMeta; template constexpr HopMethod argsT() const; diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index c342a062..24c51356 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -157,14 +157,16 @@ namespace rtl::detail template template - requires (!std::is_const_v && !std::is_same_v) + requires (!std::is_same_v) inline constexpr const method HopMethod::returnT() const { - if (m_lambda != nullptr) + if (!m_argsTfnMeta.is_empty()) { const auto retId = traits::uid::value; - return m_lambda->template get_hopper(retId); + return m_argsTfnMeta.get_lambda() + .template to_method() + .template get_hopper(retId); } return method(); } @@ -172,69 +174,41 @@ namespace rtl::detail template template - requires (std::is_const_v && !std::is_same_v) - inline constexpr const - method HopMethod::returnT() const - { - if (m_lambda != nullptr) - { - const auto retId = traits::uid::value; - return m_lambda->template get_hopper(retId); - } - return method(); - } - - - template - template - requires (std::is_const_v && std::is_same_v) - inline constexpr const - method HopMethod::returnT() const - { - if (m_lambda != nullptr) - { - const auto retId = traits::uid::value; - return m_lambda->template get_hopper(retId); - } - return method(); - } - - - template - template - requires (!std::is_const_v && std::is_same_v) + requires (std::is_same_v) inline constexpr const method HopMethod::returnT() const { - bool isRetTypeVoid = false; - method...)> erasedReturnMthd; + bool isReturnTvoid = false; + method...)> erasedRetHop; - for (auto lambda : m_lambdaRefOverloads) + for (auto& fnMeta : m_overloadsFnMeta) { - erasedReturnMthd.get_overloads().push_back(lambda); - if (lambda) + if (!fnMeta.is_empty()) { - auto eret = lambda->get_unerasure().to_erased_return_rec...>(); - if (lambda->is_void()) { - erasedReturnMthd.get_vhop().push_back(eret.get_void_hopper()); - isRetTypeVoid = true; + auto erasedRetFn = fnMeta.get_erased_lambda() + .template to_erased_return_rec...>(); + if (fnMeta.is_void()) { + isReturnTvoid = true; + erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); } else { - erasedReturnMthd.get_rhop().push_back(eret.get_return_hopper()); + erasedRetHop.get_rhop().push_back(erasedRetFn.get_return_hopper()); } + erasedRetHop.get_overloads().push_back(&fnMeta.get_lambda()); } else { - erasedReturnMthd.get_vhop().push_back(nullptr); - erasedReturnMthd.get_rhop().push_back(nullptr); + erasedRetHop.get_vhop().push_back(nullptr); + erasedRetHop.get_rhop().push_back(nullptr); + erasedRetHop.get_overloads().push_back(nullptr); } } - if (isRetTypeVoid) { - erasedReturnMthd.get_rhop().clear(); + if (isReturnTvoid) { + erasedRetHop.get_rhop().clear(); } else { - erasedReturnMthd.get_vhop().clear(); + erasedRetHop.get_vhop().clear(); } - return erasedReturnMthd; + return erasedRetHop; } @@ -246,97 +220,39 @@ namespace rtl::detail auto strictArgsId = traits::uid>::value; auto normalArgsId = traits::uid>::value; - const dispatch::lambda_method* lambda_mt = nullptr; - std::vector refOverloads = { nullptr }; + rtl::type_meta argsTfnMeta; + //initializing pos '0' with empty 'type_meta'. + std::vector overloadsFnMeta = { rtl::type_meta() }; - for (auto& functorId : m_functorIds) + for (auto& fnMeta : m_functorsMeta) { - auto& lambda = functorId.get_lambda(); - if (recordId != lambda.get_record_id()) { + if (recordId != fnMeta.get_record_id()) { continue; } - if (!lambda_mt && strictArgsId == lambda.get_strict_sign_id()) { - lambda_mt = &(lambda.to_method()); + if (argsTfnMeta.is_empty() && strictArgsId == fnMeta.get_strict_args_id()) { + argsTfnMeta = fnMeta; } - if (normalArgsId == lambda.get_normal_sign_id()) + if (normalArgsId == fnMeta.get_normal_args_id()) { - if (normalArgsId == lambda.get_strict_sign_id()) { - refOverloads[0] = λ + if (normalArgsId == fnMeta.get_strict_args_id()) { + // same normal & strict ids, means no refs exists in target function's signature + // target's function signature is call by value, always at pos '0'. + // if doesn't exists, this pos is occupied by an empty 'type_meta'. + overloadsFnMeta[0] = fnMeta; } - else if (!lambda.is_any_ncref()) { - refOverloads.push_back(&lambda); + else if (!fnMeta.is_any_arg_ncref()) { + // its a const-ref-overload with no non-const-ref in signature, added from pos '1' onwards. + overloadsFnMeta.push_back(fnMeta); } } } - for (auto& functorId : m_functorIds) - { - auto& lambda = functorId.get_lambda(); - if (recordId == lambda.get_record_id() && - normalArgsId == lambda.get_normal_sign_id() && lambda.is_any_ncref()) { - refOverloads.push_back(&lambda); - } - } - return { lambda_mt, refOverloads }; - } -} - - -namespace rtl::detail -{ - template - template requires (std::is_same_v, RObject> == false) - ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept - { - return { error::InvalidCaller, RObject{} }; - - auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); - if (functorId.first) [[likely]] - { - const auto& erased = functorId.first->m_lambda->get_unerasure(); - const auto& caller = erased.template to_erased_return_rec(); - //if(functorId.first->m_lambda->is_void()) - //{ - // caller.hop_void(m_target, std::forward(params)...); - return { error::None, RObject{} }; - //} - //else - //{ - // return{ error::None, - // RObject{ caller.hop_return(m_target, std::forward(params)...), - // caller.get_return_id(), nullptr } - // }; - //} - } - else [[unlikely]] { - return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; - } - } - - template - template requires (std::is_same_v, RObject> == true) - ForceInline constexpr Return ErasedInvoker::operator()(argsT&&...params) const noexcept - { - return { error::InvalidCaller, RObject{} }; - - auto functorId = m_method.getLambdaByNormalId(traits::uid>::value); - if (functorId.first) [[likely]] - { - const auto& erased = functorId.first->m_lambda->get_unerasure(); - const auto& caller = erased.template to_erased_return(); - //if (functorId.first->m_lambda->is_void()) - //{ - // caller.hop_void(m_target, std::forward(params)...); - return { error::None, RObject{} }; - //} - //else - //{ - // return{ error::None, - // RObject{ caller.hop_return(m_target, std::forward(params)...), - // caller.get_return_id(), nullptr } - // }; - //} + for (auto& fnMeta : m_functorsMeta) { + if (recordId == fnMeta.get_record_id() && + normalArgsId == fnMeta.get_normal_args_id() && fnMeta.is_any_arg_ncref()) { + overloadsFnMeta.push_back(fnMeta); + } } - else return { (functorId.second ? error::ExplicitRefBindingRequired:error::SignatureMismatch), RObject{} }; + return { argsTfnMeta, overloadsFnMeta }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index e7762b94..ea3acaf8 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -33,7 +33,7 @@ namespace rtl::dispatch m_returnId = traits::uid::value; m_is_void = (m_returnId == traits::uid::value); - m_is_any_ncref = (traits::is_nonconst_ref_v || ...); + m_is_any_arg_ncref = (traits::is_nonconst_ref_v || ...); m_normal_signId = traits::uid>::value; m_strict_signId = traits::uid>::value; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index b674ff4e..010fb7bf 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -11,6 +11,7 @@ #pragma once +#include "rtl_traits.h" #include "rtl_constants.h" #include "rtl_forward_decls.h" @@ -22,8 +23,6 @@ namespace rtl::dispatch return m_is_void; } - GETTER_CPTR(lambda_base, _lambda, m_lambda) - protected: std::string m_recordStr; @@ -37,26 +36,34 @@ namespace rtl::dispatch traits::uid_t m_strict_signId = traits::uid<>::none; bool m_is_void = false; - bool m_is_any_ncref = false; + bool m_is_any_arg_ncref = false; std::vector m_argumentsId = {}; detail::methodQ m_qualifier = detail::methodQ::None; private: - constexpr void set_lambda(const lambda_base* p_lambda) const { + constexpr void set_lambda(const dispatch::lambda_base* p_lambda) const { m_lambda = p_lambda; } - mutable const lambda_base* m_lambda = nullptr; + constexpr void set_erased_lambda(const dispatch::erased_fnbase* p_elambda) const { + m_erased_lambda = p_elambda; + } + + mutable const dispatch::lambda_base* m_lambda = nullptr; + + mutable const dispatch::erased_fnbase* m_erased_lambda = nullptr; + + friend rtl::type_meta; - friend lambda_base; + friend dispatch::lambda_base; template - friend struct lambda_function; + friend struct dispatch::lambda_function; template - friend struct lambda_method; + friend struct dispatch::lambda_method; template friend struct cache::lambda_function; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index 3ca7519e..cc280644 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -59,28 +59,19 @@ namespace rtl::dispatch } GETTER_BOOL(_void, m_functor.m_is_void) - - GETTER_CREF(functor, _functor, m_functor) - - GETTER_CREF(erase::erasure_base, _unerasure, m_erasure) - - GETTER_CREF(detail::RObjectId, _return_id, m_erasure.m_return_id); - - GETTER_BOOL(_any_ncref, m_functor.m_is_any_ncref) - - GETTER(traits::uid_t, _record_id, m_functor.m_recordId) + GETTER_BOOL(_any_arg_ncref, m_functor.m_is_any_arg_ncref) GETTER(traits::uid_t, _strict_sign_id, m_functor.m_strict_signId) - GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_signId) + GETTER_CREF(detail::RObjectId, _return_id, m_erasure.m_return_id) - lambda_base(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept + lambda_base(const functor& p_functor, const erased_fnbase& p_erasure) noexcept : m_functor(p_functor) , m_erasure(p_erasure) { } const functor& m_functor; - const erase::erasure_base& m_erasure; + const erased_fnbase& m_erasure; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index e636a8a5..b6f8c7be 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -41,7 +41,7 @@ namespace rtl::dispatch return hopper_t(); } - lambda_function(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept + lambda_function(const functor& p_functor, const erased_fnbase& p_erasure) noexcept : lambda_base(p_functor, p_erasure) { } }; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 5601e349..4207ddf3 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -12,9 +12,11 @@ #pragma once #include "lambda_base.h" -#include "rtl_method.h" -#include "erased_hopper_rec.h" + #include "method_ptr.h" +#include "erased_hopper_rec.h" + +#include "rtl_method.h" #include "rtl_method_const.h" @@ -57,7 +59,7 @@ namespace rtl::dispatch return hopper_ct(); } - lambda_method(const functor& p_functor, const erase::erasure_base& p_erasure) noexcept + lambda_method(const functor& p_functor, const erased_fnbase& p_erasure) noexcept : lambda_base(p_functor, p_erasure) { } }; diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 89c9c45b..f3fd4315 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -38,7 +38,7 @@ namespace rtl::dispatch m_is_void = (m_returnId == traits::uid::value); m_recordId = traits::uid::value; - m_is_any_ncref = (traits::is_nonconst_ref_v || ...); + m_is_any_arg_ncref = (traits::is_nonconst_ref_v || ...); m_normal_signId = traits::uid>::value; m_strict_signId = traits::uid>::value; diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h index 3386381d..120b2b3c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h @@ -38,7 +38,7 @@ namespace rtl::dispatch m_is_void = (m_returnId == traits::uid::value); m_recordId = traits::uid::value; - m_is_any_ncref = (traits::is_nonconst_ref_v || ...); + m_is_any_arg_ncref = (traits::is_nonconst_ref_v || ...); m_normal_signId = traits::uid>::value; m_strict_signId = traits::uid>::value; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index d97efea2..b3e3026f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -100,7 +100,7 @@ namespace rtl constexpr bool must_bind_refs() const noexcept { return (m_lambdas[call_by::value] == nullptr && - (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); + (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_arg_ncref())); } enum call_by diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h index bd7ebca0..d7e74b3c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h @@ -111,7 +111,7 @@ namespace rtl constexpr bool must_bind_refs() const noexcept { return (m_lambdas[call_by::value] == nullptr && - (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); + (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_arg_ncref())); } enum call_by diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h index 60522c2f..640ab794 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -121,7 +121,7 @@ namespace rtl constexpr bool must_bind_refs() const noexcept { return (m_lambdas[call_by::value] == nullptr && - (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_ncref())); + (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_arg_ncref())); } enum call_by diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h index f557e5c8..1e3cfb6c 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper.h @@ -14,12 +14,12 @@ #include #include "erased_hopper.h" -namespace rtl::dispatch::erase +namespace rtl::dispatch { template - struct aware_hopper : public erased_hopper...> + struct aware_hopper : public erased_return_fn...> { - using base_t = erased_hopper...>; + using base_t = erased_return_fn...>; constexpr static bool isConstCastSafe = (!traits::is_const_v); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h index 8c702b19..fb49a395 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h @@ -16,12 +16,12 @@ #include "RObjectId.h" #include "erased_hopper_rec.h" -namespace rtl::dispatch::erase +namespace rtl::dispatch { template - struct aware_hopper_rec : public erased_hopper_rec...> + struct aware_hopper_rec : public erased_return_fn_rec...> { - using base_t = erased_hopper_rec...>; + using base_t = erased_return_fn_rec...>; constexpr static bool isConstCastSafe = (!traits::is_const_v); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h index aa62e848..4bfdb4bb 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h @@ -16,12 +16,12 @@ #include "RObjectId.h" #include "erased_hopper_rec.h" -namespace rtl::dispatch::erase +namespace rtl::dispatch { template - struct aware_hopper_rec : public erased_hopper_rec...> + struct aware_hopper_rec : public erased_return_fn_rec...> { - using base_t = erased_hopper_rec...>; + using base_t = erased_return_fn_rec...>; constexpr static bool isConstCastSafe = (!traits::is_const_v); diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h index b37c423f..c8fb1d86 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper.h @@ -15,10 +15,10 @@ #include "erasure_base.h" -namespace rtl::dispatch::erase +namespace rtl::dispatch { template - struct erased_hopper : public erasure_base + struct erased_return_fn : public erased_fnbase { using lambda_vt = std::function; @@ -43,22 +43,22 @@ namespace rtl::dispatch::erase lambda_robj_rt m_rmhopper; - erased_hopper( const dispatch::functor& p_functor, - const lambda_vt& p_void_hop, - const lambda_rt& p_any_ret_hop, - const detail::RObjectId& p_ret_id ) noexcept + erased_return_fn( const dispatch::functor& p_functor, + const lambda_vt& p_void_hop, + const lambda_rt& p_any_ret_hop, + const detail::RObjectId& p_ret_id ) noexcept - : erasure_base(p_functor, p_ret_id) + : erased_fnbase(p_functor, p_ret_id) , m_vhopper(p_void_hop) , m_rhopper(p_any_ret_hop) { } - erased_hopper( const dispatch::functor& p_functor, - const lambda_robj_vt& p_void_method_hop, - const lambda_robj_rt& p_any_ret_method_hop, - const detail::RObjectId& p_ret_id ) noexcept + erased_return_fn( const dispatch::functor& p_functor, + const lambda_robj_vt& p_void_method_hop, + const lambda_robj_rt& p_any_ret_method_hop, + const detail::RObjectId& p_ret_id ) noexcept - : erasure_base(p_functor, p_ret_id) + : erased_fnbase(p_functor, p_ret_id) , m_vmhopper(p_void_method_hop) , m_rmhopper(p_any_ret_method_hop) { } diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h index 03ae69a4..014997c4 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h @@ -17,10 +17,10 @@ #include "erased_hopper.h" #include "rtl_forward_decls.h" -namespace rtl::dispatch::erase +namespace rtl::dispatch { template - struct erased_hopper_rec : public erased_hopper + struct erased_return_fn_rec : public erased_return_fn { using lambda_vt = std::function; @@ -36,14 +36,14 @@ namespace rtl::dispatch::erase lambda_rt m_rhopper; - using base_t = erased_hopper; + using base_t = erased_return_fn; - erased_hopper_rec( const dispatch::functor& p_functor, - const lambda_vt& p_void_hop, - const lambda_rt& p_any_ret_hop, - const base_t::lambda_robj_vt& p_void_robj_hop, - const base_t::lambda_robj_rt& p_any_ret_robj_hop, - const detail::RObjectId& p_ret_id ) noexcept + erased_return_fn_rec( const dispatch::functor& p_functor, + const lambda_vt& p_void_hop, + const lambda_rt& p_any_ret_hop, + const base_t::lambda_robj_vt& p_void_robj_hop, + const base_t::lambda_robj_rt& p_any_ret_robj_hop, + const detail::RObjectId& p_ret_id ) noexcept : base_t(p_functor, p_void_robj_hop, p_any_ret_robj_hop, p_ret_id) , m_vhopper(p_void_hop) diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_base.h b/ReflectionTemplateLib/rtl/erasure/erasure_base.h index 00b3c369..0dbb9319 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_base.h +++ b/ReflectionTemplateLib/rtl/erasure/erasure_base.h @@ -15,12 +15,12 @@ #include "RObjectId.h" #include "rtl_constants.h" -namespace rtl::dispatch::erase +namespace rtl::dispatch { - struct erasure_base + struct erased_fnbase { template - using ehop_t = erased_hopper...>; + using ehop_t = erased_return_fn...>; template constexpr const ehop_t& to_erased_return() const @@ -29,7 +29,7 @@ namespace rtl::dispatch::erase } template - using ehop_rt = erased_hopper_rec...>; + using ehop_rt = erased_return_fn_rec...>; template constexpr const ehop_rt& to_erased_return_rec() const @@ -37,7 +37,7 @@ namespace rtl::dispatch::erase return static_cast&>(*this); } - erasure_base(const dispatch::functor& p_functor, const detail::RObjectId& p_ret_id) noexcept + erased_fnbase(const dispatch::functor& p_functor, const detail::RObjectId& p_ret_id) noexcept : m_functor(p_functor) , m_return_id(p_ret_id) { } @@ -45,9 +45,5 @@ namespace rtl::dispatch::erase const dispatch::functor& m_functor; const detail::RObjectId m_return_id; - - GETTER_CREF(detail::RObjectId, _return_id, m_return_id); - - GETTER_CREF(dispatch::lambda_base, _lambda, (*m_functor.get_lambda())); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/CMakeLists.txt b/ReflectionTemplateLib/rtl/inc/CMakeLists.txt index 1896bc2f..aff67f32 100644 --- a/ReflectionTemplateLib/rtl/inc/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/inc/CMakeLists.txt @@ -12,6 +12,8 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/Record.h" "${CMAKE_CURRENT_SOURCE_DIR}/RObject.h" "${CMAKE_CURRENT_SOURCE_DIR}/RObject.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/type_meta.h" + "${CMAKE_CURRENT_SOURCE_DIR}/type_meta.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/view.h" "${CMAKE_CURRENT_SOURCE_DIR}/view.hpp" ) diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index 97390eab..b5f3f265 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -49,29 +49,31 @@ namespace rtl { //name of the namespace as supplied by the user. std::string m_namespace; + mutable std::vector m_functorsMeta; + //FunctorId acts as a hash-key to look up the functor in table. multiple 'FunctoreId' for overloaded functors. mutable std::vector m_functorIds; private: Function(const std::string_view pNamespace, const std::string_view pClassName, - const std::string_view pFuncName, const detail::FunctorId& pFunctorId, + const std::string_view pFuncName, const type_meta& pFunctorsMeta, const detail::FunctorId& pFunctorId, const std::size_t pRecordTypeId, const detail::methodQ pQualifier); void addOverload(const Function& pOtherFunc) const; protected: - Function(const Function& pOther, const detail::FunctorId& pFunctorId, + Function(const Function& pOther, const type_meta& pFunctorsMeta, const detail::FunctorId& pFunctorId, const std::string_view pFunctorName); const std::size_t hasSignatureId(const std::size_t pSignatureId) const; const detail::FunctorId* hasFunctorId(const std::size_t pSignatureId) const; - std::pair getLambdaByNormalId(const std::size_t pSignatureId) const; + std::pair, bool> getLambdaByNormalId(const std::size_t pSignatureId) const; - constexpr const detail::FunctorId* getLambdaByStrictId(const std::size_t pSignatureId) const; + constexpr std::optional getLambdaByStrictId(const std::size_t pSignatureId) const; GETTER(detail::methodQ, Qualifier, m_qualifier); @@ -84,6 +86,7 @@ namespace rtl { GETTER_CREF(std::string, RecordName, m_record); GETTER_CREF(std::string, Namespace, m_namespace); GETTER_CREF(std::string, FunctionName, m_function); + GETTER_CREF(std::vector, FunctorsMeta, m_functorsMeta) GETTER_CREF(std::vector, Functors, m_functorIds); Function() = default; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 38453edb..3cbe88f4 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -29,7 +29,7 @@ namespace rtl template inline constexpr const detail::HopFunction Function::argsT() const { - return detail::Hopper<>{ m_functorIds }.argsT(); + return detail::Hopper<>{ m_functorsMeta }.argsT(); } @@ -76,41 +76,41 @@ namespace rtl } - inline constexpr const detail::FunctorId* Function::getLambdaByStrictId(const std::size_t pSignatureId) const + inline constexpr std::optional Function::getLambdaByStrictId(const std::size_t pSignatureId) const { //simple linear-search, efficient for small set of elements. - for (const auto& functorId : m_functorIds) { - if (pSignatureId == functorId.get_lambda().get_strict_sign_id()) [[likely]] { - return &functorId; + for (const auto& functorMeta : m_functorsMeta) { + if (pSignatureId == functorMeta.get_strict_args_id()) [[likely]] { + return { functorMeta }; } } - return nullptr; + return std::nullopt; } - ForceInline std::pair Function::getLambdaByNormalId(const std::size_t pSignatureId) const + ForceInline std::pair, bool> Function::getLambdaByNormalId(const std::size_t pSignatureId) const { - const detail::FunctorId* functorId = getLambdaByStrictId(pSignatureId); - if (functorId != nullptr) { - return { functorId, false }; + std::optional functorMeta = getLambdaByStrictId(pSignatureId); + if (functorMeta) { + return { functorMeta, false }; } std::size_t index = rtl::index_none; - for (int i = 0; i < m_functorIds.size(); i++) + for (int i = 0; i < m_functorsMeta.size(); i++) { - if (pSignatureId == m_functorIds[i].get_lambda().get_normal_sign_id()) [[likely]] { + if (pSignatureId == m_functorsMeta[i].get_normal_args_id()) [[likely]] { if (index == rtl::index_none) { index = i; } - else return { nullptr, true }; + else return { std::nullopt, true }; } } if (index != rtl::index_none) { - auto isAnyNonConstRefInArgsT = (m_functorIds[index].get_lambda().is_any_ncref()); - return { (isAnyNonConstRefInArgsT ? nullptr : &m_functorIds[index]), isAnyNonConstRefInArgsT }; + auto isAnyNonConstRefInArgsT = (m_functorsMeta[index].is_any_arg_ncref()); + return { (isAnyNonConstRefInArgsT ? std::nullopt : std::make_optional(m_functorsMeta[index])), isAnyNonConstRefInArgsT }; } - return { nullptr, false }; + return { std::nullopt, false }; } -} +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 04f7b75b..4d5da65e 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -34,8 +34,8 @@ namespace rtl { { } //private ctor, called by 'Record' class. - Method(const Function& pFunction, const detail::FunctorId& pFunctorId, const std::string& pFunctorName) - : Function(pFunction, pFunctorId, pFunctorName) + Method(const Function& pFunction, const type_meta& pFunctorMeta, const detail::FunctorId& pFunctorId, const std::string& pFunctorName) + : Function(pFunction, pFunctorMeta, pFunctorId, pFunctorName) { } //invokes the constructor associated with this 'Method' diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 1542c1eb..b4cf7b95 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -32,7 +32,7 @@ namespace rtl template inline constexpr detail::Hopper Method::targetT() const { - return detail::Hopper{ getFunctorIds() }; + return detail::Hopper{ getFunctorsMeta() }; } diff --git a/ReflectionTemplateLib/rtl/inc/RObject.hpp b/ReflectionTemplateLib/rtl/inc/RObject.hpp index b84b4bac..67395e64 100644 --- a/ReflectionTemplateLib/rtl/inc/RObject.hpp +++ b/ReflectionTemplateLib/rtl/inc/RObject.hpp @@ -258,4 +258,4 @@ namespace rtl } } } -} +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Record.h b/ReflectionTemplateLib/rtl/inc/Record.h index f5293425..498adeb9 100644 --- a/ReflectionTemplateLib/rtl/inc/Record.h +++ b/ReflectionTemplateLib/rtl/inc/Record.h @@ -50,8 +50,7 @@ namespace rtl { : m_recordId(pRecordId) , m_namespace(pNamespace) , m_recordName(pRecordName) - { - } + { } GETTER_REF_C(MethodMap, FunctionsMap, m_methods) diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h new file mode 100644 index 00000000..ddf8dbe0 --- /dev/null +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -0,0 +1,79 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include +#include + +#include "functor.h" +#include "erasure_base.h" + +namespace rtl +{ + struct type_meta + { + type_meta(const dispatch::functor& p_functor) + : m_functor(p_functor) + { } + + type_meta() = default; + type_meta(type_meta&&) = default; + type_meta(const type_meta&) = default; + type_meta& operator=(type_meta&&) = default; + type_meta& operator=(const type_meta&) = default; + bool operator==(const type_meta&) const = default; + + GETTER_BOOL(_empty, !m_functor.has_value()) + GETTER_BOOL(_void, m_functor->get().m_is_void) + GETTER_BOOL(_any_arg_ncref, m_functor->get().m_is_any_arg_ncref) + + GETTER(std::string, _record_str, m_functor->get().m_recordStr) + GETTER(std::string, _return_str, m_functor->get().m_returnStr) + GETTER_CREF(std::vector, _args_id_arr, m_functor->get().m_argumentsId) + + GETTER(traits::uid_t, _record_id, m_functor->get().m_recordId) + GETTER(traits::uid_t, _normal_args_id, m_functor->get().m_normal_signId) + GETTER(traits::uid_t, _strict_args_id, m_functor->get().m_strict_signId) + + GETTER(detail::methodQ, _method_qual, m_functor->get().m_qualifier) + + GETTER_CREF(dispatch::lambda_base, _lambda, *(m_functor->get().m_lambda)) + GETTER_CREF(dispatch::erased_fnbase, _erased_lambda, *(m_functor->get().m_erased_lambda)) + + template + static type_meta add_function(return_t(*pFunctor)(signature_t...), std::size_t p_index); + + template + static type_meta add_method(return_t(record_t::* pFunctor)(signature_t...), std::size_t p_index); + + template + static type_meta add_method(return_t(record_t::* pFunctor)(signature_t...) const, std::size_t p_index); + + template + using lambda_fn_t = dispatch::lambda_function<_signature...>; + + template + using lambda_mth_t = dispatch::lambda_method; + + template + constexpr const lambda_fn_t* get_lambda_function(std::size_t p_argsId = 0) const; + + template + constexpr const lambda_mth_t* get_lambda_method(std::size_t p_recordId = 0, std::size_t p_argsId = 0) const; + + private: + + using functor_t = std::optional>; + + functor_t m_functor = std::nullopt; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.hpp b/ReflectionTemplateLib/rtl/inc/type_meta.hpp new file mode 100644 index 00000000..ec3354c1 --- /dev/null +++ b/ReflectionTemplateLib/rtl/inc/type_meta.hpp @@ -0,0 +1,84 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "type_meta.h" + +#include "lambda_base.h" +#include "erasure_base.h" + +#include "cache_method_ptr.h" +#include "cache_function_ptr.h" +#include "cache_method_ptr_const.h" + +#include "cache_lambda_method.h" +#include "cache_lambda_function.h" + +namespace rtl +{ + template + inline constexpr const type_meta::lambda_fn_t* type_meta::get_lambda_function(std::size_t p_argsId) const + { + return m_functor->get().m_lambda->to_function(p_argsId); + } + + template + inline constexpr const type_meta::lambda_mth_t* type_meta::get_lambda_method(std::size_t p_recordId, std::size_t p_argsId) const + { + return m_functor->get().m_lambda->to_method(p_recordId, p_argsId); + } + + template + inline type_meta type_meta::add_function(return_t(*pFunctor)(signature_t...), std::size_t p_index) + { + auto& fc = cache::function_ptr::instance(); + auto& lc = cache::lambda_function::instance(); + + auto& functor = fc.push(pFunctor, p_index); + auto [lambda, elambda] = lc.push(functor); + + functor.set_lambda(lambda); + functor.set_erased_lambda(elambda); + + return type_meta(functor); + } + + template + inline type_meta type_meta::add_method(return_t(record_t::* pFunctor)(signature_t...), std::size_t p_index) + { + auto& fc = cache::method_ptr::instance(); + auto& lc = cache::lambda_method::instance(); + + auto& functor = fc.push(pFunctor, p_index); + auto [lambda, elambda] = lc.push(functor); + + functor.set_lambda(lambda); + functor.set_erased_lambda(elambda); + + return type_meta(functor); + } + + template + inline type_meta type_meta::add_method(return_t(record_t::* pFunctor)(signature_t...) const, std::size_t p_index) + { + auto& fc = cache::method_ptr::instance(); + auto& lc = cache::lambda_method::instance(); + + auto& functor = fc.push(pFunctor, p_index); + auto [lambda, elambda] = lc.push(functor); + + functor.set_lambda(lambda); + functor.set_erased_lambda(elambda); + + return type_meta(functor); + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index dfb1259a..b5ab9dba 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -11,8 +11,6 @@ #pragma once -#include "rtl_constants.h" - namespace rtl { struct Return; @@ -25,6 +23,8 @@ namespace rtl class CxxMirror; + struct type_meta; + template struct function; @@ -35,6 +35,8 @@ namespace rtl { struct FunctorId; + struct RObjectId; + template class FunctorContainer; @@ -69,6 +71,8 @@ namespace rtl struct lambda_base; + struct erased_fnbase; + template struct lambda_function; @@ -84,19 +88,16 @@ namespace rtl template struct const_method_ptr; - namespace erase - { - template - struct erased_hopper; + template + struct erased_return_fn; - template - struct erased_hopper_rec; + template + struct erased_return_fn_rec; - template - struct aware_hopper; + template + struct aware_hopper; - template - struct aware_hopper_rec; - } + template + struct aware_hopper_rec; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/src/Function.cpp b/ReflectionTemplateLib/rtl/src/Function.cpp index 94db0f1c..a482016d 100644 --- a/ReflectionTemplateLib/rtl/src/Function.cpp +++ b/ReflectionTemplateLib/rtl/src/Function.cpp @@ -13,6 +13,7 @@ #include "Function.h" #include "FunctorId.h" +#include "type_meta.h" namespace rtl { @@ -25,13 +26,14 @@ namespace rtl * pQualifier - whether the member-function is const or non-const. methodQ::None for non-member & static-member functions. * 'Function' object is created for every functor (member/non-member) being registered. */ Function::Function(const std::string_view pNamespace, const std::string_view pRecord, - const std::string_view pFunction, const detail::FunctorId& pFunctorId, + const std::string_view pFunction, const type_meta& pFunctorsMeta, const detail::FunctorId& pFunctorId, const std::size_t pRecordTypeId, const detail::methodQ pQualifier) : m_qualifier(pQualifier) , m_recordTypeId(pRecordTypeId) , m_record(pRecord) , m_function(pFunction) , m_namespace(pNamespace) + , m_functorsMeta({ pFunctorsMeta }) , m_functorIds({ pFunctorId }) { } @@ -44,13 +46,14 @@ namespace rtl * the copy-constructor's 'FunctorId' is added to the 'Function' object associated with a constructor while registration. * the very first registration of constructor adds the copy-constructor lambda in the functor-container and sends its 'FunctorId' with the 'Function' object associated with a constructor. -*/ Function::Function(const Function& pOther, const detail::FunctorId& pFunctorId, +*/ Function::Function(const Function& pOther, const type_meta& pFunctorsMeta, const detail::FunctorId& pFunctorId, const std::string_view pFunctorName) : m_qualifier(pOther.m_qualifier) , m_recordTypeId(pOther.m_recordTypeId) , m_record(pOther.m_record) , m_function(pFunctorName) , m_namespace(pOther.m_namespace) + , m_functorsMeta({ pFunctorsMeta }) , m_functorIds({ pFunctorId }) { } @@ -76,5 +79,6 @@ namespace rtl } //add the 'functorId' of the overloaded functor. m_functorIds.push_back(pOtherFunc.m_functorIds[0]); + m_functorsMeta.push_back(pOtherFunc.m_functorsMeta[0]); } } \ No newline at end of file From d4d39658b8cf897cc27a0f676e333255b5c215b6 Mon Sep 17 00:00:00 2001 From: neeraj Date: Mon, 20 Oct 2025 21:18:13 +0530 Subject: [PATCH 100/148] gcc/clang compile error fix. --- ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h | 1 + ReflectionTemplateLib/rtl/inc/type_meta.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 1c4807db..0827577c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -11,6 +11,7 @@ #pragma once +#include "type_meta.h" #include "rtl_forward_decls.h" namespace rtl::detail diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h index ddf8dbe0..fef736ba 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.h +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -30,7 +30,6 @@ namespace rtl type_meta(const type_meta&) = default; type_meta& operator=(type_meta&&) = default; type_meta& operator=(const type_meta&) = default; - bool operator==(const type_meta&) const = default; GETTER_BOOL(_empty, !m_functor.has_value()) GETTER_BOOL(_void, m_functor->get().m_is_void) From 6c0f153200d28d32df834cc28ccaa1c834ee17fd Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 21 Oct 2025 00:15:51 +0530 Subject: [PATCH 101/148] rename/refactor --- .../rtl/cache/cache_lambda_function.h | 10 +++++----- .../rtl/cache/cache_lambda_method.h | 12 ++++++------ .../rtl/detail/inc/FunctionCaller.hpp | 2 +- .../rtl/detail/inc/MethodInvoker.hpp | 2 +- ReflectionTemplateLib/rtl/dispatch/functor.h | 4 ++-- .../rtl/dispatch/lambda_base.h | 6 +++--- .../rtl/dispatch/lambda_function.h | 4 ++-- .../rtl/dispatch/lambda_method.h | 4 ++-- .../rtl/erasure/CMakeLists.txt | 12 ++++++------ .../{aware_hopper.h => aware_return_fn.h} | 12 ++++++------ ...ware_hopper_rec.h => aware_return_fn_rec.h} | 16 ++++++++-------- ...rec_const.h => aware_return_fn_rec_const.h} | 16 ++++++++-------- .../{erasure_base.h => erase_fn_base.h} | 18 +++++++++--------- .../{erased_hopper.h => erase_return_fn.h} | 12 ++++++------ ...ased_hopper_rec.h => erase_return_fn_rec.h} | 8 ++++---- ReflectionTemplateLib/rtl/inc/type_meta.h | 4 ++-- ReflectionTemplateLib/rtl/inc/type_meta.hpp | 2 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 10 +++++----- 18 files changed, 77 insertions(+), 77 deletions(-) rename ReflectionTemplateLib/rtl/erasure/{aware_hopper.h => aware_return_fn.h} (84%) rename ReflectionTemplateLib/rtl/erasure/{aware_hopper_rec.h => aware_return_fn_rec.h} (85%) rename ReflectionTemplateLib/rtl/erasure/{aware_hopper_rec_const.h => aware_return_fn_rec_const.h} (85%) rename ReflectionTemplateLib/rtl/erasure/{erasure_base.h => erase_fn_base.h} (67%) rename ReflectionTemplateLib/rtl/erasure/{erased_hopper.h => erase_return_fn.h} (87%) rename ReflectionTemplateLib/rtl/erasure/{erased_hopper_rec.h => erase_return_fn_rec.h} (88%) diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index 97e1c6d5..c020de36 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -14,7 +14,7 @@ #include #include "lambda_function.h" -#include "aware_hopper.h" +#include "aware_return_fn.h" namespace rtl::cache { @@ -27,11 +27,11 @@ namespace rtl::cache return instance_; } - std::pair push(const dispatch::functor& p_functor) const + std::pair push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(dispatch::aware_hopper(p_functor)); + m_erasure_cache.push_back(dispatch::aware_return_fn(p_functor)); - const dispatch::erased_fnbase& eb = m_erasure_cache.back(); + const dispatch::erase_fn_base& eb = m_erasure_cache.back(); m_cache.push_back(dispatch::lambda_function(p_functor, eb)); @@ -47,7 +47,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_function() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index ae86aeca..42628953 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -14,8 +14,8 @@ #include #include "lambda_method.h" -#include "aware_hopper_rec.h" -#include "aware_hopper_rec_const.h" +#include "aware_return_fn_rec.h" +#include "aware_return_fn_rec_const.h" namespace rtl::cache { @@ -28,11 +28,11 @@ namespace rtl::cache return instance_; } - std::pair push(const dispatch::functor& p_functor) const + std::pair push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(dispatch::aware_hopper_rec(p_functor)); + m_erasure_cache.push_back(dispatch::aware_return_fn_rec(p_functor)); - const dispatch::erased_fnbase& eb = m_erasure_cache.back(); + const dispatch::erase_fn_base& eb = m_erasure_cache.back(); m_cache.push_back(dispatch::lambda_method(p_functor, eb)); @@ -48,7 +48,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_method() = default; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index eddcdc7f..c3ce990f 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -16,7 +16,7 @@ #include "FunctionCaller.h" #include "FunctorContainer.h" -#include "erased_hopper.h" +#include "erase_return_fn.h" #include "rtl_function_erased_return.h" namespace rtl::detail diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 24c51356..2ea4eb89 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -15,7 +15,7 @@ #include "RObject.h" #include "MethodInvoker.h" #include "MethodContainer.h" -#include "erased_hopper_rec.h" +#include "erase_return_fn_rec.h" #include "rtl_method_erased_return.h" diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 010fb7bf..7d1f47e7 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -47,13 +47,13 @@ namespace rtl::dispatch m_lambda = p_lambda; } - constexpr void set_erased_lambda(const dispatch::erased_fnbase* p_elambda) const { + constexpr void set_erased_lambda(const dispatch::erase_fn_base* p_elambda) const { m_erased_lambda = p_elambda; } mutable const dispatch::lambda_base* m_lambda = nullptr; - mutable const dispatch::erased_fnbase* m_erased_lambda = nullptr; + mutable const dispatch::erase_fn_base* m_erased_lambda = nullptr; friend rtl::type_meta; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index cc280644..c053765a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -13,7 +13,7 @@ #include "rtl_traits.h" #include "functor.h" -#include "erasure_base.h" +#include "erase_fn_base.h" namespace rtl::dispatch { @@ -65,13 +65,13 @@ namespace rtl::dispatch GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_signId) GETTER_CREF(detail::RObjectId, _return_id, m_erasure.m_return_id) - lambda_base(const functor& p_functor, const erased_fnbase& p_erasure) noexcept + lambda_base(const functor& p_functor, const erase_fn_base& p_erasure) noexcept : m_functor(p_functor) , m_erasure(p_erasure) { } const functor& m_functor; - const erased_fnbase& m_erasure; + const erase_fn_base& m_erasure; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index b6f8c7be..f7fc4181 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -14,7 +14,7 @@ #include "lambda_base.h" #include "rtl_function.h" #include "function_ptr.h" -#include "erased_hopper.h" +#include "erase_return_fn.h" namespace rtl::dispatch { @@ -41,7 +41,7 @@ namespace rtl::dispatch return hopper_t(); } - lambda_function(const functor& p_functor, const erased_fnbase& p_erasure) noexcept + lambda_function(const functor& p_functor, const erase_fn_base& p_erasure) noexcept : lambda_base(p_functor, p_erasure) { } }; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 4207ddf3..a677883b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -14,7 +14,7 @@ #include "lambda_base.h" #include "method_ptr.h" -#include "erased_hopper_rec.h" +#include "erase_return_fn_rec.h" #include "rtl_method.h" #include "rtl_method_const.h" @@ -59,7 +59,7 @@ namespace rtl::dispatch return hopper_ct(); } - lambda_method(const functor& p_functor, const erased_fnbase& p_erasure) noexcept + lambda_method(const functor& p_functor, const erase_fn_base& p_erasure) noexcept : lambda_base(p_functor, p_erasure) { } }; diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt index a4623933..5dc08f62 100644 --- a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -3,13 +3,13 @@ # Collect headers in this folder (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/erasure_base.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erased_hopper.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erased_hopper_rec.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_fn_base.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_return_fn.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_return_fn_rec.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_hopper.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_hopper_rec.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_hopper_rec_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_return_fn.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_return_fn_rec.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_return_fn_rec_const.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h b/ReflectionTemplateLib/rtl/erasure/aware_return_fn.h similarity index 84% rename from ReflectionTemplateLib/rtl/erasure/aware_hopper.h rename to ReflectionTemplateLib/rtl/erasure/aware_return_fn.h index 1e3cfb6c..246c50f6 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_return_fn.h @@ -12,21 +12,21 @@ #pragma once #include -#include "erased_hopper.h" +#include "erase_return_fn.h" namespace rtl::dispatch { template - struct aware_hopper : public erased_return_fn...> + struct aware_return_fn : public erase_return_fn...> { - using base_t = erased_return_fn...>; + using base_t = erase_return_fn...>; constexpr static bool isConstCastSafe = (!traits::is_const_v); - aware_hopper(const dispatch::functor& p_functor) + aware_return_fn(const dispatch::functor& p_functor) : base_t( p_functor, - p_functor.is_void() ? aware_hopper::get_lambda_void() : decltype(aware_hopper::get_lambda_void()){}, - !p_functor.is_void() ? aware_hopper::get_lambda_any_return() : decltype(aware_hopper::get_lambda_any_return()){}, + p_functor.is_void() ? aware_return_fn::get_lambda_void() : decltype(aware_return_fn::get_lambda_void()){}, + !p_functor.is_void() ? aware_return_fn::get_lambda_any_return() : decltype(aware_return_fn::get_lambda_any_return()){}, detail::RObjectId::create(isConstCastSafe) ) { } diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec.h similarity index 85% rename from ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h rename to ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec.h index fb49a395..82cba8cb 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec.h @@ -14,23 +14,23 @@ #include #include "RObjectId.h" -#include "erased_hopper_rec.h" +#include "erase_return_fn_rec.h" namespace rtl::dispatch { template - struct aware_hopper_rec : public erased_return_fn_rec...> + struct aware_return_fn_rec : public erase_return_fn_rec...> { - using base_t = erased_return_fn_rec...>; + using base_t = erase_return_fn_rec...>; constexpr static bool isConstCastSafe = (!traits::is_const_v); - aware_hopper_rec(const dispatch::functor& p_functor) + aware_return_fn_rec(const dispatch::functor& p_functor) : base_t( p_functor, - p_functor.is_void() ? aware_hopper_rec::get_lambda_void() : decltype(aware_hopper_rec::get_lambda_void()){}, - !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret() : decltype(aware_hopper_rec::get_lambda_any_ret()){}, - p_functor.is_void() ? aware_hopper_rec::get_lambda_void_robj() : decltype(aware_hopper_rec::get_lambda_void_robj()){}, - !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret_robj() : decltype(aware_hopper_rec::get_lambda_any_ret_robj()){}, + p_functor.is_void() ? aware_return_fn_rec::get_lambda_void() : decltype(aware_return_fn_rec::get_lambda_void()){}, + !p_functor.is_void() ? aware_return_fn_rec::get_lambda_any_ret() : decltype(aware_return_fn_rec::get_lambda_any_ret()){}, + p_functor.is_void() ? aware_return_fn_rec::get_lambda_void_robj() : decltype(aware_return_fn_rec::get_lambda_void_robj()){}, + !p_functor.is_void() ? aware_return_fn_rec::get_lambda_any_ret_robj() : decltype(aware_return_fn_rec::get_lambda_any_ret_robj()){}, detail::RObjectId::create(isConstCastSafe) ) { } diff --git a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec_const.h similarity index 85% rename from ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h rename to ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec_const.h index 4bfdb4bb..e191dce0 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_hopper_rec_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec_const.h @@ -14,23 +14,23 @@ #include #include "RObjectId.h" -#include "erased_hopper_rec.h" +#include "erase_return_fn_rec.h" namespace rtl::dispatch { template - struct aware_hopper_rec : public erased_return_fn_rec...> + struct aware_return_fn_rec : public erase_return_fn_rec...> { - using base_t = erased_return_fn_rec...>; + using base_t = erase_return_fn_rec...>; constexpr static bool isConstCastSafe = (!traits::is_const_v); - aware_hopper_rec(const dispatch::functor& p_functor) + aware_return_fn_rec(const dispatch::functor& p_functor) : base_t( p_functor, - p_functor.is_void() ? aware_hopper_rec::get_lambda_void() : decltype(aware_hopper_rec::get_lambda_void()){}, - !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret() : decltype(aware_hopper_rec::get_lambda_any_ret()){}, - p_functor.is_void() ? aware_hopper_rec::get_lambda_void_robj() : decltype(aware_hopper_rec::get_lambda_void_robj()){}, - !p_functor.is_void() ? aware_hopper_rec::get_lambda_any_ret_robj() : decltype(aware_hopper_rec::get_lambda_any_ret_robj()){}, + p_functor.is_void() ? aware_return_fn_rec::get_lambda_void() : decltype(aware_return_fn_rec::get_lambda_void()){}, + !p_functor.is_void() ? aware_return_fn_rec::get_lambda_any_ret() : decltype(aware_return_fn_rec::get_lambda_any_ret()){}, + p_functor.is_void() ? aware_return_fn_rec::get_lambda_void_robj() : decltype(aware_return_fn_rec::get_lambda_void_robj()){}, + !p_functor.is_void() ? aware_return_fn_rec::get_lambda_any_ret_robj() : decltype(aware_return_fn_rec::get_lambda_any_ret_robj()){}, detail::RObjectId::create(isConstCastSafe) ) { } diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_base.h b/ReflectionTemplateLib/rtl/erasure/erase_fn_base.h similarity index 67% rename from ReflectionTemplateLib/rtl/erasure/erasure_base.h rename to ReflectionTemplateLib/rtl/erasure/erase_fn_base.h index 0dbb9319..6c066a12 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_base.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_fn_base.h @@ -17,27 +17,27 @@ namespace rtl::dispatch { - struct erased_fnbase + struct erase_fn_base { template - using ehop_t = erased_return_fn...>; + using erasure_t = erase_return_fn...>; template - constexpr const ehop_t& to_erased_return() const + constexpr const erasure_t& to_erased_return() const { - return static_cast&>(*this); + return static_cast&>(*this); } - + template - using ehop_rt = erased_return_fn_rec...>; + using erasure_rt = erase_return_fn_rec...>; template - constexpr const ehop_rt& to_erased_return_rec() const + constexpr const erasure_rt& to_erased_return_rec() const { - return static_cast&>(*this); + return static_cast&>(*this); } - erased_fnbase(const dispatch::functor& p_functor, const detail::RObjectId& p_ret_id) noexcept + erase_fn_base(const dispatch::functor& p_functor, const detail::RObjectId& p_ret_id) noexcept : m_functor(p_functor) , m_return_id(p_ret_id) { } diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h b/ReflectionTemplateLib/rtl/erasure/erase_return_fn.h similarity index 87% rename from ReflectionTemplateLib/rtl/erasure/erased_hopper.h rename to ReflectionTemplateLib/rtl/erasure/erase_return_fn.h index c8fb1d86..98152ed0 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_return_fn.h @@ -13,12 +13,12 @@ #include -#include "erasure_base.h" +#include "erase_fn_base.h" namespace rtl::dispatch { template - struct erased_return_fn : public erased_fnbase + struct erase_return_fn : public erase_fn_base { using lambda_vt = std::function; @@ -43,22 +43,22 @@ namespace rtl::dispatch lambda_robj_rt m_rmhopper; - erased_return_fn( const dispatch::functor& p_functor, + erase_return_fn( const dispatch::functor& p_functor, const lambda_vt& p_void_hop, const lambda_rt& p_any_ret_hop, const detail::RObjectId& p_ret_id ) noexcept - : erased_fnbase(p_functor, p_ret_id) + : erase_fn_base(p_functor, p_ret_id) , m_vhopper(p_void_hop) , m_rhopper(p_any_ret_hop) { } - erased_return_fn( const dispatch::functor& p_functor, + erase_return_fn( const dispatch::functor& p_functor, const lambda_robj_vt& p_void_method_hop, const lambda_robj_rt& p_any_ret_method_hop, const detail::RObjectId& p_ret_id ) noexcept - : erased_fnbase(p_functor, p_ret_id) + : erase_fn_base(p_functor, p_ret_id) , m_vmhopper(p_void_method_hop) , m_rmhopper(p_any_ret_method_hop) { } diff --git a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h b/ReflectionTemplateLib/rtl/erasure/erase_return_fn_rec.h similarity index 88% rename from ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h rename to ReflectionTemplateLib/rtl/erasure/erase_return_fn_rec.h index 014997c4..813d8bc5 100644 --- a/ReflectionTemplateLib/rtl/erasure/erased_hopper_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_return_fn_rec.h @@ -14,13 +14,13 @@ #include #include -#include "erased_hopper.h" +#include "erase_return_fn.h" #include "rtl_forward_decls.h" namespace rtl::dispatch { template - struct erased_return_fn_rec : public erased_return_fn + struct erase_return_fn_rec : public erase_return_fn { using lambda_vt = std::function; @@ -36,9 +36,9 @@ namespace rtl::dispatch lambda_rt m_rhopper; - using base_t = erased_return_fn; + using base_t = erase_return_fn; - erased_return_fn_rec( const dispatch::functor& p_functor, + erase_return_fn_rec( const dispatch::functor& p_functor, const lambda_vt& p_void_hop, const lambda_rt& p_any_ret_hop, const base_t::lambda_robj_vt& p_void_robj_hop, diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h index fef736ba..af3f4c52 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.h +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -15,7 +15,7 @@ #include #include "functor.h" -#include "erasure_base.h" +#include "erase_fn_base.h" namespace rtl { @@ -46,7 +46,7 @@ namespace rtl GETTER(detail::methodQ, _method_qual, m_functor->get().m_qualifier) GETTER_CREF(dispatch::lambda_base, _lambda, *(m_functor->get().m_lambda)) - GETTER_CREF(dispatch::erased_fnbase, _erased_lambda, *(m_functor->get().m_erased_lambda)) + GETTER_CREF(dispatch::erase_fn_base, _erased_lambda, *(m_functor->get().m_erased_lambda)) template static type_meta add_function(return_t(*pFunctor)(signature_t...), std::size_t p_index); diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.hpp b/ReflectionTemplateLib/rtl/inc/type_meta.hpp index ec3354c1..cb3eb496 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.hpp +++ b/ReflectionTemplateLib/rtl/inc/type_meta.hpp @@ -14,7 +14,7 @@ #include "type_meta.h" #include "lambda_base.h" -#include "erasure_base.h" +#include "erase_fn_base.h" #include "cache_method_ptr.h" #include "cache_function_ptr.h" diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index b5ab9dba..fbf45817 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -71,7 +71,7 @@ namespace rtl struct lambda_base; - struct erased_fnbase; + struct erase_fn_base; template struct lambda_function; @@ -89,15 +89,15 @@ namespace rtl struct const_method_ptr; template - struct erased_return_fn; + struct erase_return_fn; template - struct erased_return_fn_rec; + struct erase_return_fn_rec; template - struct aware_hopper; + struct aware_return_fn; template - struct aware_hopper_rec; + struct aware_return_fn_rec; } } \ No newline at end of file From aed37df635a882e77de7d3254efb81ccce685cf6 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 22 Oct 2025 14:51:14 +0530 Subject: [PATCH 102/148] type-erasure for methods, design improved. --- .../rtl/cache/cache_lambda_function.h | 12 +- .../rtl/cache/cache_lambda_method.h | 16 +- .../rtl/detail/inc/FunctionCaller.hpp | 6 +- .../rtl/detail/inc/MethodInvoker.hpp | 7 +- ReflectionTemplateLib/rtl/dispatch/functor.h | 6 +- .../rtl/dispatch/lambda_base.h | 6 +- .../rtl/dispatch/lambda_function.h | 3 +- .../rtl/dispatch/lambda_method.h | 3 +- .../rtl/erasure/CMakeLists.txt | 15 +- .../{aware_return_fn.h => aware_return.h} | 26 +-- .../rtl/erasure/aware_return_fn_rec_const.h | 131 ------------ ...eturn_fn_rec.h => aware_return_n_target.h} | 113 +++++++--- .../rtl/erasure/aware_return_n_target_const.h | 194 ++++++++++++++++++ .../rtl/erasure/erase_fn_base.h | 49 ----- .../rtl/erasure/erase_return.h | 43 ++++ ...n_fn_rec.h => erase_return_aware_target.h} | 23 +-- .../rtl/erasure/erase_return_fn.h | 66 ------ .../rtl/erasure/erase_return_n_target.h | 57 +++++ .../rtl/erasure/erase_target_aware_return.h | 48 +++++ .../rtl/erasure/erasure_base.h | 57 +++++ .../rtl/erasure/erasure_base.hpp | 36 ++++ ReflectionTemplateLib/rtl/inc/type_meta.h | 4 +- ReflectionTemplateLib/rtl/inc/type_meta.hpp | 8 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 16 +- 24 files changed, 600 insertions(+), 345 deletions(-) rename ReflectionTemplateLib/rtl/erasure/{aware_return_fn.h => aware_return.h} (75%) delete mode 100644 ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec_const.h rename ReflectionTemplateLib/rtl/erasure/{aware_return_fn_rec.h => aware_return_n_target.h} (50%) create mode 100644 ReflectionTemplateLib/rtl/erasure/aware_return_n_target_const.h delete mode 100644 ReflectionTemplateLib/rtl/erasure/erase_fn_base.h create mode 100644 ReflectionTemplateLib/rtl/erasure/erase_return.h rename ReflectionTemplateLib/rtl/erasure/{erase_return_fn_rec.h => erase_return_aware_target.h} (63%) delete mode 100644 ReflectionTemplateLib/rtl/erasure/erase_return_fn.h create mode 100644 ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h create mode 100644 ReflectionTemplateLib/rtl/erasure/erase_target_aware_return.h create mode 100644 ReflectionTemplateLib/rtl/erasure/erasure_base.h create mode 100644 ReflectionTemplateLib/rtl/erasure/erasure_base.hpp diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h index c020de36..370b2677 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_function.h @@ -14,7 +14,7 @@ #include #include "lambda_function.h" -#include "aware_return_fn.h" +#include "aware_return.h" namespace rtl::cache { @@ -27,15 +27,15 @@ namespace rtl::cache return instance_; } - std::pair push(const dispatch::functor& p_functor) const + std::pair push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(dispatch::aware_return_fn(p_functor)); + m_erasure_cache.emplace_back(dispatch::aware_return()); - const dispatch::erase_fn_base& eb = m_erasure_cache.back(); + const dispatch::erasure_base& eb = m_erasure_cache.back(); m_cache.push_back(dispatch::lambda_function(p_functor, eb)); - return { &m_cache.back(), &m_erasure_cache.back() }; + return { &m_cache.back(), &eb }; } lambda_function(lambda_function&&) = delete; @@ -47,7 +47,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_function() = default; }; diff --git a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h index 42628953..b50b4781 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h +++ b/ReflectionTemplateLib/rtl/cache/cache_lambda_method.h @@ -14,8 +14,8 @@ #include #include "lambda_method.h" -#include "aware_return_fn_rec.h" -#include "aware_return_fn_rec_const.h" +#include "aware_return_n_target.h" +#include "aware_return_n_target_const.h" namespace rtl::cache { @@ -28,15 +28,15 @@ namespace rtl::cache return instance_; } - std::pair push(const dispatch::functor& p_functor) const + std::pair push(const dispatch::functor& p_functor) const { - m_erasure_cache.push_back(dispatch::aware_return_fn_rec(p_functor)); + m_erasure_cache.emplace_back(dispatch::aware_return_n_target()); - const dispatch::erase_fn_base& eb = m_erasure_cache.back(); - + auto& eb = m_erasure_cache.back(); + eb.init_base(); m_cache.push_back(dispatch::lambda_method(p_functor, eb)); - return { &m_cache.back(), &m_erasure_cache.back() }; + return { &m_cache.back(), &eb }; } lambda_method(lambda_method&&) = delete; @@ -48,7 +48,7 @@ namespace rtl::cache // No reallocation occurs; original objects stay intact mutable std::list> m_cache; - mutable std::list> m_erasure_cache; + mutable std::list> m_erasure_cache; lambda_method() = default; }; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index c3ce990f..41a9bdfc 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -16,7 +16,7 @@ #include "FunctionCaller.h" #include "FunctorContainer.h" -#include "erase_return_fn.h" +#include "erasure_base.h" #include "rtl_function_erased_return.h" namespace rtl::detail @@ -106,8 +106,8 @@ namespace rtl::detail { if (!fnMeta.is_empty()) { - auto erasedRetFn = fnMeta.get_erased_lambda() - .template to_erased_return...>(); + auto& erasedRetFn = fnMeta.get_erased_lambda() + .template to_erased_return...>(); if (fnMeta.is_void()) { isReturnTvoid = true; erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 2ea4eb89..66d2b4e8 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -15,9 +15,10 @@ #include "RObject.h" #include "MethodInvoker.h" #include "MethodContainer.h" -#include "erase_return_fn_rec.h" +#include "erasure_base.h" #include "rtl_method_erased_return.h" +#include "erasure_base.hpp" namespace rtl::detail { @@ -185,8 +186,8 @@ namespace rtl::detail { if (!fnMeta.is_empty()) { - auto erasedRetFn = fnMeta.get_erased_lambda() - .template to_erased_return_rec...>(); + auto& erasedRetFn = fnMeta.get_erased_lambda() + .template to_erased_return_aware_target...>(); if (fnMeta.is_void()) { isReturnTvoid = true; erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 7d1f47e7..27d3327f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -47,13 +47,13 @@ namespace rtl::dispatch m_lambda = p_lambda; } - constexpr void set_erased_lambda(const dispatch::erase_fn_base* p_elambda) const { - m_erased_lambda = p_elambda; + constexpr void set_erasure(const dispatch::erasure_base* p_elambda) const { + m_erasure = p_elambda; } mutable const dispatch::lambda_base* m_lambda = nullptr; - mutable const dispatch::erase_fn_base* m_erased_lambda = nullptr; + mutable const dispatch::erasure_base* m_erasure = nullptr; friend rtl::type_meta; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index c053765a..7a43e492 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -13,7 +13,7 @@ #include "rtl_traits.h" #include "functor.h" -#include "erase_fn_base.h" +#include "erasure_base.h" namespace rtl::dispatch { @@ -65,13 +65,13 @@ namespace rtl::dispatch GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_signId) GETTER_CREF(detail::RObjectId, _return_id, m_erasure.m_return_id) - lambda_base(const functor& p_functor, const erase_fn_base& p_erasure) noexcept + lambda_base(const functor& p_functor, const erasure_base& p_erasure) noexcept : m_functor(p_functor) , m_erasure(p_erasure) { } const functor& m_functor; - const erase_fn_base& m_erasure; + const erasure_base& m_erasure; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index f7fc4181..0f01e17b 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -14,7 +14,6 @@ #include "lambda_base.h" #include "rtl_function.h" #include "function_ptr.h" -#include "erase_return_fn.h" namespace rtl::dispatch { @@ -41,7 +40,7 @@ namespace rtl::dispatch return hopper_t(); } - lambda_function(const functor& p_functor, const erase_fn_base& p_erasure) noexcept + lambda_function(const functor& p_functor, const erasure_base& p_erasure) noexcept : lambda_base(p_functor, p_erasure) { } }; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index a677883b..49b1327c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -14,7 +14,6 @@ #include "lambda_base.h" #include "method_ptr.h" -#include "erase_return_fn_rec.h" #include "rtl_method.h" #include "rtl_method_const.h" @@ -59,7 +58,7 @@ namespace rtl::dispatch return hopper_ct(); } - lambda_method(const functor& p_functor, const erase_fn_base& p_erasure) noexcept + lambda_method(const functor& p_functor, const erasure_base& p_erasure) noexcept : lambda_base(p_functor, p_erasure) { } }; diff --git a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt index 5dc08f62..193950ab 100644 --- a/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/erasure/CMakeLists.txt @@ -3,13 +3,16 @@ # Collect headers in this folder (absolute paths) set(LOCAL_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/erase_fn_base.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erase_return_fn.h" - "${CMAKE_CURRENT_SOURCE_DIR}/erase_return_fn_rec.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erasure_base.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erasure_base.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_return.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_return_n_target.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_return_aware_target.h" + "${CMAKE_CURRENT_SOURCE_DIR}/erase_target_aware_return.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_return_fn.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_return_fn_rec.h" - "${CMAKE_CURRENT_SOURCE_DIR}/aware_return_fn_rec_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_return.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_return_n_target.h" + "${CMAKE_CURRENT_SOURCE_DIR}/aware_return_n_target_const.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/erasure/aware_return_fn.h b/ReflectionTemplateLib/rtl/erasure/aware_return.h similarity index 75% rename from ReflectionTemplateLib/rtl/erasure/aware_return_fn.h rename to ReflectionTemplateLib/rtl/erasure/aware_return.h index 246c50f6..6df79f9f 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_return_fn.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_return.h @@ -12,29 +12,31 @@ #pragma once #include -#include "erase_return_fn.h" +#include "erase_return.h" namespace rtl::dispatch { template - struct aware_return_fn : public erase_return_fn...> + struct aware_return : public erase_return...> { - using base_t = erase_return_fn...>; + using this_t = aware_return; + using base_t = erase_return...>; - constexpr static bool isConstCastSafe = (!traits::is_const_v); + constexpr static bool is_void = (std::is_void_v); - aware_return_fn(const dispatch::functor& p_functor) - : base_t( p_functor, - p_functor.is_void() ? aware_return_fn::get_lambda_void() : decltype(aware_return_fn::get_lambda_void()){}, - !p_functor.is_void() ? aware_return_fn::get_lambda_any_return() : decltype(aware_return_fn::get_lambda_any_return()){}, - detail::RObjectId::create(isConstCastSafe) ) - { } + aware_return() + : base_t( is_void ? this_t::get_lambda_void() : decltype(this_t::get_lambda_void()) {}, + !is_void ? this_t::get_lambda_any_return() : decltype(this_t::get_lambda_any_return()) {}) + { + constexpr static bool is_const_cast_safe = (!traits::is_const_v); + base_t::m_return_id = detail::RObjectId::create(is_const_cast_safe); + } constexpr static auto get_lambda_void() noexcept { return [](const lambda_base& lambda, traits::normal_sign_t&&... params)-> auto { - if constexpr (std::is_void_v) + if constexpr (is_void) { auto fptr = lambda.template to_function() .template get_functor(); @@ -48,7 +50,7 @@ namespace rtl::dispatch { return [](const lambda_base& lambda, traits::normal_sign_t&&... params)-> auto { - if constexpr (!std::is_void_v) + if constexpr (!is_void) { auto fptr = lambda.template to_function() .template get_functor(); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec_const.h b/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec_const.h deleted file mode 100644 index e191dce0..00000000 --- a/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec_const.h +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include - -#include "RObjectId.h" -#include "erase_return_fn_rec.h" - -namespace rtl::dispatch -{ - template - struct aware_return_fn_rec : public erase_return_fn_rec...> - { - using base_t = erase_return_fn_rec...>; - - constexpr static bool isConstCastSafe = (!traits::is_const_v); - - aware_return_fn_rec(const dispatch::functor& p_functor) - : base_t( p_functor, - p_functor.is_void() ? aware_return_fn_rec::get_lambda_void() : decltype(aware_return_fn_rec::get_lambda_void()){}, - !p_functor.is_void() ? aware_return_fn_rec::get_lambda_any_ret() : decltype(aware_return_fn_rec::get_lambda_any_ret()){}, - p_functor.is_void() ? aware_return_fn_rec::get_lambda_void_robj() : decltype(aware_return_fn_rec::get_lambda_void_robj()){}, - !p_functor.is_void() ? aware_return_fn_rec::get_lambda_any_ret_robj() : decltype(aware_return_fn_rec::get_lambda_any_ret_robj()){}, - detail::RObjectId::create(isConstCastSafe) ) - { } - - constexpr static auto get_lambda_void() noexcept - { - return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&... params)-> auto - { - if constexpr (std::is_void_v) - { - auto mptr = lambda.template to_method() - .template get_functor(); - - (p_target.*mptr)(std::forward(params)...); - } - }; - } - - constexpr static auto get_lambda_void_robj() noexcept - { - return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto - { - if constexpr (std::is_void_v) - { - auto mptr = lambda.template to_method() - .template get_functor(); - - const auto& target = p_target.view()->get(); - - (target.*mptr)(std::forward(params)...); - } - }; - } - - constexpr static auto get_lambda_any_ret() noexcept - { - return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&...params)-> auto - { - if constexpr (!std::is_void_v) - { - auto mptr = lambda.template to_method() - .template get_functor(); - - auto&& ret_v = (p_target.*mptr)(std::forward(params)...); - - if constexpr (std::is_pointer_v) - { - using raw_t = std::remove_pointer_t; - return std::any(static_cast(ret_v)); - } - else if constexpr (std::is_reference_v) - { - using raw_t = std::remove_cv_t>; - return std::any(static_cast(&ret_v)); - } - else - { - using craw_t = std::add_const_t>; - return std::any(craw_t(std::forward(ret_v))); - } - } - else return std::any(); - }; - } - - constexpr static auto get_lambda_any_ret_robj() noexcept - { - return[](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto - { - if constexpr (!std::is_void_v) - { - auto mptr = lambda.template to_method() - .template get_functor(); - - const auto& target = p_target.view()->get(); - - auto&& ret_v = (target.*mptr)(std::forward(params)...); - - if constexpr (std::is_pointer_v) - { - using raw_t = std::remove_pointer_t; - return std::any(static_cast(ret_v)); - } - else if constexpr (std::is_reference_v) - { - using raw_t = std::remove_cv_t>; - return std::any(static_cast(&ret_v)); - } - else - { - using craw_t = std::add_const_t>; - return std::any(craw_t(std::forward(ret_v))); - } - } - else return std::any(); - }; - } - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec.h b/ReflectionTemplateLib/rtl/erasure/aware_return_n_target.h similarity index 50% rename from ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec.h rename to ReflectionTemplateLib/rtl/erasure/aware_return_n_target.h index 82cba8cb..9b99fbd0 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_return_fn_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_return_n_target.h @@ -14,31 +14,55 @@ #include #include "RObjectId.h" -#include "erase_return_fn_rec.h" +#include "erase_return_n_target.h" +#include "erase_return_aware_target.h" +#include "erase_target_aware_return.h" namespace rtl::dispatch { template - struct aware_return_fn_rec : public erase_return_fn_rec...> + struct aware_return_n_target : public erase_return_n_target...> { - using base_t = erase_return_fn_rec...>; + using this_t = aware_return_n_target; + using base_t = erase_return_n_target...>; + + using e_return_t = erase_return_aware_target...>; + using e_target_t = erase_target_aware_return...>; - constexpr static bool isConstCastSafe = (!traits::is_const_v); - - aware_return_fn_rec(const dispatch::functor& p_functor) - : base_t( p_functor, - p_functor.is_void() ? aware_return_fn_rec::get_lambda_void() : decltype(aware_return_fn_rec::get_lambda_void()){}, - !p_functor.is_void() ? aware_return_fn_rec::get_lambda_any_ret() : decltype(aware_return_fn_rec::get_lambda_any_ret()){}, - p_functor.is_void() ? aware_return_fn_rec::get_lambda_void_robj() : decltype(aware_return_fn_rec::get_lambda_void_robj()){}, - !p_functor.is_void() ? aware_return_fn_rec::get_lambda_any_ret_robj() : decltype(aware_return_fn_rec::get_lambda_any_ret_robj()){}, - detail::RObjectId::create(isConstCastSafe) ) - { } - - constexpr static auto get_lambda_void() noexcept + constexpr static bool is_void = (std::is_void_v); + + e_return_t e_return; + e_target_t e_target; + + aware_return_n_target() + : base_t( is_void ? this_t::e_return_e_target_fnv() : decltype(this_t::e_return_e_target_fnv()) {}, + !is_void ? this_t::e_return_e_target_fnr() : decltype(this_t::e_return_e_target_fnr()) {}) + + , e_return( is_void ? this_t::e_return_a_target_fnv() : decltype(this_t::e_return_a_target_fnv()) {}, + !is_void ? this_t::e_return_a_target_fnr() : decltype(this_t::e_return_a_target_fnr()) {}) + + , e_target( is_void ? this_t::e_target_a_return_fnv() : decltype(this_t::e_target_a_return_fnv()) {}, + !is_void ? this_t::e_target_a_return_fnr() : decltype(this_t::e_target_a_return_fnr()) {}) + { + constexpr static bool is_const_cast_safe = (!traits::is_const_v); + base_t::m_return_id = detail::RObjectId::create(is_const_cast_safe); + } + + void init_base() + { + e_return.m_return_id = base_t::m_return_id; + e_target.m_return_id = base_t::m_return_id; + + base_t::m_erased_return = &e_return; + base_t::m_erased_target = &e_target; + } + + // erased-return-aware-target-function-void + constexpr static auto e_return_a_target_fnv() noexcept { return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&... params)-> auto { - if constexpr (std::is_void_v) + if constexpr (is_void) { auto mptr = lambda.template to_method() .template get_functor(); @@ -48,11 +72,29 @@ namespace rtl::dispatch }; } - constexpr static auto get_lambda_void_robj() noexcept + // erased-target-aware-return-function-void + constexpr static auto e_target_a_return_fnv() noexcept + { + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> void + { + if constexpr (is_void) + { + auto mptr = lambda.template to_method() + .template get_functor(); + + const auto& target = p_target.view()->get(); + + (const_cast(target).*mptr)(std::forward(params)...); + } + }; + } + + // erased-return-erased-target-function-void + constexpr static auto e_return_e_target_fnv() noexcept { return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { - if constexpr (std::is_void_v) + if constexpr (is_void) { auto mptr = lambda.template to_method() .template get_functor(); @@ -64,11 +106,29 @@ namespace rtl::dispatch }; } - constexpr static auto get_lambda_any_ret() noexcept + // erased-target-aware-return-function-returns(return_t) + constexpr static auto e_target_a_return_fnr() noexcept + { + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> return_t + { + if constexpr (!is_void) + { + auto mptr = lambda.template to_method() + .template get_functor(); + + const auto& target = p_target.view()->get(); + + return (const_cast(target).*mptr)(std::forward(params)...); + } + }; + } + + // erased-return-aware-target-function-returns(std::any) + constexpr static auto e_return_a_target_fnr() noexcept { return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&...params)-> auto { - if constexpr (!std::is_void_v) + if constexpr (!is_void) { auto mptr = lambda.template to_method() .template get_functor(); @@ -87,19 +147,20 @@ namespace rtl::dispatch } else { - using craw_t = std::add_const_t>; - return std::any(craw_t(std::forward(ret_v))); + using raw_ct = std::add_const_t>; + return std::any(raw_ct(std::forward(ret_v))); } } else return std::any(); }; } - constexpr static auto get_lambda_any_ret_robj() noexcept + // erased-return-erased-target-function-returns(std::any) + constexpr static auto e_return_e_target_fnr() noexcept { return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto { - if constexpr (!std::is_void_v) + if constexpr (!is_void) { auto mptr = lambda.template to_method() .template get_functor(); @@ -120,8 +181,8 @@ namespace rtl::dispatch } else { - using craw_t = std::add_const_t>; - return std::any(craw_t(std::forward(ret_v))); + using raw_ct = std::add_const_t>; + return std::any(raw_ct(std::forward(ret_v))); } } else return std::any(); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_return_n_target_const.h b/ReflectionTemplateLib/rtl/erasure/aware_return_n_target_const.h new file mode 100644 index 00000000..532a6820 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/aware_return_n_target_const.h @@ -0,0 +1,194 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "RObjectId.h" +#include "erase_return_n_target.h" +#include "erase_return_aware_target.h" +#include "erase_target_aware_return.h" + +namespace rtl::dispatch +{ + template + struct aware_return_n_target : public erase_return_n_target...> + { + using this_t = aware_return_n_target; + using base_t = erase_return_n_target...>; + + using e_return_t = erase_return_aware_target...>; + using e_target_t = erase_target_aware_return...>; + + constexpr static bool is_void = (std::is_void_v); + + e_return_t e_return; + e_target_t e_target; + + aware_return_n_target(const aware_return_n_target&) = delete; + + aware_return_n_target() + : base_t( is_void ? this_t::e_return_e_target_fnv() : decltype(this_t::e_return_e_target_fnv()) {}, + !is_void ? this_t::e_return_e_target_fnr() : decltype(this_t::e_return_e_target_fnr()) {}) + + , e_return( is_void ? this_t::e_return_a_target_fnv() : decltype(this_t::e_return_a_target_fnv()) {}, + !is_void ? this_t::e_return_a_target_fnr() : decltype(this_t::e_return_a_target_fnr()) {}) + + , e_target( is_void ? this_t::e_target_a_return_fnv() : decltype(this_t::e_target_a_return_fnv()) {}, + !is_void ? this_t::e_target_a_return_fnr() : decltype(this_t::e_target_a_return_fnr()) {}) + { + constexpr static bool is_const_cast_safe = (!traits::is_const_v); + base_t::m_return_id = detail::RObjectId::create(is_const_cast_safe); + } + + void init_base() + { + e_return.m_return_id = base_t::m_return_id; + e_target.m_return_id = base_t::m_return_id; + + base_t::m_erased_return = &e_return; + base_t::m_erased_target = &e_target; + } + + // erased-return-aware-target-function-void + constexpr static auto e_return_a_target_fnv() noexcept + { + return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&... params)-> auto + { + if constexpr (is_void) + { + auto mptr = lambda.template to_method() + .template get_functor(); + + (p_target.*mptr)(std::forward(params)...); + } + }; + } + + // erased-target-aware-return-function-void + constexpr static auto e_target_a_return_fnv() noexcept + { + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> void + { + if constexpr (is_void) + { + auto mptr = lambda.template to_method() + .template get_functor(); + + const auto& target = p_target.view()->get(); + + (target.*mptr)(std::forward(params)...); + } + }; + } + + // erased-return-erased-target-function-void + constexpr static auto e_return_e_target_fnv() noexcept + { + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto + { + if constexpr (is_void) + { + auto mptr = lambda.template to_method() + .template get_functor(); + + const auto& target = p_target.view()->get(); + + (target.*mptr)(std::forward(params)...); + } + }; + } + + // erased-target-aware-return-function-returns(return_t) + constexpr static auto e_target_a_return_fnr() noexcept + { + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> return_t + { + if constexpr (!is_void) + { + auto mptr = lambda.template to_method() + .template get_functor(); + + const auto& target = p_target.view()->get(); + + return (target.*mptr)(std::forward(params)...); + } + }; + } + + // erased-return-aware-target-function-returns(std::any) + constexpr static auto e_return_a_target_fnr() noexcept + { + return [](const lambda_base& lambda, const record_t& p_target, traits::normal_sign_t&&...params)-> auto + { + if constexpr (!is_void) + { + auto mptr = lambda.template to_method() + .template get_functor(); + + auto&& ret_v = (p_target.*mptr)(std::forward(params)...); + + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using raw_ct = std::add_const_t>; + return std::any(raw_ct(std::forward(ret_v))); + } + } + else return std::any(); + }; + } + + // erased-return-erased-target-function-returns(std::any) + constexpr static auto e_return_e_target_fnr() noexcept + { + return [](const lambda_base& lambda, const RObject& p_target, traits::normal_sign_t&&... params)-> auto + { + if constexpr (!is_void) + { + auto mptr = lambda.template to_method() + .template get_functor(); + + const auto& target = p_target.view()->get(); + + auto&& ret_v = (target.*mptr)(std::forward(params)...); + + if constexpr (std::is_pointer_v) + { + using raw_t = std::remove_pointer_t; + return std::any(static_cast(ret_v)); + } + else if constexpr (std::is_reference_v) + { + using raw_t = std::remove_cv_t>; + return std::any(static_cast(&ret_v)); + } + else + { + using raw_ct = std::add_const_t>; + return std::any(raw_ct(std::forward(ret_v))); + } + } + else return std::any(); + }; + } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_fn_base.h b/ReflectionTemplateLib/rtl/erasure/erase_fn_base.h deleted file mode 100644 index 6c066a12..00000000 --- a/ReflectionTemplateLib/rtl/erasure/erase_fn_base.h +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include "functor.h" -#include "RObjectId.h" -#include "rtl_constants.h" - -namespace rtl::dispatch -{ - struct erase_fn_base - { - template - using erasure_t = erase_return_fn...>; - - template - constexpr const erasure_t& to_erased_return() const - { - return static_cast&>(*this); - } - - template - using erasure_rt = erase_return_fn_rec...>; - - template - constexpr const erasure_rt& to_erased_return_rec() const - { - return static_cast&>(*this); - } - - erase_fn_base(const dispatch::functor& p_functor, const detail::RObjectId& p_ret_id) noexcept - : m_functor(p_functor) - , m_return_id(p_ret_id) - { } - - const dispatch::functor& m_functor; - - const detail::RObjectId m_return_id; - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return.h b/ReflectionTemplateLib/rtl/erasure/erase_return.h new file mode 100644 index 00000000..086d6024 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erase_return.h @@ -0,0 +1,43 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "erasure_base.h" + +namespace rtl::dispatch +{ + template + struct erase_return : public erasure_base + { + using lambda_vt = std::function; + + using lambda_rt = std::function; + + GETTER_CREF(lambda_vt, _void_hopper, m_vhopper) + GETTER_CREF(lambda_rt, _return_hopper, m_rhopper) + + protected: + + lambda_vt m_vhopper; + + lambda_rt m_rhopper; + + erase_return( const lambda_vt& p_void_hop, + const lambda_rt& p_any_ret_hop ) noexcept + + : m_vhopper(p_void_hop) + , m_rhopper(p_any_ret_hop) + { } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return_fn_rec.h b/ReflectionTemplateLib/rtl/erasure/erase_return_aware_target.h similarity index 63% rename from ReflectionTemplateLib/rtl/erasure/erase_return_fn_rec.h rename to ReflectionTemplateLib/rtl/erasure/erase_return_aware_target.h index 813d8bc5..891c1656 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_return_fn_rec.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_return_aware_target.h @@ -14,13 +14,12 @@ #include #include -#include "erase_return_fn.h" -#include "rtl_forward_decls.h" +#include "erasure_base.h" namespace rtl::dispatch { template - struct erase_return_fn_rec : public erase_return_fn + struct erase_return_aware_target : public erasure_base { using lambda_vt = std::function; @@ -30,24 +29,20 @@ namespace rtl::dispatch GETTER(lambda_rt, _return_hopper, m_rhopper) - protected: + private: lambda_vt m_vhopper; lambda_rt m_rhopper; - using base_t = erase_return_fn; + erase_return_aware_target( const lambda_vt& p_void_hop, + const lambda_rt& p_any_ret_hop ) noexcept - erase_return_fn_rec( const dispatch::functor& p_functor, - const lambda_vt& p_void_hop, - const lambda_rt& p_any_ret_hop, - const base_t::lambda_robj_vt& p_void_robj_hop, - const base_t::lambda_robj_rt& p_any_ret_robj_hop, - const detail::RObjectId& p_ret_id ) noexcept - - : base_t(p_functor, p_void_robj_hop, p_any_ret_robj_hop, p_ret_id) - , m_vhopper(p_void_hop) + : m_vhopper(p_void_hop) , m_rhopper(p_any_ret_hop) { } + + template + friend struct aware_return_n_target; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return_fn.h b/ReflectionTemplateLib/rtl/erasure/erase_return_fn.h deleted file mode 100644 index 98152ed0..00000000 --- a/ReflectionTemplateLib/rtl/erasure/erase_return_fn.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************* - * * - * Reflection Template Library (RTL) - Modern C++ Reflection Framework * - * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * - * * - * Copyright (c) 2025 Neeraj Singh * - * SPDX-License-Identifier: MIT * - * * - *************************************************************************/ - - -#pragma once - -#include - -#include "erase_fn_base.h" - -namespace rtl::dispatch -{ - template - struct erase_return_fn : public erase_fn_base - { - using lambda_vt = std::function; - - using lambda_rt = std::function; - - using lambda_robj_vt = std::function; - - using lambda_robj_rt = std::function; - - GETTER_CREF(lambda_vt, _void_hopper, m_vhopper) - GETTER_CREF(lambda_rt, _return_hopper, m_rhopper) - GETTER_CREF(lambda_robj_vt, _void_method_hopper, m_vmhopper) - GETTER_CREF(lambda_robj_rt, _return_method_hopper, m_rmhopper) - - protected: - - lambda_vt m_vhopper; - - lambda_rt m_rhopper; - - lambda_robj_vt m_vmhopper; - - lambda_robj_rt m_rmhopper; - - erase_return_fn( const dispatch::functor& p_functor, - const lambda_vt& p_void_hop, - const lambda_rt& p_any_ret_hop, - const detail::RObjectId& p_ret_id ) noexcept - - : erase_fn_base(p_functor, p_ret_id) - , m_vhopper(p_void_hop) - , m_rhopper(p_any_ret_hop) - { } - - erase_return_fn( const dispatch::functor& p_functor, - const lambda_robj_vt& p_void_method_hop, - const lambda_robj_rt& p_any_ret_method_hop, - const detail::RObjectId& p_ret_id ) noexcept - - : erase_fn_base(p_functor, p_ret_id) - , m_vmhopper(p_void_method_hop) - , m_rmhopper(p_any_ret_method_hop) - { } - }; -} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h b/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h new file mode 100644 index 00000000..9b69bd33 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h @@ -0,0 +1,57 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include + +#include "erasure_base.h" + +namespace rtl::dispatch +{ + template + struct erase_return_n_target : public erasure_base + { + using lambda_vt = std::function; + + using lambda_rt = std::function; + + GETTER_CREF(lambda_vt, _void_hopper, m_vhopper) + GETTER_CREF(lambda_rt, _return_hopper, m_rhopper) + + template + const erase_return_aware_target& to_erased_return() const + { + return static_cast&>(*m_erased_return); + } + + template + const erase_target_aware_return& to_erased_target() const + { + return static_cast&>(*m_erased_target); + } + + protected: + + lambda_vt m_vhopper; + lambda_rt m_rhopper; + + const erasure_base* m_erased_return; + const erasure_base* m_erased_target; + + erase_return_n_target( const lambda_vt& p_void_hop, + const lambda_rt& p_any_ret_hop ) noexcept + + : m_vhopper(p_void_hop) + , m_rhopper(p_any_ret_hop) + { } + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_target_aware_return.h b/ReflectionTemplateLib/rtl/erasure/erase_target_aware_return.h new file mode 100644 index 00000000..77e7cc14 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erase_target_aware_return.h @@ -0,0 +1,48 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include +#include + +#include "erasure_base.h" + +namespace rtl::dispatch +{ + template + struct erase_target_aware_return : public erasure_base + { + using lambda_vt = std::function; + + using lambda_rt = std::function; + + GETTER(lambda_vt, _void_hopper, m_vhopper) + + GETTER(lambda_rt, _return_hopper, m_rhopper) + + protected: + + lambda_vt m_vhopper; + + lambda_rt m_rhopper; + + erase_target_aware_return( const lambda_vt& p_void_hop, + const lambda_rt& p_any_ret_hop ) noexcept + + : m_vhopper(p_void_hop) + , m_rhopper(p_any_ret_hop) + { } + + template + friend struct aware_return_n_target; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_base.h b/ReflectionTemplateLib/rtl/erasure/erasure_base.h new file mode 100644 index 00000000..ef38c4c3 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erasure_base.h @@ -0,0 +1,57 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "RObjectId.h" +#include "rtl_forward_decls.h" + +namespace rtl::dispatch +{ + struct erasure_base + { + template + using erased_return_t = erase_return...>; + + template + using erased_record_t = erase_return_n_target...>; + + template + using e_ret_a_target_t = erase_return_aware_target...>; + + template + using e_target_a_ret_t = erase_target_aware_return...>; + + template + constexpr const erased_return_t& to_erased_return() const + { + return static_cast&>(*this); + } + + template + constexpr const erased_record_t& to_erased_record() const + { + return static_cast&>(*this); + } + + template + constexpr const e_ret_a_target_t& to_erased_return_aware_target() const; + + template + constexpr const e_target_a_ret_t& to_erased_target_aware_return() const; + + protected: + + detail::RObjectId m_return_id = {}; + + friend lambda_base; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_base.hpp b/ReflectionTemplateLib/rtl/erasure/erasure_base.hpp new file mode 100644 index 00000000..ed7fd810 --- /dev/null +++ b/ReflectionTemplateLib/rtl/erasure/erasure_base.hpp @@ -0,0 +1,36 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "erasure_base.h" +#include "erase_return_n_target.h" +#include "erase_return_aware_target.h" +#include "erase_target_aware_return.h" + +namespace rtl::dispatch +{ + template + inline constexpr const erasure_base::e_ret_a_target_t& + erasure_base::to_erased_return_aware_target() const + { + auto& erased_record = static_cast&>(*this); + return erased_record.template to_erased_return(); + } + + template + inline constexpr const erasure_base::e_target_a_ret_t& + erasure_base::to_erased_target_aware_return() const + { + auto& erased_record = static_cast&>(*this); + return erased_record.template to_erased_record(); + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h index af3f4c52..0fd8fb84 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.h +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -15,7 +15,7 @@ #include #include "functor.h" -#include "erase_fn_base.h" +#include "erasure_base.h" namespace rtl { @@ -46,7 +46,7 @@ namespace rtl GETTER(detail::methodQ, _method_qual, m_functor->get().m_qualifier) GETTER_CREF(dispatch::lambda_base, _lambda, *(m_functor->get().m_lambda)) - GETTER_CREF(dispatch::erase_fn_base, _erased_lambda, *(m_functor->get().m_erased_lambda)) + GETTER_CREF(dispatch::erasure_base, _erased_lambda, *(m_functor->get().m_erasure)) template static type_meta add_function(return_t(*pFunctor)(signature_t...), std::size_t p_index); diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.hpp b/ReflectionTemplateLib/rtl/inc/type_meta.hpp index cb3eb496..d4aa0518 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.hpp +++ b/ReflectionTemplateLib/rtl/inc/type_meta.hpp @@ -14,7 +14,7 @@ #include "type_meta.h" #include "lambda_base.h" -#include "erase_fn_base.h" +#include "erasure_base.h" #include "cache_method_ptr.h" #include "cache_function_ptr.h" @@ -47,7 +47,7 @@ namespace rtl auto [lambda, elambda] = lc.push(functor); functor.set_lambda(lambda); - functor.set_erased_lambda(elambda); + functor.set_erasure(elambda); return type_meta(functor); } @@ -62,7 +62,7 @@ namespace rtl auto [lambda, elambda] = lc.push(functor); functor.set_lambda(lambda); - functor.set_erased_lambda(elambda); + functor.set_erasure(elambda); return type_meta(functor); } @@ -77,7 +77,7 @@ namespace rtl auto [lambda, elambda] = lc.push(functor); functor.set_lambda(lambda); - functor.set_erased_lambda(elambda); + functor.set_erasure(elambda); return type_meta(functor); } diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index fbf45817..ff60e191 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -71,7 +71,7 @@ namespace rtl struct lambda_base; - struct erase_fn_base; + struct erasure_base; template struct lambda_function; @@ -89,15 +89,21 @@ namespace rtl struct const_method_ptr; template - struct erase_return_fn; + struct erase_return; + + template + struct aware_return; + + template + struct erase_return_n_target; template - struct erase_return_fn_rec; + struct erase_return_aware_target; template - struct aware_return_fn; + struct erase_target_aware_return; template - struct aware_return_fn_rec; + struct aware_return_n_target; } } \ No newline at end of file From 538066552fab05d730d7501a09ca2ee993413766 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 23 Oct 2025 22:44:46 +0530 Subject: [PATCH 103/148] type-erased interface for methods. wip. --- README.md | 2 +- .../src/ReflectedCallUnknownReturn.cpp | 123 +++++++------- .../rtl/detail/inc/FunctionCaller.hpp | 2 +- .../rtl/detail/inc/MethodInvoker.h | 14 +- .../rtl/detail/inc/MethodInvoker.hpp | 104 +++++++++++- .../rtl/dispatch/CMakeLists.txt | 12 +- .../rtl/dispatch/rtl_method.h | 1 + .../rtl/dispatch/rtl_method_const.h | 1 + .../rtl/dispatch/rtl_method_const_erased.h | 0 .../dispatch/rtl_method_const_erased_target.h | 0 .../rtl/dispatch/rtl_method_erased.h | 156 ++++++++++++++++++ .../rtl/dispatch/rtl_method_erased_return.h | 2 +- .../rtl/dispatch/rtl_method_erased_target.h | 150 +++++++++++++++++ .../rtl/erasure/aware_return_n_target.h | 2 +- .../rtl/erasure/aware_return_n_target_const.h | 2 +- .../rtl/erasure/erase_return_n_target.h | 2 +- .../rtl/erasure/erasure_base.hpp | 2 +- ReflectionTemplateLib/rtl/inc/Method.h | 6 +- ReflectionTemplateLib/rtl/inc/type_meta.h | 2 +- 19 files changed, 499 insertions(+), 84 deletions(-) create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h create mode 100644 ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h diff --git a/README.md b/README.md index ebf5c88a..90c500f5 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ RTL lets you create reflected objects on the `Heap` or `Stack` with automatic li * Move semantics — `Heap` objects follow `std::unique_ptr` rules (move transfers ownership, copy/assign disabled). `Stack` objects move like regular values. -* Return values — All returns are propagated back wrapped in `rtl::RObject`, with temporaries (e.g. smart pointers) cleaned up automatically at scope exit. +* Return values — All returns are propagated back wrapped in `rtl::RObject`, cleaned up automatically at scope exit. RTL doesn’t invent a new paradigm — it extends C++ itself. You create objects, call methods, and work with types as usual, but now safely at runtime. diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index d104c724..0f1ea398 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -17,7 +17,29 @@ namespace cxx namespace { - static rtl::function GetMessage = []() + static rtl::Record class_Node = []() + { + std::optional Node = cxx::mirror().getRecord("Node"); + if (!Node) { + std::cerr << "[x] error: record 'Node' not found.\n"; + std::abort(); + } + return Node.value(); + }(); + + static const rtl::RObject nodeObj = []() + { + auto [err, robj] = class_Node.create(); + if (robj.isEmpty()) { + std::cerr << "[x] error: " << rtl::to_string(err) << "\n"; + } + return std::move(robj); + }(); +} + +namespace +{ + static rtl::function ErasedReturnFn_GetMessage = []() { std::optional function = cxx::mirror().getFunction("getMessage"); if (!function) { @@ -27,7 +49,7 @@ namespace return function->argsT().returnT(); }(); - static rtl::function SendMessage = []() + static rtl::function ErasedReturnFn_SendMessage = []() { std::optional function = cxx::mirror().getFunction("sendMessage"); if (!function) { @@ -36,33 +58,34 @@ namespace } return function->argsT().returnT(); }(); +} - - static rtl::method NodeGetMessage = []() +namespace +{ + static rtl::Method ErasedTargetGetMessage = []() { - std::optional Node = cxx::mirror().getRecord("Node"); - if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; - std::abort(); - } - - std::optional method = Node->getMethod("getMessage"); + std::optional method = class_Node.getMethod("getMessage"); if (!method) { std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; std::abort(); } - return method->targetT().argsT().returnT<>(); + return *method; }(); - static rtl::method NodeSendMessage = []() + static rtl::Method ErasedTargetSendMessage = []() { - std::optional Node = cxx::mirror().getRecord("Node"); - if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; + std::optional method = class_Node.getMethod("sendMessage"); + if (!method) { + std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; std::abort(); } + return *method; + }(); - std::optional method = Node->getMethod("sendMessage"); + //---------------------------------------------------------------------------- + static rtl::method ErasedReturnNode_SendMessage = []() + { + std::optional method = class_Node.getMethod("sendMessage"); if (!method) { std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; std::abort(); @@ -70,61 +93,43 @@ namespace return method->targetT().argsT().returnT<>(); }(); - - static rtl::Method ErasedTargetGetMessage = []() + //---------------------------------------------------------------------------- + static rtl::method ErasedReturn_GetMessage = []() { - std::optional Node = cxx::mirror().getRecord("Node"); - if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; - std::abort(); - } - - std::optional method = Node->getMethod("getMessage"); + std::optional method = class_Node.getMethod("getMessage"); if (!method) { std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; std::abort(); } - return *method; + return method->targetT().argsT().returnT<>(); }(); - static rtl::Method ErasedTargetSendMessage = []() + static rtl::method ErasedTarget_GetMessage = []() { - std::optional Node = cxx::mirror().getRecord("Node"); - if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; - std::abort(); - } - - std::optional method = Node->getMethod("sendMessage"); + std::optional method = class_Node.getMethod("getMessage"); if (!method) { - std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; + std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; std::abort(); } - return *method; + return method->targetT<>().argsT().returnT(); }(); - static const rtl::RObject nodeObj = []() + static rtl::method ErasedReturnAndTarget_GetMessage = []() { - std::optional Node = cxx::mirror().getRecord("Node"); - if (!Node) { - std::cerr << "[x] error: record 'Node' not found.\n"; + std::optional method = class_Node.getMethod("getMessage"); + if (!method) { + std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; std::abort(); } - - auto [err, robj] = Node->create(); - if (robj.isEmpty()) { - std::cerr << "[x] error: " << rtl::to_string(err) << "\n"; - } - return std::move(robj); + return method->targetT<>().argsT().returnT<>(); }(); } - namespace { static auto _test0 = []() { - auto err = SendMessage(bm::g_longStr).err; + auto err = ErasedReturnFn_SendMessage(bm::g_longStr).err; if (err != rtl::error::None) { std::cerr << "[00] error: " << rtl::to_string(err) << "\n"; } @@ -133,7 +138,7 @@ namespace static auto _test1 = []() { - auto err = NodeSendMessage(bm::Node())(bm::g_longStr).err; + auto err = ErasedReturnNode_SendMessage(bm::Node())(bm::g_longStr).err; if (err != rtl::error::None) { std::cerr << "[01] error: " << rtl::to_string(err) << "\n"; } @@ -142,7 +147,7 @@ namespace static auto _test2 = []() { - auto err = GetMessage(bm::g_longStr).err; + auto err = ErasedReturnFn_GetMessage(bm::g_longStr).err; if (err != rtl::error::None) { std::cerr << "[02] error: " << rtl::to_string(err) << "\n"; } @@ -151,14 +156,13 @@ namespace static auto _test3 = []() { - auto err = NodeGetMessage(bm::Node())(bm::g_longStr).err; + auto err = ErasedReturn_GetMessage(bm::Node())(bm::g_longStr).err; if (err != rtl::error::None) { std::cerr << "[03] error: " << rtl::to_string(err) << "\n"; } return 0; }; - static auto _test4 = []() { auto err = ErasedTargetSendMessage(nodeObj)(bm::g_longStr).err; @@ -168,9 +172,12 @@ namespace return 0; }; - static auto _test5 = []() { + //{ + // auto [err, retOpt] = ErasedReturnAndTarget_GetMessage(rtl::RObject())(bm::g_longStr); + //} + auto err = ErasedTargetGetMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { std::cerr << "[03] error: " << rtl::to_string(err) << "\n"; @@ -192,7 +199,7 @@ void RtlErasedReturnType_call::returnVoid(benchmark::State& state) static auto _ = _test0(); for (auto _ : state) { - benchmark::DoNotOptimize(SendMessage(bm::g_longStr).err); + benchmark::DoNotOptimize(ErasedReturnFn_SendMessage(bm::g_longStr).err); } } @@ -203,7 +210,7 @@ void RtlErasedReturnType_call::returnNonVoid(benchmark::State& state) static auto _ = _test2(); for (auto _ : state) { - benchmark::DoNotOptimize(GetMessage(bm::g_longStr).err); + benchmark::DoNotOptimize(ErasedReturnFn_GetMessage(bm::g_longStr).err); } } @@ -214,7 +221,7 @@ void RtlErasedReturnType_callMethod::returnVoid(benchmark::State& state) static bm::Node node; for (auto _ : state) { - benchmark::DoNotOptimize(NodeSendMessage(node)(bm::g_longStr).err); + benchmark::DoNotOptimize(ErasedReturnNode_SendMessage(node)(bm::g_longStr).err); } } @@ -225,7 +232,7 @@ void RtlErasedReturnType_callMethod::returnNonVoid(benchmark::State& state) static bm::Node node; for (auto _ : state) { - benchmark::DoNotOptimize(NodeGetMessage(node)(bm::g_longStr).err); + benchmark::DoNotOptimize(ErasedReturn_GetMessage(node)(bm::g_longStr).err); } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 41a9bdfc..e94d911e 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -106,7 +106,7 @@ namespace rtl::detail { if (!fnMeta.is_empty()) { - auto& erasedRetFn = fnMeta.get_erased_lambda() + auto& erasedRetFn = fnMeta.get_erasure_base() .template to_erased_return...>(); if (fnMeta.is_void()) { isReturnTvoid = true; diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index cefd1e73..b53b8937 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -104,12 +104,20 @@ namespace rtl::detail std::vector m_overloadsFnMeta = {}; template - requires (!std::is_same_v) - constexpr const method returnT() const; + requires (std::is_same_v && std::is_same_v) + constexpr const method returnT() const; template - requires (std::is_same_v) + requires (std::is_same_v && !std::is_same_v) + constexpr const method returnT() const; + + template + requires (!std::is_same_v && std::is_same_v) constexpr const method returnT() const; + + template + requires (!std::is_same_v && !std::is_same_v) + constexpr const method returnT() const; }; template diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 66d2b4e8..ef71e77c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -17,8 +17,11 @@ #include "MethodContainer.h" #include "erasure_base.h" -#include "rtl_method_erased_return.h" + #include "erasure_base.hpp" +#include "rtl_method_erased.h" +#include "rtl_method_erased_target.h" +#include "rtl_method_erased_return.h" namespace rtl::detail { @@ -155,10 +158,9 @@ namespace rtl::detail namespace rtl::detail { - template template - requires (!std::is_same_v) + requires (!std::is_same_v && !std::is_same_v) inline constexpr const method HopMethod::returnT() const { @@ -175,7 +177,87 @@ namespace rtl::detail template template - requires (std::is_same_v) + requires (std::is_same_v && std::is_same_v) + inline constexpr const + method HopMethod::returnT() const + { + bool isReturnTvoid = false; + method...)> erasedRetHop; + + for (auto& fnMeta : m_overloadsFnMeta) + { + if (!fnMeta.is_empty()) + { + auto& erasedRetFn = fnMeta.get_erasure_base() + .template to_erased_record...>(); + if (fnMeta.is_void()) { + isReturnTvoid = true; + erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); + } + else { + erasedRetHop.get_rhop().push_back(erasedRetFn.get_return_hopper()); + } + erasedRetHop.get_overloads().push_back(&fnMeta.get_lambda()); + } + else { + erasedRetHop.get_vhop().push_back(nullptr); + erasedRetHop.get_rhop().push_back(nullptr); + erasedRetHop.get_overloads().push_back(nullptr); + } + } + if (isReturnTvoid) { + erasedRetHop.get_rhop().clear(); + } + else { + erasedRetHop.get_vhop().clear(); + } + return erasedRetHop; + } + + + template + template + requires (std::is_same_v && !std::is_same_v) + inline constexpr const + method HopMethod::returnT() const + { + bool isReturnTvoid = false; + method...)> erasedRetHop; + + for (auto& fnMeta : m_overloadsFnMeta) + { + if (!fnMeta.is_empty()) + { + auto& erasedRetFn = fnMeta.get_erasure_base() + .template to_erased_target_aware_return...>(); + if (fnMeta.is_void()) { + isReturnTvoid = true; + erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); + } + else { + erasedRetHop.get_rhop().push_back(erasedRetFn.get_return_hopper()); + } + erasedRetHop.get_overloads().push_back(&fnMeta.get_lambda()); + } + else { + erasedRetHop.get_vhop().push_back(nullptr); + erasedRetHop.get_rhop().push_back(nullptr); + erasedRetHop.get_overloads().push_back(nullptr); + } + } + if (isReturnTvoid) { + erasedRetHop.get_rhop().clear(); + } + else { + erasedRetHop.get_vhop().clear(); + } + return erasedRetHop; + } + + + template + template + requires (!std::is_same_v && std::is_same_v) inline constexpr const method HopMethod::returnT() const { @@ -186,7 +268,7 @@ namespace rtl::detail { if (!fnMeta.is_empty()) { - auto& erasedRetFn = fnMeta.get_erased_lambda() + auto& erasedRetFn = fnMeta.get_erasure_base() .template to_erased_return_aware_target...>(); if (fnMeta.is_void()) { isReturnTvoid = true; @@ -221,15 +303,19 @@ namespace rtl::detail auto strictArgsId = traits::uid>::value; auto normalArgsId = traits::uid>::value; - rtl::type_meta argsTfnMeta; + type_meta argsTfnMeta; //initializing pos '0' with empty 'type_meta'. - std::vector overloadsFnMeta = { rtl::type_meta() }; + std::vector overloadsFnMeta = { type_meta() }; for (auto& fnMeta : m_functorsMeta) { - if (recordId != fnMeta.get_record_id()) { - continue; + if constexpr (!std::is_same_v) + { + if (recordId != fnMeta.get_record_id()) { + return { argsTfnMeta, overloadsFnMeta }; + } } + if (argsTfnMeta.is_empty() && strictArgsId == fnMeta.get_strict_args_id()) { argsTfnMeta = fnMeta; } diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index 2705efc1..fa85e470 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -13,12 +13,18 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/lambda_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/lambda_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_return.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const_erased_return.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_function_erased_return.h" + + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_return.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_target.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const_erased.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const_erased_return.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const_erased_target.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index ec232ddc..03ec8cd6 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -18,6 +18,7 @@ namespace rtl { template + requires (!std::is_same_v || !std::is_same_v) struct method { using fptr_t = return_t (record_t::*)(signature_t...); diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index 8cf6a054..026fcd9a 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -18,6 +18,7 @@ namespace rtl { template + requires (!std::is_same_v || !std::is_same_v) struct method { using fptr_t = return_t(record_t::*)(signature_t...) const; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h new file mode 100644 index 00000000..e69de29b diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h new file mode 100644 index 00000000..e69de29b diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h new file mode 100644 index 00000000..6ae48f0e --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h @@ -0,0 +1,156 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_forward_decls.h" +#include "lambda_base.h" + +namespace rtl +{ + template + struct method + { + struct invoker + { + const RObject& target; + const method& fn; + + template requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept + { + if (!fn) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + if (fn.must_bind_refs()) [[unlikely]] { + return { error::ExplicitRefBindingRequired, RObject{} }; + } + + auto index = (fn.m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index] (*(fn.m_lambdas[index]), target, std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ fn.m_rhop[index] (*(fn.m_lambdas[index]), target, std::forward(params)...), + fn.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + }; + + template + struct perfect_fwd + { + const RObject& target; + const method& fn; + + template + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr Return operator()(args_t&&...params) const noexcept + { + if (!fn) [[unlikely]] { + return { error::InvalidCaller, RObject{} }; + } + + auto signature_id = traits::uid>::value; + for (int index = 0; index < fn.m_lambdas.size(); index++) + { + if (fn.m_lambdas[index] != nullptr) + { + if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) + { + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index] (*fn.m_lambdas[index], target, std::forward(params)...); + return { error::None, RObject{} }; + } + else + { + return { error::None, + RObject{ fn.m_rhop[index] (*fn.m_lambdas[index], target, std::forward(params)...), + fn.m_lambdas.back()->get_return_id(), nullptr + } + }; + } + } + } + } + return { error::RefBindingMismatch, RObject{} }; + } + }; + + constexpr invoker operator()(RObject& p_target) const noexcept { + return invoker{ p_target, *this }; + } + + constexpr invoker operator()(RObject&& p_target) const noexcept { + return invoker{ p_target, *this }; + } + + template + requires (std::is_same_v, std::tuple>) + constexpr const perfect_fwd bind(RObject& p_target) const noexcept { + return perfect_fwd{ p_target, *this }; + } + + template + requires (std::is_same_v, std::tuple>) + constexpr const perfect_fwd bind(RObject&& p_target) const noexcept { + return perfect_fwd{ p_target, *this }; + } + + constexpr operator bool() const noexcept { + return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } + + constexpr bool must_bind_refs() const noexcept { + return (m_lambdas[call_by::value] == nullptr && + (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_arg_ncref())); + } + + enum call_by + { + value = 0, + cref = 1, //const ref. + ncref = 2 //non-const ref. + }; + + private: + + using lambda_vt = std::function; + + using lambda_rt = std::function; + + std::vector m_rhop = {}; + + std::vector m_vhop = {}; + + std::vector m_lambdas = {}; + + GETTER_REF(std::vector, _rhop, m_rhop) + GETTER_REF(std::vector, _vhop, m_vhop) + GETTER_REF(std::vector, _overloads, m_lambdas) + + template + friend struct detail::HopMethod; + + static_assert((!std::is_reference_v && ...), + "rtl::method<...>: any type cannot be specified as reference here."); + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h index 640ab794..6a011644 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -17,7 +17,7 @@ namespace rtl { - template + template requires (!std::is_same_v) struct method { struct invoker diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h new file mode 100644 index 00000000..c18c0f80 --- /dev/null +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h @@ -0,0 +1,150 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once + +#include "rtl_traits.h" +#include "rtl_forward_decls.h" +#include "lambda_base.h" + +namespace rtl +{ + template requires (!std::is_same_v) + struct method + { + struct invoker + { + const RObject& target; + const method& fn; + + template requires (sizeof...(args_t) == sizeof...(signature_t)) + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr std::pair> operator()(args_t&&...params) const noexcept + { + if (!fn) [[unlikely]] { + return { error::InvalidCaller, std::nullopt }; + } + + if (fn.must_bind_refs()) [[unlikely]] { + return { error::ExplicitRefBindingRequired, std::nullopt }; + } + + auto index = (fn.m_lambdas[call_by::value] != nullptr ? call_by::value : call_by::cref); + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index] (*(fn.m_lambdas[index]), target, std::forward(params)...); + return { error::None, std::nullopt }; + } + else + { + auto&& ret_v = fn.m_rhop[index](*(fn.m_lambdas[index]), target, std::forward(params)...); + return { error::None, std::optional(std::move(ret_v)) }; + } + } + }; + + template + struct perfect_fwd + { + const RObject& target; + const method& fn; + + template + [[nodiscard]] [[gnu::hot]] [[gnu::flatten]] + constexpr std::pair> operator()(args_t&&...params) const noexcept + { + if (!fn) [[unlikely]] { + return { error::InvalidCaller, std::nullopt }; + } + + auto signature_id = traits::uid>::value; + for (int index = 0; index < fn.m_lambdas.size(); index++) + { + if (fn.m_lambdas[index] != nullptr) + { + if (signature_id == fn.m_lambdas[index]->get_strict_sign_id()) + { + if (fn.m_lambdas[index]->is_void()) + { + fn.m_vhop[index] (*fn.m_lambdas[index], target, std::forward(params)...); + return { error::None, std::nullopt }; + } + else + { + auto&& ret_v = fn.m_rhop[index](*fn.m_lambdas[index], target, std::forward(params)...); + return { error::None, std::optional(std::move(ret_v)) }; + } + } + } + } + return { error::RefBindingMismatch, std::nullopt }; + } + }; + + constexpr invoker operator()() const noexcept { + return invoker{ RObject{}, *this }; + } + + constexpr invoker operator()(const RObject& p_target) const noexcept { + return invoker{ p_target, *this }; + } + + template + requires (std::is_same_v, std::tuple>) + constexpr const perfect_fwd bind() const noexcept { + return perfect_fwd{ RObject{}, *this }; + } + + template + requires (std::is_same_v, std::tuple>) + constexpr const perfect_fwd bind(const RObject& p_target) const noexcept { + return perfect_fwd{ p_target, *this }; + } + + constexpr operator bool() const noexcept { + return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } + + constexpr bool must_bind_refs() const noexcept { + return (m_lambdas[call_by::value] == nullptr && + (m_lambdas.size() > call_by::ncref || m_lambdas[call_by::cref]->is_any_arg_ncref())); + } + + enum call_by + { + value = 0, + cref = 1, //const ref. + ncref = 2 //non-const ref. + }; + + private: + + using lambda_vt = std::function; + + using lambda_rt = std::function; + + std::vector m_rhop = {}; + + std::vector m_vhop = {}; + + std::vector m_lambdas = {}; + + GETTER_REF(std::vector, _rhop, m_rhop) + GETTER_REF(std::vector, _vhop, m_vhop) + GETTER_REF(std::vector, _overloads, m_lambdas) + + template + friend struct detail::HopMethod; + + static_assert((!std::is_reference_v && ...), + "rtl::method<...>: any type cannot be specified as reference here."); + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/aware_return_n_target.h b/ReflectionTemplateLib/rtl/erasure/aware_return_n_target.h index 9b99fbd0..b51cca2a 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_return_n_target.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_return_n_target.h @@ -80,7 +80,7 @@ namespace rtl::dispatch if constexpr (is_void) { auto mptr = lambda.template to_method() - .template get_functor(); + .template get_functor(); const auto& target = p_target.view()->get(); diff --git a/ReflectionTemplateLib/rtl/erasure/aware_return_n_target_const.h b/ReflectionTemplateLib/rtl/erasure/aware_return_n_target_const.h index 532a6820..7ada3ac3 100644 --- a/ReflectionTemplateLib/rtl/erasure/aware_return_n_target_const.h +++ b/ReflectionTemplateLib/rtl/erasure/aware_return_n_target_const.h @@ -82,7 +82,7 @@ namespace rtl::dispatch if constexpr (is_void) { auto mptr = lambda.template to_method() - .template get_functor(); + .template get_functor(); const auto& target = p_target.view()->get(); diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h b/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h index 9b69bd33..0ea32657 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h @@ -36,7 +36,7 @@ namespace rtl::dispatch template const erase_target_aware_return& to_erased_target() const { - return static_cast&>(*m_erased_target); + return static_cast&>(*m_erased_target); } protected: diff --git a/ReflectionTemplateLib/rtl/erasure/erasure_base.hpp b/ReflectionTemplateLib/rtl/erasure/erasure_base.hpp index ed7fd810..cd1f0fdd 100644 --- a/ReflectionTemplateLib/rtl/erasure/erasure_base.hpp +++ b/ReflectionTemplateLib/rtl/erasure/erasure_base.hpp @@ -31,6 +31,6 @@ namespace rtl::dispatch erasure_base::to_erased_target_aware_return() const { auto& erased_record = static_cast&>(*this); - return erased_record.template to_erased_record(); + return erased_record.template to_erased_target(); } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 4d5da65e..1b781798 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -60,7 +60,7 @@ namespace rtl { template constexpr const detail::HopFunction argsT() const = delete; - template + template constexpr detail::Hopper targetT() const; //indicates if a particular set of arguments accepted by the functor associated with it. @@ -82,10 +82,10 @@ namespace rtl { friend Record; friend detail::CxxReflection; - template + template friend struct detail::DefaultInvoker; - template + template friend struct detail::NonConstInvoker; template diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h index 0fd8fb84..bf88eb8c 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.h +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -46,7 +46,7 @@ namespace rtl GETTER(detail::methodQ, _method_qual, m_functor->get().m_qualifier) GETTER_CREF(dispatch::lambda_base, _lambda, *(m_functor->get().m_lambda)) - GETTER_CREF(dispatch::erasure_base, _erased_lambda, *(m_functor->get().m_erasure)) + GETTER_CREF(dispatch::erasure_base, _erasure_base, *(m_functor->get().m_erasure)) template static type_meta add_function(return_t(*pFunctor)(signature_t...), std::size_t p_index); From c49b5017c3b39983d2f5508a861c65e5fa775f4c Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 24 Oct 2025 20:37:21 +0530 Subject: [PATCH 104/148] benchmark code fixes. --- .../src/ReflectedCallUnknownReturn.cpp | 141 +++++++++++------- .../rtl/detail/inc/MethodInvoker.h | 18 +-- .../rtl/detail/inc/MethodInvoker.hpp | 12 +- .../rtl/dispatch/rtl_method.h | 2 +- .../rtl/dispatch/rtl_method_const.h | 2 +- .../rtl/dispatch/rtl_method_const_erased.h | 12 ++ .../dispatch/rtl_method_const_erased_target.h | 12 ++ .../rtl/erasure/erase_return_n_target.h | 4 +- ReflectionTemplateLib/rtl/inc/Method.h | 4 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 6 +- ReflectionTemplateLib/rtl/rtl_traits.h | 13 ++ 11 files changed, 148 insertions(+), 78 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 0f1ea398..36435a56 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -27,7 +27,7 @@ namespace return Node.value(); }(); - static const rtl::RObject nodeObj = []() + static rtl::RObject nodeObj = []() { auto [err, robj] = class_Node.create(); if (robj.isEmpty()) { @@ -41,87 +41,129 @@ namespace { static rtl::function ErasedReturnFn_GetMessage = []() { - std::optional function = cxx::mirror().getFunction("getMessage"); - if (!function) { - std::cerr << "[0] error: erase_function 'getMessage' not found.\n"; + std::optional optFunction = cxx::mirror().getFunction("getMessage"); + if (!optFunction) { + std::cerr << "[0] error: function 'getMessage' not found.\n"; std::abort(); } - return function->argsT().returnT(); + auto function = optFunction->argsT().returnT<>(); + if (!function) + { + std::cerr << "[0] error: invalid function caller.\n"; + std::abort(); + } + return function; }(); static rtl::function ErasedReturnFn_SendMessage = []() { - std::optional function = cxx::mirror().getFunction("sendMessage"); - if (!function) { - std::cerr << "[1] error: erase_function 'sendMessage' not found.\n"; + std::optional optFunction = cxx::mirror().getFunction("sendMessage"); + if (!optFunction) { + std::cerr << "[1] error: function 'sendMessage' not found.\n"; std::abort(); } - return function->argsT().returnT(); + auto function = optFunction->argsT().returnT<>(); + if (!function) + { + std::cerr << "[1] error: invalid function caller.\n"; + std::abort(); + } + return function; }(); } namespace { - static rtl::Method ErasedTargetGetMessage = []() + //---------------------------------------------------------------------------- + static rtl::method ErasedReturnAwareTarget_SendMessage = []() { - std::optional method = class_Node.getMethod("getMessage"); + std::optional optMethod = class_Node.getMethod("sendMessage"); + if (!optMethod) { + std::cerr << "[2] error: method 'Node::sendMessage' not found.\n"; + std::abort(); + } + auto method = optMethod->targetT().argsT().returnT<>(); if (!method) { - std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; + std::cerr << "[2] error: invalid method caller.\n"; std::abort(); } - return *method; + return method; }(); - static rtl::Method ErasedTargetSendMessage = []() + static rtl::method ErasedTargetAwareReturn_SendMessage = []() { - std::optional method = class_Node.getMethod("sendMessage"); - if (!method) { + std::optional optMethod = class_Node.getMethod("sendMessage"); + if (!optMethod) { std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; std::abort(); } - return *method; + auto method = optMethod->targetT<>().argsT().returnT(); + if (!method) { + std::cerr << "[3] error: invalid method caller.\n"; + std::abort(); + } + return method; }(); - //---------------------------------------------------------------------------- - static rtl::method ErasedReturnNode_SendMessage = []() + static rtl::method ErasedReturnAndTarget_SendMessage = []() { - std::optional method = class_Node.getMethod("sendMessage"); + std::optional optMethod = class_Node.getMethod("sendMessage"); + if (!optMethod) { + std::cerr << "[4] error: method 'Node::sendMessage' not found.\n"; + std::abort(); + } + auto method = optMethod->targetT<>().argsT().returnT<>(); if (!method) { - std::cerr << "[3] error: method 'Node::sendMessage' not found.\n"; + std::cerr << "[4] error: invalid method caller.\n"; std::abort(); } - return method->targetT().argsT().returnT<>(); + return method; }(); //---------------------------------------------------------------------------- - static rtl::method ErasedReturn_GetMessage = []() + static rtl::method ErasedReturnAwareTarget_GetMessage = []() { - std::optional method = class_Node.getMethod("getMessage"); + std::optional optMethod = class_Node.getMethod("getMessage"); + if (!optMethod) { + std::cerr << "[5] error: method 'Node::getMessage' not found.\n"; + std::abort(); + } + auto method = optMethod->targetT().argsT().returnT<>(); if (!method) { - std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; + std::cerr << "[5] error: invalid method caller.\n"; std::abort(); } - return method->targetT().argsT().returnT<>(); + return method; }(); - static rtl::method ErasedTarget_GetMessage = []() + static rtl::method ErasedTargetAwareReturn_GetMessage = []() { - std::optional method = class_Node.getMethod("getMessage"); + std::optional optMethod = class_Node.getMethod("getMessage"); + if (!optMethod) { + std::cerr << "[6] error: method 'Node::getMessage' not found.\n"; + std::abort(); + } + auto method = optMethod->targetT<>().argsT().returnT(); if (!method) { - std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; + std::cerr << "[6] error: invalid method caller.\n"; std::abort(); } - return method->targetT<>().argsT().returnT(); + return method; }(); static rtl::method ErasedReturnAndTarget_GetMessage = []() { - std::optional method = class_Node.getMethod("getMessage"); + std::optional optMethod = class_Node.getMethod("getMessage"); + if (!optMethod) { + std::cerr << "[7] error: method 'Node::getMessage' not found.\n"; + std::abort(); + } + auto method = optMethod->targetT<>().argsT().returnT<>(); if (!method) { - std::cerr << "[2] error: method 'Node::getMessage' not found.\n"; + std::cerr << "[7] error: invalid method caller.\n"; std::abort(); } - return method->targetT<>().argsT().returnT<>(); + return method; }(); } @@ -138,16 +180,19 @@ namespace static auto _test1 = []() { - auto err = ErasedReturnNode_SendMessage(bm::Node())(bm::g_longStr).err; + auto err = ErasedReturnFn_GetMessage(bm::g_longStr).err; if (err != rtl::error::None) { std::cerr << "[01] error: " << rtl::to_string(err) << "\n"; } return 0; }; +} +namespace +{ static auto _test2 = []() { - auto err = ErasedReturnFn_GetMessage(bm::g_longStr).err; + auto err = ErasedReturnAwareTarget_SendMessage(bm::Node())(bm::g_longStr).err; if (err != rtl::error::None) { std::cerr << "[02] error: " << rtl::to_string(err) << "\n"; } @@ -156,7 +201,7 @@ namespace static auto _test3 = []() { - auto err = ErasedReturn_GetMessage(bm::Node())(bm::g_longStr).err; + auto err = ErasedReturnAwareTarget_GetMessage(bm::Node())(bm::g_longStr).err; if (err != rtl::error::None) { std::cerr << "[03] error: " << rtl::to_string(err) << "\n"; } @@ -165,22 +210,18 @@ namespace static auto _test4 = []() { - auto err = ErasedTargetSendMessage(nodeObj)(bm::g_longStr).err; + auto err = ErasedReturnAndTarget_SendMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { - std::cerr << "[01] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[04] error: " << rtl::to_string(err) << "\n"; } return 0; }; static auto _test5 = []() { - //{ - // auto [err, retOpt] = ErasedReturnAndTarget_GetMessage(rtl::RObject())(bm::g_longStr); - //} - - auto err = ErasedTargetGetMessage(nodeObj)(bm::g_longStr).err; + auto err = ErasedReturnAndTarget_GetMessage(nodeObj)(bm::g_longStr).err; if (err != rtl::error::None) { - std::cerr << "[03] error: " << rtl::to_string(err) << "\n"; + std::cerr << "[05] error: " << rtl::to_string(err) << "\n"; } return 0; }; @@ -207,7 +248,7 @@ void RtlErasedReturnType_call::returnVoid(benchmark::State& state) void RtlErasedReturnType_call::returnNonVoid(benchmark::State& state) { static auto __= _new_line(); - static auto _ = _test2(); + static auto _ = _test1(); for (auto _ : state) { benchmark::DoNotOptimize(ErasedReturnFn_GetMessage(bm::g_longStr).err); @@ -217,11 +258,11 @@ void RtlErasedReturnType_call::returnNonVoid(benchmark::State& state) void RtlErasedReturnType_callMethod::returnVoid(benchmark::State& state) { - static auto _ = _test1(); + static auto _ = _test2(); static bm::Node node; for (auto _ : state) { - benchmark::DoNotOptimize(ErasedReturnNode_SendMessage(node)(bm::g_longStr).err); + benchmark::DoNotOptimize(ErasedReturnAwareTarget_SendMessage(node)(bm::g_longStr).err); } } @@ -232,7 +273,7 @@ void RtlErasedReturnType_callMethod::returnNonVoid(benchmark::State& state) static bm::Node node; for (auto _ : state) { - benchmark::DoNotOptimize(ErasedReturn_GetMessage(node)(bm::g_longStr).err); + benchmark::DoNotOptimize(ErasedReturnAwareTarget_GetMessage(node)(bm::g_longStr).err); } } @@ -242,7 +283,7 @@ void RtlErasedReturnType_callMethod::unknownTarget_returnVoid(benchmark::State& static auto _ = _test4(); for (auto _ : state) { - benchmark::DoNotOptimize(ErasedTargetSendMessage(nodeObj)(bm::g_longStr).err); + benchmark::DoNotOptimize(ErasedReturnAndTarget_SendMessage(nodeObj)(bm::g_longStr).err); } } @@ -252,6 +293,6 @@ void RtlErasedReturnType_callMethod::unknownTarget_returnNonVoid(benchmark::Stat static auto _ = _test5(); for (auto _ : state) { - benchmark::DoNotOptimize(ErasedTargetGetMessage(nodeObj)(bm::g_longStr).err); + benchmark::DoNotOptimize(ErasedReturnAndTarget_GetMessage(nodeObj)(bm::g_longStr).err); } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index b53b8937..7aa05bee 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -103,21 +103,17 @@ namespace rtl::detail std::vector m_overloadsFnMeta = {}; - template - requires (std::is_same_v && std::is_same_v) - constexpr const method returnT() const; + template requires (traits::type_aware_v) + constexpr const method returnT() const; - template - requires (std::is_same_v && !std::is_same_v) + template requires (traits::target_erased_v) constexpr const method returnT() const; - template - requires (!std::is_same_v && std::is_same_v) + template requires (traits::return_erased_v) constexpr const method returnT() const; - - template - requires (!std::is_same_v && !std::is_same_v) - constexpr const method returnT() const; + + template requires (traits::type_erased_v) + constexpr const method returnT() const; }; template diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index ef71e77c..72986e56 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -159,8 +159,7 @@ namespace rtl::detail namespace rtl::detail { template - template - requires (!std::is_same_v && !std::is_same_v) + template requires (traits::type_aware_v) inline constexpr const method HopMethod::returnT() const { @@ -176,8 +175,7 @@ namespace rtl::detail template - template - requires (std::is_same_v && std::is_same_v) + template requires (traits::type_erased_v) inline constexpr const method HopMethod::returnT() const { @@ -216,8 +214,7 @@ namespace rtl::detail template - template - requires (std::is_same_v && !std::is_same_v) + template requires (traits::target_erased_v) inline constexpr const method HopMethod::returnT() const { @@ -256,8 +253,7 @@ namespace rtl::detail template - template - requires (!std::is_same_v && std::is_same_v) + template requires (traits::return_erased_v) inline constexpr const method HopMethod::returnT() const { diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 03ec8cd6..39070719 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -18,7 +18,7 @@ namespace rtl { template - requires (!std::is_same_v || !std::is_same_v) + requires (!std::is_same_v && !std::is_same_v) struct method { using fptr_t = return_t (record_t::*)(signature_t...); diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index 026fcd9a..7fdde543 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -18,7 +18,7 @@ namespace rtl { template - requires (!std::is_same_v || !std::is_same_v) + requires (!std::is_same_v && !std::is_same_v) struct method { using fptr_t = return_t(record_t::*)(signature_t...) const; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h index e69de29b..5d232a04 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h @@ -0,0 +1,12 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h index e69de29b..5d232a04 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h @@ -0,0 +1,12 @@ +/************************************************************************* + * * + * Reflection Template Library (RTL) - Modern C++ Reflection Framework * + * https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP * + * * + * Copyright (c) 2025 Neeraj Singh * + * SPDX-License-Identifier: MIT * + * * + *************************************************************************/ + + +#pragma once \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h b/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h index 0ea32657..74dd2f9c 100644 --- a/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h +++ b/ReflectionTemplateLib/rtl/erasure/erase_return_n_target.h @@ -28,13 +28,13 @@ namespace rtl::dispatch GETTER_CREF(lambda_rt, _return_hopper, m_rhopper) template - const erase_return_aware_target& to_erased_return() const + constexpr const erase_return_aware_target& to_erased_return() const { return static_cast&>(*m_erased_return); } template - const erase_target_aware_return& to_erased_target() const + constexpr const erase_target_aware_return& to_erased_target() const { return static_cast&>(*m_erased_target); } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 1b781798..d423cdb1 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -60,8 +60,8 @@ namespace rtl { template constexpr const detail::HopFunction argsT() const = delete; - template - constexpr detail::Hopper targetT() const; + template + constexpr detail::Hopper targetT() const; //indicates if a particular set of arguments accepted by the functor associated with it. template diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index b4cf7b95..9454ee09 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -29,10 +29,10 @@ namespace rtl } - template - inline constexpr detail::Hopper Method::targetT() const + template + inline constexpr detail::Hopper Method::targetT() const { - return detail::Hopper{ getFunctorsMeta() }; + return detail::Hopper{ getFunctorsMeta() }; } diff --git a/ReflectionTemplateLib/rtl/rtl_traits.h b/ReflectionTemplateLib/rtl/rtl_traits.h index f91ccbea..d5bf60af 100644 --- a/ReflectionTemplateLib/rtl/rtl_traits.h +++ b/ReflectionTemplateLib/rtl/rtl_traits.h @@ -185,4 +185,17 @@ namespace rtl::traits template inline constexpr bool is_nonconst_ref_v = ((std::is_lvalue_reference_v || std::is_rvalue_reference_v) && !std::is_const_v>); + + template + constexpr static const bool type_aware_v = (!std::is_same_v && !std::is_same_v); + + template + constexpr static const bool return_erased_v = (!std::is_same_v && std::is_same_v); + + template + constexpr static const bool target_erased_v = (std::is_same_v && !std::is_same_v); + + template + constexpr static const bool type_erased_v = (std::is_same_v && std::is_same_v); + } \ No newline at end of file From 4663467b01141f64491bfff006a8c8b0309208b4 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 25 Oct 2025 01:22:32 +0530 Subject: [PATCH 105/148] benchmark for all-type-erased-method, refactor. --- RTLBenchmarkApp/src/BenchMark.cpp | 4 +- .../src/ReflectedCallKnownReturn.cpp | 119 +++++++++--------- .../src/ReflectedCallKnownReturn.h | 45 +++---- .../src/ReflectedCallUnknownReturn.cpp | 119 ++++++++++++------ .../src/ReflectedCallUnknownReturn.h | 34 +++-- RTLBenchmarkApp/src/StandardCall.cpp | 81 ++++++------ RTLBenchmarkApp/src/StandardCall.h | 33 ++--- RTLBenchmarkApp/src/main.cpp | 42 ++++--- 8 files changed, 273 insertions(+), 204 deletions(-) diff --git a/RTLBenchmarkApp/src/BenchMark.cpp b/RTLBenchmarkApp/src/BenchMark.cpp index a631aa3c..8605dcfb 100644 --- a/RTLBenchmarkApp/src/BenchMark.cpp +++ b/RTLBenchmarkApp/src/BenchMark.cpp @@ -35,7 +35,7 @@ namespace bm retStr_t getMessage(argStr_t pMsg) noexcept { - retStr_t retStr; + retStr_t retStr = g_work_done->c_str(); if(g_work_load){ g_work_done = perform_work(pMsg); retStr = g_work_done->c_str(); @@ -45,7 +45,7 @@ namespace bm retStr_t Node::getMessage(argStr_t pMsg) noexcept { - retStr_t retStr; + retStr_t retStr = g_work_done->c_str(); if(g_work_load){ g_work_done = perform_work(pMsg); retStr = g_work_done->c_str(); diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index 6016e541..d52ea7d4 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -95,88 +95,93 @@ namespace } -void NativeFunctionPtr_call::returnNonVoid(benchmark::State& state) +namespace bm_call { - static auto _=_new_line(); - static auto is_ok = test(getMessage, 0); - for (auto _ : state) + void by_FunctionPtr_Function::get_string(benchmark::State& state) { - benchmark::DoNotOptimize((getMessage.f_ptr())(bm::g_longStr)); + static auto _ = _new_line(); + static auto is_ok = test(getMessage, 0); + for (auto _ : state) + { + benchmark::DoNotOptimize((getMessage.f_ptr())(bm::g_longStr)); + } } -} -void NativeFunctionPtr_callMethod::returnNonVoid(benchmark::State& state) -{ - static bm::Node nodeObj; - static auto is_ok = test(getMessageNode, 1); - for (auto _ : state) + void by_FunctionPtr___Method::get_string(benchmark::State& state) { - benchmark::DoNotOptimize((nodeObj.*getMessageNode.f_ptr())(bm::g_longStr)); + static bm::Node nodeObj; + static auto is_ok = test(getMessageNode, 1); + for (auto _ : state) + { + benchmark::DoNotOptimize((nodeObj.*getMessageNode.f_ptr())(bm::g_longStr)); + } } -} -void NativeFunctionPtr_call::returnVoid(benchmark::State& state) -{ - static auto _ = _new_line(); - static auto is_ok = test(sendMessage, 2); - for (auto _ : state) + void by_FunctionPtr_Function::set_string(benchmark::State& state) { - (sendMessage.f_ptr())(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + static auto _ = _new_line(); + static auto is_ok = test(sendMessage, 2); + for (auto _ : state) + { + (sendMessage.f_ptr())(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } } -} -void NativeFunctionPtr_callMethod::returnVoid(benchmark::State& state) -{ - static bm::Node nodeObj; - static auto is_ok = test(getMessageNode, 2); - for (auto _ : state) + void by_FunctionPtr___Method::set_string(benchmark::State& state) { - (nodeObj.*sendMessageNode.f_ptr())(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + static bm::Node nodeObj; + static auto is_ok = test(getMessageNode, 2); + for (auto _ : state) + { + (nodeObj.*sendMessageNode.f_ptr())(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } } } - -void RtlStaticTyped_call::returnNonVoid(benchmark::State &state) +namespace bm_rtl { - static auto _ = _new_line(); - static auto is_ok = test(getMessage, 3); - for (auto _ : state) + void function_CallsFunction::get_string(benchmark::State& state) { - benchmark::DoNotOptimize(getMessage(bm::g_longStr)); + static auto _ = _new_line(); + static auto is_ok = test(getMessage, 3); + for (auto _ : state) + { + benchmark::DoNotOptimize(getMessage(bm::g_longStr)); + } } -} -void RtlStaticTyped_callMethod::returnNonVoid(benchmark::State& state) -{ - static bm::Node nodeObj; - static auto is_ok = test(getMessageNode, 4); - for (auto _ : state) + void function_CallsFunction::set_string(benchmark::State& state) { - benchmark::DoNotOptimize(getMessageNode(nodeObj)(bm::g_longStr)); + static auto _ = _new_line(); + static auto is_ok = test(sendMessage, 0); + for (auto _ : state) + { + sendMessage(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } } -} -void RtlStaticTyped_call::returnVoid(benchmark::State& state) -{ - static auto _ = _new_line(); - static auto is_ok = test(sendMessage, 0); - for (auto _ : state) + void method_____CallsMethod::get_string(benchmark::State& state) { - sendMessage(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + static bm::Node nodeObj; + static auto is_ok = test(getMessageNode, 4); + for (auto _ : state) + { + benchmark::DoNotOptimize(getMessageNode(nodeObj)(bm::g_longStr)); + } } -} -void RtlStaticTyped_callMethod::returnVoid(benchmark::State& state) -{ - static bm::Node nodeObj; - static auto is_ok = test(sendMessageNode, 5); - for (auto _ : state) + void method_____CallsMethod::set_string(benchmark::State& state) { - sendMessageNode(nodeObj)(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + static bm::Node nodeObj; + static auto is_ok = test(sendMessageNode, 5); + for (auto _ : state) + { + sendMessageNode(nodeObj)(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index 9469905f..18c840c0 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -2,33 +2,36 @@ #include -struct RtlStaticTyped_call +namespace bm_call { - static void returnVoid(benchmark::State& state); + struct by_FunctionPtr_Function + { + static void set_string(benchmark::State& state); - static void returnNonVoid(benchmark::State& state); -}; + static void get_string(benchmark::State& state); + }; + struct by_FunctionPtr___Method + { + static void set_string(benchmark::State& state); -struct NativeFunctionPtr_call -{ - static void returnVoid(benchmark::State& state); - - static void returnNonVoid(benchmark::State& state); -}; - + static void get_string(benchmark::State& state); + }; +} -struct NativeFunctionPtr_callMethod +namespace bm_rtl { - static void returnVoid(benchmark::State& state); + struct function_CallsFunction + { + static void set_string(benchmark::State& state); - static void returnNonVoid(benchmark::State& state); -}; + static void get_string(benchmark::State& state); + }; + struct method_____CallsMethod + { + static void set_string(benchmark::State& state); -struct RtlStaticTyped_callMethod -{ - static void returnVoid(benchmark::State& state); - - static void returnNonVoid(benchmark::State& state); -}; \ No newline at end of file + static void get_string(benchmark::State& state); + }; +} \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 36435a56..7e927e33 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -226,6 +226,24 @@ namespace return 0; }; + static auto _test6 = []() + { + auto [err, returnOpt] = ErasedTargetAwareReturn_SendMessage(nodeObj)(bm::g_longStr); + if (err != rtl::error::None) { + std::cerr << "[06] error: " << rtl::to_string(err) << "\n"; + } + return 0; + }; + + static auto _test7 = []() + { + auto [err, returnOpt] = ErasedTargetAwareReturn_SendMessage(nodeObj)(bm::g_longStr); + if (err != rtl::error::None) { + std::cerr << "[07] error: " << rtl::to_string(err) << "\n"; + } + return 0; + }; + static auto _new_line = []() { std::cerr << std::endl; return 0; @@ -233,66 +251,89 @@ namespace } - -void RtlErasedReturnType_call::returnVoid(benchmark::State& state) +namespace bm_rtl { - static auto __= _new_line(); - static auto _ = _test0(); - for (auto _ : state) + void function_ErasedReturnType::set_string(benchmark::State& state) { - benchmark::DoNotOptimize(ErasedReturnFn_SendMessage(bm::g_longStr).err); + static auto __ = _new_line(); + static auto _ = _test0(); + for (auto _ : state) + { + benchmark::DoNotOptimize(ErasedReturnFn_SendMessage(bm::g_longStr).err); + } } -} - -void RtlErasedReturnType_call::returnNonVoid(benchmark::State& state) -{ - static auto __= _new_line(); - static auto _ = _test1(); - for (auto _ : state) + void function_ErasedReturnType::get_string(benchmark::State& state) { - benchmark::DoNotOptimize(ErasedReturnFn_GetMessage(bm::g_longStr).err); + static auto __ = _new_line(); + static auto _ = _test1(); + for (auto _ : state) + { + benchmark::DoNotOptimize(ErasedReturnFn_GetMessage(bm::g_longStr).err); + } } } -void RtlErasedReturnType_callMethod::returnVoid(benchmark::State& state) +namespace bm_rtl { - static auto _ = _test2(); - static bm::Node node; - for (auto _ : state) + void method___ErasedReturnType::set_string(benchmark::State& state) { - benchmark::DoNotOptimize(ErasedReturnAwareTarget_SendMessage(node)(bm::g_longStr).err); + static auto _ = _test2(); + static bm::Node node; + for (auto _ : state) + { + benchmark::DoNotOptimize(ErasedReturnAwareTarget_SendMessage(node)(bm::g_longStr)); + } } -} - -void RtlErasedReturnType_callMethod::returnNonVoid(benchmark::State& state) -{ - static auto _ = _test3(); - static bm::Node node; - for (auto _ : state) + void method___ErasedReturnType::get_string(benchmark::State& state) { - benchmark::DoNotOptimize(ErasedReturnAwareTarget_GetMessage(node)(bm::g_longStr).err); + static auto _ = _test3(); + static bm::Node node; + for (auto _ : state) + { + benchmark::DoNotOptimize(ErasedReturnAwareTarget_GetMessage(node)(bm::g_longStr)); + } } -} + void method___ErasedTargetType::set_string(benchmark::State& state) + { + static auto _ = _test2(); + static bm::Node node; + for (auto _ : state) + { + benchmark::DoNotOptimize(ErasedTargetAwareReturn_SendMessage(nodeObj)(bm::g_longStr)); + } + } -void RtlErasedReturnType_callMethod::unknownTarget_returnVoid(benchmark::State& state) -{ - static auto _ = _test4(); - for (auto _ : state) + void method___ErasedTargetType::get_string(benchmark::State& state) { - benchmark::DoNotOptimize(ErasedReturnAndTarget_SendMessage(nodeObj)(bm::g_longStr).err); + static auto _ = _test3(); + static bm::Node node; + for (auto _ : state) + { + benchmark::DoNotOptimize(ErasedTargetAwareReturn_GetMessage(nodeObj)(bm::g_longStr)); + } } -} + void method___ErasedTargetAndReturnType::set_string(benchmark::State& state) + { + static auto _ = _test2(); + static bm::Node node; + for (auto _ : state) + { + benchmark::DoNotOptimize(ErasedReturnAndTarget_SendMessage(nodeObj)(bm::g_longStr)); + } + } -void RtlErasedReturnType_callMethod::unknownTarget_returnNonVoid(benchmark::State& state) -{ - static auto _ = _test5(); - for (auto _ : state) + void method___ErasedTargetAndReturnType::get_string(benchmark::State& state) { - benchmark::DoNotOptimize(ErasedReturnAndTarget_GetMessage(nodeObj)(bm::g_longStr).err); + static auto _ = _test3(); + static bm::Node node; + for (auto _ : state) + { + benchmark::DoNotOptimize(ErasedReturnAndTarget_GetMessage(nodeObj)(bm::g_longStr)); + } } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index 86f271b9..4dcb5279 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -2,21 +2,33 @@ #include -struct RtlErasedReturnType_call +namespace bm_rtl { - static void returnVoid(benchmark::State& state); + struct function_ErasedReturnType + { + static void set_string(benchmark::State& state); - static void returnNonVoid(benchmark::State& state); -}; + static void get_string(benchmark::State& state); + }; + struct method___ErasedReturnType + { + static void set_string(benchmark::State& state); -struct RtlErasedReturnType_callMethod -{ - static void returnVoid(benchmark::State& state); + static void get_string(benchmark::State& state); + }; - static void returnNonVoid(benchmark::State& state); + struct method___ErasedTargetType + { + static void set_string(benchmark::State& state); - static void unknownTarget_returnVoid(benchmark::State& state); + static void get_string(benchmark::State& state); + }; - static void unknownTarget_returnNonVoid(benchmark::State& state); -}; \ No newline at end of file + struct method___ErasedTargetAndReturnType + { + static void set_string(benchmark::State& state); + + static void get_string(benchmark::State& state); + }; +} \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index f5f93297..40868443 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -11,7 +11,7 @@ namespace { static auto _put_line = []() { std::cout << "-----------------------------------------------" - "-------------------------------------------------------" << std::endl; + "--------------------------------------------------" << std::endl; return 0; }; @@ -39,64 +39,65 @@ namespace bm extern std::function NodeGetMessage; } - -void NativeCall::returnVoid(benchmark::State& state) +namespace bm_call { - for (auto _: state) + void direct_Function::set_string(benchmark::State& state) { - bm::sendMessage(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + for (auto _ : state) + { + bm::sendMessage(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } } -} - -void NativeCall::returnNonVoid(benchmark::State& state) -{ - static auto _=_put_line(); - for (auto _: state) + void direct_Function::get_string(benchmark::State& state) { - benchmark::DoNotOptimize(bm::getMessage(bm::g_longStr)); + static auto _ = _put_line(); + for (auto _ : state) + { + benchmark::DoNotOptimize(bm::getMessage(bm::g_longStr)); + } } } -void StdFunction_call::returnVoid(benchmark::State& state) +namespace bm_std { - static auto _=_new_line(); - for (auto _: state) + void function_CallsFunction::set_string(benchmark::State& state) { - bm::SendMessage(bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + static auto _ = _new_line(); + for (auto _ : state) + { + bm::SendMessage(bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } } -} - -void StdFunction_callMethod::returnVoid(benchmark::State& state) -{ - static bm::Node nodeObj; - for (auto _: state) + void function___CallsMethod::set_string(benchmark::State& state) { - bm::NodeSendMessage(nodeObj, bm::g_longStr); - benchmark::DoNotOptimize(bm::g_work_done->c_str()); + static bm::Node nodeObj; + for (auto _ : state) + { + bm::NodeSendMessage(nodeObj, bm::g_longStr); + benchmark::DoNotOptimize(bm::g_work_done->c_str()); + } } -} - -void StdFunction_call::returnNonVoid(benchmark::State& state) -{ - static auto _=_new_line(); - for (auto _: state) + void function_CallsFunction::get_string(benchmark::State& state) { - benchmark::DoNotOptimize(bm::GetMessage(bm::g_longStr)); + static auto _ = _new_line(); + for (auto _ : state) + { + benchmark::DoNotOptimize(bm::GetMessage(bm::g_longStr)); + } } -} - -void StdFunction_callMethod::returnNonVoid(benchmark::State& state) -{ - static bm::Node nodeObj; - for (auto _: state) + void function___CallsMethod::get_string(benchmark::State& state) { - benchmark::DoNotOptimize(bm::NodeGetMessage(nodeObj, bm::g_longStr)); + static bm::Node nodeObj; + for (auto _ : state) + { + benchmark::DoNotOptimize(bm::NodeGetMessage(nodeObj, bm::g_longStr)); + } } } \ No newline at end of file diff --git a/RTLBenchmarkApp/src/StandardCall.h b/RTLBenchmarkApp/src/StandardCall.h index bbc77907..a825692c 100644 --- a/RTLBenchmarkApp/src/StandardCall.h +++ b/RTLBenchmarkApp/src/StandardCall.h @@ -2,25 +2,30 @@ #include -struct NativeCall +namespace bm_call { - static void returnVoid(benchmark::State& state); - - static void returnNonVoid(benchmark::State& state); -}; + struct direct_Function + { + static void set_string(benchmark::State& state); + static void get_string(benchmark::State& state); + }; +} -struct StdFunction_call +namespace bm_std { - static void returnVoid(benchmark::State& state); + struct function_CallsFunction + { + static void set_string(benchmark::State& state); - static void returnNonVoid(benchmark::State& state); -}; + static void get_string(benchmark::State& state); + }; -struct StdFunction_callMethod -{ - static void returnVoid(benchmark::State& state); + struct function___CallsMethod + { + static void set_string(benchmark::State& state); - static void returnNonVoid(benchmark::State& state); -}; \ No newline at end of file + static void get_string(benchmark::State& state); + }; +} \ No newline at end of file diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index 1cae31f9..f8bae56c 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -6,35 +6,37 @@ #include "ReflectedCallKnownReturn.h" #include "ReflectedCallUnknownReturn.h" -BENCHMARK(NativeCall::returnVoid); +BENCHMARK(bm_call::direct_Function::set_string); -BENCHMARK(NativeFunctionPtr_call::returnVoid); -BENCHMARK(NativeFunctionPtr_callMethod::returnVoid); +BENCHMARK(bm_call::by_FunctionPtr_Function::set_string); +BENCHMARK(bm_call::by_FunctionPtr___Method::set_string); -BENCHMARK(StdFunction_call::returnVoid); -BENCHMARK(StdFunction_callMethod::returnVoid); +BENCHMARK(bm_std::function_CallsFunction::set_string); +BENCHMARK(bm_std::function___CallsMethod::set_string); -BENCHMARK(RtlStaticTyped_call::returnVoid); -BENCHMARK(RtlStaticTyped_callMethod::returnVoid); +BENCHMARK(bm_rtl::function_CallsFunction::set_string); +BENCHMARK(bm_rtl::method_____CallsMethod::set_string); -BENCHMARK(RtlErasedReturnType_call::returnVoid); -BENCHMARK(RtlErasedReturnType_callMethod::returnVoid); -BENCHMARK(RtlErasedReturnType_callMethod::unknownTarget_returnVoid); +BENCHMARK(bm_rtl::function_ErasedReturnType::set_string); +BENCHMARK(bm_rtl::method___ErasedReturnType::set_string); +BENCHMARK(bm_rtl::method___ErasedTargetType::set_string); +BENCHMARK(bm_rtl::method___ErasedTargetAndReturnType::set_string); -BENCHMARK(NativeCall::returnNonVoid); +BENCHMARK(bm_call::direct_Function::get_string); -BENCHMARK(NativeFunctionPtr_call::returnNonVoid); -BENCHMARK(NativeFunctionPtr_callMethod::returnNonVoid); +BENCHMARK(bm_call::by_FunctionPtr_Function::get_string); +BENCHMARK(bm_call::by_FunctionPtr___Method::get_string); -BENCHMARK(StdFunction_call::returnNonVoid); -BENCHMARK(StdFunction_callMethod::returnNonVoid); +BENCHMARK(bm_std::function_CallsFunction::get_string); +BENCHMARK(bm_std::function___CallsMethod::get_string); -BENCHMARK(RtlStaticTyped_call::returnNonVoid); -BENCHMARK(RtlStaticTyped_callMethod::returnNonVoid); +BENCHMARK(bm_rtl::function_CallsFunction::get_string); +BENCHMARK(bm_rtl::method_____CallsMethod::get_string); -BENCHMARK(RtlErasedReturnType_call::returnNonVoid); -BENCHMARK(RtlErasedReturnType_callMethod::returnNonVoid); -BENCHMARK(RtlErasedReturnType_callMethod::unknownTarget_returnNonVoid); +BENCHMARK(bm_rtl::function_ErasedReturnType::get_string); +BENCHMARK(bm_rtl::method___ErasedReturnType::get_string); +BENCHMARK(bm_rtl::method___ErasedTargetType::get_string); +BENCHMARK(bm_rtl::method___ErasedTargetAndReturnType::get_string); namespace bm { From e6d46aee33929686020f719f9d198ecbdfb3021c Mon Sep 17 00:00:00 2001 From: neeraj Date: Sat, 25 Oct 2025 08:46:35 +0530 Subject: [PATCH 106/148] latest benchmark logs added. --- run_benchmarks.sh | 8 +- text-benchmark-logs/benchmark_runs.log | 5781 ++++++++---------------- 2 files changed, 1903 insertions(+), 3886 deletions(-) diff --git a/run_benchmarks.sh b/run_benchmarks.sh index f1be44c6..e6d42d56 100755 --- a/run_benchmarks.sh +++ b/run_benchmarks.sh @@ -31,28 +31,28 @@ run_benchmark() { # --------------------------- # Phase 1: Baseline runs (scale 0, 10 reps) # --------------------------- -run_benchmark 0 10 +run_benchmark 0 5 # --------------------------- # Phase 2: Scales 1 → 50 # --------------------------- SCALES_PHASE2=(1 5 10 15 20 25 30 35 40 45 50) for SCALE in "${SCALES_PHASE2[@]}"; do - run_benchmark "$SCALE" 5 + run_benchmark "$SCALE" 3 done # --------------------------- # Phase 3: Scales 58 → 90 (step 8) # --------------------------- for SCALE in $(seq 58 8 90); do - run_benchmark "$SCALE" 5 + run_benchmark "$SCALE" 3 done # --------------------------- # Phase 4: Final higher scales # --------------------------- for SCALE in 100 120 150; do - run_benchmark "$SCALE" 5 + run_benchmark "$SCALE" 3 done echo "All benchmarks completed." | tee -a "$LOGFILE" diff --git a/text-benchmark-logs/benchmark_runs.log b/text-benchmark-logs/benchmark_runs.log index fb3506bd..c7fa2be8 100644 --- a/text-benchmark-logs/benchmark_runs.log +++ b/text-benchmark-logs/benchmark_runs.log @@ -2,14 +2,14 @@ Starting benchmark runs... Binary: ./bin/RTLBenchmarkApp Log: ./benchmark_runs.log =================================== -[2025-10-09 22:16:17] >>> Run 1: workload scale = 0 +[2025-10-25 08:18:21] >>> Run 1: workload scale = 0 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 0 iterations ============================================= -2025-10-09T22:16:17+05:30 +2025-10-25T08:18:21+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -17,2008 +17,101 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 0.14, 0.76, 0.94 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.615 ns 0.614 ns 1000000000 +Load Average: 0.45, 0.40, 0.19 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 0.648 ns 0.648 ns 1000000000 -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488371014 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683556568 +bm_call::by_FunctionPtr_Function::set_string 1.04 ns 1.04 ns 681434660 +bm_call::by_FunctionPtr___Method::set_string 1.55 ns 1.55 ns 466084139 -StdFunction_call::returnVoid 1.49 ns 1.49 ns 470596629 -StdFunction_callMethod::returnVoid 1.86 ns 1.86 ns 376392993 +bm_std::function_CallsFunction::set_string 1.52 ns 1.52 ns 457442165 +bm_std::function___CallsMethod::set_string 1.73 ns 1.73 ns 404393007 -RtlFunction_call::returnVoid 1.25 ns 1.25 ns 570174699 -RtlFunction_callMethod::returnVoid 1.45 ns 1.45 ns 486118183 +bm_rtl::function_CallsFunction::set_string 1.05 ns 1.05 ns 650597013 +bm_rtl::method_____CallsMethod::set_string 1.67 ns 1.67 ns 419270587 -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201243535 -RtlFunction_callMethod_ReturnUnknown::Void 3.24 ns 3.23 ns 221225444 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.93 ns 3.93 ns 179544125 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.693 ns 0.693 ns 1000000000 +bm_rtl::function_ErasedReturnType::set_string 2.82 ns 2.82 ns 247626666 +bm_rtl::method___ErasedReturnType::set_string 3.81 ns 3.81 ns 182981375 +bm_rtl::method___ErasedTargetType::set_string 4.20 ns 4.20 ns 168530894 +bm_rtl::method___ErasedTargetAndReturnType::set_string 4.71 ns 4.71 ns 149802502 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1.40 ns 1.40 ns 478431698 -NativeFunctionPtr_call::returnNonVoid 1.09 ns 1.09 ns 649459865 -NativeFunctionPtr_callMethod::returnNonVoid 1.50 ns 1.50 ns 481407569 +bm_call::by_FunctionPtr_Function::get_string 2.78 ns 2.78 ns 258764618 +bm_call::by_FunctionPtr___Method::get_string 2.50 ns 2.50 ns 269105357 -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427191529 -StdFunction_callMethod::returnNonVoid 1.78 ns 1.78 ns 372485231 +bm_std::function_CallsFunction::get_string 2.67 ns 2.67 ns 256264788 +bm_std::function___CallsMethod::get_string 2.92 ns 2.92 ns 241666956 -RtlFunction_call::returnNonVoid 1.39 ns 1.39 ns 528064222 -RtlFunction_callMethod::returnNonVoid 1.59 ns 1.59 ns 427333237 +bm_rtl::function_CallsFunction::get_string 2.48 ns 2.48 ns 281118860 +bm_rtl::method_____CallsMethod::get_string 2.70 ns 2.69 ns 257929875 -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50786184 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.3 ns 13.3 ns 53298525 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47909277 +bm_rtl::function_ErasedReturnType::get_string 14.6 ns 14.6 ns 45984040 +bm_rtl::method___ErasedReturnType::get_string 15.1 ns 15.1 ns 44798614 +bm_rtl::method___ErasedTargetType::get_string 5.50 ns 5.50 ns 129984598 +bm_rtl::method___ErasedTargetAndReturnType::get_string 17.4 ns 17.4 ns 40921439 ----------------------------------- -[2025-10-09 22:16:35] >>> Run 2: workload scale = 0 +[2025-10-25 08:18:42] >>> Run 2: workload scale = 0 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 0 iterations ============================================= -2025-10-09T22:16:35+05:30 +2025-10-25T08:18:42+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.33, 0.77, 0.94 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.540 ns 0.540 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 487948937 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683488850 - -StdFunction_call::returnVoid 1.47 ns 1.47 ns 488617891 -StdFunction_callMethod::returnVoid 1.85 ns 1.85 ns 377645764 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569768981 -RtlFunction_callMethod::returnVoid 1.45 ns 1.45 ns 483937345 - -RtlFunction_call_ReturnUnknown::Void 3.49 ns 3.49 ns 201075618 -RtlFunction_callMethod_ReturnUnknown::Void 3.18 ns 3.18 ns 220548820 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.89 ns 3.89 ns 179320699 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.694 ns 0.694 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.10 ns 1.10 ns 647073593 -NativeFunctionPtr_callMethod::returnNonVoid 1.50 ns 1.50 ns 492913179 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427278526 -StdFunction_callMethod::returnNonVoid 1.84 ns 1.84 ns 391027228 - -RtlFunction_call::returnNonVoid 1.41 ns 1.41 ns 486150854 -RtlFunction_callMethod::returnNonVoid 1.62 ns 1.62 ns 460145276 - -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50781975 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.4 ns 13.4 ns 52916421 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.7 ns 14.7 ns 46665825 ------------------------------------ -[2025-10-09 22:16:52] >>> Run 3: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-09T22:16:52+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.52, 0.79, 0.95 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.537 ns 0.537 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 486916993 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683124349 - -StdFunction_call::returnVoid 1.48 ns 1.48 ns 472661856 -StdFunction_callMethod::returnVoid 1.85 ns 1.85 ns 380898454 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569145309 -RtlFunction_callMethod::returnVoid 1.47 ns 1.47 ns 488608846 - -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201221095 -RtlFunction_callMethod_ReturnUnknown::Void 3.16 ns 3.16 ns 219108881 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.92 ns 3.92 ns 179754192 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.693 ns 0.692 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.10 ns 1.10 ns 639080262 -NativeFunctionPtr_callMethod::returnNonVoid 1.53 ns 1.53 ns 482602667 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427317043 -StdFunction_callMethod::returnNonVoid 1.80 ns 1.80 ns 396879318 - -RtlFunction_call::returnNonVoid 1.41 ns 1.41 ns 498559192 -RtlFunction_callMethod::returnNonVoid 1.57 ns 1.57 ns 449206328 - -RtlFunction_call_ReturnUnknown::NonVoid 13.7 ns 13.7 ns 49813322 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 53497529 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.7 ns 14.7 ns 47741737 ------------------------------------ -[2025-10-09 22:17:10] >>> Run 4: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-09T22:17:10+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.63, 0.80, 0.95 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.540 ns 0.539 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488327143 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683830386 - -StdFunction_call::returnVoid 1.46 ns 1.46 ns 486442061 -StdFunction_callMethod::returnVoid 1.88 ns 1.88 ns 371827284 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 570108800 -RtlFunction_callMethod::returnVoid 1.46 ns 1.46 ns 482174568 - -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201414001 -RtlFunction_callMethod_ReturnUnknown::Void 3.18 ns 3.18 ns 219417993 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.88 ns 3.88 ns 179104676 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.694 ns 0.694 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.08 ns 1.08 ns 641935885 -NativeFunctionPtr_callMethod::returnNonVoid 1.56 ns 1.55 ns 442554688 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427559456 -StdFunction_callMethod::returnNonVoid 1.83 ns 1.83 ns 393616857 - -RtlFunction_call::returnNonVoid 1.44 ns 1.44 ns 462588664 -RtlFunction_callMethod::returnNonVoid 1.55 ns 1.55 ns 443460688 - -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 51342305 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.3 ns 13.3 ns 53292826 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47789473 ------------------------------------ -[2025-10-09 22:17:27] >>> Run 5: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-09T22:17:27+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.73, 0.81, 0.95 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.614 ns 0.614 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488465535 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 682376940 - -StdFunction_call::returnVoid 1.47 ns 1.47 ns 486399948 -StdFunction_callMethod::returnVoid 1.85 ns 1.85 ns 380599795 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569979525 -RtlFunction_callMethod::returnVoid 1.45 ns 1.45 ns 480584216 - -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201218265 -RtlFunction_callMethod_ReturnUnknown::Void 3.20 ns 3.20 ns 218513145 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.90 ns 3.90 ns 180411390 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.692 ns 0.692 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.09 ns 1.09 ns 639172235 -NativeFunctionPtr_callMethod::returnNonVoid 1.46 ns 1.46 ns 501201889 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427402144 -StdFunction_callMethod::returnNonVoid 1.79 ns 1.79 ns 392583620 - -RtlFunction_call::returnNonVoid 1.34 ns 1.34 ns 518974309 -RtlFunction_callMethod::returnNonVoid 1.58 ns 1.58 ns 447407186 - -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50810272 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 53697288 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47745107 ------------------------------------ -[2025-10-09 22:17:45] >>> Run 6: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-09T22:17:45+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.79, 0.83, 0.95 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.538 ns 0.538 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488628989 -NativeFunctionPtr_callMethod::returnVoid 1.03 ns 1.02 ns 684056697 - -StdFunction_call::returnVoid 1.46 ns 1.46 ns 482074155 -StdFunction_callMethod::returnVoid 1.84 ns 1.84 ns 379683455 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 570148014 -RtlFunction_callMethod::returnVoid 1.45 ns 1.45 ns 486200457 - -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201269021 -RtlFunction_callMethod_ReturnUnknown::Void 3.22 ns 3.22 ns 220434176 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.90 ns 3.90 ns 178941515 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.694 ns 0.694 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.10 ns 1.10 ns 640033156 -NativeFunctionPtr_callMethod::returnNonVoid 1.53 ns 1.53 ns 484321550 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427395695 -StdFunction_callMethod::returnNonVoid 1.79 ns 1.79 ns 383213510 - -RtlFunction_call::returnNonVoid 1.39 ns 1.39 ns 498672448 -RtlFunction_callMethod::returnNonVoid 1.55 ns 1.55 ns 447413397 - -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50494352 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 53438544 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47358599 ------------------------------------ -[2025-10-09 22:18:03] >>> Run 7: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-09T22:18:03+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.85, 0.84, 0.95 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.534 ns 0.534 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.44 ns 1.43 ns 487373256 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 684129923 - -StdFunction_call::returnVoid 1.49 ns 1.49 ns 486533392 -StdFunction_callMethod::returnVoid 1.87 ns 1.87 ns 372226528 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 570130359 -RtlFunction_callMethod::returnVoid 1.50 ns 1.49 ns 488476787 - -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201265803 -RtlFunction_callMethod_ReturnUnknown::Void 3.19 ns 3.19 ns 219574993 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.92 ns 3.92 ns 179946597 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.692 ns 0.692 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.08 ns 1.08 ns 636786202 -NativeFunctionPtr_callMethod::returnNonVoid 1.50 ns 1.50 ns 438081296 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427138506 -StdFunction_callMethod::returnNonVoid 1.81 ns 1.81 ns 368043984 - -RtlFunction_call::returnNonVoid 1.43 ns 1.43 ns 490343930 -RtlFunction_callMethod::returnNonVoid 1.65 ns 1.65 ns 428580493 - -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50492376 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 52986296 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.7 ns 14.7 ns 47036220 ------------------------------------ -[2025-10-09 22:18:20] >>> Run 8: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-09T22:18:20+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.89, 0.85, 0.95 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.536 ns 0.536 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488721454 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683970735 - -StdFunction_call::returnVoid 1.44 ns 1.44 ns 479849742 -StdFunction_callMethod::returnVoid 1.85 ns 1.85 ns 376284530 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569899714 -RtlFunction_callMethod::returnVoid 1.46 ns 1.46 ns 477113064 - -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.47 ns 201269015 -RtlFunction_callMethod_ReturnUnknown::Void 3.20 ns 3.20 ns 222216957 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.89 ns 3.89 ns 180306431 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.694 ns 0.694 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.10 ns 1.10 ns 647589992 -NativeFunctionPtr_callMethod::returnNonVoid 1.46 ns 1.46 ns 486880203 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427281796 -StdFunction_callMethod::returnNonVoid 1.79 ns 1.79 ns 378599554 - -RtlFunction_call::returnNonVoid 1.42 ns 1.42 ns 493358927 -RtlFunction_callMethod::returnNonVoid 1.55 ns 1.55 ns 422127463 - -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 50826607 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.3 ns 13.3 ns 53224105 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47061421 ------------------------------------ -[2025-10-09 22:18:38] >>> Run 9: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-09T22:18:38+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.92, 0.86, 0.96 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.614 ns 0.614 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488251170 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 682497941 - -StdFunction_call::returnVoid 1.45 ns 1.45 ns 475925971 -StdFunction_callMethod::returnVoid 1.88 ns 1.88 ns 377354115 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 570115463 -RtlFunction_callMethod::returnVoid 1.46 ns 1.46 ns 480603254 - -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 200777871 -RtlFunction_callMethod_ReturnUnknown::Void 3.19 ns 3.19 ns 214825856 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.90 ns 3.90 ns 179384624 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.693 ns 0.693 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.08 ns 1.08 ns 632628408 -NativeFunctionPtr_callMethod::returnNonVoid 1.50 ns 1.50 ns 491783053 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427586231 -StdFunction_callMethod::returnNonVoid 1.82 ns 1.82 ns 388424012 - -RtlFunction_call::returnNonVoid 1.37 ns 1.37 ns 507299706 -RtlFunction_callMethod::returnNonVoid 1.55 ns 1.55 ns 446340209 - -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 51035639 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.3 ns 13.3 ns 53646607 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47338426 ------------------------------------ -[2025-10-09 22:18:55] >>> Run 10: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-09T22:18:55+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.94, 0.86, 0.96 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 0.541 ns 0.541 ns 1000000000 - -NativeFunctionPtr_call::returnVoid 1.43 ns 1.43 ns 488253694 -NativeFunctionPtr_callMethod::returnVoid 1.02 ns 1.02 ns 683995671 - -StdFunction_call::returnVoid 1.47 ns 1.47 ns 482164541 -StdFunction_callMethod::returnVoid 1.86 ns 1.86 ns 378821155 - -RtlFunction_call::returnVoid 1.23 ns 1.23 ns 569848625 -RtlFunction_callMethod::returnVoid 1.48 ns 1.48 ns 471901482 - -RtlFunction_call_ReturnUnknown::Void 3.48 ns 3.48 ns 201189833 -RtlFunction_callMethod_ReturnUnknown::Void 3.19 ns 3.19 ns 217482610 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3.92 ns 3.92 ns 178990707 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 0.692 ns 0.692 ns 1000000000 - -NativeFunctionPtr_call::returnNonVoid 1.09 ns 1.09 ns 635090027 -NativeFunctionPtr_callMethod::returnNonVoid 1.51 ns 1.51 ns 497893190 - -StdFunction_call::returnNonVoid 1.64 ns 1.64 ns 427655543 -StdFunction_callMethod::returnNonVoid 1.86 ns 1.86 ns 367002436 - -RtlFunction_call::returnNonVoid 1.41 ns 1.40 ns 489489712 -RtlFunction_callMethod::returnNonVoid 1.59 ns 1.59 ns 459390527 - -RtlFunction_call_ReturnUnknown::NonVoid 13.8 ns 13.8 ns 51251170 -RtlFunction_callMethod_ReturnUnknown::NonVoid 13.2 ns 13.2 ns 52169372 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 14.8 ns 14.8 ns 47420606 ------------------------------------ -[2025-10-09 22:19:13] >>> Run 1: workload scale = 1 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 1 iterations -============================================= - -2025-10-09T22:19:13+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.96, 0.87, 0.96 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 14.9 ns 14.9 ns 46377011 - -NativeFunctionPtr_call::returnVoid 15.3 ns 15.3 ns 46227161 -NativeFunctionPtr_callMethod::returnVoid 14.9 ns 14.9 ns 46573202 - -StdFunction_call::returnVoid 15.2 ns 15.2 ns 44104419 -StdFunction_callMethod::returnVoid 15.8 ns 15.8 ns 42962369 - -RtlFunction_call::returnVoid 15.3 ns 15.3 ns 44274191 -RtlFunction_callMethod::returnVoid 15.9 ns 15.9 ns 43477860 - -RtlFunction_call_ReturnUnknown::Void 17.3 ns 17.3 ns 39575146 -RtlFunction_callMethod_ReturnUnknown::Void 17.2 ns 17.2 ns 40222647 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 18.4 ns 18.4 ns 38292662 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 20.9 ns 20.9 ns 33583339 - -NativeFunctionPtr_call::returnNonVoid 20.9 ns 20.9 ns 33634347 -NativeFunctionPtr_callMethod::returnNonVoid 21.1 ns 21.1 ns 33426262 - -StdFunction_call::returnNonVoid 21.1 ns 21.1 ns 33175655 -StdFunction_callMethod::returnNonVoid 21.5 ns 21.5 ns 32364270 - -RtlFunction_call::returnNonVoid 20.9 ns 20.9 ns 33520163 -RtlFunction_callMethod::returnNonVoid 21.1 ns 21.1 ns 33143282 - -RtlFunction_call_ReturnUnknown::NonVoid 31.0 ns 31.0 ns 22528741 -RtlFunction_callMethod_ReturnUnknown::NonVoid 30.3 ns 30.3 ns 23194476 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 32.1 ns 32.1 ns 21788728 ------------------------------------ -[2025-10-09 22:19:31] >>> Run 2: workload scale = 1 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 1 iterations -============================================= - -2025-10-09T22:19:31+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.97, 0.88, 0.96 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 14.9 ns 14.9 ns 45364596 - -NativeFunctionPtr_call::returnVoid 15.2 ns 15.2 ns 45419462 -NativeFunctionPtr_callMethod::returnVoid 14.9 ns 14.9 ns 47051088 - -StdFunction_call::returnVoid 15.2 ns 15.2 ns 46669479 -StdFunction_callMethod::returnVoid 15.4 ns 15.4 ns 46292177 - -RtlFunction_call::returnVoid 14.9 ns 14.9 ns 45293244 -RtlFunction_callMethod::returnVoid 15.2 ns 15.2 ns 45851894 - -RtlFunction_call_ReturnUnknown::Void 17.4 ns 17.4 ns 40152888 -RtlFunction_callMethod_ReturnUnknown::Void 16.7 ns 16.7 ns 41324147 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 18.6 ns 18.6 ns 37723786 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 20.5 ns 20.5 ns 33954277 - -NativeFunctionPtr_call::returnNonVoid 20.5 ns 20.5 ns 34120413 -NativeFunctionPtr_callMethod::returnNonVoid 20.7 ns 20.7 ns 33907841 - -StdFunction_call::returnNonVoid 20.7 ns 20.7 ns 33879555 -StdFunction_callMethod::returnNonVoid 21.3 ns 21.3 ns 33117134 - -RtlFunction_call::returnNonVoid 20.5 ns 20.5 ns 34127782 -RtlFunction_callMethod::returnNonVoid 20.8 ns 20.7 ns 33948897 - -RtlFunction_call_ReturnUnknown::NonVoid 30.7 ns 30.7 ns 22524742 -RtlFunction_callMethod_ReturnUnknown::NonVoid 30.2 ns 30.2 ns 23134209 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 32.0 ns 32.0 ns 21910277 ------------------------------------ -[2025-10-09 22:19:50] >>> Run 3: workload scale = 1 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 1 iterations -============================================= - -2025-10-09T22:19:50+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800.538 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.98, 0.89, 0.96 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 14.9 ns 14.9 ns 46873996 - -NativeFunctionPtr_call::returnVoid 15.1 ns 15.1 ns 44823182 -NativeFunctionPtr_callMethod::returnVoid 15.1 ns 15.1 ns 45050872 - -StdFunction_call::returnVoid 15.0 ns 15.0 ns 44965311 -StdFunction_callMethod::returnVoid 15.3 ns 15.3 ns 44736020 - -RtlFunction_call::returnVoid 15.2 ns 15.2 ns 44511657 -RtlFunction_callMethod::returnVoid 15.2 ns 15.2 ns 44209779 - -RtlFunction_call_ReturnUnknown::Void 17.4 ns 17.4 ns 39971998 -RtlFunction_callMethod_ReturnUnknown::Void 16.9 ns 16.9 ns 41038287 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 18.4 ns 18.4 ns 37834095 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 20.4 ns 20.4 ns 34202626 - -NativeFunctionPtr_call::returnNonVoid 20.5 ns 20.5 ns 33922978 -NativeFunctionPtr_callMethod::returnNonVoid 20.6 ns 20.6 ns 33861275 - -StdFunction_call::returnNonVoid 20.7 ns 20.6 ns 33733127 -StdFunction_callMethod::returnNonVoid 21.2 ns 21.2 ns 32740293 - -RtlFunction_call::returnNonVoid 20.5 ns 20.5 ns 34084806 -RtlFunction_callMethod::returnNonVoid 20.7 ns 20.7 ns 33685938 - -RtlFunction_call_ReturnUnknown::NonVoid 31.0 ns 31.0 ns 22831560 -RtlFunction_callMethod_ReturnUnknown::NonVoid 30.1 ns 30.1 ns 23205483 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 31.8 ns 31.8 ns 21996772 ------------------------------------ -[2025-10-09 22:20:08] >>> Run 4: workload scale = 1 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 1 iterations -============================================= - -2025-10-09T22:20:08+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.98, 0.90, 0.97 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 15.2 ns 15.2 ns 45936420 - -NativeFunctionPtr_call::returnVoid 15.5 ns 15.5 ns 46014580 -NativeFunctionPtr_callMethod::returnVoid 15.2 ns 15.2 ns 46535315 - -StdFunction_call::returnVoid 15.7 ns 15.7 ns 43251339 -StdFunction_callMethod::returnVoid 15.5 ns 15.5 ns 45041025 - -RtlFunction_call::returnVoid 15.0 ns 15.0 ns 45953264 -RtlFunction_callMethod::returnVoid 15.3 ns 15.3 ns 45516230 - -RtlFunction_call_ReturnUnknown::Void 18.2 ns 18.1 ns 38688796 -RtlFunction_callMethod_ReturnUnknown::Void 17.3 ns 17.3 ns 40375966 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 19.0 ns 19.0 ns 36862004 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 20.7 ns 20.7 ns 33888048 - -NativeFunctionPtr_call::returnNonVoid 20.6 ns 20.6 ns 33781492 -NativeFunctionPtr_callMethod::returnNonVoid 20.9 ns 20.9 ns 33739016 - -StdFunction_call::returnNonVoid 20.9 ns 20.9 ns 33638683 -StdFunction_callMethod::returnNonVoid 21.4 ns 21.4 ns 32675071 - -RtlFunction_call::returnNonVoid 20.6 ns 20.6 ns 33859486 -RtlFunction_callMethod::returnNonVoid 20.8 ns 20.8 ns 33657521 - -RtlFunction_call_ReturnUnknown::NonVoid 31.1 ns 31.1 ns 22420373 -RtlFunction_callMethod_ReturnUnknown::NonVoid 30.4 ns 30.4 ns 23120348 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 31.9 ns 31.9 ns 21854003 ------------------------------------ -[2025-10-09 22:20:27] >>> Run 5: workload scale = 1 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 1 iterations -============================================= - -2025-10-09T22:20:27+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.99, 0.91, 0.97 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 15.0 ns 15.0 ns 47279898 - -NativeFunctionPtr_call::returnVoid 15.3 ns 15.3 ns 45516981 -NativeFunctionPtr_callMethod::returnVoid 14.7 ns 14.7 ns 46513819 - -StdFunction_call::returnVoid 15.3 ns 15.3 ns 43850329 -StdFunction_callMethod::returnVoid 15.3 ns 15.3 ns 45168901 - -RtlFunction_call::returnVoid 15.1 ns 15.1 ns 46343637 -RtlFunction_callMethod::returnVoid 15.2 ns 15.2 ns 45176454 - -RtlFunction_call_ReturnUnknown::Void 16.9 ns 16.9 ns 40920690 -RtlFunction_callMethod_ReturnUnknown::Void 16.5 ns 16.5 ns 41926933 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 17.6 ns 17.6 ns 39234606 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 17.8 ns 17.8 ns 39112695 - -NativeFunctionPtr_call::returnNonVoid 17.4 ns 17.4 ns 40026410 -NativeFunctionPtr_callMethod::returnNonVoid 17.4 ns 17.4 ns 40676047 - -StdFunction_call::returnNonVoid 17.7 ns 17.7 ns 39540814 -StdFunction_callMethod::returnNonVoid 17.9 ns 17.9 ns 39049909 - -RtlFunction_call::returnNonVoid 17.5 ns 17.5 ns 40321431 -RtlFunction_callMethod::returnNonVoid 17.5 ns 17.5 ns 40188358 - -RtlFunction_call_ReturnUnknown::NonVoid 31.2 ns 31.2 ns 22400691 -RtlFunction_callMethod_ReturnUnknown::NonVoid 30.3 ns 30.3 ns 23233990 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 32.2 ns 32.2 ns 21865009 ------------------------------------ -[2025-10-09 22:20:45] >>> Run 1: workload scale = 5 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 5 iterations -============================================= - -2025-10-09T22:20:45+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.99, 0.91, 0.97 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 94.5 ns 94.5 ns 7418436 - -NativeFunctionPtr_call::returnVoid 95.1 ns 95.1 ns 7390751 -NativeFunctionPtr_callMethod::returnVoid 95.0 ns 95.0 ns 7346151 - -StdFunction_call::returnVoid 94.8 ns 94.8 ns 7370630 -StdFunction_callMethod::returnVoid 95.5 ns 95.5 ns 7345019 - -RtlFunction_call::returnVoid 94.7 ns 94.7 ns 7380097 -RtlFunction_callMethod::returnVoid 95.1 ns 95.1 ns 7341998 - -RtlFunction_call_ReturnUnknown::Void 97.3 ns 97.3 ns 7191391 -RtlFunction_callMethod_ReturnUnknown::Void 97.4 ns 97.4 ns 7181504 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 98.1 ns 98.1 ns 7142112 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 101 ns 101 ns 6891130 - -NativeFunctionPtr_call::returnNonVoid 102 ns 102 ns 6857124 -NativeFunctionPtr_callMethod::returnNonVoid 102 ns 102 ns 6822722 - -StdFunction_call::returnNonVoid 102 ns 102 ns 6809837 -StdFunction_callMethod::returnNonVoid 104 ns 104 ns 6735489 - -RtlFunction_call::returnNonVoid 102 ns 102 ns 6782573 -RtlFunction_callMethod::returnNonVoid 103 ns 103 ns 6813078 - -RtlFunction_call_ReturnUnknown::NonVoid 115 ns 115 ns 6059851 -RtlFunction_callMethod_ReturnUnknown::NonVoid 114 ns 114 ns 6160387 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 117 ns 117 ns 6008395 ------------------------------------ -[2025-10-09 22:21:01] >>> Run 2: workload scale = 5 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 5 iterations -============================================= - -2025-10-09T22:21:01+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.92, 0.97 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 97.0 ns 97.0 ns 7226382 - -NativeFunctionPtr_call::returnVoid 97.3 ns 97.3 ns 7197759 -NativeFunctionPtr_callMethod::returnVoid 97.1 ns 97.1 ns 7187773 - -StdFunction_call::returnVoid 97.2 ns 97.2 ns 7194186 -StdFunction_callMethod::returnVoid 97.5 ns 97.4 ns 7242579 - -RtlFunction_call::returnVoid 97.1 ns 97.0 ns 7223246 -RtlFunction_callMethod::returnVoid 97.6 ns 97.6 ns 7205800 - -RtlFunction_call_ReturnUnknown::Void 101 ns 101 ns 6977400 -RtlFunction_callMethod_ReturnUnknown::Void 99.8 ns 99.7 ns 7045819 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 101 ns 101 ns 6968577 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 115 ns 115 ns 6022471 - -NativeFunctionPtr_call::returnNonVoid 116 ns 116 ns 6055445 -NativeFunctionPtr_callMethod::returnNonVoid 117 ns 117 ns 5980019 - -StdFunction_call::returnNonVoid 116 ns 116 ns 6086357 -StdFunction_callMethod::returnNonVoid 117 ns 117 ns 6012413 - -RtlFunction_call::returnNonVoid 115 ns 115 ns 6051125 -RtlFunction_callMethod::returnNonVoid 116 ns 116 ns 6037378 - -RtlFunction_call_ReturnUnknown::NonVoid 122 ns 122 ns 5731702 -RtlFunction_callMethod_ReturnUnknown::NonVoid 122 ns 122 ns 5752072 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 122 ns 122 ns 5746437 ------------------------------------ -[2025-10-09 22:21:17] >>> Run 3: workload scale = 5 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 5 iterations -============================================= - -2025-10-09T22:21:17+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.92, 0.97 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 94.6 ns 94.6 ns 7392390 - -NativeFunctionPtr_call::returnVoid 95.2 ns 95.2 ns 7402546 -NativeFunctionPtr_callMethod::returnVoid 94.6 ns 94.5 ns 7392864 - -StdFunction_call::returnVoid 95.7 ns 95.7 ns 7014386 -StdFunction_callMethod::returnVoid 95.7 ns 95.7 ns 7236493 - -RtlFunction_call::returnVoid 94.8 ns 94.8 ns 7043913 -RtlFunction_callMethod::returnVoid 95.4 ns 95.4 ns 7406849 - -RtlFunction_call_ReturnUnknown::Void 97.2 ns 97.2 ns 7238799 -RtlFunction_callMethod_ReturnUnknown::Void 97.5 ns 97.5 ns 7273749 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 98.6 ns 98.6 ns 7118704 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 102 ns 102 ns 6900135 - -NativeFunctionPtr_call::returnNonVoid 102 ns 102 ns 6859439 -NativeFunctionPtr_callMethod::returnNonVoid 103 ns 103 ns 6769500 - -StdFunction_call::returnNonVoid 102 ns 102 ns 6885850 -StdFunction_callMethod::returnNonVoid 103 ns 103 ns 6797639 - -RtlFunction_call::returnNonVoid 102 ns 102 ns 6840686 -RtlFunction_callMethod::returnNonVoid 102 ns 102 ns 6839947 - -RtlFunction_call_ReturnUnknown::NonVoid 115 ns 115 ns 6111142 -RtlFunction_callMethod_ReturnUnknown::NonVoid 115 ns 115 ns 6134532 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 116 ns 116 ns 6031459 ------------------------------------ -[2025-10-09 22:21:34] >>> Run 4: workload scale = 5 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 5 iterations -============================================= - -2025-10-09T22:21:34+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.93, 0.97 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 94.2 ns 94.2 ns 7449867 - -NativeFunctionPtr_call::returnVoid 94.2 ns 94.2 ns 7395615 -NativeFunctionPtr_callMethod::returnVoid 94.1 ns 94.1 ns 7419278 - -StdFunction_call::returnVoid 94.7 ns 94.7 ns 7430858 -StdFunction_callMethod::returnVoid 94.5 ns 94.5 ns 7383366 - -RtlFunction_call::returnVoid 94.2 ns 94.2 ns 7446366 -RtlFunction_callMethod::returnVoid 94.8 ns 94.7 ns 7317785 - -RtlFunction_call_ReturnUnknown::Void 96.5 ns 96.5 ns 7199741 -RtlFunction_callMethod_ReturnUnknown::Void 97.0 ns 97.0 ns 7224357 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 97.6 ns 97.6 ns 7232105 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 102 ns 102 ns 6935311 - -NativeFunctionPtr_call::returnNonVoid 101 ns 101 ns 6876300 -NativeFunctionPtr_callMethod::returnNonVoid 102 ns 102 ns 6817570 - -StdFunction_call::returnNonVoid 101 ns 101 ns 6894995 -StdFunction_callMethod::returnNonVoid 102 ns 102 ns 6778790 - -RtlFunction_call::returnNonVoid 102 ns 102 ns 6788073 -RtlFunction_callMethod::returnNonVoid 102 ns 102 ns 6808113 - -RtlFunction_call_ReturnUnknown::NonVoid 114 ns 114 ns 6124217 -RtlFunction_callMethod_ReturnUnknown::NonVoid 114 ns 114 ns 6138453 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 115 ns 115 ns 6092982 ------------------------------------ -[2025-10-09 22:21:50] >>> Run 5: workload scale = 5 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 5 iterations -============================================= - -2025-10-09T22:21:50+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.93, 0.98 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 95.8 ns 95.8 ns 7289186 - -NativeFunctionPtr_call::returnVoid 96.2 ns 96.2 ns 7258317 -NativeFunctionPtr_callMethod::returnVoid 95.7 ns 95.7 ns 7161040 - -StdFunction_call::returnVoid 96.3 ns 96.3 ns 7229461 -StdFunction_callMethod::returnVoid 96.4 ns 96.4 ns 7222625 - -RtlFunction_call::returnVoid 96.1 ns 96.1 ns 7281092 -RtlFunction_callMethod::returnVoid 96.4 ns 96.4 ns 7292384 - -RtlFunction_call_ReturnUnknown::Void 98.9 ns 98.9 ns 7025539 -RtlFunction_callMethod_ReturnUnknown::Void 98.6 ns 98.6 ns 7003241 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 99.6 ns 99.6 ns 6962430 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 114 ns 114 ns 6159916 - -NativeFunctionPtr_call::returnNonVoid 114 ns 114 ns 6109376 -NativeFunctionPtr_callMethod::returnNonVoid 115 ns 115 ns 6111122 - -StdFunction_call::returnNonVoid 114 ns 114 ns 6186801 -StdFunction_callMethod::returnNonVoid 115 ns 114 ns 6135953 - -RtlFunction_call::returnNonVoid 114 ns 114 ns 6181904 -RtlFunction_callMethod::returnNonVoid 115 ns 115 ns 6085080 - -RtlFunction_call_ReturnUnknown::NonVoid 120 ns 120 ns 5848705 -RtlFunction_callMethod_ReturnUnknown::NonVoid 120 ns 120 ns 5853140 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 120 ns 120 ns 5823569 ------------------------------------ -[2025-10-09 22:22:06] >>> Run 1: workload scale = 10 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 10 iterations -============================================= - -2025-10-09T22:22:06+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.94, 0.98 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 163 ns 163 ns 4298789 - -NativeFunctionPtr_call::returnVoid 164 ns 164 ns 4263251 -NativeFunctionPtr_callMethod::returnVoid 163 ns 163 ns 4266147 - -StdFunction_call::returnVoid 164 ns 163 ns 4266550 -StdFunction_callMethod::returnVoid 164 ns 164 ns 4338164 - -RtlFunction_call::returnVoid 162 ns 162 ns 4317041 -RtlFunction_callMethod::returnVoid 164 ns 164 ns 4294553 - -RtlFunction_call_ReturnUnknown::Void 172 ns 172 ns 4090212 -RtlFunction_callMethod_ReturnUnknown::Void 169 ns 169 ns 4160670 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 170 ns 170 ns 4147575 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 186 ns 186 ns 3767569 - -NativeFunctionPtr_call::returnNonVoid 186 ns 186 ns 3773120 -NativeFunctionPtr_callMethod::returnNonVoid 187 ns 187 ns 3782427 - -StdFunction_call::returnNonVoid 185 ns 185 ns 3785312 -StdFunction_callMethod::returnNonVoid 185 ns 185 ns 3760167 - -RtlFunction_call::returnNonVoid 187 ns 187 ns 3753484 -RtlFunction_callMethod::returnNonVoid 187 ns 187 ns 3712101 - -RtlFunction_call_ReturnUnknown::NonVoid 198 ns 198 ns 3548465 -RtlFunction_callMethod_ReturnUnknown::NonVoid 199 ns 199 ns 3560529 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 200 ns 200 ns 3499395 ------------------------------------ -[2025-10-09 22:22:24] >>> Run 2: workload scale = 10 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 10 iterations -============================================= - -2025-10-09T22:22:24+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.94, 0.98 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 161 ns 161 ns 4352473 - -NativeFunctionPtr_call::returnVoid 162 ns 162 ns 4341961 -NativeFunctionPtr_callMethod::returnVoid 162 ns 162 ns 4336860 - -StdFunction_call::returnVoid 162 ns 162 ns 4334729 -StdFunction_callMethod::returnVoid 162 ns 162 ns 4311518 - -RtlFunction_call::returnVoid 161 ns 161 ns 4438099 -RtlFunction_callMethod::returnVoid 162 ns 162 ns 4285776 - -RtlFunction_call_ReturnUnknown::Void 163 ns 163 ns 4279712 -RtlFunction_callMethod_ReturnUnknown::Void 165 ns 165 ns 4325532 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 165 ns 165 ns 4217999 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 183 ns 183 ns 3873571 - -NativeFunctionPtr_call::returnNonVoid 185 ns 185 ns 3800985 -NativeFunctionPtr_callMethod::returnNonVoid 185 ns 185 ns 3798297 - -StdFunction_call::returnNonVoid 184 ns 184 ns 3769904 -StdFunction_callMethod::returnNonVoid 184 ns 184 ns 3760250 - -RtlFunction_call::returnNonVoid 185 ns 185 ns 3777362 -RtlFunction_callMethod::returnNonVoid 185 ns 185 ns 3758805 - -RtlFunction_call_ReturnUnknown::NonVoid 193 ns 193 ns 3616444 -RtlFunction_callMethod_ReturnUnknown::NonVoid 193 ns 193 ns 3650560 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 194 ns 194 ns 3603472 ------------------------------------ -[2025-10-09 22:22:42] >>> Run 3: workload scale = 10 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 10 iterations -============================================= - -2025-10-09T22:22:42+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.95, 0.98 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 163 ns 163 ns 4313760 - -NativeFunctionPtr_call::returnVoid 169 ns 169 ns 4323834 -NativeFunctionPtr_callMethod::returnVoid 173 ns 173 ns 4056268 - -StdFunction_call::returnVoid 174 ns 174 ns 3992048 -StdFunction_callMethod::returnVoid 175 ns 175 ns 3985300 - -RtlFunction_call::returnVoid 174 ns 174 ns 4034475 -RtlFunction_callMethod::returnVoid 176 ns 176 ns 4013620 - -RtlFunction_call_ReturnUnknown::Void 178 ns 178 ns 3938442 -RtlFunction_callMethod_ReturnUnknown::Void 177 ns 177 ns 3958103 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 180 ns 180 ns 3886562 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 205 ns 205 ns 3436696 - -NativeFunctionPtr_call::returnNonVoid 205 ns 205 ns 3415528 -NativeFunctionPtr_callMethod::returnNonVoid 206 ns 206 ns 3402008 - -StdFunction_call::returnNonVoid 205 ns 205 ns 3420366 -StdFunction_callMethod::returnNonVoid 206 ns 206 ns 3422671 - -RtlFunction_call::returnNonVoid 205 ns 205 ns 3419467 -RtlFunction_callMethod::returnNonVoid 205 ns 205 ns 3409997 - -RtlFunction_call_ReturnUnknown::NonVoid 212 ns 212 ns 3317595 -RtlFunction_callMethod_ReturnUnknown::NonVoid 213 ns 213 ns 3310747 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 213 ns 213 ns 3293147 ------------------------------------ -[2025-10-09 22:23:00] >>> Run 4: workload scale = 10 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 10 iterations -============================================= - -2025-10-09T22:23:00+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.95, 0.98 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 160 ns 160 ns 4338148 - -NativeFunctionPtr_call::returnVoid 160 ns 160 ns 4383707 -NativeFunctionPtr_callMethod::returnVoid 160 ns 160 ns 4352305 - -StdFunction_call::returnVoid 160 ns 160 ns 4381519 -StdFunction_callMethod::returnVoid 161 ns 161 ns 4336371 - -RtlFunction_call::returnVoid 162 ns 162 ns 4389675 -RtlFunction_callMethod::returnVoid 163 ns 163 ns 4327396 - -RtlFunction_call_ReturnUnknown::Void 164 ns 164 ns 4284776 -RtlFunction_callMethod_ReturnUnknown::Void 163 ns 163 ns 4265542 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 165 ns 165 ns 4258095 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 184 ns 184 ns 3777902 - -NativeFunctionPtr_call::returnNonVoid 186 ns 186 ns 3757189 -NativeFunctionPtr_callMethod::returnNonVoid 187 ns 187 ns 3805745 - -StdFunction_call::returnNonVoid 185 ns 185 ns 3792834 -StdFunction_callMethod::returnNonVoid 185 ns 185 ns 3800689 - -RtlFunction_call::returnNonVoid 185 ns 185 ns 3768244 -RtlFunction_callMethod::returnNonVoid 185 ns 185 ns 3814454 - -RtlFunction_call_ReturnUnknown::NonVoid 193 ns 193 ns 3603154 -RtlFunction_callMethod_ReturnUnknown::NonVoid 192 ns 192 ns 3654448 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 193 ns 193 ns 3610658 ------------------------------------ -[2025-10-09 22:23:18] >>> Run 5: workload scale = 10 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 10 iterations -============================================= - -2025-10-09T22:23:18+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4894.5 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.95, 0.98 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 161 ns 161 ns 4380340 - -NativeFunctionPtr_call::returnVoid 161 ns 161 ns 4326537 -NativeFunctionPtr_callMethod::returnVoid 160 ns 160 ns 4360434 - -StdFunction_call::returnVoid 161 ns 161 ns 4372515 -StdFunction_callMethod::returnVoid 162 ns 162 ns 4311332 - -RtlFunction_call::returnVoid 162 ns 162 ns 4336826 -RtlFunction_callMethod::returnVoid 163 ns 163 ns 4326481 - -RtlFunction_call_ReturnUnknown::Void 164 ns 164 ns 4265133 -RtlFunction_callMethod_ReturnUnknown::Void 163 ns 163 ns 4288142 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 165 ns 165 ns 4234347 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 185 ns 185 ns 3782088 - -NativeFunctionPtr_call::returnNonVoid 184 ns 184 ns 3818566 -NativeFunctionPtr_callMethod::returnNonVoid 185 ns 185 ns 3801545 - -StdFunction_call::returnNonVoid 183 ns 183 ns 3814381 -StdFunction_callMethod::returnNonVoid 183 ns 183 ns 3859080 - -RtlFunction_call::returnNonVoid 184 ns 184 ns 3775139 -RtlFunction_callMethod::returnNonVoid 184 ns 184 ns 3824835 - -RtlFunction_call_ReturnUnknown::NonVoid 193 ns 193 ns 3623645 -RtlFunction_callMethod_ReturnUnknown::NonVoid 193 ns 193 ns 3640925 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 193 ns 193 ns 3616590 ------------------------------------ -[2025-10-09 22:23:36] >>> Run 1: workload scale = 15 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 15 iterations -============================================= - -2025-10-09T22:23:36+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.96, 0.99 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 215 ns 215 ns 3263479 - -NativeFunctionPtr_call::returnVoid 214 ns 214 ns 3257184 -NativeFunctionPtr_callMethod::returnVoid 215 ns 215 ns 3264358 - -StdFunction_call::returnVoid 215 ns 215 ns 3266358 -StdFunction_callMethod::returnVoid 214 ns 214 ns 3275751 - -RtlFunction_call::returnVoid 215 ns 215 ns 3263733 -RtlFunction_callMethod::returnVoid 214 ns 214 ns 3280003 - -RtlFunction_call_ReturnUnknown::Void 214 ns 214 ns 3266284 -RtlFunction_callMethod_ReturnUnknown::Void 216 ns 216 ns 3227711 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 216 ns 215 ns 3264294 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 252 ns 252 ns 2775280 - -NativeFunctionPtr_call::returnNonVoid 250 ns 250 ns 2769552 -NativeFunctionPtr_callMethod::returnNonVoid 251 ns 251 ns 2763279 - -StdFunction_call::returnNonVoid 251 ns 251 ns 2820619 -StdFunction_callMethod::returnNonVoid 253 ns 253 ns 2766906 - -RtlFunction_call::returnNonVoid 251 ns 251 ns 2779699 -RtlFunction_callMethod::returnNonVoid 251 ns 251 ns 2801031 - -RtlFunction_call_ReturnUnknown::NonVoid 259 ns 259 ns 2700620 -RtlFunction_callMethod_ReturnUnknown::NonVoid 257 ns 257 ns 2712626 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 261 ns 261 ns 2685860 ------------------------------------ -[2025-10-09 22:23:55] >>> Run 2: workload scale = 15 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 15 iterations -============================================= - -2025-10-09T22:23:55+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.96, 0.99 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 210 ns 210 ns 3328631 - -NativeFunctionPtr_call::returnVoid 209 ns 209 ns 3337881 -NativeFunctionPtr_callMethod::returnVoid 210 ns 210 ns 3358665 - -StdFunction_call::returnVoid 209 ns 209 ns 3334221 -StdFunction_callMethod::returnVoid 208 ns 208 ns 3358880 - -RtlFunction_call::returnVoid 209 ns 209 ns 3332189 -RtlFunction_callMethod::returnVoid 210 ns 210 ns 3341235 - -RtlFunction_call_ReturnUnknown::Void 211 ns 211 ns 3318858 -RtlFunction_callMethod_ReturnUnknown::Void 210 ns 210 ns 3315392 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 210 ns 210 ns 3345894 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 248 ns 248 ns 2811463 - -NativeFunctionPtr_call::returnNonVoid 248 ns 248 ns 2837510 -NativeFunctionPtr_callMethod::returnNonVoid 248 ns 248 ns 2823747 - -StdFunction_call::returnNonVoid 248 ns 248 ns 2829500 -StdFunction_callMethod::returnNonVoid 246 ns 246 ns 2846223 - -RtlFunction_call::returnNonVoid 249 ns 249 ns 2825214 -RtlFunction_callMethod::returnNonVoid 249 ns 249 ns 2838485 - -RtlFunction_call_ReturnUnknown::NonVoid 256 ns 256 ns 2743765 -RtlFunction_callMethod_ReturnUnknown::NonVoid 254 ns 254 ns 2754043 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 256 ns 256 ns 2746382 ------------------------------------ -[2025-10-09 22:24:14] >>> Run 3: workload scale = 15 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 15 iterations -============================================= - -2025-10-09T22:24:14+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800.265 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.96, 0.99 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 207 ns 207 ns 3378932 - -NativeFunctionPtr_call::returnVoid 208 ns 208 ns 3354717 -NativeFunctionPtr_callMethod::returnVoid 208 ns 208 ns 3358316 - -StdFunction_call::returnVoid 208 ns 208 ns 3370362 -StdFunction_callMethod::returnVoid 208 ns 208 ns 3366749 - -RtlFunction_call::returnVoid 208 ns 208 ns 3392121 -RtlFunction_callMethod::returnVoid 209 ns 208 ns 3363052 - -RtlFunction_call_ReturnUnknown::Void 210 ns 210 ns 3340887 -RtlFunction_callMethod_ReturnUnknown::Void 209 ns 209 ns 3359366 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 210 ns 210 ns 3324467 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 246 ns 245 ns 2863116 - -NativeFunctionPtr_call::returnNonVoid 247 ns 247 ns 2854025 -NativeFunctionPtr_callMethod::returnNonVoid 245 ns 245 ns 2838441 - -StdFunction_call::returnNonVoid 225 ns 225 ns 3205357 -StdFunction_callMethod::returnNonVoid 246 ns 246 ns 2873877 - -RtlFunction_call::returnNonVoid 245 ns 245 ns 2834809 -RtlFunction_callMethod::returnNonVoid 246 ns 246 ns 2865471 - -RtlFunction_call_ReturnUnknown::NonVoid 254 ns 254 ns 2764367 -RtlFunction_callMethod_ReturnUnknown::NonVoid 253 ns 253 ns 2758970 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 254 ns 254 ns 2738846 ------------------------------------ -[2025-10-09 22:24:34] >>> Run 4: workload scale = 15 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 15 iterations -============================================= - -2025-10-09T22:24:34+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4878.67 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.97, 0.99 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 189 ns 189 ns 3726055 - -NativeFunctionPtr_call::returnVoid 189 ns 189 ns 3727086 -NativeFunctionPtr_callMethod::returnVoid 188 ns 188 ns 3698951 - -StdFunction_call::returnVoid 188 ns 188 ns 3742233 -StdFunction_callMethod::returnVoid 190 ns 190 ns 3687148 - -RtlFunction_call::returnVoid 188 ns 188 ns 3712470 -RtlFunction_callMethod::returnVoid 189 ns 189 ns 3703809 - -RtlFunction_call_ReturnUnknown::Void 192 ns 192 ns 3651160 -RtlFunction_callMethod_ReturnUnknown::Void 191 ns 191 ns 3649884 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 191 ns 191 ns 3616240 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 219 ns 219 ns 3185509 - -NativeFunctionPtr_call::returnNonVoid 221 ns 221 ns 3198363 -NativeFunctionPtr_callMethod::returnNonVoid 222 ns 222 ns 3120890 - -StdFunction_call::returnNonVoid 218 ns 218 ns 3203607 -StdFunction_callMethod::returnNonVoid 223 ns 223 ns 3140770 - -RtlFunction_call::returnNonVoid 217 ns 217 ns 3176653 -RtlFunction_callMethod::returnNonVoid 220 ns 220 ns 3169054 - -RtlFunction_call_ReturnUnknown::NonVoid 226 ns 226 ns 3107784 -RtlFunction_callMethod_ReturnUnknown::NonVoid 226 ns 226 ns 3107618 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 233 ns 233 ns 2982875 ------------------------------------ -[2025-10-09 22:24:52] >>> Run 5: workload scale = 15 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 15 iterations -============================================= - -2025-10-09T22:24:52+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.97, 0.99 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 187 ns 187 ns 3765076 - -NativeFunctionPtr_call::returnVoid 188 ns 188 ns 3749209 -NativeFunctionPtr_callMethod::returnVoid 187 ns 187 ns 3738778 - -StdFunction_call::returnVoid 187 ns 187 ns 3736466 -StdFunction_callMethod::returnVoid 187 ns 187 ns 3734846 - -RtlFunction_call::returnVoid 187 ns 187 ns 3743346 -RtlFunction_callMethod::returnVoid 188 ns 188 ns 3740283 - -RtlFunction_call_ReturnUnknown::Void 191 ns 191 ns 3682864 -RtlFunction_callMethod_ReturnUnknown::Void 189 ns 189 ns 3704235 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 190 ns 190 ns 3669759 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 215 ns 215 ns 3257739 - -NativeFunctionPtr_call::returnNonVoid 216 ns 216 ns 3252243 -NativeFunctionPtr_callMethod::returnNonVoid 217 ns 217 ns 3255339 - -StdFunction_call::returnNonVoid 217 ns 217 ns 3245694 -StdFunction_callMethod::returnNonVoid 216 ns 216 ns 3243823 - -RtlFunction_call::returnNonVoid 215 ns 215 ns 3248934 -RtlFunction_callMethod::returnNonVoid 217 ns 217 ns 3244121 - -RtlFunction_call_ReturnUnknown::NonVoid 224 ns 224 ns 3119429 -RtlFunction_callMethod_ReturnUnknown::NonVoid 224 ns 224 ns 3089270 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 224 ns 224 ns 3120259 ------------------------------------ -[2025-10-09 22:25:11] >>> Run 1: workload scale = 20 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 20 iterations -============================================= - -2025-10-09T22:25:11+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.97, 0.99 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 273 ns 273 ns 2520910 - -NativeFunctionPtr_call::returnVoid 282 ns 282 ns 2569459 -NativeFunctionPtr_callMethod::returnVoid 304 ns 304 ns 2305232 - -StdFunction_call::returnVoid 305 ns 305 ns 2290417 -StdFunction_callMethod::returnVoid 302 ns 302 ns 2325541 - -RtlFunction_call::returnVoid 306 ns 306 ns 2300150 -RtlFunction_callMethod::returnVoid 304 ns 304 ns 2297397 - -RtlFunction_call_ReturnUnknown::Void 306 ns 306 ns 2296714 -RtlFunction_callMethod_ReturnUnknown::Void 303 ns 303 ns 2299905 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 308 ns 308 ns 2275076 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 362 ns 362 ns 1926616 - -NativeFunctionPtr_call::returnNonVoid 365 ns 364 ns 1919201 -NativeFunctionPtr_callMethod::returnNonVoid 365 ns 365 ns 1922395 - -StdFunction_call::returnNonVoid 365 ns 365 ns 1914669 -StdFunction_callMethod::returnNonVoid 358 ns 358 ns 1951810 - -RtlFunction_call::returnNonVoid 364 ns 364 ns 1914637 -RtlFunction_callMethod::returnNonVoid 364 ns 364 ns 1911739 - -RtlFunction_call_ReturnUnknown::NonVoid 367 ns 367 ns 1909904 -RtlFunction_callMethod_ReturnUnknown::NonVoid 365 ns 365 ns 1909608 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 372 ns 372 ns 1883925 ------------------------------------ -[2025-10-09 22:25:32] >>> Run 2: workload scale = 20 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 20 iterations -============================================= - -2025-10-09T22:25:32+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4885.33 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.97, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 271 ns 271 ns 2569273 - -NativeFunctionPtr_call::returnVoid 279 ns 279 ns 2508346 -NativeFunctionPtr_callMethod::returnVoid 279 ns 279 ns 2495543 - -StdFunction_call::returnVoid 282 ns 282 ns 2512583 -StdFunction_callMethod::returnVoid 282 ns 282 ns 2497604 - -RtlFunction_call::returnVoid 280 ns 280 ns 2474996 -RtlFunction_callMethod::returnVoid 281 ns 281 ns 2501878 - -RtlFunction_call_ReturnUnknown::Void 277 ns 277 ns 2527419 -RtlFunction_callMethod_ReturnUnknown::Void 278 ns 278 ns 2513950 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 277 ns 276 ns 2557708 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 316 ns 316 ns 2227704 - -NativeFunctionPtr_call::returnNonVoid 331 ns 331 ns 2117397 -NativeFunctionPtr_callMethod::returnNonVoid 331 ns 331 ns 2122544 - -StdFunction_call::returnNonVoid 329 ns 329 ns 2115896 -StdFunction_callMethod::returnNonVoid 329 ns 329 ns 2138305 - -RtlFunction_call::returnNonVoid 330 ns 330 ns 2112556 -RtlFunction_callMethod::returnNonVoid 330 ns 330 ns 2130792 - -RtlFunction_call_ReturnUnknown::NonVoid 322 ns 322 ns 2187407 -RtlFunction_callMethod_ReturnUnknown::NonVoid 321 ns 321 ns 2176270 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 320 ns 320 ns 2157920 ------------------------------------ -[2025-10-09 22:25:53] >>> Run 3: workload scale = 20 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 20 iterations -============================================= - -2025-10-09T22:25:53+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4853.88 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.98, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 303 ns 303 ns 2303932 - -NativeFunctionPtr_call::returnVoid 305 ns 305 ns 2311103 -NativeFunctionPtr_callMethod::returnVoid 304 ns 304 ns 2311627 - -StdFunction_call::returnVoid 303 ns 303 ns 2304338 -StdFunction_callMethod::returnVoid 304 ns 304 ns 2302618 - -RtlFunction_call::returnVoid 303 ns 303 ns 2280795 -RtlFunction_callMethod::returnVoid 304 ns 303 ns 2299138 - -RtlFunction_call_ReturnUnknown::Void 318 ns 318 ns 2199731 -RtlFunction_callMethod_ReturnUnknown::Void 313 ns 313 ns 2238511 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 318 ns 318 ns 2207818 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 361 ns 361 ns 1925454 - -NativeFunctionPtr_call::returnNonVoid 364 ns 364 ns 1914876 -NativeFunctionPtr_callMethod::returnNonVoid 364 ns 364 ns 1918846 - -StdFunction_call::returnNonVoid 364 ns 364 ns 1911425 -StdFunction_callMethod::returnNonVoid 364 ns 364 ns 1923711 - -RtlFunction_call::returnNonVoid 363 ns 363 ns 1926305 -RtlFunction_callMethod::returnNonVoid 364 ns 364 ns 1918944 - -RtlFunction_call_ReturnUnknown::NonVoid 371 ns 371 ns 1889184 -RtlFunction_callMethod_ReturnUnknown::NonVoid 374 ns 374 ns 1883084 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 371 ns 371 ns 1879894 ------------------------------------ -[2025-10-09 22:26:14] >>> Run 4: workload scale = 20 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 20 iterations -============================================= - -2025-10-09T22:26:14+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.98, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 272 ns 272 ns 2540691 - -NativeFunctionPtr_call::returnVoid 274 ns 274 ns 2593245 -NativeFunctionPtr_callMethod::returnVoid 275 ns 275 ns 2556586 - -StdFunction_call::returnVoid 274 ns 274 ns 2558445 -StdFunction_callMethod::returnVoid 274 ns 274 ns 2543576 - -RtlFunction_call::returnVoid 275 ns 275 ns 2539357 -RtlFunction_callMethod::returnVoid 275 ns 275 ns 2561621 - -RtlFunction_call_ReturnUnknown::Void 281 ns 281 ns 2506532 -RtlFunction_callMethod_ReturnUnknown::Void 275 ns 275 ns 2503188 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 276 ns 276 ns 2546862 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 315 ns 315 ns 2203523 - -NativeFunctionPtr_call::returnNonVoid 317 ns 317 ns 2202686 -NativeFunctionPtr_callMethod::returnNonVoid 320 ns 320 ns 2189183 - -StdFunction_call::returnNonVoid 319 ns 319 ns 2209198 -StdFunction_callMethod::returnNonVoid 319 ns 319 ns 2219351 - -RtlFunction_call::returnNonVoid 317 ns 317 ns 2199084 -RtlFunction_callMethod::returnNonVoid 319 ns 319 ns 2214805 - -RtlFunction_call_ReturnUnknown::NonVoid 320 ns 320 ns 2177273 -RtlFunction_callMethod_ReturnUnknown::NonVoid 323 ns 323 ns 2161121 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 324 ns 324 ns 2142259 ------------------------------------ -[2025-10-09 22:26:35] >>> Run 5: workload scale = 20 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 20 iterations -============================================= - -2025-10-09T22:26:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.98, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 269 ns 269 ns 2614274 - -NativeFunctionPtr_call::returnVoid 268 ns 268 ns 2604691 -NativeFunctionPtr_callMethod::returnVoid 269 ns 269 ns 2587066 - -StdFunction_call::returnVoid 269 ns 269 ns 2606229 -StdFunction_callMethod::returnVoid 270 ns 270 ns 2614556 - -RtlFunction_call::returnVoid 269 ns 269 ns 2617864 -RtlFunction_callMethod::returnVoid 269 ns 269 ns 2586264 - -RtlFunction_call_ReturnUnknown::Void 277 ns 277 ns 2535614 -RtlFunction_callMethod_ReturnUnknown::Void 276 ns 276 ns 2567940 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 284 ns 284 ns 2485045 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 314 ns 314 ns 2231644 - -NativeFunctionPtr_call::returnNonVoid 315 ns 315 ns 2226538 -NativeFunctionPtr_callMethod::returnNonVoid 315 ns 315 ns 2227936 - -StdFunction_call::returnNonVoid 313 ns 313 ns 2237189 -StdFunction_callMethod::returnNonVoid 316 ns 316 ns 2224588 - -RtlFunction_call::returnNonVoid 315 ns 315 ns 2223037 -RtlFunction_callMethod::returnNonVoid 314 ns 314 ns 2213917 - -RtlFunction_call_ReturnUnknown::NonVoid 339 ns 339 ns 2061326 -RtlFunction_callMethod_ReturnUnknown::NonVoid 324 ns 324 ns 2180645 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 339 ns 339 ns 2061094 ------------------------------------ -[2025-10-09 22:26:55] >>> Run 1: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-10-09T22:26:55+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 0.98, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 300 ns 300 ns 2338117 - -NativeFunctionPtr_call::returnVoid 298 ns 298 ns 2355296 -NativeFunctionPtr_callMethod::returnVoid 298 ns 298 ns 2320772 - -StdFunction_call::returnVoid 297 ns 297 ns 2362909 -StdFunction_callMethod::returnVoid 299 ns 299 ns 2355840 - -RtlFunction_call::returnVoid 297 ns 297 ns 2338452 -RtlFunction_callMethod::returnVoid 298 ns 298 ns 2343060 - -RtlFunction_call_ReturnUnknown::Void 306 ns 306 ns 2271939 -RtlFunction_callMethod_ReturnUnknown::Void 304 ns 304 ns 2318101 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 306 ns 306 ns 2305028 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 362 ns 362 ns 1947425 - -NativeFunctionPtr_call::returnNonVoid 361 ns 360 ns 1928345 -NativeFunctionPtr_callMethod::returnNonVoid 363 ns 363 ns 1913332 - -StdFunction_call::returnNonVoid 362 ns 362 ns 1944195 -StdFunction_callMethod::returnNonVoid 364 ns 364 ns 1935312 - -RtlFunction_call::returnNonVoid 363 ns 363 ns 1936550 -RtlFunction_callMethod::returnNonVoid 363 ns 363 ns 1924690 - -RtlFunction_call_ReturnUnknown::NonVoid 372 ns 372 ns 1863292 -RtlFunction_callMethod_ReturnUnknown::NonVoid 373 ns 373 ns 1854535 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 374 ns 373 ns 1862070 ------------------------------------ -[2025-10-09 22:27:17] >>> Run 2: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-10-09T22:27:17+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.19, 1.03, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 343 ns 343 ns 2061132 - -NativeFunctionPtr_call::returnVoid 337 ns 336 ns 2068643 -NativeFunctionPtr_callMethod::returnVoid 337 ns 337 ns 2052308 - -StdFunction_call::returnVoid 337 ns 337 ns 2083873 -StdFunction_callMethod::returnVoid 334 ns 334 ns 2106632 - -RtlFunction_call::returnVoid 300 ns 300 ns 2208447 -RtlFunction_callMethod::returnVoid 299 ns 299 ns 2329548 - -RtlFunction_call_ReturnUnknown::Void 305 ns 305 ns 2274547 -RtlFunction_callMethod_ReturnUnknown::Void 302 ns 302 ns 2306504 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 305 ns 305 ns 2297009 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 366 ns 366 ns 1912241 - -NativeFunctionPtr_call::returnNonVoid 364 ns 364 ns 1916331 -NativeFunctionPtr_callMethod::returnNonVoid 367 ns 367 ns 1913166 - -StdFunction_call::returnNonVoid 366 ns 366 ns 1922189 -StdFunction_callMethod::returnNonVoid 362 ns 362 ns 1933790 - -RtlFunction_call::returnNonVoid 366 ns 366 ns 1924279 -RtlFunction_callMethod::returnNonVoid 365 ns 365 ns 1924374 - -RtlFunction_call_ReturnUnknown::NonVoid 373 ns 373 ns 1882074 -RtlFunction_callMethod_ReturnUnknown::NonVoid 373 ns 373 ns 1883708 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 375 ns 375 ns 1872075 ------------------------------------ -[2025-10-09 22:27:39] >>> Run 3: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-10-09T22:27:39+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.13, 1.03, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 298 ns 298 ns 2324259 - -NativeFunctionPtr_call::returnVoid 302 ns 302 ns 2318675 -NativeFunctionPtr_callMethod::returnVoid 299 ns 299 ns 2346754 - -StdFunction_call::returnVoid 299 ns 299 ns 2336837 -StdFunction_callMethod::returnVoid 300 ns 300 ns 2347785 - -RtlFunction_call::returnVoid 301 ns 301 ns 2346448 -RtlFunction_callMethod::returnVoid 300 ns 300 ns 2342174 - -RtlFunction_call_ReturnUnknown::Void 310 ns 310 ns 2256901 -RtlFunction_callMethod_ReturnUnknown::Void 312 ns 312 ns 2277142 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 311 ns 311 ns 2222204 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 361 ns 361 ns 1917143 - -NativeFunctionPtr_call::returnNonVoid 364 ns 364 ns 1907259 -NativeFunctionPtr_callMethod::returnNonVoid 365 ns 365 ns 1912708 - -StdFunction_call::returnNonVoid 366 ns 366 ns 1937138 -StdFunction_callMethod::returnNonVoid 367 ns 367 ns 1919569 - -RtlFunction_call::returnNonVoid 369 ns 369 ns 1874180 -RtlFunction_callMethod::returnNonVoid 362 ns 362 ns 1915226 - -RtlFunction_call_ReturnUnknown::NonVoid 372 ns 372 ns 1891945 -RtlFunction_callMethod_ReturnUnknown::NonVoid 373 ns 373 ns 1876384 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 372 ns 372 ns 1887359 ------------------------------------ -[2025-10-09 22:28:00] >>> Run 4: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-10-09T22:28:00+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.09, 1.03, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 296 ns 296 ns 2350217 - -NativeFunctionPtr_call::returnVoid 296 ns 296 ns 2340079 -NativeFunctionPtr_callMethod::returnVoid 296 ns 296 ns 2357817 - -StdFunction_call::returnVoid 298 ns 298 ns 2371125 -StdFunction_callMethod::returnVoid 298 ns 298 ns 2344992 - -RtlFunction_call::returnVoid 296 ns 296 ns 2353660 -RtlFunction_callMethod::returnVoid 297 ns 297 ns 2337540 - -RtlFunction_call_ReturnUnknown::Void 303 ns 303 ns 2319549 -RtlFunction_callMethod_ReturnUnknown::Void 301 ns 301 ns 2323886 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 304 ns 304 ns 2332608 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 362 ns 361 ns 1946177 - -NativeFunctionPtr_call::returnNonVoid 363 ns 363 ns 1947334 -NativeFunctionPtr_callMethod::returnNonVoid 362 ns 362 ns 1924561 - -StdFunction_call::returnNonVoid 359 ns 359 ns 1941891 -StdFunction_callMethod::returnNonVoid 362 ns 362 ns 1935593 - -RtlFunction_call::returnNonVoid 360 ns 359 ns 1930723 -RtlFunction_callMethod::returnNonVoid 361 ns 361 ns 1948673 - -RtlFunction_call_ReturnUnknown::NonVoid 372 ns 372 ns 1893811 -RtlFunction_callMethod_ReturnUnknown::NonVoid 371 ns 371 ns 1880068 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 372 ns 372 ns 1894361 ------------------------------------ -[2025-10-09 22:28:21] >>> Run 5: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-10-09T22:28:21+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.07, 1.02, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 304 ns 304 ns 2320564 - -NativeFunctionPtr_call::returnVoid 305 ns 305 ns 2314315 -NativeFunctionPtr_callMethod::returnVoid 308 ns 308 ns 2306194 - -StdFunction_call::returnVoid 306 ns 306 ns 2268882 -StdFunction_callMethod::returnVoid 303 ns 303 ns 2330974 - -RtlFunction_call::returnVoid 305 ns 305 ns 2291288 -RtlFunction_callMethod::returnVoid 304 ns 304 ns 2296612 - -RtlFunction_call_ReturnUnknown::Void 310 ns 310 ns 2255425 -RtlFunction_callMethod_ReturnUnknown::Void 307 ns 307 ns 2273163 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 310 ns 310 ns 2271135 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 367 ns 367 ns 1904923 - -NativeFunctionPtr_call::returnNonVoid 372 ns 372 ns 1907990 -NativeFunctionPtr_callMethod::returnNonVoid 372 ns 372 ns 1898216 - -StdFunction_call::returnNonVoid 370 ns 370 ns 1878913 -StdFunction_callMethod::returnNonVoid 370 ns 370 ns 1895647 - -RtlFunction_call::returnNonVoid 369 ns 369 ns 1891638 -RtlFunction_callMethod::returnNonVoid 372 ns 372 ns 1901882 - -RtlFunction_call_ReturnUnknown::NonVoid 378 ns 378 ns 1859020 -RtlFunction_callMethod_ReturnUnknown::NonVoid 376 ns 376 ns 1865751 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 379 ns 379 ns 1848271 ------------------------------------ -[2025-10-09 22:28:43] >>> Run 1: workload scale = 30 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 30 iterations -============================================= - -2025-10-09T22:28:43+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3304.61 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.04, 1.02, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 375 ns 375 ns 1862003 +Load Average: 0.74, 0.47, 0.22 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 0.648 ns 0.647 ns 1000000000 -NativeFunctionPtr_call::returnVoid 375 ns 375 ns 1858998 -NativeFunctionPtr_callMethod::returnVoid 377 ns 377 ns 1863926 +bm_call::by_FunctionPtr_Function::set_string 1.03 ns 1.03 ns 656251881 +bm_call::by_FunctionPtr___Method::set_string 1.44 ns 1.44 ns 476757016 -StdFunction_call::returnVoid 375 ns 375 ns 1854774 -StdFunction_callMethod::returnVoid 378 ns 378 ns 1858140 +bm_std::function_CallsFunction::set_string 1.44 ns 1.44 ns 470314609 +bm_std::function___CallsMethod::set_string 1.65 ns 1.65 ns 417062240 -RtlFunction_call::returnVoid 376 ns 376 ns 1861100 -RtlFunction_callMethod::returnVoid 376 ns 376 ns 1861280 +bm_rtl::function_CallsFunction::set_string 1.04 ns 1.04 ns 659236438 +bm_rtl::method_____CallsMethod::set_string 1.64 ns 1.64 ns 424815428 -RtlFunction_call_ReturnUnknown::Void 377 ns 377 ns 1848987 -RtlFunction_callMethod_ReturnUnknown::Void 378 ns 378 ns 1856361 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 380 ns 380 ns 1839194 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 444 ns 444 ns 1583671 +bm_rtl::function_ErasedReturnType::set_string 2.89 ns 2.89 ns 236586863 +bm_rtl::method___ErasedReturnType::set_string 3.71 ns 3.70 ns 186293054 +bm_rtl::method___ErasedTargetType::set_string 4.20 ns 4.20 ns 167817004 +bm_rtl::method___ErasedTargetAndReturnType::set_string 4.54 ns 4.53 ns 155605148 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1.36 ns 1.36 ns 493932968 -NativeFunctionPtr_call::returnNonVoid 440 ns 440 ns 1589570 -NativeFunctionPtr_callMethod::returnNonVoid 440 ns 440 ns 1588032 +bm_call::by_FunctionPtr_Function::get_string 2.69 ns 2.69 ns 258479344 +bm_call::by_FunctionPtr___Method::get_string 2.47 ns 2.47 ns 280926161 -StdFunction_call::returnNonVoid 441 ns 441 ns 1590750 -StdFunction_callMethod::returnNonVoid 442 ns 442 ns 1589307 +bm_std::function_CallsFunction::get_string 2.68 ns 2.68 ns 259014104 +bm_std::function___CallsMethod::get_string 2.88 ns 2.88 ns 235369356 -RtlFunction_call::returnNonVoid 441 ns 441 ns 1589175 -RtlFunction_callMethod::returnNonVoid 444 ns 444 ns 1586771 +bm_rtl::function_CallsFunction::get_string 2.47 ns 2.47 ns 279617188 +bm_rtl::method_____CallsMethod::get_string 2.68 ns 2.68 ns 261205131 -RtlFunction_call_ReturnUnknown::NonVoid 493 ns 493 ns 1363464 -RtlFunction_callMethod_ReturnUnknown::NonVoid 455 ns 455 ns 1539028 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 457 ns 457 ns 1531875 +bm_rtl::function_ErasedReturnType::get_string 14.6 ns 14.6 ns 48709947 +bm_rtl::method___ErasedReturnType::get_string 15.3 ns 15.3 ns 46894992 +bm_rtl::method___ErasedTargetType::get_string 5.47 ns 5.47 ns 128622322 +bm_rtl::method___ErasedTargetAndReturnType::get_string 17.0 ns 17.0 ns 41823660 ----------------------------------- -[2025-10-09 22:29:06] >>> Run 2: workload scale = 30 +[2025-10-25 08:19:02] >>> Run 3: workload scale = 0 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 30 iterations +Scale : 0 iterations ============================================= -2025-10-09T22:29:06+05:30 +2025-10-25T08:19:02+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -2026,97 +119,101 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.03, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 394 ns 394 ns 1780206 +Load Average: 0.81, 0.51, 0.24 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 0.551 ns 0.551 ns 1000000000 -NativeFunctionPtr_call::returnVoid 394 ns 394 ns 1770515 -NativeFunctionPtr_callMethod::returnVoid 395 ns 395 ns 1774757 +bm_call::by_FunctionPtr_Function::set_string 1.03 ns 1.03 ns 658445343 +bm_call::by_FunctionPtr___Method::set_string 1.44 ns 1.44 ns 471488825 -StdFunction_call::returnVoid 393 ns 393 ns 1774702 -StdFunction_callMethod::returnVoid 392 ns 392 ns 1790215 +bm_std::function_CallsFunction::set_string 1.44 ns 1.44 ns 476231396 +bm_std::function___CallsMethod::set_string 1.65 ns 1.65 ns 420945966 -RtlFunction_call::returnVoid 395 ns 395 ns 1777944 -RtlFunction_callMethod::returnVoid 396 ns 396 ns 1767421 +bm_rtl::function_CallsFunction::set_string 1.03 ns 1.03 ns 664980277 +bm_rtl::method_____CallsMethod::set_string 1.64 ns 1.64 ns 419659954 -RtlFunction_call_ReturnUnknown::Void 395 ns 395 ns 1768723 -RtlFunction_callMethod_ReturnUnknown::Void 395 ns 395 ns 1766669 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 381 ns 380 ns 1769593 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 421 ns 421 ns 1660930 +bm_rtl::function_ErasedReturnType::set_string 2.80 ns 2.80 ns 247763482 +bm_rtl::method___ErasedReturnType::set_string 3.71 ns 3.71 ns 186533146 +bm_rtl::method___ErasedTargetType::set_string 4.15 ns 4.15 ns 167655898 +bm_rtl::method___ErasedTargetAndReturnType::set_string 4.59 ns 4.59 ns 152815905 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1.38 ns 1.38 ns 492459263 -NativeFunctionPtr_call::returnNonVoid 420 ns 420 ns 1668362 -NativeFunctionPtr_callMethod::returnNonVoid 421 ns 421 ns 1665328 +bm_call::by_FunctionPtr_Function::get_string 2.81 ns 2.81 ns 240960786 +bm_call::by_FunctionPtr___Method::get_string 2.47 ns 2.47 ns 280206200 -StdFunction_call::returnNonVoid 418 ns 418 ns 1669473 -StdFunction_callMethod::returnNonVoid 420 ns 420 ns 1673333 +bm_std::function_CallsFunction::get_string 2.67 ns 2.67 ns 261693890 +bm_std::function___CallsMethod::get_string 2.89 ns 2.89 ns 239552750 -RtlFunction_call::returnNonVoid 422 ns 422 ns 1661673 -RtlFunction_callMethod::returnNonVoid 421 ns 421 ns 1657094 +bm_rtl::function_CallsFunction::get_string 2.46 ns 2.46 ns 279113400 +bm_rtl::method_____CallsMethod::get_string 2.67 ns 2.67 ns 260583976 -RtlFunction_call_ReturnUnknown::NonVoid 426 ns 426 ns 1643063 -RtlFunction_callMethod_ReturnUnknown::NonVoid 427 ns 427 ns 1646820 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 429 ns 429 ns 1626103 +bm_rtl::function_ErasedReturnType::get_string 15.0 ns 15.0 ns 46074384 +bm_rtl::method___ErasedReturnType::get_string 15.4 ns 15.4 ns 44466471 +bm_rtl::method___ErasedTargetType::get_string 5.49 ns 5.49 ns 126135231 +bm_rtl::method___ErasedTargetAndReturnType::get_string 17.0 ns 17.0 ns 40088742 ----------------------------------- -[2025-10-09 22:29:29] >>> Run 3: workload scale = 30 +[2025-10-25 08:19:22] >>> Run 4: workload scale = 0 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 30 iterations +Scale : 0 iterations ============================================= -2025-10-09T22:29:29+05:30 +2025-10-25T08:19:22+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3789.01 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.02, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 393 ns 393 ns 1776209 +Load Average: 0.94, 0.56, 0.26 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 0.734 ns 0.734 ns 1000000000 -NativeFunctionPtr_call::returnVoid 393 ns 393 ns 1780927 -NativeFunctionPtr_callMethod::returnVoid 395 ns 395 ns 1773879 +bm_call::by_FunctionPtr_Function::set_string 1.03 ns 1.03 ns 659830073 +bm_call::by_FunctionPtr___Method::set_string 1.44 ns 1.44 ns 480099742 -StdFunction_call::returnVoid 395 ns 395 ns 1778780 -StdFunction_callMethod::returnVoid 393 ns 393 ns 1782892 +bm_std::function_CallsFunction::set_string 1.44 ns 1.44 ns 479828845 +bm_std::function___CallsMethod::set_string 1.65 ns 1.65 ns 418130244 -RtlFunction_call::returnVoid 394 ns 394 ns 1775635 -RtlFunction_callMethod::returnVoid 395 ns 395 ns 1765210 +bm_rtl::function_CallsFunction::set_string 1.04 ns 1.04 ns 659319071 +bm_rtl::method_____CallsMethod::set_string 1.66 ns 1.66 ns 421905274 -RtlFunction_call_ReturnUnknown::Void 396 ns 396 ns 1761114 -RtlFunction_callMethod_ReturnUnknown::Void 395 ns 395 ns 1768030 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 397 ns 397 ns 1758820 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 469 ns 469 ns 1487199 +bm_rtl::function_ErasedReturnType::set_string 2.77 ns 2.77 ns 249634586 +bm_rtl::method___ErasedReturnType::set_string 3.74 ns 3.74 ns 188550991 +bm_rtl::method___ErasedTargetType::set_string 4.12 ns 4.12 ns 166325953 +bm_rtl::method___ErasedTargetAndReturnType::set_string 4.52 ns 4.53 ns 153059766 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1.37 ns 1.37 ns 470510214 -NativeFunctionPtr_call::returnNonVoid 471 ns 470 ns 1487718 -NativeFunctionPtr_callMethod::returnNonVoid 472 ns 472 ns 1485276 +bm_call::by_FunctionPtr_Function::get_string 2.73 ns 2.74 ns 249330071 +bm_call::by_FunctionPtr___Method::get_string 2.47 ns 2.47 ns 274811981 -StdFunction_call::returnNonVoid 469 ns 469 ns 1495580 -StdFunction_callMethod::returnNonVoid 480 ns 480 ns 1476257 +bm_std::function_CallsFunction::get_string 2.66 ns 2.66 ns 259812894 +bm_std::function___CallsMethod::get_string 2.86 ns 2.87 ns 243195723 -RtlFunction_call::returnNonVoid 473 ns 473 ns 1484166 -RtlFunction_callMethod::returnNonVoid 472 ns 472 ns 1477993 +bm_rtl::function_CallsFunction::get_string 2.45 ns 2.46 ns 283467019 +bm_rtl::method_____CallsMethod::get_string 2.66 ns 2.67 ns 260247098 -RtlFunction_call_ReturnUnknown::NonVoid 478 ns 478 ns 1464224 -RtlFunction_callMethod_ReturnUnknown::NonVoid 478 ns 478 ns 1460289 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 478 ns 478 ns 1460410 +bm_rtl::function_ErasedReturnType::get_string 14.0 ns 14.0 ns 47780007 +bm_rtl::method___ErasedReturnType::get_string 15.4 ns 15.4 ns 45943239 +bm_rtl::method___ErasedTargetType::get_string 5.37 ns 5.38 ns 128203773 +bm_rtl::method___ErasedTargetAndReturnType::get_string 16.8 ns 16.8 ns 40999544 ----------------------------------- -[2025-10-09 22:29:52] >>> Run 4: workload scale = 30 +[2025-10-25 08:19:43] >>> Run 5: workload scale = 0 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 30 iterations +Scale : 0 iterations ============================================= -2025-10-09T22:29:52+05:30 +2025-10-25T08:19:43+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -2124,1175 +221,1223 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.01, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 361 ns 361 ns 1940795 +Load Average: 1.03, 0.60, 0.29 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 0.631 ns 0.632 ns 1000000000 -NativeFunctionPtr_call::returnVoid 361 ns 361 ns 1930440 -NativeFunctionPtr_callMethod::returnVoid 361 ns 361 ns 1955461 +bm_call::by_FunctionPtr_Function::set_string 1.03 ns 1.03 ns 666792792 +bm_call::by_FunctionPtr___Method::set_string 1.46 ns 1.46 ns 473236703 -StdFunction_call::returnVoid 359 ns 359 ns 1927669 -StdFunction_callMethod::returnVoid 362 ns 362 ns 1933320 +bm_std::function_CallsFunction::set_string 1.44 ns 1.45 ns 475143135 +bm_std::function___CallsMethod::set_string 1.65 ns 1.65 ns 418841792 -RtlFunction_call::returnVoid 360 ns 360 ns 1937323 -RtlFunction_callMethod::returnVoid 371 ns 371 ns 1933598 +bm_rtl::function_CallsFunction::set_string 1.03 ns 1.03 ns 667445817 +bm_rtl::method_____CallsMethod::set_string 1.64 ns 1.65 ns 416846062 -RtlFunction_call_ReturnUnknown::Void 405 ns 404 ns 1693301 -RtlFunction_callMethod_ReturnUnknown::Void 403 ns 403 ns 1736508 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 410 ns 410 ns 1702735 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 471 ns 471 ns 1479714 +bm_rtl::function_ErasedReturnType::set_string 2.83 ns 2.83 ns 249324871 +bm_rtl::method___ErasedReturnType::set_string 3.73 ns 3.73 ns 186308314 +bm_rtl::method___ErasedTargetType::set_string 4.13 ns 4.14 ns 169716154 +bm_rtl::method___ErasedTargetAndReturnType::set_string 4.42 ns 4.42 ns 154047402 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1.35 ns 1.35 ns 503328815 -NativeFunctionPtr_call::returnNonVoid 474 ns 474 ns 1478273 -NativeFunctionPtr_callMethod::returnNonVoid 478 ns 478 ns 1468965 +bm_call::by_FunctionPtr_Function::get_string 2.71 ns 2.71 ns 259229712 +bm_call::by_FunctionPtr___Method::get_string 2.46 ns 2.46 ns 277899881 -StdFunction_call::returnNonVoid 475 ns 475 ns 1467770 -StdFunction_callMethod::returnNonVoid 475 ns 475 ns 1470489 +bm_std::function_CallsFunction::get_string 2.67 ns 2.67 ns 258771892 +bm_std::function___CallsMethod::get_string 2.87 ns 2.87 ns 241524683 -RtlFunction_call::returnNonVoid 475 ns 475 ns 1470438 -RtlFunction_callMethod::returnNonVoid 481 ns 481 ns 1456197 +bm_rtl::function_CallsFunction::get_string 2.46 ns 2.46 ns 283237330 +bm_rtl::method_____CallsMethod::get_string 2.68 ns 2.69 ns 257420026 -RtlFunction_call_ReturnUnknown::NonVoid 487 ns 487 ns 1435053 -RtlFunction_callMethod_ReturnUnknown::NonVoid 484 ns 484 ns 1438840 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 496 ns 496 ns 1392810 +bm_rtl::function_ErasedReturnType::get_string 14.5 ns 14.5 ns 48605151 +bm_rtl::method___ErasedReturnType::get_string 14.8 ns 14.8 ns 45921688 +bm_rtl::method___ErasedTargetType::get_string 5.41 ns 5.42 ns 129878520 +bm_rtl::method___ErasedTargetAndReturnType::get_string 16.7 ns 16.7 ns 40744148 ----------------------------------- -[2025-10-09 22:30:15] >>> Run 5: workload scale = 30 +[2025-10-25 08:20:03] >>> Run 1: workload scale = 1 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 30 iterations +Scale : 1 iterations ============================================= -2025-10-09T22:30:15+05:30 +2025-10-25T08:20:03+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2665.28 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.01, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 360 ns 360 ns 1941073 +Load Average: 1.07, 0.65, 0.31 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 15.0 ns 15.0 ns 46489314 -NativeFunctionPtr_call::returnVoid 362 ns 362 ns 1934866 -NativeFunctionPtr_callMethod::returnVoid 362 ns 362 ns 1929133 +bm_call::by_FunctionPtr_Function::set_string 15.5 ns 15.5 ns 44790901 +bm_call::by_FunctionPtr___Method::set_string 15.7 ns 15.7 ns 43399121 -StdFunction_call::returnVoid 363 ns 363 ns 1938397 -StdFunction_callMethod::returnVoid 362 ns 362 ns 1919071 +bm_std::function_CallsFunction::set_string 15.5 ns 15.6 ns 44476865 +bm_std::function___CallsMethod::set_string 16.5 ns 16.5 ns 42190284 -RtlFunction_call::returnVoid 362 ns 362 ns 1941842 -RtlFunction_callMethod::returnVoid 363 ns 363 ns 1916383 +bm_rtl::function_CallsFunction::set_string 16.1 ns 16.1 ns 42912065 +bm_rtl::method_____CallsMethod::set_string 16.2 ns 16.2 ns 42326302 -RtlFunction_call_ReturnUnknown::Void 365 ns 365 ns 1907408 -RtlFunction_callMethod_ReturnUnknown::Void 363 ns 363 ns 1923142 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 365 ns 365 ns 1932398 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 429 ns 429 ns 1635609 +bm_rtl::function_ErasedReturnType::set_string 18.2 ns 18.2 ns 37532677 +bm_rtl::method___ErasedReturnType::set_string 19.2 ns 19.2 ns 35793231 +bm_rtl::method___ErasedTargetType::set_string 19.3 ns 19.3 ns 36200905 +bm_rtl::method___ErasedTargetAndReturnType::set_string 20.6 ns 20.6 ns 33014032 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 25.5 ns 25.5 ns 27311934 -NativeFunctionPtr_call::returnNonVoid 431 ns 431 ns 1633937 -NativeFunctionPtr_callMethod::returnNonVoid 421 ns 421 ns 1663536 +bm_call::by_FunctionPtr_Function::get_string 25.6 ns 25.6 ns 27089191 +bm_call::by_FunctionPtr___Method::get_string 26.9 ns 26.9 ns 26852749 -StdFunction_call::returnNonVoid 430 ns 430 ns 1635257 -StdFunction_callMethod::returnNonVoid 420 ns 420 ns 1666612 +bm_std::function_CallsFunction::get_string 26.7 ns 26.7 ns 26331017 +bm_std::function___CallsMethod::get_string 26.9 ns 27.0 ns 25916070 -RtlFunction_call::returnNonVoid 430 ns 430 ns 1628640 -RtlFunction_callMethod::returnNonVoid 420 ns 420 ns 1659967 +bm_rtl::function_CallsFunction::get_string 23.0 ns 23.0 ns 26905535 +bm_rtl::method_____CallsMethod::get_string 21.7 ns 21.7 ns 31447444 -RtlFunction_call_ReturnUnknown::NonVoid 443 ns 443 ns 1577000 -RtlFunction_callMethod_ReturnUnknown::NonVoid 429 ns 429 ns 1631922 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 432 ns 432 ns 1626032 +bm_rtl::function_ErasedReturnType::get_string 34.8 ns 34.8 ns 19825366 +bm_rtl::method___ErasedReturnType::get_string 36.1 ns 36.1 ns 19592230 +bm_rtl::method___ErasedTargetType::get_string 24.4 ns 24.5 ns 28769601 +bm_rtl::method___ErasedTargetAndReturnType::get_string 37.2 ns 37.2 ns 18695077 ----------------------------------- -[2025-10-09 22:30:38] >>> Run 1: workload scale = 35 +[2025-10-25 08:20:24] >>> Run 2: workload scale = 1 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 35 iterations +Scale : 1 iterations ============================================= -2025-10-09T22:30:38+05:30 +2025-10-25T08:20:24+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3657.52 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 683 ns 683 ns 1024747 +Load Average: 1.27, 0.72, 0.34 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 14.6 ns 14.6 ns 46519998 -NativeFunctionPtr_call::returnVoid 681 ns 681 ns 1031950 -NativeFunctionPtr_callMethod::returnVoid 682 ns 682 ns 1021311 +bm_call::by_FunctionPtr_Function::set_string 15.1 ns 15.1 ns 46355255 +bm_call::by_FunctionPtr___Method::set_string 15.2 ns 15.2 ns 45793009 -StdFunction_call::returnVoid 681 ns 681 ns 1025739 -StdFunction_callMethod::returnVoid 685 ns 685 ns 1024940 +bm_std::function_CallsFunction::set_string 15.1 ns 15.1 ns 45496352 +bm_std::function___CallsMethod::set_string 15.1 ns 15.1 ns 46803659 -RtlFunction_call::returnVoid 671 ns 671 ns 1047757 -RtlFunction_callMethod::returnVoid 673 ns 673 ns 1042146 +bm_rtl::function_CallsFunction::set_string 15.3 ns 15.3 ns 44864140 +bm_rtl::method_____CallsMethod::set_string 15.7 ns 15.7 ns 42768352 -RtlFunction_call_ReturnUnknown::Void 685 ns 685 ns 1002530 -RtlFunction_callMethod_ReturnUnknown::Void 683 ns 683 ns 1025495 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 684 ns 684 ns 1028604 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 779 ns 779 ns 902122 +bm_rtl::function_ErasedReturnType::set_string 17.5 ns 17.5 ns 39957227 +bm_rtl::method___ErasedReturnType::set_string 18.1 ns 18.1 ns 38339282 +bm_rtl::method___ErasedTargetType::set_string 18.1 ns 18.1 ns 37281995 +bm_rtl::method___ErasedTargetAndReturnType::set_string 18.5 ns 18.5 ns 36832626 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 23.1 ns 23.1 ns 31436556 -NativeFunctionPtr_call::returnNonVoid 810 ns 810 ns 900341 -NativeFunctionPtr_callMethod::returnNonVoid 803 ns 803 ns 835135 +bm_call::by_FunctionPtr_Function::get_string 21.7 ns 21.7 ns 32182266 +bm_call::by_FunctionPtr___Method::get_string 21.5 ns 21.6 ns 32162869 -StdFunction_call::returnNonVoid 776 ns 776 ns 900075 -StdFunction_callMethod::returnNonVoid 780 ns 779 ns 901231 +bm_std::function_CallsFunction::get_string 21.9 ns 21.9 ns 30912997 +bm_std::function___CallsMethod::get_string 21.8 ns 21.8 ns 30892316 -RtlFunction_call::returnNonVoid 779 ns 779 ns 900202 -RtlFunction_callMethod::returnNonVoid 777 ns 777 ns 901870 +bm_rtl::function_CallsFunction::get_string 21.4 ns 21.4 ns 31993182 +bm_rtl::method_____CallsMethod::get_string 21.9 ns 21.9 ns 31331163 -RtlFunction_call_ReturnUnknown::NonVoid 797 ns 797 ns 879234 -RtlFunction_callMethod_ReturnUnknown::NonVoid 799 ns 799 ns 879126 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 798 ns 798 ns 877726 +bm_rtl::function_ErasedReturnType::get_string 35.7 ns 35.7 ns 19393306 +bm_rtl::method___ErasedReturnType::get_string 36.5 ns 36.5 ns 19212247 +bm_rtl::method___ErasedTargetType::get_string 24.8 ns 24.8 ns 27574548 +bm_rtl::method___ErasedTargetAndReturnType::get_string 37.9 ns 37.9 ns 18644241 ----------------------------------- -[2025-10-09 22:30:54] >>> Run 2: workload scale = 35 +[2025-10-25 08:20:44] >>> Run 3: workload scale = 1 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 35 iterations +Scale : 1 iterations ============================================= -2025-10-09T22:30:54+05:30 +2025-10-25T08:20:44+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3797.51 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.34, 1.09, 1.03 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 690 ns 690 ns 1010752 +Load Average: 1.35, 0.77, 0.37 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 16.0 ns 16.0 ns 41976810 -NativeFunctionPtr_call::returnVoid 686 ns 686 ns 1016034 -NativeFunctionPtr_callMethod::returnVoid 685 ns 685 ns 1012362 +bm_call::by_FunctionPtr_Function::set_string 16.0 ns 16.0 ns 41832795 +bm_call::by_FunctionPtr___Method::set_string 16.5 ns 16.5 ns 40619550 -StdFunction_call::returnVoid 687 ns 687 ns 1015099 -StdFunction_callMethod::returnVoid 688 ns 688 ns 1022024 +bm_std::function_CallsFunction::set_string 16.1 ns 16.1 ns 41469240 +bm_std::function___CallsMethod::set_string 16.2 ns 16.2 ns 40420660 -RtlFunction_call::returnVoid 688 ns 688 ns 1019452 -RtlFunction_callMethod::returnVoid 685 ns 685 ns 1025522 +bm_rtl::function_CallsFunction::set_string 15.0 ns 15.0 ns 46611247 +bm_rtl::method_____CallsMethod::set_string 15.7 ns 15.7 ns 42476573 -RtlFunction_call_ReturnUnknown::Void 696 ns 696 ns 999232 -RtlFunction_callMethod_ReturnUnknown::Void 691 ns 691 ns 1015509 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 693 ns 693 ns 1012501 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 785 ns 785 ns 893087 +bm_rtl::function_ErasedReturnType::set_string 17.2 ns 17.2 ns 38895808 +bm_rtl::method___ErasedReturnType::set_string 17.8 ns 17.8 ns 38234678 +bm_rtl::method___ErasedTargetType::set_string 17.9 ns 17.9 ns 37495782 +bm_rtl::method___ErasedTargetAndReturnType::set_string 18.5 ns 18.6 ns 36640863 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 22.5 ns 22.5 ns 30463924 -NativeFunctionPtr_call::returnNonVoid 779 ns 779 ns 897872 -NativeFunctionPtr_callMethod::returnNonVoid 776 ns 776 ns 900682 +bm_call::by_FunctionPtr_Function::get_string 22.5 ns 22.5 ns 30610948 +bm_call::by_FunctionPtr___Method::get_string 22.5 ns 22.5 ns 30735698 -StdFunction_call::returnNonVoid 777 ns 777 ns 900615 -StdFunction_callMethod::returnNonVoid 775 ns 775 ns 904093 +bm_std::function_CallsFunction::get_string 22.4 ns 22.4 ns 31197397 +bm_std::function___CallsMethod::get_string 22.3 ns 22.3 ns 31234800 -RtlFunction_call::returnNonVoid 775 ns 775 ns 900935 -RtlFunction_callMethod::returnNonVoid 775 ns 775 ns 901345 +bm_rtl::function_CallsFunction::get_string 22.6 ns 22.6 ns 30567039 +bm_rtl::method_____CallsMethod::get_string 22.6 ns 22.6 ns 31412197 -RtlFunction_call_ReturnUnknown::NonVoid 789 ns 789 ns 886938 -RtlFunction_callMethod_ReturnUnknown::NonVoid 799 ns 799 ns 878579 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 800 ns 800 ns 874472 +bm_rtl::function_ErasedReturnType::get_string 34.5 ns 34.5 ns 20465307 +bm_rtl::method___ErasedReturnType::get_string 37.3 ns 37.3 ns 19304351 +bm_rtl::method___ErasedTargetType::get_string 28.7 ns 28.7 ns 24064394 +bm_rtl::method___ErasedTargetAndReturnType::get_string 38.6 ns 38.6 ns 18326204 ----------------------------------- -[2025-10-09 22:31:09] >>> Run 3: workload scale = 35 +[2025-10-25 08:21:05] >>> Run 1: workload scale = 5 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 35 iterations +Scale : 5 iterations ============================================= -2025-10-09T22:31:09+05:30 +2025-10-25T08:21:05+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3520.89 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.27, 1.08, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 717 ns 717 ns 984558 +Load Average: 1.31, 0.81, 0.39 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 98.2 ns 98.2 ns 6889902 -NativeFunctionPtr_call::returnVoid 718 ns 718 ns 972954 -NativeFunctionPtr_callMethod::returnVoid 716 ns 716 ns 979919 +bm_call::by_FunctionPtr_Function::set_string 97.1 ns 97.1 ns 7004090 +bm_call::by_FunctionPtr___Method::set_string 97.9 ns 97.9 ns 6941573 -StdFunction_call::returnVoid 718 ns 718 ns 960825 -StdFunction_callMethod::returnVoid 721 ns 721 ns 974166 +bm_std::function_CallsFunction::set_string 98.7 ns 98.7 ns 6766823 +bm_std::function___CallsMethod::set_string 97.5 ns 97.5 ns 7061625 -RtlFunction_call::returnVoid 719 ns 719 ns 977272 -RtlFunction_callMethod::returnVoid 717 ns 717 ns 975161 +bm_rtl::function_CallsFunction::set_string 98.3 ns 98.4 ns 6919195 +bm_rtl::method_____CallsMethod::set_string 98.6 ns 98.6 ns 6678480 -RtlFunction_call_ReturnUnknown::Void 729 ns 729 ns 963392 -RtlFunction_callMethod_ReturnUnknown::Void 723 ns 723 ns 965541 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 710 ns 709 ns 984115 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 805 ns 805 ns 867056 +bm_rtl::function_ErasedReturnType::set_string 100 ns 100 ns 6659211 +bm_rtl::method___ErasedReturnType::set_string 100 ns 100 ns 6865663 +bm_rtl::method___ErasedTargetType::set_string 101 ns 101 ns 6373256 +bm_rtl::method___ErasedTargetAndReturnType::set_string 102 ns 102 ns 6645843 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 134 ns 134 ns 5151911 -NativeFunctionPtr_call::returnNonVoid 803 ns 803 ns 870656 -NativeFunctionPtr_callMethod::returnNonVoid 805 ns 805 ns 871527 +bm_call::by_FunctionPtr_Function::get_string 135 ns 135 ns 4779355 +bm_call::by_FunctionPtr___Method::get_string 135 ns 135 ns 4882235 -StdFunction_call::returnNonVoid 807 ns 807 ns 869225 -StdFunction_callMethod::returnNonVoid 794 ns 793 ns 879346 +bm_std::function_CallsFunction::get_string 136 ns 136 ns 4897122 +bm_std::function___CallsMethod::get_string 135 ns 135 ns 5014591 -RtlFunction_call::returnNonVoid 804 ns 804 ns 869666 -RtlFunction_callMethod::returnNonVoid 804 ns 804 ns 870562 +bm_rtl::function_CallsFunction::get_string 136 ns 136 ns 4824411 +bm_rtl::method_____CallsMethod::get_string 137 ns 137 ns 4978156 -RtlFunction_call_ReturnUnknown::NonVoid 813 ns 813 ns 860837 -RtlFunction_callMethod_ReturnUnknown::NonVoid 818 ns 818 ns 853952 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 820 ns 820 ns 855449 +bm_rtl::function_ErasedReturnType::get_string 145 ns 145 ns 4625178 +bm_rtl::method___ErasedReturnType::get_string 146 ns 146 ns 4599328 +bm_rtl::method___ErasedTargetType::get_string 133 ns 133 ns 5050703 +bm_rtl::method___ErasedTargetAndReturnType::get_string 147 ns 147 ns 4767692 ----------------------------------- -[2025-10-09 22:31:25] >>> Run 4: workload scale = 35 +[2025-10-25 08:21:23] >>> Run 2: workload scale = 5 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 35 iterations +Scale : 5 iterations ============================================= -2025-10-09T22:31:25+05:30 +2025-10-25T08:21:23+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3841.43 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.21, 1.08, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 677 ns 677 ns 1030590 +Load Average: 1.31, 0.83, 0.40 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 100 ns 100 ns 6692322 -NativeFunctionPtr_call::returnVoid 680 ns 680 ns 1012390 -NativeFunctionPtr_callMethod::returnVoid 679 ns 679 ns 1028254 +bm_call::by_FunctionPtr_Function::set_string 100 ns 100 ns 6766344 +bm_call::by_FunctionPtr___Method::set_string 102 ns 102 ns 6727036 -StdFunction_call::returnVoid 681 ns 681 ns 1028605 -StdFunction_callMethod::returnVoid 683 ns 683 ns 1021847 +bm_std::function_CallsFunction::set_string 100 ns 100 ns 6540251 +bm_std::function___CallsMethod::set_string 103 ns 103 ns 6233534 -RtlFunction_call::returnVoid 680 ns 680 ns 1025142 -RtlFunction_callMethod::returnVoid 679 ns 679 ns 1027089 +bm_rtl::function_CallsFunction::set_string 97.8 ns 97.8 ns 6866111 +bm_rtl::method_____CallsMethod::set_string 98.7 ns 98.7 ns 6727472 -RtlFunction_call_ReturnUnknown::Void 694 ns 694 ns 1005031 -RtlFunction_callMethod_ReturnUnknown::Void 690 ns 690 ns 1015221 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 690 ns 690 ns 1016998 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 772 ns 772 ns 907121 +bm_rtl::function_ErasedReturnType::set_string 100 ns 100 ns 6586303 +bm_rtl::method___ErasedReturnType::set_string 100 ns 100 ns 6710424 +bm_rtl::method___ErasedTargetType::set_string 101 ns 101 ns 6570920 +bm_rtl::method___ErasedTargetAndReturnType::set_string 102 ns 102 ns 6713114 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 119 ns 119 ns 5588782 -NativeFunctionPtr_call::returnNonVoid 773 ns 773 ns 907194 -NativeFunctionPtr_callMethod::returnNonVoid 771 ns 771 ns 904318 +bm_call::by_FunctionPtr_Function::get_string 123 ns 123 ns 5512353 +bm_call::by_FunctionPtr___Method::get_string 125 ns 125 ns 5361141 -StdFunction_call::returnNonVoid 774 ns 774 ns 904984 -StdFunction_callMethod::returnNonVoid 775 ns 775 ns 892394 +bm_std::function_CallsFunction::get_string 124 ns 124 ns 5343909 +bm_std::function___CallsMethod::get_string 124 ns 124 ns 5593743 -RtlFunction_call::returnNonVoid 771 ns 771 ns 907135 -RtlFunction_callMethod::returnNonVoid 771 ns 771 ns 909602 +bm_rtl::function_CallsFunction::get_string 124 ns 124 ns 5386510 +bm_rtl::method_____CallsMethod::get_string 122 ns 122 ns 5453558 -RtlFunction_call_ReturnUnknown::NonVoid 792 ns 792 ns 885728 -RtlFunction_callMethod_ReturnUnknown::NonVoid 801 ns 801 ns 876551 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 803 ns 803 ns 871792 +bm_rtl::function_ErasedReturnType::get_string 128 ns 128 ns 5400261 +bm_rtl::method___ErasedReturnType::get_string 128 ns 128 ns 5195725 +bm_rtl::method___ErasedTargetType::get_string 120 ns 120 ns 5725123 +bm_rtl::method___ErasedTargetAndReturnType::get_string 132 ns 132 ns 5119969 ----------------------------------- -[2025-10-09 22:31:41] >>> Run 5: workload scale = 35 +[2025-10-25 08:21:40] >>> Run 3: workload scale = 5 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 35 iterations +Scale : 5 iterations ============================================= -2025-10-09T22:31:41+05:30 +2025-10-25T08:21:40+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4517.2 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.16, 1.08, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 678 ns 678 ns 1030229 +Load Average: 1.54, 0.91, 0.44 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 96.1 ns 96.1 ns 6860471 -NativeFunctionPtr_call::returnVoid 682 ns 682 ns 1028955 -NativeFunctionPtr_callMethod::returnVoid 680 ns 680 ns 1024874 +bm_call::by_FunctionPtr_Function::set_string 98.1 ns 98.1 ns 6906275 +bm_call::by_FunctionPtr___Method::set_string 97.6 ns 97.6 ns 6744491 -StdFunction_call::returnVoid 680 ns 680 ns 1035697 -StdFunction_callMethod::returnVoid 682 ns 682 ns 1027575 +bm_std::function_CallsFunction::set_string 98.2 ns 98.2 ns 6716549 +bm_std::function___CallsMethod::set_string 98.1 ns 98.1 ns 6809655 -RtlFunction_call::returnVoid 679 ns 679 ns 1034510 -RtlFunction_callMethod::returnVoid 682 ns 682 ns 1025157 +bm_rtl::function_CallsFunction::set_string 97.3 ns 97.3 ns 7019050 +bm_rtl::method_____CallsMethod::set_string 97.6 ns 97.6 ns 6872439 -RtlFunction_call_ReturnUnknown::Void 691 ns 691 ns 1017271 -RtlFunction_callMethod_ReturnUnknown::Void 689 ns 689 ns 1014372 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 687 ns 687 ns 1018986 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 780 ns 780 ns 893173 +bm_rtl::function_ErasedReturnType::set_string 99.1 ns 99.2 ns 6930500 +bm_rtl::method___ErasedReturnType::set_string 101 ns 101 ns 6748918 +bm_rtl::method___ErasedTargetType::set_string 102 ns 102 ns 6567633 +bm_rtl::method___ErasedTargetAndReturnType::set_string 101 ns 101 ns 6057670 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 118 ns 118 ns 5842333 -NativeFunctionPtr_call::returnNonVoid 781 ns 781 ns 895297 -NativeFunctionPtr_callMethod::returnNonVoid 780 ns 780 ns 885395 +bm_call::by_FunctionPtr_Function::get_string 118 ns 118 ns 5652674 +bm_call::by_FunctionPtr___Method::get_string 118 ns 118 ns 5739336 -StdFunction_call::returnNonVoid 780 ns 780 ns 895356 -StdFunction_callMethod::returnNonVoid 786 ns 786 ns 891045 +bm_std::function_CallsFunction::get_string 119 ns 119 ns 5696574 +bm_std::function___CallsMethod::get_string 118 ns 118 ns 5647767 -RtlFunction_call::returnNonVoid 782 ns 781 ns 895682 -RtlFunction_callMethod::returnNonVoid 780 ns 780 ns 898162 +bm_rtl::function_CallsFunction::get_string 117 ns 117 ns 5846432 +bm_rtl::method_____CallsMethod::get_string 117 ns 117 ns 5843085 -RtlFunction_call_ReturnUnknown::NonVoid 796 ns 796 ns 880495 -RtlFunction_callMethod_ReturnUnknown::NonVoid 802 ns 802 ns 870804 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 805 ns 805 ns 869103 +bm_rtl::function_ErasedReturnType::get_string 129 ns 129 ns 5403621 +bm_rtl::method___ErasedReturnType::get_string 131 ns 131 ns 4977944 +bm_rtl::method___ErasedTargetType::get_string 118 ns 118 ns 5719642 +bm_rtl::method___ErasedTargetAndReturnType::get_string 132 ns 132 ns 5019900 ----------------------------------- -[2025-10-09 22:31:56] >>> Run 1: workload scale = 40 +[2025-10-25 08:21:58] >>> Run 1: workload scale = 10 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 40 iterations +Scale : 10 iterations ============================================= -2025-10-09T22:31:56+05:30 +2025-10-25T08:21:58+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 1121.39 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.12, 1.07, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 756 ns 756 ns 926102 +Load Average: 1.58, 0.95, 0.46 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 164 ns 164 ns 4069799 -NativeFunctionPtr_call::returnVoid 761 ns 761 ns 918536 -NativeFunctionPtr_callMethod::returnVoid 762 ns 762 ns 921185 +bm_call::by_FunctionPtr_Function::set_string 166 ns 166 ns 4054108 +bm_call::by_FunctionPtr___Method::set_string 165 ns 165 ns 4054498 -StdFunction_call::returnVoid 758 ns 758 ns 923567 -StdFunction_callMethod::returnVoid 758 ns 758 ns 925007 +bm_std::function_CallsFunction::set_string 166 ns 166 ns 4123163 +bm_std::function___CallsMethod::set_string 165 ns 165 ns 4023412 -RtlFunction_call::returnVoid 760 ns 760 ns 923296 -RtlFunction_callMethod::returnVoid 761 ns 761 ns 917046 +bm_rtl::function_CallsFunction::set_string 166 ns 166 ns 4058757 +bm_rtl::method_____CallsMethod::set_string 166 ns 166 ns 4110012 -RtlFunction_call_ReturnUnknown::Void 770 ns 770 ns 909624 -RtlFunction_callMethod_ReturnUnknown::Void 779 ns 778 ns 896321 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 778 ns 778 ns 898624 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 866 ns 866 ns 799845 +bm_rtl::function_ErasedReturnType::set_string 167 ns 167 ns 4151252 +bm_rtl::method___ErasedReturnType::set_string 167 ns 167 ns 4149683 +bm_rtl::method___ErasedTargetType::set_string 169 ns 169 ns 4025346 +bm_rtl::method___ErasedTargetAndReturnType::set_string 169 ns 169 ns 3998850 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 213 ns 213 ns 3240485 -NativeFunctionPtr_call::returnNonVoid 870 ns 870 ns 804887 -NativeFunctionPtr_callMethod::returnNonVoid 874 ns 874 ns 802180 +bm_call::by_FunctionPtr_Function::get_string 215 ns 215 ns 3236431 +bm_call::by_FunctionPtr___Method::get_string 214 ns 214 ns 3203988 -StdFunction_call::returnNonVoid 868 ns 868 ns 805459 -StdFunction_callMethod::returnNonVoid 864 ns 864 ns 807214 +bm_std::function_CallsFunction::get_string 213 ns 213 ns 3227674 +bm_std::function___CallsMethod::get_string 214 ns 214 ns 3157838 -RtlFunction_call::returnNonVoid 871 ns 871 ns 798744 -RtlFunction_callMethod::returnNonVoid 870 ns 870 ns 804203 +bm_rtl::function_CallsFunction::get_string 213 ns 213 ns 3203868 +bm_rtl::method_____CallsMethod::get_string 214 ns 214 ns 3273507 -RtlFunction_call_ReturnUnknown::NonVoid 886 ns 886 ns 792012 -RtlFunction_callMethod_ReturnUnknown::NonVoid 888 ns 888 ns 787808 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 895 ns 895 ns 780923 +bm_rtl::function_ErasedReturnType::get_string 220 ns 220 ns 3105014 +bm_rtl::method___ErasedReturnType::get_string 222 ns 222 ns 3154485 +bm_rtl::method___ErasedTargetType::get_string 214 ns 214 ns 3149977 +bm_rtl::method___ErasedTargetAndReturnType::get_string 224 ns 224 ns 3085534 ----------------------------------- -[2025-10-09 22:32:12] >>> Run 2: workload scale = 40 +[2025-10-25 08:22:18] >>> Run 2: workload scale = 10 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 40 iterations +Scale : 10 iterations ============================================= -2025-10-09T22:32:12+05:30 +2025-10-25T08:22:18+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4442.84 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.09, 1.07, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 767 ns 767 ns 911387 +Load Average: 1.75, 1.03, 0.50 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 168 ns 168 ns 3978102 -NativeFunctionPtr_call::returnVoid 769 ns 769 ns 907143 -NativeFunctionPtr_callMethod::returnVoid 771 ns 771 ns 912114 +bm_call::by_FunctionPtr_Function::set_string 168 ns 168 ns 4051326 +bm_call::by_FunctionPtr___Method::set_string 168 ns 168 ns 4156354 -StdFunction_call::returnVoid 768 ns 767 ns 907714 -StdFunction_callMethod::returnVoid 773 ns 773 ns 904032 +bm_std::function_CallsFunction::set_string 166 ns 166 ns 4053881 +bm_std::function___CallsMethod::set_string 168 ns 168 ns 4052544 -RtlFunction_call::returnVoid 771 ns 771 ns 907825 -RtlFunction_callMethod::returnVoid 770 ns 770 ns 910243 +bm_rtl::function_CallsFunction::set_string 165 ns 165 ns 4085161 +bm_rtl::method_____CallsMethod::set_string 166 ns 166 ns 4101420 -RtlFunction_call_ReturnUnknown::Void 776 ns 776 ns 905365 -RtlFunction_callMethod_ReturnUnknown::Void 783 ns 783 ns 891957 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 783 ns 783 ns 894958 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 898 ns 898 ns 783301 +bm_rtl::function_ErasedReturnType::set_string 171 ns 171 ns 3969963 +bm_rtl::method___ErasedReturnType::set_string 170 ns 170 ns 3995007 +bm_rtl::method___ErasedTargetType::set_string 170 ns 170 ns 3985711 +bm_rtl::method___ErasedTargetAndReturnType::set_string 169 ns 169 ns 4067461 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 213 ns 213 ns 3277607 -NativeFunctionPtr_call::returnNonVoid 898 ns 898 ns 780964 -NativeFunctionPtr_callMethod::returnNonVoid 900 ns 900 ns 782415 +bm_call::by_FunctionPtr_Function::get_string 215 ns 215 ns 3201902 +bm_call::by_FunctionPtr___Method::get_string 212 ns 212 ns 2962783 -StdFunction_call::returnNonVoid 899 ns 899 ns 774099 -StdFunction_callMethod::returnNonVoid 904 ns 904 ns 776048 +bm_std::function_CallsFunction::get_string 211 ns 211 ns 3245056 +bm_std::function___CallsMethod::get_string 216 ns 216 ns 3297880 -RtlFunction_call::returnNonVoid 900 ns 900 ns 775668 -RtlFunction_callMethod::returnNonVoid 900 ns 900 ns 781529 +bm_rtl::function_CallsFunction::get_string 212 ns 212 ns 3128085 +bm_rtl::method_____CallsMethod::get_string 216 ns 216 ns 3176378 -RtlFunction_call_ReturnUnknown::NonVoid 920 ns 920 ns 762014 -RtlFunction_callMethod_ReturnUnknown::NonVoid 918 ns 918 ns 762473 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 918 ns 918 ns 761633 +bm_rtl::function_ErasedReturnType::get_string 221 ns 221 ns 3122756 +bm_rtl::method___ErasedReturnType::get_string 222 ns 222 ns 3115933 +bm_rtl::method___ErasedTargetType::get_string 218 ns 218 ns 3137484 +bm_rtl::method___ErasedTargetAndReturnType::get_string 224 ns 224 ns 3070469 ----------------------------------- -[2025-10-09 22:32:28] >>> Run 3: workload scale = 40 +[2025-10-25 08:22:38] >>> Run 3: workload scale = 10 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 40 iterations +Scale : 10 iterations ============================================= -2025-10-09T22:32:28+05:30 +2025-10-25T08:22:38+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4020.04 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.07, 1.06, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 774 ns 774 ns 904501 +Load Average: 1.68, 1.06, 0.52 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 167 ns 167 ns 4001035 -NativeFunctionPtr_call::returnVoid 782 ns 782 ns 893850 -NativeFunctionPtr_callMethod::returnVoid 782 ns 782 ns 897541 +bm_call::by_FunctionPtr_Function::set_string 166 ns 166 ns 4080216 +bm_call::by_FunctionPtr___Method::set_string 167 ns 167 ns 4190485 -StdFunction_call::returnVoid 782 ns 782 ns 884219 -StdFunction_callMethod::returnVoid 771 ns 771 ns 905848 +bm_std::function_CallsFunction::set_string 166 ns 166 ns 4129880 +bm_std::function___CallsMethod::set_string 167 ns 167 ns 4222833 -RtlFunction_call::returnVoid 783 ns 783 ns 897668 -RtlFunction_callMethod::returnVoid 781 ns 781 ns 895090 +bm_rtl::function_CallsFunction::set_string 168 ns 168 ns 4095875 +bm_rtl::method_____CallsMethod::set_string 168 ns 168 ns 3969292 -RtlFunction_call_ReturnUnknown::Void 780 ns 780 ns 898020 -RtlFunction_callMethod_ReturnUnknown::Void 785 ns 785 ns 895232 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 790 ns 790 ns 886672 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 902 ns 902 ns 777862 +bm_rtl::function_ErasedReturnType::set_string 169 ns 169 ns 4020936 +bm_rtl::method___ErasedReturnType::set_string 169 ns 169 ns 3922265 +bm_rtl::method___ErasedTargetType::set_string 170 ns 170 ns 4018842 +bm_rtl::method___ErasedTargetAndReturnType::set_string 172 ns 172 ns 3928258 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 217 ns 217 ns 3194965 -NativeFunctionPtr_call::returnNonVoid 906 ns 906 ns 771483 -NativeFunctionPtr_callMethod::returnNonVoid 909 ns 908 ns 770677 +bm_call::by_FunctionPtr_Function::get_string 212 ns 212 ns 3253014 +bm_call::by_FunctionPtr___Method::get_string 215 ns 215 ns 3220321 -StdFunction_call::returnNonVoid 910 ns 910 ns 771651 -StdFunction_callMethod::returnNonVoid 896 ns 896 ns 781756 +bm_std::function_CallsFunction::get_string 213 ns 213 ns 3164498 +bm_std::function___CallsMethod::get_string 216 ns 216 ns 3260806 -RtlFunction_call::returnNonVoid 907 ns 907 ns 772768 -RtlFunction_callMethod::returnNonVoid 905 ns 905 ns 765665 +bm_rtl::function_CallsFunction::get_string 211 ns 211 ns 3206234 +bm_rtl::method_____CallsMethod::get_string 216 ns 216 ns 3279560 -RtlFunction_call_ReturnUnknown::NonVoid 911 ns 911 ns 766856 -RtlFunction_callMethod_ReturnUnknown::NonVoid 919 ns 919 ns 765357 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 916 ns 916 ns 764862 +bm_rtl::function_ErasedReturnType::get_string 221 ns 221 ns 3067409 +bm_rtl::method___ErasedReturnType::get_string 222 ns 222 ns 3161991 +bm_rtl::method___ErasedTargetType::get_string 215 ns 215 ns 3267470 +bm_rtl::method___ErasedTargetAndReturnType::get_string 224 ns 224 ns 3170448 ----------------------------------- -[2025-10-09 22:32:44] >>> Run 4: workload scale = 40 +[2025-10-25 08:22:58] >>> Run 1: workload scale = 15 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 40 iterations +Scale : 15 iterations ============================================= -2025-10-09T22:32:44+05:30 +2025-10-25T08:22:58+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4363.94 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.05, 1.06, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 759 ns 759 ns 923624 +Load Average: 1.49, 1.06, 0.53 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 199 ns 199 ns 3361772 -NativeFunctionPtr_call::returnVoid 760 ns 760 ns 921711 -NativeFunctionPtr_callMethod::returnVoid 761 ns 761 ns 917719 +bm_call::by_FunctionPtr_Function::set_string 200 ns 200 ns 3530667 +bm_call::by_FunctionPtr___Method::set_string 198 ns 198 ns 3398436 -StdFunction_call::returnVoid 756 ns 755 ns 920127 -StdFunction_callMethod::returnVoid 760 ns 760 ns 924480 +bm_std::function_CallsFunction::set_string 200 ns 200 ns 3366241 +bm_std::function___CallsMethod::set_string 201 ns 201 ns 3421104 -RtlFunction_call::returnVoid 760 ns 760 ns 921583 -RtlFunction_callMethod::returnVoid 762 ns 762 ns 917381 +bm_rtl::function_CallsFunction::set_string 196 ns 196 ns 3494923 +bm_rtl::method_____CallsMethod::set_string 200 ns 200 ns 3446454 -RtlFunction_call_ReturnUnknown::Void 771 ns 771 ns 904689 -RtlFunction_callMethod_ReturnUnknown::Void 769 ns 769 ns 910101 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 770 ns 770 ns 909102 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 868 ns 868 ns 807221 +bm_rtl::function_ErasedReturnType::set_string 205 ns 205 ns 3356999 +bm_rtl::method___ErasedReturnType::set_string 201 ns 201 ns 3478117 +bm_rtl::method___ErasedTargetType::set_string 207 ns 207 ns 3352277 +bm_rtl::method___ErasedTargetAndReturnType::set_string 204 ns 204 ns 3373659 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 260 ns 260 ns 2664406 -NativeFunctionPtr_call::returnNonVoid 868 ns 868 ns 805695 -NativeFunctionPtr_callMethod::returnNonVoid 868 ns 867 ns 803711 +bm_call::by_FunctionPtr_Function::get_string 262 ns 262 ns 2695726 +bm_call::by_FunctionPtr___Method::get_string 264 ns 264 ns 2634217 -StdFunction_call::returnNonVoid 866 ns 866 ns 806829 -StdFunction_callMethod::returnNonVoid 869 ns 869 ns 803810 +bm_std::function_CallsFunction::get_string 265 ns 265 ns 2651289 +bm_std::function___CallsMethod::get_string 267 ns 267 ns 2593115 -RtlFunction_call::returnNonVoid 867 ns 867 ns 804933 -RtlFunction_callMethod::returnNonVoid 868 ns 867 ns 805070 +bm_rtl::function_CallsFunction::get_string 263 ns 263 ns 2621767 +bm_rtl::method_____CallsMethod::get_string 262 ns 262 ns 2635351 -RtlFunction_call_ReturnUnknown::NonVoid 885 ns 885 ns 789841 -RtlFunction_callMethod_ReturnUnknown::NonVoid 885 ns 885 ns 790502 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 883 ns 883 ns 793804 +bm_rtl::function_ErasedReturnType::get_string 266 ns 266 ns 2598312 +bm_rtl::method___ErasedReturnType::get_string 266 ns 266 ns 2631091 +bm_rtl::method___ErasedTargetType::get_string 264 ns 264 ns 2622779 +bm_rtl::method___ErasedTargetAndReturnType::get_string 267 ns 267 ns 2585988 ----------------------------------- -[2025-10-09 22:33:00] >>> Run 5: workload scale = 40 +[2025-10-25 08:23:19] >>> Run 2: workload scale = 15 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 40 iterations +Scale : 15 iterations ============================================= -2025-10-09T22:33:00+05:30 +2025-10-25T08:23:19+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3406.12 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.04, 1.05, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 754 ns 754 ns 927477 +Load Average: 1.38, 1.07, 0.55 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 228 ns 228 ns 3011429 -NativeFunctionPtr_call::returnVoid 755 ns 755 ns 930677 -NativeFunctionPtr_callMethod::returnVoid 755 ns 755 ns 929205 +bm_call::by_FunctionPtr_Function::set_string 210 ns 210 ns 3332108 +bm_call::by_FunctionPtr___Method::set_string 209 ns 209 ns 3292897 -StdFunction_call::returnVoid 750 ns 750 ns 931061 -StdFunction_callMethod::returnVoid 756 ns 756 ns 925171 +bm_std::function_CallsFunction::set_string 209 ns 209 ns 3315961 +bm_std::function___CallsMethod::set_string 200 ns 200 ns 3503400 -RtlFunction_call::returnVoid 753 ns 753 ns 930525 -RtlFunction_callMethod::returnVoid 755 ns 755 ns 925200 +bm_rtl::function_CallsFunction::set_string 212 ns 212 ns 3332068 +bm_rtl::method_____CallsMethod::set_string 210 ns 210 ns 3232850 -RtlFunction_call_ReturnUnknown::Void 766 ns 766 ns 913707 -RtlFunction_callMethod_ReturnUnknown::Void 763 ns 763 ns 913366 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 771 ns 771 ns 910654 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 860 ns 860 ns 814438 +bm_rtl::function_ErasedReturnType::set_string 202 ns 202 ns 3360085 +bm_rtl::method___ErasedReturnType::set_string 202 ns 202 ns 3416690 +bm_rtl::method___ErasedTargetType::set_string 199 ns 199 ns 3342178 +bm_rtl::method___ErasedTargetAndReturnType::set_string 205 ns 205 ns 3372374 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 312 ns 312 ns 2380574 -NativeFunctionPtr_call::returnNonVoid 860 ns 860 ns 817263 -NativeFunctionPtr_callMethod::returnNonVoid 859 ns 859 ns 814168 +bm_call::by_FunctionPtr_Function::get_string 304 ns 304 ns 2248341 +bm_call::by_FunctionPtr___Method::get_string 305 ns 305 ns 2263551 -StdFunction_call::returnNonVoid 859 ns 859 ns 814257 -StdFunction_callMethod::returnNonVoid 858 ns 858 ns 813961 +bm_std::function_CallsFunction::get_string 272 ns 272 ns 2555796 +bm_std::function___CallsMethod::get_string 258 ns 258 ns 2690258 -RtlFunction_call::returnNonVoid 859 ns 859 ns 813742 -RtlFunction_callMethod::returnNonVoid 859 ns 859 ns 818402 +bm_rtl::function_CallsFunction::get_string 268 ns 268 ns 2603528 +bm_rtl::method_____CallsMethod::get_string 270 ns 270 ns 2558733 -RtlFunction_call_ReturnUnknown::NonVoid 886 ns 886 ns 787918 -RtlFunction_callMethod_ReturnUnknown::NonVoid 887 ns 887 ns 790058 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 888 ns 888 ns 785851 +bm_rtl::function_ErasedReturnType::get_string 267 ns 267 ns 2585635 +bm_rtl::method___ErasedReturnType::get_string 263 ns 263 ns 2639753 +bm_rtl::method___ErasedTargetType::get_string 258 ns 258 ns 2633615 +bm_rtl::method___ErasedTargetAndReturnType::get_string 267 ns 267 ns 2577062 ----------------------------------- -[2025-10-09 22:33:16] >>> Run 1: workload scale = 45 +[2025-10-25 08:23:40] >>> Run 3: workload scale = 15 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 45 iterations +Scale : 15 iterations ============================================= -2025-10-09T22:33:16+05:30 +2025-10-25T08:23:40+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 1259.19 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.03, 1.05, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 866 ns 866 ns 809157 +Load Average: 1.41, 1.10, 0.57 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 198 ns 198 ns 3489418 -NativeFunctionPtr_call::returnVoid 869 ns 869 ns 804129 -NativeFunctionPtr_callMethod::returnVoid 868 ns 868 ns 808091 +bm_call::by_FunctionPtr_Function::set_string 198 ns 198 ns 3495888 +bm_call::by_FunctionPtr___Method::set_string 203 ns 203 ns 3450549 -StdFunction_call::returnVoid 869 ns 869 ns 804521 -StdFunction_callMethod::returnVoid 867 ns 867 ns 805994 +bm_std::function_CallsFunction::set_string 198 ns 198 ns 3432590 +bm_std::function___CallsMethod::set_string 200 ns 200 ns 3518722 -RtlFunction_call::returnVoid 868 ns 868 ns 806034 -RtlFunction_callMethod::returnVoid 869 ns 869 ns 805939 +bm_rtl::function_CallsFunction::set_string 196 ns 196 ns 3513293 +bm_rtl::method_____CallsMethod::set_string 199 ns 199 ns 3470396 -RtlFunction_call_ReturnUnknown::Void 866 ns 866 ns 808584 -RtlFunction_callMethod_ReturnUnknown::Void 871 ns 871 ns 802708 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 877 ns 877 ns 800314 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1012 ns 1012 ns 693687 +bm_rtl::function_ErasedReturnType::set_string 202 ns 202 ns 3415664 +bm_rtl::method___ErasedReturnType::set_string 203 ns 203 ns 3428745 +bm_rtl::method___ErasedTargetType::set_string 205 ns 205 ns 3356545 +bm_rtl::method___ErasedTargetAndReturnType::set_string 226 ns 226 ns 3047738 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 300 ns 300 ns 2316121 -NativeFunctionPtr_call::returnNonVoid 1014 ns 1014 ns 691382 -NativeFunctionPtr_callMethod::returnNonVoid 1011 ns 1011 ns 692979 +bm_call::by_FunctionPtr_Function::get_string 304 ns 304 ns 2291577 +bm_call::by_FunctionPtr___Method::get_string 304 ns 304 ns 2295085 -StdFunction_call::returnNonVoid 1013 ns 1013 ns 690350 -StdFunction_callMethod::returnNonVoid 1012 ns 1012 ns 691672 +bm_std::function_CallsFunction::get_string 299 ns 299 ns 2281782 +bm_std::function___CallsMethod::get_string 283 ns 283 ns 2318211 -RtlFunction_call::returnNonVoid 1014 ns 1014 ns 691463 -RtlFunction_callMethod::returnNonVoid 1011 ns 1011 ns 694030 +bm_rtl::function_CallsFunction::get_string 254 ns 254 ns 2666980 +bm_rtl::method_____CallsMethod::get_string 256 ns 256 ns 2707601 -RtlFunction_call_ReturnUnknown::NonVoid 1027 ns 1027 ns 682217 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1029 ns 1029 ns 679886 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1036 ns 1036 ns 675673 +bm_rtl::function_ErasedReturnType::get_string 263 ns 263 ns 2628819 +bm_rtl::method___ErasedReturnType::get_string 263 ns 263 ns 2619550 +bm_rtl::method___ErasedTargetType::get_string 256 ns 256 ns 2732110 +bm_rtl::method___ErasedTargetAndReturnType::get_string 265 ns 265 ns 2670969 ----------------------------------- -[2025-10-09 22:33:32] >>> Run 2: workload scale = 45 +[2025-10-25 08:24:01] >>> Run 1: workload scale = 20 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 45 iterations +Scale : 20 iterations ============================================= -2025-10-09T22:33:32+05:30 +2025-10-25T08:24:01+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3905.37 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.02, 1.05, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 828 ns 828 ns 844001 +Load Average: 1.52, 1.14, 0.60 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 283 ns 283 ns 2501203 -NativeFunctionPtr_call::returnVoid 834 ns 834 ns 840215 -NativeFunctionPtr_callMethod::returnVoid 834 ns 834 ns 837732 +bm_call::by_FunctionPtr_Function::set_string 282 ns 281 ns 2459533 +bm_call::by_FunctionPtr___Method::set_string 284 ns 284 ns 2450814 -StdFunction_call::returnVoid 835 ns 835 ns 838406 -StdFunction_callMethod::returnVoid 832 ns 832 ns 842586 +bm_std::function_CallsFunction::set_string 281 ns 281 ns 2453704 +bm_std::function___CallsMethod::set_string 277 ns 277 ns 2518160 -RtlFunction_call::returnVoid 833 ns 833 ns 840219 -RtlFunction_callMethod::returnVoid 835 ns 834 ns 839874 +bm_rtl::function_CallsFunction::set_string 281 ns 281 ns 2522655 +bm_rtl::method_____CallsMethod::set_string 282 ns 282 ns 2437387 -RtlFunction_call_ReturnUnknown::Void 834 ns 834 ns 837088 -RtlFunction_callMethod_ReturnUnknown::Void 834 ns 834 ns 836092 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 852 ns 852 ns 820915 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 990 ns 990 ns 706808 +bm_rtl::function_ErasedReturnType::set_string 282 ns 282 ns 2416455 +bm_rtl::method___ErasedReturnType::set_string 283 ns 283 ns 2505911 +bm_rtl::method___ErasedTargetType::set_string 276 ns 276 ns 2455881 +bm_rtl::method___ErasedTargetAndReturnType::set_string 282 ns 282 ns 2461023 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 388 ns 388 ns 1810444 -NativeFunctionPtr_call::returnNonVoid 992 ns 992 ns 706543 -NativeFunctionPtr_callMethod::returnNonVoid 991 ns 991 ns 706313 +bm_call::by_FunctionPtr_Function::get_string 401 ns 401 ns 1743086 +bm_call::by_FunctionPtr___Method::get_string 403 ns 403 ns 1771226 -StdFunction_call::returnNonVoid 991 ns 991 ns 705794 -StdFunction_callMethod::returnNonVoid 995 ns 995 ns 703058 +bm_std::function_CallsFunction::get_string 402 ns 402 ns 1777319 +bm_std::function___CallsMethod::get_string 402 ns 402 ns 1771757 -RtlFunction_call::returnNonVoid 992 ns 992 ns 705367 -RtlFunction_callMethod::returnNonVoid 992 ns 991 ns 705893 +bm_rtl::function_CallsFunction::get_string 395 ns 395 ns 1754995 +bm_rtl::method_____CallsMethod::get_string 405 ns 405 ns 1756312 -RtlFunction_call_ReturnUnknown::NonVoid 1013 ns 1013 ns 690644 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1014 ns 1014 ns 689561 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1017 ns 1017 ns 688660 +bm_rtl::function_ErasedReturnType::get_string 466 ns 466 ns 1693433 +bm_rtl::method___ErasedReturnType::get_string 479 ns 479 ns 1483174 +bm_rtl::method___ErasedTargetType::get_string 456 ns 456 ns 1527682 +bm_rtl::method___ErasedTargetAndReturnType::get_string 481 ns 481 ns 1479821 ----------------------------------- -[2025-10-09 22:33:48] >>> Run 3: workload scale = 45 +[2025-10-25 08:24:25] >>> Run 2: workload scale = 20 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 45 iterations +Scale : 20 iterations ============================================= -2025-10-09T22:33:48+05:30 +2025-10-25T08:24:25+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4492.67 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.02, 1.04, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 834 ns 834 ns 837333 +Load Average: 1.65, 1.21, 0.64 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 285 ns 285 ns 2441453 -NativeFunctionPtr_call::returnVoid 840 ns 840 ns 836001 -NativeFunctionPtr_callMethod::returnVoid 836 ns 836 ns 836723 +bm_call::by_FunctionPtr_Function::set_string 309 ns 309 ns 2241751 +bm_call::by_FunctionPtr___Method::set_string 284 ns 284 ns 2406971 -StdFunction_call::returnVoid 836 ns 836 ns 837552 -StdFunction_callMethod::returnVoid 844 ns 844 ns 828047 +bm_std::function_CallsFunction::set_string 282 ns 282 ns 2456674 +bm_std::function___CallsMethod::set_string 279 ns 279 ns 2435726 -RtlFunction_call::returnVoid 837 ns 837 ns 836533 -RtlFunction_callMethod::returnVoid 837 ns 837 ns 835148 +bm_rtl::function_CallsFunction::set_string 282 ns 282 ns 2435486 +bm_rtl::method_____CallsMethod::set_string 283 ns 283 ns 2499768 -RtlFunction_call_ReturnUnknown::Void 840 ns 840 ns 832909 -RtlFunction_callMethod_ReturnUnknown::Void 850 ns 850 ns 821781 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 861 ns 861 ns 812181 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 992 ns 992 ns 706173 +bm_rtl::function_ErasedReturnType::set_string 313 ns 313 ns 2216865 +bm_rtl::method___ErasedReturnType::set_string 319 ns 319 ns 2214151 +bm_rtl::method___ErasedTargetType::set_string 284 ns 284 ns 2405765 +bm_rtl::method___ErasedTargetAndReturnType::set_string 321 ns 321 ns 2262805 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 455 ns 455 ns 1553877 -NativeFunctionPtr_call::returnNonVoid 998 ns 998 ns 702016 -NativeFunctionPtr_callMethod::returnNonVoid 998 ns 998 ns 702496 +bm_call::by_FunctionPtr_Function::get_string 460 ns 460 ns 1551413 +bm_call::by_FunctionPtr___Method::get_string 455 ns 455 ns 1551524 -StdFunction_call::returnNonVoid 998 ns 998 ns 702002 -StdFunction_callMethod::returnNonVoid 999 ns 999 ns 702186 +bm_std::function_CallsFunction::get_string 451 ns 451 ns 1539290 +bm_std::function___CallsMethod::get_string 461 ns 461 ns 1547633 -RtlFunction_call::returnNonVoid 998 ns 998 ns 701652 -RtlFunction_callMethod::returnNonVoid 999 ns 999 ns 701933 +bm_rtl::function_CallsFunction::get_string 455 ns 455 ns 1552175 +bm_rtl::method_____CallsMethod::get_string 454 ns 454 ns 1554256 -RtlFunction_call_ReturnUnknown::NonVoid 1022 ns 1022 ns 683428 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1015 ns 1015 ns 689908 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1023 ns 1023 ns 684003 +bm_rtl::function_ErasedReturnType::get_string 484 ns 484 ns 1475111 +bm_rtl::method___ErasedReturnType::get_string 484 ns 484 ns 1470290 +bm_rtl::method___ErasedTargetType::get_string 455 ns 455 ns 1533822 +bm_rtl::method___ErasedTargetAndReturnType::get_string 471 ns 471 ns 1484570 ----------------------------------- -[2025-10-09 22:34:04] >>> Run 4: workload scale = 45 +[2025-10-25 08:24:50] >>> Run 3: workload scale = 20 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 45 iterations +Scale : 20 iterations ============================================= -2025-10-09T22:34:04+05:30 +2025-10-25T08:24:50+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3892.7 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.01, 1.04, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 860 ns 860 ns 811771 +Load Average: 1.69, 1.25, 0.67 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 310 ns 310 ns 2264442 -NativeFunctionPtr_call::returnVoid 861 ns 861 ns 811896 -NativeFunctionPtr_callMethod::returnVoid 862 ns 862 ns 809499 +bm_call::by_FunctionPtr_Function::set_string 311 ns 311 ns 2202797 +bm_call::by_FunctionPtr___Method::set_string 281 ns 281 ns 2449804 -StdFunction_call::returnVoid 863 ns 863 ns 810522 -StdFunction_callMethod::returnVoid 870 ns 869 ns 804066 +bm_std::function_CallsFunction::set_string 278 ns 278 ns 2446273 +bm_std::function___CallsMethod::set_string 279 ns 279 ns 2471984 -RtlFunction_call::returnVoid 863 ns 863 ns 813219 -RtlFunction_callMethod::returnVoid 863 ns 863 ns 812608 +bm_rtl::function_CallsFunction::set_string 277 ns 277 ns 2481374 +bm_rtl::method_____CallsMethod::set_string 281 ns 281 ns 2518203 -RtlFunction_call_ReturnUnknown::Void 859 ns 859 ns 813712 -RtlFunction_callMethod_ReturnUnknown::Void 876 ns 876 ns 799429 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 881 ns 881 ns 795613 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1007 ns 1007 ns 696038 +bm_rtl::function_ErasedReturnType::set_string 277 ns 277 ns 2462013 +bm_rtl::method___ErasedReturnType::set_string 283 ns 283 ns 2524713 +bm_rtl::method___ErasedTargetType::set_string 283 ns 283 ns 2456834 +bm_rtl::method___ErasedTargetAndReturnType::set_string 284 ns 284 ns 2438519 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 447 ns 447 ns 1576527 -NativeFunctionPtr_call::returnNonVoid 1013 ns 1013 ns 691469 -NativeFunctionPtr_callMethod::returnNonVoid 1011 ns 1011 ns 691744 +bm_call::by_FunctionPtr_Function::get_string 457 ns 457 ns 1563160 +bm_call::by_FunctionPtr___Method::get_string 459 ns 459 ns 1545299 -StdFunction_call::returnNonVoid 1015 ns 1015 ns 690018 -StdFunction_callMethod::returnNonVoid 1011 ns 1011 ns 692145 +bm_std::function_CallsFunction::get_string 413 ns 413 ns 1546368 +bm_std::function___CallsMethod::get_string 394 ns 394 ns 1756190 -RtlFunction_call::returnNonVoid 1012 ns 1012 ns 692785 -RtlFunction_callMethod::returnNonVoid 1010 ns 1010 ns 692879 +bm_rtl::function_CallsFunction::get_string 403 ns 403 ns 1764987 +bm_rtl::method_____CallsMethod::get_string 403 ns 403 ns 1792886 -RtlFunction_call_ReturnUnknown::NonVoid 1031 ns 1031 ns 679524 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1024 ns 1023 ns 683812 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1032 ns 1032 ns 678159 +bm_rtl::function_ErasedReturnType::get_string 421 ns 421 ns 1688043 +bm_rtl::method___ErasedReturnType::get_string 422 ns 422 ns 1684851 +bm_rtl::method___ErasedTargetType::get_string 409 ns 409 ns 1757196 +bm_rtl::method___ErasedTargetAndReturnType::get_string 425 ns 425 ns 1666642 ----------------------------------- -[2025-10-09 22:34:20] >>> Run 5: workload scale = 45 +[2025-10-25 08:25:14] >>> Run 1: workload scale = 25 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 45 iterations +Scale : 25 iterations ============================================= -2025-10-09T22:34:20+05:30 +2025-10-25T08:25:14+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 1952.85 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.01, 1.04, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 840 ns 840 ns 832360 +Load Average: 1.46, 1.23, 0.68 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 325 ns 325 ns 2129647 -NativeFunctionPtr_call::returnVoid 844 ns 844 ns 830015 -NativeFunctionPtr_callMethod::returnVoid 845 ns 845 ns 829703 +bm_call::by_FunctionPtr_Function::set_string 325 ns 325 ns 2170705 +bm_call::by_FunctionPtr___Method::set_string 320 ns 320 ns 2157738 -StdFunction_call::returnVoid 845 ns 845 ns 829638 -StdFunction_callMethod::returnVoid 840 ns 840 ns 835607 +bm_std::function_CallsFunction::set_string 323 ns 323 ns 2157761 +bm_std::function___CallsMethod::set_string 326 ns 326 ns 2155660 -RtlFunction_call::returnVoid 844 ns 844 ns 826581 -RtlFunction_callMethod::returnVoid 844 ns 844 ns 829324 +bm_rtl::function_CallsFunction::set_string 320 ns 320 ns 2164697 +bm_rtl::method_____CallsMethod::set_string 324 ns 324 ns 2153530 -RtlFunction_call_ReturnUnknown::Void 837 ns 837 ns 834891 -RtlFunction_callMethod_ReturnUnknown::Void 844 ns 844 ns 829558 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 855 ns 855 ns 820735 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 968 ns 968 ns 722959 +bm_rtl::function_ErasedReturnType::set_string 337 ns 337 ns 2059035 +bm_rtl::method___ErasedReturnType::set_string 335 ns 335 ns 2102518 +bm_rtl::method___ErasedTargetType::set_string 330 ns 330 ns 2092067 +bm_rtl::method___ErasedTargetAndReturnType::set_string 341 ns 341 ns 2100353 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 522 ns 522 ns 1333442 -NativeFunctionPtr_call::returnNonVoid 972 ns 972 ns 721065 -NativeFunctionPtr_callMethod::returnNonVoid 972 ns 972 ns 720746 +bm_call::by_FunctionPtr_Function::get_string 518 ns 518 ns 1335447 +bm_call::by_FunctionPtr___Method::get_string 524 ns 524 ns 1267263 -StdFunction_call::returnNonVoid 972 ns 972 ns 720795 -StdFunction_callMethod::returnNonVoid 967 ns 967 ns 723954 +bm_std::function_CallsFunction::get_string 519 ns 519 ns 1265282 +bm_std::function___CallsMethod::get_string 518 ns 518 ns 1272629 -RtlFunction_call::returnNonVoid 971 ns 971 ns 719967 -RtlFunction_callMethod::returnNonVoid 972 ns 972 ns 720005 +bm_rtl::function_CallsFunction::get_string 522 ns 522 ns 1278100 +bm_rtl::method_____CallsMethod::get_string 476 ns 476 ns 1516375 -RtlFunction_call_ReturnUnknown::NonVoid 987 ns 987 ns 709286 -RtlFunction_callMethod_ReturnUnknown::NonVoid 980 ns 980 ns 715900 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 989 ns 988 ns 708690 +bm_rtl::function_ErasedReturnType::get_string 486 ns 486 ns 1389634 +bm_rtl::method___ErasedReturnType::get_string 485 ns 485 ns 1363658 +bm_rtl::method___ErasedTargetType::get_string 464 ns 464 ns 1509898 +bm_rtl::method___ErasedTargetAndReturnType::get_string 496 ns 496 ns 1437235 ----------------------------------- -[2025-10-09 22:34:36] >>> Run 1: workload scale = 50 +[2025-10-25 08:25:35] >>> Run 2: workload scale = 25 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 50 iterations +Scale : 25 iterations ============================================= -2025-10-09T22:34:36+05:30 +2025-10-25T08:25:35+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 968.875 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.01, 1.04, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 925 ns 925 ns 756744 +Load Average: 1.54, 1.27, 0.70 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 320 ns 320 ns 2208206 -NativeFunctionPtr_call::returnVoid 924 ns 924 ns 757546 -NativeFunctionPtr_callMethod::returnVoid 925 ns 925 ns 756714 +bm_call::by_FunctionPtr_Function::set_string 319 ns 319 ns 2195587 +bm_call::by_FunctionPtr___Method::set_string 309 ns 309 ns 2208978 -StdFunction_call::returnVoid 925 ns 925 ns 757808 -StdFunction_callMethod::returnVoid 928 ns 928 ns 756162 +bm_std::function_CallsFunction::set_string 321 ns 321 ns 2250497 +bm_std::function___CallsMethod::set_string 317 ns 317 ns 2213322 -RtlFunction_call::returnVoid 923 ns 923 ns 758543 -RtlFunction_callMethod::returnVoid 925 ns 925 ns 756594 +bm_rtl::function_CallsFunction::set_string 312 ns 312 ns 2217980 +bm_rtl::method_____CallsMethod::set_string 316 ns 316 ns 2221718 -RtlFunction_call_ReturnUnknown::Void 933 ns 933 ns 749852 -RtlFunction_callMethod_ReturnUnknown::Void 927 ns 927 ns 754843 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 938 ns 938 ns 746632 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1056 ns 1056 ns 660848 +bm_rtl::function_ErasedReturnType::set_string 320 ns 320 ns 2185990 +bm_rtl::method___ErasedReturnType::set_string 319 ns 319 ns 2169884 +bm_rtl::method___ErasedTargetType::set_string 320 ns 320 ns 2173336 +bm_rtl::method___ErasedTargetAndReturnType::set_string 321 ns 321 ns 2165718 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 470 ns 470 ns 1523263 -NativeFunctionPtr_call::returnNonVoid 1054 ns 1054 ns 663610 -NativeFunctionPtr_callMethod::returnNonVoid 1053 ns 1053 ns 664580 +bm_call::by_FunctionPtr_Function::get_string 471 ns 471 ns 1517079 +bm_call::by_FunctionPtr___Method::get_string 467 ns 467 ns 1527828 -StdFunction_call::returnNonVoid 1055 ns 1055 ns 661895 -StdFunction_callMethod::returnNonVoid 1055 ns 1055 ns 662731 +bm_std::function_CallsFunction::get_string 471 ns 471 ns 1527036 +bm_std::function___CallsMethod::get_string 476 ns 476 ns 1503885 -RtlFunction_call::returnNonVoid 1054 ns 1054 ns 664913 -RtlFunction_callMethod::returnNonVoid 1055 ns 1055 ns 664932 +bm_rtl::function_CallsFunction::get_string 476 ns 476 ns 1508360 +bm_rtl::method_____CallsMethod::get_string 473 ns 473 ns 1510504 -RtlFunction_call_ReturnUnknown::NonVoid 1084 ns 1084 ns 645326 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1085 ns 1085 ns 644799 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1085 ns 1084 ns 645482 +bm_rtl::function_ErasedReturnType::get_string 481 ns 481 ns 1372771 +bm_rtl::method___ErasedReturnType::get_string 478 ns 478 ns 1472287 +bm_rtl::method___ErasedTargetType::get_string 481 ns 481 ns 1484371 +bm_rtl::method___ErasedTargetAndReturnType::get_string 483 ns 483 ns 1390696 ----------------------------------- -[2025-10-09 22:34:52] >>> Run 2: workload scale = 50 +[2025-10-25 08:25:59] >>> Run 3: workload scale = 25 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 50 iterations +Scale : 25 iterations ============================================= -2025-10-09T22:34:52+05:30 +2025-10-25T08:25:59+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4691.33 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.03, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 907 ns 907 ns 771423 +Load Average: 1.68, 1.32, 0.74 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 322 ns 322 ns 2178890 -NativeFunctionPtr_call::returnVoid 911 ns 911 ns 769454 -NativeFunctionPtr_callMethod::returnVoid 911 ns 910 ns 768672 +bm_call::by_FunctionPtr_Function::set_string 323 ns 323 ns 2180391 +bm_call::by_FunctionPtr___Method::set_string 322 ns 322 ns 2181922 -StdFunction_call::returnVoid 909 ns 909 ns 769736 -StdFunction_callMethod::returnVoid 910 ns 910 ns 769969 +bm_std::function_CallsFunction::set_string 321 ns 321 ns 2173138 +bm_std::function___CallsMethod::set_string 317 ns 317 ns 2184692 -RtlFunction_call::returnVoid 910 ns 910 ns 767614 -RtlFunction_callMethod::returnVoid 911 ns 911 ns 769431 +bm_rtl::function_CallsFunction::set_string 313 ns 313 ns 2218258 +bm_rtl::method_____CallsMethod::set_string 318 ns 318 ns 2252143 -RtlFunction_call_ReturnUnknown::Void 916 ns 916 ns 765503 -RtlFunction_callMethod_ReturnUnknown::Void 911 ns 911 ns 769526 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 918 ns 918 ns 763819 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1067 ns 1067 ns 656515 +bm_rtl::function_ErasedReturnType::set_string 326 ns 326 ns 2144037 +bm_rtl::method___ErasedReturnType::set_string 326 ns 326 ns 2166888 +bm_rtl::method___ErasedTargetType::set_string 325 ns 325 ns 2129620 +bm_rtl::method___ErasedTargetAndReturnType::set_string 326 ns 326 ns 2128004 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 464 ns 464 ns 1510116 -NativeFunctionPtr_call::returnNonVoid 1071 ns 1071 ns 653572 -NativeFunctionPtr_callMethod::returnNonVoid 1069 ns 1069 ns 654981 +bm_call::by_FunctionPtr_Function::get_string 459 ns 459 ns 1530899 +bm_call::by_FunctionPtr___Method::get_string 460 ns 460 ns 1530126 -StdFunction_call::returnNonVoid 1072 ns 1072 ns 653906 -StdFunction_callMethod::returnNonVoid 1070 ns 1070 ns 654678 +bm_std::function_CallsFunction::get_string 474 ns 474 ns 1511348 +bm_std::function___CallsMethod::get_string 465 ns 465 ns 1515448 -RtlFunction_call::returnNonVoid 1069 ns 1069 ns 654802 -RtlFunction_callMethod::returnNonVoid 1071 ns 1071 ns 654057 +bm_rtl::function_CallsFunction::get_string 470 ns 470 ns 1502887 +bm_rtl::method_____CallsMethod::get_string 469 ns 469 ns 1516318 -RtlFunction_call_ReturnUnknown::NonVoid 1084 ns 1084 ns 645423 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1085 ns 1085 ns 645445 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1086 ns 1086 ns 643595 +bm_rtl::function_ErasedReturnType::get_string 483 ns 483 ns 1473870 +bm_rtl::method___ErasedReturnType::get_string 480 ns 480 ns 1460097 +bm_rtl::method___ErasedTargetType::get_string 469 ns 469 ns 1513756 +bm_rtl::method___ErasedTargetAndReturnType::get_string 497 ns 497 ns 1457855 ----------------------------------- -[2025-10-09 22:35:08] >>> Run 3: workload scale = 50 +[2025-10-25 08:26:24] >>> Run 1: workload scale = 30 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 50 iterations +Scale : 30 iterations ============================================= -2025-10-09T22:35:08+05:30 +2025-10-25T08:26:24+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3140.67 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.03, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 910 ns 910 ns 767785 +Load Average: 1.98, 1.43, 0.79 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 373 ns 373 ns 1909657 -NativeFunctionPtr_call::returnVoid 913 ns 913 ns 767341 -NativeFunctionPtr_callMethod::returnVoid 914 ns 914 ns 767157 +bm_call::by_FunctionPtr_Function::set_string 366 ns 366 ns 1931781 +bm_call::by_FunctionPtr___Method::set_string 361 ns 361 ns 1909844 -StdFunction_call::returnVoid 913 ns 913 ns 767217 -StdFunction_callMethod::returnVoid 916 ns 915 ns 766123 +bm_std::function_CallsFunction::set_string 360 ns 360 ns 1943490 +bm_std::function___CallsMethod::set_string 371 ns 371 ns 1924831 -RtlFunction_call::returnVoid 914 ns 913 ns 767388 -RtlFunction_callMethod::returnVoid 916 ns 916 ns 765652 +bm_rtl::function_CallsFunction::set_string 388 ns 388 ns 1864646 +bm_rtl::method_____CallsMethod::set_string 374 ns 374 ns 1830562 -RtlFunction_call_ReturnUnknown::Void 915 ns 915 ns 766052 -RtlFunction_callMethod_ReturnUnknown::Void 915 ns 914 ns 767732 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 915 ns 915 ns 767030 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1033 ns 1033 ns 677004 +bm_rtl::function_ErasedReturnType::set_string 402 ns 402 ns 1808169 +bm_rtl::method___ErasedReturnType::set_string 418 ns 418 ns 1667832 +bm_rtl::method___ErasedTargetType::set_string 376 ns 376 ns 1916355 +bm_rtl::method___ErasedTargetAndReturnType::set_string 370 ns 370 ns 1907324 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 522 ns 522 ns 1325773 -NativeFunctionPtr_call::returnNonVoid 1039 ns 1039 ns 675264 -NativeFunctionPtr_callMethod::returnNonVoid 1037 ns 1037 ns 675643 +bm_call::by_FunctionPtr_Function::get_string 527 ns 527 ns 1318536 +bm_call::by_FunctionPtr___Method::get_string 527 ns 527 ns 1297988 -StdFunction_call::returnNonVoid 1038 ns 1038 ns 675230 -StdFunction_callMethod::returnNonVoid 1037 ns 1037 ns 675307 +bm_std::function_CallsFunction::get_string 530 ns 530 ns 1315804 +bm_std::function___CallsMethod::get_string 527 ns 527 ns 1303359 -RtlFunction_call::returnNonVoid 1038 ns 1038 ns 672573 -RtlFunction_callMethod::returnNonVoid 1039 ns 1038 ns 674737 +bm_rtl::function_CallsFunction::get_string 525 ns 525 ns 1325287 +bm_rtl::method_____CallsMethod::get_string 526 ns 526 ns 1330457 -RtlFunction_call_ReturnUnknown::NonVoid 1053 ns 1053 ns 664901 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1046 ns 1045 ns 669741 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1047 ns 1046 ns 669072 +bm_rtl::function_ErasedReturnType::get_string 547 ns 547 ns 1272551 +bm_rtl::method___ErasedReturnType::get_string 542 ns 542 ns 1269963 +bm_rtl::method___ErasedTargetType::get_string 532 ns 532 ns 1317687 +bm_rtl::method___ErasedTargetAndReturnType::get_string 547 ns 547 ns 1282806 ----------------------------------- -[2025-10-09 22:35:24] >>> Run 4: workload scale = 50 +[2025-10-25 08:26:45] >>> Run 2: workload scale = 30 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 50 iterations +Scale : 30 iterations ============================================= -2025-10-09T22:35:24+05:30 +2025-10-25T08:26:45+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3432.96 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.03, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 983 ns 982 ns 711381 +Load Average: 1.77, 1.41, 0.80 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 362 ns 362 ns 1945387 -NativeFunctionPtr_call::returnVoid 976 ns 976 ns 717755 -NativeFunctionPtr_callMethod::returnVoid 976 ns 976 ns 717214 +bm_call::by_FunctionPtr_Function::set_string 359 ns 359 ns 1963574 +bm_call::by_FunctionPtr___Method::set_string 360 ns 360 ns 1930130 -StdFunction_call::returnVoid 978 ns 978 ns 716311 -StdFunction_callMethod::returnVoid 960 ns 960 ns 726226 +bm_std::function_CallsFunction::set_string 361 ns 361 ns 1965409 +bm_std::function___CallsMethod::set_string 357 ns 357 ns 1956066 -RtlFunction_call::returnVoid 975 ns 975 ns 717093 -RtlFunction_callMethod::returnVoid 977 ns 976 ns 716878 +bm_rtl::function_CallsFunction::set_string 358 ns 358 ns 1949217 +bm_rtl::method_____CallsMethod::set_string 361 ns 361 ns 1903211 -RtlFunction_call_ReturnUnknown::Void 960 ns 960 ns 727671 -RtlFunction_callMethod_ReturnUnknown::Void 964 ns 964 ns 725591 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 970 ns 969 ns 719357 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1104 ns 1104 ns 633453 +bm_rtl::function_ErasedReturnType::set_string 391 ns 391 ns 1901142 +bm_rtl::method___ErasedReturnType::set_string 372 ns 372 ns 1806889 +bm_rtl::method___ErasedTargetType::set_string 365 ns 365 ns 1902457 +bm_rtl::method___ErasedTargetAndReturnType::set_string 368 ns 368 ns 1885493 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 518 ns 518 ns 1345222 -NativeFunctionPtr_call::returnNonVoid 1086 ns 1086 ns 643041 -NativeFunctionPtr_callMethod::returnNonVoid 1086 ns 1086 ns 643635 +bm_call::by_FunctionPtr_Function::get_string 526 ns 526 ns 1341456 +bm_call::by_FunctionPtr___Method::get_string 528 ns 528 ns 1316870 -StdFunction_call::returnNonVoid 1087 ns 1087 ns 644609 -StdFunction_callMethod::returnNonVoid 1083 ns 1083 ns 645401 +bm_std::function_CallsFunction::get_string 525 ns 525 ns 1336722 +bm_std::function___CallsMethod::get_string 524 ns 524 ns 1326344 -RtlFunction_call::returnNonVoid 1086 ns 1086 ns 644157 -RtlFunction_callMethod::returnNonVoid 1085 ns 1085 ns 643034 +bm_rtl::function_CallsFunction::get_string 527 ns 527 ns 1330642 +bm_rtl::method_____CallsMethod::get_string 523 ns 523 ns 1330518 -RtlFunction_call_ReturnUnknown::NonVoid 1093 ns 1092 ns 641167 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1092 ns 1092 ns 640012 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1091 ns 1091 ns 641847 +bm_rtl::function_ErasedReturnType::get_string 539 ns 539 ns 1267504 +bm_rtl::method___ErasedReturnType::get_string 539 ns 539 ns 1306267 +bm_rtl::method___ErasedTargetType::get_string 532 ns 532 ns 1304795 +bm_rtl::method___ErasedTargetAndReturnType::get_string 542 ns 542 ns 1294289 ----------------------------------- -[2025-10-09 22:35:41] >>> Run 5: workload scale = 50 +[2025-10-25 08:27:06] >>> Run 3: workload scale = 30 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 50 iterations +Scale : 30 iterations ============================================= -2025-10-09T22:35:41+05:30 +2025-10-25T08:27:06+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 1508.39 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.03, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 901 ns 901 ns 776903 +Load Average: 1.55, 1.39, 0.80 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 366 ns 366 ns 1919740 -NativeFunctionPtr_call::returnVoid 907 ns 907 ns 770209 -NativeFunctionPtr_callMethod::returnVoid 907 ns 907 ns 769710 +bm_call::by_FunctionPtr_Function::set_string 367 ns 367 ns 1911290 +bm_call::by_FunctionPtr___Method::set_string 366 ns 366 ns 1904880 -StdFunction_call::returnVoid 907 ns 907 ns 768412 -StdFunction_callMethod::returnVoid 905 ns 905 ns 772351 +bm_std::function_CallsFunction::set_string 366 ns 366 ns 1876743 +bm_std::function___CallsMethod::set_string 370 ns 370 ns 1892013 -RtlFunction_call::returnVoid 906 ns 906 ns 770224 -RtlFunction_callMethod::returnVoid 909 ns 909 ns 771678 +bm_rtl::function_CallsFunction::set_string 369 ns 368 ns 1917651 +bm_rtl::method_____CallsMethod::set_string 366 ns 366 ns 1907502 -RtlFunction_call_ReturnUnknown::Void 913 ns 913 ns 767049 -RtlFunction_callMethod_ReturnUnknown::Void 916 ns 916 ns 765685 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 922 ns 922 ns 759992 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1029 ns 1029 ns 680497 +bm_rtl::function_ErasedReturnType::set_string 387 ns 387 ns 1801830 +bm_rtl::method___ErasedReturnType::set_string 384 ns 384 ns 1826847 +bm_rtl::method___ErasedTargetType::set_string 382 ns 382 ns 1844261 +bm_rtl::method___ErasedTargetAndReturnType::set_string 371 ns 371 ns 1886391 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 526 ns 526 ns 1329959 -NativeFunctionPtr_call::returnNonVoid 1032 ns 1032 ns 677650 -NativeFunctionPtr_callMethod::returnNonVoid 1033 ns 1033 ns 676900 +bm_call::by_FunctionPtr_Function::get_string 525 ns 525 ns 1338440 +bm_call::by_FunctionPtr___Method::get_string 529 ns 529 ns 1309704 -StdFunction_call::returnNonVoid 1036 ns 1035 ns 676858 -StdFunction_callMethod::returnNonVoid 1036 ns 1035 ns 675873 +bm_std::function_CallsFunction::get_string 536 ns 536 ns 1321836 +bm_std::function___CallsMethod::get_string 558 ns 557 ns 1311973 -RtlFunction_call::returnNonVoid 1035 ns 1035 ns 676220 -RtlFunction_callMethod::returnNonVoid 1037 ns 1037 ns 676462 +bm_rtl::function_CallsFunction::get_string 606 ns 606 ns 1159851 +bm_rtl::method_____CallsMethod::get_string 590 ns 590 ns 1113064 -RtlFunction_call_ReturnUnknown::NonVoid 1059 ns 1059 ns 662541 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1058 ns 1058 ns 661582 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1059 ns 1059 ns 661306 +bm_rtl::function_ErasedReturnType::get_string 608 ns 608 ns 1152150 +bm_rtl::method___ErasedReturnType::get_string 617 ns 617 ns 1131216 +bm_rtl::method___ErasedTargetType::get_string 610 ns 610 ns 1151877 +bm_rtl::method___ErasedTargetAndReturnType::get_string 620 ns 620 ns 1138753 ----------------------------------- -[2025-10-09 22:35:57] >>> Run 1: workload scale = 58 +[2025-10-25 08:27:26] >>> Run 1: workload scale = 35 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 58 iterations +Scale : 35 iterations ============================================= -2025-10-09T22:35:57+05:30 +2025-10-25T08:27:26+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 1071.83 MHz CPU s) +Run on (16 X 2310.48 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1017 ns 1017 ns 688223 +Load Average: 1.39, 1.36, 0.81 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 738 ns 737 ns 949910 -NativeFunctionPtr_call::returnVoid 1017 ns 1017 ns 689065 -NativeFunctionPtr_callMethod::returnVoid 1016 ns 1016 ns 689482 +bm_call::by_FunctionPtr_Function::set_string 746 ns 746 ns 958502 +bm_call::by_FunctionPtr___Method::set_string 725 ns 725 ns 961082 -StdFunction_call::returnVoid 1017 ns 1017 ns 689150 -StdFunction_callMethod::returnVoid 1020 ns 1019 ns 686631 +bm_std::function_CallsFunction::set_string 733 ns 733 ns 945471 +bm_std::function___CallsMethod::set_string 724 ns 724 ns 962085 -RtlFunction_call::returnVoid 1017 ns 1017 ns 689619 -RtlFunction_callMethod::returnVoid 1016 ns 1016 ns 688181 +bm_rtl::function_CallsFunction::set_string 727 ns 727 ns 930075 +bm_rtl::method_____CallsMethod::set_string 736 ns 735 ns 957228 -RtlFunction_call_ReturnUnknown::Void 1022 ns 1022 ns 685431 -RtlFunction_callMethod_ReturnUnknown::Void 1022 ns 1022 ns 685152 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1023 ns 1023 ns 681943 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1186 ns 1186 ns 590484 +bm_rtl::function_ErasedReturnType::set_string 729 ns 729 ns 941981 +bm_rtl::method___ErasedReturnType::set_string 735 ns 735 ns 948788 +bm_rtl::method___ErasedTargetType::set_string 726 ns 725 ns 959696 +bm_rtl::method___ErasedTargetAndReturnType::set_string 724 ns 724 ns 960229 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 911 ns 911 ns 745135 -NativeFunctionPtr_call::returnNonVoid 1185 ns 1185 ns 591072 -NativeFunctionPtr_callMethod::returnNonVoid 1185 ns 1185 ns 590879 +bm_call::by_FunctionPtr_Function::get_string 915 ns 915 ns 755979 +bm_call::by_FunctionPtr___Method::get_string 918 ns 918 ns 752319 -StdFunction_call::returnNonVoid 1186 ns 1186 ns 590813 -StdFunction_callMethod::returnNonVoid 1190 ns 1190 ns 587526 +bm_std::function_CallsFunction::get_string 918 ns 918 ns 750587 +bm_std::function___CallsMethod::get_string 910 ns 910 ns 758746 -RtlFunction_call::returnNonVoid 1185 ns 1185 ns 589054 -RtlFunction_callMethod::returnNonVoid 1185 ns 1185 ns 590356 +bm_rtl::function_CallsFunction::get_string 916 ns 915 ns 755424 +bm_rtl::method_____CallsMethod::get_string 916 ns 916 ns 756404 -RtlFunction_call_ReturnUnknown::NonVoid 1205 ns 1205 ns 580445 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1204 ns 1204 ns 581492 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1207 ns 1206 ns 579706 +bm_rtl::function_ErasedReturnType::get_string 987 ns 987 ns 694625 +bm_rtl::method___ErasedReturnType::get_string 922 ns 922 ns 732291 +bm_rtl::method___ErasedTargetType::get_string 915 ns 914 ns 758787 +bm_rtl::method___ErasedTargetAndReturnType::get_string 925 ns 925 ns 750609 ----------------------------------- -[2025-10-09 22:36:13] >>> Run 2: workload scale = 58 +[2025-10-25 08:27:44] >>> Run 2: workload scale = 35 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 58 iterations +Scale : 35 iterations ============================================= -2025-10-09T22:36:13+05:30 +2025-10-25T08:27:44+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3575.93 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1020 ns 1020 ns 686146 +Load Average: 1.35, 1.35, 0.82 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 694 ns 694 ns 966668 -NativeFunctionPtr_call::returnVoid 1022 ns 1022 ns 685871 -NativeFunctionPtr_callMethod::returnVoid 1023 ns 1022 ns 684704 +bm_call::by_FunctionPtr_Function::set_string 691 ns 691 ns 994391 +bm_call::by_FunctionPtr___Method::set_string 690 ns 689 ns 1018565 -StdFunction_call::returnVoid 1024 ns 1024 ns 684907 -StdFunction_callMethod::returnVoid 1024 ns 1023 ns 683217 +bm_std::function_CallsFunction::set_string 691 ns 691 ns 998812 +bm_std::function___CallsMethod::set_string 694 ns 693 ns 1004926 -RtlFunction_call::returnVoid 1021 ns 1021 ns 686029 -RtlFunction_callMethod::returnVoid 1022 ns 1021 ns 685508 +bm_rtl::function_CallsFunction::set_string 700 ns 699 ns 1008183 +bm_rtl::method_____CallsMethod::set_string 694 ns 694 ns 1005650 -RtlFunction_call_ReturnUnknown::Void 1026 ns 1026 ns 682906 -RtlFunction_callMethod_ReturnUnknown::Void 1027 ns 1027 ns 682324 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1028 ns 1028 ns 680506 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1193 ns 1193 ns 587243 +bm_rtl::function_ErasedReturnType::set_string 705 ns 705 ns 986699 +bm_rtl::method___ErasedReturnType::set_string 702 ns 702 ns 983604 +bm_rtl::method___ErasedTargetType::set_string 700 ns 700 ns 986677 +bm_rtl::method___ErasedTargetAndReturnType::set_string 705 ns 705 ns 979085 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 896 ns 896 ns 764388 -NativeFunctionPtr_call::returnNonVoid 1191 ns 1190 ns 587438 -NativeFunctionPtr_callMethod::returnNonVoid 1191 ns 1191 ns 587449 +bm_call::by_FunctionPtr_Function::get_string 900 ns 900 ns 767693 +bm_call::by_FunctionPtr___Method::get_string 897 ns 897 ns 772348 -StdFunction_call::returnNonVoid 1192 ns 1191 ns 588016 -StdFunction_callMethod::returnNonVoid 1192 ns 1192 ns 587654 +bm_std::function_CallsFunction::get_string 903 ns 903 ns 769105 +bm_std::function___CallsMethod::get_string 898 ns 898 ns 771183 -RtlFunction_call::returnNonVoid 1191 ns 1191 ns 587588 -RtlFunction_callMethod::returnNonVoid 1191 ns 1190 ns 585562 +bm_rtl::function_CallsFunction::get_string 900 ns 899 ns 765085 +bm_rtl::method_____CallsMethod::get_string 897 ns 897 ns 776452 -RtlFunction_call_ReturnUnknown::NonVoid 1209 ns 1209 ns 579108 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1204 ns 1204 ns 581221 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1211 ns 1211 ns 578505 +bm_rtl::function_ErasedReturnType::get_string 921 ns 921 ns 754699 +bm_rtl::method___ErasedReturnType::get_string 921 ns 920 ns 753361 +bm_rtl::method___ErasedTargetType::get_string 905 ns 905 ns 755296 +bm_rtl::method___ErasedTargetAndReturnType::get_string 918 ns 918 ns 753835 ----------------------------------- -[2025-10-09 22:36:30] >>> Run 3: workload scale = 58 +[2025-10-25 08:28:01] >>> Run 3: workload scale = 35 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 58 iterations +Scale : 35 iterations ============================================= -2025-10-09T22:36:30+05:30 +2025-10-25T08:28:01+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -3300,146 +1445,152 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1057 ns 1057 ns 662676 +Load Average: 1.35, 1.35, 0.83 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 691 ns 690 ns 959679 -NativeFunctionPtr_call::returnVoid 1057 ns 1057 ns 662479 -NativeFunctionPtr_callMethod::returnVoid 1057 ns 1057 ns 662618 +bm_call::by_FunctionPtr_Function::set_string 695 ns 694 ns 1004970 +bm_call::by_FunctionPtr___Method::set_string 693 ns 692 ns 1005822 -StdFunction_call::returnVoid 1056 ns 1056 ns 661366 -StdFunction_callMethod::returnVoid 1055 ns 1055 ns 664957 +bm_std::function_CallsFunction::set_string 694 ns 693 ns 995310 +bm_std::function___CallsMethod::set_string 699 ns 698 ns 950112 -RtlFunction_call::returnVoid 1057 ns 1057 ns 661655 -RtlFunction_callMethod::returnVoid 1056 ns 1056 ns 663351 +bm_rtl::function_CallsFunction::set_string 694 ns 694 ns 1016276 +bm_rtl::method_____CallsMethod::set_string 689 ns 689 ns 1014165 -RtlFunction_call_ReturnUnknown::Void 1061 ns 1060 ns 661005 -RtlFunction_callMethod_ReturnUnknown::Void 1056 ns 1056 ns 663085 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1060 ns 1060 ns 661394 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1222 ns 1222 ns 573160 +bm_rtl::function_ErasedReturnType::set_string 699 ns 699 ns 997349 +bm_rtl::method___ErasedReturnType::set_string 699 ns 699 ns 991395 +bm_rtl::method___ErasedTargetType::set_string 697 ns 697 ns 997670 +bm_rtl::method___ErasedTargetAndReturnType::set_string 703 ns 703 ns 999820 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 899 ns 898 ns 769821 -NativeFunctionPtr_call::returnNonVoid 1222 ns 1222 ns 573052 -NativeFunctionPtr_callMethod::returnNonVoid 1223 ns 1222 ns 572696 +bm_call::by_FunctionPtr_Function::get_string 898 ns 898 ns 759644 +bm_call::by_FunctionPtr___Method::get_string 899 ns 898 ns 769545 -StdFunction_call::returnNonVoid 1223 ns 1223 ns 571572 -StdFunction_callMethod::returnNonVoid 1222 ns 1222 ns 573104 +bm_std::function_CallsFunction::get_string 903 ns 903 ns 752728 +bm_std::function___CallsMethod::get_string 897 ns 897 ns 760283 -RtlFunction_call::returnNonVoid 1223 ns 1223 ns 572700 -RtlFunction_callMethod::returnNonVoid 1222 ns 1222 ns 573468 +bm_rtl::function_CallsFunction::get_string 897 ns 896 ns 763113 +bm_rtl::method_____CallsMethod::get_string 899 ns 898 ns 760667 -RtlFunction_call_ReturnUnknown::NonVoid 1235 ns 1235 ns 567072 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1235 ns 1234 ns 567330 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1238 ns 1238 ns 565464 +bm_rtl::function_ErasedReturnType::get_string 931 ns 931 ns 741176 +bm_rtl::method___ErasedReturnType::get_string 928 ns 928 ns 744110 +bm_rtl::method___ErasedTargetType::get_string 921 ns 920 ns 747090 +bm_rtl::method___ErasedTargetAndReturnType::get_string 938 ns 938 ns 744325 ----------------------------------- -[2025-10-09 22:36:46] >>> Run 4: workload scale = 58 +[2025-10-25 08:28:18] >>> Run 1: workload scale = 40 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 58 iterations +Scale : 40 iterations ============================================= -2025-10-09T22:36:46+05:30 +2025-10-25T08:28:18+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2646.92 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1016 ns 1015 ns 688702 +Load Average: 1.27, 1.33, 0.83 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 816 ns 816 ns 874256 -NativeFunctionPtr_call::returnVoid 1017 ns 1016 ns 687175 -NativeFunctionPtr_callMethod::returnVoid 1017 ns 1017 ns 687586 +bm_call::by_FunctionPtr_Function::set_string 788 ns 788 ns 863946 +bm_call::by_FunctionPtr___Method::set_string 785 ns 784 ns 880553 -StdFunction_call::returnVoid 1018 ns 1017 ns 689533 -StdFunction_callMethod::returnVoid 1022 ns 1021 ns 686748 +bm_std::function_CallsFunction::set_string 782 ns 782 ns 861889 +bm_std::function___CallsMethod::set_string 791 ns 791 ns 864983 -RtlFunction_call::returnVoid 1017 ns 1017 ns 687457 -RtlFunction_callMethod::returnVoid 1018 ns 1017 ns 687584 +bm_rtl::function_CallsFunction::set_string 780 ns 780 ns 881562 +bm_rtl::method_____CallsMethod::set_string 781 ns 781 ns 882033 -RtlFunction_call_ReturnUnknown::Void 1024 ns 1024 ns 684873 -RtlFunction_callMethod_ReturnUnknown::Void 1022 ns 1022 ns 684522 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1026 ns 1026 ns 683416 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1145 ns 1145 ns 611880 +bm_rtl::function_ErasedReturnType::set_string 793 ns 792 ns 869968 +bm_rtl::method___ErasedReturnType::set_string 793 ns 793 ns 857392 +bm_rtl::method___ErasedTargetType::set_string 800 ns 800 ns 865195 +bm_rtl::method___ErasedTargetAndReturnType::set_string 796 ns 796 ns 870378 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 986 ns 985 ns 696152 -NativeFunctionPtr_call::returnNonVoid 1144 ns 1144 ns 611850 -NativeFunctionPtr_callMethod::returnNonVoid 1148 ns 1147 ns 610908 +bm_call::by_FunctionPtr_Function::get_string 988 ns 988 ns 696698 +bm_call::by_FunctionPtr___Method::get_string 987 ns 987 ns 696962 -StdFunction_call::returnNonVoid 1146 ns 1146 ns 610474 -StdFunction_callMethod::returnNonVoid 1149 ns 1149 ns 610191 +bm_std::function_CallsFunction::get_string 989 ns 989 ns 692755 +bm_std::function___CallsMethod::get_string 990 ns 990 ns 698164 -RtlFunction_call::returnNonVoid 1145 ns 1145 ns 611206 -RtlFunction_callMethod::returnNonVoid 1145 ns 1145 ns 610365 +bm_rtl::function_CallsFunction::get_string 988 ns 988 ns 691324 +bm_rtl::method_____CallsMethod::get_string 990 ns 990 ns 690412 -RtlFunction_call_ReturnUnknown::NonVoid 1168 ns 1168 ns 599252 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1162 ns 1162 ns 602772 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1168 ns 1168 ns 599755 +bm_rtl::function_ErasedReturnType::get_string 1023 ns 1022 ns 683091 +bm_rtl::method___ErasedReturnType::get_string 1021 ns 1021 ns 678424 +bm_rtl::method___ErasedTargetType::get_string 998 ns 998 ns 693112 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1025 ns 1024 ns 670793 ----------------------------------- -[2025-10-09 22:37:03] >>> Run 5: workload scale = 58 +[2025-10-25 08:28:35] >>> Run 2: workload scale = 40 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 58 iterations +Scale : 40 iterations ============================================= -2025-10-09T22:37:03+05:30 +2025-10-25T08:28:35+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3833.58 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1014 ns 1014 ns 690854 +Load Average: 1.19, 1.31, 0.84 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 799 ns 799 ns 824743 -NativeFunctionPtr_call::returnVoid 1018 ns 1018 ns 688026 -NativeFunctionPtr_callMethod::returnVoid 1018 ns 1018 ns 681535 +bm_call::by_FunctionPtr_Function::set_string 798 ns 798 ns 882489 +bm_call::by_FunctionPtr___Method::set_string 788 ns 788 ns 869707 -StdFunction_call::returnVoid 1019 ns 1019 ns 685012 -StdFunction_callMethod::returnVoid 1021 ns 1021 ns 686342 +bm_std::function_CallsFunction::set_string 787 ns 787 ns 868766 +bm_std::function___CallsMethod::set_string 790 ns 790 ns 877734 -RtlFunction_call::returnVoid 1017 ns 1017 ns 689481 -RtlFunction_callMethod::returnVoid 1016 ns 1016 ns 689388 +bm_rtl::function_CallsFunction::set_string 795 ns 795 ns 858663 +bm_rtl::method_____CallsMethod::set_string 792 ns 792 ns 870837 -RtlFunction_call_ReturnUnknown::Void 1024 ns 1024 ns 677009 -RtlFunction_callMethod_ReturnUnknown::Void 1023 ns 1023 ns 683703 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1029 ns 1029 ns 680827 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1188 ns 1188 ns 589325 +bm_rtl::function_ErasedReturnType::set_string 794 ns 793 ns 876657 +bm_rtl::method___ErasedReturnType::set_string 794 ns 793 ns 871405 +bm_rtl::method___ErasedTargetType::set_string 792 ns 792 ns 876060 +bm_rtl::method___ErasedTargetAndReturnType::set_string 796 ns 796 ns 869998 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 994 ns 993 ns 695050 -NativeFunctionPtr_call::returnNonVoid 1189 ns 1189 ns 589444 -NativeFunctionPtr_callMethod::returnNonVoid 1188 ns 1188 ns 589075 +bm_call::by_FunctionPtr_Function::get_string 993 ns 993 ns 693618 +bm_call::by_FunctionPtr___Method::get_string 993 ns 993 ns 693206 -StdFunction_call::returnNonVoid 1190 ns 1189 ns 588550 -StdFunction_callMethod::returnNonVoid 1191 ns 1191 ns 588850 +bm_std::function_CallsFunction::get_string 994 ns 994 ns 684979 +bm_std::function___CallsMethod::get_string 991 ns 991 ns 683134 -RtlFunction_call::returnNonVoid 1188 ns 1188 ns 589155 -RtlFunction_callMethod::returnNonVoid 1190 ns 1190 ns 589574 +bm_rtl::function_CallsFunction::get_string 992 ns 992 ns 691637 +bm_rtl::method_____CallsMethod::get_string 997 ns 997 ns 667779 -RtlFunction_call_ReturnUnknown::NonVoid 1210 ns 1210 ns 578489 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1209 ns 1209 ns 579083 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1211 ns 1210 ns 579422 +bm_rtl::function_ErasedReturnType::get_string 1007 ns 1007 ns 675607 +bm_rtl::method___ErasedReturnType::get_string 1014 ns 1014 ns 673832 +bm_rtl::method___ErasedTargetType::get_string 1003 ns 1003 ns 693006 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1008 ns 1008 ns 687912 ----------------------------------- -[2025-10-09 22:37:19] >>> Run 1: workload scale = 66 +[2025-10-25 08:28:53] >>> Run 3: workload scale = 40 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 66 iterations +Scale : 40 iterations ============================================= -2025-10-09T22:37:19+05:30 +2025-10-25T08:28:53+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -3447,97 +1598,101 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1600 ns 1600 ns 436385 +Load Average: 1.15, 1.30, 0.84 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 780 ns 780 ns 873096 -NativeFunctionPtr_call::returnVoid 1604 ns 1604 ns 436230 -NativeFunctionPtr_callMethod::returnVoid 1603 ns 1602 ns 436650 +bm_call::by_FunctionPtr_Function::set_string 781 ns 780 ns 885065 +bm_call::by_FunctionPtr___Method::set_string 787 ns 787 ns 820768 -StdFunction_call::returnVoid 1607 ns 1606 ns 437326 -StdFunction_callMethod::returnVoid 1604 ns 1604 ns 436121 +bm_std::function_CallsFunction::set_string 782 ns 782 ns 888663 +bm_std::function___CallsMethod::set_string 782 ns 781 ns 886206 -RtlFunction_call::returnVoid 1602 ns 1602 ns 436830 -RtlFunction_callMethod::returnVoid 1602 ns 1602 ns 436999 +bm_rtl::function_CallsFunction::set_string 781 ns 780 ns 877242 +bm_rtl::method_____CallsMethod::set_string 780 ns 780 ns 885708 -RtlFunction_call_ReturnUnknown::Void 1631 ns 1631 ns 429057 -RtlFunction_callMethod_ReturnUnknown::Void 1603 ns 1602 ns 436413 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1648 ns 1648 ns 424915 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1760 ns 1760 ns 397933 +bm_rtl::function_ErasedReturnType::set_string 790 ns 790 ns 883274 +bm_rtl::method___ErasedReturnType::set_string 807 ns 807 ns 859777 +bm_rtl::method___ErasedTargetType::set_string 789 ns 789 ns 872521 +bm_rtl::method___ErasedTargetAndReturnType::set_string 795 ns 795 ns 863205 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1049 ns 1048 ns 641851 -NativeFunctionPtr_call::returnNonVoid 1760 ns 1760 ns 397613 -NativeFunctionPtr_callMethod::returnNonVoid 1761 ns 1761 ns 397339 +bm_call::by_FunctionPtr_Function::get_string 1041 ns 1040 ns 657253 +bm_call::by_FunctionPtr___Method::get_string 1039 ns 1039 ns 656430 -StdFunction_call::returnNonVoid 1763 ns 1763 ns 397079 -StdFunction_callMethod::returnNonVoid 1766 ns 1766 ns 396389 +bm_std::function_CallsFunction::get_string 1039 ns 1039 ns 660020 +bm_std::function___CallsMethod::get_string 1023 ns 1023 ns 655020 -RtlFunction_call::returnNonVoid 1760 ns 1760 ns 397778 -RtlFunction_callMethod::returnNonVoid 1760 ns 1760 ns 397708 +bm_rtl::function_CallsFunction::get_string 983 ns 983 ns 686350 +bm_rtl::method_____CallsMethod::get_string 982 ns 982 ns 707057 -RtlFunction_call_ReturnUnknown::NonVoid 1814 ns 1814 ns 385836 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1800 ns 1800 ns 388585 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1785 ns 1784 ns 392294 +bm_rtl::function_ErasedReturnType::get_string 1000 ns 1000 ns 694252 +bm_rtl::method___ErasedReturnType::get_string 999 ns 999 ns 682297 +bm_rtl::method___ErasedTargetType::get_string 1008 ns 1008 ns 696929 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1028 ns 1028 ns 679697 ----------------------------------- -[2025-10-09 22:37:37] >>> Run 2: workload scale = 66 +[2025-10-25 08:29:10] >>> Run 1: workload scale = 45 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 66 iterations +Scale : 45 iterations ============================================= -2025-10-09T22:37:37+05:30 +2025-10-25T08:29:10+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 1471.95 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1613 ns 1613 ns 433621 +Load Average: 1.11, 1.28, 0.84 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 843 ns 843 ns 787190 -NativeFunctionPtr_call::returnVoid 1619 ns 1618 ns 432916 -NativeFunctionPtr_callMethod::returnVoid 1615 ns 1615 ns 433261 +bm_call::by_FunctionPtr_Function::set_string 850 ns 850 ns 821517 +bm_call::by_FunctionPtr___Method::set_string 845 ns 845 ns 820441 -StdFunction_call::returnVoid 1615 ns 1615 ns 433326 -StdFunction_callMethod::returnVoid 1619 ns 1619 ns 432547 +bm_std::function_CallsFunction::set_string 838 ns 838 ns 810942 +bm_std::function___CallsMethod::set_string 841 ns 841 ns 821034 -RtlFunction_call::returnVoid 1616 ns 1616 ns 433581 -RtlFunction_callMethod::returnVoid 1614 ns 1614 ns 433431 +bm_rtl::function_CallsFunction::set_string 842 ns 842 ns 808850 +bm_rtl::method_____CallsMethod::set_string 851 ns 851 ns 822477 -RtlFunction_call_ReturnUnknown::Void 1623 ns 1623 ns 430795 -RtlFunction_callMethod_ReturnUnknown::Void 1618 ns 1618 ns 432710 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1624 ns 1624 ns 431140 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1802 ns 1802 ns 388594 +bm_rtl::function_ErasedReturnType::set_string 856 ns 856 ns 802630 +bm_rtl::method___ErasedReturnType::set_string 856 ns 856 ns 785080 +bm_rtl::method___ErasedTargetType::set_string 839 ns 839 ns 829114 +bm_rtl::method___ErasedTargetAndReturnType::set_string 844 ns 844 ns 812546 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1098 ns 1098 ns 642734 -NativeFunctionPtr_call::returnNonVoid 1799 ns 1798 ns 389146 -NativeFunctionPtr_callMethod::returnNonVoid 1799 ns 1799 ns 389238 +bm_call::by_FunctionPtr_Function::get_string 1105 ns 1104 ns 621246 +bm_call::by_FunctionPtr___Method::get_string 1090 ns 1090 ns 615328 -StdFunction_call::returnNonVoid 1801 ns 1801 ns 388945 -StdFunction_callMethod::returnNonVoid 1805 ns 1805 ns 388052 +bm_std::function_CallsFunction::get_string 1081 ns 1081 ns 627872 +bm_std::function___CallsMethod::get_string 1085 ns 1085 ns 580917 -RtlFunction_call::returnNonVoid 1799 ns 1799 ns 389035 -RtlFunction_callMethod::returnNonVoid 1799 ns 1799 ns 388790 +bm_rtl::function_CallsFunction::get_string 1082 ns 1082 ns 613484 +bm_rtl::method_____CallsMethod::get_string 1071 ns 1071 ns 624194 -RtlFunction_call_ReturnUnknown::NonVoid 1828 ns 1828 ns 382853 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1832 ns 1832 ns 383383 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1829 ns 1829 ns 382548 +bm_rtl::function_ErasedReturnType::get_string 1091 ns 1091 ns 631934 +bm_rtl::method___ErasedReturnType::get_string 1110 ns 1110 ns 618882 +bm_rtl::method___ErasedTargetType::get_string 1104 ns 1104 ns 645393 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1095 ns 1095 ns 626560 ----------------------------------- -[2025-10-09 22:37:55] >>> Run 3: workload scale = 66 +[2025-10-25 08:29:28] >>> Run 2: workload scale = 45 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 66 iterations +Scale : 45 iterations ============================================= -2025-10-09T22:37:55+05:30 +2025-10-25T08:29:28+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -3545,146 +1700,152 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1618 ns 1618 ns 432405 +Load Average: 1.32, 1.31, 0.86 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 863 ns 863 ns 790862 -NativeFunctionPtr_call::returnVoid 1620 ns 1620 ns 432224 -NativeFunctionPtr_callMethod::returnVoid 1618 ns 1617 ns 432408 +bm_call::by_FunctionPtr_Function::set_string 875 ns 875 ns 786432 +bm_call::by_FunctionPtr___Method::set_string 859 ns 859 ns 790154 -StdFunction_call::returnVoid 1619 ns 1619 ns 432761 -StdFunction_callMethod::returnVoid 1621 ns 1621 ns 431805 +bm_std::function_CallsFunction::set_string 902 ns 902 ns 796736 +bm_std::function___CallsMethod::set_string 905 ns 905 ns 734361 -RtlFunction_call::returnVoid 1618 ns 1618 ns 432749 -RtlFunction_callMethod::returnVoid 1618 ns 1618 ns 432757 +bm_rtl::function_CallsFunction::set_string 877 ns 877 ns 757947 +bm_rtl::method_____CallsMethod::set_string 877 ns 877 ns 781854 -RtlFunction_call_ReturnUnknown::Void 1627 ns 1627 ns 430553 -RtlFunction_callMethod_ReturnUnknown::Void 1637 ns 1636 ns 427801 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1625 ns 1624 ns 431362 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1804 ns 1804 ns 388076 +bm_rtl::function_ErasedReturnType::set_string 879 ns 879 ns 772766 +bm_rtl::method___ErasedReturnType::set_string 898 ns 897 ns 755860 +bm_rtl::method___ErasedTargetType::set_string 900 ns 900 ns 761109 +bm_rtl::method___ErasedTargetAndReturnType::set_string 899 ns 899 ns 746903 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1122 ns 1122 ns 613838 -NativeFunctionPtr_call::returnNonVoid 1803 ns 1803 ns 388011 -NativeFunctionPtr_callMethod::returnNonVoid 1804 ns 1803 ns 388212 +bm_call::by_FunctionPtr_Function::get_string 1110 ns 1110 ns 611555 +bm_call::by_FunctionPtr___Method::get_string 1091 ns 1091 ns 599366 -StdFunction_call::returnNonVoid 1805 ns 1804 ns 387668 -StdFunction_callMethod::returnNonVoid 1808 ns 1808 ns 387071 +bm_std::function_CallsFunction::get_string 1108 ns 1108 ns 614760 +bm_std::function___CallsMethod::get_string 1132 ns 1132 ns 603410 -RtlFunction_call::returnNonVoid 1803 ns 1803 ns 388011 -RtlFunction_callMethod::returnNonVoid 1804 ns 1804 ns 388127 +bm_rtl::function_CallsFunction::get_string 1104 ns 1104 ns 609206 +bm_rtl::method_____CallsMethod::get_string 1102 ns 1102 ns 611815 -RtlFunction_call_ReturnUnknown::NonVoid 1827 ns 1827 ns 383173 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1823 ns 1823 ns 384070 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1827 ns 1827 ns 383220 +bm_rtl::function_ErasedReturnType::get_string 1108 ns 1108 ns 605701 +bm_rtl::method___ErasedReturnType::get_string 1097 ns 1097 ns 588117 +bm_rtl::method___ErasedTargetType::get_string 1081 ns 1081 ns 632189 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1101 ns 1101 ns 620309 ----------------------------------- -[2025-10-09 22:38:13] >>> Run 4: workload scale = 66 +[2025-10-25 08:29:45] >>> Run 3: workload scale = 45 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 66 iterations +Scale : 45 iterations ============================================= -2025-10-09T22:38:13+05:30 +2025-10-25T08:29:45+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 1848.59 MHz CPU s) +Run on (16 X 2665.8 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1617 ns 1617 ns 432860 +Load Average: 1.60, 1.37, 0.89 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 844 ns 844 ns 787973 -NativeFunctionPtr_call::returnVoid 1617 ns 1617 ns 432688 -NativeFunctionPtr_callMethod::returnVoid 1615 ns 1615 ns 433493 +bm_call::by_FunctionPtr_Function::set_string 851 ns 851 ns 810521 +bm_call::by_FunctionPtr___Method::set_string 849 ns 849 ns 824023 -StdFunction_call::returnVoid 1615 ns 1615 ns 433467 -StdFunction_callMethod::returnVoid 1623 ns 1622 ns 431721 +bm_std::function_CallsFunction::set_string 850 ns 850 ns 826104 +bm_std::function___CallsMethod::set_string 848 ns 848 ns 814198 -RtlFunction_call::returnVoid 1615 ns 1615 ns 433383 -RtlFunction_callMethod::returnVoid 1615 ns 1615 ns 433324 +bm_rtl::function_CallsFunction::set_string 848 ns 848 ns 817784 +bm_rtl::method_____CallsMethod::set_string 845 ns 845 ns 822104 -RtlFunction_call_ReturnUnknown::Void 1623 ns 1623 ns 431084 -RtlFunction_callMethod_ReturnUnknown::Void 1614 ns 1614 ns 433944 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1621 ns 1620 ns 432351 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1803 ns 1803 ns 388501 +bm_rtl::function_ErasedReturnType::set_string 851 ns 851 ns 809302 +bm_rtl::method___ErasedReturnType::set_string 848 ns 848 ns 807888 +bm_rtl::method___ErasedTargetType::set_string 848 ns 848 ns 816118 +bm_rtl::method___ErasedTargetAndReturnType::set_string 852 ns 851 ns 815328 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1069 ns 1069 ns 643492 -NativeFunctionPtr_call::returnNonVoid 1801 ns 1801 ns 388522 -NativeFunctionPtr_callMethod::returnNonVoid 1800 ns 1800 ns 388728 +bm_call::by_FunctionPtr_Function::get_string 1066 ns 1066 ns 643062 +bm_call::by_FunctionPtr___Method::get_string 1066 ns 1066 ns 640979 -StdFunction_call::returnNonVoid 1803 ns 1803 ns 388057 -StdFunction_callMethod::returnNonVoid 1807 ns 1807 ns 386892 +bm_std::function_CallsFunction::get_string 1066 ns 1066 ns 632847 +bm_std::function___CallsMethod::get_string 1074 ns 1074 ns 647084 -RtlFunction_call::returnNonVoid 1801 ns 1801 ns 388940 -RtlFunction_callMethod::returnNonVoid 1802 ns 1801 ns 388635 +bm_rtl::function_CallsFunction::get_string 1066 ns 1066 ns 652862 +bm_rtl::method_____CallsMethod::get_string 1067 ns 1067 ns 652673 -RtlFunction_call_ReturnUnknown::NonVoid 1827 ns 1827 ns 383400 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1821 ns 1821 ns 384418 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1830 ns 1830 ns 382810 +bm_rtl::function_ErasedReturnType::get_string 1092 ns 1092 ns 632999 +bm_rtl::method___ErasedReturnType::get_string 1091 ns 1091 ns 624987 +bm_rtl::method___ErasedTargetType::get_string 1079 ns 1079 ns 639076 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1096 ns 1095 ns 629950 ----------------------------------- -[2025-10-09 22:38:31] >>> Run 5: workload scale = 66 +[2025-10-25 08:30:03] >>> Run 1: workload scale = 50 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 66 iterations +Scale : 50 iterations ============================================= -2025-10-09T22:38:31+05:30 +2025-10-25T08:30:03+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 1140.79 MHz CPU s) +Run on (16 X 3589.81 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1603 ns 1602 ns 436929 +Load Average: 1.47, 1.35, 0.90 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 920 ns 920 ns 738697 -NativeFunctionPtr_call::returnVoid 1602 ns 1601 ns 436985 -NativeFunctionPtr_callMethod::returnVoid 1600 ns 1600 ns 437146 +bm_call::by_FunctionPtr_Function::set_string 921 ns 921 ns 717097 +bm_call::by_FunctionPtr___Method::set_string 922 ns 922 ns 756736 -StdFunction_call::returnVoid 1600 ns 1600 ns 434586 -StdFunction_callMethod::returnVoid 1605 ns 1605 ns 436545 +bm_std::function_CallsFunction::set_string 918 ns 918 ns 743148 +bm_std::function___CallsMethod::set_string 923 ns 923 ns 742602 -RtlFunction_call::returnVoid 1604 ns 1603 ns 437626 -RtlFunction_callMethod::returnVoid 1600 ns 1600 ns 437431 +bm_rtl::function_CallsFunction::set_string 921 ns 921 ns 748875 +bm_rtl::method_____CallsMethod::set_string 917 ns 916 ns 748828 -RtlFunction_call_ReturnUnknown::Void 1611 ns 1611 ns 435485 -RtlFunction_callMethod_ReturnUnknown::Void 1602 ns 1602 ns 437140 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1609 ns 1608 ns 435371 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1758 ns 1757 ns 398110 +bm_rtl::function_ErasedReturnType::set_string 934 ns 934 ns 736668 +bm_rtl::method___ErasedReturnType::set_string 930 ns 930 ns 747673 +bm_rtl::method___ErasedTargetType::set_string 931 ns 931 ns 726636 +bm_rtl::method___ErasedTargetAndReturnType::set_string 935 ns 935 ns 727628 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1177 ns 1176 ns 572959 -NativeFunctionPtr_call::returnNonVoid 1758 ns 1758 ns 398283 -NativeFunctionPtr_callMethod::returnNonVoid 1762 ns 1762 ns 398076 +bm_call::by_FunctionPtr_Function::get_string 1176 ns 1176 ns 582468 +bm_call::by_FunctionPtr___Method::get_string 1183 ns 1183 ns 574525 -StdFunction_call::returnNonVoid 1763 ns 1762 ns 397384 -StdFunction_callMethod::returnNonVoid 1768 ns 1768 ns 396828 +bm_std::function_CallsFunction::get_string 1176 ns 1176 ns 575515 +bm_std::function___CallsMethod::get_string 1190 ns 1190 ns 571997 -RtlFunction_call::returnNonVoid 1759 ns 1759 ns 398057 -RtlFunction_callMethod::returnNonVoid 1761 ns 1761 ns 398049 +bm_rtl::function_CallsFunction::get_string 1175 ns 1175 ns 578051 +bm_rtl::method_____CallsMethod::get_string 1174 ns 1174 ns 566082 -RtlFunction_call_ReturnUnknown::NonVoid 1783 ns 1783 ns 392427 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1779 ns 1778 ns 393989 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1782 ns 1782 ns 392158 +bm_rtl::function_ErasedReturnType::get_string 1199 ns 1199 ns 575119 +bm_rtl::method___ErasedReturnType::get_string 1199 ns 1199 ns 574217 +bm_rtl::method___ErasedTargetType::get_string 1192 ns 1191 ns 582765 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1205 ns 1205 ns 568205 ----------------------------------- -[2025-10-09 22:38:48] >>> Run 1: workload scale = 74 +[2025-10-25 08:30:20] >>> Run 2: workload scale = 50 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 74 iterations +Scale : 50 iterations ============================================= -2025-10-09T22:38:48+05:30 +2025-10-25T08:30:20+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -3692,881 +1853,917 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1690 ns 1690 ns 413456 +Load Average: 1.40, 1.35, 0.91 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 914 ns 913 ns 741391 -NativeFunctionPtr_call::returnVoid 1695 ns 1694 ns 413568 -NativeFunctionPtr_callMethod::returnVoid 1691 ns 1690 ns 414074 +bm_call::by_FunctionPtr_Function::set_string 911 ns 911 ns 755564 +bm_call::by_FunctionPtr___Method::set_string 911 ns 911 ns 761951 -StdFunction_call::returnVoid 1692 ns 1692 ns 414083 -StdFunction_callMethod::returnVoid 1694 ns 1694 ns 413416 +bm_std::function_CallsFunction::set_string 911 ns 911 ns 755882 +bm_std::function___CallsMethod::set_string 909 ns 909 ns 663426 -RtlFunction_call::returnVoid 1692 ns 1692 ns 413887 -RtlFunction_callMethod::returnVoid 1691 ns 1691 ns 414207 +bm_rtl::function_CallsFunction::set_string 913 ns 913 ns 756577 +bm_rtl::method_____CallsMethod::set_string 925 ns 925 ns 757855 -RtlFunction_call_ReturnUnknown::Void 1698 ns 1698 ns 412184 -RtlFunction_callMethod_ReturnUnknown::Void 1690 ns 1690 ns 411539 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1696 ns 1696 ns 412729 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1914 ns 1914 ns 366023 +bm_rtl::function_ErasedReturnType::set_string 940 ns 939 ns 742353 +bm_rtl::method___ErasedReturnType::set_string 931 ns 931 ns 725754 +bm_rtl::method___ErasedTargetType::set_string 929 ns 929 ns 734123 +bm_rtl::method___ErasedTargetAndReturnType::set_string 939 ns 939 ns 723982 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1168 ns 1168 ns 583887 -NativeFunctionPtr_call::returnNonVoid 1911 ns 1910 ns 366512 -NativeFunctionPtr_callMethod::returnNonVoid 1913 ns 1913 ns 366399 +bm_call::by_FunctionPtr_Function::get_string 1167 ns 1167 ns 578193 +bm_call::by_FunctionPtr___Method::get_string 1167 ns 1167 ns 587466 -StdFunction_call::returnNonVoid 1915 ns 1915 ns 365932 -StdFunction_callMethod::returnNonVoid 1919 ns 1919 ns 364599 +bm_std::function_CallsFunction::get_string 1168 ns 1168 ns 593884 +bm_std::function___CallsMethod::get_string 1173 ns 1173 ns 585582 -RtlFunction_call::returnNonVoid 1911 ns 1911 ns 366396 -RtlFunction_callMethod::returnNonVoid 1915 ns 1914 ns 365912 +bm_rtl::function_CallsFunction::get_string 1168 ns 1168 ns 589844 +bm_rtl::method_____CallsMethod::get_string 1168 ns 1168 ns 591239 -RtlFunction_call_ReturnUnknown::NonVoid 1940 ns 1939 ns 360998 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1934 ns 1934 ns 361624 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1938 ns 1938 ns 359495 +bm_rtl::function_ErasedReturnType::get_string 1200 ns 1200 ns 571595 +bm_rtl::method___ErasedReturnType::get_string 1202 ns 1202 ns 560720 +bm_rtl::method___ErasedTargetType::get_string 1182 ns 1182 ns 553380 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1209 ns 1209 ns 575085 ----------------------------------- -[2025-10-09 22:39:06] >>> Run 2: workload scale = 74 +[2025-10-25 08:30:38] >>> Run 3: workload scale = 50 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 74 iterations +Scale : 50 iterations ============================================= -2025-10-09T22:39:06+05:30 +2025-10-25T08:30:38+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 1897.49 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1681 ns 1680 ns 415852 +Load Average: 1.85, 1.46, 0.95 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 921 ns 920 ns 740235 -NativeFunctionPtr_call::returnVoid 1681 ns 1681 ns 405148 -NativeFunctionPtr_callMethod::returnVoid 1680 ns 1680 ns 416822 +bm_call::by_FunctionPtr_Function::set_string 926 ns 925 ns 754127 +bm_call::by_FunctionPtr___Method::set_string 924 ns 924 ns 756576 -StdFunction_call::returnVoid 1679 ns 1679 ns 417233 -StdFunction_callMethod::returnVoid 1683 ns 1683 ns 416139 +bm_std::function_CallsFunction::set_string 923 ns 923 ns 747271 +bm_std::function___CallsMethod::set_string 928 ns 927 ns 745917 -RtlFunction_call::returnVoid 1679 ns 1679 ns 417327 -RtlFunction_callMethod::returnVoid 1680 ns 1680 ns 416365 +bm_rtl::function_CallsFunction::set_string 922 ns 921 ns 743806 +bm_rtl::method_____CallsMethod::set_string 924 ns 924 ns 732865 -RtlFunction_call_ReturnUnknown::Void 1687 ns 1686 ns 415109 -RtlFunction_callMethod_ReturnUnknown::Void 1679 ns 1679 ns 416907 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1683 ns 1683 ns 415653 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1870 ns 1870 ns 374302 +bm_rtl::function_ErasedReturnType::set_string 942 ns 942 ns 730851 +bm_rtl::method___ErasedReturnType::set_string 940 ns 940 ns 744287 +bm_rtl::method___ErasedTargetType::set_string 939 ns 939 ns 740601 +bm_rtl::method___ErasedTargetAndReturnType::set_string 938 ns 938 ns 733123 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1178 ns 1178 ns 589582 -NativeFunctionPtr_call::returnNonVoid 1871 ns 1871 ns 374375 -NativeFunctionPtr_callMethod::returnNonVoid 1871 ns 1871 ns 373993 +bm_call::by_FunctionPtr_Function::get_string 1178 ns 1178 ns 579966 +bm_call::by_FunctionPtr___Method::get_string 1181 ns 1181 ns 581942 -StdFunction_call::returnNonVoid 1873 ns 1873 ns 373579 -StdFunction_callMethod::returnNonVoid 1875 ns 1875 ns 373470 +bm_std::function_CallsFunction::get_string 1193 ns 1193 ns 568660 +bm_std::function___CallsMethod::get_string 1181 ns 1181 ns 579403 -RtlFunction_call::returnNonVoid 1869 ns 1869 ns 374406 -RtlFunction_callMethod::returnNonVoid 1871 ns 1870 ns 374098 +bm_rtl::function_CallsFunction::get_string 1178 ns 1177 ns 584070 +bm_rtl::method_____CallsMethod::get_string 1177 ns 1177 ns 587694 -RtlFunction_call_ReturnUnknown::NonVoid 1898 ns 1898 ns 368169 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1891 ns 1891 ns 370428 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1897 ns 1897 ns 367942 +bm_rtl::function_ErasedReturnType::get_string 1205 ns 1204 ns 570455 +bm_rtl::method___ErasedReturnType::get_string 1207 ns 1207 ns 570787 +bm_rtl::method___ErasedTargetType::get_string 1196 ns 1196 ns 569793 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1210 ns 1210 ns 561648 ----------------------------------- -[2025-10-09 22:39:24] >>> Run 3: workload scale = 74 +[2025-10-25 08:30:56] >>> Run 1: workload scale = 58 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 74 iterations +Scale : 58 iterations ============================================= -2025-10-09T22:39:24+05:30 +2025-10-25T08:30:56+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2587.18 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1682 ns 1682 ns 415896 +Load Average: 1.61, 1.43, 0.95 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1039 ns 1039 ns 607414 -NativeFunctionPtr_call::returnVoid 1683 ns 1683 ns 415946 -NativeFunctionPtr_callMethod::returnVoid 1681 ns 1681 ns 416150 +bm_call::by_FunctionPtr_Function::set_string 1042 ns 1042 ns 661448 +bm_call::by_FunctionPtr___Method::set_string 1044 ns 1044 ns 643057 -StdFunction_call::returnVoid 1683 ns 1683 ns 416123 -StdFunction_callMethod::returnVoid 1683 ns 1683 ns 416331 +bm_std::function_CallsFunction::set_string 1040 ns 1040 ns 656520 +bm_std::function___CallsMethod::set_string 1040 ns 1040 ns 667856 -RtlFunction_call::returnVoid 1682 ns 1682 ns 416179 -RtlFunction_callMethod::returnVoid 1683 ns 1683 ns 415128 +bm_rtl::function_CallsFunction::set_string 1038 ns 1038 ns 666280 +bm_rtl::method_____CallsMethod::set_string 1041 ns 1041 ns 659063 -RtlFunction_call_ReturnUnknown::Void 1691 ns 1691 ns 413901 -RtlFunction_callMethod_ReturnUnknown::Void 1684 ns 1684 ns 416111 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1690 ns 1689 ns 415003 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1874 ns 1873 ns 373708 +bm_rtl::function_ErasedReturnType::set_string 1055 ns 1055 ns 659455 +bm_rtl::method___ErasedReturnType::set_string 1063 ns 1063 ns 631920 +bm_rtl::method___ErasedTargetType::set_string 1053 ns 1053 ns 647693 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1055 ns 1055 ns 647299 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1315 ns 1315 ns 521662 -NativeFunctionPtr_call::returnNonVoid 1876 ns 1875 ns 373210 -NativeFunctionPtr_callMethod::returnNonVoid 1875 ns 1875 ns 373554 +bm_call::by_FunctionPtr_Function::get_string 1317 ns 1317 ns 517580 +bm_call::by_FunctionPtr___Method::get_string 1318 ns 1318 ns 517157 -StdFunction_call::returnNonVoid 1878 ns 1878 ns 373119 -StdFunction_callMethod::returnNonVoid 1877 ns 1876 ns 372692 +bm_std::function_CallsFunction::get_string 1317 ns 1317 ns 519268 +bm_std::function___CallsMethod::get_string 1324 ns 1324 ns 521569 -RtlFunction_call::returnNonVoid 1874 ns 1874 ns 373273 -RtlFunction_callMethod::returnNonVoid 1874 ns 1874 ns 373279 +bm_rtl::function_CallsFunction::get_string 1316 ns 1316 ns 513808 +bm_rtl::method_____CallsMethod::get_string 1315 ns 1315 ns 519418 -RtlFunction_call_ReturnUnknown::NonVoid 1898 ns 1898 ns 368554 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1893 ns 1893 ns 369625 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1900 ns 1900 ns 368374 +bm_rtl::function_ErasedReturnType::get_string 1350 ns 1350 ns 501073 +bm_rtl::method___ErasedReturnType::get_string 1351 ns 1350 ns 514857 +bm_rtl::method___ErasedTargetType::get_string 1334 ns 1334 ns 521104 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1356 ns 1356 ns 511897 ----------------------------------- -[2025-10-09 22:39:42] >>> Run 4: workload scale = 74 +[2025-10-25 08:31:14] >>> Run 2: workload scale = 58 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 74 iterations +Scale : 58 iterations ============================================= -2025-10-09T22:39:42+05:30 +2025-10-25T08:31:14+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2251.16 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1693 ns 1693 ns 412694 +Load Average: 1.44, 1.40, 0.95 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1063 ns 1063 ns 635505 -NativeFunctionPtr_call::returnVoid 1695 ns 1695 ns 412741 -NativeFunctionPtr_callMethod::returnVoid 1694 ns 1694 ns 413429 +bm_call::by_FunctionPtr_Function::set_string 1064 ns 1064 ns 640683 +bm_call::by_FunctionPtr___Method::set_string 1083 ns 1083 ns 627856 -StdFunction_call::returnVoid 1693 ns 1693 ns 413657 -StdFunction_callMethod::returnVoid 1698 ns 1698 ns 412501 +bm_std::function_CallsFunction::set_string 1082 ns 1082 ns 642487 +bm_std::function___CallsMethod::set_string 1093 ns 1093 ns 606137 -RtlFunction_call::returnVoid 1693 ns 1693 ns 413448 -RtlFunction_callMethod::returnVoid 1694 ns 1694 ns 413417 +bm_rtl::function_CallsFunction::set_string 1068 ns 1068 ns 636794 +bm_rtl::method_____CallsMethod::set_string 1071 ns 1071 ns 638437 -RtlFunction_call_ReturnUnknown::Void 1705 ns 1704 ns 410623 -RtlFunction_callMethod_ReturnUnknown::Void 1696 ns 1696 ns 412685 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1702 ns 1702 ns 411282 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1918 ns 1918 ns 365470 +bm_rtl::function_ErasedReturnType::set_string 1079 ns 1079 ns 633153 +bm_rtl::method___ErasedReturnType::set_string 1080 ns 1080 ns 634223 +bm_rtl::method___ErasedTargetType::set_string 1084 ns 1084 ns 640960 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1086 ns 1086 ns 622752 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1408 ns 1408 ns 486469 -NativeFunctionPtr_call::returnNonVoid 1921 ns 1921 ns 364815 -NativeFunctionPtr_callMethod::returnNonVoid 1921 ns 1921 ns 364317 +bm_call::by_FunctionPtr_Function::get_string 1410 ns 1410 ns 488214 +bm_call::by_FunctionPtr___Method::get_string 1409 ns 1409 ns 486255 -StdFunction_call::returnNonVoid 1923 ns 1923 ns 363918 -StdFunction_callMethod::returnNonVoid 1923 ns 1923 ns 363502 +bm_std::function_CallsFunction::get_string 1409 ns 1409 ns 491521 +bm_std::function___CallsMethod::get_string 1416 ns 1416 ns 480957 -RtlFunction_call::returnNonVoid 1920 ns 1920 ns 364545 -RtlFunction_callMethod::returnNonVoid 1921 ns 1921 ns 364450 +bm_rtl::function_CallsFunction::get_string 1410 ns 1410 ns 483599 +bm_rtl::method_____CallsMethod::get_string 1330 ns 1330 ns 484411 -RtlFunction_call_ReturnUnknown::NonVoid 1947 ns 1947 ns 359754 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1937 ns 1937 ns 361172 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1946 ns 1946 ns 359430 +bm_rtl::function_ErasedReturnType::get_string 1368 ns 1368 ns 485899 +bm_rtl::method___ErasedReturnType::get_string 1378 ns 1378 ns 505612 +bm_rtl::method___ErasedTargetType::get_string 1349 ns 1349 ns 512357 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1378 ns 1378 ns 501375 ----------------------------------- -[2025-10-09 22:40:00] >>> Run 5: workload scale = 74 +[2025-10-25 08:31:32] >>> Run 3: workload scale = 58 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 74 iterations +Scale : 58 iterations ============================================= -2025-10-09T22:40:00+05:30 +2025-10-25T08:31:32+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2505.01 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1676 ns 1676 ns 417519 +Load Average: 1.34, 1.38, 0.96 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1033 ns 1033 ns 653562 -NativeFunctionPtr_call::returnVoid 1679 ns 1679 ns 417046 -NativeFunctionPtr_callMethod::returnVoid 1677 ns 1676 ns 417618 +bm_call::by_FunctionPtr_Function::set_string 1044 ns 1044 ns 676146 +bm_call::by_FunctionPtr___Method::set_string 1039 ns 1039 ns 660769 -StdFunction_call::returnVoid 1675 ns 1675 ns 417300 -StdFunction_callMethod::returnVoid 1680 ns 1680 ns 415928 +bm_std::function_CallsFunction::set_string 1036 ns 1036 ns 663675 +bm_std::function___CallsMethod::set_string 1038 ns 1038 ns 632749 -RtlFunction_call::returnVoid 1676 ns 1676 ns 418188 -RtlFunction_callMethod::returnVoid 1677 ns 1676 ns 417493 +bm_rtl::function_CallsFunction::set_string 1032 ns 1032 ns 660063 +bm_rtl::method_____CallsMethod::set_string 1033 ns 1033 ns 665554 -RtlFunction_call_ReturnUnknown::Void 1687 ns 1687 ns 414584 -RtlFunction_callMethod_ReturnUnknown::Void 1684 ns 1684 ns 415970 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1689 ns 1689 ns 414604 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1872 ns 1871 ns 374658 +bm_rtl::function_ErasedReturnType::set_string 1045 ns 1045 ns 656138 +bm_rtl::method___ErasedReturnType::set_string 1044 ns 1044 ns 657250 +bm_rtl::method___ErasedTargetType::set_string 1048 ns 1048 ns 650987 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1052 ns 1052 ns 648697 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1402 ns 1402 ns 491352 -NativeFunctionPtr_call::returnNonVoid 1870 ns 1870 ns 374480 -NativeFunctionPtr_callMethod::returnNonVoid 1869 ns 1869 ns 374314 +bm_call::by_FunctionPtr_Function::get_string 1401 ns 1401 ns 448467 +bm_call::by_FunctionPtr___Method::get_string 1399 ns 1399 ns 494260 -StdFunction_call::returnNonVoid 1872 ns 1872 ns 373200 -StdFunction_callMethod::returnNonVoid 1877 ns 1877 ns 373379 +bm_std::function_CallsFunction::get_string 1403 ns 1403 ns 486788 +bm_std::function___CallsMethod::get_string 1402 ns 1402 ns 485865 -RtlFunction_call::returnNonVoid 1870 ns 1870 ns 374416 -RtlFunction_callMethod::returnNonVoid 1869 ns 1869 ns 374204 +bm_rtl::function_CallsFunction::get_string 1400 ns 1400 ns 490048 +bm_rtl::method_____CallsMethod::get_string 1403 ns 1403 ns 477421 -RtlFunction_call_ReturnUnknown::NonVoid 1902 ns 1902 ns 368492 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1892 ns 1892 ns 370016 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 1900 ns 1900 ns 368252 +bm_rtl::function_ErasedReturnType::get_string 1430 ns 1430 ns 473002 +bm_rtl::method___ErasedReturnType::get_string 1433 ns 1433 ns 476489 +bm_rtl::method___ErasedTargetType::get_string 1330 ns 1330 ns 459592 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1362 ns 1362 ns 503378 ----------------------------------- -[2025-10-09 22:40:18] >>> Run 1: workload scale = 82 +[2025-10-25 08:31:50] >>> Run 1: workload scale = 66 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 82 iterations +Scale : 66 iterations ============================================= -2025-10-09T22:40:18+05:30 +2025-10-25T08:31:50+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3667.44 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1765 ns 1764 ns 396103 +Load Average: 1.24, 1.35, 0.96 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1641 ns 1641 ns 412193 -NativeFunctionPtr_call::returnVoid 1767 ns 1767 ns 396034 -NativeFunctionPtr_callMethod::returnVoid 1766 ns 1766 ns 396530 +bm_call::by_FunctionPtr_Function::set_string 1639 ns 1639 ns 421723 +bm_call::by_FunctionPtr___Method::set_string 1644 ns 1643 ns 417838 -StdFunction_call::returnVoid 1765 ns 1765 ns 396669 -StdFunction_callMethod::returnVoid 1772 ns 1772 ns 395166 +bm_std::function_CallsFunction::set_string 1640 ns 1640 ns 417527 +bm_std::function___CallsMethod::set_string 1655 ns 1655 ns 421014 -RtlFunction_call::returnVoid 1764 ns 1764 ns 396604 -RtlFunction_callMethod::returnVoid 1766 ns 1765 ns 396195 +bm_rtl::function_CallsFunction::set_string 1640 ns 1640 ns 418821 +bm_rtl::method_____CallsMethod::set_string 1654 ns 1654 ns 409820 -RtlFunction_call_ReturnUnknown::Void 1772 ns 1772 ns 395162 -RtlFunction_callMethod_ReturnUnknown::Void 1767 ns 1767 ns 396402 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1772 ns 1772 ns 394985 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2018 ns 2018 ns 346687 +bm_rtl::function_ErasedReturnType::set_string 1674 ns 1674 ns 418479 +bm_rtl::method___ErasedReturnType::set_string 1661 ns 1661 ns 418139 +bm_rtl::method___ErasedTargetType::set_string 1664 ns 1664 ns 418528 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1664 ns 1664 ns 418322 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1945 ns 1945 ns 354277 -NativeFunctionPtr_call::returnNonVoid 2017 ns 2017 ns 346410 -NativeFunctionPtr_callMethod::returnNonVoid 2019 ns 2018 ns 346463 +bm_call::by_FunctionPtr_Function::get_string 1960 ns 1959 ns 354803 +bm_call::by_FunctionPtr___Method::get_string 1972 ns 1972 ns 355522 -StdFunction_call::returnNonVoid 2022 ns 2022 ns 346385 -StdFunction_callMethod::returnNonVoid 2023 ns 2023 ns 346094 +bm_std::function_CallsFunction::get_string 1945 ns 1944 ns 357891 +bm_std::function___CallsMethod::get_string 1954 ns 1954 ns 357123 -RtlFunction_call::returnNonVoid 2018 ns 2018 ns 347016 -RtlFunction_callMethod::returnNonVoid 2018 ns 2018 ns 346613 +bm_rtl::function_CallsFunction::get_string 1942 ns 1942 ns 358463 +bm_rtl::method_____CallsMethod::get_string 1945 ns 1944 ns 356140 -RtlFunction_call_ReturnUnknown::NonVoid 2043 ns 2043 ns 342739 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2038 ns 2038 ns 343160 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2046 ns 2045 ns 341702 +bm_rtl::function_ErasedReturnType::get_string 1978 ns 1978 ns 345108 +bm_rtl::method___ErasedReturnType::get_string 1987 ns 1987 ns 343202 +bm_rtl::method___ErasedTargetType::get_string 1984 ns 1983 ns 346992 +bm_rtl::method___ErasedTargetAndReturnType::get_string 1994 ns 1994 ns 347995 ----------------------------------- -[2025-10-09 22:40:36] >>> Run 2: workload scale = 82 +[2025-10-25 08:32:09] >>> Run 2: workload scale = 66 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 82 iterations +Scale : 66 iterations ============================================= -2025-10-09T22:40:36+05:30 +2025-10-25T08:32:09+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 1135.34 MHz CPU s) +Run on (16 X 4000.93 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1761 ns 1760 ns 397427 +Load Average: 1.17, 1.33, 0.96 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1645 ns 1645 ns 415761 -NativeFunctionPtr_call::returnVoid 1761 ns 1761 ns 397592 -NativeFunctionPtr_callMethod::returnVoid 1759 ns 1759 ns 396975 +bm_call::by_FunctionPtr_Function::set_string 1654 ns 1654 ns 408700 +bm_call::by_FunctionPtr___Method::set_string 1655 ns 1654 ns 419621 -StdFunction_call::returnVoid 1759 ns 1759 ns 397680 -StdFunction_callMethod::returnVoid 1765 ns 1765 ns 397152 +bm_std::function_CallsFunction::set_string 1644 ns 1644 ns 416574 +bm_std::function___CallsMethod::set_string 1664 ns 1663 ns 420065 -RtlFunction_call::returnVoid 1759 ns 1758 ns 397971 -RtlFunction_callMethod::returnVoid 1759 ns 1759 ns 397676 +bm_rtl::function_CallsFunction::set_string 1644 ns 1644 ns 422602 +bm_rtl::method_____CallsMethod::set_string 1649 ns 1648 ns 410531 -RtlFunction_call_ReturnUnknown::Void 1767 ns 1767 ns 396426 -RtlFunction_callMethod_ReturnUnknown::Void 1759 ns 1758 ns 398399 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1763 ns 1762 ns 397242 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1978 ns 1977 ns 354040 +bm_rtl::function_ErasedReturnType::set_string 1683 ns 1682 ns 401698 +bm_rtl::method___ErasedReturnType::set_string 1759 ns 1759 ns 416906 +bm_rtl::method___ErasedTargetType::set_string 1698 ns 1698 ns 400002 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1682 ns 1682 ns 403504 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1954 ns 1954 ns 345967 -NativeFunctionPtr_call::returnNonVoid 1969 ns 1968 ns 355603 -NativeFunctionPtr_callMethod::returnNonVoid 1969 ns 1969 ns 355704 +bm_call::by_FunctionPtr_Function::get_string 1974 ns 1974 ns 352961 +bm_call::by_FunctionPtr___Method::get_string 1964 ns 1963 ns 347646 -StdFunction_call::returnNonVoid 1971 ns 1971 ns 353677 -StdFunction_callMethod::returnNonVoid 1975 ns 1975 ns 354680 +bm_std::function_CallsFunction::get_string 1980 ns 1979 ns 343104 +bm_std::function___CallsMethod::get_string 1996 ns 1996 ns 340852 -RtlFunction_call::returnNonVoid 1970 ns 1970 ns 355759 -RtlFunction_callMethod::returnNonVoid 1969 ns 1969 ns 355124 +bm_rtl::function_CallsFunction::get_string 1980 ns 1980 ns 343611 +bm_rtl::method_____CallsMethod::get_string 1954 ns 1954 ns 353870 -RtlFunction_call_ReturnUnknown::NonVoid 2003 ns 2003 ns 349397 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1998 ns 1998 ns 350705 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2009 ns 2009 ns 349110 +bm_rtl::function_ErasedReturnType::get_string 2027 ns 2027 ns 336628 +bm_rtl::method___ErasedReturnType::get_string 2094 ns 2094 ns 330396 +bm_rtl::method___ErasedTargetType::get_string 2103 ns 2102 ns 332761 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2120 ns 2121 ns 320103 ----------------------------------- -[2025-10-09 22:40:55] >>> Run 3: workload scale = 82 +[2025-10-25 08:32:29] >>> Run 3: workload scale = 66 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 82 iterations +Scale : 66 iterations ============================================= -2025-10-09T22:40:55+05:30 +2025-10-25T08:32:29+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4073.84 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1756 ns 1755 ns 398587 +Load Average: 1.20, 1.32, 0.97 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1650 ns 1650 ns 365465 -NativeFunctionPtr_call::returnVoid 1757 ns 1757 ns 398159 -NativeFunctionPtr_callMethod::returnVoid 1755 ns 1755 ns 398777 +bm_call::by_FunctionPtr_Function::set_string 1669 ns 1669 ns 424816 +bm_call::by_FunctionPtr___Method::set_string 1690 ns 1690 ns 399614 -StdFunction_call::returnVoid 1756 ns 1756 ns 398645 -StdFunction_callMethod::returnVoid 1761 ns 1761 ns 398296 +bm_std::function_CallsFunction::set_string 1638 ns 1638 ns 416539 +bm_std::function___CallsMethod::set_string 1639 ns 1639 ns 421581 -RtlFunction_call::returnVoid 1756 ns 1756 ns 398762 -RtlFunction_callMethod::returnVoid 1759 ns 1758 ns 398916 +bm_rtl::function_CallsFunction::set_string 1636 ns 1635 ns 423276 +bm_rtl::method_____CallsMethod::set_string 1640 ns 1640 ns 424255 -RtlFunction_call_ReturnUnknown::Void 1763 ns 1763 ns 396837 -RtlFunction_callMethod_ReturnUnknown::Void 1757 ns 1757 ns 398736 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1763 ns 1762 ns 397320 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1971 ns 1970 ns 356090 +bm_rtl::function_ErasedReturnType::set_string 1660 ns 1660 ns 415799 +bm_rtl::method___ErasedReturnType::set_string 1704 ns 1704 ns 400690 +bm_rtl::method___ErasedTargetType::set_string 1663 ns 1663 ns 413724 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1659 ns 1659 ns 419075 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 1954 ns 1954 ns 355079 -NativeFunctionPtr_call::returnNonVoid 1967 ns 1966 ns 356192 -NativeFunctionPtr_callMethod::returnNonVoid 1967 ns 1966 ns 356038 +bm_call::by_FunctionPtr_Function::get_string 1954 ns 1954 ns 353538 +bm_call::by_FunctionPtr___Method::get_string 1952 ns 1952 ns 353309 -StdFunction_call::returnNonVoid 1971 ns 1971 ns 353175 -StdFunction_callMethod::returnNonVoid 1971 ns 1971 ns 354723 +bm_std::function_CallsFunction::get_string 1972 ns 1972 ns 352881 +bm_std::function___CallsMethod::get_string 2057 ns 2053 ns 352379 -RtlFunction_call::returnNonVoid 1970 ns 1970 ns 355458 -RtlFunction_callMethod::returnNonVoid 1967 ns 1967 ns 355902 +bm_rtl::function_CallsFunction::get_string 1953 ns 1954 ns 336499 +bm_rtl::method_____CallsMethod::get_string 1971 ns 1970 ns 353984 -RtlFunction_call_ReturnUnknown::NonVoid 1996 ns 1996 ns 351337 -RtlFunction_callMethod_ReturnUnknown::NonVoid 1989 ns 1989 ns 352047 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2000 ns 2000 ns 350827 +bm_rtl::function_ErasedReturnType::get_string 2080 ns 2079 ns 336928 +bm_rtl::method___ErasedReturnType::get_string 2121 ns 2120 ns 327293 +bm_rtl::method___ErasedTargetType::get_string 2069 ns 2069 ns 333408 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2088 ns 2087 ns 332177 ----------------------------------- -[2025-10-09 22:41:13] >>> Run 4: workload scale = 82 +[2025-10-25 08:32:49] >>> Run 1: workload scale = 74 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 82 iterations +Scale : 74 iterations ============================================= -2025-10-09T22:41:13+05:30 +2025-10-25T08:32:49+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2701.98 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1774 ns 1774 ns 394692 +Load Average: 1.14, 1.30, 0.97 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1697 ns 1697 ns 406949 -NativeFunctionPtr_call::returnVoid 1778 ns 1778 ns 394712 -NativeFunctionPtr_callMethod::returnVoid 1773 ns 1773 ns 394819 +bm_call::by_FunctionPtr_Function::set_string 1694 ns 1694 ns 401873 +bm_call::by_FunctionPtr___Method::set_string 1694 ns 1694 ns 407047 -StdFunction_call::returnVoid 1774 ns 1774 ns 394600 -StdFunction_callMethod::returnVoid 1785 ns 1784 ns 392790 +bm_std::function_CallsFunction::set_string 1695 ns 1695 ns 406108 +bm_std::function___CallsMethod::set_string 1707 ns 1707 ns 406647 -RtlFunction_call::returnVoid 1773 ns 1773 ns 394658 -RtlFunction_callMethod::returnVoid 1775 ns 1775 ns 394979 +bm_rtl::function_CallsFunction::set_string 1702 ns 1702 ns 410421 +bm_rtl::method_____CallsMethod::set_string 1703 ns 1703 ns 407913 -RtlFunction_call_ReturnUnknown::Void 1786 ns 1785 ns 392102 -RtlFunction_callMethod_ReturnUnknown::Void 1779 ns 1779 ns 393901 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1782 ns 1782 ns 393097 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2034 ns 2034 ns 344484 +bm_rtl::function_ErasedReturnType::set_string 1723 ns 1723 ns 403518 +bm_rtl::method___ErasedReturnType::set_string 1724 ns 1723 ns 400739 +bm_rtl::method___ErasedTargetType::set_string 1708 ns 1708 ns 384649 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1712 ns 1712 ns 400208 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2056 ns 2056 ns 334788 -NativeFunctionPtr_call::returnNonVoid 2030 ns 2030 ns 344790 -NativeFunctionPtr_callMethod::returnNonVoid 2032 ns 2032 ns 344393 +bm_call::by_FunctionPtr_Function::get_string 2056 ns 2056 ns 334349 +bm_call::by_FunctionPtr___Method::get_string 2055 ns 2055 ns 334176 -StdFunction_call::returnNonVoid 2034 ns 2034 ns 342985 -StdFunction_callMethod::returnNonVoid 2040 ns 2040 ns 343340 +bm_std::function_CallsFunction::get_string 2056 ns 2055 ns 335245 +bm_std::function___CallsMethod::get_string 2061 ns 2061 ns 336646 -RtlFunction_call::returnNonVoid 2034 ns 2033 ns 344828 -RtlFunction_callMethod::returnNonVoid 2030 ns 2030 ns 344623 +bm_rtl::function_CallsFunction::get_string 2056 ns 2056 ns 336772 +bm_rtl::method_____CallsMethod::get_string 2059 ns 2059 ns 332961 -RtlFunction_call_ReturnUnknown::NonVoid 2065 ns 2065 ns 339605 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2055 ns 2054 ns 340562 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2066 ns 2066 ns 339528 +bm_rtl::function_ErasedReturnType::get_string 2101 ns 2100 ns 331315 +bm_rtl::method___ErasedReturnType::get_string 2111 ns 2111 ns 325895 +bm_rtl::method___ErasedTargetType::get_string 2073 ns 2073 ns 333731 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2110 ns 2110 ns 328204 ----------------------------------- -[2025-10-09 22:41:31] >>> Run 5: workload scale = 82 +[2025-10-25 08:33:09] >>> Run 2: workload scale = 74 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 82 iterations +Scale : 74 iterations ============================================= -2025-10-09T22:41:31+05:30 +2025-10-25T08:33:09+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4876.82 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1759 ns 1759 ns 398238 +Load Average: 1.10, 1.28, 0.97 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1704 ns 1704 ns 404192 -NativeFunctionPtr_call::returnVoid 1761 ns 1761 ns 397991 -NativeFunctionPtr_callMethod::returnVoid 1760 ns 1759 ns 397731 +bm_call::by_FunctionPtr_Function::set_string 1708 ns 1708 ns 399263 +bm_call::by_FunctionPtr___Method::set_string 1699 ns 1699 ns 383305 -StdFunction_call::returnVoid 1759 ns 1759 ns 397634 -StdFunction_callMethod::returnVoid 1769 ns 1769 ns 395694 +bm_std::function_CallsFunction::set_string 1699 ns 1699 ns 408931 +bm_std::function___CallsMethod::set_string 1707 ns 1706 ns 404996 -RtlFunction_call::returnVoid 1760 ns 1759 ns 398155 -RtlFunction_callMethod::returnVoid 1760 ns 1760 ns 397884 +bm_rtl::function_CallsFunction::set_string 1698 ns 1698 ns 401629 +bm_rtl::method_____CallsMethod::set_string 1713 ns 1713 ns 408609 -RtlFunction_call_ReturnUnknown::Void 1768 ns 1767 ns 395892 -RtlFunction_callMethod_ReturnUnknown::Void 1761 ns 1761 ns 397262 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1772 ns 1771 ns 395650 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 1977 ns 1977 ns 353581 +bm_rtl::function_ErasedReturnType::set_string 1717 ns 1717 ns 404724 +bm_rtl::method___ErasedReturnType::set_string 1710 ns 1710 ns 408370 +bm_rtl::method___ErasedTargetType::set_string 1710 ns 1710 ns 378159 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1720 ns 1720 ns 401154 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2060 ns 2060 ns 335768 -NativeFunctionPtr_call::returnNonVoid 1975 ns 1975 ns 354607 -NativeFunctionPtr_callMethod::returnNonVoid 1975 ns 1975 ns 354429 +bm_call::by_FunctionPtr_Function::get_string 2055 ns 2055 ns 337995 +bm_call::by_FunctionPtr___Method::get_string 2060 ns 2060 ns 336425 -StdFunction_call::returnNonVoid 1977 ns 1977 ns 354100 -StdFunction_callMethod::returnNonVoid 1990 ns 1990 ns 351306 +bm_std::function_CallsFunction::get_string 2056 ns 2056 ns 338343 +bm_std::function___CallsMethod::get_string 2067 ns 2067 ns 336134 -RtlFunction_call::returnNonVoid 1974 ns 1974 ns 354710 -RtlFunction_callMethod::returnNonVoid 1974 ns 1974 ns 354700 +bm_rtl::function_CallsFunction::get_string 2166 ns 2166 ns 339526 +bm_rtl::method_____CallsMethod::get_string 2147 ns 2147 ns 325746 -RtlFunction_call_ReturnUnknown::NonVoid 2009 ns 2008 ns 348830 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2000 ns 2000 ns 349537 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2004 ns 2004 ns 349186 +bm_rtl::function_ErasedReturnType::get_string 2193 ns 2193 ns 314638 +bm_rtl::method___ErasedReturnType::get_string 2194 ns 2193 ns 317047 +bm_rtl::method___ErasedTargetType::get_string 2074 ns 2074 ns 327298 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2105 ns 2104 ns 330671 ----------------------------------- -[2025-10-09 22:41:49] >>> Run 1: workload scale = 90 +[2025-10-25 08:33:29] >>> Run 3: workload scale = 74 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 90 iterations +Scale : 74 iterations ============================================= -2025-10-09T22:41:49+05:30 +2025-10-25T08:33:29+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2993.46 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1825 ns 1825 ns 382826 +Load Average: 1.07, 1.26, 0.97 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1708 ns 1708 ns 407515 -NativeFunctionPtr_call::returnVoid 1828 ns 1828 ns 382809 -NativeFunctionPtr_callMethod::returnVoid 1828 ns 1828 ns 382836 +bm_call::by_FunctionPtr_Function::set_string 1696 ns 1696 ns 409851 +bm_call::by_FunctionPtr___Method::set_string 1700 ns 1700 ns 378158 -StdFunction_call::returnVoid 1829 ns 1829 ns 383031 -StdFunction_callMethod::returnVoid 1827 ns 1827 ns 383073 +bm_std::function_CallsFunction::set_string 1697 ns 1696 ns 402302 +bm_std::function___CallsMethod::set_string 1702 ns 1702 ns 407699 -RtlFunction_call::returnVoid 1827 ns 1827 ns 383289 -RtlFunction_callMethod::returnVoid 1827 ns 1827 ns 383090 +bm_rtl::function_CallsFunction::set_string 1697 ns 1697 ns 409996 +bm_rtl::method_____CallsMethod::set_string 1700 ns 1700 ns 411719 -RtlFunction_call_ReturnUnknown::Void 1833 ns 1833 ns 382184 -RtlFunction_callMethod_ReturnUnknown::Void 1831 ns 1831 ns 382123 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1831 ns 1831 ns 382028 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2058 ns 2058 ns 339842 +bm_rtl::function_ErasedReturnType::set_string 1710 ns 1710 ns 404169 +bm_rtl::method___ErasedReturnType::set_string 1723 ns 1723 ns 398981 +bm_rtl::method___ErasedTargetType::set_string 1714 ns 1714 ns 381104 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1720 ns 1720 ns 393269 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2066 ns 2066 ns 331466 -NativeFunctionPtr_call::returnNonVoid 2060 ns 2060 ns 339863 -NativeFunctionPtr_callMethod::returnNonVoid 2060 ns 2060 ns 339965 +bm_call::by_FunctionPtr_Function::get_string 2055 ns 2054 ns 336380 +bm_call::by_FunctionPtr___Method::get_string 2054 ns 2054 ns 338278 -StdFunction_call::returnNonVoid 2061 ns 2061 ns 339854 -StdFunction_callMethod::returnNonVoid 2059 ns 2059 ns 340183 +bm_std::function_CallsFunction::get_string 2056 ns 2055 ns 337711 +bm_std::function___CallsMethod::get_string 2061 ns 2061 ns 335271 -RtlFunction_call::returnNonVoid 2060 ns 2060 ns 339724 -RtlFunction_callMethod::returnNonVoid 2060 ns 2060 ns 339734 +bm_rtl::function_CallsFunction::get_string 2054 ns 2054 ns 331481 +bm_rtl::method_____CallsMethod::get_string 2055 ns 2055 ns 334503 -RtlFunction_call_ReturnUnknown::NonVoid 2081 ns 2080 ns 336513 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2072 ns 2072 ns 337885 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2076 ns 2076 ns 337164 +bm_rtl::function_ErasedReturnType::get_string 2092 ns 2092 ns 329649 +bm_rtl::method___ErasedReturnType::get_string 2098 ns 2098 ns 328223 +bm_rtl::method___ErasedTargetType::get_string 2073 ns 2073 ns 332538 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2104 ns 2104 ns 327401 ----------------------------------- -[2025-10-09 22:42:08] >>> Run 2: workload scale = 90 +[2025-10-25 08:33:48] >>> Run 1: workload scale = 82 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 90 iterations +Scale : 82 iterations ============================================= -2025-10-09T22:42:08+05:30 +2025-10-25T08:33:48+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3588.8 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.08, 1.02, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1835 ns 1834 ns 381565 +Load Average: 1.05, 1.25, 0.97 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1779 ns 1779 ns 387486 -NativeFunctionPtr_call::returnVoid 1833 ns 1833 ns 381819 -NativeFunctionPtr_callMethod::returnVoid 1825 ns 1825 ns 382935 +bm_call::by_FunctionPtr_Function::set_string 1794 ns 1794 ns 387209 +bm_call::by_FunctionPtr___Method::set_string 1779 ns 1779 ns 388305 -StdFunction_call::returnVoid 1826 ns 1826 ns 383228 -StdFunction_callMethod::returnVoid 1831 ns 1831 ns 382737 +bm_std::function_CallsFunction::set_string 1787 ns 1787 ns 389820 +bm_std::function___CallsMethod::set_string 1810 ns 1810 ns 391535 -RtlFunction_call::returnVoid 1826 ns 1825 ns 383644 -RtlFunction_callMethod::returnVoid 1823 ns 1823 ns 383323 +bm_rtl::function_CallsFunction::set_string 1797 ns 1797 ns 379250 +bm_rtl::method_____CallsMethod::set_string 1778 ns 1778 ns 388107 -RtlFunction_call_ReturnUnknown::Void 1831 ns 1830 ns 382699 -RtlFunction_callMethod_ReturnUnknown::Void 1826 ns 1826 ns 383607 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1831 ns 1831 ns 381873 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2059 ns 2059 ns 340004 +bm_rtl::function_ErasedReturnType::set_string 1810 ns 1810 ns 384295 +bm_rtl::method___ErasedReturnType::set_string 1787 ns 1786 ns 364818 +bm_rtl::method___ErasedTargetType::set_string 1788 ns 1787 ns 384642 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1791 ns 1791 ns 383000 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2177 ns 2176 ns 317302 -NativeFunctionPtr_call::returnNonVoid 2064 ns 2064 ns 338970 -NativeFunctionPtr_callMethod::returnNonVoid 2064 ns 2064 ns 339262 +bm_call::by_FunctionPtr_Function::get_string 2172 ns 2172 ns 318645 +bm_call::by_FunctionPtr___Method::get_string 2174 ns 2174 ns 318447 -StdFunction_call::returnNonVoid 2065 ns 2065 ns 339070 -StdFunction_callMethod::returnNonVoid 2071 ns 2071 ns 338202 +bm_std::function_CallsFunction::get_string 2174 ns 2174 ns 319232 +bm_std::function___CallsMethod::get_string 2197 ns 2197 ns 316734 -RtlFunction_call::returnNonVoid 2063 ns 2063 ns 339252 -RtlFunction_callMethod::returnNonVoid 2064 ns 2064 ns 339093 +bm_rtl::function_CallsFunction::get_string 2172 ns 2172 ns 318832 +bm_rtl::method_____CallsMethod::get_string 2172 ns 2172 ns 316541 -RtlFunction_call_ReturnUnknown::NonVoid 2086 ns 2086 ns 335254 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2078 ns 2078 ns 336857 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2085 ns 2085 ns 335233 +bm_rtl::function_ErasedReturnType::get_string 2219 ns 2219 ns 312813 +bm_rtl::method___ErasedReturnType::get_string 2218 ns 2218 ns 311007 +bm_rtl::method___ErasedTargetType::get_string 2190 ns 2190 ns 314579 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2225 ns 2225 ns 309521 ----------------------------------- -[2025-10-09 22:42:26] >>> Run 3: workload scale = 90 +[2025-10-25 08:34:09] >>> Run 2: workload scale = 82 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 90 iterations +Scale : 82 iterations ============================================= -2025-10-09T22:42:26+05:30 +2025-10-25T08:34:09+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4156.76 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.06, 1.02, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1848 ns 1848 ns 378323 +Load Average: 1.11, 1.25, 0.98 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1784 ns 1784 ns 367827 -NativeFunctionPtr_call::returnVoid 1850 ns 1850 ns 378621 -NativeFunctionPtr_callMethod::returnVoid 1845 ns 1845 ns 379576 +bm_call::by_FunctionPtr_Function::set_string 1780 ns 1780 ns 390498 +bm_call::by_FunctionPtr___Method::set_string 1777 ns 1778 ns 388454 -StdFunction_call::returnVoid 1846 ns 1846 ns 379452 -StdFunction_callMethod::returnVoid 1851 ns 1851 ns 378151 +bm_std::function_CallsFunction::set_string 1779 ns 1778 ns 389015 +bm_std::function___CallsMethod::set_string 1791 ns 1791 ns 381515 -RtlFunction_call::returnVoid 1846 ns 1846 ns 379187 -RtlFunction_callMethod::returnVoid 1846 ns 1846 ns 379242 +bm_rtl::function_CallsFunction::set_string 1774 ns 1774 ns 383265 +bm_rtl::method_____CallsMethod::set_string 1777 ns 1777 ns 391082 -RtlFunction_call_ReturnUnknown::Void 1859 ns 1859 ns 376224 -RtlFunction_callMethod_ReturnUnknown::Void 1854 ns 1854 ns 377715 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1861 ns 1860 ns 376177 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2076 ns 2076 ns 337143 +bm_rtl::function_ErasedReturnType::set_string 1781 ns 1781 ns 378135 +bm_rtl::method___ErasedReturnType::set_string 1782 ns 1782 ns 387188 +bm_rtl::method___ErasedTargetType::set_string 1790 ns 1790 ns 384569 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1789 ns 1788 ns 386650 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2189 ns 2189 ns 317309 -NativeFunctionPtr_call::returnNonVoid 2078 ns 2077 ns 337457 -NativeFunctionPtr_callMethod::returnNonVoid 2077 ns 2077 ns 337143 +bm_call::by_FunctionPtr_Function::get_string 2193 ns 2193 ns 314034 +bm_call::by_FunctionPtr___Method::get_string 2174 ns 2174 ns 313889 -StdFunction_call::returnNonVoid 2077 ns 2076 ns 336986 -StdFunction_callMethod::returnNonVoid 2083 ns 2083 ns 336041 +bm_std::function_CallsFunction::get_string 2268 ns 2268 ns 304192 +bm_std::function___CallsMethod::get_string 2303 ns 2303 ns 304211 -RtlFunction_call::returnNonVoid 2076 ns 2076 ns 337229 -RtlFunction_callMethod::returnNonVoid 2078 ns 2077 ns 336822 +bm_rtl::function_CallsFunction::get_string 2272 ns 2272 ns 301322 +bm_rtl::method_____CallsMethod::get_string 2269 ns 2269 ns 306845 -RtlFunction_call_ReturnUnknown::NonVoid 2120 ns 2119 ns 330714 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2102 ns 2102 ns 332859 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2116 ns 2116 ns 330867 +bm_rtl::function_ErasedReturnType::get_string 2312 ns 2311 ns 297662 +bm_rtl::method___ErasedReturnType::get_string 2313 ns 2313 ns 299116 +bm_rtl::method___ErasedTargetType::get_string 2300 ns 2300 ns 301456 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2322 ns 2322 ns 296404 ----------------------------------- -[2025-10-09 22:42:44] >>> Run 4: workload scale = 90 +[2025-10-25 08:34:29] >>> Run 3: workload scale = 82 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 90 iterations +Scale : 82 iterations ============================================= -2025-10-09T22:42:44+05:30 +2025-10-25T08:34:29+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2493.05 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.04, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1873 ns 1873 ns 373623 +Load Average: 1.13, 1.24, 0.99 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1779 ns 1779 ns 383358 -NativeFunctionPtr_call::returnVoid 1877 ns 1877 ns 372676 -NativeFunctionPtr_callMethod::returnVoid 1874 ns 1874 ns 373712 +bm_call::by_FunctionPtr_Function::set_string 1775 ns 1775 ns 389326 +bm_call::by_FunctionPtr___Method::set_string 1788 ns 1788 ns 386498 -StdFunction_call::returnVoid 1874 ns 1874 ns 373609 -StdFunction_callMethod::returnVoid 1877 ns 1877 ns 372992 +bm_std::function_CallsFunction::set_string 1804 ns 1804 ns 384468 +bm_std::function___CallsMethod::set_string 1815 ns 1815 ns 385798 -RtlFunction_call::returnVoid 1875 ns 1875 ns 373439 -RtlFunction_callMethod::returnVoid 1873 ns 1873 ns 373683 +bm_rtl::function_CallsFunction::set_string 1838 ns 1838 ns 368710 +bm_rtl::method_____CallsMethod::set_string 1810 ns 1810 ns 368489 -RtlFunction_call_ReturnUnknown::Void 1881 ns 1881 ns 372270 -RtlFunction_callMethod_ReturnUnknown::Void 1874 ns 1874 ns 373602 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1881 ns 1881 ns 371886 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2151 ns 2151 ns 325389 +bm_rtl::function_ErasedReturnType::set_string 1818 ns 1818 ns 383808 +bm_rtl::method___ErasedReturnType::set_string 1818 ns 1818 ns 369718 +bm_rtl::method___ErasedTargetType::set_string 1795 ns 1795 ns 380611 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1826 ns 1826 ns 383829 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2220 ns 2220 ns 314628 -NativeFunctionPtr_call::returnNonVoid 2156 ns 2155 ns 324646 -NativeFunctionPtr_callMethod::returnNonVoid 2155 ns 2155 ns 324623 +bm_call::by_FunctionPtr_Function::get_string 2213 ns 2213 ns 310711 +bm_call::by_FunctionPtr___Method::get_string 2217 ns 2217 ns 311869 -StdFunction_call::returnNonVoid 2157 ns 2156 ns 324551 -StdFunction_callMethod::returnNonVoid 2162 ns 2161 ns 323798 +bm_std::function_CallsFunction::get_string 2223 ns 2223 ns 306243 +bm_std::function___CallsMethod::get_string 2234 ns 2234 ns 302403 -RtlFunction_call::returnNonVoid 2155 ns 2155 ns 324812 -RtlFunction_callMethod::returnNonVoid 2156 ns 2156 ns 324764 +bm_rtl::function_CallsFunction::get_string 2189 ns 2189 ns 308538 +bm_rtl::method_____CallsMethod::get_string 2221 ns 2221 ns 320200 -RtlFunction_call_ReturnUnknown::NonVoid 2179 ns 2179 ns 321245 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2174 ns 2174 ns 321847 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2183 ns 2183 ns 320763 +bm_rtl::function_ErasedReturnType::get_string 2277 ns 2276 ns 302587 +bm_rtl::method___ErasedReturnType::get_string 2258 ns 2258 ns 309144 +bm_rtl::method___ErasedTargetType::get_string 2207 ns 2207 ns 306786 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2232 ns 2232 ns 313358 ----------------------------------- -[2025-10-09 22:43:03] >>> Run 5: workload scale = 90 +[2025-10-25 08:34:49] >>> Run 1: workload scale = 90 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 90 iterations ============================================= -2025-10-09T22:43:03+05:30 +2025-10-25T08:34:49+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 1424.19 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.03, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1826 ns 1825 ns 382952 +Load Average: 1.38, 1.29, 1.01 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1933 ns 1933 ns 349906 -NativeFunctionPtr_call::returnVoid 1828 ns 1828 ns 383457 -NativeFunctionPtr_callMethod::returnVoid 1827 ns 1827 ns 383968 +bm_call::by_FunctionPtr_Function::set_string 1917 ns 1917 ns 345429 +bm_call::by_FunctionPtr___Method::set_string 1902 ns 1901 ns 361299 -StdFunction_call::returnVoid 1825 ns 1825 ns 383632 -StdFunction_callMethod::returnVoid 1829 ns 1829 ns 382087 +bm_std::function_CallsFunction::set_string 1878 ns 1878 ns 366506 +bm_std::function___CallsMethod::set_string 1901 ns 1901 ns 363119 -RtlFunction_call::returnVoid 1826 ns 1825 ns 383082 -RtlFunction_callMethod::returnVoid 1825 ns 1825 ns 382945 +bm_rtl::function_CallsFunction::set_string 1882 ns 1882 ns 361076 +bm_rtl::method_____CallsMethod::set_string 1880 ns 1880 ns 368733 -RtlFunction_call_ReturnUnknown::Void 1829 ns 1829 ns 382941 -RtlFunction_callMethod_ReturnUnknown::Void 1825 ns 1825 ns 383782 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1830 ns 1830 ns 382649 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2057 ns 2057 ns 340422 +bm_rtl::function_ErasedReturnType::set_string 1884 ns 1883 ns 367639 +bm_rtl::method___ErasedReturnType::set_string 1887 ns 1887 ns 366878 +bm_rtl::method___ErasedTargetType::set_string 1901 ns 1901 ns 367533 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1891 ns 1891 ns 366409 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2331 ns 2330 ns 299960 -NativeFunctionPtr_call::returnNonVoid 2062 ns 2062 ns 339517 -NativeFunctionPtr_callMethod::returnNonVoid 2062 ns 2062 ns 339289 +bm_call::by_FunctionPtr_Function::get_string 2331 ns 2331 ns 295021 +bm_call::by_FunctionPtr___Method::get_string 2331 ns 2330 ns 296435 -StdFunction_call::returnNonVoid 2063 ns 2063 ns 339492 -StdFunction_callMethod::returnNonVoid 2064 ns 2064 ns 339182 +bm_std::function_CallsFunction::get_string 2331 ns 2331 ns 297285 +bm_std::function___CallsMethod::get_string 2350 ns 2350 ns 296781 -RtlFunction_call::returnNonVoid 2061 ns 2061 ns 339423 -RtlFunction_callMethod::returnNonVoid 2062 ns 2062 ns 339404 +bm_rtl::function_CallsFunction::get_string 2337 ns 2337 ns 298852 +bm_rtl::method_____CallsMethod::get_string 2334 ns 2333 ns 298520 -RtlFunction_call_ReturnUnknown::NonVoid 2082 ns 2082 ns 335859 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2077 ns 2077 ns 336963 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2084 ns 2083 ns 336077 +bm_rtl::function_ErasedReturnType::get_string 2366 ns 2365 ns 293798 +bm_rtl::method___ErasedReturnType::get_string 2373 ns 2374 ns 289975 +bm_rtl::method___ErasedTargetType::get_string 2374 ns 2374 ns 293920 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2379 ns 2378 ns 293933 ----------------------------------- -[2025-10-09 22:43:21] >>> Run 1: workload scale = 100 +[2025-10-25 08:35:09] >>> Run 2: workload scale = 90 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 100 iterations +Scale : 90 iterations ============================================= -2025-10-09T22:43:21+05:30 +2025-10-25T08:35:09+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 4899.04 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.02, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1915 ns 1914 ns 365590 +Load Average: 1.27, 1.27, 1.01 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1852 ns 1852 ns 375676 -NativeFunctionPtr_call::returnVoid 1917 ns 1917 ns 365411 -NativeFunctionPtr_callMethod::returnVoid 1916 ns 1915 ns 365174 +bm_call::by_FunctionPtr_Function::set_string 1848 ns 1848 ns 375998 +bm_call::by_FunctionPtr___Method::set_string 1869 ns 1869 ns 366130 -StdFunction_call::returnVoid 1915 ns 1915 ns 365658 -StdFunction_callMethod::returnVoid 1919 ns 1919 ns 365034 +bm_std::function_CallsFunction::set_string 1877 ns 1877 ns 372184 +bm_std::function___CallsMethod::set_string 1859 ns 1858 ns 376433 -RtlFunction_call::returnVoid 1916 ns 1916 ns 365570 -RtlFunction_callMethod::returnVoid 1917 ns 1916 ns 365394 +bm_rtl::function_CallsFunction::set_string 1850 ns 1849 ns 376898 +bm_rtl::method_____CallsMethod::set_string 1855 ns 1855 ns 376759 -RtlFunction_call_ReturnUnknown::Void 1925 ns 1925 ns 364387 -RtlFunction_callMethod_ReturnUnknown::Void 1925 ns 1925 ns 363779 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1930 ns 1930 ns 362633 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2222 ns 2222 ns 314861 +bm_rtl::function_ErasedReturnType::set_string 1865 ns 1865 ns 371051 +bm_rtl::method___ErasedReturnType::set_string 1862 ns 1862 ns 372576 +bm_rtl::method___ErasedTargetType::set_string 1865 ns 1864 ns 374003 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1867 ns 1866 ns 360437 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2296 ns 2296 ns 302719 -NativeFunctionPtr_call::returnNonVoid 2220 ns 2220 ns 315456 -NativeFunctionPtr_callMethod::returnNonVoid 2220 ns 2219 ns 315353 +bm_call::by_FunctionPtr_Function::get_string 2297 ns 2297 ns 300343 +bm_call::by_FunctionPtr___Method::get_string 2298 ns 2298 ns 301440 -StdFunction_call::returnNonVoid 2223 ns 2222 ns 314941 -StdFunction_callMethod::returnNonVoid 2225 ns 2225 ns 314549 +bm_std::function_CallsFunction::get_string 2296 ns 2296 ns 302012 +bm_std::function___CallsMethod::get_string 2301 ns 2301 ns 303483 -RtlFunction_call::returnNonVoid 2221 ns 2220 ns 315626 -RtlFunction_callMethod::returnNonVoid 2222 ns 2222 ns 315388 +bm_rtl::function_CallsFunction::get_string 2299 ns 2298 ns 299325 +bm_rtl::method_____CallsMethod::get_string 2298 ns 2298 ns 296660 -RtlFunction_call_ReturnUnknown::NonVoid 2249 ns 2248 ns 311471 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2242 ns 2241 ns 312265 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2248 ns 2248 ns 310921 +bm_rtl::function_ErasedReturnType::get_string 2330 ns 2330 ns 296734 +bm_rtl::method___ErasedReturnType::get_string 2330 ns 2330 ns 297457 +bm_rtl::method___ErasedTargetType::get_string 2311 ns 2311 ns 298532 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2328 ns 2328 ns 296429 ----------------------------------- -[2025-10-09 22:43:40] >>> Run 2: workload scale = 100 +[2025-10-25 08:35:30] >>> Run 3: workload scale = 90 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 -Scale : 100 iterations +Scale : 90 iterations ============================================= -2025-10-09T22:43:40+05:30 +2025-10-25T08:35:30+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2681.19 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.02, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1950 ns 1950 ns 358882 +Load Average: 1.19, 1.25, 1.01 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1882 ns 1881 ns 362066 -NativeFunctionPtr_call::returnVoid 1933 ns 1933 ns 361914 -NativeFunctionPtr_callMethod::returnVoid 1934 ns 1933 ns 360542 +bm_call::by_FunctionPtr_Function::set_string 1908 ns 1908 ns 362543 +bm_call::by_FunctionPtr___Method::set_string 1881 ns 1881 ns 362704 -StdFunction_call::returnVoid 1934 ns 1934 ns 362422 -StdFunction_callMethod::returnVoid 1923 ns 1922 ns 364490 +bm_std::function_CallsFunction::set_string 1895 ns 1894 ns 368862 +bm_std::function___CallsMethod::set_string 1891 ns 1890 ns 364312 -RtlFunction_call::returnVoid 1932 ns 1932 ns 361923 -RtlFunction_callMethod::returnVoid 1937 ns 1937 ns 362152 +bm_rtl::function_CallsFunction::set_string 1881 ns 1880 ns 365398 +bm_rtl::method_____CallsMethod::set_string 1886 ns 1884 ns 366020 -RtlFunction_call_ReturnUnknown::Void 1923 ns 1923 ns 364112 -RtlFunction_callMethod_ReturnUnknown::Void 1919 ns 1919 ns 365375 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1920 ns 1920 ns 364660 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2216 ns 2216 ns 316147 +bm_rtl::function_ErasedReturnType::set_string 1895 ns 1893 ns 366268 +bm_rtl::method___ErasedReturnType::set_string 1896 ns 1895 ns 367781 +bm_rtl::method___ErasedTargetType::set_string 1898 ns 1897 ns 360838 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1902 ns 1901 ns 363268 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2440 ns 2438 ns 283334 -NativeFunctionPtr_call::returnNonVoid 2187 ns 2187 ns 319749 -NativeFunctionPtr_callMethod::returnNonVoid 2185 ns 2185 ns 320097 +bm_call::by_FunctionPtr_Function::get_string 2445 ns 2443 ns 281807 +bm_call::by_FunctionPtr___Method::get_string 2443 ns 2442 ns 282459 -StdFunction_call::returnNonVoid 2187 ns 2187 ns 318705 -StdFunction_callMethod::returnNonVoid 2185 ns 2184 ns 320225 +bm_std::function_CallsFunction::get_string 2441 ns 2440 ns 281487 +bm_std::function___CallsMethod::get_string 2450 ns 2448 ns 281680 -RtlFunction_call::returnNonVoid 2192 ns 2191 ns 320106 -RtlFunction_callMethod::returnNonVoid 2187 ns 2187 ns 320212 +bm_rtl::function_CallsFunction::get_string 2444 ns 2442 ns 278353 +bm_rtl::method_____CallsMethod::get_string 2443 ns 2441 ns 283136 -RtlFunction_call_ReturnUnknown::NonVoid 2208 ns 2207 ns 317529 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2197 ns 2197 ns 318468 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2208 ns 2208 ns 317680 +bm_rtl::function_ErasedReturnType::get_string 2480 ns 2478 ns 280665 +bm_rtl::method___ErasedReturnType::get_string 2487 ns 2485 ns 280503 +bm_rtl::method___ErasedTargetType::get_string 2458 ns 2457 ns 283885 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2491 ns 2490 ns 279281 ----------------------------------- -[2025-10-09 22:43:58] >>> Run 3: workload scale = 100 +[2025-10-25 08:35:50] >>> Run 1: workload scale = 100 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 100 iterations ============================================= -2025-10-09T22:43:58+05:30 +2025-10-25T08:35:50+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2723.35 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.01, 1.01, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1933 ns 1933 ns 361796 +Load Average: 1.14, 1.24, 1.01 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1954 ns 1953 ns 350463 -NativeFunctionPtr_call::returnVoid 1939 ns 1938 ns 361665 -NativeFunctionPtr_callMethod::returnVoid 1934 ns 1933 ns 362333 +bm_call::by_FunctionPtr_Function::set_string 1959 ns 1958 ns 351380 +bm_call::by_FunctionPtr___Method::set_string 1954 ns 1953 ns 356616 -StdFunction_call::returnVoid 1937 ns 1936 ns 362278 -StdFunction_callMethod::returnVoid 1936 ns 1936 ns 361500 +bm_std::function_CallsFunction::set_string 1961 ns 1960 ns 358462 +bm_std::function___CallsMethod::set_string 1957 ns 1956 ns 355388 -RtlFunction_call::returnVoid 1934 ns 1933 ns 362382 -RtlFunction_callMethod::returnVoid 1933 ns 1933 ns 360283 +bm_rtl::function_CallsFunction::set_string 1957 ns 1956 ns 352196 +bm_rtl::method_____CallsMethod::set_string 1949 ns 1948 ns 353989 -RtlFunction_call_ReturnUnknown::Void 1941 ns 1941 ns 360321 -RtlFunction_callMethod_ReturnUnknown::Void 1941 ns 1941 ns 361662 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1942 ns 1941 ns 360918 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2201 ns 2201 ns 318760 +bm_rtl::function_ErasedReturnType::set_string 1983 ns 1982 ns 351235 +bm_rtl::method___ErasedReturnType::set_string 1963 ns 1962 ns 353021 +bm_rtl::method___ErasedTargetType::set_string 1968 ns 1966 ns 353340 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1969 ns 1968 ns 352915 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2479 ns 2478 ns 281632 -NativeFunctionPtr_call::returnNonVoid 2194 ns 2194 ns 318782 -NativeFunctionPtr_callMethod::returnNonVoid 2198 ns 2198 ns 318698 +bm_call::by_FunctionPtr_Function::get_string 2477 ns 2476 ns 279233 +bm_call::by_FunctionPtr___Method::get_string 2476 ns 2474 ns 280922 -StdFunction_call::returnNonVoid 2198 ns 2198 ns 318178 -StdFunction_callMethod::returnNonVoid 2205 ns 2205 ns 317905 +bm_std::function_CallsFunction::get_string 2478 ns 2477 ns 272740 +bm_std::function___CallsMethod::get_string 2478 ns 2477 ns 277517 -RtlFunction_call::returnNonVoid 2196 ns 2195 ns 318521 -RtlFunction_callMethod::returnNonVoid 2198 ns 2198 ns 318881 +bm_rtl::function_CallsFunction::get_string 2478 ns 2477 ns 281494 +bm_rtl::method_____CallsMethod::get_string 2478 ns 2476 ns 279161 -RtlFunction_call_ReturnUnknown::NonVoid 2231 ns 2231 ns 313880 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2220 ns 2220 ns 315109 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2227 ns 2227 ns 312692 +bm_rtl::function_ErasedReturnType::get_string 2518 ns 2517 ns 275047 +bm_rtl::method___ErasedReturnType::get_string 2513 ns 2512 ns 275243 +bm_rtl::method___ErasedTargetType::get_string 2494 ns 2492 ns 279343 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2517 ns 2516 ns 270535 ----------------------------------- -[2025-10-09 22:44:17] >>> Run 4: workload scale = 100 +[2025-10-25 08:36:11] >>> Run 2: workload scale = 100 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 100 iterations ============================================= -2025-10-09T22:44:17+05:30 +2025-10-25T08:36:11+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -4574,146 +2771,50 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.01, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1915 ns 1914 ns 365356 +Load Average: 1.10, 1.22, 1.00 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1963 ns 1962 ns 353266 -NativeFunctionPtr_call::returnVoid 1919 ns 1919 ns 363376 -NativeFunctionPtr_callMethod::returnVoid 1916 ns 1916 ns 365649 +bm_call::by_FunctionPtr_Function::set_string 1999 ns 1998 ns 352801 +bm_call::by_FunctionPtr___Method::set_string 1956 ns 1955 ns 351957 -StdFunction_call::returnVoid 1919 ns 1919 ns 365532 -StdFunction_callMethod::returnVoid 1919 ns 1919 ns 364911 +bm_std::function_CallsFunction::set_string 1952 ns 1951 ns 355320 +bm_std::function___CallsMethod::set_string 1959 ns 1958 ns 354606 -RtlFunction_call::returnVoid 1918 ns 1918 ns 365585 -RtlFunction_callMethod::returnVoid 1916 ns 1916 ns 364302 +bm_rtl::function_CallsFunction::set_string 1968 ns 1966 ns 353484 +bm_rtl::method_____CallsMethod::set_string 1959 ns 1959 ns 351589 -RtlFunction_call_ReturnUnknown::Void 1924 ns 1924 ns 364010 -RtlFunction_callMethod_ReturnUnknown::Void 1921 ns 1921 ns 364316 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1924 ns 1924 ns 363660 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2178 ns 2177 ns 320166 +bm_rtl::function_ErasedReturnType::set_string 1970 ns 1969 ns 353459 +bm_rtl::method___ErasedReturnType::set_string 1966 ns 1965 ns 351721 +bm_rtl::method___ErasedTargetType::set_string 1970 ns 1969 ns 351911 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1974 ns 1972 ns 353143 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2575 ns 2574 ns 270466 -NativeFunctionPtr_call::returnNonVoid 2178 ns 2178 ns 321284 -NativeFunctionPtr_callMethod::returnNonVoid 2179 ns 2178 ns 320312 +bm_call::by_FunctionPtr_Function::get_string 2573 ns 2572 ns 266600 +bm_call::by_FunctionPtr___Method::get_string 2572 ns 2571 ns 268784 -StdFunction_call::returnNonVoid 2179 ns 2179 ns 321510 -StdFunction_callMethod::returnNonVoid 2190 ns 2190 ns 320512 +bm_std::function_CallsFunction::get_string 2575 ns 2574 ns 270868 +bm_std::function___CallsMethod::get_string 2577 ns 2576 ns 268486 -RtlFunction_call::returnNonVoid 2179 ns 2179 ns 321585 -RtlFunction_callMethod::returnNonVoid 2181 ns 2181 ns 321088 +bm_rtl::function_CallsFunction::get_string 2575 ns 2574 ns 269710 +bm_rtl::method_____CallsMethod::get_string 2585 ns 2584 ns 269620 -RtlFunction_call_ReturnUnknown::NonVoid 2209 ns 2209 ns 316939 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2206 ns 2206 ns 317901 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2213 ns 2213 ns 316659 +bm_rtl::function_ErasedReturnType::get_string 2586 ns 2584 ns 265265 +bm_rtl::method___ErasedReturnType::get_string 2620 ns 2618 ns 265946 +bm_rtl::method___ErasedTargetType::get_string 2593 ns 2591 ns 268385 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2625 ns 2624 ns 264396 ----------------------------------- -[2025-10-09 22:44:35] >>> Run 5: workload scale = 100 +[2025-10-25 08:36:32] >>> Run 3: workload scale = 100 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 100 iterations ============================================= -2025-10-09T22:44:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 799.718 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 1931 ns 1931 ns 363432 - -NativeFunctionPtr_call::returnVoid 1926 ns 1926 ns 363081 -NativeFunctionPtr_callMethod::returnVoid 1929 ns 1928 ns 361320 - -StdFunction_call::returnVoid 1926 ns 1925 ns 363575 -StdFunction_callMethod::returnVoid 1928 ns 1928 ns 363309 - -RtlFunction_call::returnVoid 1925 ns 1925 ns 361987 -RtlFunction_callMethod::returnVoid 1926 ns 1926 ns 363698 - -RtlFunction_call_ReturnUnknown::Void 1938 ns 1938 ns 361939 -RtlFunction_callMethod_ReturnUnknown::Void 1927 ns 1927 ns 363365 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 1935 ns 1935 ns 362379 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2226 ns 2226 ns 314431 - -NativeFunctionPtr_call::returnNonVoid 2235 ns 2235 ns 313549 -NativeFunctionPtr_callMethod::returnNonVoid 2232 ns 2232 ns 313726 - -StdFunction_call::returnNonVoid 2237 ns 2237 ns 313224 -StdFunction_callMethod::returnNonVoid 2234 ns 2233 ns 313533 - -RtlFunction_call::returnNonVoid 2235 ns 2235 ns 313494 -RtlFunction_callMethod::returnNonVoid 2232 ns 2231 ns 313624 - -RtlFunction_call_ReturnUnknown::NonVoid 2248 ns 2248 ns 311433 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2244 ns 2244 ns 310568 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2250 ns 2250 ns 311259 ------------------------------------ -[2025-10-09 22:44:54] >>> Run 1: workload scale = 120 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 120 iterations -============================================= - -2025-10-09T22:44:54+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 2127 ns 2126 ns 327584 - -NativeFunctionPtr_call::returnVoid 2126 ns 2126 ns 329705 -NativeFunctionPtr_callMethod::returnVoid 2127 ns 2127 ns 329783 - -StdFunction_call::returnVoid 2124 ns 2123 ns 329620 -StdFunction_callMethod::returnVoid 2135 ns 2135 ns 328409 - -RtlFunction_call::returnVoid 2124 ns 2124 ns 329789 -RtlFunction_callMethod::returnVoid 2127 ns 2127 ns 329843 - -RtlFunction_call_ReturnUnknown::Void 2136 ns 2136 ns 327334 -RtlFunction_callMethod_ReturnUnknown::Void 2130 ns 2129 ns 329277 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2134 ns 2134 ns 328114 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2575 ns 2575 ns 272452 - -NativeFunctionPtr_call::returnNonVoid 2567 ns 2567 ns 272643 -NativeFunctionPtr_callMethod::returnNonVoid 2572 ns 2571 ns 272647 - -StdFunction_call::returnNonVoid 2571 ns 2570 ns 272249 -StdFunction_callMethod::returnNonVoid 2576 ns 2575 ns 271922 - -RtlFunction_call::returnNonVoid 2567 ns 2567 ns 272553 -RtlFunction_callMethod::returnNonVoid 2568 ns 2568 ns 272648 - -RtlFunction_call_ReturnUnknown::NonVoid 2605 ns 2605 ns 267798 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2600 ns 2600 ns 269023 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2610 ns 2610 ns 266981 ------------------------------------ -[2025-10-09 22:45:13] >>> Run 2: workload scale = 120 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 120 iterations -============================================= - -2025-10-09T22:45:13+05:30 +2025-10-25T08:36:32+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -4721,48 +2822,50 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 2146 ns 2145 ns 326094 +Load Average: 1.07, 1.20, 1.00 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 1951 ns 1950 ns 354593 -NativeFunctionPtr_call::returnVoid 2148 ns 2147 ns 323370 -NativeFunctionPtr_callMethod::returnVoid 2144 ns 2144 ns 326373 +bm_call::by_FunctionPtr_Function::set_string 1959 ns 1958 ns 357458 +bm_call::by_FunctionPtr___Method::set_string 1956 ns 1955 ns 354524 -StdFunction_call::returnVoid 2146 ns 2146 ns 326429 -StdFunction_callMethod::returnVoid 2145 ns 2145 ns 326412 +bm_std::function_CallsFunction::set_string 1955 ns 1953 ns 350815 +bm_std::function___CallsMethod::set_string 1959 ns 1958 ns 356103 -RtlFunction_call::returnVoid 2146 ns 2146 ns 326763 -RtlFunction_callMethod::returnVoid 2144 ns 2144 ns 326623 +bm_rtl::function_CallsFunction::set_string 1957 ns 1956 ns 358544 +bm_rtl::method_____CallsMethod::set_string 1962 ns 1961 ns 354408 -RtlFunction_call_ReturnUnknown::Void 2128 ns 2128 ns 329583 -RtlFunction_callMethod_ReturnUnknown::Void 2118 ns 2117 ns 330471 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2133 ns 2133 ns 329135 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2599 ns 2599 ns 269327 +bm_rtl::function_ErasedReturnType::set_string 1965 ns 1964 ns 352941 +bm_rtl::method___ErasedReturnType::set_string 1970 ns 1969 ns 346967 +bm_rtl::method___ErasedTargetType::set_string 1968 ns 1967 ns 335767 +bm_rtl::method___ErasedTargetAndReturnType::set_string 1974 ns 1972 ns 350625 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2472 ns 2471 ns 280910 -NativeFunctionPtr_call::returnNonVoid 2604 ns 2604 ns 269268 -NativeFunctionPtr_callMethod::returnNonVoid 2601 ns 2601 ns 269194 +bm_call::by_FunctionPtr_Function::get_string 2469 ns 2468 ns 282225 +bm_call::by_FunctionPtr___Method::get_string 2468 ns 2467 ns 280716 -StdFunction_call::returnNonVoid 2610 ns 2609 ns 268917 -StdFunction_callMethod::returnNonVoid 2603 ns 2603 ns 268866 +bm_std::function_CallsFunction::get_string 2468 ns 2467 ns 280210 +bm_std::function___CallsMethod::get_string 2473 ns 2472 ns 280456 -RtlFunction_call::returnNonVoid 2604 ns 2604 ns 269245 -RtlFunction_callMethod::returnNonVoid 2601 ns 2601 ns 269132 +bm_rtl::function_CallsFunction::get_string 2468 ns 2467 ns 279723 +bm_rtl::method_____CallsMethod::get_string 2468 ns 2467 ns 281312 -RtlFunction_call_ReturnUnknown::NonVoid 2608 ns 2607 ns 268916 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2595 ns 2595 ns 269755 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2602 ns 2602 ns 269447 +bm_rtl::function_ErasedReturnType::get_string 2505 ns 2504 ns 275122 +bm_rtl::method___ErasedReturnType::get_string 2506 ns 2504 ns 276606 +bm_rtl::method___ErasedTargetType::get_string 2485 ns 2484 ns 278931 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2513 ns 2511 ns 275206 ----------------------------------- -[2025-10-09 22:45:33] >>> Run 3: workload scale = 120 +[2025-10-25 08:36:53] >>> Run 1: workload scale = 120 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 120 iterations ============================================= -2025-10-09T22:45:33+05:30 +2025-10-25T08:36:53+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -4770,293 +2873,203 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.00, 1.00, 1.00 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 2132 ns 2132 ns 328161 +Load Average: 1.05, 1.19, 1.00 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 2154 ns 2153 ns 323732 -NativeFunctionPtr_call::returnVoid 2135 ns 2135 ns 327953 -NativeFunctionPtr_callMethod::returnVoid 2132 ns 2132 ns 328259 +bm_call::by_FunctionPtr_Function::set_string 2150 ns 2149 ns 320699 +bm_call::by_FunctionPtr___Method::set_string 2159 ns 2158 ns 323064 -StdFunction_call::returnVoid 2132 ns 2132 ns 328345 -StdFunction_callMethod::returnVoid 2136 ns 2136 ns 327576 +bm_std::function_CallsFunction::set_string 2133 ns 2133 ns 320767 +bm_std::function___CallsMethod::set_string 2144 ns 2143 ns 322062 -RtlFunction_call::returnVoid 2132 ns 2131 ns 328339 -RtlFunction_callMethod::returnVoid 2131 ns 2131 ns 328277 +bm_rtl::function_CallsFunction::set_string 2138 ns 2137 ns 325609 +bm_rtl::method_____CallsMethod::set_string 2136 ns 2136 ns 319234 -RtlFunction_call_ReturnUnknown::Void 2141 ns 2141 ns 326811 -RtlFunction_callMethod_ReturnUnknown::Void 2133 ns 2132 ns 328303 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2138 ns 2138 ns 327370 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2576 ns 2576 ns 271756 +bm_rtl::function_ErasedReturnType::set_string 2135 ns 2134 ns 318553 +bm_rtl::method___ErasedReturnType::set_string 2138 ns 2137 ns 324005 +bm_rtl::method___ErasedTargetType::set_string 2161 ns 2160 ns 320548 +bm_rtl::method___ErasedTargetAndReturnType::set_string 2144 ns 2143 ns 322260 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2918 ns 2916 ns 237030 -NativeFunctionPtr_call::returnNonVoid 2575 ns 2575 ns 271997 -NativeFunctionPtr_callMethod::returnNonVoid 2576 ns 2576 ns 271924 +bm_call::by_FunctionPtr_Function::get_string 2918 ns 2916 ns 234279 +bm_call::by_FunctionPtr___Method::get_string 2917 ns 2915 ns 237717 -StdFunction_call::returnNonVoid 2578 ns 2577 ns 271665 -StdFunction_callMethod::returnNonVoid 2580 ns 2579 ns 271431 +bm_std::function_CallsFunction::get_string 2917 ns 2915 ns 234701 +bm_std::function___CallsMethod::get_string 2925 ns 2924 ns 236487 -RtlFunction_call::returnNonVoid 2580 ns 2580 ns 268885 -RtlFunction_callMethod::returnNonVoid 2582 ns 2581 ns 271163 +bm_rtl::function_CallsFunction::get_string 2918 ns 2917 ns 236650 +bm_rtl::method_____CallsMethod::get_string 2917 ns 2916 ns 237493 -RtlFunction_call_ReturnUnknown::NonVoid 2612 ns 2611 ns 268093 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2609 ns 2608 ns 268677 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2609 ns 2609 ns 268332 +bm_rtl::function_ErasedReturnType::get_string 2950 ns 2948 ns 233932 +bm_rtl::method___ErasedReturnType::get_string 2957 ns 2955 ns 234740 +bm_rtl::method___ErasedTargetType::get_string 2968 ns 2967 ns 224637 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2962 ns 2961 ns 234086 ----------------------------------- -[2025-10-09 22:45:52] >>> Run 4: workload scale = 120 +[2025-10-25 08:37:14] >>> Run 2: workload scale = 120 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 120 iterations ============================================= -2025-10-09T22:45:52+05:30 +2025-10-25T08:37:14+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2422.26 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.08, 1.02, 1.01 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 2117 ns 2116 ns 330320 +Load Average: 1.03, 1.17, 1.00 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 2126 ns 2126 ns 324679 -NativeFunctionPtr_call::returnVoid 2116 ns 2115 ns 330510 -NativeFunctionPtr_callMethod::returnVoid 2116 ns 2115 ns 330810 +bm_call::by_FunctionPtr_Function::set_string 2134 ns 2133 ns 323473 +bm_call::by_FunctionPtr___Method::set_string 2140 ns 2139 ns 323268 -StdFunction_call::returnVoid 2115 ns 2114 ns 330719 -StdFunction_callMethod::returnVoid 2120 ns 2120 ns 330247 +bm_std::function_CallsFunction::set_string 2129 ns 2128 ns 323338 +bm_std::function___CallsMethod::set_string 2135 ns 2134 ns 310502 -RtlFunction_call::returnVoid 2163 ns 2163 ns 330721 -RtlFunction_callMethod::returnVoid 2112 ns 2112 ns 331151 +bm_rtl::function_CallsFunction::set_string 2128 ns 2127 ns 328046 +bm_rtl::method_____CallsMethod::set_string 2132 ns 2131 ns 323372 -RtlFunction_call_ReturnUnknown::Void 2123 ns 2122 ns 330134 -RtlFunction_callMethod_ReturnUnknown::Void 2115 ns 2114 ns 330945 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2119 ns 2119 ns 328815 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2537 ns 2537 ns 275748 +bm_rtl::function_ErasedReturnType::set_string 2134 ns 2133 ns 326776 +bm_rtl::method___ErasedReturnType::set_string 2154 ns 2152 ns 326321 +bm_rtl::method___ErasedTargetType::set_string 2156 ns 2156 ns 320272 +bm_rtl::method___ErasedTargetAndReturnType::set_string 2173 ns 2172 ns 321768 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 3039 ns 3038 ns 228220 -NativeFunctionPtr_call::returnNonVoid 2536 ns 2535 ns 276027 -NativeFunctionPtr_callMethod::returnNonVoid 2535 ns 2535 ns 276198 +bm_call::by_FunctionPtr_Function::get_string 3066 ns 3065 ns 228111 +bm_call::by_FunctionPtr___Method::get_string 3033 ns 3033 ns 229934 -StdFunction_call::returnNonVoid 2538 ns 2538 ns 275897 -StdFunction_callMethod::returnNonVoid 2541 ns 2540 ns 275598 +bm_std::function_CallsFunction::get_string 3041 ns 3039 ns 229708 +bm_std::function___CallsMethod::get_string 3044 ns 3044 ns 229028 -RtlFunction_call::returnNonVoid 2536 ns 2535 ns 276112 -RtlFunction_callMethod::returnNonVoid 2536 ns 2535 ns 276031 +bm_rtl::function_CallsFunction::get_string 2911 ns 2911 ns 233145 +bm_rtl::method_____CallsMethod::get_string 2912 ns 2911 ns 239735 -RtlFunction_call_ReturnUnknown::NonVoid 2565 ns 2564 ns 272802 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2560 ns 2559 ns 273419 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2608 ns 2608 ns 273229 +bm_rtl::function_ErasedReturnType::get_string 3028 ns 3027 ns 236359 +bm_rtl::method___ErasedReturnType::get_string 3079 ns 3078 ns 226199 +bm_rtl::method___ErasedTargetType::get_string 3068 ns 3067 ns 227273 +bm_rtl::method___ErasedTargetAndReturnType::get_string 3089 ns 3088 ns 225302 ----------------------------------- -[2025-10-09 22:46:11] >>> Run 5: workload scale = 120 +[2025-10-25 08:37:36] >>> Run 3: workload scale = 120 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 120 iterations ============================================= -2025-10-09T22:46:11+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.32, 1.08, 1.03 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 2185 ns 2185 ns 311510 - -NativeFunctionPtr_call::returnVoid 2184 ns 2184 ns 324186 -NativeFunctionPtr_callMethod::returnVoid 2159 ns 2159 ns 324695 - -StdFunction_call::returnVoid 2160 ns 2160 ns 324530 -StdFunction_callMethod::returnVoid 2163 ns 2163 ns 323744 - -RtlFunction_call::returnVoid 2158 ns 2158 ns 324315 -RtlFunction_callMethod::returnVoid 2160 ns 2159 ns 324420 - -RtlFunction_call_ReturnUnknown::Void 2163 ns 2163 ns 323559 -RtlFunction_callMethod_ReturnUnknown::Void 2155 ns 2155 ns 324663 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 2165 ns 2165 ns 323713 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 2584 ns 2584 ns 270900 - -NativeFunctionPtr_call::returnNonVoid 2587 ns 2587 ns 270723 -NativeFunctionPtr_callMethod::returnNonVoid 2587 ns 2587 ns 270727 - -StdFunction_call::returnNonVoid 2588 ns 2587 ns 270520 -StdFunction_callMethod::returnNonVoid 2589 ns 2589 ns 270335 - -RtlFunction_call::returnNonVoid 2585 ns 2584 ns 270667 -RtlFunction_callMethod::returnNonVoid 2590 ns 2589 ns 270591 - -RtlFunction_call_ReturnUnknown::NonVoid 2614 ns 2614 ns 267845 -RtlFunction_callMethod_ReturnUnknown::NonVoid 2608 ns 2607 ns 268680 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 2620 ns 2619 ns 267332 ------------------------------------ -[2025-10-09 22:46:30] >>> Run 1: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-10-09T22:46:30+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.23, 1.07, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 3499 ns 3499 ns 199937 - -NativeFunctionPtr_call::returnVoid 3501 ns 3501 ns 199944 -NativeFunctionPtr_callMethod::returnVoid 3500 ns 3499 ns 200076 - -StdFunction_call::returnVoid 3500 ns 3499 ns 200104 -StdFunction_callMethod::returnVoid 3507 ns 3506 ns 199590 - -RtlFunction_call::returnVoid 3499 ns 3499 ns 199992 -RtlFunction_callMethod::returnVoid 3499 ns 3498 ns 200046 - -RtlFunction_call_ReturnUnknown::Void 3506 ns 3506 ns 199699 -RtlFunction_callMethod_ReturnUnknown::Void 3504 ns 3503 ns 199923 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3509 ns 3508 ns 199515 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 3969 ns 3968 ns 176496 - -NativeFunctionPtr_call::returnNonVoid 3968 ns 3968 ns 176502 -NativeFunctionPtr_callMethod::returnNonVoid 3968 ns 3968 ns 176426 - -StdFunction_call::returnNonVoid 3969 ns 3969 ns 176325 -StdFunction_callMethod::returnNonVoid 3976 ns 3976 ns 176121 - -RtlFunction_call::returnNonVoid 3967 ns 3967 ns 176388 -RtlFunction_callMethod::returnNonVoid 3969 ns 3968 ns 176396 - -RtlFunction_call_ReturnUnknown::NonVoid 4011 ns 4010 ns 174538 -RtlFunction_callMethod_ReturnUnknown::NonVoid 3993 ns 3993 ns 175317 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 3998 ns 3998 ns 175120 ------------------------------------ -[2025-10-09 22:46:53] >>> Run 2: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-10-09T22:46:53+05:30 +2025-10-25T08:37:36+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 3688.05 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.15, 1.07, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 3487 ns 3487 ns 200624 +Load Average: 1.17, 1.20, 1.01 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 2143 ns 2142 ns 299942 -NativeFunctionPtr_call::returnVoid 3487 ns 3487 ns 200797 -NativeFunctionPtr_callMethod::returnVoid 3485 ns 3485 ns 200903 +bm_call::by_FunctionPtr_Function::set_string 2161 ns 2160 ns 324844 +bm_call::by_FunctionPtr___Method::set_string 2140 ns 2139 ns 326218 -StdFunction_call::returnVoid 3485 ns 3485 ns 200885 -StdFunction_callMethod::returnVoid 3492 ns 3492 ns 200459 +bm_std::function_CallsFunction::set_string 2129 ns 2128 ns 317297 +bm_std::function___CallsMethod::set_string 2136 ns 2135 ns 323624 -RtlFunction_call::returnVoid 3486 ns 3485 ns 200836 -RtlFunction_callMethod::returnVoid 3485 ns 3484 ns 200811 +bm_rtl::function_CallsFunction::set_string 2134 ns 2133 ns 320355 +bm_rtl::method_____CallsMethod::set_string 2131 ns 2130 ns 321763 -RtlFunction_call_ReturnUnknown::Void 3498 ns 3497 ns 200154 -RtlFunction_callMethod_ReturnUnknown::Void 3492 ns 3492 ns 200479 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3495 ns 3495 ns 200337 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 3957 ns 3956 ns 176928 +bm_rtl::function_ErasedReturnType::set_string 2136 ns 2135 ns 324047 +bm_rtl::method___ErasedReturnType::set_string 2140 ns 2138 ns 321731 +bm_rtl::method___ErasedTargetType::set_string 2143 ns 2142 ns 322519 +bm_rtl::method___ErasedTargetAndReturnType::set_string 2143 ns 2143 ns 321554 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 2927 ns 2925 ns 236348 -NativeFunctionPtr_call::returnNonVoid 3953 ns 3953 ns 177062 -NativeFunctionPtr_callMethod::returnNonVoid 3953 ns 3953 ns 176987 +bm_call::by_FunctionPtr_Function::get_string 2936 ns 2935 ns 236522 +bm_call::by_FunctionPtr___Method::get_string 2924 ns 2924 ns 236896 -StdFunction_call::returnNonVoid 3957 ns 3956 ns 176999 -StdFunction_callMethod::returnNonVoid 3966 ns 3966 ns 176485 +bm_std::function_CallsFunction::get_string 2921 ns 2920 ns 236227 +bm_std::function___CallsMethod::get_string 2931 ns 2931 ns 235379 -RtlFunction_call::returnNonVoid 3954 ns 3954 ns 176831 -RtlFunction_callMethod::returnNonVoid 3953 ns 3953 ns 177027 +bm_rtl::function_CallsFunction::get_string 2922 ns 2921 ns 235415 +bm_rtl::method_____CallsMethod::get_string 2924 ns 2924 ns 236926 -RtlFunction_call_ReturnUnknown::NonVoid 3990 ns 3989 ns 175588 -RtlFunction_callMethod_ReturnUnknown::NonVoid 3985 ns 3985 ns 175753 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 3992 ns 3991 ns 175344 +bm_rtl::function_ErasedReturnType::get_string 2972 ns 2971 ns 234773 +bm_rtl::method___ErasedReturnType::get_string 2972 ns 2971 ns 233069 +bm_rtl::method___ErasedTargetType::get_string 2940 ns 2939 ns 235111 +bm_rtl::method___ErasedTargetAndReturnType::get_string 2967 ns 2966 ns 231931 ----------------------------------- -[2025-10-09 22:47:15] >>> Run 3: workload scale = 150 +[2025-10-25 08:37:57] >>> Run 1: workload scale = 150 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 150 iterations ============================================= -2025-10-09T22:47:15+05:30 +2025-10-25T08:37:57+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 2614.17 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.11, 1.06, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 3486 ns 3486 ns 200956 +Load Average: 1.12, 1.18, 1.01 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 3517 ns 3515 ns 198375 -NativeFunctionPtr_call::returnVoid 3487 ns 3486 ns 200747 -NativeFunctionPtr_callMethod::returnVoid 3484 ns 3484 ns 200875 +bm_call::by_FunctionPtr_Function::set_string 3530 ns 3529 ns 198234 +bm_call::by_FunctionPtr___Method::set_string 3523 ns 3523 ns 195386 -StdFunction_call::returnVoid 3485 ns 3484 ns 200789 -StdFunction_callMethod::returnVoid 3488 ns 3487 ns 200722 +bm_std::function_CallsFunction::set_string 3518 ns 3517 ns 196144 +bm_std::function___CallsMethod::set_string 3518 ns 3517 ns 197544 -RtlFunction_call::returnVoid 3485 ns 3485 ns 200870 -RtlFunction_callMethod::returnVoid 3487 ns 3487 ns 200780 +bm_rtl::function_CallsFunction::set_string 3518 ns 3518 ns 197541 +bm_rtl::method_____CallsMethod::set_string 3519 ns 3518 ns 198159 -RtlFunction_call_ReturnUnknown::Void 3495 ns 3495 ns 200222 -RtlFunction_callMethod_ReturnUnknown::Void 3486 ns 3486 ns 200746 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3488 ns 3488 ns 200524 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 3963 ns 3962 ns 176670 +bm_rtl::function_ErasedReturnType::set_string 3523 ns 3522 ns 197699 +bm_rtl::method___ErasedReturnType::set_string 3525 ns 3525 ns 195578 +bm_rtl::method___ErasedTargetType::set_string 3529 ns 3529 ns 196644 +bm_rtl::method___ErasedTargetAndReturnType::set_string 3553 ns 3552 ns 195863 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 4439 ns 4437 ns 154718 -NativeFunctionPtr_call::returnNonVoid 3954 ns 3954 ns 177006 -NativeFunctionPtr_callMethod::returnNonVoid 3955 ns 3954 ns 177009 +bm_call::by_FunctionPtr_Function::get_string 4434 ns 4433 ns 156870 +bm_call::by_FunctionPtr___Method::get_string 4433 ns 4432 ns 156941 -StdFunction_call::returnNonVoid 3956 ns 3956 ns 177000 -StdFunction_callMethod::returnNonVoid 3957 ns 3957 ns 176882 +bm_std::function_CallsFunction::get_string 4430 ns 4429 ns 153896 +bm_std::function___CallsMethod::get_string 4475 ns 4474 ns 156754 -RtlFunction_call::returnNonVoid 3953 ns 3953 ns 177049 -RtlFunction_callMethod::returnNonVoid 3955 ns 3954 ns 177008 +bm_rtl::function_CallsFunction::get_string 4431 ns 4431 ns 156729 +bm_rtl::method_____CallsMethod::get_string 4433 ns 4432 ns 156452 -RtlFunction_call_ReturnUnknown::NonVoid 3986 ns 3986 ns 175626 -RtlFunction_callMethod_ReturnUnknown::NonVoid 3981 ns 3980 ns 175785 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 3991 ns 3990 ns 175430 +bm_rtl::function_ErasedReturnType::get_string 4476 ns 4474 ns 155013 +bm_rtl::method___ErasedReturnType::get_string 4477 ns 4476 ns 155632 +bm_rtl::method___ErasedTargetType::get_string 4477 ns 4476 ns 155619 +bm_rtl::method___ErasedTargetAndReturnType::get_string 4500 ns 4498 ns 154454 ----------------------------------- -[2025-10-09 22:47:37] >>> Run 4: workload scale = 150 +[2025-10-25 08:38:23] >>> Run 2: workload scale = 150 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 150 iterations ============================================= -2025-10-09T22:47:37+05:30 +2025-10-25T08:38:23+05:30 Running ./bin/RTLBenchmarkApp Run on (16 X 800 MHz CPU s) CPU Caches: @@ -5064,87 +3077,91 @@ CPU Caches: L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.08, 1.06, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 3549 ns 3549 ns 197165 +Load Average: 1.08, 1.17, 1.01 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 3520 ns 3519 ns 197160 -NativeFunctionPtr_call::returnVoid 3549 ns 3548 ns 197318 -NativeFunctionPtr_callMethod::returnVoid 3546 ns 3546 ns 197387 +bm_call::by_FunctionPtr_Function::set_string 3542 ns 3541 ns 196662 +bm_call::by_FunctionPtr___Method::set_string 3530 ns 3529 ns 197455 -StdFunction_call::returnVoid 3546 ns 3546 ns 197389 -StdFunction_callMethod::returnVoid 3551 ns 3551 ns 197181 +bm_std::function_CallsFunction::set_string 3509 ns 3508 ns 196642 +bm_std::function___CallsMethod::set_string 3511 ns 3511 ns 192804 -RtlFunction_call::returnVoid 3546 ns 3546 ns 197414 -RtlFunction_callMethod::returnVoid 3546 ns 3545 ns 197496 +bm_rtl::function_CallsFunction::set_string 3514 ns 3513 ns 198927 +bm_rtl::method_____CallsMethod::set_string 3511 ns 3510 ns 198884 -RtlFunction_call_ReturnUnknown::Void 3555 ns 3554 ns 196865 -RtlFunction_callMethod_ReturnUnknown::Void 3558 ns 3557 ns 196840 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3562 ns 3561 ns 196448 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 4075 ns 4075 ns 171802 +bm_rtl::function_ErasedReturnType::set_string 3523 ns 3522 ns 198748 +bm_rtl::method___ErasedReturnType::set_string 3520 ns 3519 ns 198328 +bm_rtl::method___ErasedTargetType::set_string 3532 ns 3531 ns 198312 +bm_rtl::method___ErasedTargetAndReturnType::set_string 3525 ns 3524 ns 195834 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 4436 ns 4435 ns 155924 -NativeFunctionPtr_call::returnNonVoid 4074 ns 4074 ns 171810 -NativeFunctionPtr_callMethod::returnNonVoid 4074 ns 4074 ns 171823 +bm_call::by_FunctionPtr_Function::get_string 4438 ns 4437 ns 156402 +bm_call::by_FunctionPtr___Method::get_string 4437 ns 4436 ns 155993 -StdFunction_call::returnNonVoid 4078 ns 4077 ns 171735 -StdFunction_callMethod::returnNonVoid 4080 ns 4080 ns 171580 +bm_std::function_CallsFunction::get_string 4460 ns 4459 ns 156561 +bm_std::function___CallsMethod::get_string 4443 ns 4442 ns 156940 -RtlFunction_call::returnNonVoid 4074 ns 4074 ns 171809 -RtlFunction_callMethod::returnNonVoid 4075 ns 4075 ns 171782 +bm_rtl::function_CallsFunction::get_string 4438 ns 4438 ns 156357 +bm_rtl::method_____CallsMethod::get_string 4439 ns 4438 ns 157440 -RtlFunction_call_ReturnUnknown::NonVoid 4112 ns 4112 ns 170240 -RtlFunction_callMethod_ReturnUnknown::NonVoid 4104 ns 4103 ns 170511 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 4110 ns 4109 ns 170348 +bm_rtl::function_ErasedReturnType::get_string 4485 ns 4484 ns 155721 +bm_rtl::method___ErasedReturnType::get_string 4482 ns 4480 ns 155966 +bm_rtl::method___ErasedTargetType::get_string 4457 ns 4456 ns 156554 +bm_rtl::method___ErasedTargetAndReturnType::get_string 4492 ns 4491 ns 155021 ----------------------------------- -[2025-10-09 22:48:00] >>> Run 5: workload scale = 150 +[2025-10-25 08:38:48] >>> Run 3: workload scale = 150 ======== RTL Benchmark Configuration ======== Workload: concatenate string of length 500 Scale : 150 iterations ============================================= -2025-10-09T22:48:00+05:30 +2025-10-25T08:38:48+05:30 Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) +Run on (16 X 1399.59 MHz CPU s) CPU Caches: L1 Data 48 KiB (x8) L1 Instruction 32 KiB (x8) L2 Unified 1280 KiB (x8) L3 Unified 20480 KiB (x1) -Load Average: 1.05, 1.05, 1.02 ------------------------------------------------------------------------------------------------------ -Benchmark Time CPU Iterations ------------------------------------------------------------------------------------------------------ -NativeCall::returnVoid 3501 ns 3501 ns 200070 +Load Average: 1.05, 1.15, 1.00 +------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::set_string 3523 ns 3522 ns 195782 -NativeFunctionPtr_call::returnVoid 3502 ns 3502 ns 199961 -NativeFunctionPtr_callMethod::returnVoid 3500 ns 3499 ns 200004 +bm_call::by_FunctionPtr_Function::set_string 3524 ns 3524 ns 195591 +bm_call::by_FunctionPtr___Method::set_string 3522 ns 3521 ns 197458 -StdFunction_call::returnVoid 3500 ns 3499 ns 200110 -StdFunction_callMethod::returnVoid 3503 ns 3503 ns 199929 +bm_std::function_CallsFunction::set_string 3559 ns 3558 ns 196261 +bm_std::function___CallsMethod::set_string 3559 ns 3558 ns 194883 -RtlFunction_call::returnVoid 3498 ns 3498 ns 200098 -RtlFunction_callMethod::returnVoid 3498 ns 3498 ns 200061 +bm_rtl::function_CallsFunction::set_string 3521 ns 3520 ns 198009 +bm_rtl::method_____CallsMethod::set_string 3529 ns 3528 ns 194897 -RtlFunction_call_ReturnUnknown::Void 3518 ns 3518 ns 199005 -RtlFunction_callMethod_ReturnUnknown::Void 3507 ns 3507 ns 199664 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_Void 3513 ns 3513 ns 199195 ------------------------------------------------------------------------------------------------------ -NativeCall::returnNonVoid 3974 ns 3973 ns 176195 +bm_rtl::function_ErasedReturnType::set_string 3535 ns 3535 ns 196213 +bm_rtl::method___ErasedReturnType::set_string 3544 ns 3543 ns 196908 +bm_rtl::method___ErasedTargetType::set_string 3543 ns 3543 ns 196724 +bm_rtl::method___ErasedTargetAndReturnType::set_string 3545 ns 3544 ns 196325 +------------------------------------------------------------------------------------------------- +bm_call::direct_Function::get_string 4440 ns 4439 ns 156865 -NativeFunctionPtr_call::returnNonVoid 3970 ns 3970 ns 176307 -NativeFunctionPtr_callMethod::returnNonVoid 3970 ns 3970 ns 176351 +bm_call::by_FunctionPtr_Function::get_string 4448 ns 4447 ns 156018 +bm_call::by_FunctionPtr___Method::get_string 4444 ns 4442 ns 156434 -StdFunction_call::returnNonVoid 3974 ns 3973 ns 176208 -StdFunction_callMethod::returnNonVoid 3984 ns 3984 ns 175710 +bm_std::function_CallsFunction::get_string 4445 ns 4444 ns 155973 +bm_std::function___CallsMethod::get_string 4453 ns 4453 ns 156511 -RtlFunction_call::returnNonVoid 3971 ns 3971 ns 176261 -RtlFunction_callMethod::returnNonVoid 3971 ns 3971 ns 176279 +bm_rtl::function_CallsFunction::get_string 4443 ns 4443 ns 157164 +bm_rtl::method_____CallsMethod::get_string 4445 ns 4444 ns 156931 -RtlFunction_call_ReturnUnknown::NonVoid 4010 ns 4010 ns 174663 -RtlFunction_callMethod_ReturnUnknown::NonVoid 4004 ns 4003 ns 174832 -RtlFunction_callMethod_ReturnUnknown::erasedTarget_NonVoid 4006 ns 4006 ns 174751 +bm_rtl::function_ErasedReturnType::get_string 4535 ns 4535 ns 153398 +bm_rtl::method___ErasedReturnType::get_string 4499 ns 4497 ns 154376 +bm_rtl::method___ErasedTargetType::get_string 4473 ns 4471 ns 155462 +bm_rtl::method___ErasedTargetAndReturnType::get_string 4505 ns 4504 ns 155125 ----------------------------------- All benchmarks completed. From 3693994c2ac4854d8c169890cc2615e4f7b18c57 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sun, 26 Oct 2025 09:54:26 +0530 Subject: [PATCH 107/148] static & const method calls. wip. --- ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt | 6 +++--- ...{rtl_method_const_erased.h => rtl_method_erased_const.h} | 0 ...nst_erased_return.h => rtl_method_erased_return_const.h} | 0 ...nst_erased_target.h => rtl_method_erased_target_const.h} | 0 ReflectionTemplateLib/rtl/rtl_errors.h | 1 + 5 files changed, 4 insertions(+), 3 deletions(-) rename ReflectionTemplateLib/rtl/dispatch/{rtl_method_const_erased.h => rtl_method_erased_const.h} (100%) rename ReflectionTemplateLib/rtl/dispatch/{rtl_method_const_erased_return.h => rtl_method_erased_return_const.h} (100%) rename ReflectionTemplateLib/rtl/dispatch/{rtl_method_const_erased_target.h => rtl_method_erased_target_const.h} (100%) diff --git a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt index fa85e470..3cbcbd02 100644 --- a/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt +++ b/ReflectionTemplateLib/rtl/dispatch/CMakeLists.txt @@ -22,9 +22,9 @@ set(LOCAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_target.h" "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const_erased.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const_erased_return.h" - "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_const_erased_target.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_return_const.h" + "${CMAKE_CURRENT_SOURCE_DIR}/rtl_method_erased_target_const.h" ) target_sources(ReflectionTemplateLib PRIVATE ${LOCAL_HEADERS}) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_const.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased.h rename to ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_const.h diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_return.h rename to ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target_const.h similarity index 100% rename from ReflectionTemplateLib/rtl/dispatch/rtl_method_const_erased_target.h rename to ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target_const.h diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index da12a345..8e7a4a7f 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -26,6 +26,7 @@ namespace rtl SignatureMismatch, RefBindingMismatch, ExplicitRefBindingRequired, + NonStaticMethodRequiresTarget, CloningDisabled, //Used only in case of cloning is disabled e.g, unregistered type. FunctionNotRegistered, //Not used by RTL at all, for external purpose only. From db38f24b5a47f9b24bbd07a37274d3890f46867f Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 28 Oct 2025 20:57:48 +0530 Subject: [PATCH 108/148] builder code cleanup/refactor. static-method calls- wip. --- .../src/ReflectedCallKnownReturn.cpp | 16 ++-- .../src/ReflectedCallKnownReturn.h | 8 +- .../src/ReflectedCallUnknownReturn.cpp | 16 ++-- .../src/ReflectedCallUnknownReturn.h | 8 +- RTLBenchmarkApp/src/StandardCall.cpp | 14 +-- RTLBenchmarkApp/src/StandardCall.h | 6 +- RTLBenchmarkApp/src/main.cpp | 44 ++++----- ReflectionTemplateLib/rtl/builder/Builder.h | 80 ++++------------ ReflectionTemplateLib/rtl/builder/Builder.hpp | 92 ++++--------------- .../rtl/builder/ConstructorBuilder.h | 4 +- .../rtl/builder/MethodContainer.h | 22 ++--- .../rtl/builder/RecordBuilder.h | 12 +-- .../rtl/builder/RecordBuilder.hpp | 36 ++++---- ReflectionTemplateLib/rtl/builder/Reflect.h | 4 +- ReflectionTemplateLib/rtl/builder/Reflect.hpp | 12 +-- .../rtl/builder/ReflectionBuilder.hpp | 12 +-- .../rtl/builder/SetupConstructor.hpp | 2 +- .../rtl/builder/SetupMethod.h | 4 +- .../rtl/builder/SetupMethod.hpp | 20 ++-- .../rtl/detail/inc/MethodInvoker.hpp | 14 +-- ReflectionTemplateLib/rtl/dispatch/functor.h | 2 +- .../rtl/dispatch/method_ptr.h | 2 +- .../rtl/dispatch/method_ptr_const.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.h | 8 +- ReflectionTemplateLib/rtl/inc/Method.h | 2 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 10 +- ReflectionTemplateLib/rtl/inc/type_meta.h | 2 +- ReflectionTemplateLib/rtl/rtl_constants.h | 11 ++- ReflectionTemplateLib/rtl/rtl_errors.h | 2 +- ReflectionTemplateLib/rtl/src/Function.cpp | 4 +- 30 files changed, 186 insertions(+), 285 deletions(-) diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp index d52ea7d4..b305cc7f 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.cpp @@ -97,7 +97,7 @@ namespace namespace bm_call { - void by_FunctionPtr_Function::get_string(benchmark::State& state) + void via_function_ptr__Function::get_string(benchmark::State& state) { static auto _ = _new_line(); static auto is_ok = test(getMessage, 0); @@ -107,7 +107,7 @@ namespace bm_call } } - void by_FunctionPtr___Method::get_string(benchmark::State& state) + void via_function_ptr____Method::get_string(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(getMessageNode, 1); @@ -117,7 +117,7 @@ namespace bm_call } } - void by_FunctionPtr_Function::set_string(benchmark::State& state) + void via_function_ptr__Function::set_string(benchmark::State& state) { static auto _ = _new_line(); static auto is_ok = test(sendMessage, 2); @@ -128,7 +128,7 @@ namespace bm_call } } - void by_FunctionPtr___Method::set_string(benchmark::State& state) + void via_function_ptr____Method::set_string(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(getMessageNode, 2); @@ -143,7 +143,7 @@ namespace bm_call namespace bm_rtl { - void function_CallsFunction::get_string(benchmark::State& state) + void function_calls__Function::get_string(benchmark::State& state) { static auto _ = _new_line(); static auto is_ok = test(getMessage, 3); @@ -153,7 +153,7 @@ namespace bm_rtl } } - void function_CallsFunction::set_string(benchmark::State& state) + void function_calls__Function::set_string(benchmark::State& state) { static auto _ = _new_line(); static auto is_ok = test(sendMessage, 0); @@ -164,7 +164,7 @@ namespace bm_rtl } } - void method_____CallsMethod::get_string(benchmark::State& state) + void method_calls______Method::get_string(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(getMessageNode, 4); @@ -174,7 +174,7 @@ namespace bm_rtl } } - void method_____CallsMethod::set_string(benchmark::State& state) + void method_calls______Method::set_string(benchmark::State& state) { static bm::Node nodeObj; static auto is_ok = test(sendMessageNode, 5); diff --git a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h index 18c840c0..c8dbea8f 100644 --- a/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallKnownReturn.h @@ -4,14 +4,14 @@ namespace bm_call { - struct by_FunctionPtr_Function + struct via_function_ptr__Function { static void set_string(benchmark::State& state); static void get_string(benchmark::State& state); }; - struct by_FunctionPtr___Method + struct via_function_ptr____Method { static void set_string(benchmark::State& state); @@ -21,14 +21,14 @@ namespace bm_call namespace bm_rtl { - struct function_CallsFunction + struct function_calls__Function { static void set_string(benchmark::State& state); static void get_string(benchmark::State& state); }; - struct method_____CallsMethod + struct method_calls______Method { static void set_string(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp index 7e927e33..2cdeaefa 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.cpp @@ -253,7 +253,7 @@ namespace namespace bm_rtl { - void function_ErasedReturnType::set_string(benchmark::State& state) + void function__ErasedReturnType::set_string(benchmark::State& state) { static auto __ = _new_line(); static auto _ = _test0(); @@ -263,7 +263,7 @@ namespace bm_rtl } } - void function_ErasedReturnType::get_string(benchmark::State& state) + void function__ErasedReturnType::get_string(benchmark::State& state) { static auto __ = _new_line(); static auto _ = _test1(); @@ -277,7 +277,7 @@ namespace bm_rtl namespace bm_rtl { - void method___ErasedReturnType::set_string(benchmark::State& state) + void method____ErasedReturnType::set_string(benchmark::State& state) { static auto _ = _test2(); static bm::Node node; @@ -287,7 +287,7 @@ namespace bm_rtl } } - void method___ErasedReturnType::get_string(benchmark::State& state) + void method____ErasedReturnType::get_string(benchmark::State& state) { static auto _ = _test3(); static bm::Node node; @@ -297,7 +297,7 @@ namespace bm_rtl } } - void method___ErasedTargetType::set_string(benchmark::State& state) + void method____ErasedTargetType::set_string(benchmark::State& state) { static auto _ = _test2(); static bm::Node node; @@ -307,7 +307,7 @@ namespace bm_rtl } } - void method___ErasedTargetType::get_string(benchmark::State& state) + void method____ErasedTargetType::get_string(benchmark::State& state) { static auto _ = _test3(); static bm::Node node; @@ -317,7 +317,7 @@ namespace bm_rtl } } - void method___ErasedTargetAndReturnType::set_string(benchmark::State& state) + void method____ErasedTargetAndReturnType::set_string(benchmark::State& state) { static auto _ = _test2(); static bm::Node node; @@ -327,7 +327,7 @@ namespace bm_rtl } } - void method___ErasedTargetAndReturnType::get_string(benchmark::State& state) + void method____ErasedTargetAndReturnType::get_string(benchmark::State& state) { static auto _ = _test3(); static bm::Node node; diff --git a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h index 4dcb5279..08dcaa3a 100644 --- a/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h +++ b/RTLBenchmarkApp/src/ReflectedCallUnknownReturn.h @@ -4,28 +4,28 @@ namespace bm_rtl { - struct function_ErasedReturnType + struct function__ErasedReturnType { static void set_string(benchmark::State& state); static void get_string(benchmark::State& state); }; - struct method___ErasedReturnType + struct method____ErasedReturnType { static void set_string(benchmark::State& state); static void get_string(benchmark::State& state); }; - struct method___ErasedTargetType + struct method____ErasedTargetType { static void set_string(benchmark::State& state); static void get_string(benchmark::State& state); }; - struct method___ErasedTargetAndReturnType + struct method____ErasedTargetAndReturnType { static void set_string(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/StandardCall.cpp b/RTLBenchmarkApp/src/StandardCall.cpp index 40868443..5fc48105 100644 --- a/RTLBenchmarkApp/src/StandardCall.cpp +++ b/RTLBenchmarkApp/src/StandardCall.cpp @@ -11,7 +11,7 @@ namespace { static auto _put_line = []() { std::cout << "-----------------------------------------------" - "--------------------------------------------------" << std::endl; + "---------------------------------------------------" << std::endl; return 0; }; @@ -41,7 +41,7 @@ namespace bm namespace bm_call { - void direct_Function::set_string(benchmark::State& state) + void direct__Function::set_string(benchmark::State& state) { for (auto _ : state) { @@ -50,7 +50,7 @@ namespace bm_call } } - void direct_Function::get_string(benchmark::State& state) + void direct__Function::get_string(benchmark::State& state) { static auto _ = _put_line(); for (auto _ : state) @@ -63,7 +63,7 @@ namespace bm_call namespace bm_std { - void function_CallsFunction::set_string(benchmark::State& state) + void function_calls__Function::set_string(benchmark::State& state) { static auto _ = _new_line(); for (auto _ : state) @@ -73,7 +73,7 @@ namespace bm_std } } - void function___CallsMethod::set_string(benchmark::State& state) + void function_calls____Method::set_string(benchmark::State& state) { static bm::Node nodeObj; for (auto _ : state) @@ -83,7 +83,7 @@ namespace bm_std } } - void function_CallsFunction::get_string(benchmark::State& state) + void function_calls__Function::get_string(benchmark::State& state) { static auto _ = _new_line(); for (auto _ : state) @@ -92,7 +92,7 @@ namespace bm_std } } - void function___CallsMethod::get_string(benchmark::State& state) + void function_calls____Method::get_string(benchmark::State& state) { static bm::Node nodeObj; for (auto _ : state) diff --git a/RTLBenchmarkApp/src/StandardCall.h b/RTLBenchmarkApp/src/StandardCall.h index a825692c..b74bad74 100644 --- a/RTLBenchmarkApp/src/StandardCall.h +++ b/RTLBenchmarkApp/src/StandardCall.h @@ -4,7 +4,7 @@ namespace bm_call { - struct direct_Function + struct direct__Function { static void set_string(benchmark::State& state); @@ -14,7 +14,7 @@ namespace bm_call namespace bm_std { - struct function_CallsFunction + struct function_calls__Function { static void set_string(benchmark::State& state); @@ -22,7 +22,7 @@ namespace bm_std }; - struct function___CallsMethod + struct function_calls____Method { static void set_string(benchmark::State& state); diff --git a/RTLBenchmarkApp/src/main.cpp b/RTLBenchmarkApp/src/main.cpp index f8bae56c..20c9a0f7 100644 --- a/RTLBenchmarkApp/src/main.cpp +++ b/RTLBenchmarkApp/src/main.cpp @@ -6,37 +6,37 @@ #include "ReflectedCallKnownReturn.h" #include "ReflectedCallUnknownReturn.h" -BENCHMARK(bm_call::direct_Function::set_string); +BENCHMARK(bm_call::direct__Function::set_string); -BENCHMARK(bm_call::by_FunctionPtr_Function::set_string); -BENCHMARK(bm_call::by_FunctionPtr___Method::set_string); +BENCHMARK(bm_call::via_function_ptr__Function::set_string); +BENCHMARK(bm_call::via_function_ptr____Method::set_string); -BENCHMARK(bm_std::function_CallsFunction::set_string); -BENCHMARK(bm_std::function___CallsMethod::set_string); +BENCHMARK(bm_std::function_calls__Function::set_string); +BENCHMARK(bm_std::function_calls____Method::set_string); -BENCHMARK(bm_rtl::function_CallsFunction::set_string); -BENCHMARK(bm_rtl::method_____CallsMethod::set_string); +BENCHMARK(bm_rtl::function_calls__Function::set_string); +BENCHMARK(bm_rtl::method_calls______Method::set_string); -BENCHMARK(bm_rtl::function_ErasedReturnType::set_string); -BENCHMARK(bm_rtl::method___ErasedReturnType::set_string); -BENCHMARK(bm_rtl::method___ErasedTargetType::set_string); -BENCHMARK(bm_rtl::method___ErasedTargetAndReturnType::set_string); +BENCHMARK(bm_rtl::function__ErasedReturnType::set_string); +BENCHMARK(bm_rtl::method____ErasedReturnType::set_string); +BENCHMARK(bm_rtl::method____ErasedTargetType::set_string); +BENCHMARK(bm_rtl::method____ErasedTargetAndReturnType::set_string); -BENCHMARK(bm_call::direct_Function::get_string); +BENCHMARK(bm_call::direct__Function::get_string); -BENCHMARK(bm_call::by_FunctionPtr_Function::get_string); -BENCHMARK(bm_call::by_FunctionPtr___Method::get_string); +BENCHMARK(bm_call::via_function_ptr__Function::get_string); +BENCHMARK(bm_call::via_function_ptr____Method::get_string); -BENCHMARK(bm_std::function_CallsFunction::get_string); -BENCHMARK(bm_std::function___CallsMethod::get_string); +BENCHMARK(bm_std::function_calls__Function::get_string); +BENCHMARK(bm_std::function_calls____Method::get_string); -BENCHMARK(bm_rtl::function_CallsFunction::get_string); -BENCHMARK(bm_rtl::method_____CallsMethod::get_string); +BENCHMARK(bm_rtl::function_calls__Function::get_string); +BENCHMARK(bm_rtl::method_calls______Method::get_string); -BENCHMARK(bm_rtl::function_ErasedReturnType::get_string); -BENCHMARK(bm_rtl::method___ErasedReturnType::get_string); -BENCHMARK(bm_rtl::method___ErasedTargetType::get_string); -BENCHMARK(bm_rtl::method___ErasedTargetAndReturnType::get_string); +BENCHMARK(bm_rtl::function__ErasedReturnType::get_string); +BENCHMARK(bm_rtl::method____ErasedReturnType::get_string); +BENCHMARK(bm_rtl::method____ErasedTargetType::get_string); +BENCHMARK(bm_rtl::method____ErasedTargetAndReturnType::get_string); namespace bm { diff --git a/ReflectionTemplateLib/rtl/builder/Builder.h b/ReflectionTemplateLib/rtl/builder/Builder.h index 687de0f2..e197516e 100644 --- a/ReflectionTemplateLib/rtl/builder/Builder.h +++ b/ReflectionTemplateLib/rtl/builder/Builder.h @@ -28,48 +28,32 @@ namespace rtl { }; - /* @struct: Builder - @param: specialized with methodQ, - * methodQ::NonConst - provides interface to register member funtion. - * methodQ::Const - provides interface to register const-member funtions. - * methodQ::None - provides interface to register non-member and static member funtions. + /* @struct: Builder + @param: specialized with member, + * member::NonConst - provides interface to register member funtion. + * member::Const - provides interface to register const-member funtions. + * member::None - provides interface to register non-member and static member funtions. @param: * _signature: arguments types of functions pointers or constructors (auto deduced/explicitly specified). * provides interface to register all sort of functions, methods & constructors. * every specialization has a 'build()' function, which accepts a function pointer. * function pointer can be non-member or member(static/const/non-const) functions. - */ template + */ template struct Builder; } namespace builder { - /* @struct: Builder - * specialized specifically to register overloaded non-member & static member functions with no arguments. - * Objects of this class will be created & returned by these functions, - * - type::function(..) - * - RecordBuilder<_recordType>::methodStatic(..) - * with template parameter is only 'void', explicitly specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(std::size_t pRecordId, const std::string_view pFunction, - const std::string_view pNamespace); - - template - const Function build(_returnType(*pFunctor)()) const; - }; - - /* @struct: Builder + /* @struct: Builder * specialized specifically to register overloaded non-member & static member functions with any arguments. * Objects of this class will be created & returned by these functions, * - type::function<...>(..) * - RecordBuilder<_recordType>::methodStatic<...>(..) * with template parameters can be anything, explicitly specified. */ template - struct Builder : protected detail::ReflectionBuilder + struct Builder : protected detail::ReflectionBuilder { Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace); @@ -79,14 +63,14 @@ namespace rtl { }; - /* @struct: Builder + /* @struct: Builder * specialized specifically to register non-member functions with any signature and with no overloads. * Objects of this class will be created & returned by these functions, * - type::function(..) * - RecordBuilder<_recordType>::methodStatic(..) * with no template parameters specified. */ template<> - struct Builder : protected detail::ReflectionBuilder + struct Builder : protected detail::ReflectionBuilder { Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace); @@ -99,28 +83,14 @@ namespace rtl { namespace builder { - /* @struct: Builder - * specialized specifically to register overloaded const-member-functions with no arguments. - * Objects of this class will be created & returned by function, - * - RecordBuilder<_recordType>::methodConst(..) - * with template parameters is only 'void' explicitly specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(const std::string_view pFunction, std::size_t pRecordId); - template - const Function build(_returnType(_recordType::* pFunctor)() const) const; - }; - - - /* @struct: Builder + /* @struct: Builder * specialized specifically to register overloaded const-member-functions with any arguments. * Objects of this class will be created & returned by function, * - RecordBuilder<_recordType>::methodConst<...>(..) * with template parameters can be anything, explicitly specified. */ template - struct Builder : protected detail::ReflectionBuilder + struct Builder : protected detail::ReflectionBuilder { Builder(const std::string_view pFunction, std::size_t pRecordId); @@ -129,13 +99,13 @@ namespace rtl { }; - /* @struct: Builder + /* @struct: Builder * specialized specifically to register non-overloaded const-member-functions with any arguments. * Objects of this class will be created & returned by function, * - RecordBuilder<_recordType>::methodConst() * with no template parameters specified. */ template<> - struct Builder : protected detail::ReflectionBuilder + struct Builder : protected detail::ReflectionBuilder { Builder(const std::string_view pFunction, std::size_t pRecordId); @@ -147,28 +117,14 @@ namespace rtl { namespace builder { - /* @struct: Builder - * specialized specifically to register overloaded non-const-member-functions with no arguments. - * Objects of this class will be created & returned by function, - * - RecordBuilder<_recordType>::method(..) - * with template parameters is only 'void' explicitly specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(const std::string_view pFunction, std::size_t pRecordId); - - template - const Function build(_returnType(_recordType::* pFunctor)()) const; - }; - - /* @struct: Builder + /* @struct: Builder * specialized specifically to register overloaded non-const-member-functions with no arguments. * Objects of this class will be created & returned by function, * - RecordBuilder<_recordType>::method(..) * with template parameters is only 'void' explicitly specified. */ template - struct Builder : protected detail::ReflectionBuilder + struct Builder : protected detail::ReflectionBuilder { Builder(const std::string_view pFunction, std::size_t pRecordId); @@ -177,13 +133,13 @@ namespace rtl { }; - /* @struct: Builder + /* @struct: Builder * specialized specifically to register non-overloaded non-const-member-functions and constructors with any arguments. * Objects of this class will be created & returned by function, * - RecordBuilder<_recordType>::method() - with no template parameters specified. * - RecordBuilder<_recordType>::constructor<...>() - template parameters can be anything or none, explicitly specified. */ template<> - struct Builder : protected detail::ReflectionBuilder + struct Builder : protected detail::ReflectionBuilder { Builder(const std::string_view pFunction, std::size_t pRecordId); diff --git a/ReflectionTemplateLib/rtl/builder/Builder.hpp b/ReflectionTemplateLib/rtl/builder/Builder.hpp index a343fbd8..67a10134 100644 --- a/ReflectionTemplateLib/rtl/builder/Builder.hpp +++ b/ReflectionTemplateLib/rtl/builder/Builder.hpp @@ -44,7 +44,7 @@ namespace rtl { namespace builder { - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) : ReflectionBuilder(pFunction, pRecordId, pNamespace) { } @@ -55,37 +55,16 @@ namespace rtl * called on the objects returned by 'type::function()' & 'RecordBuilder<_recordType>::methodStatic(..)'. * template params are auto deduced from the function pointer passed. */ template - inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const + inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { return buildFunctor(pFunctor); } } - - namespace builder - { - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) - : ReflectionBuilder(pFunction, pRecordId, pNamespace) - { } - - /* @method: build() - @param: _returnType(*)() - @return: 'Function' object. - * accepts a non-member or static-member function pointer with no arguments. - * called on objects returned by 'type::function(..)' & 'RecordBuilder<_recordType>::methodStatic(..)' - * template param 'void' is explicitly specified. - */ template - inline const Function Builder::build(_returnType(*pFunctor)()) const - { - return buildFunctor(pFunctor); - } - } - - namespace builder { template - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) : ReflectionBuilder(pFunction, pRecordId, pNamespace) { } @@ -98,16 +77,19 @@ namespace rtl * template params are explicitly specified. */ template template - inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const + inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { return buildFunctor(pFunctor); } } +} +namespace rtl +{ namespace builder { - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) : ReflectionBuilder(pFunction, pRecordId) { } @@ -118,37 +100,17 @@ namespace rtl * called on object returned by 'RecordBuilder<_recordType>::methodConst()' * template params will be auto deduced from the function pointer passed. */ template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...) const) const + inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...) const) const { return buildMethodFunctor(pFunctor); } } - namespace builder - { - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId) - { } - - /* @method: build() - @param: _returnType(_recordType::*)() const. - @return: 'Function' object. - * accepts a const-member-function pointer with no arguments. - * called on object returned by 'RecordBuilder<_recordType>::methodConst()' - * template param 'void' is explicitly specified. - */ template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)() const) const - { - return buildMethodFunctor(pFunctor); - } - } - - namespace builder { template - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) : ReflectionBuilder(pFunction, pRecordId) { } @@ -160,16 +122,19 @@ namespace rtl * template param are explicitly specified. */ template template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...) const) const + inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...) const) const { return buildMethodFunctor(pFunctor); } } +} +namespace rtl +{ namespace builder { - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) : ReflectionBuilder(pFunction, pRecordId) { } @@ -181,28 +146,7 @@ namespace rtl * called on object returned by 'RecordBuilder<_recordType>::method()' * template params are auto deduced from the pointer passed. */ template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...)) const - { - return buildMethodFunctor(pFunctor); - } - } - - - namespace builder - { - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId) - { } - - - /* @method: build() - @param: _returnType(_recordType::*)() - @return: 'Function' object. - * accepts a non-const-member-function pointer with no arguments. - * called on object returned by 'RecordBuilder<_recordType>::method()' - * template param 'void' is explicitly specified. - */ template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)()) const + inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...)) const { return buildMethodFunctor(pFunctor); } @@ -212,7 +156,7 @@ namespace rtl namespace builder { template - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) : ReflectionBuilder(pFunction, pRecordId) { } @@ -224,7 +168,7 @@ namespace rtl * template params are explicitly specified. */ template template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...)) const + inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...)) const { return buildMethodFunctor(pFunctor); } diff --git a/ReflectionTemplateLib/rtl/builder/ConstructorBuilder.h b/ReflectionTemplateLib/rtl/builder/ConstructorBuilder.h index 5031b02e..36acf76a 100644 --- a/ReflectionTemplateLib/rtl/builder/ConstructorBuilder.h +++ b/ReflectionTemplateLib/rtl/builder/ConstructorBuilder.h @@ -49,8 +49,8 @@ namespace rtl { /* @method: build() @param: none @return: 'Function' object. - * constructs temparory object of class Builder with given class/struct, namespace name & constructor type. - * forwards the call to Builder::build(). + * constructs temparory object of class Builder with given class/struct, namespace name & constructor type. + * forwards the call to Builder::build(). */ const Function build() const { // Check if the constructor is not deleted and publicly accessible (excluding default constructor). diff --git a/ReflectionTemplateLib/rtl/builder/MethodContainer.h b/ReflectionTemplateLib/rtl/builder/MethodContainer.h index a542b033..2568f716 100644 --- a/ReflectionTemplateLib/rtl/builder/MethodContainer.h +++ b/ReflectionTemplateLib/rtl/builder/MethodContainer.h @@ -29,22 +29,22 @@ namespace rtl { //forward decl class ReflectionBuilder; - template + template class MethodContainer; - /* @class: MethodContainer + /* @class: MethodContainer @param: '_signature...' (combination of any types) * container class for holding lambda's wrapping non-const-member-function functor calls of same signatures. * maintains a std::vector with static lifetime. */ template - class MethodContainer : public SetupMethod>, - public CallReflector> + class MethodContainer : public SetupMethod>, + public CallReflector> { using MethodLambda = std::function < Return (const FunctorId&, const rtl::RObject&, _signature...) >; public: - //every MethodContainer will have a unique-id. + //every MethodContainer will have a unique-id. static std::size_t getContainerId() { //holds unique-id static const std::size_t containerId = generate_unique_id(); @@ -98,26 +98,26 @@ namespace rtl { //friends :) friend ReflectionBuilder; - friend SetupMethod>; + friend SetupMethod>; }; } namespace detail { - /* @class: MethodContainer + /* @class: MethodContainer @param: '_signature...' (combination of any types) * container class for holding lambda's wrapping const-member-function functor calls of same signatures. * maintains a std::vector with static lifetime. */ template - class MethodContainer : public SetupMethod>, - public CallReflector> + class MethodContainer : public SetupMethod>, + public CallReflector> { using MethodLambda = std::function < Return (const FunctorId&, const rtl::RObject&, _signature...) >; public: - //every MethodContainer will have a unique-id. + //every MethodContainer will have a unique-id. ForceInline static std::size_t getContainerId() { //holds unique-id static const std::size_t containerId = generate_unique_id(); @@ -171,7 +171,7 @@ namespace rtl { //friends :) friend ReflectionBuilder; - friend SetupMethod>; + friend SetupMethod>; }; } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/RecordBuilder.h b/ReflectionTemplateLib/rtl/builder/RecordBuilder.h index 7f28bd76..b3db5344 100644 --- a/ReflectionTemplateLib/rtl/builder/RecordBuilder.h +++ b/ReflectionTemplateLib/rtl/builder/RecordBuilder.h @@ -46,20 +46,20 @@ namespace rtl { */ template struct MethodBuilder { - const Builder method(const std::string_view pFunction) const; + const Builder method(const std::string_view pFunction) const; - const Builder methodConst(const std::string_view pFunction) const; + const Builder methodConst(const std::string_view pFunction) const; - const Builder methodStatic(const std::string_view pFunction) const; + const Builder methodStatic(const std::string_view pFunction) const; template - const Builder method(const std::string_view pFunction) const; + const Builder method(const std::string_view pFunction) const; template - const Builder methodConst(const std::string_view pFunction) const; + const Builder methodConst(const std::string_view pFunction) const; template - const Builder methodStatic(const std::string_view pFunction) const; + const Builder methodStatic(const std::string_view pFunction) const; template constexpr const ConstructorBuilder<_recordType, traits::remove_cref_t<_signature>...> constructor() const; diff --git a/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp index b9a74cf6..d4b13185 100644 --- a/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp @@ -57,21 +57,21 @@ namespace rtl::builder /* @method: methodStatic() @param: std::string, name of function as string. - @return: Builder + @return: Builder * registers only static member functions. * used for registering unique static member function, if overload exists, use templated version 'methodStatic<...>()'. * the 'build(..)' called on return object will accepts static member function pointer only. * compiler error on 'build(..)' if non-static member or non-member function pointer is passed. */ template - inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const + inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const { - return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); + return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); } /* @method: methodStatic<...>() @param: std::string, name of function as string. - @return: Builder + @return: Builder * registers only static member functions. * used for registering overloads, if unique member function, use non-templated version 'methodStatic()'. * template parameters must be explicitly specified, should be exactly same as the member-function being registered. @@ -79,43 +79,43 @@ namespace rtl::builder * compiler error on 'build(..)' if const member or non-member function pointer is passed. */ template template - inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const + inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const { - return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); + return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); } /* @method: method() @param: std::string, name of function as string. - @return: Builder + @return: Builder * registers non-const, non-static member functions. * the 'build(..)' called on return object will accepts non-const, non-static member-function-pointer only. * compiler error on 'build(..)' if const, static member or non-member function pointer is passed. */ template - inline const Builder MethodBuilder<_recordType>::method(const std::string_view pFunction) const + inline const Builder MethodBuilder<_recordType>::method(const std::string_view pFunction) const { - return Builder(pFunction, detail::TypeId<_recordType>::get()); + return Builder(pFunction, detail::TypeId<_recordType>::get()); } /* @method: methodConst() @param: std::string, name of function as string. - @return: Builder + @return: Builder * registers const member functions. * used for registering unique member function, if overload exists, use templated version 'methodConst<...>()'. * template parameters must be explicitly specified, should be exactly same as the member-function being registered. * the 'build(..)' called on return object will accepts non-const member-function-pointer only. * compiler error 'build(..)' if non-const, static member or non-member function pointer is passed. */ template - inline const Builder MethodBuilder<_recordType>::methodConst(const std::string_view pFunction) const + inline const Builder MethodBuilder<_recordType>::methodConst(const std::string_view pFunction) const { - return Builder(pFunction, detail::TypeId<_recordType>::get()); + return Builder(pFunction, detail::TypeId<_recordType>::get()); } /* @method: method() @param: std::string, name of function as string. - @return: Builder + @return: Builder * registers non-const member functions. * used for registering overloads, for unique member function, use non-templated version 'method()'. * template parameters must be explicitly specified, should be exactly same as the member-function being registered. @@ -123,15 +123,15 @@ namespace rtl::builder * compiler error on 'build(..)' if const, static member or non-member function pointer is passed. */ template template - inline const Builder MethodBuilder<_recordType>::method(const std::string_view pFunction) const + inline const Builder MethodBuilder<_recordType>::method(const std::string_view pFunction) const { - return Builder(pFunction, detail::TypeId<_recordType>::get()); + return Builder(pFunction, detail::TypeId<_recordType>::get()); } /* @method: methodConst<...>() @param: std::string, name of function as string. - @return: Builder + @return: Builder * registers const member functions. * used for registering overloads, for unique member function, use non-templated version 'methodConst()'. * template parameters must be explicitly specified, should be exactly same as the member-function being registered. @@ -139,8 +139,8 @@ namespace rtl::builder * compiler error on 'build(..)' if non-const, static member or non-member function pointer is passed. */ template template - inline const Builder MethodBuilder<_recordType>::methodConst(const std::string_view pFunction) const + inline const Builder MethodBuilder<_recordType>::methodConst(const std::string_view pFunction) const { - return Builder(pFunction, detail::TypeId<_recordType>::get()); + return Builder(pFunction, detail::TypeId<_recordType>::get()); } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/Reflect.h b/ReflectionTemplateLib/rtl/builder/Reflect.h index 9f6fc62e..8c8bf1a4 100644 --- a/ReflectionTemplateLib/rtl/builder/Reflect.h +++ b/ReflectionTemplateLib/rtl/builder/Reflect.h @@ -43,7 +43,7 @@ namespace rtl constexpr const builder::RecordBuilder<_recordType> record(const std::string_view pClass); template - constexpr const builder::Builder function(const std::string_view pFunction); + constexpr const builder::Builder function(const std::string_view pFunction); private: @@ -79,7 +79,7 @@ namespace rtl } template - constexpr const builder::Builder function(const std::string_view pFunction) + constexpr const builder::Builder function(const std::string_view pFunction) { constexpr bool hasConstRValueRef = ((std::is_const_v> && std::is_rvalue_reference_v<_signature>) || ...); static_assert(!hasConstRValueRef, "Registration of functions with 'const T&&' parameters is not allowed."); diff --git a/ReflectionTemplateLib/rtl/builder/Reflect.hpp b/ReflectionTemplateLib/rtl/builder/Reflect.hpp index 07cda31d..0e0e54f1 100644 --- a/ReflectionTemplateLib/rtl/builder/Reflect.hpp +++ b/ReflectionTemplateLib/rtl/builder/Reflect.hpp @@ -40,14 +40,14 @@ namespace rtl /* @function: function() @param: std::string (name of the function). - @return: Builder + @return: Builder * registers only non-member functions. * the 'build(..)' called on return object accepts non-member function pointer only. * compiler error on 'build(..)' if member function pointer is passed. */ template<> - inline const builder::Builder type_ns::function(const std::string_view pFunction) + inline const builder::Builder type_ns::function(const std::string_view pFunction) { - return builder::Builder(detail::TypeId<>::None, pFunction, m_namespace); + return builder::Builder(detail::TypeId<>::None, pFunction, m_namespace); } @@ -66,15 +66,15 @@ namespace rtl /* @method: function<...>() @param: std::string (name of function) - @return: Builder + @return: Builder * registers only non-member functions. * used for registering overloads, if unique member function, use non-templated version 'function()'. * template parameters must be explicitly specified, should be exactly same as the function being registered. * the 'build(..)' called on return object accepts non-member function pointer only. * compiler error on 'build(..)' if any member function pointer is passed. */ template - inline constexpr const builder::Builder type_ns::function(const std::string_view pFunction) + inline constexpr const builder::Builder type_ns::function(const std::string_view pFunction) { - return builder::Builder(detail::TypeId<>::None, pFunction, m_namespace); + return builder::Builder(detail::TypeId<>::None, pFunction, m_namespace); } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp index f4e2af04..980f88c8 100644 --- a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp @@ -43,7 +43,7 @@ namespace rtl::detail { using Container = FunctorContainer< traits::remove_const_if_not_reference<_signature>...>; auto [typeMeta, functorId] = Container::template addFunctor<_returnType, _signature...>(pFunctor, m_recordId); - return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, methodQ::None); + return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, member::None); } @@ -57,9 +57,9 @@ namespace rtl::detail */ template inline const Function ReflectionBuilder::buildMethodFunctor(_returnType(_recordType::* pFunctor)(_signature...)) const { - using Container = MethodContainer...>; + using Container = MethodContainer...>; auto [typeMeta, functorId] = Container::template addFunctor<_recordType, _returnType, _signature...>(pFunctor); - return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, methodQ::NonConst); + return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, member::NonConst); } @@ -73,9 +73,9 @@ namespace rtl::detail */ template inline const Function ReflectionBuilder::buildMethodFunctor(_returnType(_recordType::* pFunctor)(_signature...) const) const { - using Container = MethodContainer...>; + using Container = MethodContainer...>; auto [typeMeta, functorId] = Container::template addFunctor<_recordType, _returnType, _signature...>(pFunctor); - return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, methodQ::Const); + return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, member::Const); } @@ -90,7 +90,7 @@ namespace rtl::detail using Container = FunctorContainer < rtl::alloc, FunctorId, traits::remove_const_if_not_reference<_ctorSignature>... > ; const FunctorId& functorId = Container::template addConstructor<_recordType, _ctorSignature...>(); const FunctorId& copyCtorId = traits::Cloner::template addCopyConstructor<_recordType, RObject, alloc>(); - const Function& ctorFunction = Function(m_namespace, m_record, m_function, rtl::type_meta(), functorId, m_recordId, methodQ::None); + const Function& ctorFunction = Function(m_namespace, m_record, m_function, rtl::type_meta(), functorId, m_recordId, member::None); ctorFunction.getFunctorIds().push_back(copyCtorId); return ctorFunction; diff --git a/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp b/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp index dfe8245e..880127e4 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupConstructor.hpp @@ -175,7 +175,7 @@ namespace rtl::detail return (itr != ctorSet.end() ? itr->second : index_none); }; - //auto& lambdaCache = lambda_function::get<_signature...>(); + //auto& lambdaCache = lambda_function::get<_signature...>(); //const auto& pushLambdaHopper = [&]()-> std::size_t //{ // return lambdaCache.push_cloner<_recordType>(); diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.h b/ReflectionTemplateLib/rtl/builder/SetupMethod.h index f6a1f858..6b177d54 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.h +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.h @@ -19,8 +19,8 @@ namespace rtl::detail { @param: _derivedType (type which inherits this class) * creates a lambda to perform call on the registered functor. * adds it to the functor-container, maintains the already added functor set as well. - * deriving classes is MethodContainer & - MethodContainer, which must implement - + * deriving classes is MethodContainer & + MethodContainer, which must implement - - std::size_t& _derived::getContainerId(); - std::string _derivedType::getSignatureStr(); - std::size_t& _derived::pushBack(std::function < RObject (error&, const rtl::RObject&, _signature...) >, diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 77e1d48c..27f732e4 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -30,7 +30,7 @@ namespace rtl::detail SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...)) { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>() @@ -54,7 +54,7 @@ namespace rtl::detail SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...)) { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>() @@ -99,7 +99,7 @@ namespace rtl::detail SetupMethod<_derivedType>::getMethodCaller(void(_recordType::* pFunctor)(_signature...) const) { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { auto fptr = pFunctorId.get_lambda_method() @@ -119,7 +119,7 @@ namespace rtl::detail SetupMethod<_derivedType>::getMethodCaller(_returnType(_recordType::* pFunctor)(_signature...) const) { /* a variable arguments lambda, which finally calls the 'pFunctor' with 'params...'. - this is stored in _derivedType's (MethodContainer) vector holding lambda's. + this is stored in _derivedType's (MethodContainer) vector holding lambda's. */ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return { auto fptr = pFunctorId.get_lambda_method() @@ -155,12 +155,12 @@ namespace rtl::detail /* @method: addFunctor(). @param: 'pFuntor' (a non-const, non-static-member function pointer). - '_derivedType' : class deriving this class ('MethodContainer'). + '_derivedType' : class deriving this class ('MethodContainer'). '_recordType' : the owner 'class/stuct' type of the functor. '_returnType' : return type deduced from 'pFunctor'. '_signature...' : function signature deduced from 'pFunctor'. @return: 'FunctorId' object, a hash-key to lookup the lambda (functor-wrapped) in the _derivedType's lambda-table. - * adds lambda (functor-wrapped) in '_derivedType' (MethodContainer) and maintains functorSet. + * adds lambda (functor-wrapped) in '_derivedType' (MethodContainer) and maintains functorSet. * thread safe, multiple functors can be registered simultaneously. */ template template @@ -185,7 +185,7 @@ namespace rtl::detail //generate a type-id of '_returnType'. const std::size_t retTypeId = TypeId>::get(); - //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. + //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); //construct the hash-key 'FunctorId' and return. @@ -206,12 +206,12 @@ namespace rtl::detail /* @method: addFunctor(). @param: 'pFuntor' (a const, non-static-member function pointer). - '_derivedType' : class deriving this class ('MethodContainer'). + '_derivedType' : class deriving this class ('MethodContainer'). '_recordType' : the owner 'class/stuct' type of the functor. '_returnType' : return type deduced from 'pFunctor'. '_signature...' : function signature deduced from 'pFunctor'. @return: 'FunctorId' object, a hash-key to lookup the lambda (containing functor) in the _derivedType's lambda table. - * adds lambda (containing functor) in '_derivedType' (MethodContainer) and maintains a functorSet. + * adds lambda (containing functor) in '_derivedType' (MethodContainer) and maintains a functorSet. * thread safe, multiple functors can be registered simultaneously. */ template template @@ -235,7 +235,7 @@ namespace rtl::detail //generate a type-id of '_returnType'. const std::size_t retTypeId = TypeId>::get(); - //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. + //finally add the lambda 'functor' in 'MethodContainer' lambda vector and get the index. auto lambdaIndex = _derivedType::pushBack(getMethodCaller(pFunctor), getIndex, updateIndex); diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 72986e56..4274e362 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -33,8 +33,8 @@ namespace rtl::detail template ForceInline Return DefaultInvoker<_signature...>::call(_args&& ...params) const noexcept { - //Only static-member-functions have Qualifier- 'methodQ::None' - if (m_method->getQualifier() == methodQ::None) [[unlikely]] { + //Only static-member-functions have Qualifier- 'member::None' + if (m_method->getQualifier() == member::None) [[unlikely]] { return static_cast(*m_method).bind().call(std::forward<_args>(params)...); } else if (m_target->isEmpty()) [[unlikely]] { @@ -67,7 +67,7 @@ namespace rtl::detail const RObject& pTarget, _args&&... params) { - using containerConst = detail::MethodContainer; + using containerConst = detail::MethodContainer; const FunctorId* constFunctorId = pMethod.hasFunctorId(containerConst::getContainerId()); if (constFunctorId != nullptr) [[likely]] @@ -76,7 +76,7 @@ namespace rtl::detail } else [[unlikely]] { - using containerNonConst = detail::MethodContainer; + using containerNonConst = detail::MethodContainer; const FunctorId* functorId = pMethod.hasFunctorId(containerNonConst::getContainerId()); if (functorId != nullptr) @@ -102,7 +102,7 @@ namespace rtl::detail template ForceInline Return NonConstInvoker<_signature...>::call(_args&& ...params) const noexcept { - if (m_method->getQualifier() == methodQ::None) [[unlikely]] { + if (m_method->getQualifier() == member::None) [[unlikely]] { return static_cast(*m_method).bind().call(std::forward<_args>(params)...); } else if (m_target->isEmpty()) [[unlikely]] { @@ -134,7 +134,7 @@ namespace rtl::detail const RObject& pTarget, _args&&... params) { - using container0 = detail::MethodContainer; + using container0 = detail::MethodContainer; const FunctorId* functorId = pMethod.hasFunctorId(container0::getContainerId()); if (functorId != nullptr) [[likely]] { @@ -143,7 +143,7 @@ namespace rtl::detail else { // check if the const-overload method is present. - using container2 = detail::MethodContainer; + using container2 = detail::MethodContainer; std::size_t index = pMethod.hasSignatureId(container2::getContainerId()); if (index != rtl::index_none) { // So, const-overload is present and non-const overload is not registered or doesn't exists. diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 27d3327f..439613f7 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -39,7 +39,7 @@ namespace rtl::dispatch bool m_is_any_arg_ncref = false; std::vector m_argumentsId = {}; - detail::methodQ m_qualifier = detail::methodQ::None; + detail::member m_qualifier = detail::member::None; private: diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index f3fd4315..20a49d40 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -32,7 +32,7 @@ namespace rtl::dispatch method_ptr(functor_t fptr) :m_functor(fptr) { - m_qualifier = detail::methodQ::NonConst; + m_qualifier = detail::member::NonConst; m_returnId = traits::uid::value; m_is_void = (m_returnId == traits::uid::value); diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h index 120b2b3c..8790b9e8 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h @@ -32,7 +32,7 @@ namespace rtl::dispatch method_ptr(functor_t fptr) :m_functor(fptr) { - m_qualifier = detail::methodQ::Const; + m_qualifier = detail::member::Const; m_returnId = traits::uid::value; m_is_void = (m_returnId == traits::uid::value); diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index b5f3f265..e40c46d4 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -34,8 +34,8 @@ namespace rtl { * perform call on the functor represented by this object. */ class Function { - //methodQ::Const/Mute represents the const/non-const member-function, Type::None for non-member & static-member functions. - detail::methodQ m_qualifier; + //member::Const/Mute represents the const/non-const member-function, Type::None for non-member & static-member functions. + detail::member m_qualifier; //type id of class/struct (if it represents a member-function, else always '0') std::size_t m_recordTypeId; @@ -58,7 +58,7 @@ namespace rtl { Function(const std::string_view pNamespace, const std::string_view pClassName, const std::string_view pFuncName, const type_meta& pFunctorsMeta, const detail::FunctorId& pFunctorId, - const std::size_t pRecordTypeId, const detail::methodQ pQualifier); + const std::size_t pRecordTypeId, const detail::member pQualifier); void addOverload(const Function& pOtherFunc) const; @@ -75,7 +75,7 @@ namespace rtl { constexpr std::optional getLambdaByStrictId(const std::size_t pSignatureId) const; - GETTER(detail::methodQ, Qualifier, m_qualifier); + GETTER(detail::member, Qualifier, m_qualifier); GETTER_REF_C(std::vector, FunctorIds, m_functorIds) diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index d423cdb1..282b26b3 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -50,7 +50,7 @@ namespace rtl { Method& operator=(Method&&) = default; Method& operator=(const Method&) = default; - GETTER_BOOL(Const, (getQualifier() == detail::methodQ::Const)); + GETTER_BOOL(Const, (getQualifier() == detail::member::Const)); using Function::bind; diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 9454ee09..8fe10421 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -62,15 +62,15 @@ namespace rtl { switch (getQualifier()) { - case detail::methodQ::None: { + case detail::member::None: { return Function::hasSignature<_args...>(); } - case detail::methodQ::NonConst: { - using Container = detail::MethodContainer; + case detail::member::NonConst: { + using Container = detail::MethodContainer; return (hasSignatureId(Container::getContainerId()) != -1); } - case detail::methodQ::Const: { - using Container = detail::MethodContainer; + case detail::member::Const: { + using Container = detail::MethodContainer; return (hasSignatureId(Container::getContainerId()) != -1); } } diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h index bf88eb8c..d9dfcde4 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.h +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -43,7 +43,7 @@ namespace rtl GETTER(traits::uid_t, _normal_args_id, m_functor->get().m_normal_signId) GETTER(traits::uid_t, _strict_args_id, m_functor->get().m_strict_signId) - GETTER(detail::methodQ, _method_qual, m_functor->get().m_qualifier) + GETTER(detail::member, _method_qual, m_functor->get().m_qualifier) GETTER_CREF(dispatch::lambda_base, _lambda, *(m_functor->get().m_lambda)) GETTER_CREF(dispatch::erasure_base, _erasure_base, *(m_functor->get().m_erasure)) diff --git a/ReflectionTemplateLib/rtl/rtl_constants.h b/ReflectionTemplateLib/rtl/rtl_constants.h index 7e999cb2..f5817472 100644 --- a/ReflectionTemplateLib/rtl/rtl_constants.h +++ b/ReflectionTemplateLib/rtl/rtl_constants.h @@ -128,11 +128,12 @@ namespace rtl::detail // MethodQ: Method qualifier + static marker. - enum class methodQ + enum class member { - None = 0, // Static method (no const/non-const qualifier) + None = 0, // non-member functions. Const, // Const-qualified instance method - NonConst // Non-const instance method + NonConst, // Non-const instance method + Static // Static methods }; constexpr const std::string_view NAMESPACE_GLOBAL = "global"; @@ -142,9 +143,9 @@ namespace rtl::detail return (std::string(pRecordName) + "::" + std::string(pRecordName) + "()"); } -#define GETTER(_varType, _name, _var) \ +#define GETTER(_varType, _name, _var) \ inline constexpr const _varType get##_name() const { \ - return _var; \ + return _var; \ } #define GETTER_REF_C(_varType, _name, _var) \ diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index 8e7a4a7f..0b338525 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -28,7 +28,7 @@ namespace rtl ExplicitRefBindingRequired, NonStaticMethodRequiresTarget, - CloningDisabled, //Used only in case of cloning is disabled e.g, unregistered type. + CloningDisabled, //Used only in case of cloning is disabled e.g, unregistered type returnd from a function. FunctionNotRegistered, //Not used by RTL at all, for external purpose only. IllegalConstCast, diff --git a/ReflectionTemplateLib/rtl/src/Function.cpp b/ReflectionTemplateLib/rtl/src/Function.cpp index a482016d..829f1e1a 100644 --- a/ReflectionTemplateLib/rtl/src/Function.cpp +++ b/ReflectionTemplateLib/rtl/src/Function.cpp @@ -23,11 +23,11 @@ namespace rtl * pFunction - given name of the function as string. * pFunctorId - 'FunctorId', generated for every functor being registered. * pRecordTypeId - type id of class/struct if the functor is member-function, '0' for non-member-functions. - * pQualifier - whether the member-function is const or non-const. methodQ::None for non-member & static-member functions. + * pQualifier - whether the member-function is const or non-const. member::None for non-member & static-member functions. * 'Function' object is created for every functor (member/non-member) being registered. */ Function::Function(const std::string_view pNamespace, const std::string_view pRecord, const std::string_view pFunction, const type_meta& pFunctorsMeta, const detail::FunctorId& pFunctorId, - const std::size_t pRecordTypeId, const detail::methodQ pQualifier) + const std::size_t pRecordTypeId, const detail::member pQualifier) : m_qualifier(pQualifier) , m_recordTypeId(pRecordTypeId) , m_record(pRecord) From a10642230812cf7e30675c29e021a0d7da9ee7b6 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 29 Oct 2025 08:07:54 +0530 Subject: [PATCH 109/148] gcc/clang compilation error fix. --- ReflectionTemplateLib/rtl/builder/Builder.h | 44 +++++++++++++ ReflectionTemplateLib/rtl/builder/Builder.hpp | 62 +++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/ReflectionTemplateLib/rtl/builder/Builder.h b/ReflectionTemplateLib/rtl/builder/Builder.h index e197516e..ccea02cc 100644 --- a/ReflectionTemplateLib/rtl/builder/Builder.h +++ b/ReflectionTemplateLib/rtl/builder/Builder.h @@ -45,6 +45,22 @@ namespace rtl { namespace builder { + /* @struct: Builder + * specialized specifically to register overloaded non-member & static member functions with no arguments. + * Objects of this class will be created & returned by these functions, + * - type::function(..) + * - RecordBuilder<_recordType>::methodStatic(..) + * with template parameter is only 'void', explicitly specified. + */ template<> + struct Builder : protected detail::ReflectionBuilder + { + Builder(std::size_t pRecordId, const std::string_view pFunction, + const std::string_view pNamespace); + + template + const Function build(_returnType(*pFunctor)()) const; + }; + /* @struct: Builder * specialized specifically to register overloaded non-member & static member functions with any arguments. @@ -83,6 +99,20 @@ namespace rtl { namespace builder { + /* @struct: Builder + * specialized specifically to register overloaded const-member-functions with no arguments. + * Objects of this class will be created & returned by function, + * - RecordBuilder<_recordType>::methodConst(..) + * with template parameters is only 'void' explicitly specified. + */ template<> + struct Builder : protected detail::ReflectionBuilder + { + Builder(const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build(_returnType(_recordType::* pFunctor)() const) const; + }; + /* @struct: Builder * specialized specifically to register overloaded const-member-functions with any arguments. @@ -117,6 +147,20 @@ namespace rtl { namespace builder { + /* @struct: Builder + * specialized specifically to register overloaded non-const-member-functions with no arguments. + * Objects of this class will be created & returned by function, + * - RecordBuilder<_recordType>::method(..) + * with template parameters is only 'void' explicitly specified. + */ template<> + struct Builder : protected detail::ReflectionBuilder + { + Builder(const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build(_returnType(_recordType::* pFunctor)()) const; + }; + /* @struct: Builder * specialized specifically to register overloaded non-const-member-functions with no arguments. diff --git a/ReflectionTemplateLib/rtl/builder/Builder.hpp b/ReflectionTemplateLib/rtl/builder/Builder.hpp index 67a10134..18f6c45b 100644 --- a/ReflectionTemplateLib/rtl/builder/Builder.hpp +++ b/ReflectionTemplateLib/rtl/builder/Builder.hpp @@ -61,6 +61,27 @@ namespace rtl } } + + namespace builder + { + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + : ReflectionBuilder(pFunction, pRecordId, pNamespace) + { } + + /* @method: build() + @param: _returnType(*)() + @return: 'Function' object. + * accepts a non-member or static-member function pointer with no arguments. + * called on objects returned by 'type::function(..)' & 'RecordBuilder<_recordType>::methodStatic(..)' + * template param 'void' is explicitly specified. + */ template + inline const Function Builder::build(_returnType(*pFunctor)()) const + { + return buildFunctor(pFunctor); + } + } + + namespace builder { template @@ -107,6 +128,26 @@ namespace rtl } + namespace builder + { + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId) + { } + + /* @method: build() + @param: _returnType(_recordType::*)() const. + @return: 'Function' object. + * accepts a const-member-function pointer with no arguments. + * called on object returned by 'RecordBuilder<_recordType>::methodConst()' + * template param 'void' is explicitly specified. + */ template + inline const Function Builder::build(_returnType(_recordType::* pFunctor)() const) const + { + return buildMethodFunctor(pFunctor); + } + } + + namespace builder { template @@ -152,6 +193,27 @@ namespace rtl } } + + namespace builder + { + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId) + { } + + + /* @method: build() + @param: _returnType(_recordType::*)() + @return: 'Function' object. + * accepts a non-const-member-function pointer with no arguments. + * called on object returned by 'RecordBuilder<_recordType>::method()' + * template param 'void' is explicitly specified. + */ template + inline const Function Builder::build(_returnType(_recordType::* pFunctor)()) const + { + return buildMethodFunctor(pFunctor); + } + } + namespace builder { From 3da8c70ab539d537c268ad5dbde192483da69607 Mon Sep 17 00:00:00 2001 From: neeraj Date: Wed, 29 Oct 2025 12:38:04 +0530 Subject: [PATCH 110/148] static-method-calls, tests failing. wip. --- ReflectionTemplateLib/rtl/builder/Builder.h | 390 +++++++++-------- ReflectionTemplateLib/rtl/builder/Builder.hpp | 406 ++++++++++-------- .../rtl/builder/RecordBuilder.h | 4 +- .../rtl/builder/RecordBuilder.hpp | 12 +- .../rtl/builder/ReflectionBuilder.h | 3 +- .../rtl/builder/ReflectionBuilder.hpp | 4 +- 6 files changed, 458 insertions(+), 361 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/Builder.h b/ReflectionTemplateLib/rtl/builder/Builder.h index ccea02cc..fdadbcde 100644 --- a/ReflectionTemplateLib/rtl/builder/Builder.h +++ b/ReflectionTemplateLib/rtl/builder/Builder.h @@ -14,181 +14,227 @@ #include "Function.h" #include "ReflectionBuilder.h" -namespace rtl { +namespace rtl::builder +{ + struct CtorBuilder : protected detail::ReflectionBuilder + { + CtorBuilder(const std::string_view pNamespace, const std::string_view pRecord, + const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build() const; + }; + + +/* @struct: Builder + @param: specialized with member, + * member::NonConst - provides interface to register member funtion. + * member::Const - provides interface to register const-member funtions. + * member::Static - provides interface to register static member funtions. + * member::None - provides interface to register non-member funtions. + @param: + * _signature: arguments types of functions pointers or constructors (auto-deduced/explicitly-specified). + * provides interface to register all sort of functions, methods & constructors. + * every specialization has a 'build()' function, which accepts a function pointer. + * function pointer can be non-member or member(static/const/non-const) functions. +*/ template + struct Builder; +} + + +namespace rtl::builder +{ +/* @struct: Builder + * specialized specifically to register overloaded non-member & static member functions with no arguments. + * Objects of this class will be created & returned by the function, + * - type::function(..) + * with template parameter is only 'void', explicitly specified. +*/ template<> + struct Builder : protected detail::ReflectionBuilder + { + Builder(std::size_t pRecordId, const std::string_view pFunction, + const std::string_view pNamespace); + + template + const Function build(_returnType(*pFunctor)()) const; + }; - namespace builder + +/* @struct: Builder + * specialized specifically to register overloaded non-member & static member functions with any arguments. + * Objects of this class will be created & returned by the function, + * - type::function<...>(..) + * with template parameters can be anything, explicitly specified. +*/ template + struct Builder : protected detail::ReflectionBuilder { - struct CtorBuilder : protected detail::ReflectionBuilder - { - CtorBuilder(const std::string_view pNamespace, const std::string_view pRecord, - const std::string_view pFunction, std::size_t pRecordId); - - template - const Function build() const; - }; - - - /* @struct: Builder - @param: specialized with member, - * member::NonConst - provides interface to register member funtion. - * member::Const - provides interface to register const-member funtions. - * member::None - provides interface to register non-member and static member funtions. - @param: - * _signature: arguments types of functions pointers or constructors (auto deduced/explicitly specified). - * provides interface to register all sort of functions, methods & constructors. - * every specialization has a 'build()' function, which accepts a function pointer. - * function pointer can be non-member or member(static/const/non-const) functions. - */ template - struct Builder; - } - - - namespace builder + Builder(std::size_t pRecordId, const std::string_view pFunction, + const std::string_view pNamespace); + + template + const Function build(_returnType(*pFunctor)(_signature...)) const; + }; + + +/* @struct: Builder + * specialized specifically to register non-member functions with any signature and with no overloads. + * Objects of this class will be created & returned by the function, + * - type::function(..) + * with no template parameters specified. +*/ template<> + struct Builder : protected detail::ReflectionBuilder { - /* @struct: Builder - * specialized specifically to register overloaded non-member & static member functions with no arguments. - * Objects of this class will be created & returned by these functions, - * - type::function(..) - * - RecordBuilder<_recordType>::methodStatic(..) - * with template parameter is only 'void', explicitly specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(std::size_t pRecordId, const std::string_view pFunction, - const std::string_view pNamespace); - - template - const Function build(_returnType(*pFunctor)()) const; - }; - - - /* @struct: Builder - * specialized specifically to register overloaded non-member & static member functions with any arguments. - * Objects of this class will be created & returned by these functions, - * - type::function<...>(..) - * - RecordBuilder<_recordType>::methodStatic<...>(..) - * with template parameters can be anything, explicitly specified. - */ template - struct Builder : protected detail::ReflectionBuilder - { - Builder(std::size_t pRecordId, const std::string_view pFunction, - const std::string_view pNamespace); - - template - const Function build(_returnType(*pFunctor)(_signature...)) const; - }; - - - /* @struct: Builder - * specialized specifically to register non-member functions with any signature and with no overloads. - * Objects of this class will be created & returned by these functions, - * - type::function(..) - * - RecordBuilder<_recordType>::methodStatic(..) - * with no template parameters specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(std::size_t pRecordId, const std::string_view pFunction, - const std::string_view pNamespace); - - template - const Function build(_returnType(*pFunctor)(_signature...)) const; - }; - } - - - namespace builder + Builder(std::size_t pRecordId, const std::string_view pFunction, + const std::string_view pNamespace); + + template + const Function build(_returnType(*pFunctor)(_signature...)) const; + }; +} + + +namespace rtl::builder +{ +/* @struct: Builder + * specialized specifically to register overloaded non-member & static member functions with no arguments. + * Objects of this class will be created & returned by the function, + * - RecordBuilder<_recordType>::methodStatic(..) + * with template parameter is only 'void', explicitly specified. +*/ template<> + struct Builder : protected detail::ReflectionBuilder { - /* @struct: Builder - * specialized specifically to register overloaded const-member-functions with no arguments. - * Objects of this class will be created & returned by function, - * - RecordBuilder<_recordType>::methodConst(..) - * with template parameters is only 'void' explicitly specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(const std::string_view pFunction, std::size_t pRecordId); - - template - const Function build(_returnType(_recordType::* pFunctor)() const) const; - }; - - - /* @struct: Builder - * specialized specifically to register overloaded const-member-functions with any arguments. - * Objects of this class will be created & returned by function, - * - RecordBuilder<_recordType>::methodConst<...>(..) - * with template parameters can be anything, explicitly specified. - */ template - struct Builder : protected detail::ReflectionBuilder - { - Builder(const std::string_view pFunction, std::size_t pRecordId); - - template - const Function build(_returnType(_recordType::* pFunctor)(_signature...) const) const; - }; - - - /* @struct: Builder - * specialized specifically to register non-overloaded const-member-functions with any arguments. - * Objects of this class will be created & returned by function, - * - RecordBuilder<_recordType>::methodConst() - * with no template parameters specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(const std::string_view pFunction, std::size_t pRecordId); - - template - const Function build(_returnType(_recordType::* pFunctor)(_signature...) const) const; - }; - } - - - namespace builder + Builder(std::size_t pRecordId, const std::string_view pFunction, + const std::string_view pNamespace); + + template + const Function build(_returnType(*pFunctor)()) const; + }; + + +/* @struct: Builder + * specialized specifically to register overloaded non-member & static member functions with any arguments. + * Objects of this class will be created & returned by the function, + * - RecordBuilder<_recordType>::methodStatic<...>(..) + * with template parameters can be anything, explicitly specified. +*/ template + struct Builder : protected detail::ReflectionBuilder + { + Builder(std::size_t pRecordId, const std::string_view pFunction, + const std::string_view pNamespace); + + template + const Function build(_returnType(*pFunctor)(_signature...)) const; + }; + + +/* @struct: Builder + * specialized specifically to register non-member functions with any signature and with no overloads. + * Objects of this class will be created & returned by the function, + * - RecordBuilder<_recordType>::methodStatic(..) + * with no template parameters specified. +*/ template<> + struct Builder : protected detail::ReflectionBuilder + { + Builder(std::size_t pRecordId, const std::string_view pFunction, + const std::string_view pNamespace); + + template + const Function build(_returnType(*pFunctor)(_signature...)) const; + }; +} + + +namespace rtl::builder +{ +/* @struct: Builder + * specialized specifically to register overloaded const-member-functions with no arguments. + * Objects of this class will be created & returned by function, + * - RecordBuilder<_recordType>::methodConst(..) + * with template parameters is only 'void' explicitly specified. +*/ template<> + struct Builder : protected detail::ReflectionBuilder { - /* @struct: Builder - * specialized specifically to register overloaded non-const-member-functions with no arguments. - * Objects of this class will be created & returned by function, - * - RecordBuilder<_recordType>::method(..) - * with template parameters is only 'void' explicitly specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(const std::string_view pFunction, std::size_t pRecordId); - - template - const Function build(_returnType(_recordType::* pFunctor)()) const; - }; - - - /* @struct: Builder - * specialized specifically to register overloaded non-const-member-functions with no arguments. - * Objects of this class will be created & returned by function, - * - RecordBuilder<_recordType>::method(..) - * with template parameters is only 'void' explicitly specified. - */ template - struct Builder : protected detail::ReflectionBuilder - { - Builder(const std::string_view pFunction, std::size_t pRecordId); - - template - const Function build(_returnType(_recordType::* pFunctor)(_signature...)) const; - }; - - - /* @struct: Builder - * specialized specifically to register non-overloaded non-const-member-functions and constructors with any arguments. - * Objects of this class will be created & returned by function, - * - RecordBuilder<_recordType>::method() - with no template parameters specified. - * - RecordBuilder<_recordType>::constructor<...>() - template parameters can be anything or none, explicitly specified. - */ template<> - struct Builder : protected detail::ReflectionBuilder - { - Builder(const std::string_view pFunction, std::size_t pRecordId); - - template - const Function build(_returnType(_recordType::* pFunctor)(_signature...)) const; - }; - } + Builder(const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build(_returnType(_recordType::* pFunctor)() const) const; + }; + + +/* @struct: Builder + * specialized specifically to register overloaded const-member-functions with any arguments. + * Objects of this class will be created & returned by function, + * - RecordBuilder<_recordType>::methodConst<...>(..) + * with template parameters can be anything, explicitly specified. +*/ template + struct Builder : protected detail::ReflectionBuilder + { + Builder(const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build(_returnType(_recordType::* pFunctor)(_signature...) const) const; + }; + + +/* @struct: Builder + * specialized specifically to register non-overloaded const-member-functions with any arguments. + * Objects of this class will be created & returned by function, + * - RecordBuilder<_recordType>::methodConst() + * with no template parameters specified. +*/ template<> + struct Builder : protected detail::ReflectionBuilder + { + Builder(const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build(_returnType(_recordType::* pFunctor)(_signature...) const) const; + }; +} + + +namespace rtl::builder +{ +/* @struct: Builder + * specialized specifically to register overloaded non-const-member-functions with no arguments. + * Objects of this class will be created & returned by function, + * - RecordBuilder<_recordType>::method(..) + * with template parameters is only 'void' explicitly specified. +*/ template<> + struct Builder : protected detail::ReflectionBuilder + { + Builder(const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build(_returnType(_recordType::* pFunctor)()) const; + }; + + +/* @struct: Builder + * specialized specifically to register overloaded non-const-member-functions with no arguments. + * Objects of this class will be created & returned by function, + * - RecordBuilder<_recordType>::method(..) + * with template parameters is only 'void' explicitly specified. +*/ template + struct Builder : protected detail::ReflectionBuilder + { + Builder(const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build(_returnType(_recordType::* pFunctor)(_signature...)) const; + }; + + +/* @struct: Builder + * specialized specifically to register non-overloaded non-const-member-functions and constructors with any arguments. + * Objects of this class will be created & returned by function, + * - RecordBuilder<_recordType>::method() - with no template parameters specified. + * - RecordBuilder<_recordType>::constructor<...>() - template parameters can be anything or none, explicitly specified. +*/ template<> + struct Builder : protected detail::ReflectionBuilder + { + Builder(const std::string_view pFunction, std::size_t pRecordId); + + template + const Function build(_returnType(_recordType::* pFunctor)(_signature...)) const; + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/Builder.hpp b/ReflectionTemplateLib/rtl/builder/Builder.hpp index 18f6c45b..2207079a 100644 --- a/ReflectionTemplateLib/rtl/builder/Builder.hpp +++ b/ReflectionTemplateLib/rtl/builder/Builder.hpp @@ -11,228 +11,278 @@ #pragma once -#include "rtl_typeid.h" #include "Builder.h" #include "ReflectionBuilder.hpp" -namespace rtl +namespace rtl::builder +{ + inline CtorBuilder::CtorBuilder(const std::string_view pNamespace, const std::string_view pRecord, + const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId, pNamespace, pRecord) { + } + +/* @method: build() + @param: none + @return: 'Function' object. + * accepts no arguments, builds copy constructor which takes const object source. + * called on object returned by 'RecordBuilder<_recordType>::constructor<...>()' + * template params <...>, explicitly specified. + * calling with zero template params will build the default constructor ie, 'RecordBuilder<_recordType>::constructor()' +*/ template + inline const Function CtorBuilder::build() const + { + return buildConstructor<_recordType, _signature...>(); + } +} + + +namespace rtl::builder +{ + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + : ReflectionBuilder(pFunction, pRecordId, pNamespace) { + } + +/* @method: build() + @param: _returnType(*)(_signature...) + @return: 'Function' object. + * accepts all non-member and static-member function pointer. + * called on the objects returned by 'type::function()' & 'RecordBuilder<_recordType>::methodStatic(..)'. + * template params are auto deduced from the function pointer passed. +*/ template + inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const + { + return buildFunctor(pFunctor, detail::member::None); + } +} + + +namespace rtl::builder +{ + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + : ReflectionBuilder(pFunction, pRecordId, pNamespace) + { } + +/* @method: build() + @param: _returnType(*)() + @return: 'Function' object. + * accepts a non-member or static-member function pointer with no arguments. + * called on objects returned by 'type::function(..)' & 'RecordBuilder<_recordType>::methodStatic(..)' + * template param 'void' is explicitly specified. +*/ template + inline const Function Builder::build(_returnType(*pFunctor)()) const + { + return buildFunctor(pFunctor, detail::member::None); + } +} + + +namespace rtl::builder { - namespace builder + template + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + : ReflectionBuilder(pFunction, pRecordId, pNamespace) + { } + + +/* @method: build() + @param: _returnType(*)(_signature...) + @return: 'Function' object. + * it accepts a non-member or static-member function pointer. + * called on objects returned by 'type::function<...>(..)' & 'RecordBuilder<_recordType>::methodStatic<...>(..)'. + * template params are explicitly specified. +*/ template + template + inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { - inline CtorBuilder::CtorBuilder(const std::string_view pNamespace, const std::string_view pRecord, - const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId, pNamespace, pRecord) { - } - - /* @method: build() - @param: none - @return: 'Function' object. - * accepts no arguments, builds copy constructor which takes const object source. - * called on object returned by 'RecordBuilder<_recordType>::constructor<...>()' - * template params <...>, explicitly specified. - * calling with zero template params will build the default constructor ie, 'RecordBuilder<_recordType>::constructor()' - */ template - inline const Function CtorBuilder::build() const - { - return buildConstructor<_recordType, _signature...>(); - } + return buildFunctor(pFunctor, detail::member::None); } } -namespace rtl +namespace rtl::builder { - namespace builder + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + : ReflectionBuilder(pFunction, pRecordId, pNamespace) { + } + +/* @method: build() + @param: _returnType(*)(_signature...) + @return: 'Function' object. + * accepts all non-member and static-member function pointer. + * called on the objects returned by 'type::function()' & 'RecordBuilder<_recordType>::methodStatic(..)'. + * template params are auto deduced from the function pointer passed. +*/ template + inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) - : ReflectionBuilder(pFunction, pRecordId, pNamespace) { - } - - /* @method: build() - @param: _returnType(*)(_signature...) - @return: 'Function' object. - * accepts all non-member and static-member function pointer. - * called on the objects returned by 'type::function()' & 'RecordBuilder<_recordType>::methodStatic(..)'. - * template params are auto deduced from the function pointer passed. - */ template - inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const - { - return buildFunctor(pFunctor); - } + return buildFunctor(pFunctor, detail::member::Static); } +} - namespace builder +namespace rtl::builder +{ + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + : ReflectionBuilder(pFunction, pRecordId, pNamespace) + { } + +/* @method: build() + @param: _returnType(*)() + @return: 'Function' object. + * accepts a non-member or static-member function pointer with no arguments. + * called on objects returned by 'type::function(..)' & 'RecordBuilder<_recordType>::methodStatic(..)' + * template param 'void' is explicitly specified. +*/ template + inline const Function Builder::build(_returnType(*pFunctor)()) const { - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) - : ReflectionBuilder(pFunction, pRecordId, pNamespace) - { } - - /* @method: build() - @param: _returnType(*)() - @return: 'Function' object. - * accepts a non-member or static-member function pointer with no arguments. - * called on objects returned by 'type::function(..)' & 'RecordBuilder<_recordType>::methodStatic(..)' - * template param 'void' is explicitly specified. - */ template - inline const Function Builder::build(_returnType(*pFunctor)()) const - { - return buildFunctor(pFunctor); - } + return buildFunctor(pFunctor, detail::member::Static); } +} - namespace builder +namespace rtl::builder +{ + template + inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + : ReflectionBuilder(pFunction, pRecordId, pNamespace) + { } + + +/* @method: build() + @param: _returnType(*)(_signature...) + @return: 'Function' object. + * it accepts a non-member or static-member function pointer. + * called on objects returned by 'type::function<...>(..)' & 'RecordBuilder<_recordType>::methodStatic<...>(..)'. + * template params are explicitly specified. +*/ template + template + inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { - template - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) - : ReflectionBuilder(pFunction, pRecordId, pNamespace) - { } - - - /* @method: build() - @param: _returnType(*)(_signature...) - @return: 'Function' object. - * it accepts a non-member or static-member function pointer. - * called on objects returned by 'type::function<...>(..)' & 'RecordBuilder<_recordType>::methodStatic<...>(..)'. - * template params are explicitly specified. - */ template - template - inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const - { - return buildFunctor(pFunctor); - } + return buildFunctor(pFunctor, detail::member::Static); } } -namespace rtl +namespace rtl::builder { - namespace builder + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId) + { } + +/* @method: build() + @param: _returnType(_recordType::*)(_signature...) const. + @return: 'Function' object. + * accepts function pointer of a const-member-function with any signature. + * called on object returned by 'RecordBuilder<_recordType>::methodConst()' + * template params will be auto deduced from the function pointer passed. +*/ template + inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...) const) const { - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId) - { } - - /* @method: build() - @param: _returnType(_recordType::*)(_signature...) const. - @return: 'Function' object. - * accepts function pointer of a const-member-function with any signature. - * called on object returned by 'RecordBuilder<_recordType>::methodConst()' - * template params will be auto deduced from the function pointer passed. - */ template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...) const) const - { - return buildMethodFunctor(pFunctor); - } + return buildMethodFunctor(pFunctor); } +} - namespace builder +namespace rtl::builder +{ + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId) + { } + +/* @method: build() + @param: _returnType(_recordType::*)() const. + @return: 'Function' object. + * accepts a const-member-function pointer with no arguments. + * called on object returned by 'RecordBuilder<_recordType>::methodConst()' + * template param 'void' is explicitly specified. +*/ template + inline const Function Builder::build(_returnType(_recordType::* pFunctor)() const) const { - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId) - { } - - /* @method: build() - @param: _returnType(_recordType::*)() const. - @return: 'Function' object. - * accepts a const-member-function pointer with no arguments. - * called on object returned by 'RecordBuilder<_recordType>::methodConst()' - * template param 'void' is explicitly specified. - */ template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)() const) const - { - return buildMethodFunctor(pFunctor); - } + return buildMethodFunctor(pFunctor); } - +} + - namespace builder +namespace rtl::builder +{ + template + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId) + { } + +/* @method: build() + @param: _returnType(_recordType::*)(_signature...) const. + @return: 'Function' object. + * accepts a const-member-function pointer with any arguments. + * called on object returned by 'RecordBuilder<_recordType>::methodConst<...>()' + * template param are explicitly specified. +*/ template + template + inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...) const) const { - template - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId) - { } - - /* @method: build() - @param: _returnType(_recordType::*)(_signature...) const. - @return: 'Function' object. - * accepts a const-member-function pointer with any arguments. - * called on object returned by 'RecordBuilder<_recordType>::methodConst<...>()' - * template param are explicitly specified. - */ template - template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...) const) const - { - return buildMethodFunctor(pFunctor); - } + return buildMethodFunctor(pFunctor); } } -namespace rtl +namespace rtl::builder { - namespace builder + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId) + { } + + +/* @method: build() + @param: _returnType(_recordType::*)(_signature...) + @return: 'Function' object. + * accepts a non-const-member-function pointer with any arguments. + * called on object returned by 'RecordBuilder<_recordType>::method()' + * template params are auto deduced from the pointer passed. +*/ template + inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...)) const { - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId) - { } - - - /* @method: build() - @param: _returnType(_recordType::*)(_signature...) - @return: 'Function' object. - * accepts a non-const-member-function pointer with any arguments. - * called on object returned by 'RecordBuilder<_recordType>::method()' - * template params are auto deduced from the pointer passed. - */ template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...)) const - { - return buildMethodFunctor(pFunctor); - } + return buildMethodFunctor(pFunctor); } +} - - namespace builder + +namespace rtl::builder +{ + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId) + { } + + +/* @method: build() + @param: _returnType(_recordType::*)() + @return: 'Function' object. + * accepts a non-const-member-function pointer with no arguments. + * called on object returned by 'RecordBuilder<_recordType>::method()' + * template param 'void' is explicitly specified. +*/ template + inline const Function Builder::build(_returnType(_recordType::* pFunctor)()) const { - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId) - { } - - - /* @method: build() - @param: _returnType(_recordType::*)() - @return: 'Function' object. - * accepts a non-const-member-function pointer with no arguments. - * called on object returned by 'RecordBuilder<_recordType>::method()' - * template param 'void' is explicitly specified. - */ template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)()) const - { - return buildMethodFunctor(pFunctor); - } + return buildMethodFunctor(pFunctor); } +} - namespace builder +namespace rtl::builder +{ + template + inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) + : ReflectionBuilder(pFunction, pRecordId) + { } + +/* @method: build() + @param: _returnType(_recordType::*)(_signature...) + @return: 'Function' object. + * accepts a non-const-member-function pointer with any arguments. + * called on object returned by 'RecordBuilder<_recordType>::method<...>()' + * template params are explicitly specified. +*/ template + template + inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...)) const { - template - inline Builder::Builder(const std::string_view pFunction, std::size_t pRecordId) - : ReflectionBuilder(pFunction, pRecordId) - { } - - /* @method: build() - @param: _returnType(_recordType::*)(_signature...) - @return: 'Function' object. - * accepts a non-const-member-function pointer with any arguments. - * called on object returned by 'RecordBuilder<_recordType>::method<...>()' - * template params are explicitly specified. - */ template - template - inline const Function Builder::build(_returnType(_recordType::* pFunctor)(_signature...)) const - { - return buildMethodFunctor(pFunctor); - } + return buildMethodFunctor(pFunctor); } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/RecordBuilder.h b/ReflectionTemplateLib/rtl/builder/RecordBuilder.h index b3db5344..f317ce8e 100644 --- a/ReflectionTemplateLib/rtl/builder/RecordBuilder.h +++ b/ReflectionTemplateLib/rtl/builder/RecordBuilder.h @@ -50,7 +50,7 @@ namespace rtl { const Builder methodConst(const std::string_view pFunction) const; - const Builder methodStatic(const std::string_view pFunction) const; + const Builder methodStatic(const std::string_view pFunction) const; template const Builder method(const std::string_view pFunction) const; @@ -59,7 +59,7 @@ namespace rtl { const Builder methodConst(const std::string_view pFunction) const; template - const Builder methodStatic(const std::string_view pFunction) const; + const Builder methodStatic(const std::string_view pFunction) const; template constexpr const ConstructorBuilder<_recordType, traits::remove_cref_t<_signature>...> constructor() const; diff --git a/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp index d4b13185..292b2ccf 100644 --- a/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp @@ -57,21 +57,21 @@ namespace rtl::builder /* @method: methodStatic() @param: std::string, name of function as string. - @return: Builder + @return: Builder * registers only static member functions. * used for registering unique static member function, if overload exists, use templated version 'methodStatic<...>()'. * the 'build(..)' called on return object will accepts static member function pointer only. * compiler error on 'build(..)' if non-static member or non-member function pointer is passed. */ template - inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const + inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const { - return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); + return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); } /* @method: methodStatic<...>() @param: std::string, name of function as string. - @return: Builder + @return: Builder * registers only static member functions. * used for registering overloads, if unique member function, use non-templated version 'methodStatic()'. * template parameters must be explicitly specified, should be exactly same as the member-function being registered. @@ -79,9 +79,9 @@ namespace rtl::builder * compiler error on 'build(..)' if const member or non-member function pointer is passed. */ template template - inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const + inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const { - return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); + return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); } diff --git a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h index abc75d98..b9c925b3 100644 --- a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h +++ b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h @@ -12,6 +12,7 @@ #pragma once #include "Function.h" +#include "rtl_constants.h" namespace rtl { @@ -40,7 +41,7 @@ namespace rtl { //adds 'pFunctor' to the 'FunctorContainer'. template - const Function buildFunctor(_returnType(*pFunctor)(_signature...)) const; + const Function buildFunctor(_returnType(*pFunctor)(_signature...), member pMemberType) const; //adds 'pFunctor' to the 'MethodContainer'. template diff --git a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp index 980f88c8..5bb709c8 100644 --- a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp @@ -39,11 +39,11 @@ namespace rtl::detail * accepts only a non-member or static-member function pointer. * builds the 'Function' object containing hash-key & meta-data for the given functor. */ template - inline const Function ReflectionBuilder::buildFunctor(_returnType(*pFunctor)(_signature...)) const + inline const Function ReflectionBuilder::buildFunctor(_returnType(*pFunctor)(_signature...), member pMemberType) const { using Container = FunctorContainer< traits::remove_const_if_not_reference<_signature>...>; auto [typeMeta, functorId] = Container::template addFunctor<_returnType, _signature...>(pFunctor, m_recordId); - return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, member::None); + return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, pMemberType); } From c645923b001acbb8faa1ba58e2dcb8be53c8b606 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 29 Oct 2025 23:14:02 +0530 Subject: [PATCH 111/148] static-method calls, wip. --- ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp | 2 +- ReflectionTemplateLib/rtl/builder/SetupFunction.h | 2 +- ReflectionTemplateLib/rtl/builder/SetupFunction.hpp | 8 ++++---- ReflectionTemplateLib/rtl/builder/SetupMethod.hpp | 6 ++---- ReflectionTemplateLib/rtl/cache/cache_function_ptr.h | 4 ++-- ReflectionTemplateLib/rtl/dispatch/function_ptr.h | 3 ++- ReflectionTemplateLib/rtl/dispatch/functor.h | 2 +- ReflectionTemplateLib/rtl/dispatch/method_ptr.h | 2 +- ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.h | 4 ++-- ReflectionTemplateLib/rtl/inc/type_meta.h | 4 ++-- ReflectionTemplateLib/rtl/inc/type_meta.hpp | 4 ++-- ReflectionTemplateLib/rtl/rtl_errors.h | 2 +- ReflectionTemplateLib/rtl/src/Function.cpp | 4 ++-- 14 files changed, 24 insertions(+), 25 deletions(-) diff --git a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp index 5bb709c8..5e127ad4 100644 --- a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp @@ -42,7 +42,7 @@ namespace rtl::detail inline const Function ReflectionBuilder::buildFunctor(_returnType(*pFunctor)(_signature...), member pMemberType) const { using Container = FunctorContainer< traits::remove_const_if_not_reference<_signature>...>; - auto [typeMeta, functorId] = Container::template addFunctor<_returnType, _signature...>(pFunctor, m_recordId); + auto [typeMeta, functorId] = Container::template addFunctor<_returnType, _signature...>(pFunctor, m_recordId, pMemberType); return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, pMemberType); } diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.h b/ReflectionTemplateLib/rtl/builder/SetupFunction.h index c29d99fc..ec51e321 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.h +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.h @@ -42,6 +42,6 @@ namespace rtl::detail protected: template - static std::pair addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId); + static std::pair addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId, member pMemberType); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index e5288f1a..d167f62b 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -90,11 +90,12 @@ namespace rtl * thread safe, multiple functors can be registered simultaneously. */ template template - inline std::pair SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId) + inline std::pair + SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId, member pMemberType) { rtl::type_meta typeMeta; const auto& updateIndex = [&](std::size_t pIndex)-> void { - typeMeta = rtl::type_meta::add_function(pFunctor, pIndex); + typeMeta = rtl::type_meta::add_function(pFunctor, pMemberType, pIndex); }; const auto& getIndex = [&]()-> std::size_t @@ -115,8 +116,7 @@ namespace rtl //construct the hash-key 'FunctorId' and return. return { typeMeta, - FunctorId - { + FunctorId { lambdaIndex, returnId, pRecordId, diff --git a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp index 27f732e4..58638616 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupMethod.hpp @@ -191,8 +191,7 @@ namespace rtl::detail //construct the hash-key 'FunctorId' and return. return { typeMeta, - FunctorId - { + FunctorId { lambdaIndex, retTypeId, TypeId<_recordType>::get(), @@ -242,8 +241,7 @@ namespace rtl::detail //construct the hash-key 'FunctorId' and return. return { typeMeta, - FunctorId - { + FunctorId { lambdaIndex, retTypeId, TypeId<_recordType>::get(), diff --git a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index 2d827eed..b181073b 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -28,9 +28,9 @@ namespace rtl::cache return instance_; } - const dispatch::functor& push(return_t(*fptr)(signature_t...), std::size_t lambda_index) const + const dispatch::functor& push(return_t(*fptr)(signature_t...), detail::member member_kind, std::size_t lambda_index) const { - m_cache.emplace_back(std::make_pair(fptr, lambda_index)); + m_cache.emplace_back(std::make_pair(function_t(fptr, member_kind), lambda_index)); return m_cache.back().first; } diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index ea3acaf8..1bf19fcf 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -28,11 +28,12 @@ namespace rtl::dispatch return (fptr == m_functor); } - function_ptr(functor_t fptr) :m_functor(fptr) + function_ptr(functor_t fptr, detail::member member_kind) :m_functor(fptr) { m_returnId = traits::uid::value; m_is_void = (m_returnId == traits::uid::value); + m_member_kind = member_kind; m_is_any_arg_ncref = (traits::is_nonconst_ref_v || ...); m_normal_signId = traits::uid>::value; m_strict_signId = traits::uid>::value; diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index 439613f7..d921f188 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -39,7 +39,7 @@ namespace rtl::dispatch bool m_is_any_arg_ncref = false; std::vector m_argumentsId = {}; - detail::member m_qualifier = detail::member::None; + detail::member m_member_kind = detail::member::None; private: diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 20a49d40..97683d3f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -32,7 +32,7 @@ namespace rtl::dispatch method_ptr(functor_t fptr) :m_functor(fptr) { - m_qualifier = detail::member::NonConst; + m_member_kind = detail::member::NonConst; m_returnId = traits::uid::value; m_is_void = (m_returnId == traits::uid::value); diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h index 8790b9e8..2fa260b4 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h @@ -32,7 +32,7 @@ namespace rtl::dispatch method_ptr(functor_t fptr) :m_functor(fptr) { - m_qualifier = detail::member::Const; + m_member_kind = detail::member::Const; m_returnId = traits::uid::value; m_is_void = (m_returnId == traits::uid::value); diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index e40c46d4..de95ee26 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -35,7 +35,7 @@ namespace rtl { */ class Function { //member::Const/Mute represents the const/non-const member-function, Type::None for non-member & static-member functions. - detail::member m_qualifier; + detail::member m_member_kind; //type id of class/struct (if it represents a member-function, else always '0') std::size_t m_recordTypeId; @@ -75,7 +75,7 @@ namespace rtl { constexpr std::optional getLambdaByStrictId(const std::size_t pSignatureId) const; - GETTER(detail::member, Qualifier, m_qualifier); + GETTER(detail::member, Qualifier, m_member_kind); GETTER_REF_C(std::vector, FunctorIds, m_functorIds) diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h index d9dfcde4..3db4f387 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.h +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -43,13 +43,13 @@ namespace rtl GETTER(traits::uid_t, _normal_args_id, m_functor->get().m_normal_signId) GETTER(traits::uid_t, _strict_args_id, m_functor->get().m_strict_signId) - GETTER(detail::member, _method_qual, m_functor->get().m_qualifier) + GETTER(detail::member, _method_qual, m_functor->get().m_member_kind) GETTER_CREF(dispatch::lambda_base, _lambda, *(m_functor->get().m_lambda)) GETTER_CREF(dispatch::erasure_base, _erasure_base, *(m_functor->get().m_erasure)) template - static type_meta add_function(return_t(*pFunctor)(signature_t...), std::size_t p_index); + static type_meta add_function(return_t(*pFunctor)(signature_t...), detail::member pMemberType, std::size_t p_index); template static type_meta add_method(return_t(record_t::* pFunctor)(signature_t...), std::size_t p_index); diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.hpp b/ReflectionTemplateLib/rtl/inc/type_meta.hpp index d4aa0518..75e9a5a6 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.hpp +++ b/ReflectionTemplateLib/rtl/inc/type_meta.hpp @@ -38,12 +38,12 @@ namespace rtl } template - inline type_meta type_meta::add_function(return_t(*pFunctor)(signature_t...), std::size_t p_index) + inline type_meta type_meta::add_function(return_t(*pFunctor)(signature_t...), detail::member pMemberKind, std::size_t p_index) { auto& fc = cache::function_ptr::instance(); auto& lc = cache::lambda_function::instance(); - auto& functor = fc.push(pFunctor, p_index); + auto& functor = fc.push(pFunctor, pMemberKind, p_index); auto [lambda, elambda] = lc.push(functor); functor.set_lambda(lambda); diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index 0b338525..4451d86d 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -26,7 +26,7 @@ namespace rtl SignatureMismatch, RefBindingMismatch, ExplicitRefBindingRequired, - NonStaticMethodRequiresTarget, + InvalidStaticMethodCaller, CloningDisabled, //Used only in case of cloning is disabled e.g, unregistered type returnd from a function. FunctionNotRegistered, //Not used by RTL at all, for external purpose only. diff --git a/ReflectionTemplateLib/rtl/src/Function.cpp b/ReflectionTemplateLib/rtl/src/Function.cpp index 829f1e1a..6de57f2a 100644 --- a/ReflectionTemplateLib/rtl/src/Function.cpp +++ b/ReflectionTemplateLib/rtl/src/Function.cpp @@ -28,7 +28,7 @@ namespace rtl */ Function::Function(const std::string_view pNamespace, const std::string_view pRecord, const std::string_view pFunction, const type_meta& pFunctorsMeta, const detail::FunctorId& pFunctorId, const std::size_t pRecordTypeId, const detail::member pQualifier) - : m_qualifier(pQualifier) + : m_member_kind(pQualifier) , m_recordTypeId(pRecordTypeId) , m_record(pRecord) , m_function(pFunction) @@ -48,7 +48,7 @@ namespace rtl 'FunctorId' with the 'Function' object associated with a constructor. */ Function::Function(const Function& pOther, const type_meta& pFunctorsMeta, const detail::FunctorId& pFunctorId, const std::string_view pFunctorName) - : m_qualifier(pOther.m_qualifier) + : m_member_kind(pOther.m_member_kind) , m_recordTypeId(pOther.m_recordTypeId) , m_record(pOther.m_record) , m_function(pFunctorName) From 9b94e141f729b9884be17e0d7e913fd911a71490 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 30 Oct 2025 08:48:59 +0530 Subject: [PATCH 112/148] static-method call tests, wip. --- CxxTestProps/inc/StringOps.h | 41 ++++++ CxxTestProps/src/StringOps.cpp | 137 ++++++++++++++++++ CxxTestRegistration/inc/TestMirrorProvider.h | 1 + .../src/TestMirrorProvider.cpp | 54 ++++++- .../StrictStaticTypeDispatch_ConstMethod.cpp | 1 - .../StrictStaticTypeDispatch_StaticMethod.cpp | 69 +++++++++ .../rtl/detail/inc/MethodInvoker.hpp | 2 +- .../rtl/dispatch/rtl_method_erased_target.h | 10 -- ReflectionTemplateLib/rtl/inc/type_meta.h | 12 +- ReflectionTemplateLib/rtl/inc/type_meta.hpp | 12 +- 10 files changed, 314 insertions(+), 25 deletions(-) diff --git a/CxxTestProps/inc/StringOps.h b/CxxTestProps/inc/StringOps.h index 95600a25..b59aa993 100644 --- a/CxxTestProps/inc/StringOps.h +++ b/CxxTestProps/inc/StringOps.h @@ -119,4 +119,45 @@ struct StringC std::string revStrOverloadRefAndCRef(std::string_view& pStr) const; std::string revStrOverloadRefAndCRef(const std::string_view& pStr) const; +}; + + +// 'StringS' - String-Static, all methods are static. +struct StringS +{ + constexpr static const char* struct_ = "StringS"; + + static std::string reverseString(); + + static std::string reverseString(const char* pStr); + + static std::string reverseString(std::string pStr); // (1) by value + + static std::string reverseString(std::string& pStr); // (2) lvalue ref + + static std::string reverseString(const std::string& pStr); // (3) const lvalue ref + + static std::string reverseString(std::string&& pStr); // (4) rvalue ref + + static std::string reverseString(std::string* pStr); // (5) pointer + + static std::string reverseString(const std::string* pStr); // (6) pointer to const + + static std::string revStrConstRefArg(const std::string_view& pStr); + + static std::string revStrNonConstRefArg(std::string_view& pStr); + + static std::string revStrRValueRefArg(std::string_view&& pStr); + + static std::string revStrOverloadValRef(std::string_view pStr); + + static std::string revStrOverloadValRef(std::string_view& pStr); + + static std::string revStrOverloadValCRef(std::string_view pStr); + + static std::string revStrOverloadValCRef(const std::string_view& pStr); + + static std::string revStrOverloadRefAndCRef(std::string_view& pStr); + + static std::string revStrOverloadRefAndCRef(const std::string_view& pStr); }; \ No newline at end of file diff --git a/CxxTestProps/src/StringOps.cpp b/CxxTestProps/src/StringOps.cpp index 67dc0bd7..6ff4a802 100644 --- a/CxxTestProps/src/StringOps.cpp +++ b/CxxTestProps/src/StringOps.cpp @@ -7,6 +7,7 @@ namespace test_utils { const char* SUFFIX_void = "_void"; const char* SUFFIX_const = "_const"; + const char* SUFFIX_static = "_static"; const char* SUFFIX_const_char_ptr = "_const_char_*"; const char* SUFFIX_std_string = "_std::string"; @@ -431,4 +432,140 @@ std::string StringC::revStrOverloadRefAndCRef(const std::string_view& pStr) cons std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); return retStr + SUFFIX_std_string_view_clvref + SUFFIX_const; +} + + +//---------------------------StringS-------------------------------- + +std::string StringS::reverseString() +{ + return std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_static; +} + + +std::string StringS::reverseString(const char* pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_const_char_ptr + SUFFIX_static; +} + + +std::string StringS::reverseString(std::string pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string + SUFFIX_static; +} + + +std::string StringS::reverseString(std::string& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_lvref + SUFFIX_static; +} + + +std::string StringS::reverseString(std::string&& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_rvref + SUFFIX_static; +} + + +std::string StringS::reverseString(const std::string& pStr) +{ + std::string retStr = pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_clvref + SUFFIX_static; +} + + +std::string StringS::reverseString(std::string* pStr) +{ + std::string retStr = *pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_ptr + SUFFIX_static; +} + + +std::string StringS::reverseString(const std::string* pStr) +{ + std::string retStr = *pStr; + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_cptr + SUFFIX_static; +} + + +std::string StringS::revStrConstRefArg(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view_clvref + SUFFIX_static; +} + + +std::string StringS::revStrRValueRefArg(std::string_view&& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view_rvref + SUFFIX_static; +} + + +std::string StringS::revStrNonConstRefArg(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view_lvref + SUFFIX_static; +} + + +std::string StringS::revStrOverloadValCRef(std::string_view pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view + SUFFIX_static; +} + + +std::string StringS::revStrOverloadValCRef(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view_clvref + SUFFIX_static; +} + + +std::string StringS::revStrOverloadValRef(std::string_view pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view + SUFFIX_static; +} + + +std::string StringS::revStrOverloadValRef(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view_lvref + SUFFIX_static; +} + + +std::string StringS::revStrOverloadRefAndCRef(std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view_lvref + SUFFIX_static; +} + + +std::string StringS::revStrOverloadRefAndCRef(const std::string_view& pStr) +{ + std::string retStr(pStr); + std::reverse(retStr.begin(), retStr.end()); + return retStr + SUFFIX_std_string_view_clvref + SUFFIX_static; } \ No newline at end of file diff --git a/CxxTestRegistration/inc/TestMirrorProvider.h b/CxxTestRegistration/inc/TestMirrorProvider.h index eb839e53..1bb72c4d 100644 --- a/CxxTestRegistration/inc/TestMirrorProvider.h +++ b/CxxTestRegistration/inc/TestMirrorProvider.h @@ -22,6 +22,7 @@ namespace test_mirror static std::size_t calender; static std::size_t string_m; static std::size_t string_c; + static std::size_t string_s; static std::size_t char_t; static std::size_t int_t; diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 7a15904b..d052c7a8 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -126,6 +126,7 @@ namespace test_mirror rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), +//--------------------------------------------------------------------------------------------------------------------------------------------------- rtl::type().record(StringM::struct_).build(), // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. @@ -173,6 +174,7 @@ namespace test_mirror rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringM::revStrOverloadRefAndCRef), rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringM::revStrOverloadRefAndCRef), +//--------------------------------------------------------------------------------------------------------------------------------------------------- rtl::type().record(StringC::struct_).build(), // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. @@ -220,6 +222,54 @@ namespace test_mirror rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StringC::revStrOverloadRefAndCRef), rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StringC::revStrOverloadRefAndCRef), +//-------------------------------------------------------------------------------------------------------------------------------------------------------- + rtl::type().record(StringS::struct_).build(), + + // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. + rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + + // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. + rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + + // Overloaded function, takes 'const char*' arguments. + rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + + // numereous other overloads. + #if defined(__GNUC__) && !defined(__clang__) + /* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: + + static_cast(reverseString) + */ + rtl::type().member().methodStatic(str_reverseString) + .build(static_cast(&StringS::reverseString)), + rtl::type().member().methodStatic(str_reverseString) + .build(static_cast(&StringS::reverseString)), + rtl::type().member().methodStatic(str_reverseString) + .build(static_cast(&StringS::reverseString)), + #else + rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + #endif + rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + + rtl::type().member().methodStatic(str_revStrNonConstRefArg).build(&StringS::revStrNonConstRefArg), + rtl::type().member().methodStatic(str_revStrRValueRefArg).build(&StringS::revStrRValueRefArg), + rtl::type().member().methodStatic(str_revStrConstRefArg).build(&StringS::revStrConstRefArg), + + rtl::type().member().methodStatic(str_revStrOverloadValRef).build(&StringS::revStrOverloadValRef), + rtl::type().member().methodStatic(str_revStrOverloadValRef).build(&StringS::revStrOverloadValRef), + + rtl::type().member().methodStatic(str_revStrOverloadValCRef).build(&StringS::revStrOverloadValCRef), + rtl::type().member().methodStatic(str_revStrOverloadValCRef).build(&StringS::revStrOverloadValCRef), + + rtl::type().member().methodStatic(str_revStrOverloadValRefAndCRef).build(&StringS::revStrOverloadRefAndCRef), + rtl::type().member().methodStatic(str_revStrOverloadValRefAndCRef).build(&StringS::revStrOverloadRefAndCRef), +//--------------------------------------------------------------------------------------------------------------------------------------------------------- // Unique function, no overloads, no need to specify signature as template parameters. rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), @@ -405,6 +455,7 @@ namespace test_mirror std::size_t reflected_id::calender = rtl::detail::TypeId::get(); std::size_t reflected_id::string_m = rtl::detail::TypeId::get(); std::size_t reflected_id::string_c = rtl::detail::TypeId::get(); + std::size_t reflected_id::string_s = rtl::detail::TypeId::get(); std::size_t reflected_id::int_t = rtl::detail::TypeId::get(); std::size_t reflected_id::char_t = rtl::detail::TypeId::get(); @@ -429,7 +480,8 @@ namespace test_mirror { library::class_, library }, { calender::struct_, calender }, { StringM::struct_, string_m }, - { StringC::struct_, string_c } + { StringC::struct_, string_c }, + { StringS::struct_, string_s } }); const auto& itr = nameIdMap.find(pRecordName); diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp index d0268263..8f3711f9 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp @@ -1,5 +1,4 @@ -#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index e69de29b..9f172ffe 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -0,0 +1,69 @@ + +#include + +#include "TestMirrorProvider.h" +#include "GlobalTestUtils.h" +#include "../CxxTestProps/inc/StringOps.h" + +using namespace test_utils; +using namespace test_mirror; + +namespace rtl_tests +{ + TEST(StrictStaticTypeRtl_static_method, overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + } { + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringS())(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringS())(STRB); + auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::method reverse_string = reverseString->targetT() + .argsT<>() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(StringS())(); + auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_const; + EXPECT_EQ(ret_str, exp_str); + } + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 4274e362..aab2569d 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -163,7 +163,7 @@ namespace rtl::detail inline constexpr const method HopMethod::returnT() const { - if (!m_argsTfnMeta.is_empty()) + if (!m_argsTfnMeta.is_empty() && m_argsTfnMeta.get_member_kind() != member::Static) { const auto retId = traits::uid::value; return m_argsTfnMeta.get_lambda() diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h index c18c0f80..7c858708 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h @@ -89,20 +89,10 @@ namespace rtl } }; - constexpr invoker operator()() const noexcept { - return invoker{ RObject{}, *this }; - } - constexpr invoker operator()(const RObject& p_target) const noexcept { return invoker{ p_target, *this }; } - template - requires (std::is_same_v, std::tuple>) - constexpr const perfect_fwd bind() const noexcept { - return perfect_fwd{ RObject{}, *this }; - } - template requires (std::is_same_v, std::tuple>) constexpr const perfect_fwd bind(const RObject& p_target) const noexcept { diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h index 3db4f387..c4827feb 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.h +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -43,19 +43,19 @@ namespace rtl GETTER(traits::uid_t, _normal_args_id, m_functor->get().m_normal_signId) GETTER(traits::uid_t, _strict_args_id, m_functor->get().m_strict_signId) - GETTER(detail::member, _method_qual, m_functor->get().m_member_kind) + GETTER(detail::member, _member_kind, m_functor->get().m_member_kind) GETTER_CREF(dispatch::lambda_base, _lambda, *(m_functor->get().m_lambda)) GETTER_CREF(dispatch::erasure_base, _erasure_base, *(m_functor->get().m_erasure)) template - static type_meta add_function(return_t(*pFunctor)(signature_t...), detail::member pMemberType, std::size_t p_index); + static type_meta add_function(return_t(*p_fptr)(signature_t...), detail::member p_member_kind, std::size_t p_index); template - static type_meta add_method(return_t(record_t::* pFunctor)(signature_t...), std::size_t p_index); + static type_meta add_method(return_t(record_t::* p_fptr)(signature_t...), std::size_t p_index); template - static type_meta add_method(return_t(record_t::* pFunctor)(signature_t...) const, std::size_t p_index); + static type_meta add_method(return_t(record_t::* p_fptr)(signature_t...) const, std::size_t p_index); template using lambda_fn_t = dispatch::lambda_function<_signature...>; @@ -64,10 +64,10 @@ namespace rtl using lambda_mth_t = dispatch::lambda_method; template - constexpr const lambda_fn_t* get_lambda_function(std::size_t p_argsId = 0) const; + constexpr const lambda_fn_t* get_lambda_function(std::size_t p_args_id = 0) const; template - constexpr const lambda_mth_t* get_lambda_method(std::size_t p_recordId = 0, std::size_t p_argsId = 0) const; + constexpr const lambda_mth_t* get_lambda_method(std::size_t p_recordId = 0, std::size_t p_args_id = 0) const; private: diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.hpp b/ReflectionTemplateLib/rtl/inc/type_meta.hpp index 75e9a5a6..f258166e 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.hpp +++ b/ReflectionTemplateLib/rtl/inc/type_meta.hpp @@ -38,12 +38,12 @@ namespace rtl } template - inline type_meta type_meta::add_function(return_t(*pFunctor)(signature_t...), detail::member pMemberKind, std::size_t p_index) + inline type_meta type_meta::add_function(return_t(*p_fptr)(signature_t...), detail::member p_member_kind, std::size_t p_index) { auto& fc = cache::function_ptr::instance(); auto& lc = cache::lambda_function::instance(); - auto& functor = fc.push(pFunctor, pMemberKind, p_index); + auto& functor = fc.push(p_fptr, p_member_kind, p_index); auto [lambda, elambda] = lc.push(functor); functor.set_lambda(lambda); @@ -53,12 +53,12 @@ namespace rtl } template - inline type_meta type_meta::add_method(return_t(record_t::* pFunctor)(signature_t...), std::size_t p_index) + inline type_meta type_meta::add_method(return_t(record_t::* p_fptr)(signature_t...), std::size_t p_index) { auto& fc = cache::method_ptr::instance(); auto& lc = cache::lambda_method::instance(); - auto& functor = fc.push(pFunctor, p_index); + auto& functor = fc.push(p_fptr, p_index); auto [lambda, elambda] = lc.push(functor); functor.set_lambda(lambda); @@ -68,12 +68,12 @@ namespace rtl } template - inline type_meta type_meta::add_method(return_t(record_t::* pFunctor)(signature_t...) const, std::size_t p_index) + inline type_meta type_meta::add_method(return_t(record_t::* p_fptr)(signature_t...) const, std::size_t p_index) { auto& fc = cache::method_ptr::instance(); auto& lc = cache::lambda_method::instance(); - auto& functor = fc.push(pFunctor, p_index); + auto& functor = fc.push(p_fptr, p_index); auto [lambda, elambda] = lc.push(functor); functor.set_lambda(lambda); From ea32ea4f6f49fc7bca080d7df788b5b7a3c36742 Mon Sep 17 00:00:00 2001 From: neeraj Date: Thu, 30 Oct 2025 10:06:57 +0530 Subject: [PATCH 113/148] fix- gcc compile err i.e, expicit ref-overload resolution --- CxxTestRegistration/src/TestMirrorProvider.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index d052c7a8..72af7793 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -244,11 +244,11 @@ namespace test_mirror static_cast(reverseString) */ rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StringS::reverseString)), + .build(static_cast(&StringS::reverseString)), rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StringS::reverseString)), + .build(static_cast(&StringS::reverseString)), rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StringS::reverseString)), + .build(static_cast(&StringS::reverseString)), #else rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), From dba32217196980da225965fb1835d33168f6e969 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 30 Oct 2025 13:39:17 +0530 Subject: [PATCH 114/148] static-method call tests, wip. --- CxxTestUtils/inc/GlobalTestUtils.h | 3 +- .../StrictStaticTypeDispatch_StaticMethod.cpp | 51 +++++++++---------- ReflectionTemplateLib/rtl/builder/Builder.h | 18 ++++--- ReflectionTemplateLib/rtl/builder/Builder.hpp | 28 ++++++---- .../rtl/builder/RecordBuilder.hpp | 4 +- .../rtl/builder/ReflectionBuilder.h | 2 +- .../rtl/builder/ReflectionBuilder.hpp | 4 +- .../rtl/builder/SetupFunction.h | 2 +- .../rtl/builder/SetupFunction.hpp | 4 +- .../rtl/cache/cache_function_ptr.h | 4 +- .../rtl/dispatch/function_ptr.h | 17 ++++--- ReflectionTemplateLib/rtl/dispatch/functor.h | 16 +++--- .../rtl/dispatch/lambda_base.h | 8 +-- .../rtl/dispatch/lambda_function.h | 2 +- .../rtl/dispatch/lambda_method.h | 4 +- .../rtl/dispatch/method_ptr.h | 16 +++--- .../rtl/dispatch/method_ptr_const.h | 16 +++--- ReflectionTemplateLib/rtl/inc/Method.h | 4 +- ReflectionTemplateLib/rtl/inc/type_meta.h | 14 ++--- ReflectionTemplateLib/rtl/inc/type_meta.hpp | 4 +- 20 files changed, 116 insertions(+), 105 deletions(-) diff --git a/CxxTestUtils/inc/GlobalTestUtils.h b/CxxTestUtils/inc/GlobalTestUtils.h index b1bf09b0..9e4c43ad 100644 --- a/CxxTestUtils/inc/GlobalTestUtils.h +++ b/CxxTestUtils/inc/GlobalTestUtils.h @@ -10,8 +10,9 @@ Provides interface for Testing/Comparing the global functions & types (may or no */ namespace test_utils { - extern const char* SUFFIX_const; extern const char* SUFFIX_void; + extern const char* SUFFIX_const; + extern const char* SUFFIX_static; extern const char* SUFFIX_const_char_ptr; extern const char* SUFFIX_std_string; diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index 9f172ffe..af905eeb 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -18,51 +18,48 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString->targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::function reverse_string = reverseString->argsT() + .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringS())(STRA); - auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr + SUFFIX_const; + std::string ret_str = reverse_string(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr + SUFFIX_static; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::function reverse_string = reverseString->argsT() + .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringS())(STRB); - auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string + SUFFIX_const; + std::string ret_str = reverse_string(STRB); + auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string + SUFFIX_static; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() - .argsT<>() - .returnT(); + rtl::function reverse_string = reverseString->argsT<>() + .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringS())(); - auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_const; + std::string ret_str = reverse_string(); + auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_static; EXPECT_EQ(ret_str, exp_str); } } diff --git a/ReflectionTemplateLib/rtl/builder/Builder.h b/ReflectionTemplateLib/rtl/builder/Builder.h index fdadbcde..3b2880f1 100644 --- a/ReflectionTemplateLib/rtl/builder/Builder.h +++ b/ReflectionTemplateLib/rtl/builder/Builder.h @@ -103,8 +103,10 @@ namespace rtl::builder */ template<> struct Builder : protected detail::ReflectionBuilder { - Builder(std::size_t pRecordId, const std::string_view pFunction, - const std::string_view pNamespace); + traits::uid_t m_recordUid; + + Builder(traits::uid_t pRecordUid, const std::string_view pFunction, + std::size_t pRecordId, const std::string_view pNamespace); template const Function build(_returnType(*pFunctor)()) const; @@ -119,8 +121,10 @@ namespace rtl::builder */ template struct Builder : protected detail::ReflectionBuilder { - Builder(std::size_t pRecordId, const std::string_view pFunction, - const std::string_view pNamespace); + traits::uid_t m_recordUid; + + Builder(traits::uid_t pRecordUid, const std::string_view pFunction, + std::size_t pRecordId, const std::string_view pNamespace); template const Function build(_returnType(*pFunctor)(_signature...)) const; @@ -135,8 +139,10 @@ namespace rtl::builder */ template<> struct Builder : protected detail::ReflectionBuilder { - Builder(std::size_t pRecordId, const std::string_view pFunction, - const std::string_view pNamespace); + traits::uid_t m_recordUid; + + Builder(traits::uid_t pRecordUid, const std::string_view pFunction, + std::size_t pRecordId, const std::string_view pNamespace); template const Function build(_returnType(*pFunctor)(_signature...)) const; diff --git a/ReflectionTemplateLib/rtl/builder/Builder.hpp b/ReflectionTemplateLib/rtl/builder/Builder.hpp index 2207079a..1b32da25 100644 --- a/ReflectionTemplateLib/rtl/builder/Builder.hpp +++ b/ReflectionTemplateLib/rtl/builder/Builder.hpp @@ -51,7 +51,7 @@ namespace rtl::builder */ template inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { - return buildFunctor(pFunctor, detail::member::None); + return buildFunctor(pFunctor, detail::member::None, traits::uid<>::none); } } @@ -71,7 +71,7 @@ namespace rtl::builder */ template inline const Function Builder::build(_returnType(*pFunctor)()) const { - return buildFunctor(pFunctor, detail::member::None); + return buildFunctor(pFunctor, detail::member::None, traits::uid<>::none); } } @@ -94,16 +94,18 @@ namespace rtl::builder template inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { - return buildFunctor(pFunctor, detail::member::None); + return buildFunctor(pFunctor, detail::member::None, traits::uid<>::none); } } namespace rtl::builder { - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) - : ReflectionBuilder(pFunction, pRecordId, pNamespace) { - } + inline Builder::Builder(traits::uid_t pRecordUid, const std::string_view pFunction, + std::size_t pRecordId, const std::string_view pNamespace) + : ReflectionBuilder(pFunction, pRecordId, pNamespace) + , m_recordUid(pRecordUid) + { } /* @method: build() @param: _returnType(*)(_signature...) @@ -114,15 +116,17 @@ namespace rtl::builder */ template inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { - return buildFunctor(pFunctor, detail::member::Static); + return buildFunctor(pFunctor, detail::member::Static, m_recordUid); } } namespace rtl::builder { - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + inline Builder::Builder(traits::uid_t pRecordUid, const std::string_view pFunction, + std::size_t pRecordId, const std::string_view pNamespace) : ReflectionBuilder(pFunction, pRecordId, pNamespace) + , m_recordUid(pRecordUid) { } /* @method: build() @@ -134,7 +138,7 @@ namespace rtl::builder */ template inline const Function Builder::build(_returnType(*pFunctor)()) const { - return buildFunctor(pFunctor, detail::member::Static); + return buildFunctor(pFunctor, detail::member::Static, m_recordUid); } } @@ -142,8 +146,10 @@ namespace rtl::builder namespace rtl::builder { template - inline Builder::Builder(std::size_t pRecordId, const std::string_view pFunction, const std::string_view pNamespace) + inline Builder::Builder(traits::uid_t pRecordUid, const std::string_view pFunction, + std::size_t pRecordId, const std::string_view pNamespace) : ReflectionBuilder(pFunction, pRecordId, pNamespace) + , m_recordUid(pRecordUid) { } @@ -157,7 +163,7 @@ namespace rtl::builder template inline const Function Builder::build(_returnType(*pFunctor)(_signature...)) const { - return buildFunctor(pFunctor, detail::member::Static); + return buildFunctor(pFunctor, detail::member::Static, m_recordUid); } } diff --git a/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp index 292b2ccf..be365208 100644 --- a/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/RecordBuilder.hpp @@ -65,7 +65,7 @@ namespace rtl::builder */ template inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const { - return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); + return Builder(traits::uid<_recordType>::value, pFunction, detail::TypeId<_recordType>::get(), ""); } @@ -81,7 +81,7 @@ namespace rtl::builder template inline const Builder MethodBuilder<_recordType>::methodStatic(const std::string_view pFunction) const { - return Builder(detail::TypeId<_recordType>::get(), pFunction, ""); + return Builder(traits::uid<_recordType>::value, pFunction, detail::TypeId<_recordType>::get(), ""); } diff --git a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h index b9c925b3..708b1793 100644 --- a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h +++ b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h @@ -41,7 +41,7 @@ namespace rtl { //adds 'pFunctor' to the 'FunctorContainer'. template - const Function buildFunctor(_returnType(*pFunctor)(_signature...), member pMemberType) const; + const Function buildFunctor(_returnType(*pFunctor)(_signature...), member pMemberType, traits::uid_t pRecordUid) const; //adds 'pFunctor' to the 'MethodContainer'. template diff --git a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp index 5e127ad4..1a5c96dc 100644 --- a/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp +++ b/ReflectionTemplateLib/rtl/builder/ReflectionBuilder.hpp @@ -39,10 +39,10 @@ namespace rtl::detail * accepts only a non-member or static-member function pointer. * builds the 'Function' object containing hash-key & meta-data for the given functor. */ template - inline const Function ReflectionBuilder::buildFunctor(_returnType(*pFunctor)(_signature...), member pMemberType) const + inline const Function ReflectionBuilder::buildFunctor(_returnType(*pFunctor)(_signature...), member pMemberType, traits::uid_t pRecordUid) const { using Container = FunctorContainer< traits::remove_const_if_not_reference<_signature>...>; - auto [typeMeta, functorId] = Container::template addFunctor<_returnType, _signature...>(pFunctor, m_recordId, pMemberType); + auto [typeMeta, functorId] = Container::template addFunctor<_returnType, _signature...>(pFunctor, pRecordUid, m_recordId, pMemberType); return Function(m_namespace, m_record, m_function, typeMeta, functorId, m_recordId, pMemberType); } diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.h b/ReflectionTemplateLib/rtl/builder/SetupFunction.h index ec51e321..d32553cc 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.h +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.h @@ -42,6 +42,6 @@ namespace rtl::detail protected: template - static std::pair addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId, member pMemberType); + static std::pair addFunctor(_returnType(*pFunctor)(_signature...), traits::uid_t pRecordUid, std::size_t pRecordId, member pMemberType); }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp index d167f62b..cb866535 100644 --- a/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp +++ b/ReflectionTemplateLib/rtl/builder/SetupFunction.hpp @@ -91,11 +91,11 @@ namespace rtl */ template template inline std::pair - SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), std::size_t pRecordId, member pMemberType) + SetupFunction<_derivedType>::addFunctor(_returnType(*pFunctor)(_signature...), traits::uid_t pRecordUid, std::size_t pRecordId, member pMemberType) { rtl::type_meta typeMeta; const auto& updateIndex = [&](std::size_t pIndex)-> void { - typeMeta = rtl::type_meta::add_function(pFunctor, pMemberType, pIndex); + typeMeta = rtl::type_meta::add_function(pFunctor, pRecordUid, pMemberType, pIndex); }; const auto& getIndex = [&]()-> std::size_t diff --git a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h index b181073b..ea9baa22 100644 --- a/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h +++ b/ReflectionTemplateLib/rtl/cache/cache_function_ptr.h @@ -28,9 +28,9 @@ namespace rtl::cache return instance_; } - const dispatch::functor& push(return_t(*fptr)(signature_t...), detail::member member_kind, std::size_t lambda_index) const + const dispatch::functor& push(return_t(*fptr)(signature_t...), traits::uid_t p_record_uid, detail::member member_kind, std::size_t lambda_index) const { - m_cache.emplace_back(std::make_pair(function_t(fptr, member_kind), lambda_index)); + m_cache.emplace_back(std::make_pair(function_t(fptr, p_record_uid, member_kind), lambda_index)); return m_cache.back().first; } diff --git a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h index 1bf19fcf..e21895de 100644 --- a/ReflectionTemplateLib/rtl/dispatch/function_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/function_ptr.h @@ -28,18 +28,19 @@ namespace rtl::dispatch return (fptr == m_functor); } - function_ptr(functor_t fptr, detail::member member_kind) :m_functor(fptr) + function_ptr(functor_t fptr, traits::uid_t p_record_uid, detail::member member_kind) :m_functor(fptr) { - m_returnId = traits::uid::value; - m_is_void = (m_returnId == traits::uid::value); - + m_record_id = p_record_uid; + m_is_void = std::is_void_v; + m_return_id = traits::uid::value; + m_member_kind = member_kind; m_is_any_arg_ncref = (traits::is_nonconst_ref_v || ...); - m_normal_signId = traits::uid>::value; - m_strict_signId = traits::uid>::value; + m_normal_args_id = traits::uid>::value; + m_strict_args_id = traits::uid>::value; - m_returnStr = detail::TypeId::toString(); - m_signatureStr = detail::TypeId::toString(); + m_return_str = detail::TypeId::toString(); + m_signature_str = detail::TypeId::toString(); } private: diff --git a/ReflectionTemplateLib/rtl/dispatch/functor.h b/ReflectionTemplateLib/rtl/dispatch/functor.h index d921f188..b01c0fa8 100644 --- a/ReflectionTemplateLib/rtl/dispatch/functor.h +++ b/ReflectionTemplateLib/rtl/dispatch/functor.h @@ -25,19 +25,19 @@ namespace rtl::dispatch protected: - std::string m_recordStr; - std::string m_returnStr; - std::string m_signatureStr; + std::string m_record_str; + std::string m_return_str; + std::string m_signature_str; - traits::uid_t m_recordId = traits::uid<>::none; - traits::uid_t m_returnId = traits::uid<>::none; + traits::uid_t m_record_id = traits::uid<>::none; + traits::uid_t m_return_id = traits::uid<>::none; - traits::uid_t m_normal_signId = traits::uid<>::none; - traits::uid_t m_strict_signId = traits::uid<>::none; + traits::uid_t m_normal_args_id = traits::uid<>::none; + traits::uid_t m_strict_args_id = traits::uid<>::none; bool m_is_void = false; bool m_is_any_arg_ncref = false; - std::vector m_argumentsId = {}; + std::vector m_args_type_ids = {}; detail::member m_member_kind = detail::member::None; diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h index 7a43e492..ec3cc924 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_base.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_base.h @@ -31,7 +31,7 @@ namespace rtl::dispatch template constexpr const function_t* to_function(std::size_t p_argsId) const { - if (p_argsId == 0 || p_argsId == m_functor.m_strict_signId) [[likely]] + if (p_argsId == 0 || p_argsId == m_functor.m_strict_args_id) [[likely]] { return static_cast*>(this); } @@ -51,7 +51,7 @@ namespace rtl::dispatch constexpr const method_t* to_method(std::size_t p_recordId, std::size_t p_argsId) const { if (p_recordId == 0 || p_argsId ==0 || - (p_recordId == m_functor.m_recordId && p_argsId == m_functor.m_strict_signId)) [[likely]] + (p_recordId == m_functor.m_record_id && p_argsId == m_functor.m_strict_args_id)) [[likely]] { return static_cast*>(this); } @@ -61,8 +61,8 @@ namespace rtl::dispatch GETTER_BOOL(_void, m_functor.m_is_void) GETTER_BOOL(_any_arg_ncref, m_functor.m_is_any_arg_ncref) - GETTER(traits::uid_t, _strict_sign_id, m_functor.m_strict_signId) - GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_signId) + GETTER(traits::uid_t, _strict_sign_id, m_functor.m_strict_args_id) + GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_args_id) GETTER_CREF(detail::RObjectId, _return_id, m_erasure.m_return_id) lambda_base(const functor& p_functor, const erasure_base& p_erasure) noexcept diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h index 0f01e17b..bc18ddf0 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_function.h @@ -32,7 +32,7 @@ namespace rtl::dispatch template constexpr const hopper_t get_hopper(const std::size_t p_returnId = 0) const { - if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] + if (p_returnId == 0 || p_returnId == m_functor.m_return_id) [[likely]] { auto fptr = static_cast&>(m_functor).f_ptr(); return hopper_t(fptr); diff --git a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h index 49b1327c..e2325fe6 100644 --- a/ReflectionTemplateLib/rtl/dispatch/lambda_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/lambda_method.h @@ -36,7 +36,7 @@ namespace rtl::dispatch template requires (!std::is_const_v) constexpr const hopper_t get_hopper(std::size_t p_returnId = 0) const { - if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] + if (p_returnId == 0 || p_returnId == m_functor.m_return_id) [[likely]] { auto fptr = static_cast&>(m_functor).f_ptr(); return hopper_t(fptr); @@ -50,7 +50,7 @@ namespace rtl::dispatch template requires (std::is_const_v) constexpr const hopper_ct get_hopper(std::size_t p_returnId = 0) const { - if (p_returnId == 0 || p_returnId == m_functor.m_returnId) [[likely]] + if (p_returnId == 0 || p_returnId == m_functor.m_return_id) [[likely]] { auto fptr = static_cast&>(m_functor).f_ptr(); return hopper_ct(fptr); diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h index 97683d3f..5bd763ea 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr.h @@ -34,17 +34,17 @@ namespace rtl::dispatch { m_member_kind = detail::member::NonConst; - m_returnId = traits::uid::value; - m_is_void = (m_returnId == traits::uid::value); - m_recordId = traits::uid::value; + m_is_void = std::is_void_v; + m_return_id = traits::uid::value; + m_record_id = traits::uid::value; m_is_any_arg_ncref = (traits::is_nonconst_ref_v || ...); - m_normal_signId = traits::uid>::value; - m_strict_signId = traits::uid>::value; + m_normal_args_id = traits::uid>::value; + m_strict_args_id = traits::uid>::value; - m_returnStr = detail::TypeId::toString(); - m_recordStr = detail::TypeId::toString(); - m_signatureStr = detail::TypeId::toString(); + m_return_str = detail::TypeId::toString(); + m_record_str = detail::TypeId::toString(); + m_signature_str = detail::TypeId::toString(); } private: diff --git a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h index 2fa260b4..416fd565 100644 --- a/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/method_ptr_const.h @@ -34,17 +34,17 @@ namespace rtl::dispatch { m_member_kind = detail::member::Const; - m_returnId = traits::uid::value; - m_is_void = (m_returnId == traits::uid::value); - m_recordId = traits::uid::value; + m_return_id = traits::uid::value; + m_is_void = (m_return_id == traits::uid::value); + m_record_id = traits::uid::value; m_is_any_arg_ncref = (traits::is_nonconst_ref_v || ...); - m_normal_signId = traits::uid>::value; - m_strict_signId = traits::uid>::value; + m_normal_args_id = traits::uid>::value; + m_strict_args_id = traits::uid>::value; - m_returnStr = detail::TypeId::toString(); - m_recordStr = detail::TypeId::toString(); - m_signatureStr = detail::TypeId::toString(); + m_return_str = detail::TypeId::toString(); + m_record_str = detail::TypeId::toString(); + m_signature_str = detail::TypeId::toString(); } private: diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 282b26b3..4310a08b 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -57,8 +57,8 @@ namespace rtl { template constexpr const detail::ErasedCaller operator()(_args&&...params) const noexcept = delete; - template - constexpr const detail::HopFunction argsT() const = delete; + //template + //constexpr const detail::HopFunction argsT() const = delete; template constexpr detail::Hopper targetT() const; diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.h b/ReflectionTemplateLib/rtl/inc/type_meta.h index c4827feb..2c808ee4 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.h +++ b/ReflectionTemplateLib/rtl/inc/type_meta.h @@ -35,13 +35,13 @@ namespace rtl GETTER_BOOL(_void, m_functor->get().m_is_void) GETTER_BOOL(_any_arg_ncref, m_functor->get().m_is_any_arg_ncref) - GETTER(std::string, _record_str, m_functor->get().m_recordStr) - GETTER(std::string, _return_str, m_functor->get().m_returnStr) - GETTER_CREF(std::vector, _args_id_arr, m_functor->get().m_argumentsId) + GETTER(std::string, _record_str, m_functor->get().m_record_str) + GETTER(std::string, _return_str, m_functor->get().m_return_str) + GETTER_CREF(std::vector, _args_id_arr, m_functor->get().m_args_type_ids) - GETTER(traits::uid_t, _record_id, m_functor->get().m_recordId) - GETTER(traits::uid_t, _normal_args_id, m_functor->get().m_normal_signId) - GETTER(traits::uid_t, _strict_args_id, m_functor->get().m_strict_signId) + GETTER(traits::uid_t, _record_id, m_functor->get().m_record_id) + GETTER(traits::uid_t, _normal_args_id, m_functor->get().m_normal_args_id) + GETTER(traits::uid_t, _strict_args_id, m_functor->get().m_strict_args_id) GETTER(detail::member, _member_kind, m_functor->get().m_member_kind) @@ -49,7 +49,7 @@ namespace rtl GETTER_CREF(dispatch::erasure_base, _erasure_base, *(m_functor->get().m_erasure)) template - static type_meta add_function(return_t(*p_fptr)(signature_t...), detail::member p_member_kind, std::size_t p_index); + static type_meta add_function(return_t(*p_fptr)(signature_t...), traits::uid_t p_record_uid, detail::member p_member_kind, std::size_t p_index); template static type_meta add_method(return_t(record_t::* p_fptr)(signature_t...), std::size_t p_index); diff --git a/ReflectionTemplateLib/rtl/inc/type_meta.hpp b/ReflectionTemplateLib/rtl/inc/type_meta.hpp index f258166e..38c94886 100644 --- a/ReflectionTemplateLib/rtl/inc/type_meta.hpp +++ b/ReflectionTemplateLib/rtl/inc/type_meta.hpp @@ -38,12 +38,12 @@ namespace rtl } template - inline type_meta type_meta::add_function(return_t(*p_fptr)(signature_t...), detail::member p_member_kind, std::size_t p_index) + inline type_meta type_meta::add_function(return_t(*p_fptr)(signature_t...), traits::uid_t p_record_uid, detail::member p_member_kind, std::size_t p_index) { auto& fc = cache::function_ptr::instance(); auto& lc = cache::lambda_function::instance(); - auto& functor = fc.push(p_fptr, p_member_kind, p_index); + auto& functor = fc.push(p_fptr, p_record_uid, p_member_kind, p_index); auto [lambda, elambda] = lc.push(functor); functor.set_lambda(lambda); From 04c3a65dbfcdc5cc12cca611003858841986bc71 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Thu, 30 Oct 2025 21:31:06 +0530 Subject: [PATCH 115/148] introducing rtl::static_method. --- .../StrictStaticTypeDispatch_StaticMethod.cpp | 45 ++++---- .../rtl/detail/inc/FunctionCaller.h | 18 ++- .../rtl/detail/inc/FunctionCaller.hpp | 105 +++++++++++------- .../rtl/detail/inc/MethodInvoker.h | 2 +- .../rtl/detail/inc/MethodInvoker.hpp | 4 +- .../rtl/dispatch/rtl_function.h | 22 +++- .../rtl/dispatch/rtl_function_erased_return.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.h | 2 +- ReflectionTemplateLib/rtl/inc/Function.hpp | 4 +- ReflectionTemplateLib/rtl/inc/Method.h | 6 +- ReflectionTemplateLib/rtl/inc/Method.hpp | 9 +- ReflectionTemplateLib/rtl/rtl_constants.h | 13 ++- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 7 +- 13 files changed, 153 insertions(+), 86 deletions(-) diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index af905eeb..33c93502 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -15,47 +15,54 @@ namespace rtl_tests std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); ASSERT_TRUE(optStringUtil); - std::optional reverseString = optStringUtil->getMethod(str_reverseString); + std::optional reverseString = optStringUtil.value().getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::function reverse_string = reverseString->argsT() - .returnT(); + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr + SUFFIX_static; EXPECT_EQ(ret_str, exp_str); } { - rtl::function reverse_string = reverseString->argsT() - .returnT(); + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(STRB); auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string + SUFFIX_static; EXPECT_EQ(ret_str, exp_str); } { - rtl::function reverse_string = reverseString->argsT<>() - .returnT(); + rtl::static_method reverse_string = reverseString.value() + .argsT<>() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 0827577c..8b2ec3ed 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -41,27 +41,33 @@ namespace rtl::detail namespace rtl::detail { - template + template struct HopFunction { rtl::type_meta m_argsTfnMeta; std::vector m_overloadsFnMeta = {}; - template requires (std::is_same_v<_returnType, rtl::Return>) + template requires (member_kind == member::None && std::is_same_v<_returnType, rtl::Return>) constexpr function returnT() const; - template requires (!std::is_same_v<_returnType, rtl::Return>) + template requires (member_kind == member::None && !std::is_same_v<_returnType, rtl::Return>) constexpr const function<_returnType(_signature...)> returnT() const; + + template requires (member_kind == member::Static && std::is_same_v<_returnType, rtl::Return>) + constexpr const static_method returnT() const; + + template requires (member_kind == member::Static && !std::is_same_v<_returnType, rtl::Return>) + constexpr const static_method<_returnType(_signature...)> returnT() const; }; - template<> - struct Hopper<> + template + struct Hopper { const std::vector& m_functorsMeta; template - constexpr const HopFunction<_signature...> argsT() const; + constexpr const HopFunction argsT() const; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index e94d911e..4045a980 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -40,64 +40,48 @@ namespace rtl::detail namespace rtl::detail { - template - template requires (!std::is_same_v) - inline constexpr const function HopFunction::returnT() const + template + template requires (member_kind == member::Static && !std::is_same_v) + inline constexpr const static_method HopFunction::returnT() const { const auto retId = traits::uid::value; if (!m_argsTfnMeta.is_empty()) { return m_argsTfnMeta.get_lambda() .template to_function() - .template get_hopper(retId); + .template get_hopper(retId) + .f_ptr(); } - return function(); + return static_method(); } - template - inline constexpr const HopFunction Hopper<>::argsT() const + template + template requires (member_kind == member::Static && std::is_same_v) + inline constexpr const static_method HopFunction::returnT() const { - auto strictArgsId = traits::uid>::value; - auto normalArgsId = traits::uid>::value; + return static_method(); + } - rtl::type_meta argsTfnMeta; - //initializing pos '0' with empty 'type_meta'. - std::vector overloadsFnMeta = { rtl::type_meta() }; - for (auto& fnMeta : m_functorsMeta) + template + template requires (member_kind == member::None && !std::is_same_v) + inline constexpr const function HopFunction::returnT() const + { + const auto retId = traits::uid::value; + if (!m_argsTfnMeta.is_empty()) { - if (argsTfnMeta.is_empty() && strictArgsId == fnMeta.get_strict_args_id()) { - argsTfnMeta = fnMeta; - } - if (normalArgsId == fnMeta.get_normal_args_id()) - { - if (normalArgsId == fnMeta.get_strict_args_id()) { - // same normal & strict ids, means no refs exists in target function's signature - // target's function signature is call by value, always at pos '0'. - // if doesn't exists, this pos is occupied by an empty 'type_meta'. - overloadsFnMeta[0] = fnMeta; - } - else if (!fnMeta.is_any_arg_ncref()) { - // its a const-ref-overload with no non-const-ref in signature, added from pos '1' onwards. - overloadsFnMeta.push_back(fnMeta); - } - } - } - - for (auto& fnMeta : m_functorsMeta) { - if (normalArgsId == fnMeta.get_normal_args_id() && fnMeta.is_any_arg_ncref()) { - // any remaining overload, const/non-const ref added from pos '1' onwards. - overloadsFnMeta.push_back(fnMeta); - } + return m_argsTfnMeta.get_lambda() + .template to_function() + .template get_hopper(retId); } - return { argsTfnMeta, overloadsFnMeta }; + return function(); } - template - template requires (std::is_same_v) - inline constexpr function HopFunction::returnT() const + template + template requires (member_kind == member::None && std::is_same_v) + inline constexpr function HopFunction::returnT() const { bool isReturnTvoid = false; function...)> erasedRetHop; @@ -131,4 +115,45 @@ namespace rtl::detail } return erasedRetHop; } + + + template + template + inline constexpr const HopFunction Hopper::argsT() const + { + auto strictArgsId = traits::uid>::value; + auto normalArgsId = traits::uid>::value; + + rtl::type_meta argsTfnMeta; + //initializing pos '0' with empty 'type_meta'. + std::vector overloadsFnMeta = { rtl::type_meta() }; + + for (auto& fnMeta : m_functorsMeta) + { + if (argsTfnMeta.is_empty() && strictArgsId == fnMeta.get_strict_args_id()) { + argsTfnMeta = fnMeta; + } + if (normalArgsId == fnMeta.get_normal_args_id()) + { + if (normalArgsId == fnMeta.get_strict_args_id()) { + // same normal & strict ids, means no refs exists in target function's signature + // target's function signature is call by value, always at pos '0'. + // if doesn't exists, this pos is occupied by an empty 'type_meta'. + overloadsFnMeta[0] = fnMeta; + } + else if (!fnMeta.is_any_arg_ncref()) { + // its a const-ref-overload with no non-const-ref in signature, added from pos '1' onwards. + overloadsFnMeta.push_back(fnMeta); + } + } + } + + for (auto& fnMeta : m_functorsMeta) { + if (normalArgsId == fnMeta.get_normal_args_id() && fnMeta.is_any_arg_ncref()) { + // any remaining overload, const/non-const ref added from pos '1' onwards. + overloadsFnMeta.push_back(fnMeta); + } + } + return { argsTfnMeta, overloadsFnMeta }; + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 7aa05bee..804b53fb 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -116,7 +116,7 @@ namespace rtl::detail constexpr const method returnT() const; }; - template + template struct Hopper { const std::vector& m_functorsMeta; diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index aab2569d..efaece86 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -291,9 +291,9 @@ namespace rtl::detail } - template + template template - inline constexpr HopMethod Hopper::argsT() const + inline constexpr HopMethod Hopper::argsT() const { auto recordId = traits::uid::value; auto strictArgsId = traits::uid>::value; diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index 6d6fe61a..b6155a12 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -46,8 +46,28 @@ namespace rtl function& operator=(function&&) = default; function& operator=(const function&) = default; - private: + protected: fptr_t m_functor = nullptr; }; } + + +namespace rtl +{ + template + struct static_method : function + { + using base_t = function; + + static_method(base_t::fptr_t p_functor) : base_t(p_functor) + { } + + static_method() = default; + static_method(static_method&&) = default; + static_method(const static_method&) = default; + + static_method& operator=(static_method&&) = default; + static_method& operator=(const static_method&) = default; + }; +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index b3e3026f..0543877c 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -126,7 +126,7 @@ namespace rtl GETTER_REF(std::vector, _vhop, m_vhop) GETTER_REF(std::vector, _overloads, m_lambdas) - template + template friend struct detail::HopFunction; static_assert((!std::is_reference_v && ...), diff --git a/ReflectionTemplateLib/rtl/inc/Function.h b/ReflectionTemplateLib/rtl/inc/Function.h index de95ee26..a7abd276 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.h +++ b/ReflectionTemplateLib/rtl/inc/Function.h @@ -96,7 +96,7 @@ namespace rtl { Function& operator=(const Function&) = default; template - constexpr const detail::HopFunction argsT() const; + constexpr const detail::HopFunction argsT() const; bool hasSignature() const; diff --git a/ReflectionTemplateLib/rtl/inc/Function.hpp b/ReflectionTemplateLib/rtl/inc/Function.hpp index 3cbe88f4..b97c8e6c 100644 --- a/ReflectionTemplateLib/rtl/inc/Function.hpp +++ b/ReflectionTemplateLib/rtl/inc/Function.hpp @@ -27,9 +27,9 @@ namespace rtl } template - inline constexpr const detail::HopFunction Function::argsT() const + inline constexpr const detail::HopFunction Function::argsT() const { - return detail::Hopper<>{ m_functorsMeta }.argsT(); + return detail::Hopper{ m_functorsMeta }.argsT(); } diff --git a/ReflectionTemplateLib/rtl/inc/Method.h b/ReflectionTemplateLib/rtl/inc/Method.h index 4310a08b..94211bb8 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.h +++ b/ReflectionTemplateLib/rtl/inc/Method.h @@ -57,11 +57,11 @@ namespace rtl { template constexpr const detail::ErasedCaller operator()(_args&&...params) const noexcept = delete; - //template - //constexpr const detail::HopFunction argsT() const = delete; + template + constexpr const detail::HopFunction argsT() const; template - constexpr detail::Hopper targetT() const; + constexpr detail::Hopper targetT() const; //indicates if a particular set of arguments accepted by the functor associated with it. template diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 8fe10421..37daf93e 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -30,11 +30,16 @@ namespace rtl template - inline constexpr detail::Hopper Method::targetT() const + inline constexpr detail::Hopper Method::targetT() const { - return detail::Hopper{ getFunctorsMeta() }; + return detail::Hopper{ getFunctorsMeta() }; } + template + constexpr const detail::HopFunction Method::argsT() const + { + return detail::Hopper{ getFunctorsMeta() }.argsT(); + } /* @method: invokeCtor() @params: variable arguments. diff --git a/ReflectionTemplateLib/rtl/rtl_constants.h b/ReflectionTemplateLib/rtl/rtl_constants.h index f5817472..1ae30435 100644 --- a/ReflectionTemplateLib/rtl/rtl_constants.h +++ b/ReflectionTemplateLib/rtl/rtl_constants.h @@ -20,7 +20,7 @@ namespace rtl { // cleanup is always automatic. enum class alloc { - None = 0,/* + None, /* * Assigned to empty or moved-from RObjects. * - Represents an invalid / non-owning state. * - Any attempt to call or clone results in rtl::error::EmptyRObject. @@ -102,7 +102,7 @@ namespace rtl::detail { enum class EntityKind { - None = 0, + None, Ptr, Value, Wrapper @@ -110,7 +110,7 @@ namespace rtl::detail enum class Wrapper { - None = 0, + None, Any, Weak, Unique, @@ -127,13 +127,14 @@ namespace rtl::detail }; - // MethodQ: Method qualifier + static marker. enum class member { - None = 0, // non-member functions. + None, // non-member functions. Const, // Const-qualified instance method NonConst, // Non-const instance method - Static // Static methods + Static, // Static methods + Ctor, + CopyCtor }; constexpr const std::string_view NAMESPACE_GLOBAL = "global"; diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index ff60e191..7c3e70fb 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -31,6 +31,9 @@ namespace rtl template struct method; + template + struct static_method; + namespace detail { struct FunctorId; @@ -49,10 +52,10 @@ namespace rtl template class SetupMethod; - template + template struct Hopper; - template + template struct HopFunction; } From b36f4751322d3a9cd5c5d870d226d2e42177e381 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 31 Oct 2025 19:15:39 +0530 Subject: [PATCH 116/148] static-method, init-error for callables, wip --- .../BasicTypeErasedDispatch_StaticMethod.cpp | 179 +++++++++++++++++ .../rtl/detail/inc/FunctionCaller.h | 2 + .../rtl/detail/inc/FunctionCaller.hpp | 70 ++++--- .../rtl/detail/inc/MethodInvoker.h | 13 +- .../rtl/detail/inc/MethodInvoker.hpp | 187 +++++++----------- .../rtl/dispatch/rtl_function.h | 11 +- .../rtl/dispatch/rtl_function_erased_return.h | 20 +- .../rtl/dispatch/rtl_method.h | 11 +- .../rtl/dispatch/rtl_method_const.h | 11 +- .../rtl/dispatch/rtl_method_erased.h | 12 +- .../rtl/dispatch/rtl_method_erased_return.h | 12 +- .../dispatch/rtl_method_erased_return_const.h | 12 +- .../rtl/dispatch/rtl_method_erased_target.h | 12 +- 13 files changed, 382 insertions(+), 170 deletions(-) diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp index e69de29b..ca02e54e 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp @@ -0,0 +1,179 @@ +#include +#include + +#include "TestMirrorProvider.h" +#include "GlobalTestUtils.h" +#include "../CxxTestProps/inc/StringOps.h" + +using namespace test_utils; +using namespace test_mirror; + +namespace rtl_tests +{ + TEST(BasicTypeErasedRtl_static_method, implicit_resolutions_to_call_by_value_overloads) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + std::optional reverseStrOpt = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseStrOpt); + EXPECT_FALSE(reverseStrOpt->hasSignature()); + { + rtl::method reverseString = reverseStrOpt.value() + .targetT() + .argsT() + .returnT<>(); + EXPECT_FALSE(reverseString); + { + auto [err, robj] = reverseString(StringS())(const_cast(STRA)); + + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } { + auto [err, robj] = reverseString.bind(StringS())(const_cast(STRA)); + + EXPECT_EQ(err, rtl::error::InvalidCaller); + EXPECT_TRUE(robj.isEmpty()); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::method reverseString = reverseStrOpt.value().targetT() + .argsT() + .returnT<>(); + EXPECT_FALSE(reverseString); + { + auto [err, robj] = reverseString(StringS())(STRA); + EXPECT_EQ(err, rtl::error::InvalidStaticMethodCaller); + } + } + //{ + // auto [err, robj] = reverseString.bind(StringS())(STRA); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; + // EXPECT_EQ(retStr, expStr); + // } + //} + //EXPECT_TRUE(reverseStrOpt->hasSignature()); + //{ + // rtl::method reverseString = reverseStrOpt.value().targetT() + // .argsT() + // .returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // auto [err, robj] = reverseString(StringS())(STRA); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; + // EXPECT_EQ(retStr, expStr); + // } { + // auto [err, robj] = reverseString.bind(StringS())(STRA); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; + // EXPECT_EQ(retStr, expStr); + // } + //} + //EXPECT_TRUE(reverseStrOpt->hasSignature()); + //{ + // rtl::method reverseString = reverseStrOpt.value().targetT() + // .argsT() + // .returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // std::string str = STRA; + // auto [err, robj] = reverseString(StringS())(&str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; + // EXPECT_EQ(retStr, expStr); + // } { + // std::string str = STRA; + // auto [err, robj] = reverseString.bind(StringS())(&str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; + // EXPECT_EQ(retStr, expStr); + // } + //} + //EXPECT_TRUE(reverseStrOpt->hasSignature()); + //{ + // rtl::method reverseString = reverseStrOpt.value().targetT() + // .argsT() + // .returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // const std::string str = STRA; + // auto [err, robj] = reverseString(StringS())(&str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; + // EXPECT_EQ(retStr, expStr); + // } { + // const std::string str = STRA; + // auto [err, robj] = reverseString.bind(StringS())(&str); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; + // EXPECT_EQ(retStr, expStr); + // } + //} + //EXPECT_TRUE(reverseStrOpt->hasSignature<>()); + //{ + // rtl::method reverseString = reverseStrOpt.value().targetT() + // .argsT<>() + // .returnT<>(); + // EXPECT_TRUE(reverseString); + // { + // auto [err, robj] = reverseString(StringS())(); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; + // EXPECT_EQ(retStr, expStr); + // } { + // auto [err, robj] = reverseString.bind(StringS())(); + + // EXPECT_EQ(err, rtl::error::None); + // ASSERT_FALSE(robj.isEmpty()); + // ASSERT_TRUE(robj.canViewAs()); + + // const std::string& retStr = robj.view()->get(); + // std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; + // EXPECT_EQ(retStr, expStr); + // } + //} + } +} \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h index 8b2ec3ed..ee501b33 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.h @@ -48,6 +48,8 @@ namespace rtl::detail std::vector m_overloadsFnMeta = {}; + void initHopper(function& pFn) const; + template requires (member_kind == member::None && std::is_same_v<_returnType, rtl::Return>) constexpr function returnT() const; diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index 4045a980..fa461deb 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -40,6 +40,25 @@ namespace rtl::detail namespace rtl::detail { + template + template requires (member_kind == member::None && std::is_same_v) + inline constexpr function HopFunction::returnT() const + { + function...)> erasedFn; + initHopper(erasedFn); + return erasedFn; + } + + + template + template requires (member_kind == member::Static && std::is_same_v) + inline constexpr const static_method HopFunction::returnT() const + { + static_method erasedFn; + initHopper(erasedFn); + return erasedFn; + } + template template requires (member_kind == member::Static && !std::is_same_v) inline constexpr const static_method HopFunction::returnT() const @@ -56,14 +75,6 @@ namespace rtl::detail } - template - template requires (member_kind == member::Static && std::is_same_v) - inline constexpr const static_method HopFunction::returnT() const - { - return static_method(); - } - - template template requires (member_kind == member::None && !std::is_same_v) inline constexpr const function HopFunction::returnT() const @@ -80,40 +91,39 @@ namespace rtl::detail template - template requires (member_kind == member::None && std::is_same_v) - inline constexpr function HopFunction::returnT() const + inline void HopFunction::initHopper(function& pHopFn) const { bool isReturnTvoid = false; - function...)> erasedRetHop; - for (auto& fnMeta : m_overloadsFnMeta) - { - if (!fnMeta.is_empty()) + { + if (fnMeta.is_empty()) { - auto& erasedRetFn = fnMeta.get_erasure_base() - .template to_erased_return...>(); - if (fnMeta.is_void()) { - isReturnTvoid = true; - erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); - } - else { - erasedRetHop.get_rhop().push_back(erasedRetFn.get_return_hopper()); - } - erasedRetHop.get_overloads().push_back(&fnMeta.get_lambda()); + pHopFn.get_vhop().push_back(nullptr); + pHopFn.get_rhop().push_back(nullptr); + pHopFn.get_overloads().push_back(nullptr); + continue; + } + + auto& erasedRetFn = fnMeta.get_erasure_base() + .template to_erased_return...>(); + if (fnMeta.is_void()) { + isReturnTvoid = true; + pHopFn.get_vhop().push_back(erasedRetFn.get_void_hopper()); } else { - erasedRetHop.get_vhop().push_back(nullptr); - erasedRetHop.get_rhop().push_back(nullptr); - erasedRetHop.get_overloads().push_back(nullptr); + pHopFn.get_rhop().push_back(erasedRetFn.get_return_hopper()); } + pHopFn.get_overloads().push_back(&fnMeta.get_lambda()); } if (isReturnTvoid) { - erasedRetHop.get_rhop().clear(); + pHopFn.get_rhop().clear(); } else { - erasedRetHop.get_vhop().clear(); + pHopFn.get_vhop().clear(); + } + if (pHopFn) { + pHopFn.set_init_error(error::None); } - return erasedRetHop; } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h index 804b53fb..b86d9766 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.h @@ -103,17 +103,14 @@ namespace rtl::detail std::vector m_overloadsFnMeta = {}; + template requires (!traits::type_aware_v) + void initHopper(method& pMth) const; + template requires (traits::type_aware_v) constexpr const method returnT() const; - template requires (traits::target_erased_v) - constexpr const method returnT() const; - - template requires (traits::return_erased_v) - constexpr const method returnT() const; - - template requires (traits::type_erased_v) - constexpr const method returnT() const; + template requires (!traits::type_aware_v) + constexpr const method returnT() const; }; template diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index efaece86..4de97d9c 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -158,10 +158,19 @@ namespace rtl::detail namespace rtl::detail { + template + template requires (!traits::type_aware_v) + inline constexpr const method HopMethod::returnT() const + { + method...)> erasedMth; + initHopper(erasedMth); + return erasedMth; + } + + template template requires (traits::type_aware_v) - inline constexpr const - method HopMethod::returnT() const + inline constexpr const method HopMethod::returnT() const { if (!m_argsTfnMeta.is_empty() && m_argsTfnMeta.get_member_kind() != member::Static) { @@ -174,123 +183,6 @@ namespace rtl::detail } - template - template requires (traits::type_erased_v) - inline constexpr const - method HopMethod::returnT() const - { - bool isReturnTvoid = false; - method...)> erasedRetHop; - - for (auto& fnMeta : m_overloadsFnMeta) - { - if (!fnMeta.is_empty()) - { - auto& erasedRetFn = fnMeta.get_erasure_base() - .template to_erased_record...>(); - if (fnMeta.is_void()) { - isReturnTvoid = true; - erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); - } - else { - erasedRetHop.get_rhop().push_back(erasedRetFn.get_return_hopper()); - } - erasedRetHop.get_overloads().push_back(&fnMeta.get_lambda()); - } - else { - erasedRetHop.get_vhop().push_back(nullptr); - erasedRetHop.get_rhop().push_back(nullptr); - erasedRetHop.get_overloads().push_back(nullptr); - } - } - if (isReturnTvoid) { - erasedRetHop.get_rhop().clear(); - } - else { - erasedRetHop.get_vhop().clear(); - } - return erasedRetHop; - } - - - template - template requires (traits::target_erased_v) - inline constexpr const - method HopMethod::returnT() const - { - bool isReturnTvoid = false; - method...)> erasedRetHop; - - for (auto& fnMeta : m_overloadsFnMeta) - { - if (!fnMeta.is_empty()) - { - auto& erasedRetFn = fnMeta.get_erasure_base() - .template to_erased_target_aware_return...>(); - if (fnMeta.is_void()) { - isReturnTvoid = true; - erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); - } - else { - erasedRetHop.get_rhop().push_back(erasedRetFn.get_return_hopper()); - } - erasedRetHop.get_overloads().push_back(&fnMeta.get_lambda()); - } - else { - erasedRetHop.get_vhop().push_back(nullptr); - erasedRetHop.get_rhop().push_back(nullptr); - erasedRetHop.get_overloads().push_back(nullptr); - } - } - if (isReturnTvoid) { - erasedRetHop.get_rhop().clear(); - } - else { - erasedRetHop.get_vhop().clear(); - } - return erasedRetHop; - } - - - template - template requires (traits::return_erased_v) - inline constexpr const - method HopMethod::returnT() const - { - bool isReturnTvoid = false; - method...)> erasedRetHop; - - for (auto& fnMeta : m_overloadsFnMeta) - { - if (!fnMeta.is_empty()) - { - auto& erasedRetFn = fnMeta.get_erasure_base() - .template to_erased_return_aware_target...>(); - if (fnMeta.is_void()) { - isReturnTvoid = true; - erasedRetHop.get_vhop().push_back(erasedRetFn.get_void_hopper()); - } - else { - erasedRetHop.get_rhop().push_back(erasedRetFn.get_return_hopper()); - } - erasedRetHop.get_overloads().push_back(&fnMeta.get_lambda()); - } - else { - erasedRetHop.get_vhop().push_back(nullptr); - erasedRetHop.get_rhop().push_back(nullptr); - erasedRetHop.get_overloads().push_back(nullptr); - } - } - if (isReturnTvoid) { - erasedRetHop.get_rhop().clear(); - } - else { - erasedRetHop.get_vhop().clear(); - } - return erasedRetHop; - } - - template template inline constexpr HopMethod Hopper::argsT() const @@ -338,4 +230,61 @@ namespace rtl::detail } return { argsTfnMeta, overloadsFnMeta }; } + + + template + template requires (!traits::type_aware_v) + inline void HopMethod::initHopper(method& pMth) const + { + bool isReturnTvoid = false; + for (auto& fnMeta : m_overloadsFnMeta) + { + if (fnMeta.is_empty()) + { + pMth.get_vhop().push_back(nullptr); + pMth.get_rhop().push_back(nullptr); + pMth.get_overloads().push_back(nullptr); + continue; + } + + if (fnMeta.get_member_kind() == member::Static) { + pMth.set_init_error(error::InvalidStaticMethodCaller); + return; + } + + auto& erasedFn = [&]() -> decltype(auto) { + if constexpr (traits::type_erased_v) { + return fnMeta.get_erasure_base() + .template to_erased_record...>(); + } + else if constexpr (traits::target_erased_v) { + return fnMeta.get_erasure_base() + .template to_erased_target_aware_return...>(); + } + else if constexpr (traits::return_erased_v) { + return fnMeta.get_erasure_base() + .template to_erased_return_aware_target...>(); + } + }(); + + if (fnMeta.is_void()) { + isReturnTvoid = true; + pMth.get_vhop().push_back(erasedFn.get_void_hopper()); + } + else { + pMth.get_rhop().push_back(erasedFn.get_return_hopper()); + } + pMth.get_overloads().push_back(&fnMeta.get_lambda()); + + } + if (isReturnTvoid) { + pMth.get_rhop().clear(); + } + else { + pMth.get_vhop().clear(); + } + if (pMth) { + pMth.set_init_error(error::None); + } + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index b6155a12..1e654dd3 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -36,7 +36,9 @@ namespace rtl return (*m_functor)(std::forward(params)...); } - function(fptr_t p_functor): m_functor(p_functor) + function(fptr_t p_functor) + : m_init_err(error::None) + , m_functor(p_functor) { } function() = default; @@ -46,9 +48,16 @@ namespace rtl function& operator=(function&&) = default; function& operator=(const function&) = default; + GETTER(rtl::error, _init_error, m_init_err) + protected: fptr_t m_functor = nullptr; + error m_init_err = error::InvalidCaller; + + void set_init_error(error p_err) { + m_init_err = p_err; + } }; } diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index 0543877c..00eefe05 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -25,7 +25,7 @@ namespace rtl constexpr Return operator()(args_t&&...params) const noexcept { if (!(*this)) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + return { m_init_err, RObject{} }; } if (must_bind_refs()) [[unlikely]] { @@ -58,7 +58,7 @@ namespace rtl constexpr Return operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + return { fn.m_init_err, RObject{} }; } auto signature_id = traits::uid>::value; @@ -110,6 +110,8 @@ namespace rtl ncref = 2 //non-const ref. }; + GETTER(rtl::error, _init_error, m_init_err) + private: using lambda_vt = std::function; @@ -122,6 +124,12 @@ namespace rtl std::vector m_lambdas = {}; + error m_init_err = error::InvalidCaller; + + void set_init_error(error p_err) { + m_init_err = p_err; + } + GETTER_REF(std::vector, _rhop, m_rhop) GETTER_REF(std::vector, _vhop, m_vhop) GETTER_REF(std::vector, _overloads, m_lambdas) @@ -132,4 +140,12 @@ namespace rtl static_assert((!std::is_reference_v && ...), "rtl::function<...>: any type cannot be specified as reference here"); }; +} + + +namespace rtl +{ + template + struct static_method : function + { }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index 39070719..f920da65 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -55,7 +55,9 @@ namespace rtl return invoker{ m_functor, p_target }; } - method(fptr_t p_functor) : m_functor(p_functor) + method(fptr_t p_functor) + : m_init_err(error::None) + , m_functor(p_functor) { } method() = default; @@ -65,8 +67,15 @@ namespace rtl method& operator=(method&&) = default; method& operator=(const method&) = default; + GETTER(rtl::error, _init_error, m_init_err) + private: fptr_t m_functor = nullptr; + error m_init_err = error::InvalidCaller; + + void set_init_error(error p_err) { + m_init_err = p_err; + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index 7fdde543..9d0e90ad 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -50,7 +50,9 @@ namespace rtl return invoker{ m_functor, p_target }; } - method(fptr_t p_functor) : m_functor(p_functor) + method(fptr_t p_functor) + : m_init_err(error::None) + , m_functor(p_functor) { } method() = default; @@ -60,8 +62,15 @@ namespace rtl method& operator=(method&&) = default; method& operator=(const method&) = default; + GETTER(rtl::error, _init_error, m_init_err) + private: fptr_t m_functor = nullptr; + error m_init_err = error::InvalidCaller; + + void set_init_error(error p_err) { + m_init_err = p_err; + } }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h index 6ae48f0e..7ee112fb 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h @@ -30,7 +30,7 @@ namespace rtl constexpr Return operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + return { fn.m_init_err, RObject{} }; } if (fn.must_bind_refs()) [[unlikely]] { @@ -65,7 +65,7 @@ namespace rtl constexpr Return operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + return { fn.m_init_err, RObject{} }; } auto signature_id = traits::uid>::value; @@ -131,6 +131,8 @@ namespace rtl ncref = 2 //non-const ref. }; + GETTER(rtl::error, _init_error, m_init_err) + private: using lambda_vt = std::function; @@ -142,7 +144,13 @@ namespace rtl std::vector m_vhop = {}; std::vector m_lambdas = {}; + + error m_init_err = error::InvalidCaller; + void set_init_error(error p_err) { + m_init_err = p_err; + } + GETTER_REF(std::vector, _rhop, m_rhop) GETTER_REF(std::vector, _vhop, m_vhop) GETTER_REF(std::vector, _overloads, m_lambdas) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h index 6a011644..1c82914f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -30,7 +30,7 @@ namespace rtl constexpr Return operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + return { fn.m_init_err, RObject{} }; } if (fn.must_bind_refs()) [[unlikely]] { @@ -65,7 +65,7 @@ namespace rtl constexpr Return operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + return { fn.m_init_err, RObject{} }; } auto signature_id = traits::uid>::value; @@ -131,6 +131,8 @@ namespace rtl ncref = 2 //non-const ref. }; + GETTER(rtl::error, _init_error, m_init_err) + private: using lambda_vt = std::function; @@ -143,6 +145,12 @@ namespace rtl std::vector m_lambdas = {}; + error m_init_err = error::InvalidCaller; + + void set_init_error(error p_err) { + m_init_err = p_err; + } + GETTER_REF(std::vector, _rhop, m_rhop) GETTER_REF(std::vector, _vhop, m_vhop) GETTER_REF(std::vector, _overloads, m_lambdas) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h index d7e74b3c..0cbfc5f4 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h @@ -30,7 +30,7 @@ namespace rtl constexpr Return operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + return { fn.m_init_err, RObject{} }; } if (fn.must_bind_refs()) [[unlikely]] { @@ -65,7 +65,7 @@ namespace rtl constexpr Return operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, RObject{} }; + return { fn.m_init_err, RObject{} }; } auto signature_id = traits::uid>::value; @@ -121,6 +121,8 @@ namespace rtl ncref = 2 //non-const ref. }; + GETTER(rtl::error, _init_error, m_init_err) + private: using lambda_vt = std::function; @@ -132,7 +134,13 @@ namespace rtl std::vector m_vhop = {}; std::vector m_lambdas = {}; + + error m_init_err = error::InvalidCaller; + void set_init_error(error p_err) { + m_init_err = p_err; + } + GETTER_REF(std::vector, _rhop, m_rhop) GETTER_REF(std::vector, _vhop, m_vhop) GETTER_REF(std::vector, _overloads, m_lambdas) diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h index 7c858708..cd637dff 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h @@ -30,7 +30,7 @@ namespace rtl constexpr std::pair> operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, std::nullopt }; + return { fn.m_init_err, std::nullopt }; } if (fn.must_bind_refs()) [[unlikely]] { @@ -62,7 +62,7 @@ namespace rtl constexpr std::pair> operator()(args_t&&...params) const noexcept { if (!fn) [[unlikely]] { - return { error::InvalidCaller, std::nullopt }; + return { fn.m_init_err, std::nullopt }; } auto signature_id = traits::uid>::value; @@ -115,6 +115,8 @@ namespace rtl ncref = 2 //non-const ref. }; + GETTER(rtl::error, _init_error, m_init_err) + private: using lambda_vt = std::function; @@ -127,6 +129,12 @@ namespace rtl std::vector m_lambdas = {}; + error m_init_err = error::InvalidCaller; + + void set_init_error(error p_err) { + m_init_err = p_err; + } + GETTER_REF(std::vector, _rhop, m_rhop) GETTER_REF(std::vector, _vhop, m_vhop) GETTER_REF(std::vector, _overloads, m_lambdas) From eb3f764395f03e8648d43fd3b0f4170fc255f0fd Mon Sep 17 00:00:00 2001 From: Neeraj Date: Fri, 31 Oct 2025 23:34:41 +0530 Subject: [PATCH 117/148] Updated readme. --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 90c500f5..62d1a1c5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,26 @@ # Reflection Template Library - Modern C++ Reflection Framework -*Reflection Template Library (RTL)* is a lightweight C++ runtime reflection library that enables introspection and dynamic manipulation of ***Types*** — allowing you to access, modify, and invoke objects at runtime without compile-time type knowledge. +*Reflection Template Library (RTL)* brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. -RTL is implemented as a *static library* that organizes function pointers into `std::vector` tables, with each functor wrapped in a lambda. This design enables constant-time `O(1)` lookups while ensuring type-safe and efficient runtime access. +🪞 What is “Reflection”? — Imagine you’ve written a simple function, +```c++ +std::string GetAsString(int num); +``` +Now, somewhere else in your codebase — without a direct include, without knowing the function’s signature — you can do this: +```c++ +rtl::function toString = rtl::CxxMirror(...).getFunction("GetAsString"); +std::string result = toString(69375); +``` +That’s it. +You just looked up a function by name, called it safely, and got a real return value — all through RTL. + +⚡ Performance? Overhead? Practically none. +This RTL reflective call is just a native function pointer hop — faster than std::function in the example above. + +Yes, RTL performs reflective invocations — for free functions, methods, constructors, or even unknown instance types — at near-zero runtime cost, even when the types involved are not known at compile time. + +💡 In One Line +> RTL is a lightweight, static library that brings a robust, type-safe runtime reflection system to C++ — as flexible as in managed languages, yet as fast as native code. [![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) From d2c8eb0c4b7482ecf2a8d8474d13b451abe8478a Mon Sep 17 00:00:00 2001 From: Neeraj Date: Fri, 31 Oct 2025 23:43:29 +0530 Subject: [PATCH 118/148] Updated Readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62d1a1c5..fdff5704 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Reflection Template Library - Modern C++ Reflection Framework -*Reflection Template Library (RTL)* brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. +***Reflection Template Library (RTL)*** brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. 🪞 What is “Reflection”? — Imagine you’ve written a simple function, ```c++ From 4f82ff4f2421d337e73418f600f64320f036d144 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Sat, 1 Nov 2025 00:06:50 +0530 Subject: [PATCH 119/148] Updated Readme. --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fdff5704..1649818b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Reflection Template Library - Modern C++ Reflection Framework -***Reflection Template Library (RTL)*** brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. +**Reflection Template Library (RTL)** brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. 🪞 What is “Reflection”? — Imagine you’ve written a simple function, ```c++ @@ -8,19 +8,19 @@ std::string GetAsString(int num); ``` Now, somewhere else in your codebase — without a direct include, without knowing the function’s signature — you can do this: ```c++ -rtl::function toString = rtl::CxxMirror(...).getFunction("GetAsString"); -std::string result = toString(69375); +rtl::function toStr = ... getFunction("GetAsString").argsT().returnT(); +std::string result = toStr(69375); ``` That’s it. You just looked up a function by name, called it safely, and got a real return value — all through RTL. ⚡ Performance? Overhead? Practically none. -This RTL reflective call is just a native function pointer hop — faster than std::function in the example above. +This RTL reflective call is just a native function pointer hop — faster than `std::function`. -Yes, RTL performs reflective invocations — for free functions, methods, constructors, or even unknown instance types — at near-zero runtime cost, even when the types involved are not known at compile time. +Yes, RTL performs reflective invocations — for free functions, methods, constructors — at near-zero runtime cost, even when the types involved are not known at compile time. 💡 In One Line -> RTL is a lightweight, static library that brings a robust, type-safe runtime reflection system to C++ — as flexible as in managed languages, yet as fast as native code. +> RTL is a lightweight, static library that brings a robust, type-safe runtime reflection system to C++ — as flexible as in managed languages, yet as fast as possible to native code. [![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) From 2382aef57834ec77b928f6d69e13da93013506a7 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 1 Nov 2025 10:24:52 +0530 Subject: [PATCH 120/148] static-method, test cases fix. --- .../BasicTypeErasedDispatch_StaticMethod.cpp | 262 +++++++++--------- ReflectionTemplateLib/rtl/inc/Method.hpp | 2 +- 2 files changed, 134 insertions(+), 130 deletions(-) diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp index ca02e54e..04e5f975 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp @@ -38,7 +38,8 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt.value().targetT() + rtl::method reverseString = reverseStrOpt.value() + .targetT() .argsT() .returnT<>(); EXPECT_FALSE(reverseString); @@ -46,134 +47,137 @@ namespace rtl_tests auto [err, robj] = reverseString(StringS())(STRA); EXPECT_EQ(err, rtl::error::InvalidStaticMethodCaller); } + } { + rtl::static_method reverseString = reverseStrOpt.value() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(STRA); + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::static_method reverseString = reverseStrOpt.value() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind()(STRA); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::static_method reverseString = reverseStrOpt.value() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + std::string str = STRA; + auto [err, robj] = reverseString(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } { + std::string str = STRA; + auto [err, robj] = reverseString.bind()(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature()); + { + rtl::static_method reverseString = reverseStrOpt.value() + .argsT() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + const std::string str = STRA; + auto [err, robj] = reverseString(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } { + const std::string str = STRA; + auto [err, robj] = reverseString.bind()(&str); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } + } + EXPECT_TRUE(reverseStrOpt->hasSignature<>()); + { + rtl::static_method reverseString = reverseStrOpt.value() + .argsT<>() + .returnT<>(); + EXPECT_TRUE(reverseString); + { + auto [err, robj] = reverseString(); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } { + auto [err, robj] = reverseString.bind()(); + + EXPECT_EQ(err, rtl::error::None); + ASSERT_FALSE(robj.isEmpty()); + ASSERT_TRUE(robj.canViewAs()); + + const std::string& retStr = robj.view()->get(); + std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_static; + EXPECT_EQ(retStr, expStr); + } } - //{ - // auto [err, robj] = reverseString.bind(StringS())(STRA); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; - // EXPECT_EQ(retStr, expStr); - // } - //} - //EXPECT_TRUE(reverseStrOpt->hasSignature()); - //{ - // rtl::method reverseString = reverseStrOpt.value().targetT() - // .argsT() - // .returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // auto [err, robj] = reverseString(StringS())(STRA); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; - // EXPECT_EQ(retStr, expStr); - // } { - // auto [err, robj] = reverseString.bind(StringS())(STRA); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; - // EXPECT_EQ(retStr, expStr); - // } - //} - //EXPECT_TRUE(reverseStrOpt->hasSignature()); - //{ - // rtl::method reverseString = reverseStrOpt.value().targetT() - // .argsT() - // .returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // std::string str = STRA; - // auto [err, robj] = reverseString(StringS())(&str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; - // EXPECT_EQ(retStr, expStr); - // } { - // std::string str = STRA; - // auto [err, robj] = reverseString.bind(StringS())(&str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; - // EXPECT_EQ(retStr, expStr); - // } - //} - //EXPECT_TRUE(reverseStrOpt->hasSignature()); - //{ - // rtl::method reverseString = reverseStrOpt.value().targetT() - // .argsT() - // .returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // const std::string str = STRA; - // auto [err, robj] = reverseString(StringS())(&str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; - // EXPECT_EQ(retStr, expStr); - // } { - // const std::string str = STRA; - // auto [err, robj] = reverseString.bind(StringS())(&str); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr; - // EXPECT_EQ(retStr, expStr); - // } - //} - //EXPECT_TRUE(reverseStrOpt->hasSignature<>()); - //{ - // rtl::method reverseString = reverseStrOpt.value().targetT() - // .argsT<>() - // .returnT<>(); - // EXPECT_TRUE(reverseString); - // { - // auto [err, robj] = reverseString(StringS())(); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; - // EXPECT_EQ(retStr, expStr); - // } { - // auto [err, robj] = reverseString.bind(StringS())(); - - // EXPECT_EQ(err, rtl::error::None); - // ASSERT_FALSE(robj.isEmpty()); - // ASSERT_TRUE(robj.canViewAs()); - - // const std::string& retStr = robj.view()->get(); - // std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; - // EXPECT_EQ(retStr, expStr); - // } - //} } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/inc/Method.hpp b/ReflectionTemplateLib/rtl/inc/Method.hpp index 37daf93e..01f65fc1 100644 --- a/ReflectionTemplateLib/rtl/inc/Method.hpp +++ b/ReflectionTemplateLib/rtl/inc/Method.hpp @@ -67,7 +67,7 @@ namespace rtl { switch (getQualifier()) { - case detail::member::None: { + case detail::member::Static: { return Function::hasSignature<_args...>(); } case detail::member::NonConst: { From 7bbdfa789dc119dc45594deec09b941724aba526 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 1 Nov 2025 12:43:34 +0530 Subject: [PATCH 121/148] Updated readme. --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1649818b..b80fe4fa 100644 --- a/README.md +++ b/README.md @@ -2,25 +2,27 @@ **Reflection Template Library (RTL)** brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. -🪞 What is “Reflection”? — Imagine you’ve written a simple function, +🪞 What is “Reflection”? — Reflection lets you intract with code **by name** instead of **by type**. +Imagine you’ve written a simple function, ```c++ std::string GetAsString(int num); ``` -Now, somewhere else in your codebase — without a direct include, without knowing the function’s signature — you can do this: +**RTL** lets you call it dynamically: ```c++ -rtl::function toStr = ... getFunction("GetAsString").argsT().returnT(); -std::string result = toStr(69375); +rtl::function toStr = rtl_mirror.getFunction("GetAsString") //rtl_mirror?? see quick-preview! + ->argsT() + .returnT(); +std::string result = toStr(69375); // Works! ``` -That’s it. -You just looked up a function by name, called it safely, and got a real return value — all through RTL. +**No includes** | **No compile-timetype knowledge** | **Just runtime lookup & type-safe invocation** ⚡ Performance? Overhead? Practically none. This RTL reflective call is just a native function pointer hop — faster than `std::function`. -Yes, RTL performs reflective invocations — for free functions, methods, constructors — at near-zero runtime cost, even when the types involved are not known at compile time. +Yes, RTL performs reflective invocations — for free functions, methods, constructors — at near-zero cost, even when types are unknown at compile time. 💡 In One Line -> RTL is a lightweight, static library that brings a robust, type-safe runtime reflection system to C++ — as flexible as in managed languages, yet as fast as possible to native code. +*** RTL is a lightweight, static library that enables a robust, type-safe runtime reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance. *** [![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) @@ -54,7 +56,7 @@ Yes, RTL performs reflective invocations — for free functions, methods, constr ``` Create an instance of `CxxMirror`, passing all type information directly to its constructor — and you're done! ```c++ -auto cxx_mirror = rtl::CxxMirror({ +auto rtl_mirror = rtl::CxxMirror({ /* ...register all types here... */ rtl::type().record("Person").build(), rtl::type().member().constructor().build(), @@ -63,7 +65,7 @@ auto cxx_mirror = rtl::CxxMirror({ }); ``` -With just this much, you’ve registered your types and unlocked full runtime reflection. The `cxx_mirror` object is your gateway to query, introspect, and instantiate types at runtime — all without compile-time knowledge of those types, without strict static coupling. +With just this much, you’ve registered your types and unlocked full runtime reflection. The `rtl_mirror` object is your gateway to query, introspect, and instantiate types at runtime — all without compile-time knowledge of those types, without strict static coupling. **Without reflection:** @@ -77,7 +79,7 @@ std::cout << p.getName(); ```c++ // Look up the class by name -std::optional classPerson = cxx_mirror.getRecord("Person"); +std::optional classPerson = rtl_mirror.getRecord("Person"); if (classPerson) // Check has_value() before use. { From f5eca8eef3cd7fde50d3bfb026aba019027e1e58 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 1 Nov 2025 12:53:21 +0530 Subject: [PATCH 122/148] Updated Readme. --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b80fe4fa..ebfbc280 100644 --- a/README.md +++ b/README.md @@ -2,26 +2,27 @@ **Reflection Template Library (RTL)** brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. -🪞 What is “Reflection”? — Reflection lets you intract with code **by name** instead of **by type**. +🪞 What is “Reflection”? — Reflection lets you intract with code *by name* instead of *by type*. Imagine you’ve written a simple function, ```c++ std::string GetAsString(int num); ``` **RTL** lets you call it dynamically: ```c++ -rtl::function toStr = rtl_mirror.getFunction("GetAsString") //rtl_mirror?? see quick-preview! +rtl::function toStr = cxx_mirror.getFunction("GetAsString") //cxx_mirror?? see quick-preview! ->argsT() .returnT(); std::string result = toStr(69375); // Works! ``` -**No includes** | **No compile-timetype knowledge** | **Just runtime lookup & type-safe invocation** +**No includes | No compile-time type knowledge | Just runtime lookup & type-safe invocation**. ⚡ Performance? Overhead? Practically none. -This RTL reflective call is just a native function pointer hop — faster than `std::function`. +This RTL reflective call is just a native function pointer hop — faster than `std::function`. Yes! `rtl::function` is faster than `std::function`. -Yes, RTL performs reflective invocations — for free functions, methods, constructors — at near-zero cost, even when types are unknown at compile time. +RTL performs reflective invocations — for free functions, methods, constructors — at near-zero cost, even when types are unknown at compile time. 💡 In One Line + *** RTL is a lightweight, static library that enables a robust, type-safe runtime reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance. *** [![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) @@ -56,7 +57,7 @@ Yes, RTL performs reflective invocations — for free functions, methods, constr ``` Create an instance of `CxxMirror`, passing all type information directly to its constructor — and you're done! ```c++ -auto rtl_mirror = rtl::CxxMirror({ +auto cxx_mirror = rtl::CxxMirror({ /* ...register all types here... */ rtl::type().record("Person").build(), rtl::type().member().constructor().build(), @@ -65,7 +66,7 @@ auto rtl_mirror = rtl::CxxMirror({ }); ``` -With just this much, you’ve registered your types and unlocked full runtime reflection. The `rtl_mirror` object is your gateway to query, introspect, and instantiate types at runtime — all without compile-time knowledge of those types, without strict static coupling. +With just this much, you’ve registered your types and unlocked full runtime reflection. The `cxx_mirror` object is your gateway to query, introspect, and instantiate types at runtime — all without compile-time knowledge of those types, without strict static coupling. **Without reflection:** @@ -79,7 +80,7 @@ std::cout << p.getName(); ```c++ // Look up the class by name -std::optional classPerson = rtl_mirror.getRecord("Person"); +std::optional classPerson = cxx_mirror.getRecord("Person"); if (classPerson) // Check has_value() before use. { From 13fc6a48e0086668c9e0e1a74f17bc7b928d9d29 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 1 Nov 2025 12:54:42 +0530 Subject: [PATCH 123/148] Updated Readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ebfbc280..b22a75af 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ RTL performs reflective invocations — for free functions, methods, constructor 💡 In One Line -*** RTL is a lightweight, static library that enables a robust, type-safe runtime reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance. *** +***RTL is a lightweight, static library that enables a robust, type-safe runtime reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance.*** [![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) From 125b2f5528560308e98e3fb6544647e522ede842 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 1 Nov 2025 19:41:01 +0530 Subject: [PATCH 124/148] Updated Readme, action yml. --- .github/workflows/build.yml | 4 ++-- README.md | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68304f36..fbb3a500 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,11 +2,11 @@ name: RTL Build on: push: - branches: [ release ] + branches: [ release, develop ] paths-ignore: - '**/*.md' pull_request: - branches: [ release ] + branches: [ release, develop ] paths-ignore: - '**/*.md' workflow_dispatch: diff --git a/README.md b/README.md index b22a75af..0f0a2c22 100644 --- a/README.md +++ b/README.md @@ -2,27 +2,29 @@ **Reflection Template Library (RTL)** brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. -🪞 What is “Reflection”? — Reflection lets you intract with code *by name* instead of *by type*. -Imagine you’ve written a simple function, +🪞 What's “Reflection” ? +Reflection lets you interact with code by `name` instead of by `type`. Imagine you’ve written a simple function, ```c++ std::string GetAsString(int num); ``` **RTL** lets you call it dynamically: ```c++ -rtl::function toStr = cxx_mirror.getFunction("GetAsString") //cxx_mirror?? see quick-preview! +rtl::function toStr = cxx_mirror.getFunction("GetAsString") // cxx_mirror?? see quick preview! ->argsT() .returnT(); -std::string result = toStr(69375); // Works! +if(toStr) { // All's well? + std::string result = toStr(69375); // Works! +} ``` -**No includes | No compile-time type knowledge | Just runtime lookup & type-safe invocation**. +**No includes. No compile-time linking. Just run-time lookup & type-safe invocation**. -⚡ Performance? Overhead? Practically none. -This RTL reflective call is just a native function pointer hop — faster than `std::function`. Yes! `rtl::function` is faster than `std::function`. +⚡ Performance! +Overhead? Practically none. **RTL**'s reflective calls — when return and argument types are known — are just a native function-pointer hop, often faster than `std::function`. +Yes! `rtl::function` is faster than `std::function`. RTL performs reflective invocations — for free functions, methods, constructors — at near-zero cost, even when types are unknown at compile time. 💡 In One Line - ***RTL is a lightweight, static library that enables a robust, type-safe runtime reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance.*** [![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) From 0bdd773317d58daa569c6e863348e71c79fdcfb2 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 1 Nov 2025 19:47:59 +0530 Subject: [PATCH 125/148] Updated Readme. --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f0a2c22..383601c6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ **Reflection Template Library (RTL)** brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. -🪞 What's “Reflection” ? +🪞 What's “Reflection”? + Reflection lets you interact with code by `name` instead of by `type`. Imagine you’ve written a simple function, ```c++ std::string GetAsString(int num); @@ -19,12 +20,15 @@ if(toStr) { // All's well? **No includes. No compile-time linking. Just run-time lookup & type-safe invocation**. ⚡ Performance! + Overhead? Practically none. **RTL**'s reflective calls — when return and argument types are known — are just a native function-pointer hop, often faster than `std::function`. + Yes! `rtl::function` is faster than `std::function`. RTL performs reflective invocations — for free functions, methods, constructors — at near-zero cost, even when types are unknown at compile time. 💡 In One Line + ***RTL is a lightweight, static library that enables a robust, type-safe runtime reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance.*** [![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) From 5286a9fca11e67765a45a2c59c12a5b2916687b3 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sun, 2 Nov 2025 10:41:04 +0530 Subject: [PATCH 126/148] Updated Readme. --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 383601c6..4742aaa3 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ # Reflection Template Library - Modern C++ Reflection Framework -**Reflection Template Library (RTL)** brings rich runtime reflection to modern C++ — combining compile-time safety with runtime flexibility. +**Reflection Template Library (RTL)** brings rich run-time reflection to modern C++ — combining compile-time safety with run-time flexibility. 🪞 What's “Reflection”? Reflection lets you interact with code by `name` instead of by `type`. Imagine you’ve written a simple function, ```c++ -std::string GetAsString(int num); +std::string complexToStr(float real, float img); ``` **RTL** lets you call it dynamically: ```c++ -rtl::function toStr = cxx_mirror.getFunction("GetAsString") // cxx_mirror?? see quick preview! - ->argsT() - .returnT(); -if(toStr) { // All's well? - std::string result = toStr(69375); // Works! +rtl::function cToStr = cxx_mirror.getFunction("complexToStr") // cxx_mirror?? see quick preview! + ->argsT() + .returnT(); +if(cToStr) { // All's well? + std::string result = cToStr(61, 35); // Works! (int → float? No problem.) } ``` -**No includes. No compile-time linking. Just run-time lookup & type-safe invocation**. +*No includes. No compile-time linking. No argument type-casting. No guess work. Just run-time lookup & type-safe invocation*. ⚡ Performance! @@ -29,7 +29,7 @@ RTL performs reflective invocations — for free functions, methods, constructor 💡 In One Line -***RTL is a lightweight, static library that enables a robust, type-safe runtime reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance.*** +***"RTL is a lightweight, static library that enables a robust, type-safe run-time reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance."*** [![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) @@ -72,7 +72,7 @@ auto cxx_mirror = rtl::CxxMirror({ }); ``` -With just this much, you’ve registered your types and unlocked full runtime reflection. The `cxx_mirror` object is your gateway to query, introspect, and instantiate types at runtime — all without compile-time knowledge of those types, without strict static coupling. +With just this much, you’ve registered your types and unlocked full run-time reflection. The `cxx_mirror` object is your gateway to query, introspect, and instantiate types at run-time — all without compile-time knowledge of those types, without strict static coupling. **Without reflection:** @@ -128,7 +128,7 @@ RTL lets you create reflected objects on the `Heap` or `Stack` with automatic li * Return values — All returns are propagated back wrapped in `rtl::RObject`, cleaned up automatically at scope exit. -RTL doesn’t invent a new paradigm — it extends C++ itself. You create objects, call methods, and work with types as usual, but now safely at runtime. +RTL doesn’t invent a new paradigm — it extends C++ itself. You create objects, call methods, and work with types as usual, but now safely at run-time. ## Reflection Features From ab3b9cca62897bee488da1c6fd9e85b6951590b1 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sun, 2 Nov 2025 20:36:05 +0530 Subject: [PATCH 127/148] static_method test cases, error-codes, doc. --- README.md | 9 +- .../StrictStaticTypeDispatch_StaticMethod.cpp | 111 ++++++++++++++++++ .../rtl/detail/inc/FunctionCaller.hpp | 47 +++++--- .../rtl/detail/inc/MethodInvoker.hpp | 24 ++-- .../rtl/dispatch/rtl_function.h | 6 + .../rtl/dispatch/rtl_function_erased_return.h | 9 +- .../rtl/dispatch/rtl_method.h | 3 + .../rtl/dispatch/rtl_method_const.h | 3 + .../rtl/dispatch/rtl_method_erased.h | 3 +- .../rtl/dispatch/rtl_method_erased_return.h | 4 +- .../dispatch/rtl_method_erased_return_const.h | 4 +- .../rtl/dispatch/rtl_method_erased_target.h | 4 +- ReflectionTemplateLib/rtl/rtl_errors.h | 9 +- ReflectionTemplateLib/rtl/rtl_forward_decls.h | 13 +- 14 files changed, 207 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 4742aaa3..377b4e92 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Reflection Template Library - Modern C++ Reflection Framework +# Reflection Template Library (RTL) — A Modern C++ Run-Time Reflection Framework -**Reflection Template Library (RTL)** brings rich run-time reflection to modern C++ — combining compile-time safety with run-time flexibility. +**RTL** brings rich, type-safe run-time reflection to modern C++ — combining compile-time guarantees with run-time flexibility. 🪞 What's “Reflection”? @@ -13,11 +13,12 @@ std::string complexToStr(float real, float img); rtl::function cToStr = cxx_mirror.getFunction("complexToStr") // cxx_mirror?? see quick preview! ->argsT() .returnT(); -if(cToStr) { // All's well? +if(cToStr) { // Function found? std::string result = cToStr(61, 35); // Works! (int → float? No problem.) } ``` -*No includes. No compile-time linking. No argument type-casting. No guess work. Just run-time lookup & type-safe invocation*. +*No includes. No compile-time linking. No argument type-casting. No guess work.* +*Just run-time lookup and type-safe invocation*. ⚡ Performance! diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index 33c93502..bf1c19a7 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -10,6 +10,57 @@ using namespace test_mirror; namespace rtl_tests { + TEST(StrictStaticTypeRtl_static_method, using_wrong_class_n_callable_apis_for_static_method) + { + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); // has only static-methods. + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); + } { + rtl::function reverse_string = static_cast(reverseString.value()) + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); + } + } { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); // doesn't have any static-methods. + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidNonStaticMethodCaller); + } { + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); // doesn't have any static-methods. + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + EXPECT_FALSE(reverse_string); + EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidNonStaticMethodCaller); + } + } + } + + TEST(StrictStaticTypeRtl_static_method, overload_resolution_with_known_signatures) { std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); @@ -70,4 +121,64 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } } + + + TEST(StrictStaticTypeRtl_static_method, lvalue_ref_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + //non-const target. + StringM target; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + //argument lvalue-ref + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + std::string lv_str = STRA; + std::string ret_str = reverse_string(lv_str); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_lvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + //argument const-lvalue-ref + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + const std::string lv_str = STRA; + std::string ret_str = reverse_string(lv_str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_clvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + //argument lvalue-ref + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + std::string lv_str = STRA; + std::string ret_str = reverse_string(lv_str); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_lvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + //argument const-lvalue-ref + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + //const-target. + const StringM& c_target = target; + std::string lv_str = STRA; + + std::string ret_str = reverse_string(lv_str); + + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_clvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } + } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index fa461deb..f59daefd 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -54,7 +54,7 @@ namespace rtl::detail template requires (member_kind == member::Static && std::is_same_v) inline constexpr const static_method HopFunction::returnT() const { - static_method erasedFn; + static_method...)> erasedFn; initHopper(erasedFn); return erasedFn; } @@ -63,15 +63,22 @@ namespace rtl::detail template requires (member_kind == member::Static && !std::is_same_v) inline constexpr const static_method HopFunction::returnT() const { - const auto retId = traits::uid::value; + static_method fn; if (!m_argsTfnMeta.is_empty()) { - return m_argsTfnMeta.get_lambda() - .template to_function() - .template get_hopper(retId) - .f_ptr(); + if (m_argsTfnMeta.get_member_kind() != member::Static) { + fn.set_init_error(error::InvalidNonStaticMethodCaller); + } + else if (m_argsTfnMeta.get_member_kind() == member::Static) { + + const auto retId = traits::uid::value; + return m_argsTfnMeta.get_lambda() + .template to_function() + .template get_hopper(retId) + .f_ptr(); + } } - return static_method(); + return fn; } @@ -79,14 +86,21 @@ namespace rtl::detail template requires (member_kind == member::None && !std::is_same_v) inline constexpr const function HopFunction::returnT() const { - const auto retId = traits::uid::value; + function fn; if (!m_argsTfnMeta.is_empty()) { - return m_argsTfnMeta.get_lambda() - .template to_function() - .template get_hopper(retId); + if (m_argsTfnMeta.get_member_kind() == member::Static) { + fn.set_init_error(error::InvalidStaticMethodCaller); + } + else if (m_argsTfnMeta.get_member_kind() == member::None) { + + const auto retId = traits::uid::value; + return m_argsTfnMeta.get_lambda() + .template to_function() + .template get_hopper(retId); + } } - return function(); + return fn; } @@ -104,6 +118,11 @@ namespace rtl::detail continue; } + if (fnMeta.get_member_kind() != member::None && fnMeta.get_member_kind() != member::Static) { + pHopFn.set_init_error(error::InvalidNonStaticMethodCaller); + return; + } + auto& erasedRetFn = fnMeta.get_erasure_base() .template to_erased_return...>(); if (fnMeta.is_void()) { @@ -114,6 +133,7 @@ namespace rtl::detail pHopFn.get_rhop().push_back(erasedRetFn.get_return_hopper()); } pHopFn.get_overloads().push_back(&fnMeta.get_lambda()); + pHopFn.set_init_error(error::None); } if (isReturnTvoid) { pHopFn.get_rhop().clear(); @@ -121,9 +141,6 @@ namespace rtl::detail else { pHopFn.get_vhop().clear(); } - if (pHopFn) { - pHopFn.set_init_error(error::None); - } } diff --git a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp index 4de97d9c..ed22e853 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/MethodInvoker.hpp @@ -172,14 +172,21 @@ namespace rtl::detail template requires (traits::type_aware_v) inline constexpr const method HopMethod::returnT() const { - if (!m_argsTfnMeta.is_empty() && m_argsTfnMeta.get_member_kind() != member::Static) + method mth; + if (!m_argsTfnMeta.is_empty()) { - const auto retId = traits::uid::value; - return m_argsTfnMeta.get_lambda() - .template to_method() - .template get_hopper(retId); + if (m_argsTfnMeta.get_member_kind() == member::Static) { + mth.set_init_error(error::InvalidStaticMethodCaller); + } + else { + + const auto retId = traits::uid::value; + return m_argsTfnMeta.get_lambda() + .template to_method() + .template get_hopper(retId); + } } - return method(); + return mth; } @@ -275,7 +282,7 @@ namespace rtl::detail pMth.get_rhop().push_back(erasedFn.get_return_hopper()); } pMth.get_overloads().push_back(&fnMeta.get_lambda()); - + pMth.set_init_error(error::None); } if (isReturnTvoid) { pMth.get_rhop().clear(); @@ -283,8 +290,5 @@ namespace rtl::detail else { pMth.get_vhop().clear(); } - if (pMth) { - pMth.set_init_error(error::None); - } } } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h index 1e654dd3..b536296f 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function.h @@ -58,6 +58,9 @@ namespace rtl void set_init_error(error p_err) { m_init_err = p_err; } + + template + friend struct detail::HopFunction; }; } @@ -78,5 +81,8 @@ namespace rtl static_method& operator=(static_method&&) = default; static_method& operator=(const static_method&) = default; + + template + friend struct detail::HopFunction; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h index 00eefe05..939a9b41 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_function_erased_return.h @@ -95,7 +95,9 @@ namespace rtl } constexpr operator bool() const noexcept { - return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + return !(m_init_err != error::None || m_lambdas.empty() || + (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } constexpr bool must_bind_refs() const noexcept { @@ -147,5 +149,8 @@ namespace rtl { template struct static_method : function - { }; + { + template + friend struct detail::HopFunction; + }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h index f920da65..506001bd 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method.h @@ -77,5 +77,8 @@ namespace rtl void set_init_error(error p_err) { m_init_err = p_err; } + + template + friend struct detail::HopMethod; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h index 9d0e90ad..4f5ac8c9 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_const.h @@ -72,5 +72,8 @@ namespace rtl void set_init_error(error p_err) { m_init_err = p_err; } + + template + friend struct detail::HopMethod; }; } \ No newline at end of file diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h index 7ee112fb..6fd94f0e 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased.h @@ -116,7 +116,8 @@ namespace rtl } constexpr operator bool() const noexcept { - return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + return !(m_init_err != error::None || m_lambdas.empty() || + (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); } constexpr bool must_bind_refs() const noexcept { diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h index 1c82914f..35c9ae42 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return.h @@ -116,7 +116,9 @@ namespace rtl } constexpr operator bool() const noexcept { - return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + return !(m_init_err != error::None || m_lambdas.empty() || + (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } constexpr bool must_bind_refs() const noexcept { diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h index 0cbfc5f4..eebd801d 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_return_const.h @@ -106,7 +106,9 @@ namespace rtl } constexpr operator bool() const noexcept { - return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + return !(m_init_err != error::None || m_lambdas.empty() || + (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } constexpr bool must_bind_refs() const noexcept { diff --git a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h index cd637dff..bd206ced 100644 --- a/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h +++ b/ReflectionTemplateLib/rtl/dispatch/rtl_method_erased_target.h @@ -100,7 +100,9 @@ namespace rtl } constexpr operator bool() const noexcept { - return !(m_lambdas.empty() || (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + return !(m_init_err != error::None || m_lambdas.empty() || + (m_lambdas.size() == 1 && m_lambdas[0] == nullptr)); + } constexpr bool must_bind_refs() const noexcept { diff --git a/ReflectionTemplateLib/rtl/rtl_errors.h b/ReflectionTemplateLib/rtl/rtl_errors.h index 4451d86d..0e707e99 100644 --- a/ReflectionTemplateLib/rtl/rtl_errors.h +++ b/ReflectionTemplateLib/rtl/rtl_errors.h @@ -27,6 +27,7 @@ namespace rtl RefBindingMismatch, ExplicitRefBindingRequired, InvalidStaticMethodCaller, + InvalidNonStaticMethodCaller, CloningDisabled, //Used only in case of cloning is disabled e.g, unregistered type returnd from a function. FunctionNotRegistered, //Not used by RTL at all, for external purpose only. @@ -49,14 +50,18 @@ namespace rtl return "No error (operation successful)"; case error::EmptyRObject: return "Empty instance: RObject does not hold any reflected object"; - case error::InvalidCaller: - return "Invalid callable: rtl::function/rtl::method object bieng used is empty."; case error::SignatureMismatch: return "Signature mismatch: Function parameters do not match the expected signature"; case error::RefBindingMismatch: return "Reference binding mismatch: Argument references do not match the expected parameter bindings"; case error::ExplicitRefBindingRequired: return "Explicit reference binding required for correct overload resolution"; + case error::InvalidCaller: + return "Invalid callable: rtl::function/rtl::method object being used is empty."; + case error::InvalidStaticMethodCaller: + return "Invalid callable: rtl::method being used to call a static method; use rtl::static_method instead."; + case error::InvalidNonStaticMethodCaller: + return "Invalid callable: rtl::static_method being used to call a non-static method; use rtl::method instead."; case error::CloningDisabled: return "Type not registered: The requested type is not explicitly registered in the Reflection system"; case error::FunctionNotRegistered: diff --git a/ReflectionTemplateLib/rtl/rtl_forward_decls.h b/ReflectionTemplateLib/rtl/rtl_forward_decls.h index 7c3e70fb..5fdfc56a 100644 --- a/ReflectionTemplateLib/rtl/rtl_forward_decls.h +++ b/ReflectionTemplateLib/rtl/rtl_forward_decls.h @@ -40,23 +40,26 @@ namespace rtl struct RObjectId; - template + template class FunctorContainer; - template + template struct ErasedCaller; - template + template struct ErasedInvoker; template class SetupMethod; - template + template struct Hopper; - template + template struct HopFunction; + + template + struct HopMethod; } namespace cache From 1932383833c4ad28e0d6f99444a5b49b1f62235c Mon Sep 17 00:00:00 2001 From: Neeraj Date: Sun, 2 Nov 2025 21:57:13 +0530 Subject: [PATCH 128/148] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 377b4e92..95fe4dff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Reflection Template Library (RTL) — A Modern C++ Run-Time Reflection Framework -**RTL** brings rich, type-safe run-time reflection to modern C++ — combining compile-time guarantees with run-time flexibility. +**RTL** brings rich, type-safe run-time reflection to modern C++ — combining compile-time safety with run-time flexibility. 🪞 What's “Reflection”? @@ -18,6 +18,7 @@ if(cToStr) { // Function found? } ``` *No includes. No compile-time linking. No argument type-casting. No guess work.* + *Just run-time lookup and type-safe invocation*. ⚡ Performance! From 7fca65c7b717859e152953151d916be2b977ff46 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Sun, 2 Nov 2025 23:01:00 +0530 Subject: [PATCH 129/148] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 95fe4dff..c6518675 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,11 @@ std::string complexToStr(float real, float img); rtl::function cToStr = cxx_mirror.getFunction("complexToStr") // cxx_mirror?? see quick preview! ->argsT() .returnT(); -if(cToStr) { // Function found? +if(cToStr) { // Function materialized? std::string result = cToStr(61, 35); // Works! (int → float? No problem.) } ``` *No includes. No compile-time linking. No argument type-casting. No guess work.* - *Just run-time lookup and type-safe invocation*. ⚡ Performance! From 422906a3bcb8093abc9ddeccf5765900285f89ee Mon Sep 17 00:00:00 2001 From: Neeraj Date: Sun, 2 Nov 2025 23:59:49 +0530 Subject: [PATCH 130/148] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c6518675..f46ee661 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,10 @@ if(cToStr) { // Function materialized? Overhead? Practically none. **RTL**'s reflective calls — when return and argument types are known — are just a native function-pointer hop, often faster than `std::function`. -Yes! `rtl::function` is faster than `std::function`. +Yes — `rtl::function` is faster than `std::function`. -RTL performs reflective invocations — for free functions, methods, constructors — at near-zero cost, even when types are unknown at compile time. +Microbenchmarks show reflective invocations through `rtl::function` have lower call overhead — a single, native pointer jump with no extra indirection. +Once the functions start doing real work, both perform identically — always, under all conditions. 💡 In One Line From ab87b866b82f4345b6a41f701262816e20d3a5f1 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 3 Nov 2025 09:56:07 +0530 Subject: [PATCH 131/148] added test case, readme update. --- README.md | 23 ++++++++----------- .../StrictStaticTypeDispatch_StaticMethod.cpp | 20 ++++++++++++++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f46ee661..6574fe19 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ **RTL** brings rich, type-safe run-time reflection to modern C++ — combining compile-time safety with run-time flexibility. -🪞 What's “Reflection”? +[![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) + +### 🪞 What’s “Reflection”? Reflection lets you interact with code by `name` instead of by `type`. Imagine you’ve written a simple function, ```c++ @@ -17,28 +19,23 @@ if(cToStr) { // Function materialized? std::string result = cToStr(61, 35); // Works! (int → float? No problem.) } ``` -*No includes. No compile-time linking. No argument type-casting. No guess work.* +*No includes. No compile-time linking. No argument type-casting. No guesswork.* *Just run-time lookup and type-safe invocation*. -⚡ Performance! +### ⚡ Performance! -Overhead? Practically none. **RTL**'s reflective calls — when return and argument types are known — are just a native function-pointer hop, often faster than `std::function`. +Overhead? Practically none. **RTL**’s reflective calls — when return and argument types are known — are just a native function-pointer hop, often faster than `std::function`. Yes — `rtl::function` is faster than `std::function`. Microbenchmarks show reflective invocations through `rtl::function` have lower call overhead — a single, native pointer jump with no extra indirection. Once the functions start doing real work, both perform identically — always, under all conditions. -💡 In One Line +### 💡 In One Line ***"RTL is a lightweight, static library that enables a robust, type-safe run-time reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance."*** -[![CMake](https://img.shields.io/badge/CMake-Enabled-brightgreen)](https://cmake.org) [![C++20](https://img.shields.io/badge/C++-20-blue)](https://isocpp.org) [![RTL Build](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml/badge.svg?branch=release)](https://github.com/ReflectCxx/ReflectionTemplateLibrary-CPP/actions/workflows/build.yml?query=branch%3Arelease) [![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE) - - -## What RTL Brings to Your Code - -* ***Runtime Reflection for C++*** – Introspect and manipulate objects dynamically, similar to Java or .NET, but with modern C++ idioms. +## What’s more? * ***Single Source of Truth*** – All metadata lives in one immutable `rtl::CxxMirror`, ensuring a consistent, thread-safe, duplication-free, and deterministic view of reflection data. @@ -63,7 +60,7 @@ Once the functions start doing real work, both perform identically — always, u ```c++ #include "RTLibInterface.h" // Reflection access interface. ``` -Create an instance of `CxxMirror`, passing all type information directly to its constructor — and you're done! +Create an instance of `CxxMirror`, passing all type information directly to its constructor — and you’re done! ```c++ auto cxx_mirror = rtl::CxxMirror({ /* ...register all types here... */ @@ -154,7 +151,7 @@ RTL doesn’t invent a new paradigm — it extends C++ itself. You create object * ✅ **Perfect Forwarding** 🚀 – Binds LValue/RValue to correct overload. * ✅ **Zero Overhead Forwarding** ⚡ – No temporaries or copies during method forwarding. * ✅ **Namespace Support** 🗂️ – Group and reflect under namespaces. -* ✅ **Reflected Returns** 🔍 – Access return values whose types are unknown at compile time. Validate against the expected type and use them as if the type was known all along. +* ✅ **Reflected Returns** 🔍 – Access return values whose types are unknown at compile-time. Validate against the expected type and use them as if the type was known all along. * ✅ **Smart Pointer Reflection** 🔗 – Reflect `std::shared_ptr` and `std::unique_ptr`, transparently access the underlying type, and benefit from automatic lifetime management with full sharing and cloning semantics. * 🟨 **Conservative Conversions** 🛡️ – Safely reinterpret reflected values without hidden costs. For example: treat an `int` as a `char`, or a `std::string` as a `std::string_view` / `const char*` — with no hidden copies and only safe, non-widening POD conversions. *(In Progress)* * 🟨 **Materialize New Types** 🔄 – Convert a reflected type `A` into type `B` if they are implicitly convertible. Define custom conversions at registration to make them available automatically. *(In Progress)* diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index bf1c19a7..47d16b94 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -181,4 +181,24 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } } + + + TEST(StrictStaticTypeRtl_static_method, rvalue_ref_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(STRA); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_rvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } + } } \ No newline at end of file From 0e6d7029d8ce13c8cd023a0b16c8e9fe260978c7 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Mon, 3 Nov 2025 14:53:44 +0530 Subject: [PATCH 132/148] all test cases passing now. --- README.md | 4 +- .../PerfectForwardingTests.cpp | 13 +++- .../FunctionalityTests/StaticMethodTests.cpp | 76 ++++++++++--------- .../StrictStaticTypeDispatch_StaticMethod.cpp | 30 ++++++++ .../MyReflectionTests/MyReflectionTests.cpp | 22 ------ 5 files changed, 82 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 6574fe19..d9d55499 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,14 @@ if(cToStr) { // Function materialized? *No includes. No compile-time linking. No argument type-casting. No guesswork.* *Just run-time lookup and type-safe invocation*. -### ⚡ Performance! +### ⚡ Performance Overhead? Practically none. **RTL**’s reflective calls — when return and argument types are known — are just a native function-pointer hop, often faster than `std::function`. Yes — `rtl::function` is faster than `std::function`. Microbenchmarks show reflective invocations through `rtl::function` have lower call overhead — a single, native pointer jump with no extra indirection. -Once the functions start doing real work, both perform identically — always, under all conditions. +Once the functions start doing real work, both perform identically. ### 💡 In One Line diff --git a/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp b/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp index 5b3aeab8..642d0b2c 100644 --- a/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp @@ -321,8 +321,11 @@ namespace rtl_tests const auto& isValid = updateZooKeeper->hasSignature(); EXPECT_TRUE(isValid); - const auto zookeeper = std::string(animal::ZOO_KEEPER); - auto [err, ret] = updateZooKeeper->bind()(zookeeper); + rtl::static_method updateZooKeeperMth = updateZooKeeper.value() + .argsT() + .returnT<>(); + + auto [err, ret] = updateZooKeeperMth.bind()(animal::ZOO_KEEPER); EXPECT_TRUE(err == error::None); ASSERT_FALSE(ret.isEmpty()); @@ -349,8 +352,10 @@ namespace rtl_tests const auto& isValid = updateZooKeeper->hasSignature(); EXPECT_TRUE(isValid); - auto zookeeper = std::string(animal::ZOO_KEEPER); - auto [err, ret] = updateZooKeeper->bind()(zookeeper); + rtl::static_method updateZooKeeperMth = updateZooKeeper.value() + .argsT() + .returnT<>(); + auto [err, ret] = updateZooKeeperMth.bind()(animal::ZOO_KEEPER); EXPECT_TRUE(err == error::None); ASSERT_FALSE(ret.isEmpty()); diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp index db6de258..7de57a83 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp @@ -112,25 +112,30 @@ namespace rtl_tests optional classPerson = cxx::mirror().getRecord(person::class_); ASSERT_TRUE(classPerson); - optional getDefaults = classPerson->getMethod(person::str_getDefaults); - ASSERT_TRUE(getDefaults); - EXPECT_TRUE(getDefaults->hasSignature<>()); //empty template params checks for zero arguments. + optional getDefaultsOpt = classPerson->getMethod(person::str_getDefaults); + ASSERT_TRUE(getDefaultsOpt); + EXPECT_TRUE(getDefaultsOpt->hasSignature<>()); //empty template params checks for zero arguments. + { + rtl::method getDefaults = getDefaultsOpt.value().targetT().argsT().returnT(); - auto [err0, person] = classPerson->create(); + EXPECT_FALSE(getDefaults); + EXPECT_EQ(getDefaults.get_init_error(), error::InvalidStaticMethodCaller); - EXPECT_TRUE(err0 == error::None); - ASSERT_FALSE(person.isEmpty()); - { - auto [err, ret] = getDefaults->bind(person).call(); - EXPECT_TRUE(err == error::None); - ASSERT_FALSE(ret.isEmpty()); - EXPECT_TRUE(ret.canViewAs()); + auto [err0, person] = classPerson->create(); - auto& retStr = ret.view()->get(); - EXPECT_EQ(retStr, person::get_str_returned_on_call_getDefaults()); + EXPECT_EQ(err0, error::None); + ASSERT_FALSE(person.isEmpty()); + + auto [err, ret] = getDefaults(person)(); + + EXPECT_EQ(err, error::InvalidStaticMethodCaller); + EXPECT_TRUE(ret.isEmpty()); } { - auto [err, ret] = getDefaults->bind(person).call(); - EXPECT_TRUE(err == error::None); + rtl::static_method getDefaults = getDefaultsOpt.value().argsT().returnT(); + + auto [err, ret] = getDefaults(); + + EXPECT_EQ(err, error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); @@ -145,38 +150,39 @@ namespace rtl_tests optional classPerson = cxx::mirror().getRecord(person::class_); ASSERT_TRUE(classPerson); - auto [err0, person] = classPerson->create(); + optional getProfileOpt = classPerson->getMethod(person::str_getProfile); + ASSERT_TRUE(getProfileOpt); + EXPECT_TRUE((getProfileOpt->hasSignature())); - EXPECT_TRUE(err0 == error::None); - ASSERT_FALSE(person.isEmpty()); - - optional getProfile = classPerson->getMethod(person::str_getProfile); - ASSERT_TRUE(getProfile); - EXPECT_TRUE((getProfile->hasSignature())); - - size_t age = person::AGE; - string occupation = person::OCCUPATION; { - auto [err, ret] = getProfile->bind(person).call(occupation, age); + rtl::method getProfile = getProfileOpt.value() + .targetT() + .argsT() + .returnT(); + EXPECT_FALSE(getProfile); + EXPECT_EQ(getProfile.get_init_error(), error::InvalidStaticMethodCaller); - EXPECT_TRUE(err == error::None); - ASSERT_FALSE(ret.isEmpty()); - EXPECT_TRUE(ret.canViewAs()); + auto [err0, person] = classPerson->create(); - const string& retStr = ret.view()->get(); - const string& checkStr = person::get_str_returned_on_call_getProfile(); + EXPECT_EQ(err0, error::None); + ASSERT_FALSE(person.isEmpty()); - EXPECT_EQ(retStr, checkStr); + auto [err, ret] = getProfile(person)(person::OCCUPATION, person::AGE); + + EXPECT_EQ(err, error::InvalidStaticMethodCaller); + ASSERT_TRUE(ret.isEmpty()); } { - auto [err, ret] = getProfile->bind(person).call(occupation, age); + rtl::static_method getProfile = getProfileOpt.value() + .argsT() + .returnT(); + auto [err, ret] = getProfile(person::OCCUPATION, person::AGE); - EXPECT_TRUE(err == error::None); + EXPECT_EQ(err, error::None); ASSERT_FALSE(ret.isEmpty()); EXPECT_TRUE(ret.canViewAs()); const string& retStr = ret.view()->get(); const string& checkStr = person::get_str_returned_on_call_getProfile(); - EXPECT_EQ(retStr, checkStr); } } diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index 47d16b94..0e7d9042 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -201,4 +201,34 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } } + + + TEST(StrictStaticTypeRtl_static_method, ptr_and_const_ptr_overload_resolution_with_known_signatures) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + std::string str = STRA; + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(&str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(&str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_cptr + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } + } } \ No newline at end of file diff --git a/RTLTestRunApp/src/MyReflectionTests/MyReflectionTests.cpp b/RTLTestRunApp/src/MyReflectionTests/MyReflectionTests.cpp index b076085f..33b7738e 100644 --- a/RTLTestRunApp/src/MyReflectionTests/MyReflectionTests.cpp +++ b/RTLTestRunApp/src/MyReflectionTests/MyReflectionTests.cpp @@ -176,28 +176,6 @@ namespace std::optional> strView = ret.view(); ASSERT_TRUE(strView); - const std::string& retStr = strView->get(); - // Confirms the expected static function was invoked. - EXPECT_EQ(retStr, expectReturnStr); - } { - // Now create a `Person` object and reflect it into RTL. - rtl::RObject robj = rtl::reflect(Person("")); - - // Even if we bind a target object before calling the static function, - // it has no effect — the call remains valid and succeeds. - // This matches C++ native semantics: binding an instance is irrelevant - // for static member functions. - auto [err, ret] = getDefaults->bind(robj).call(); - - // Validate reflective call succeeded. - EXPECT_TRUE(err == rtl::error::None); - EXPECT_FALSE(ret.isEmpty()); - - // Verify return type and extract result. - EXPECT_TRUE(ret.canViewAs()); - std::optional> strView = ret.view(); - ASSERT_TRUE(strView); - const std::string& retStr = strView->get(); // Confirms the expected static function was invoked. EXPECT_EQ(retStr, expectReturnStr); From 0250333f2b9119a91a101f7bd5ed6272fd660be9 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Mon, 3 Nov 2025 17:09:52 +0530 Subject: [PATCH 133/148] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76f30079..df999f59 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ if(cToStr) { // Function materialized? Overhead? Practically none. **RTL**’s reflective calls — when return and argument types are known — are just a native function-pointer hop, often faster than `std::function`. -Yes — `rtl::function` is faster than `std::function`. +Yes — `rtl::function`’s dispatch is faster than `std::function`. Microbenchmarks show reflective invocations through `rtl::function` have lower call overhead — a single, native pointer jump with no extra indirection. Once the functions start doing real work, both perform identically. From 1d29859a6960cf5237ad8ba8c63c01c4bb891b07 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Tue, 4 Nov 2025 11:04:25 +0530 Subject: [PATCH 134/148] static_method, known args/return type tests. done. --- README.md | 8 +- .../StrictStaticTypeDispatch_StaticMethod.cpp | 140 +++++++++++++++++- 2 files changed, 141 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index df999f59..112c40f9 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ std::string complexToStr(float real, float img); ``` **RTL** lets you call it dynamically: ```c++ -rtl::function cToStr = cxx_mirror.getFunction("complexToStr") // cxx_mirror?? see quick preview! - ->argsT() - .returnT(); +rtl::function cToStr = cxx::mirror().getFunction("complexToStr") // cxx::mirror?? see quick preview! + ->argsT() + .returnT(); if(cToStr) { // Function materialized? std::string result = cToStr(61, 35); // Works! (int → float? No problem.) } @@ -44,8 +44,6 @@ Once the functions start doing real work, both perform identically. * ***Exception-Free Surface*** – All predictable failures return error codes; no hidden throws. -* ***Deterministic Lifetimes*** – Automatic ownership tracking of `Heap` and `Stack` instances with zero hidden deep copies. - * ***Cross-Compiler Consistency*** – Pure standard C++20, with no compiler extensions or conditional branching on compiler differences. * ***Tooling-Friendly Architecture*** – Reflection data is encapsulated in a single immutable, lazily-initialized object that can be shared with tools and frameworks without compile-time type knowledge — ideal for serializers, debuggers, test frameworks, scripting engines, and editors. diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index 0e7d9042..329f684e 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -222,8 +222,8 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } { rtl::static_method reverse_string = reverseString.value() - .argsT() - .returnT(); + .argsT() + .returnT(); ASSERT_TRUE(reverse_string); std::string ret_str = reverse_string(&str); @@ -231,4 +231,140 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } } + + + TEST(StrictStaticTypeRtl_static_method, distinct_functions_with_ref_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + std::string str = STRA; + { + std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); + ASSERT_TRUE(reverseString); + + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); + ASSERT_TRUE(reverseString); + + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + auto lvstr = std::string_view(str); + std::string ret_str = reverse_string(lvstr); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); + ASSERT_TRUE(reverseString); + + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(str)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_rvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_static_method, overloads_with_ref_and_value_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); + ASSERT_TRUE(reverseString); + { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string_view str = STRA; + std::string ret_str = reverse_string(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_static_method, overloads_with_const_ref_and_value_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); + ASSERT_TRUE(reverseString); + { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } + } + + + TEST(StrictStaticTypeRtl_static_method, overloads_with_ref_and_const_ref_args_call_with_known_signature) + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); + ASSERT_TRUE(reverseString); + { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string_view str = STRA; + std::string ret_str = reverse_string(str); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT(); + ASSERT_TRUE(reverse_string); + + std::string ret_str = reverse_string(std::string_view(STRA)); + auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref + SUFFIX_static; + EXPECT_EQ(ret_str, exp_str); + } + } } \ No newline at end of file From 7da867a1b4396b5607e21fb09e20a419e3ac8fe4 Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 4 Nov 2025 12:48:06 +0530 Subject: [PATCH 135/148] added latest benchmarks with std::string & std::string_view. --- .../benchmark_return_string_view.log | 1655 --------- .../benchmark_returns_std_string.log | 1655 --------- text-benchmark-logs/benchmark_runs.log | 3167 ----------------- text-benchmark-logs/benchmark_runs_string.log | 3167 +++++++++++++++++ .../benchmark_runs_string_view.log | 3167 +++++++++++++++++ 5 files changed, 6334 insertions(+), 6477 deletions(-) delete mode 100644 text-benchmark-logs/benchmark_return_string_view.log delete mode 100644 text-benchmark-logs/benchmark_returns_std_string.log delete mode 100644 text-benchmark-logs/benchmark_runs.log create mode 100644 text-benchmark-logs/benchmark_runs_string.log create mode 100644 text-benchmark-logs/benchmark_runs_string_view.log diff --git a/text-benchmark-logs/benchmark_return_string_view.log b/text-benchmark-logs/benchmark_return_string_view.log deleted file mode 100644 index 1acdfca7..00000000 --- a/text-benchmark-logs/benchmark_return_string_view.log +++ /dev/null @@ -1,1655 +0,0 @@ -Starting benchmark runs... -Binary: ./bin/RTLBenchmarkApp -Log: ./benchmark_runs.log -=================================== ->>> Run 1: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:26:58+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3673.84 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.50, 0.43, 0.62 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.68 ns 2.68 ns 261129948 -StdFuncCall::noReturn 3.63 ns 3.63 ns 205756521 -ReflectedCall::noReturn 4.56 ns 4.56 ns 152287993 - -StdFuncMethodCall::noReturn 3.66 ns 3.66 ns 190424278 -ReflectedMethodCall::noReturn 7.58 ns 7.58 ns 91861976 --------------------------------------------------------------------------- -DirectCall::withReturn 7.99 ns 7.99 ns 87640884 -StdFuncCall::withReturn 8.19 ns 8.19 ns 85275679 -ReflectedCall::withReturn 16.4 ns 16.4 ns 42162218 - -StdFuncMethodCall::withReturn 8.19 ns 8.19 ns 85314435 -ReflectedMethodCall::withReturn 18.4 ns 18.4 ns 38123916 ------------------------------------ ->>> Run 2: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:27:07+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4900 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.58, 0.45, 0.63 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.68 ns 2.68 ns 261249982 -StdFuncCall::noReturn 3.53 ns 3.53 ns 193958493 -ReflectedCall::noReturn 4.54 ns 4.54 ns 154118128 - -StdFuncMethodCall::noReturn 3.70 ns 3.70 ns 189590103 -ReflectedMethodCall::noReturn 7.66 ns 7.66 ns 92278133 --------------------------------------------------------------------------- -DirectCall::withReturn 7.98 ns 7.98 ns 87518334 -StdFuncCall::withReturn 8.20 ns 8.20 ns 85410105 -ReflectedCall::withReturn 16.5 ns 16.5 ns 42955309 - -StdFuncMethodCall::withReturn 8.19 ns 8.19 ns 85484532 -ReflectedMethodCall::withReturn 18.5 ns 18.5 ns 37798366 ------------------------------------ ->>> Run 3: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:27:17+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4894.06 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.64, 0.47, 0.63 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.68 ns 2.68 ns 262137459 -StdFuncCall::noReturn 3.66 ns 3.66 ns 186118715 -ReflectedCall::noReturn 4.56 ns 4.56 ns 152295433 - -StdFuncMethodCall::noReturn 3.65 ns 3.65 ns 193507678 -ReflectedMethodCall::noReturn 7.68 ns 7.68 ns 89857228 --------------------------------------------------------------------------- -DirectCall::withReturn 7.99 ns 7.99 ns 87152273 -StdFuncCall::withReturn 8.19 ns 8.19 ns 84706545 -ReflectedCall::withReturn 16.3 ns 16.3 ns 42842896 - -StdFuncMethodCall::withReturn 8.19 ns 8.19 ns 84681044 -ReflectedMethodCall::withReturn 18.5 ns 18.5 ns 38078832 ------------------------------------ ->>> Run 4: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:27:26+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3764.4 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.70, 0.48, 0.64 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.69 ns 2.69 ns 261376697 -StdFuncCall::noReturn 3.71 ns 3.71 ns 190913629 -ReflectedCall::noReturn 4.71 ns 4.71 ns 150141200 - -StdFuncMethodCall::noReturn 3.64 ns 3.64 ns 192162902 -ReflectedMethodCall::noReturn 7.67 ns 7.67 ns 90578497 --------------------------------------------------------------------------- -DirectCall::withReturn 8.19 ns 8.19 ns 85408568 -StdFuncCall::withReturn 8.39 ns 8.39 ns 83226473 -ReflectedCall::withReturn 16.7 ns 16.7 ns 41844284 - -StdFuncMethodCall::withReturn 8.39 ns 8.39 ns 83073249 -ReflectedMethodCall::withReturn 18.4 ns 18.4 ns 37663093 ------------------------------------ ->>> Run 5: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:27:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1321.93 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.72, 0.49, 0.64 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.69 ns 2.69 ns 259677166 -StdFuncCall::noReturn 3.63 ns 3.63 ns 190282286 -ReflectedCall::noReturn 4.64 ns 4.64 ns 150576640 - -StdFuncMethodCall::noReturn 3.70 ns 3.70 ns 189991616 -ReflectedMethodCall::noReturn 7.59 ns 7.58 ns 88533673 --------------------------------------------------------------------------- -DirectCall::withReturn 7.98 ns 7.98 ns 86873175 -StdFuncCall::withReturn 8.20 ns 8.20 ns 84535948 -ReflectedCall::withReturn 16.5 ns 16.5 ns 42143122 - -StdFuncMethodCall::withReturn 8.19 ns 8.19 ns 85127244 -ReflectedMethodCall::withReturn 18.7 ns 18.7 ns 37470244 ------------------------------------ ->>> Run 6: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:27:45+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2798.79 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.76, 0.51, 0.64 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.68 ns 2.68 ns 258313912 -StdFuncCall::noReturn 3.45 ns 3.45 ns 202668270 -ReflectedCall::noReturn 4.45 ns 4.45 ns 155726805 - -StdFuncMethodCall::noReturn 3.66 ns 3.66 ns 195257109 -ReflectedMethodCall::noReturn 7.72 ns 7.71 ns 91691488 --------------------------------------------------------------------------- -DirectCall::withReturn 8.40 ns 8.40 ns 83232030 -StdFuncCall::withReturn 8.19 ns 8.19 ns 84719682 -ReflectedCall::withReturn 16.4 ns 16.4 ns 41763228 - -StdFuncMethodCall::withReturn 8.19 ns 8.19 ns 85406769 -ReflectedMethodCall::withReturn 18.5 ns 18.5 ns 38342729 ------------------------------------ ->>> Run 7: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:27:54+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4820.72 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.80, 0.53, 0.65 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.70 ns 2.70 ns 255687919 -StdFuncCall::noReturn 3.80 ns 3.80 ns 192744917 -ReflectedCall::noReturn 4.54 ns 4.54 ns 155638851 - -StdFuncMethodCall::noReturn 3.71 ns 3.71 ns 189990747 -ReflectedMethodCall::noReturn 7.65 ns 7.65 ns 90475902 --------------------------------------------------------------------------- -DirectCall::withReturn 8.41 ns 8.41 ns 82783681 -StdFuncCall::withReturn 8.19 ns 8.19 ns 85113727 -ReflectedCall::withReturn 16.4 ns 16.3 ns 43469078 - -StdFuncMethodCall::withReturn 8.21 ns 8.21 ns 85061209 -ReflectedMethodCall::withReturn 18.4 ns 18.4 ns 38318216 ------------------------------------ ->>> Run 8: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:28:04+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.83, 0.54, 0.65 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.67 ns 2.67 ns 259545419 -StdFuncCall::noReturn 3.68 ns 3.68 ns 186620879 -ReflectedCall::noReturn 4.68 ns 4.68 ns 151229098 - -StdFuncMethodCall::noReturn 3.69 ns 3.69 ns 192148650 -ReflectedMethodCall::noReturn 7.65 ns 7.64 ns 92628011 --------------------------------------------------------------------------- -DirectCall::withReturn 7.98 ns 7.98 ns 87367388 -StdFuncCall::withReturn 8.20 ns 8.20 ns 85464076 -ReflectedCall::withReturn 16.4 ns 16.4 ns 41631547 - -StdFuncMethodCall::withReturn 8.19 ns 8.19 ns 84841078 -ReflectedMethodCall::withReturn 18.5 ns 18.5 ns 38096443 ------------------------------------ ->>> Run 9: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:28:13+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2581.19 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.86, 0.56, 0.66 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.69 ns 2.69 ns 261320876 -StdFuncCall::noReturn 3.76 ns 3.76 ns 183274387 -ReflectedCall::noReturn 4.55 ns 4.55 ns 154257846 - -StdFuncMethodCall::noReturn 3.69 ns 3.69 ns 183824695 -ReflectedMethodCall::noReturn 7.67 ns 7.67 ns 91673266 --------------------------------------------------------------------------- -DirectCall::withReturn 8.39 ns 8.39 ns 82340975 -StdFuncCall::withReturn 8.19 ns 8.19 ns 85259148 -ReflectedCall::withReturn 16.5 ns 16.5 ns 43168408 - -StdFuncMethodCall::withReturn 8.19 ns 8.19 ns 85150908 -ReflectedMethodCall::withReturn 18.4 ns 18.4 ns 38115440 ------------------------------------ ->>> Run 10: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:28:22+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4020.89 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.88, 0.57, 0.66 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.68 ns 2.68 ns 261232254 -StdFuncCall::noReturn 3.75 ns 3.75 ns 187932171 -ReflectedCall::noReturn 4.51 ns 4.51 ns 152128258 - -StdFuncMethodCall::noReturn 3.65 ns 3.64 ns 190154894 -ReflectedMethodCall::noReturn 7.63 ns 7.63 ns 92473165 --------------------------------------------------------------------------- -DirectCall::withReturn 8.40 ns 8.40 ns 83290327 -StdFuncCall::withReturn 8.18 ns 8.18 ns 85083846 -ReflectedCall::withReturn 16.7 ns 16.7 ns 41687403 - -StdFuncMethodCall::withReturn 8.20 ns 8.20 ns 85490157 -ReflectedMethodCall::withReturn 18.5 ns 18.5 ns 38928701 ------------------------------------ ->>> Run 1: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:28:32+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3453.76 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.90, 0.59, 0.66 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 301 ns 301 ns 2303982 -StdFuncCall::noReturn 300 ns 300 ns 2342931 -ReflectedCall::noReturn 306 ns 306 ns 2284404 - -StdFuncMethodCall::noReturn 301 ns 301 ns 2329281 -ReflectedMethodCall::noReturn 309 ns 309 ns 2277267 --------------------------------------------------------------------------- -DirectCall::withReturn 373 ns 373 ns 1874653 -StdFuncCall::withReturn 370 ns 370 ns 1870666 -ReflectedCall::withReturn 385 ns 385 ns 1817975 - -StdFuncMethodCall::withReturn 372 ns 372 ns 1861488 -ReflectedMethodCall::withReturn 387 ns 387 ns 1808677 ------------------------------------ ->>> Run 2: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:28:42+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1209.55 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.92, 0.60, 0.67 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 307 ns 307 ns 2302722 -StdFuncCall::noReturn 305 ns 305 ns 2290835 -ReflectedCall::noReturn 303 ns 303 ns 2297945 - -StdFuncMethodCall::noReturn 306 ns 306 ns 2296470 -ReflectedMethodCall::noReturn 305 ns 305 ns 2290296 --------------------------------------------------------------------------- -DirectCall::withReturn 380 ns 380 ns 1843902 -StdFuncCall::withReturn 430 ns 430 ns 1754632 -ReflectedCall::withReturn 440 ns 440 ns 1589233 - -StdFuncMethodCall::withReturn 431 ns 431 ns 1624807 -ReflectedMethodCall::withReturn 433 ns 433 ns 1611959 ------------------------------------ ->>> Run 3: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:28:54+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.93, 0.62, 0.67 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 298 ns 298 ns 2339343 -StdFuncCall::noReturn 298 ns 298 ns 2362369 -ReflectedCall::noReturn 301 ns 301 ns 2308822 - -StdFuncMethodCall::noReturn 297 ns 297 ns 2342636 -ReflectedMethodCall::noReturn 341 ns 341 ns 2303815 --------------------------------------------------------------------------- -DirectCall::withReturn 425 ns 425 ns 1654379 -StdFuncCall::withReturn 424 ns 424 ns 1650814 -ReflectedCall::withReturn 434 ns 434 ns 1612383 - -StdFuncMethodCall::withReturn 426 ns 426 ns 1639874 -ReflectedMethodCall::withReturn 434 ns 434 ns 1616096 ------------------------------------ ->>> Run 4: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:29:05+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.94, 0.63, 0.67 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 341 ns 341 ns 2060360 -StdFuncCall::noReturn 334 ns 334 ns 2092530 -ReflectedCall::noReturn 336 ns 336 ns 2084367 - -StdFuncMethodCall::noReturn 335 ns 335 ns 2086575 -ReflectedMethodCall::noReturn 344 ns 344 ns 2032773 --------------------------------------------------------------------------- -DirectCall::withReturn 421 ns 421 ns 1662603 -StdFuncCall::withReturn 423 ns 423 ns 1666937 -ReflectedCall::withReturn 431 ns 431 ns 1623342 - -StdFuncMethodCall::withReturn 421 ns 421 ns 1658766 -ReflectedMethodCall::withReturn 433 ns 433 ns 1618268 ------------------------------------ ->>> Run 5: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:29:16+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4781.24 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.03, 0.66, 0.68 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 339 ns 339 ns 2086251 -StdFuncCall::noReturn 334 ns 334 ns 2096201 -ReflectedCall::noReturn 336 ns 336 ns 2079979 - -StdFuncMethodCall::noReturn 335 ns 335 ns 2092323 -ReflectedMethodCall::noReturn 344 ns 344 ns 2037126 --------------------------------------------------------------------------- -DirectCall::withReturn 420 ns 420 ns 1666613 -StdFuncCall::withReturn 420 ns 420 ns 1674857 -ReflectedCall::withReturn 431 ns 431 ns 1620878 - -StdFuncMethodCall::withReturn 420 ns 420 ns 1654424 -ReflectedMethodCall::withReturn 432 ns 432 ns 1616853 ------------------------------------ ->>> Run 1: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:29:27+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2132.68 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.34, 0.74, 0.71 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 901 ns 901 ns 759524 -StdFuncCall::noReturn 906 ns 906 ns 767684 -ReflectedCall::noReturn 912 ns 912 ns 765256 - -StdFuncMethodCall::noReturn 906 ns 906 ns 769566 -ReflectedMethodCall::noReturn 916 ns 916 ns 762842 --------------------------------------------------------------------------- -DirectCall::withReturn 1036 ns 1036 ns 675246 -StdFuncCall::withReturn 1035 ns 1034 ns 675401 -ReflectedCall::withReturn 1048 ns 1048 ns 667279 - -StdFuncMethodCall::withReturn 1035 ns 1034 ns 676395 -ReflectedMethodCall::withReturn 1053 ns 1053 ns 665275 ------------------------------------ ->>> Run 2: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:29:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.32, 0.75, 0.71 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 897 ns 897 ns 759896 -StdFuncCall::noReturn 902 ns 902 ns 776407 -ReflectedCall::noReturn 913 ns 913 ns 769246 - -StdFuncMethodCall::noReturn 902 ns 902 ns 776430 -ReflectedMethodCall::noReturn 919 ns 918 ns 760482 --------------------------------------------------------------------------- -DirectCall::withReturn 1042 ns 1042 ns 671791 -StdFuncCall::withReturn 1041 ns 1041 ns 671217 -ReflectedCall::withReturn 1051 ns 1051 ns 664465 - -StdFuncMethodCall::withReturn 1041 ns 1041 ns 672055 -ReflectedMethodCall::withReturn 1057 ns 1057 ns 661898 ------------------------------------ ->>> Run 3: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:29:43+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1717.77 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.27, 0.76, 0.72 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 895 ns 894 ns 770126 -StdFuncCall::noReturn 902 ns 902 ns 775366 -ReflectedCall::noReturn 911 ns 911 ns 768376 - -StdFuncMethodCall::noReturn 901 ns 901 ns 772646 -ReflectedMethodCall::noReturn 932 ns 932 ns 748823 --------------------------------------------------------------------------- -DirectCall::withReturn 1035 ns 1035 ns 675872 -StdFuncCall::withReturn 1034 ns 1034 ns 672118 -ReflectedCall::withReturn 1052 ns 1052 ns 661468 - -StdFuncMethodCall::withReturn 1035 ns 1035 ns 672736 -ReflectedMethodCall::withReturn 1061 ns 1061 ns 659470 ------------------------------------ ->>> Run 4: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:29:51+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2364.83 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.23, 0.76, 0.72 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 899 ns 899 ns 757381 -StdFuncCall::noReturn 904 ns 904 ns 769320 -ReflectedCall::noReturn 911 ns 911 ns 762634 - -StdFuncMethodCall::noReturn 902 ns 902 ns 767011 -ReflectedMethodCall::noReturn 954 ns 954 ns 726736 --------------------------------------------------------------------------- -DirectCall::withReturn 1075 ns 1075 ns 651123 -StdFuncCall::withReturn 1078 ns 1078 ns 648677 -ReflectedCall::withReturn 1087 ns 1087 ns 640363 - -StdFuncMethodCall::withReturn 1076 ns 1076 ns 648598 -ReflectedMethodCall::withReturn 1118 ns 1118 ns 625917 ------------------------------------ ->>> Run 5: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:29:59+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.21, 0.77, 0.72 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 896 ns 896 ns 767762 -StdFuncCall::noReturn 910 ns 910 ns 763215 -ReflectedCall::noReturn 923 ns 923 ns 755913 - -StdFuncMethodCall::noReturn 910 ns 909 ns 760598 -ReflectedMethodCall::noReturn 928 ns 928 ns 750732 --------------------------------------------------------------------------- -DirectCall::withReturn 1080 ns 1080 ns 644211 -StdFuncCall::withReturn 1081 ns 1081 ns 642103 -ReflectedCall::withReturn 1095 ns 1095 ns 638553 - -StdFuncMethodCall::withReturn 1082 ns 1082 ns 642934 -ReflectedMethodCall::withReturn 1098 ns 1098 ns 633816 ------------------------------------ ->>> Run 1: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:30:08+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2499.32 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.17, 0.78, 0.73 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1718 ns 1718 ns 403509 -StdFuncCall::noReturn 1711 ns 1711 ns 408919 -ReflectedCall::noReturn 1719 ns 1719 ns 406569 - -StdFuncMethodCall::noReturn 1710 ns 1710 ns 409246 -ReflectedMethodCall::noReturn 1735 ns 1735 ns 403276 --------------------------------------------------------------------------- -DirectCall::withReturn 1942 ns 1942 ns 360231 -StdFuncCall::withReturn 1944 ns 1944 ns 359937 -ReflectedCall::withReturn 1967 ns 1967 ns 355508 - -StdFuncMethodCall::withReturn 1945 ns 1945 ns 360153 -ReflectedMethodCall::withReturn 1971 ns 1971 ns 354944 ------------------------------------ ->>> Run 2: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:30:17+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2418.55 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.15, 0.78, 0.73 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1720 ns 1719 ns 403240 -StdFuncCall::noReturn 1711 ns 1711 ns 409539 -ReflectedCall::noReturn 1722 ns 1722 ns 407137 - -StdFuncMethodCall::noReturn 1710 ns 1710 ns 408876 -ReflectedMethodCall::noReturn 1735 ns 1735 ns 403563 --------------------------------------------------------------------------- -DirectCall::withReturn 1905 ns 1905 ns 364610 -StdFuncCall::withReturn 1906 ns 1905 ns 367144 -ReflectedCall::withReturn 1932 ns 1931 ns 362876 - -StdFuncMethodCall::withReturn 1904 ns 1904 ns 367010 -ReflectedMethodCall::withReturn 1941 ns 1940 ns 360733 ------------------------------------ ->>> Run 3: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:30:26+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4754.64 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.14, 0.79, 0.73 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1700 ns 1700 ns 408515 -StdFuncCall::noReturn 1706 ns 1706 ns 411515 -ReflectedCall::noReturn 1711 ns 1710 ns 409353 - -StdFuncMethodCall::noReturn 1702 ns 1702 ns 410901 -ReflectedMethodCall::noReturn 1723 ns 1722 ns 406169 --------------------------------------------------------------------------- -DirectCall::withReturn 1888 ns 1888 ns 370526 -StdFuncCall::withReturn 1888 ns 1887 ns 370612 -ReflectedCall::withReturn 1916 ns 1916 ns 365093 - -StdFuncMethodCall::withReturn 1890 ns 1889 ns 371318 -ReflectedMethodCall::withReturn 1927 ns 1927 ns 362766 ------------------------------------ ->>> Run 4: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:30:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1859.33 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.11, 0.80, 0.73 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1708 ns 1707 ns 404396 -StdFuncCall::noReturn 1709 ns 1708 ns 409461 -ReflectedCall::noReturn 1717 ns 1717 ns 407033 - -StdFuncMethodCall::noReturn 1708 ns 1708 ns 409492 -ReflectedMethodCall::noReturn 1732 ns 1731 ns 404102 --------------------------------------------------------------------------- -DirectCall::withReturn 1949 ns 1948 ns 359921 -StdFuncCall::withReturn 1944 ns 1944 ns 360031 -ReflectedCall::withReturn 1969 ns 1968 ns 355377 - -StdFuncMethodCall::withReturn 2043 ns 2042 ns 358913 -ReflectedMethodCall::withReturn 2102 ns 2102 ns 351247 ------------------------------------ ->>> Run 5: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:30:44+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4274.37 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.10, 0.80, 0.74 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1854 ns 1853 ns 369519 -StdFuncCall::noReturn 1804 ns 1804 ns 389051 -ReflectedCall::noReturn 1768 ns 1767 ns 372147 - -StdFuncMethodCall::noReturn 1845 ns 1845 ns 366941 -ReflectedMethodCall::noReturn 1892 ns 1891 ns 390576 --------------------------------------------------------------------------- -DirectCall::withReturn 2059 ns 2059 ns 321965 -StdFuncCall::withReturn 2102 ns 2102 ns 331998 -ReflectedCall::withReturn 2122 ns 2122 ns 333219 - -StdFuncMethodCall::withReturn 2060 ns 2060 ns 333788 -ReflectedMethodCall::withReturn 2079 ns 2079 ns 331928 ------------------------------------ ->>> Run 1: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:30:53+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.24, 0.84, 0.75 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1960 ns 1959 ns 357975 -StdFuncCall::noReturn 2034 ns 2034 ns 341249 -ReflectedCall::noReturn 2022 ns 2022 ns 341827 - -StdFuncMethodCall::noReturn 2013 ns 2013 ns 303915 -ReflectedMethodCall::noReturn 2014 ns 2014 ns 343680 --------------------------------------------------------------------------- -DirectCall::withReturn 2207 ns 2207 ns 310242 -StdFuncCall::withReturn 2217 ns 2216 ns 310202 -ReflectedCall::withReturn 2254 ns 2253 ns 304225 - -StdFuncMethodCall::withReturn 2240 ns 2239 ns 306452 -ReflectedMethodCall::withReturn 2265 ns 2264 ns 299926 ------------------------------------ ->>> Run 2: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:31:02+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3021.9 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.43, 0.90, 0.77 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1981 ns 1981 ns 342744 -StdFuncCall::noReturn 1966 ns 1965 ns 352075 -ReflectedCall::noReturn 2002 ns 2001 ns 345397 - -StdFuncMethodCall::noReturn 2081 ns 2080 ns 341551 -ReflectedMethodCall::noReturn 1969 ns 1969 ns 333753 --------------------------------------------------------------------------- -DirectCall::withReturn 2207 ns 2207 ns 316294 -StdFuncCall::withReturn 2208 ns 2207 ns 308338 -ReflectedCall::withReturn 2215 ns 2215 ns 312972 - -StdFuncMethodCall::withReturn 2192 ns 2191 ns 314740 -ReflectedMethodCall::withReturn 2224 ns 2223 ns 305823 ------------------------------------ ->>> Run 3: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:31:11+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4705.12 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.44, 0.92, 0.78 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1940 ns 1939 ns 350727 -StdFuncCall::noReturn 1965 ns 1965 ns 347915 -ReflectedCall::noReturn 1951 ns 1951 ns 352534 - -StdFuncMethodCall::noReturn 1938 ns 1938 ns 359757 -ReflectedMethodCall::noReturn 1965 ns 1964 ns 356003 --------------------------------------------------------------------------- -DirectCall::withReturn 2195 ns 2194 ns 317298 -StdFuncCall::withReturn 2197 ns 2196 ns 316093 -ReflectedCall::withReturn 2214 ns 2213 ns 302642 - -StdFuncMethodCall::withReturn 2197 ns 2197 ns 318178 -ReflectedMethodCall::withReturn 2227 ns 2226 ns 313484 ------------------------------------ ->>> Run 4: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:31:21+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2658.72 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.48, 0.94, 0.79 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2027 ns 2027 ns 330486 -StdFuncCall::noReturn 2014 ns 2013 ns 352994 -ReflectedCall::noReturn 2031 ns 2030 ns 345623 - -StdFuncMethodCall::noReturn 1982 ns 1982 ns 341573 -ReflectedMethodCall::noReturn 2017 ns 2017 ns 349908 --------------------------------------------------------------------------- -DirectCall::withReturn 2296 ns 2296 ns 294346 -StdFuncCall::withReturn 2321 ns 2319 ns 300846 -ReflectedCall::withReturn 2360 ns 2360 ns 286766 - -StdFuncMethodCall::withReturn 2270 ns 2270 ns 301661 -ReflectedMethodCall::withReturn 2284 ns 2284 ns 291059 ------------------------------------ ->>> Run 5: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:31:30+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2259.74 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.71, 1.00, 0.81 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1977 ns 1977 ns 353401 -StdFuncCall::noReturn 2000 ns 2000 ns 345838 -ReflectedCall::noReturn 1986 ns 1985 ns 351401 - -StdFuncMethodCall::noReturn 1963 ns 1962 ns 353888 -ReflectedMethodCall::noReturn 1965 ns 1965 ns 348781 --------------------------------------------------------------------------- -DirectCall::withReturn 2208 ns 2207 ns 312994 -StdFuncCall::withReturn 2208 ns 2208 ns 312348 -ReflectedCall::withReturn 2234 ns 2234 ns 311258 - -StdFuncMethodCall::withReturn 2210 ns 2209 ns 313612 -ReflectedMethodCall::withReturn 2243 ns 2243 ns 310464 ------------------------------------ ->>> Run 1: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:31:39+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2565.99 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.89, 1.07, 0.83 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2186 ns 2186 ns 298930 -StdFuncCall::noReturn 2180 ns 2179 ns 316013 -ReflectedCall::noReturn 2185 ns 2185 ns 317280 - -StdFuncMethodCall::noReturn 2178 ns 2178 ns 318283 -ReflectedMethodCall::noReturn 2199 ns 2199 ns 317096 --------------------------------------------------------------------------- -DirectCall::withReturn 2651 ns 2651 ns 262036 -StdFuncCall::withReturn 2659 ns 2659 ns 262524 -ReflectedCall::withReturn 2687 ns 2686 ns 259459 - -StdFuncMethodCall::withReturn 2662 ns 2661 ns 260168 -ReflectedMethodCall::withReturn 2689 ns 2689 ns 255403 ------------------------------------ ->>> Run 2: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:31:49+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.76, 1.07, 0.84 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2167 ns 2166 ns 317573 -StdFuncCall::noReturn 2178 ns 2178 ns 319987 -ReflectedCall::noReturn 2173 ns 2172 ns 319725 - -StdFuncMethodCall::noReturn 2167 ns 2167 ns 319864 -ReflectedMethodCall::noReturn 2215 ns 2215 ns 314983 --------------------------------------------------------------------------- -DirectCall::withReturn 2597 ns 2596 ns 267537 -StdFuncCall::withReturn 2609 ns 2608 ns 263587 -ReflectedCall::withReturn 2639 ns 2638 ns 264562 - -StdFuncMethodCall::withReturn 2594 ns 2593 ns 268609 -ReflectedMethodCall::withReturn 2649 ns 2648 ns 261252 ------------------------------------ ->>> Run 3: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:31:59+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.64, 1.06, 0.84 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2187 ns 2187 ns 311240 -StdFuncCall::noReturn 2195 ns 2195 ns 321853 -ReflectedCall::noReturn 2195 ns 2194 ns 315480 - -StdFuncMethodCall::noReturn 2188 ns 2187 ns 319537 -ReflectedMethodCall::noReturn 2212 ns 2212 ns 315561 --------------------------------------------------------------------------- -DirectCall::withReturn 2636 ns 2635 ns 264251 -StdFuncCall::withReturn 2625 ns 2624 ns 264662 -ReflectedCall::withReturn 2654 ns 2653 ns 261530 - -StdFuncMethodCall::withReturn 2625 ns 2625 ns 262978 -ReflectedMethodCall::withReturn 2668 ns 2668 ns 259997 ------------------------------------ ->>> Run 4: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:32:08+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.54, 1.06, 0.84 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2181 ns 2180 ns 317614 -StdFuncCall::noReturn 2172 ns 2172 ns 317161 -ReflectedCall::noReturn 2190 ns 2190 ns 321018 - -StdFuncMethodCall::noReturn 2281 ns 2281 ns 304077 -ReflectedMethodCall::noReturn 2242 ns 2242 ns 290170 --------------------------------------------------------------------------- -DirectCall::withReturn 2601 ns 2601 ns 266644 -StdFuncCall::withReturn 2723 ns 2723 ns 263459 -ReflectedCall::withReturn 2724 ns 2723 ns 257965 - -StdFuncMethodCall::withReturn 2611 ns 2611 ns 262426 -ReflectedMethodCall::withReturn 2683 ns 2682 ns 258950 ------------------------------------ ->>> Run 5: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:32:18+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.46, 1.06, 0.84 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2195 ns 2195 ns 313426 -StdFuncCall::noReturn 2183 ns 2182 ns 312811 -ReflectedCall::noReturn 2182 ns 2181 ns 320013 - -StdFuncMethodCall::noReturn 2184 ns 2184 ns 318661 -ReflectedMethodCall::noReturn 2194 ns 2194 ns 317609 --------------------------------------------------------------------------- -DirectCall::withReturn 2601 ns 2601 ns 261526 -StdFuncCall::withReturn 2598 ns 2597 ns 266007 -ReflectedCall::withReturn 2623 ns 2623 ns 264649 - -StdFuncMethodCall::withReturn 2593 ns 2593 ns 268179 -ReflectedMethodCall::withReturn 2643 ns 2642 ns 261745 ------------------------------------ ->>> Run 1: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:32:28+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.46, 1.07, 0.85 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3533 ns 3532 ns 195801 -StdFuncCall::noReturn 3526 ns 3525 ns 197420 -ReflectedCall::noReturn 3535 ns 3535 ns 196633 - -StdFuncMethodCall::noReturn 3524 ns 3523 ns 197148 -ReflectedMethodCall::noReturn 3546 ns 3546 ns 194787 --------------------------------------------------------------------------- -DirectCall::withReturn 3992 ns 3992 ns 173680 -StdFuncCall::withReturn 3995 ns 3994 ns 174034 -ReflectedCall::withReturn 4028 ns 4028 ns 172386 - -StdFuncMethodCall::withReturn 3989 ns 3989 ns 173898 -ReflectedMethodCall::withReturn 4041 ns 4040 ns 172324 ------------------------------------ ->>> Run 2: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:32:39+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3872.32 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.47, 1.09, 0.86 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3520 ns 3520 ns 194024 -StdFuncCall::noReturn 3532 ns 3532 ns 196774 -ReflectedCall::noReturn 3531 ns 3530 ns 196912 - -StdFuncMethodCall::noReturn 3527 ns 3526 ns 197173 -ReflectedMethodCall::noReturn 3545 ns 3544 ns 195935 --------------------------------------------------------------------------- -DirectCall::withReturn 3988 ns 3987 ns 174580 -StdFuncCall::withReturn 3986 ns 3985 ns 175002 -ReflectedCall::withReturn 4015 ns 4014 ns 172705 - -StdFuncMethodCall::withReturn 4088 ns 4087 ns 174540 -ReflectedMethodCall::withReturn 4095 ns 4094 ns 169848 ------------------------------------ ->>> Run 3: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:32:50+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.40, 1.08, 0.86 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3552 ns 3552 ns 195236 -StdFuncCall::noReturn 3563 ns 3562 ns 195128 -ReflectedCall::noReturn 3559 ns 3558 ns 195504 - -StdFuncMethodCall::noReturn 3559 ns 3559 ns 195249 -ReflectedMethodCall::noReturn 3574 ns 3573 ns 195050 --------------------------------------------------------------------------- -DirectCall::withReturn 4036 ns 4035 ns 173264 -StdFuncCall::withReturn 4022 ns 4021 ns 171261 -ReflectedCall::withReturn 4060 ns 4059 ns 171454 - -StdFuncMethodCall::withReturn 4025 ns 4024 ns 172789 -ReflectedMethodCall::withReturn 4065 ns 4064 ns 171108 ------------------------------------ ->>> Run 4: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:33:01+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.41, 1.10, 0.87 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3500 ns 3500 ns 197777 -StdFuncCall::noReturn 3519 ns 3518 ns 198267 -ReflectedCall::noReturn 3539 ns 3538 ns 197240 - -StdFuncMethodCall::noReturn 3539 ns 3538 ns 197720 -ReflectedMethodCall::noReturn 3563 ns 3563 ns 196002 --------------------------------------------------------------------------- -DirectCall::withReturn 4079 ns 4078 ns 171166 -StdFuncCall::withReturn 4069 ns 4069 ns 171810 -ReflectedCall::withReturn 4099 ns 4097 ns 170406 - -StdFuncMethodCall::withReturn 4063 ns 4061 ns 170961 -ReflectedMethodCall::withReturn 4036 ns 4035 ns 172161 ------------------------------------ ->>> Run 5: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:33:12+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1801.89 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.39, 1.11, 0.87 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3537 ns 3536 ns 198280 -StdFuncCall::noReturn 3515 ns 3515 ns 198830 -ReflectedCall::noReturn 3521 ns 3520 ns 198314 - -StdFuncMethodCall::noReturn 3514 ns 3514 ns 196875 -ReflectedMethodCall::noReturn 3586 ns 3586 ns 194396 --------------------------------------------------------------------------- -DirectCall::withReturn 4039 ns 4038 ns 173252 -StdFuncCall::withReturn 4029 ns 4029 ns 174445 -ReflectedCall::withReturn 4015 ns 4014 ns 172859 - -StdFuncMethodCall::withReturn 3996 ns 3996 ns 174457 -ReflectedMethodCall::withReturn 4030 ns 4029 ns 172232 ------------------------------------ ->>> Run 1: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:33:24+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4390.34 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.33, 1.10, 0.88 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3802 ns 3801 ns 184513 -StdFuncCall::noReturn 3795 ns 3794 ns 184144 -ReflectedCall::noReturn 3790 ns 3789 ns 184898 - -StdFuncMethodCall::noReturn 3765 ns 3764 ns 177760 -ReflectedMethodCall::noReturn 3778 ns 3778 ns 183638 --------------------------------------------------------------------------- -DirectCall::withReturn 4329 ns 4328 ns 161157 -StdFuncCall::withReturn 4332 ns 4330 ns 160003 -ReflectedCall::withReturn 4367 ns 4366 ns 159612 - -StdFuncMethodCall::withReturn 4335 ns 4335 ns 160361 -ReflectedMethodCall::withReturn 4372 ns 4371 ns 159538 ------------------------------------ ->>> Run 2: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:33:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4300.1 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.28, 1.10, 0.88 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3778 ns 3777 ns 183159 -StdFuncCall::noReturn 3762 ns 3761 ns 185032 -ReflectedCall::noReturn 3764 ns 3762 ns 185710 - -StdFuncMethodCall::noReturn 3758 ns 3757 ns 185331 -ReflectedMethodCall::noReturn 3779 ns 3778 ns 176155 --------------------------------------------------------------------------- -DirectCall::withReturn 4339 ns 4338 ns 159051 -StdFuncCall::withReturn 4342 ns 4342 ns 160567 -ReflectedCall::withReturn 4363 ns 4362 ns 159875 - -StdFuncMethodCall::withReturn 4338 ns 4337 ns 160163 -ReflectedMethodCall::withReturn 4382 ns 4382 ns 159491 ------------------------------------ ->>> Run 3: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:33:47+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.21, 1.09, 0.88 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3768 ns 3767 ns 186032 -StdFuncCall::noReturn 3753 ns 3753 ns 181678 -ReflectedCall::noReturn 3767 ns 3767 ns 184272 - -StdFuncMethodCall::noReturn 3759 ns 3758 ns 183679 -ReflectedMethodCall::noReturn 3774 ns 3773 ns 184695 --------------------------------------------------------------------------- -DirectCall::withReturn 4341 ns 4341 ns 160622 -StdFuncCall::withReturn 4356 ns 4355 ns 159689 -ReflectedCall::withReturn 4369 ns 4368 ns 159362 - -StdFuncMethodCall::withReturn 4353 ns 4352 ns 160835 -ReflectedMethodCall::withReturn 4376 ns 4375 ns 159727 ------------------------------------ ->>> Run 4: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:33:58+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.26, 1.11, 0.89 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3755 ns 3754 ns 186615 -StdFuncCall::noReturn 3745 ns 3744 ns 184616 -ReflectedCall::noReturn 3771 ns 3771 ns 185449 - -StdFuncMethodCall::noReturn 3747 ns 3747 ns 186113 -ReflectedMethodCall::noReturn 3773 ns 3772 ns 182904 --------------------------------------------------------------------------- -DirectCall::withReturn 4325 ns 4323 ns 161325 -StdFuncCall::withReturn 4321 ns 4321 ns 160422 -ReflectedCall::withReturn 4348 ns 4347 ns 159032 - -StdFuncMethodCall::withReturn 4315 ns 4315 ns 159476 -ReflectedMethodCall::withReturn 4363 ns 4362 ns 159343 ------------------------------------ ->>> Run 5: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:34:10+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.22, 1.10, 0.89 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3824 ns 3823 ns 182597 -StdFuncCall::noReturn 3822 ns 3822 ns 182367 -ReflectedCall::noReturn 3835 ns 3835 ns 182224 - -StdFuncMethodCall::noReturn 3820 ns 3820 ns 182550 -ReflectedMethodCall::noReturn 3878 ns 3877 ns 179398 --------------------------------------------------------------------------- -DirectCall::withReturn 4498 ns 4497 ns 153854 -StdFuncCall::withReturn 4437 ns 4436 ns 157785 -ReflectedCall::withReturn 4484 ns 4483 ns 156149 - -StdFuncMethodCall::withReturn 4469 ns 4467 ns 155734 -ReflectedMethodCall::withReturn 4484 ns 4483 ns 154092 ------------------------------------ ->>> Run 1: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:34:21+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2714.66 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.19, 1.10, 0.89 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4158 ns 4157 ns 168841 -StdFuncCall::noReturn 4107 ns 4107 ns 167421 -ReflectedCall::noReturn 4073 ns 4072 ns 172223 - -StdFuncMethodCall::noReturn 4072 ns 4071 ns 171726 -ReflectedMethodCall::noReturn 4078 ns 4077 ns 171379 --------------------------------------------------------------------------- -DirectCall::withReturn 4718 ns 4718 ns 148098 -StdFuncCall::withReturn 4703 ns 4702 ns 146865 -ReflectedCall::withReturn 4735 ns 4733 ns 146683 - -StdFuncMethodCall::withReturn 4858 ns 4858 ns 147228 -ReflectedMethodCall::withReturn 4877 ns 4876 ns 135299 ------------------------------------ ->>> Run 2: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:34:33+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4000.23 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.14, 1.09, 0.90 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4149 ns 4149 ns 171540 -StdFuncCall::noReturn 4078 ns 4078 ns 173142 -ReflectedCall::noReturn 4163 ns 4162 ns 172296 - -StdFuncMethodCall::noReturn 4164 ns 4163 ns 171601 -ReflectedMethodCall::noReturn 4206 ns 4206 ns 167024 --------------------------------------------------------------------------- -DirectCall::withReturn 4803 ns 4802 ns 146401 -StdFuncCall::withReturn 4767 ns 4766 ns 146265 -ReflectedCall::withReturn 4813 ns 4813 ns 144824 - -StdFuncMethodCall::withReturn 4797 ns 4797 ns 144938 -ReflectedMethodCall::withReturn 4842 ns 4841 ns 143714 ------------------------------------ ->>> Run 3: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:34:45+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3428.64 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.20, 1.11, 0.90 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4051 ns 4050 ns 169785 -StdFuncCall::noReturn 4060 ns 4060 ns 171288 -ReflectedCall::noReturn 4069 ns 4067 ns 171269 - -StdFuncMethodCall::noReturn 4037 ns 4036 ns 171130 -ReflectedMethodCall::noReturn 4070 ns 4069 ns 170385 --------------------------------------------------------------------------- -DirectCall::withReturn 4715 ns 4714 ns 147560 -StdFuncCall::withReturn 4710 ns 4710 ns 147903 -ReflectedCall::withReturn 4732 ns 4730 ns 146870 - -StdFuncMethodCall::withReturn 4706 ns 4705 ns 147200 -ReflectedMethodCall::withReturn 4743 ns 4741 ns 146280 ------------------------------------ ->>> Run 4: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:34:56+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3097.37 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.15, 1.10, 0.91 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4049 ns 4048 ns 172698 -StdFuncCall::noReturn 4028 ns 4028 ns 172826 -ReflectedCall::noReturn 4020 ns 4019 ns 172895 - -StdFuncMethodCall::noReturn 4011 ns 4010 ns 173064 -ReflectedMethodCall::noReturn 4022 ns 4022 ns 167520 --------------------------------------------------------------------------- -DirectCall::withReturn 4674 ns 4673 ns 149145 -StdFuncCall::withReturn 4664 ns 4663 ns 148506 -ReflectedCall::withReturn 4701 ns 4700 ns 148023 - -StdFuncMethodCall::withReturn 4671 ns 4670 ns 149320 -ReflectedMethodCall::withReturn 4706 ns 4706 ns 148082 ------------------------------------ ->>> Run 5: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:35:08+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1963.71 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.13, 1.10, 0.91 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4035 ns 4035 ns 172990 -StdFuncCall::noReturn 4036 ns 4035 ns 169934 -ReflectedCall::noReturn 4037 ns 4035 ns 173552 - -StdFuncMethodCall::noReturn 4027 ns 4027 ns 173475 -ReflectedMethodCall::noReturn 4046 ns 4046 ns 172800 --------------------------------------------------------------------------- -DirectCall::withReturn 4683 ns 4682 ns 149053 -StdFuncCall::withReturn 4664 ns 4663 ns 148728 -ReflectedCall::withReturn 4695 ns 4694 ns 148659 - -StdFuncMethodCall::withReturn 4666 ns 4665 ns 148374 -ReflectedMethodCall::withReturn 4716 ns 4715 ns 147755 ------------------------------------ -All benchmarks completed. diff --git a/text-benchmark-logs/benchmark_returns_std_string.log b/text-benchmark-logs/benchmark_returns_std_string.log deleted file mode 100644 index 1a714ce3..00000000 --- a/text-benchmark-logs/benchmark_returns_std_string.log +++ /dev/null @@ -1,1655 +0,0 @@ -Starting benchmark runs... -Binary: ./bin/RTLBenchmarkApp -Log: ./benchmark_runs.log -=================================== ->>> Run 1: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:43:11+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4157.05 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 2.65, 1.34, 1.02 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.69 ns 2.69 ns 257512106 -StdFuncCall::noReturn 3.78 ns 3.78 ns 191372055 -ReflectedCall::noReturn 4.75 ns 4.74 ns 150632849 - -StdFuncMethodCall::noReturn 3.37 ns 3.37 ns 205734218 -ReflectedMethodCall::noReturn 8.16 ns 8.15 ns 83185450 --------------------------------------------------------------------------- -DirectCall::withReturn 9.53 ns 9.52 ns 73618012 -StdFuncCall::withReturn 10.1 ns 10.1 ns 69035901 -ReflectedCall::withReturn 18.9 ns 18.9 ns 36880785 - -StdFuncMethodCall::withReturn 10.1 ns 10.1 ns 69220259 -ReflectedMethodCall::withReturn 22.1 ns 22.1 ns 31879199 ------------------------------------ ->>> Run 2: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:43:21+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2840.42 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 2.40, 1.33, 1.02 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.68 ns 2.68 ns 260488715 -StdFuncCall::noReturn 3.62 ns 3.62 ns 200782884 -ReflectedCall::noReturn 4.56 ns 4.56 ns 148944703 - -StdFuncMethodCall::noReturn 3.39 ns 3.39 ns 208809945 -ReflectedMethodCall::noReturn 8.11 ns 8.10 ns 87050327 --------------------------------------------------------------------------- -DirectCall::withReturn 9.60 ns 9.60 ns 72996970 -StdFuncCall::withReturn 10.1 ns 10.1 ns 65628479 -ReflectedCall::withReturn 20.2 ns 20.2 ns 35013149 - -StdFuncMethodCall::withReturn 10.4 ns 10.4 ns 65866447 -ReflectedMethodCall::withReturn 23.0 ns 23.0 ns 30671071 ------------------------------------ ->>> Run 3: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:43:30+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4460.24 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 2.18, 1.32, 1.02 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.87 ns 2.87 ns 241103915 -StdFuncCall::noReturn 3.82 ns 3.82 ns 196511816 -ReflectedCall::noReturn 4.81 ns 4.81 ns 146383768 - -StdFuncMethodCall::noReturn 3.44 ns 3.44 ns 203121679 -ReflectedMethodCall::noReturn 8.30 ns 8.29 ns 81544882 --------------------------------------------------------------------------- -DirectCall::withReturn 9.71 ns 9.70 ns 70716392 -StdFuncCall::withReturn 10.2 ns 10.2 ns 68308824 -ReflectedCall::withReturn 19.1 ns 19.1 ns 35574641 - -StdFuncMethodCall::withReturn 10.4 ns 10.4 ns 67503571 -ReflectedMethodCall::withReturn 22.1 ns 22.1 ns 31856370 ------------------------------------ ->>> Run 4: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:43:40+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3303.29 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 2.15, 1.34, 1.03 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.78 ns 2.78 ns 244476044 -StdFuncCall::noReturn 3.51 ns 3.51 ns 186742133 -ReflectedCall::noReturn 4.72 ns 4.72 ns 145124302 - -StdFuncMethodCall::noReturn 3.71 ns 3.71 ns 195045272 -ReflectedMethodCall::noReturn 8.33 ns 8.32 ns 83825689 --------------------------------------------------------------------------- -DirectCall::withReturn 9.94 ns 9.94 ns 67349049 -StdFuncCall::withReturn 10.1 ns 10.1 ns 66482926 -ReflectedCall::withReturn 19.2 ns 19.2 ns 36102397 - -StdFuncMethodCall::withReturn 10.1 ns 10.1 ns 67142276 -ReflectedMethodCall::withReturn 22.8 ns 22.8 ns 29914325 ------------------------------------ ->>> Run 5: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:43:49+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1457.53 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 2.21, 1.38, 1.05 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.72 ns 2.72 ns 252082597 -StdFuncCall::noReturn 3.57 ns 3.57 ns 187629241 -ReflectedCall::noReturn 4.85 ns 4.85 ns 145919895 - -StdFuncMethodCall::noReturn 3.47 ns 3.47 ns 205701290 -ReflectedMethodCall::noReturn 8.19 ns 8.19 ns 82512348 --------------------------------------------------------------------------- -DirectCall::withReturn 9.82 ns 9.82 ns 68734745 -StdFuncCall::withReturn 10.2 ns 10.2 ns 66343231 -ReflectedCall::withReturn 19.1 ns 19.1 ns 36036806 - -StdFuncMethodCall::withReturn 10.1 ns 10.1 ns 66426936 -ReflectedMethodCall::withReturn 21.9 ns 21.9 ns 30764432 ------------------------------------ ->>> Run 6: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:43:59+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4134.64 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 2.10, 1.39, 1.05 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.68 ns 2.68 ns 255151415 -StdFuncCall::noReturn 3.57 ns 3.57 ns 194877796 -ReflectedCall::noReturn 4.68 ns 4.68 ns 148012652 - -StdFuncMethodCall::noReturn 3.41 ns 3.41 ns 203119855 -ReflectedMethodCall::noReturn 8.27 ns 8.27 ns 84231855 --------------------------------------------------------------------------- -DirectCall::withReturn 9.91 ns 9.91 ns 67237407 -StdFuncCall::withReturn 10.1 ns 10.1 ns 66701430 -ReflectedCall::withReturn 19.0 ns 19.0 ns 35306832 - -StdFuncMethodCall::withReturn 10.1 ns 10.1 ns 66190294 -ReflectedMethodCall::withReturn 22.8 ns 22.8 ns 31433430 ------------------------------------ ->>> Run 7: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:44:08+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3065.25 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 2.01, 1.39, 1.06 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.76 ns 2.75 ns 258152508 -StdFuncCall::noReturn 3.54 ns 3.54 ns 188663322 -ReflectedCall::noReturn 4.70 ns 4.70 ns 148190073 - -StdFuncMethodCall::noReturn 3.48 ns 3.48 ns 204262478 -ReflectedMethodCall::noReturn 8.15 ns 8.15 ns 82688841 --------------------------------------------------------------------------- -DirectCall::withReturn 9.71 ns 9.71 ns 70719451 -StdFuncCall::withReturn 10.2 ns 10.2 ns 66710422 -ReflectedCall::withReturn 19.2 ns 19.2 ns 35438621 - -StdFuncMethodCall::withReturn 10.1 ns 10.1 ns 64913832 -ReflectedMethodCall::withReturn 22.6 ns 22.5 ns 30465366 ------------------------------------ ->>> Run 8: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:44:17+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4152.63 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.85, 1.38, 1.06 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.70 ns 2.70 ns 258092134 -StdFuncCall::noReturn 3.59 ns 3.59 ns 190138329 -ReflectedCall::noReturn 4.77 ns 4.77 ns 148249878 - -StdFuncMethodCall::noReturn 3.49 ns 3.49 ns 201288659 -ReflectedMethodCall::noReturn 8.16 ns 8.16 ns 81918693 --------------------------------------------------------------------------- -DirectCall::withReturn 9.91 ns 9.91 ns 70546801 -StdFuncCall::withReturn 10.2 ns 10.2 ns 65288578 -ReflectedCall::withReturn 18.9 ns 18.9 ns 35386904 - -StdFuncMethodCall::withReturn 10.2 ns 10.2 ns 66910973 -ReflectedMethodCall::withReturn 22.8 ns 22.8 ns 30535267 ------------------------------------ ->>> Run 9: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:44:27+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4236.18 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.88, 1.40, 1.07 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2.75 ns 2.75 ns 256627078 -StdFuncCall::noReturn 3.62 ns 3.62 ns 191604367 -ReflectedCall::noReturn 4.90 ns 4.90 ns 146177763 - -StdFuncMethodCall::noReturn 3.51 ns 3.51 ns 207243986 -ReflectedMethodCall::noReturn 8.34 ns 8.34 ns 85440083 --------------------------------------------------------------------------- -DirectCall::withReturn 9.71 ns 9.71 ns 70073783 -StdFuncCall::withReturn 10.3 ns 10.3 ns 64837520 -ReflectedCall::withReturn 19.2 ns 19.2 ns 36494857 - -StdFuncMethodCall::withReturn 10.2 ns 10.2 ns 64693494 -ReflectedMethodCall::withReturn 22.5 ns 22.5 ns 31231450 ------------------------------------ ->>> Run 10: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-09-11T00:44:36+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3410.16 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.80, 1.39, 1.07 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3.18 ns 3.18 ns 220289404 -StdFuncCall::noReturn 3.68 ns 3.68 ns 185037995 -ReflectedCall::noReturn 4.95 ns 4.95 ns 138642595 - -StdFuncMethodCall::noReturn 3.69 ns 3.69 ns 191910140 -ReflectedMethodCall::noReturn 8.40 ns 8.40 ns 82408566 --------------------------------------------------------------------------- -DirectCall::withReturn 9.78 ns 9.78 ns 68512931 -StdFuncCall::withReturn 10.1 ns 10.1 ns 64820748 -ReflectedCall::withReturn 19.0 ns 19.0 ns 36083173 - -StdFuncMethodCall::withReturn 10.2 ns 10.2 ns 66179461 -ReflectedMethodCall::withReturn 22.4 ns 22.4 ns 31255435 ------------------------------------ ->>> Run 1: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:44:45+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3869.61 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.76, 1.39, 1.07 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 310 ns 310 ns 2254101 -StdFuncCall::noReturn 315 ns 315 ns 2239763 -ReflectedCall::noReturn 316 ns 316 ns 2198780 - -StdFuncMethodCall::noReturn 313 ns 313 ns 2258100 -ReflectedMethodCall::noReturn 323 ns 323 ns 2166074 --------------------------------------------------------------------------- -DirectCall::withReturn 453 ns 453 ns 1577637 -StdFuncCall::withReturn 452 ns 452 ns 1575065 -ReflectedCall::withReturn 633 ns 633 ns 1064025 - -StdFuncMethodCall::withReturn 452 ns 451 ns 1575285 -ReflectedMethodCall::withReturn 640 ns 640 ns 1059786 ------------------------------------ ->>> Run 2: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:44:56+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3794.29 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.72, 1.40, 1.08 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 317 ns 317 ns 2228177 -StdFuncCall::noReturn 308 ns 308 ns 2227891 -ReflectedCall::noReturn 318 ns 318 ns 2185558 - -StdFuncMethodCall::noReturn 320 ns 320 ns 2209955 -ReflectedMethodCall::noReturn 324 ns 324 ns 2131421 --------------------------------------------------------------------------- -DirectCall::withReturn 445 ns 445 ns 1580444 -StdFuncCall::withReturn 457 ns 457 ns 1550760 -ReflectedCall::withReturn 633 ns 633 ns 1077338 - -StdFuncMethodCall::withReturn 446 ns 446 ns 1563643 -ReflectedMethodCall::withReturn 646 ns 646 ns 1082286 ------------------------------------ ->>> Run 3: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:45:06+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2203.19 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.77, 1.42, 1.09 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 312 ns 312 ns 2244981 -StdFuncCall::noReturn 308 ns 308 ns 2262484 -ReflectedCall::noReturn 318 ns 318 ns 2253123 - -StdFuncMethodCall::noReturn 312 ns 312 ns 2223455 -ReflectedMethodCall::noReturn 325 ns 325 ns 2208582 --------------------------------------------------------------------------- -DirectCall::withReturn 515 ns 515 ns 1315012 -StdFuncCall::withReturn 514 ns 514 ns 1314421 -ReflectedCall::withReturn 705 ns 705 ns 996799 - -StdFuncMethodCall::withReturn 518 ns 518 ns 1295521 -ReflectedMethodCall::withReturn 706 ns 706 ns 928961 ------------------------------------ ->>> Run 4: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:45:15+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1438.63 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.72, 1.42, 1.09 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 351 ns 351 ns 2035112 -StdFuncCall::noReturn 349 ns 349 ns 2030713 -ReflectedCall::noReturn 349 ns 349 ns 1980472 - -StdFuncMethodCall::noReturn 349 ns 349 ns 2023659 -ReflectedMethodCall::noReturn 353 ns 353 ns 1978482 --------------------------------------------------------------------------- -DirectCall::withReturn 510 ns 510 ns 1329271 -StdFuncCall::withReturn 513 ns 513 ns 1337409 -ReflectedCall::withReturn 712 ns 712 ns 931367 - -StdFuncMethodCall::withReturn 511 ns 511 ns 1279105 -ReflectedMethodCall::withReturn 711 ns 711 ns 980263 ------------------------------------ ->>> Run 5: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-09-11T00:45:24+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3937.8 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.61, 1.41, 1.09 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 316 ns 316 ns 2233794 -StdFuncCall::noReturn 345 ns 345 ns 2026485 -ReflectedCall::noReturn 354 ns 354 ns 1979604 - -StdFuncMethodCall::noReturn 351 ns 351 ns 1987525 -ReflectedMethodCall::noReturn 363 ns 363 ns 1943031 --------------------------------------------------------------------------- -DirectCall::withReturn 523 ns 523 ns 1281177 -StdFuncCall::withReturn 522 ns 522 ns 1331638 -ReflectedCall::withReturn 702 ns 702 ns 971089 - -StdFuncMethodCall::withReturn 527 ns 527 ns 1342443 -ReflectedMethodCall::withReturn 707 ns 707 ns 966971 ------------------------------------ ->>> Run 1: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:45:34+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3864.23 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.52, 1.39, 1.09 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 907 ns 906 ns 671085 -StdFuncCall::noReturn 913 ns 913 ns 750555 -ReflectedCall::noReturn 927 ns 927 ns 739691 - -StdFuncMethodCall::noReturn 913 ns 913 ns 734242 -ReflectedMethodCall::noReturn 938 ns 938 ns 722635 --------------------------------------------------------------------------- -DirectCall::withReturn 1246 ns 1246 ns 536846 -StdFuncCall::withReturn 1268 ns 1268 ns 546493 -ReflectedCall::withReturn 1595 ns 1595 ns 423002 - -StdFuncMethodCall::withReturn 1240 ns 1240 ns 548835 -ReflectedMethodCall::withReturn 1533 ns 1533 ns 444235 ------------------------------------ ->>> Run 2: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:45:42+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4198.35 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.56, 1.40, 1.10 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 897 ns 897 ns 725976 -StdFuncCall::noReturn 907 ns 907 ns 753162 -ReflectedCall::noReturn 928 ns 927 ns 742010 - -StdFuncMethodCall::noReturn 919 ns 919 ns 716837 -ReflectedMethodCall::noReturn 939 ns 939 ns 713611 --------------------------------------------------------------------------- -DirectCall::withReturn 1199 ns 1199 ns 561452 -StdFuncCall::withReturn 1197 ns 1197 ns 560668 -ReflectedCall::withReturn 1530 ns 1529 ns 426508 - -StdFuncMethodCall::withReturn 1209 ns 1209 ns 556128 -ReflectedMethodCall::withReturn 1540 ns 1540 ns 434049 ------------------------------------ ->>> Run 3: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:45:50+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3711.21 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.47, 1.39, 1.09 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 906 ns 906 ns 730770 -StdFuncCall::noReturn 904 ns 904 ns 752526 -ReflectedCall::noReturn 924 ns 924 ns 717981 - -StdFuncMethodCall::noReturn 899 ns 899 ns 738039 -ReflectedMethodCall::noReturn 923 ns 923 ns 726660 --------------------------------------------------------------------------- -DirectCall::withReturn 1172 ns 1172 ns 563431 -StdFuncCall::withReturn 1187 ns 1186 ns 559493 -ReflectedCall::withReturn 1525 ns 1525 ns 444023 - -StdFuncMethodCall::withReturn 1180 ns 1180 ns 564379 -ReflectedMethodCall::withReturn 1540 ns 1540 ns 444693 ------------------------------------ ->>> Run 4: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:45:58+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4048.1 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.55, 1.41, 1.10 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 899 ns 899 ns 744944 -StdFuncCall::noReturn 905 ns 905 ns 755918 -ReflectedCall::noReturn 910 ns 910 ns 735203 - -StdFuncMethodCall::noReturn 910 ns 910 ns 751759 -ReflectedMethodCall::noReturn 927 ns 927 ns 718062 --------------------------------------------------------------------------- -DirectCall::withReturn 1193 ns 1192 ns 571996 -StdFuncCall::withReturn 1196 ns 1196 ns 551911 -ReflectedCall::withReturn 1509 ns 1509 ns 431152 - -StdFuncMethodCall::withReturn 1191 ns 1191 ns 546073 -ReflectedMethodCall::withReturn 1537 ns 1537 ns 441082 ------------------------------------ ->>> Run 5: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-09-11T00:46:06+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1023.61 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.51, 1.40, 1.10 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 916 ns 916 ns 732935 -StdFuncCall::noReturn 923 ns 923 ns 738825 -ReflectedCall::noReturn 920 ns 920 ns 716561 - -StdFuncMethodCall::noReturn 909 ns 909 ns 733723 -ReflectedMethodCall::noReturn 939 ns 939 ns 712708 --------------------------------------------------------------------------- -DirectCall::withReturn 1189 ns 1188 ns 567232 -StdFuncCall::withReturn 1190 ns 1190 ns 556865 -ReflectedCall::withReturn 1531 ns 1531 ns 454023 - -StdFuncMethodCall::withReturn 1187 ns 1187 ns 586934 -ReflectedMethodCall::withReturn 1536 ns 1536 ns 448828 ------------------------------------ ->>> Run 1: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:46:14+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4506.7 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.51, 1.41, 1.11 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1711 ns 1710 ns 397182 -StdFuncCall::noReturn 1701 ns 1701 ns 392625 -ReflectedCall::noReturn 1707 ns 1707 ns 404729 - -StdFuncMethodCall::noReturn 1708 ns 1708 ns 400940 -ReflectedMethodCall::noReturn 1745 ns 1744 ns 393836 --------------------------------------------------------------------------- -DirectCall::withReturn 2360 ns 2360 ns 296471 -StdFuncCall::withReturn 2358 ns 2358 ns 293315 -ReflectedCall::withReturn 3057 ns 3057 ns 229041 - -StdFuncMethodCall::withReturn 2355 ns 2354 ns 296620 -ReflectedMethodCall::withReturn 3034 ns 3034 ns 227950 ------------------------------------ ->>> Run 2: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:46:23+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1536.93 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.51, 1.41, 1.11 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1746 ns 1746 ns 395262 -StdFuncCall::noReturn 1734 ns 1733 ns 403023 -ReflectedCall::noReturn 1752 ns 1752 ns 380243 - -StdFuncMethodCall::noReturn 1753 ns 1753 ns 388427 -ReflectedMethodCall::noReturn 1752 ns 1751 ns 388074 --------------------------------------------------------------------------- -DirectCall::withReturn 2395 ns 2395 ns 289058 -StdFuncCall::withReturn 2433 ns 2433 ns 286696 -ReflectedCall::withReturn 3164 ns 3164 ns 221492 - -StdFuncMethodCall::withReturn 2440 ns 2440 ns 281890 -ReflectedMethodCall::withReturn 3166 ns 3166 ns 221117 ------------------------------------ ->>> Run 3: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:46:32+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3018.84 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.43, 1.40, 1.11 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1741 ns 1741 ns 377462 -StdFuncCall::noReturn 1715 ns 1715 ns 398238 -ReflectedCall::noReturn 1722 ns 1721 ns 395238 - -StdFuncMethodCall::noReturn 1740 ns 1740 ns 391977 -ReflectedMethodCall::noReturn 1709 ns 1709 ns 391583 --------------------------------------------------------------------------- -DirectCall::withReturn 2301 ns 2301 ns 303807 -StdFuncCall::withReturn 2312 ns 2311 ns 300175 -ReflectedCall::withReturn 3073 ns 3073 ns 226573 - -StdFuncMethodCall::withReturn 2423 ns 2423 ns 290465 -ReflectedMethodCall::withReturn 3169 ns 3169 ns 224297 ------------------------------------ ->>> Run 4: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:46:42+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3748.07 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.56, 1.42, 1.12 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1762 ns 1762 ns 388500 -StdFuncCall::noReturn 1755 ns 1754 ns 387350 -ReflectedCall::noReturn 1753 ns 1753 ns 380083 - -StdFuncMethodCall::noReturn 1750 ns 1750 ns 393882 -ReflectedMethodCall::noReturn 1776 ns 1776 ns 391549 --------------------------------------------------------------------------- -DirectCall::withReturn 2401 ns 2400 ns 295056 -StdFuncCall::withReturn 2397 ns 2397 ns 295309 -ReflectedCall::withReturn 3079 ns 3079 ns 222199 - -StdFuncMethodCall::withReturn 2409 ns 2409 ns 282929 -ReflectedMethodCall::withReturn 3179 ns 3179 ns 223918 ------------------------------------ ->>> Run 5: workload scale = 75 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 75 iterations -============================================= - -2025-09-11T00:46:51+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1163.73 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.63, 1.44, 1.13 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1723 ns 1722 ns 384064 -StdFuncCall::noReturn 1737 ns 1737 ns 391656 -ReflectedCall::noReturn 1731 ns 1730 ns 386459 - -StdFuncMethodCall::noReturn 1733 ns 1733 ns 397046 -ReflectedMethodCall::noReturn 1737 ns 1737 ns 395967 --------------------------------------------------------------------------- -DirectCall::withReturn 2369 ns 2369 ns 291883 -StdFuncCall::withReturn 2372 ns 2371 ns 291833 -ReflectedCall::withReturn 3078 ns 3078 ns 228938 - -StdFuncMethodCall::withReturn 2363 ns 2363 ns 291230 -ReflectedMethodCall::withReturn 3115 ns 3115 ns 224035 ------------------------------------ ->>> Run 1: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:47:01+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4500 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.60, 1.44, 1.13 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1980 ns 1979 ns 351441 -StdFuncCall::noReturn 1949 ns 1949 ns 354766 -ReflectedCall::noReturn 1986 ns 1986 ns 347476 - -StdFuncMethodCall::noReturn 1961 ns 1960 ns 344503 -ReflectedMethodCall::noReturn 1994 ns 1993 ns 343757 --------------------------------------------------------------------------- -DirectCall::withReturn 3012 ns 3011 ns 236164 -StdFuncCall::withReturn 2976 ns 2976 ns 235449 -ReflectedCall::withReturn 3916 ns 3916 ns 184109 - -StdFuncMethodCall::withReturn 3026 ns 3026 ns 229148 -ReflectedMethodCall::withReturn 3878 ns 3878 ns 181123 ------------------------------------ ->>> Run 2: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:47:11+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3869.01 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.59, 1.45, 1.14 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1973 ns 1973 ns 343831 -StdFuncCall::noReturn 1967 ns 1966 ns 336873 -ReflectedCall::noReturn 1989 ns 1989 ns 348169 - -StdFuncMethodCall::noReturn 1988 ns 1988 ns 348304 -ReflectedMethodCall::noReturn 2012 ns 2012 ns 335265 --------------------------------------------------------------------------- -DirectCall::withReturn 3000 ns 3000 ns 230973 -StdFuncCall::withReturn 2967 ns 2966 ns 232757 -ReflectedCall::withReturn 3876 ns 3876 ns 183695 - -StdFuncMethodCall::withReturn 3027 ns 3027 ns 232206 -ReflectedMethodCall::withReturn 3816 ns 3815 ns 182478 ------------------------------------ ->>> Run 3: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:47:20+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4509.87 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.58, 1.45, 1.14 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1987 ns 1987 ns 344531 -StdFuncCall::noReturn 1974 ns 1974 ns 339319 -ReflectedCall::noReturn 1991 ns 1990 ns 341989 - -StdFuncMethodCall::noReturn 1991 ns 1991 ns 345119 -ReflectedMethodCall::noReturn 1994 ns 1993 ns 350809 --------------------------------------------------------------------------- -DirectCall::withReturn 3024 ns 3023 ns 236080 -StdFuncCall::withReturn 2991 ns 2990 ns 234932 -ReflectedCall::withReturn 3841 ns 3841 ns 182164 - -StdFuncMethodCall::withReturn 2949 ns 2948 ns 237674 -ReflectedMethodCall::withReturn 3890 ns 3890 ns 180491 ------------------------------------ ->>> Run 4: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:47:30+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2443.13 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.57, 1.45, 1.14 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1974 ns 1974 ns 347223 -StdFuncCall::noReturn 1973 ns 1972 ns 348490 -ReflectedCall::noReturn 1994 ns 1994 ns 345264 - -StdFuncMethodCall::noReturn 1940 ns 1939 ns 343663 -ReflectedMethodCall::noReturn 2003 ns 2003 ns 348942 --------------------------------------------------------------------------- -DirectCall::withReturn 2965 ns 2965 ns 237170 -StdFuncCall::withReturn 2913 ns 2913 ns 238241 -ReflectedCall::withReturn 3852 ns 3852 ns 184604 - -StdFuncMethodCall::withReturn 2915 ns 2915 ns 237691 -ReflectedMethodCall::withReturn 3782 ns 3782 ns 185705 ------------------------------------ ->>> Run 5: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-09-11T00:47:40+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4409.93 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.56, 1.45, 1.15 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 1982 ns 1982 ns 351034 -StdFuncCall::noReturn 1964 ns 1964 ns 341721 -ReflectedCall::noReturn 1989 ns 1988 ns 350068 - -StdFuncMethodCall::noReturn 1955 ns 1954 ns 348141 -ReflectedMethodCall::noReturn 2003 ns 2003 ns 342525 --------------------------------------------------------------------------- -DirectCall::withReturn 2953 ns 2953 ns 234331 -StdFuncCall::withReturn 2934 ns 2934 ns 238160 -ReflectedCall::withReturn 3811 ns 3810 ns 186625 - -StdFuncMethodCall::withReturn 2912 ns 2912 ns 236835 -ReflectedMethodCall::withReturn 3899 ns 3898 ns 184770 ------------------------------------ ->>> Run 1: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:47:50+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4575.95 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.63, 1.47, 1.16 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2187 ns 2187 ns 313314 -StdFuncCall::noReturn 2203 ns 2202 ns 310954 -ReflectedCall::noReturn 2231 ns 2231 ns 314343 - -StdFuncMethodCall::noReturn 2218 ns 2217 ns 308543 -ReflectedMethodCall::noReturn 2262 ns 2262 ns 307479 --------------------------------------------------------------------------- -DirectCall::withReturn 3654 ns 3654 ns 191381 -StdFuncCall::withReturn 3651 ns 3650 ns 193595 -ReflectedCall::withReturn 4748 ns 4747 ns 151401 - -StdFuncMethodCall::withReturn 3605 ns 3605 ns 194245 -ReflectedMethodCall::withReturn 4691 ns 4690 ns 152913 ------------------------------------ ->>> Run 2: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:48:01+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4523.6 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.69, 1.49, 1.17 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2236 ns 2236 ns 309724 -StdFuncCall::noReturn 2214 ns 2214 ns 315329 -ReflectedCall::noReturn 2236 ns 2236 ns 309095 - -StdFuncMethodCall::noReturn 2217 ns 2217 ns 304364 -ReflectedMethodCall::noReturn 2247 ns 2247 ns 313155 --------------------------------------------------------------------------- -DirectCall::withReturn 3592 ns 3592 ns 195293 -StdFuncCall::withReturn 3587 ns 3587 ns 194462 -ReflectedCall::withReturn 4691 ns 4691 ns 152353 - -StdFuncMethodCall::withReturn 3594 ns 3594 ns 196395 -ReflectedMethodCall::withReturn 4737 ns 4737 ns 151845 ------------------------------------ ->>> Run 3: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:48:11+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 799.56 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.73, 1.50, 1.18 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2237 ns 2237 ns 301530 -StdFuncCall::noReturn 2248 ns 2248 ns 305381 -ReflectedCall::noReturn 2234 ns 2233 ns 307334 - -StdFuncMethodCall::noReturn 2250 ns 2249 ns 289243 -ReflectedMethodCall::noReturn 2241 ns 2241 ns 308428 --------------------------------------------------------------------------- -DirectCall::withReturn 3685 ns 3684 ns 190114 -StdFuncCall::withReturn 3669 ns 3668 ns 190878 -ReflectedCall::withReturn 4782 ns 4782 ns 150076 - -StdFuncMethodCall::withReturn 3606 ns 3606 ns 191373 -ReflectedMethodCall::withReturn 4723 ns 4722 ns 152622 ------------------------------------ ->>> Run 4: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:48:22+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2959.43 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.77, 1.52, 1.19 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2182 ns 2182 ns 307571 -StdFuncCall::noReturn 2184 ns 2183 ns 313459 -ReflectedCall::noReturn 2205 ns 2205 ns 317597 - -StdFuncMethodCall::noReturn 2224 ns 2223 ns 310829 -ReflectedMethodCall::noReturn 2235 ns 2235 ns 303977 --------------------------------------------------------------------------- -DirectCall::withReturn 3643 ns 3642 ns 195401 -StdFuncCall::withReturn 3554 ns 3554 ns 196445 -ReflectedCall::withReturn 4606 ns 4605 ns 154556 - -StdFuncMethodCall::withReturn 3581 ns 3581 ns 195507 -ReflectedMethodCall::withReturn 4713 ns 4713 ns 152328 ------------------------------------ ->>> Run 5: workload scale = 125 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 125 iterations -============================================= - -2025-09-11T00:48:32+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3933.71 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.90, 1.56, 1.20 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 2204 ns 2204 ns 305118 -StdFuncCall::noReturn 2204 ns 2204 ns 319369 -ReflectedCall::noReturn 2209 ns 2208 ns 314425 - -StdFuncMethodCall::noReturn 2226 ns 2226 ns 305314 -ReflectedMethodCall::noReturn 2220 ns 2220 ns 310974 --------------------------------------------------------------------------- -DirectCall::withReturn 3649 ns 3648 ns 195704 -StdFuncCall::withReturn 3665 ns 3664 ns 193630 -ReflectedCall::withReturn 4598 ns 4598 ns 152357 - -StdFuncMethodCall::withReturn 3629 ns 3628 ns 195927 -ReflectedMethodCall::withReturn 4805 ns 4805 ns 154283 ------------------------------------ ->>> Run 1: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:48:43+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2671.41 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.92, 1.58, 1.21 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3533 ns 3533 ns 195180 -StdFuncCall::noReturn 3546 ns 3545 ns 195924 -ReflectedCall::noReturn 3625 ns 3625 ns 195820 - -StdFuncMethodCall::noReturn 3629 ns 3629 ns 197819 -ReflectedMethodCall::noReturn 3626 ns 3626 ns 195755 --------------------------------------------------------------------------- -DirectCall::withReturn 5182 ns 5181 ns 131107 -StdFuncCall::withReturn 5141 ns 5140 ns 130322 -ReflectedCall::withReturn 6380 ns 6380 ns 107050 - -StdFuncMethodCall::withReturn 5139 ns 5137 ns 130221 -ReflectedMethodCall::withReturn 6283 ns 6283 ns 109882 ------------------------------------ ->>> Run 2: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:48:52+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1153.89 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.92, 1.58, 1.22 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3645 ns 3644 ns 194763 -StdFuncCall::noReturn 3536 ns 3536 ns 197643 -ReflectedCall::noReturn 3549 ns 3549 ns 197667 - -StdFuncMethodCall::noReturn 3535 ns 3534 ns 197002 -ReflectedMethodCall::noReturn 3554 ns 3553 ns 196119 --------------------------------------------------------------------------- -DirectCall::withReturn 5181 ns 5181 ns 135659 -StdFuncCall::withReturn 5179 ns 5178 ns 133046 -ReflectedCall::withReturn 6373 ns 6371 ns 109310 - -StdFuncMethodCall::withReturn 5177 ns 5176 ns 132606 -ReflectedMethodCall::withReturn 6372 ns 6372 ns 109258 ------------------------------------ ->>> Run 3: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:49:01+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.93, 1.60, 1.23 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3528 ns 3528 ns 197592 -StdFuncCall::noReturn 3510 ns 3510 ns 191078 -ReflectedCall::noReturn 3526 ns 3526 ns 197562 - -StdFuncMethodCall::noReturn 3514 ns 3513 ns 198411 -ReflectedMethodCall::noReturn 3730 ns 3730 ns 196892 --------------------------------------------------------------------------- -DirectCall::withReturn 5354 ns 5352 ns 123800 -StdFuncCall::withReturn 5245 ns 5244 ns 136768 -ReflectedCall::withReturn 6398 ns 6397 ns 106337 - -StdFuncMethodCall::withReturn 5175 ns 5175 ns 131618 -ReflectedMethodCall::withReturn 6289 ns 6287 ns 110758 ------------------------------------ ->>> Run 4: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:49:10+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2161.83 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.87, 1.59, 1.23 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3542 ns 3541 ns 198073 -StdFuncCall::noReturn 3610 ns 3609 ns 195386 -ReflectedCall::noReturn 3583 ns 3582 ns 195941 - -StdFuncMethodCall::noReturn 3507 ns 3506 ns 199751 -ReflectedMethodCall::noReturn 3609 ns 3608 ns 195357 --------------------------------------------------------------------------- -DirectCall::withReturn 5074 ns 5073 ns 137709 -StdFuncCall::withReturn 5121 ns 5120 ns 136175 -ReflectedCall::withReturn 6347 ns 6346 ns 107908 - -StdFuncMethodCall::withReturn 5089 ns 5088 ns 132717 -ReflectedMethodCall::withReturn 6358 ns 6358 ns 111927 ------------------------------------ ->>> Run 5: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-09-11T00:49:20+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1932.44 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.73, 1.57, 1.23 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3578 ns 3577 ns 198985 -StdFuncCall::noReturn 3533 ns 3532 ns 198881 -ReflectedCall::noReturn 3517 ns 3517 ns 198702 - -StdFuncMethodCall::noReturn 3572 ns 3572 ns 198500 -ReflectedMethodCall::noReturn 3572 ns 3572 ns 185939 --------------------------------------------------------------------------- -DirectCall::withReturn 5046 ns 5046 ns 137950 -StdFuncCall::withReturn 5080 ns 5078 ns 138211 -ReflectedCall::withReturn 6306 ns 6304 ns 110192 - -StdFuncMethodCall::withReturn 5132 ns 5132 ns 131855 -ReflectedMethodCall::withReturn 6343 ns 6343 ns 107271 ------------------------------------ ->>> Run 1: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:49:29+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2271.38 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.62, 1.55, 1.22 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3789 ns 3788 ns 183993 -StdFuncCall::noReturn 3777 ns 3776 ns 185241 -ReflectedCall::noReturn 3781 ns 3780 ns 183887 - -StdFuncMethodCall::noReturn 3778 ns 3777 ns 185194 -ReflectedMethodCall::noReturn 3815 ns 3814 ns 183316 --------------------------------------------------------------------------- -DirectCall::withReturn 5771 ns 5770 ns 121611 -StdFuncCall::withReturn 5735 ns 5734 ns 117886 -ReflectedCall::withReturn 7182 ns 7182 ns 94871 - -StdFuncMethodCall::withReturn 5796 ns 5795 ns 116975 -ReflectedMethodCall::withReturn 7194 ns 7193 ns 94083 ------------------------------------ ->>> Run 2: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:49:38+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2817.81 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.52, 1.54, 1.22 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3877 ns 3877 ns 180661 -StdFuncCall::noReturn 3876 ns 3876 ns 181752 -ReflectedCall::noReturn 3864 ns 3864 ns 180348 - -StdFuncMethodCall::noReturn 3914 ns 3914 ns 180868 -ReflectedMethodCall::noReturn 3853 ns 3853 ns 179813 --------------------------------------------------------------------------- -DirectCall::withReturn 5826 ns 5826 ns 120405 -StdFuncCall::withReturn 5768 ns 5768 ns 120615 -ReflectedCall::withReturn 7147 ns 7147 ns 97322 - -StdFuncMethodCall::withReturn 5783 ns 5783 ns 120537 -ReflectedMethodCall::withReturn 7177 ns 7176 ns 96515 ------------------------------------ ->>> Run 3: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:49:48+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2468.99 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.44, 1.52, 1.22 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3867 ns 3866 ns 184722 -StdFuncCall::noReturn 3813 ns 3813 ns 182052 -ReflectedCall::noReturn 3799 ns 3799 ns 183532 - -StdFuncMethodCall::noReturn 3901 ns 3901 ns 180895 -ReflectedMethodCall::noReturn 3821 ns 3820 ns 180911 --------------------------------------------------------------------------- -DirectCall::withReturn 5694 ns 5694 ns 122739 -StdFuncCall::withReturn 5726 ns 5726 ns 122179 -ReflectedCall::withReturn 7126 ns 7125 ns 99356 - -StdFuncMethodCall::withReturn 5669 ns 5669 ns 120489 -ReflectedMethodCall::withReturn 7014 ns 7013 ns 94851 ------------------------------------ ->>> Run 4: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:49:57+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.37, 1.50, 1.21 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3811 ns 3811 ns 185570 -StdFuncCall::noReturn 4045 ns 4045 ns 173991 -ReflectedCall::noReturn 3913 ns 3913 ns 178008 - -StdFuncMethodCall::noReturn 3858 ns 3858 ns 180877 -ReflectedMethodCall::noReturn 3897 ns 3897 ns 181085 --------------------------------------------------------------------------- -DirectCall::withReturn 5706 ns 5706 ns 118455 -StdFuncCall::withReturn 5694 ns 5693 ns 119512 -ReflectedCall::withReturn 7093 ns 7093 ns 95014 - -StdFuncMethodCall::withReturn 5716 ns 5715 ns 117328 -ReflectedMethodCall::withReturn 7107 ns 7107 ns 92531 ------------------------------------ ->>> Run 5: workload scale = 175 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 175 iterations -============================================= - -2025-09-11T00:50:07+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2389.7 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.34, 1.49, 1.21 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 3823 ns 3822 ns 184164 -StdFuncCall::noReturn 3921 ns 3920 ns 184054 -ReflectedCall::noReturn 3892 ns 3892 ns 181641 - -StdFuncMethodCall::noReturn 3917 ns 3917 ns 182002 -ReflectedMethodCall::noReturn 3937 ns 3937 ns 179719 --------------------------------------------------------------------------- -DirectCall::withReturn 5706 ns 5706 ns 116926 -StdFuncCall::withReturn 5727 ns 5726 ns 122669 -ReflectedCall::withReturn 7154 ns 7153 ns 92948 - -StdFuncMethodCall::withReturn 5696 ns 5695 ns 117101 -ReflectedMethodCall::withReturn 7157 ns 7157 ns 94837 ------------------------------------ ->>> Run 1: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:50:16+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3209.87 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.37, 1.49, 1.22 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4196 ns 4196 ns 170841 -StdFuncCall::noReturn 4197 ns 4197 ns 171474 -ReflectedCall::noReturn 4213 ns 4213 ns 167685 - -StdFuncMethodCall::noReturn 4195 ns 4195 ns 169093 -ReflectedMethodCall::noReturn 4235 ns 4235 ns 167817 --------------------------------------------------------------------------- -DirectCall::withReturn 6403 ns 6401 ns 105705 -StdFuncCall::withReturn 6411 ns 6409 ns 104979 -ReflectedCall::withReturn 7984 ns 7982 ns 83508 - -StdFuncMethodCall::withReturn 6531 ns 6529 ns 106182 -ReflectedMethodCall::withReturn 7987 ns 7986 ns 83759 ------------------------------------ ->>> Run 2: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:50:26+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4359.42 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.47, 1.51, 1.22 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4189 ns 4188 ns 170733 -StdFuncCall::noReturn 4075 ns 4073 ns 173783 -ReflectedCall::noReturn 4062 ns 4062 ns 172155 - -StdFuncMethodCall::noReturn 4036 ns 4036 ns 172871 -ReflectedMethodCall::noReturn 4156 ns 4156 ns 171048 --------------------------------------------------------------------------- -DirectCall::withReturn 6255 ns 6255 ns 107881 -StdFuncCall::withReturn 6202 ns 6201 ns 111269 -ReflectedCall::withReturn 7732 ns 7731 ns 88927 - -StdFuncMethodCall::withReturn 6237 ns 6237 ns 108573 -ReflectedMethodCall::withReturn 7717 ns 7716 ns 87408 ------------------------------------ ->>> Run 3: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:50:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3349.71 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.47, 1.51, 1.23 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4183 ns 4182 ns 172969 -StdFuncCall::noReturn 4158 ns 4158 ns 169661 -ReflectedCall::noReturn 4320 ns 4320 ns 167031 - -StdFuncMethodCall::noReturn 4142 ns 4142 ns 171242 -ReflectedMethodCall::noReturn 4244 ns 4243 ns 167943 --------------------------------------------------------------------------- -DirectCall::withReturn 6215 ns 6214 ns 107561 -StdFuncCall::withReturn 6285 ns 6284 ns 106520 -ReflectedCall::withReturn 7794 ns 7794 ns 86470 - -StdFuncMethodCall::withReturn 6259 ns 6257 ns 109244 -ReflectedMethodCall::withReturn 7877 ns 7876 ns 83397 ------------------------------------ ->>> Run 4: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:50:45+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4518.55 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.56, 1.52, 1.24 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4097 ns 4097 ns 172402 -StdFuncCall::noReturn 4102 ns 4102 ns 171446 -ReflectedCall::noReturn 4218 ns 4217 ns 171091 - -StdFuncMethodCall::noReturn 4080 ns 4080 ns 170058 -ReflectedMethodCall::noReturn 4114 ns 4114 ns 170617 --------------------------------------------------------------------------- -DirectCall::withReturn 6368 ns 6367 ns 109122 -StdFuncCall::withReturn 6411 ns 6410 ns 104101 -ReflectedCall::withReturn 8033 ns 8032 ns 86564 - -StdFuncMethodCall::withReturn 6449 ns 6448 ns 103769 -ReflectedMethodCall::withReturn 8047 ns 8047 ns 82650 ------------------------------------ ->>> Run 5: workload scale = 200 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 200 iterations -============================================= - -2025-09-11T00:50:55+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3507.94 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.55, 1.52, 1.24 --------------------------------------------------------------------------- -Benchmark Time CPU Iterations --------------------------------------------------------------------------- -DirectCall::noReturn 4065 ns 4065 ns 171561 -StdFuncCall::noReturn 4084 ns 4084 ns 174097 -ReflectedCall::noReturn 4206 ns 4205 ns 172296 - -StdFuncMethodCall::noReturn 4229 ns 4229 ns 173534 -ReflectedMethodCall::noReturn 4068 ns 4068 ns 171180 --------------------------------------------------------------------------- -DirectCall::withReturn 6278 ns 6277 ns 111032 -StdFuncCall::withReturn 6352 ns 6351 ns 106040 -ReflectedCall::withReturn 7900 ns 7898 ns 87218 - -StdFuncMethodCall::withReturn 6349 ns 6349 ns 110877 -ReflectedMethodCall::withReturn 7880 ns 7878 ns 84629 ------------------------------------ -All benchmarks completed. diff --git a/text-benchmark-logs/benchmark_runs.log b/text-benchmark-logs/benchmark_runs.log deleted file mode 100644 index c7fa2be8..00000000 --- a/text-benchmark-logs/benchmark_runs.log +++ /dev/null @@ -1,3167 +0,0 @@ -Starting benchmark runs... -Binary: ./bin/RTLBenchmarkApp -Log: ./benchmark_runs.log -=================================== -[2025-10-25 08:18:21] >>> Run 1: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-25T08:18:21+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.45, 0.40, 0.19 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 0.648 ns 0.648 ns 1000000000 - -bm_call::by_FunctionPtr_Function::set_string 1.04 ns 1.04 ns 681434660 -bm_call::by_FunctionPtr___Method::set_string 1.55 ns 1.55 ns 466084139 - -bm_std::function_CallsFunction::set_string 1.52 ns 1.52 ns 457442165 -bm_std::function___CallsMethod::set_string 1.73 ns 1.73 ns 404393007 - -bm_rtl::function_CallsFunction::set_string 1.05 ns 1.05 ns 650597013 -bm_rtl::method_____CallsMethod::set_string 1.67 ns 1.67 ns 419270587 - -bm_rtl::function_ErasedReturnType::set_string 2.82 ns 2.82 ns 247626666 -bm_rtl::method___ErasedReturnType::set_string 3.81 ns 3.81 ns 182981375 -bm_rtl::method___ErasedTargetType::set_string 4.20 ns 4.20 ns 168530894 -bm_rtl::method___ErasedTargetAndReturnType::set_string 4.71 ns 4.71 ns 149802502 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1.40 ns 1.40 ns 478431698 - -bm_call::by_FunctionPtr_Function::get_string 2.78 ns 2.78 ns 258764618 -bm_call::by_FunctionPtr___Method::get_string 2.50 ns 2.50 ns 269105357 - -bm_std::function_CallsFunction::get_string 2.67 ns 2.67 ns 256264788 -bm_std::function___CallsMethod::get_string 2.92 ns 2.92 ns 241666956 - -bm_rtl::function_CallsFunction::get_string 2.48 ns 2.48 ns 281118860 -bm_rtl::method_____CallsMethod::get_string 2.70 ns 2.69 ns 257929875 - -bm_rtl::function_ErasedReturnType::get_string 14.6 ns 14.6 ns 45984040 -bm_rtl::method___ErasedReturnType::get_string 15.1 ns 15.1 ns 44798614 -bm_rtl::method___ErasedTargetType::get_string 5.50 ns 5.50 ns 129984598 -bm_rtl::method___ErasedTargetAndReturnType::get_string 17.4 ns 17.4 ns 40921439 ------------------------------------ -[2025-10-25 08:18:42] >>> Run 2: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-25T08:18:42+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3304.61 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.74, 0.47, 0.22 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 0.648 ns 0.647 ns 1000000000 - -bm_call::by_FunctionPtr_Function::set_string 1.03 ns 1.03 ns 656251881 -bm_call::by_FunctionPtr___Method::set_string 1.44 ns 1.44 ns 476757016 - -bm_std::function_CallsFunction::set_string 1.44 ns 1.44 ns 470314609 -bm_std::function___CallsMethod::set_string 1.65 ns 1.65 ns 417062240 - -bm_rtl::function_CallsFunction::set_string 1.04 ns 1.04 ns 659236438 -bm_rtl::method_____CallsMethod::set_string 1.64 ns 1.64 ns 424815428 - -bm_rtl::function_ErasedReturnType::set_string 2.89 ns 2.89 ns 236586863 -bm_rtl::method___ErasedReturnType::set_string 3.71 ns 3.70 ns 186293054 -bm_rtl::method___ErasedTargetType::set_string 4.20 ns 4.20 ns 167817004 -bm_rtl::method___ErasedTargetAndReturnType::set_string 4.54 ns 4.53 ns 155605148 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1.36 ns 1.36 ns 493932968 - -bm_call::by_FunctionPtr_Function::get_string 2.69 ns 2.69 ns 258479344 -bm_call::by_FunctionPtr___Method::get_string 2.47 ns 2.47 ns 280926161 - -bm_std::function_CallsFunction::get_string 2.68 ns 2.68 ns 259014104 -bm_std::function___CallsMethod::get_string 2.88 ns 2.88 ns 235369356 - -bm_rtl::function_CallsFunction::get_string 2.47 ns 2.47 ns 279617188 -bm_rtl::method_____CallsMethod::get_string 2.68 ns 2.68 ns 261205131 - -bm_rtl::function_ErasedReturnType::get_string 14.6 ns 14.6 ns 48709947 -bm_rtl::method___ErasedReturnType::get_string 15.3 ns 15.3 ns 46894992 -bm_rtl::method___ErasedTargetType::get_string 5.47 ns 5.47 ns 128622322 -bm_rtl::method___ErasedTargetAndReturnType::get_string 17.0 ns 17.0 ns 41823660 ------------------------------------ -[2025-10-25 08:19:02] >>> Run 3: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-25T08:19:02+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.81, 0.51, 0.24 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 0.551 ns 0.551 ns 1000000000 - -bm_call::by_FunctionPtr_Function::set_string 1.03 ns 1.03 ns 658445343 -bm_call::by_FunctionPtr___Method::set_string 1.44 ns 1.44 ns 471488825 - -bm_std::function_CallsFunction::set_string 1.44 ns 1.44 ns 476231396 -bm_std::function___CallsMethod::set_string 1.65 ns 1.65 ns 420945966 - -bm_rtl::function_CallsFunction::set_string 1.03 ns 1.03 ns 664980277 -bm_rtl::method_____CallsMethod::set_string 1.64 ns 1.64 ns 419659954 - -bm_rtl::function_ErasedReturnType::set_string 2.80 ns 2.80 ns 247763482 -bm_rtl::method___ErasedReturnType::set_string 3.71 ns 3.71 ns 186533146 -bm_rtl::method___ErasedTargetType::set_string 4.15 ns 4.15 ns 167655898 -bm_rtl::method___ErasedTargetAndReturnType::set_string 4.59 ns 4.59 ns 152815905 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1.38 ns 1.38 ns 492459263 - -bm_call::by_FunctionPtr_Function::get_string 2.81 ns 2.81 ns 240960786 -bm_call::by_FunctionPtr___Method::get_string 2.47 ns 2.47 ns 280206200 - -bm_std::function_CallsFunction::get_string 2.67 ns 2.67 ns 261693890 -bm_std::function___CallsMethod::get_string 2.89 ns 2.89 ns 239552750 - -bm_rtl::function_CallsFunction::get_string 2.46 ns 2.46 ns 279113400 -bm_rtl::method_____CallsMethod::get_string 2.67 ns 2.67 ns 260583976 - -bm_rtl::function_ErasedReturnType::get_string 15.0 ns 15.0 ns 46074384 -bm_rtl::method___ErasedReturnType::get_string 15.4 ns 15.4 ns 44466471 -bm_rtl::method___ErasedTargetType::get_string 5.49 ns 5.49 ns 126135231 -bm_rtl::method___ErasedTargetAndReturnType::get_string 17.0 ns 17.0 ns 40088742 ------------------------------------ -[2025-10-25 08:19:22] >>> Run 4: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-25T08:19:22+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3789.01 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 0.94, 0.56, 0.26 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 0.734 ns 0.734 ns 1000000000 - -bm_call::by_FunctionPtr_Function::set_string 1.03 ns 1.03 ns 659830073 -bm_call::by_FunctionPtr___Method::set_string 1.44 ns 1.44 ns 480099742 - -bm_std::function_CallsFunction::set_string 1.44 ns 1.44 ns 479828845 -bm_std::function___CallsMethod::set_string 1.65 ns 1.65 ns 418130244 - -bm_rtl::function_CallsFunction::set_string 1.04 ns 1.04 ns 659319071 -bm_rtl::method_____CallsMethod::set_string 1.66 ns 1.66 ns 421905274 - -bm_rtl::function_ErasedReturnType::set_string 2.77 ns 2.77 ns 249634586 -bm_rtl::method___ErasedReturnType::set_string 3.74 ns 3.74 ns 188550991 -bm_rtl::method___ErasedTargetType::set_string 4.12 ns 4.12 ns 166325953 -bm_rtl::method___ErasedTargetAndReturnType::set_string 4.52 ns 4.53 ns 153059766 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1.37 ns 1.37 ns 470510214 - -bm_call::by_FunctionPtr_Function::get_string 2.73 ns 2.74 ns 249330071 -bm_call::by_FunctionPtr___Method::get_string 2.47 ns 2.47 ns 274811981 - -bm_std::function_CallsFunction::get_string 2.66 ns 2.66 ns 259812894 -bm_std::function___CallsMethod::get_string 2.86 ns 2.87 ns 243195723 - -bm_rtl::function_CallsFunction::get_string 2.45 ns 2.46 ns 283467019 -bm_rtl::method_____CallsMethod::get_string 2.66 ns 2.67 ns 260247098 - -bm_rtl::function_ErasedReturnType::get_string 14.0 ns 14.0 ns 47780007 -bm_rtl::method___ErasedReturnType::get_string 15.4 ns 15.4 ns 45943239 -bm_rtl::method___ErasedTargetType::get_string 5.37 ns 5.38 ns 128203773 -bm_rtl::method___ErasedTargetAndReturnType::get_string 16.8 ns 16.8 ns 40999544 ------------------------------------ -[2025-10-25 08:19:43] >>> Run 5: workload scale = 0 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 0 iterations -============================================= - -2025-10-25T08:19:43+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.03, 0.60, 0.29 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 0.631 ns 0.632 ns 1000000000 - -bm_call::by_FunctionPtr_Function::set_string 1.03 ns 1.03 ns 666792792 -bm_call::by_FunctionPtr___Method::set_string 1.46 ns 1.46 ns 473236703 - -bm_std::function_CallsFunction::set_string 1.44 ns 1.45 ns 475143135 -bm_std::function___CallsMethod::set_string 1.65 ns 1.65 ns 418841792 - -bm_rtl::function_CallsFunction::set_string 1.03 ns 1.03 ns 667445817 -bm_rtl::method_____CallsMethod::set_string 1.64 ns 1.65 ns 416846062 - -bm_rtl::function_ErasedReturnType::set_string 2.83 ns 2.83 ns 249324871 -bm_rtl::method___ErasedReturnType::set_string 3.73 ns 3.73 ns 186308314 -bm_rtl::method___ErasedTargetType::set_string 4.13 ns 4.14 ns 169716154 -bm_rtl::method___ErasedTargetAndReturnType::set_string 4.42 ns 4.42 ns 154047402 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1.35 ns 1.35 ns 503328815 - -bm_call::by_FunctionPtr_Function::get_string 2.71 ns 2.71 ns 259229712 -bm_call::by_FunctionPtr___Method::get_string 2.46 ns 2.46 ns 277899881 - -bm_std::function_CallsFunction::get_string 2.67 ns 2.67 ns 258771892 -bm_std::function___CallsMethod::get_string 2.87 ns 2.87 ns 241524683 - -bm_rtl::function_CallsFunction::get_string 2.46 ns 2.46 ns 283237330 -bm_rtl::method_____CallsMethod::get_string 2.68 ns 2.69 ns 257420026 - -bm_rtl::function_ErasedReturnType::get_string 14.5 ns 14.5 ns 48605151 -bm_rtl::method___ErasedReturnType::get_string 14.8 ns 14.8 ns 45921688 -bm_rtl::method___ErasedTargetType::get_string 5.41 ns 5.42 ns 129878520 -bm_rtl::method___ErasedTargetAndReturnType::get_string 16.7 ns 16.7 ns 40744148 ------------------------------------ -[2025-10-25 08:20:03] >>> Run 1: workload scale = 1 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 1 iterations -============================================= - -2025-10-25T08:20:03+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2665.28 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.07, 0.65, 0.31 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 15.0 ns 15.0 ns 46489314 - -bm_call::by_FunctionPtr_Function::set_string 15.5 ns 15.5 ns 44790901 -bm_call::by_FunctionPtr___Method::set_string 15.7 ns 15.7 ns 43399121 - -bm_std::function_CallsFunction::set_string 15.5 ns 15.6 ns 44476865 -bm_std::function___CallsMethod::set_string 16.5 ns 16.5 ns 42190284 - -bm_rtl::function_CallsFunction::set_string 16.1 ns 16.1 ns 42912065 -bm_rtl::method_____CallsMethod::set_string 16.2 ns 16.2 ns 42326302 - -bm_rtl::function_ErasedReturnType::set_string 18.2 ns 18.2 ns 37532677 -bm_rtl::method___ErasedReturnType::set_string 19.2 ns 19.2 ns 35793231 -bm_rtl::method___ErasedTargetType::set_string 19.3 ns 19.3 ns 36200905 -bm_rtl::method___ErasedTargetAndReturnType::set_string 20.6 ns 20.6 ns 33014032 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 25.5 ns 25.5 ns 27311934 - -bm_call::by_FunctionPtr_Function::get_string 25.6 ns 25.6 ns 27089191 -bm_call::by_FunctionPtr___Method::get_string 26.9 ns 26.9 ns 26852749 - -bm_std::function_CallsFunction::get_string 26.7 ns 26.7 ns 26331017 -bm_std::function___CallsMethod::get_string 26.9 ns 27.0 ns 25916070 - -bm_rtl::function_CallsFunction::get_string 23.0 ns 23.0 ns 26905535 -bm_rtl::method_____CallsMethod::get_string 21.7 ns 21.7 ns 31447444 - -bm_rtl::function_ErasedReturnType::get_string 34.8 ns 34.8 ns 19825366 -bm_rtl::method___ErasedReturnType::get_string 36.1 ns 36.1 ns 19592230 -bm_rtl::method___ErasedTargetType::get_string 24.4 ns 24.5 ns 28769601 -bm_rtl::method___ErasedTargetAndReturnType::get_string 37.2 ns 37.2 ns 18695077 ------------------------------------ -[2025-10-25 08:20:24] >>> Run 2: workload scale = 1 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 1 iterations -============================================= - -2025-10-25T08:20:24+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3657.52 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.27, 0.72, 0.34 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 14.6 ns 14.6 ns 46519998 - -bm_call::by_FunctionPtr_Function::set_string 15.1 ns 15.1 ns 46355255 -bm_call::by_FunctionPtr___Method::set_string 15.2 ns 15.2 ns 45793009 - -bm_std::function_CallsFunction::set_string 15.1 ns 15.1 ns 45496352 -bm_std::function___CallsMethod::set_string 15.1 ns 15.1 ns 46803659 - -bm_rtl::function_CallsFunction::set_string 15.3 ns 15.3 ns 44864140 -bm_rtl::method_____CallsMethod::set_string 15.7 ns 15.7 ns 42768352 - -bm_rtl::function_ErasedReturnType::set_string 17.5 ns 17.5 ns 39957227 -bm_rtl::method___ErasedReturnType::set_string 18.1 ns 18.1 ns 38339282 -bm_rtl::method___ErasedTargetType::set_string 18.1 ns 18.1 ns 37281995 -bm_rtl::method___ErasedTargetAndReturnType::set_string 18.5 ns 18.5 ns 36832626 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 23.1 ns 23.1 ns 31436556 - -bm_call::by_FunctionPtr_Function::get_string 21.7 ns 21.7 ns 32182266 -bm_call::by_FunctionPtr___Method::get_string 21.5 ns 21.6 ns 32162869 - -bm_std::function_CallsFunction::get_string 21.9 ns 21.9 ns 30912997 -bm_std::function___CallsMethod::get_string 21.8 ns 21.8 ns 30892316 - -bm_rtl::function_CallsFunction::get_string 21.4 ns 21.4 ns 31993182 -bm_rtl::method_____CallsMethod::get_string 21.9 ns 21.9 ns 31331163 - -bm_rtl::function_ErasedReturnType::get_string 35.7 ns 35.7 ns 19393306 -bm_rtl::method___ErasedReturnType::get_string 36.5 ns 36.5 ns 19212247 -bm_rtl::method___ErasedTargetType::get_string 24.8 ns 24.8 ns 27574548 -bm_rtl::method___ErasedTargetAndReturnType::get_string 37.9 ns 37.9 ns 18644241 ------------------------------------ -[2025-10-25 08:20:44] >>> Run 3: workload scale = 1 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 1 iterations -============================================= - -2025-10-25T08:20:44+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3797.51 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.35, 0.77, 0.37 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 16.0 ns 16.0 ns 41976810 - -bm_call::by_FunctionPtr_Function::set_string 16.0 ns 16.0 ns 41832795 -bm_call::by_FunctionPtr___Method::set_string 16.5 ns 16.5 ns 40619550 - -bm_std::function_CallsFunction::set_string 16.1 ns 16.1 ns 41469240 -bm_std::function___CallsMethod::set_string 16.2 ns 16.2 ns 40420660 - -bm_rtl::function_CallsFunction::set_string 15.0 ns 15.0 ns 46611247 -bm_rtl::method_____CallsMethod::set_string 15.7 ns 15.7 ns 42476573 - -bm_rtl::function_ErasedReturnType::set_string 17.2 ns 17.2 ns 38895808 -bm_rtl::method___ErasedReturnType::set_string 17.8 ns 17.8 ns 38234678 -bm_rtl::method___ErasedTargetType::set_string 17.9 ns 17.9 ns 37495782 -bm_rtl::method___ErasedTargetAndReturnType::set_string 18.5 ns 18.6 ns 36640863 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 22.5 ns 22.5 ns 30463924 - -bm_call::by_FunctionPtr_Function::get_string 22.5 ns 22.5 ns 30610948 -bm_call::by_FunctionPtr___Method::get_string 22.5 ns 22.5 ns 30735698 - -bm_std::function_CallsFunction::get_string 22.4 ns 22.4 ns 31197397 -bm_std::function___CallsMethod::get_string 22.3 ns 22.3 ns 31234800 - -bm_rtl::function_CallsFunction::get_string 22.6 ns 22.6 ns 30567039 -bm_rtl::method_____CallsMethod::get_string 22.6 ns 22.6 ns 31412197 - -bm_rtl::function_ErasedReturnType::get_string 34.5 ns 34.5 ns 20465307 -bm_rtl::method___ErasedReturnType::get_string 37.3 ns 37.3 ns 19304351 -bm_rtl::method___ErasedTargetType::get_string 28.7 ns 28.7 ns 24064394 -bm_rtl::method___ErasedTargetAndReturnType::get_string 38.6 ns 38.6 ns 18326204 ------------------------------------ -[2025-10-25 08:21:05] >>> Run 1: workload scale = 5 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 5 iterations -============================================= - -2025-10-25T08:21:05+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3520.89 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.31, 0.81, 0.39 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 98.2 ns 98.2 ns 6889902 - -bm_call::by_FunctionPtr_Function::set_string 97.1 ns 97.1 ns 7004090 -bm_call::by_FunctionPtr___Method::set_string 97.9 ns 97.9 ns 6941573 - -bm_std::function_CallsFunction::set_string 98.7 ns 98.7 ns 6766823 -bm_std::function___CallsMethod::set_string 97.5 ns 97.5 ns 7061625 - -bm_rtl::function_CallsFunction::set_string 98.3 ns 98.4 ns 6919195 -bm_rtl::method_____CallsMethod::set_string 98.6 ns 98.6 ns 6678480 - -bm_rtl::function_ErasedReturnType::set_string 100 ns 100 ns 6659211 -bm_rtl::method___ErasedReturnType::set_string 100 ns 100 ns 6865663 -bm_rtl::method___ErasedTargetType::set_string 101 ns 101 ns 6373256 -bm_rtl::method___ErasedTargetAndReturnType::set_string 102 ns 102 ns 6645843 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 134 ns 134 ns 5151911 - -bm_call::by_FunctionPtr_Function::get_string 135 ns 135 ns 4779355 -bm_call::by_FunctionPtr___Method::get_string 135 ns 135 ns 4882235 - -bm_std::function_CallsFunction::get_string 136 ns 136 ns 4897122 -bm_std::function___CallsMethod::get_string 135 ns 135 ns 5014591 - -bm_rtl::function_CallsFunction::get_string 136 ns 136 ns 4824411 -bm_rtl::method_____CallsMethod::get_string 137 ns 137 ns 4978156 - -bm_rtl::function_ErasedReturnType::get_string 145 ns 145 ns 4625178 -bm_rtl::method___ErasedReturnType::get_string 146 ns 146 ns 4599328 -bm_rtl::method___ErasedTargetType::get_string 133 ns 133 ns 5050703 -bm_rtl::method___ErasedTargetAndReturnType::get_string 147 ns 147 ns 4767692 ------------------------------------ -[2025-10-25 08:21:23] >>> Run 2: workload scale = 5 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 5 iterations -============================================= - -2025-10-25T08:21:23+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3841.43 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.31, 0.83, 0.40 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 100 ns 100 ns 6692322 - -bm_call::by_FunctionPtr_Function::set_string 100 ns 100 ns 6766344 -bm_call::by_FunctionPtr___Method::set_string 102 ns 102 ns 6727036 - -bm_std::function_CallsFunction::set_string 100 ns 100 ns 6540251 -bm_std::function___CallsMethod::set_string 103 ns 103 ns 6233534 - -bm_rtl::function_CallsFunction::set_string 97.8 ns 97.8 ns 6866111 -bm_rtl::method_____CallsMethod::set_string 98.7 ns 98.7 ns 6727472 - -bm_rtl::function_ErasedReturnType::set_string 100 ns 100 ns 6586303 -bm_rtl::method___ErasedReturnType::set_string 100 ns 100 ns 6710424 -bm_rtl::method___ErasedTargetType::set_string 101 ns 101 ns 6570920 -bm_rtl::method___ErasedTargetAndReturnType::set_string 102 ns 102 ns 6713114 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 119 ns 119 ns 5588782 - -bm_call::by_FunctionPtr_Function::get_string 123 ns 123 ns 5512353 -bm_call::by_FunctionPtr___Method::get_string 125 ns 125 ns 5361141 - -bm_std::function_CallsFunction::get_string 124 ns 124 ns 5343909 -bm_std::function___CallsMethod::get_string 124 ns 124 ns 5593743 - -bm_rtl::function_CallsFunction::get_string 124 ns 124 ns 5386510 -bm_rtl::method_____CallsMethod::get_string 122 ns 122 ns 5453558 - -bm_rtl::function_ErasedReturnType::get_string 128 ns 128 ns 5400261 -bm_rtl::method___ErasedReturnType::get_string 128 ns 128 ns 5195725 -bm_rtl::method___ErasedTargetType::get_string 120 ns 120 ns 5725123 -bm_rtl::method___ErasedTargetAndReturnType::get_string 132 ns 132 ns 5119969 ------------------------------------ -[2025-10-25 08:21:40] >>> Run 3: workload scale = 5 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 5 iterations -============================================= - -2025-10-25T08:21:40+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4517.2 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.54, 0.91, 0.44 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 96.1 ns 96.1 ns 6860471 - -bm_call::by_FunctionPtr_Function::set_string 98.1 ns 98.1 ns 6906275 -bm_call::by_FunctionPtr___Method::set_string 97.6 ns 97.6 ns 6744491 - -bm_std::function_CallsFunction::set_string 98.2 ns 98.2 ns 6716549 -bm_std::function___CallsMethod::set_string 98.1 ns 98.1 ns 6809655 - -bm_rtl::function_CallsFunction::set_string 97.3 ns 97.3 ns 7019050 -bm_rtl::method_____CallsMethod::set_string 97.6 ns 97.6 ns 6872439 - -bm_rtl::function_ErasedReturnType::set_string 99.1 ns 99.2 ns 6930500 -bm_rtl::method___ErasedReturnType::set_string 101 ns 101 ns 6748918 -bm_rtl::method___ErasedTargetType::set_string 102 ns 102 ns 6567633 -bm_rtl::method___ErasedTargetAndReturnType::set_string 101 ns 101 ns 6057670 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 118 ns 118 ns 5842333 - -bm_call::by_FunctionPtr_Function::get_string 118 ns 118 ns 5652674 -bm_call::by_FunctionPtr___Method::get_string 118 ns 118 ns 5739336 - -bm_std::function_CallsFunction::get_string 119 ns 119 ns 5696574 -bm_std::function___CallsMethod::get_string 118 ns 118 ns 5647767 - -bm_rtl::function_CallsFunction::get_string 117 ns 117 ns 5846432 -bm_rtl::method_____CallsMethod::get_string 117 ns 117 ns 5843085 - -bm_rtl::function_ErasedReturnType::get_string 129 ns 129 ns 5403621 -bm_rtl::method___ErasedReturnType::get_string 131 ns 131 ns 4977944 -bm_rtl::method___ErasedTargetType::get_string 118 ns 118 ns 5719642 -bm_rtl::method___ErasedTargetAndReturnType::get_string 132 ns 132 ns 5019900 ------------------------------------ -[2025-10-25 08:21:58] >>> Run 1: workload scale = 10 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 10 iterations -============================================= - -2025-10-25T08:21:58+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1121.39 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.58, 0.95, 0.46 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 164 ns 164 ns 4069799 - -bm_call::by_FunctionPtr_Function::set_string 166 ns 166 ns 4054108 -bm_call::by_FunctionPtr___Method::set_string 165 ns 165 ns 4054498 - -bm_std::function_CallsFunction::set_string 166 ns 166 ns 4123163 -bm_std::function___CallsMethod::set_string 165 ns 165 ns 4023412 - -bm_rtl::function_CallsFunction::set_string 166 ns 166 ns 4058757 -bm_rtl::method_____CallsMethod::set_string 166 ns 166 ns 4110012 - -bm_rtl::function_ErasedReturnType::set_string 167 ns 167 ns 4151252 -bm_rtl::method___ErasedReturnType::set_string 167 ns 167 ns 4149683 -bm_rtl::method___ErasedTargetType::set_string 169 ns 169 ns 4025346 -bm_rtl::method___ErasedTargetAndReturnType::set_string 169 ns 169 ns 3998850 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 213 ns 213 ns 3240485 - -bm_call::by_FunctionPtr_Function::get_string 215 ns 215 ns 3236431 -bm_call::by_FunctionPtr___Method::get_string 214 ns 214 ns 3203988 - -bm_std::function_CallsFunction::get_string 213 ns 213 ns 3227674 -bm_std::function___CallsMethod::get_string 214 ns 214 ns 3157838 - -bm_rtl::function_CallsFunction::get_string 213 ns 213 ns 3203868 -bm_rtl::method_____CallsMethod::get_string 214 ns 214 ns 3273507 - -bm_rtl::function_ErasedReturnType::get_string 220 ns 220 ns 3105014 -bm_rtl::method___ErasedReturnType::get_string 222 ns 222 ns 3154485 -bm_rtl::method___ErasedTargetType::get_string 214 ns 214 ns 3149977 -bm_rtl::method___ErasedTargetAndReturnType::get_string 224 ns 224 ns 3085534 ------------------------------------ -[2025-10-25 08:22:18] >>> Run 2: workload scale = 10 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 10 iterations -============================================= - -2025-10-25T08:22:18+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4442.84 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.75, 1.03, 0.50 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 168 ns 168 ns 3978102 - -bm_call::by_FunctionPtr_Function::set_string 168 ns 168 ns 4051326 -bm_call::by_FunctionPtr___Method::set_string 168 ns 168 ns 4156354 - -bm_std::function_CallsFunction::set_string 166 ns 166 ns 4053881 -bm_std::function___CallsMethod::set_string 168 ns 168 ns 4052544 - -bm_rtl::function_CallsFunction::set_string 165 ns 165 ns 4085161 -bm_rtl::method_____CallsMethod::set_string 166 ns 166 ns 4101420 - -bm_rtl::function_ErasedReturnType::set_string 171 ns 171 ns 3969963 -bm_rtl::method___ErasedReturnType::set_string 170 ns 170 ns 3995007 -bm_rtl::method___ErasedTargetType::set_string 170 ns 170 ns 3985711 -bm_rtl::method___ErasedTargetAndReturnType::set_string 169 ns 169 ns 4067461 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 213 ns 213 ns 3277607 - -bm_call::by_FunctionPtr_Function::get_string 215 ns 215 ns 3201902 -bm_call::by_FunctionPtr___Method::get_string 212 ns 212 ns 2962783 - -bm_std::function_CallsFunction::get_string 211 ns 211 ns 3245056 -bm_std::function___CallsMethod::get_string 216 ns 216 ns 3297880 - -bm_rtl::function_CallsFunction::get_string 212 ns 212 ns 3128085 -bm_rtl::method_____CallsMethod::get_string 216 ns 216 ns 3176378 - -bm_rtl::function_ErasedReturnType::get_string 221 ns 221 ns 3122756 -bm_rtl::method___ErasedReturnType::get_string 222 ns 222 ns 3115933 -bm_rtl::method___ErasedTargetType::get_string 218 ns 218 ns 3137484 -bm_rtl::method___ErasedTargetAndReturnType::get_string 224 ns 224 ns 3070469 ------------------------------------ -[2025-10-25 08:22:38] >>> Run 3: workload scale = 10 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 10 iterations -============================================= - -2025-10-25T08:22:38+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4020.04 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.68, 1.06, 0.52 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 167 ns 167 ns 4001035 - -bm_call::by_FunctionPtr_Function::set_string 166 ns 166 ns 4080216 -bm_call::by_FunctionPtr___Method::set_string 167 ns 167 ns 4190485 - -bm_std::function_CallsFunction::set_string 166 ns 166 ns 4129880 -bm_std::function___CallsMethod::set_string 167 ns 167 ns 4222833 - -bm_rtl::function_CallsFunction::set_string 168 ns 168 ns 4095875 -bm_rtl::method_____CallsMethod::set_string 168 ns 168 ns 3969292 - -bm_rtl::function_ErasedReturnType::set_string 169 ns 169 ns 4020936 -bm_rtl::method___ErasedReturnType::set_string 169 ns 169 ns 3922265 -bm_rtl::method___ErasedTargetType::set_string 170 ns 170 ns 4018842 -bm_rtl::method___ErasedTargetAndReturnType::set_string 172 ns 172 ns 3928258 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 217 ns 217 ns 3194965 - -bm_call::by_FunctionPtr_Function::get_string 212 ns 212 ns 3253014 -bm_call::by_FunctionPtr___Method::get_string 215 ns 215 ns 3220321 - -bm_std::function_CallsFunction::get_string 213 ns 213 ns 3164498 -bm_std::function___CallsMethod::get_string 216 ns 216 ns 3260806 - -bm_rtl::function_CallsFunction::get_string 211 ns 211 ns 3206234 -bm_rtl::method_____CallsMethod::get_string 216 ns 216 ns 3279560 - -bm_rtl::function_ErasedReturnType::get_string 221 ns 221 ns 3067409 -bm_rtl::method___ErasedReturnType::get_string 222 ns 222 ns 3161991 -bm_rtl::method___ErasedTargetType::get_string 215 ns 215 ns 3267470 -bm_rtl::method___ErasedTargetAndReturnType::get_string 224 ns 224 ns 3170448 ------------------------------------ -[2025-10-25 08:22:58] >>> Run 1: workload scale = 15 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 15 iterations -============================================= - -2025-10-25T08:22:58+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4363.94 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.49, 1.06, 0.53 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 199 ns 199 ns 3361772 - -bm_call::by_FunctionPtr_Function::set_string 200 ns 200 ns 3530667 -bm_call::by_FunctionPtr___Method::set_string 198 ns 198 ns 3398436 - -bm_std::function_CallsFunction::set_string 200 ns 200 ns 3366241 -bm_std::function___CallsMethod::set_string 201 ns 201 ns 3421104 - -bm_rtl::function_CallsFunction::set_string 196 ns 196 ns 3494923 -bm_rtl::method_____CallsMethod::set_string 200 ns 200 ns 3446454 - -bm_rtl::function_ErasedReturnType::set_string 205 ns 205 ns 3356999 -bm_rtl::method___ErasedReturnType::set_string 201 ns 201 ns 3478117 -bm_rtl::method___ErasedTargetType::set_string 207 ns 207 ns 3352277 -bm_rtl::method___ErasedTargetAndReturnType::set_string 204 ns 204 ns 3373659 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 260 ns 260 ns 2664406 - -bm_call::by_FunctionPtr_Function::get_string 262 ns 262 ns 2695726 -bm_call::by_FunctionPtr___Method::get_string 264 ns 264 ns 2634217 - -bm_std::function_CallsFunction::get_string 265 ns 265 ns 2651289 -bm_std::function___CallsMethod::get_string 267 ns 267 ns 2593115 - -bm_rtl::function_CallsFunction::get_string 263 ns 263 ns 2621767 -bm_rtl::method_____CallsMethod::get_string 262 ns 262 ns 2635351 - -bm_rtl::function_ErasedReturnType::get_string 266 ns 266 ns 2598312 -bm_rtl::method___ErasedReturnType::get_string 266 ns 266 ns 2631091 -bm_rtl::method___ErasedTargetType::get_string 264 ns 264 ns 2622779 -bm_rtl::method___ErasedTargetAndReturnType::get_string 267 ns 267 ns 2585988 ------------------------------------ -[2025-10-25 08:23:19] >>> Run 2: workload scale = 15 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 15 iterations -============================================= - -2025-10-25T08:23:19+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3406.12 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.38, 1.07, 0.55 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 228 ns 228 ns 3011429 - -bm_call::by_FunctionPtr_Function::set_string 210 ns 210 ns 3332108 -bm_call::by_FunctionPtr___Method::set_string 209 ns 209 ns 3292897 - -bm_std::function_CallsFunction::set_string 209 ns 209 ns 3315961 -bm_std::function___CallsMethod::set_string 200 ns 200 ns 3503400 - -bm_rtl::function_CallsFunction::set_string 212 ns 212 ns 3332068 -bm_rtl::method_____CallsMethod::set_string 210 ns 210 ns 3232850 - -bm_rtl::function_ErasedReturnType::set_string 202 ns 202 ns 3360085 -bm_rtl::method___ErasedReturnType::set_string 202 ns 202 ns 3416690 -bm_rtl::method___ErasedTargetType::set_string 199 ns 199 ns 3342178 -bm_rtl::method___ErasedTargetAndReturnType::set_string 205 ns 205 ns 3372374 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 312 ns 312 ns 2380574 - -bm_call::by_FunctionPtr_Function::get_string 304 ns 304 ns 2248341 -bm_call::by_FunctionPtr___Method::get_string 305 ns 305 ns 2263551 - -bm_std::function_CallsFunction::get_string 272 ns 272 ns 2555796 -bm_std::function___CallsMethod::get_string 258 ns 258 ns 2690258 - -bm_rtl::function_CallsFunction::get_string 268 ns 268 ns 2603528 -bm_rtl::method_____CallsMethod::get_string 270 ns 270 ns 2558733 - -bm_rtl::function_ErasedReturnType::get_string 267 ns 267 ns 2585635 -bm_rtl::method___ErasedReturnType::get_string 263 ns 263 ns 2639753 -bm_rtl::method___ErasedTargetType::get_string 258 ns 258 ns 2633615 -bm_rtl::method___ErasedTargetAndReturnType::get_string 267 ns 267 ns 2577062 ------------------------------------ -[2025-10-25 08:23:40] >>> Run 3: workload scale = 15 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 15 iterations -============================================= - -2025-10-25T08:23:40+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1259.19 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.41, 1.10, 0.57 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 198 ns 198 ns 3489418 - -bm_call::by_FunctionPtr_Function::set_string 198 ns 198 ns 3495888 -bm_call::by_FunctionPtr___Method::set_string 203 ns 203 ns 3450549 - -bm_std::function_CallsFunction::set_string 198 ns 198 ns 3432590 -bm_std::function___CallsMethod::set_string 200 ns 200 ns 3518722 - -bm_rtl::function_CallsFunction::set_string 196 ns 196 ns 3513293 -bm_rtl::method_____CallsMethod::set_string 199 ns 199 ns 3470396 - -bm_rtl::function_ErasedReturnType::set_string 202 ns 202 ns 3415664 -bm_rtl::method___ErasedReturnType::set_string 203 ns 203 ns 3428745 -bm_rtl::method___ErasedTargetType::set_string 205 ns 205 ns 3356545 -bm_rtl::method___ErasedTargetAndReturnType::set_string 226 ns 226 ns 3047738 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 300 ns 300 ns 2316121 - -bm_call::by_FunctionPtr_Function::get_string 304 ns 304 ns 2291577 -bm_call::by_FunctionPtr___Method::get_string 304 ns 304 ns 2295085 - -bm_std::function_CallsFunction::get_string 299 ns 299 ns 2281782 -bm_std::function___CallsMethod::get_string 283 ns 283 ns 2318211 - -bm_rtl::function_CallsFunction::get_string 254 ns 254 ns 2666980 -bm_rtl::method_____CallsMethod::get_string 256 ns 256 ns 2707601 - -bm_rtl::function_ErasedReturnType::get_string 263 ns 263 ns 2628819 -bm_rtl::method___ErasedReturnType::get_string 263 ns 263 ns 2619550 -bm_rtl::method___ErasedTargetType::get_string 256 ns 256 ns 2732110 -bm_rtl::method___ErasedTargetAndReturnType::get_string 265 ns 265 ns 2670969 ------------------------------------ -[2025-10-25 08:24:01] >>> Run 1: workload scale = 20 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 20 iterations -============================================= - -2025-10-25T08:24:01+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3905.37 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.52, 1.14, 0.60 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 283 ns 283 ns 2501203 - -bm_call::by_FunctionPtr_Function::set_string 282 ns 281 ns 2459533 -bm_call::by_FunctionPtr___Method::set_string 284 ns 284 ns 2450814 - -bm_std::function_CallsFunction::set_string 281 ns 281 ns 2453704 -bm_std::function___CallsMethod::set_string 277 ns 277 ns 2518160 - -bm_rtl::function_CallsFunction::set_string 281 ns 281 ns 2522655 -bm_rtl::method_____CallsMethod::set_string 282 ns 282 ns 2437387 - -bm_rtl::function_ErasedReturnType::set_string 282 ns 282 ns 2416455 -bm_rtl::method___ErasedReturnType::set_string 283 ns 283 ns 2505911 -bm_rtl::method___ErasedTargetType::set_string 276 ns 276 ns 2455881 -bm_rtl::method___ErasedTargetAndReturnType::set_string 282 ns 282 ns 2461023 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 388 ns 388 ns 1810444 - -bm_call::by_FunctionPtr_Function::get_string 401 ns 401 ns 1743086 -bm_call::by_FunctionPtr___Method::get_string 403 ns 403 ns 1771226 - -bm_std::function_CallsFunction::get_string 402 ns 402 ns 1777319 -bm_std::function___CallsMethod::get_string 402 ns 402 ns 1771757 - -bm_rtl::function_CallsFunction::get_string 395 ns 395 ns 1754995 -bm_rtl::method_____CallsMethod::get_string 405 ns 405 ns 1756312 - -bm_rtl::function_ErasedReturnType::get_string 466 ns 466 ns 1693433 -bm_rtl::method___ErasedReturnType::get_string 479 ns 479 ns 1483174 -bm_rtl::method___ErasedTargetType::get_string 456 ns 456 ns 1527682 -bm_rtl::method___ErasedTargetAndReturnType::get_string 481 ns 481 ns 1479821 ------------------------------------ -[2025-10-25 08:24:25] >>> Run 2: workload scale = 20 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 20 iterations -============================================= - -2025-10-25T08:24:25+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4492.67 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.65, 1.21, 0.64 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 285 ns 285 ns 2441453 - -bm_call::by_FunctionPtr_Function::set_string 309 ns 309 ns 2241751 -bm_call::by_FunctionPtr___Method::set_string 284 ns 284 ns 2406971 - -bm_std::function_CallsFunction::set_string 282 ns 282 ns 2456674 -bm_std::function___CallsMethod::set_string 279 ns 279 ns 2435726 - -bm_rtl::function_CallsFunction::set_string 282 ns 282 ns 2435486 -bm_rtl::method_____CallsMethod::set_string 283 ns 283 ns 2499768 - -bm_rtl::function_ErasedReturnType::set_string 313 ns 313 ns 2216865 -bm_rtl::method___ErasedReturnType::set_string 319 ns 319 ns 2214151 -bm_rtl::method___ErasedTargetType::set_string 284 ns 284 ns 2405765 -bm_rtl::method___ErasedTargetAndReturnType::set_string 321 ns 321 ns 2262805 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 455 ns 455 ns 1553877 - -bm_call::by_FunctionPtr_Function::get_string 460 ns 460 ns 1551413 -bm_call::by_FunctionPtr___Method::get_string 455 ns 455 ns 1551524 - -bm_std::function_CallsFunction::get_string 451 ns 451 ns 1539290 -bm_std::function___CallsMethod::get_string 461 ns 461 ns 1547633 - -bm_rtl::function_CallsFunction::get_string 455 ns 455 ns 1552175 -bm_rtl::method_____CallsMethod::get_string 454 ns 454 ns 1554256 - -bm_rtl::function_ErasedReturnType::get_string 484 ns 484 ns 1475111 -bm_rtl::method___ErasedReturnType::get_string 484 ns 484 ns 1470290 -bm_rtl::method___ErasedTargetType::get_string 455 ns 455 ns 1533822 -bm_rtl::method___ErasedTargetAndReturnType::get_string 471 ns 471 ns 1484570 ------------------------------------ -[2025-10-25 08:24:50] >>> Run 3: workload scale = 20 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 20 iterations -============================================= - -2025-10-25T08:24:50+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3892.7 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.69, 1.25, 0.67 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 310 ns 310 ns 2264442 - -bm_call::by_FunctionPtr_Function::set_string 311 ns 311 ns 2202797 -bm_call::by_FunctionPtr___Method::set_string 281 ns 281 ns 2449804 - -bm_std::function_CallsFunction::set_string 278 ns 278 ns 2446273 -bm_std::function___CallsMethod::set_string 279 ns 279 ns 2471984 - -bm_rtl::function_CallsFunction::set_string 277 ns 277 ns 2481374 -bm_rtl::method_____CallsMethod::set_string 281 ns 281 ns 2518203 - -bm_rtl::function_ErasedReturnType::set_string 277 ns 277 ns 2462013 -bm_rtl::method___ErasedReturnType::set_string 283 ns 283 ns 2524713 -bm_rtl::method___ErasedTargetType::set_string 283 ns 283 ns 2456834 -bm_rtl::method___ErasedTargetAndReturnType::set_string 284 ns 284 ns 2438519 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 447 ns 447 ns 1576527 - -bm_call::by_FunctionPtr_Function::get_string 457 ns 457 ns 1563160 -bm_call::by_FunctionPtr___Method::get_string 459 ns 459 ns 1545299 - -bm_std::function_CallsFunction::get_string 413 ns 413 ns 1546368 -bm_std::function___CallsMethod::get_string 394 ns 394 ns 1756190 - -bm_rtl::function_CallsFunction::get_string 403 ns 403 ns 1764987 -bm_rtl::method_____CallsMethod::get_string 403 ns 403 ns 1792886 - -bm_rtl::function_ErasedReturnType::get_string 421 ns 421 ns 1688043 -bm_rtl::method___ErasedReturnType::get_string 422 ns 422 ns 1684851 -bm_rtl::method___ErasedTargetType::get_string 409 ns 409 ns 1757196 -bm_rtl::method___ErasedTargetAndReturnType::get_string 425 ns 425 ns 1666642 ------------------------------------ -[2025-10-25 08:25:14] >>> Run 1: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-10-25T08:25:14+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1952.85 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.46, 1.23, 0.68 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 325 ns 325 ns 2129647 - -bm_call::by_FunctionPtr_Function::set_string 325 ns 325 ns 2170705 -bm_call::by_FunctionPtr___Method::set_string 320 ns 320 ns 2157738 - -bm_std::function_CallsFunction::set_string 323 ns 323 ns 2157761 -bm_std::function___CallsMethod::set_string 326 ns 326 ns 2155660 - -bm_rtl::function_CallsFunction::set_string 320 ns 320 ns 2164697 -bm_rtl::method_____CallsMethod::set_string 324 ns 324 ns 2153530 - -bm_rtl::function_ErasedReturnType::set_string 337 ns 337 ns 2059035 -bm_rtl::method___ErasedReturnType::set_string 335 ns 335 ns 2102518 -bm_rtl::method___ErasedTargetType::set_string 330 ns 330 ns 2092067 -bm_rtl::method___ErasedTargetAndReturnType::set_string 341 ns 341 ns 2100353 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 522 ns 522 ns 1333442 - -bm_call::by_FunctionPtr_Function::get_string 518 ns 518 ns 1335447 -bm_call::by_FunctionPtr___Method::get_string 524 ns 524 ns 1267263 - -bm_std::function_CallsFunction::get_string 519 ns 519 ns 1265282 -bm_std::function___CallsMethod::get_string 518 ns 518 ns 1272629 - -bm_rtl::function_CallsFunction::get_string 522 ns 522 ns 1278100 -bm_rtl::method_____CallsMethod::get_string 476 ns 476 ns 1516375 - -bm_rtl::function_ErasedReturnType::get_string 486 ns 486 ns 1389634 -bm_rtl::method___ErasedReturnType::get_string 485 ns 485 ns 1363658 -bm_rtl::method___ErasedTargetType::get_string 464 ns 464 ns 1509898 -bm_rtl::method___ErasedTargetAndReturnType::get_string 496 ns 496 ns 1437235 ------------------------------------ -[2025-10-25 08:25:35] >>> Run 2: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-10-25T08:25:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 968.875 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.54, 1.27, 0.70 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 320 ns 320 ns 2208206 - -bm_call::by_FunctionPtr_Function::set_string 319 ns 319 ns 2195587 -bm_call::by_FunctionPtr___Method::set_string 309 ns 309 ns 2208978 - -bm_std::function_CallsFunction::set_string 321 ns 321 ns 2250497 -bm_std::function___CallsMethod::set_string 317 ns 317 ns 2213322 - -bm_rtl::function_CallsFunction::set_string 312 ns 312 ns 2217980 -bm_rtl::method_____CallsMethod::set_string 316 ns 316 ns 2221718 - -bm_rtl::function_ErasedReturnType::set_string 320 ns 320 ns 2185990 -bm_rtl::method___ErasedReturnType::set_string 319 ns 319 ns 2169884 -bm_rtl::method___ErasedTargetType::set_string 320 ns 320 ns 2173336 -bm_rtl::method___ErasedTargetAndReturnType::set_string 321 ns 321 ns 2165718 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 470 ns 470 ns 1523263 - -bm_call::by_FunctionPtr_Function::get_string 471 ns 471 ns 1517079 -bm_call::by_FunctionPtr___Method::get_string 467 ns 467 ns 1527828 - -bm_std::function_CallsFunction::get_string 471 ns 471 ns 1527036 -bm_std::function___CallsMethod::get_string 476 ns 476 ns 1503885 - -bm_rtl::function_CallsFunction::get_string 476 ns 476 ns 1508360 -bm_rtl::method_____CallsMethod::get_string 473 ns 473 ns 1510504 - -bm_rtl::function_ErasedReturnType::get_string 481 ns 481 ns 1372771 -bm_rtl::method___ErasedReturnType::get_string 478 ns 478 ns 1472287 -bm_rtl::method___ErasedTargetType::get_string 481 ns 481 ns 1484371 -bm_rtl::method___ErasedTargetAndReturnType::get_string 483 ns 483 ns 1390696 ------------------------------------ -[2025-10-25 08:25:59] >>> Run 3: workload scale = 25 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 25 iterations -============================================= - -2025-10-25T08:25:59+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4691.33 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.68, 1.32, 0.74 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 322 ns 322 ns 2178890 - -bm_call::by_FunctionPtr_Function::set_string 323 ns 323 ns 2180391 -bm_call::by_FunctionPtr___Method::set_string 322 ns 322 ns 2181922 - -bm_std::function_CallsFunction::set_string 321 ns 321 ns 2173138 -bm_std::function___CallsMethod::set_string 317 ns 317 ns 2184692 - -bm_rtl::function_CallsFunction::set_string 313 ns 313 ns 2218258 -bm_rtl::method_____CallsMethod::set_string 318 ns 318 ns 2252143 - -bm_rtl::function_ErasedReturnType::set_string 326 ns 326 ns 2144037 -bm_rtl::method___ErasedReturnType::set_string 326 ns 326 ns 2166888 -bm_rtl::method___ErasedTargetType::set_string 325 ns 325 ns 2129620 -bm_rtl::method___ErasedTargetAndReturnType::set_string 326 ns 326 ns 2128004 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 464 ns 464 ns 1510116 - -bm_call::by_FunctionPtr_Function::get_string 459 ns 459 ns 1530899 -bm_call::by_FunctionPtr___Method::get_string 460 ns 460 ns 1530126 - -bm_std::function_CallsFunction::get_string 474 ns 474 ns 1511348 -bm_std::function___CallsMethod::get_string 465 ns 465 ns 1515448 - -bm_rtl::function_CallsFunction::get_string 470 ns 470 ns 1502887 -bm_rtl::method_____CallsMethod::get_string 469 ns 469 ns 1516318 - -bm_rtl::function_ErasedReturnType::get_string 483 ns 483 ns 1473870 -bm_rtl::method___ErasedReturnType::get_string 480 ns 480 ns 1460097 -bm_rtl::method___ErasedTargetType::get_string 469 ns 469 ns 1513756 -bm_rtl::method___ErasedTargetAndReturnType::get_string 497 ns 497 ns 1457855 ------------------------------------ -[2025-10-25 08:26:24] >>> Run 1: workload scale = 30 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 30 iterations -============================================= - -2025-10-25T08:26:24+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3140.67 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.98, 1.43, 0.79 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 373 ns 373 ns 1909657 - -bm_call::by_FunctionPtr_Function::set_string 366 ns 366 ns 1931781 -bm_call::by_FunctionPtr___Method::set_string 361 ns 361 ns 1909844 - -bm_std::function_CallsFunction::set_string 360 ns 360 ns 1943490 -bm_std::function___CallsMethod::set_string 371 ns 371 ns 1924831 - -bm_rtl::function_CallsFunction::set_string 388 ns 388 ns 1864646 -bm_rtl::method_____CallsMethod::set_string 374 ns 374 ns 1830562 - -bm_rtl::function_ErasedReturnType::set_string 402 ns 402 ns 1808169 -bm_rtl::method___ErasedReturnType::set_string 418 ns 418 ns 1667832 -bm_rtl::method___ErasedTargetType::set_string 376 ns 376 ns 1916355 -bm_rtl::method___ErasedTargetAndReturnType::set_string 370 ns 370 ns 1907324 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 522 ns 522 ns 1325773 - -bm_call::by_FunctionPtr_Function::get_string 527 ns 527 ns 1318536 -bm_call::by_FunctionPtr___Method::get_string 527 ns 527 ns 1297988 - -bm_std::function_CallsFunction::get_string 530 ns 530 ns 1315804 -bm_std::function___CallsMethod::get_string 527 ns 527 ns 1303359 - -bm_rtl::function_CallsFunction::get_string 525 ns 525 ns 1325287 -bm_rtl::method_____CallsMethod::get_string 526 ns 526 ns 1330457 - -bm_rtl::function_ErasedReturnType::get_string 547 ns 547 ns 1272551 -bm_rtl::method___ErasedReturnType::get_string 542 ns 542 ns 1269963 -bm_rtl::method___ErasedTargetType::get_string 532 ns 532 ns 1317687 -bm_rtl::method___ErasedTargetAndReturnType::get_string 547 ns 547 ns 1282806 ------------------------------------ -[2025-10-25 08:26:45] >>> Run 2: workload scale = 30 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 30 iterations -============================================= - -2025-10-25T08:26:45+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3432.96 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.77, 1.41, 0.80 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 362 ns 362 ns 1945387 - -bm_call::by_FunctionPtr_Function::set_string 359 ns 359 ns 1963574 -bm_call::by_FunctionPtr___Method::set_string 360 ns 360 ns 1930130 - -bm_std::function_CallsFunction::set_string 361 ns 361 ns 1965409 -bm_std::function___CallsMethod::set_string 357 ns 357 ns 1956066 - -bm_rtl::function_CallsFunction::set_string 358 ns 358 ns 1949217 -bm_rtl::method_____CallsMethod::set_string 361 ns 361 ns 1903211 - -bm_rtl::function_ErasedReturnType::set_string 391 ns 391 ns 1901142 -bm_rtl::method___ErasedReturnType::set_string 372 ns 372 ns 1806889 -bm_rtl::method___ErasedTargetType::set_string 365 ns 365 ns 1902457 -bm_rtl::method___ErasedTargetAndReturnType::set_string 368 ns 368 ns 1885493 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 518 ns 518 ns 1345222 - -bm_call::by_FunctionPtr_Function::get_string 526 ns 526 ns 1341456 -bm_call::by_FunctionPtr___Method::get_string 528 ns 528 ns 1316870 - -bm_std::function_CallsFunction::get_string 525 ns 525 ns 1336722 -bm_std::function___CallsMethod::get_string 524 ns 524 ns 1326344 - -bm_rtl::function_CallsFunction::get_string 527 ns 527 ns 1330642 -bm_rtl::method_____CallsMethod::get_string 523 ns 523 ns 1330518 - -bm_rtl::function_ErasedReturnType::get_string 539 ns 539 ns 1267504 -bm_rtl::method___ErasedReturnType::get_string 539 ns 539 ns 1306267 -bm_rtl::method___ErasedTargetType::get_string 532 ns 532 ns 1304795 -bm_rtl::method___ErasedTargetAndReturnType::get_string 542 ns 542 ns 1294289 ------------------------------------ -[2025-10-25 08:27:06] >>> Run 3: workload scale = 30 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 30 iterations -============================================= - -2025-10-25T08:27:06+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1508.39 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.55, 1.39, 0.80 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 366 ns 366 ns 1919740 - -bm_call::by_FunctionPtr_Function::set_string 367 ns 367 ns 1911290 -bm_call::by_FunctionPtr___Method::set_string 366 ns 366 ns 1904880 - -bm_std::function_CallsFunction::set_string 366 ns 366 ns 1876743 -bm_std::function___CallsMethod::set_string 370 ns 370 ns 1892013 - -bm_rtl::function_CallsFunction::set_string 369 ns 368 ns 1917651 -bm_rtl::method_____CallsMethod::set_string 366 ns 366 ns 1907502 - -bm_rtl::function_ErasedReturnType::set_string 387 ns 387 ns 1801830 -bm_rtl::method___ErasedReturnType::set_string 384 ns 384 ns 1826847 -bm_rtl::method___ErasedTargetType::set_string 382 ns 382 ns 1844261 -bm_rtl::method___ErasedTargetAndReturnType::set_string 371 ns 371 ns 1886391 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 526 ns 526 ns 1329959 - -bm_call::by_FunctionPtr_Function::get_string 525 ns 525 ns 1338440 -bm_call::by_FunctionPtr___Method::get_string 529 ns 529 ns 1309704 - -bm_std::function_CallsFunction::get_string 536 ns 536 ns 1321836 -bm_std::function___CallsMethod::get_string 558 ns 557 ns 1311973 - -bm_rtl::function_CallsFunction::get_string 606 ns 606 ns 1159851 -bm_rtl::method_____CallsMethod::get_string 590 ns 590 ns 1113064 - -bm_rtl::function_ErasedReturnType::get_string 608 ns 608 ns 1152150 -bm_rtl::method___ErasedReturnType::get_string 617 ns 617 ns 1131216 -bm_rtl::method___ErasedTargetType::get_string 610 ns 610 ns 1151877 -bm_rtl::method___ErasedTargetAndReturnType::get_string 620 ns 620 ns 1138753 ------------------------------------ -[2025-10-25 08:27:26] >>> Run 1: workload scale = 35 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 35 iterations -============================================= - -2025-10-25T08:27:26+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2310.48 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.39, 1.36, 0.81 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 738 ns 737 ns 949910 - -bm_call::by_FunctionPtr_Function::set_string 746 ns 746 ns 958502 -bm_call::by_FunctionPtr___Method::set_string 725 ns 725 ns 961082 - -bm_std::function_CallsFunction::set_string 733 ns 733 ns 945471 -bm_std::function___CallsMethod::set_string 724 ns 724 ns 962085 - -bm_rtl::function_CallsFunction::set_string 727 ns 727 ns 930075 -bm_rtl::method_____CallsMethod::set_string 736 ns 735 ns 957228 - -bm_rtl::function_ErasedReturnType::set_string 729 ns 729 ns 941981 -bm_rtl::method___ErasedReturnType::set_string 735 ns 735 ns 948788 -bm_rtl::method___ErasedTargetType::set_string 726 ns 725 ns 959696 -bm_rtl::method___ErasedTargetAndReturnType::set_string 724 ns 724 ns 960229 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 911 ns 911 ns 745135 - -bm_call::by_FunctionPtr_Function::get_string 915 ns 915 ns 755979 -bm_call::by_FunctionPtr___Method::get_string 918 ns 918 ns 752319 - -bm_std::function_CallsFunction::get_string 918 ns 918 ns 750587 -bm_std::function___CallsMethod::get_string 910 ns 910 ns 758746 - -bm_rtl::function_CallsFunction::get_string 916 ns 915 ns 755424 -bm_rtl::method_____CallsMethod::get_string 916 ns 916 ns 756404 - -bm_rtl::function_ErasedReturnType::get_string 987 ns 987 ns 694625 -bm_rtl::method___ErasedReturnType::get_string 922 ns 922 ns 732291 -bm_rtl::method___ErasedTargetType::get_string 915 ns 914 ns 758787 -bm_rtl::method___ErasedTargetAndReturnType::get_string 925 ns 925 ns 750609 ------------------------------------ -[2025-10-25 08:27:44] >>> Run 2: workload scale = 35 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 35 iterations -============================================= - -2025-10-25T08:27:44+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3575.93 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.35, 1.35, 0.82 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 694 ns 694 ns 966668 - -bm_call::by_FunctionPtr_Function::set_string 691 ns 691 ns 994391 -bm_call::by_FunctionPtr___Method::set_string 690 ns 689 ns 1018565 - -bm_std::function_CallsFunction::set_string 691 ns 691 ns 998812 -bm_std::function___CallsMethod::set_string 694 ns 693 ns 1004926 - -bm_rtl::function_CallsFunction::set_string 700 ns 699 ns 1008183 -bm_rtl::method_____CallsMethod::set_string 694 ns 694 ns 1005650 - -bm_rtl::function_ErasedReturnType::set_string 705 ns 705 ns 986699 -bm_rtl::method___ErasedReturnType::set_string 702 ns 702 ns 983604 -bm_rtl::method___ErasedTargetType::set_string 700 ns 700 ns 986677 -bm_rtl::method___ErasedTargetAndReturnType::set_string 705 ns 705 ns 979085 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 896 ns 896 ns 764388 - -bm_call::by_FunctionPtr_Function::get_string 900 ns 900 ns 767693 -bm_call::by_FunctionPtr___Method::get_string 897 ns 897 ns 772348 - -bm_std::function_CallsFunction::get_string 903 ns 903 ns 769105 -bm_std::function___CallsMethod::get_string 898 ns 898 ns 771183 - -bm_rtl::function_CallsFunction::get_string 900 ns 899 ns 765085 -bm_rtl::method_____CallsMethod::get_string 897 ns 897 ns 776452 - -bm_rtl::function_ErasedReturnType::get_string 921 ns 921 ns 754699 -bm_rtl::method___ErasedReturnType::get_string 921 ns 920 ns 753361 -bm_rtl::method___ErasedTargetType::get_string 905 ns 905 ns 755296 -bm_rtl::method___ErasedTargetAndReturnType::get_string 918 ns 918 ns 753835 ------------------------------------ -[2025-10-25 08:28:01] >>> Run 3: workload scale = 35 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 35 iterations -============================================= - -2025-10-25T08:28:01+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.35, 1.35, 0.83 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 691 ns 690 ns 959679 - -bm_call::by_FunctionPtr_Function::set_string 695 ns 694 ns 1004970 -bm_call::by_FunctionPtr___Method::set_string 693 ns 692 ns 1005822 - -bm_std::function_CallsFunction::set_string 694 ns 693 ns 995310 -bm_std::function___CallsMethod::set_string 699 ns 698 ns 950112 - -bm_rtl::function_CallsFunction::set_string 694 ns 694 ns 1016276 -bm_rtl::method_____CallsMethod::set_string 689 ns 689 ns 1014165 - -bm_rtl::function_ErasedReturnType::set_string 699 ns 699 ns 997349 -bm_rtl::method___ErasedReturnType::set_string 699 ns 699 ns 991395 -bm_rtl::method___ErasedTargetType::set_string 697 ns 697 ns 997670 -bm_rtl::method___ErasedTargetAndReturnType::set_string 703 ns 703 ns 999820 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 899 ns 898 ns 769821 - -bm_call::by_FunctionPtr_Function::get_string 898 ns 898 ns 759644 -bm_call::by_FunctionPtr___Method::get_string 899 ns 898 ns 769545 - -bm_std::function_CallsFunction::get_string 903 ns 903 ns 752728 -bm_std::function___CallsMethod::get_string 897 ns 897 ns 760283 - -bm_rtl::function_CallsFunction::get_string 897 ns 896 ns 763113 -bm_rtl::method_____CallsMethod::get_string 899 ns 898 ns 760667 - -bm_rtl::function_ErasedReturnType::get_string 931 ns 931 ns 741176 -bm_rtl::method___ErasedReturnType::get_string 928 ns 928 ns 744110 -bm_rtl::method___ErasedTargetType::get_string 921 ns 920 ns 747090 -bm_rtl::method___ErasedTargetAndReturnType::get_string 938 ns 938 ns 744325 ------------------------------------ -[2025-10-25 08:28:18] >>> Run 1: workload scale = 40 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 40 iterations -============================================= - -2025-10-25T08:28:18+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2646.92 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.27, 1.33, 0.83 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 816 ns 816 ns 874256 - -bm_call::by_FunctionPtr_Function::set_string 788 ns 788 ns 863946 -bm_call::by_FunctionPtr___Method::set_string 785 ns 784 ns 880553 - -bm_std::function_CallsFunction::set_string 782 ns 782 ns 861889 -bm_std::function___CallsMethod::set_string 791 ns 791 ns 864983 - -bm_rtl::function_CallsFunction::set_string 780 ns 780 ns 881562 -bm_rtl::method_____CallsMethod::set_string 781 ns 781 ns 882033 - -bm_rtl::function_ErasedReturnType::set_string 793 ns 792 ns 869968 -bm_rtl::method___ErasedReturnType::set_string 793 ns 793 ns 857392 -bm_rtl::method___ErasedTargetType::set_string 800 ns 800 ns 865195 -bm_rtl::method___ErasedTargetAndReturnType::set_string 796 ns 796 ns 870378 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 986 ns 985 ns 696152 - -bm_call::by_FunctionPtr_Function::get_string 988 ns 988 ns 696698 -bm_call::by_FunctionPtr___Method::get_string 987 ns 987 ns 696962 - -bm_std::function_CallsFunction::get_string 989 ns 989 ns 692755 -bm_std::function___CallsMethod::get_string 990 ns 990 ns 698164 - -bm_rtl::function_CallsFunction::get_string 988 ns 988 ns 691324 -bm_rtl::method_____CallsMethod::get_string 990 ns 990 ns 690412 - -bm_rtl::function_ErasedReturnType::get_string 1023 ns 1022 ns 683091 -bm_rtl::method___ErasedReturnType::get_string 1021 ns 1021 ns 678424 -bm_rtl::method___ErasedTargetType::get_string 998 ns 998 ns 693112 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1025 ns 1024 ns 670793 ------------------------------------ -[2025-10-25 08:28:35] >>> Run 2: workload scale = 40 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 40 iterations -============================================= - -2025-10-25T08:28:35+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3833.58 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.19, 1.31, 0.84 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 799 ns 799 ns 824743 - -bm_call::by_FunctionPtr_Function::set_string 798 ns 798 ns 882489 -bm_call::by_FunctionPtr___Method::set_string 788 ns 788 ns 869707 - -bm_std::function_CallsFunction::set_string 787 ns 787 ns 868766 -bm_std::function___CallsMethod::set_string 790 ns 790 ns 877734 - -bm_rtl::function_CallsFunction::set_string 795 ns 795 ns 858663 -bm_rtl::method_____CallsMethod::set_string 792 ns 792 ns 870837 - -bm_rtl::function_ErasedReturnType::set_string 794 ns 793 ns 876657 -bm_rtl::method___ErasedReturnType::set_string 794 ns 793 ns 871405 -bm_rtl::method___ErasedTargetType::set_string 792 ns 792 ns 876060 -bm_rtl::method___ErasedTargetAndReturnType::set_string 796 ns 796 ns 869998 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 994 ns 993 ns 695050 - -bm_call::by_FunctionPtr_Function::get_string 993 ns 993 ns 693618 -bm_call::by_FunctionPtr___Method::get_string 993 ns 993 ns 693206 - -bm_std::function_CallsFunction::get_string 994 ns 994 ns 684979 -bm_std::function___CallsMethod::get_string 991 ns 991 ns 683134 - -bm_rtl::function_CallsFunction::get_string 992 ns 992 ns 691637 -bm_rtl::method_____CallsMethod::get_string 997 ns 997 ns 667779 - -bm_rtl::function_ErasedReturnType::get_string 1007 ns 1007 ns 675607 -bm_rtl::method___ErasedReturnType::get_string 1014 ns 1014 ns 673832 -bm_rtl::method___ErasedTargetType::get_string 1003 ns 1003 ns 693006 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1008 ns 1008 ns 687912 ------------------------------------ -[2025-10-25 08:28:53] >>> Run 3: workload scale = 40 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 40 iterations -============================================= - -2025-10-25T08:28:53+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.15, 1.30, 0.84 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 780 ns 780 ns 873096 - -bm_call::by_FunctionPtr_Function::set_string 781 ns 780 ns 885065 -bm_call::by_FunctionPtr___Method::set_string 787 ns 787 ns 820768 - -bm_std::function_CallsFunction::set_string 782 ns 782 ns 888663 -bm_std::function___CallsMethod::set_string 782 ns 781 ns 886206 - -bm_rtl::function_CallsFunction::set_string 781 ns 780 ns 877242 -bm_rtl::method_____CallsMethod::set_string 780 ns 780 ns 885708 - -bm_rtl::function_ErasedReturnType::set_string 790 ns 790 ns 883274 -bm_rtl::method___ErasedReturnType::set_string 807 ns 807 ns 859777 -bm_rtl::method___ErasedTargetType::set_string 789 ns 789 ns 872521 -bm_rtl::method___ErasedTargetAndReturnType::set_string 795 ns 795 ns 863205 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1049 ns 1048 ns 641851 - -bm_call::by_FunctionPtr_Function::get_string 1041 ns 1040 ns 657253 -bm_call::by_FunctionPtr___Method::get_string 1039 ns 1039 ns 656430 - -bm_std::function_CallsFunction::get_string 1039 ns 1039 ns 660020 -bm_std::function___CallsMethod::get_string 1023 ns 1023 ns 655020 - -bm_rtl::function_CallsFunction::get_string 983 ns 983 ns 686350 -bm_rtl::method_____CallsMethod::get_string 982 ns 982 ns 707057 - -bm_rtl::function_ErasedReturnType::get_string 1000 ns 1000 ns 694252 -bm_rtl::method___ErasedReturnType::get_string 999 ns 999 ns 682297 -bm_rtl::method___ErasedTargetType::get_string 1008 ns 1008 ns 696929 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1028 ns 1028 ns 679697 ------------------------------------ -[2025-10-25 08:29:10] >>> Run 1: workload scale = 45 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 45 iterations -============================================= - -2025-10-25T08:29:10+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1471.95 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.11, 1.28, 0.84 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 843 ns 843 ns 787190 - -bm_call::by_FunctionPtr_Function::set_string 850 ns 850 ns 821517 -bm_call::by_FunctionPtr___Method::set_string 845 ns 845 ns 820441 - -bm_std::function_CallsFunction::set_string 838 ns 838 ns 810942 -bm_std::function___CallsMethod::set_string 841 ns 841 ns 821034 - -bm_rtl::function_CallsFunction::set_string 842 ns 842 ns 808850 -bm_rtl::method_____CallsMethod::set_string 851 ns 851 ns 822477 - -bm_rtl::function_ErasedReturnType::set_string 856 ns 856 ns 802630 -bm_rtl::method___ErasedReturnType::set_string 856 ns 856 ns 785080 -bm_rtl::method___ErasedTargetType::set_string 839 ns 839 ns 829114 -bm_rtl::method___ErasedTargetAndReturnType::set_string 844 ns 844 ns 812546 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1098 ns 1098 ns 642734 - -bm_call::by_FunctionPtr_Function::get_string 1105 ns 1104 ns 621246 -bm_call::by_FunctionPtr___Method::get_string 1090 ns 1090 ns 615328 - -bm_std::function_CallsFunction::get_string 1081 ns 1081 ns 627872 -bm_std::function___CallsMethod::get_string 1085 ns 1085 ns 580917 - -bm_rtl::function_CallsFunction::get_string 1082 ns 1082 ns 613484 -bm_rtl::method_____CallsMethod::get_string 1071 ns 1071 ns 624194 - -bm_rtl::function_ErasedReturnType::get_string 1091 ns 1091 ns 631934 -bm_rtl::method___ErasedReturnType::get_string 1110 ns 1110 ns 618882 -bm_rtl::method___ErasedTargetType::get_string 1104 ns 1104 ns 645393 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1095 ns 1095 ns 626560 ------------------------------------ -[2025-10-25 08:29:28] >>> Run 2: workload scale = 45 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 45 iterations -============================================= - -2025-10-25T08:29:28+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.32, 1.31, 0.86 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 863 ns 863 ns 790862 - -bm_call::by_FunctionPtr_Function::set_string 875 ns 875 ns 786432 -bm_call::by_FunctionPtr___Method::set_string 859 ns 859 ns 790154 - -bm_std::function_CallsFunction::set_string 902 ns 902 ns 796736 -bm_std::function___CallsMethod::set_string 905 ns 905 ns 734361 - -bm_rtl::function_CallsFunction::set_string 877 ns 877 ns 757947 -bm_rtl::method_____CallsMethod::set_string 877 ns 877 ns 781854 - -bm_rtl::function_ErasedReturnType::set_string 879 ns 879 ns 772766 -bm_rtl::method___ErasedReturnType::set_string 898 ns 897 ns 755860 -bm_rtl::method___ErasedTargetType::set_string 900 ns 900 ns 761109 -bm_rtl::method___ErasedTargetAndReturnType::set_string 899 ns 899 ns 746903 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1122 ns 1122 ns 613838 - -bm_call::by_FunctionPtr_Function::get_string 1110 ns 1110 ns 611555 -bm_call::by_FunctionPtr___Method::get_string 1091 ns 1091 ns 599366 - -bm_std::function_CallsFunction::get_string 1108 ns 1108 ns 614760 -bm_std::function___CallsMethod::get_string 1132 ns 1132 ns 603410 - -bm_rtl::function_CallsFunction::get_string 1104 ns 1104 ns 609206 -bm_rtl::method_____CallsMethod::get_string 1102 ns 1102 ns 611815 - -bm_rtl::function_ErasedReturnType::get_string 1108 ns 1108 ns 605701 -bm_rtl::method___ErasedReturnType::get_string 1097 ns 1097 ns 588117 -bm_rtl::method___ErasedTargetType::get_string 1081 ns 1081 ns 632189 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1101 ns 1101 ns 620309 ------------------------------------ -[2025-10-25 08:29:45] >>> Run 3: workload scale = 45 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 45 iterations -============================================= - -2025-10-25T08:29:45+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2665.8 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.60, 1.37, 0.89 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 844 ns 844 ns 787973 - -bm_call::by_FunctionPtr_Function::set_string 851 ns 851 ns 810521 -bm_call::by_FunctionPtr___Method::set_string 849 ns 849 ns 824023 - -bm_std::function_CallsFunction::set_string 850 ns 850 ns 826104 -bm_std::function___CallsMethod::set_string 848 ns 848 ns 814198 - -bm_rtl::function_CallsFunction::set_string 848 ns 848 ns 817784 -bm_rtl::method_____CallsMethod::set_string 845 ns 845 ns 822104 - -bm_rtl::function_ErasedReturnType::set_string 851 ns 851 ns 809302 -bm_rtl::method___ErasedReturnType::set_string 848 ns 848 ns 807888 -bm_rtl::method___ErasedTargetType::set_string 848 ns 848 ns 816118 -bm_rtl::method___ErasedTargetAndReturnType::set_string 852 ns 851 ns 815328 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1069 ns 1069 ns 643492 - -bm_call::by_FunctionPtr_Function::get_string 1066 ns 1066 ns 643062 -bm_call::by_FunctionPtr___Method::get_string 1066 ns 1066 ns 640979 - -bm_std::function_CallsFunction::get_string 1066 ns 1066 ns 632847 -bm_std::function___CallsMethod::get_string 1074 ns 1074 ns 647084 - -bm_rtl::function_CallsFunction::get_string 1066 ns 1066 ns 652862 -bm_rtl::method_____CallsMethod::get_string 1067 ns 1067 ns 652673 - -bm_rtl::function_ErasedReturnType::get_string 1092 ns 1092 ns 632999 -bm_rtl::method___ErasedReturnType::get_string 1091 ns 1091 ns 624987 -bm_rtl::method___ErasedTargetType::get_string 1079 ns 1079 ns 639076 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1096 ns 1095 ns 629950 ------------------------------------ -[2025-10-25 08:30:03] >>> Run 1: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-10-25T08:30:03+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3589.81 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.47, 1.35, 0.90 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 920 ns 920 ns 738697 - -bm_call::by_FunctionPtr_Function::set_string 921 ns 921 ns 717097 -bm_call::by_FunctionPtr___Method::set_string 922 ns 922 ns 756736 - -bm_std::function_CallsFunction::set_string 918 ns 918 ns 743148 -bm_std::function___CallsMethod::set_string 923 ns 923 ns 742602 - -bm_rtl::function_CallsFunction::set_string 921 ns 921 ns 748875 -bm_rtl::method_____CallsMethod::set_string 917 ns 916 ns 748828 - -bm_rtl::function_ErasedReturnType::set_string 934 ns 934 ns 736668 -bm_rtl::method___ErasedReturnType::set_string 930 ns 930 ns 747673 -bm_rtl::method___ErasedTargetType::set_string 931 ns 931 ns 726636 -bm_rtl::method___ErasedTargetAndReturnType::set_string 935 ns 935 ns 727628 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1177 ns 1176 ns 572959 - -bm_call::by_FunctionPtr_Function::get_string 1176 ns 1176 ns 582468 -bm_call::by_FunctionPtr___Method::get_string 1183 ns 1183 ns 574525 - -bm_std::function_CallsFunction::get_string 1176 ns 1176 ns 575515 -bm_std::function___CallsMethod::get_string 1190 ns 1190 ns 571997 - -bm_rtl::function_CallsFunction::get_string 1175 ns 1175 ns 578051 -bm_rtl::method_____CallsMethod::get_string 1174 ns 1174 ns 566082 - -bm_rtl::function_ErasedReturnType::get_string 1199 ns 1199 ns 575119 -bm_rtl::method___ErasedReturnType::get_string 1199 ns 1199 ns 574217 -bm_rtl::method___ErasedTargetType::get_string 1192 ns 1191 ns 582765 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1205 ns 1205 ns 568205 ------------------------------------ -[2025-10-25 08:30:20] >>> Run 2: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-10-25T08:30:20+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.40, 1.35, 0.91 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 914 ns 913 ns 741391 - -bm_call::by_FunctionPtr_Function::set_string 911 ns 911 ns 755564 -bm_call::by_FunctionPtr___Method::set_string 911 ns 911 ns 761951 - -bm_std::function_CallsFunction::set_string 911 ns 911 ns 755882 -bm_std::function___CallsMethod::set_string 909 ns 909 ns 663426 - -bm_rtl::function_CallsFunction::set_string 913 ns 913 ns 756577 -bm_rtl::method_____CallsMethod::set_string 925 ns 925 ns 757855 - -bm_rtl::function_ErasedReturnType::set_string 940 ns 939 ns 742353 -bm_rtl::method___ErasedReturnType::set_string 931 ns 931 ns 725754 -bm_rtl::method___ErasedTargetType::set_string 929 ns 929 ns 734123 -bm_rtl::method___ErasedTargetAndReturnType::set_string 939 ns 939 ns 723982 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1168 ns 1168 ns 583887 - -bm_call::by_FunctionPtr_Function::get_string 1167 ns 1167 ns 578193 -bm_call::by_FunctionPtr___Method::get_string 1167 ns 1167 ns 587466 - -bm_std::function_CallsFunction::get_string 1168 ns 1168 ns 593884 -bm_std::function___CallsMethod::get_string 1173 ns 1173 ns 585582 - -bm_rtl::function_CallsFunction::get_string 1168 ns 1168 ns 589844 -bm_rtl::method_____CallsMethod::get_string 1168 ns 1168 ns 591239 - -bm_rtl::function_ErasedReturnType::get_string 1200 ns 1200 ns 571595 -bm_rtl::method___ErasedReturnType::get_string 1202 ns 1202 ns 560720 -bm_rtl::method___ErasedTargetType::get_string 1182 ns 1182 ns 553380 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1209 ns 1209 ns 575085 ------------------------------------ -[2025-10-25 08:30:38] >>> Run 3: workload scale = 50 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 50 iterations -============================================= - -2025-10-25T08:30:38+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1897.49 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.85, 1.46, 0.95 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 921 ns 920 ns 740235 - -bm_call::by_FunctionPtr_Function::set_string 926 ns 925 ns 754127 -bm_call::by_FunctionPtr___Method::set_string 924 ns 924 ns 756576 - -bm_std::function_CallsFunction::set_string 923 ns 923 ns 747271 -bm_std::function___CallsMethod::set_string 928 ns 927 ns 745917 - -bm_rtl::function_CallsFunction::set_string 922 ns 921 ns 743806 -bm_rtl::method_____CallsMethod::set_string 924 ns 924 ns 732865 - -bm_rtl::function_ErasedReturnType::set_string 942 ns 942 ns 730851 -bm_rtl::method___ErasedReturnType::set_string 940 ns 940 ns 744287 -bm_rtl::method___ErasedTargetType::set_string 939 ns 939 ns 740601 -bm_rtl::method___ErasedTargetAndReturnType::set_string 938 ns 938 ns 733123 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1178 ns 1178 ns 589582 - -bm_call::by_FunctionPtr_Function::get_string 1178 ns 1178 ns 579966 -bm_call::by_FunctionPtr___Method::get_string 1181 ns 1181 ns 581942 - -bm_std::function_CallsFunction::get_string 1193 ns 1193 ns 568660 -bm_std::function___CallsMethod::get_string 1181 ns 1181 ns 579403 - -bm_rtl::function_CallsFunction::get_string 1178 ns 1177 ns 584070 -bm_rtl::method_____CallsMethod::get_string 1177 ns 1177 ns 587694 - -bm_rtl::function_ErasedReturnType::get_string 1205 ns 1204 ns 570455 -bm_rtl::method___ErasedReturnType::get_string 1207 ns 1207 ns 570787 -bm_rtl::method___ErasedTargetType::get_string 1196 ns 1196 ns 569793 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1210 ns 1210 ns 561648 ------------------------------------ -[2025-10-25 08:30:56] >>> Run 1: workload scale = 58 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 58 iterations -============================================= - -2025-10-25T08:30:56+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2587.18 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.61, 1.43, 0.95 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1039 ns 1039 ns 607414 - -bm_call::by_FunctionPtr_Function::set_string 1042 ns 1042 ns 661448 -bm_call::by_FunctionPtr___Method::set_string 1044 ns 1044 ns 643057 - -bm_std::function_CallsFunction::set_string 1040 ns 1040 ns 656520 -bm_std::function___CallsMethod::set_string 1040 ns 1040 ns 667856 - -bm_rtl::function_CallsFunction::set_string 1038 ns 1038 ns 666280 -bm_rtl::method_____CallsMethod::set_string 1041 ns 1041 ns 659063 - -bm_rtl::function_ErasedReturnType::set_string 1055 ns 1055 ns 659455 -bm_rtl::method___ErasedReturnType::set_string 1063 ns 1063 ns 631920 -bm_rtl::method___ErasedTargetType::set_string 1053 ns 1053 ns 647693 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1055 ns 1055 ns 647299 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1315 ns 1315 ns 521662 - -bm_call::by_FunctionPtr_Function::get_string 1317 ns 1317 ns 517580 -bm_call::by_FunctionPtr___Method::get_string 1318 ns 1318 ns 517157 - -bm_std::function_CallsFunction::get_string 1317 ns 1317 ns 519268 -bm_std::function___CallsMethod::get_string 1324 ns 1324 ns 521569 - -bm_rtl::function_CallsFunction::get_string 1316 ns 1316 ns 513808 -bm_rtl::method_____CallsMethod::get_string 1315 ns 1315 ns 519418 - -bm_rtl::function_ErasedReturnType::get_string 1350 ns 1350 ns 501073 -bm_rtl::method___ErasedReturnType::get_string 1351 ns 1350 ns 514857 -bm_rtl::method___ErasedTargetType::get_string 1334 ns 1334 ns 521104 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1356 ns 1356 ns 511897 ------------------------------------ -[2025-10-25 08:31:14] >>> Run 2: workload scale = 58 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 58 iterations -============================================= - -2025-10-25T08:31:14+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2251.16 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.44, 1.40, 0.95 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1063 ns 1063 ns 635505 - -bm_call::by_FunctionPtr_Function::set_string 1064 ns 1064 ns 640683 -bm_call::by_FunctionPtr___Method::set_string 1083 ns 1083 ns 627856 - -bm_std::function_CallsFunction::set_string 1082 ns 1082 ns 642487 -bm_std::function___CallsMethod::set_string 1093 ns 1093 ns 606137 - -bm_rtl::function_CallsFunction::set_string 1068 ns 1068 ns 636794 -bm_rtl::method_____CallsMethod::set_string 1071 ns 1071 ns 638437 - -bm_rtl::function_ErasedReturnType::set_string 1079 ns 1079 ns 633153 -bm_rtl::method___ErasedReturnType::set_string 1080 ns 1080 ns 634223 -bm_rtl::method___ErasedTargetType::set_string 1084 ns 1084 ns 640960 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1086 ns 1086 ns 622752 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1408 ns 1408 ns 486469 - -bm_call::by_FunctionPtr_Function::get_string 1410 ns 1410 ns 488214 -bm_call::by_FunctionPtr___Method::get_string 1409 ns 1409 ns 486255 - -bm_std::function_CallsFunction::get_string 1409 ns 1409 ns 491521 -bm_std::function___CallsMethod::get_string 1416 ns 1416 ns 480957 - -bm_rtl::function_CallsFunction::get_string 1410 ns 1410 ns 483599 -bm_rtl::method_____CallsMethod::get_string 1330 ns 1330 ns 484411 - -bm_rtl::function_ErasedReturnType::get_string 1368 ns 1368 ns 485899 -bm_rtl::method___ErasedReturnType::get_string 1378 ns 1378 ns 505612 -bm_rtl::method___ErasedTargetType::get_string 1349 ns 1349 ns 512357 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1378 ns 1378 ns 501375 ------------------------------------ -[2025-10-25 08:31:32] >>> Run 3: workload scale = 58 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 58 iterations -============================================= - -2025-10-25T08:31:32+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2505.01 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.34, 1.38, 0.96 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1033 ns 1033 ns 653562 - -bm_call::by_FunctionPtr_Function::set_string 1044 ns 1044 ns 676146 -bm_call::by_FunctionPtr___Method::set_string 1039 ns 1039 ns 660769 - -bm_std::function_CallsFunction::set_string 1036 ns 1036 ns 663675 -bm_std::function___CallsMethod::set_string 1038 ns 1038 ns 632749 - -bm_rtl::function_CallsFunction::set_string 1032 ns 1032 ns 660063 -bm_rtl::method_____CallsMethod::set_string 1033 ns 1033 ns 665554 - -bm_rtl::function_ErasedReturnType::set_string 1045 ns 1045 ns 656138 -bm_rtl::method___ErasedReturnType::set_string 1044 ns 1044 ns 657250 -bm_rtl::method___ErasedTargetType::set_string 1048 ns 1048 ns 650987 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1052 ns 1052 ns 648697 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1402 ns 1402 ns 491352 - -bm_call::by_FunctionPtr_Function::get_string 1401 ns 1401 ns 448467 -bm_call::by_FunctionPtr___Method::get_string 1399 ns 1399 ns 494260 - -bm_std::function_CallsFunction::get_string 1403 ns 1403 ns 486788 -bm_std::function___CallsMethod::get_string 1402 ns 1402 ns 485865 - -bm_rtl::function_CallsFunction::get_string 1400 ns 1400 ns 490048 -bm_rtl::method_____CallsMethod::get_string 1403 ns 1403 ns 477421 - -bm_rtl::function_ErasedReturnType::get_string 1430 ns 1430 ns 473002 -bm_rtl::method___ErasedReturnType::get_string 1433 ns 1433 ns 476489 -bm_rtl::method___ErasedTargetType::get_string 1330 ns 1330 ns 459592 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1362 ns 1362 ns 503378 ------------------------------------ -[2025-10-25 08:31:50] >>> Run 1: workload scale = 66 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 66 iterations -============================================= - -2025-10-25T08:31:50+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3667.44 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.24, 1.35, 0.96 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1641 ns 1641 ns 412193 - -bm_call::by_FunctionPtr_Function::set_string 1639 ns 1639 ns 421723 -bm_call::by_FunctionPtr___Method::set_string 1644 ns 1643 ns 417838 - -bm_std::function_CallsFunction::set_string 1640 ns 1640 ns 417527 -bm_std::function___CallsMethod::set_string 1655 ns 1655 ns 421014 - -bm_rtl::function_CallsFunction::set_string 1640 ns 1640 ns 418821 -bm_rtl::method_____CallsMethod::set_string 1654 ns 1654 ns 409820 - -bm_rtl::function_ErasedReturnType::set_string 1674 ns 1674 ns 418479 -bm_rtl::method___ErasedReturnType::set_string 1661 ns 1661 ns 418139 -bm_rtl::method___ErasedTargetType::set_string 1664 ns 1664 ns 418528 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1664 ns 1664 ns 418322 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1945 ns 1945 ns 354277 - -bm_call::by_FunctionPtr_Function::get_string 1960 ns 1959 ns 354803 -bm_call::by_FunctionPtr___Method::get_string 1972 ns 1972 ns 355522 - -bm_std::function_CallsFunction::get_string 1945 ns 1944 ns 357891 -bm_std::function___CallsMethod::get_string 1954 ns 1954 ns 357123 - -bm_rtl::function_CallsFunction::get_string 1942 ns 1942 ns 358463 -bm_rtl::method_____CallsMethod::get_string 1945 ns 1944 ns 356140 - -bm_rtl::function_ErasedReturnType::get_string 1978 ns 1978 ns 345108 -bm_rtl::method___ErasedReturnType::get_string 1987 ns 1987 ns 343202 -bm_rtl::method___ErasedTargetType::get_string 1984 ns 1983 ns 346992 -bm_rtl::method___ErasedTargetAndReturnType::get_string 1994 ns 1994 ns 347995 ------------------------------------ -[2025-10-25 08:32:09] >>> Run 2: workload scale = 66 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 66 iterations -============================================= - -2025-10-25T08:32:09+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4000.93 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.17, 1.33, 0.96 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1645 ns 1645 ns 415761 - -bm_call::by_FunctionPtr_Function::set_string 1654 ns 1654 ns 408700 -bm_call::by_FunctionPtr___Method::set_string 1655 ns 1654 ns 419621 - -bm_std::function_CallsFunction::set_string 1644 ns 1644 ns 416574 -bm_std::function___CallsMethod::set_string 1664 ns 1663 ns 420065 - -bm_rtl::function_CallsFunction::set_string 1644 ns 1644 ns 422602 -bm_rtl::method_____CallsMethod::set_string 1649 ns 1648 ns 410531 - -bm_rtl::function_ErasedReturnType::set_string 1683 ns 1682 ns 401698 -bm_rtl::method___ErasedReturnType::set_string 1759 ns 1759 ns 416906 -bm_rtl::method___ErasedTargetType::set_string 1698 ns 1698 ns 400002 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1682 ns 1682 ns 403504 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1954 ns 1954 ns 345967 - -bm_call::by_FunctionPtr_Function::get_string 1974 ns 1974 ns 352961 -bm_call::by_FunctionPtr___Method::get_string 1964 ns 1963 ns 347646 - -bm_std::function_CallsFunction::get_string 1980 ns 1979 ns 343104 -bm_std::function___CallsMethod::get_string 1996 ns 1996 ns 340852 - -bm_rtl::function_CallsFunction::get_string 1980 ns 1980 ns 343611 -bm_rtl::method_____CallsMethod::get_string 1954 ns 1954 ns 353870 - -bm_rtl::function_ErasedReturnType::get_string 2027 ns 2027 ns 336628 -bm_rtl::method___ErasedReturnType::get_string 2094 ns 2094 ns 330396 -bm_rtl::method___ErasedTargetType::get_string 2103 ns 2102 ns 332761 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2120 ns 2121 ns 320103 ------------------------------------ -[2025-10-25 08:32:29] >>> Run 3: workload scale = 66 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 66 iterations -============================================= - -2025-10-25T08:32:29+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4073.84 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.20, 1.32, 0.97 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1650 ns 1650 ns 365465 - -bm_call::by_FunctionPtr_Function::set_string 1669 ns 1669 ns 424816 -bm_call::by_FunctionPtr___Method::set_string 1690 ns 1690 ns 399614 - -bm_std::function_CallsFunction::set_string 1638 ns 1638 ns 416539 -bm_std::function___CallsMethod::set_string 1639 ns 1639 ns 421581 - -bm_rtl::function_CallsFunction::set_string 1636 ns 1635 ns 423276 -bm_rtl::method_____CallsMethod::set_string 1640 ns 1640 ns 424255 - -bm_rtl::function_ErasedReturnType::set_string 1660 ns 1660 ns 415799 -bm_rtl::method___ErasedReturnType::set_string 1704 ns 1704 ns 400690 -bm_rtl::method___ErasedTargetType::set_string 1663 ns 1663 ns 413724 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1659 ns 1659 ns 419075 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 1954 ns 1954 ns 355079 - -bm_call::by_FunctionPtr_Function::get_string 1954 ns 1954 ns 353538 -bm_call::by_FunctionPtr___Method::get_string 1952 ns 1952 ns 353309 - -bm_std::function_CallsFunction::get_string 1972 ns 1972 ns 352881 -bm_std::function___CallsMethod::get_string 2057 ns 2053 ns 352379 - -bm_rtl::function_CallsFunction::get_string 1953 ns 1954 ns 336499 -bm_rtl::method_____CallsMethod::get_string 1971 ns 1970 ns 353984 - -bm_rtl::function_ErasedReturnType::get_string 2080 ns 2079 ns 336928 -bm_rtl::method___ErasedReturnType::get_string 2121 ns 2120 ns 327293 -bm_rtl::method___ErasedTargetType::get_string 2069 ns 2069 ns 333408 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2088 ns 2087 ns 332177 ------------------------------------ -[2025-10-25 08:32:49] >>> Run 1: workload scale = 74 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 74 iterations -============================================= - -2025-10-25T08:32:49+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2701.98 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.14, 1.30, 0.97 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1697 ns 1697 ns 406949 - -bm_call::by_FunctionPtr_Function::set_string 1694 ns 1694 ns 401873 -bm_call::by_FunctionPtr___Method::set_string 1694 ns 1694 ns 407047 - -bm_std::function_CallsFunction::set_string 1695 ns 1695 ns 406108 -bm_std::function___CallsMethod::set_string 1707 ns 1707 ns 406647 - -bm_rtl::function_CallsFunction::set_string 1702 ns 1702 ns 410421 -bm_rtl::method_____CallsMethod::set_string 1703 ns 1703 ns 407913 - -bm_rtl::function_ErasedReturnType::set_string 1723 ns 1723 ns 403518 -bm_rtl::method___ErasedReturnType::set_string 1724 ns 1723 ns 400739 -bm_rtl::method___ErasedTargetType::set_string 1708 ns 1708 ns 384649 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1712 ns 1712 ns 400208 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2056 ns 2056 ns 334788 - -bm_call::by_FunctionPtr_Function::get_string 2056 ns 2056 ns 334349 -bm_call::by_FunctionPtr___Method::get_string 2055 ns 2055 ns 334176 - -bm_std::function_CallsFunction::get_string 2056 ns 2055 ns 335245 -bm_std::function___CallsMethod::get_string 2061 ns 2061 ns 336646 - -bm_rtl::function_CallsFunction::get_string 2056 ns 2056 ns 336772 -bm_rtl::method_____CallsMethod::get_string 2059 ns 2059 ns 332961 - -bm_rtl::function_ErasedReturnType::get_string 2101 ns 2100 ns 331315 -bm_rtl::method___ErasedReturnType::get_string 2111 ns 2111 ns 325895 -bm_rtl::method___ErasedTargetType::get_string 2073 ns 2073 ns 333731 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2110 ns 2110 ns 328204 ------------------------------------ -[2025-10-25 08:33:09] >>> Run 2: workload scale = 74 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 74 iterations -============================================= - -2025-10-25T08:33:09+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4876.82 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.10, 1.28, 0.97 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1704 ns 1704 ns 404192 - -bm_call::by_FunctionPtr_Function::set_string 1708 ns 1708 ns 399263 -bm_call::by_FunctionPtr___Method::set_string 1699 ns 1699 ns 383305 - -bm_std::function_CallsFunction::set_string 1699 ns 1699 ns 408931 -bm_std::function___CallsMethod::set_string 1707 ns 1706 ns 404996 - -bm_rtl::function_CallsFunction::set_string 1698 ns 1698 ns 401629 -bm_rtl::method_____CallsMethod::set_string 1713 ns 1713 ns 408609 - -bm_rtl::function_ErasedReturnType::set_string 1717 ns 1717 ns 404724 -bm_rtl::method___ErasedReturnType::set_string 1710 ns 1710 ns 408370 -bm_rtl::method___ErasedTargetType::set_string 1710 ns 1710 ns 378159 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1720 ns 1720 ns 401154 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2060 ns 2060 ns 335768 - -bm_call::by_FunctionPtr_Function::get_string 2055 ns 2055 ns 337995 -bm_call::by_FunctionPtr___Method::get_string 2060 ns 2060 ns 336425 - -bm_std::function_CallsFunction::get_string 2056 ns 2056 ns 338343 -bm_std::function___CallsMethod::get_string 2067 ns 2067 ns 336134 - -bm_rtl::function_CallsFunction::get_string 2166 ns 2166 ns 339526 -bm_rtl::method_____CallsMethod::get_string 2147 ns 2147 ns 325746 - -bm_rtl::function_ErasedReturnType::get_string 2193 ns 2193 ns 314638 -bm_rtl::method___ErasedReturnType::get_string 2194 ns 2193 ns 317047 -bm_rtl::method___ErasedTargetType::get_string 2074 ns 2074 ns 327298 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2105 ns 2104 ns 330671 ------------------------------------ -[2025-10-25 08:33:29] >>> Run 3: workload scale = 74 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 74 iterations -============================================= - -2025-10-25T08:33:29+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2993.46 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.07, 1.26, 0.97 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1708 ns 1708 ns 407515 - -bm_call::by_FunctionPtr_Function::set_string 1696 ns 1696 ns 409851 -bm_call::by_FunctionPtr___Method::set_string 1700 ns 1700 ns 378158 - -bm_std::function_CallsFunction::set_string 1697 ns 1696 ns 402302 -bm_std::function___CallsMethod::set_string 1702 ns 1702 ns 407699 - -bm_rtl::function_CallsFunction::set_string 1697 ns 1697 ns 409996 -bm_rtl::method_____CallsMethod::set_string 1700 ns 1700 ns 411719 - -bm_rtl::function_ErasedReturnType::set_string 1710 ns 1710 ns 404169 -bm_rtl::method___ErasedReturnType::set_string 1723 ns 1723 ns 398981 -bm_rtl::method___ErasedTargetType::set_string 1714 ns 1714 ns 381104 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1720 ns 1720 ns 393269 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2066 ns 2066 ns 331466 - -bm_call::by_FunctionPtr_Function::get_string 2055 ns 2054 ns 336380 -bm_call::by_FunctionPtr___Method::get_string 2054 ns 2054 ns 338278 - -bm_std::function_CallsFunction::get_string 2056 ns 2055 ns 337711 -bm_std::function___CallsMethod::get_string 2061 ns 2061 ns 335271 - -bm_rtl::function_CallsFunction::get_string 2054 ns 2054 ns 331481 -bm_rtl::method_____CallsMethod::get_string 2055 ns 2055 ns 334503 - -bm_rtl::function_ErasedReturnType::get_string 2092 ns 2092 ns 329649 -bm_rtl::method___ErasedReturnType::get_string 2098 ns 2098 ns 328223 -bm_rtl::method___ErasedTargetType::get_string 2073 ns 2073 ns 332538 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2104 ns 2104 ns 327401 ------------------------------------ -[2025-10-25 08:33:48] >>> Run 1: workload scale = 82 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 82 iterations -============================================= - -2025-10-25T08:33:48+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3588.8 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.05, 1.25, 0.97 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1779 ns 1779 ns 387486 - -bm_call::by_FunctionPtr_Function::set_string 1794 ns 1794 ns 387209 -bm_call::by_FunctionPtr___Method::set_string 1779 ns 1779 ns 388305 - -bm_std::function_CallsFunction::set_string 1787 ns 1787 ns 389820 -bm_std::function___CallsMethod::set_string 1810 ns 1810 ns 391535 - -bm_rtl::function_CallsFunction::set_string 1797 ns 1797 ns 379250 -bm_rtl::method_____CallsMethod::set_string 1778 ns 1778 ns 388107 - -bm_rtl::function_ErasedReturnType::set_string 1810 ns 1810 ns 384295 -bm_rtl::method___ErasedReturnType::set_string 1787 ns 1786 ns 364818 -bm_rtl::method___ErasedTargetType::set_string 1788 ns 1787 ns 384642 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1791 ns 1791 ns 383000 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2177 ns 2176 ns 317302 - -bm_call::by_FunctionPtr_Function::get_string 2172 ns 2172 ns 318645 -bm_call::by_FunctionPtr___Method::get_string 2174 ns 2174 ns 318447 - -bm_std::function_CallsFunction::get_string 2174 ns 2174 ns 319232 -bm_std::function___CallsMethod::get_string 2197 ns 2197 ns 316734 - -bm_rtl::function_CallsFunction::get_string 2172 ns 2172 ns 318832 -bm_rtl::method_____CallsMethod::get_string 2172 ns 2172 ns 316541 - -bm_rtl::function_ErasedReturnType::get_string 2219 ns 2219 ns 312813 -bm_rtl::method___ErasedReturnType::get_string 2218 ns 2218 ns 311007 -bm_rtl::method___ErasedTargetType::get_string 2190 ns 2190 ns 314579 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2225 ns 2225 ns 309521 ------------------------------------ -[2025-10-25 08:34:09] >>> Run 2: workload scale = 82 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 82 iterations -============================================= - -2025-10-25T08:34:09+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4156.76 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.11, 1.25, 0.98 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1784 ns 1784 ns 367827 - -bm_call::by_FunctionPtr_Function::set_string 1780 ns 1780 ns 390498 -bm_call::by_FunctionPtr___Method::set_string 1777 ns 1778 ns 388454 - -bm_std::function_CallsFunction::set_string 1779 ns 1778 ns 389015 -bm_std::function___CallsMethod::set_string 1791 ns 1791 ns 381515 - -bm_rtl::function_CallsFunction::set_string 1774 ns 1774 ns 383265 -bm_rtl::method_____CallsMethod::set_string 1777 ns 1777 ns 391082 - -bm_rtl::function_ErasedReturnType::set_string 1781 ns 1781 ns 378135 -bm_rtl::method___ErasedReturnType::set_string 1782 ns 1782 ns 387188 -bm_rtl::method___ErasedTargetType::set_string 1790 ns 1790 ns 384569 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1789 ns 1788 ns 386650 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2189 ns 2189 ns 317309 - -bm_call::by_FunctionPtr_Function::get_string 2193 ns 2193 ns 314034 -bm_call::by_FunctionPtr___Method::get_string 2174 ns 2174 ns 313889 - -bm_std::function_CallsFunction::get_string 2268 ns 2268 ns 304192 -bm_std::function___CallsMethod::get_string 2303 ns 2303 ns 304211 - -bm_rtl::function_CallsFunction::get_string 2272 ns 2272 ns 301322 -bm_rtl::method_____CallsMethod::get_string 2269 ns 2269 ns 306845 - -bm_rtl::function_ErasedReturnType::get_string 2312 ns 2311 ns 297662 -bm_rtl::method___ErasedReturnType::get_string 2313 ns 2313 ns 299116 -bm_rtl::method___ErasedTargetType::get_string 2300 ns 2300 ns 301456 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2322 ns 2322 ns 296404 ------------------------------------ -[2025-10-25 08:34:29] >>> Run 3: workload scale = 82 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 82 iterations -============================================= - -2025-10-25T08:34:29+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2493.05 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.13, 1.24, 0.99 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1779 ns 1779 ns 383358 - -bm_call::by_FunctionPtr_Function::set_string 1775 ns 1775 ns 389326 -bm_call::by_FunctionPtr___Method::set_string 1788 ns 1788 ns 386498 - -bm_std::function_CallsFunction::set_string 1804 ns 1804 ns 384468 -bm_std::function___CallsMethod::set_string 1815 ns 1815 ns 385798 - -bm_rtl::function_CallsFunction::set_string 1838 ns 1838 ns 368710 -bm_rtl::method_____CallsMethod::set_string 1810 ns 1810 ns 368489 - -bm_rtl::function_ErasedReturnType::set_string 1818 ns 1818 ns 383808 -bm_rtl::method___ErasedReturnType::set_string 1818 ns 1818 ns 369718 -bm_rtl::method___ErasedTargetType::set_string 1795 ns 1795 ns 380611 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1826 ns 1826 ns 383829 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2220 ns 2220 ns 314628 - -bm_call::by_FunctionPtr_Function::get_string 2213 ns 2213 ns 310711 -bm_call::by_FunctionPtr___Method::get_string 2217 ns 2217 ns 311869 - -bm_std::function_CallsFunction::get_string 2223 ns 2223 ns 306243 -bm_std::function___CallsMethod::get_string 2234 ns 2234 ns 302403 - -bm_rtl::function_CallsFunction::get_string 2189 ns 2189 ns 308538 -bm_rtl::method_____CallsMethod::get_string 2221 ns 2221 ns 320200 - -bm_rtl::function_ErasedReturnType::get_string 2277 ns 2276 ns 302587 -bm_rtl::method___ErasedReturnType::get_string 2258 ns 2258 ns 309144 -bm_rtl::method___ErasedTargetType::get_string 2207 ns 2207 ns 306786 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2232 ns 2232 ns 313358 ------------------------------------ -[2025-10-25 08:34:49] >>> Run 1: workload scale = 90 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 90 iterations -============================================= - -2025-10-25T08:34:49+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1424.19 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.38, 1.29, 1.01 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1933 ns 1933 ns 349906 - -bm_call::by_FunctionPtr_Function::set_string 1917 ns 1917 ns 345429 -bm_call::by_FunctionPtr___Method::set_string 1902 ns 1901 ns 361299 - -bm_std::function_CallsFunction::set_string 1878 ns 1878 ns 366506 -bm_std::function___CallsMethod::set_string 1901 ns 1901 ns 363119 - -bm_rtl::function_CallsFunction::set_string 1882 ns 1882 ns 361076 -bm_rtl::method_____CallsMethod::set_string 1880 ns 1880 ns 368733 - -bm_rtl::function_ErasedReturnType::set_string 1884 ns 1883 ns 367639 -bm_rtl::method___ErasedReturnType::set_string 1887 ns 1887 ns 366878 -bm_rtl::method___ErasedTargetType::set_string 1901 ns 1901 ns 367533 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1891 ns 1891 ns 366409 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2331 ns 2330 ns 299960 - -bm_call::by_FunctionPtr_Function::get_string 2331 ns 2331 ns 295021 -bm_call::by_FunctionPtr___Method::get_string 2331 ns 2330 ns 296435 - -bm_std::function_CallsFunction::get_string 2331 ns 2331 ns 297285 -bm_std::function___CallsMethod::get_string 2350 ns 2350 ns 296781 - -bm_rtl::function_CallsFunction::get_string 2337 ns 2337 ns 298852 -bm_rtl::method_____CallsMethod::get_string 2334 ns 2333 ns 298520 - -bm_rtl::function_ErasedReturnType::get_string 2366 ns 2365 ns 293798 -bm_rtl::method___ErasedReturnType::get_string 2373 ns 2374 ns 289975 -bm_rtl::method___ErasedTargetType::get_string 2374 ns 2374 ns 293920 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2379 ns 2378 ns 293933 ------------------------------------ -[2025-10-25 08:35:09] >>> Run 2: workload scale = 90 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 90 iterations -============================================= - -2025-10-25T08:35:09+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 4899.04 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.27, 1.27, 1.01 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1852 ns 1852 ns 375676 - -bm_call::by_FunctionPtr_Function::set_string 1848 ns 1848 ns 375998 -bm_call::by_FunctionPtr___Method::set_string 1869 ns 1869 ns 366130 - -bm_std::function_CallsFunction::set_string 1877 ns 1877 ns 372184 -bm_std::function___CallsMethod::set_string 1859 ns 1858 ns 376433 - -bm_rtl::function_CallsFunction::set_string 1850 ns 1849 ns 376898 -bm_rtl::method_____CallsMethod::set_string 1855 ns 1855 ns 376759 - -bm_rtl::function_ErasedReturnType::set_string 1865 ns 1865 ns 371051 -bm_rtl::method___ErasedReturnType::set_string 1862 ns 1862 ns 372576 -bm_rtl::method___ErasedTargetType::set_string 1865 ns 1864 ns 374003 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1867 ns 1866 ns 360437 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2296 ns 2296 ns 302719 - -bm_call::by_FunctionPtr_Function::get_string 2297 ns 2297 ns 300343 -bm_call::by_FunctionPtr___Method::get_string 2298 ns 2298 ns 301440 - -bm_std::function_CallsFunction::get_string 2296 ns 2296 ns 302012 -bm_std::function___CallsMethod::get_string 2301 ns 2301 ns 303483 - -bm_rtl::function_CallsFunction::get_string 2299 ns 2298 ns 299325 -bm_rtl::method_____CallsMethod::get_string 2298 ns 2298 ns 296660 - -bm_rtl::function_ErasedReturnType::get_string 2330 ns 2330 ns 296734 -bm_rtl::method___ErasedReturnType::get_string 2330 ns 2330 ns 297457 -bm_rtl::method___ErasedTargetType::get_string 2311 ns 2311 ns 298532 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2328 ns 2328 ns 296429 ------------------------------------ -[2025-10-25 08:35:30] >>> Run 3: workload scale = 90 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 90 iterations -============================================= - -2025-10-25T08:35:30+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2681.19 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.19, 1.25, 1.01 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1882 ns 1881 ns 362066 - -bm_call::by_FunctionPtr_Function::set_string 1908 ns 1908 ns 362543 -bm_call::by_FunctionPtr___Method::set_string 1881 ns 1881 ns 362704 - -bm_std::function_CallsFunction::set_string 1895 ns 1894 ns 368862 -bm_std::function___CallsMethod::set_string 1891 ns 1890 ns 364312 - -bm_rtl::function_CallsFunction::set_string 1881 ns 1880 ns 365398 -bm_rtl::method_____CallsMethod::set_string 1886 ns 1884 ns 366020 - -bm_rtl::function_ErasedReturnType::set_string 1895 ns 1893 ns 366268 -bm_rtl::method___ErasedReturnType::set_string 1896 ns 1895 ns 367781 -bm_rtl::method___ErasedTargetType::set_string 1898 ns 1897 ns 360838 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1902 ns 1901 ns 363268 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2440 ns 2438 ns 283334 - -bm_call::by_FunctionPtr_Function::get_string 2445 ns 2443 ns 281807 -bm_call::by_FunctionPtr___Method::get_string 2443 ns 2442 ns 282459 - -bm_std::function_CallsFunction::get_string 2441 ns 2440 ns 281487 -bm_std::function___CallsMethod::get_string 2450 ns 2448 ns 281680 - -bm_rtl::function_CallsFunction::get_string 2444 ns 2442 ns 278353 -bm_rtl::method_____CallsMethod::get_string 2443 ns 2441 ns 283136 - -bm_rtl::function_ErasedReturnType::get_string 2480 ns 2478 ns 280665 -bm_rtl::method___ErasedReturnType::get_string 2487 ns 2485 ns 280503 -bm_rtl::method___ErasedTargetType::get_string 2458 ns 2457 ns 283885 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2491 ns 2490 ns 279281 ------------------------------------ -[2025-10-25 08:35:50] >>> Run 1: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-10-25T08:35:50+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2723.35 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.14, 1.24, 1.01 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1954 ns 1953 ns 350463 - -bm_call::by_FunctionPtr_Function::set_string 1959 ns 1958 ns 351380 -bm_call::by_FunctionPtr___Method::set_string 1954 ns 1953 ns 356616 - -bm_std::function_CallsFunction::set_string 1961 ns 1960 ns 358462 -bm_std::function___CallsMethod::set_string 1957 ns 1956 ns 355388 - -bm_rtl::function_CallsFunction::set_string 1957 ns 1956 ns 352196 -bm_rtl::method_____CallsMethod::set_string 1949 ns 1948 ns 353989 - -bm_rtl::function_ErasedReturnType::set_string 1983 ns 1982 ns 351235 -bm_rtl::method___ErasedReturnType::set_string 1963 ns 1962 ns 353021 -bm_rtl::method___ErasedTargetType::set_string 1968 ns 1966 ns 353340 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1969 ns 1968 ns 352915 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2479 ns 2478 ns 281632 - -bm_call::by_FunctionPtr_Function::get_string 2477 ns 2476 ns 279233 -bm_call::by_FunctionPtr___Method::get_string 2476 ns 2474 ns 280922 - -bm_std::function_CallsFunction::get_string 2478 ns 2477 ns 272740 -bm_std::function___CallsMethod::get_string 2478 ns 2477 ns 277517 - -bm_rtl::function_CallsFunction::get_string 2478 ns 2477 ns 281494 -bm_rtl::method_____CallsMethod::get_string 2478 ns 2476 ns 279161 - -bm_rtl::function_ErasedReturnType::get_string 2518 ns 2517 ns 275047 -bm_rtl::method___ErasedReturnType::get_string 2513 ns 2512 ns 275243 -bm_rtl::method___ErasedTargetType::get_string 2494 ns 2492 ns 279343 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2517 ns 2516 ns 270535 ------------------------------------ -[2025-10-25 08:36:11] >>> Run 2: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-10-25T08:36:11+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.10, 1.22, 1.00 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1963 ns 1962 ns 353266 - -bm_call::by_FunctionPtr_Function::set_string 1999 ns 1998 ns 352801 -bm_call::by_FunctionPtr___Method::set_string 1956 ns 1955 ns 351957 - -bm_std::function_CallsFunction::set_string 1952 ns 1951 ns 355320 -bm_std::function___CallsMethod::set_string 1959 ns 1958 ns 354606 - -bm_rtl::function_CallsFunction::set_string 1968 ns 1966 ns 353484 -bm_rtl::method_____CallsMethod::set_string 1959 ns 1959 ns 351589 - -bm_rtl::function_ErasedReturnType::set_string 1970 ns 1969 ns 353459 -bm_rtl::method___ErasedReturnType::set_string 1966 ns 1965 ns 351721 -bm_rtl::method___ErasedTargetType::set_string 1970 ns 1969 ns 351911 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1974 ns 1972 ns 353143 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2575 ns 2574 ns 270466 - -bm_call::by_FunctionPtr_Function::get_string 2573 ns 2572 ns 266600 -bm_call::by_FunctionPtr___Method::get_string 2572 ns 2571 ns 268784 - -bm_std::function_CallsFunction::get_string 2575 ns 2574 ns 270868 -bm_std::function___CallsMethod::get_string 2577 ns 2576 ns 268486 - -bm_rtl::function_CallsFunction::get_string 2575 ns 2574 ns 269710 -bm_rtl::method_____CallsMethod::get_string 2585 ns 2584 ns 269620 - -bm_rtl::function_ErasedReturnType::get_string 2586 ns 2584 ns 265265 -bm_rtl::method___ErasedReturnType::get_string 2620 ns 2618 ns 265946 -bm_rtl::method___ErasedTargetType::get_string 2593 ns 2591 ns 268385 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2625 ns 2624 ns 264396 ------------------------------------ -[2025-10-25 08:36:32] >>> Run 3: workload scale = 100 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 100 iterations -============================================= - -2025-10-25T08:36:32+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.07, 1.20, 1.00 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 1951 ns 1950 ns 354593 - -bm_call::by_FunctionPtr_Function::set_string 1959 ns 1958 ns 357458 -bm_call::by_FunctionPtr___Method::set_string 1956 ns 1955 ns 354524 - -bm_std::function_CallsFunction::set_string 1955 ns 1953 ns 350815 -bm_std::function___CallsMethod::set_string 1959 ns 1958 ns 356103 - -bm_rtl::function_CallsFunction::set_string 1957 ns 1956 ns 358544 -bm_rtl::method_____CallsMethod::set_string 1962 ns 1961 ns 354408 - -bm_rtl::function_ErasedReturnType::set_string 1965 ns 1964 ns 352941 -bm_rtl::method___ErasedReturnType::set_string 1970 ns 1969 ns 346967 -bm_rtl::method___ErasedTargetType::set_string 1968 ns 1967 ns 335767 -bm_rtl::method___ErasedTargetAndReturnType::set_string 1974 ns 1972 ns 350625 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2472 ns 2471 ns 280910 - -bm_call::by_FunctionPtr_Function::get_string 2469 ns 2468 ns 282225 -bm_call::by_FunctionPtr___Method::get_string 2468 ns 2467 ns 280716 - -bm_std::function_CallsFunction::get_string 2468 ns 2467 ns 280210 -bm_std::function___CallsMethod::get_string 2473 ns 2472 ns 280456 - -bm_rtl::function_CallsFunction::get_string 2468 ns 2467 ns 279723 -bm_rtl::method_____CallsMethod::get_string 2468 ns 2467 ns 281312 - -bm_rtl::function_ErasedReturnType::get_string 2505 ns 2504 ns 275122 -bm_rtl::method___ErasedReturnType::get_string 2506 ns 2504 ns 276606 -bm_rtl::method___ErasedTargetType::get_string 2485 ns 2484 ns 278931 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2513 ns 2511 ns 275206 ------------------------------------ -[2025-10-25 08:36:53] >>> Run 1: workload scale = 120 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 120 iterations -============================================= - -2025-10-25T08:36:53+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.05, 1.19, 1.00 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 2154 ns 2153 ns 323732 - -bm_call::by_FunctionPtr_Function::set_string 2150 ns 2149 ns 320699 -bm_call::by_FunctionPtr___Method::set_string 2159 ns 2158 ns 323064 - -bm_std::function_CallsFunction::set_string 2133 ns 2133 ns 320767 -bm_std::function___CallsMethod::set_string 2144 ns 2143 ns 322062 - -bm_rtl::function_CallsFunction::set_string 2138 ns 2137 ns 325609 -bm_rtl::method_____CallsMethod::set_string 2136 ns 2136 ns 319234 - -bm_rtl::function_ErasedReturnType::set_string 2135 ns 2134 ns 318553 -bm_rtl::method___ErasedReturnType::set_string 2138 ns 2137 ns 324005 -bm_rtl::method___ErasedTargetType::set_string 2161 ns 2160 ns 320548 -bm_rtl::method___ErasedTargetAndReturnType::set_string 2144 ns 2143 ns 322260 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2918 ns 2916 ns 237030 - -bm_call::by_FunctionPtr_Function::get_string 2918 ns 2916 ns 234279 -bm_call::by_FunctionPtr___Method::get_string 2917 ns 2915 ns 237717 - -bm_std::function_CallsFunction::get_string 2917 ns 2915 ns 234701 -bm_std::function___CallsMethod::get_string 2925 ns 2924 ns 236487 - -bm_rtl::function_CallsFunction::get_string 2918 ns 2917 ns 236650 -bm_rtl::method_____CallsMethod::get_string 2917 ns 2916 ns 237493 - -bm_rtl::function_ErasedReturnType::get_string 2950 ns 2948 ns 233932 -bm_rtl::method___ErasedReturnType::get_string 2957 ns 2955 ns 234740 -bm_rtl::method___ErasedTargetType::get_string 2968 ns 2967 ns 224637 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2962 ns 2961 ns 234086 ------------------------------------ -[2025-10-25 08:37:14] >>> Run 2: workload scale = 120 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 120 iterations -============================================= - -2025-10-25T08:37:14+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2422.26 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.03, 1.17, 1.00 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 2126 ns 2126 ns 324679 - -bm_call::by_FunctionPtr_Function::set_string 2134 ns 2133 ns 323473 -bm_call::by_FunctionPtr___Method::set_string 2140 ns 2139 ns 323268 - -bm_std::function_CallsFunction::set_string 2129 ns 2128 ns 323338 -bm_std::function___CallsMethod::set_string 2135 ns 2134 ns 310502 - -bm_rtl::function_CallsFunction::set_string 2128 ns 2127 ns 328046 -bm_rtl::method_____CallsMethod::set_string 2132 ns 2131 ns 323372 - -bm_rtl::function_ErasedReturnType::set_string 2134 ns 2133 ns 326776 -bm_rtl::method___ErasedReturnType::set_string 2154 ns 2152 ns 326321 -bm_rtl::method___ErasedTargetType::set_string 2156 ns 2156 ns 320272 -bm_rtl::method___ErasedTargetAndReturnType::set_string 2173 ns 2172 ns 321768 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 3039 ns 3038 ns 228220 - -bm_call::by_FunctionPtr_Function::get_string 3066 ns 3065 ns 228111 -bm_call::by_FunctionPtr___Method::get_string 3033 ns 3033 ns 229934 - -bm_std::function_CallsFunction::get_string 3041 ns 3039 ns 229708 -bm_std::function___CallsMethod::get_string 3044 ns 3044 ns 229028 - -bm_rtl::function_CallsFunction::get_string 2911 ns 2911 ns 233145 -bm_rtl::method_____CallsMethod::get_string 2912 ns 2911 ns 239735 - -bm_rtl::function_ErasedReturnType::get_string 3028 ns 3027 ns 236359 -bm_rtl::method___ErasedReturnType::get_string 3079 ns 3078 ns 226199 -bm_rtl::method___ErasedTargetType::get_string 3068 ns 3067 ns 227273 -bm_rtl::method___ErasedTargetAndReturnType::get_string 3089 ns 3088 ns 225302 ------------------------------------ -[2025-10-25 08:37:36] >>> Run 3: workload scale = 120 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 120 iterations -============================================= - -2025-10-25T08:37:36+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 3688.05 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.17, 1.20, 1.01 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 2143 ns 2142 ns 299942 - -bm_call::by_FunctionPtr_Function::set_string 2161 ns 2160 ns 324844 -bm_call::by_FunctionPtr___Method::set_string 2140 ns 2139 ns 326218 - -bm_std::function_CallsFunction::set_string 2129 ns 2128 ns 317297 -bm_std::function___CallsMethod::set_string 2136 ns 2135 ns 323624 - -bm_rtl::function_CallsFunction::set_string 2134 ns 2133 ns 320355 -bm_rtl::method_____CallsMethod::set_string 2131 ns 2130 ns 321763 - -bm_rtl::function_ErasedReturnType::set_string 2136 ns 2135 ns 324047 -bm_rtl::method___ErasedReturnType::set_string 2140 ns 2138 ns 321731 -bm_rtl::method___ErasedTargetType::set_string 2143 ns 2142 ns 322519 -bm_rtl::method___ErasedTargetAndReturnType::set_string 2143 ns 2143 ns 321554 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 2927 ns 2925 ns 236348 - -bm_call::by_FunctionPtr_Function::get_string 2936 ns 2935 ns 236522 -bm_call::by_FunctionPtr___Method::get_string 2924 ns 2924 ns 236896 - -bm_std::function_CallsFunction::get_string 2921 ns 2920 ns 236227 -bm_std::function___CallsMethod::get_string 2931 ns 2931 ns 235379 - -bm_rtl::function_CallsFunction::get_string 2922 ns 2921 ns 235415 -bm_rtl::method_____CallsMethod::get_string 2924 ns 2924 ns 236926 - -bm_rtl::function_ErasedReturnType::get_string 2972 ns 2971 ns 234773 -bm_rtl::method___ErasedReturnType::get_string 2972 ns 2971 ns 233069 -bm_rtl::method___ErasedTargetType::get_string 2940 ns 2939 ns 235111 -bm_rtl::method___ErasedTargetAndReturnType::get_string 2967 ns 2966 ns 231931 ------------------------------------ -[2025-10-25 08:37:57] >>> Run 1: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-10-25T08:37:57+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 2614.17 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.12, 1.18, 1.01 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 3517 ns 3515 ns 198375 - -bm_call::by_FunctionPtr_Function::set_string 3530 ns 3529 ns 198234 -bm_call::by_FunctionPtr___Method::set_string 3523 ns 3523 ns 195386 - -bm_std::function_CallsFunction::set_string 3518 ns 3517 ns 196144 -bm_std::function___CallsMethod::set_string 3518 ns 3517 ns 197544 - -bm_rtl::function_CallsFunction::set_string 3518 ns 3518 ns 197541 -bm_rtl::method_____CallsMethod::set_string 3519 ns 3518 ns 198159 - -bm_rtl::function_ErasedReturnType::set_string 3523 ns 3522 ns 197699 -bm_rtl::method___ErasedReturnType::set_string 3525 ns 3525 ns 195578 -bm_rtl::method___ErasedTargetType::set_string 3529 ns 3529 ns 196644 -bm_rtl::method___ErasedTargetAndReturnType::set_string 3553 ns 3552 ns 195863 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 4439 ns 4437 ns 154718 - -bm_call::by_FunctionPtr_Function::get_string 4434 ns 4433 ns 156870 -bm_call::by_FunctionPtr___Method::get_string 4433 ns 4432 ns 156941 - -bm_std::function_CallsFunction::get_string 4430 ns 4429 ns 153896 -bm_std::function___CallsMethod::get_string 4475 ns 4474 ns 156754 - -bm_rtl::function_CallsFunction::get_string 4431 ns 4431 ns 156729 -bm_rtl::method_____CallsMethod::get_string 4433 ns 4432 ns 156452 - -bm_rtl::function_ErasedReturnType::get_string 4476 ns 4474 ns 155013 -bm_rtl::method___ErasedReturnType::get_string 4477 ns 4476 ns 155632 -bm_rtl::method___ErasedTargetType::get_string 4477 ns 4476 ns 155619 -bm_rtl::method___ErasedTargetAndReturnType::get_string 4500 ns 4498 ns 154454 ------------------------------------ -[2025-10-25 08:38:23] >>> Run 2: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-10-25T08:38:23+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 800 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.08, 1.17, 1.01 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 3520 ns 3519 ns 197160 - -bm_call::by_FunctionPtr_Function::set_string 3542 ns 3541 ns 196662 -bm_call::by_FunctionPtr___Method::set_string 3530 ns 3529 ns 197455 - -bm_std::function_CallsFunction::set_string 3509 ns 3508 ns 196642 -bm_std::function___CallsMethod::set_string 3511 ns 3511 ns 192804 - -bm_rtl::function_CallsFunction::set_string 3514 ns 3513 ns 198927 -bm_rtl::method_____CallsMethod::set_string 3511 ns 3510 ns 198884 - -bm_rtl::function_ErasedReturnType::set_string 3523 ns 3522 ns 198748 -bm_rtl::method___ErasedReturnType::set_string 3520 ns 3519 ns 198328 -bm_rtl::method___ErasedTargetType::set_string 3532 ns 3531 ns 198312 -bm_rtl::method___ErasedTargetAndReturnType::set_string 3525 ns 3524 ns 195834 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 4436 ns 4435 ns 155924 - -bm_call::by_FunctionPtr_Function::get_string 4438 ns 4437 ns 156402 -bm_call::by_FunctionPtr___Method::get_string 4437 ns 4436 ns 155993 - -bm_std::function_CallsFunction::get_string 4460 ns 4459 ns 156561 -bm_std::function___CallsMethod::get_string 4443 ns 4442 ns 156940 - -bm_rtl::function_CallsFunction::get_string 4438 ns 4438 ns 156357 -bm_rtl::method_____CallsMethod::get_string 4439 ns 4438 ns 157440 - -bm_rtl::function_ErasedReturnType::get_string 4485 ns 4484 ns 155721 -bm_rtl::method___ErasedReturnType::get_string 4482 ns 4480 ns 155966 -bm_rtl::method___ErasedTargetType::get_string 4457 ns 4456 ns 156554 -bm_rtl::method___ErasedTargetAndReturnType::get_string 4492 ns 4491 ns 155021 ------------------------------------ -[2025-10-25 08:38:48] >>> Run 3: workload scale = 150 - -======== RTL Benchmark Configuration ======== -Workload: concatenate string of length 500 -Scale : 150 iterations -============================================= - -2025-10-25T08:38:48+05:30 -Running ./bin/RTLBenchmarkApp -Run on (16 X 1399.59 MHz CPU s) -CPU Caches: - L1 Data 48 KiB (x8) - L1 Instruction 32 KiB (x8) - L2 Unified 1280 KiB (x8) - L3 Unified 20480 KiB (x1) -Load Average: 1.05, 1.15, 1.00 -------------------------------------------------------------------------------------------------- -Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::set_string 3523 ns 3522 ns 195782 - -bm_call::by_FunctionPtr_Function::set_string 3524 ns 3524 ns 195591 -bm_call::by_FunctionPtr___Method::set_string 3522 ns 3521 ns 197458 - -bm_std::function_CallsFunction::set_string 3559 ns 3558 ns 196261 -bm_std::function___CallsMethod::set_string 3559 ns 3558 ns 194883 - -bm_rtl::function_CallsFunction::set_string 3521 ns 3520 ns 198009 -bm_rtl::method_____CallsMethod::set_string 3529 ns 3528 ns 194897 - -bm_rtl::function_ErasedReturnType::set_string 3535 ns 3535 ns 196213 -bm_rtl::method___ErasedReturnType::set_string 3544 ns 3543 ns 196908 -bm_rtl::method___ErasedTargetType::set_string 3543 ns 3543 ns 196724 -bm_rtl::method___ErasedTargetAndReturnType::set_string 3545 ns 3544 ns 196325 -------------------------------------------------------------------------------------------------- -bm_call::direct_Function::get_string 4440 ns 4439 ns 156865 - -bm_call::by_FunctionPtr_Function::get_string 4448 ns 4447 ns 156018 -bm_call::by_FunctionPtr___Method::get_string 4444 ns 4442 ns 156434 - -bm_std::function_CallsFunction::get_string 4445 ns 4444 ns 155973 -bm_std::function___CallsMethod::get_string 4453 ns 4453 ns 156511 - -bm_rtl::function_CallsFunction::get_string 4443 ns 4443 ns 157164 -bm_rtl::method_____CallsMethod::get_string 4445 ns 4444 ns 156931 - -bm_rtl::function_ErasedReturnType::get_string 4535 ns 4535 ns 153398 -bm_rtl::method___ErasedReturnType::get_string 4499 ns 4497 ns 154376 -bm_rtl::method___ErasedTargetType::get_string 4473 ns 4471 ns 155462 -bm_rtl::method___ErasedTargetAndReturnType::get_string 4505 ns 4504 ns 155125 ------------------------------------ -All benchmarks completed. diff --git a/text-benchmark-logs/benchmark_runs_string.log b/text-benchmark-logs/benchmark_runs_string.log new file mode 100644 index 00000000..8411fb33 --- /dev/null +++ b/text-benchmark-logs/benchmark_runs_string.log @@ -0,0 +1,3167 @@ +Starting benchmark runs... +Binary: ./bin/RTLBenchmarkApp +Log: ./benchmark_runs.log +=================================== +[2025-11-04 12:16:26] >>> Run 1: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T12:16:26+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3710.04 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.72, 1.01, 0.81 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 10.7 ns 10.7 ns 63153409 + +bm_call::via_function_ptr__Function::set_string 11.0 ns 11.0 ns 62273630 +bm_call::via_function_ptr____Method::set_string 11.1 ns 11.1 ns 62565849 + +bm_std::function_calls__Function::set_string 11.3 ns 11.3 ns 60820859 +bm_std::function_calls____Method::set_string 11.3 ns 11.2 ns 62223001 + +bm_rtl::function_calls__Function::set_string 11.8 ns 11.8 ns 62334625 +bm_rtl::method_calls______Method::set_string 11.7 ns 11.7 ns 58038245 + +bm_rtl::function__ErasedReturnType::set_string 13.6 ns 13.6 ns 51307142 +bm_rtl::method____ErasedReturnType::set_string 14.5 ns 14.5 ns 49013292 +bm_rtl::method____ErasedTargetType::set_string 14.4 ns 14.4 ns 48282886 +bm_rtl::method____ErasedTargetAndReturnType::set_string 14.3 ns 14.3 ns 48290341 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 12.3 ns 12.3 ns 56910624 + +bm_call::via_function_ptr__Function::get_string 13.3 ns 13.3 ns 54725237 +bm_call::via_function_ptr____Method::get_string 13.5 ns 13.5 ns 51174087 + +bm_std::function_calls__Function::get_string 13.4 ns 13.4 ns 51284624 +bm_std::function_calls____Method::get_string 13.4 ns 13.4 ns 53332275 + +bm_rtl::function_calls__Function::get_string 12.9 ns 12.9 ns 51676343 +bm_rtl::method_calls______Method::get_string 13.0 ns 13.0 ns 53310944 + +bm_rtl::function__ErasedReturnType::get_string 33.5 ns 33.5 ns 21875285 +bm_rtl::method____ErasedReturnType::get_string 33.8 ns 33.8 ns 20417210 +bm_rtl::method____ErasedTargetType::get_string 23.0 ns 23.0 ns 31547854 +bm_rtl::method____ErasedTargetAndReturnType::get_string 34.6 ns 34.6 ns 20062476 +----------------------------------- +[2025-11-04 12:16:45] >>> Run 2: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T12:16:45+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3859.55 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 1.06, 0.83 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 10.8 ns 10.8 ns 59543169 + +bm_call::via_function_ptr__Function::set_string 11.3 ns 11.3 ns 63603473 +bm_call::via_function_ptr____Method::set_string 11.4 ns 11.4 ns 60018727 + +bm_std::function_calls__Function::set_string 11.6 ns 11.6 ns 61482058 +bm_std::function_calls____Method::set_string 11.4 ns 11.4 ns 60456156 + +bm_rtl::function_calls__Function::set_string 11.2 ns 11.2 ns 62862118 +bm_rtl::method_calls______Method::set_string 11.8 ns 11.8 ns 58169006 + +bm_rtl::function__ErasedReturnType::set_string 13.8 ns 13.8 ns 49964913 +bm_rtl::method____ErasedReturnType::set_string 14.1 ns 14.1 ns 49075849 +bm_rtl::method____ErasedTargetType::set_string 14.7 ns 14.7 ns 47435229 +bm_rtl::method____ErasedTargetAndReturnType::set_string 14.4 ns 14.4 ns 48401256 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 12.7 ns 12.7 ns 54462134 + +bm_call::via_function_ptr__Function::get_string 12.9 ns 12.9 ns 55248821 +bm_call::via_function_ptr____Method::get_string 12.9 ns 12.9 ns 54718885 + +bm_std::function_calls__Function::get_string 13.0 ns 13.0 ns 53924949 +bm_std::function_calls____Method::get_string 12.9 ns 12.9 ns 53432887 + +bm_rtl::function_calls__Function::get_string 12.6 ns 12.6 ns 55170671 +bm_rtl::method_calls______Method::get_string 12.8 ns 12.8 ns 54845579 + +bm_rtl::function__ErasedReturnType::get_string 31.9 ns 31.8 ns 21982235 +bm_rtl::method____ErasedReturnType::get_string 32.3 ns 32.3 ns 21861314 +bm_rtl::method____ErasedTargetType::get_string 21.5 ns 21.5 ns 32708463 +bm_rtl::method____ErasedTargetAndReturnType::get_string 32.9 ns 32.9 ns 21076858 +----------------------------------- +[2025-11-04 12:17:05] >>> Run 3: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T12:17:05+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.05, 0.83 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 10.6 ns 10.6 ns 64487293 + +bm_call::via_function_ptr__Function::set_string 10.9 ns 10.9 ns 64347447 +bm_call::via_function_ptr____Method::set_string 10.9 ns 10.9 ns 63847988 + +bm_std::function_calls__Function::set_string 11.2 ns 11.2 ns 61218687 +bm_std::function_calls____Method::set_string 11.3 ns 11.3 ns 61153450 + +bm_rtl::function_calls__Function::set_string 11.1 ns 11.1 ns 61892878 +bm_rtl::method_calls______Method::set_string 11.3 ns 11.3 ns 61658245 + +bm_rtl::function__ErasedReturnType::set_string 13.3 ns 13.3 ns 52552206 +bm_rtl::method____ErasedReturnType::set_string 13.9 ns 13.9 ns 50430274 +bm_rtl::method____ErasedTargetType::set_string 14.4 ns 14.4 ns 47389596 +bm_rtl::method____ErasedTargetAndReturnType::set_string 14.7 ns 14.7 ns 47109221 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 12.6 ns 12.6 ns 55992884 + +bm_call::via_function_ptr__Function::get_string 12.9 ns 12.9 ns 51161238 +bm_call::via_function_ptr____Method::get_string 12.9 ns 12.9 ns 55017241 + +bm_std::function_calls__Function::get_string 13.5 ns 13.5 ns 53286324 +bm_std::function_calls____Method::get_string 13.3 ns 13.3 ns 52908638 + +bm_rtl::function_calls__Function::get_string 12.6 ns 12.6 ns 54243132 +bm_rtl::method_calls______Method::get_string 13.2 ns 13.2 ns 54944142 + +bm_rtl::function__ErasedReturnType::get_string 33.1 ns 33.1 ns 20589263 +bm_rtl::method____ErasedReturnType::get_string 32.9 ns 32.9 ns 21653434 +bm_rtl::method____ErasedTargetType::get_string 23.6 ns 23.6 ns 32185719 +bm_rtl::method____ErasedTargetAndReturnType::get_string 34.2 ns 34.2 ns 20567080 +----------------------------------- +[2025-11-04 12:17:24] >>> Run 4: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T12:17:24+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4288.87 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.09, 1.07, 0.84 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 11.1 ns 11.1 ns 66290824 + +bm_call::via_function_ptr__Function::set_string 11.0 ns 11.0 ns 60341873 +bm_call::via_function_ptr____Method::set_string 11.6 ns 11.6 ns 61663734 + +bm_std::function_calls__Function::set_string 11.6 ns 11.6 ns 62238534 +bm_std::function_calls____Method::set_string 11.4 ns 11.4 ns 62096594 + +bm_rtl::function_calls__Function::set_string 11.3 ns 11.3 ns 61460234 +bm_rtl::method_calls______Method::set_string 11.6 ns 11.6 ns 60712083 + +bm_rtl::function__ErasedReturnType::set_string 13.3 ns 13.3 ns 52213654 +bm_rtl::method____ErasedReturnType::set_string 14.2 ns 14.2 ns 48504898 +bm_rtl::method____ErasedTargetType::set_string 14.7 ns 14.7 ns 47578516 +bm_rtl::method____ErasedTargetAndReturnType::set_string 14.7 ns 14.7 ns 48196113 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 12.4 ns 12.4 ns 56590796 + +bm_call::via_function_ptr__Function::get_string 12.7 ns 12.7 ns 55116932 +bm_call::via_function_ptr____Method::get_string 12.8 ns 12.8 ns 53240632 + +bm_std::function_calls__Function::get_string 13.0 ns 13.0 ns 52948776 +bm_std::function_calls____Method::get_string 12.9 ns 12.9 ns 54392848 + +bm_rtl::function_calls__Function::get_string 12.6 ns 12.6 ns 55104443 +bm_rtl::method_calls______Method::get_string 12.7 ns 12.7 ns 54425465 + +bm_rtl::function__ErasedReturnType::get_string 31.6 ns 31.6 ns 22273160 +bm_rtl::method____ErasedReturnType::get_string 32.1 ns 32.1 ns 21839814 +bm_rtl::method____ErasedTargetType::get_string 22.2 ns 22.2 ns 31167600 +bm_rtl::method____ErasedTargetAndReturnType::get_string 32.7 ns 32.7 ns 21437578 +----------------------------------- +[2025-11-04 12:17:43] >>> Run 5: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T12:17:43+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2364.75 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.13, 1.08, 0.85 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 10.6 ns 10.6 ns 65062380 + +bm_call::via_function_ptr__Function::set_string 10.8 ns 10.8 ns 64248959 +bm_call::via_function_ptr____Method::set_string 11.0 ns 11.0 ns 62551535 + +bm_std::function_calls__Function::set_string 11.2 ns 11.2 ns 60406745 +bm_std::function_calls____Method::set_string 11.3 ns 11.3 ns 62448796 + +bm_rtl::function_calls__Function::set_string 11.2 ns 11.2 ns 62675614 +bm_rtl::method_calls______Method::set_string 11.3 ns 11.3 ns 61733399 + +bm_rtl::function__ErasedReturnType::set_string 13.3 ns 13.3 ns 52161573 +bm_rtl::method____ErasedReturnType::set_string 14.3 ns 14.3 ns 48854344 +bm_rtl::method____ErasedTargetType::set_string 14.5 ns 14.5 ns 47526683 +bm_rtl::method____ErasedTargetAndReturnType::set_string 14.4 ns 14.4 ns 48356248 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 12.4 ns 12.4 ns 57334137 + +bm_call::via_function_ptr__Function::get_string 12.7 ns 12.7 ns 54933363 +bm_call::via_function_ptr____Method::get_string 12.8 ns 12.8 ns 53994926 + +bm_std::function_calls__Function::get_string 12.9 ns 12.9 ns 53790025 +bm_std::function_calls____Method::get_string 12.9 ns 12.9 ns 54509865 + +bm_rtl::function_calls__Function::get_string 12.6 ns 12.6 ns 55782606 +bm_rtl::method_calls______Method::get_string 12.8 ns 12.8 ns 54696995 + +bm_rtl::function__ErasedReturnType::get_string 31.7 ns 31.7 ns 22095198 +bm_rtl::method____ErasedReturnType::get_string 32.4 ns 32.3 ns 21713225 +bm_rtl::method____ErasedTargetType::get_string 22.2 ns 22.2 ns 31569734 +bm_rtl::method____ErasedTargetAndReturnType::get_string 33.1 ns 33.1 ns 21257867 +----------------------------------- +[2025-11-04 12:18:02] >>> Run 1: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-11-04T12:18:02+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2640.13 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.09, 1.07, 0.85 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 24.9 ns 24.9 ns 28022770 + +bm_call::via_function_ptr__Function::set_string 25.9 ns 25.9 ns 26967330 +bm_call::via_function_ptr____Method::set_string 25.9 ns 25.9 ns 27132859 + +bm_std::function_calls__Function::set_string 26.4 ns 26.4 ns 26707120 +bm_std::function_calls____Method::set_string 27.0 ns 27.0 ns 25364124 + +bm_rtl::function_calls__Function::set_string 26.5 ns 26.5 ns 26552439 +bm_rtl::method_calls______Method::set_string 26.6 ns 26.6 ns 26210950 + +bm_rtl::function__ErasedReturnType::set_string 28.3 ns 28.3 ns 24736980 +bm_rtl::method____ErasedReturnType::set_string 30.2 ns 30.2 ns 23375542 +bm_rtl::method____ErasedTargetType::set_string 30.6 ns 30.6 ns 22925732 +bm_rtl::method____ErasedTargetAndReturnType::set_string 30.2 ns 30.2 ns 23200080 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 48.3 ns 48.3 ns 15089307 + +bm_call::via_function_ptr__Function::get_string 46.2 ns 46.2 ns 14395666 +bm_call::via_function_ptr____Method::get_string 46.4 ns 46.4 ns 15068891 + +bm_std::function_calls__Function::get_string 47.4 ns 47.4 ns 14709171 +bm_std::function_calls____Method::get_string 47.0 ns 47.0 ns 14929156 + +bm_rtl::function_calls__Function::get_string 47.2 ns 47.2 ns 14911798 +bm_rtl::method_calls______Method::get_string 47.4 ns 47.3 ns 14890050 + +bm_rtl::function__ErasedReturnType::get_string 73.3 ns 73.3 ns 9416841 +bm_rtl::method____ErasedReturnType::get_string 74.4 ns 74.4 ns 9461511 +bm_rtl::method____ErasedTargetType::get_string 51.9 ns 51.8 ns 13545805 +bm_rtl::method____ErasedTargetAndReturnType::get_string 76.1 ns 76.1 ns 9115088 +----------------------------------- +[2025-11-04 12:18:25] >>> Run 2: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-11-04T12:18:25+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3955.49 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.19, 1.10, 0.87 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 26.2 ns 26.2 ns 27125007 + +bm_call::via_function_ptr__Function::set_string 27.0 ns 27.0 ns 25958094 +bm_call::via_function_ptr____Method::set_string 27.6 ns 27.6 ns 25196375 + +bm_std::function_calls__Function::set_string 26.5 ns 26.5 ns 25360125 +bm_std::function_calls____Method::set_string 26.9 ns 26.9 ns 26002489 + +bm_rtl::function_calls__Function::set_string 27.6 ns 27.6 ns 26475578 +bm_rtl::method_calls______Method::set_string 27.4 ns 27.4 ns 26001742 + +bm_rtl::function__ErasedReturnType::set_string 29.0 ns 29.0 ns 24504219 +bm_rtl::method____ErasedReturnType::set_string 30.8 ns 30.8 ns 22220233 +bm_rtl::method____ErasedTargetType::set_string 32.1 ns 32.1 ns 22030367 +bm_rtl::method____ErasedTargetAndReturnType::set_string 31.5 ns 31.5 ns 21595468 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 48.9 ns 48.9 ns 14300718 + +bm_call::via_function_ptr__Function::get_string 47.1 ns 47.0 ns 14990892 +bm_call::via_function_ptr____Method::get_string 50.2 ns 50.2 ns 12790209 + +bm_std::function_calls__Function::get_string 51.9 ns 51.9 ns 13535943 +bm_std::function_calls____Method::get_string 51.0 ns 51.0 ns 13266104 + +bm_rtl::function_calls__Function::get_string 52.0 ns 52.0 ns 13086597 +bm_rtl::method_calls______Method::get_string 52.3 ns 52.3 ns 13161774 + +bm_rtl::function__ErasedReturnType::get_string 75.2 ns 75.1 ns 9107436 +bm_rtl::method____ErasedReturnType::get_string 75.1 ns 75.1 ns 9267100 +bm_rtl::method____ErasedTargetType::get_string 55.1 ns 55.1 ns 12320961 +bm_rtl::method____ErasedTargetAndReturnType::get_string 75.8 ns 75.8 ns 8943782 +----------------------------------- +[2025-11-04 12:18:45] >>> Run 3: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-11-04T12:18:45+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3021.55 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.42, 1.16, 0.89 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 25.8 ns 25.8 ns 26976208 + +bm_call::via_function_ptr__Function::set_string 26.2 ns 26.2 ns 26667714 +bm_call::via_function_ptr____Method::set_string 25.9 ns 25.9 ns 26622049 + +bm_std::function_calls__Function::set_string 26.5 ns 26.5 ns 26580719 +bm_std::function_calls____Method::set_string 26.5 ns 26.5 ns 26123278 + +bm_rtl::function_calls__Function::set_string 26.5 ns 26.5 ns 26879045 +bm_rtl::method_calls______Method::set_string 26.9 ns 26.9 ns 25596201 + +bm_rtl::function__ErasedReturnType::set_string 28.5 ns 28.5 ns 24501028 +bm_rtl::method____ErasedReturnType::set_string 29.4 ns 29.4 ns 23746741 +bm_rtl::method____ErasedTargetType::set_string 30.3 ns 30.3 ns 23247708 +bm_rtl::method____ErasedTargetAndReturnType::set_string 29.8 ns 29.7 ns 23353452 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 50.2 ns 50.2 ns 13814456 + +bm_call::via_function_ptr__Function::get_string 50.3 ns 50.3 ns 13214574 +bm_call::via_function_ptr____Method::get_string 50.3 ns 50.3 ns 13867447 + +bm_std::function_calls__Function::get_string 51.4 ns 51.4 ns 13700559 +bm_std::function_calls____Method::get_string 50.8 ns 50.8 ns 12953501 + +bm_rtl::function_calls__Function::get_string 51.3 ns 51.2 ns 13527958 +bm_rtl::method_calls______Method::get_string 51.4 ns 51.4 ns 13420354 + +bm_rtl::function__ErasedReturnType::get_string 72.1 ns 72.1 ns 9577905 +bm_rtl::method____ErasedReturnType::get_string 73.4 ns 73.4 ns 9418802 +bm_rtl::method____ErasedTargetType::get_string 52.8 ns 52.8 ns 12881319 +bm_rtl::method____ErasedTargetAndReturnType::get_string 75.1 ns 75.1 ns 9268764 +----------------------------------- +[2025-11-04 12:19:05] >>> Run 1: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-11-04T12:19:05+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1832.76 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.51, 1.19, 0.91 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 109 ns 109 ns 6356905 + +bm_call::via_function_ptr__Function::set_string 110 ns 110 ns 6362958 +bm_call::via_function_ptr____Method::set_string 110 ns 110 ns 6337180 + +bm_std::function_calls__Function::set_string 112 ns 112 ns 6271505 +bm_std::function_calls____Method::set_string 111 ns 111 ns 6267824 + +bm_rtl::function_calls__Function::set_string 111 ns 111 ns 6287188 +bm_rtl::method_calls______Method::set_string 111 ns 111 ns 6263824 + +bm_rtl::function__ErasedReturnType::set_string 114 ns 114 ns 6107867 +bm_rtl::method____ErasedReturnType::set_string 114 ns 114 ns 6126524 +bm_rtl::method____ErasedTargetType::set_string 115 ns 115 ns 6078615 +bm_rtl::method____ErasedTargetAndReturnType::set_string 114 ns 114 ns 6060333 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 211 ns 211 ns 3302773 + +bm_call::via_function_ptr__Function::get_string 212 ns 212 ns 3300130 +bm_call::via_function_ptr____Method::get_string 213 ns 213 ns 3269215 + +bm_std::function_calls__Function::get_string 212 ns 212 ns 3289700 +bm_std::function_calls____Method::get_string 212 ns 212 ns 3283718 + +bm_rtl::function_calls__Function::get_string 213 ns 213 ns 3282782 +bm_rtl::method_calls______Method::get_string 214 ns 214 ns 3260274 + +bm_rtl::function__ErasedReturnType::get_string 267 ns 267 ns 2625824 +bm_rtl::method____ErasedReturnType::get_string 268 ns 268 ns 2609629 +bm_rtl::method____ErasedTargetType::get_string 218 ns 218 ns 3204239 +bm_rtl::method____ErasedTargetAndReturnType::get_string 269 ns 269 ns 2603345 +----------------------------------- +[2025-11-04 12:19:24] >>> Run 2: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-11-04T12:19:24+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4801.49 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.40, 1.18, 0.92 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 110 ns 110 ns 6254342 + +bm_call::via_function_ptr__Function::set_string 111 ns 111 ns 6127808 +bm_call::via_function_ptr____Method::set_string 110 ns 110 ns 6215491 + +bm_std::function_calls__Function::set_string 112 ns 112 ns 6194003 +bm_std::function_calls____Method::set_string 112 ns 112 ns 6253000 + +bm_rtl::function_calls__Function::set_string 111 ns 111 ns 6277966 +bm_rtl::method_calls______Method::set_string 110 ns 110 ns 6335238 + +bm_rtl::function__ErasedReturnType::set_string 113 ns 113 ns 6173358 +bm_rtl::method____ErasedReturnType::set_string 113 ns 113 ns 6189036 +bm_rtl::method____ErasedTargetType::set_string 114 ns 114 ns 6088778 +bm_rtl::method____ErasedTargetAndReturnType::set_string 114 ns 114 ns 6097107 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 190 ns 190 ns 3679128 + +bm_call::via_function_ptr__Function::get_string 190 ns 190 ns 3672961 +bm_call::via_function_ptr____Method::get_string 190 ns 190 ns 3680081 + +bm_std::function_calls__Function::get_string 189 ns 189 ns 3685674 +bm_std::function_calls____Method::get_string 189 ns 189 ns 3697261 + +bm_rtl::function_calls__Function::get_string 190 ns 190 ns 3690621 +bm_rtl::method_calls______Method::get_string 190 ns 190 ns 3685585 + +bm_rtl::function__ErasedReturnType::get_string 242 ns 242 ns 2896462 +bm_rtl::method____ErasedReturnType::get_string 240 ns 240 ns 2919692 +bm_rtl::method____ErasedTargetType::get_string 195 ns 195 ns 3598721 +bm_rtl::method____ErasedTargetAndReturnType::get_string 242 ns 242 ns 2896405 +----------------------------------- +[2025-11-04 12:19:44] >>> Run 3: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-11-04T12:19:44+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2019.39 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.28, 1.17, 0.92 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 109 ns 109 ns 6366490 + +bm_call::via_function_ptr__Function::set_string 110 ns 110 ns 6364151 +bm_call::via_function_ptr____Method::set_string 110 ns 110 ns 6358758 + +bm_std::function_calls__Function::set_string 111 ns 111 ns 6296215 +bm_std::function_calls____Method::set_string 111 ns 111 ns 6318768 + +bm_rtl::function_calls__Function::set_string 110 ns 110 ns 6318789 +bm_rtl::method_calls______Method::set_string 110 ns 110 ns 6326380 + +bm_rtl::function__ErasedReturnType::set_string 113 ns 113 ns 6147018 +bm_rtl::method____ErasedReturnType::set_string 113 ns 113 ns 6162989 +bm_rtl::method____ErasedTargetType::set_string 115 ns 115 ns 5940721 +bm_rtl::method____ErasedTargetAndReturnType::set_string 114 ns 114 ns 6084423 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 191 ns 191 ns 3678026 + +bm_call::via_function_ptr__Function::get_string 191 ns 191 ns 3666456 +bm_call::via_function_ptr____Method::get_string 191 ns 191 ns 3666182 + +bm_std::function_calls__Function::get_string 190 ns 190 ns 3676735 +bm_std::function_calls____Method::get_string 190 ns 190 ns 3679305 + +bm_rtl::function_calls__Function::get_string 191 ns 190 ns 3683024 +bm_rtl::method_calls______Method::get_string 191 ns 191 ns 3674662 + +bm_rtl::function__ErasedReturnType::get_string 242 ns 242 ns 2882786 +bm_rtl::method____ErasedReturnType::get_string 241 ns 241 ns 2911958 +bm_rtl::method____ErasedTargetType::get_string 196 ns 196 ns 3581200 +bm_rtl::method____ErasedTargetAndReturnType::get_string 243 ns 243 ns 2882409 +----------------------------------- +[2025-11-04 12:20:03] >>> Run 1: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-11-04T12:20:03+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3993.12 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.20, 1.16, 0.92 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 187 ns 187 ns 3726311 + +bm_call::via_function_ptr__Function::set_string 188 ns 188 ns 3744673 +bm_call::via_function_ptr____Method::set_string 188 ns 188 ns 3735227 + +bm_std::function_calls__Function::set_string 188 ns 188 ns 3718232 +bm_std::function_calls____Method::set_string 188 ns 188 ns 3712163 + +bm_rtl::function_calls__Function::set_string 188 ns 188 ns 3719395 +bm_rtl::method_calls______Method::set_string 188 ns 188 ns 3708975 + +bm_rtl::function__ErasedReturnType::set_string 192 ns 192 ns 3644143 +bm_rtl::method____ErasedReturnType::set_string 192 ns 192 ns 3646885 +bm_rtl::method____ErasedTargetType::set_string 193 ns 193 ns 3651118 +bm_rtl::method____ErasedTargetAndReturnType::set_string 194 ns 194 ns 3617474 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 358 ns 358 ns 1956467 + +bm_call::via_function_ptr__Function::get_string 349 ns 349 ns 2006340 +bm_call::via_function_ptr____Method::get_string 351 ns 351 ns 2002609 + +bm_std::function_calls__Function::get_string 348 ns 348 ns 2008102 +bm_std::function_calls____Method::get_string 349 ns 349 ns 2011577 + +bm_rtl::function_calls__Function::get_string 348 ns 348 ns 2010126 +bm_rtl::method_calls______Method::get_string 349 ns 349 ns 2004066 + +bm_rtl::function__ErasedReturnType::get_string 426 ns 426 ns 1643422 +bm_rtl::method____ErasedReturnType::get_string 430 ns 430 ns 1629089 +bm_rtl::method____ErasedTargetType::get_string 353 ns 353 ns 1979505 +bm_rtl::method____ErasedTargetAndReturnType::get_string 429 ns 428 ns 1635028 +----------------------------------- +[2025-11-04 12:20:25] >>> Run 2: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-11-04T12:20:25+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2840.4 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.13, 1.14, 0.92 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 177 ns 177 ns 3940952 + +bm_call::via_function_ptr__Function::set_string 178 ns 178 ns 3934929 +bm_call::via_function_ptr____Method::set_string 178 ns 178 ns 3932855 + +bm_std::function_calls__Function::set_string 179 ns 178 ns 3927235 +bm_std::function_calls____Method::set_string 183 ns 183 ns 3673773 + +bm_rtl::function_calls__Function::set_string 180 ns 180 ns 3868708 +bm_rtl::method_calls______Method::set_string 180 ns 180 ns 3907622 + +bm_rtl::function__ErasedReturnType::set_string 183 ns 183 ns 3861068 +bm_rtl::method____ErasedReturnType::set_string 180 ns 180 ns 3885727 +bm_rtl::method____ErasedTargetType::set_string 183 ns 183 ns 3796810 +bm_rtl::method____ErasedTargetAndReturnType::set_string 183 ns 183 ns 3820688 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 319 ns 319 ns 2203411 + +bm_call::via_function_ptr__Function::get_string 310 ns 310 ns 2263612 +bm_call::via_function_ptr____Method::get_string 312 ns 312 ns 2254295 + +bm_std::function_calls__Function::get_string 311 ns 311 ns 2247231 +bm_std::function_calls____Method::get_string 310 ns 310 ns 2274352 + +bm_rtl::function_calls__Function::get_string 314 ns 314 ns 2259091 +bm_rtl::method_calls______Method::get_string 315 ns 315 ns 2266882 + +bm_rtl::function__ErasedReturnType::get_string 381 ns 381 ns 1843706 +bm_rtl::method____ErasedReturnType::get_string 382 ns 382 ns 1846973 +bm_rtl::method____ErasedTargetType::get_string 316 ns 316 ns 2213949 +bm_rtl::method____ErasedTargetAndReturnType::get_string 381 ns 381 ns 1843965 +----------------------------------- +[2025-11-04 12:20:47] >>> Run 3: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-11-04T12:20:47+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2572.05 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.25, 1.17, 0.93 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 178 ns 178 ns 3900950 + +bm_call::via_function_ptr__Function::set_string 180 ns 180 ns 3879189 +bm_call::via_function_ptr____Method::set_string 179 ns 179 ns 3834422 + +bm_std::function_calls__Function::set_string 179 ns 179 ns 3920381 +bm_std::function_calls____Method::set_string 180 ns 180 ns 3891620 + +bm_rtl::function_calls__Function::set_string 181 ns 181 ns 3872767 +bm_rtl::method_calls______Method::set_string 180 ns 180 ns 3910455 + +bm_rtl::function__ErasedReturnType::set_string 182 ns 182 ns 3832558 +bm_rtl::method____ErasedReturnType::set_string 181 ns 181 ns 3885287 +bm_rtl::method____ErasedTargetType::set_string 185 ns 185 ns 3776004 +bm_rtl::method____ErasedTargetAndReturnType::set_string 183 ns 183 ns 3823404 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 320 ns 320 ns 2191852 + +bm_call::via_function_ptr__Function::get_string 311 ns 311 ns 2255298 +bm_call::via_function_ptr____Method::get_string 314 ns 314 ns 2234056 + +bm_std::function_calls__Function::get_string 313 ns 313 ns 2230322 +bm_std::function_calls____Method::get_string 313 ns 313 ns 2216167 + +bm_rtl::function_calls__Function::get_string 355 ns 355 ns 2009288 +bm_rtl::method_calls______Method::get_string 323 ns 323 ns 1912946 + +bm_rtl::function__ErasedReturnType::get_string 384 ns 384 ns 1824265 +bm_rtl::method____ErasedReturnType::get_string 384 ns 384 ns 1808329 +bm_rtl::method____ErasedTargetType::get_string 321 ns 321 ns 2143924 +bm_rtl::method____ErasedTargetAndReturnType::get_string 385 ns 385 ns 1808807 +----------------------------------- +[2025-11-04 12:21:09] >>> Run 1: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-11-04T12:21:09+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4900 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.18, 1.16, 0.94 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 208 ns 208 ns 3354887 + +bm_call::via_function_ptr__Function::set_string 209 ns 209 ns 3348189 +bm_call::via_function_ptr____Method::set_string 214 ns 214 ns 3338144 + +bm_std::function_calls__Function::set_string 210 ns 210 ns 3356079 +bm_std::function_calls____Method::set_string 209 ns 209 ns 3352077 + +bm_rtl::function_calls__Function::set_string 211 ns 211 ns 3317584 +bm_rtl::method_calls______Method::set_string 209 ns 209 ns 3338550 + +bm_rtl::function__ErasedReturnType::set_string 212 ns 212 ns 3325113 +bm_rtl::method____ErasedReturnType::set_string 216 ns 216 ns 3217407 +bm_rtl::method____ErasedTargetType::set_string 212 ns 212 ns 3296378 +bm_rtl::method____ErasedTargetAndReturnType::set_string 210 ns 210 ns 3347149 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 383 ns 383 ns 1835016 + +bm_call::via_function_ptr__Function::get_string 381 ns 381 ns 1842308 +bm_call::via_function_ptr____Method::get_string 383 ns 383 ns 1831574 + +bm_std::function_calls__Function::get_string 395 ns 395 ns 1761881 +bm_std::function_calls____Method::get_string 387 ns 387 ns 1804570 + +bm_rtl::function_calls__Function::get_string 383 ns 383 ns 1817991 +bm_rtl::method_calls______Method::get_string 385 ns 385 ns 1823692 + +bm_rtl::function__ErasedReturnType::get_string 461 ns 461 ns 1524833 +bm_rtl::method____ErasedReturnType::get_string 463 ns 463 ns 1511457 +bm_rtl::method____ErasedTargetType::get_string 390 ns 390 ns 1795845 +bm_rtl::method____ErasedTargetAndReturnType::get_string 462 ns 462 ns 1515668 +----------------------------------- +[2025-11-04 12:21:31] >>> Run 2: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-11-04T12:21:31+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3073.18 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.19, 1.16, 0.94 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 210 ns 210 ns 3340652 + +bm_call::via_function_ptr__Function::set_string 211 ns 211 ns 3324856 +bm_call::via_function_ptr____Method::set_string 211 ns 211 ns 3310404 + +bm_std::function_calls__Function::set_string 212 ns 212 ns 3308725 +bm_std::function_calls____Method::set_string 212 ns 212 ns 3287037 + +bm_rtl::function_calls__Function::set_string 212 ns 212 ns 3314574 +bm_rtl::method_calls______Method::set_string 212 ns 212 ns 3283145 + +bm_rtl::function__ErasedReturnType::set_string 211 ns 211 ns 3341051 +bm_rtl::method____ErasedReturnType::set_string 214 ns 214 ns 3259385 +bm_rtl::method____ErasedTargetType::set_string 212 ns 212 ns 3304041 +bm_rtl::method____ErasedTargetAndReturnType::set_string 226 ns 226 ns 3085668 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 382 ns 382 ns 1626037 + +bm_call::via_function_ptr__Function::get_string 381 ns 381 ns 1835546 +bm_call::via_function_ptr____Method::get_string 383 ns 383 ns 1828808 + +bm_std::function_calls__Function::get_string 387 ns 387 ns 1822200 +bm_std::function_calls____Method::get_string 393 ns 393 ns 1800319 + +bm_rtl::function_calls__Function::get_string 386 ns 386 ns 1800817 +bm_rtl::method_calls______Method::get_string 384 ns 384 ns 1823455 + +bm_rtl::function__ErasedReturnType::get_string 462 ns 462 ns 1519511 +bm_rtl::method____ErasedReturnType::get_string 464 ns 464 ns 1504120 +bm_rtl::method____ErasedTargetType::get_string 393 ns 393 ns 1794253 +bm_rtl::method____ErasedTargetAndReturnType::get_string 462 ns 462 ns 1497097 +----------------------------------- +[2025-11-04 12:21:54] >>> Run 3: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-11-04T12:21:54+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2736.79 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.14, 1.15, 0.95 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 212 ns 212 ns 3300818 + +bm_call::via_function_ptr__Function::set_string 213 ns 213 ns 3277311 +bm_call::via_function_ptr____Method::set_string 212 ns 212 ns 3300103 + +bm_std::function_calls__Function::set_string 212 ns 212 ns 3272237 +bm_std::function_calls____Method::set_string 212 ns 212 ns 3299601 + +bm_rtl::function_calls__Function::set_string 219 ns 219 ns 3298106 +bm_rtl::method_calls______Method::set_string 217 ns 217 ns 3175023 + +bm_rtl::function__ErasedReturnType::set_string 228 ns 228 ns 3138094 +bm_rtl::method____ErasedReturnType::set_string 225 ns 225 ns 3093211 +bm_rtl::method____ErasedTargetType::set_string 222 ns 222 ns 3260985 +bm_rtl::method____ErasedTargetAndReturnType::set_string 225 ns 225 ns 3014027 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 409 ns 409 ns 1704362 + +bm_call::via_function_ptr__Function::get_string 400 ns 400 ns 1816140 +bm_call::via_function_ptr____Method::get_string 396 ns 396 ns 1710091 + +bm_std::function_calls__Function::get_string 396 ns 396 ns 1764724 +bm_std::function_calls____Method::get_string 413 ns 413 ns 1719759 + +bm_rtl::function_calls__Function::get_string 401 ns 401 ns 1722218 +bm_rtl::method_calls______Method::get_string 396 ns 395 ns 1730519 + +bm_rtl::function__ErasedReturnType::get_string 494 ns 494 ns 1440837 +bm_rtl::method____ErasedReturnType::get_string 475 ns 475 ns 1396097 +bm_rtl::method____ErasedTargetType::get_string 394 ns 394 ns 1749298 +bm_rtl::method____ErasedTargetAndReturnType::get_string 462 ns 462 ns 1464101 +----------------------------------- +[2025-11-04 12:22:17] >>> Run 1: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-11-04T12:22:17+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4443.83 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.39, 1.20, 0.97 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 300 ns 300 ns 2364526 + +bm_call::via_function_ptr__Function::set_string 308 ns 308 ns 2261139 +bm_call::via_function_ptr____Method::set_string 305 ns 305 ns 2314184 + +bm_std::function_calls__Function::set_string 304 ns 304 ns 2341024 +bm_std::function_calls____Method::set_string 289 ns 289 ns 2389222 + +bm_rtl::function_calls__Function::set_string 332 ns 332 ns 2175216 +bm_rtl::method_calls______Method::set_string 322 ns 322 ns 2088936 + +bm_rtl::function__ErasedReturnType::set_string 323 ns 322 ns 2146160 +bm_rtl::method____ErasedReturnType::set_string 333 ns 333 ns 2191564 +bm_rtl::method____ErasedTargetType::set_string 303 ns 303 ns 2332242 +bm_rtl::method____ErasedTargetAndReturnType::set_string 326 ns 326 ns 2345345 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 566 ns 566 ns 1251288 + +bm_call::via_function_ptr__Function::get_string 548 ns 548 ns 1233039 +bm_call::via_function_ptr____Method::get_string 540 ns 540 ns 1272200 + +bm_std::function_calls__Function::get_string 541 ns 541 ns 1268122 +bm_std::function_calls____Method::get_string 543 ns 543 ns 1234772 + +bm_rtl::function_calls__Function::get_string 543 ns 543 ns 1288268 +bm_rtl::method_calls______Method::get_string 546 ns 546 ns 1267151 + +bm_rtl::function__ErasedReturnType::get_string 659 ns 659 ns 1057558 +bm_rtl::method____ErasedReturnType::get_string 662 ns 662 ns 1022937 +bm_rtl::method____ErasedTargetType::get_string 562 ns 562 ns 1212939 +bm_rtl::method____ErasedTargetAndReturnType::get_string 666 ns 666 ns 1049185 +----------------------------------- +[2025-11-04 12:22:37] >>> Run 2: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-11-04T12:22:37+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1913.44 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.41, 1.22, 0.98 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 295 ns 295 ns 2334833 + +bm_call::via_function_ptr__Function::set_string 300 ns 300 ns 2352180 +bm_call::via_function_ptr____Method::set_string 301 ns 301 ns 2293720 + +bm_std::function_calls__Function::set_string 296 ns 296 ns 2395257 +bm_std::function_calls____Method::set_string 301 ns 301 ns 2276040 + +bm_rtl::function_calls__Function::set_string 297 ns 297 ns 2345901 +bm_rtl::method_calls______Method::set_string 296 ns 296 ns 2355417 + +bm_rtl::function__ErasedReturnType::set_string 295 ns 295 ns 2377750 +bm_rtl::method____ErasedReturnType::set_string 294 ns 294 ns 2351079 +bm_rtl::method____ErasedTargetType::set_string 295 ns 295 ns 2383689 +bm_rtl::method____ErasedTargetAndReturnType::set_string 296 ns 296 ns 2374165 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 536 ns 536 ns 1301506 + +bm_call::via_function_ptr__Function::get_string 535 ns 535 ns 1316754 +bm_call::via_function_ptr____Method::get_string 534 ns 534 ns 1293290 + +bm_std::function_calls__Function::get_string 537 ns 536 ns 1307063 +bm_std::function_calls____Method::get_string 540 ns 540 ns 1284540 + +bm_rtl::function_calls__Function::get_string 536 ns 536 ns 1287766 +bm_rtl::method_calls______Method::get_string 539 ns 539 ns 1301959 + +bm_rtl::function__ErasedReturnType::get_string 641 ns 641 ns 1085182 +bm_rtl::method____ErasedReturnType::get_string 645 ns 645 ns 1084685 +bm_rtl::method____ErasedTargetType::get_string 546 ns 546 ns 1273493 +bm_rtl::method____ErasedTargetAndReturnType::get_string 649 ns 649 ns 1072660 +----------------------------------- +[2025-11-04 12:22:57] >>> Run 3: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-11-04T12:22:57+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3817.78 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.29, 1.21, 0.98 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 288 ns 288 ns 2443622 + +bm_call::via_function_ptr__Function::set_string 291 ns 291 ns 2423578 +bm_call::via_function_ptr____Method::set_string 295 ns 295 ns 2407524 + +bm_std::function_calls__Function::set_string 294 ns 294 ns 2344270 +bm_std::function_calls____Method::set_string 291 ns 291 ns 2396174 + +bm_rtl::function_calls__Function::set_string 293 ns 293 ns 2412280 +bm_rtl::method_calls______Method::set_string 294 ns 294 ns 2426574 + +bm_rtl::function__ErasedReturnType::set_string 295 ns 295 ns 2377689 +bm_rtl::method____ErasedReturnType::set_string 293 ns 293 ns 2394389 +bm_rtl::method____ErasedTargetType::set_string 297 ns 297 ns 2344509 +bm_rtl::method____ErasedTargetAndReturnType::set_string 300 ns 300 ns 2352884 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 536 ns 536 ns 1295414 + +bm_call::via_function_ptr__Function::get_string 541 ns 541 ns 1233897 +bm_call::via_function_ptr____Method::get_string 541 ns 541 ns 1288959 + +bm_std::function_calls__Function::get_string 547 ns 547 ns 1262440 +bm_std::function_calls____Method::get_string 566 ns 566 ns 1227613 + +bm_rtl::function_calls__Function::get_string 548 ns 548 ns 1275405 +bm_rtl::method_calls______Method::get_string 548 ns 548 ns 1245585 + +bm_rtl::function__ErasedReturnType::get_string 653 ns 653 ns 1046627 +bm_rtl::method____ErasedReturnType::get_string 650 ns 650 ns 1059528 +bm_rtl::method____ErasedTargetType::get_string 552 ns 552 ns 1244640 +bm_rtl::method____ErasedTargetAndReturnType::get_string 654 ns 654 ns 1067972 +----------------------------------- +[2025-11-04 12:23:16] >>> Run 1: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-11-04T12:23:16+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2745.05 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.21, 1.19, 0.99 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 321 ns 321 ns 2145052 + +bm_call::via_function_ptr__Function::set_string 321 ns 321 ns 2172662 +bm_call::via_function_ptr____Method::set_string 320 ns 320 ns 2190165 + +bm_std::function_calls__Function::set_string 319 ns 319 ns 2215014 +bm_std::function_calls____Method::set_string 319 ns 319 ns 2192899 + +bm_rtl::function_calls__Function::set_string 326 ns 326 ns 2167253 +bm_rtl::method_calls______Method::set_string 323 ns 323 ns 2146891 + +bm_rtl::function__ErasedReturnType::set_string 331 ns 331 ns 2128543 +bm_rtl::method____ErasedReturnType::set_string 330 ns 330 ns 2161480 +bm_rtl::method____ErasedTargetType::set_string 329 ns 329 ns 2093144 +bm_rtl::method____ErasedTargetAndReturnType::set_string 328 ns 328 ns 2128289 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 669 ns 668 ns 937516 + +bm_call::via_function_ptr__Function::get_string 664 ns 664 ns 1042010 +bm_call::via_function_ptr____Method::get_string 666 ns 666 ns 1047814 + +bm_std::function_calls__Function::get_string 668 ns 668 ns 1021621 +bm_std::function_calls____Method::get_string 668 ns 668 ns 1017963 + +bm_rtl::function_calls__Function::get_string 669 ns 669 ns 1037708 +bm_rtl::method_calls______Method::get_string 665 ns 665 ns 1047174 + +bm_rtl::function__ErasedReturnType::get_string 793 ns 793 ns 883503 +bm_rtl::method____ErasedReturnType::get_string 795 ns 795 ns 871865 +bm_rtl::method____ErasedTargetType::get_string 680 ns 680 ns 1021801 +bm_rtl::method____ErasedTargetAndReturnType::get_string 801 ns 801 ns 874189 +----------------------------------- +[2025-11-04 12:23:37] >>> Run 2: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-11-04T12:23:37+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3126.6 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.22, 1.19, 0.99 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 320 ns 320 ns 2189231 + +bm_call::via_function_ptr__Function::set_string 342 ns 342 ns 2163509 +bm_call::via_function_ptr____Method::set_string 365 ns 365 ns 1916223 + +bm_std::function_calls__Function::set_string 361 ns 361 ns 1905923 +bm_std::function_calls____Method::set_string 356 ns 356 ns 1958867 + +bm_rtl::function_calls__Function::set_string 359 ns 359 ns 1907278 +bm_rtl::method_calls______Method::set_string 354 ns 354 ns 1909265 + +bm_rtl::function__ErasedReturnType::set_string 364 ns 363 ns 1935027 +bm_rtl::method____ErasedReturnType::set_string 360 ns 360 ns 1957560 +bm_rtl::method____ErasedTargetType::set_string 362 ns 362 ns 1941976 +bm_rtl::method____ErasedTargetAndReturnType::set_string 332 ns 332 ns 2099239 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 680 ns 680 ns 1030475 + +bm_call::via_function_ptr__Function::get_string 668 ns 667 ns 1005079 +bm_call::via_function_ptr____Method::get_string 668 ns 668 ns 1048120 + +bm_std::function_calls__Function::get_string 670 ns 670 ns 1049568 +bm_std::function_calls____Method::get_string 666 ns 666 ns 1053000 + +bm_rtl::function_calls__Function::get_string 665 ns 665 ns 1055481 +bm_rtl::method_calls______Method::get_string 665 ns 665 ns 1058130 + +bm_rtl::function__ErasedReturnType::get_string 788 ns 788 ns 887250 +bm_rtl::method____ErasedReturnType::get_string 793 ns 793 ns 890800 +bm_rtl::method____ErasedTargetType::get_string 698 ns 698 ns 1004244 +bm_rtl::method____ErasedTargetAndReturnType::get_string 794 ns 794 ns 884426 +----------------------------------- +[2025-11-04 12:23:57] >>> Run 3: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-11-04T12:23:57+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800.525 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.44, 1.25, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 318 ns 318 ns 2197752 + +bm_call::via_function_ptr__Function::set_string 322 ns 322 ns 2162163 +bm_call::via_function_ptr____Method::set_string 345 ns 345 ns 2174209 + +bm_std::function_calls__Function::set_string 354 ns 354 ns 1984909 +bm_std::function_calls____Method::set_string 353 ns 353 ns 1979871 + +bm_rtl::function_calls__Function::set_string 358 ns 357 ns 1969102 +bm_rtl::method_calls______Method::set_string 357 ns 357 ns 1963100 + +bm_rtl::function__ErasedReturnType::set_string 356 ns 356 ns 1956769 +bm_rtl::method____ErasedReturnType::set_string 359 ns 359 ns 1953417 +bm_rtl::method____ErasedTargetType::set_string 363 ns 363 ns 1961373 +bm_rtl::method____ErasedTargetAndReturnType::set_string 360 ns 360 ns 1947329 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 748 ns 748 ns 924341 + +bm_call::via_function_ptr__Function::get_string 747 ns 747 ns 925487 +bm_call::via_function_ptr____Method::get_string 746 ns 746 ns 928898 + +bm_std::function_calls__Function::get_string 749 ns 749 ns 925990 +bm_std::function_calls____Method::get_string 749 ns 749 ns 929901 + +bm_rtl::function_calls__Function::get_string 746 ns 746 ns 915844 +bm_rtl::method_calls______Method::get_string 750 ns 750 ns 928817 + +bm_rtl::function__ErasedReturnType::get_string 901 ns 901 ns 776868 +bm_rtl::method____ErasedReturnType::get_string 897 ns 897 ns 773498 +bm_rtl::method____ErasedTargetType::get_string 757 ns 757 ns 925383 +bm_rtl::method____ErasedTargetAndReturnType::get_string 897 ns 897 ns 778280 +----------------------------------- +[2025-11-04 12:24:18] >>> Run 1: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-11-04T12:24:18+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4153.56 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.32, 1.23, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 374 ns 373 ns 1873476 + +bm_call::via_function_ptr__Function::set_string 376 ns 376 ns 1863509 +bm_call::via_function_ptr____Method::set_string 374 ns 374 ns 1863221 + +bm_std::function_calls__Function::set_string 373 ns 373 ns 1871738 +bm_std::function_calls____Method::set_string 376 ns 376 ns 1865547 + +bm_rtl::function_calls__Function::set_string 376 ns 376 ns 1865067 +bm_rtl::method_calls______Method::set_string 377 ns 377 ns 1858187 + +bm_rtl::function__ErasedReturnType::set_string 380 ns 380 ns 1837243 +bm_rtl::method____ErasedReturnType::set_string 386 ns 386 ns 1822783 +bm_rtl::method____ErasedTargetType::set_string 412 ns 412 ns 1701170 +bm_rtl::method____ErasedTargetAndReturnType::set_string 414 ns 413 ns 1700118 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 956 ns 956 ns 728821 + +bm_call::via_function_ptr__Function::get_string 956 ns 956 ns 729173 +bm_call::via_function_ptr____Method::get_string 955 ns 954 ns 732604 + +bm_std::function_calls__Function::get_string 963 ns 963 ns 720513 +bm_std::function_calls____Method::get_string 970 ns 970 ns 720651 + +bm_rtl::function_calls__Function::get_string 962 ns 962 ns 724222 +bm_rtl::method_calls______Method::get_string 964 ns 964 ns 720737 + +bm_rtl::function__ErasedReturnType::get_string 1167 ns 1166 ns 598228 +bm_rtl::method____ErasedReturnType::get_string 1177 ns 1177 ns 594646 +bm_rtl::method____ErasedTargetType::get_string 982 ns 982 ns 710920 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1181 ns 1181 ns 590085 +----------------------------------- +[2025-11-04 12:24:39] >>> Run 2: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-11-04T12:24:39+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2855.26 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.23, 1.22, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 400 ns 400 ns 1746516 + +bm_call::via_function_ptr__Function::set_string 401 ns 401 ns 1746207 +bm_call::via_function_ptr____Method::set_string 401 ns 401 ns 1755755 + +bm_std::function_calls__Function::set_string 402 ns 402 ns 1742386 +bm_std::function_calls____Method::set_string 403 ns 403 ns 1743721 + +bm_rtl::function_calls__Function::set_string 406 ns 406 ns 1726824 +bm_rtl::method_calls______Method::set_string 401 ns 401 ns 1734713 + +bm_rtl::function__ErasedReturnType::set_string 408 ns 408 ns 1720118 +bm_rtl::method____ErasedReturnType::set_string 407 ns 407 ns 1718166 +bm_rtl::method____ErasedTargetType::set_string 410 ns 410 ns 1711945 +bm_rtl::method____ErasedTargetAndReturnType::set_string 381 ns 381 ns 1768747 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 881 ns 881 ns 787730 + +bm_call::via_function_ptr__Function::get_string 874 ns 874 ns 796785 +bm_call::via_function_ptr____Method::get_string 872 ns 872 ns 793060 + +bm_std::function_calls__Function::get_string 891 ns 890 ns 784802 +bm_std::function_calls____Method::get_string 889 ns 889 ns 780768 + +bm_rtl::function_calls__Function::get_string 883 ns 883 ns 789722 +bm_rtl::method_calls______Method::get_string 887 ns 887 ns 786262 + +bm_rtl::function__ErasedReturnType::get_string 1083 ns 1083 ns 643370 +bm_rtl::method____ErasedReturnType::get_string 1089 ns 1089 ns 643122 +bm_rtl::method____ErasedTargetType::get_string 912 ns 912 ns 752875 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1095 ns 1095 ns 640973 +----------------------------------- +[2025-11-04 12:25:01] >>> Run 3: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-11-04T12:25:01+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4282.06 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.15, 1.20, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 374 ns 374 ns 1885971 + +bm_call::via_function_ptr__Function::set_string 375 ns 375 ns 1873368 +bm_call::via_function_ptr____Method::set_string 373 ns 373 ns 1868671 + +bm_std::function_calls__Function::set_string 377 ns 377 ns 1860537 +bm_std::function_calls____Method::set_string 378 ns 378 ns 1854349 + +bm_rtl::function_calls__Function::set_string 376 ns 376 ns 1861382 +bm_rtl::method_calls______Method::set_string 376 ns 376 ns 1858131 + +bm_rtl::function__ErasedReturnType::set_string 383 ns 383 ns 1839310 +bm_rtl::method____ErasedReturnType::set_string 383 ns 383 ns 1832865 +bm_rtl::method____ErasedTargetType::set_string 389 ns 389 ns 1823647 +bm_rtl::method____ErasedTargetAndReturnType::set_string 393 ns 393 ns 1743924 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 897 ns 897 ns 777617 + +bm_call::via_function_ptr__Function::get_string 891 ns 891 ns 792904 +bm_call::via_function_ptr____Method::get_string 883 ns 883 ns 752790 + +bm_std::function_calls__Function::get_string 897 ns 897 ns 769458 +bm_std::function_calls____Method::get_string 893 ns 893 ns 783150 + +bm_rtl::function_calls__Function::get_string 881 ns 881 ns 783511 +bm_rtl::method_calls______Method::get_string 892 ns 892 ns 785936 + +bm_rtl::function__ErasedReturnType::get_string 1126 ns 1125 ns 633797 +bm_rtl::method____ErasedReturnType::get_string 1137 ns 1137 ns 602780 +bm_rtl::method____ErasedTargetType::get_string 932 ns 931 ns 758769 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1108 ns 1108 ns 602980 +----------------------------------- +[2025-11-04 12:25:22] >>> Run 1: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-11-04T12:25:22+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2237.04 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.10, 1.18, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 750 ns 750 ns 924083 + +bm_call::via_function_ptr__Function::set_string 757 ns 757 ns 920347 +bm_call::via_function_ptr____Method::set_string 771 ns 771 ns 912619 + +bm_std::function_calls__Function::set_string 780 ns 780 ns 883371 +bm_std::function_calls____Method::set_string 781 ns 780 ns 898678 + +bm_rtl::function_calls__Function::set_string 787 ns 787 ns 862899 +bm_rtl::method_calls______Method::set_string 796 ns 796 ns 914393 + +bm_rtl::function__ErasedReturnType::set_string 775 ns 775 ns 874764 +bm_rtl::method____ErasedReturnType::set_string 776 ns 776 ns 907678 +bm_rtl::method____ErasedTargetType::set_string 790 ns 789 ns 866660 +bm_rtl::method____ErasedTargetAndReturnType::set_string 805 ns 805 ns 869127 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1383 ns 1383 ns 499739 + +bm_call::via_function_ptr__Function::get_string 1315 ns 1315 ns 524654 +bm_call::via_function_ptr____Method::get_string 1326 ns 1326 ns 513208 + +bm_std::function_calls__Function::get_string 1309 ns 1309 ns 531060 +bm_std::function_calls____Method::get_string 1331 ns 1331 ns 534228 + +bm_rtl::function_calls__Function::get_string 1326 ns 1326 ns 514575 +bm_rtl::method_calls______Method::get_string 1326 ns 1326 ns 525314 + +bm_rtl::function__ErasedReturnType::get_string 1549 ns 1549 ns 447415 +bm_rtl::method____ErasedReturnType::get_string 1543 ns 1543 ns 452767 +bm_rtl::method____ErasedTargetType::get_string 1352 ns 1351 ns 524647 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1562 ns 1562 ns 434293 +----------------------------------- +[2025-11-04 12:25:40] >>> Run 2: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-11-04T12:25:40+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3670.17 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.22, 1.21, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 743 ns 743 ns 909759 + +bm_call::via_function_ptr__Function::set_string 740 ns 740 ns 930090 +bm_call::via_function_ptr____Method::set_string 744 ns 744 ns 933324 + +bm_std::function_calls__Function::set_string 743 ns 743 ns 913502 +bm_std::function_calls____Method::set_string 758 ns 758 ns 931457 + +bm_rtl::function_calls__Function::set_string 767 ns 767 ns 910065 +bm_rtl::method_calls______Method::set_string 743 ns 743 ns 931388 + +bm_rtl::function__ErasedReturnType::set_string 775 ns 775 ns 921081 +bm_rtl::method____ErasedReturnType::set_string 761 ns 761 ns 915625 +bm_rtl::method____ErasedTargetType::set_string 756 ns 756 ns 913038 +bm_rtl::method____ErasedTargetAndReturnType::set_string 771 ns 771 ns 901263 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1357 ns 1357 ns 502661 + +bm_call::via_function_ptr__Function::get_string 1408 ns 1408 ns 503040 +bm_call::via_function_ptr____Method::get_string 1446 ns 1446 ns 478290 + +bm_std::function_calls__Function::get_string 1373 ns 1373 ns 498957 +bm_std::function_calls____Method::get_string 1398 ns 1398 ns 502891 + +bm_rtl::function_calls__Function::get_string 1395 ns 1395 ns 488686 +bm_rtl::method_calls______Method::get_string 1382 ns 1382 ns 497336 + +bm_rtl::function__ErasedReturnType::get_string 1560 ns 1560 ns 425909 +bm_rtl::method____ErasedReturnType::get_string 1542 ns 1542 ns 450811 +bm_rtl::method____ErasedTargetType::get_string 1337 ns 1337 ns 521375 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1552 ns 1552 ns 447731 +----------------------------------- +[2025-11-04 12:25:58] >>> Run 3: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-11-04T12:25:58+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4129.78 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.23, 1.21, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 699 ns 699 ns 970616 + +bm_call::via_function_ptr__Function::set_string 733 ns 732 ns 992416 +bm_call::via_function_ptr____Method::set_string 743 ns 743 ns 951176 + +bm_std::function_calls__Function::set_string 719 ns 718 ns 953330 +bm_std::function_calls____Method::set_string 722 ns 722 ns 981699 + +bm_rtl::function_calls__Function::set_string 716 ns 716 ns 988945 +bm_rtl::method_calls______Method::set_string 711 ns 711 ns 992867 + +bm_rtl::function__ErasedReturnType::set_string 729 ns 728 ns 961326 +bm_rtl::method____ErasedReturnType::set_string 762 ns 762 ns 954194 +bm_rtl::method____ErasedTargetType::set_string 768 ns 768 ns 893804 +bm_rtl::method____ErasedTargetAndReturnType::set_string 737 ns 736 ns 929658 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1318 ns 1317 ns 529166 + +bm_call::via_function_ptr__Function::get_string 1321 ns 1321 ns 530054 +bm_call::via_function_ptr____Method::get_string 1316 ns 1316 ns 531188 + +bm_std::function_calls__Function::get_string 1319 ns 1319 ns 531843 +bm_std::function_calls____Method::get_string 1321 ns 1321 ns 532253 + +bm_rtl::function_calls__Function::get_string 1319 ns 1319 ns 531646 +bm_rtl::method_calls______Method::get_string 1319 ns 1319 ns 528183 + +bm_rtl::function__ErasedReturnType::get_string 1615 ns 1614 ns 444285 +bm_rtl::method____ErasedReturnType::get_string 1592 ns 1592 ns 436514 +bm_rtl::method____ErasedTargetType::get_string 1407 ns 1407 ns 496278 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1624 ns 1624 ns 430770 +----------------------------------- +[2025-11-04 12:26:16] >>> Run 1: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-11-04T12:26:16+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1742.32 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.30, 1.23, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 786 ns 785 ns 874794 + +bm_call::via_function_ptr__Function::set_string 789 ns 789 ns 874362 +bm_call::via_function_ptr____Method::set_string 790 ns 790 ns 883497 + +bm_std::function_calls__Function::set_string 786 ns 786 ns 884943 +bm_std::function_calls____Method::set_string 790 ns 790 ns 870155 + +bm_rtl::function_calls__Function::set_string 790 ns 790 ns 878262 +bm_rtl::method_calls______Method::set_string 791 ns 791 ns 871008 + +bm_rtl::function__ErasedReturnType::set_string 793 ns 793 ns 881206 +bm_rtl::method____ErasedReturnType::set_string 794 ns 794 ns 876546 +bm_rtl::method____ErasedTargetType::set_string 792 ns 792 ns 872609 +bm_rtl::method____ErasedTargetAndReturnType::set_string 794 ns 794 ns 875157 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1478 ns 1478 ns 473478 + +bm_call::via_function_ptr__Function::get_string 1469 ns 1469 ns 473069 +bm_call::via_function_ptr____Method::get_string 1468 ns 1468 ns 473326 + +bm_std::function_calls__Function::get_string 1471 ns 1470 ns 473822 +bm_std::function_calls____Method::get_string 1473 ns 1473 ns 472376 + +bm_rtl::function_calls__Function::get_string 1473 ns 1473 ns 473798 +bm_rtl::method_calls______Method::get_string 1470 ns 1470 ns 476866 + +bm_rtl::function__ErasedReturnType::get_string 1821 ns 1821 ns 385183 +bm_rtl::method____ErasedReturnType::get_string 1816 ns 1816 ns 385499 +bm_rtl::method____ErasedTargetType::get_string 1489 ns 1489 ns 469694 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1821 ns 1821 ns 382024 +----------------------------------- +[2025-11-04 12:26:34] >>> Run 2: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-11-04T12:26:34+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1593.45 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.23, 1.22, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 785 ns 785 ns 883374 + +bm_call::via_function_ptr__Function::set_string 796 ns 796 ns 886782 +bm_call::via_function_ptr____Method::set_string 794 ns 794 ns 877309 + +bm_std::function_calls__Function::set_string 794 ns 794 ns 873699 +bm_std::function_calls____Method::set_string 796 ns 796 ns 872066 + +bm_rtl::function_calls__Function::set_string 793 ns 793 ns 885099 +bm_rtl::method_calls______Method::set_string 816 ns 816 ns 841390 + +bm_rtl::function__ErasedReturnType::set_string 802 ns 802 ns 847247 +bm_rtl::method____ErasedReturnType::set_string 802 ns 802 ns 858644 +bm_rtl::method____ErasedTargetType::set_string 798 ns 797 ns 870491 +bm_rtl::method____ErasedTargetAndReturnType::set_string 797 ns 797 ns 870936 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1507 ns 1507 ns 461478 + +bm_call::via_function_ptr__Function::get_string 1507 ns 1507 ns 461730 +bm_call::via_function_ptr____Method::get_string 1507 ns 1507 ns 464680 + +bm_std::function_calls__Function::get_string 1507 ns 1507 ns 463574 +bm_std::function_calls____Method::get_string 1520 ns 1520 ns 464089 + +bm_rtl::function_calls__Function::get_string 1504 ns 1503 ns 458070 +bm_rtl::method_calls______Method::get_string 1517 ns 1517 ns 463656 + +bm_rtl::function__ErasedReturnType::get_string 1837 ns 1837 ns 382222 +bm_rtl::method____ErasedReturnType::get_string 1840 ns 1840 ns 381090 +bm_rtl::method____ErasedTargetType::get_string 1521 ns 1521 ns 454047 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1841 ns 1840 ns 381784 +----------------------------------- +[2025-11-04 12:26:52] >>> Run 3: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-11-04T12:26:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.16, 1.20, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 765 ns 765 ns 900609 + +bm_call::via_function_ptr__Function::set_string 773 ns 773 ns 902357 +bm_call::via_function_ptr____Method::set_string 775 ns 775 ns 895698 + +bm_std::function_calls__Function::set_string 769 ns 769 ns 884989 +bm_std::function_calls____Method::set_string 770 ns 770 ns 905215 + +bm_rtl::function_calls__Function::set_string 781 ns 781 ns 893172 +bm_rtl::method_calls______Method::set_string 785 ns 785 ns 871377 + +bm_rtl::function__ErasedReturnType::set_string 796 ns 796 ns 876191 +bm_rtl::method____ErasedReturnType::set_string 795 ns 795 ns 870611 +bm_rtl::method____ErasedTargetType::set_string 786 ns 786 ns 875116 +bm_rtl::method____ErasedTargetAndReturnType::set_string 793 ns 793 ns 853059 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1482 ns 1482 ns 471648 + +bm_call::via_function_ptr__Function::get_string 1478 ns 1477 ns 472419 +bm_call::via_function_ptr____Method::get_string 1487 ns 1487 ns 474564 + +bm_std::function_calls__Function::get_string 1479 ns 1479 ns 467774 +bm_std::function_calls____Method::get_string 1468 ns 1468 ns 475985 + +bm_rtl::function_calls__Function::get_string 1477 ns 1477 ns 471129 +bm_rtl::method_calls______Method::get_string 1484 ns 1483 ns 471432 + +bm_rtl::function__ErasedReturnType::get_string 1830 ns 1829 ns 379477 +bm_rtl::method____ErasedReturnType::get_string 1833 ns 1833 ns 381079 +bm_rtl::method____ErasedTargetType::get_string 1499 ns 1499 ns 460559 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1837 ns 1837 ns 375044 +----------------------------------- +[2025-11-04 12:27:10] >>> Run 1: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-11-04T12:27:10+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2727.08 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.12, 1.19, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 859 ns 859 ns 811645 + +bm_call::via_function_ptr__Function::set_string 868 ns 868 ns 810851 +bm_call::via_function_ptr____Method::set_string 865 ns 865 ns 807435 + +bm_std::function_calls__Function::set_string 864 ns 863 ns 780880 +bm_std::function_calls____Method::set_string 872 ns 872 ns 806447 + +bm_rtl::function_calls__Function::set_string 866 ns 865 ns 809246 +bm_rtl::method_calls______Method::set_string 857 ns 857 ns 818472 + +bm_rtl::function__ErasedReturnType::set_string 880 ns 880 ns 787509 +bm_rtl::method____ErasedReturnType::set_string 876 ns 876 ns 795235 +bm_rtl::method____ErasedTargetType::set_string 866 ns 866 ns 790561 +bm_rtl::method____ErasedTargetAndReturnType::set_string 880 ns 880 ns 799653 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1656 ns 1656 ns 423691 + +bm_call::via_function_ptr__Function::get_string 1645 ns 1645 ns 412059 +bm_call::via_function_ptr____Method::get_string 1651 ns 1651 ns 421852 + +bm_std::function_calls__Function::get_string 1674 ns 1674 ns 417578 +bm_std::function_calls____Method::get_string 1656 ns 1656 ns 425072 + +bm_rtl::function_calls__Function::get_string 1631 ns 1631 ns 426111 +bm_rtl::method_calls______Method::get_string 1724 ns 1724 ns 420215 + +bm_rtl::function__ErasedReturnType::get_string 2239 ns 2239 ns 319096 +bm_rtl::method____ErasedReturnType::get_string 2118 ns 2117 ns 319400 +bm_rtl::method____ErasedTargetType::get_string 1635 ns 1634 ns 419574 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2082 ns 2081 ns 341195 +----------------------------------- +[2025-11-04 12:27:29] >>> Run 2: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-11-04T12:27:29+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4086.01 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.17, 1.19, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 879 ns 879 ns 763667 + +bm_call::via_function_ptr__Function::set_string 899 ns 899 ns 800493 +bm_call::via_function_ptr____Method::set_string 874 ns 874 ns 784385 + +bm_std::function_calls__Function::set_string 917 ns 916 ns 791343 +bm_std::function_calls____Method::set_string 895 ns 894 ns 722973 + +bm_rtl::function_calls__Function::set_string 901 ns 901 ns 809623 +bm_rtl::method_calls______Method::set_string 886 ns 886 ns 772267 + +bm_rtl::function__ErasedReturnType::set_string 869 ns 869 ns 807341 +bm_rtl::method____ErasedReturnType::set_string 869 ns 869 ns 806497 +bm_rtl::method____ErasedTargetType::set_string 868 ns 868 ns 808556 +bm_rtl::method____ErasedTargetAndReturnType::set_string 869 ns 869 ns 807730 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1570 ns 1570 ns 445252 + +bm_call::via_function_ptr__Function::get_string 1566 ns 1566 ns 446490 +bm_call::via_function_ptr____Method::get_string 1564 ns 1564 ns 447557 + +bm_std::function_calls__Function::get_string 1565 ns 1565 ns 447484 +bm_std::function_calls____Method::get_string 1567 ns 1567 ns 447153 + +bm_rtl::function_calls__Function::get_string 1560 ns 1560 ns 449067 +bm_rtl::method_calls______Method::get_string 1558 ns 1558 ns 449923 + +bm_rtl::function__ErasedReturnType::get_string 2038 ns 2038 ns 342820 +bm_rtl::method____ErasedReturnType::get_string 2039 ns 2039 ns 343146 +bm_rtl::method____ErasedTargetType::get_string 1573 ns 1573 ns 445077 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2045 ns 2045 ns 342394 +----------------------------------- +[2025-11-04 12:27:48] >>> Run 3: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-11-04T12:27:48+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.25, 1.21, 1.04 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 861 ns 861 ns 814704 + +bm_call::via_function_ptr__Function::set_string 857 ns 857 ns 817829 +bm_call::via_function_ptr____Method::set_string 858 ns 858 ns 813922 + +bm_std::function_calls__Function::set_string 863 ns 863 ns 813055 +bm_std::function_calls____Method::set_string 857 ns 857 ns 812189 + +bm_rtl::function_calls__Function::set_string 860 ns 860 ns 815403 +bm_rtl::method_calls______Method::set_string 855 ns 855 ns 817960 + +bm_rtl::function__ErasedReturnType::set_string 863 ns 863 ns 811827 +bm_rtl::method____ErasedReturnType::set_string 864 ns 864 ns 812329 +bm_rtl::method____ErasedTargetType::set_string 859 ns 859 ns 811367 +bm_rtl::method____ErasedTargetAndReturnType::set_string 872 ns 872 ns 806139 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1579 ns 1579 ns 443558 + +bm_call::via_function_ptr__Function::get_string 1567 ns 1566 ns 447638 +bm_call::via_function_ptr____Method::get_string 1561 ns 1561 ns 448644 + +bm_std::function_calls__Function::get_string 1578 ns 1578 ns 443746 +bm_std::function_calls____Method::get_string 1579 ns 1579 ns 442695 + +bm_rtl::function_calls__Function::get_string 1560 ns 1560 ns 448822 +bm_rtl::method_calls______Method::get_string 1567 ns 1567 ns 447470 + +bm_rtl::function__ErasedReturnType::get_string 2039 ns 2039 ns 343449 +bm_rtl::method____ErasedReturnType::get_string 2043 ns 2043 ns 343320 +bm_rtl::method____ErasedTargetType::get_string 1578 ns 1578 ns 443800 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2048 ns 2048 ns 342248 +----------------------------------- +[2025-11-04 12:28:06] >>> Run 1: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-11-04T12:28:06+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.26, 1.21, 1.04 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 926 ns 926 ns 751413 + +bm_call::via_function_ptr__Function::set_string 915 ns 915 ns 767518 +bm_call::via_function_ptr____Method::set_string 919 ns 919 ns 763863 + +bm_std::function_calls__Function::set_string 937 ns 937 ns 751780 +bm_std::function_calls____Method::set_string 936 ns 936 ns 746176 + +bm_rtl::function_calls__Function::set_string 920 ns 920 ns 758837 +bm_rtl::method_calls______Method::set_string 917 ns 917 ns 767318 + +bm_rtl::function__ErasedReturnType::set_string 933 ns 933 ns 750999 +bm_rtl::method____ErasedReturnType::set_string 929 ns 929 ns 755410 +bm_rtl::method____ErasedTargetType::set_string 928 ns 928 ns 756971 +bm_rtl::method____ErasedTargetAndReturnType::set_string 936 ns 936 ns 747793 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1788 ns 1788 ns 391424 + +bm_call::via_function_ptr__Function::get_string 1786 ns 1786 ns 389634 +bm_call::via_function_ptr____Method::get_string 1783 ns 1782 ns 392565 + +bm_std::function_calls__Function::get_string 1790 ns 1790 ns 391537 +bm_std::function_calls____Method::get_string 1784 ns 1784 ns 392494 + +bm_rtl::function_calls__Function::get_string 1702 ns 1702 ns 412018 +bm_rtl::method_calls______Method::get_string 1698 ns 1698 ns 412199 + +bm_rtl::function__ErasedReturnType::get_string 2253 ns 2253 ns 311171 +bm_rtl::method____ErasedReturnType::get_string 2246 ns 2246 ns 311656 +bm_rtl::method____ErasedTargetType::get_string 1715 ns 1715 ns 408229 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2250 ns 2250 ns 310623 +----------------------------------- +[2025-11-04 12:28:25] >>> Run 2: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-11-04T12:28:25+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.19, 1.20, 1.04 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 926 ns 926 ns 740549 + +bm_call::via_function_ptr__Function::set_string 916 ns 916 ns 770299 +bm_call::via_function_ptr____Method::set_string 916 ns 916 ns 762809 + +bm_std::function_calls__Function::set_string 938 ns 938 ns 745627 +bm_std::function_calls____Method::set_string 935 ns 935 ns 750822 + +bm_rtl::function_calls__Function::set_string 918 ns 918 ns 763866 +bm_rtl::method_calls______Method::set_string 917 ns 917 ns 765743 + +bm_rtl::function__ErasedReturnType::set_string 932 ns 932 ns 751226 +bm_rtl::method____ErasedReturnType::set_string 935 ns 935 ns 746666 +bm_rtl::method____ErasedTargetType::set_string 931 ns 931 ns 751925 +bm_rtl::method____ErasedTargetAndReturnType::set_string 943 ns 943 ns 743274 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1704 ns 1704 ns 411061 + +bm_call::via_function_ptr__Function::get_string 1701 ns 1701 ns 411864 +bm_call::via_function_ptr____Method::get_string 1696 ns 1696 ns 412619 + +bm_std::function_calls__Function::get_string 1699 ns 1699 ns 411971 +bm_std::function_calls____Method::get_string 1698 ns 1698 ns 412360 + +bm_rtl::function_calls__Function::get_string 1695 ns 1694 ns 413307 +bm_rtl::method_calls______Method::get_string 1694 ns 1694 ns 413337 + +bm_rtl::function__ErasedReturnType::get_string 2245 ns 2245 ns 311139 +bm_rtl::method____ErasedReturnType::get_string 2240 ns 2240 ns 312685 +bm_rtl::method____ErasedTargetType::get_string 1709 ns 1709 ns 409763 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2243 ns 2243 ns 311738 +----------------------------------- +[2025-11-04 12:28:44] >>> Run 3: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-11-04T12:28:44+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.14, 1.19, 1.04 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 917 ns 917 ns 757756 + +bm_call::via_function_ptr__Function::set_string 906 ns 906 ns 777002 +bm_call::via_function_ptr____Method::set_string 908 ns 907 ns 772247 + +bm_std::function_calls__Function::set_string 931 ns 931 ns 745509 +bm_std::function_calls____Method::set_string 928 ns 928 ns 754015 + +bm_rtl::function_calls__Function::set_string 916 ns 916 ns 766789 +bm_rtl::method_calls______Method::set_string 909 ns 909 ns 770952 + +bm_rtl::function__ErasedReturnType::set_string 931 ns 931 ns 751400 +bm_rtl::method____ErasedReturnType::set_string 927 ns 927 ns 746782 +bm_rtl::method____ErasedTargetType::set_string 925 ns 925 ns 757055 +bm_rtl::method____ErasedTargetAndReturnType::set_string 930 ns 930 ns 753039 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1705 ns 1705 ns 410944 + +bm_call::via_function_ptr__Function::get_string 1705 ns 1705 ns 411331 +bm_call::via_function_ptr____Method::get_string 1699 ns 1698 ns 412291 + +bm_std::function_calls__Function::get_string 1701 ns 1701 ns 411580 +bm_std::function_calls____Method::get_string 1695 ns 1694 ns 410757 + +bm_rtl::function_calls__Function::get_string 1697 ns 1697 ns 412312 +bm_rtl::method_calls______Method::get_string 1699 ns 1699 ns 412540 + +bm_rtl::function__ErasedReturnType::get_string 2241 ns 2241 ns 312288 +bm_rtl::method____ErasedReturnType::get_string 2246 ns 2246 ns 312211 +bm_rtl::method____ErasedTargetType::get_string 1710 ns 1709 ns 409508 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2248 ns 2248 ns 311951 +----------------------------------- +[2025-11-04 12:29:03] >>> Run 1: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-11-04T12:29:03+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.10, 1.18, 1.04 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1031 ns 1031 ns 675248 + +bm_call::via_function_ptr__Function::set_string 1026 ns 1026 ns 682545 +bm_call::via_function_ptr____Method::set_string 1027 ns 1027 ns 684770 + +bm_std::function_calls__Function::set_string 1034 ns 1034 ns 676829 +bm_std::function_calls____Method::set_string 1035 ns 1035 ns 675698 + +bm_rtl::function_calls__Function::set_string 1027 ns 1027 ns 682713 +bm_rtl::method_calls______Method::set_string 1043 ns 1043 ns 670770 + +bm_rtl::function__ErasedReturnType::set_string 1033 ns 1033 ns 678708 +bm_rtl::method____ErasedReturnType::set_string 1030 ns 1030 ns 679008 +bm_rtl::method____ErasedTargetType::set_string 1030 ns 1030 ns 681699 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1032 ns 1031 ns 680008 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2019 ns 2019 ns 347188 + +bm_call::via_function_ptr__Function::get_string 2013 ns 2013 ns 347842 +bm_call::via_function_ptr____Method::get_string 2010 ns 2010 ns 348147 + +bm_std::function_calls__Function::get_string 2017 ns 2017 ns 345495 +bm_std::function_calls____Method::get_string 2013 ns 2013 ns 347790 + +bm_rtl::function_calls__Function::get_string 2012 ns 2012 ns 348405 +bm_rtl::method_calls______Method::get_string 2004 ns 2004 ns 349276 + +bm_rtl::function__ErasedReturnType::get_string 2618 ns 2618 ns 267985 +bm_rtl::method____ErasedReturnType::get_string 2615 ns 2615 ns 267741 +bm_rtl::method____ErasedTargetType::get_string 2027 ns 2027 ns 345609 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2617 ns 2617 ns 266663 +----------------------------------- +[2025-11-04 12:29:22] >>> Run 2: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-11-04T12:29:22+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 973.131 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.07, 1.16, 1.04 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1028 ns 1028 ns 677855 + +bm_call::via_function_ptr__Function::set_string 1030 ns 1030 ns 679335 +bm_call::via_function_ptr____Method::set_string 1030 ns 1030 ns 680947 + +bm_std::function_calls__Function::set_string 1027 ns 1027 ns 684721 +bm_std::function_calls____Method::set_string 1026 ns 1026 ns 681824 + +bm_rtl::function_calls__Function::set_string 1029 ns 1029 ns 678759 +bm_rtl::method_calls______Method::set_string 1029 ns 1029 ns 681165 + +bm_rtl::function__ErasedReturnType::set_string 1034 ns 1034 ns 677875 +bm_rtl::method____ErasedReturnType::set_string 1035 ns 1035 ns 676821 +bm_rtl::method____ErasedTargetType::set_string 1030 ns 1030 ns 680401 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1033 ns 1033 ns 678651 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2008 ns 2007 ns 348680 + +bm_call::via_function_ptr__Function::get_string 2012 ns 2012 ns 348322 +bm_call::via_function_ptr____Method::get_string 2007 ns 2007 ns 348814 + +bm_std::function_calls__Function::get_string 2004 ns 2004 ns 349186 +bm_std::function_calls____Method::get_string 2002 ns 2002 ns 348243 + +bm_rtl::function_calls__Function::get_string 2007 ns 2007 ns 348882 +bm_rtl::method_calls______Method::get_string 2004 ns 2004 ns 349758 + +bm_rtl::function__ErasedReturnType::get_string 2604 ns 2604 ns 268928 +bm_rtl::method____ErasedReturnType::get_string 2612 ns 2612 ns 268364 +bm_rtl::method____ErasedTargetType::get_string 2016 ns 2016 ns 347257 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2614 ns 2614 ns 268179 +----------------------------------- +[2025-11-04 12:29:41] >>> Run 3: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-11-04T12:29:41+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2968.51 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.05, 1.15, 1.04 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1040 ns 1040 ns 671097 + +bm_call::via_function_ptr__Function::set_string 1033 ns 1033 ns 676942 +bm_call::via_function_ptr____Method::set_string 1030 ns 1030 ns 678677 + +bm_std::function_calls__Function::set_string 1038 ns 1038 ns 674691 +bm_std::function_calls____Method::set_string 1037 ns 1037 ns 675090 + +bm_rtl::function_calls__Function::set_string 1026 ns 1026 ns 678381 +bm_rtl::method_calls______Method::set_string 1032 ns 1032 ns 679923 + +bm_rtl::function__ErasedReturnType::set_string 1033 ns 1033 ns 675492 +bm_rtl::method____ErasedReturnType::set_string 1037 ns 1037 ns 674332 +bm_rtl::method____ErasedTargetType::set_string 1033 ns 1033 ns 680263 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1035 ns 1035 ns 675409 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2011 ns 2011 ns 348434 + +bm_call::via_function_ptr__Function::get_string 2005 ns 2005 ns 349051 +bm_call::via_function_ptr____Method::get_string 2007 ns 2006 ns 349321 + +bm_std::function_calls__Function::get_string 2007 ns 2007 ns 348916 +bm_std::function_calls____Method::get_string 2012 ns 2012 ns 348275 + +bm_rtl::function_calls__Function::get_string 2002 ns 2002 ns 349353 +bm_rtl::method_calls______Method::get_string 1998 ns 1998 ns 350484 + +bm_rtl::function__ErasedReturnType::get_string 2604 ns 2604 ns 267612 +bm_rtl::method____ErasedReturnType::get_string 2604 ns 2604 ns 268910 +bm_rtl::method____ErasedTargetType::get_string 2018 ns 2018 ns 345292 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2607 ns 2607 ns 268415 +----------------------------------- +[2025-11-04 12:30:00] >>> Run 1: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-11-04T12:30:00+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2220.56 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.14, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1634 ns 1633 ns 428902 + +bm_call::via_function_ptr__Function::set_string 1630 ns 1629 ns 429772 +bm_call::via_function_ptr____Method::set_string 1631 ns 1631 ns 430681 + +bm_std::function_calls__Function::set_string 1631 ns 1631 ns 428808 +bm_std::function_calls____Method::set_string 1635 ns 1635 ns 428582 + +bm_rtl::function_calls__Function::set_string 1630 ns 1630 ns 429178 +bm_rtl::method_calls______Method::set_string 1633 ns 1632 ns 428391 + +bm_rtl::function__ErasedReturnType::set_string 1636 ns 1636 ns 424931 +bm_rtl::method____ErasedReturnType::set_string 1639 ns 1639 ns 426912 +bm_rtl::method____ErasedTargetType::set_string 1637 ns 1637 ns 427969 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1637 ns 1637 ns 427833 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2782 ns 2782 ns 251867 + +bm_call::via_function_ptr__Function::get_string 2777 ns 2777 ns 252122 +bm_call::via_function_ptr____Method::get_string 2783 ns 2783 ns 251687 + +bm_std::function_calls__Function::get_string 2790 ns 2790 ns 250927 +bm_std::function_calls____Method::get_string 2781 ns 2781 ns 252071 + +bm_rtl::function_calls__Function::get_string 2783 ns 2782 ns 251500 +bm_rtl::method_calls______Method::get_string 2781 ns 2781 ns 252113 + +bm_rtl::function__ErasedReturnType::get_string 3385 ns 3384 ns 206887 +bm_rtl::method____ErasedReturnType::get_string 3389 ns 3389 ns 206881 +bm_rtl::method____ErasedTargetType::get_string 2796 ns 2796 ns 250294 +bm_rtl::method____ErasedTargetAndReturnType::get_string 3391 ns 3391 ns 206588 +----------------------------------- +[2025-11-04 12:30:22] >>> Run 2: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-11-04T12:30:22+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3530.37 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.13, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1622 ns 1622 ns 430852 + +bm_call::via_function_ptr__Function::set_string 1623 ns 1623 ns 431449 +bm_call::via_function_ptr____Method::set_string 1621 ns 1621 ns 431436 + +bm_std::function_calls__Function::set_string 1625 ns 1625 ns 430362 +bm_std::function_calls____Method::set_string 1625 ns 1625 ns 431010 + +bm_rtl::function_calls__Function::set_string 1624 ns 1624 ns 430846 +bm_rtl::method_calls______Method::set_string 1624 ns 1624 ns 431257 + +bm_rtl::function__ErasedReturnType::set_string 1630 ns 1630 ns 428687 +bm_rtl::method____ErasedReturnType::set_string 1629 ns 1629 ns 429973 +bm_rtl::method____ErasedTargetType::set_string 1626 ns 1625 ns 430676 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1629 ns 1629 ns 430277 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2765 ns 2765 ns 253039 + +bm_call::via_function_ptr__Function::get_string 2763 ns 2763 ns 253401 +bm_call::via_function_ptr____Method::get_string 2763 ns 2763 ns 253536 + +bm_std::function_calls__Function::get_string 2765 ns 2765 ns 253255 +bm_std::function_calls____Method::get_string 2761 ns 2761 ns 253706 + +bm_rtl::function_calls__Function::get_string 2763 ns 2763 ns 253459 +bm_rtl::method_calls______Method::get_string 2758 ns 2758 ns 253800 + +bm_rtl::function__ErasedReturnType::get_string 3375 ns 3375 ns 207380 +bm_rtl::method____ErasedReturnType::get_string 3368 ns 3368 ns 207775 +bm_rtl::method____ErasedTargetType::get_string 2782 ns 2782 ns 251728 +bm_rtl::method____ErasedTargetAndReturnType::get_string 3368 ns 3368 ns 207848 +----------------------------------- +[2025-11-04 12:30:42] >>> Run 3: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-11-04T12:30:42+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3341.01 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.12, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1625 ns 1625 ns 430251 + +bm_call::via_function_ptr__Function::set_string 1626 ns 1626 ns 431687 +bm_call::via_function_ptr____Method::set_string 1626 ns 1625 ns 430629 + +bm_std::function_calls__Function::set_string 1626 ns 1626 ns 430290 +bm_std::function_calls____Method::set_string 1629 ns 1629 ns 429636 + +bm_rtl::function_calls__Function::set_string 1626 ns 1626 ns 430275 +bm_rtl::method_calls______Method::set_string 1627 ns 1627 ns 429935 + +bm_rtl::function__ErasedReturnType::set_string 1640 ns 1640 ns 426127 +bm_rtl::method____ErasedReturnType::set_string 1643 ns 1643 ns 426224 +bm_rtl::method____ErasedTargetType::set_string 1640 ns 1640 ns 427764 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1643 ns 1643 ns 426215 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2773 ns 2773 ns 252463 + +bm_call::via_function_ptr__Function::get_string 2767 ns 2767 ns 252937 +bm_call::via_function_ptr____Method::get_string 2768 ns 2768 ns 252976 + +bm_std::function_calls__Function::get_string 2772 ns 2772 ns 252487 +bm_std::function_calls____Method::get_string 2770 ns 2770 ns 252793 + +bm_rtl::function_calls__Function::get_string 2767 ns 2767 ns 253164 +bm_rtl::method_calls______Method::get_string 2770 ns 2770 ns 252709 + +bm_rtl::function__ErasedReturnType::get_string 3376 ns 3375 ns 207460 +bm_rtl::method____ErasedReturnType::get_string 3382 ns 3382 ns 207067 +bm_rtl::method____ErasedTargetType::get_string 2803 ns 2802 ns 249785 +bm_rtl::method____ErasedTargetAndReturnType::get_string 3384 ns 3384 ns 207041 +----------------------------------- +[2025-11-04 12:31:03] >>> Run 1: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-11-04T12:31:03+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4041.98 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.11, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1716 ns 1715 ns 408274 + +bm_call::via_function_ptr__Function::set_string 1712 ns 1712 ns 409361 +bm_call::via_function_ptr____Method::set_string 1713 ns 1713 ns 405493 + +bm_std::function_calls__Function::set_string 1718 ns 1717 ns 407832 +bm_std::function_calls____Method::set_string 1715 ns 1715 ns 408119 + +bm_rtl::function_calls__Function::set_string 1713 ns 1713 ns 408560 +bm_rtl::method_calls______Method::set_string 1709 ns 1709 ns 409044 + +bm_rtl::function__ErasedReturnType::set_string 1711 ns 1710 ns 408836 +bm_rtl::method____ErasedReturnType::set_string 1713 ns 1713 ns 408499 +bm_rtl::method____ErasedTargetType::set_string 1707 ns 1707 ns 409755 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1708 ns 1708 ns 409164 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3084 ns 3084 ns 226877 + +bm_call::via_function_ptr__Function::get_string 3082 ns 3082 ns 227143 +bm_call::via_function_ptr____Method::get_string 3083 ns 3083 ns 227251 + +bm_std::function_calls__Function::get_string 3085 ns 3085 ns 226897 +bm_std::function_calls____Method::get_string 3086 ns 3085 ns 226916 + +bm_rtl::function_calls__Function::get_string 3085 ns 3085 ns 226921 +bm_rtl::method_calls______Method::get_string 3073 ns 3073 ns 227717 + +bm_rtl::function__ErasedReturnType::get_string 3715 ns 3715 ns 188463 +bm_rtl::method____ErasedReturnType::get_string 3719 ns 3719 ns 188241 +bm_rtl::method____ErasedTargetType::get_string 3088 ns 3088 ns 226725 +bm_rtl::method____ErasedTargetAndReturnType::get_string 3718 ns 3718 ns 188254 +----------------------------------- +[2025-11-04 12:31:25] >>> Run 2: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-11-04T12:31:25+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.11, 1.03 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1704 ns 1704 ns 411933 + +bm_call::via_function_ptr__Function::set_string 1699 ns 1699 ns 412511 +bm_call::via_function_ptr____Method::set_string 1702 ns 1702 ns 411047 + +bm_std::function_calls__Function::set_string 1702 ns 1702 ns 411998 +bm_std::function_calls____Method::set_string 1702 ns 1702 ns 411072 + +bm_rtl::function_calls__Function::set_string 1698 ns 1698 ns 409485 +bm_rtl::method_calls______Method::set_string 1702 ns 1702 ns 411717 + +bm_rtl::function__ErasedReturnType::set_string 1705 ns 1705 ns 409692 +bm_rtl::method____ErasedReturnType::set_string 1708 ns 1708 ns 408834 +bm_rtl::method____ErasedTargetType::set_string 1709 ns 1709 ns 410268 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1708 ns 1708 ns 409422 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3072 ns 3072 ns 228015 + +bm_call::via_function_ptr__Function::get_string 3069 ns 3068 ns 228059 +bm_call::via_function_ptr____Method::get_string 3074 ns 3074 ns 227965 + +bm_std::function_calls__Function::get_string 3066 ns 3066 ns 228246 +bm_std::function_calls____Method::get_string 3070 ns 3070 ns 228340 + +bm_rtl::function_calls__Function::get_string 3066 ns 3066 ns 228209 +bm_rtl::method_calls______Method::get_string 3073 ns 3073 ns 228131 + +bm_rtl::function__ErasedReturnType::get_string 3716 ns 3715 ns 188572 +bm_rtl::method____ErasedReturnType::get_string 3720 ns 3720 ns 188419 +bm_rtl::method____ErasedTargetType::get_string 3085 ns 3085 ns 226900 +bm_rtl::method____ErasedTargetAndReturnType::get_string 3717 ns 3717 ns 187844 +----------------------------------- +[2025-11-04 12:31:46] >>> Run 3: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-11-04T12:31:46+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1641.19 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.10, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1708 ns 1708 ns 409543 + +bm_call::via_function_ptr__Function::set_string 1707 ns 1707 ns 411072 +bm_call::via_function_ptr____Method::set_string 1705 ns 1704 ns 409726 + +bm_std::function_calls__Function::set_string 1710 ns 1710 ns 409640 +bm_std::function_calls____Method::set_string 1706 ns 1706 ns 410029 + +bm_rtl::function_calls__Function::set_string 1707 ns 1707 ns 409382 +bm_rtl::method_calls______Method::set_string 1704 ns 1704 ns 410793 + +bm_rtl::function__ErasedReturnType::set_string 1712 ns 1712 ns 409380 +bm_rtl::method____ErasedReturnType::set_string 1714 ns 1714 ns 406447 +bm_rtl::method____ErasedTargetType::set_string 1706 ns 1706 ns 409968 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1712 ns 1712 ns 409490 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3068 ns 3068 ns 228115 + +bm_call::via_function_ptr__Function::get_string 3075 ns 3075 ns 228097 +bm_call::via_function_ptr____Method::get_string 3071 ns 3071 ns 228102 + +bm_std::function_calls__Function::get_string 3073 ns 3072 ns 228116 +bm_std::function_calls____Method::get_string 3073 ns 3072 ns 227749 + +bm_rtl::function_calls__Function::get_string 3074 ns 3074 ns 227707 +bm_rtl::method_calls______Method::get_string 3071 ns 3071 ns 228043 + +bm_rtl::function__ErasedReturnType::get_string 3716 ns 3716 ns 187872 +bm_rtl::method____ErasedReturnType::get_string 3717 ns 3717 ns 188232 +bm_rtl::method____ErasedTargetType::get_string 3092 ns 3092 ns 225613 +bm_rtl::method____ErasedTargetAndReturnType::get_string 3722 ns 3722 ns 188133 +----------------------------------- +[2025-11-04 12:32:08] >>> Run 1: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-11-04T12:32:08+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3729.3 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.09, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1767 ns 1766 ns 395242 + +bm_call::via_function_ptr__Function::set_string 1772 ns 1772 ns 394957 +bm_call::via_function_ptr____Method::set_string 1772 ns 1772 ns 394786 + +bm_std::function_calls__Function::set_string 1771 ns 1771 ns 395414 +bm_std::function_calls____Method::set_string 1776 ns 1776 ns 395160 + +bm_rtl::function_calls__Function::set_string 1774 ns 1774 ns 394773 +bm_rtl::method_calls______Method::set_string 1780 ns 1780 ns 393690 + +bm_rtl::function__ErasedReturnType::set_string 1778 ns 1778 ns 393159 +bm_rtl::method____ErasedReturnType::set_string 1782 ns 1782 ns 393163 +bm_rtl::method____ErasedTargetType::set_string 1781 ns 1781 ns 392715 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1782 ns 1782 ns 392482 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3335 ns 3335 ns 209233 + +bm_call::via_function_ptr__Function::get_string 3338 ns 3338 ns 209626 +bm_call::via_function_ptr____Method::get_string 3337 ns 3337 ns 209562 + +bm_std::function_calls__Function::get_string 3333 ns 3333 ns 210286 +bm_std::function_calls____Method::get_string 3337 ns 3337 ns 209884 + +bm_rtl::function_calls__Function::get_string 3338 ns 3338 ns 209988 +bm_rtl::method_calls______Method::get_string 3336 ns 3336 ns 209984 + +bm_rtl::function__ErasedReturnType::get_string 4070 ns 4069 ns 172155 +bm_rtl::method____ErasedReturnType::get_string 4068 ns 4067 ns 172083 +bm_rtl::method____ErasedTargetType::get_string 3352 ns 3351 ns 209120 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4069 ns 4068 ns 172041 +----------------------------------- +[2025-11-04 12:32:30] >>> Run 2: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-11-04T12:32:30+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3961.21 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.07, 1.10, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1776 ns 1776 ns 393592 + +bm_call::via_function_ptr__Function::set_string 1777 ns 1777 ns 394043 +bm_call::via_function_ptr____Method::set_string 1779 ns 1779 ns 393918 + +bm_std::function_calls__Function::set_string 1773 ns 1773 ns 395185 +bm_std::function_calls____Method::set_string 1773 ns 1773 ns 394879 + +bm_rtl::function_calls__Function::set_string 1778 ns 1778 ns 393670 +bm_rtl::method_calls______Method::set_string 1778 ns 1778 ns 393972 + +bm_rtl::function__ErasedReturnType::set_string 1787 ns 1787 ns 391688 +bm_rtl::method____ErasedReturnType::set_string 1787 ns 1787 ns 391402 +bm_rtl::method____ErasedTargetType::set_string 1783 ns 1783 ns 391780 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1785 ns 1785 ns 391770 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3332 ns 3332 ns 209745 + +bm_call::via_function_ptr__Function::get_string 3332 ns 3331 ns 210115 +bm_call::via_function_ptr____Method::get_string 3333 ns 3333 ns 209826 + +bm_std::function_calls__Function::get_string 3326 ns 3326 ns 210463 +bm_std::function_calls____Method::get_string 3327 ns 3327 ns 210290 + +bm_rtl::function_calls__Function::get_string 3326 ns 3325 ns 210512 +bm_rtl::method_calls______Method::get_string 3325 ns 3325 ns 210556 + +bm_rtl::function__ErasedReturnType::get_string 4044 ns 4044 ns 173233 +bm_rtl::method____ErasedReturnType::get_string 4042 ns 4042 ns 173222 +bm_rtl::method____ErasedTargetType::get_string 3339 ns 3339 ns 209665 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4043 ns 4043 ns 173090 +----------------------------------- +[2025-11-04 12:32:52] >>> Run 3: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-11-04T12:32:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.09, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1784 ns 1783 ns 392280 + +bm_call::via_function_ptr__Function::set_string 1786 ns 1786 ns 392452 +bm_call::via_function_ptr____Method::set_string 1789 ns 1789 ns 391699 + +bm_std::function_calls__Function::set_string 1794 ns 1794 ns 390359 +bm_std::function_calls____Method::set_string 1804 ns 1804 ns 388507 + +bm_rtl::function_calls__Function::set_string 1811 ns 1811 ns 387372 +bm_rtl::method_calls______Method::set_string 1808 ns 1808 ns 387531 + +bm_rtl::function__ErasedReturnType::set_string 1782 ns 1782 ns 392864 +bm_rtl::method____ErasedReturnType::set_string 1785 ns 1785 ns 392227 +bm_rtl::method____ErasedTargetType::set_string 1780 ns 1780 ns 393273 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1780 ns 1780 ns 393240 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3362 ns 3362 ns 208152 + +bm_call::via_function_ptr__Function::get_string 3366 ns 3366 ns 207975 +bm_call::via_function_ptr____Method::get_string 3368 ns 3368 ns 207809 + +bm_std::function_calls__Function::get_string 3362 ns 3361 ns 208229 +bm_std::function_calls____Method::get_string 3347 ns 3347 ns 209205 + +bm_rtl::function_calls__Function::get_string 3361 ns 3361 ns 208356 +bm_rtl::method_calls______Method::get_string 3349 ns 3349 ns 208934 + +bm_rtl::function__ErasedReturnType::get_string 4051 ns 4051 ns 172849 +bm_rtl::method____ErasedReturnType::get_string 4051 ns 4051 ns 172829 +bm_rtl::method____ErasedTargetType::get_string 3368 ns 3367 ns 207905 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4048 ns 4048 ns 172912 +----------------------------------- +[2025-11-04 12:33:14] >>> Run 1: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-11-04T12:33:14+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 1.08, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1850 ns 1850 ns 379224 + +bm_call::via_function_ptr__Function::set_string 1850 ns 1850 ns 378200 +bm_call::via_function_ptr____Method::set_string 1852 ns 1852 ns 378223 + +bm_std::function_calls__Function::set_string 1853 ns 1853 ns 377629 +bm_std::function_calls____Method::set_string 1853 ns 1852 ns 377833 + +bm_rtl::function_calls__Function::set_string 1853 ns 1852 ns 378253 +bm_rtl::method_calls______Method::set_string 1855 ns 1855 ns 377285 + +bm_rtl::function__ErasedReturnType::set_string 1866 ns 1865 ns 375269 +bm_rtl::method____ErasedReturnType::set_string 1872 ns 1872 ns 374394 +bm_rtl::method____ErasedTargetType::set_string 1865 ns 1864 ns 375297 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1870 ns 1869 ns 375229 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3621 ns 3621 ns 193229 + +bm_call::via_function_ptr__Function::get_string 3620 ns 3620 ns 193390 +bm_call::via_function_ptr____Method::get_string 3619 ns 3619 ns 193491 + +bm_std::function_calls__Function::get_string 3627 ns 3627 ns 193051 +bm_std::function_calls____Method::get_string 3629 ns 3629 ns 192921 + +bm_rtl::function_calls__Function::get_string 3626 ns 3626 ns 193080 +bm_rtl::method_calls______Method::get_string 3630 ns 3630 ns 192853 + +bm_rtl::function__ErasedReturnType::get_string 4345 ns 4345 ns 161148 +bm_rtl::method____ErasedReturnType::get_string 4348 ns 4348 ns 160982 +bm_rtl::method____ErasedTargetType::get_string 3658 ns 3658 ns 191325 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4350 ns 4350 ns 160848 +----------------------------------- +[2025-11-04 12:33:36] >>> Run 2: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-11-04T12:33:36+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.07, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1850 ns 1850 ns 378250 + +bm_call::via_function_ptr__Function::set_string 1851 ns 1851 ns 378198 +bm_call::via_function_ptr____Method::set_string 1853 ns 1852 ns 377792 + +bm_std::function_calls__Function::set_string 1862 ns 1862 ns 376203 +bm_std::function_calls____Method::set_string 1859 ns 1859 ns 376918 + +bm_rtl::function_calls__Function::set_string 1864 ns 1864 ns 375389 +bm_rtl::method_calls______Method::set_string 1864 ns 1864 ns 375592 + +bm_rtl::function__ErasedReturnType::set_string 1877 ns 1877 ns 373174 +bm_rtl::method____ErasedReturnType::set_string 1877 ns 1877 ns 373198 +bm_rtl::method____ErasedTargetType::set_string 1871 ns 1870 ns 374468 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1876 ns 1876 ns 373838 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3626 ns 3625 ns 193072 + +bm_call::via_function_ptr__Function::get_string 3623 ns 3623 ns 193302 +bm_call::via_function_ptr____Method::get_string 3622 ns 3622 ns 193279 + +bm_std::function_calls__Function::get_string 3630 ns 3630 ns 192894 +bm_std::function_calls____Method::get_string 3637 ns 3637 ns 192511 + +bm_rtl::function_calls__Function::get_string 3632 ns 3632 ns 192793 +bm_rtl::method_calls______Method::get_string 3629 ns 3629 ns 192875 + +bm_rtl::function__ErasedReturnType::get_string 4396 ns 4395 ns 159101 +bm_rtl::method____ErasedReturnType::get_string 4380 ns 4380 ns 159765 +bm_rtl::method____ErasedTargetType::get_string 3663 ns 3663 ns 191171 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4382 ns 4382 ns 159762 +----------------------------------- +[2025-11-04 12:33:58] >>> Run 3: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-11-04T12:33:58+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.07, 1.02 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1867 ns 1867 ns 374901 + +bm_call::via_function_ptr__Function::set_string 1869 ns 1869 ns 374808 +bm_call::via_function_ptr____Method::set_string 1868 ns 1868 ns 374856 + +bm_std::function_calls__Function::set_string 1871 ns 1871 ns 374208 +bm_std::function_calls____Method::set_string 1860 ns 1860 ns 375819 + +bm_rtl::function_calls__Function::set_string 1873 ns 1873 ns 374232 +bm_rtl::method_calls______Method::set_string 1866 ns 1866 ns 375267 + +bm_rtl::function__ErasedReturnType::set_string 1885 ns 1885 ns 371538 +bm_rtl::method____ErasedReturnType::set_string 1899 ns 1899 ns 368497 +bm_rtl::method____ErasedTargetType::set_string 1882 ns 1882 ns 372145 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1896 ns 1896 ns 369384 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3811 ns 3811 ns 183639 + +bm_call::via_function_ptr__Function::get_string 3811 ns 3811 ns 183675 +bm_call::via_function_ptr____Method::get_string 3809 ns 3808 ns 183773 + +bm_std::function_calls__Function::get_string 3821 ns 3821 ns 183176 +bm_std::function_calls____Method::get_string 3822 ns 3821 ns 183277 + +bm_rtl::function_calls__Function::get_string 3817 ns 3816 ns 183495 +bm_rtl::method_calls______Method::get_string 3820 ns 3820 ns 183226 + +bm_rtl::function__ErasedReturnType::get_string 4565 ns 4565 ns 153385 +bm_rtl::method____ErasedReturnType::get_string 4539 ns 4539 ns 154235 +bm_rtl::method____ErasedTargetType::get_string 3844 ns 3843 ns 182098 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4541 ns 4540 ns 154162 +----------------------------------- +[2025-11-04 12:34:21] >>> Run 1: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-11-04T12:34:21+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 954.973 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.06, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1961 ns 1961 ns 357857 + +bm_call::via_function_ptr__Function::set_string 1962 ns 1962 ns 356890 +bm_call::via_function_ptr____Method::set_string 1964 ns 1964 ns 356347 + +bm_std::function_calls__Function::set_string 1981 ns 1980 ns 353093 +bm_std::function_calls____Method::set_string 1980 ns 1980 ns 353920 + +bm_rtl::function_calls__Function::set_string 1986 ns 1985 ns 352760 +bm_rtl::method_calls______Method::set_string 1960 ns 1960 ns 357367 + +bm_rtl::function__ErasedReturnType::set_string 1966 ns 1966 ns 355968 +bm_rtl::method____ErasedReturnType::set_string 1966 ns 1966 ns 356507 +bm_rtl::method____ErasedTargetType::set_string 1965 ns 1965 ns 356382 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1969 ns 1969 ns 355503 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 4122 ns 4122 ns 169805 + +bm_call::via_function_ptr__Function::get_string 4123 ns 4122 ns 169776 +bm_call::via_function_ptr____Method::get_string 3985 ns 3985 ns 171499 + +bm_std::function_calls__Function::get_string 3952 ns 3951 ns 176989 +bm_std::function_calls____Method::get_string 3953 ns 3952 ns 177118 + +bm_rtl::function_calls__Function::get_string 3957 ns 3957 ns 176932 +bm_rtl::method_calls______Method::get_string 3957 ns 3957 ns 176974 + +bm_rtl::function__ErasedReturnType::get_string 4745 ns 4744 ns 147638 +bm_rtl::method____ErasedReturnType::get_string 4746 ns 4746 ns 147454 +bm_rtl::method____ErasedTargetType::get_string 3978 ns 3978 ns 175930 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4745 ns 4745 ns 147401 +----------------------------------- +[2025-11-04 12:34:44] >>> Run 2: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-11-04T12:34:44+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.06, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1934 ns 1934 ns 361337 + +bm_call::via_function_ptr__Function::set_string 1940 ns 1940 ns 360781 +bm_call::via_function_ptr____Method::set_string 1936 ns 1936 ns 361609 + +bm_std::function_calls__Function::set_string 1937 ns 1936 ns 360705 +bm_std::function_calls____Method::set_string 1942 ns 1942 ns 361593 + +bm_rtl::function_calls__Function::set_string 1944 ns 1944 ns 360392 +bm_rtl::method_calls______Method::set_string 1945 ns 1945 ns 359927 + +bm_rtl::function__ErasedReturnType::set_string 1952 ns 1952 ns 358537 +bm_rtl::method____ErasedReturnType::set_string 1958 ns 1958 ns 357397 +bm_rtl::method____ErasedTargetType::set_string 1963 ns 1963 ns 357730 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1972 ns 1972 ns 354598 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 4096 ns 4096 ns 170858 + +bm_call::via_function_ptr__Function::get_string 4094 ns 4093 ns 170965 +bm_call::via_function_ptr____Method::get_string 4092 ns 4092 ns 171123 + +bm_std::function_calls__Function::get_string 4098 ns 4098 ns 170793 +bm_std::function_calls____Method::get_string 4103 ns 4103 ns 170634 + +bm_rtl::function_calls__Function::get_string 4102 ns 4102 ns 170611 +bm_rtl::method_calls______Method::get_string 4102 ns 4102 ns 170566 + +bm_rtl::function__ErasedReturnType::get_string 4891 ns 4891 ns 143266 +bm_rtl::method____ErasedReturnType::get_string 4896 ns 4895 ns 142971 +bm_rtl::method____ErasedTargetType::get_string 4128 ns 4128 ns 169566 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4896 ns 4896 ns 142983 +----------------------------------- +[2025-11-04 12:35:07] >>> Run 3: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-11-04T12:35:07+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.05, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1977 ns 1977 ns 353596 + +bm_call::via_function_ptr__Function::set_string 1985 ns 1984 ns 353779 +bm_call::via_function_ptr____Method::set_string 1989 ns 1989 ns 352715 + +bm_std::function_calls__Function::set_string 2003 ns 2003 ns 350400 +bm_std::function_calls____Method::set_string 2008 ns 2008 ns 349132 + +bm_rtl::function_calls__Function::set_string 2006 ns 2006 ns 349311 +bm_rtl::method_calls______Method::set_string 2011 ns 2011 ns 349247 + +bm_rtl::function__ErasedReturnType::set_string 2000 ns 1999 ns 350105 +bm_rtl::method____ErasedReturnType::set_string 2000 ns 2000 ns 350108 +bm_rtl::method____ErasedTargetType::set_string 2002 ns 2002 ns 349732 +bm_rtl::method____ErasedTargetAndReturnType::set_string 2002 ns 2002 ns 349713 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3976 ns 3976 ns 175636 + +bm_call::via_function_ptr__Function::get_string 3977 ns 3977 ns 176258 +bm_call::via_function_ptr____Method::get_string 3969 ns 3968 ns 176389 + +bm_std::function_calls__Function::get_string 4001 ns 4001 ns 175249 +bm_std::function_calls____Method::get_string 3993 ns 3993 ns 175269 + +bm_rtl::function_calls__Function::get_string 4006 ns 4006 ns 174915 +bm_rtl::method_calls______Method::get_string 3975 ns 3975 ns 176077 + +bm_rtl::function__ErasedReturnType::get_string 4735 ns 4735 ns 147503 +bm_rtl::method____ErasedReturnType::get_string 4744 ns 4744 ns 147790 +bm_rtl::method____ErasedTargetType::get_string 3979 ns 3979 ns 175845 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4745 ns 4745 ns 147593 +----------------------------------- +[2025-11-04 12:35:30] >>> Run 1: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-11-04T12:35:30+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 1.05, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 2145 ns 2145 ns 326478 + +bm_call::via_function_ptr__Function::set_string 2145 ns 2145 ns 326264 +bm_call::via_function_ptr____Method::set_string 2148 ns 2148 ns 325609 + +bm_std::function_calls__Function::set_string 2150 ns 2149 ns 325379 +bm_std::function_calls____Method::set_string 2146 ns 2146 ns 326018 + +bm_rtl::function_calls__Function::set_string 2151 ns 2151 ns 325875 +bm_rtl::method_calls______Method::set_string 2152 ns 2152 ns 325215 + +bm_rtl::function__ErasedReturnType::set_string 2161 ns 2161 ns 324202 +bm_rtl::method____ErasedReturnType::set_string 2162 ns 2162 ns 324182 +bm_rtl::method____ErasedTargetType::set_string 2157 ns 2157 ns 324788 +bm_rtl::method____ErasedTargetAndReturnType::set_string 2162 ns 2161 ns 324038 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 4617 ns 4617 ns 151631 + +bm_call::via_function_ptr__Function::get_string 4617 ns 4617 ns 151639 +bm_call::via_function_ptr____Method::get_string 4617 ns 4616 ns 151716 + +bm_std::function_calls__Function::get_string 4627 ns 4626 ns 151346 +bm_std::function_calls____Method::get_string 4619 ns 4619 ns 151470 + +bm_rtl::function_calls__Function::get_string 4620 ns 4620 ns 151567 +bm_rtl::method_calls______Method::get_string 4620 ns 4620 ns 151462 + +bm_rtl::function__ErasedReturnType::get_string 5616 ns 5616 ns 124617 +bm_rtl::method____ErasedReturnType::get_string 5608 ns 5608 ns 124657 +bm_rtl::method____ErasedTargetType::get_string 4645 ns 4644 ns 150774 +bm_rtl::method____ErasedTargetAndReturnType::get_string 5612 ns 5612 ns 124546 +----------------------------------- +[2025-11-04 12:35:52] >>> Run 2: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-11-04T12:35:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 1.06, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 2145 ns 2145 ns 326686 + +bm_call::via_function_ptr__Function::set_string 2143 ns 2143 ns 327072 +bm_call::via_function_ptr____Method::set_string 2142 ns 2142 ns 326938 + +bm_std::function_calls__Function::set_string 2152 ns 2152 ns 325170 +bm_std::function_calls____Method::set_string 2149 ns 2149 ns 326018 + +bm_rtl::function_calls__Function::set_string 2153 ns 2153 ns 325215 +bm_rtl::method_calls______Method::set_string 2150 ns 2150 ns 325278 + +bm_rtl::function__ErasedReturnType::set_string 2165 ns 2164 ns 323427 +bm_rtl::method____ErasedReturnType::set_string 2189 ns 2189 ns 319619 +bm_rtl::method____ErasedTargetType::set_string 2171 ns 2170 ns 322824 +bm_rtl::method____ErasedTargetAndReturnType::set_string 2181 ns 2181 ns 320945 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 4793 ns 4792 ns 146051 + +bm_call::via_function_ptr__Function::get_string 4795 ns 4794 ns 146001 +bm_call::via_function_ptr____Method::get_string 4792 ns 4792 ns 146108 + +bm_std::function_calls__Function::get_string 4649 ns 4649 ns 145872 +bm_std::function_calls____Method::get_string 4627 ns 4627 ns 150967 + +bm_rtl::function_calls__Function::get_string 4631 ns 4631 ns 151175 +bm_rtl::method_calls______Method::get_string 4632 ns 4632 ns 151161 + +bm_rtl::function__ErasedReturnType::get_string 5685 ns 5684 ns 123111 +bm_rtl::method____ErasedReturnType::get_string 5630 ns 5629 ns 124248 +bm_rtl::method____ErasedTargetType::get_string 4674 ns 4674 ns 149772 +bm_rtl::method____ErasedTargetAndReturnType::get_string 5637 ns 5637 ns 124261 +----------------------------------- +[2025-11-04 12:36:15] >>> Run 3: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-11-04T12:36:15+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.05, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 2157 ns 2157 ns 324031 + +bm_call::via_function_ptr__Function::set_string 2157 ns 2157 ns 323762 +bm_call::via_function_ptr____Method::set_string 2158 ns 2158 ns 324457 + +bm_std::function_calls__Function::set_string 2168 ns 2168 ns 323051 +bm_std::function_calls____Method::set_string 2169 ns 2169 ns 322789 + +bm_rtl::function_calls__Function::set_string 2164 ns 2164 ns 324068 +bm_rtl::method_calls______Method::set_string 2162 ns 2162 ns 323716 + +bm_rtl::function__ErasedReturnType::set_string 2178 ns 2177 ns 322027 +bm_rtl::method____ErasedReturnType::set_string 2179 ns 2179 ns 321347 +bm_rtl::method____ErasedTargetType::set_string 2180 ns 2180 ns 321745 +bm_rtl::method____ErasedTargetAndReturnType::set_string 2180 ns 2180 ns 321062 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 4636 ns 4636 ns 151263 + +bm_call::via_function_ptr__Function::get_string 4632 ns 4631 ns 151234 +bm_call::via_function_ptr____Method::get_string 4627 ns 4627 ns 150946 + +bm_std::function_calls__Function::get_string 4643 ns 4642 ns 151075 +bm_std::function_calls____Method::get_string 4633 ns 4633 ns 151103 + +bm_rtl::function_calls__Function::get_string 4647 ns 4647 ns 150930 +bm_rtl::method_calls______Method::get_string 4634 ns 4634 ns 151052 + +bm_rtl::function__ErasedReturnType::get_string 5627 ns 5626 ns 124604 +bm_rtl::method____ErasedReturnType::get_string 5618 ns 5618 ns 124566 +bm_rtl::method____ErasedTargetType::get_string 4667 ns 4667 ns 150194 +bm_rtl::method____ErasedTargetAndReturnType::get_string 5622 ns 5622 ns 124669 +----------------------------------- +[2025-11-04 12:36:37] >>> Run 1: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-11-04T12:36:37+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.08, 1.06, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 3511 ns 3511 ns 199591 + +bm_call::via_function_ptr__Function::set_string 3504 ns 3504 ns 199578 +bm_call::via_function_ptr____Method::set_string 3513 ns 3512 ns 199781 + +bm_std::function_calls__Function::set_string 3518 ns 3518 ns 199107 +bm_std::function_calls____Method::set_string 3521 ns 3521 ns 199095 + +bm_rtl::function_calls__Function::set_string 3519 ns 3518 ns 199087 +bm_rtl::method_calls______Method::set_string 3525 ns 3525 ns 198202 + +bm_rtl::function__ErasedReturnType::set_string 3531 ns 3530 ns 198334 +bm_rtl::method____ErasedReturnType::set_string 3544 ns 3543 ns 197580 +bm_rtl::method____ErasedTargetType::set_string 3538 ns 3537 ns 198133 +bm_rtl::method____ErasedTargetAndReturnType::set_string 3545 ns 3544 ns 197480 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 6774 ns 6772 ns 103350 + +bm_call::via_function_ptr__Function::get_string 6773 ns 6772 ns 103343 +bm_call::via_function_ptr____Method::get_string 6772 ns 6772 ns 103373 + +bm_std::function_calls__Function::get_string 6784 ns 6783 ns 103220 +bm_std::function_calls____Method::get_string 6780 ns 6780 ns 103259 + +bm_rtl::function_calls__Function::get_string 6779 ns 6778 ns 103272 +bm_rtl::method_calls______Method::get_string 6782 ns 6781 ns 103246 + +bm_rtl::function__ErasedReturnType::get_string 7997 ns 7997 ns 87528 +bm_rtl::method____ErasedReturnType::get_string 7989 ns 7986 ns 87655 +bm_rtl::method____ErasedTargetType::get_string 6792 ns 6791 ns 103053 +bm_rtl::method____ErasedTargetAndReturnType::get_string 7992 ns 7989 ns 87557 +----------------------------------- +[2025-11-04 12:36:58] >>> Run 2: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-11-04T12:36:58+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 1.06, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 3549 ns 3548 ns 197190 + +bm_call::via_function_ptr__Function::set_string 3550 ns 3550 ns 197298 +bm_call::via_function_ptr____Method::set_string 3545 ns 3545 ns 197213 + +bm_std::function_calls__Function::set_string 3557 ns 3556 ns 197059 +bm_std::function_calls____Method::set_string 3547 ns 3547 ns 197291 + +bm_rtl::function_calls__Function::set_string 3550 ns 3550 ns 197117 +bm_rtl::method_calls______Method::set_string 3555 ns 3554 ns 197038 + +bm_rtl::function__ErasedReturnType::set_string 3568 ns 3567 ns 196518 +bm_rtl::method____ErasedReturnType::set_string 3571 ns 3570 ns 195914 +bm_rtl::method____ErasedTargetType::set_string 3563 ns 3563 ns 196195 +bm_rtl::method____ErasedTargetAndReturnType::set_string 3567 ns 3566 ns 196254 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 6601 ns 6600 ns 106086 + +bm_call::via_function_ptr__Function::get_string 6598 ns 6597 ns 106016 +bm_call::via_function_ptr____Method::get_string 6598 ns 6597 ns 106208 + +bm_std::function_calls__Function::get_string 6607 ns 6606 ns 105997 +bm_std::function_calls____Method::get_string 6609 ns 6608 ns 105976 + +bm_rtl::function_calls__Function::get_string 6606 ns 6605 ns 105996 +bm_rtl::method_calls______Method::get_string 6601 ns 6600 ns 106125 + +bm_rtl::function__ErasedReturnType::get_string 7820 ns 7818 ns 89497 +bm_rtl::method____ErasedReturnType::get_string 7813 ns 7812 ns 89600 +bm_rtl::method____ErasedTargetType::get_string 6614 ns 6613 ns 105770 +bm_rtl::method____ErasedTargetAndReturnType::get_string 7815 ns 7814 ns 89559 +----------------------------------- +[2025-11-04 12:37:18] >>> Run 3: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-11-04T12:37:18+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.05, 1.01 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 3521 ns 3520 ns 198831 + +bm_call::via_function_ptr__Function::set_string 3519 ns 3519 ns 199065 +bm_call::via_function_ptr____Method::set_string 3520 ns 3519 ns 198988 + +bm_std::function_calls__Function::set_string 3529 ns 3528 ns 198384 +bm_std::function_calls____Method::set_string 3535 ns 3534 ns 198140 + +bm_rtl::function_calls__Function::set_string 3529 ns 3529 ns 198462 +bm_rtl::method_calls______Method::set_string 3528 ns 3528 ns 198319 + +bm_rtl::function__ErasedReturnType::set_string 3537 ns 3536 ns 197784 +bm_rtl::method____ErasedReturnType::set_string 3544 ns 3543 ns 197602 +bm_rtl::method____ErasedTargetType::set_string 3544 ns 3543 ns 197518 +bm_rtl::method____ErasedTargetAndReturnType::set_string 3547 ns 3546 ns 197510 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 6791 ns 6789 ns 103143 + +bm_call::via_function_ptr__Function::get_string 6789 ns 6788 ns 103109 +bm_call::via_function_ptr____Method::get_string 6789 ns 6787 ns 103031 + +bm_std::function_calls__Function::get_string 6785 ns 6783 ns 103175 +bm_std::function_calls____Method::get_string 6783 ns 6782 ns 103233 + +bm_rtl::function_calls__Function::get_string 6792 ns 6791 ns 103075 +bm_rtl::method_calls______Method::get_string 6796 ns 6795 ns 103017 + +bm_rtl::function__ErasedReturnType::get_string 7988 ns 7987 ns 87673 +bm_rtl::method____ErasedReturnType::get_string 7989 ns 7985 ns 87691 +bm_rtl::method____ErasedTargetType::get_string 6797 ns 6796 ns 103050 +bm_rtl::method____ErasedTargetAndReturnType::get_string 7990 ns 7988 ns 87626 +----------------------------------- +All benchmarks completed. diff --git a/text-benchmark-logs/benchmark_runs_string_view.log b/text-benchmark-logs/benchmark_runs_string_view.log new file mode 100644 index 00000000..0399b902 --- /dev/null +++ b/text-benchmark-logs/benchmark_runs_string_view.log @@ -0,0 +1,3167 @@ +Starting benchmark runs... +Binary: ./bin/RTLBenchmarkApp +Log: ./benchmark_runs.log +=================================== +[2025-11-04 11:28:24] >>> Run 1: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T11:28:24+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.38, 0.13, 0.04 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 0.614 ns 0.614 ns 1000000000 + +bm_call::via_function_ptr__Function::set_string 1.02 ns 1.02 ns 683678776 +bm_call::via_function_ptr____Method::set_string 1.23 ns 1.23 ns 569885030 + +bm_std::function_calls__Function::set_string 1.23 ns 1.23 ns 562884499 +bm_std::function_calls____Method::set_string 1.64 ns 1.64 ns 426729520 + +bm_rtl::function_calls__Function::set_string 1.02 ns 1.02 ns 683865607 +bm_rtl::method_calls______Method::set_string 1.62 ns 1.62 ns 430515116 + +bm_rtl::function__ErasedReturnType::set_string 3.04 ns 3.04 ns 230360121 +bm_rtl::method____ErasedReturnType::set_string 4.04 ns 4.04 ns 172858129 +bm_rtl::method____ErasedTargetType::set_string 4.26 ns 4.26 ns 166388092 +bm_rtl::method____ErasedTargetAndReturnType::set_string 4.74 ns 4.74 ns 149410247 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1.48 ns 1.48 ns 466378476 + +bm_call::via_function_ptr__Function::get_string 2.58 ns 2.58 ns 270570089 +bm_call::via_function_ptr____Method::get_string 2.59 ns 2.59 ns 269322401 + +bm_std::function_calls__Function::get_string 2.76 ns 2.76 ns 251347073 +bm_std::function_calls____Method::get_string 3.27 ns 3.27 ns 217804162 + +bm_rtl::function_calls__Function::get_string 2.58 ns 2.58 ns 270312043 +bm_rtl::method_calls______Method::get_string 2.98 ns 2.98 ns 230536281 + +bm_rtl::function__ErasedReturnType::get_string 15.1 ns 15.1 ns 45710706 +bm_rtl::method____ErasedReturnType::get_string 15.8 ns 15.8 ns 44050977 +bm_rtl::method____ErasedTargetType::get_string 5.97 ns 5.97 ns 117370904 +bm_rtl::method____ErasedTargetAndReturnType::get_string 17.3 ns 17.3 ns 43244655 +----------------------------------- +[2025-11-04 11:28:44] >>> Run 2: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T11:28:44+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4611.4 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 0.78, 0.24, 0.08 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 0.634 ns 0.634 ns 1000000000 + +bm_call::via_function_ptr__Function::set_string 1.08 ns 1.08 ns 654860358 +bm_call::via_function_ptr____Method::set_string 1.30 ns 1.30 ns 525150563 + +bm_std::function_calls__Function::set_string 1.28 ns 1.28 ns 542946738 +bm_std::function_calls____Method::set_string 1.65 ns 1.65 ns 415930435 + +bm_rtl::function_calls__Function::set_string 1.07 ns 1.07 ns 676793908 +bm_rtl::method_calls______Method::set_string 1.68 ns 1.68 ns 408934924 + +bm_rtl::function__ErasedReturnType::set_string 3.20 ns 3.20 ns 229478489 +bm_rtl::method____ErasedReturnType::set_string 4.05 ns 4.05 ns 170238631 +bm_rtl::method____ErasedTargetType::set_string 4.22 ns 4.22 ns 164288125 +bm_rtl::method____ErasedTargetAndReturnType::set_string 4.68 ns 4.68 ns 150597958 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1.43 ns 1.43 ns 474635786 + +bm_call::via_function_ptr__Function::get_string 2.49 ns 2.49 ns 282523832 +bm_call::via_function_ptr____Method::get_string 2.48 ns 2.48 ns 283788061 + +bm_std::function_calls__Function::get_string 2.69 ns 2.69 ns 256523801 +bm_std::function_calls____Method::get_string 3.11 ns 3.11 ns 225496053 + +bm_rtl::function_calls__Function::get_string 2.56 ns 2.56 ns 271049574 +bm_rtl::method_calls______Method::get_string 2.95 ns 2.95 ns 242354631 + +bm_rtl::function__ErasedReturnType::get_string 15.5 ns 15.5 ns 45846828 +bm_rtl::method____ErasedReturnType::get_string 15.7 ns 15.7 ns 44262788 +bm_rtl::method____ErasedTargetType::get_string 5.89 ns 5.89 ns 117265605 +bm_rtl::method____ErasedTargetAndReturnType::get_string 16.3 ns 16.3 ns 42284738 +----------------------------------- +[2025-11-04 11:29:05] >>> Run 3: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T11:29:05+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.13, 0.35, 0.12 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 0.543 ns 0.543 ns 1000000000 + +bm_call::via_function_ptr__Function::set_string 1.03 ns 1.03 ns 683567202 +bm_call::via_function_ptr____Method::set_string 1.23 ns 1.23 ns 569508463 + +bm_std::function_calls__Function::set_string 1.23 ns 1.23 ns 570111428 +bm_std::function_calls____Method::set_string 1.64 ns 1.64 ns 427615238 + +bm_rtl::function_calls__Function::set_string 1.02 ns 1.02 ns 684124829 +bm_rtl::method_calls______Method::set_string 1.62 ns 1.62 ns 476008120 + +bm_rtl::function__ErasedReturnType::set_string 3.02 ns 3.02 ns 230302984 +bm_rtl::method____ErasedReturnType::set_string 4.02 ns 4.02 ns 172265220 +bm_rtl::method____ErasedTargetType::set_string 4.26 ns 4.26 ns 164395945 +bm_rtl::method____ErasedTargetAndReturnType::set_string 4.67 ns 4.67 ns 151752309 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1.41 ns 1.41 ns 495458672 + +bm_call::via_function_ptr__Function::get_string 2.46 ns 2.46 ns 284981627 +bm_call::via_function_ptr____Method::get_string 2.49 ns 2.49 ns 280143091 + +bm_std::function_calls__Function::get_string 2.66 ns 2.66 ns 263196386 +bm_std::function_calls____Method::get_string 3.11 ns 3.10 ns 227498153 + +bm_rtl::function_calls__Function::get_string 2.46 ns 2.46 ns 284559260 +bm_rtl::method_calls______Method::get_string 2.87 ns 2.87 ns 244503914 + +bm_rtl::function__ErasedReturnType::get_string 14.7 ns 14.7 ns 48203413 +bm_rtl::method____ErasedReturnType::get_string 15.2 ns 15.2 ns 45954622 +bm_rtl::method____ErasedTargetType::get_string 5.81 ns 5.81 ns 120895674 +bm_rtl::method____ErasedTargetAndReturnType::get_string 16.4 ns 16.4 ns 42589796 +----------------------------------- +[2025-11-04 11:29:25] >>> Run 4: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T11:29:25+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4142.36 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.09, 0.39, 0.14 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 0.619 ns 0.620 ns 1000000000 + +bm_call::via_function_ptr__Function::set_string 1.02 ns 1.02 ns 683826531 +bm_call::via_function_ptr____Method::set_string 1.23 ns 1.23 ns 569466070 + +bm_std::function_calls__Function::set_string 1.23 ns 1.23 ns 563230061 +bm_std::function_calls____Method::set_string 1.64 ns 1.64 ns 427349799 + +bm_rtl::function_calls__Function::set_string 1.02 ns 1.03 ns 684106315 +bm_rtl::method_calls______Method::set_string 1.50 ns 1.50 ns 485473792 + +bm_rtl::function__ErasedReturnType::set_string 3.04 ns 3.04 ns 231054109 +bm_rtl::method____ErasedReturnType::set_string 4.01 ns 4.01 ns 177095634 +bm_rtl::method____ErasedTargetType::set_string 4.15 ns 4.15 ns 168485741 +bm_rtl::method____ErasedTargetAndReturnType::set_string 4.58 ns 4.58 ns 149929544 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1.42 ns 1.42 ns 495133376 + +bm_call::via_function_ptr__Function::get_string 2.45 ns 2.46 ns 285005788 +bm_call::via_function_ptr____Method::get_string 2.48 ns 2.48 ns 284236287 + +bm_std::function_calls__Function::get_string 2.66 ns 2.66 ns 263017751 +bm_std::function_calls____Method::get_string 3.10 ns 3.10 ns 224825065 + +bm_rtl::function_calls__Function::get_string 2.46 ns 2.46 ns 284512552 +bm_rtl::method_calls______Method::get_string 2.86 ns 2.86 ns 243917692 + +bm_rtl::function__ErasedReturnType::get_string 14.7 ns 14.7 ns 47450172 +bm_rtl::method____ErasedReturnType::get_string 15.2 ns 15.2 ns 46035495 +bm_rtl::method____ErasedTargetType::get_string 5.86 ns 5.86 ns 121152258 +bm_rtl::method____ErasedTargetAndReturnType::get_string 16.3 ns 16.3 ns 41584993 +----------------------------------- +[2025-11-04 11:29:46] >>> Run 5: workload scale = 0 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 0 iterations +============================================= + +2025-11-04T11:29:46+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 0.43, 0.16 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 0.540 ns 0.540 ns 1000000000 + +bm_call::via_function_ptr__Function::set_string 1.03 ns 1.03 ns 682847039 +bm_call::via_function_ptr____Method::set_string 1.23 ns 1.23 ns 568512058 + +bm_std::function_calls__Function::set_string 1.23 ns 1.23 ns 569587483 +bm_std::function_calls____Method::set_string 1.64 ns 1.64 ns 427385239 + +bm_rtl::function_calls__Function::set_string 1.02 ns 1.02 ns 683618197 +bm_rtl::method_calls______Method::set_string 1.63 ns 1.63 ns 428438447 + +bm_rtl::function__ErasedReturnType::set_string 3.03 ns 3.03 ns 230910273 +bm_rtl::method____ErasedReturnType::set_string 3.96 ns 3.96 ns 177102134 +bm_rtl::method____ErasedTargetType::set_string 4.21 ns 4.21 ns 166155415 +bm_rtl::method____ErasedTargetAndReturnType::set_string 4.63 ns 4.63 ns 151585002 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1.42 ns 1.42 ns 495417193 + +bm_call::via_function_ptr__Function::get_string 2.45 ns 2.46 ns 285068393 +bm_call::via_function_ptr____Method::get_string 2.48 ns 2.48 ns 283577125 + +bm_std::function_calls__Function::get_string 2.66 ns 2.66 ns 263081859 +bm_std::function_calls____Method::get_string 3.09 ns 3.09 ns 225912956 + +bm_rtl::function_calls__Function::get_string 2.46 ns 2.46 ns 285086595 +bm_rtl::method_calls______Method::get_string 2.88 ns 2.88 ns 242840494 + +bm_rtl::function__ErasedReturnType::get_string 14.9 ns 14.9 ns 46919301 +bm_rtl::method____ErasedReturnType::get_string 15.0 ns 15.0 ns 45689265 +bm_rtl::method____ErasedTargetType::get_string 5.87 ns 5.88 ns 119688015 +bm_rtl::method____ErasedTargetAndReturnType::get_string 16.3 ns 16.3 ns 43375628 +----------------------------------- +[2025-11-04 11:30:06] >>> Run 1: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-11-04T11:30:06+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 0.47, 0.18 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 14.5 ns 14.5 ns 48242791 + +bm_call::via_function_ptr__Function::set_string 14.6 ns 14.6 ns 47568680 +bm_call::via_function_ptr____Method::set_string 14.5 ns 14.5 ns 48746560 + +bm_std::function_calls__Function::set_string 14.4 ns 14.4 ns 48361996 +bm_std::function_calls____Method::set_string 14.7 ns 14.7 ns 47229848 + +bm_rtl::function_calls__Function::set_string 14.3 ns 14.3 ns 47864234 +bm_rtl::method_calls______Method::set_string 15.0 ns 15.0 ns 46668705 + +bm_rtl::function__ErasedReturnType::set_string 16.8 ns 16.8 ns 41584347 +bm_rtl::method____ErasedReturnType::set_string 17.0 ns 17.0 ns 41277560 +bm_rtl::method____ErasedTargetType::set_string 17.9 ns 17.9 ns 38831295 +bm_rtl::method____ErasedTargetAndReturnType::set_string 18.1 ns 18.1 ns 38521566 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 21.4 ns 21.4 ns 32748201 + +bm_call::via_function_ptr__Function::get_string 21.7 ns 21.7 ns 32229019 +bm_call::via_function_ptr____Method::get_string 21.8 ns 21.8 ns 32216795 + +bm_std::function_calls__Function::get_string 21.8 ns 21.8 ns 32016965 +bm_std::function_calls____Method::get_string 21.7 ns 21.7 ns 32038907 + +bm_rtl::function_calls__Function::get_string 21.7 ns 21.7 ns 32075981 +bm_rtl::method_calls______Method::get_string 21.8 ns 21.8 ns 32139933 + +bm_rtl::function__ErasedReturnType::get_string 34.3 ns 34.3 ns 20292635 +bm_rtl::method____ErasedReturnType::get_string 35.5 ns 35.5 ns 19832365 +bm_rtl::method____ErasedTargetType::get_string 24.2 ns 24.2 ns 29003990 +bm_rtl::method____ErasedTargetAndReturnType::get_string 35.8 ns 35.8 ns 19482072 +----------------------------------- +[2025-11-04 11:30:27] >>> Run 2: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-11-04T11:30:27+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 0.51, 0.20 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 14.5 ns 14.5 ns 48600272 + +bm_call::via_function_ptr__Function::set_string 14.4 ns 14.4 ns 47262841 +bm_call::via_function_ptr____Method::set_string 14.7 ns 14.7 ns 47560475 + +bm_std::function_calls__Function::set_string 14.7 ns 14.7 ns 46778629 +bm_std::function_calls____Method::set_string 15.0 ns 15.0 ns 46225572 + +bm_rtl::function_calls__Function::set_string 14.4 ns 14.4 ns 47934169 +bm_rtl::method_calls______Method::set_string 15.0 ns 15.0 ns 46326371 + +bm_rtl::function__ErasedReturnType::set_string 16.7 ns 16.7 ns 41965256 +bm_rtl::method____ErasedReturnType::set_string 17.2 ns 17.2 ns 41096893 +bm_rtl::method____ErasedTargetType::set_string 17.5 ns 17.5 ns 40225175 +bm_rtl::method____ErasedTargetAndReturnType::set_string 18.1 ns 18.1 ns 38566575 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 21.1 ns 21.2 ns 32955668 + +bm_call::via_function_ptr__Function::get_string 21.2 ns 21.2 ns 33076981 +bm_call::via_function_ptr____Method::get_string 21.4 ns 21.4 ns 32585058 + +bm_std::function_calls__Function::get_string 21.3 ns 21.3 ns 32772706 +bm_std::function_calls____Method::get_string 22.2 ns 22.2 ns 31420316 + +bm_rtl::function_calls__Function::get_string 21.2 ns 21.2 ns 33089599 +bm_rtl::method_calls______Method::get_string 21.6 ns 21.6 ns 32466374 + +bm_rtl::function__ErasedReturnType::get_string 34.2 ns 34.2 ns 20325951 +bm_rtl::method____ErasedReturnType::get_string 35.1 ns 35.1 ns 19870274 +bm_rtl::method____ErasedTargetType::get_string 24.3 ns 24.3 ns 29128625 +bm_rtl::method____ErasedTargetAndReturnType::get_string 36.0 ns 36.0 ns 19558210 +----------------------------------- +[2025-11-04 11:30:47] >>> Run 3: workload scale = 1 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 1 iterations +============================================= + +2025-11-04T11:30:47+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 0.55, 0.22 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 24.0 ns 24.0 ns 29170635 + +bm_call::via_function_ptr__Function::set_string 23.5 ns 23.5 ns 29738969 +bm_call::via_function_ptr____Method::set_string 23.7 ns 23.7 ns 29340017 + +bm_std::function_calls__Function::set_string 23.7 ns 23.7 ns 29670419 +bm_std::function_calls____Method::set_string 15.2 ns 15.2 ns 46003960 + +bm_rtl::function_calls__Function::set_string 23.5 ns 23.5 ns 29709584 +bm_rtl::method_calls______Method::set_string 23.8 ns 23.8 ns 29608054 + +bm_rtl::function__ErasedReturnType::set_string 20.2 ns 20.2 ns 34607217 +bm_rtl::method____ErasedReturnType::set_string 20.3 ns 20.3 ns 34461009 +bm_rtl::method____ErasedTargetType::set_string 26.1 ns 26.1 ns 26810310 +bm_rtl::method____ErasedTargetAndReturnType::set_string 26.1 ns 26.1 ns 26832712 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 32.8 ns 32.8 ns 21350792 + +bm_call::via_function_ptr__Function::get_string 32.4 ns 32.4 ns 21599677 +bm_call::via_function_ptr____Method::get_string 32.6 ns 32.6 ns 21499549 + +bm_std::function_calls__Function::get_string 32.6 ns 32.6 ns 21435275 +bm_std::function_calls____Method::get_string 26.5 ns 26.5 ns 26588723 + +bm_rtl::function_calls__Function::get_string 32.4 ns 32.4 ns 21569659 +bm_rtl::method_calls______Method::get_string 32.6 ns 32.6 ns 21481163 + +bm_rtl::function__ErasedReturnType::get_string 35.0 ns 35.0 ns 20082606 +bm_rtl::method____ErasedReturnType::get_string 45.6 ns 45.6 ns 15272559 +bm_rtl::method____ErasedTargetType::get_string 32.7 ns 32.7 ns 21388794 +bm_rtl::method____ErasedTargetAndReturnType::get_string 37.5 ns 37.5 ns 18706136 +----------------------------------- +[2025-11-04 11:31:10] >>> Run 1: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-11-04T11:31:10+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 0.58, 0.24 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 93.8 ns 93.8 ns 7417031 + +bm_call::via_function_ptr__Function::set_string 94.0 ns 94.0 ns 7452008 +bm_call::via_function_ptr____Method::set_string 93.8 ns 93.8 ns 7473913 + +bm_std::function_calls__Function::set_string 94.1 ns 94.1 ns 7465042 +bm_std::function_calls____Method::set_string 94.1 ns 94.1 ns 7427433 + +bm_rtl::function_calls__Function::set_string 93.9 ns 93.9 ns 7491989 +bm_rtl::method_calls______Method::set_string 94.3 ns 94.3 ns 7440296 + +bm_rtl::function__ErasedReturnType::set_string 95.6 ns 95.6 ns 7316655 +bm_rtl::method____ErasedReturnType::set_string 96.8 ns 96.8 ns 7149766 +bm_rtl::method____ErasedTargetType::set_string 97.4 ns 97.4 ns 7189451 +bm_rtl::method____ErasedTargetAndReturnType::set_string 103 ns 103 ns 6771417 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 115 ns 116 ns 6045433 + +bm_call::via_function_ptr__Function::get_string 115 ns 115 ns 6052590 +bm_call::via_function_ptr____Method::get_string 115 ns 115 ns 6090268 + +bm_std::function_calls__Function::get_string 115 ns 115 ns 6074354 +bm_std::function_calls____Method::get_string 115 ns 115 ns 6102339 + +bm_rtl::function_calls__Function::get_string 115 ns 115 ns 6077686 +bm_rtl::method_calls______Method::get_string 115 ns 115 ns 6086147 + +bm_rtl::function__ErasedReturnType::get_string 125 ns 125 ns 5583022 +bm_rtl::method____ErasedReturnType::get_string 125 ns 125 ns 5606210 +bm_rtl::method____ErasedTargetType::get_string 116 ns 116 ns 6030406 +bm_rtl::method____ErasedTargetAndReturnType::get_string 127 ns 127 ns 5496168 +----------------------------------- +[2025-11-04 11:31:28] >>> Run 2: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-11-04T11:31:28+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 0.61, 0.26 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 93.9 ns 93.9 ns 7413892 + +bm_call::via_function_ptr__Function::set_string 93.6 ns 93.6 ns 7458233 +bm_call::via_function_ptr____Method::set_string 93.6 ns 93.6 ns 7470144 + +bm_std::function_calls__Function::set_string 93.7 ns 93.7 ns 7426724 +bm_std::function_calls____Method::set_string 94.1 ns 94.1 ns 7412709 + +bm_rtl::function_calls__Function::set_string 93.7 ns 93.7 ns 7485217 +bm_rtl::method_calls______Method::set_string 94.1 ns 94.1 ns 7455729 + +bm_rtl::function__ErasedReturnType::set_string 95.7 ns 95.7 ns 7312618 +bm_rtl::method____ErasedReturnType::set_string 96.7 ns 96.7 ns 7219262 +bm_rtl::method____ErasedTargetType::set_string 97.6 ns 97.6 ns 7145010 +bm_rtl::method____ErasedTargetAndReturnType::set_string 103 ns 103 ns 6807671 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 116 ns 116 ns 6072780 + +bm_call::via_function_ptr__Function::get_string 115 ns 115 ns 6034419 +bm_call::via_function_ptr____Method::get_string 115 ns 115 ns 6080424 + +bm_std::function_calls__Function::get_string 115 ns 115 ns 6047388 +bm_std::function_calls____Method::get_string 115 ns 115 ns 6093462 + +bm_rtl::function_calls__Function::get_string 115 ns 115 ns 6097576 +bm_rtl::method_calls______Method::get_string 115 ns 115 ns 6098871 + +bm_rtl::function__ErasedReturnType::get_string 125 ns 125 ns 5597537 +bm_rtl::method____ErasedReturnType::get_string 126 ns 126 ns 5581065 +bm_rtl::method____ErasedTargetType::get_string 116 ns 116 ns 6036900 +bm_rtl::method____ErasedTargetAndReturnType::get_string 127 ns 127 ns 5516757 +----------------------------------- +[2025-11-04 11:31:46] >>> Run 3: workload scale = 5 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 5 iterations +============================================= + +2025-11-04T11:31:46+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 0.63, 0.27 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 94.4 ns 94.4 ns 7268124 + +bm_call::via_function_ptr__Function::set_string 94.2 ns 94.2 ns 7461840 +bm_call::via_function_ptr____Method::set_string 94.2 ns 94.2 ns 7427933 + +bm_std::function_calls__Function::set_string 94.5 ns 94.5 ns 7422218 +bm_std::function_calls____Method::set_string 94.6 ns 94.6 ns 7430982 + +bm_rtl::function_calls__Function::set_string 94.5 ns 94.5 ns 7430754 +bm_rtl::method_calls______Method::set_string 94.7 ns 94.8 ns 7407535 + +bm_rtl::function__ErasedReturnType::set_string 96.1 ns 96.1 ns 7196656 +bm_rtl::method____ErasedReturnType::set_string 96.9 ns 96.9 ns 7211863 +bm_rtl::method____ErasedTargetType::set_string 97.0 ns 97.0 ns 7195465 +bm_rtl::method____ErasedTargetAndReturnType::set_string 102 ns 102 ns 6818975 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 115 ns 115 ns 6065805 + +bm_call::via_function_ptr__Function::get_string 115 ns 115 ns 6096645 +bm_call::via_function_ptr____Method::get_string 115 ns 115 ns 6071541 + +bm_std::function_calls__Function::get_string 116 ns 116 ns 6047175 +bm_std::function_calls____Method::get_string 115 ns 115 ns 6060394 + +bm_rtl::function_calls__Function::get_string 115 ns 115 ns 6075944 +bm_rtl::method_calls______Method::get_string 115 ns 115 ns 6079330 + +bm_rtl::function__ErasedReturnType::get_string 125 ns 125 ns 5584045 +bm_rtl::method____ErasedReturnType::get_string 126 ns 126 ns 5557081 +bm_rtl::method____ErasedTargetType::get_string 117 ns 117 ns 5989672 +bm_rtl::method____ErasedTargetAndReturnType::get_string 128 ns 128 ns 5499308 +----------------------------------- +[2025-11-04 11:32:04] >>> Run 1: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-11-04T11:32:04+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.65, 0.29 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 161 ns 161 ns 4332878 + +bm_call::via_function_ptr__Function::set_string 161 ns 161 ns 4416633 +bm_call::via_function_ptr____Method::set_string 160 ns 160 ns 4399361 + +bm_std::function_calls__Function::set_string 161 ns 161 ns 4305144 +bm_std::function_calls____Method::set_string 161 ns 161 ns 4342427 + +bm_rtl::function_calls__Function::set_string 161 ns 161 ns 4357679 +bm_rtl::method_calls______Method::set_string 160 ns 160 ns 4336485 + +bm_rtl::function__ErasedReturnType::set_string 164 ns 164 ns 4290751 +bm_rtl::method____ErasedReturnType::set_string 164 ns 164 ns 4305488 +bm_rtl::method____ErasedTargetType::set_string 165 ns 165 ns 4271135 +bm_rtl::method____ErasedTargetAndReturnType::set_string 171 ns 171 ns 4087737 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 209 ns 209 ns 3342955 + +bm_call::via_function_ptr__Function::get_string 210 ns 210 ns 3341236 +bm_call::via_function_ptr____Method::get_string 209 ns 209 ns 3340519 + +bm_std::function_calls__Function::get_string 209 ns 209 ns 3329193 +bm_std::function_calls____Method::get_string 209 ns 209 ns 3334552 + +bm_rtl::function_calls__Function::get_string 210 ns 210 ns 3341471 +bm_rtl::method_calls______Method::get_string 210 ns 210 ns 3317212 + +bm_rtl::function__ErasedReturnType::get_string 217 ns 217 ns 3257317 +bm_rtl::method____ErasedReturnType::get_string 218 ns 218 ns 3238960 +bm_rtl::method____ErasedTargetType::get_string 212 ns 212 ns 3304550 +bm_rtl::method____ErasedTargetAndReturnType::get_string 218 ns 218 ns 3228561 +----------------------------------- +[2025-11-04 11:32:24] >>> Run 2: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-11-04T11:32:24+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2413.91 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.67, 0.30 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 163 ns 163 ns 4302963 + +bm_call::via_function_ptr__Function::set_string 164 ns 164 ns 4290635 +bm_call::via_function_ptr____Method::set_string 164 ns 164 ns 4255706 + +bm_std::function_calls__Function::set_string 163 ns 163 ns 4297600 +bm_std::function_calls____Method::set_string 163 ns 163 ns 4369051 + +bm_rtl::function_calls__Function::set_string 163 ns 163 ns 4271991 +bm_rtl::method_calls______Method::set_string 163 ns 163 ns 4317493 + +bm_rtl::function__ErasedReturnType::set_string 165 ns 165 ns 4257845 +bm_rtl::method____ErasedReturnType::set_string 164 ns 164 ns 4253764 +bm_rtl::method____ErasedTargetType::set_string 167 ns 167 ns 4215960 +bm_rtl::method____ErasedTargetAndReturnType::set_string 173 ns 173 ns 4066978 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 211 ns 211 ns 3342799 + +bm_call::via_function_ptr__Function::get_string 210 ns 210 ns 3344684 +bm_call::via_function_ptr____Method::get_string 212 ns 212 ns 3308560 + +bm_std::function_calls__Function::get_string 211 ns 211 ns 3330519 +bm_std::function_calls____Method::get_string 211 ns 211 ns 3300133 + +bm_rtl::function_calls__Function::get_string 211 ns 211 ns 3302953 +bm_rtl::method_calls______Method::get_string 212 ns 212 ns 3298514 + +bm_rtl::function__ErasedReturnType::get_string 218 ns 218 ns 3215137 +bm_rtl::method____ErasedReturnType::get_string 219 ns 219 ns 3201579 +bm_rtl::method____ErasedTargetType::get_string 214 ns 214 ns 3298595 +bm_rtl::method____ErasedTargetAndReturnType::get_string 219 ns 219 ns 3203336 +----------------------------------- +[2025-11-04 11:32:44] >>> Run 3: workload scale = 10 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 10 iterations +============================================= + +2025-11-04T11:32:44+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4877.87 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.70, 0.32 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 162 ns 162 ns 4338121 + +bm_call::via_function_ptr__Function::set_string 163 ns 163 ns 4377872 +bm_call::via_function_ptr____Method::set_string 161 ns 161 ns 4352982 + +bm_std::function_calls__Function::set_string 161 ns 161 ns 4421243 +bm_std::function_calls____Method::set_string 161 ns 161 ns 4359250 + +bm_rtl::function_calls__Function::set_string 161 ns 161 ns 4315918 +bm_rtl::method_calls______Method::set_string 161 ns 161 ns 4328071 + +bm_rtl::function__ErasedReturnType::set_string 164 ns 164 ns 4284932 +bm_rtl::method____ErasedReturnType::set_string 164 ns 164 ns 4272614 +bm_rtl::method____ErasedTargetType::set_string 165 ns 165 ns 4233649 +bm_rtl::method____ErasedTargetAndReturnType::set_string 171 ns 171 ns 4102406 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 209 ns 209 ns 3346131 + +bm_call::via_function_ptr__Function::get_string 210 ns 210 ns 3324956 +bm_call::via_function_ptr____Method::get_string 211 ns 211 ns 3317701 + +bm_std::function_calls__Function::get_string 210 ns 210 ns 3332691 +bm_std::function_calls____Method::get_string 210 ns 210 ns 3329162 + +bm_rtl::function_calls__Function::get_string 209 ns 209 ns 3294911 +bm_rtl::method_calls______Method::get_string 211 ns 211 ns 3331679 + +bm_rtl::function__ErasedReturnType::get_string 215 ns 216 ns 3244227 +bm_rtl::method____ErasedReturnType::get_string 216 ns 216 ns 3251398 +bm_rtl::method____ErasedTargetType::get_string 210 ns 210 ns 3351688 +bm_rtl::method____ErasedTargetAndReturnType::get_string 216 ns 216 ns 3247038 +----------------------------------- +[2025-11-04 11:33:04] >>> Run 1: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-11-04T11:33:04+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.72, 0.33 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 194 ns 194 ns 3624354 + +bm_call::via_function_ptr__Function::set_string 194 ns 194 ns 3627036 +bm_call::via_function_ptr____Method::set_string 195 ns 195 ns 3601256 + +bm_std::function_calls__Function::set_string 194 ns 194 ns 3589830 +bm_std::function_calls____Method::set_string 194 ns 194 ns 3637376 + +bm_rtl::function_calls__Function::set_string 194 ns 194 ns 3638687 +bm_rtl::method_calls______Method::set_string 195 ns 195 ns 3599993 + +bm_rtl::function__ErasedReturnType::set_string 196 ns 196 ns 3578184 +bm_rtl::method____ErasedReturnType::set_string 197 ns 197 ns 3547623 +bm_rtl::method____ErasedTargetType::set_string 198 ns 198 ns 3539370 +bm_rtl::method____ErasedTargetAndReturnType::set_string 203 ns 203 ns 3430347 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 271 ns 271 ns 2477136 + +bm_call::via_function_ptr__Function::get_string 254 ns 254 ns 2745060 +bm_call::via_function_ptr____Method::get_string 253 ns 253 ns 2760175 + +bm_std::function_calls__Function::get_string 253 ns 253 ns 2742774 +bm_std::function_calls____Method::get_string 253 ns 253 ns 2748295 + +bm_rtl::function_calls__Function::get_string 252 ns 252 ns 2791858 +bm_rtl::method_calls______Method::get_string 252 ns 252 ns 2745882 + +bm_rtl::function__ErasedReturnType::get_string 258 ns 258 ns 2714931 +bm_rtl::method____ErasedReturnType::get_string 259 ns 259 ns 2686641 +bm_rtl::method____ErasedTargetType::get_string 252 ns 252 ns 2771666 +bm_rtl::method____ErasedTargetAndReturnType::get_string 260 ns 260 ns 2687541 +----------------------------------- +[2025-11-04 11:33:25] >>> Run 2: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-11-04T11:33:25+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 799.812 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.74, 0.35 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 211 ns 211 ns 3320178 + +bm_call::via_function_ptr__Function::set_string 212 ns 212 ns 3321160 +bm_call::via_function_ptr____Method::set_string 211 ns 211 ns 3335082 + +bm_std::function_calls__Function::set_string 212 ns 212 ns 3308055 +bm_std::function_calls____Method::set_string 211 ns 211 ns 3304941 + +bm_rtl::function_calls__Function::set_string 212 ns 212 ns 3304781 +bm_rtl::method_calls______Method::set_string 213 ns 213 ns 3303226 + +bm_rtl::function__ErasedReturnType::set_string 214 ns 214 ns 3258122 +bm_rtl::method____ErasedReturnType::set_string 214 ns 214 ns 3264878 +bm_rtl::method____ErasedTargetType::set_string 216 ns 216 ns 3251560 +bm_rtl::method____ErasedTargetAndReturnType::set_string 218 ns 218 ns 3207293 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 293 ns 293 ns 2384492 + +bm_call::via_function_ptr__Function::get_string 293 ns 293 ns 2407150 +bm_call::via_function_ptr____Method::get_string 294 ns 294 ns 2380693 + +bm_std::function_calls__Function::get_string 295 ns 295 ns 2398510 +bm_std::function_calls____Method::get_string 292 ns 292 ns 2407469 + +bm_rtl::function_calls__Function::get_string 293 ns 293 ns 2396622 +bm_rtl::method_calls______Method::get_string 292 ns 292 ns 2398263 + +bm_rtl::function__ErasedReturnType::get_string 297 ns 297 ns 2353980 +bm_rtl::method____ErasedReturnType::get_string 299 ns 299 ns 2337886 +bm_rtl::method____ErasedTargetType::get_string 295 ns 295 ns 2380052 +bm_rtl::method____ErasedTargetAndReturnType::get_string 302 ns 302 ns 2319651 +----------------------------------- +[2025-11-04 11:33:46] >>> Run 3: workload scale = 15 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 15 iterations +============================================= + +2025-11-04T11:33:46+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 0.77, 0.37 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 194 ns 194 ns 3620973 + +bm_call::via_function_ptr__Function::set_string 193 ns 193 ns 3638599 +bm_call::via_function_ptr____Method::set_string 193 ns 193 ns 3638008 + +bm_std::function_calls__Function::set_string 194 ns 194 ns 3628619 +bm_std::function_calls____Method::set_string 194 ns 194 ns 3577027 + +bm_rtl::function_calls__Function::set_string 194 ns 194 ns 3633217 +bm_rtl::method_calls______Method::set_string 195 ns 195 ns 3607754 + +bm_rtl::function__ErasedReturnType::set_string 194 ns 194 ns 3603029 +bm_rtl::method____ErasedReturnType::set_string 196 ns 196 ns 3592022 +bm_rtl::method____ErasedTargetType::set_string 197 ns 197 ns 3535375 +bm_rtl::method____ErasedTargetAndReturnType::set_string 203 ns 203 ns 3455803 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 251 ns 251 ns 2770899 + +bm_call::via_function_ptr__Function::get_string 252 ns 252 ns 2787847 +bm_call::via_function_ptr____Method::get_string 255 ns 255 ns 2794390 + +bm_std::function_calls__Function::get_string 252 ns 252 ns 2783053 +bm_std::function_calls____Method::get_string 254 ns 254 ns 2762588 + +bm_rtl::function_calls__Function::get_string 251 ns 251 ns 2750173 +bm_rtl::method_calls______Method::get_string 254 ns 254 ns 2780142 + +bm_rtl::function__ErasedReturnType::get_string 258 ns 258 ns 2713804 +bm_rtl::method____ErasedReturnType::get_string 259 ns 259 ns 2681868 +bm_rtl::method____ErasedTargetType::get_string 254 ns 254 ns 2774394 +bm_rtl::method____ErasedTargetAndReturnType::get_string 260 ns 260 ns 2703368 +----------------------------------- +[2025-11-04 11:34:07] >>> Run 1: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-11-04T11:34:07+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 0.79, 0.38 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 306 ns 306 ns 2290492 + +bm_call::via_function_ptr__Function::set_string 311 ns 311 ns 2241247 +bm_call::via_function_ptr____Method::set_string 313 ns 313 ns 2234098 + +bm_std::function_calls__Function::set_string 312 ns 312 ns 2234676 +bm_std::function_calls____Method::set_string 312 ns 312 ns 2241612 + +bm_rtl::function_calls__Function::set_string 312 ns 312 ns 2253856 +bm_rtl::method_calls______Method::set_string 313 ns 313 ns 2228407 + +bm_rtl::function__ErasedReturnType::set_string 308 ns 308 ns 2261970 +bm_rtl::method____ErasedReturnType::set_string 312 ns 312 ns 2245957 +bm_rtl::method____ErasedTargetType::set_string 311 ns 311 ns 2213517 +bm_rtl::method____ErasedTargetAndReturnType::set_string 314 ns 314 ns 2241483 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 443 ns 443 ns 1581839 + +bm_call::via_function_ptr__Function::get_string 451 ns 451 ns 1548794 +bm_call::via_function_ptr____Method::get_string 452 ns 452 ns 1550466 + +bm_std::function_calls__Function::get_string 452 ns 452 ns 1550969 +bm_std::function_calls____Method::get_string 447 ns 447 ns 1563335 + +bm_rtl::function_calls__Function::get_string 452 ns 452 ns 1551478 +bm_rtl::method_calls______Method::get_string 452 ns 452 ns 1548665 + +bm_rtl::function__ErasedReturnType::get_string 459 ns 459 ns 1528761 +bm_rtl::method____ErasedReturnType::get_string 459 ns 459 ns 1522846 +bm_rtl::method____ErasedTargetType::get_string 449 ns 449 ns 1559946 +bm_rtl::method____ErasedTargetAndReturnType::get_string 468 ns 468 ns 1496384 +----------------------------------- +[2025-11-04 11:34:32] >>> Run 2: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-11-04T11:34:32+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 0.80, 0.40 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 272 ns 272 ns 2558705 + +bm_call::via_function_ptr__Function::set_string 272 ns 272 ns 2566816 +bm_call::via_function_ptr____Method::set_string 273 ns 273 ns 2560637 + +bm_std::function_calls__Function::set_string 270 ns 270 ns 2573221 +bm_std::function_calls____Method::set_string 273 ns 273 ns 2573250 + +bm_rtl::function_calls__Function::set_string 272 ns 272 ns 2575772 +bm_rtl::method_calls______Method::set_string 274 ns 274 ns 2567684 + +bm_rtl::function__ErasedReturnType::set_string 276 ns 276 ns 2525378 +bm_rtl::method____ErasedReturnType::set_string 277 ns 277 ns 2554199 +bm_rtl::method____ErasedTargetType::set_string 275 ns 275 ns 2561448 +bm_rtl::method____ErasedTargetAndReturnType::set_string 282 ns 282 ns 2483219 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 381 ns 381 ns 1842934 + +bm_call::via_function_ptr__Function::get_string 386 ns 386 ns 1819888 +bm_call::via_function_ptr____Method::get_string 384 ns 384 ns 1818988 + +bm_std::function_calls__Function::get_string 385 ns 385 ns 1814239 +bm_std::function_calls____Method::get_string 386 ns 386 ns 1810637 + +bm_rtl::function_calls__Function::get_string 385 ns 385 ns 1821229 +bm_rtl::method_calls______Method::get_string 387 ns 387 ns 1815740 + +bm_rtl::function__ErasedReturnType::get_string 401 ns 401 ns 1742383 +bm_rtl::method____ErasedReturnType::get_string 402 ns 402 ns 1744796 +bm_rtl::method____ErasedTargetType::get_string 391 ns 391 ns 1786914 +bm_rtl::method____ErasedTargetAndReturnType::get_string 402 ns 403 ns 1734389 +----------------------------------- +[2025-11-04 11:34:55] >>> Run 3: workload scale = 20 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 20 iterations +============================================= + +2025-11-04T11:34:55+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1003.07 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 0.82, 0.42 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 273 ns 273 ns 2555885 + +bm_call::via_function_ptr__Function::set_string 273 ns 273 ns 2520891 +bm_call::via_function_ptr____Method::set_string 273 ns 273 ns 2549459 + +bm_std::function_calls__Function::set_string 273 ns 273 ns 2576378 +bm_std::function_calls____Method::set_string 273 ns 273 ns 2571194 + +bm_rtl::function_calls__Function::set_string 274 ns 274 ns 2506842 +bm_rtl::method_calls______Method::set_string 274 ns 274 ns 2574283 + +bm_rtl::function__ErasedReturnType::set_string 278 ns 278 ns 2531104 +bm_rtl::method____ErasedReturnType::set_string 275 ns 275 ns 2543654 +bm_rtl::method____ErasedTargetType::set_string 274 ns 274 ns 2532744 +bm_rtl::method____ErasedTargetAndReturnType::set_string 284 ns 284 ns 2459606 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 384 ns 384 ns 1816058 + +bm_call::via_function_ptr__Function::get_string 388 ns 388 ns 1807084 +bm_call::via_function_ptr____Method::get_string 388 ns 388 ns 1802275 + +bm_std::function_calls__Function::get_string 386 ns 386 ns 1800274 +bm_std::function_calls____Method::get_string 387 ns 387 ns 1809751 + +bm_rtl::function_calls__Function::get_string 388 ns 388 ns 1809043 +bm_rtl::method_calls______Method::get_string 388 ns 388 ns 1807297 + +bm_rtl::function__ErasedReturnType::get_string 403 ns 403 ns 1733679 +bm_rtl::method____ErasedReturnType::get_string 402 ns 402 ns 1738530 +bm_rtl::method____ErasedTargetType::get_string 392 ns 392 ns 1778195 +bm_rtl::method____ErasedTargetAndReturnType::get_string 404 ns 404 ns 1736458 +----------------------------------- +[2025-11-04 11:35:19] >>> Run 1: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-11-04T11:35:19+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 0.84, 0.43 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 308 ns 308 ns 2289455 + +bm_call::via_function_ptr__Function::set_string 308 ns 308 ns 2295086 +bm_call::via_function_ptr____Method::set_string 305 ns 305 ns 2282996 + +bm_std::function_calls__Function::set_string 306 ns 306 ns 2287656 +bm_std::function_calls____Method::set_string 305 ns 305 ns 2290493 + +bm_rtl::function_calls__Function::set_string 306 ns 306 ns 2293649 +bm_rtl::method_calls______Method::set_string 308 ns 308 ns 2263061 + +bm_rtl::function__ErasedReturnType::set_string 310 ns 310 ns 2270433 +bm_rtl::method____ErasedReturnType::set_string 322 ns 322 ns 2184471 +bm_rtl::method____ErasedTargetType::set_string 311 ns 311 ns 2252261 +bm_rtl::method____ErasedTargetAndReturnType::set_string 318 ns 318 ns 2177221 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 449 ns 449 ns 1556063 + +bm_call::via_function_ptr__Function::get_string 449 ns 449 ns 1558473 +bm_call::via_function_ptr____Method::get_string 450 ns 450 ns 1553390 + +bm_std::function_calls__Function::get_string 451 ns 451 ns 1557283 +bm_std::function_calls____Method::get_string 452 ns 452 ns 1544521 + +bm_rtl::function_calls__Function::get_string 451 ns 451 ns 1549646 +bm_rtl::method_calls______Method::get_string 450 ns 450 ns 1547760 + +bm_rtl::function__ErasedReturnType::get_string 468 ns 468 ns 1489242 +bm_rtl::method____ErasedReturnType::get_string 469 ns 469 ns 1493530 +bm_rtl::method____ErasedTargetType::get_string 457 ns 457 ns 1534035 +bm_rtl::method____ErasedTargetAndReturnType::get_string 471 ns 471 ns 1482462 +----------------------------------- +[2025-11-04 11:35:44] >>> Run 2: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-11-04T11:35:44+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 0.85, 0.45 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 310 ns 310 ns 2249513 + +bm_call::via_function_ptr__Function::set_string 309 ns 309 ns 2268930 +bm_call::via_function_ptr____Method::set_string 311 ns 311 ns 2250980 + +bm_std::function_calls__Function::set_string 310 ns 310 ns 2266376 +bm_std::function_calls____Method::set_string 310 ns 310 ns 2268158 + +bm_rtl::function_calls__Function::set_string 312 ns 312 ns 2263713 +bm_rtl::method_calls______Method::set_string 310 ns 310 ns 2262103 + +bm_rtl::function__ErasedReturnType::set_string 315 ns 315 ns 2229881 +bm_rtl::method____ErasedReturnType::set_string 315 ns 315 ns 2221153 +bm_rtl::method____ErasedTargetType::set_string 311 ns 311 ns 2246314 +bm_rtl::method____ErasedTargetAndReturnType::set_string 321 ns 321 ns 2167043 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 448 ns 448 ns 1561857 + +bm_call::via_function_ptr__Function::get_string 448 ns 448 ns 1559884 +bm_call::via_function_ptr____Method::get_string 450 ns 450 ns 1556156 + +bm_std::function_calls__Function::get_string 447 ns 447 ns 1561230 +bm_std::function_calls____Method::get_string 451 ns 451 ns 1549786 + +bm_rtl::function_calls__Function::get_string 448 ns 448 ns 1563251 +bm_rtl::method_calls______Method::get_string 450 ns 450 ns 1554882 + +bm_rtl::function__ErasedReturnType::get_string 468 ns 468 ns 1495466 +bm_rtl::method____ErasedReturnType::get_string 468 ns 468 ns 1496289 +bm_rtl::method____ErasedTargetType::get_string 456 ns 456 ns 1536797 +bm_rtl::method____ErasedTargetAndReturnType::get_string 470 ns 470 ns 1492470 +----------------------------------- +[2025-11-04 11:36:08] >>> Run 3: workload scale = 25 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 25 iterations +============================================= + +2025-11-04T11:36:08+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.86, 0.47 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 339 ns 339 ns 2075571 + +bm_call::via_function_ptr__Function::set_string 339 ns 339 ns 2066316 +bm_call::via_function_ptr____Method::set_string 339 ns 339 ns 2068331 + +bm_std::function_calls__Function::set_string 339 ns 339 ns 2063704 +bm_std::function_calls____Method::set_string 340 ns 340 ns 2055163 + +bm_rtl::function_calls__Function::set_string 339 ns 339 ns 2070474 +bm_rtl::method_calls______Method::set_string 338 ns 338 ns 2054751 + +bm_rtl::function__ErasedReturnType::set_string 342 ns 342 ns 2041861 +bm_rtl::method____ErasedReturnType::set_string 344 ns 344 ns 2032415 +bm_rtl::method____ErasedTargetType::set_string 344 ns 344 ns 2041850 +bm_rtl::method____ErasedTargetAndReturnType::set_string 346 ns 346 ns 2021772 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 508 ns 508 ns 1375311 + +bm_call::via_function_ptr__Function::get_string 508 ns 508 ns 1377949 +bm_call::via_function_ptr____Method::get_string 508 ns 508 ns 1376675 + +bm_std::function_calls__Function::get_string 509 ns 509 ns 1381695 +bm_std::function_calls____Method::get_string 509 ns 509 ns 1372143 + +bm_rtl::function_calls__Function::get_string 506 ns 507 ns 1370074 +bm_rtl::method_calls______Method::get_string 509 ns 509 ns 1374760 + +bm_rtl::function__ErasedReturnType::get_string 526 ns 526 ns 1335483 +bm_rtl::method____ErasedReturnType::get_string 524 ns 524 ns 1334099 +bm_rtl::method____ErasedTargetType::get_string 516 ns 516 ns 1364756 +bm_rtl::method____ErasedTargetAndReturnType::get_string 526 ns 526 ns 1332934 +----------------------------------- +[2025-11-04 11:36:29] >>> Run 1: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-11-04T11:36:29+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.87, 0.48 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 369 ns 369 ns 1897874 + +bm_call::via_function_ptr__Function::set_string 368 ns 368 ns 1913102 +bm_call::via_function_ptr____Method::set_string 369 ns 369 ns 1901147 + +bm_std::function_calls__Function::set_string 367 ns 367 ns 1908243 +bm_std::function_calls____Method::set_string 370 ns 370 ns 1882990 + +bm_rtl::function_calls__Function::set_string 367 ns 367 ns 1889567 +bm_rtl::method_calls______Method::set_string 367 ns 367 ns 1903609 + +bm_rtl::function__ErasedReturnType::set_string 376 ns 376 ns 1862890 +bm_rtl::method____ErasedReturnType::set_string 375 ns 375 ns 1858506 +bm_rtl::method____ErasedTargetType::set_string 380 ns 380 ns 1850619 +bm_rtl::method____ErasedTargetAndReturnType::set_string 385 ns 385 ns 1836768 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 524 ns 524 ns 1338003 + +bm_call::via_function_ptr__Function::get_string 525 ns 525 ns 1334577 +bm_call::via_function_ptr____Method::get_string 528 ns 528 ns 1335001 + +bm_std::function_calls__Function::get_string 526 ns 526 ns 1316735 +bm_std::function_calls____Method::get_string 533 ns 533 ns 1315542 + +bm_rtl::function_calls__Function::get_string 526 ns 526 ns 1333276 +bm_rtl::method_calls______Method::get_string 526 ns 526 ns 1342865 + +bm_rtl::function__ErasedReturnType::get_string 558 ns 558 ns 1248312 +bm_rtl::method____ErasedReturnType::get_string 558 ns 558 ns 1257303 +bm_rtl::method____ErasedTargetType::get_string 546 ns 546 ns 1288987 +bm_rtl::method____ErasedTargetAndReturnType::get_string 563 ns 563 ns 1246070 +----------------------------------- +[2025-11-04 11:36:49] >>> Run 2: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-11-04T11:36:49+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1873.5 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.88, 0.49 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 374 ns 374 ns 1879098 + +bm_call::via_function_ptr__Function::set_string 375 ns 375 ns 1876482 +bm_call::via_function_ptr____Method::set_string 375 ns 375 ns 1865772 + +bm_std::function_calls__Function::set_string 374 ns 374 ns 1878401 +bm_std::function_calls____Method::set_string 373 ns 373 ns 1886366 + +bm_rtl::function_calls__Function::set_string 374 ns 374 ns 1876114 +bm_rtl::method_calls______Method::set_string 375 ns 375 ns 1869158 + +bm_rtl::function__ErasedReturnType::set_string 397 ns 397 ns 1760547 +bm_rtl::method____ErasedReturnType::set_string 394 ns 394 ns 1778330 +bm_rtl::method____ErasedTargetType::set_string 388 ns 388 ns 1810762 +bm_rtl::method____ErasedTargetAndReturnType::set_string 403 ns 403 ns 1736610 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 525 ns 525 ns 1327945 + +bm_call::via_function_ptr__Function::get_string 529 ns 529 ns 1321273 +bm_call::via_function_ptr____Method::get_string 529 ns 530 ns 1329153 + +bm_std::function_calls__Function::get_string 528 ns 528 ns 1315558 +bm_std::function_calls____Method::get_string 532 ns 532 ns 1307079 + +bm_rtl::function_calls__Function::get_string 529 ns 529 ns 1318584 +bm_rtl::method_calls______Method::get_string 531 ns 531 ns 1310759 + +bm_rtl::function__ErasedReturnType::get_string 572 ns 572 ns 1222508 +bm_rtl::method____ErasedReturnType::get_string 566 ns 566 ns 1234666 +bm_rtl::method____ErasedTargetType::get_string 549 ns 549 ns 1271292 +bm_rtl::method____ErasedTargetAndReturnType::get_string 567 ns 567 ns 1236981 +----------------------------------- +[2025-11-04 11:37:10] >>> Run 3: workload scale = 30 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 30 iterations +============================================= + +2025-11-04T11:37:10+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4884.35 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.89, 0.50 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 373 ns 373 ns 1882535 + +bm_call::via_function_ptr__Function::set_string 370 ns 370 ns 1883841 +bm_call::via_function_ptr____Method::set_string 370 ns 370 ns 1885110 + +bm_std::function_calls__Function::set_string 368 ns 368 ns 1888699 +bm_std::function_calls____Method::set_string 373 ns 373 ns 1885554 + +bm_rtl::function_calls__Function::set_string 370 ns 370 ns 1903630 +bm_rtl::method_calls______Method::set_string 369 ns 369 ns 1891577 + +bm_rtl::function__ErasedReturnType::set_string 377 ns 377 ns 1854098 +bm_rtl::method____ErasedReturnType::set_string 378 ns 378 ns 1851962 +bm_rtl::method____ErasedTargetType::set_string 382 ns 382 ns 1839652 +bm_rtl::method____ErasedTargetAndReturnType::set_string 411 ns 411 ns 1708015 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 588 ns 588 ns 1193909 + +bm_call::via_function_ptr__Function::get_string 591 ns 591 ns 1184323 +bm_call::via_function_ptr____Method::get_string 590 ns 590 ns 1182298 + +bm_std::function_calls__Function::get_string 591 ns 591 ns 1191866 +bm_std::function_calls____Method::get_string 594 ns 594 ns 1174765 + +bm_rtl::function_calls__Function::get_string 591 ns 591 ns 1187334 +bm_rtl::method_calls______Method::get_string 590 ns 591 ns 1188320 + +bm_rtl::function__ErasedReturnType::get_string 627 ns 627 ns 1104635 +bm_rtl::method____ErasedReturnType::get_string 624 ns 624 ns 1123294 +bm_rtl::method____ErasedTargetType::get_string 612 ns 612 ns 1142836 +bm_rtl::method____ErasedTargetAndReturnType::get_string 628 ns 628 ns 1114390 +----------------------------------- +[2025-11-04 11:37:31] >>> Run 1: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-11-04T11:37:31+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4879.57 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.90, 0.51 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 737 ns 737 ns 949233 + +bm_call::via_function_ptr__Function::set_string 744 ns 744 ns 940157 +bm_call::via_function_ptr____Method::set_string 739 ns 739 ns 947272 + +bm_std::function_calls__Function::set_string 743 ns 743 ns 940579 +bm_std::function_calls____Method::set_string 750 ns 750 ns 931994 + +bm_rtl::function_calls__Function::set_string 743 ns 743 ns 942206 +bm_rtl::method_calls______Method::set_string 740 ns 739 ns 947113 + +bm_rtl::function__ErasedReturnType::set_string 751 ns 751 ns 932672 +bm_rtl::method____ErasedReturnType::set_string 753 ns 753 ns 930104 +bm_rtl::method____ErasedTargetType::set_string 758 ns 758 ns 910359 +bm_rtl::method____ErasedTargetAndReturnType::set_string 758 ns 758 ns 922853 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 941 ns 941 ns 747998 + +bm_call::via_function_ptr__Function::get_string 941 ns 941 ns 744259 +bm_call::via_function_ptr____Method::get_string 942 ns 942 ns 743961 + +bm_std::function_calls__Function::get_string 942 ns 942 ns 736240 +bm_std::function_calls____Method::get_string 948 ns 948 ns 737759 + +bm_rtl::function_calls__Function::get_string 944 ns 944 ns 742616 +bm_rtl::method_calls______Method::get_string 944 ns 944 ns 741708 + +bm_rtl::function__ErasedReturnType::get_string 977 ns 977 ns 716160 +bm_rtl::method____ErasedReturnType::get_string 982 ns 982 ns 707304 +bm_rtl::method____ErasedTargetType::get_string 968 ns 968 ns 723075 +bm_rtl::method____ErasedTargetAndReturnType::get_string 989 ns 989 ns 709624 +----------------------------------- +[2025-11-04 11:37:48] >>> Run 2: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-11-04T11:37:48+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.91, 0.53 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 696 ns 696 ns 997945 + +bm_call::via_function_ptr__Function::set_string 696 ns 696 ns 1008698 +bm_call::via_function_ptr____Method::set_string 697 ns 697 ns 1006462 + +bm_std::function_calls__Function::set_string 696 ns 696 ns 1006201 +bm_std::function_calls____Method::set_string 700 ns 700 ns 1001226 + +bm_rtl::function_calls__Function::set_string 697 ns 697 ns 1006362 +bm_rtl::method_calls______Method::set_string 697 ns 697 ns 1006337 + +bm_rtl::function__ErasedReturnType::set_string 710 ns 710 ns 988589 +bm_rtl::method____ErasedReturnType::set_string 709 ns 709 ns 984855 +bm_rtl::method____ErasedTargetType::set_string 715 ns 712 ns 981415 +bm_rtl::method____ErasedTargetAndReturnType::set_string 723 ns 719 ns 972341 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 905 ns 901 ns 777630 + +bm_call::via_function_ptr__Function::get_string 904 ns 900 ns 777827 +bm_call::via_function_ptr____Method::get_string 905 ns 901 ns 776675 + +bm_std::function_calls__Function::get_string 904 ns 900 ns 777750 +bm_std::function_calls____Method::get_string 910 ns 906 ns 772493 + +bm_rtl::function_calls__Function::get_string 903 ns 899 ns 777881 +bm_rtl::method_calls______Method::get_string 905 ns 901 ns 776797 + +bm_rtl::function__ErasedReturnType::get_string 949 ns 945 ns 739878 +bm_rtl::method____ErasedReturnType::get_string 951 ns 948 ns 738968 +bm_rtl::method____ErasedTargetType::get_string 928 ns 925 ns 757011 +bm_rtl::method____ErasedTargetAndReturnType::get_string 965 ns 962 ns 727928 +----------------------------------- +[2025-11-04 11:38:06] >>> Run 3: workload scale = 35 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 35 iterations +============================================= + +2025-11-04T11:38:06+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1390.47 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.91, 0.53 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 685 ns 682 ns 1018054 + +bm_call::via_function_ptr__Function::set_string 690 ns 687 ns 1016613 +bm_call::via_function_ptr____Method::set_string 687 ns 685 ns 1020388 + +bm_std::function_calls__Function::set_string 689 ns 686 ns 1019090 +bm_std::function_calls____Method::set_string 696 ns 694 ns 1009476 + +bm_rtl::function_calls__Function::set_string 691 ns 688 ns 1010954 +bm_rtl::method_calls______Method::set_string 688 ns 685 ns 1021430 + +bm_rtl::function__ErasedReturnType::set_string 700 ns 698 ns 1002649 +bm_rtl::method____ErasedReturnType::set_string 704 ns 702 ns 997297 +bm_rtl::method____ErasedTargetType::set_string 705 ns 702 ns 998683 +bm_rtl::method____ErasedTargetAndReturnType::set_string 711 ns 709 ns 986675 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 906 ns 903 ns 776326 + +bm_call::via_function_ptr__Function::get_string 906 ns 903 ns 774790 +bm_call::via_function_ptr____Method::get_string 906 ns 904 ns 774417 + +bm_std::function_calls__Function::get_string 906 ns 903 ns 773345 +bm_std::function_calls____Method::get_string 914 ns 912 ns 768527 + +bm_rtl::function_calls__Function::get_string 905 ns 903 ns 775225 +bm_rtl::method_calls______Method::get_string 906 ns 903 ns 775504 + +bm_rtl::function__ErasedReturnType::get_string 947 ns 945 ns 740012 +bm_rtl::method____ErasedReturnType::get_string 947 ns 944 ns 742160 +bm_rtl::method____ErasedTargetType::get_string 929 ns 926 ns 755413 +bm_rtl::method____ErasedTargetAndReturnType::get_string 953 ns 950 ns 737066 +----------------------------------- +[2025-11-04 11:38:23] >>> Run 1: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-11-04T11:38:23+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.92, 0.55 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 800 ns 799 ns 867264 + +bm_call::via_function_ptr__Function::set_string 798 ns 796 ns 880085 +bm_call::via_function_ptr____Method::set_string 799 ns 797 ns 880685 + +bm_std::function_calls__Function::set_string 797 ns 795 ns 880499 +bm_std::function_calls____Method::set_string 809 ns 807 ns 866812 + +bm_rtl::function_calls__Function::set_string 796 ns 794 ns 883223 +bm_rtl::method_calls______Method::set_string 799 ns 797 ns 876599 + +bm_rtl::function__ErasedReturnType::set_string 812 ns 810 ns 861595 +bm_rtl::method____ErasedReturnType::set_string 815 ns 813 ns 863290 +bm_rtl::method____ErasedTargetType::set_string 817 ns 815 ns 860003 +bm_rtl::method____ErasedTargetAndReturnType::set_string 825 ns 823 ns 848476 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1016 ns 1014 ns 691107 + +bm_call::via_function_ptr__Function::get_string 1018 ns 1016 ns 688866 +bm_call::via_function_ptr____Method::get_string 1017 ns 1015 ns 688426 + +bm_std::function_calls__Function::get_string 1018 ns 1016 ns 689406 +bm_std::function_calls____Method::get_string 1030 ns 1028 ns 680879 + +bm_rtl::function_calls__Function::get_string 1017 ns 1015 ns 688175 +bm_rtl::method_calls______Method::get_string 1017 ns 1016 ns 689699 + +bm_rtl::function__ErasedReturnType::get_string 1062 ns 1060 ns 660938 +bm_rtl::method____ErasedReturnType::get_string 1062 ns 1060 ns 660987 +bm_rtl::method____ErasedTargetType::get_string 1041 ns 1039 ns 674072 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1068 ns 1066 ns 655561 +----------------------------------- +[2025-11-04 11:38:41] >>> Run 2: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-11-04T11:38:41+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1231.43 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.92, 0.55 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 788 ns 786 ns 878975 + +bm_call::via_function_ptr__Function::set_string 788 ns 787 ns 886890 +bm_call::via_function_ptr____Method::set_string 789 ns 788 ns 889408 + +bm_std::function_calls__Function::set_string 790 ns 789 ns 890087 +bm_std::function_calls____Method::set_string 793 ns 792 ns 881178 + +bm_rtl::function_calls__Function::set_string 789 ns 787 ns 889915 +bm_rtl::method_calls______Method::set_string 788 ns 787 ns 885010 + +bm_rtl::function__ErasedReturnType::set_string 798 ns 797 ns 876161 +bm_rtl::method____ErasedReturnType::set_string 797 ns 796 ns 878707 +bm_rtl::method____ErasedTargetType::set_string 800 ns 799 ns 876369 +bm_rtl::method____ErasedTargetAndReturnType::set_string 807 ns 806 ns 871804 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1004 ns 1003 ns 696947 + +bm_call::via_function_ptr__Function::get_string 1058 ns 1056 ns 696943 +bm_call::via_function_ptr____Method::get_string 1058 ns 1057 ns 662406 + +bm_std::function_calls__Function::get_string 1060 ns 1059 ns 661064 +bm_std::function_calls____Method::get_string 1061 ns 1060 ns 660663 + +bm_rtl::function_calls__Function::get_string 1059 ns 1057 ns 662143 +bm_rtl::method_calls______Method::get_string 1059 ns 1058 ns 661466 + +bm_rtl::function__ErasedReturnType::get_string 1097 ns 1096 ns 638879 +bm_rtl::method____ErasedReturnType::get_string 1098 ns 1097 ns 638203 +bm_rtl::method____ErasedTargetType::get_string 1076 ns 1075 ns 650820 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1101 ns 1100 ns 636763 +----------------------------------- +[2025-11-04 11:38:58] >>> Run 3: workload scale = 40 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 40 iterations +============================================= + +2025-11-04T11:38:58+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.93, 0.56 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 790 ns 789 ns 879491 + +bm_call::via_function_ptr__Function::set_string 801 ns 800 ns 876063 +bm_call::via_function_ptr____Method::set_string 801 ns 800 ns 875793 + +bm_std::function_calls__Function::set_string 801 ns 800 ns 867836 +bm_std::function_calls____Method::set_string 793 ns 793 ns 882424 + +bm_rtl::function_calls__Function::set_string 801 ns 800 ns 873938 +bm_rtl::method_calls______Method::set_string 800 ns 799 ns 876111 + +bm_rtl::function__ErasedReturnType::set_string 791 ns 790 ns 883758 +bm_rtl::method____ErasedReturnType::set_string 794 ns 793 ns 882458 +bm_rtl::method____ErasedTargetType::set_string 795 ns 794 ns 882106 +bm_rtl::method____ErasedTargetAndReturnType::set_string 802 ns 802 ns 875097 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1011 ns 1010 ns 691725 + +bm_call::via_function_ptr__Function::get_string 1013 ns 1012 ns 690708 +bm_call::via_function_ptr____Method::get_string 1015 ns 1014 ns 690969 + +bm_std::function_calls__Function::get_string 1014 ns 1013 ns 691823 +bm_std::function_calls____Method::get_string 1007 ns 1006 ns 696324 + +bm_rtl::function_calls__Function::get_string 1014 ns 1013 ns 690932 +bm_rtl::method_calls______Method::get_string 1016 ns 1015 ns 691167 + +bm_rtl::function__ErasedReturnType::get_string 1029 ns 1028 ns 679959 +bm_rtl::method____ErasedReturnType::get_string 1036 ns 1035 ns 676196 +bm_rtl::method____ErasedTargetType::get_string 1017 ns 1016 ns 689113 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1043 ns 1042 ns 672677 +----------------------------------- +[2025-11-04 11:39:16] >>> Run 1: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-11-04T11:39:16+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 1640.45 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.93, 0.57 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 846 ns 846 ns 821898 + +bm_call::via_function_ptr__Function::set_string 846 ns 846 ns 829586 +bm_call::via_function_ptr____Method::set_string 847 ns 846 ns 827075 + +bm_std::function_calls__Function::set_string 848 ns 848 ns 823698 +bm_std::function_calls____Method::set_string 850 ns 849 ns 824485 + +bm_rtl::function_calls__Function::set_string 848 ns 848 ns 826498 +bm_rtl::method_calls______Method::set_string 847 ns 846 ns 826833 + +bm_rtl::function__ErasedReturnType::set_string 857 ns 857 ns 817116 +bm_rtl::method____ErasedReturnType::set_string 856 ns 855 ns 819321 +bm_rtl::method____ErasedTargetType::set_string 860 ns 859 ns 815630 +bm_rtl::method____ErasedTargetAndReturnType::set_string 871 ns 870 ns 803543 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1082 ns 1081 ns 648078 + +bm_call::via_function_ptr__Function::get_string 1079 ns 1078 ns 649415 +bm_call::via_function_ptr____Method::get_string 1080 ns 1079 ns 648859 + +bm_std::function_calls__Function::get_string 1078 ns 1077 ns 649608 +bm_std::function_calls____Method::get_string 1085 ns 1084 ns 646485 + +bm_rtl::function_calls__Function::get_string 1077 ns 1077 ns 650108 +bm_rtl::method_calls______Method::get_string 1080 ns 1079 ns 648442 + +bm_rtl::function__ErasedReturnType::get_string 1115 ns 1114 ns 626958 +bm_rtl::method____ErasedReturnType::get_string 1117 ns 1116 ns 626786 +bm_rtl::method____ErasedTargetType::get_string 1096 ns 1095 ns 638830 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1126 ns 1125 ns 622353 +----------------------------------- +[2025-11-04 11:39:34] >>> Run 2: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-11-04T11:39:34+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.94, 0.58 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 848 ns 847 ns 822625 + +bm_call::via_function_ptr__Function::set_string 845 ns 844 ns 820487 +bm_call::via_function_ptr____Method::set_string 844 ns 843 ns 829949 + +bm_std::function_calls__Function::set_string 845 ns 844 ns 825232 +bm_std::function_calls____Method::set_string 853 ns 852 ns 821822 + +bm_rtl::function_calls__Function::set_string 845 ns 844 ns 827961 +bm_rtl::method_calls______Method::set_string 845 ns 845 ns 826856 + +bm_rtl::function__ErasedReturnType::set_string 856 ns 855 ns 819788 +bm_rtl::method____ErasedReturnType::set_string 855 ns 854 ns 822908 +bm_rtl::method____ErasedTargetType::set_string 857 ns 857 ns 817574 +bm_rtl::method____ErasedTargetAndReturnType::set_string 868 ns 867 ns 808004 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1083 ns 1082 ns 648003 + +bm_call::via_function_ptr__Function::get_string 1077 ns 1077 ns 649849 +bm_call::via_function_ptr____Method::get_string 1080 ns 1079 ns 649233 + +bm_std::function_calls__Function::get_string 1076 ns 1076 ns 650966 +bm_std::function_calls____Method::get_string 1088 ns 1087 ns 643800 + +bm_rtl::function_calls__Function::get_string 1078 ns 1078 ns 646730 +bm_rtl::method_calls______Method::get_string 1078 ns 1078 ns 649617 + +bm_rtl::function__ErasedReturnType::get_string 1112 ns 1111 ns 629505 +bm_rtl::method____ErasedReturnType::get_string 1116 ns 1116 ns 626620 +bm_rtl::method____ErasedTargetType::get_string 1094 ns 1093 ns 640864 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1121 ns 1120 ns 619886 +----------------------------------- +[2025-11-04 11:39:52] >>> Run 3: workload scale = 45 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 45 iterations +============================================= + +2025-11-04T11:39:52+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.00, 0.94, 0.59 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 841 ns 841 ns 828006 + +bm_call::via_function_ptr__Function::set_string 846 ns 845 ns 827058 +bm_call::via_function_ptr____Method::set_string 844 ns 843 ns 830739 + +bm_std::function_calls__Function::set_string 844 ns 843 ns 826509 +bm_std::function_calls____Method::set_string 849 ns 848 ns 825604 + +bm_rtl::function_calls__Function::set_string 846 ns 846 ns 828447 +bm_rtl::method_calls______Method::set_string 845 ns 844 ns 829668 + +bm_rtl::function__ErasedReturnType::set_string 855 ns 854 ns 821153 +bm_rtl::method____ErasedReturnType::set_string 860 ns 859 ns 813919 +bm_rtl::method____ErasedTargetType::set_string 855 ns 854 ns 818020 +bm_rtl::method____ErasedTargetAndReturnType::set_string 869 ns 869 ns 807824 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1074 ns 1073 ns 652774 + +bm_call::via_function_ptr__Function::get_string 1071 ns 1070 ns 653625 +bm_call::via_function_ptr____Method::get_string 1072 ns 1071 ns 653933 + +bm_std::function_calls__Function::get_string 1072 ns 1071 ns 653516 +bm_std::function_calls____Method::get_string 1079 ns 1079 ns 648755 + +bm_rtl::function_calls__Function::get_string 1071 ns 1071 ns 654398 +bm_rtl::method_calls______Method::get_string 1072 ns 1072 ns 653285 + +bm_rtl::function__ErasedReturnType::get_string 1108 ns 1108 ns 631753 +bm_rtl::method____ErasedReturnType::get_string 1111 ns 1111 ns 630268 +bm_rtl::method____ErasedTargetType::get_string 1085 ns 1084 ns 645525 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1122 ns 1121 ns 624251 +----------------------------------- +[2025-11-04 11:40:09] >>> Run 1: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-11-04T11:40:09+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 0.96, 0.60 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 909 ns 909 ns 767477 + +bm_call::via_function_ptr__Function::set_string 912 ns 911 ns 767505 +bm_call::via_function_ptr____Method::set_string 909 ns 909 ns 770254 + +bm_std::function_calls__Function::set_string 911 ns 910 ns 771378 +bm_std::function_calls____Method::set_string 912 ns 912 ns 768127 + +bm_rtl::function_calls__Function::set_string 911 ns 911 ns 768533 +bm_rtl::method_calls______Method::set_string 911 ns 911 ns 768158 + +bm_rtl::function__ErasedReturnType::set_string 919 ns 919 ns 760767 +bm_rtl::method____ErasedReturnType::set_string 926 ns 926 ns 755851 +bm_rtl::method____ErasedTargetType::set_string 933 ns 932 ns 751905 +bm_rtl::method____ErasedTargetAndReturnType::set_string 931 ns 930 ns 751605 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1174 ns 1174 ns 596533 + +bm_call::via_function_ptr__Function::get_string 1175 ns 1174 ns 596482 +bm_call::via_function_ptr____Method::get_string 1175 ns 1175 ns 595587 + +bm_std::function_calls__Function::get_string 1174 ns 1173 ns 596838 +bm_std::function_calls____Method::get_string 1178 ns 1177 ns 594976 + +bm_rtl::function_calls__Function::get_string 1174 ns 1173 ns 596710 +bm_rtl::method_calls______Method::get_string 1176 ns 1175 ns 596243 + +bm_rtl::function__ErasedReturnType::get_string 1214 ns 1213 ns 577055 +bm_rtl::method____ErasedReturnType::get_string 1213 ns 1213 ns 577546 +bm_rtl::method____ErasedTargetType::get_string 1198 ns 1198 ns 584466 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1219 ns 1218 ns 574204 +----------------------------------- +[2025-11-04 11:40:27] >>> Run 2: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-11-04T11:40:27+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.05, 0.97, 0.61 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 943 ns 942 ns 737843 + +bm_call::via_function_ptr__Function::set_string 944 ns 943 ns 742177 +bm_call::via_function_ptr____Method::set_string 944 ns 944 ns 742264 + +bm_std::function_calls__Function::set_string 944 ns 943 ns 743093 +bm_std::function_calls____Method::set_string 947 ns 946 ns 738334 + +bm_rtl::function_calls__Function::set_string 944 ns 944 ns 741385 +bm_rtl::method_calls______Method::set_string 945 ns 944 ns 741519 + +bm_rtl::function__ErasedReturnType::set_string 957 ns 956 ns 730993 +bm_rtl::method____ErasedReturnType::set_string 961 ns 961 ns 729195 +bm_rtl::method____ErasedTargetType::set_string 959 ns 958 ns 730421 +bm_rtl::method____ErasedTargetAndReturnType::set_string 967 ns 967 ns 723365 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1259 ns 1259 ns 556770 + +bm_call::via_function_ptr__Function::get_string 1261 ns 1260 ns 554829 +bm_call::via_function_ptr____Method::get_string 1261 ns 1261 ns 555062 + +bm_std::function_calls__Function::get_string 1261 ns 1260 ns 554486 +bm_std::function_calls____Method::get_string 1266 ns 1266 ns 553304 + +bm_rtl::function_calls__Function::get_string 1261 ns 1260 ns 555273 +bm_rtl::method_calls______Method::get_string 1262 ns 1262 ns 554575 + +bm_rtl::function__ErasedReturnType::get_string 1292 ns 1292 ns 541838 +bm_rtl::method____ErasedReturnType::get_string 1294 ns 1293 ns 541593 +bm_rtl::method____ErasedTargetType::get_string 1279 ns 1279 ns 546731 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1307 ns 1306 ns 536321 +----------------------------------- +[2025-11-04 11:40:46] >>> Run 3: workload scale = 50 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 50 iterations +============================================= + +2025-11-04T11:40:46+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 0.97, 0.62 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 913 ns 913 ns 765510 + +bm_call::via_function_ptr__Function::set_string 910 ns 909 ns 771256 +bm_call::via_function_ptr____Method::set_string 909 ns 908 ns 771309 + +bm_std::function_calls__Function::set_string 908 ns 907 ns 770894 +bm_std::function_calls____Method::set_string 912 ns 912 ns 768112 + +bm_rtl::function_calls__Function::set_string 907 ns 907 ns 770584 +bm_rtl::method_calls______Method::set_string 908 ns 908 ns 771993 + +bm_rtl::function__ErasedReturnType::set_string 921 ns 921 ns 760196 +bm_rtl::method____ErasedReturnType::set_string 924 ns 923 ns 756860 +bm_rtl::method____ErasedTargetType::set_string 926 ns 926 ns 757342 +bm_rtl::method____ErasedTargetAndReturnType::set_string 929 ns 929 ns 754776 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1174 ns 1173 ns 595250 + +bm_call::via_function_ptr__Function::get_string 1172 ns 1172 ns 597161 +bm_call::via_function_ptr____Method::get_string 1173 ns 1172 ns 597285 + +bm_std::function_calls__Function::get_string 1173 ns 1172 ns 597217 +bm_std::function_calls____Method::get_string 1177 ns 1177 ns 595388 + +bm_rtl::function_calls__Function::get_string 1172 ns 1171 ns 597813 +bm_rtl::method_calls______Method::get_string 1173 ns 1173 ns 596603 + +bm_rtl::function__ErasedReturnType::get_string 1206 ns 1206 ns 580285 +bm_rtl::method____ErasedReturnType::get_string 1211 ns 1210 ns 578485 +bm_rtl::method____ErasedTargetType::get_string 1190 ns 1189 ns 588583 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1222 ns 1221 ns 573429 +----------------------------------- +[2025-11-04 11:41:04] >>> Run 1: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-11-04T11:41:04+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 0.97, 0.63 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1032 ns 1031 ns 676070 + +bm_call::via_function_ptr__Function::set_string 1032 ns 1031 ns 678824 +bm_call::via_function_ptr____Method::set_string 1032 ns 1031 ns 678016 + +bm_std::function_calls__Function::set_string 1031 ns 1031 ns 677827 +bm_std::function_calls____Method::set_string 1036 ns 1036 ns 674869 + +bm_rtl::function_calls__Function::set_string 1030 ns 1029 ns 679752 +bm_rtl::method_calls______Method::set_string 1032 ns 1031 ns 678902 + +bm_rtl::function__ErasedReturnType::set_string 1042 ns 1042 ns 671992 +bm_rtl::method____ErasedReturnType::set_string 1044 ns 1044 ns 669776 +bm_rtl::method____ErasedTargetType::set_string 1048 ns 1048 ns 669636 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1057 ns 1057 ns 662078 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1320 ns 1319 ns 530013 + +bm_call::via_function_ptr__Function::get_string 1320 ns 1319 ns 530104 +bm_call::via_function_ptr____Method::get_string 1322 ns 1321 ns 529144 + +bm_std::function_calls__Function::get_string 1321 ns 1320 ns 530134 +bm_std::function_calls____Method::get_string 1328 ns 1327 ns 526957 + +bm_rtl::function_calls__Function::get_string 1320 ns 1319 ns 530249 +bm_rtl::method_calls______Method::get_string 1323 ns 1322 ns 529609 + +bm_rtl::function__ErasedReturnType::get_string 1362 ns 1361 ns 514888 +bm_rtl::method____ErasedReturnType::get_string 1368 ns 1367 ns 512162 +bm_rtl::method____ErasedTargetType::get_string 1334 ns 1334 ns 524950 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1372 ns 1371 ns 510495 +----------------------------------- +[2025-11-04 11:41:22] >>> Run 2: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-11-04T11:41:22+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 820.226 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 0.97, 0.64 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1031 ns 1031 ns 675121 + +bm_call::via_function_ptr__Function::set_string 1031 ns 1030 ns 679015 +bm_call::via_function_ptr____Method::set_string 1032 ns 1031 ns 679476 + +bm_std::function_calls__Function::set_string 1031 ns 1031 ns 677910 +bm_std::function_calls____Method::set_string 1041 ns 1041 ns 670513 + +bm_rtl::function_calls__Function::set_string 1032 ns 1031 ns 680773 +bm_rtl::method_calls______Method::set_string 1032 ns 1032 ns 679489 + +bm_rtl::function__ErasedReturnType::set_string 1042 ns 1041 ns 671509 +bm_rtl::method____ErasedReturnType::set_string 1046 ns 1045 ns 668786 +bm_rtl::method____ErasedTargetType::set_string 1051 ns 1050 ns 668456 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1051 ns 1051 ns 665655 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1321 ns 1320 ns 529589 + +bm_call::via_function_ptr__Function::get_string 1319 ns 1319 ns 527334 +bm_call::via_function_ptr____Method::get_string 1321 ns 1320 ns 530323 + +bm_std::function_calls__Function::get_string 1321 ns 1320 ns 530845 +bm_std::function_calls____Method::get_string 1330 ns 1329 ns 526538 + +bm_rtl::function_calls__Function::get_string 1320 ns 1320 ns 531222 +bm_rtl::method_calls______Method::get_string 1321 ns 1320 ns 530152 + +bm_rtl::function__ErasedReturnType::get_string 1361 ns 1361 ns 514252 +bm_rtl::method____ErasedReturnType::get_string 1362 ns 1362 ns 510922 +bm_rtl::method____ErasedTargetType::get_string 1338 ns 1337 ns 523350 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1371 ns 1370 ns 512355 +----------------------------------- +[2025-11-04 11:41:40] >>> Run 3: workload scale = 58 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 58 iterations +============================================= + +2025-11-04T11:41:40+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 0.98, 0.64 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1017 ns 1027 ns 679622 + +bm_call::via_function_ptr__Function::set_string 1015 ns 1029 ns 680787 +bm_call::via_function_ptr____Method::set_string 1016 ns 1029 ns 679486 + +bm_std::function_calls__Function::set_string 1018 ns 1030 ns 680557 +bm_std::function_calls____Method::set_string 1030 ns 1040 ns 672817 + +bm_rtl::function_calls__Function::set_string 1019 ns 1028 ns 680440 +bm_rtl::method_calls______Method::set_string 1021 ns 1030 ns 679426 + +bm_rtl::function__ErasedReturnType::set_string 1033 ns 1041 ns 669612 +bm_rtl::method____ErasedReturnType::set_string 1033 ns 1041 ns 673638 +bm_rtl::method____ErasedTargetType::set_string 1044 ns 1050 ns 668898 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1043 ns 1049 ns 667070 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1315 ns 1321 ns 530349 + +bm_call::via_function_ptr__Function::get_string 1313 ns 1319 ns 530447 +bm_call::via_function_ptr____Method::get_string 1314 ns 1320 ns 529779 + +bm_std::function_calls__Function::get_string 1317 ns 1322 ns 530934 +bm_std::function_calls____Method::get_string 1321 ns 1326 ns 527723 + +bm_rtl::function_calls__Function::get_string 1317 ns 1321 ns 530957 +bm_rtl::method_calls______Method::get_string 1316 ns 1320 ns 530817 + +bm_rtl::function__ErasedReturnType::get_string 1354 ns 1357 ns 515832 +bm_rtl::method____ErasedReturnType::get_string 1358 ns 1361 ns 508856 +bm_rtl::method____ErasedTargetType::get_string 1336 ns 1339 ns 522359 +bm_rtl::method____ErasedTargetAndReturnType::get_string 1363 ns 1366 ns 511858 +----------------------------------- +[2025-11-04 11:41:58] >>> Run 1: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-11-04T11:41:58+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.08, 0.99, 0.66 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1657 ns 1660 ns 421772 + +bm_call::via_function_ptr__Function::set_string 1659 ns 1661 ns 421261 +bm_call::via_function_ptr____Method::set_string 1657 ns 1659 ns 421660 + +bm_std::function_calls__Function::set_string 1659 ns 1661 ns 421457 +bm_std::function_calls____Method::set_string 1664 ns 1666 ns 417619 + +bm_rtl::function_calls__Function::set_string 1655 ns 1657 ns 421767 +bm_rtl::method_calls______Method::set_string 1660 ns 1662 ns 421804 + +bm_rtl::function__ErasedReturnType::set_string 1653 ns 1655 ns 418490 +bm_rtl::method____ErasedReturnType::set_string 1662 ns 1663 ns 424133 +bm_rtl::method____ErasedTargetType::set_string 1675 ns 1677 ns 417375 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1698 ns 1699 ns 412042 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2033 ns 2035 ns 343824 + +bm_call::via_function_ptr__Function::get_string 2029 ns 2030 ns 344946 +bm_call::via_function_ptr____Method::get_string 2029 ns 2030 ns 344269 + +bm_std::function_calls__Function::get_string 2029 ns 2030 ns 344471 +bm_std::function_calls____Method::get_string 2037 ns 2038 ns 344001 + +bm_rtl::function_calls__Function::get_string 2032 ns 2030 ns 344558 +bm_rtl::method_calls______Method::get_string 2034 ns 2032 ns 345067 + +bm_rtl::function__ErasedReturnType::get_string 2076 ns 2075 ns 337071 +bm_rtl::method____ErasedReturnType::get_string 2082 ns 2080 ns 336215 +bm_rtl::method____ErasedTargetType::get_string 2049 ns 2048 ns 342138 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2085 ns 2083 ns 336181 +----------------------------------- +[2025-11-04 11:42:18] >>> Run 2: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-11-04T11:42:18+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.05, 1.00, 0.67 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1668 ns 1666 ns 420591 + +bm_call::via_function_ptr__Function::set_string 1666 ns 1665 ns 420519 +bm_call::via_function_ptr____Method::set_string 1665 ns 1664 ns 420393 + +bm_std::function_calls__Function::set_string 1666 ns 1665 ns 420597 +bm_std::function_calls____Method::set_string 1670 ns 1669 ns 418433 + +bm_rtl::function_calls__Function::set_string 1661 ns 1660 ns 421384 +bm_rtl::method_calls______Method::set_string 1664 ns 1663 ns 421078 + +bm_rtl::function__ErasedReturnType::set_string 1674 ns 1674 ns 418103 +bm_rtl::method____ErasedReturnType::set_string 1676 ns 1676 ns 417778 +bm_rtl::method____ErasedTargetType::set_string 1681 ns 1680 ns 417245 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1684 ns 1683 ns 415930 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 1986 ns 1985 ns 352254 + +bm_call::via_function_ptr__Function::get_string 1987 ns 1986 ns 352702 +bm_call::via_function_ptr____Method::get_string 1988 ns 1988 ns 352071 + +bm_std::function_calls__Function::get_string 1987 ns 1986 ns 352640 +bm_std::function_calls____Method::get_string 1993 ns 1993 ns 350926 + +bm_rtl::function_calls__Function::get_string 1986 ns 1986 ns 352094 +bm_rtl::method_calls______Method::get_string 1989 ns 1989 ns 351886 + +bm_rtl::function__ErasedReturnType::get_string 2027 ns 2027 ns 345297 +bm_rtl::method____ErasedReturnType::get_string 2029 ns 2029 ns 345232 +bm_rtl::method____ErasedTargetType::get_string 2004 ns 2004 ns 349685 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2034 ns 2034 ns 344459 +----------------------------------- +[2025-11-04 11:42:38] >>> Run 3: workload scale = 66 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 66 iterations +============================================= + +2025-11-04T11:42:38+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.00, 0.67 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1656 ns 1656 ns 419723 + +bm_call::via_function_ptr__Function::set_string 1655 ns 1655 ns 422991 +bm_call::via_function_ptr____Method::set_string 1657 ns 1657 ns 422611 + +bm_std::function_calls__Function::set_string 1656 ns 1656 ns 422654 +bm_std::function_calls____Method::set_string 1671 ns 1671 ns 419437 + +bm_rtl::function_calls__Function::set_string 1653 ns 1653 ns 423328 +bm_rtl::method_calls______Method::set_string 1658 ns 1658 ns 422855 + +bm_rtl::function__ErasedReturnType::set_string 1671 ns 1671 ns 418940 +bm_rtl::method____ErasedReturnType::set_string 1672 ns 1672 ns 418670 +bm_rtl::method____ErasedTargetType::set_string 1678 ns 1678 ns 415373 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1679 ns 1679 ns 416931 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2035 ns 2036 ns 344330 + +bm_call::via_function_ptr__Function::get_string 2031 ns 2032 ns 344346 +bm_call::via_function_ptr____Method::get_string 2034 ns 2035 ns 344556 + +bm_std::function_calls__Function::get_string 2033 ns 2033 ns 344441 +bm_std::function_calls____Method::get_string 2040 ns 2041 ns 343498 + +bm_rtl::function_calls__Function::get_string 2032 ns 2032 ns 344410 +bm_rtl::method_calls______Method::get_string 2035 ns 2035 ns 344515 + +bm_rtl::function__ErasedReturnType::get_string 2076 ns 2077 ns 336831 +bm_rtl::method____ErasedReturnType::get_string 2077 ns 2077 ns 336922 +bm_rtl::method____ErasedTargetType::get_string 2049 ns 2049 ns 340087 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2083 ns 2084 ns 336074 +----------------------------------- +[2025-11-04 11:42:58] >>> Run 1: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-11-04T11:42:58+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 1.00, 0.68 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1702 ns 1702 ns 410993 + +bm_call::via_function_ptr__Function::set_string 1700 ns 1701 ns 411578 +bm_call::via_function_ptr____Method::set_string 1701 ns 1701 ns 411305 + +bm_std::function_calls__Function::set_string 1703 ns 1704 ns 410550 +bm_std::function_calls____Method::set_string 1706 ns 1706 ns 410063 + +bm_rtl::function_calls__Function::set_string 1699 ns 1699 ns 412192 +bm_rtl::method_calls______Method::set_string 1700 ns 1701 ns 412000 + +bm_rtl::function__ErasedReturnType::set_string 1739 ns 1739 ns 401572 +bm_rtl::method____ErasedReturnType::set_string 1724 ns 1725 ns 405479 +bm_rtl::method____ErasedTargetType::set_string 1726 ns 1727 ns 405687 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1775 ns 1776 ns 393707 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2054 ns 2054 ns 340080 + +bm_call::via_function_ptr__Function::get_string 2054 ns 2055 ns 340747 +bm_call::via_function_ptr____Method::get_string 2056 ns 2056 ns 340564 + +bm_std::function_calls__Function::get_string 2054 ns 2055 ns 340353 +bm_std::function_calls____Method::get_string 2064 ns 2065 ns 339177 + +bm_rtl::function_calls__Function::get_string 2059 ns 2060 ns 340492 +bm_rtl::method_calls______Method::get_string 2056 ns 2057 ns 339582 + +bm_rtl::function__ErasedReturnType::get_string 2106 ns 2106 ns 331861 +bm_rtl::method____ErasedReturnType::get_string 2146 ns 2147 ns 326249 +bm_rtl::method____ErasedTargetType::get_string 2091 ns 2092 ns 334710 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2116 ns 2116 ns 330808 +----------------------------------- +[2025-11-04 11:43:18] >>> Run 2: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-11-04T11:43:18+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.00, 0.69 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1705 ns 1706 ns 410050 + +bm_call::via_function_ptr__Function::set_string 1703 ns 1703 ns 411193 +bm_call::via_function_ptr____Method::set_string 1704 ns 1704 ns 410529 + +bm_std::function_calls__Function::set_string 1703 ns 1703 ns 411017 +bm_std::function_calls____Method::set_string 1713 ns 1713 ns 408256 + +bm_rtl::function_calls__Function::set_string 1702 ns 1702 ns 410861 +bm_rtl::method_calls______Method::set_string 1702 ns 1703 ns 411267 + +bm_rtl::function__ErasedReturnType::set_string 1758 ns 1759 ns 398120 +bm_rtl::method____ErasedReturnType::set_string 1746 ns 1747 ns 400302 +bm_rtl::method____ErasedTargetType::set_string 1738 ns 1739 ns 403136 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1717 ns 1718 ns 406824 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2062 ns 2062 ns 339419 + +bm_call::via_function_ptr__Function::get_string 2062 ns 2063 ns 339231 +bm_call::via_function_ptr____Method::get_string 2064 ns 2065 ns 339106 + +bm_std::function_calls__Function::get_string 2062 ns 2063 ns 339570 +bm_std::function_calls____Method::get_string 2070 ns 2070 ns 338163 + +bm_rtl::function_calls__Function::get_string 2064 ns 2065 ns 338796 +bm_rtl::method_calls______Method::get_string 2065 ns 2066 ns 339087 + +bm_rtl::function__ErasedReturnType::get_string 2105 ns 2106 ns 332120 +bm_rtl::method____ErasedReturnType::get_string 2100 ns 2100 ns 333314 +bm_rtl::method____ErasedTargetType::get_string 2095 ns 2096 ns 333978 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2105 ns 2106 ns 332620 +----------------------------------- +[2025-11-04 11:43:38] >>> Run 3: workload scale = 74 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 74 iterations +============================================= + +2025-11-04T11:43:38+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.08, 1.02, 0.70 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1725 ns 1726 ns 406312 + +bm_call::via_function_ptr__Function::set_string 1726 ns 1726 ns 405636 +bm_call::via_function_ptr____Method::set_string 1727 ns 1727 ns 405754 + +bm_std::function_calls__Function::set_string 1724 ns 1725 ns 405818 +bm_std::function_calls____Method::set_string 1731 ns 1731 ns 404376 + +bm_rtl::function_calls__Function::set_string 1726 ns 1726 ns 402702 +bm_rtl::method_calls______Method::set_string 1725 ns 1725 ns 406029 + +bm_rtl::function__ErasedReturnType::set_string 1734 ns 1734 ns 403830 +bm_rtl::method____ErasedReturnType::set_string 1736 ns 1736 ns 403200 +bm_rtl::method____ErasedTargetType::set_string 1741 ns 1742 ns 402231 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1741 ns 1742 ns 401846 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2091 ns 2092 ns 334903 + +bm_call::via_function_ptr__Function::get_string 2087 ns 2087 ns 335367 +bm_call::via_function_ptr____Method::get_string 2090 ns 2090 ns 335217 + +bm_std::function_calls__Function::get_string 2087 ns 2087 ns 335223 +bm_std::function_calls____Method::get_string 2093 ns 2094 ns 334231 + +bm_rtl::function_calls__Function::get_string 2087 ns 2088 ns 333794 +bm_rtl::method_calls______Method::get_string 2089 ns 2089 ns 335209 + +bm_rtl::function__ErasedReturnType::get_string 2130 ns 2130 ns 328921 +bm_rtl::method____ErasedReturnType::get_string 2131 ns 2131 ns 328695 +bm_rtl::method____ErasedTargetType::get_string 2109 ns 2110 ns 332174 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2139 ns 2140 ns 327151 +----------------------------------- +[2025-11-04 11:43:58] >>> Run 1: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-11-04T11:43:58+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 1.01, 0.71 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1797 ns 1797 ns 389525 + +bm_call::via_function_ptr__Function::set_string 1798 ns 1798 ns 389536 +bm_call::via_function_ptr____Method::set_string 1798 ns 1798 ns 389365 + +bm_std::function_calls__Function::set_string 1800 ns 1801 ns 389607 +bm_std::function_calls____Method::set_string 1829 ns 1830 ns 386984 + +bm_rtl::function_calls__Function::set_string 1810 ns 1810 ns 380113 +bm_rtl::method_calls______Method::set_string 1798 ns 1799 ns 389381 + +bm_rtl::function__ErasedReturnType::set_string 1802 ns 1803 ns 388635 +bm_rtl::method____ErasedReturnType::set_string 1803 ns 1803 ns 388548 +bm_rtl::method____ErasedTargetType::set_string 1811 ns 1812 ns 386464 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1810 ns 1811 ns 386941 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2284 ns 2285 ns 306552 + +bm_call::via_function_ptr__Function::get_string 2283 ns 2284 ns 306654 +bm_call::via_function_ptr____Method::get_string 2286 ns 2286 ns 306173 + +bm_std::function_calls__Function::get_string 2283 ns 2284 ns 306482 +bm_std::function_calls____Method::get_string 2290 ns 2290 ns 305618 + +bm_rtl::function_calls__Function::get_string 2283 ns 2284 ns 306531 +bm_rtl::method_calls______Method::get_string 2285 ns 2285 ns 306323 + +bm_rtl::function__ErasedReturnType::get_string 2326 ns 2327 ns 300755 +bm_rtl::method____ErasedReturnType::get_string 2325 ns 2325 ns 300885 +bm_rtl::method____ErasedTargetType::get_string 2310 ns 2311 ns 302696 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2330 ns 2330 ns 300284 +----------------------------------- +[2025-11-04 11:44:19] >>> Run 2: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-11-04T11:44:19+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 851.313 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.10, 1.03, 0.72 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1778 ns 1778 ns 393555 + +bm_call::via_function_ptr__Function::set_string 1783 ns 1783 ns 393270 +bm_call::via_function_ptr____Method::set_string 1785 ns 1785 ns 392516 + +bm_std::function_calls__Function::set_string 1782 ns 1783 ns 393411 +bm_std::function_calls____Method::set_string 1789 ns 1789 ns 391871 + +bm_rtl::function_calls__Function::set_string 1780 ns 1781 ns 392505 +bm_rtl::method_calls______Method::set_string 1778 ns 1778 ns 393604 + +bm_rtl::function__ErasedReturnType::set_string 1778 ns 1779 ns 391999 +bm_rtl::method____ErasedReturnType::set_string 1782 ns 1783 ns 392539 +bm_rtl::method____ErasedTargetType::set_string 1794 ns 1794 ns 389821 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1786 ns 1787 ns 391779 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2181 ns 2181 ns 321380 + +bm_call::via_function_ptr__Function::get_string 2175 ns 2176 ns 321625 +bm_call::via_function_ptr____Method::get_string 2178 ns 2179 ns 321527 + +bm_std::function_calls__Function::get_string 2175 ns 2176 ns 321528 +bm_std::function_calls____Method::get_string 2186 ns 2186 ns 320422 + +bm_rtl::function_calls__Function::get_string 2173 ns 2174 ns 322110 +bm_rtl::method_calls______Method::get_string 2180 ns 2180 ns 321745 + +bm_rtl::function__ErasedReturnType::get_string 2217 ns 2218 ns 315599 +bm_rtl::method____ErasedReturnType::get_string 2219 ns 2220 ns 315241 +bm_rtl::method____ErasedTargetType::get_string 2195 ns 2196 ns 317502 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2221 ns 2222 ns 315139 +----------------------------------- +[2025-11-04 11:44:39] >>> Run 3: workload scale = 82 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 82 iterations +============================================= + +2025-11-04T11:44:39+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4073.78 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.07, 1.03, 0.73 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1789 ns 1789 ns 391681 + +bm_call::via_function_ptr__Function::set_string 1790 ns 1791 ns 391507 +bm_call::via_function_ptr____Method::set_string 1791 ns 1792 ns 390930 + +bm_std::function_calls__Function::set_string 1787 ns 1788 ns 391890 +bm_std::function_calls____Method::set_string 1794 ns 1794 ns 390805 + +bm_rtl::function_calls__Function::set_string 1786 ns 1787 ns 392220 +bm_rtl::method_calls______Method::set_string 1790 ns 1790 ns 391457 + +bm_rtl::function__ErasedReturnType::set_string 1789 ns 1789 ns 391299 +bm_rtl::method____ErasedReturnType::set_string 1790 ns 1791 ns 391105 +bm_rtl::method____ErasedTargetType::set_string 1797 ns 1798 ns 389126 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1798 ns 1799 ns 388968 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2281 ns 2282 ns 307129 + +bm_call::via_function_ptr__Function::get_string 2277 ns 2278 ns 307178 +bm_call::via_function_ptr____Method::get_string 2282 ns 2283 ns 307132 + +bm_std::function_calls__Function::get_string 2278 ns 2279 ns 307271 +bm_std::function_calls____Method::get_string 2289 ns 2290 ns 306018 + +bm_rtl::function_calls__Function::get_string 2276 ns 2277 ns 307466 +bm_rtl::method_calls______Method::get_string 2283 ns 2283 ns 306991 + +bm_rtl::function__ErasedReturnType::get_string 2316 ns 2316 ns 302121 +bm_rtl::method____ErasedReturnType::get_string 2317 ns 2318 ns 302362 +bm_rtl::method____ErasedTargetType::get_string 2302 ns 2303 ns 304074 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2325 ns 2325 ns 301350 +----------------------------------- +[2025-11-04 11:44:59] >>> Run 1: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-11-04T11:44:59+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.05, 1.02, 0.74 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1855 ns 1856 ns 377098 + +bm_call::via_function_ptr__Function::set_string 1855 ns 1855 ns 378267 +bm_call::via_function_ptr____Method::set_string 1853 ns 1853 ns 377675 + +bm_std::function_calls__Function::set_string 1853 ns 1854 ns 378218 +bm_std::function_calls____Method::set_string 1862 ns 1862 ns 376248 + +bm_rtl::function_calls__Function::set_string 1850 ns 1850 ns 378137 +bm_rtl::method_calls______Method::set_string 1855 ns 1856 ns 377582 + +bm_rtl::function__ErasedReturnType::set_string 1862 ns 1863 ns 375415 +bm_rtl::method____ErasedReturnType::set_string 1864 ns 1865 ns 376111 +bm_rtl::method____ErasedTargetType::set_string 1869 ns 1870 ns 374624 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1870 ns 1870 ns 373729 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2285 ns 2285 ns 305947 + +bm_call::via_function_ptr__Function::get_string 2287 ns 2288 ns 305982 +bm_call::via_function_ptr____Method::get_string 2289 ns 2290 ns 305610 + +bm_std::function_calls__Function::get_string 2287 ns 2288 ns 305896 +bm_std::function_calls____Method::get_string 2290 ns 2291 ns 305644 + +bm_rtl::function_calls__Function::get_string 2287 ns 2288 ns 306110 +bm_rtl::method_calls______Method::get_string 2289 ns 2289 ns 305683 + +bm_rtl::function__ErasedReturnType::get_string 2321 ns 2322 ns 301437 +bm_rtl::method____ErasedReturnType::get_string 2323 ns 2323 ns 301190 +bm_rtl::method____ErasedTargetType::get_string 2295 ns 2295 ns 304947 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2331 ns 2332 ns 300136 +----------------------------------- +[2025-11-04 11:45:20] >>> Run 2: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-11-04T11:45:20+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.02, 0.74 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1870 ns 1871 ns 373902 + +bm_call::via_function_ptr__Function::set_string 1866 ns 1866 ns 375733 +bm_call::via_function_ptr____Method::set_string 1860 ns 1860 ns 376397 + +bm_std::function_calls__Function::set_string 1859 ns 1860 ns 376365 +bm_std::function_calls____Method::set_string 1862 ns 1863 ns 373798 + +bm_rtl::function_calls__Function::set_string 1857 ns 1858 ns 376991 +bm_rtl::method_calls______Method::set_string 1862 ns 1863 ns 376328 + +bm_rtl::function__ErasedReturnType::set_string 1865 ns 1865 ns 375497 +bm_rtl::method____ErasedReturnType::set_string 1868 ns 1868 ns 375141 +bm_rtl::method____ErasedTargetType::set_string 1872 ns 1873 ns 373961 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1876 ns 1876 ns 373051 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2317 ns 2317 ns 301971 + +bm_call::via_function_ptr__Function::get_string 2312 ns 2312 ns 302404 +bm_call::via_function_ptr____Method::get_string 2313 ns 2314 ns 302312 + +bm_std::function_calls__Function::get_string 2312 ns 2313 ns 302678 +bm_std::function_calls____Method::get_string 2320 ns 2320 ns 301614 + +bm_rtl::function_calls__Function::get_string 2313 ns 2314 ns 302455 +bm_rtl::method_calls______Method::get_string 2314 ns 2315 ns 302291 + +bm_rtl::function__ErasedReturnType::get_string 2350 ns 2351 ns 297755 +bm_rtl::method____ErasedReturnType::get_string 2354 ns 2354 ns 297340 +bm_rtl::method____ErasedTargetType::get_string 2333 ns 2334 ns 300017 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2366 ns 2366 ns 295941 +----------------------------------- +[2025-11-04 11:45:40] >>> Run 3: workload scale = 90 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 90 iterations +============================================= + +2025-11-04T11:45:40+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 3231.2 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.09, 1.04, 0.75 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1868 ns 1869 ns 374396 + +bm_call::via_function_ptr__Function::set_string 1867 ns 1867 ns 374797 +bm_call::via_function_ptr____Method::set_string 1868 ns 1869 ns 374400 + +bm_std::function_calls__Function::set_string 1867 ns 1868 ns 375065 +bm_std::function_calls____Method::set_string 1871 ns 1872 ns 374292 + +bm_rtl::function_calls__Function::set_string 1867 ns 1867 ns 374894 +bm_rtl::method_calls______Method::set_string 1869 ns 1869 ns 374490 + +bm_rtl::function__ErasedReturnType::set_string 1871 ns 1872 ns 373958 +bm_rtl::method____ErasedReturnType::set_string 1875 ns 1875 ns 373262 +bm_rtl::method____ErasedTargetType::set_string 1883 ns 1883 ns 371719 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1883 ns 1884 ns 371947 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2410 ns 2410 ns 290228 + +bm_call::via_function_ptr__Function::get_string 2410 ns 2411 ns 290367 +bm_call::via_function_ptr____Method::get_string 2412 ns 2413 ns 290266 + +bm_std::function_calls__Function::get_string 2408 ns 2409 ns 290412 +bm_std::function_calls____Method::get_string 2417 ns 2418 ns 289516 + +bm_rtl::function_calls__Function::get_string 2410 ns 2411 ns 290432 +bm_rtl::method_calls______Method::get_string 2411 ns 2411 ns 290130 + +bm_rtl::function__ErasedReturnType::get_string 2448 ns 2449 ns 285773 +bm_rtl::method____ErasedReturnType::get_string 2453 ns 2454 ns 285286 +bm_rtl::method____ErasedTargetType::get_string 2433 ns 2434 ns 287844 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2458 ns 2458 ns 284818 +----------------------------------- +[2025-11-04 11:46:01] >>> Run 1: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-11-04T11:46:01+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2637.51 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 1.03, 0.76 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1962 ns 1962 ns 356628 + +bm_call::via_function_ptr__Function::set_string 1959 ns 1960 ns 357267 +bm_call::via_function_ptr____Method::set_string 1958 ns 1959 ns 357354 + +bm_std::function_calls__Function::set_string 1958 ns 1959 ns 357026 +bm_std::function_calls____Method::set_string 1966 ns 1966 ns 356465 + +bm_rtl::function_calls__Function::set_string 1959 ns 1959 ns 357324 +bm_rtl::method_calls______Method::set_string 1959 ns 1960 ns 357320 + +bm_rtl::function__ErasedReturnType::set_string 1971 ns 1971 ns 354968 +bm_rtl::method____ErasedReturnType::set_string 1967 ns 1968 ns 355173 +bm_rtl::method____ErasedTargetType::set_string 1976 ns 1977 ns 354265 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1977 ns 1978 ns 353660 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2488 ns 2488 ns 281199 + +bm_call::via_function_ptr__Function::get_string 2486 ns 2487 ns 281683 +bm_call::via_function_ptr____Method::get_string 2490 ns 2491 ns 280922 + +bm_std::function_calls__Function::get_string 2492 ns 2492 ns 280970 +bm_std::function_calls____Method::get_string 2494 ns 2495 ns 280222 + +bm_rtl::function_calls__Function::get_string 2485 ns 2486 ns 281630 +bm_rtl::method_calls______Method::get_string 2488 ns 2489 ns 281276 + +bm_rtl::function__ErasedReturnType::get_string 2523 ns 2524 ns 277389 +bm_rtl::method____ErasedReturnType::get_string 2527 ns 2528 ns 276820 +bm_rtl::method____ErasedTargetType::get_string 2504 ns 2504 ns 279332 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2533 ns 2534 ns 276551 +----------------------------------- +[2025-11-04 11:46:22] >>> Run 2: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-11-04T11:46:22+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4866.2 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.03, 0.77 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1958 ns 1959 ns 357126 + +bm_call::via_function_ptr__Function::set_string 1960 ns 1960 ns 357441 +bm_call::via_function_ptr____Method::set_string 1957 ns 1958 ns 357515 + +bm_std::function_calls__Function::set_string 1957 ns 1958 ns 357880 +bm_std::function_calls____Method::set_string 1969 ns 1969 ns 356125 + +bm_rtl::function_calls__Function::set_string 1959 ns 1959 ns 357313 +bm_rtl::method_calls______Method::set_string 1957 ns 1958 ns 357136 + +bm_rtl::function__ErasedReturnType::set_string 1966 ns 1967 ns 355791 +bm_rtl::method____ErasedReturnType::set_string 1968 ns 1968 ns 355742 +bm_rtl::method____ErasedTargetType::set_string 1973 ns 1973 ns 354496 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1978 ns 1979 ns 353748 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2583 ns 2584 ns 270769 + +bm_call::via_function_ptr__Function::get_string 2585 ns 2586 ns 270684 +bm_call::via_function_ptr____Method::get_string 2586 ns 2587 ns 270687 + +bm_std::function_calls__Function::get_string 2591 ns 2592 ns 270101 +bm_std::function_calls____Method::get_string 2592 ns 2593 ns 270162 + +bm_rtl::function_calls__Function::get_string 2588 ns 2589 ns 270376 +bm_rtl::method_calls______Method::get_string 2591 ns 2591 ns 269776 + +bm_rtl::function__ErasedReturnType::get_string 2619 ns 2620 ns 267102 +bm_rtl::method____ErasedReturnType::get_string 2619 ns 2620 ns 267036 +bm_rtl::method____ErasedTargetType::get_string 2601 ns 2602 ns 268965 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2625 ns 2626 ns 266419 +----------------------------------- +[2025-11-04 11:46:43] >>> Run 3: workload scale = 100 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 100 iterations +============================================= + +2025-11-04T11:46:43+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4684.54 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.09, 1.04, 0.78 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 1958 ns 1958 ns 357642 + +bm_call::via_function_ptr__Function::set_string 1976 ns 1976 ns 354513 +bm_call::via_function_ptr____Method::set_string 1975 ns 1975 ns 354409 + +bm_std::function_calls__Function::set_string 1975 ns 1976 ns 354522 +bm_std::function_calls____Method::set_string 2040 ns 2040 ns 342871 + +bm_rtl::function_calls__Function::set_string 1972 ns 1972 ns 355167 +bm_rtl::method_calls______Method::set_string 1973 ns 1974 ns 354698 + +bm_rtl::function__ErasedReturnType::set_string 1969 ns 1970 ns 355340 +bm_rtl::method____ErasedReturnType::set_string 1974 ns 1975 ns 354492 +bm_rtl::method____ErasedTargetType::set_string 1979 ns 1980 ns 353705 +bm_rtl::method____ErasedTargetAndReturnType::set_string 1982 ns 1982 ns 353134 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2570 ns 2571 ns 272122 + +bm_call::via_function_ptr__Function::get_string 2615 ns 2616 ns 267506 +bm_call::via_function_ptr____Method::get_string 2618 ns 2619 ns 267281 + +bm_std::function_calls__Function::get_string 2618 ns 2618 ns 267315 +bm_std::function_calls____Method::get_string 2658 ns 2658 ns 263345 + +bm_rtl::function_calls__Function::get_string 2616 ns 2617 ns 267494 +bm_rtl::method_calls______Method::get_string 2619 ns 2620 ns 267124 + +bm_rtl::function__ErasedReturnType::get_string 2616 ns 2617 ns 267478 +bm_rtl::method____ErasedReturnType::get_string 2615 ns 2616 ns 267658 +bm_rtl::method____ErasedTargetType::get_string 2591 ns 2592 ns 270061 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2620 ns 2620 ns 266947 +----------------------------------- +[2025-11-04 11:47:04] >>> Run 1: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-11-04T11:47:04+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.06, 1.04, 0.78 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 2135 ns 2136 ns 327606 + +bm_call::via_function_ptr__Function::set_string 2134 ns 2135 ns 327517 +bm_call::via_function_ptr____Method::set_string 2134 ns 2135 ns 327554 + +bm_std::function_calls__Function::set_string 2138 ns 2139 ns 327567 +bm_std::function_calls____Method::set_string 2137 ns 2138 ns 326930 + +bm_rtl::function_calls__Function::set_string 2134 ns 2135 ns 328040 +bm_rtl::method_calls______Method::set_string 2134 ns 2135 ns 327050 + +bm_rtl::function__ErasedReturnType::set_string 2140 ns 2141 ns 326742 +bm_rtl::method____ErasedReturnType::set_string 2142 ns 2143 ns 326912 +bm_rtl::method____ErasedTargetType::set_string 2147 ns 2147 ns 326378 +bm_rtl::method____ErasedTargetAndReturnType::set_string 2151 ns 2152 ns 325392 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 2925 ns 2926 ns 239187 + +bm_call::via_function_ptr__Function::get_string 2922 ns 2923 ns 239675 +bm_call::via_function_ptr____Method::get_string 2919 ns 2920 ns 239757 + +bm_std::function_calls__Function::get_string 2922 ns 2923 ns 239511 +bm_std::function_calls____Method::get_string 2927 ns 2927 ns 239088 + +bm_rtl::function_calls__Function::get_string 2921 ns 2922 ns 239587 +bm_rtl::method_calls______Method::get_string 2919 ns 2920 ns 239850 + +bm_rtl::function__ErasedReturnType::get_string 2970 ns 2971 ns 235687 +bm_rtl::method____ErasedReturnType::get_string 2969 ns 2970 ns 235693 +bm_rtl::method____ErasedTargetType::get_string 2939 ns 2940 ns 238228 +bm_rtl::method____ErasedTargetAndReturnType::get_string 2973 ns 2974 ns 235380 +----------------------------------- +[2025-11-04 11:47:25] >>> Run 2: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-11-04T11:47:25+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.04, 1.03, 0.79 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 2143 ns 2143 ns 327009 + +bm_call::via_function_ptr__Function::set_string 2144 ns 2144 ns 326962 +bm_call::via_function_ptr____Method::set_string 2143 ns 2143 ns 326336 + +bm_std::function_calls__Function::set_string 2141 ns 2142 ns 326610 +bm_std::function_calls____Method::set_string 2147 ns 2148 ns 325479 + +bm_rtl::function_calls__Function::set_string 2141 ns 2141 ns 326887 +bm_rtl::method_calls______Method::set_string 2141 ns 2142 ns 326810 + +bm_rtl::function__ErasedReturnType::set_string 2149 ns 2149 ns 325633 +bm_rtl::method____ErasedReturnType::set_string 2152 ns 2152 ns 325416 +bm_rtl::method____ErasedTargetType::set_string 2151 ns 2152 ns 325646 +bm_rtl::method____ErasedTargetAndReturnType::set_string 2159 ns 2160 ns 324017 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3033 ns 3034 ns 230681 + +bm_call::via_function_ptr__Function::get_string 3036 ns 3037 ns 230556 +bm_call::via_function_ptr____Method::get_string 3035 ns 3036 ns 230561 + +bm_std::function_calls__Function::get_string 3036 ns 3037 ns 230558 +bm_std::function_calls____Method::get_string 3044 ns 3045 ns 229777 + +bm_rtl::function_calls__Function::get_string 3036 ns 3036 ns 230539 +bm_rtl::method_calls______Method::get_string 3036 ns 3037 ns 230571 + +bm_rtl::function__ErasedReturnType::get_string 3078 ns 3079 ns 227428 +bm_rtl::method____ErasedReturnType::get_string 3082 ns 3083 ns 227040 +bm_rtl::method____ErasedTargetType::get_string 3052 ns 3053 ns 229389 +bm_rtl::method____ErasedTargetAndReturnType::get_string 3092 ns 3093 ns 226442 +----------------------------------- +[2025-11-04 11:47:47] >>> Run 3: workload scale = 120 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 120 iterations +============================================= + +2025-11-04T11:47:47+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.03, 1.03, 0.80 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 2146 ns 2147 ns 326155 + +bm_call::via_function_ptr__Function::set_string 2146 ns 2146 ns 326275 +bm_call::via_function_ptr____Method::set_string 2146 ns 2146 ns 326240 + +bm_std::function_calls__Function::set_string 2145 ns 2146 ns 325899 +bm_std::function_calls____Method::set_string 2147 ns 2148 ns 325784 + +bm_rtl::function_calls__Function::set_string 2143 ns 2143 ns 326216 +bm_rtl::method_calls______Method::set_string 2144 ns 2144 ns 326155 + +bm_rtl::function__ErasedReturnType::set_string 2152 ns 2153 ns 325106 +bm_rtl::method____ErasedReturnType::set_string 2155 ns 2156 ns 324821 +bm_rtl::method____ErasedTargetType::set_string 2156 ns 2157 ns 324752 +bm_rtl::method____ErasedTargetAndReturnType::set_string 2161 ns 2162 ns 323898 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 3035 ns 3036 ns 230716 + +bm_call::via_function_ptr__Function::get_string 3033 ns 3034 ns 230686 +bm_call::via_function_ptr____Method::get_string 3034 ns 3035 ns 230636 + +bm_std::function_calls__Function::get_string 3034 ns 3034 ns 230656 +bm_std::function_calls____Method::get_string 3047 ns 3048 ns 230042 + +bm_rtl::function_calls__Function::get_string 3040 ns 3041 ns 230018 +bm_rtl::method_calls______Method::get_string 3034 ns 3035 ns 230309 + +bm_rtl::function__ErasedReturnType::get_string 3080 ns 3080 ns 227057 +bm_rtl::method____ErasedReturnType::get_string 3083 ns 3084 ns 226951 +bm_rtl::method____ErasedTargetType::get_string 3056 ns 3057 ns 229016 +bm_rtl::method____ErasedTargetAndReturnType::get_string 3086 ns 3087 ns 226766 +----------------------------------- +[2025-11-04 11:48:09] >>> Run 1: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-11-04T11:48:09+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 800 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.02, 1.03, 0.80 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 3513 ns 3514 ns 199230 + +bm_call::via_function_ptr__Function::set_string 3518 ns 3518 ns 199138 +bm_call::via_function_ptr____Method::set_string 3515 ns 3517 ns 199100 + +bm_std::function_calls__Function::set_string 3513 ns 3514 ns 199262 +bm_std::function_calls____Method::set_string 3522 ns 3523 ns 198748 + +bm_rtl::function_calls__Function::set_string 3511 ns 3512 ns 199310 +bm_rtl::method_calls______Method::set_string 3513 ns 3514 ns 199163 + +bm_rtl::function__ErasedReturnType::set_string 3524 ns 3525 ns 198360 +bm_rtl::method____ErasedReturnType::set_string 3524 ns 3525 ns 198512 +bm_rtl::method____ErasedTargetType::set_string 3528 ns 3529 ns 198173 +bm_rtl::method____ErasedTargetAndReturnType::set_string 3534 ns 3535 ns 198093 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 4425 ns 4426 ns 158169 + +bm_call::via_function_ptr__Function::get_string 4427 ns 4429 ns 158159 +bm_call::via_function_ptr____Method::get_string 4427 ns 4428 ns 158046 + +bm_std::function_calls__Function::get_string 4425 ns 4427 ns 158030 +bm_std::function_calls____Method::get_string 4437 ns 4438 ns 157709 + +bm_rtl::function_calls__Function::get_string 4426 ns 4427 ns 158157 +bm_rtl::method_calls______Method::get_string 4429 ns 4430 ns 158050 + +bm_rtl::function__ErasedReturnType::get_string 4477 ns 4478 ns 156294 +bm_rtl::method____ErasedReturnType::get_string 4477 ns 4479 ns 156172 +bm_rtl::method____ErasedTargetType::get_string 4454 ns 4456 ns 157109 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4486 ns 4487 ns 155951 +----------------------------------- +[2025-11-04 11:48:34] >>> Run 2: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-11-04T11:48:34+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 4900.01 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.02, 0.81 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 3523 ns 3524 ns 198828 + +bm_call::via_function_ptr__Function::set_string 3520 ns 3521 ns 199061 +bm_call::via_function_ptr____Method::set_string 3524 ns 3525 ns 198822 + +bm_std::function_calls__Function::set_string 3518 ns 3519 ns 198928 +bm_std::function_calls____Method::set_string 3530 ns 3531 ns 198583 + +bm_rtl::function_calls__Function::set_string 3521 ns 3522 ns 198936 +bm_rtl::method_calls______Method::set_string 3525 ns 3526 ns 198848 + +bm_rtl::function__ErasedReturnType::set_string 3527 ns 3528 ns 198359 +bm_rtl::method____ErasedReturnType::set_string 3527 ns 3528 ns 197890 +bm_rtl::method____ErasedTargetType::set_string 3534 ns 3535 ns 197890 +bm_rtl::method____ErasedTargetAndReturnType::set_string 3536 ns 3537 ns 197487 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 4456 ns 4457 ns 157300 + +bm_call::via_function_ptr__Function::get_string 4449 ns 4450 ns 157301 +bm_call::via_function_ptr____Method::get_string 4457 ns 4458 ns 157197 + +bm_std::function_calls__Function::get_string 4449 ns 4450 ns 157266 +bm_std::function_calls____Method::get_string 4458 ns 4460 ns 156701 + +bm_rtl::function_calls__Function::get_string 4455 ns 4456 ns 157313 +bm_rtl::method_calls______Method::get_string 4451 ns 4453 ns 157215 + +bm_rtl::function__ErasedReturnType::get_string 4495 ns 4497 ns 155850 +bm_rtl::method____ErasedReturnType::get_string 4494 ns 4495 ns 155702 +bm_rtl::method____ErasedTargetType::get_string 4470 ns 4471 ns 156262 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4508 ns 4510 ns 155393 +----------------------------------- +[2025-11-04 11:48:59] >>> Run 3: workload scale = 150 + +======== RTL Benchmark Configuration ======== +Workload: concatenate string of length 500 +Scale : 150 iterations +============================================= + +2025-11-04T11:48:59+05:30 +Running ./bin/RTLBenchmarkApp +Run on (16 X 2162.72 MHz CPU s) +CPU Caches: + L1 Data 48 KiB (x8) + L1 Instruction 32 KiB (x8) + L2 Unified 1280 KiB (x8) + L3 Unified 20480 KiB (x1) +Load Average: 1.01, 1.02, 0.82 +-------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::set_string 3504 ns 3505 ns 199689 + +bm_call::via_function_ptr__Function::set_string 3505 ns 3506 ns 199740 +bm_call::via_function_ptr____Method::set_string 3504 ns 3505 ns 199829 + +bm_std::function_calls__Function::set_string 3502 ns 3503 ns 199609 +bm_std::function_calls____Method::set_string 3512 ns 3513 ns 199226 + +bm_rtl::function_calls__Function::set_string 3505 ns 3506 ns 199956 +bm_rtl::method_calls______Method::set_string 3504 ns 3505 ns 199794 + +bm_rtl::function__ErasedReturnType::set_string 3519 ns 3520 ns 198946 +bm_rtl::method____ErasedReturnType::set_string 3518 ns 3519 ns 198913 +bm_rtl::method____ErasedTargetType::set_string 3525 ns 3526 ns 198501 +bm_rtl::method____ErasedTargetAndReturnType::set_string 3525 ns 3526 ns 198610 +-------------------------------------------------------------------------------------------------- +bm_call::direct__Function::get_string 4431 ns 4432 ns 157921 + +bm_call::via_function_ptr__Function::get_string 4440 ns 4441 ns 157629 +bm_call::via_function_ptr____Method::get_string 4441 ns 4442 ns 157533 + +bm_std::function_calls__Function::get_string 4440 ns 4441 ns 157655 +bm_std::function_calls____Method::get_string 4437 ns 4438 ns 157742 + +bm_rtl::function_calls__Function::get_string 4439 ns 4440 ns 157633 +bm_rtl::method_calls______Method::get_string 4441 ns 4443 ns 157563 + +bm_rtl::function__ErasedReturnType::get_string 4470 ns 4471 ns 156524 +bm_rtl::method____ErasedReturnType::get_string 4472 ns 4474 ns 156472 +bm_rtl::method____ErasedTargetType::get_string 4448 ns 4449 ns 157314 +bm_rtl::method____ErasedTargetAndReturnType::get_string 4478 ns 4479 ns 156261 +----------------------------------- +All benchmarks completed. From 7aa25a79a441ca58fc8f76830ab8c0fb31799f9c Mon Sep 17 00:00:00 2001 From: Neeraj Date: Tue, 4 Nov 2025 23:21:32 +0530 Subject: [PATCH 136/148] Update README.md --- README.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 112c40f9..62e1d9d5 100644 --- a/README.md +++ b/README.md @@ -55,20 +55,35 @@ Once the functions start doing real work, both perform identically. ## A Quick Preview: Reflection That Looks and Feels Like C++ ```c++ -#include "RTLibInterface.h" // Reflection access interface. +#include // Reflection access interface. ``` Create an instance of `CxxMirror`, passing all type information directly to its constructor — and you’re done! ```c++ auto cxx_mirror = rtl::CxxMirror({ /* ...register all types here... */ + rtl::type().function("complexToStr").build(complexToStr), rtl::type().record("Person").build(), rtl::type().member().constructor().build(), rtl::type().member().method("setAge").build(Person::setAge), rtl::type().member().method("getName").build(Person::getName) }); ``` +The `cxx_mirror` object is your gateway to runtime reflection — it lets you query, introspect, and even instantiate types without any compile-time knowledge or static coupling. It can live anywhere — in any translation unit, quietly sitting in a corner of your codebase. All you need is to expose the `cxx_mirror` wherever reflection is required. -With just this much, you’ve registered your types and unlocked full run-time reflection. The `cxx_mirror` object is your gateway to query, introspect, and instantiate types at run-time — all without compile-time knowledge of those types, without strict static coupling. +And what better way to do that than a Singleton: +```c++ +struct cxx { static rtl::CxxMirror& mirror(); }; +``` +define and register everything in an isolated translation unit. +```c++ +rtl::CxxMirror& cxx::mirror() { + static auto cxx_mirror = rtl::CxxMirror({ + /* ...all type registrations... */ + }); + return cxx_mirror; +} +``` +> Singleton ensures one central registry, initialized once, accessible everywhere. No static coupling, no multiple instances, just clean runtime reflection. **Without reflection:** @@ -82,7 +97,7 @@ std::cout << p.getName(); ```c++ // Look up the class by name -std::optional classPerson = cxx_mirror.getRecord("Person"); +std::optional classPerson = cxx::mirror().getRecord("Person"); if (classPerson) // Check has_value() before use. { From d2b9aff3b1a98c1762a1b3811a8af822a1dd182a Mon Sep 17 00:00:00 2001 From: Neeraj Date: Tue, 4 Nov 2025 23:42:38 +0530 Subject: [PATCH 137/148] Refactor README for improved readability Consolidate multiple lines into single statements for clarity. --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 62e1d9d5..db4f7dbe 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,14 @@ if(cToStr) { // Function materialized? std::string result = cToStr(61, 35); // Works! (int → float? No problem.) } ``` -*No includes. No compile-time linking. No argument type-casting. No guesswork.* -*Just run-time lookup and type-safe invocation*. - +> *No includes. No compile-time linking. No argument type-casting. No guesswork. Just run-time lookup and type-safe invocation.* ### ⚡ Performance Overhead? Practically none. **RTL**’s reflective calls — when return and argument types are known — are just a native function-pointer hop, often faster than `std::function`. Yes — `rtl::function`’s dispatch is faster than `std::function`. -Microbenchmarks show reflective invocations through `rtl::function` have lower call overhead — a single, native pointer jump with no extra indirection. -Once the functions start doing real work, both perform identically. +> Microbenchmarks show reflective invocations through `rtl::function` have lower call overhead — a single, native pointer jump with no extra indirection. Once the functions start doing real work, both perform identically. ### 💡 In One Line @@ -70,7 +67,7 @@ auto cxx_mirror = rtl::CxxMirror({ ``` The `cxx_mirror` object is your gateway to runtime reflection — it lets you query, introspect, and even instantiate types without any compile-time knowledge or static coupling. It can live anywhere — in any translation unit, quietly sitting in a corner of your codebase. All you need is to expose the `cxx_mirror` wherever reflection is required. -And what better way to do that than a Singleton: +And what better way to do that than a **Singleton**: ```c++ struct cxx { static rtl::CxxMirror& mirror(); }; ``` From 68d445120e6aff60d26886a6cad82a3b6dc7f66d Mon Sep 17 00:00:00 2001 From: Neeraj Date: Wed, 5 Nov 2025 00:04:30 +0530 Subject: [PATCH 138/148] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db4f7dbe..c3f516a9 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ auto cxx_mirror = rtl::CxxMirror({ rtl::type().member().method("getName").build(Person::getName) }); ``` -The `cxx_mirror` object is your gateway to runtime reflection — it lets you query, introspect, and even instantiate types without any compile-time knowledge or static coupling. It can live anywhere — in any translation unit, quietly sitting in a corner of your codebase. All you need is to expose the `cxx_mirror` wherever reflection is required. +The `cxx_mirror` object is your gateway to runtime reflection — it lets you query, introspect, and even instantiate types without any compile-time knowledge. It can live anywhere — in any translation unit, quietly sitting in a corner of your codebase. All you need is to expose the `cxx_mirror` wherever reflection is required. And what better way to do that than a **Singleton**: ```c++ From 6e80bf11a3104d33075ee054c72ce76f0ae8c9c9 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 5 Nov 2025 10:48:02 +0530 Subject: [PATCH 139/148] return-erased static_method test, fixes, doc ups. --- README.md | 17 +++--- .../ReflectionOpErrorCodeTests.cpp | 2 +- .../BasicTypeErasedDispatch_Function.cpp | 22 ++++---- .../BasicTypeErasedDispatch_Method.cpp | 22 ++++---- .../BasicTypeErasedDispatch_StaticMethod.cpp | 53 ++++++++++++++++++- .../rtl/detail/inc/FunctionCaller.hpp | 14 +++-- 6 files changed, 95 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index c3f516a9..a37fef42 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,11 @@ Overhead? Practically none. **RTL**’s reflective calls — when return and arg Yes — `rtl::function`’s dispatch is faster than `std::function`. -> Microbenchmarks show reflective invocations through `rtl::function` have lower call overhead — a single, native pointer jump with no extra indirection. Once the functions start doing real work, both perform identically. +> *Microbenchmarks show reflective invocations through `rtl::function` have lower call overhead — a single, native pointer jump with no extra indirection. Once the functions start doing real work, both perform identically.* ### 💡 In One Line -***"RTL is a lightweight, static library that enables a robust, type-safe run-time reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance."*** +*"RTL is a lightweight, static library that enables a robust, type-safe run-time reflection system for C++ — as flexible as in managed languages, yet as close as possible to native performance."* ## What’s more? @@ -57,12 +57,13 @@ Yes — `rtl::function`’s dispatch is faster than `std::function`. Create an instance of `CxxMirror`, passing all type information directly to its constructor — and you’re done! ```c++ auto cxx_mirror = rtl::CxxMirror({ - /* ...register all types here... */ - rtl::type().function("complexToStr").build(complexToStr), + // Register free function - + rtl::type().function("complexToStr").build(complexToStr), + // Register class 'Person'- rtl::type().record("Person").build(), - rtl::type().member().constructor().build(), - rtl::type().member().method("setAge").build(Person::setAge), - rtl::type().member().method("getName").build(Person::getName) + rtl::type().member().constructor().build(), // User defined ctor. + rtl::type().member().method("setAge").build(Person::setAge), // a setter method. + rtl::type().member().method("getName").build(Person::getName) // and a getter. }); ``` The `cxx_mirror` object is your gateway to runtime reflection — it lets you query, introspect, and even instantiate types without any compile-time knowledge. It can live anywhere — in any translation unit, quietly sitting in a corner of your codebase. All you need is to expose the `cxx_mirror` wherever reflection is required. @@ -75,7 +76,7 @@ define and register everything in an isolated translation unit. ```c++ rtl::CxxMirror& cxx::mirror() { static auto cxx_mirror = rtl::CxxMirror({ - /* ...all type registrations... */ + /* ...register all types here... */ }); return cxx_mirror; } diff --git a/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp index c8416f4e..ac75d0ed 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp @@ -8,7 +8,7 @@ * rtl::error::NonConstOverloadMissing * rtl::error::ConstCallViolation * -* Covered in BasicTypeErasedDispatch.cpp +* Covered in ReturnTypeErasedDispatch.cpp * rtl::error::ExplicitRefBindingRequired * * and, diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp index 352c51ad..08b003f3 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp @@ -11,7 +11,7 @@ using namespace test_mirror; namespace rtl_tests { - TEST(BasicTypeErasedRtl_function, invalid_erased_return_rtl_function) + TEST(ReturnTypeErased_rtl_function, invalid_erased_return_rtl_function) { { rtl::function erased_ret_fn; @@ -40,7 +40,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, implicit_resolutions_to_call_by_value_overloads) + TEST(ReturnTypeErased_rtl_function, implicit_resolutions_to_call_by_value_overloads) { auto reverseStrOpt = cxx::mirror().getFunction(str_reverseString); ASSERT_TRUE(reverseStrOpt); @@ -197,7 +197,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) + TEST(ReturnTypeErased_rtl_function, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) { auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); ASSERT_TRUE(revStrOverloadValCRefOpt); @@ -241,7 +241,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) + TEST(ReturnTypeErased_rtl_function, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) { auto revStrOverloadValCRefOpt = cxx::mirror().getFunction(str_revStrOverloadValCRef); ASSERT_TRUE(revStrOverloadValCRefOpt); @@ -278,7 +278,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) + TEST(ReturnTypeErased_rtl_function, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) { auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); ASSERT_TRUE(revStrOverloadValRefOpt); @@ -318,7 +318,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) + TEST(ReturnTypeErased_rtl_function, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) { auto revStrOverloadValRefOpt = cxx::mirror().getFunction(str_revStrOverloadValRef); ASSERT_TRUE(revStrOverloadValRefOpt); @@ -353,7 +353,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, calling_non_overloaded_non_const_ref_argument) + TEST(ReturnTypeErased_rtl_function, calling_non_overloaded_non_const_ref_argument) { auto revStrNonConstRefArgOpt = cxx::mirror().getFunction(str_revStrNonConstRefArg); ASSERT_TRUE(revStrNonConstRefArgOpt); @@ -396,7 +396,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, calling_non_overloaded_const_ref_argument) + TEST(ReturnTypeErased_rtl_function, calling_non_overloaded_const_ref_argument) { auto revStrConstRefArgOpt = cxx::mirror().getFunction(str_revStrConstRefArg); ASSERT_TRUE(revStrConstRefArgOpt); @@ -445,7 +445,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, calling_non_overloaded_rvalue_ref_argument) + TEST(ReturnTypeErased_rtl_function, calling_non_overloaded_rvalue_ref_argument) { auto revStrRValueRefArgOpt = cxx::mirror().getFunction(str_revStrRValueRefArg); ASSERT_TRUE(revStrRValueRefArgOpt); @@ -476,7 +476,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, implicit_resolution_to_ambiguous_ref_and_cref_overload) + TEST(ReturnTypeErased_rtl_function, implicit_resolution_to_ambiguous_ref_and_cref_overload) { auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(revStrOverloadValRefNCrefOpt); @@ -507,7 +507,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_function, explicit_resolution_to_ambiguous_ref_and_cref_overload) + TEST(ReturnTypeErased_rtl_function, explicit_resolution_to_ambiguous_ref_and_cref_overload) { auto revStrOverloadValRefNCrefOpt = cxx::mirror().getFunction(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(revStrOverloadValRefNCrefOpt); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp index 50e88ce2..28e37212 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -12,7 +12,7 @@ using namespace test_mirror; namespace rtl_tests { - TEST(BasicTypeErasedRtl_method, invalid_erased_return_rtl_function) + TEST(ReturnTypeErased_rtl_method, invalid_erased_return_rtl_function) { { rtl::method erased_ret_mt; @@ -41,7 +41,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, implicit_resolutions_to_call_by_value_overloads) + TEST(ReturnTypeErased_rtl_method, implicit_resolutions_to_call_by_value_overloads) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -213,7 +213,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) + TEST(ReturnTypeErased_rtl_method, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -263,7 +263,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) + TEST(ReturnTypeErased_rtl_method, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -306,7 +306,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) + TEST(ReturnTypeErased_rtl_method, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -353,7 +353,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) + TEST(ReturnTypeErased_rtl_method, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -395,7 +395,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, calling_non_overloaded_non_const_ref_argument) + TEST(ReturnTypeErased_rtl_method, calling_non_overloaded_non_const_ref_argument) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -443,7 +443,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, calling_non_overloaded_const_ref_argument) + TEST(ReturnTypeErased_rtl_method, calling_non_overloaded_const_ref_argument) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -498,7 +498,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, calling_non_overloaded_rvalue_ref_argument) + TEST(ReturnTypeErased_rtl_method, calling_non_overloaded_rvalue_ref_argument) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -535,7 +535,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, implicit_resolution_to_ambiguous_ref_and_cref_overload) + TEST(ReturnTypeErased_rtl_method, implicit_resolution_to_ambiguous_ref_and_cref_overload) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); @@ -572,7 +572,7 @@ namespace rtl_tests } - TEST(BasicTypeErasedRtl_method, explicit_resolution_to_ambiguous_ref_and_cref_overload) + TEST(ReturnTypeErased_rtl_method, explicit_resolution_to_ambiguous_ref_and_cref_overload) { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); ASSERT_TRUE(optStringUtil); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp index 04e5f975..4a03360e 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp @@ -10,7 +10,58 @@ using namespace test_mirror; namespace rtl_tests { - TEST(BasicTypeErasedRtl_static_method, implicit_resolutions_to_call_by_value_overloads) + TEST(ReturnTypeErased_rtl_static_method, using_wrong_class_n_callable_apis_for_static_method) + { + { + std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); // has only static-methods. + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT<>(); + EXPECT_FALSE(reverse_string); + EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); + } { + rtl::function reverse_string = static_cast(reverseString.value()) + .argsT() + .returnT<>(); + EXPECT_FALSE(reverse_string); + EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); + } + } { + std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); // doesn't have any static-methods. + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT<>(); + EXPECT_FALSE(reverse_string); + EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidNonStaticMethodCaller); + } { + std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); // doesn't have any static-methods. + ASSERT_TRUE(optStringUtil); + + std::optional reverseString = optStringUtil->getMethod(str_reverseString); + ASSERT_TRUE(reverseString); + { + rtl::static_method reverse_string = reverseString.value() + .argsT() + .returnT<>(); + EXPECT_FALSE(reverse_string); + EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidNonStaticMethodCaller); + } + } + } + + + TEST(ReturnTypeErased_rtl_static_method, implicit_resolutions_to_call_by_value_overloads) { std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); ASSERT_TRUE(optStringUtil); diff --git a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp index f59daefd..4871ca01 100644 --- a/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp +++ b/ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp @@ -118,9 +118,17 @@ namespace rtl::detail continue; } - if (fnMeta.get_member_kind() != member::None && fnMeta.get_member_kind() != member::Static) { - pHopFn.set_init_error(error::InvalidNonStaticMethodCaller); - return; + if constexpr (member_kind == member::Static) { + if (fnMeta.get_member_kind() != member::Static) { + pHopFn.set_init_error(error::InvalidNonStaticMethodCaller); + return; + } + } + else if constexpr (member_kind == member::None) { + if (fnMeta.get_member_kind() == member::Static) { + pHopFn.set_init_error(error::InvalidStaticMethodCaller); + return; + } } auto& erasedRetFn = fnMeta.get_erasure_base() From 287323ebedf6056a4dcf619f3a465a358c319426 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Wed, 5 Nov 2025 15:12:33 +0530 Subject: [PATCH 140/148] test-case & doc update. --- README.md | 2 +- .../BasicTypeErasedDispatch_StaticMethod.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a37fef42..d77d73b9 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ auto cxx_mirror = rtl::CxxMirror({ rtl::type().member().method("getName").build(Person::getName) // and a getter. }); ``` -The `cxx_mirror` object is your gateway to runtime reflection — it lets you query, introspect, and even instantiate types without any compile-time knowledge. It can live anywhere — in any translation unit, quietly sitting in a corner of your codebase. All you need is to expose the `cxx_mirror` wherever reflection is required. +The `cxx_mirror` object is your gateway to runtime reflection — it lets you query, introspect, and even instantiate types without any compile-time knowledge. It can live anywhere — in any translation unit, quietly resting in a corner of your codebase, remaining dormant until first access. All you need is to expose the `cxx_mirror` wherever reflection is required. And what better way to do that than a **Singleton**: ```c++ diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp index 4a03360e..c5bf9360 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp @@ -25,13 +25,21 @@ namespace rtl_tests .returnT<>(); EXPECT_FALSE(reverse_string); EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); + + auto [err, robj] = reverse_string(StringS())(std::string()); + EXPECT_EQ(err, rtl::error::InvalidStaticMethodCaller); + EXPECT_TRUE(robj.isEmpty()); } { rtl::function reverse_string = static_cast(reverseString.value()) .argsT() .returnT<>(); EXPECT_FALSE(reverse_string); EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); - } + + auto [err, robj] = reverse_string(std::string()); + EXPECT_EQ(err, rtl::error::InvalidStaticMethodCaller); + EXPECT_TRUE(robj.isEmpty()); + } } { std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); // doesn't have any static-methods. ASSERT_TRUE(optStringUtil); @@ -44,6 +52,10 @@ namespace rtl_tests .returnT<>(); EXPECT_FALSE(reverse_string); EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidNonStaticMethodCaller); + + auto [err, robj] = reverse_string(std::string()); + EXPECT_EQ(err, rtl::error::InvalidNonStaticMethodCaller); + EXPECT_TRUE(robj.isEmpty()); } { std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); // doesn't have any static-methods. ASSERT_TRUE(optStringUtil); @@ -56,6 +68,10 @@ namespace rtl_tests .returnT<>(); EXPECT_FALSE(reverse_string); EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidNonStaticMethodCaller); + + auto [err, robj] = reverse_string(std::string()); + EXPECT_EQ(err, rtl::error::InvalidNonStaticMethodCaller); + EXPECT_TRUE(robj.isEmpty()); } } } From c5d6c2792b219021ec1c9123099f73ee4b94756e Mon Sep 17 00:00:00 2001 From: Neeraj Date: Thu, 6 Nov 2025 09:50:55 +0530 Subject: [PATCH 141/148] Create reflection-apis-redefined.txt --- .../reflection-apis-redefined.txt | 514 ++++++++++++++++++ 1 file changed, 514 insertions(+) create mode 100644 text-sailors-log/reflection-apis-redefined.txt diff --git a/text-sailors-log/reflection-apis-redefined.txt b/text-sailors-log/reflection-apis-redefined.txt new file mode 100644 index 00000000..137ac67c --- /dev/null +++ b/text-sailors-log/reflection-apis-redefined.txt @@ -0,0 +1,514 @@ +Design log, 06/11/2025 +Author, Neeraj Singh. +------------------------------------- +# Why RTL's API is Different + +Most C++ reflection libraries follow patterns inherited from dynamically-typed languages like Python, Ruby, or JavaScript. These patterns make sense in those contexts—but they're fundamentally mismatched to C++'s nature as a statically-typed, performance-oriented language. + +RTL takes a different approach: **leverage C++'s type system instead of fighting it**. + +--- + +## The Traditional Reflection Model: "Shooting in the Dark" + +**The typical reflection API looks like this:** + +```cpp +// Traditional reflection (most libraries) +result = invoke("functionName", arg1, arg2, arg3); +``` + +**What happens at runtime:** + +1. **Lookup:** Hash map search for "functionName" (~10-50ns) +2. **Arity check:** Does argument count match? (~5ns) +3. **Type validation:** Do argument types match expected types? (~10-30ns) +4. **Type conversion:** Convert arguments if possible (~10-50ns) +5. **Dispatch:** Finally, call the function (~1-2ns) + +**If any step 1-4 fails:** Throw exception (after consuming all that time). + +**If you call this function 1,000 times:** Pay the lookup + validation cost 1,000 times. + +--- + +### **The Problems with This Model** + +#### **1. Performance Degrades at Scale** + +```cpp +// Every call repeats the entire lookup + validation process +for (int i = 0; i < 1000000; i++) { + invoke("processData", data[i]); // 1M × (lookup + validate + dispatch) +} +``` + +**Cost per call:** 30-100ns overhead, even if the function itself is fast. + +For a trivial function (say, 5ns of actual work), **you're spending 85-95% of time on reflection overhead**. + +--- + +#### **2. Error Handling is Reactive, Not Proactive** + +```cpp +try { + result = invoke("funcName", arg1, arg2); +} catch (const ReflectionException& e) { + // What failed? + // - Function not found? + // - Wrong argument count? + // - Type mismatch? + // - Can't convert types? + + // Parse error message to figure it out? 😞 +} +``` + +**You discover errors during the call, not before.** + +Every invocation is a gamble: will it work, or will it throw? + +--- + +#### **3. User Intent is Ambiguous** + +```cpp +invoke("compute", 42, 3.14); +``` + +**Questions the library must guess:** +- Is this a function taking `(int, double)`? +- Or `(double, double)` with int→double conversion? +- Or `(float, float)` with narrowing conversions? +- Or `(long, float)` with multiple conversions? + +**The library guesses. Sometimes it guesses wrong.** + +--- + +## The RTL Model: "Turn On the Lights First" + +RTL separates reflection into **two distinct phases**: + +### **Phase 1: Lookup & Validation (Once)** + +```cpp +rtl::function compute = + mirror.getFunction("compute") + ->argsT() + .returnT(); + +if (!compute) { + // Function doesn't exist or signature doesn't match + // Handle this ONCE, at setup time + std::cerr << "Function 'compute' not found or signature mismatch\n"; + return; +} +``` + +**This is where you "agree and commit":** +- "I want a function named `compute`" +- "That takes `(float, float)`" +- "And returns `std::string`" + +**If this succeeds:** You have a **valid, typed callable**. Invocation is guaranteed to work. + +**If this fails:** You get an empty `optional`. Handle it gracefully, once. + +--- + +### **Phase 2: Dispatch (Many Times, Zero Overhead)** + +```cpp +// Now call it as many times as you want +for (int i = 0; i < 1000000; i++) { + std::string result = compute(data[i].x, data[i].y); // Just dispatch +} +``` + +**What happens per call:** +1. **Dispatch:** Jump to function pointer (~1-2ns) +2. Done. + +**No lookup. No validation. No type checking. No exceptions.** + +**Just a single, native function pointer jump.** + +--- + +## Why This is Architecturally Superior + +### **1. Performance: Amortize the Cost** + +**Traditional Model:** +``` +Total cost = N × (Lookup + Validate + Dispatch) +1,000 calls = 1,000 × (50ns) = 50,000ns = 50µs +``` + +**RTL Model:** +``` +Total cost = 1 × (Lookup + Validate) + N × (Dispatch) +1,000 calls = 1 × (50ns) + 1,000 × (2ns) = 2,050ns = 2µs +``` + +**RTL is 24× faster for 1,000 calls.** + +**The more you call, the bigger RTL's advantage.** + +--- + +### **2. Error Handling: Fail Fast** + +**Traditional:** +```cpp +try { + for (auto& item : data) { + invoke("process", item); // Might fail on iteration 847 + } +} catch (...) { + // Crashed mid-loop. Now what? +} +``` + +**RTL:** +```cpp +auto process = mirror.getFunction("process")->argsT().returnT<>(); + +if (!process) { + // Failed at setup. Handle it BEFORE the loop. + return error("Function 'process' not found"); +} + +// If we get here, all 1,000 calls are guaranteed to work: +for (auto& item : data) { + process(item); // No try-catch needed +} +``` + +**Errors are discovered at lookup time, not call time.** + +**"Fail fast" done right.** + +--- + +### **3. User Intent is Explicit** + +**Traditional (ambiguous):** +```cpp +invoke("func", 42, 3.14); // What signature does user expect? +``` + +**RTL (explicit):** +```cpp +rtl::function func = ...; // User declares intent +func(42, 3.14); // Compiler enforces it +``` + +**No guessing. User's expectations are crystal clear.** + +--- + +### **4. Composability** + +RTL's callables are **first-class objects**: + +```cpp +// Store them +std::map> handlers; +handlers["onConnect"] = mirror.getFunction("handleConnect")->argsT(); +handlers["onDisconnect"] = mirror.getFunction("handleDisconnect")->argsT(); + +// Pass them around +void registerHandler(const std::string& event, rtl::function handler); + +// Compose them +auto combined = [f1, f2](int x) { f1(x); f2(x); }; +``` + +**You can't do this with `invoke("name", ...)` — the lookup is coupled to the call.** + +--- + +## The Type System is Your Friend + +### **Insight: Types Exist at the Call Site** + +When you write: +```cpp +int x = 42; +float y = 3.14f; +invoke("compute", x, y); +``` + +**The compiler knows `x` is `int` and `y` is `float`.** + +**Why throw away that information just to rediscover it at runtime?** + +--- + +### **RTL's Philosophy:** + +> **"C++ is statically typed. Users write typed code. Reflection should use those types, not fight them."** + +When you write: +```cpp +rtl::function compute = ...; +compute(x, y); +``` + +**The compiler:** +- Knows you're calling a function expecting `(int, float)` +- Knows you're passing `(int, float)` +- Validates this at compile time (if variables are typed) +- Generates the call with zero overhead + +**RTL just forwards the arguments. The compiler does the rest.** + +--- + +## The Two Design Decisions That Make This Work + +### **Decision 1: Let C++ Handle Implicit Conversions** + +**Most reflection libraries try to implement conversion logic:** + +```cpp +// What other libraries do (pseudocode): +if (arg_type == int && param_type == float) { + float converted = static_cast(arg); + // Now handle: double, long, short, unsigned... + // Also handle: const, pointers, references... + // Also handle: user-defined conversions... + // 5,000 lines later... +} +``` + +**RTL's approach:** + +```cpp +// User declares expected types +rtl::function func = ...; + +// User passes ints +func(61, 35); // Compiler converts int→float (standard C++) +``` + +**RTL doesn't handle conversions. C++ does.** + +**Benefits:** +- ✅ Zero conversion code to write/maintain +- ✅ Zero runtime overhead (compiler optimizes) +- ✅ All standard conversions work automatically +- ✅ User-defined conversions work automatically +- ✅ Perfect forwarding works +- ✅ Const-correctness preserved + +**RTL leverages the compiler instead of reimplementing it.** + +--- + +### **Decision 2: Decouple Lookup from Invocation** + +**Most libraries couple them:** +```cpp +invoke(name, args) = [Lookup + Validate + Call] as one operation +``` + +**RTL decouples them:** +```cpp +callable = lookup(name, signature) // Once +callable(args) // Many times +``` + +**This separation gives you:** +- ✅ Performance (amortize lookup cost) +- ✅ Safety (validate once, call many) +- ✅ Clarity (errors at lookup, not call) +- ✅ Composability (callables are values) + +**Single Responsibility Principle applied to reflection.** + +--- + +## A Complete Example: Before and After + +### **Traditional Reflection Library** + +```cpp +// Setup (none needed, everything happens at call-time) + +// Usage +void processData(const std::vector& data) { + for (const auto& point : data) { + try { + // Every call: lookup + validate + dispatch + auto result = reflection::invoke("computeValue", point.x, point.y); + + // Type-cast the result (runtime check) + double value = std::any_cast(result); + + // Use value... + } catch (const reflection::NotFoundException& e) { + // Function not found + } catch (const reflection::TypeMismatchException& e) { + // Type error + } catch (const std::bad_any_cast& e) { + // Wrong return type + } + } +} +``` + +**Problems:** +- ❌ Lookup + validation × N times (slow) +- ❌ Three different exception types to catch +- ❌ Runtime type casting required +- ❌ Errors discovered during loop (too late) + +--- + +### **RTL Approach** + +```cpp +// Setup (once, at initialization) +auto computeValue = mirror.getFunction("computeValue") + ->argsT() + .returnT(); + +if (!computeValue) { + // Handle error at setup time + return error("Function 'computeValue' not found or signature mismatch"); +} + +// Usage +void processData(const std::vector& data) { + for (const auto& point : data) { + // Just dispatch (no lookup, no validation, no exceptions) + double value = computeValue(point.x, point.y); + + // Use value... + } +} +``` + +**Benefits:** +- ✅ Lookup + validation once (fast) +- ✅ Zero exception handling in loop +- ✅ Statically typed result (no casting) +- ✅ Errors discovered before loop (fail fast) + +--- + +## When to Use Each API Style + +RTL provides **two APIs** for different scenarios: + +### **Typed API (When You Know Types)** + +```cpp +// You know the signature at the call site +rtl::function func = + mirror.getFunction("toString") + ->argsT() + .returnT(); + +std::string result = func(42, 100); // Compile-time type checking +``` + +**Use when:** +- You know the function signature +- You want compile-time type safety +- You need maximum performance (~1-2ns overhead) + +--- + +### **Type-Erased API (When Types are Unknown)** + +```cpp +// Runtime flexibility when types aren't known at compile time +auto [err, result] = mirror.getFunction("toString") + ->bind(obj) + .call(42, 100); + +if (err == rtl::error::None && result.canViewAs()) { + std::string str = result.view()->get(); +} +``` + +**Use when:** +- Loading plugins at runtime +- Scripting language integration +- Serialization/deserialization +- Generic tool building (debuggers, editors) + +**Even the type-erased API separates lookup from invocation:** +- Lookup: `getFunction("toString")` +- Invocation: `call(args)` + +--- + +## The Philosophy: "Ask, Don't Assume" + +**Traditional reflection:** +```cpp +invoke("func", args); // Hope it works, catch if it doesn't +``` + +**RTL:** +```cpp +auto func = mirror.getFunction("func")->argsT(); +if (func) { + func(args); // Guaranteed to work +} else { + // Handle the known error +} +``` + +**Instead of assuming the function exists and catching exceptions when it doesn't, RTL lets you ASK:** + +- "Does this function exist?" +- "Does it have this signature?" +- "Give me a callable if yes, null if no." + +**Then you decide what to do.** + +**This is:** +- More explicit (no hidden exceptions) +- More efficient (no wasted work on invalid calls) +- More composable (callables are values) + +--- + +## Summary: Two Key Insights + +### **1. C++ Has Types — Use Them** + +**Don't throw away type information just to rediscover it at runtime.** + +Let users declare expected types. Let the compiler handle conversions and validation. Reflection becomes a thin layer, not a complex runtime system. + +--- + +### **2. Separate Lookup from Dispatch** + +**Don't couple lookup + validation with every call.** + +Validate once at setup. Then dispatch becomes a single function pointer jump — as fast as C++ can possibly be. + +--- + +## The Result + +**RTL reflection calls are 10-50× faster than traditional reflection.** + +**Not through clever optimization tricks.** + +**Through better architecture.** + +--- + +**By thinking in C++ instead of copying dynamic languages, RTL achieves both flexibility AND performance.** + +**That's the RTL difference.** From 0d7382c48001da3cf814a8bcbe2d9c4468e189c3 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Thu, 6 Nov 2025 09:51:45 +0530 Subject: [PATCH 142/148] Rename reflection-apis-redefined.txt to reflection-apis-redefined.md --- ...reflection-apis-redefined.txt => reflection-apis-redefined.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename text-sailors-log/{reflection-apis-redefined.txt => reflection-apis-redefined.md} (100%) diff --git a/text-sailors-log/reflection-apis-redefined.txt b/text-sailors-log/reflection-apis-redefined.md similarity index 100% rename from text-sailors-log/reflection-apis-redefined.txt rename to text-sailors-log/reflection-apis-redefined.md From 960e6990efe01b828c0ba6e413bb80c2596cc32d Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Fri, 7 Nov 2025 22:45:27 +0530 Subject: [PATCH 143/148] CxxTestRegistration: code-improvement, wip. --- CxxTestProps/inc/Complex.h | 5 ++ CxxTestProps/inc/StringOps.h | 3 - CxxTestRegistration/inc/Registration.h | 28 +++++++ CxxTestRegistration/inc/TestMirrorProvider.h | 12 ++- .../src/AnimalRegistration.cpp | 82 +++++++++++++++++++ CxxTestRegistration/src/BookRegistration.cpp | 60 ++++++++++++++ CxxTestRegistration/src/CMakeLists.txt | 10 +++ .../src/CalenderRegistration.cpp | 42 ++++++++++ .../src/ComplexRegistration.cpp | 33 ++++++++ CxxTestRegistration/src/DateRegistration.cpp | 40 +++++++++ CxxTestRegistration/src/EventRegistration.cpp | 24 ++++++ .../src/LibraryRegistration.cpp | 30 +++++++ .../src/PersonRegistration.cpp | 72 ++++++++++++++++ .../src/PodStdRegistration.cpp | 60 ++++++++++++++ .../src/TestMirrorProvider.cpp | 4 +- .../FunctionalityTests/ClassMethodsTests.cpp | 2 + .../ConstMethodOverloadTests.cpp | 2 + .../FunctionalityTests/ConstructorTests.cpp | 2 + .../CopyConstructorTests.cpp | 2 + .../MoveConstructorTests.cpp | 1 + .../NameSpaceGlobalsTests.cpp | 4 +- .../PerfectForwardingTests.cpp | 2 + .../ReflectionOpErrorCodeTests.cpp | 2 + .../ReturnValueReflectionTest.cpp | 3 +- .../FunctionalityTests/StaticMethodTests.cpp | 1 + .../StrictStaticTypeDispatch_ConstMethod.cpp | 1 + .../StrictStaticTypeDispatch_Function.cpp | 3 +- .../StrictStaticTypeDispatch_Method.cpp | 4 +- .../StrictStaticTypeDispatch_StaticMethod.cpp | 1 + .../BasicTypeErasedDispatch_Function.cpp | 3 +- .../BasicTypeErasedDispatch_Method.cpp | 3 +- .../BasicTypeErasedDispatch_StaticMethod.cpp | 2 + .../MyReflectionTests/MyCxxMirrorProvider.cpp | 4 +- 33 files changed, 531 insertions(+), 16 deletions(-) create mode 100644 CxxTestRegistration/inc/Registration.h create mode 100644 CxxTestRegistration/src/AnimalRegistration.cpp create mode 100644 CxxTestRegistration/src/BookRegistration.cpp create mode 100644 CxxTestRegistration/src/CalenderRegistration.cpp create mode 100644 CxxTestRegistration/src/ComplexRegistration.cpp create mode 100644 CxxTestRegistration/src/DateRegistration.cpp create mode 100644 CxxTestRegistration/src/EventRegistration.cpp create mode 100644 CxxTestRegistration/src/LibraryRegistration.cpp create mode 100644 CxxTestRegistration/src/PersonRegistration.cpp create mode 100644 CxxTestRegistration/src/PodStdRegistration.cpp diff --git a/CxxTestProps/inc/Complex.h b/CxxTestProps/inc/Complex.h index 680d6b44..808a270f 100644 --- a/CxxTestProps/inc/Complex.h +++ b/CxxTestProps/inc/Complex.h @@ -1,5 +1,10 @@ #pragma once +#include + +// C-style/free-functions. +std::string getComplexNumAsString(); + namespace complex { double getMagnitude(); diff --git a/CxxTestProps/inc/StringOps.h b/CxxTestProps/inc/StringOps.h index b59aa993..ba7f9af6 100644 --- a/CxxTestProps/inc/StringOps.h +++ b/CxxTestProps/inc/StringOps.h @@ -2,9 +2,6 @@ #include -// C-style/free-functions. -std::string getComplexNumAsString(); - std::string reverseString(); std::string reverseString(const char* pStr); diff --git a/CxxTestRegistration/inc/Registration.h b/CxxTestRegistration/inc/Registration.h new file mode 100644 index 00000000..013f2a8a --- /dev/null +++ b/CxxTestRegistration/inc/Registration.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +namespace rtl { + class Function; +} + +namespace test_mirror +{ + static void registerPodStdTypes(std::vector&); + + static void registerTypeComplex(std::vector&); + + static void registerTypeDate(std::vector&); + + static void registerTypeEvent(std::vector&); + + static void registerTypeCalender(std::vector&); + + static void registerTypePerson(std::vector&); + + static void registerTypeBook(std::vector&); + + static void registerTypeLibrary(std::vector&); + + static void registerTypeAnimal(std::vector&); +} \ No newline at end of file diff --git a/CxxTestRegistration/inc/TestMirrorProvider.h b/CxxTestRegistration/inc/TestMirrorProvider.h index 1bb72c4d..8ab87235 100644 --- a/CxxTestRegistration/inc/TestMirrorProvider.h +++ b/CxxTestRegistration/inc/TestMirrorProvider.h @@ -1,15 +1,19 @@ #pragma once -#include +namespace rtl { + class CxxMirror; +} namespace test_mirror { - struct cxx - { + struct cxx { + static const rtl::CxxMirror& mirror(); }; +} - +namespace test_mirror +{ // Optional setup: do this if you prefer to access your registered types by unique 'ID', not by string. struct reflected_id { diff --git a/CxxTestRegistration/src/AnimalRegistration.cpp b/CxxTestRegistration/src/AnimalRegistration.cpp new file mode 100644 index 00000000..33c4194c --- /dev/null +++ b/CxxTestRegistration/src/AnimalRegistration.cpp @@ -0,0 +1,82 @@ + +#include + +#include "Animal.h" +#include "Registration.h" +#include "TestUtilsAnimal.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypeAnimal(std::vector& fns) + { + // class 'Animal', methods & constructors. + fns.push_back(rtl::type().record(animal::class_) + .build()); + + fns.push_back(rtl::type().member() + .constructor() + .build()); //overloaded constructor. + + fns.push_back(rtl::type().member() + .method(animal::str_setFamilyName) + .build(&Animal::setFamilyName)); //unique method, no overloads. + + // Unique const-method, no overloads. + fns.push_back(rtl::type().member() + .methodConst(animal::str_getFamilyName) + .build(&Animal::getFamilyName)); + + // Overloaded method, taking const-ref as argument. + fns.push_back(rtl::type().member() + .method(animal::str_setAnimalName) + .build(&Animal::setAnimalName)); + + // Static method, taking const-ref as argument. + fns.push_back(rtl::type().member() + .methodStatic(animal::str_updateZooKeeper) + .build(&Animal::updateZooKeeper)); + +#if defined(__GNUC__) && !defined(__clang__) +/* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the member function pointer, e.g.: + + static_cast(&Animal::setAnimalName) +*/ + fns.push_back(rtl::type().member() + .method(animal::str_setAnimalName) + .build(static_cast(&Animal::setAnimalName))); //overloaded method, taking non-const lvalue reference as argument. + + fns.push_back(rtl::type().member() + .method(animal::str_setAnimalName) + .build(static_cast(&Animal::setAnimalName))); //overloaded method, taking rvalue reference as argument. + + fns.push_back(rtl::type().member() + .methodStatic(animal::str_updateZooKeeper) + .build(static_cast(&Animal::updateZooKeeper))); //static method, taking non-const lvalue reference as argument. + + fns.push_back(rtl::type().member() + .methodStatic(animal::str_updateZooKeeper) + .build(static_cast(&Animal::updateZooKeeper))); //static method, taking rvalue reference as argument. +#else + fns.push_back(rtl::type().member() + .method(animal::str_setAnimalName) + .build(&Animal::setAnimalName)); //overloaded method, taking non-const lvalue reference as argument. + + fns.push_back(rtl::type().member() + .method(animal::str_setAnimalName) + .build(&Animal::setAnimalName)); //overloaded method, taking rvalue reference as argument. + + fns.push_back(rtl::type().member() + .methodStatic(animal::str_updateZooKeeper) + .build(&Animal::updateZooKeeper)); //static method, taking non-const lvalue reference as argument. + + fns.push_back(rtl::type().member() + .methodStatic(animal::str_updateZooKeeper) + .build(&Animal::updateZooKeeper)); //static method, taking rvalue reference as argument. +#endif + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/BookRegistration.cpp b/CxxTestRegistration/src/BookRegistration.cpp new file mode 100644 index 00000000..b980d707 --- /dev/null +++ b/CxxTestRegistration/src/BookRegistration.cpp @@ -0,0 +1,60 @@ + +#include + +#include "Book.h" +#include "Registration.h" +#include "TestUtilsBook.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypeBook(std::vector& fns) + { + // class 'Book', methods & constructors. + // Registering default constructor. + fns.push_back(rtl::type().record(book::class_) + .build()); + + // Registering overloaded constructor, signature must be specified as template parameter. + fns.push_back(rtl::type().member() + .constructor() + .build()); + + // Unique methods, no overloads. + fns.push_back(rtl::type().member() + .method(book::str_setAuthor) + .build(&Book::setAuthor)); + + // Unique method, taking 'std::string' & 'const std::string&' as argument, auto deduced via function-pointer. + fns.push_back(rtl::type().member() + .method(book::str_addPreface) + .build(&Book::addPreface)); + + // Furthur registrations of unique-menthods, signature auto-deduced via function pointer. + fns.push_back(rtl::type().member() + .method(book::str_setDescription) + .build(&Book::setDescription)); + + fns.push_back(rtl::type().member() + .method(book::str_getPublishedOn) + .build(&Book::getPublishedOn)); + + fns.push_back(rtl::type().member() + .method(book::str_addCopyrightTag) + .build(&Book::addCopyrightTag)); + + // Registering overloaded methods, signature must be specified as template params since other overloads exists, else compiler error. + fns.push_back(rtl::type().member() + .method(book::str_updateBookInfo) + .build(&Book::updateBookInfo)); + + fns.push_back(rtl::type().member() + .method(book::str_updateBookInfo) + .build(&Book::updateBookInfo)); + + fns.push_back(rtl::type().member() + .method(book::str_updateBookInfo) + .build(&Book::updateBookInfo)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/CMakeLists.txt b/CxxTestRegistration/src/CMakeLists.txt index f021f09a..51847336 100644 --- a/CxxTestRegistration/src/CMakeLists.txt +++ b/CxxTestRegistration/src/CMakeLists.txt @@ -6,9 +6,19 @@ project(CxxTestRegistration) # Create a variable containing the source files for your target set(LOCAL_SOURCES "${CMAKE_CURRENT_LIST_DIR}/TestMirrorProvider.cpp" + "${CMAKE_CURRENT_LIST_DIR}/AnimalRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BookRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/CalenderRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/ComplexRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/DateRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/EventRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/LibraryRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/PersonRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/PodStdRegistration.cpp" ) SET(LOCAL_HEADERS + "${PROJECT_SOURCE_DIR}/inc/Registration.h" "${PROJECT_SOURCE_DIR}/inc/TestMirrorProvider.h" ) diff --git a/CxxTestRegistration/src/CalenderRegistration.cpp b/CxxTestRegistration/src/CalenderRegistration.cpp new file mode 100644 index 00000000..6896607c --- /dev/null +++ b/CxxTestRegistration/src/CalenderRegistration.cpp @@ -0,0 +1,42 @@ + +#include + +#include "Registration.h" + +#include "Date.h" +#include "TestUtilsDate.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypeCalender(std::vector& fns) + { + // Registring static-method, 'methodStatic()' function must be used. compiler error otherwise. + fns.push_back(rtl::type().member() + .methodStatic(calender::str_create) + .build(&nsdate::Calender::create)); + + // Registring unique methods of class Calender, no overloads. + fns.push_back(rtl::type().member() + .method(calender::str_getTheEvent) + .build(&nsdate::Calender::getTheEvent)); + + fns.push_back(rtl::type().member() + .method(calender::str_getTheDate) + .build(&nsdate::Calender::getTheDate)); + + fns.push_back(rtl::type().member() + .method(calender::str_getSavedEvent) + .build(&nsdate::Calender::getSavedEvent)); + + fns.push_back(rtl::type().member() + .method(calender::str_getSavedDate) + .build(&nsdate::Calender::getSavedDate)); + + // class Calender, registering after the methods. (order doesn't matter) + fns.push_back(rtl::type().ns(date::ns) + .record(calender::struct_) + .build()); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/ComplexRegistration.cpp b/CxxTestRegistration/src/ComplexRegistration.cpp new file mode 100644 index 00000000..51ad05fc --- /dev/null +++ b/CxxTestRegistration/src/ComplexRegistration.cpp @@ -0,0 +1,33 @@ + +#include + +#include "Complex.h" +#include "Registration.h" +#include "GlobalTestUtils.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypeComplex(std::vector& fns) + { + // Unique function, no overloads, no need to specify signature as template parameters. + fns.push_back(rtl::type().function(str_getComplexNumAsString) + .build(getComplexNumAsString)); + + /* Grouping functions under a namespace, which is optional. they can be registered without it as well. + but if registered under namspace, then to retrieve it from CxxMirror object, namespace name must be passed, + e.g. cxx::mirror().getFunction("namespace_name", "function_name") & cxx::mirror().getRecord("namespace_name", "record_name") */ + fns.push_back(rtl::type().ns(str_complex) + .function(str_setReal) + .build(complex::setReal)); + + fns.push_back(rtl::type().ns(str_complex) + .function(str_setImaginary) + .build(complex::setImaginary)); + + fns.push_back(rtl::type().ns(str_complex) + .function(str_getMagnitude) + .build(complex::getMagnitude)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/DateRegistration.cpp b/CxxTestRegistration/src/DateRegistration.cpp new file mode 100644 index 00000000..785d4424 --- /dev/null +++ b/CxxTestRegistration/src/DateRegistration.cpp @@ -0,0 +1,40 @@ + +#include + +#include "Date.h" +#include "Registration.h" +#include "TestUtilsDate.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypeDate(std::vector& fns) + { + // Constructors registration, class/struct name and type must be passed 'record("NAME")'. + // Registers default constructor with implicit registration of destructor & copy-constructor. + fns.push_back(rtl::type().ns(date::ns) + .record(date::struct_) + .build()); + + // Overloaded constructor, taking 'string' as argument, signature must be specified as template parameter. + fns.push_back(rtl::type().member() + .constructor() + .build()); + + // Again, register an overloaded constructor with diffeent signature. + fns.push_back(rtl::type().member() + .constructor() + .build()); + + // Registring, Unique method, no overloads. Taking param 'std::string', auto deduced via function-pointer. + fns.push_back(rtl::type().member() + .method(date::str_updateDate) + .build(&nsdate::Date::updateDate)); + + // Registring const-method, 'methodConst()' function must be used. compiler error otherwise. + fns.push_back(rtl::type().member() + .methodConst(date::str_getAsString) + .build(&nsdate::Date::getAsString)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/EventRegistration.cpp b/CxxTestRegistration/src/EventRegistration.cpp new file mode 100644 index 00000000..d431113e --- /dev/null +++ b/CxxTestRegistration/src/EventRegistration.cpp @@ -0,0 +1,24 @@ + +#include + +#include "Date.h" +#include "Registration.h" +#include "TestUtilsDate.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypeEvent(std::vector& fns) + { + // Registering 'Event' for reflection; instance creation via reflection fails since its default constructor is private or deleted. + // At least one member must be registered for RTL to recognize the type. be it property, member-function or constructor. + fns.push_back(rtl::type().ns(event::ns) + .record(event::struct_) + .build()); + + fns.push_back(rtl::type().member() + .method(event::str_reset) + .build(&nsdate::Event::reset)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/LibraryRegistration.cpp b/CxxTestRegistration/src/LibraryRegistration.cpp new file mode 100644 index 00000000..2ed5c811 --- /dev/null +++ b/CxxTestRegistration/src/LibraryRegistration.cpp @@ -0,0 +1,30 @@ + +#include + +#include "Book.h" +#include "Library.h" +#include "Registration.h" +#include "TestUtilsBook.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypeLibrary(std::vector& fns) + { + // Registering Library's constructor. Stack allocation (rtl::alloc::Stack) will fail since its copy constructor is deleted + // and its required by 'std::any' to store its object via copy-construction. But instance on heap (rtl::alloc::HEAP) can be + // constructed since, in that case, 'std::any' stores only the poiner which does not requires copy constructor to be called. + fns.push_back(rtl::type().record(library::class_) + .build()); + + // Registring static-method, 'methodStatic()' function must be used. compiler error otherwise. + fns.push_back(rtl::type().member() + .methodStatic(library::str_addBook) + .build(&Library::addBook)); + + fns.push_back(rtl::type().member() + .methodStatic(library::str_getBookByTitle) + .build(&Library::getBookByTitle)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/PersonRegistration.cpp b/CxxTestRegistration/src/PersonRegistration.cpp new file mode 100644 index 00000000..48928c3d --- /dev/null +++ b/CxxTestRegistration/src/PersonRegistration.cpp @@ -0,0 +1,72 @@ + +#include + +#include "Person.h" +#include "Registration.h" +#include "TestUtilsPerson.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypePerson(std::vector& fns) + { + // class 'Person', methods & constructors. + fns.push_back(rtl::type().record(person::class_) + .build()); + + fns.push_back(rtl::type().member() + .constructor() + .build()); + + fns.push_back(rtl::type().member() + .methodStatic(person::str_createPtr) + .build(&Person::createPtr)); + + fns.push_back(rtl::type().member() + .method(person::str_updateAddress) + .build(&Person::updateAddress)); + + fns.push_back(rtl::type().member() + .method(person::str_updateAddress) + .build(&Person::updateAddress)); + + fns.push_back(rtl::type().member() + .method(person::str_getFirstName) + .build(&Person::getFirstName)); + + // Registring const-method, 'methodConst()' function must be used. compiler error otherwise. + fns.push_back(rtl::type().member() + .methodConst(person::str_updateLastName) + .build(&Person::updateLastName)); + + // Registring const-method overload, non-const overloaded method already registered above. + fns.push_back(rtl::type().member() + .methodConst(person::str_updateAddress) + .build(&Person::updateAddress)); + + fns.push_back(rtl::type().member() + .methodConst(person::str_updateAddress) + .build(&Person::updateAddress)); + + fns.push_back(rtl::type().member() + .methodStatic(person::str_getDefaults) + .build(&Person::getDefaults)); + + fns.push_back(rtl::type().member() + .methodStatic(person::str_createConst) + .build(&Person::createConst)); + + fns.push_back(rtl::type().member() + .methodStatic(person::str_getProfile) + .build(&Person::getProfile)); + + fns.push_back(rtl::type().member() + .methodStatic(person::str_getProfile) + .build(&Person::getProfile)); + + fns.push_back(rtl::type().member() + .methodStatic(person::str_getProfile) + .build(&Person::getProfile)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/PodStdRegistration.cpp b/CxxTestRegistration/src/PodStdRegistration.cpp new file mode 100644 index 00000000..fae4d44e --- /dev/null +++ b/CxxTestRegistration/src/PodStdRegistration.cpp @@ -0,0 +1,60 @@ + +#include + +#include "Registration.h" + +namespace test_mirror +{ + void registerPodStdTypes(std::vector& fns) + { + // Registering int. + fns.push_back(rtl::type().record("int") + .build()); + + // Registering type 'int' again, ignored & emits- + // [WARNING] Multiple registrations of the same type detected. + fns.push_back(rtl::type().record("int") + .build()); + + // Registering type 'void' again, but with different name. ignored & emits- + // [WARNING] Multiple registrations of the same type detected. + fns.push_back(rtl::type().record("ccint") + .build()); + + // Registering pod, reflecting- constructor, copy-constructor & destructor. + fns.push_back(rtl::type().record("char") + .build()); + + fns.push_back(rtl::type().ns("std") + .record("string_view") + .build()); + + // Registers std::string class + fns.push_back(rtl::type().member() + .methodConst("empty") + .build(&std::string::empty)); + + /* Attempting to register the same type(`std::string`) again under a different name. + * RTL will ignore this duplicate registration and retain the first one. Emits a warning on the console: + * "[WARNING] Multiple registrations of the same type with different names detected." + */ fns.push_back(rtl::type().member() + .methodConst("empty") + .build(&std::string::empty)); + + fns.push_back(rtl::type().ns("std") + .record("string") + .build()); + + /* Attempting to register std::string_view, but the provided member function pointer belongs to std::string. + * RTL will ignore this registration. Emits a warning on the console: + * "[WARNING] Member function pointer does not belong to the class being registered!" + */ fns.push_back(rtl::type().member() + .methodConst("empty") + .build(&std::string::empty)); + + // Finally, register std::string_view with correct member-function-pointer + fns.push_back(rtl::type().member() + .methodConst("empty") + .build(&std::string_view::empty)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 72af7793..95afde7d 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -19,7 +19,9 @@ /* TestUtils, provides the interface to test/compare reflected type objects with actual objects (created via strict typing) without exposing the actual type objects to "CxxReflectionTests" project.*/ -#include "Reflect.h" +#include "Reflect.hpp" +#include "CxxMirror.h" + #include "TestUtilsBook.h" #include "TestUtilsDate.h" #include "TestUtilsPerson.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp index 319807b3..f1804d82 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp @@ -1,3 +1,5 @@ + +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp index 874c66d0..9054c390 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp @@ -1,3 +1,5 @@ + +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/ConstructorTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ConstructorTests.cpp index 66ad00e4..9255e4d2 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ConstructorTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ConstructorTests.cpp @@ -1,3 +1,5 @@ + +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/CopyConstructorTests.cpp b/RTLTestRunApp/src/FunctionalityTests/CopyConstructorTests.cpp index 86ba0331..7fcab755 100644 --- a/RTLTestRunApp/src/FunctionalityTests/CopyConstructorTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/CopyConstructorTests.cpp @@ -1,3 +1,5 @@ + +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/MoveConstructorTests.cpp b/RTLTestRunApp/src/FunctionalityTests/MoveConstructorTests.cpp index 02431be3..36f687f0 100644 --- a/RTLTestRunApp/src/FunctionalityTests/MoveConstructorTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/MoveConstructorTests.cpp @@ -1,4 +1,5 @@ +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp index 8b277ff9..80b451f6 100644 --- a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp @@ -1,7 +1,9 @@ -#include +#include #include +#include + #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp b/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp index 642d0b2c..77ffc81a 100644 --- a/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/PerfectForwardingTests.cpp @@ -16,6 +16,8 @@ * - `RObject`: A type-erased wrapper for return values and objects created via reflection, ensuring proper memory management. */ + +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp index ac75d0ed..469718c4 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ReflectionOpErrorCodeTests.cpp @@ -18,6 +18,8 @@ * */ + +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/ReturnValueReflectionTest.cpp b/RTLTestRunApp/src/FunctionalityTests/ReturnValueReflectionTest.cpp index 61bc03ed..e0271cde 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ReturnValueReflectionTest.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ReturnValueReflectionTest.cpp @@ -1,10 +1,9 @@ +#include #include #include "TestMirrorProvider.h" #include "TestUtilsDate.h" -//#include "TestUtilsBook.h" -//#include "GlobalTestUtils.h" using namespace test_utils; using namespace test_mirror; diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp index 7de57a83..f28536a4 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticMethodTests.cpp @@ -1,4 +1,5 @@ +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp index 8f3711f9..86c7e08c 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp @@ -1,4 +1,5 @@ +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp index c5d96267..93bdb379 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Function.cpp @@ -1,6 +1,7 @@ -#include +#include #include +#include #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp index 2f198244..9b01a657 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -1,7 +1,9 @@ -#include +#include #include +#include + #include "TestMirrorProvider.h" #include "GlobalTestUtils.h" #include "../CxxTestProps/inc/StringOps.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index 329f684e..b0019fcf 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -1,4 +1,5 @@ +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp index 08b003f3..d32dda88 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Function.cpp @@ -1,6 +1,7 @@ -#include +#include #include +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp index 28e37212..63f300b3 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -1,6 +1,7 @@ -#include +#include #include +#include #include #include "TestMirrorProvider.h" diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp index c5bf9360..8653f3a5 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp @@ -1,3 +1,5 @@ + +#include #include #include diff --git a/RTLTestRunApp/src/MyReflectionTests/MyCxxMirrorProvider.cpp b/RTLTestRunApp/src/MyReflectionTests/MyCxxMirrorProvider.cpp index 1fa8fe82..b68cd685 100644 --- a/RTLTestRunApp/src/MyReflectionTests/MyCxxMirrorProvider.cpp +++ b/RTLTestRunApp/src/MyReflectionTests/MyCxxMirrorProvider.cpp @@ -50,7 +50,9 @@ namespace my_type /* Register a class/struct type without a namespace. Since no namespace is provided, it will be queried directly by name, e.g.: cxx_mirror().getRecord("Person"); - + + (class/struct- generally termed as 'Record' as per LLVM's naming convention) + This registration implicitly adds the default constructor, copy constructor, and destructor. Explicitly registering these members is not allowed and will result in a compile-time error. From 733052d94b803fd80e7acfd95e2bea8603d8fcde Mon Sep 17 00:00:00 2001 From: neeraj Date: Fri, 7 Nov 2025 23:13:57 +0530 Subject: [PATCH 144/148] fix- gcc/clang err, missed include. --- CxxTestRegistration/src/TestMirrorProvider.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 95afde7d..e7ae77c0 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -20,6 +20,7 @@ TestUtils, provides the interface to test/compare reflected type objects with actual objects (created via strict typing) without exposing the actual type objects to "CxxReflectionTests" project.*/ #include "Reflect.hpp" +#include "CxxMirror.hpp" #include "CxxMirror.h" #include "TestUtilsBook.h" From 252ad6e0ec8e95f7fbc74ababe4f54ecee5aa4c2 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 8 Nov 2025 10:34:18 +0530 Subject: [PATCH 145/148] refactor, renames. --- CxxTestProps/inc/StringOps.h | 18 +- CxxTestProps/src/StringOps.cpp | 108 ++++++------ CxxTestRegistration/src/CMakeLists.txt | 7 +- .../src/StrConstRegistration.cpp | 0 .../src/StrDerivedRegistration.cpp | 0 .../src/StrFuncsRegistration.cpp | 0 .../src/StrMuteRegistration.cpp | 0 .../src/StrStaticRegistration.cpp | 0 .../src/TestMirrorProvider.cpp | 156 +++++++++--------- .../StrictStaticTypeDispatch_ConstMethod.cpp | 94 +++++------ .../StrictStaticTypeDispatch_Method.cpp | 92 +++++------ .../StrictStaticTypeDispatch_StaticMethod.cpp | 66 ++++---- .../BasicTypeErasedDispatch_Method.cpp | 92 +++++------ .../BasicTypeErasedDispatch_StaticMethod.cpp | 40 ++--- 14 files changed, 339 insertions(+), 334 deletions(-) create mode 100644 CxxTestRegistration/src/StrConstRegistration.cpp create mode 100644 CxxTestRegistration/src/StrDerivedRegistration.cpp create mode 100644 CxxTestRegistration/src/StrFuncsRegistration.cpp create mode 100644 CxxTestRegistration/src/StrMuteRegistration.cpp create mode 100644 CxxTestRegistration/src/StrStaticRegistration.cpp diff --git a/CxxTestProps/inc/StringOps.h b/CxxTestProps/inc/StringOps.h index ba7f9af6..3fe0a062 100644 --- a/CxxTestProps/inc/StringOps.h +++ b/CxxTestProps/inc/StringOps.h @@ -37,10 +37,10 @@ std::string revStrOverloadRefAndCRef(std::string_view& pStr); std::string revStrOverloadRefAndCRef(const std::string_view& pStr); -// 'StringM' - String-Mutable, all methods are non-const. -struct StringM +// 'StrMute' - String-Mutable, all methods are non-const. +struct StrMute { - constexpr static const char* struct_ = "StringM"; + constexpr static const char* struct_ = "StrMute"; std::string reverseString(); @@ -78,10 +78,10 @@ struct StringM }; -// 'StringC' - String-Const, all methods are const. -struct StringC +// 'StrConst' - String-Const, all methods are const. +struct StrConst { - constexpr static const char* struct_ = "StringC"; + constexpr static const char* struct_ = "StrConst"; std::string reverseString() const; @@ -119,10 +119,10 @@ struct StringC }; -// 'StringS' - String-Static, all methods are static. -struct StringS +// 'StrStatic' - String-Static, all methods are static. +struct StrStatic { - constexpr static const char* struct_ = "StringS"; + constexpr static const char* struct_ = "StrStatic"; static std::string reverseString(); diff --git a/CxxTestProps/src/StringOps.cpp b/CxxTestProps/src/StringOps.cpp index 6ff4a802..b5f85634 100644 --- a/CxxTestProps/src/StringOps.cpp +++ b/CxxTestProps/src/StringOps.cpp @@ -163,15 +163,15 @@ std::string revStrOverloadRefAndCRef(const std::string_view& pStr) return retStr + SUFFIX_std_string_view_clvref; } -//---------------------------StringM-------------------------------- +//---------------------------StrMute-------------------------------- -std::string StringM::reverseString() +std::string StrMute::reverseString() { return std::string(REV_STR_VOID_RET) + SUFFIX_void; } -std::string StringM::reverseString(const char* pStr) +std::string StrMute::reverseString(const char* pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -179,7 +179,7 @@ std::string StringM::reverseString(const char* pStr) } -std::string StringM::reverseString(std::string pStr) +std::string StrMute::reverseString(std::string pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -187,7 +187,7 @@ std::string StringM::reverseString(std::string pStr) } -std::string StringM::reverseString(std::string& pStr) +std::string StrMute::reverseString(std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -195,7 +195,7 @@ std::string StringM::reverseString(std::string& pStr) } -std::string StringM::reverseString(std::string&& pStr) +std::string StrMute::reverseString(std::string&& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -203,7 +203,7 @@ std::string StringM::reverseString(std::string&& pStr) } -std::string StringM::reverseString(const std::string& pStr) +std::string StrMute::reverseString(const std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -211,7 +211,7 @@ std::string StringM::reverseString(const std::string& pStr) } -std::string StringM::reverseString(std::string* pStr) +std::string StrMute::reverseString(std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); @@ -219,7 +219,7 @@ std::string StringM::reverseString(std::string* pStr) } -std::string StringM::reverseString(const std::string* pStr) +std::string StrMute::reverseString(const std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); @@ -227,7 +227,7 @@ std::string StringM::reverseString(const std::string* pStr) } -std::string StringM::revStrConstRefArg(const std::string_view& pStr) +std::string StrMute::revStrConstRefArg(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -235,7 +235,7 @@ std::string StringM::revStrConstRefArg(const std::string_view& pStr) } -std::string StringM::revStrRValueRefArg(std::string_view&& pStr) +std::string StrMute::revStrRValueRefArg(std::string_view&& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -243,7 +243,7 @@ std::string StringM::revStrRValueRefArg(std::string_view&& pStr) } -std::string StringM::revStrNonConstRefArg(std::string_view& pStr) +std::string StrMute::revStrNonConstRefArg(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -251,7 +251,7 @@ std::string StringM::revStrNonConstRefArg(std::string_view& pStr) } -std::string StringM::revStrOverloadValCRef(std::string_view pStr) +std::string StrMute::revStrOverloadValCRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -259,7 +259,7 @@ std::string StringM::revStrOverloadValCRef(std::string_view pStr) } -std::string StringM::revStrOverloadValCRef(const std::string_view& pStr) +std::string StrMute::revStrOverloadValCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -267,7 +267,7 @@ std::string StringM::revStrOverloadValCRef(const std::string_view& pStr) } -std::string StringM::revStrOverloadValRef(std::string_view pStr) +std::string StrMute::revStrOverloadValRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -275,7 +275,7 @@ std::string StringM::revStrOverloadValRef(std::string_view pStr) } -std::string StringM::revStrOverloadValRef(std::string_view& pStr) +std::string StrMute::revStrOverloadValRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -283,7 +283,7 @@ std::string StringM::revStrOverloadValRef(std::string_view& pStr) } -std::string StringM::revStrOverloadRefAndCRef(std::string_view& pStr) +std::string StrMute::revStrOverloadRefAndCRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -291,7 +291,7 @@ std::string StringM::revStrOverloadRefAndCRef(std::string_view& pStr) } -std::string StringM::revStrOverloadRefAndCRef(const std::string_view& pStr) +std::string StrMute::revStrOverloadRefAndCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -299,15 +299,15 @@ std::string StringM::revStrOverloadRefAndCRef(const std::string_view& pStr) } -//---------------------------StringC-------------------------------- +//---------------------------StrConst-------------------------------- -std::string StringC::reverseString() const +std::string StrConst::reverseString() const { return std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_const; } -std::string StringC::reverseString(const char* pStr) const +std::string StrConst::reverseString(const char* pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -315,7 +315,7 @@ std::string StringC::reverseString(const char* pStr) const } -std::string StringC::reverseString(std::string pStr) const +std::string StrConst::reverseString(std::string pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -323,7 +323,7 @@ std::string StringC::reverseString(std::string pStr) const } -std::string StringC::reverseString(std::string& pStr) const +std::string StrConst::reverseString(std::string& pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -331,7 +331,7 @@ std::string StringC::reverseString(std::string& pStr) const } -std::string StringC::reverseString(std::string&& pStr) const +std::string StrConst::reverseString(std::string&& pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -339,7 +339,7 @@ std::string StringC::reverseString(std::string&& pStr) const } -std::string StringC::reverseString(const std::string& pStr) const +std::string StrConst::reverseString(const std::string& pStr) const { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -347,7 +347,7 @@ std::string StringC::reverseString(const std::string& pStr) const } -std::string StringC::reverseString(std::string* pStr) const +std::string StrConst::reverseString(std::string* pStr) const { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); @@ -355,7 +355,7 @@ std::string StringC::reverseString(std::string* pStr) const } -std::string StringC::reverseString(const std::string* pStr) const +std::string StrConst::reverseString(const std::string* pStr) const { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); @@ -363,7 +363,7 @@ std::string StringC::reverseString(const std::string* pStr) const } -std::string StringC::revStrConstRefArg(const std::string_view& pStr) const +std::string StrConst::revStrConstRefArg(const std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -371,7 +371,7 @@ std::string StringC::revStrConstRefArg(const std::string_view& pStr) const } -std::string StringC::revStrRValueRefArg(std::string_view&& pStr) const +std::string StrConst::revStrRValueRefArg(std::string_view&& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -379,7 +379,7 @@ std::string StringC::revStrRValueRefArg(std::string_view&& pStr) const } -std::string StringC::revStrNonConstRefArg(std::string_view& pStr) const +std::string StrConst::revStrNonConstRefArg(std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -387,7 +387,7 @@ std::string StringC::revStrNonConstRefArg(std::string_view& pStr) const } -std::string StringC::revStrOverloadValCRef(std::string_view pStr) const +std::string StrConst::revStrOverloadValCRef(std::string_view pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -395,7 +395,7 @@ std::string StringC::revStrOverloadValCRef(std::string_view pStr) const } -std::string StringC::revStrOverloadValCRef(const std::string_view& pStr) const +std::string StrConst::revStrOverloadValCRef(const std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -403,7 +403,7 @@ std::string StringC::revStrOverloadValCRef(const std::string_view& pStr) const } -std::string StringC::revStrOverloadValRef(std::string_view pStr) const +std::string StrConst::revStrOverloadValRef(std::string_view pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -411,7 +411,7 @@ std::string StringC::revStrOverloadValRef(std::string_view pStr) const } -std::string StringC::revStrOverloadValRef(std::string_view& pStr) const +std::string StrConst::revStrOverloadValRef(std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -419,7 +419,7 @@ std::string StringC::revStrOverloadValRef(std::string_view& pStr) const } -std::string StringC::revStrOverloadRefAndCRef(std::string_view& pStr) const +std::string StrConst::revStrOverloadRefAndCRef(std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -427,7 +427,7 @@ std::string StringC::revStrOverloadRefAndCRef(std::string_view& pStr) const } -std::string StringC::revStrOverloadRefAndCRef(const std::string_view& pStr) const +std::string StrConst::revStrOverloadRefAndCRef(const std::string_view& pStr) const { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -435,15 +435,15 @@ std::string StringC::revStrOverloadRefAndCRef(const std::string_view& pStr) cons } -//---------------------------StringS-------------------------------- +//---------------------------StrStatic-------------------------------- -std::string StringS::reverseString() +std::string StrStatic::reverseString() { return std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_static; } -std::string StringS::reverseString(const char* pStr) +std::string StrStatic::reverseString(const char* pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -451,7 +451,7 @@ std::string StringS::reverseString(const char* pStr) } -std::string StringS::reverseString(std::string pStr) +std::string StrStatic::reverseString(std::string pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -459,7 +459,7 @@ std::string StringS::reverseString(std::string pStr) } -std::string StringS::reverseString(std::string& pStr) +std::string StrStatic::reverseString(std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -467,7 +467,7 @@ std::string StringS::reverseString(std::string& pStr) } -std::string StringS::reverseString(std::string&& pStr) +std::string StrStatic::reverseString(std::string&& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -475,7 +475,7 @@ std::string StringS::reverseString(std::string&& pStr) } -std::string StringS::reverseString(const std::string& pStr) +std::string StrStatic::reverseString(const std::string& pStr) { std::string retStr = pStr; std::reverse(retStr.begin(), retStr.end()); @@ -483,7 +483,7 @@ std::string StringS::reverseString(const std::string& pStr) } -std::string StringS::reverseString(std::string* pStr) +std::string StrStatic::reverseString(std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); @@ -491,7 +491,7 @@ std::string StringS::reverseString(std::string* pStr) } -std::string StringS::reverseString(const std::string* pStr) +std::string StrStatic::reverseString(const std::string* pStr) { std::string retStr = *pStr; std::reverse(retStr.begin(), retStr.end()); @@ -499,7 +499,7 @@ std::string StringS::reverseString(const std::string* pStr) } -std::string StringS::revStrConstRefArg(const std::string_view& pStr) +std::string StrStatic::revStrConstRefArg(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -507,7 +507,7 @@ std::string StringS::revStrConstRefArg(const std::string_view& pStr) } -std::string StringS::revStrRValueRefArg(std::string_view&& pStr) +std::string StrStatic::revStrRValueRefArg(std::string_view&& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -515,7 +515,7 @@ std::string StringS::revStrRValueRefArg(std::string_view&& pStr) } -std::string StringS::revStrNonConstRefArg(std::string_view& pStr) +std::string StrStatic::revStrNonConstRefArg(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -523,7 +523,7 @@ std::string StringS::revStrNonConstRefArg(std::string_view& pStr) } -std::string StringS::revStrOverloadValCRef(std::string_view pStr) +std::string StrStatic::revStrOverloadValCRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -531,7 +531,7 @@ std::string StringS::revStrOverloadValCRef(std::string_view pStr) } -std::string StringS::revStrOverloadValCRef(const std::string_view& pStr) +std::string StrStatic::revStrOverloadValCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -539,7 +539,7 @@ std::string StringS::revStrOverloadValCRef(const std::string_view& pStr) } -std::string StringS::revStrOverloadValRef(std::string_view pStr) +std::string StrStatic::revStrOverloadValRef(std::string_view pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -547,7 +547,7 @@ std::string StringS::revStrOverloadValRef(std::string_view pStr) } -std::string StringS::revStrOverloadValRef(std::string_view& pStr) +std::string StrStatic::revStrOverloadValRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -555,7 +555,7 @@ std::string StringS::revStrOverloadValRef(std::string_view& pStr) } -std::string StringS::revStrOverloadRefAndCRef(std::string_view& pStr) +std::string StrStatic::revStrOverloadRefAndCRef(std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); @@ -563,7 +563,7 @@ std::string StringS::revStrOverloadRefAndCRef(std::string_view& pStr) } -std::string StringS::revStrOverloadRefAndCRef(const std::string_view& pStr) +std::string StrStatic::revStrOverloadRefAndCRef(const std::string_view& pStr) { std::string retStr(pStr); std::reverse(retStr.begin(), retStr.end()); diff --git a/CxxTestRegistration/src/CMakeLists.txt b/CxxTestRegistration/src/CMakeLists.txt index 51847336..614bae82 100644 --- a/CxxTestRegistration/src/CMakeLists.txt +++ b/CxxTestRegistration/src/CMakeLists.txt @@ -5,7 +5,6 @@ project(CxxTestRegistration) # Create a variable containing the source files for your target set(LOCAL_SOURCES - "${CMAKE_CURRENT_LIST_DIR}/TestMirrorProvider.cpp" "${CMAKE_CURRENT_LIST_DIR}/AnimalRegistration.cpp" "${CMAKE_CURRENT_LIST_DIR}/BookRegistration.cpp" "${CMAKE_CURRENT_LIST_DIR}/CalenderRegistration.cpp" @@ -15,6 +14,12 @@ set(LOCAL_SOURCES "${CMAKE_CURRENT_LIST_DIR}/LibraryRegistration.cpp" "${CMAKE_CURRENT_LIST_DIR}/PersonRegistration.cpp" "${CMAKE_CURRENT_LIST_DIR}/PodStdRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StrConstRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StrDerivedRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StrFuncsRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StrMuteRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StrStaticRegistration.cpp" + "${CMAKE_CURRENT_LIST_DIR}/TestMirrorProvider.cpp" ) SET(LOCAL_HEADERS diff --git a/CxxTestRegistration/src/StrConstRegistration.cpp b/CxxTestRegistration/src/StrConstRegistration.cpp new file mode 100644 index 00000000..e69de29b diff --git a/CxxTestRegistration/src/StrDerivedRegistration.cpp b/CxxTestRegistration/src/StrDerivedRegistration.cpp new file mode 100644 index 00000000..e69de29b diff --git a/CxxTestRegistration/src/StrFuncsRegistration.cpp b/CxxTestRegistration/src/StrFuncsRegistration.cpp new file mode 100644 index 00000000..e69de29b diff --git a/CxxTestRegistration/src/StrMuteRegistration.cpp b/CxxTestRegistration/src/StrMuteRegistration.cpp new file mode 100644 index 00000000..e69de29b diff --git a/CxxTestRegistration/src/StrStaticRegistration.cpp b/CxxTestRegistration/src/StrStaticRegistration.cpp new file mode 100644 index 00000000..e69de29b diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index e7ae77c0..4ffb1fb5 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -130,16 +130,16 @@ namespace test_mirror rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), //--------------------------------------------------------------------------------------------------------------------------------------------------- - rtl::type().record(StringM::struct_).build(), + rtl::type().record(StrMute::struct_).build(), // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. - rtl::type().member().method(str_reverseString).build(&StringM::reverseString), + rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. - rtl::type().member().method(str_reverseString).build(&StringM::reverseString), + rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), // Overloaded function, takes 'const char*' arguments. - rtl::type().member().method(str_reverseString).build(&StringM::reverseString), + rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), // numereous other overloads. #if defined(__GNUC__) && !defined(__clang__) @@ -150,44 +150,44 @@ namespace test_mirror static_cast(reverseString) */ - rtl::type().member().method(str_reverseString) - .build(static_cast(&StringM::reverseString)), - rtl::type().member().method(str_reverseString) - .build(static_cast(&StringM::reverseString)), - rtl::type().member().method(str_reverseString) - .build(static_cast(&StringM::reverseString)), + rtl::type().member().method(str_reverseString) + .build(static_cast(&StrMute::reverseString)), + rtl::type().member().method(str_reverseString) + .build(static_cast(&StrMute::reverseString)), + rtl::type().member().method(str_reverseString) + .build(static_cast(&StrMute::reverseString)), #else - rtl::type().member().method(str_reverseString).build(&StringM::reverseString), - rtl::type().member().method(str_reverseString).build(&StringM::reverseString), - rtl::type().member().method(str_reverseString).build(&StringM::reverseString), + rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), + rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), + rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), #endif - rtl::type().member().method(str_reverseString).build(&StringM::reverseString), - rtl::type().member().method(str_reverseString).build(&StringM::reverseString), + rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), + rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - rtl::type().member().method(str_revStrNonConstRefArg).build(&StringM::revStrNonConstRefArg), - rtl::type().member().method(str_revStrRValueRefArg).build(&StringM::revStrRValueRefArg), - rtl::type().member().method(str_revStrConstRefArg).build(&StringM::revStrConstRefArg), + rtl::type().member().method(str_revStrNonConstRefArg).build(&StrMute::revStrNonConstRefArg), + rtl::type().member().method(str_revStrRValueRefArg).build(&StrMute::revStrRValueRefArg), + rtl::type().member().method(str_revStrConstRefArg).build(&StrMute::revStrConstRefArg), - rtl::type().member().method(str_revStrOverloadValRef).build(&StringM::revStrOverloadValRef), - rtl::type().member().method(str_revStrOverloadValRef).build(&StringM::revStrOverloadValRef), + rtl::type().member().method(str_revStrOverloadValRef).build(&StrMute::revStrOverloadValRef), + rtl::type().member().method(str_revStrOverloadValRef).build(&StrMute::revStrOverloadValRef), - rtl::type().member().method(str_revStrOverloadValCRef).build(&StringM::revStrOverloadValCRef), - rtl::type().member().method(str_revStrOverloadValCRef).build(&StringM::revStrOverloadValCRef), + rtl::type().member().method(str_revStrOverloadValCRef).build(&StrMute::revStrOverloadValCRef), + rtl::type().member().method(str_revStrOverloadValCRef).build(&StrMute::revStrOverloadValCRef), - rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringM::revStrOverloadRefAndCRef), - rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StringM::revStrOverloadRefAndCRef), + rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StrMute::revStrOverloadRefAndCRef), + rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StrMute::revStrOverloadRefAndCRef), //--------------------------------------------------------------------------------------------------------------------------------------------------- - rtl::type().record(StringC::struct_).build(), + rtl::type().record(StrConst::struct_).build(), // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. - rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. - rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), // Overloaded function, takes 'const char*' arguments. - rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), // numereous other overloads. #if defined(__GNUC__) && !defined(__clang__) @@ -198,44 +198,44 @@ namespace test_mirror static_cast(reverseString) */ - rtl::type().member().methodConst(str_reverseString) - .build(static_cast(&StringC::reverseString)), - rtl::type().member().methodConst(str_reverseString) - .build(static_cast(&StringC::reverseString)), - rtl::type().member().methodConst(str_reverseString) - .build(static_cast(&StringC::reverseString)), + rtl::type().member().methodConst(str_reverseString) + .build(static_cast(&StrConst::reverseString)), + rtl::type().member().methodConst(str_reverseString) + .build(static_cast(&StrConst::reverseString)), + rtl::type().member().methodConst(str_reverseString) + .build(static_cast(&StrConst::reverseString)), #else - rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), - rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), - rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), #endif - rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), - rtl::type().member().methodConst(str_reverseString).build(&StringC::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), + rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), - rtl::type().member().methodConst(str_revStrNonConstRefArg).build(&StringC::revStrNonConstRefArg), - rtl::type().member().methodConst(str_revStrRValueRefArg).build(&StringC::revStrRValueRefArg), - rtl::type().member().methodConst(str_revStrConstRefArg).build(&StringC::revStrConstRefArg), + rtl::type().member().methodConst(str_revStrNonConstRefArg).build(&StrConst::revStrNonConstRefArg), + rtl::type().member().methodConst(str_revStrRValueRefArg).build(&StrConst::revStrRValueRefArg), + rtl::type().member().methodConst(str_revStrConstRefArg).build(&StrConst::revStrConstRefArg), - rtl::type().member().methodConst(str_revStrOverloadValRef).build(&StringC::revStrOverloadValRef), - rtl::type().member().methodConst(str_revStrOverloadValRef).build(&StringC::revStrOverloadValRef), + rtl::type().member().methodConst(str_revStrOverloadValRef).build(&StrConst::revStrOverloadValRef), + rtl::type().member().methodConst(str_revStrOverloadValRef).build(&StrConst::revStrOverloadValRef), - rtl::type().member().methodConst(str_revStrOverloadValCRef).build(&StringC::revStrOverloadValCRef), - rtl::type().member().methodConst(str_revStrOverloadValCRef).build(&StringC::revStrOverloadValCRef), + rtl::type().member().methodConst(str_revStrOverloadValCRef).build(&StrConst::revStrOverloadValCRef), + rtl::type().member().methodConst(str_revStrOverloadValCRef).build(&StrConst::revStrOverloadValCRef), - rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StringC::revStrOverloadRefAndCRef), - rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StringC::revStrOverloadRefAndCRef), + rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StrConst::revStrOverloadRefAndCRef), + rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StrConst::revStrOverloadRefAndCRef), //-------------------------------------------------------------------------------------------------------------------------------------------------------- - rtl::type().record(StringS::struct_).build(), + rtl::type().record(StrStatic::struct_).build(), // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. - rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. - rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), // Overloaded function, takes 'const char*' arguments. - rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), // numereous other overloads. #if defined(__GNUC__) && !defined(__clang__) @@ -246,32 +246,32 @@ namespace test_mirror static_cast(reverseString) */ - rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StringS::reverseString)), - rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StringS::reverseString)), - rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StringS::reverseString)), + rtl::type().member().methodStatic(str_reverseString) + .build(static_cast(&StrStatic::reverseString)), + rtl::type().member().methodStatic(str_reverseString) + .build(static_cast(&StrStatic::reverseString)), + rtl::type().member().methodStatic(str_reverseString) + .build(static_cast(&StrStatic::reverseString)), #else - rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), - rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), - rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), #endif - rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), - rtl::type().member().methodStatic(str_reverseString).build(&StringS::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), + rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - rtl::type().member().methodStatic(str_revStrNonConstRefArg).build(&StringS::revStrNonConstRefArg), - rtl::type().member().methodStatic(str_revStrRValueRefArg).build(&StringS::revStrRValueRefArg), - rtl::type().member().methodStatic(str_revStrConstRefArg).build(&StringS::revStrConstRefArg), + rtl::type().member().methodStatic(str_revStrNonConstRefArg).build(&StrStatic::revStrNonConstRefArg), + rtl::type().member().methodStatic(str_revStrRValueRefArg).build(&StrStatic::revStrRValueRefArg), + rtl::type().member().methodStatic(str_revStrConstRefArg).build(&StrStatic::revStrConstRefArg), - rtl::type().member().methodStatic(str_revStrOverloadValRef).build(&StringS::revStrOverloadValRef), - rtl::type().member().methodStatic(str_revStrOverloadValRef).build(&StringS::revStrOverloadValRef), + rtl::type().member().methodStatic(str_revStrOverloadValRef).build(&StrStatic::revStrOverloadValRef), + rtl::type().member().methodStatic(str_revStrOverloadValRef).build(&StrStatic::revStrOverloadValRef), - rtl::type().member().methodStatic(str_revStrOverloadValCRef).build(&StringS::revStrOverloadValCRef), - rtl::type().member().methodStatic(str_revStrOverloadValCRef).build(&StringS::revStrOverloadValCRef), + rtl::type().member().methodStatic(str_revStrOverloadValCRef).build(&StrStatic::revStrOverloadValCRef), + rtl::type().member().methodStatic(str_revStrOverloadValCRef).build(&StrStatic::revStrOverloadValCRef), - rtl::type().member().methodStatic(str_revStrOverloadValRefAndCRef).build(&StringS::revStrOverloadRefAndCRef), - rtl::type().member().methodStatic(str_revStrOverloadValRefAndCRef).build(&StringS::revStrOverloadRefAndCRef), + rtl::type().member().methodStatic(str_revStrOverloadValRefAndCRef).build(&StrStatic::revStrOverloadRefAndCRef), + rtl::type().member().methodStatic(str_revStrOverloadValRefAndCRef).build(&StrStatic::revStrOverloadRefAndCRef), //--------------------------------------------------------------------------------------------------------------------------------------------------------- // Unique function, no overloads, no need to specify signature as template parameters. @@ -456,9 +456,9 @@ namespace test_mirror std::size_t reflected_id::date = rtl::detail::TypeId::get(); std::size_t reflected_id::event = rtl::detail::TypeId::get(); std::size_t reflected_id::calender = rtl::detail::TypeId::get(); - std::size_t reflected_id::string_m = rtl::detail::TypeId::get(); - std::size_t reflected_id::string_c = rtl::detail::TypeId::get(); - std::size_t reflected_id::string_s = rtl::detail::TypeId::get(); + std::size_t reflected_id::string_m = rtl::detail::TypeId::get(); + std::size_t reflected_id::string_c = rtl::detail::TypeId::get(); + std::size_t reflected_id::string_s = rtl::detail::TypeId::get(); std::size_t reflected_id::int_t = rtl::detail::TypeId::get(); std::size_t reflected_id::char_t = rtl::detail::TypeId::get(); @@ -482,9 +482,9 @@ namespace test_mirror { person::class_, person }, { library::class_, library }, { calender::struct_, calender }, - { StringM::struct_, string_m }, - { StringC::struct_, string_c }, - { StringS::struct_, string_s } + { StrMute::struct_, string_m }, + { StrConst::struct_, string_c }, + { StrStatic::struct_, string_s } }); const auto& itr = nameIdMap.find(pRecordName); diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp index 86c7e08c..caa358e2 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_ConstMethod.cpp @@ -46,56 +46,56 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_const_method, overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringC())(STRA); + std::string ret_str = reverse_string(StrConst())(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringC())(STRB); + std::string ret_str = reverse_string(StrConst())(STRB); auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT<>() .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringC())(); + std::string ret_str = reverse_string(StrConst())(); auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_void + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } @@ -104,19 +104,19 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_const_method, lvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { //argument lvalue-ref. - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); //non-const target - StringC target; + StrConst target; std::string lv_str = STRA; std::string ret_str = reverse_string(target)(lv_str); @@ -124,12 +124,12 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } { //argument const-lvalue-ref. - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); //non-const target - StringC target; + StrConst target; const std::string lv_str = STRA; std::string ret_str = reverse_string(target)(lv_str); @@ -137,12 +137,12 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } { //argument lvalue-ref. - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); //const target. - const StringC target; + const StrConst target; std::string lv_str = STRA; std::string ret_str = reverse_string(target)(lv_str); @@ -150,12 +150,12 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } { //argument const-lvalue-ref. - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); //const target. - const StringC target; + const StrConst target; const std::string lv_str = STRA; std::string ret_str = reverse_string(target)(lv_str); @@ -167,34 +167,34 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_const_method, rvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); { //non-const target. - StringC target; + StrConst target; std::string ret_str = reverse_string(target)(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_rvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { //const-target - const StringC target; + const StrConst target; std::string ret_str = reverse_string(target)(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_rvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); @@ -204,15 +204,15 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_const_method, ptr_and_const_ptr_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); ASSERT_TRUE(optStringUtil); - StringC target; + StrConst target; std::string str = STRA; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -221,7 +221,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -264,21 +264,21 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_const_method, distinct_functions_with_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); ASSERT_TRUE(optStringUtil); - StringC target; + StrConst target; std::string str = STRA; { std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - StringC target; + StrConst target; std::string ret_str = reverse_string(target)(str); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_clvref + SUFFIX_const; @@ -287,7 +287,7 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -301,7 +301,7 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -316,14 +316,14 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_const_method, overloads_with_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); ASSERT_TRUE(optStringUtil); - StringC target; + StrConst target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -332,7 +332,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -348,14 +348,14 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_const_method, overloads_with_const_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); ASSERT_TRUE(optStringUtil); - StringC target; + StrConst target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -364,7 +364,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -378,14 +378,14 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_const_method, overloads_with_ref_and_const_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); ASSERT_TRUE(optStringUtil); - StringC target; + StrConst target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -395,7 +395,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref + SUFFIX_const; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp index 9b01a657..0d6d184c 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_Method.cpp @@ -15,56 +15,56 @@ namespace rtl_tests { TEST(StrictStaticTypeRtl_method, overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringM())(STRA); + std::string ret_str = reverse_string(StrMute())(STRA); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringM())(STRB); + std::string ret_str = reverse_string(StrMute())(STRB); auto exp_str = std::string(STRB_REVERSE) + SUFFIX_std_string; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT<>() .returnT(); ASSERT_TRUE(reverse_string); - std::string ret_str = reverse_string(StringM())(); + std::string ret_str = reverse_string(StrMute())(); auto exp_str = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(ret_str, exp_str); } @@ -73,16 +73,16 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, lvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); //non-const target. - StringM target; + StrMute target; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { //argument lvalue-ref - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -93,7 +93,7 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } { //argument const-lvalue-ref - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -104,33 +104,33 @@ namespace rtl_tests EXPECT_EQ(ret_str, exp_str); } { //argument lvalue-ref - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); //const-target. - const StringM& c_target = target; + const StrMute& c_target = target; std::string lv_str = STRA; // compile error - // std::string ret_str = reverse_string(const_target)(lv_str); - std::string ret_str = reverse_string(const_cast(c_target))(lv_str); + std::string ret_str = reverse_string(const_cast(c_target))(lv_str); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_lvref; EXPECT_EQ(ret_str, exp_str); } { //argument const-lvalue-ref - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); //const-target. - const StringM& c_target = target; + const StrMute& c_target = target; std::string lv_str = STRA; // compile error - // std::string ret_str = reverse_string(c_target)(lv_str); - std::string ret_str = reverse_string(const_cast(c_target))(lv_str); + std::string ret_str = reverse_string(const_cast(c_target))(lv_str); auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_clvref; EXPECT_EQ(ret_str, exp_str); @@ -140,14 +140,14 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, rvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); - StringM target; + StrMute target; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -156,7 +156,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_rvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); EXPECT_FALSE(reverse_string); @@ -166,15 +166,15 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, ptr_and_const_ptr_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); - StringM target; + StrMute target; std::string str = STRA; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -183,7 +183,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_ptr; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -197,16 +197,16 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, distinct_functions_with_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); - StringM target; + StrMute target; std::string str = STRA; { std::optional reverseString = optStringUtil->getMethod(str_revStrConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -218,7 +218,7 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrNonConstRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -231,7 +231,7 @@ namespace rtl_tests std::optional reverseString = optStringUtil->getMethod(str_revStrRValueRefArg); ASSERT_TRUE(reverseString); - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -245,14 +245,14 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); - StringM target; + StrMute target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -261,7 +261,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -276,14 +276,14 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_const_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); - StringM target; + StrMute target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -292,7 +292,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -306,14 +306,14 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_method, overloads_with_ref_and_const_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); - StringM target; + StrMute target; std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); @@ -323,7 +323,7 @@ namespace rtl_tests auto exp_str = std::string(STRA_REVERSE) + SUFFIX_std_string_view_lvref; EXPECT_EQ(ret_str, exp_str); } { - rtl::method reverse_string = reverseString->targetT() + rtl::method reverse_string = reverseString->targetT() .argsT() .returnT(); ASSERT_TRUE(reverse_string); diff --git a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp index b0019fcf..3116b0f2 100644 --- a/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/StaticTypeReflectiveCalls/StrictStaticTypeDispatch_StaticMethod.cpp @@ -14,16 +14,16 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, using_wrong_class_n_callable_apis_for_static_method) { { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); // has only static-methods. + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); // has only static-methods. ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString.value() - .targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); } { @@ -34,7 +34,7 @@ namespace rtl_tests EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); } } { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); // doesn't have any static-methods. + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); // doesn't have any static-methods. ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); @@ -46,7 +46,7 @@ namespace rtl_tests EXPECT_FALSE(reverse_string); EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidNonStaticMethodCaller); } { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); // doesn't have any static-methods. + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); // doesn't have any static-methods. ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); @@ -64,34 +64,34 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil.value().getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString.value() - .targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString.value() - .targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString.value() - .targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { - rtl::method reverse_string = reverseString.value() - .targetT() - .argsT() - .returnT(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT(); EXPECT_FALSE(reverse_string); } { rtl::static_method reverse_string = reverseString.value() @@ -126,11 +126,11 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, lvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); //non-const target. - StringM target; + StrMute target; std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { @@ -173,7 +173,7 @@ namespace rtl_tests .returnT(); ASSERT_TRUE(reverse_string); //const-target. - const StringM& c_target = target; + const StrMute& c_target = target; std::string lv_str = STRA; std::string ret_str = reverse_string(lv_str); @@ -186,7 +186,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, rvalue_ref_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); @@ -206,7 +206,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, ptr_and_const_ptr_overload_resolution_with_known_signatures) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); std::string str = STRA; @@ -236,7 +236,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, distinct_functions_with_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); std::string str = STRA; @@ -283,7 +283,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, overloads_with_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRef); @@ -313,7 +313,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, overloads_with_const_ref_and_value_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValCRef); @@ -342,7 +342,7 @@ namespace rtl_tests TEST(StrictStaticTypeRtl_static_method, overloads_with_ref_and_const_ref_args_call_with_known_signature) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp index 63f300b3..a716229e 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_Method.cpp @@ -44,24 +44,24 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, implicit_resolutions_to_call_by_value_overloads) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseStrOpt); EXPECT_FALSE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_FALSE(reverseString); { - auto [err, robj] = reverseString(StringM())(const_cast(STRA)); + auto [err, robj] = reverseString(StrMute())(const_cast(STRA)); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } { - auto [err, robj] = reverseString.bind(StringM())(const_cast(STRA)); + auto [err, robj] = reverseString.bind(StrMute())(const_cast(STRA)); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); @@ -69,12 +69,12 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); { - auto [err, robj] = reverseString(StringM())(STRA); + auto [err, robj] = reverseString(StrMute())(STRA); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -84,7 +84,7 @@ namespace rtl_tests std::string expStr = std::string(STRA_REVERSE) + SUFFIX_const_char_ptr; EXPECT_EQ(retStr, expStr); } { - auto [err, robj] = reverseString.bind(StringM())(STRA); + auto [err, robj] = reverseString.bind(StrMute())(STRA); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -97,12 +97,12 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); { - auto [err, robj] = reverseString(StringM())(STRA); + auto [err, robj] = reverseString(StrMute())(STRA); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -112,7 +112,7 @@ namespace rtl_tests std::string expStr = std::string(STRA_REVERSE) + SUFFIX_std_string; EXPECT_EQ(retStr, expStr); } { - auto [err, robj] = reverseString.bind(StringM())(STRA); + auto [err, robj] = reverseString.bind(StrMute())(STRA); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -125,13 +125,13 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); { std::string str = STRA; - auto [err, robj] = reverseString(StringM())(&str); + auto [err, robj] = reverseString(StrMute())(&str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -142,7 +142,7 @@ namespace rtl_tests EXPECT_EQ(retStr, expStr); } { std::string str = STRA; - auto [err, robj] = reverseString.bind(StringM())(&str); + auto [err, robj] = reverseString.bind(StrMute())(&str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -155,13 +155,13 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); { const std::string str = STRA; - auto [err, robj] = reverseString(StringM())(&str); + auto [err, robj] = reverseString(StrMute())(&str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -172,7 +172,7 @@ namespace rtl_tests EXPECT_EQ(retStr, expStr); } { const std::string str = STRA; - auto [err, robj] = reverseString.bind(StringM())(&str); + auto [err, robj] = reverseString.bind(StrMute())(&str); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -185,12 +185,12 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature<>()); { - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT<>() .returnT<>(); EXPECT_TRUE(reverseString); { - auto [err, robj] = reverseString(StringM())(); + auto [err, robj] = reverseString(StrMute())(); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -200,7 +200,7 @@ namespace rtl_tests std::string expStr = std::string(REV_STR_VOID_RET) + SUFFIX_void; EXPECT_EQ(retStr, expStr); } { - auto [err, robj] = reverseString.bind(StringM())(); + auto [err, robj] = reverseString.bind(StrMute())(); EXPECT_EQ(err, rtl::error::None); ASSERT_FALSE(robj.isEmpty()); @@ -216,7 +216,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, implicit_resolution_to_ambiguous_lvalue_and_cref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); @@ -229,9 +229,9 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; + StrMute target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -266,7 +266,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, explicit_resolution_to_ambiguous_lvalue_and_cref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValCRef); @@ -279,9 +279,9 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; + StrMute target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -309,7 +309,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, implicit_resolution_to_ambiguous_lvalue_and_ref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRef); @@ -322,9 +322,9 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; + StrMute target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -356,7 +356,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, explicit_resolution_to_ambiguous_lvalue_and_ref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRef); @@ -369,9 +369,9 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; + StrMute target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -398,7 +398,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, calling_non_overloaded_non_const_ref_argument) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrNonConstRefArg); @@ -411,9 +411,9 @@ namespace rtl_tests // Here no overloads exists, only non-const ref (T&) argument. EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; + StrMute target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -446,7 +446,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, calling_non_overloaded_const_ref_argument) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrConstRefArg); @@ -459,9 +459,9 @@ namespace rtl_tests // Here no overloads exists, only non-const ref (T&) argument. EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; + StrMute target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -501,7 +501,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, calling_non_overloaded_rvalue_ref_argument) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrRValueRefArg); @@ -514,8 +514,8 @@ namespace rtl_tests // Here no overloads exists, only non-const ref (T&) argument. EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; - rtl::method reverseString = reverseStrOpt->targetT() + StrMute target; + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -538,7 +538,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, implicit_resolution_to_ambiguous_ref_and_cref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); @@ -551,9 +551,9 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; + StrMute target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); @@ -575,7 +575,7 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_method, explicit_resolution_to_ambiguous_ref_and_cref_overload) { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_revStrOverloadValRefAndCRef); @@ -588,9 +588,9 @@ namespace rtl_tests EXPECT_TRUE(reverseStrOpt->hasSignature()); EXPECT_TRUE(reverseStrOpt->hasSignature()); - StringM target; + StrMute target; std::string_view str = STRA; - rtl::method reverseString = reverseStrOpt->targetT() + rtl::method reverseString = reverseStrOpt->targetT() .argsT() .returnT<>(); EXPECT_TRUE(reverseString); diff --git a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp index 8653f3a5..97259cd5 100644 --- a/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/TypeErasedReflectiveCalls/BasicTypeErasedDispatch_StaticMethod.cpp @@ -15,20 +15,20 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_static_method, using_wrong_class_n_callable_apis_for_static_method) { { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); // has only static-methods. + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); // has only static-methods. ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseString); { - rtl::method reverse_string = reverseString.value() - .targetT() - .argsT() - .returnT<>(); + rtl::method reverse_string = reverseString.value() + .targetT() + .argsT() + .returnT<>(); EXPECT_FALSE(reverse_string); EXPECT_EQ(reverse_string.get_init_error(), rtl::error::InvalidStaticMethodCaller); - auto [err, robj] = reverse_string(StringS())(std::string()); + auto [err, robj] = reverse_string(StrStatic())(std::string()); EXPECT_EQ(err, rtl::error::InvalidStaticMethodCaller); EXPECT_TRUE(robj.isEmpty()); } { @@ -43,7 +43,7 @@ namespace rtl_tests EXPECT_TRUE(robj.isEmpty()); } } { - std::optional optStringUtil = cxx::mirror().getRecord(StringC::struct_); // doesn't have any static-methods. + std::optional optStringUtil = cxx::mirror().getRecord(StrConst::struct_); // doesn't have any static-methods. ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); @@ -59,7 +59,7 @@ namespace rtl_tests EXPECT_EQ(err, rtl::error::InvalidNonStaticMethodCaller); EXPECT_TRUE(robj.isEmpty()); } { - std::optional optStringUtil = cxx::mirror().getRecord(StringM::struct_); // doesn't have any static-methods. + std::optional optStringUtil = cxx::mirror().getRecord(StrMute::struct_); // doesn't have any static-methods. ASSERT_TRUE(optStringUtil); std::optional reverseString = optStringUtil->getMethod(str_reverseString); @@ -81,25 +81,25 @@ namespace rtl_tests TEST(ReturnTypeErased_rtl_static_method, implicit_resolutions_to_call_by_value_overloads) { - std::optional optStringUtil = cxx::mirror().getRecord(StringS::struct_); + std::optional optStringUtil = cxx::mirror().getRecord(StrStatic::struct_); ASSERT_TRUE(optStringUtil); std::optional reverseStrOpt = optStringUtil->getMethod(str_reverseString); ASSERT_TRUE(reverseStrOpt); EXPECT_FALSE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt.value() - .targetT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt.value() + .targetT() + .argsT() + .returnT<>(); EXPECT_FALSE(reverseString); { - auto [err, robj] = reverseString(StringS())(const_cast(STRA)); + auto [err, robj] = reverseString(StrStatic())(const_cast(STRA)); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); } { - auto [err, robj] = reverseString.bind(StringS())(const_cast(STRA)); + auto [err, robj] = reverseString.bind(StrStatic())(const_cast(STRA)); EXPECT_EQ(err, rtl::error::InvalidCaller); EXPECT_TRUE(robj.isEmpty()); @@ -107,13 +107,13 @@ namespace rtl_tests } EXPECT_TRUE(reverseStrOpt->hasSignature()); { - rtl::method reverseString = reverseStrOpt.value() - .targetT() - .argsT() - .returnT<>(); + rtl::method reverseString = reverseStrOpt.value() + .targetT() + .argsT() + .returnT<>(); EXPECT_FALSE(reverseString); { - auto [err, robj] = reverseString(StringS())(STRA); + auto [err, robj] = reverseString(StrStatic())(STRA); EXPECT_EQ(err, rtl::error::InvalidStaticMethodCaller); } } { From 00e393e3783ec34fab713b728eaced7fc7009c28 Mon Sep 17 00:00:00 2001 From: neeraj31285 Date: Sat, 8 Nov 2025 16:29:12 +0530 Subject: [PATCH 146/148] CxxTestRegistration: improvements done. --- CxxTestRegistration/inc/Registration.h | 49 +- CxxTestRegistration/inc/TestMirrorProvider.h | 25 +- .../src/AnimalRegistration.cpp | 5 + CxxTestRegistration/src/BookRegistration.cpp | 5 + .../src/CalenderRegistration.cpp | 5 + .../src/ComplexRegistration.cpp | 6 +- CxxTestRegistration/src/DateRegistration.cpp | 5 + CxxTestRegistration/src/EventRegistration.cpp | 5 + .../src/LibraryRegistration.cpp | 5 + .../src/PersonRegistration.cpp | 5 + .../src/PodStdRegistration.cpp | 8 + .../src/StrConstRegistration.cpp | 113 ++++ .../src/StrFuncsRegistration.cpp | 86 +++ .../src/StrMuteRegistration.cpp | 114 ++++ .../src/StrStaticRegistration.cpp | 113 ++++ .../src/TestMirrorProvider.cpp | 499 ++---------------- .../FunctionalityTests/ClassMethodsTests.cpp | 2 +- .../NameSpaceGlobalsTests.cpp | 2 +- .../ReturnValueReflectionTest.cpp | 6 +- 19 files changed, 559 insertions(+), 499 deletions(-) diff --git a/CxxTestRegistration/inc/Registration.h b/CxxTestRegistration/inc/Registration.h index 013f2a8a..fb819625 100644 --- a/CxxTestRegistration/inc/Registration.h +++ b/CxxTestRegistration/inc/Registration.h @@ -8,21 +8,52 @@ namespace rtl { namespace test_mirror { - static void registerPodStdTypes(std::vector&); + extern void registerPodStdTypes(std::vector&); - static void registerTypeComplex(std::vector&); + extern void registerTypeComplex(std::vector&); - static void registerTypeDate(std::vector&); + extern void registerTypeDate(std::vector&); - static void registerTypeEvent(std::vector&); + extern void registerTypeEvent(std::vector&); - static void registerTypeCalender(std::vector&); + extern void registerTypeCalender(std::vector&); - static void registerTypePerson(std::vector&); + extern void registerTypePerson(std::vector&); - static void registerTypeBook(std::vector&); + extern void registerTypeBook(std::vector&); - static void registerTypeLibrary(std::vector&); + extern void registerTypeLibrary(std::vector&); - static void registerTypeAnimal(std::vector&); + extern void registerTypeAnimal(std::vector&); + + extern void registerTypeStringFuncs(std::vector&); + + extern void registerTypeStringMute(std::vector&); + + extern void registerTypeStringConst(std::vector&); + + extern void registerTypeStringStatic(std::vector&); + +//--------------------------------------------------------------------------------- + extern void addTypeIdPodStd(std::unordered_map&); + + extern void addTypeIdDate(std::unordered_map&); + + extern void addTypeIdEvent(std::unordered_map&); + + extern void addTypeIdCalender(std::unordered_map&); + + extern void addTypeIdPerson(std::unordered_map&); + + extern void addTypeIdBook(std::unordered_map&); + + extern void addTypeIdLibrary(std::unordered_map&); + + extern void addTypeIdAnimal(std::unordered_map&); + + extern void addTypeIdStringMute(std::unordered_map&); + + extern void addTypeIdStringConst(std::unordered_map&); + + extern void addTypeIdStringStatic(std::unordered_map&); } \ No newline at end of file diff --git a/CxxTestRegistration/inc/TestMirrorProvider.h b/CxxTestRegistration/inc/TestMirrorProvider.h index 8ab87235..596f3a00 100644 --- a/CxxTestRegistration/inc/TestMirrorProvider.h +++ b/CxxTestRegistration/inc/TestMirrorProvider.h @@ -9,30 +9,7 @@ namespace test_mirror struct cxx { static const rtl::CxxMirror& mirror(); - }; -} - -namespace test_mirror -{ - // Optional setup: do this if you prefer to access your registered types by unique 'ID', not by string. - struct reflected_id { - - static std::size_t date; - static std::size_t book; - static std::size_t event; - static std::size_t animal; - static std::size_t person; - static std::size_t library; - static std::size_t calender; - static std::size_t string_m; - static std::size_t string_c; - static std::size_t string_s; - - static std::size_t char_t; - static std::size_t int_t; - static std::size_t std_string; - static std::size_t std_string_view; - static const std::size_t getRecordIdFor(const std::string& pRecordName); + static const std::size_t reflected_id(const std::string& pRecordName); }; } \ No newline at end of file diff --git a/CxxTestRegistration/src/AnimalRegistration.cpp b/CxxTestRegistration/src/AnimalRegistration.cpp index 33c4194c..1918070c 100644 --- a/CxxTestRegistration/src/AnimalRegistration.cpp +++ b/CxxTestRegistration/src/AnimalRegistration.cpp @@ -9,6 +9,11 @@ using namespace test_utils; namespace test_mirror { + void addTypeIdAnimal(std::unordered_map& id) + { + id.insert(std::make_pair(animal::class_, rtl::detail::TypeId::get())); + } + void registerTypeAnimal(std::vector& fns) { // class 'Animal', methods & constructors. diff --git a/CxxTestRegistration/src/BookRegistration.cpp b/CxxTestRegistration/src/BookRegistration.cpp index b980d707..515c4e0d 100644 --- a/CxxTestRegistration/src/BookRegistration.cpp +++ b/CxxTestRegistration/src/BookRegistration.cpp @@ -9,6 +9,11 @@ using namespace test_utils; namespace test_mirror { + void addTypeIdBook(std::unordered_map& id) + { + id.insert(std::make_pair(book::class_, rtl::detail::TypeId::get())); + } + void registerTypeBook(std::vector& fns) { // class 'Book', methods & constructors. diff --git a/CxxTestRegistration/src/CalenderRegistration.cpp b/CxxTestRegistration/src/CalenderRegistration.cpp index 6896607c..854833c3 100644 --- a/CxxTestRegistration/src/CalenderRegistration.cpp +++ b/CxxTestRegistration/src/CalenderRegistration.cpp @@ -10,6 +10,11 @@ using namespace test_utils; namespace test_mirror { + void addTypeIdCalender(std::unordered_map& id) + { + id.insert(std::make_pair(calender::struct_, rtl::detail::TypeId::get())); + } + void registerTypeCalender(std::vector& fns) { // Registring static-method, 'methodStatic()' function must be used. compiler error otherwise. diff --git a/CxxTestRegistration/src/ComplexRegistration.cpp b/CxxTestRegistration/src/ComplexRegistration.cpp index 51ad05fc..074905de 100644 --- a/CxxTestRegistration/src/ComplexRegistration.cpp +++ b/CxxTestRegistration/src/ComplexRegistration.cpp @@ -15,9 +15,9 @@ namespace test_mirror fns.push_back(rtl::type().function(str_getComplexNumAsString) .build(getComplexNumAsString)); - /* Grouping functions under a namespace, which is optional. they can be registered without it as well. - but if registered under namspace, then to retrieve it from CxxMirror object, namespace name must be passed, - e.g. cxx::mirror().getFunction("namespace_name", "function_name") & cxx::mirror().getRecord("namespace_name", "record_name") */ + /* Grouping functions under a namespace, which is optional. they can be registered without it as well. + but if registered under namspace, then to retrieve it from CxxMirror object, namespace name must be passed, + e.g. cxx::mirror().getFunction("namespace_name", "function_name") & cxx::mirror().getRecord("namespace_name", "record_name") */ fns.push_back(rtl::type().ns(str_complex) .function(str_setReal) .build(complex::setReal)); diff --git a/CxxTestRegistration/src/DateRegistration.cpp b/CxxTestRegistration/src/DateRegistration.cpp index 785d4424..d581684e 100644 --- a/CxxTestRegistration/src/DateRegistration.cpp +++ b/CxxTestRegistration/src/DateRegistration.cpp @@ -9,6 +9,11 @@ using namespace test_utils; namespace test_mirror { + void addTypeIdDate(std::unordered_map& id) + { + id.insert(std::make_pair(date::struct_, rtl::detail::TypeId::get())); + } + void registerTypeDate(std::vector& fns) { // Constructors registration, class/struct name and type must be passed 'record("NAME")'. diff --git a/CxxTestRegistration/src/EventRegistration.cpp b/CxxTestRegistration/src/EventRegistration.cpp index d431113e..7f70bc83 100644 --- a/CxxTestRegistration/src/EventRegistration.cpp +++ b/CxxTestRegistration/src/EventRegistration.cpp @@ -9,6 +9,11 @@ using namespace test_utils; namespace test_mirror { + void addTypeIdEvent(std::unordered_map& id) + { + id.insert(std::make_pair(event::struct_, rtl::detail::TypeId::get())); + } + void registerTypeEvent(std::vector& fns) { // Registering 'Event' for reflection; instance creation via reflection fails since its default constructor is private or deleted. diff --git a/CxxTestRegistration/src/LibraryRegistration.cpp b/CxxTestRegistration/src/LibraryRegistration.cpp index 2ed5c811..5b26a82b 100644 --- a/CxxTestRegistration/src/LibraryRegistration.cpp +++ b/CxxTestRegistration/src/LibraryRegistration.cpp @@ -10,6 +10,11 @@ using namespace test_utils; namespace test_mirror { + void addTypeIdLibrary(std::unordered_map& id) + { + id.insert(std::make_pair(library::class_, rtl::detail::TypeId::get())); + } + void registerTypeLibrary(std::vector& fns) { // Registering Library's constructor. Stack allocation (rtl::alloc::Stack) will fail since its copy constructor is deleted diff --git a/CxxTestRegistration/src/PersonRegistration.cpp b/CxxTestRegistration/src/PersonRegistration.cpp index 48928c3d..954a5f08 100644 --- a/CxxTestRegistration/src/PersonRegistration.cpp +++ b/CxxTestRegistration/src/PersonRegistration.cpp @@ -9,6 +9,11 @@ using namespace test_utils; namespace test_mirror { + void addTypeIdPerson(std::unordered_map& id) + { + id.insert(std::make_pair(person::class_, rtl::detail::TypeId::get())); + } + void registerTypePerson(std::vector& fns) { // class 'Person', methods & constructors. diff --git a/CxxTestRegistration/src/PodStdRegistration.cpp b/CxxTestRegistration/src/PodStdRegistration.cpp index fae4d44e..c18cd704 100644 --- a/CxxTestRegistration/src/PodStdRegistration.cpp +++ b/CxxTestRegistration/src/PodStdRegistration.cpp @@ -5,6 +5,14 @@ namespace test_mirror { + void addTypeIdPodStd(std::unordered_map& id) + { + id.insert(std::make_pair("int", rtl::detail::TypeId::get())); + id.insert(std::make_pair("char", rtl::detail::TypeId::get())); + id.insert(std::make_pair("string", rtl::detail::TypeId::get())); + id.insert(std::make_pair("string_view", rtl::detail::TypeId::get())); + } + void registerPodStdTypes(std::vector& fns) { // Registering int. diff --git a/CxxTestRegistration/src/StrConstRegistration.cpp b/CxxTestRegistration/src/StrConstRegistration.cpp index e69de29b..5cf29bfd 100644 --- a/CxxTestRegistration/src/StrConstRegistration.cpp +++ b/CxxTestRegistration/src/StrConstRegistration.cpp @@ -0,0 +1,113 @@ +#include + +#include "StringOps.h" +#include "Registration.h" +#include "GlobalTestUtils.h" + +using namespace test_utils; + +namespace test_mirror +{ + void addTypeIdStringConst(std::unordered_map& id) + { + id.insert(std::make_pair(StrConst::struct_, rtl::detail::TypeId::get())); + } + + void registerTypeStringConst(std::vector& fns) + { + fns.push_back(rtl::type().record(StrConst::struct_) + .build()); + + // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(&StrConst::reverseString)); + + // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(&StrConst::reverseString)); + + // Overloaded function, takes 'const char*' arguments. + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(&StrConst::reverseString)); + + // numereous other overloads. + #if defined(__GNUC__) && !defined(__clang__) + /* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: + + static_cast(reverseString) + */ + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(static_cast(&StrConst::reverseString))); + + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(static_cast(&StrConst::reverseString))); + + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(static_cast(&StrConst::reverseString))); +#else + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(&StrConst::reverseString)); + + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(&StrConst::reverseString)); + + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(&StrConst::reverseString)); +#endif + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(&StrConst::reverseString)); + + fns.push_back(rtl::type().member() + .methodConst(str_reverseString) + .build(&StrConst::reverseString)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrNonConstRefArg) + .build(&StrConst::revStrNonConstRefArg)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrRValueRefArg) + .build(&StrConst::revStrRValueRefArg)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrConstRefArg) + .build(&StrConst::revStrConstRefArg)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrOverloadValRef) + .build(&StrConst::revStrOverloadValRef)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrOverloadValRef) + .build(&StrConst::revStrOverloadValRef)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrOverloadValCRef) + .build(&StrConst::revStrOverloadValCRef)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrOverloadValCRef) + .build(&StrConst::revStrOverloadValCRef)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrOverloadValRefAndCRef) + .build(&StrConst::revStrOverloadRefAndCRef)); + + fns.push_back(rtl::type().member() + .methodConst(str_revStrOverloadValRefAndCRef) + .build(&StrConst::revStrOverloadRefAndCRef)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/StrFuncsRegistration.cpp b/CxxTestRegistration/src/StrFuncsRegistration.cpp index e69de29b..47a81617 100644 --- a/CxxTestRegistration/src/StrFuncsRegistration.cpp +++ b/CxxTestRegistration/src/StrFuncsRegistration.cpp @@ -0,0 +1,86 @@ + +#include + +#include "StringOps.h" +#include "Registration.h" +#include "GlobalTestUtils.h" + +using namespace test_utils; + +namespace test_mirror +{ + void registerTypeStringFuncs(std::vector& fns) + { + // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. + fns.push_back(rtl::type().function(str_reverseString) + .build(reverseString)); + + // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. + fns.push_back(rtl::type().function(str_reverseString) + .build(reverseString)); + + // Overloaded function, takes 'const char*' arguments. + fns.push_back(rtl::type().function(str_reverseString) + .build(reverseString)); + + // numereous other overloads. + #if defined(__GNUC__) && !defined(__clang__) + /* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: + + static_cast(reverseString) + */ + fns.push_back(rtl::type().function(str_reverseString) + .build(static_cast(reverseString))); + + fns.push_back(rtl::type().function(str_reverseString) + .build(static_cast(reverseString))); + + fns.push_back(rtl::type().function(str_reverseString) + .build(static_cast(reverseString))); +#else + fns.push_back(rtl::type().function(str_reverseString) + .build(reverseString)); + + fns.push_back(rtl::type().function(str_reverseString) + .build(reverseString)); + + fns.push_back(rtl::type().function(str_reverseString) + .build(reverseString)); +#endif + fns.push_back(rtl::type().function(str_reverseString) + .build(reverseString)); + + fns.push_back(rtl::type().function(str_reverseString) + .build(reverseString)); + + fns.push_back(rtl::type().function(str_revStrNonConstRefArg) + .build(revStrNonConstRefArg)); + + fns.push_back(rtl::type().function(str_revStrRValueRefArg) + .build(revStrRValueRefArg)); + + fns.push_back(rtl::type().function(str_revStrConstRefArg) + .build(revStrConstRefArg)); + + fns.push_back(rtl::type().function(str_revStrOverloadValRef) + .build(revStrOverloadValRef)); + + fns.push_back(rtl::type().function(str_revStrOverloadValRef) + .build(revStrOverloadValRef)); + + fns.push_back(rtl::type().function(str_revStrOverloadValCRef) + .build(revStrOverloadValCRef)); + + fns.push_back(rtl::type().function(str_revStrOverloadValCRef) + .build(revStrOverloadValCRef)); + + fns.push_back(rtl::type().function(str_revStrOverloadValRefAndCRef) + .build(revStrOverloadRefAndCRef)); + + fns.push_back(rtl::type().function(str_revStrOverloadValRefAndCRef) + .build(revStrOverloadRefAndCRef)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/StrMuteRegistration.cpp b/CxxTestRegistration/src/StrMuteRegistration.cpp index e69de29b..ece0aea7 100644 --- a/CxxTestRegistration/src/StrMuteRegistration.cpp +++ b/CxxTestRegistration/src/StrMuteRegistration.cpp @@ -0,0 +1,114 @@ + +#include + +#include "StringOps.h" +#include "Registration.h" +#include "GlobalTestUtils.h" + +using namespace test_utils; + +namespace test_mirror +{ + void addTypeIdStringMute(std::unordered_map& id) + { + id.insert(std::make_pair(StrMute::struct_, rtl::detail::TypeId::get())); + } + + void registerTypeStringMute(std::vector& fns) + { + fns.push_back(rtl::type().record(StrMute::struct_) + .build()); + + // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(&StrMute::reverseString)); + + // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(&StrMute::reverseString)); + + // Overloaded function, takes 'const char*' arguments. + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(&StrMute::reverseString)); + + // numereous other overloads. + #if defined(__GNUC__) && !defined(__clang__) + /* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: + + static_cast(reverseString) + */ + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(static_cast(&StrMute::reverseString))); + + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(static_cast(&StrMute::reverseString))); + + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(static_cast(&StrMute::reverseString))); +#else + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(&StrMute::reverseString)); + + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(&StrMute::reverseString)); + + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(&StrMute::reverseString)); +#endif + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(&StrMute::reverseString)); + + fns.push_back(rtl::type().member() + .method(str_reverseString) + .build(&StrMute::reverseString)); + + fns.push_back(rtl::type().member() + .method(str_revStrNonConstRefArg) + .build(&StrMute::revStrNonConstRefArg)); + + fns.push_back(rtl::type().member() + .method(str_revStrRValueRefArg) + .build(&StrMute::revStrRValueRefArg)); + + fns.push_back(rtl::type().member() + .method(str_revStrConstRefArg) + .build(&StrMute::revStrConstRefArg)); + + fns.push_back(rtl::type().member() + .method(str_revStrOverloadValRef) + .build(&StrMute::revStrOverloadValRef)); + + fns.push_back(rtl::type().member() + .method(str_revStrOverloadValRef) + .build(&StrMute::revStrOverloadValRef)); + + fns.push_back(rtl::type().member() + .method(str_revStrOverloadValCRef) + .build(&StrMute::revStrOverloadValCRef)); + + fns.push_back(rtl::type().member() + .method(str_revStrOverloadValCRef) + .build(&StrMute::revStrOverloadValCRef)); + + fns.push_back(rtl::type().member() + .method(str_revStrOverloadValRefAndCRef) + .build(&StrMute::revStrOverloadRefAndCRef)); + + fns.push_back(rtl::type().member() + .method(str_revStrOverloadValRefAndCRef) + .build(&StrMute::revStrOverloadRefAndCRef)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/StrStaticRegistration.cpp b/CxxTestRegistration/src/StrStaticRegistration.cpp index e69de29b..e492a7d9 100644 --- a/CxxTestRegistration/src/StrStaticRegistration.cpp +++ b/CxxTestRegistration/src/StrStaticRegistration.cpp @@ -0,0 +1,113 @@ +#include + +#include "StringOps.h" +#include "Registration.h" +#include "GlobalTestUtils.h" + +using namespace test_utils; + +namespace test_mirror +{ + void addTypeIdStringStatic(std::unordered_map& id) + { + id.insert(std::make_pair(StrStatic::struct_, rtl::detail::TypeId::get())); + } + + void registerTypeStringStatic(std::vector& fns) + { + fns.push_back(rtl::type().record(StrStatic::struct_) + .build()); + + // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(&StrStatic::reverseString)); + + // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(&StrStatic::reverseString)); + + // Overloaded function, takes 'const char*' arguments. + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(&StrStatic::reverseString)); + + // numereous other overloads. + #if defined(__GNUC__) && !defined(__clang__) + /* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: + + static_cast(reverseString) + */ + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(static_cast(&StrStatic::reverseString))); + + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(static_cast(&StrStatic::reverseString))); + + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(static_cast(&StrStatic::reverseString))); +#else + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(&StrStatic::reverseString)); + + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(&StrStatic::reverseString)); + + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(&StrStatic::reverseString)); +#endif + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(&StrStatic::reverseString)); + + fns.push_back(rtl::type().member() + .methodStatic(str_reverseString) + .build(&StrStatic::reverseString)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrNonConstRefArg) + .build(&StrStatic::revStrNonConstRefArg)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrRValueRefArg) + .build(&StrStatic::revStrRValueRefArg)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrConstRefArg) + .build(&StrStatic::revStrConstRefArg)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrOverloadValRef) + .build(&StrStatic::revStrOverloadValRef)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrOverloadValRef) + .build(&StrStatic::revStrOverloadValRef)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrOverloadValCRef) + .build(&StrStatic::revStrOverloadValCRef)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrOverloadValCRef) + .build(&StrStatic::revStrOverloadValCRef)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrOverloadValRefAndCRef) + .build(&StrStatic::revStrOverloadRefAndCRef)); + + fns.push_back(rtl::type().member() + .methodStatic(str_revStrOverloadValRefAndCRef) + .build(&StrStatic::revStrOverloadRefAndCRef)); + } +} \ No newline at end of file diff --git a/CxxTestRegistration/src/TestMirrorProvider.cpp b/CxxTestRegistration/src/TestMirrorProvider.cpp index 4ffb1fb5..d80c0374 100644 --- a/CxxTestRegistration/src/TestMirrorProvider.cpp +++ b/CxxTestRegistration/src/TestMirrorProvider.cpp @@ -1,434 +1,41 @@ #include #include -#include + +#include #include "TestMirrorProvider.h" +#include "Registration.h" #include "CxxMirrorToJson.h" -#include "GlobalTestUtils.h" - -//User defined types to be reflected. -#include "Date.h" -#include "Book.h" -#include "Person.h" -#include "Complex.h" -#include "StringOps.h" -#include "Animal.h" -#include "Library.h" - -/* -TestUtils, provides the interface to test/compare reflected type objects with actual objects (created via strict typing) -without exposing the actual type objects to "CxxReflectionTests" project.*/ -#include "Reflect.hpp" -#include "CxxMirror.hpp" -#include "CxxMirror.h" - -#include "TestUtilsBook.h" -#include "TestUtilsDate.h" -#include "TestUtilsPerson.h" -#include "TestUtilsAnimal.h" - - -using namespace std; -using namespace test_utils; namespace test_mirror { const rtl::CxxMirror& cxx::mirror() { - static auto cxx_mirror = rtl::CxxMirror({ - - /* --------------------------------- - Registering pod & few STL types. - --------------------------------- */ - - // Registering void, valid but not useful at all. - rtl::type().record("int").build(), - - // Registering type 'void' again, ignored & emits- - // [WARNING] Multiple registrations of the same type detected. - rtl::type().record("int").build(), - - // Registering type 'void' again, but with different name. ignored & emits- - // [WARNING] Multiple registrations of the same type detected. - rtl::type().record("ccint").build(), - - // Registering pod, reflecting- constructor, copy-constructor & destructor. - rtl::type().record("char").build(), - - rtl::type().ns("std").record("string_view").build(), - - // Registers std::string class - rtl::type().member().methodConst("empty").build(&std::string::empty), - - /* Attempting to register the same type(`std::string`) again under a different name. - * RTL will ignore this duplicate registration and retain the first one. Emits a warning on the console: - * "[WARNING] Multiple registrations of the same type with different names detected." - */ rtl::type().member().methodConst("empty").build(&std::string::empty), - - rtl::type().ns("std").record("string").build(), - - /* Attempting to register std::string_view, but the provided member function pointer belongs to std::string. - * RTL will ignore this registration. Emits a warning on the console: - * "[WARNING] Member function pointer does not belong to the class being registered!" - */ rtl::type().member().methodConst("empty").build(&std::string::empty), - - //// Finally, register std::string_view with correct member-function-pointer - // rtl::type().ns("ccstd").record().methodConst("empty").build(&std::string_view::empty), - - // Finally, register std::string_view with correct member-function-pointer - rtl::type().member().methodConst("empty").build(&std::string_view::empty), - - - /* ----------------------------------------------------------------- - Registering global, C-like functions, with & without namespaces. - ----------------------------------------------------------------- */ - - // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. - rtl::type().function(str_reverseString).build(reverseString), - - // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. - rtl::type().function(str_reverseString).build(reverseString), - - // Overloaded function, takes 'const char*' arguments. - rtl::type().function(str_reverseString).build(reverseString), - - // numereous other overloads. - #if defined(__GNUC__) && !defined(__clang__) - /* - GCC here fails to automatically resolve the correct overloaded functor - when both a lvalue reference and an rvalue overload exist. - To disambiguate, explicitly cast the function pointer, e.g.: - - static_cast(reverseString) - */ - rtl::type().function(str_reverseString) - .build(static_cast(reverseString)), - rtl::type().function(str_reverseString) - .build(static_cast(reverseString)), - rtl::type().function(str_reverseString) - .build(static_cast(reverseString)), - #else - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), - #endif - rtl::type().function(str_reverseString).build(reverseString), - rtl::type().function(str_reverseString).build(reverseString), - - rtl::type().function(str_revStrNonConstRefArg).build(revStrNonConstRefArg), - rtl::type().function(str_revStrRValueRefArg).build(revStrRValueRefArg), - rtl::type().function(str_revStrConstRefArg).build(revStrConstRefArg), - - rtl::type().function(str_revStrOverloadValRef).build(revStrOverloadValRef), - rtl::type().function(str_revStrOverloadValRef).build(revStrOverloadValRef), - - rtl::type().function(str_revStrOverloadValCRef).build(revStrOverloadValCRef), - rtl::type().function(str_revStrOverloadValCRef).build(revStrOverloadValCRef), - - rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), - rtl::type().function(str_revStrOverloadValRefAndCRef).build(revStrOverloadRefAndCRef), - -//--------------------------------------------------------------------------------------------------------------------------------------------------- - rtl::type().record(StrMute::struct_).build(), - - // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. - rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - - // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. - rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - - // Overloaded function, takes 'const char*' arguments. - rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - - // numereous other overloads. - #if defined(__GNUC__) && !defined(__clang__) - /* - GCC here fails to automatically resolve the correct overloaded functor - when both a lvalue reference and an rvalue overload exist. - To disambiguate, explicitly cast the function pointer, e.g.: - - static_cast(reverseString) - */ - rtl::type().member().method(str_reverseString) - .build(static_cast(&StrMute::reverseString)), - rtl::type().member().method(str_reverseString) - .build(static_cast(&StrMute::reverseString)), - rtl::type().member().method(str_reverseString) - .build(static_cast(&StrMute::reverseString)), - #else - rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - #endif - rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - rtl::type().member().method(str_reverseString).build(&StrMute::reverseString), - - rtl::type().member().method(str_revStrNonConstRefArg).build(&StrMute::revStrNonConstRefArg), - rtl::type().member().method(str_revStrRValueRefArg).build(&StrMute::revStrRValueRefArg), - rtl::type().member().method(str_revStrConstRefArg).build(&StrMute::revStrConstRefArg), - - rtl::type().member().method(str_revStrOverloadValRef).build(&StrMute::revStrOverloadValRef), - rtl::type().member().method(str_revStrOverloadValRef).build(&StrMute::revStrOverloadValRef), - - rtl::type().member().method(str_revStrOverloadValCRef).build(&StrMute::revStrOverloadValCRef), - rtl::type().member().method(str_revStrOverloadValCRef).build(&StrMute::revStrOverloadValCRef), - - rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StrMute::revStrOverloadRefAndCRef), - rtl::type().member().method(str_revStrOverloadValRefAndCRef).build(&StrMute::revStrOverloadRefAndCRef), - -//--------------------------------------------------------------------------------------------------------------------------------------------------- - rtl::type().record(StrConst::struct_).build(), - - // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. - rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), - - // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. - rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), + static auto cxx_mirror = rtl::CxxMirror( + []() { - // Overloaded function, takes 'const char*' arguments. - rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), + std::vector meta_fns; - // numereous other overloads. - #if defined(__GNUC__) && !defined(__clang__) - /* - GCC here fails to automatically resolve the correct overloaded functor - when both a lvalue reference and an rvalue overload exist. - To disambiguate, explicitly cast the function pointer, e.g.: + registerPodStdTypes(meta_fns); - static_cast(reverseString) - */ - rtl::type().member().methodConst(str_reverseString) - .build(static_cast(&StrConst::reverseString)), - rtl::type().member().methodConst(str_reverseString) - .build(static_cast(&StrConst::reverseString)), - rtl::type().member().methodConst(str_reverseString) - .build(static_cast(&StrConst::reverseString)), - #else - rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), - rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), - rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), - #endif - rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), - rtl::type().member().methodConst(str_reverseString).build(&StrConst::reverseString), + registerTypeBook(meta_fns); + registerTypeDate(meta_fns); + registerTypeEvent(meta_fns); + registerTypePerson(meta_fns); + registerTypeAnimal(meta_fns); + registerTypeLibrary(meta_fns); + registerTypeComplex(meta_fns); + registerTypeCalender(meta_fns); - rtl::type().member().methodConst(str_revStrNonConstRefArg).build(&StrConst::revStrNonConstRefArg), - rtl::type().member().methodConst(str_revStrRValueRefArg).build(&StrConst::revStrRValueRefArg), - rtl::type().member().methodConst(str_revStrConstRefArg).build(&StrConst::revStrConstRefArg), - - rtl::type().member().methodConst(str_revStrOverloadValRef).build(&StrConst::revStrOverloadValRef), - rtl::type().member().methodConst(str_revStrOverloadValRef).build(&StrConst::revStrOverloadValRef), - - rtl::type().member().methodConst(str_revStrOverloadValCRef).build(&StrConst::revStrOverloadValCRef), - rtl::type().member().methodConst(str_revStrOverloadValCRef).build(&StrConst::revStrOverloadValCRef), - - rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StrConst::revStrOverloadRefAndCRef), - rtl::type().member().methodConst(str_revStrOverloadValRefAndCRef).build(&StrConst::revStrOverloadRefAndCRef), - -//-------------------------------------------------------------------------------------------------------------------------------------------------------- - rtl::type().record(StrStatic::struct_).build(), - - // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. - rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - - // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. - rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - - // Overloaded function, takes 'const char*' arguments. - rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - - // numereous other overloads. - #if defined(__GNUC__) && !defined(__clang__) - /* - GCC here fails to automatically resolve the correct overloaded functor - when both a lvalue reference and an rvalue overload exist. - To disambiguate, explicitly cast the function pointer, e.g.: - - static_cast(reverseString) - */ - rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StrStatic::reverseString)), - rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StrStatic::reverseString)), - rtl::type().member().methodStatic(str_reverseString) - .build(static_cast(&StrStatic::reverseString)), - #else - rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - #endif - rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - rtl::type().member().methodStatic(str_reverseString).build(&StrStatic::reverseString), - - rtl::type().member().methodStatic(str_revStrNonConstRefArg).build(&StrStatic::revStrNonConstRefArg), - rtl::type().member().methodStatic(str_revStrRValueRefArg).build(&StrStatic::revStrRValueRefArg), - rtl::type().member().methodStatic(str_revStrConstRefArg).build(&StrStatic::revStrConstRefArg), - - rtl::type().member().methodStatic(str_revStrOverloadValRef).build(&StrStatic::revStrOverloadValRef), - rtl::type().member().methodStatic(str_revStrOverloadValRef).build(&StrStatic::revStrOverloadValRef), - - rtl::type().member().methodStatic(str_revStrOverloadValCRef).build(&StrStatic::revStrOverloadValCRef), - rtl::type().member().methodStatic(str_revStrOverloadValCRef).build(&StrStatic::revStrOverloadValCRef), - - rtl::type().member().methodStatic(str_revStrOverloadValRefAndCRef).build(&StrStatic::revStrOverloadRefAndCRef), - rtl::type().member().methodStatic(str_revStrOverloadValRefAndCRef).build(&StrStatic::revStrOverloadRefAndCRef), -//--------------------------------------------------------------------------------------------------------------------------------------------------------- - - // Unique function, no overloads, no need to specify signature as template parameters. - rtl::type().function(str_getComplexNumAsString).build(getComplexNumAsString), - - /* Grouping functions under a namespace, which is optional. they can be registered without it as well. - but if registered under namspace, then to retrieve it from CxxMirror object, namespace name must be passed, - e.g. cxx::mirror().getFunction("namespace_name", "function_name") & cxx::mirror().getRecord("namespace_name", "record_name") - */ rtl::type().ns(str_complex).function(str_setReal).build(complex::setReal), - rtl::type().ns(str_complex).function(str_setImaginary).build(complex::setImaginary), - rtl::type().ns(str_complex).function(str_getMagnitude).build(complex::getMagnitude), - - /* ----------------------------------------------------------------------------------------------------------- - Registering user defined types. class/struct- generally termed as 'Record' as per LLVM's naming convention - ----------------------------------------------------------------------------------------------------------- */ - - // Constructors registration, class/struct name and type must be passed 'record("NAME")'. - // Registers default constructor with implicit registration of destructor & copy-constructor. - rtl::type().ns(date::ns).record(date::struct_).build(), - - // Overloaded constructor, taking 'string' as argument, signature must be specified as template parameter. - rtl::type().member().constructor().build(), - - // Again, register an overloaded constructor with diffeent signature. - rtl::type().member().constructor().build(), - - // Registring, Unique method, no overloads. Taking param 'std::string', auto deduced via function-pointer. - rtl::type().member().method(date::str_updateDate).build(&nsdate::Date::updateDate), - - // Registring const-method, 'methodConst()' function must be used. compiler error otherwise. - rtl::type().member().methodConst(date::str_getAsString).build(&nsdate::Date::getAsString), - - // Registring static-method, 'methodStatic()' function must be used. compiler error otherwise. - rtl::type().member().methodStatic(calender::str_create).build(&nsdate::Calender::create), - - // Registring unique methods of class Calender, no overloads. - rtl::type().member().method(calender::str_getTheEvent).build(&nsdate::Calender::getTheEvent), - rtl::type().member().method(calender::str_getTheDate).build(&nsdate::Calender::getTheDate), - rtl::type().member().method(calender::str_getSavedEvent).build(&nsdate::Calender::getSavedEvent), - rtl::type().member().method(calender::str_getSavedDate).build(&nsdate::Calender::getSavedDate), - - // class Calender, registering after the methods. (order doesn't matter) - rtl::type().ns(date::ns).record(calender::struct_).build(), - - // Registering 'Event' for reflection; instance creation fails since its default constructor is private or deleted. - // At least one member must be registered for RTL to recognize the type. be it property, member-function or constructor. - rtl::type().ns(event::ns).record(event::struct_).build(), - rtl::type().member().method(event::str_reset).build(&nsdate::Event::reset), - - // Registering Library's constructor. Stack allocation (rtl::alloc::Stack) will fail since its copy constructor is deleted - // and its required by 'std::any' to store its object via copy-construction. But instance on heap (rtl::alloc::HEAP) can be - // constructed since, in that case, 'std::any' stores only the poiner which does not requires copy constructor to be called. - rtl::type().record(library::class_).build(), - - // Registring static-method, 'methodStatic()' function must be used. compiler error otherwise. - rtl::type().member().methodStatic(library::str_addBook).build(&Library::addBook), - rtl::type().member().methodStatic(library::str_getBookByTitle).build(&Library::getBookByTitle), - - // class 'Book', methods & constructors. - // Registering default constructor. - rtl::type().record(book::class_).build(), - - // Registering overloaded constructor, signature must be specified as template parameter. - rtl::type().member().constructor().build(), - - // Unique methods, no overloads. - rtl::type().member().method(book::str_setAuthor).build(&Book::setAuthor), - - // Unique method, taking 'std::string' & 'const std::string&' as argument, auto deduced via function-pointer. - rtl::type().member().method(book::str_addPreface).build(&Book::addPreface), - - // Furthur registrations of unique-menthods, signature auto-deduced via function pointer. - rtl::type().member().method(book::str_setDescription).build(&Book::setDescription), - rtl::type().member().method(book::str_getPublishedOn).build(&Book::getPublishedOn), - rtl::type().member().method(book::str_addCopyrightTag).build(&Book::addCopyrightTag), - - // Registering overloaded methods, signature must be specified as template params since other overloads exists, else compiler error. - rtl::type().member().method(book::str_updateBookInfo).build(&Book::updateBookInfo), - rtl::type().member().method(book::str_updateBookInfo).build(&Book::updateBookInfo), - rtl::type().member().method(book::str_updateBookInfo).build(&Book::updateBookInfo), - - // class 'Person', methods & constructors. - rtl::type().record(person::class_).build(), - rtl::type().member().constructor().build(), - rtl::type().member().methodStatic(person::str_createPtr).build(&Person::createPtr), - rtl::type().member().method(person::str_updateAddress).build(&Person::updateAddress), - rtl::type().member().method(person::str_updateAddress).build(&Person::updateAddress), - rtl::type().member().method(person::str_getFirstName).build(&Person::getFirstName), - - // Registring const-method, 'methodConst()' function must be used. compiler error otherwise. - rtl::type().member().methodConst(person::str_updateLastName).build(&Person::updateLastName), - - // Registring const-method overload, non-const overloaded method already registered above. - rtl::type().member().methodConst(person::str_updateAddress).build(&Person::updateAddress), - rtl::type().member().methodConst(person::str_updateAddress).build(&Person::updateAddress), - rtl::type().member().methodStatic(person::str_getDefaults).build(&Person::getDefaults), - rtl::type().member().methodStatic(person::str_createConst).build(&Person::createConst), - rtl::type().member().methodStatic(person::str_getProfile).build(&Person::getProfile), - rtl::type().member().methodStatic(person::str_getProfile).build(&Person::getProfile), - rtl::type().member().methodStatic(person::str_getProfile).build(&Person::getProfile), - - // class 'Animal', methods & constructors. - rtl::type().record(animal::class_).build(), - rtl::type().member().constructor().build(), //overloaded constructor. - rtl::type().member().method(animal::str_setFamilyName).build(&Animal::setFamilyName), //unique method, no overloads. - - // Unique const-method, no overloads. - rtl::type().member().methodConst(animal::str_getFamilyName).build(&Animal::getFamilyName), - - // Overloaded method, taking const-ref as argument. - rtl::type().member().method(animal::str_setAnimalName).build(&Animal::setAnimalName), - - // Static method, taking const-ref as argument. - rtl::type().member().methodStatic(animal::str_updateZooKeeper).build(&Animal::updateZooKeeper), - - #if defined(__GNUC__) && !defined(__clang__) - /* - GCC here fails to automatically resolve the correct overloaded functor - when both a lvalue reference and an rvalue overload exist. - To disambiguate, explicitly cast the member function pointer, e.g.: - - static_cast(&Animal::setAnimalName) - */ - rtl::type().member() - .method(animal::str_setAnimalName) - .build(static_cast(&Animal::setAnimalName)), //overloaded method, taking non-const lvalue reference as argument. - - rtl::type().member() - .method(animal::str_setAnimalName) - .build(static_cast(&Animal::setAnimalName)), //overloaded method, taking rvalue reference as argument. - - rtl::type().member() - .methodStatic(animal::str_updateZooKeeper) - .build(static_cast(&Animal::updateZooKeeper)), //static method, taking non-const lvalue reference as argument. - - rtl::type().member() - .methodStatic(animal::str_updateZooKeeper) - .build(static_cast(&Animal::updateZooKeeper)), //static method, taking rvalue reference as argument. - #else - rtl::type().member() - .method(animal::str_setAnimalName) - .build(&Animal::setAnimalName), //overloaded method, taking non-const lvalue reference as argument. - - rtl::type().member() - .method(animal::str_setAnimalName) - .build(&Animal::setAnimalName), //overloaded method, taking rvalue reference as argument. - - rtl::type().member() - .methodStatic(animal::str_updateZooKeeper) - .build(&Animal::updateZooKeeper), //static method, taking non-const lvalue reference as argument. - - rtl::type().member() - .methodStatic(animal::str_updateZooKeeper) - .build(&Animal::updateZooKeeper), //static method, taking rvalue reference as argument. - #endif - }); + registerTypeStringMute(meta_fns); + registerTypeStringConst(meta_fns); + registerTypeStringFuncs(meta_fns); + registerTypeStringStatic(meta_fns); + return meta_fns; + }() + ); static const auto _= [&]() { @@ -441,53 +48,29 @@ namespace test_mirror return cxx_mirror; } -} - - -namespace test_mirror -{ - //Optional setup for accessing registered types via unique-ids. (for Testing-Purposes only, not required by RTL). - std::size_t reflected_id::book = rtl::detail::TypeId::get(); - std::size_t reflected_id::person = rtl::detail::TypeId::get(); - std::size_t reflected_id::animal = rtl::detail::TypeId::get(); - std::size_t reflected_id::library = rtl::detail::TypeId::get(); - - std::size_t reflected_id::date = rtl::detail::TypeId::get(); - std::size_t reflected_id::event = rtl::detail::TypeId::get(); - std::size_t reflected_id::calender = rtl::detail::TypeId::get(); - std::size_t reflected_id::string_m = rtl::detail::TypeId::get(); - std::size_t reflected_id::string_c = rtl::detail::TypeId::get(); - std::size_t reflected_id::string_s = rtl::detail::TypeId::get(); - - std::size_t reflected_id::int_t = rtl::detail::TypeId::get(); - std::size_t reflected_id::char_t = rtl::detail::TypeId::get(); - std::size_t reflected_id::std_string = rtl::detail::TypeId::get(); - std::size_t reflected_id::std_string_view = rtl::detail::TypeId::get(); - - //Optional setup - mapping unique-ids to string type-names (for Testing-Purposes only, not required by RTL). - const std::size_t reflected_id::getRecordIdFor(const std::string& pRecordName) + const std::size_t cxx::reflected_id(const std::string& pRecordName) { - static std::unordered_map nameIdMap( + static std::unordered_map nameIdMap = []() { - { "char", char_t }, - { "int", int_t }, - { "string", std_string }, - { "string_view", std_string_view }, - - { book::class_, book }, - { date::struct_, date }, - { event::struct_, event }, - { animal::class_, animal }, - { person::class_, person }, - { library::class_, library }, - { calender::struct_, calender }, - { StrMute::struct_, string_m }, - { StrConst::struct_, string_c }, - { StrStatic::struct_, string_s } - }); + std::unordered_map idMap; + + addTypeIdBook(idMap); + addTypeIdDate(idMap); + addTypeIdEvent(idMap); + addTypeIdPerson(idMap); + addTypeIdPodStd(idMap); + addTypeIdAnimal(idMap); + addTypeIdLibrary(idMap); + addTypeIdCalender(idMap); + addTypeIdStringMute(idMap); + addTypeIdStringConst(idMap); + addTypeIdStringStatic(idMap); + + return idMap; + }(); const auto& itr = nameIdMap.find(pRecordName); - return (itr == nameIdMap.end() ? rtl::index_none:itr->second); + return (itr == nameIdMap.end() ? rtl::index_none : itr->second); } } \ No newline at end of file diff --git a/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp index f1804d82..54cc1f7b 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ClassMethodsTests.cpp @@ -35,7 +35,7 @@ namespace rtl_tests for (const auto& itr1 : namespaceRecordMap) { const std::string& recordName = itr1.first; - const std::size_t recordId = reflected_id::getRecordIdFor(recordName); + const std::size_t recordId = cxx::reflected_id(recordName); const auto& itr = rtl_recordIdMap.find(recordId); ASSERT_TRUE(itr != rtl_recordIdMap.end()); diff --git a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp index 80b451f6..a7afb80c 100644 --- a/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/NameSpaceGlobalsTests.cpp @@ -18,7 +18,7 @@ namespace rtl_tests TEST(Reflecting_pod, construct_char_on_heap_and_stack) { - optional charType = cxx::mirror().getRecord(reflected_id::char_t); + optional charType = cxx::mirror().getRecord(cxx::reflected_id("char")); ASSERT_TRUE(charType); { /* Attempting to construct a POD type('char') with a value directly via Record::create<>(). diff --git a/RTLTestRunApp/src/FunctionalityTests/ReturnValueReflectionTest.cpp b/RTLTestRunApp/src/FunctionalityTests/ReturnValueReflectionTest.cpp index e0271cde..76ecdecf 100644 --- a/RTLTestRunApp/src/FunctionalityTests/ReturnValueReflectionTest.cpp +++ b/RTLTestRunApp/src/FunctionalityTests/ReturnValueReflectionTest.cpp @@ -13,7 +13,7 @@ namespace rtl_tests TEST(ReflecetdReturnValues, on_registered_return_type__test_cloning) { //I don't know if the 'Event' is class or struct..Reflection YaY!. :P - auto classEvent = cxx::mirror().getRecord(reflected_id::event); + auto classEvent = cxx::mirror().getRecord(cxx::reflected_id(event::struct_)); ASSERT_TRUE(classEvent); auto [err0, robj0] = classEvent->create(); @@ -22,7 +22,7 @@ namespace rtl_tests EXPECT_TRUE(err0 == rtl::error::TypeNotDefaultConstructible); ASSERT_TRUE(robj0.isEmpty()); { - auto classCalender = cxx::mirror().getRecord(reflected_id::calender); + auto classCalender = cxx::mirror().getRecord(cxx::reflected_id(calender::struct_)); ASSERT_TRUE(classCalender); auto [err1, calender] = classCalender->create(); @@ -43,7 +43,7 @@ namespace rtl_tests auto [err2, event] = getEvent->bind(calender).call(); EXPECT_TRUE(err2 == rtl::error::None); ASSERT_FALSE(event.isEmpty()); - EXPECT_TRUE(event.getTypeId() == reflected_id::event); + EXPECT_TRUE(event.getTypeId() == cxx::reflected_id(event::struct_)); { { auto [err, robj] = event.clone(); From e92d2eb0f937630ded954b0416e734e7ddf98761 Mon Sep 17 00:00:00 2001 From: neeraj Date: Sat, 8 Nov 2025 17:01:34 +0530 Subject: [PATCH 147/148] fix- gcc compile errors. --- .../src/StrConstRegistration.cpp | 6 ++-- .../src/StrFuncsRegistration.cpp | 31 +++++++++---------- .../src/StrStaticRegistration.cpp | 6 ++-- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/CxxTestRegistration/src/StrConstRegistration.cpp b/CxxTestRegistration/src/StrConstRegistration.cpp index 5cf29bfd..98141331 100644 --- a/CxxTestRegistration/src/StrConstRegistration.cpp +++ b/CxxTestRegistration/src/StrConstRegistration.cpp @@ -44,15 +44,15 @@ namespace test_mirror */ fns.push_back(rtl::type().member() .methodConst(str_reverseString) - .build(static_cast(&StrConst::reverseString))); + .build(static_cast(&StrConst::reverseString))); fns.push_back(rtl::type().member() .methodConst(str_reverseString) - .build(static_cast(&StrConst::reverseString))); + .build(static_cast(&StrConst::reverseString))); fns.push_back(rtl::type().member() .methodConst(str_reverseString) - .build(static_cast(&StrConst::reverseString))); + .build(static_cast(&StrConst::reverseString))); #else fns.push_back(rtl::type().member() .methodConst(str_reverseString) diff --git a/CxxTestRegistration/src/StrFuncsRegistration.cpp b/CxxTestRegistration/src/StrFuncsRegistration.cpp index 47a81617..0bc77b12 100644 --- a/CxxTestRegistration/src/StrFuncsRegistration.cpp +++ b/CxxTestRegistration/src/StrFuncsRegistration.cpp @@ -9,37 +9,36 @@ using namespace test_utils; namespace test_mirror { - void registerTypeStringFuncs(std::vector& fns) - { + void registerTypeStringFuncs(std::vector& fns) + { // Function taking no arguments. '' must be specified if other overload exists else not needed. compiler error otherwise. fns.push_back(rtl::type().function(str_reverseString) - .build(reverseString)); + .build(reverseString)); // Overloaded function, takes 'string' arguments. '' must be specified as template parameter. fns.push_back(rtl::type().function(str_reverseString) - .build(reverseString)); + .build(reverseString)); // Overloaded function, takes 'const char*' arguments. fns.push_back(rtl::type().function(str_reverseString) - .build(reverseString)); - + .build(reverseString)); // numereous other overloads. #if defined(__GNUC__) && !defined(__clang__) - /* - GCC here fails to automatically resolve the correct overloaded functor - when both a lvalue reference and an rvalue overload exist. - To disambiguate, explicitly cast the function pointer, e.g.: +/* + GCC here fails to automatically resolve the correct overloaded functor + when both a lvalue reference and an rvalue overload exist. + To disambiguate, explicitly cast the function pointer, e.g.: - static_cast(reverseString) - */ + static_cast(reverseString) +*/ fns.push_back(rtl::type().function(str_reverseString) - .build(static_cast(reverseString))); + .build(static_cast(reverseString))); fns.push_back(rtl::type().function(str_reverseString) - .build(static_cast(reverseString))); + .build(static_cast(reverseString))); fns.push_back(rtl::type().function(str_reverseString) - .build(static_cast(reverseString))); + .build(static_cast(reverseString))); #else fns.push_back(rtl::type().function(str_reverseString) .build(reverseString)); @@ -82,5 +81,5 @@ namespace test_mirror fns.push_back(rtl::type().function(str_revStrOverloadValRefAndCRef) .build(revStrOverloadRefAndCRef)); - } + } } \ No newline at end of file diff --git a/CxxTestRegistration/src/StrStaticRegistration.cpp b/CxxTestRegistration/src/StrStaticRegistration.cpp index e492a7d9..a09863f9 100644 --- a/CxxTestRegistration/src/StrStaticRegistration.cpp +++ b/CxxTestRegistration/src/StrStaticRegistration.cpp @@ -44,15 +44,15 @@ namespace test_mirror */ fns.push_back(rtl::type().member() .methodStatic(str_reverseString) - .build(static_cast(&StrStatic::reverseString))); + .build(static_cast(&StrStatic::reverseString))); fns.push_back(rtl::type().member() .methodStatic(str_reverseString) - .build(static_cast(&StrStatic::reverseString))); + .build(static_cast(&StrStatic::reverseString))); fns.push_back(rtl::type().member() .methodStatic(str_reverseString) - .build(static_cast(&StrStatic::reverseString))); + .build(static_cast(&StrStatic::reverseString))); #else fns.push_back(rtl::type().member() .methodStatic(str_reverseString) From d7103333ae49666da35420bd47012904b3bdced4 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Sat, 8 Nov 2025 22:42:31 +0530 Subject: [PATCH 148/148] Readme update. --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d77d73b9..d0c79da8 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,15 @@ Yes — `rtl::function`’s dispatch is faster than `std::function`. Create an instance of `CxxMirror`, passing all type information directly to its constructor — and you’re done! ```c++ auto cxx_mirror = rtl::CxxMirror({ - // Register free function - + // Register free(C-Style) function - rtl::type().function("complexToStr").build(complexToStr), - // Register class 'Person'- - rtl::type().record("Person").build(), - rtl::type().member().constructor().build(), // User defined ctor. - rtl::type().member().method("setAge").build(Person::setAge), // a setter method. - rtl::type().member().method("getName").build(Person::getName) // and a getter. + // Register class 'Person' ('record' is general term used for 'struct/class') - + rtl::type().record("Person").build(), // Registers default/copy ctor as well. + // Register user-defined ctor - + rtl::type().member().constructor().build(), + // Register methods - + rtl::type().member().method("setAge").build(&Person::setAge), + rtl::type().member().method("getName").build(&Person::getName) }); ``` The `cxx_mirror` object is your gateway to runtime reflection — it lets you query, introspect, and even instantiate types without any compile-time knowledge. It can live anywhere — in any translation unit, quietly resting in a corner of your codebase, remaining dormant until first access. All you need is to expose the `cxx_mirror` wherever reflection is required.