Skip to content

Commit e540ae2

Browse files
TristonianJoneskyessenov
authored andcommitted
Code style updates to CEL C++
1. Update `namespace` declarations to be inline 2. Swap from `int64`, `uint64` to `int64_t`, `uint64_t` 3. Split `Activation` from `BaseActivation` 4. Cleanup `include` and related `BUILD` deps PiperOrigin-RevId: 401009612
1 parent 9773e0b commit e540ae2

86 files changed

Lines changed: 425 additions & 769 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ cc_library(
5454
"//util/task:status",
5555
"@com_google_absl//absl/status",
5656
"@com_google_absl//absl/status:statusor",
57-
"@com_google_absl//absl/strings",
5857
"@com_google_absl//absl/time",
5958
],
6059
)

common/overflow.cc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "absl/status/status.h"
77
#include "absl/status/statusor.h"
8-
#include "absl/strings/str_cat.h"
98
#include "absl/time/time.h"
109
#include "util/task/status_macros.h"
1110

@@ -43,20 +42,14 @@ const int64_t kMinUnixTime =
4342
const int64_t kMaxUnixTime =
4443
(MaxTime() - absl::UnixEpoch()) / kOneSecondDuration;
4544

46-
template <typename... MP>
47-
Status CheckRange(bool valid_expression, absl::string_view error_message,
48-
MP... message_parts) {
45+
Status CheckRange(bool valid_expression, absl::string_view error_message) {
4946
return valid_expression ? absl::OkStatus()
50-
: absl::OutOfRangeError(
51-
absl::StrCat(error_message, message_parts...));
47+
: absl::OutOfRangeError(error_message);
5248
}
5349

54-
template <typename... MP>
55-
Status CheckArgument(bool valid_expression, absl::string_view error_message,
56-
MP... message_parts) {
50+
Status CheckArgument(bool valid_expression, absl::string_view error_message) {
5751
return valid_expression ? absl::OkStatus()
58-
: absl::InvalidArgumentError(
59-
absl::StrCat(error_message, message_parts...));
52+
: absl::InvalidArgumentError(error_message);
6053
}
6154

6255
// Determine whether the duration is finite.

conformance/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ cc_binary(
3232
testonly = 1,
3333
srcs = ["server.cc"],
3434
deps = [
35+
"//eval/public:activation",
3536
"//eval/public:builtin_func_registrar",
3637
"//eval/public:cel_expr_builder_factory",
3738
"//eval/public:transform_utility",

conformance/server.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "absl/flags/flag.h"
1313
#include "absl/flags/parse.h"
1414
#include "absl/strings/str_split.h"
15+
#include "eval/public/activation.h"
1516
#include "eval/public/builtin_func_registrar.h"
1617
#include "eval/public/cel_expr_builder_factory.h"
1718
#include "eval/public/containers/container_backed_list_impl.h"
@@ -29,10 +30,7 @@ using ::google::protobuf::util::MessageToJsonString;
2930

3031
ABSL_FLAG(bool, opt, false, "Enable optimizations (constant folding)");
3132

32-
namespace google {
33-
namespace api {
34-
namespace expr {
35-
namespace runtime {
33+
namespace google::api::expr::runtime {
3634

3735
class ConformanceServiceImpl {
3836
public:
@@ -218,10 +216,7 @@ int RunServer(bool optimize) {
218216
return 0;
219217
}
220218

221-
} // namespace runtime
222-
} // namespace expr
223-
} // namespace api
224-
} // namespace google
219+
} // namespace google::api::expr::runtime
225220

226221
int main(int argc, char** argv) {
227222
absl::ParseCommandLine(argc, argv);

eval/compiler/BUILD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ cc_library(
3838
"//eval/public:cel_expression",
3939
"//eval/public:cel_function_registry",
4040
"//eval/public:source_position",
41-
"//util/task:status",
4241
"@com_google_absl//absl/container:node_hash_map",
4342
"@com_google_absl//absl/status",
4443
"@com_google_absl//absl/status:statusor",
@@ -55,6 +54,7 @@ cc_test(
5554
],
5655
deps = [
5756
":flat_expr_builder",
57+
"//eval/public:activation",
5858
"//eval/public:builtin_func_registrar",
5959
"//eval/public:cel_attribute",
6060
"//eval/public:cel_builtins",
@@ -85,6 +85,7 @@ cc_test(
8585
],
8686
deps = [
8787
":flat_expr_builder",
88+
"//eval/public:activation",
8889
"//eval/public:builtin_func_registrar",
8990
"//eval/public:cel_attribute",
9091
"//eval/public:cel_builtins",
@@ -136,7 +137,6 @@ cc_test(
136137
"//eval/testutil:test_message_cc_proto",
137138
"//internal:testing",
138139
"//util/task:status",
139-
"@com_google_absl//absl/strings",
140140
"@com_google_googleapis//google/api/expr/v1alpha1:syntax_cc_proto",
141141
"@com_google_protobuf//:protobuf",
142142
],
@@ -176,6 +176,7 @@ cc_library(
176176
"//eval/public:cel_function_registry",
177177
"//eval/public:cel_type_registry",
178178
"//eval/public:cel_value",
179+
"@com_google_absl//absl/container:flat_hash_map",
179180
"@com_google_absl//absl/strings",
180181
"@com_google_absl//absl/types:optional",
181182
"@com_google_protobuf//:protobuf",

eval/compiler/constant_folding.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
#include "eval/public/cel_function_registry.h"
77
#include "eval/public/containers/container_backed_list_impl.h"
88

9-
namespace google {
10-
namespace api {
11-
namespace expr {
12-
namespace runtime {
9+
namespace google::api::expr::runtime {
1310

1411
namespace {
1512

16-
using google::api::expr::v1alpha1::Expr;
13+
using ::google::api::expr::v1alpha1::Expr;
1714

1815
class ConstantFoldingTransform {
1916
public:
@@ -224,7 +221,4 @@ void FoldConstants(const Expr& expr, const CelFunctionRegistry& registry,
224221
constant_folder.Transform(expr, out);
225222
}
226223

227-
} // namespace runtime
228-
} // namespace expr
229-
} // namespace api
230-
} // namespace google
224+
} // namespace google::api::expr::runtime

eval/compiler/constant_folding.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
#include "eval/public/cel_function_registry.h"
88
#include "eval/public/cel_value.h"
99

10-
namespace google {
11-
namespace api {
12-
namespace expr {
13-
namespace runtime {
10+
namespace google::api::expr::runtime {
1411

1512
// A transformation over input expression that produces a new expression with
1613
// constant sub-expressions replaced by generated idents in the constant_idents
@@ -20,9 +17,6 @@ void FoldConstants(const google::api::expr::v1alpha1::Expr& expr,
2017
absl::flat_hash_map<std::string, CelValue>& constant_idents,
2118
google::api::expr::v1alpha1::Expr* out);
2219

23-
} // namespace runtime
24-
} // namespace expr
25-
} // namespace api
26-
} // namespace google
20+
} // namespace google::api::expr::runtime
2721

2822
#endif // THIRD_PARTY_CEL_CPP_EVAL_COMPILER_CONSTANT_FOLDING_H_

eval/compiler/constant_folding_test.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@
1010
#include "eval/testutil/test_message.pb.h"
1111
#include "util/task/status_macros.h"
1212

13-
namespace google {
14-
namespace api {
15-
namespace expr {
16-
namespace runtime {
13+
namespace google::api::expr::runtime {
1714

1815
namespace {
1916

20-
using google::api::expr::v1alpha1::Expr;
17+
using ::google::api::expr::v1alpha1::Expr;
2118

2219
// Validate select is preserved as-is
2320
TEST(ConstantFoldingTest, Select) {
@@ -446,7 +443,4 @@ TEST(ConstantFoldingTest, MapComprehension) {
446443

447444
} // namespace
448445

449-
} // namespace runtime
450-
} // namespace expr
451-
} // namespace api
452-
} // namespace google
446+
} // namespace google::api::expr::runtime

eval/compiler/flat_expr_builder.cc

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "eval/compiler/flat_expr_builder.h"
22

3+
#include <cstdint>
34
#include <memory>
45

56
#include "google/api/expr/v1alpha1/checked.pb.h"
@@ -34,24 +35,21 @@
3435
#include "eval/public/cel_function_registry.h"
3536
#include "eval/public/source_position.h"
3637

37-
namespace google {
38-
namespace api {
39-
namespace expr {
40-
namespace runtime {
38+
namespace google::api::expr::runtime {
4139

4240
namespace {
4341

44-
using google::api::expr::v1alpha1::CheckedExpr;
45-
using google::api::expr::v1alpha1::Constant;
46-
using google::api::expr::v1alpha1::Expr;
47-
using google::api::expr::v1alpha1::Reference;
48-
using google::api::expr::v1alpha1::SourceInfo;
49-
using Ident = google::api::expr::v1alpha1::Expr::Ident;
50-
using Select = google::api::expr::v1alpha1::Expr::Select;
51-
using Call = google::api::expr::v1alpha1::Expr::Call;
52-
using CreateList = google::api::expr::v1alpha1::Expr::CreateList;
53-
using CreateStruct = google::api::expr::v1alpha1::Expr::CreateStruct;
54-
using Comprehension = google::api::expr::v1alpha1::Expr::Comprehension;
42+
using ::google::api::expr::v1alpha1::CheckedExpr;
43+
using ::google::api::expr::v1alpha1::Constant;
44+
using ::google::api::expr::v1alpha1::Expr;
45+
using ::google::api::expr::v1alpha1::Reference;
46+
using ::google::api::expr::v1alpha1::SourceInfo;
47+
using Ident = ::google::api::expr::v1alpha1::Expr::Ident;
48+
using Select = ::google::api::expr::v1alpha1::Expr::Select;
49+
using Call = ::google::api::expr::v1alpha1::Expr::Call;
50+
using CreateList = ::google::api::expr::v1alpha1::Expr::CreateList;
51+
using CreateStruct = ::google::api::expr::v1alpha1::Expr::CreateStruct;
52+
using Comprehension = ::google::api::expr::v1alpha1::Expr::Comprehension;
5553

5654
// Forward declare to resolve circular dependency for short_circuiting visitors.
5755
class FlatExprVisitor;
@@ -885,7 +883,4 @@ FlatExprBuilder::CreateExpression(const CheckedExpr* checked_expr) const {
885883
/*warnings=*/nullptr);
886884
}
887885

888-
} // namespace runtime
889-
} // namespace expr
890-
} // namespace api
891-
} // namespace google
886+
} // namespace google::api::expr::runtime

eval/compiler/flat_expr_builder.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
#include "absl/status/statusor.h"
77
#include "eval/public/cel_expression.h"
88

9-
namespace google {
10-
namespace api {
11-
namespace expr {
12-
namespace runtime {
9+
namespace google::api::expr::runtime {
1310

1411
// CelExpressionBuilder implementation.
1512
// Builds instances of CelExpressionFlatImpl.
@@ -108,9 +105,6 @@ class FlatExprBuilder : public CelExpressionBuilder {
108105
bool enable_qualified_type_identifiers_;
109106
};
110107

111-
} // namespace runtime
112-
} // namespace expr
113-
} // namespace api
114-
} // namespace google
108+
} // namespace google::api::expr::runtime
115109

116110
#endif // THIRD_PARTY_CEL_CPP_EVAL_COMPILER_FLAT_EXPR_BUILDER_H_

0 commit comments

Comments
 (0)