From eb395e925d0832950a6357a451978ed28f2f1594 Mon Sep 17 00:00:00 2001 From: Dmitrii Petukhov Date: Wed, 12 Feb 2025 18:33:20 +0200 Subject: [PATCH 1/3] Implement support for exists() in BISON expressions Signed-off-by: Dmitrii Petukhov --- .../bmq/bmqeval/bmqeval_simpleevaluator.cpp | 29 +++++++++++++++ .../bmq/bmqeval/bmqeval_simpleevaluator.h | 36 +++++++++++++++++++ .../bmq/bmqeval/bmqeval_simpleevaluator.t.cpp | 9 +++++ .../bmqeval/bmqeval_simpleevaluatorparser.y | 27 +++++++++++--- .../bmqeval/bmqeval_simpleevaluatorscanner.l | 5 +++ 5 files changed, 102 insertions(+), 4 deletions(-) diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp index b88ef3d473..7ceefb5f17 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp @@ -364,5 +364,34 @@ bdld::Datum SimpleEvaluator::Not::evaluate(EvaluationContext& context) const return bdld::Datum::createBoolean(!value.theBoolean()); } +// -------------------------- +// class SimpleEvaluator::Exists +// -------------------------- + +SimpleEvaluator::Exists::Exists(const bsl::string& name) +: d_name(name) +{ +} + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) +SimpleEvaluator::Exists::Exists(bsl::string&& name) noexcept +: d_name(bsl::move(name)) +{ +} +#endif + +bdld::Datum SimpleEvaluator::Exists::evaluate(EvaluationContext& context) const +{ + bdld::Datum value = context.d_propertiesReader->get(d_name, + context.d_allocator); + + if (value.isError()) { + return bdld::Datum::createBoolean(false); + } + + return bdld::Datum::createBoolean(true); +} + } // close package namespace } // close enterprise namespace diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h index 79e4122ba1..7a8e581ed7 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h @@ -478,6 +478,41 @@ class SimpleEvaluator { evaluate(EvaluationContext& context) const BSLS_KEYWORD_OVERRIDE; }; + // --- + // Exists + // --- + + class Exists : public Expression { + private: + // DATA + + // The name of the property. + bsl::string d_name; + + public: + // CREATORS + + /// Create an object that evaluates property `name`, in the + /// evaluation context, as a boolean. + explicit Exists(const bsl::string& name); + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) + /// Create an object that evaluates property `name`, in the + /// evaluation context, as a boolean. + explicit Exists(bsl::string&& name) noexcept; +#endif + + // ACCESSORS + + /// Evaluate `expression` passed to the constructor. If it is a + /// boolean, return the negated value as a boolean Datum. + /// Otherwise, set the error in the context to e_TYPE, stop the + /// evaluation, and return a null datum. + bdld::Datum + evaluate(EvaluationContext& context) const BSLS_KEYWORD_OVERRIDE; + }; + private: // SimpleEvaluator(const SimpleEvaluator& other) BSLS_KEYWORD_DELETED; // SimpleEvaluator& operator=(const SimpleEvaluator& other) @@ -549,6 +584,7 @@ class SimpleEvaluator { friend class SimpleEvaluatorScanner; // for access to Expression hierarchy friend class CompilationContext; // for access to ExpressionPtr }; + // ======================== // class CompilationContext // ======================== diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp index de3fd963fc..7c48688b16 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp @@ -55,6 +55,7 @@ class MockPropertiesReader : public PropertiesReader { d_map["i_42"] = bdld::Datum::createInteger(42); d_map["i64_42"] = bdld::Datum::createInteger64(42, allocator); d_map["s_foo"] = bdld::Datum::createStringRef("foo", allocator); + d_map["exists"] = bdld::Datum::createInteger(42); } // Destroy this object. @@ -520,6 +521,14 @@ static void test3_evaluation() {"i_0 != -9223372036854775807", true}, // -(2 ** 63) + 1 {"i_0 != 9223372036854775807", true}, // 2 ** 63 - 1 {"i_0 != -9223372036854775808", true}, // -(2 ** 63) + + // exists + {"exists(i_42)", true}, + {"exists(non_existing_property)", false}, + {"exists(i_42) && i_42 > 41", true}, + {"exists(non_existing_property) && non_existing_property > 41", false}, + {"exists == 42", true}, + {"exists(exists)", true}, }; const TestParameters* testParametersEnd = testParameters + sizeof(testParameters) / diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorparser.y b/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorparser.y index cfcd81e15e..83896ca5e7 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorparser.y +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorparser.y @@ -75,6 +75,7 @@ %token PLUS "+" MINUS "-"; %token TIMES "*" DIVIDES "/" MODULUS "%"; %token EQ "=" NE "<>" LT "<" LE "<=" GE ">=" GT ">"; +%token EXISTS "exists"; %left OR; %left AND; @@ -84,6 +85,7 @@ %left TIMES DIVIDES MODULUS; %right NOT "!"; +%type variable; %type expression; %type predicate; %start predicate @@ -95,18 +97,35 @@ predicate : expression END ctx.d_expression = $1; } -expression +variable : PROPERTY { + ++ctx.d_numProperties; + $$ = $1; + } + | EXISTS + { + ++ctx.d_numProperties; + $$ = $1; + } -#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \ +expression + : variable { + #if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \ && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) $$ = ctx.makeUnaryExpression(bsl::move($1)); #else $$ = ctx.makeUnaryExpression($1); #endif - - ++ctx.d_numProperties; + } + | EXISTS LPAR variable RPAR + { +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \ +&& defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) + $$ = ctx.makeUnaryExpression(bsl::move($3)); +#else + $$ = ctx.makeUnaryExpression($3); +#endif } | INTEGER { $$ = ctx.makeLiteral($1); } diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorscanner.l b/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorscanner.l index c0da8dea85..b9e5cd6a3d 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorscanner.l +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorscanner.l @@ -32,6 +32,11 @@ return SimpleEvaluatorParser::make_FALSE(); } +"exists" { + updatePosition(); + return SimpleEvaluatorParser::make_EXISTS(yytext); +} + [a-zA-Z][a-zA-Z0-9_.]* { updatePosition(); return SimpleEvaluatorParser::make_PROPERTY(yytext); From 28c0bcc8357252ea9bbab5e12922fb29cef62762 Mon Sep 17 00:00:00 2001 From: Dmitrii Petukhov Date: Fri, 14 Feb 2025 18:00:51 +0200 Subject: [PATCH 2/3] Implement support for abs() in subscription expressions Signed-off-by: Dmitrii Petukhov --- .../bmq/bmqeval/bmqeval_simpleevaluator.cpp | 29 ++++ .../bmq/bmqeval/bmqeval_simpleevaluator.h | 36 ++++ .../bmq/bmqeval/bmqeval_simpleevaluator.t.cpp | 8 + .../bmqeval/bmqeval_simpleevaluatorparser.y | 8 + .../bmqeval/bmqeval_simpleevaluatorscanner.l | 5 + src/groups/bmq/bmqu/bmqu_operationchain.h | 14 +- .../bmq/bmqu/bmqu_operationchain_cpp03.h | 157 ++++++++++-------- 7 files changed, 179 insertions(+), 78 deletions(-) diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp index 7ceefb5f17..3dbf4e7405 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp @@ -364,6 +364,35 @@ bdld::Datum SimpleEvaluator::Not::evaluate(EvaluationContext& context) const return bdld::Datum::createBoolean(!value.theBoolean()); } +// --------------------------------- +// class SimpleEvaluator::Abs +// --------------------------------- + +bdld::Datum +SimpleEvaluator::Abs::evaluate(EvaluationContext& context) const +{ + bdld::Datum expr = d_expression->evaluate(context); + if (context.d_stop) { + return bdld::Datum::createNull(); // RETURN + } + + bsls::Types::Int64 value; + if (expr.isInteger64()) { + value = expr.theInteger64(); + } + + else if (expr.isInteger()) { + value = expr.theInteger(); + } + else { + context.d_lastError = ErrorType::e_TYPE; + return context.stop(); // RETURN + } + + value = abs(value); + return bdld::Datum::createInteger64(value, context.d_allocator); +} + // -------------------------- // class SimpleEvaluator::Exists // -------------------------- diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h index 7a8e581ed7..0cbd51c86d 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h @@ -451,6 +451,33 @@ class SimpleEvaluator { evaluate(EvaluationContext& context) const BSLS_KEYWORD_OVERRIDE; }; + // ---------- + // Abs + // ---------- + + class Abs : public Expression { + private: + // DATA + + // The expression to negate. + ExpressionPtr d_expression; + + public: + // CREATORS + + /// Create an object that implements arithmetic negation. + explicit Abs(ExpressionPtr expression); + + // ACCESSORS + + /// Evaluate `expression` passed to the constructor. If it is an + /// integer, return the negated value as an Int64 Datum. Otherwise, + /// set the error in the context to e_TYPE, stop the evaluation, + /// and return a null datum. + bdld::Datum + evaluate(EvaluationContext& context) const BSLS_KEYWORD_OVERRIDE; + }; + // --- // Not // --- @@ -995,6 +1022,15 @@ inline SimpleEvaluator::Not::Not(ExpressionPtr expression) { } +// ------------------------------------------ +// template class SimpleEvaluator::Abs +// ------------------------------------------ + +inline SimpleEvaluator::Abs::Abs(ExpressionPtr expression) +: d_expression(expression) +{ +} + // ------------------------ // class CompilationContext // ------------------------ diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp index 7c48688b16..64e31a1646 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp @@ -53,6 +53,7 @@ class MockPropertiesReader : public PropertiesReader { d_map["i_2"] = bdld::Datum::createInteger(2); d_map["i_3"] = bdld::Datum::createInteger(3); d_map["i_42"] = bdld::Datum::createInteger(42); + d_map["i_n42"] = bdld::Datum::createInteger(-42); d_map["i64_42"] = bdld::Datum::createInteger64(42, allocator); d_map["s_foo"] = bdld::Datum::createStringRef("foo", allocator); d_map["exists"] = bdld::Datum::createInteger(42); @@ -428,6 +429,13 @@ static void test3_evaluation() // mixed integer types {"i_42 == 42", true}, + // abs function + {"i_n42 == -42", true}, + {"-i_n42 == 42", true}, + {"abs(i_n42) == 42", true}, + {"abs(i_n42) == i_42", true}, + {"abs(i_42) == i_42", true}, + // string comparisons {"s_foo == \"foo\"", true}, {"s_foo != \"foo\"", false}, diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorparser.y b/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorparser.y index 83896ca5e7..eed1ade2d0 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorparser.y +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorparser.y @@ -76,6 +76,7 @@ %token TIMES "*" DIVIDES "/" MODULUS "%"; %token EQ "=" NE "<>" LT "<" LE "<=" GE ">=" GT ">"; %token EXISTS "exists"; +%token ABS "abs"; %left OR; %left AND; @@ -108,6 +109,11 @@ variable ++ctx.d_numProperties; $$ = $1; } + | ABS + { + ++ctx.d_numProperties; + $$ = $1; + } expression : variable { @@ -158,6 +164,8 @@ expression { $$ = ctx.makeBooleanBinaryExpression($1, $3); } | NOT expression { $$ = ctx.makeUnaryExpression($2); } + | ABS LPAR expression RPAR + { $$ = ctx.makeUnaryExpression($3); } | expression PLUS expression { $$ = ctx.makeNumBinaryExpression($1, $3); } | expression MINUS expression diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorscanner.l b/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorscanner.l index b9e5cd6a3d..51f6de212d 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorscanner.l +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluatorscanner.l @@ -37,6 +37,11 @@ return SimpleEvaluatorParser::make_EXISTS(yytext); } +"abs" { + updatePosition(); + return SimpleEvaluatorParser::make_ABS(yytext); +} + [a-zA-Z][a-zA-Z0-9_.]* { updatePosition(); return SimpleEvaluatorParser::make_PROPERTY(yytext); diff --git a/src/groups/bmq/bmqu/bmqu_operationchain.h b/src/groups/bmq/bmqu/bmqu_operationchain.h index 01465b8246..cec2c7c31d 100644 --- a/src/groups/bmq/bmqu/bmqu_operationchain.h +++ b/src/groups/bmq/bmqu/bmqu_operationchain.h @@ -192,11 +192,11 @@ #if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // Include version that can be compiled with C++03 -// Generated on Tue Oct 15 17:39:53 2024 +// Generated on Fri Feb 14 17:43:15 2025 // Command line: sim_cpp11_features.pl bmqu_operationchain.h -#define COMPILING_BMQU_OPERATIONCHAIN_H -#include -#undef COMPILING_BMQU_OPERATIONCHAIN_H +# define COMPILING_BMQU_OPERATIONCHAIN_H +# include +# undef COMPILING_BMQU_OPERATIONCHAIN_H #else namespace BloombergLP { @@ -301,7 +301,7 @@ class OperationChain_CompletionCallbackWrapper { public: // ACCESSORS -#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9 +#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9 /// Invoke the associated completion callback with the specified `args` /// arguments and notify the associated operation chain. Propagate any @@ -806,7 +806,7 @@ inline OperationChain_CompletionCallbackWrapper:: } // ACCESSORS -#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9 +#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9 template template inline void OperationChain_CompletionCallbackWrapper::operator()( @@ -1021,6 +1021,6 @@ inline void bmqu::swap(OperationChainLink& lhs, } // close enterprise namespace -#endif // End C++11 code +#endif // End C++11 code #endif diff --git a/src/groups/bmq/bmqu/bmqu_operationchain_cpp03.h b/src/groups/bmq/bmqu/bmqu_operationchain_cpp03.h index dd69f868df..fa009a09e6 100644 --- a/src/groups/bmq/bmqu/bmqu_operationchain_cpp03.h +++ b/src/groups/bmq/bmqu/bmqu_operationchain_cpp03.h @@ -36,7 +36,7 @@ // regions of C++11 code, then this header contains no code and is not // '#include'd in the original header. // -// Generated on Thu Oct 17 16:05:19 2024 +// Generated on Fri Feb 14 17:43:15 2025 // Command line: sim_cpp11_features.pl bmqu_operationchain.h #ifdef COMPILING_BMQU_OPERATIONCHAIN_H @@ -163,20 +163,26 @@ class OperationChain_CompletionCallbackWrapper { #endif // BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 1 #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 2 - template + template void operator()(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2) const; #endif // BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 2 #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 3 - template + template void operator()(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_3) args_3) const; #endif // BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 3 #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 4 - template + template void operator()(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_3) args_3, @@ -269,8 +275,8 @@ class OperationChain_CompletionCallbackWrapper { #endif // BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 9 #else - // The generated code below is a workaround for the absence of perfect - // forwarding in some compilers. +// The generated code below is a workaround for the absence of perfect +// forwarding in some compilers. template void operator()(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args) const; @@ -784,11 +790,12 @@ inline OperationChain_CompletionCallbackWrapper:: #endif #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 0 template -inline void -OperationChain_CompletionCallbackWrapper::operator()() const +inline void OperationChain_CompletionCallbackWrapper::operator()( + ) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))(); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + ); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -820,15 +827,16 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 2 template -template +template inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2) const { try { - bslmf::Util::moveIfSupported( - (*d_coCallback_p))(bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2)); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -841,17 +849,19 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 3 template -template +template inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_3) args_3) const { try { - bslmf::Util::moveIfSupported( - (*d_coCallback_p))(bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3)); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -864,7 +874,10 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 4 template -template +template inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, @@ -872,11 +885,11 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_4) args_4) const { try { - bslmf::Util::moveIfSupported( - (*d_coCallback_p))(bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4)); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -889,7 +902,11 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 5 template -template +template inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, @@ -898,12 +915,12 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_5) args_5) const { try { - bslmf::Util::moveIfSupported( - (*d_coCallback_p))(bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5)); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -931,13 +948,13 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_6) args_6) const { try { - bslmf::Util::moveIfSupported( - (*d_coCallback_p))(bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5), - bslmf::Util::forward(args_6)); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5), + bslmf::Util::forward(args_6)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -967,14 +984,14 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_7) args_7) const { try { - bslmf::Util::moveIfSupported( - (*d_coCallback_p))(bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5), - bslmf::Util::forward(args_6), - bslmf::Util::forward(args_7)); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5), + bslmf::Util::forward(args_6), + bslmf::Util::forward(args_7)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -1006,15 +1023,15 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_8) args_8) const { try { - bslmf::Util::moveIfSupported( - (*d_coCallback_p))(bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5), - bslmf::Util::forward(args_6), - bslmf::Util::forward(args_7), - bslmf::Util::forward(args_8)); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5), + bslmf::Util::forward(args_6), + bslmf::Util::forward(args_7), + bslmf::Util::forward(args_8)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -1048,16 +1065,16 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_9) args_9) const { try { - bslmf::Util::moveIfSupported( - (*d_coCallback_p))(bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5), - bslmf::Util::forward(args_6), - bslmf::Util::forward(args_7), - bslmf::Util::forward(args_8), - bslmf::Util::forward(args_9)); + bslmf::Util::moveIfSupported((*d_coCallback_p))( + bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5), + bslmf::Util::forward(args_6), + bslmf::Util::forward(args_7), + bslmf::Util::forward(args_8), + bslmf::Util::forward(args_9)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -1283,11 +1300,9 @@ inline void bmqu::swap(OperationChainLink& lhs, } // close enterprise namespace -#else // if ! defined(DEFINED_BMQU_OPERATIONCHAIN_H) -#error Not valid except when included from bmqu_operationchain.h -#endif // ! defined(COMPILING_BMQU_OPERATIONCHAIN_H) +#else // if ! defined(DEFINED_BMQU_OPERATIONCHAIN_H) +# error Not valid except when included from bmqu_operationchain.h +#endif // ! defined(COMPILING_BMQU_OPERATIONCHAIN_H) -#endif // ! defined(INCLUDED_BMQU_OPERATIONCHAIN_CPP03) +#endif // ! defined(INCLUDED_BMQU_OPERATIONCHAIN_CPP03) -// SCRIPT-SHA: 60926cad35f1091c31a7d8cc9d33acc38edd25e4891f3e1d41fe7c40fd6e02f5 -// SOURCE-SHA: 7610aa7a0ecb116c786702dfc71b197eda2f52aa0f3efa66433723466764a626 From 98623eec87426942737c033ab91d6ebe6e46626f Mon Sep 17 00:00:00 2001 From: Dmitrii Petukhov Date: Mon, 24 Feb 2025 12:22:59 +0200 Subject: [PATCH 3/3] clang format Signed-off-by: Dmitrii Petukhov --- .../bmq/bmqeval/bmqeval_simpleevaluator.cpp | 5 +- src/groups/bmq/bmqu/bmqu_operationchain.h | 12 +- .../bmq/bmqu/bmqu_operationchain_cpp03.h | 154 ++++++++---------- 3 files changed, 76 insertions(+), 95 deletions(-) diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp index 3dbf4e7405..61a31cb3bb 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.cpp @@ -368,8 +368,7 @@ bdld::Datum SimpleEvaluator::Not::evaluate(EvaluationContext& context) const // class SimpleEvaluator::Abs // --------------------------------- -bdld::Datum -SimpleEvaluator::Abs::evaluate(EvaluationContext& context) const +bdld::Datum SimpleEvaluator::Abs::evaluate(EvaluationContext& context) const { bdld::Datum expr = d_expression->evaluate(context); if (context.d_stop) { @@ -388,7 +387,7 @@ SimpleEvaluator::Abs::evaluate(EvaluationContext& context) const context.d_lastError = ErrorType::e_TYPE; return context.stop(); // RETURN } - + value = abs(value); return bdld::Datum::createInteger64(value, context.d_allocator); } diff --git a/src/groups/bmq/bmqu/bmqu_operationchain.h b/src/groups/bmq/bmqu/bmqu_operationchain.h index cec2c7c31d..2633ad1a79 100644 --- a/src/groups/bmq/bmqu/bmqu_operationchain.h +++ b/src/groups/bmq/bmqu/bmqu_operationchain.h @@ -194,9 +194,9 @@ // Include version that can be compiled with C++03 // Generated on Fri Feb 14 17:43:15 2025 // Command line: sim_cpp11_features.pl bmqu_operationchain.h -# define COMPILING_BMQU_OPERATIONCHAIN_H -# include -# undef COMPILING_BMQU_OPERATIONCHAIN_H +#define COMPILING_BMQU_OPERATIONCHAIN_H +#include +#undef COMPILING_BMQU_OPERATIONCHAIN_H #else namespace BloombergLP { @@ -301,7 +301,7 @@ class OperationChain_CompletionCallbackWrapper { public: // ACCESSORS -#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9 +#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9 /// Invoke the associated completion callback with the specified `args` /// arguments and notify the associated operation chain. Propagate any @@ -806,7 +806,7 @@ inline OperationChain_CompletionCallbackWrapper:: } // ACCESSORS -#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9 +#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=9 template template inline void OperationChain_CompletionCallbackWrapper::operator()( @@ -1021,6 +1021,6 @@ inline void bmqu::swap(OperationChainLink& lhs, } // close enterprise namespace -#endif // End C++11 code +#endif // End C++11 code #endif diff --git a/src/groups/bmq/bmqu/bmqu_operationchain_cpp03.h b/src/groups/bmq/bmqu/bmqu_operationchain_cpp03.h index fa009a09e6..7ba56d53cd 100644 --- a/src/groups/bmq/bmqu/bmqu_operationchain_cpp03.h +++ b/src/groups/bmq/bmqu/bmqu_operationchain_cpp03.h @@ -163,26 +163,20 @@ class OperationChain_CompletionCallbackWrapper { #endif // BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 1 #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 2 - template + template void operator()(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2) const; #endif // BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 2 #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 3 - template + template void operator()(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_3) args_3) const; #endif // BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 3 #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 4 - template + template void operator()(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_3) args_3, @@ -275,8 +269,8 @@ class OperationChain_CompletionCallbackWrapper { #endif // BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_A >= 9 #else -// The generated code below is a workaround for the absence of perfect -// forwarding in some compilers. + // The generated code below is a workaround for the absence of perfect + // forwarding in some compilers. template void operator()(BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args) const; @@ -790,12 +784,11 @@ inline OperationChain_CompletionCallbackWrapper:: #endif #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 0 template -inline void OperationChain_CompletionCallbackWrapper::operator()( - ) const +inline void +OperationChain_CompletionCallbackWrapper::operator()() const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - ); + bslmf::Util::moveIfSupported((*d_coCallback_p))(); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -827,16 +820,15 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 2 template -template +template inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2)); + bslmf::Util::moveIfSupported( + (*d_coCallback_p))(bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -849,19 +841,17 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 3 template -template +template inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_3) args_3) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3)); + bslmf::Util::moveIfSupported( + (*d_coCallback_p))(bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -874,10 +864,7 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 4 template -template +template inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, @@ -885,11 +872,11 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_4) args_4) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4)); + bslmf::Util::moveIfSupported( + (*d_coCallback_p))(bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -902,11 +889,7 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( #if BMQU_OPERATIONCHAIN_VARIADIC_LIMIT_B >= 5 template -template +template inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_1) args_1, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_2) args_2, @@ -915,12 +898,12 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_5) args_5) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5)); + bslmf::Util::moveIfSupported( + (*d_coCallback_p))(bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -948,13 +931,13 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_6) args_6) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5), - bslmf::Util::forward(args_6)); + bslmf::Util::moveIfSupported( + (*d_coCallback_p))(bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5), + bslmf::Util::forward(args_6)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -984,14 +967,14 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_7) args_7) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5), - bslmf::Util::forward(args_6), - bslmf::Util::forward(args_7)); + bslmf::Util::moveIfSupported( + (*d_coCallback_p))(bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5), + bslmf::Util::forward(args_6), + bslmf::Util::forward(args_7)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -1023,15 +1006,15 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_8) args_8) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5), - bslmf::Util::forward(args_6), - bslmf::Util::forward(args_7), - bslmf::Util::forward(args_8)); + bslmf::Util::moveIfSupported( + (*d_coCallback_p))(bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5), + bslmf::Util::forward(args_6), + bslmf::Util::forward(args_7), + bslmf::Util::forward(args_8)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -1065,16 +1048,16 @@ inline void OperationChain_CompletionCallbackWrapper::operator()( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_9) args_9) const { try { - bslmf::Util::moveIfSupported((*d_coCallback_p))( - bslmf::Util::forward(args_1), - bslmf::Util::forward(args_2), - bslmf::Util::forward(args_3), - bslmf::Util::forward(args_4), - bslmf::Util::forward(args_5), - bslmf::Util::forward(args_6), - bslmf::Util::forward(args_7), - bslmf::Util::forward(args_8), - bslmf::Util::forward(args_9)); + bslmf::Util::moveIfSupported( + (*d_coCallback_p))(bslmf::Util::forward(args_1), + bslmf::Util::forward(args_2), + bslmf::Util::forward(args_3), + bslmf::Util::forward(args_4), + bslmf::Util::forward(args_5), + bslmf::Util::forward(args_6), + bslmf::Util::forward(args_7), + bslmf::Util::forward(args_8), + bslmf::Util::forward(args_9)); } catch (...) { d_chain_p->onOperationCompleted(d_jobHandle); @@ -1300,9 +1283,8 @@ inline void bmqu::swap(OperationChainLink& lhs, } // close enterprise namespace -#else // if ! defined(DEFINED_BMQU_OPERATIONCHAIN_H) -# error Not valid except when included from bmqu_operationchain.h -#endif // ! defined(COMPILING_BMQU_OPERATIONCHAIN_H) - -#endif // ! defined(INCLUDED_BMQU_OPERATIONCHAIN_CPP03) +#else // if ! defined(DEFINED_BMQU_OPERATIONCHAIN_H) +#error Not valid except when included from bmqu_operationchain.h +#endif // ! defined(COMPILING_BMQU_OPERATIONCHAIN_H) +#endif // ! defined(INCLUDED_BMQU_OPERATIONCHAIN_CPP03)