Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
build --cxxopt=-fsized-deallocation
common --enable_platform_specific_config

build --enable_bzlmod
build --copt=-Wno-deprecated-declarations
build --compilation_mode=fastbuild

build:linux --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
build:linux --cxxopt=-fsized-deallocation
build:linux --copt=-Wno-deprecated-declarations

# you will typically need to spell out the compiler for local dev
# BAZEL_VC=<install directory>
# BAZEL_VC_FULL_VERSION=14.44.3520
build:msvc --cxxopt="-std:c++20" --cxxopt="-utf-8" --host_cxxopt="-std:c++20"
build:msvc --define=protobuf_allow_msvc=true
build:msvc --test_tag_filters=-benchmark,-notap,-notestmsvc
build:msvc --build_tag_filters=-notestmsvc

test --test_output=errors

# Enable matchers in googletest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ bazel-cel-cpp
clang.bazelrc
user.bazelrc
local_tsan.bazelrc
MODULE.bazel.lock
7 changes: 6 additions & 1 deletion bazel/antlr.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/synchronization",
],
)
)

--- VERSION
+++ /dev/null
@@ -1,1 +1,0 @@
-4.13.2
1 change: 1 addition & 0 deletions bazel/cel_proto_transitive_descriptor_set.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ cel_proto_transitive_descriptor_set = rule(
},
implementation = _cel_proto_transitive_descriptor_set,
)

2 changes: 2 additions & 0 deletions common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ cc_test(
"@com_google_absl//absl/strings:string_view",
"@com_google_protobuf//:protobuf",
],
tags = ["notestmsvc"],
)

cc_library(
Expand Down Expand Up @@ -882,6 +883,7 @@ cc_test(
"@com_google_absl//absl/strings:string_view",
"@com_google_protobuf//:protobuf",
],
tags = ["notestmsvc"],
)

cc_library(
Expand Down
26 changes: 16 additions & 10 deletions common/value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1148,12 +1148,10 @@ struct WellKnownTypesValueVisitor {
Value operator()(absl::Time value) const { return TimestampValue(value); }
};

struct OwningWellKnownTypesValueVisitor : public WellKnownTypesValueVisitor {
struct OwningWellKnownTypesValueVisitor {
google::protobuf::Arena* absl_nullable arena;
std::string* absl_nonnull scratch;

using WellKnownTypesValueVisitor::operator();

Value operator()(well_known_types::BytesValue&& value) const {
return absl::visit(absl::Overload(
[&](absl::string_view string) -> BytesValue {
Expand Down Expand Up @@ -1242,15 +1240,18 @@ struct OwningWellKnownTypesValueVisitor : public WellKnownTypesValueVisitor {
}
return ParsedMessageValue(value.release(), arena);
}

template <typename T>
Value operator()(T t) const {
return WellKnownTypesValueVisitor{}.operator()(t);
}
};

struct BorrowingWellKnownTypesValueVisitor : public WellKnownTypesValueVisitor {
struct BorrowingWellKnownTypesValueVisitor {
const google::protobuf::Message* absl_nonnull message;
google::protobuf::Arena* absl_nonnull arena;
std::string* absl_nonnull scratch;

using WellKnownTypesValueVisitor::operator();

Value operator()(well_known_types::BytesValue&& value) const {
return absl::visit(
absl::Overload(
Expand Down Expand Up @@ -1332,6 +1333,11 @@ struct BorrowingWellKnownTypesValueVisitor : public WellKnownTypesValueVisitor {
}
return ParsedMessageValue(value.release(), arena);
}

template <typename T>
Value operator()(T t) const {
return WellKnownTypesValueVisitor{}.operator()(t);
}
};

} // namespace
Expand All @@ -1355,7 +1361,7 @@ Value Value::FromMessage(
}
return absl::visit(
absl::Overload(
OwningWellKnownTypesValueVisitor{.arena = arena, .scratch = &scratch},
OwningWellKnownTypesValueVisitor{/* .arena = */ arena, /* .scratch = */ &scratch},
[&](absl::monostate) -> Value {
auto* cloned = message.New(arena);
cloned->CopyFrom(message);
Expand Down Expand Up @@ -1383,7 +1389,7 @@ Value Value::FromMessage(
}
return absl::visit(
absl::Overload(
OwningWellKnownTypesValueVisitor{.arena = arena, .scratch = &scratch},
OwningWellKnownTypesValueVisitor{/* .arena = */ arena, /* .scratch = */ &scratch},
[&](absl::monostate) -> Value {
auto* cloned = message.New(arena);
cloned->GetReflection()->Swap(cloned, &message);
Expand Down Expand Up @@ -1414,7 +1420,7 @@ Value Value::WrapMessage(
return absl::visit(
absl::Overload(
BorrowingWellKnownTypesValueVisitor{
.message = message, .arena = arena, .scratch = &scratch},
/* .message = */ message, /* .arena = */ arena, /* .scratch = */ &scratch},
[&](absl::monostate) -> Value {
if (message->GetArena() != arena) {
auto* cloned = message->New(arena);
Expand Down Expand Up @@ -1448,7 +1454,7 @@ Value Value::WrapMessageUnsafe(
return absl::visit(
absl::Overload(
BorrowingWellKnownTypesValueVisitor{
.message = message, .arena = arena, .scratch = &scratch},
/* .message = */ message, /* .arena = */ arena, /* .scratch = */ &scratch},
[&](absl::monostate) -> Value {
if (message->GetArena() != arena) {
return UnsafeParsedMessageValue(message);
Expand Down
8 changes: 8 additions & 0 deletions common/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
#include "google/protobuf/map_field.h"
#include "google/protobuf/message.h"


#undef CEL_DISPATCHER_CONST_INIT
#ifdef _MSC_VER > 0
#define CEL_DISPATCHER_CONST_INIT static
#else
#define CEL_DISPATCHER_CONST_INIT ABSL_CONST_INIT
#endif // ifdef _MSC_VE

namespace cel {

// `Value` is a composition type which encompasses all values supported by the
Expand Down
4 changes: 3 additions & 1 deletion common/values/error_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI ErrorValue final

ErrorValue(google::protobuf::Arena* absl_nonnull arena,
const absl::Status* absl_nonnull status)
: arena_(arena), status_{.ptr = status} {}
: arena_(arena) {
status_.ptr = status;
}

void CopyConstruct(const ErrorValue& other) {
arena_ = other.arena_;
Expand Down
Loading