Commit 12fdeb9b authored by Jisi Liu's avatar Jisi Liu

Merge branch 'master' of github.com:google/protobuf

parents cf14183b b53417c7
......@@ -377,6 +377,8 @@ RELATIVE_TEST_PROTOS = [
"google/protobuf/unittest_preserve_unknown_enum.proto",
"google/protobuf/unittest_preserve_unknown_enum2.proto",
"google/protobuf/unittest_proto3_arena.proto",
"google/protobuf/unittest_proto3_arena_lite.proto",
"google/protobuf/unittest_proto3_lite.proto",
"google/protobuf/unittest_well_known_types.proto",
"google/protobuf/util/internal/testdata/anys.proto",
"google/protobuf/util/internal/testdata/books.proto",
......@@ -463,6 +465,8 @@ cc_test(
"src/google/protobuf/no_field_presence_test.cc",
"src/google/protobuf/preserve_unknown_enum_test.cc",
"src/google/protobuf/proto3_arena_unittest.cc",
"src/google/protobuf/proto3_arena_lite_unittest.cc",
"src/google/protobuf/proto3_lite_unittest.cc",
"src/google/protobuf/reflection_ops_unittest.cc",
"src/google/protobuf/repeated_field_reflection_unittest.cc",
"src/google/protobuf/repeated_field_unittest.cc",
......
......@@ -139,6 +139,8 @@ namespace Google.Protobuf.WellKnownTypes {
/// * If no schema is provided, `https` is assumed.
/// * The last segment of the URL's path must represent the fully
/// qualified name of the type (as in `path/google.protobuf.Duration`).
/// The name should be in a canonical form (e.g., leading "." is
/// not accepted).
/// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
/// value in binary format, or produce an error.
/// * Applications are allowed to cache lookup results based on the
......
......@@ -86,7 +86,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// operation applies to all fields (as if a FieldMask of all fields
/// had been specified).
///
/// Note that a field mask does not necessarily applies to the
/// Note that a field mask does not necessarily apply to the
/// top-level response message. In case of a REST get operation, the
/// field mask applies directly to the response, but in case of a REST
/// list operation, the mask instead applies to each individual message
......
This diff is collapsed.
# Third-Party Add-ons for Protocol Buffers
This page lists code related to Protocol Buffers which is developed and maintained by third parties. You may find this code useful, but note that **these projects are not affiliated with or endorsed by Google (unless explicitly marked)**; try them at your own risk. Also note that many projects here are in the early stages of development and not production-ready.
If you have a project that should be listed here, please [send us a pull request](https://github.com/google/protobuf/pulls) to update this page.
## Programming Languages
These are projects we know about implementing Protocol Buffers for other programming languages:
* Action Script: http://code.google.com/p/protobuf-actionscript3/
* Action Script: https://code.google.com/p/protoc-gen-as3/
* Action Script: https://github.com/matrix3d/JProtoc
* C: https://github.com/protobuf-c/protobuf-c
* C: http://koti.kapsi.fi/jpa/nanopb/
* C: https://github.com/cloudwu/pbc/
* C: https://github.com/haberman/upb/wiki
* C: https://github.com/squidfunk/protobluff
* C++: https://github.com/google/protobuf (Google-official implementation)
* C/C++: http://spbc.sf.net/
* C#: http://code.google.com/p/protobuf-csharp-port
* C#: http://code.google.com/p/protosharp/
* C#: https://silentorbit.com/protobuf/
* C#/.NET/WCF/VB: http://code.google.com/p/protobuf-net/
* Clojure: http://github.com/ninjudd/clojure-protobuf
* Common Lisp: http://www.prism.gatech.edu/~ndantam3/docs/s-protobuf/
* Common Lisp: http://github.com/brown/protobuf
* D: https://github.com/msoucy/dproto
* D: http://256.makerslocal.org/wiki/index.php/ProtocolBuffer
* D: https://github.com/opticron/ProtocolBuffer
* Dart: https://github.com/dart-lang/dart-protobuf (runtime) https://github.com/dart-lang/dart-protoc-plugin (code generator)
* Delphi: http://sourceforge.net/projects/protobuf-delphi/
* Delphi: http://fundementals.sourceforge.net/dl.html
* Elixir: https://github.com/jeremyong/exprotoc
* Erlang: http://github.com/ngerakines/erlang_protobuffs/tree/master
* Erlang: http://piqi.org/
* Erlang: https://code.google.com/p/protoc-gen-erl/
* Erlang: https://github.com/basho/erlang_protobuffs
* Go: https://github.com/golang/protobuf (Google-official implementation)
* Go: http://code.google.com/p/goprotobuf/
* Go: https://github.com/akunspy/gopbuf
* Haskell: http://hackage.haskell.org/package/hprotoc
* Haxe: https://github.com/Atry/protoc-gen-haxe
* Java: https://github.com/google/protobuf (Google-official implementation)
* Java/Android: https://github.com/square/wire
* Java ME: http://code.google.com/p/protobuf-javame/
* Java ME: http://swingme.sourceforge.net/encode.shtml
* Java ME: http://github.com/ponderingpanda/protobuf-j2me
* Java ME: http://code.google.com/p/protobuf-j2me/
* Javascript: http://code.google.com/p/protobuf-js/
* Javascript: http://github.com/sirikata/protojs
* Javascript: https://github.com/dcodeIO/ProtoBuf.js
* Javascript: http://code.google.com/p/protobuf-for-node/
* Javascript: http://code.google.com/p/protostuff/
* Julia: https://github.com/tanmaykm/ProtoBuf.jl
* Lua: http://code.google.com/p/protoc-gen-lua/
* Lua: http://github.com/indygreg/lua-protobuf
* Lua: https://github.com/Neopallium/lua-pb
* Matlab: http://code.google.com/p/protobuf-matlab/
* Mercury: http://code.google.com/p/protobuf-mercury/
* Objective C: http://code.google.com/p/protobuf-objc/
* Objective C: https://github.com/alexeyxo/protobuf-objc
* OCaml: http://piqi.org/
* Perl: http://groups.google.com/group/protobuf-perl
* Perl: http://search.cpan.org/perldoc?Google::ProtocolBuffers
* Perl/XS: http://code.google.com/p/protobuf-perlxs/
* PHP: http://code.google.com/p/pb4php/
* PHP: https://github.com/allegro/php-protobuf/
* PHP: https://github.com/chobie/php-protocolbuffers
* PHP: http://drslump.github.com/Protobuf-PHP
* Prolog: http://www.swi-prolog.org/pldoc/package/protobufs.html
* Python: https://github.com/google/protobuf (Google-official implementation)
* Python: http://eigenein.github.com/protobuf/
* R: http://cran.r-project.org/package=RProtoBuf
* Ruby: http://code.google.com/p/ruby-protobuf/
* Ruby: http://github.com/mozy/ruby-protocol-buffers
* Ruby: https://github.com/bmizerany/beefcake/tree/master/lib/beefcake
* Ruby: https://github.com/localshred/protobuf
* Rust: https://github.com/stepancheg/rust-protobuf/
* Scala: http://github.com/jeffplaisance/scala-protobuf
* Scala: http://code.google.com/p/protobuf-scala
* Scala: https://github.com/SandroGrzicic/ScalaBuff
* Scala: http://trueaccord.github.io/ScalaPB/
* Swift: https://github.com/alexeyxo/protobuf-swift
* Vala: https://launchpad.net/protobuf-vala
* Visual Basic: http://code.google.com/p/protobuf-net/
## RPC Implementations
GRPC (http://www.grpc.io/) is Google's RPC implementation for Protocol Buffers. There are other third-party RPC implementations as well. Some of these actually work with Protocol Buffers service definitions (defined using the `service` keyword in `.proto` files) while others just use Protocol Buffers message objects.
* https://github.com/grpc/grpc (C++, Node.js, Python, Ruby, Objective-C, PHP, C#, Google-official implementation)
* http://zeroc.com/ice.html (Multiple languages)
* http://code.google.com/p/protobuf-net/ (C#/.NET/WCF/VB)
* https://launchpad.net/txprotobuf/ (Python)
* https://github.com/modeswitch/protobuf-rpc (Python)
* http://code.google.com/p/protobuf-socket-rpc/ (Java, Python)
* http://code.google.com/p/proto-streamer/ (Java)
* http://code.google.com/p/server1/ (C++)
* http://deltavsoft.com/RcfUserGuide/Protobufs (C++)
* http://code.google.com/p/protobuf-mina-rpc/ (Python client, Java server)
* http://code.google.com/p/casocklib/ (C++)
* http://code.google.com/p/cxf-protobuf/ (Java)
* http://code.google.com/p/protobuf-remote/ (C++/C#)
* http://code.google.com/p/protobuf-rpc-pro/ (Java)
* https://code.google.com/p/protorpc/ (Go/C++)
* https://code.google.com/p/eneter-protobuf-serializer/ (Java/.NET)
* http://www.deltavsoft.com/RCFProto.html (C++/Java/Python/C#)
* https://github.com/robbinfan/claire-protorpc (C++)
* https://github.com/BaiduPS/sofa-pbrpc (C++)
* https://github.com/ebencheung/arab (C++)
* http://code.google.com/p/protobuf-csharp-rpc/ (C#)
* https://github.com/thesamet/rpcz (C++/Python, based on ZeroMQ)
* https://github.com/w359405949/libmaid (C++, Python)
* https://github.com/madwyn/libpbrpc (C++)
## Other Utilities
There are miscellaneous other things you may find useful as a Protocol Buffers developer.
* [NetBeans IDE plugin](http://code.google.com/p/protobuf-netbeans-plugin/)
* [Wireshark/Ethereal packet sniffer plugin](http://code.google.com/p/protobuf-wireshark/)
* [Alternate encodings (JSON, XML, HTML) for Java protobufs](http://code.google.com/p/protobuf-java-format/)
* [Another JSON encoder/decoder for Java](https://github.com/sijuv/protobuf-codec)
* [Editor for serialized protobufs](http://code.google.com/p/protobufeditor/)
* [Intellij IDEA plugin](http://github.com/nnmatveev/idea-plugin-protobuf)
* [TextMate syntax highlighting](http://github.com/michaeledgar/protobuf-tmbundle)
* [Oracle PL SQL plugin](http://code.google.com/p/protocol-buffer-plsql/)
* [Eclipse editor for protobuf (from Google)](http://code.google.com/p/protobuf-dt/)
* [C++ Builder compatible protobuf](https://github.com/saadware/protobuf-cppbuilder)
* Maven Protocol Compiler Plugin
* https://github.com/sergei-ivanov/maven-protoc-plugin/
* http://igor-petruk.github.com/protobuf-maven-plugin/
* http://code.google.com/p/maven-protoc-plugin/
* https://github.com/os72/protoc-jar-maven-plugin
* [Documentation generator plugin (Markdown/HTML/DocBook/...)](https://github.com/estan/protoc-gen-doc)
* [DocBook generator for .proto files](http://code.google.com/p/protoc-gen-docbook/)
* [Protobuf for nginx module](https://github.com/dbcode/protobuf-nginx/)
* [RSpec matchers and Cucumber step defs for testing Protocol Buffers](https://github.com/connamara/protobuf_spec)
* [Sbt plugin for Protocol Buffers](https://github.com/Atry/sbt-cppp)
* [Gradle Protobuf Plugin](https://github.com/aantono/gradle-plugin-protobuf)
* [Multi-platform executable JAR and Java API for protoc](https://github.com/os72/protoc-jar)
* [Python scripts to convert between Protocol Buffers and JSON](https://github.com/NextTuesday/py-pb-converters)
* [Visual Studio Language Service support for Protocol Buffers](http://visualstudiogallery.msdn.microsoft.com/4bc0f38c-b058-4e05-ae38-155e053c19c5)
* [C++ library for serialization/de-serialization between Protocol Buffers and JSON.](https://github.com/yinqiwen/pbjson)
* [ProtoBuf with Java EE7 Expression Language 3.0; pure Java ProtoBuf Parser and Builder.](https://github.com/protobufel/protobuf-el)
* [Notepad++ Syntax Highlighting for .proto files](https://github.com/chai2010/notepadplus-protobuf)
* [Linter for .proto files](https://github.com/ckaznocha/protoc-gen-lint)
......@@ -797,6 +797,8 @@ public abstract class GeneratedMessage extends AbstractMessage
extends GeneratedMessage
implements ExtendableMessageOrBuilder<MessageType> {
private static final long serialVersionUID = 1L;
private final FieldSet<FieldDescriptor> extensions;
protected ExtendableMessage() {
......
......@@ -2603,9 +2603,13 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
size_t fieldOffset = field->description_->offset;
switch (fieldDataType) {
case GPBDataTypeBool: {
BOOL *selfValPtr = (BOOL *)&selfStorage[fieldOffset];
BOOL *otherValPtr = (BOOL *)&otherStorage[fieldOffset];
if (*selfValPtr != *otherValPtr) {
// Bools are stored in has_bits to avoid needing explicit space in
// the storage structure.
// (the field number passed to the HasIvar helper doesn't really
// matter since the offset is never negative)
BOOL selfValue = GPBGetHasIvar(self, (int32_t)(fieldOffset), 0);
BOOL otherValue = GPBGetHasIvar(other, (int32_t)(fieldOffset), 0);
if (selfValue != otherValue) {
return NO;
}
break;
......@@ -2714,8 +2718,12 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
size_t fieldOffset = field->description_->offset;
switch (fieldDataType) {
case GPBDataTypeBool: {
BOOL *valPtr = (BOOL *)&storage[fieldOffset];
result = prime * result + *valPtr;
// Bools are stored in has_bits to avoid needing explicit space in
// the storage structure.
// (the field number passed to the HasIvar helper doesn't really
// matter since the offset is never negative)
BOOL value = GPBGetHasIvar(self, (int32_t)(fieldOffset), 0);
result = prime * result + value;
break;
}
case GPBDataTypeSFixed32:
......
......@@ -1947,4 +1947,76 @@
EnumTestMsg_MyEnum_NegTwo);
}
- (void)testOneBasedEnumHolder {
// Test case for https://github.com/google/protobuf/issues/1453
// Message with no explicit defaults, but a non zero default for an enum.
MessageWithOneBasedEnum *enumMsg = [MessageWithOneBasedEnum message];
XCTAssertEqual(enumMsg.enumField, MessageWithOneBasedEnum_OneBasedEnum_One);
}
- (void)testBoolOffsetUsage {
// Bools use storage within has_bits; this test ensures that this is honored
// in all places where things should crash or fail based on reading out of
// field storage instead.
BoolOnlyMessage *msg1 = [BoolOnlyMessage message];
BoolOnlyMessage *msg2 = [BoolOnlyMessage message];
msg1.boolField1 = YES;
msg2.boolField1 = YES;
msg1.boolField3 = YES;
msg2.boolField3 = YES;
msg1.boolField5 = YES;
msg2.boolField5 = YES;
msg1.boolField7 = YES;
msg2.boolField7 = YES;
msg1.boolField9 = YES;
msg2.boolField9 = YES;
msg1.boolField11 = YES;
msg2.boolField11 = YES;
msg1.boolField13 = YES;
msg2.boolField13 = YES;
msg1.boolField15 = YES;
msg2.boolField15 = YES;
msg1.boolField17 = YES;
msg2.boolField17 = YES;
msg1.boolField19 = YES;
msg2.boolField19 = YES;
msg1.boolField21 = YES;
msg2.boolField21 = YES;
msg1.boolField23 = YES;
msg2.boolField23 = YES;
msg1.boolField25 = YES;
msg2.boolField25 = YES;
msg1.boolField27 = YES;
msg2.boolField27 = YES;
msg1.boolField29 = YES;
msg2.boolField29 = YES;
msg1.boolField31 = YES;
msg2.boolField31 = YES;
msg1.boolField32 = YES;
msg2.boolField32 = YES;
XCTAssertTrue(msg1 != msg2); // Different pointers.
XCTAssertEqual([msg1 hash], [msg2 hash]);
XCTAssertEqualObjects(msg1, msg2);
BoolOnlyMessage *msg1Prime = [[msg1 copy] autorelease];
XCTAssertTrue(msg1Prime != msg1); // Different pointers.
XCTAssertEqual([msg1 hash], [msg1Prime hash]);
XCTAssertEqualObjects(msg1, msg1Prime);
// Field set in one, but not the other means they don't match (even if
// set to default value).
msg1Prime.boolField2 = NO;
XCTAssertNotEqualObjects(msg1Prime, msg1);
// And when set to different values.
msg1.boolField2 = YES;
XCTAssertNotEqualObjects(msg1Prime, msg1);
// And then they match again.
msg1.boolField2 = NO;
XCTAssertEqualObjects(msg1Prime, msg1);
XCTAssertEqual([msg1 hash], [msg1Prime hash]);
}
@end
......@@ -401,3 +401,49 @@ message EnumTestMsg {
repeated MyEnum mumble = 4;
}
// Test case for https://github.com/google/protobuf/issues/1453
// Message with no explicit defaults, but a non zero default for an enum.
message MessageWithOneBasedEnum {
enum OneBasedEnum {
ONE = 1;
TWO = 2;
}
optional OneBasedEnum enum_field = 1;
}
// Message with all bools for testing things related to bool storage.
message BoolOnlyMessage {
optional bool bool_field_1 = 1;
optional bool bool_field_2 = 2;
optional bool bool_field_3 = 3;
optional bool bool_field_4 = 4;
optional bool bool_field_5 = 5;
optional bool bool_field_6 = 6;
optional bool bool_field_7 = 7;
optional bool bool_field_8 = 8;
optional bool bool_field_9 = 9;
optional bool bool_field_10 = 10;
optional bool bool_field_11 = 11;
optional bool bool_field_12 = 12;
optional bool bool_field_13 = 13;
optional bool bool_field_14 = 14;
optional bool bool_field_15 = 15;
optional bool bool_field_16 = 16;
optional bool bool_field_17 = 17;
optional bool bool_field_18 = 18;
optional bool bool_field_19 = 19;
optional bool bool_field_20 = 20;
optional bool bool_field_21 = 21;
optional bool bool_field_22 = 22;
optional bool bool_field_23 = 23;
optional bool bool_field_24 = 24;
optional bool bool_field_25 = 25;
optional bool bool_field_26 = 26;
optional bool bool_field_27 = 27;
optional bool bool_field_28 = 28;
optional bool bool_field_29 = 29;
optional bool bool_field_30 = 30;
optional bool bool_field_31 = 31;
optional bool bool_field_32 = 32;
}
......@@ -656,7 +656,6 @@ static const upb_json_parsermethod *msgdef_jsonparsermethod(Descriptor* desc) {
#define STACK_ENV_STACKBYTES 4096
typedef struct {
upb_env env;
upb_seededalloc alloc;
const char* ruby_error_template;
char allocbuf[STACK_ENV_STACKBYTES];
} stackenv;
......@@ -681,16 +680,12 @@ static bool env_error_func(void* ud, const upb_status* status) {
static void stackenv_init(stackenv* se, const char* errmsg) {
se->ruby_error_template = errmsg;
upb_env_init(&se->env);
upb_seededalloc_init(&se->alloc, &se->allocbuf, STACK_ENV_STACKBYTES);
upb_env_setallocfunc(
&se->env, upb_seededalloc_getallocfunc(&se->alloc), &se->alloc);
upb_env_init2(&se->env, se->allocbuf, sizeof(se->allocbuf), NULL);
upb_env_seterrorfunc(&se->env, env_error_func, se);
}
static void stackenv_uninit(stackenv* se) {
upb_env_uninit(&se->env);
upb_seededalloc_uninit(&se->alloc);
}
/*
......
......@@ -151,32 +151,30 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) {
name_len--;
}
// Check for a oneof name first.
o = upb_msgdef_ntoo(self->descriptor->msgdef,
name, name_len);
// See if this name corresponds to either a oneof or field in this message.
if (!upb_msgdef_lookupname(self->descriptor->msgdef, name, name_len, &f,
&o)) {
return rb_call_super(argc, argv);
}
if (o != NULL) {
// This is a oneof -- return which field inside the oneof is set.
if (setter) {
rb_raise(rb_eRuntimeError, "Oneof accessors are read-only.");
}
return which_oneof_field(self, o);
}
// Otherwise, check for a field with that name.
f = upb_msgdef_ntof(self->descriptor->msgdef,
name, name_len);
if (f == NULL) {
return rb_call_super(argc, argv);
}
if (setter) {
if (argc < 2) {
rb_raise(rb_eArgError, "No value provided to setter.");
}
layout_set(self->descriptor->layout, Message_data(self), f, argv[1]);
return Qnil;
} else {
return layout_get(self->descriptor->layout, Message_data(self), f);
// This is a field -- get or set the field's value.
assert(f);
if (setter) {
if (argc < 2) {
rb_raise(rb_eArgError, "No value provided to setter.");
}
layout_set(self->descriptor->layout, Message_data(self), f, argv[1]);
return Qnil;
} else {
return layout_get(self->descriptor->layout, Message_data(self), f);
}
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -69,8 +69,8 @@ module Google
# relationship explicit instead of implicit
def_delegators :to_ary,
:&, :*, :-, :'<=>',
:assoc, :bsearch, :combination, :compact, :count, :cycle,
:drop, :drop_while, :eql?, :fetch, :find_index, :flatten,
:assoc, :bsearch, :bsearch_index, :combination, :compact, :count,
:cycle, :dig, :drop, :drop_while, :eql?, :fetch, :find_index, :flatten,
:include?, :index, :inspect, :join,
:pack, :permutation, :product, :pretty_print, :pretty_print_cycle,
:rassoc, :repeated_combination, :repeated_permutation, :reverse,
......
......@@ -507,6 +507,8 @@ protoc_inputs = \
google/protobuf/unittest_preserve_unknown_enum.proto \
google/protobuf/unittest.proto \
google/protobuf/unittest_proto3_arena.proto \
google/protobuf/unittest_proto3_arena_lite.proto \
google/protobuf/unittest_proto3_lite.proto \
google/protobuf/unittest_well_known_types.proto \
google/protobuf/util/internal/testdata/anys.proto \
google/protobuf/util/internal/testdata/books.proto \
......@@ -609,6 +611,10 @@ protoc_outputs = \
google/protobuf/unittest_preserve_unknown_enum.pb.h \
google/protobuf/unittest_proto3_arena.pb.cc \
google/protobuf/unittest_proto3_arena.pb.h \
google/protobuf/unittest_proto3_arena_lite.pb.cc \
google/protobuf/unittest_proto3_arena_lite.pb.h \
google/protobuf/unittest_proto3_lite.pb.cc \
google/protobuf/unittest_proto3_lite.pb.h \
google/protobuf/unittest_well_known_types.pb.cc \
google/protobuf/unittest_well_known_types.pb.h \
google/protobuf/util/internal/testdata/anys.pb.cc \
......@@ -710,6 +716,8 @@ protobuf_test_SOURCES = \
google/protobuf/no_field_presence_test.cc \
google/protobuf/preserve_unknown_enum_test.cc \
google/protobuf/proto3_arena_unittest.cc \
google/protobuf/proto3_arena_lite_unittest.cc \
google/protobuf/proto3_lite_unittest.cc \
google/protobuf/reflection_ops_unittest.cc \
google/protobuf/repeated_field_reflection_unittest.cc \
google/protobuf/repeated_field_unittest.cc \
......
......@@ -996,8 +996,16 @@ Method* Method::New(::google::protobuf::Arena* arena) const {
void Method::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Method)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(Method, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<Method*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......
......@@ -757,10 +757,11 @@ bool HasNonZeroDefaultValue(const FieldDescriptor* field) {
return false;
}
if (!field->has_default_value()) {
// No custom default set in the proto file.
return false;
}
// As much as checking field->has_default_value() seems useful, it isn't
// because of enums. proto2 syntax allows the first item in an enum (the
// default) to be non zero. So checking field->has_default_value() would
// result in missing this non zero default. See MessageWithOneBasedEnum in
// objectivec/Tests/unittest_objc.proto for a test Message to confirm this.
// Some proto file set the default to the zero value, so make sure the value
// isn't the zero case.
......
......@@ -2491,8 +2491,16 @@ DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::pr
void DescriptorProto_ExtensionRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(DescriptorProto_ExtensionRange, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<DescriptorProto_ExtensionRange*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......@@ -2782,8 +2790,16 @@ DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::prot
void DescriptorProto_ReservedRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(DescriptorProto_ReservedRange, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<DescriptorProto_ReservedRange*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......@@ -7161,8 +7177,16 @@ MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* are
void MethodDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(MethodDescriptorProto, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<MethodDescriptorProto*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......@@ -7965,8 +7989,16 @@ FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const {
void FileOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions)
_extensions_.Clear();
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(FileOptions, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<FileOptions*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......@@ -9360,8 +9392,16 @@ MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const {
void MessageOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions)
_extensions_.Clear();
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(MessageOptions, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<MessageOptions*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......@@ -9961,8 +10001,16 @@ FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const {
void FieldOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions)
_extensions_.Clear();
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(FieldOptions, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<FieldOptions*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......@@ -10645,8 +10693,16 @@ EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const {
void EnumOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions)
_extensions_.Clear();
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(EnumOptions, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<EnumOptions*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......@@ -12473,8 +12529,16 @@ UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena)
void UninterpretedOption::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(UninterpretedOption, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<UninterpretedOption*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......@@ -14338,8 +14402,16 @@ GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protob
void GeneratedCodeInfo_Annotation::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(GeneratedCodeInfo_Annotation, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<GeneratedCodeInfo_Annotation*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......
......@@ -180,8 +180,16 @@ Duration* Duration::New(::google::protobuf::Arena* arena) const {
void Duration::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Duration)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(Duration, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<Duration*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......
// 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 <string>
#include <memory>
#ifndef _SHARED_PTR_H
#include <google/protobuf/stubs/shared_ptr.h>
#endif
#include <vector>
#include <google/protobuf/test_util.h>
#include <google/protobuf/unittest.pb.h>
#include <google/protobuf/unittest_proto3_arena_lite.pb.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
namespace google {
using proto3_arena_lite_unittest::TestAllTypes;
namespace protobuf {
namespace {
// We selectively set/check a few representative fields rather than all fields
// as this test is only expected to cover the basics of arena support.
void SetAllFields(TestAllTypes* m) {
m->set_optional_int32(100);
m->set_optional_string("asdf");
m->set_optional_bytes("jkl;");
m->mutable_optional_nested_message()->set_bb(42);
m->mutable_optional_foreign_message()->set_c(43);
m->set_optional_nested_enum(
proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ);
m->set_optional_foreign_enum(
proto3_arena_lite_unittest::FOREIGN_BAZ);
m->mutable_optional_lazy_message()->set_bb(45);
m->add_repeated_int32(100);
m->add_repeated_string("asdf");
m->add_repeated_bytes("jkl;");
m->add_repeated_nested_message()->set_bb(46);
m->add_repeated_foreign_message()->set_c(47);
m->add_repeated_nested_enum(
proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ);
m->add_repeated_foreign_enum(
proto3_arena_lite_unittest::FOREIGN_BAZ);
m->add_repeated_lazy_message()->set_bb(49);
m->set_oneof_uint32(1);
m->mutable_oneof_nested_message()->set_bb(50);
m->set_oneof_string("test"); // only this one remains set
}
void ExpectAllFieldsSet(const TestAllTypes& m) {
EXPECT_EQ(100, m.optional_int32());
EXPECT_EQ("asdf", m.optional_string());
EXPECT_EQ("jkl;", m.optional_bytes());
EXPECT_EQ(true, m.has_optional_nested_message());
EXPECT_EQ(42, m.optional_nested_message().bb());
EXPECT_EQ(true, m.has_optional_foreign_message());
EXPECT_EQ(43, m.optional_foreign_message().c());
EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ,
m.optional_nested_enum());
EXPECT_EQ(proto3_arena_lite_unittest::FOREIGN_BAZ,
m.optional_foreign_enum());
EXPECT_EQ(true, m.has_optional_lazy_message());
EXPECT_EQ(45, m.optional_lazy_message().bb());
EXPECT_EQ(1, m.repeated_int32_size());
EXPECT_EQ(100, m.repeated_int32(0));
EXPECT_EQ(1, m.repeated_string_size());
EXPECT_EQ("asdf", m.repeated_string(0));
EXPECT_EQ(1, m.repeated_bytes_size());
EXPECT_EQ("jkl;", m.repeated_bytes(0));
EXPECT_EQ(1, m.repeated_nested_message_size());
EXPECT_EQ(46, m.repeated_nested_message(0).bb());
EXPECT_EQ(1, m.repeated_foreign_message_size());
EXPECT_EQ(47, m.repeated_foreign_message(0).c());
EXPECT_EQ(1, m.repeated_nested_enum_size());
EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ,
m.repeated_nested_enum(0));
EXPECT_EQ(1, m.repeated_foreign_enum_size());
EXPECT_EQ(proto3_arena_lite_unittest::FOREIGN_BAZ,
m.repeated_foreign_enum(0));
EXPECT_EQ(1, m.repeated_lazy_message_size());
EXPECT_EQ(49, m.repeated_lazy_message(0).bb());
EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes::kOneofString,
m.oneof_field_case());
EXPECT_EQ("test", m.oneof_string());
}
// In this file we only test some basic functionalities of arena support in
// proto3 and expect the arena support to be fully tested in proto2 unittests
// because proto3 shares most code with proto2.
TEST(Proto3ArenaLiteTest, Parsing) {
TestAllTypes original;
SetAllFields(&original);
Arena arena;
TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
arena_message->ParseFromString(original.SerializeAsString());
ExpectAllFieldsSet(*arena_message);
}
TEST(Proto3ArenaLiteTest, Swap) {
Arena arena1;
Arena arena2;
// Test Swap().
TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);
TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);
arena1_message->Swap(arena2_message);
EXPECT_EQ(&arena1, arena1_message->GetArena());
EXPECT_EQ(&arena2, arena2_message->GetArena());
}
TEST(Proto3ArenaLiteTest, SetAllocatedMessage) {
Arena arena;
TestAllTypes *arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
TestAllTypes::NestedMessage* nested = new TestAllTypes::NestedMessage;
nested->set_bb(118);
arena_message->set_allocated_optional_nested_message(nested);
EXPECT_EQ(118, arena_message->optional_nested_message().bb());
}
TEST(Proto3ArenaLiteTest, ReleaseMessage) {
Arena arena;
TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
arena_message->mutable_optional_nested_message()->set_bb(118);
google::protobuf::scoped_ptr<TestAllTypes::NestedMessage> nested(
arena_message->release_optional_nested_message());
EXPECT_EQ(118, nested->bb());
}
} // namespace
} // namespace protobuf
} // namespace google
// 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 <string>
#include <memory>
#ifndef _SHARED_PTR_H
#include <google/protobuf/stubs/shared_ptr.h>
#endif
#include <vector>
#include <google/protobuf/test_util.h>
#include <google/protobuf/unittest.pb.h>
#include <google/protobuf/unittest_proto3_lite.pb.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
namespace google {
using proto3_lite_unittest::TestAllTypes;
namespace protobuf {
namespace {
// We selectively set/check a few representative fields rather than all fields
// as this test is only expected to cover the basics of lite support.
void SetAllFields(TestAllTypes* m) {
m->set_optional_int32(100);
m->set_optional_string("asdf");
m->set_optional_bytes("jkl;");
m->mutable_optional_nested_message()->set_bb(42);
m->mutable_optional_foreign_message()->set_c(43);
m->set_optional_nested_enum(
proto3_lite_unittest::TestAllTypes_NestedEnum_BAZ);
m->set_optional_foreign_enum(
proto3_lite_unittest::FOREIGN_BAZ);
m->mutable_optional_lazy_message()->set_bb(45);
m->add_repeated_int32(100);
m->add_repeated_string("asdf");
m->add_repeated_bytes("jkl;");
m->add_repeated_nested_message()->set_bb(46);
m->add_repeated_foreign_message()->set_c(47);
m->add_repeated_nested_enum(
proto3_lite_unittest::TestAllTypes_NestedEnum_BAZ);
m->add_repeated_foreign_enum(
proto3_lite_unittest::FOREIGN_BAZ);
m->add_repeated_lazy_message()->set_bb(49);
m->set_oneof_uint32(1);
m->mutable_oneof_nested_message()->set_bb(50);
m->set_oneof_string("test"); // only this one remains set
}
void ExpectAllFieldsSet(const TestAllTypes& m) {
EXPECT_EQ(100, m.optional_int32());
EXPECT_EQ("asdf", m.optional_string());
EXPECT_EQ("jkl;", m.optional_bytes());
EXPECT_EQ(true, m.has_optional_nested_message());
EXPECT_EQ(42, m.optional_nested_message().bb());
EXPECT_EQ(true, m.has_optional_foreign_message());
EXPECT_EQ(43, m.optional_foreign_message().c());
EXPECT_EQ(proto3_lite_unittest::TestAllTypes_NestedEnum_BAZ,
m.optional_nested_enum());
EXPECT_EQ(proto3_lite_unittest::FOREIGN_BAZ,
m.optional_foreign_enum());
EXPECT_EQ(true, m.has_optional_lazy_message());
EXPECT_EQ(45, m.optional_lazy_message().bb());
EXPECT_EQ(1, m.repeated_int32_size());
EXPECT_EQ(100, m.repeated_int32(0));
EXPECT_EQ(1, m.repeated_string_size());
EXPECT_EQ("asdf", m.repeated_string(0));
EXPECT_EQ(1, m.repeated_bytes_size());
EXPECT_EQ("jkl;", m.repeated_bytes(0));
EXPECT_EQ(1, m.repeated_nested_message_size());
EXPECT_EQ(46, m.repeated_nested_message(0).bb());
EXPECT_EQ(1, m.repeated_foreign_message_size());
EXPECT_EQ(47, m.repeated_foreign_message(0).c());
EXPECT_EQ(1, m.repeated_nested_enum_size());
EXPECT_EQ(proto3_lite_unittest::TestAllTypes_NestedEnum_BAZ,
m.repeated_nested_enum(0));
EXPECT_EQ(1, m.repeated_foreign_enum_size());
EXPECT_EQ(proto3_lite_unittest::FOREIGN_BAZ,
m.repeated_foreign_enum(0));
EXPECT_EQ(1, m.repeated_lazy_message_size());
EXPECT_EQ(49, m.repeated_lazy_message(0).bb());
EXPECT_EQ(proto3_lite_unittest::TestAllTypes::kOneofString,
m.oneof_field_case());
EXPECT_EQ("test", m.oneof_string());
}
// In this file we only test some basic functionalities of in proto3 and expect
// the rest is fully tested in proto2 unittests because proto3 shares most code
// with proto2.
TEST(Proto3LiteTest, Parsing) {
TestAllTypes original;
SetAllFields(&original);
TestAllTypes msg;
msg.ParseFromString(original.SerializeAsString());
ExpectAllFieldsSet(msg);
}
TEST(Proto3LiteTest, Swap) {
// Test Swap().
TestAllTypes msg1;
TestAllTypes msg2;
msg1.set_optional_string("123");
msg2.set_optional_string("3456");
msg1.Swap(&msg2);
EXPECT_EQ("3456", msg1.optional_string());
EXPECT_EQ("123", msg2.optional_string());
EXPECT_EQ(msg1.ByteSize(), msg2.ByteSize() + 1);
}
} // namespace
} // namespace protobuf
} // namespace google
......@@ -194,8 +194,16 @@ Timestamp* Timestamp::New(::google::protobuf::Arena* arena) const {
void Timestamp::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Timestamp)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(Timestamp, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<Timestamp*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......
......@@ -1116,8 +1116,16 @@ Field* Field::New(::google::protobuf::Arena* arena) const {
void Field::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Field)
#if defined(__clang__)
#define ZR_HELPER_(f) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
__builtin_offsetof(Field, f) \
_Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast<char*>(\
&reinterpret_cast<Field*>(16)->f)
#endif
#define ZR_(first, last) do {\
::memset(&first, 0,\
......
// 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.
syntax = "proto3";
option cc_enable_arenas = true;
option optimize_for = LITE_RUNTIME;
import "google/protobuf/unittest_import.proto";
package proto3_arena_lite_unittest;
// This proto includes every type of field in both singular and repeated
// forms.
message TestAllTypes {
message NestedMessage {
// The field name "b" fails to compile in proto1 because it conflicts with
// a local variable named "b" in one of the generated methods. Doh.
// This file needs to compile in proto1 to test backwards-compatibility.
int32 bb = 1;
}
enum NestedEnum {
ZERO = 0;
FOO = 1;
BAR = 2;
BAZ = 3;
NEG = -1; // Intentionally negative.
}
// Singular
int32 optional_int32 = 1;
int64 optional_int64 = 2;
uint32 optional_uint32 = 3;
uint64 optional_uint64 = 4;
sint32 optional_sint32 = 5;
sint64 optional_sint64 = 6;
fixed32 optional_fixed32 = 7;
fixed64 optional_fixed64 = 8;
sfixed32 optional_sfixed32 = 9;
sfixed64 optional_sfixed64 = 10;
float optional_float = 11;
double optional_double = 12;
bool optional_bool = 13;
string optional_string = 14;
bytes optional_bytes = 15;
// Groups are not allowed in proto3.
// optional group OptionalGroup = 16 {
// optional int32 a = 17;
// }
NestedMessage optional_nested_message = 18;
ForeignMessage optional_foreign_message = 19;
protobuf_unittest_import.ImportMessage optional_import_message = 20;
NestedEnum optional_nested_enum = 21;
ForeignEnum optional_foreign_enum = 22;
// Omitted (compared to unittest.proto) because proto2 enums are not allowed
// inside proto2 messages.
//
// optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
string optional_string_piece = 24 [ctype=STRING_PIECE];
string optional_cord = 25 [ctype=CORD];
// Defined in unittest_import_public.proto
protobuf_unittest_import.PublicImportMessage
optional_public_import_message = 26;
NestedMessage optional_lazy_message = 27 [lazy=true];
// Repeated
repeated int32 repeated_int32 = 31;
repeated int64 repeated_int64 = 32;
repeated uint32 repeated_uint32 = 33;
repeated uint64 repeated_uint64 = 34;
repeated sint32 repeated_sint32 = 35;
repeated sint64 repeated_sint64 = 36;
repeated fixed32 repeated_fixed32 = 37;
repeated fixed64 repeated_fixed64 = 38;
repeated sfixed32 repeated_sfixed32 = 39;
repeated sfixed64 repeated_sfixed64 = 40;
repeated float repeated_float = 41;
repeated double repeated_double = 42;
repeated bool repeated_bool = 43;
repeated string repeated_string = 44;
repeated bytes repeated_bytes = 45;
// Groups are not allowed in proto3.
// repeated group RepeatedGroup = 46 {
// optional int32 a = 47;
// }
repeated NestedMessage repeated_nested_message = 48;
repeated ForeignMessage repeated_foreign_message = 49;
repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
repeated NestedEnum repeated_nested_enum = 51;
repeated ForeignEnum repeated_foreign_enum = 52;
// Omitted (compared to unittest.proto) because proto2 enums are not allowed
// inside proto2 messages.
//
// repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
repeated string repeated_cord = 55 [ctype=CORD];
repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
oneof oneof_field {
uint32 oneof_uint32 = 111;
NestedMessage oneof_nested_message = 112;
string oneof_string = 113;
bytes oneof_bytes = 114;
}
}
// Test messages for packed fields
message TestPackedTypes {
repeated int32 packed_int32 = 90 [packed = true];
repeated int64 packed_int64 = 91 [packed = true];
repeated uint32 packed_uint32 = 92 [packed = true];
repeated uint64 packed_uint64 = 93 [packed = true];
repeated sint32 packed_sint32 = 94 [packed = true];
repeated sint64 packed_sint64 = 95 [packed = true];
repeated fixed32 packed_fixed32 = 96 [packed = true];
repeated fixed64 packed_fixed64 = 97 [packed = true];
repeated sfixed32 packed_sfixed32 = 98 [packed = true];
repeated sfixed64 packed_sfixed64 = 99 [packed = true];
repeated float packed_float = 100 [packed = true];
repeated double packed_double = 101 [packed = true];
repeated bool packed_bool = 102 [packed = true];
repeated ForeignEnum packed_enum = 103 [packed = true];
}
// Explicitly set packed to false
message TestUnpackedTypes {
repeated int32 repeated_int32 = 1 [packed = false];
repeated int64 repeated_int64 = 2 [packed = false];
repeated uint32 repeated_uint32 = 3 [packed = false];
repeated uint64 repeated_uint64 = 4 [packed = false];
repeated sint32 repeated_sint32 = 5 [packed = false];
repeated sint64 repeated_sint64 = 6 [packed = false];
repeated fixed32 repeated_fixed32 = 7 [packed = false];
repeated fixed64 repeated_fixed64 = 8 [packed = false];
repeated sfixed32 repeated_sfixed32 = 9 [packed = false];
repeated sfixed64 repeated_sfixed64 = 10 [packed = false];
repeated float repeated_float = 11 [packed = false];
repeated double repeated_double = 12 [packed = false];
repeated bool repeated_bool = 13 [packed = false];
repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];
}
// This proto includes a recusively nested message.
message NestedTestAllTypes {
NestedTestAllTypes child = 1;
TestAllTypes payload = 2;
}
// Define these after TestAllTypes to make sure the compiler can handle
// that.
message ForeignMessage {
int32 c = 1;
}
enum ForeignEnum {
FOREIGN_ZERO = 0;
FOREIGN_FOO = 4;
FOREIGN_BAR = 5;
FOREIGN_BAZ = 6;
}
// TestEmptyMessage is used to test behavior of unknown fields.
message TestEmptyMessage {
}
// 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.
syntax = "proto3";
option optimize_for = LITE_RUNTIME;
import "google/protobuf/unittest_import.proto";
package proto3_lite_unittest;
// This proto includes every type of field in both singular and repeated
// forms.
message TestAllTypes {
message NestedMessage {
// The field name "b" fails to compile in proto1 because it conflicts with
// a local variable named "b" in one of the generated methods. Doh.
// This file needs to compile in proto1 to test backwards-compatibility.
int32 bb = 1;
}
enum NestedEnum {
ZERO = 0;
FOO = 1;
BAR = 2;
BAZ = 3;
NEG = -1; // Intentionally negative.
}
// Singular
int32 optional_int32 = 1;
int64 optional_int64 = 2;
uint32 optional_uint32 = 3;
uint64 optional_uint64 = 4;
sint32 optional_sint32 = 5;
sint64 optional_sint64 = 6;
fixed32 optional_fixed32 = 7;
fixed64 optional_fixed64 = 8;
sfixed32 optional_sfixed32 = 9;
sfixed64 optional_sfixed64 = 10;
float optional_float = 11;
double optional_double = 12;
bool optional_bool = 13;
string optional_string = 14;
bytes optional_bytes = 15;
// Groups are not allowed in proto3.
// optional group OptionalGroup = 16 {
// optional int32 a = 17;
// }
NestedMessage optional_nested_message = 18;
ForeignMessage optional_foreign_message = 19;
protobuf_unittest_import.ImportMessage optional_import_message = 20;
NestedEnum optional_nested_enum = 21;
ForeignEnum optional_foreign_enum = 22;
// Omitted (compared to unittest.proto) because proto2 enums are not allowed
// inside proto2 messages.
//
// optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
string optional_string_piece = 24 [ctype=STRING_PIECE];
string optional_cord = 25 [ctype=CORD];
// Defined in unittest_import_public.proto
protobuf_unittest_import.PublicImportMessage
optional_public_import_message = 26;
NestedMessage optional_lazy_message = 27 [lazy=true];
// Repeated
repeated int32 repeated_int32 = 31;
repeated int64 repeated_int64 = 32;
repeated uint32 repeated_uint32 = 33;
repeated uint64 repeated_uint64 = 34;
repeated sint32 repeated_sint32 = 35;
repeated sint64 repeated_sint64 = 36;
repeated fixed32 repeated_fixed32 = 37;
repeated fixed64 repeated_fixed64 = 38;
repeated sfixed32 repeated_sfixed32 = 39;
repeated sfixed64 repeated_sfixed64 = 40;
repeated float repeated_float = 41;
repeated double repeated_double = 42;
repeated bool repeated_bool = 43;
repeated string repeated_string = 44;
repeated bytes repeated_bytes = 45;
// Groups are not allowed in proto3.
// repeated group RepeatedGroup = 46 {
// optional int32 a = 47;
// }
repeated NestedMessage repeated_nested_message = 48;
repeated ForeignMessage repeated_foreign_message = 49;
repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
repeated NestedEnum repeated_nested_enum = 51;
repeated ForeignEnum repeated_foreign_enum = 52;
// Omitted (compared to unittest.proto) because proto2 enums are not allowed
// inside proto2 messages.
//
// repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
repeated string repeated_cord = 55 [ctype=CORD];
repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
oneof oneof_field {
uint32 oneof_uint32 = 111;
NestedMessage oneof_nested_message = 112;
string oneof_string = 113;
bytes oneof_bytes = 114;
}
}
// Test messages for packed fields
message TestPackedTypes {
repeated int32 packed_int32 = 90 [packed = true];
repeated int64 packed_int64 = 91 [packed = true];
repeated uint32 packed_uint32 = 92 [packed = true];
repeated uint64 packed_uint64 = 93 [packed = true];
repeated sint32 packed_sint32 = 94 [packed = true];
repeated sint64 packed_sint64 = 95 [packed = true];
repeated fixed32 packed_fixed32 = 96 [packed = true];
repeated fixed64 packed_fixed64 = 97 [packed = true];
repeated sfixed32 packed_sfixed32 = 98 [packed = true];
repeated sfixed64 packed_sfixed64 = 99 [packed = true];
repeated float packed_float = 100 [packed = true];
repeated double packed_double = 101 [packed = true];
repeated bool packed_bool = 102 [packed = true];
repeated ForeignEnum packed_enum = 103 [packed = true];
}
// Explicitly set packed to false
message TestUnpackedTypes {
repeated int32 repeated_int32 = 1 [packed = false];
repeated int64 repeated_int64 = 2 [packed = false];
repeated uint32 repeated_uint32 = 3 [packed = false];
repeated uint64 repeated_uint64 = 4 [packed = false];
repeated sint32 repeated_sint32 = 5 [packed = false];
repeated sint64 repeated_sint64 = 6 [packed = false];
repeated fixed32 repeated_fixed32 = 7 [packed = false];
repeated fixed64 repeated_fixed64 = 8 [packed = false];
repeated sfixed32 repeated_sfixed32 = 9 [packed = false];
repeated sfixed64 repeated_sfixed64 = 10 [packed = false];
repeated float repeated_float = 11 [packed = false];
repeated double repeated_double = 12 [packed = false];
repeated bool repeated_bool = 13 [packed = false];
repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];
}
// This proto includes a recusively nested message.
message NestedTestAllTypes {
NestedTestAllTypes child = 1;
TestAllTypes payload = 2;
}
// Define these after TestAllTypes to make sure the compiler can handle
// that.
message ForeignMessage {
int32 c = 1;
}
enum ForeignEnum {
FOREIGN_ZERO = 0;
FOREIGN_FOO = 4;
FOREIGN_BAR = 5;
FOREIGN_BAZ = 6;
}
// TestEmptyMessage is used to test behavior of unknown fields.
message TestEmptyMessage {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment