diff options
author | Armelle Laine <armellel@google.com> | 2022-11-06 19:03:46 +0000 |
---|---|---|
committer | Armelle Laine <armellel@google.com> | 2022-12-09 22:51:57 +0000 |
commit | 2f5a7077b298202e8685b1993533dcb18648c2b9 (patch) | |
tree | 148cbfa91ed72a13a94e92b7b279c8f9618d64f5 /src/google/protobuf/any.cc | |
parent | 15f2a41e3ed59f5a1b6333b30a533e213da3eb26 (diff) | |
download | linux-android-games-sdk-game-text-input-release.tar.gz |
Check in prebuilt protoc compiler and protobuf python libHEADmastermainandroid-games-sdk-games-performance-tuner-releaseandroid-games-sdk-games-memory-advice-releaseandroid-games-sdk-games-frame-pacing-releaseandroid-games-sdk-games-controller-releaseandroid-games-sdk-game-text-input-releaseandroid-games-sdk-game-activity-release
Updated to latest protobuf version 21.9, proceeding as follow:
1. Download libprotobuf from
https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protobuf-all-21.9.zip
2. Goto protobuf-all-21.9/python
3. python setup.py build
4. Copy `python` folder from protobuf-all-21.9 to
the local path for `prebuilts/libprotobuf/linux`
5. Copy `src` folder from protobuf-all-21.9 to
the local path for `prebuilts/libprotobuf/linux`,
this is necessary for unit tests.
6. Copy `LICENSE`, `CHANGES.txt` from protobuf-all-21.9 to
the local path for `prebuilts/libprotobuf/linux`
6. Download the prebuilt protoc compiler from
https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-x86_64.zip
7. Copy `bin` folder, `include` folder, `readme.txt`
from protoc-21.9-linux-x86_64 into
the local path for `prebuilts/libprotobuf/linux`
8. Update `METADATA` file
Bug: None
Change-Id: I8bfee218492ca001e951cb4adcc8929d14259767
(cherry picked from commit fbc6810e0ea7322e5ed7c80662ddc4aad97fe60d)
Diffstat (limited to 'src/google/protobuf/any.cc')
-rw-r--r-- | src/google/protobuf/any.cc | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/google/protobuf/any.cc b/src/google/protobuf/any.cc new file mode 100644 index 0000000..346fa19 --- /dev/null +++ b/src/google/protobuf/any.cc @@ -0,0 +1,82 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <google/protobuf/any.h> + +#include <google/protobuf/arenastring.h> +#include <google/protobuf/descriptor.h> +#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/message.h> + +// Must be included last. +#include <google/protobuf/port_def.inc> + +namespace google { +namespace protobuf { +namespace internal { + +bool AnyMetadata::PackFrom(Arena* arena, const Message& message) { + return PackFrom(arena, message, kTypeGoogleApisComPrefix); +} + +bool AnyMetadata::PackFrom(Arena* arena, const Message& message, + StringPiece type_url_prefix) { + type_url_->Set( + GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix), arena); + return message.SerializeToString(value_->Mutable(arena)); +} + +bool AnyMetadata::UnpackTo(Message* message) const { + if (!InternalIs(message->GetDescriptor()->full_name())) { + return false; + } + return message->ParseFromString(value_->Get()); +} + +bool GetAnyFieldDescriptors(const Message& message, + const FieldDescriptor** type_url_field, + const FieldDescriptor** value_field) { + const Descriptor* descriptor = message.GetDescriptor(); + if (descriptor->full_name() != kAnyFullTypeName) { + return false; + } + *type_url_field = descriptor->FindFieldByNumber(1); + *value_field = descriptor->FindFieldByNumber(2); + return (*type_url_field != nullptr && + (*type_url_field)->type() == FieldDescriptor::TYPE_STRING && + *value_field != nullptr && + (*value_field)->type() == FieldDescriptor::TYPE_BYTES); +} + +} // namespace internal +} // namespace protobuf +} // namespace google + +#include <google/protobuf/port_undef.inc> |