Skip to content

Commit

Permalink
Add a default ctor for sapi::v::Proto
Browse files Browse the repository at this point in the history
If the default ctored proto message cannot be serialized that likely means it's not usable with SAPI at all (at least for proto3).\
This is so that one can easily construct a `sapi::v:Proto` to get result out of a sandboxee.

PiperOrigin-RevId: 630951119
Change-Id: Ie3d558ddaba77ab4aa045e4324b674a127a7424b
  • Loading branch information
happyCoder92 authored and Copybara-Service committed May 6, 2024
1 parent 9aa72d4 commit 69bc135
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sandboxed_api/var_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "absl/base/attributes.h"
#include "absl/base/macros.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
Expand All @@ -51,6 +52,8 @@ class Proto : public Var {
static_assert(std::is_base_of<google::protobuf::MessageLite, T>::value,
"Template argument must be a proto message");

Proto() : wrapped_var_(SerializeProto(T{}).value()) {}

Proto(PrivateToken, std::vector<uint8_t> data)
: wrapped_var_(std::move(data)) {}

Expand Down

0 comments on commit 69bc135

Please sign in to comment.