Compare commits
57 commits
Author | SHA1 | Date | |
---|---|---|---|
|
b50c9ec122 | ||
|
311e7a73eb | ||
|
7d758c00bc | ||
|
4f44a0f4bb | ||
|
74aaca63ba | ||
|
3491ebd05e | ||
|
08e4ef3c07 | ||
|
a7e05be8ec | ||
|
cc99e1293c | ||
|
4020fe427c | ||
|
fa925b9893 | ||
|
32886f1f85 | ||
|
d47fb8d69e | ||
|
82c7017891 | ||
|
f276479860 | ||
|
750cda35e6 | ||
|
124a2f6dbc | ||
|
2edf2bdebf | ||
|
5adf493bf6 | ||
|
c7f4c7bc41 | ||
|
e3583877ac | ||
|
4aa2e9312e | ||
|
593e917c17 | ||
|
2c8346a259 | ||
|
d1f0939a42 | ||
|
d9668797a2 | ||
|
be83f46b67 | ||
|
b22c6b090f | ||
|
6eeb5c7d0f | ||
|
3e51b3d4b6 | ||
|
5750146bd6 | ||
|
4447637bf7 | ||
|
790fc9387c | ||
|
531ebd9b94 | ||
|
60d4f8af48 | ||
|
e259b515a5 | ||
|
83fb8c7d29 | ||
|
64cbfab937 | ||
|
77e434de36 | ||
|
46dee43e25 | ||
|
a24ddc570f | ||
|
d1fde361a7 | ||
|
c871ce6e7b | ||
|
911e84e706 | ||
|
da9fea1d20 | ||
|
f5cc1a54c5 | ||
|
e230283f75 | ||
|
117f771641 | ||
|
2f38ce1f98 | ||
|
2d8a54477f | ||
|
f424c715e1 | ||
|
c7cbf5fc37 | ||
|
e02ff1a194 | ||
|
cf502405fc | ||
|
a9cdd803d6 | ||
|
9cb253f46e | ||
|
199d82fde1 |
183 changed files with 9285 additions and 4998 deletions
18
BUILD
18
BUILD
|
@ -227,6 +227,24 @@ cc_proto_library(
|
|||
# Protocol Buffers Compiler
|
||||
################################################################################
|
||||
|
||||
cc_binary(
|
||||
name = "js_embed",
|
||||
srcs = ["src/google/protobuf/compiler/js/embed.cc"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "generate_js_well_known_types_embed",
|
||||
srcs = [
|
||||
"src/google/protobuf/compiler/js/well_known_types/any.js",
|
||||
"src/google/protobuf/compiler/js/well_known_types/struct.js",
|
||||
"src/google/protobuf/compiler/js/well_known_types/timestamp.js",
|
||||
],
|
||||
outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"],
|
||||
cmd = "$(location :js_embed) $(SRCS) > $@",
|
||||
tools = [":js_embed"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "protoc_lib",
|
||||
srcs = [
|
||||
|
|
82
CHANGES.txt
82
CHANGES.txt
|
@ -1,3 +1,75 @@
|
|||
2017-01-23 version 3.2.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite)
|
||||
General
|
||||
* Added protoc version number to protoc plugin protocol. It can be used by
|
||||
protoc plugin to detect which version of protoc is used with the plugin and
|
||||
mitigate known problems in certain version of protoc.
|
||||
|
||||
C++
|
||||
* The default parsing byte size limit has been raised from 64MB to 2GB.
|
||||
* Added rvalue setters for non-arena string fields.
|
||||
* Enabled debug logging for Android.
|
||||
* Fixed a double-free problem when using Reflection::SetAllocatedMessage()
|
||||
with extension fields.
|
||||
* Fixed several deterministic serialization bugs:
|
||||
* MessageLite::SerializeAsString() now respects the global deterministic
|
||||
serialization flag.
|
||||
* Extension fields are serialized deterministically as well. Fixed protocol
|
||||
compiler to correctly report importing-self as an error.
|
||||
* Fixed FileDescriptor::DebugString() to print custom options correctly.
|
||||
* Various performance/codesize optimizations and cleanups.
|
||||
|
||||
Java
|
||||
* The default parsing byte size limit has been raised from 64MB to 2GB.
|
||||
* Added recursion limit when parsing JSON.
|
||||
* Fixed a bug that enumType.getDescriptor().getOptions() doesn't have custom
|
||||
options.
|
||||
* Fixed generated code to support field numbers up to 2^29-1.
|
||||
|
||||
Python
|
||||
* You can now assign NumPy scalars/arrays (np.int32, np.int64) to protobuf
|
||||
fields, and assigning other numeric types has been optimized for
|
||||
performance.
|
||||
* Pure-Python: message types are now garbage-collectable.
|
||||
* Python/C++: a lot of internal cleanup/refactoring.
|
||||
|
||||
PHP (Alpha)
|
||||
* For 64-bit integers type (int64/uint64/sfixed64/fixed64/sint64), use PHP
|
||||
integer on 64-bit environment and PHP string on 32-bit environment.
|
||||
* PHP generated code also conforms to PSR-4 now.
|
||||
* Fixed ZTS build for c extension.
|
||||
* Fixed c extension build on Mac.
|
||||
* Fixed c extension build on 32-bit linux.
|
||||
* Fixed the bug that message without namespace is not found in the descriptor
|
||||
pool. (#2240)
|
||||
* Fixed the bug that repeated field is not iterable in c extension.
|
||||
* Message names Empty will be converted to GPBEmpty in generated code.
|
||||
* Added phpdoc in generated files.
|
||||
* The released API is almost stable. Unless there is large problem, we won't
|
||||
change it. See
|
||||
https://developers.google.com/protocol-buffers/docs/reference/php-generated
|
||||
for more details.
|
||||
|
||||
Objective-C
|
||||
* Added support for push/pop of the stream limit on CodedInputStream for
|
||||
anyone doing manual parsing.
|
||||
|
||||
C#
|
||||
* No changes.
|
||||
|
||||
Ruby
|
||||
* Message objects now support #respond_to? for field getters/setters.
|
||||
* You can now compare “message == non_message_object” and it will return false
|
||||
instead of throwing an exception.
|
||||
* JRuby: fixed #hashCode to properly reflect the values in the message.
|
||||
|
||||
Javascript
|
||||
* Deserialization of repeated fields no longer has quadratic performance
|
||||
behavior.
|
||||
* UTF-8 encoding/decoding now properly supports high codepoints.
|
||||
* Added convenience methods for some well-known types: Any, Struct, and
|
||||
Timestamp. These make it easier to convert data between native JavaScript
|
||||
types and the well-known protobuf types.
|
||||
|
||||
2016-09-23 version 3.1.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite)
|
||||
General
|
||||
* Proto3 support in PHP (alpha).
|
||||
|
@ -40,23 +112,23 @@
|
|||
APIs and share the same generated code. Users don’t need to re-generate
|
||||
code for the same proto definition when they want to switch the
|
||||
implementation later. The pure PHP package is included in the php/src
|
||||
directory, and the c extension is included in the php/ext directory.
|
||||
|
||||
directory, and the c extension is included in the php/ext directory.
|
||||
|
||||
Both implementations provide idiomatic PHP APIs:
|
||||
* All messages and enums are defined as PHP classes.
|
||||
* All message fields can only be accessed via getter/setter.
|
||||
* Both repeated field elements and map elements are stored in containers
|
||||
that act like a normal PHP array.
|
||||
|
||||
|
||||
Unlike several existing third-party PHP implementations for protobuf, our
|
||||
implementations are built on a "strongly-typed" philosophy: message fields
|
||||
and array/map containers will throw exceptions eagerly when values of the
|
||||
incorrect type (not including those that can be type converted, e.g.,
|
||||
double <-> integer <-> numeric string) are inserted.
|
||||
|
||||
|
||||
Currently, pure PHP runtime supports php5.5, 5.6 and 7 on linux. C
|
||||
extension runtime supports php5.5 and 5.6 on linux.
|
||||
|
||||
|
||||
See php/README.md for more details about installment. See
|
||||
https://developers.google.com/protocol-buffers/docs/phptutorial for more
|
||||
details about APIs.
|
||||
|
|
|
@ -525,6 +525,7 @@ objectivec_EXTRA_DIST= \
|
|||
objectivec/Tests/GPBDictionaryTests+String.m \
|
||||
objectivec/Tests/GPBDictionaryTests+UInt32.m \
|
||||
objectivec/Tests/GPBDictionaryTests+UInt64.m \
|
||||
objectivec/Tests/GPBDictionaryTests.m \
|
||||
objectivec/Tests/GPBDictionaryTests.pddm \
|
||||
objectivec/Tests/GPBMessageTests+Merge.m \
|
||||
objectivec/Tests/GPBMessageTests+Runtime.m \
|
||||
|
@ -778,6 +779,7 @@ ruby_EXTRA_DIST= \
|
|||
ruby/ext/google/protobuf_c/storage.c \
|
||||
ruby/ext/google/protobuf_c/upb.c \
|
||||
ruby/ext/google/protobuf_c/upb.h \
|
||||
ruby/ext/google/protobuf_c/wrap_memcpy.c \
|
||||
ruby/google-protobuf.gemspec \
|
||||
ruby/lib/google/protobuf/message_exts.rb \
|
||||
ruby/lib/google/protobuf/repeated_field.rb \
|
||||
|
@ -819,6 +821,7 @@ js_EXTRA_DIST= \
|
|||
js/binary/decoder.js \
|
||||
js/binary/decoder_test.js \
|
||||
js/binary/encoder.js \
|
||||
js/binary/message_test.js \
|
||||
js/binary/proto_test.js \
|
||||
js/binary/reader.js \
|
||||
js/binary/reader_test.js \
|
||||
|
@ -852,6 +855,7 @@ js_EXTRA_DIST= \
|
|||
js/test3.proto \
|
||||
js/test4.proto \
|
||||
js/test5.proto \
|
||||
js/test8.proto \
|
||||
js/test_bootstrap.js \
|
||||
js/testbinary.proto \
|
||||
js/testempty.proto
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# dependent projects use the :git notation to refer to the library.
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'Protobuf'
|
||||
s.version = '3.1.0'
|
||||
s.version = '3.2.1'
|
||||
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
|
||||
s.homepage = 'https://github.com/google/protobuf'
|
||||
s.license = 'New BSD'
|
||||
|
@ -34,7 +34,7 @@ Pod::Spec.new do |s|
|
|||
s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
|
||||
s.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
|
||||
|
||||
s.ios.deployment_target = '7.1'
|
||||
s.ios.deployment_target = '7.0'
|
||||
s.osx.deployment_target = '10.9'
|
||||
s.watchos.deployment_target = '2.0'
|
||||
s.requires_arc = false
|
||||
|
|
|
@ -94,7 +94,7 @@ set(libprotoc_files
|
|||
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc
|
||||
)
|
||||
|
||||
set(js_well_known_types_sources,
|
||||
set(js_well_known_types_sources
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/any.js
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/struct.js
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/timestamp.js
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Google\\Protobuf\\Internal\\": "src/Google/Protobuf/Internal",
|
||||
"GPBMetadata\\Google\\Protobuf\\Internal\\": "src/GPBMetadata/Google/Protobuf/Internal"
|
||||
"Google\\Protobuf\\Internal\\": "php/src/Google/Protobuf/Internal",
|
||||
"GPBMetadata\\Google\\Protobuf\\Internal\\": "php/src/GPBMetadata/Google/Protobuf/Internal"
|
||||
},
|
||||
"files": [
|
||||
"src/Google/Protobuf/descriptor.php"
|
||||
"php/src/Google/Protobuf/descriptor.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ AC_PREREQ(2.59)
|
|||
# In the SVN trunk, the version should always be the next anticipated release
|
||||
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
|
||||
# the size of one file name in the dist tarfile over the 99-char limit.)
|
||||
AC_INIT([Protocol Buffers],[3.1.0],[protobuf@googlegroups.com],[protobuf])
|
||||
AC_INIT([Protocol Buffers],[3.2.0],[protobuf@googlegroups.com],[protobuf])
|
||||
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
|
||||
|
@ -60,6 +60,7 @@ AC_ARG_WITH([protoc],
|
|||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CXX_FOR_BUILD
|
||||
AC_LANG([C++])
|
||||
ACX_USE_SYSTEM_EXTENSIONS
|
||||
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<title>Google Protocol Buffers tools</title>
|
||||
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
|
||||
<description>See project site for more info.</description>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0</version>
|
||||
<authors>Google Inc.</authors>
|
||||
<owners>protobuf-packages</owners>
|
||||
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
|
||||
|
|
|
@ -1766,6 +1766,9 @@ namespace Google.Protobuf.Reflection {
|
|||
[pbr::OriginalName("TYPE_STRING")] String = 9,
|
||||
/// <summary>
|
||||
/// Tag-delimited aggregate.
|
||||
/// Group type is deprecated and not supported in proto3. However, Proto3
|
||||
/// implementations should still be able to parse the group wire format and
|
||||
/// treat group fields as unknown fields.
|
||||
/// </summary>
|
||||
[pbr::OriginalName("TYPE_GROUP")] Group = 10,
|
||||
/// <summary>
|
||||
|
|
|
@ -1311,7 +1311,10 @@ namespace Google.Protobuf.WellKnownTypes {
|
|||
public const int NameFieldNumber = 1;
|
||||
private string name_ = "";
|
||||
/// <summary>
|
||||
/// The option's name. For example, `"java_package"`.
|
||||
/// The option's name. For protobuf built-in options (options defined in
|
||||
/// descriptor.proto), this is the short name. For example, `"map_entry"`.
|
||||
/// For custom options, it should be the fully-qualified name. For example,
|
||||
/// `"google.api.http"`.
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public string Name {
|
||||
|
@ -1325,7 +1328,10 @@ namespace Google.Protobuf.WellKnownTypes {
|
|||
public const int ValueFieldNumber = 2;
|
||||
private global::Google.Protobuf.WellKnownTypes.Any value_;
|
||||
/// <summary>
|
||||
/// The option's value. For example, `"com.google.protobuf"`.
|
||||
/// The option's value packed in an Any message. If the value is a primitive,
|
||||
/// the corresponding wrapper type defined in google/protobuf/wrappers.proto
|
||||
/// should be used. If the value is an enum, it should be stored as an int32
|
||||
/// value using the google.protobuf.Int32Value type.
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
public global::Google.Protobuf.WellKnownTypes.Any Value {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "3.1.0",
|
||||
"version": "3.2.0",
|
||||
"title": "Google Protocol Buffers",
|
||||
"description": "See project site for more info.",
|
||||
"authors": [ "Google Inc." ],
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
|
|
|
@ -48,7 +48,6 @@ public abstract class AbstractMessageLite<
|
|||
BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>
|
||||
implements MessageLite {
|
||||
protected int memoizedHashCode = 0;
|
||||
|
||||
@Override
|
||||
public ByteString toByteString() {
|
||||
try {
|
||||
|
|
|
@ -220,6 +220,7 @@ final class FieldSet<FieldDescriptorType extends
|
|||
return fields.entrySet().iterator();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Useful for implementing
|
||||
* {@link Message#hasField(Descriptors.FieldDescriptor)}.
|
||||
|
|
|
@ -83,7 +83,7 @@ public final class MapFieldLite<K, V> extends LinkedHashMap<K, V> {
|
|||
|
||||
@Override public void clear() {
|
||||
ensureMutable();
|
||||
clear();
|
||||
super.clear();
|
||||
}
|
||||
|
||||
@Override public V put(K key, V value) {
|
||||
|
|
|
@ -197,6 +197,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
|
|||
overflowEntries.entrySet();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return entryList.size() + overflowEntries.size();
|
||||
|
@ -356,6 +357,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
|
|||
return lazyEntrySet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException if {@link #makeImmutable()} has
|
||||
* has been called.
|
||||
|
@ -525,6 +527,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Iterator implementation that switches from the entry array to the overflow
|
||||
* entries appropriately.
|
||||
|
@ -617,43 +620,43 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
|
|||
return (Iterable<T>) ITERABLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!(o instanceof SmallSortedMap)) {
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
|
||||
SmallSortedMap<?, ?> other = (SmallSortedMap<?, ?>) o;
|
||||
final int size = size();
|
||||
if (size != other.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Best effort try to avoid allocating an entry set.
|
||||
final int numArrayEntries = getNumArrayEntries();
|
||||
if (numArrayEntries != other.getNumArrayEntries()) {
|
||||
return entrySet().equals(other.entrySet());
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < numArrayEntries; i++) {
|
||||
if (!getArrayEntryAt(i).equals(other.getArrayEntryAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (numArrayEntries != size) {
|
||||
return overflowEntries.equals(other.overflowEntries);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = 0;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package com.google.protobuf;
|
||||
|
||||
import com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -39,6 +38,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
@ -58,7 +58,9 @@ import java.util.TreeMap;
|
|||
*/
|
||||
public final class UnknownFieldSet implements MessageLite {
|
||||
|
||||
private UnknownFieldSet() {}
|
||||
private UnknownFieldSet() {
|
||||
fields = null;
|
||||
}
|
||||
|
||||
/** Create a new {@link Builder}. */
|
||||
public static Builder newBuilder() {
|
||||
|
@ -82,16 +84,18 @@ public final class UnknownFieldSet implements MessageLite {
|
|||
return defaultInstance;
|
||||
}
|
||||
private static final UnknownFieldSet defaultInstance =
|
||||
new UnknownFieldSet(Collections.<Integer, Field>emptyMap());
|
||||
new UnknownFieldSet(Collections.<Integer, Field>emptyMap(),
|
||||
Collections.<Integer, Field>emptyMap());
|
||||
|
||||
/**
|
||||
* Construct an {@code UnknownFieldSet} around the given map. The map is
|
||||
* expected to be immutable.
|
||||
*/
|
||||
private UnknownFieldSet(final Map<Integer, Field> fields) {
|
||||
private UnknownFieldSet(final Map<Integer, Field> fields,
|
||||
final Map<Integer, Field> fieldsDescending) {
|
||||
this.fields = fields;
|
||||
}
|
||||
private Map<Integer, Field> fields;
|
||||
private final Map<Integer, Field> fields;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -224,10 +228,8 @@ public final class UnknownFieldSet implements MessageLite {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of bytes required to encode this set using
|
||||
* {@code MessageSet} wire format.
|
||||
*/
|
||||
|
||||
/** Get the number of bytes required to encode this set using {@code MessageSet} wire format. */
|
||||
public int getSerializedSizeAsMessageSet() {
|
||||
int result = 0;
|
||||
for (final Map.Entry<Integer, Field> entry : fields.entrySet()) {
|
||||
|
@ -343,12 +345,13 @@ public final class UnknownFieldSet implements MessageLite {
|
|||
*/
|
||||
@Override
|
||||
public UnknownFieldSet build() {
|
||||
getFieldBuilder(0); // Force lastField to be built.
|
||||
getFieldBuilder(0); // Force lastField to be built.
|
||||
final UnknownFieldSet result;
|
||||
if (fields.isEmpty()) {
|
||||
result = getDefaultInstance();
|
||||
} else {
|
||||
result = new UnknownFieldSet(Collections.unmodifiableMap(fields));
|
||||
Map<Integer, Field> descendingFields = null;
|
||||
result = new UnknownFieldSet(Collections.unmodifiableMap(fields), descendingFields);
|
||||
}
|
||||
fields = null;
|
||||
return result;
|
||||
|
@ -363,8 +366,9 @@ public final class UnknownFieldSet implements MessageLite {
|
|||
@Override
|
||||
public Builder clone() {
|
||||
getFieldBuilder(0); // Force lastField to be built.
|
||||
Map<Integer, Field> descendingFields = null;
|
||||
return UnknownFieldSet.newBuilder().mergeFrom(
|
||||
new UnknownFieldSet(fields));
|
||||
new UnknownFieldSet(fields, descendingFields));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -841,9 +845,10 @@ public final class UnknownFieldSet implements MessageLite {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of bytes required to encode this field, including field
|
||||
* number, using {@code MessageSet} wire format.
|
||||
* Get the number of bytes required to encode this field, including field number, using {@code
|
||||
* MessageSet} wire format.
|
||||
*/
|
||||
public int getSerializedSizeAsMessageSetExtension(final int fieldNumber) {
|
||||
int result = 0;
|
||||
|
|
|
@ -186,10 +186,11 @@ public final class UnknownFieldSetLite {
|
|||
output.writeRawMessageSetExtension(fieldNumber, (ByteString) objects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of bytes required to encode this field, including field
|
||||
* number, using {@code MessageSet} wire format.
|
||||
* Get the number of bytes required to encode this field, including field number, using {@code
|
||||
* MessageSet} wire format.
|
||||
*/
|
||||
public int getSerializedSizeAsMessageSet() {
|
||||
int size = memoizedSerializedSize;
|
||||
|
@ -251,6 +252,24 @@ public final class UnknownFieldSetLite {
|
|||
|
||||
return size;
|
||||
}
|
||||
|
||||
private static boolean equals(int[] tags1, int[] tags2, int count) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (tags1[i] != tags2[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean equals(Object[] objects1, Object[] objects2, int count) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!objects1[i].equals(objects2[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
@ -268,9 +287,8 @@ public final class UnknownFieldSetLite {
|
|||
|
||||
UnknownFieldSetLite other = (UnknownFieldSetLite) obj;
|
||||
if (count != other.count
|
||||
// TODO(dweis): Only have to compare up to count but at worst 2x worse than we need to do.
|
||||
|| !Arrays.equals(tags, other.tags)
|
||||
|| !Arrays.deepEquals(objects, other.objects)) {
|
||||
|| !equals(tags, other.tags, count)
|
||||
|| !equals(objects, other.objects, count)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,14 @@ public class UnknownFieldSetLiteTest extends TestCase {
|
|||
assertEquals(ByteString.EMPTY, toByteString(unknownFields));
|
||||
}
|
||||
|
||||
public void testEmptyInstance() {
|
||||
UnknownFieldSetLite instance = UnknownFieldSetLite.newInstance();
|
||||
|
||||
assertEquals(0, instance.getSerializedSize());
|
||||
assertEquals(ByteString.EMPTY, toByteString(instance));
|
||||
assertEquals(UnknownFieldSetLite.getDefaultInstance(), instance);
|
||||
}
|
||||
|
||||
public void testMergeFieldFrom() throws IOException {
|
||||
Foo foo = Foo.newBuilder()
|
||||
.setValue(2)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Protocol Buffers [Parent]</name>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</parent>
|
||||
<groupId>com.google.protobuf.nano</groupId>
|
||||
<artifactId>protobuf-javanano</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>Protocol Buffer JavaNano API</name>
|
||||
<description>
|
||||
|
|
|
@ -30,8 +30,11 @@
|
|||
|
||||
package com.google.protobuf.nano;
|
||||
|
||||
import com.google.protobuf.nano.MapTestProto.TestMap;
|
||||
import com.google.protobuf.nano.CodedOutputByteBufferNano;
|
||||
import com.google.protobuf.nano.EnumClassNanos.EnumClassNano;
|
||||
import com.google.protobuf.nano.EnumClassNanos.EnumClassNano.MessageScopeEnum;
|
||||
import com.google.protobuf.nano.EnumClassNanos.FileScopeEnum;
|
||||
import com.google.protobuf.nano.MapTestProto.TestMap;
|
||||
import com.google.protobuf.nano.MapTestProto.TestMap.MessageValue;
|
||||
import com.google.protobuf.nano.NanoAccessorsOuterClass.TestNanoAccessors;
|
||||
import com.google.protobuf.nano.NanoHasOuterClass.TestAllTypesNanoHas;
|
||||
|
|
|
@ -942,7 +942,7 @@ jspb.BinaryDecoder.prototype.readEnum = function() {
|
|||
/**
|
||||
* Reads and parses a UTF-8 encoded unicode string from the stream.
|
||||
* The code is inspired by maps.vectortown.parse.StreamedDataViewReader.
|
||||
* Supports codepoints from U+0000 up to U+10FFFF.
|
||||
* Supports codepoints from U+0000 up to U+10FFFF.
|
||||
* (http://en.wikipedia.org/wiki/UTF-8).
|
||||
* @param {number} length The length of the string to read.
|
||||
* @return {string} The decoded string.
|
||||
|
@ -984,7 +984,7 @@ jspb.BinaryDecoder.prototype.readString = function(length) {
|
|||
// 4. Add 0xDC00 to the low value to form the low surrogate:
|
||||
var low = (codepoint & 1023) + 0xDC00;
|
||||
var high = ((codepoint >> 10) & 1023) + 0xD800;
|
||||
codeUnits.push(high, low)
|
||||
codeUnits.push(high, low);
|
||||
}
|
||||
}
|
||||
// String.fromCharCode.apply is faster than manually appending characters on
|
||||
|
|
|
@ -209,25 +209,25 @@ describe('binaryDecoderTest', function() {
|
|||
assertEquals(hashC, decoder.readFixedHash64());
|
||||
assertEquals(hashD, decoder.readFixedHash64());
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Test encoding and decoding utf-8.
|
||||
*/
|
||||
it('testUtf8', function() {
|
||||
var encoder = new jspb.BinaryEncoder();
|
||||
|
||||
var ascii = "ASCII should work in 3, 2, 1..."
|
||||
var ascii = "ASCII should work in 3, 2, 1...";
|
||||
var utf8_two_bytes = "©";
|
||||
var utf8_three_bytes = "❄";
|
||||
var utf8_four_bytes = "😁";
|
||||
|
||||
|
||||
encoder.writeString(ascii);
|
||||
encoder.writeString(utf8_two_bytes);
|
||||
encoder.writeString(utf8_three_bytes);
|
||||
encoder.writeString(utf8_four_bytes);
|
||||
|
||||
|
||||
var decoder = jspb.BinaryDecoder.alloc(encoder.end());
|
||||
|
||||
|
||||
assertEquals(ascii, decoder.readString(ascii.length));
|
||||
assertEquals(utf8_two_bytes, decoder.readString(utf8_two_bytes.length));
|
||||
assertEquals(utf8_three_bytes, decoder.readString(utf8_three_bytes.length));
|
||||
|
|
|
@ -452,9 +452,9 @@ jspb.BinaryEncoder.prototype.writeFixedHash64 = function(hash) {
|
|||
*/
|
||||
jspb.BinaryEncoder.prototype.writeString = function(value) {
|
||||
var oldLength = this.buffer_.length;
|
||||
|
||||
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
|
||||
|
||||
var c = value.charCodeAt(i);
|
||||
|
||||
if (c < 128) {
|
||||
|
|
60
js/binary/message_test.js
Normal file
60
js/binary/message_test.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
// 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.
|
||||
|
||||
// Test suite is written using Jasmine -- see http://jasmine.github.io/
|
||||
|
||||
goog.setTestOnly();
|
||||
|
||||
goog.require('goog.testing.asserts');
|
||||
|
||||
// CommonJS-LoadFromFile: test_pb proto.jspb.test
|
||||
goog.require('proto.jspb.test.Deeply.Nested.Message');
|
||||
|
||||
// CommonJS-LoadFromFile: test2_pb proto.jspb.test
|
||||
goog.require('proto.jspb.test.ForeignNestedFieldMessage');
|
||||
|
||||
describe('Message test suite', function() {
|
||||
// Verify that we can successfully use a field referring to a nested message
|
||||
// from a different .proto file.
|
||||
it('testForeignNestedMessage', function() {
|
||||
var msg = new proto.jspb.test.ForeignNestedFieldMessage();
|
||||
var nested = new proto.jspb.test.Deeply.Nested.Message();
|
||||
nested.setCount(5);
|
||||
msg.setDeeplyNestedMessage(nested);
|
||||
assertEquals(5, msg.getDeeplyNestedMessage().getCount());
|
||||
|
||||
// After a serialization-deserialization round trip we should get back the
|
||||
// same data we started with.
|
||||
var serialized = msg.serializeBinary();
|
||||
var deserialized =
|
||||
proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized);
|
||||
assertEquals(5, deserialized.getDeeplyNestedMessage().getCount());
|
||||
});
|
||||
});
|
58
js/map.js
58
js/map.js
|
@ -183,26 +183,39 @@ jspb.Map.fromObject = function(entries, valueCtor, valueFromObject) {
|
|||
|
||||
|
||||
/**
|
||||
* Helper: return an iterator over an array.
|
||||
* Helper: an IteratorIterable over an array.
|
||||
* @template T
|
||||
* @param {!Array<T>} arr the array
|
||||
* @return {!Iterator<T>} an iterator
|
||||
* @implements {IteratorIterable<T>}
|
||||
* @constructor @struct
|
||||
* @private
|
||||
*/
|
||||
jspb.Map.arrayIterator_ = function(arr) {
|
||||
var idx = 0;
|
||||
return /** @type {!Iterator} */ ({
|
||||
next: function() {
|
||||
if (idx < arr.length) {
|
||||
return { done: false, value: arr[idx++] };
|
||||
} else {
|
||||
return { done: true };
|
||||
}
|
||||
}
|
||||
});
|
||||
jspb.Map.ArrayIteratorIterable_ = function(arr) {
|
||||
/** @type {number} @private */
|
||||
this.idx_ = 0;
|
||||
|
||||
/** @const @private */
|
||||
this.arr_ = arr;
|
||||
};
|
||||
|
||||
|
||||
/** @override @final */
|
||||
jspb.Map.ArrayIteratorIterable_.prototype.next = function() {
|
||||
if (this.idx_ < this.arr_.length) {
|
||||
return {done: false, value: this.arr_[this.idx_++]};
|
||||
} else {
|
||||
return {done: true, value: undefined};
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof(Symbol) != 'undefined') {
|
||||
/** @override */
|
||||
jspb.Map.ArrayIteratorIterable_.prototype[Symbol.iterator] = function() {
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the map's length (number of key/value pairs).
|
||||
* @return {number}
|
||||
|
@ -260,10 +273,9 @@ jspb.Map.prototype.getEntryList = function() {
|
|||
|
||||
|
||||
/**
|
||||
* Returns an iterator over [key, value] pairs in the map.
|
||||
* Returns an iterator-iterable over [key, value] pairs in the map.
|
||||
* Closure compiler sadly doesn't support tuples, ie. Iterator<[K,V]>.
|
||||
* @return {!Iterator<!Array<K|V>>}
|
||||
* The iterator
|
||||
* @return {!IteratorIterable<!Array<K|V>>} The iterator-iterable.
|
||||
*/
|
||||
jspb.Map.prototype.entries = function() {
|
||||
var entries = [];
|
||||
|
@ -273,13 +285,13 @@ jspb.Map.prototype.entries = function() {
|
|||
var entry = this.map_[strKeys[i]];
|
||||
entries.push([entry.key, this.wrapEntry_(entry)]);
|
||||
}
|
||||
return jspb.Map.arrayIterator_(entries);
|
||||
return new jspb.Map.ArrayIteratorIterable_(entries);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns an iterator over keys in the map.
|
||||
* @return {!Iterator<K>} The iterator
|
||||
* Returns an iterator-iterable over keys in the map.
|
||||
* @return {!IteratorIterable<K>} The iterator-iterable.
|
||||
*/
|
||||
jspb.Map.prototype.keys = function() {
|
||||
var keys = [];
|
||||
|
@ -289,13 +301,13 @@ jspb.Map.prototype.keys = function() {
|
|||
var entry = this.map_[strKeys[i]];
|
||||
keys.push(entry.key);
|
||||
}
|
||||
return jspb.Map.arrayIterator_(keys);
|
||||
return new jspb.Map.ArrayIteratorIterable_(keys);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns an iterator over values in the map.
|
||||
* @return {!Iterator<V>} The iterator
|
||||
* Returns an iterator-iterable over values in the map.
|
||||
* @return {!IteratorIterable<V>} The iterator-iterable.
|
||||
*/
|
||||
jspb.Map.prototype.values = function() {
|
||||
var values = [];
|
||||
|
@ -305,7 +317,7 @@ jspb.Map.prototype.values = function() {
|
|||
var entry = this.map_[strKeys[i]];
|
||||
values.push(this.wrapEntry_(entry));
|
||||
}
|
||||
return jspb.Map.arrayIterator_(values);
|
||||
return new jspb.Map.ArrayIteratorIterable_(values);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -288,6 +288,50 @@ function makeTests(msgInfo, submessageCtor, suffix) {
|
|||
var a = msg.toArray();
|
||||
assertEquals(a[0], entries); // retains original reference
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns IteratorIterables for entries(), keys() and values().
|
||||
*/
|
||||
it('testIteratorIterables' + suffix, function() {
|
||||
var msg = new msgInfo.constructor();
|
||||
var m = msg.getMapStringStringMap();
|
||||
m.set('key1', 'value1');
|
||||
m.set('key2', 'value2');
|
||||
var entryIterator = m.entries();
|
||||
assertElementsEquals(entryIterator.next().value, ['key1', 'value1']);
|
||||
assertElementsEquals(entryIterator.next().value, ['key2', 'value2']);
|
||||
assertEquals(entryIterator.next().done, true);
|
||||
|
||||
if (typeof(Symbol) != 'undefined') {
|
||||
var entryIterable = m.entries()[Symbol.iterator]();
|
||||
assertElementsEquals(entryIterable.next().value, ['key1', 'value1']);
|
||||
assertElementsEquals(entryIterable.next().value, ['key2', 'value2']);
|
||||
assertEquals(entryIterable.next().done, true);
|
||||
}
|
||||
|
||||
var keyIterator = m.keys();
|
||||
assertEquals(keyIterator.next().value, 'key1');
|
||||
assertEquals(keyIterator.next().value, 'key2');
|
||||
assertEquals(keyIterator.next().done, true);
|
||||
|
||||
if (typeof(Symbol) != 'undefined') {
|
||||
var keyIterable = m.keys()[Symbol.iterator]();
|
||||
assertEquals(keyIterable.next().value, 'key1');
|
||||
assertEquals(keyIterable.next().value, 'key2');
|
||||
assertEquals(keyIterable.next().done, true);
|
||||
}
|
||||
var valueIterator = m.values();
|
||||
assertEquals(valueIterator.next().value, 'value1');
|
||||
assertEquals(valueIterator.next().value, 'value2');
|
||||
assertEquals(valueIterator.next().done, true);
|
||||
|
||||
if (typeof(Symbol) != 'undefined') {
|
||||
var valueIterable = m.values()[Symbol.iterator]();
|
||||
assertEquals(valueIterable.next().value, 'value1');
|
||||
assertEquals(valueIterable.next().value, 'value2');
|
||||
assertEquals(valueIterable.next().done, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe('mapsTest', function() {
|
||||
|
|
|
@ -174,6 +174,22 @@ goog.define('jspb.Message.GENERATE_TO_OBJECT', true);
|
|||
goog.define('jspb.Message.GENERATE_FROM_OBJECT', !goog.DISALLOW_TEST_ONLY_CODE);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to generate toString methods for objects. Turn
|
||||
* this off if you do use toString in your project and want to trim it from
|
||||
* compiled JS.
|
||||
*/
|
||||
goog.define('jspb.Message.GENERATE_TO_STRING', true);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether arrays passed to initialize() can be assumed to be
|
||||
* local (e.g. not from another iframe) and thus safely classified with
|
||||
* instanceof Array.
|
||||
*/
|
||||
goog.define('jspb.Message.ASSUME_LOCAL_ARRAYS', false);
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Turning on this flag does NOT change the behavior of JSPB
|
||||
* and only affects private internal state. It may, however, break some
|
||||
|
@ -363,6 +379,18 @@ jspb.Message.EMPTY_LIST_SENTINEL_ = goog.DEBUG && Object.freeze ?
|
|||
[];
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the provided argument is an array.
|
||||
* @param {*} o The object to classify as array or not.
|
||||
* @return {boolean} True if the provided object is an array.
|
||||
* @private
|
||||
*/
|
||||
jspb.Message.isArray_ = function(o) {
|
||||
return jspb.Message.ASSUME_LOCAL_ARRAYS ? o instanceof Array :
|
||||
goog.isArray(o);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Ensures that the array contains an extension object if necessary.
|
||||
* If the array contains an extension object in its last position, then the
|
||||
|
@ -383,8 +411,8 @@ jspb.Message.materializeExtensionObject_ = function(msg, suggestedPivot) {
|
|||
// the object is not an array, since arrays are valid field values.
|
||||
// NOTE(lukestebbing): We avoid looking at .length to avoid a JIT bug
|
||||
// in Safari on iOS 8. See the description of CL/86511464 for details.
|
||||
if (obj && typeof obj == 'object' && !goog.isArray(obj) &&
|
||||
!(jspb.Message.SUPPORTS_UINT8ARRAY_ && obj instanceof Uint8Array)) {
|
||||
if (obj && typeof obj == 'object' && !jspb.Message.isArray_(obj) &&
|
||||
!(jspb.Message.SUPPORTS_UINT8ARRAY_ && obj instanceof Uint8Array)) {
|
||||
msg.pivot_ = foundIndex - msg.arrayIndexOffset_;
|
||||
msg.extensionObject_ = obj;
|
||||
return;
|
||||
|
@ -1140,6 +1168,7 @@ jspb.Message.prototype.toArray = function() {
|
|||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_STRING) {
|
||||
|
||||
/**
|
||||
* Creates a string representation of the internal data array of this proto.
|
||||
|
@ -1152,6 +1181,7 @@ jspb.Message.prototype.toString = function() {
|
|||
return this.array.toString();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the extension field from the extended object.
|
||||
|
|
|
@ -39,6 +39,9 @@ goog.require('goog.userAgent');
|
|||
// CommonJS-LoadFromFile: google-protobuf jspb
|
||||
goog.require('jspb.Message');
|
||||
|
||||
// CommonJS-LoadFromFile: test8_pb proto.jspb.exttest.nested
|
||||
goog.require('proto.jspb.exttest.nested.TestOuterMessage');
|
||||
|
||||
// CommonJS-LoadFromFile: test5_pb proto.jspb.exttest.beta
|
||||
goog.require('proto.jspb.exttest.beta.floatingStrField');
|
||||
|
||||
|
@ -73,12 +76,10 @@ goog.require('proto.jspb.test.TestGroup1');
|
|||
goog.require('proto.jspb.test.TestMessageWithOneof');
|
||||
goog.require('proto.jspb.test.TestReservedNames');
|
||||
goog.require('proto.jspb.test.TestReservedNamesExtension');
|
||||
goog.require('proto.jspb.test.Deeply.Nested.Message');
|
||||
|
||||
// CommonJS-LoadFromFile: test2_pb proto.jspb.test
|
||||
goog.require('proto.jspb.test.ExtensionMessage');
|
||||
goog.require('proto.jspb.test.TestExtensionsMessage');
|
||||
goog.require('proto.jspb.test.ForeignNestedFieldMessage');
|
||||
|
||||
|
||||
|
||||
|
@ -588,6 +589,14 @@ describe('Message test suite', function() {
|
|||
assertNotUndefined(proto.jspb.exttest.beta.floatingStrField);
|
||||
});
|
||||
|
||||
it('testNestedExtensions', function() {
|
||||
var extendable = new proto.jspb.exttest.nested.TestNestedExtensionsMessage();
|
||||
var extension = new proto.jspb.exttest.nested.TestOuterMessage.NestedExtensionMessage(['s1']);
|
||||
extendable.setExtension(proto.jspb.exttest.nested.TestOuterMessage.innerExtension, extension);
|
||||
assertObjectEquals(extension,
|
||||
extendable.getExtension(proto.jspb.exttest.nested.TestOuterMessage.innerExtension));
|
||||
});
|
||||
|
||||
it('testToObject_extendedObject', function() {
|
||||
var extension1 = new proto.jspb.test.IsExtension(['ext1field']);
|
||||
var extension2 = new proto.jspb.test.Simple1(['str', ['s1', 's2'], true]);
|
||||
|
@ -1042,21 +1051,4 @@ describe('Message test suite', function() {
|
|||
assertNan(message.getDefaultDoubleField());
|
||||
});
|
||||
|
||||
// Verify that we can successfully use a field referring to a nested message
|
||||
// from a different .proto file.
|
||||
it('testForeignNestedMessage', function() {
|
||||
var msg = new proto.jspb.test.ForeignNestedFieldMessage();
|
||||
var nested = new proto.jspb.test.Deeply.Nested.Message();
|
||||
nested.setCount(5);
|
||||
msg.setDeeplyNestedMessage(nested);
|
||||
assertEquals(5, msg.getDeeplyNestedMessage().getCount());
|
||||
|
||||
// After a serialization-deserialization round trip we should get back the
|
||||
// same data we started with.
|
||||
var serialized = msg.serializeBinary();
|
||||
var deserialized =
|
||||
proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized);
|
||||
assertEquals(5, deserialized.getDeeplyNestedMessage().getCount());
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "google-protobuf",
|
||||
"version": "3.1.0",
|
||||
"version": "3.2.0",
|
||||
"description": "Protocol Buffers for JavaScript",
|
||||
"main": "google-protobuf.js",
|
||||
"files": [
|
||||
|
|
50
js/test8.proto
Normal file
50
js/test8.proto
Normal file
|
@ -0,0 +1,50 @@
|
|||
// 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 = "proto2";
|
||||
|
||||
option java_package = "com.google.apps.jspb.proto";
|
||||
option java_multiple_files = true;
|
||||
|
||||
package jspb.exttest.nested;
|
||||
|
||||
message TestNestedExtensionsMessage {
|
||||
optional int32 intfield = 1;
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
||||
message TestOuterMessage {
|
||||
message NestedExtensionMessage {
|
||||
optional string ext1 = 1;
|
||||
}
|
||||
extend TestNestedExtensionsMessage {
|
||||
optional NestedExtensionMessage inner_extension = 100;
|
||||
}
|
||||
}
|
125
m4/ax_prog_cc_for_build.m4
Normal file
125
m4/ax_prog_cc_for_build.m4
Normal file
|
@ -0,0 +1,125 @@
|
|||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_PROG_CC_FOR_BUILD
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro searches for a C compiler that generates native executables,
|
||||
# that is a C compiler that surely is not a cross-compiler. This can be
|
||||
# useful if you have to generate source code at compile-time like for
|
||||
# example GCC does.
|
||||
#
|
||||
# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
|
||||
# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD).
|
||||
# The value of these variables can be overridden by the user by specifying
|
||||
# a compiler with an environment variable (like you do for standard CC).
|
||||
#
|
||||
# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object
|
||||
# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if
|
||||
# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are
|
||||
# substituted in the Makefile.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 8
|
||||
|
||||
AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
|
||||
AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
|
||||
AC_REQUIRE([AC_PROG_CC])dnl
|
||||
AC_REQUIRE([AC_PROG_CPP])dnl
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
|
||||
dnl Use the standard macros, but make them use other variable names
|
||||
dnl
|
||||
pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
|
||||
pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
|
||||
pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
|
||||
pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
|
||||
pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
|
||||
pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
|
||||
pushdef([ac_cv_objext], ac_cv_build_objext)dnl
|
||||
pushdef([ac_exeext], ac_build_exeext)dnl
|
||||
pushdef([ac_objext], ac_build_objext)dnl
|
||||
pushdef([CC], CC_FOR_BUILD)dnl
|
||||
pushdef([CPP], CPP_FOR_BUILD)dnl
|
||||
pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
|
||||
pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
|
||||
pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
|
||||
pushdef([host], build)dnl
|
||||
pushdef([host_alias], build_alias)dnl
|
||||
pushdef([host_cpu], build_cpu)dnl
|
||||
pushdef([host_vendor], build_vendor)dnl
|
||||
pushdef([host_os], build_os)dnl
|
||||
pushdef([ac_cv_host], ac_cv_build)dnl
|
||||
pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
|
||||
pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
|
||||
pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
|
||||
pushdef([ac_cv_host_os], ac_cv_build_os)dnl
|
||||
pushdef([ac_cpp], ac_build_cpp)dnl
|
||||
pushdef([ac_compile], ac_build_compile)dnl
|
||||
pushdef([ac_link], ac_build_link)dnl
|
||||
|
||||
save_cross_compiling=$cross_compiling
|
||||
save_ac_tool_prefix=$ac_tool_prefix
|
||||
cross_compiling=no
|
||||
ac_tool_prefix=
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_EXEEXT
|
||||
|
||||
ac_tool_prefix=$save_ac_tool_prefix
|
||||
cross_compiling=$save_cross_compiling
|
||||
|
||||
dnl Restore the old definitions
|
||||
dnl
|
||||
popdef([ac_link])dnl
|
||||
popdef([ac_compile])dnl
|
||||
popdef([ac_cpp])dnl
|
||||
popdef([ac_cv_host_os])dnl
|
||||
popdef([ac_cv_host_vendor])dnl
|
||||
popdef([ac_cv_host_cpu])dnl
|
||||
popdef([ac_cv_host_alias])dnl
|
||||
popdef([ac_cv_host])dnl
|
||||
popdef([host_os])dnl
|
||||
popdef([host_vendor])dnl
|
||||
popdef([host_cpu])dnl
|
||||
popdef([host_alias])dnl
|
||||
popdef([host])dnl
|
||||
popdef([LDFLAGS])dnl
|
||||
popdef([CPPFLAGS])dnl
|
||||
popdef([CFLAGS])dnl
|
||||
popdef([CPP])dnl
|
||||
popdef([CC])dnl
|
||||
popdef([ac_objext])dnl
|
||||
popdef([ac_exeext])dnl
|
||||
popdef([ac_cv_objext])dnl
|
||||
popdef([ac_cv_exeext])dnl
|
||||
popdef([ac_cv_prog_cc_g])dnl
|
||||
popdef([ac_cv_prog_cc_cross])dnl
|
||||
popdef([ac_cv_prog_cc_works])dnl
|
||||
popdef([ac_cv_prog_gcc])dnl
|
||||
popdef([ac_cv_prog_CPP])dnl
|
||||
|
||||
dnl Finally, set Makefile variables
|
||||
dnl
|
||||
BUILD_EXEEXT=$ac_build_exeext
|
||||
BUILD_OBJEXT=$ac_build_objext
|
||||
AC_SUBST(BUILD_EXEEXT)dnl
|
||||
AC_SUBST(BUILD_OBJEXT)dnl
|
||||
AC_SUBST([CFLAGS_FOR_BUILD])dnl
|
||||
AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
|
||||
AC_SUBST([LDFLAGS_FOR_BUILD])dnl
|
||||
])
|
110
m4/ax_prog_cxx_for_build.m4
Normal file
110
m4/ax_prog_cxx_for_build.m4
Normal file
|
@ -0,0 +1,110 @@
|
|||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_prog_cxx_for_build.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_PROG_CXX_FOR_BUILD
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro searches for a C++ compiler that generates native
|
||||
# executables, that is a C++ compiler that surely is not a cross-compiler.
|
||||
# This can be useful if you have to generate source code at compile-time
|
||||
# like for example GCC does.
|
||||
#
|
||||
# The macro sets the CXX_FOR_BUILD and CXXCPP_FOR_BUILD macros to anything
|
||||
# needed to compile or link (CXX_FOR_BUILD) and preprocess
|
||||
# (CXXCPP_FOR_BUILD). The value of these variables can be overridden by
|
||||
# the user by specifying a compiler with an environment variable (like you
|
||||
# do for standard CXX).
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
|
||||
# Copyright (c) 2012 Avionic Design GmbH
|
||||
#
|
||||
# Based on the AX_PROG_CC_FOR_BUILD macro by Paolo Bonzini.
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 2
|
||||
|
||||
AU_ALIAS([AC_PROG_CXX_FOR_BUILD], [AX_PROG_CXX_FOR_BUILD])
|
||||
AC_DEFUN([AX_PROG_CXX_FOR_BUILD], [dnl
|
||||
AC_REQUIRE([AX_PROG_CC_FOR_BUILD])dnl
|
||||
AC_REQUIRE([AC_PROG_CXX])dnl
|
||||
AC_REQUIRE([AC_PROG_CXXCPP])dnl
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
|
||||
dnl Use the standard macros, but make them use other variable names
|
||||
dnl
|
||||
pushdef([ac_cv_prog_CXXCPP], ac_cv_build_prog_CXXCPP)dnl
|
||||
pushdef([ac_cv_prog_gxx], ac_cv_build_prog_gxx)dnl
|
||||
pushdef([ac_cv_prog_cxx_works], ac_cv_build_prog_cxx_works)dnl
|
||||
pushdef([ac_cv_prog_cxx_cross], ac_cv_build_prog_cxx_cross)dnl
|
||||
pushdef([ac_cv_prog_cxx_g], ac_cv_build_prog_cxx_g)dnl
|
||||
pushdef([CXX], CXX_FOR_BUILD)dnl
|
||||
pushdef([CXXCPP], CXXCPP_FOR_BUILD)dnl
|
||||
pushdef([CXXFLAGS], CXXFLAGS_FOR_BUILD)dnl
|
||||
pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
|
||||
pushdef([CXXCPPFLAGS], CXXCPPFLAGS_FOR_BUILD)dnl
|
||||
pushdef([host], build)dnl
|
||||
pushdef([host_alias], build_alias)dnl
|
||||
pushdef([host_cpu], build_cpu)dnl
|
||||
pushdef([host_vendor], build_vendor)dnl
|
||||
pushdef([host_os], build_os)dnl
|
||||
pushdef([ac_cv_host], ac_cv_build)dnl
|
||||
pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
|
||||
pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
|
||||
pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
|
||||
pushdef([ac_cv_host_os], ac_cv_build_os)dnl
|
||||
pushdef([ac_cxxcpp], ac_build_cxxcpp)dnl
|
||||
pushdef([ac_compile], ac_build_compile)dnl
|
||||
pushdef([ac_link], ac_build_link)dnl
|
||||
|
||||
save_cross_compiling=$cross_compiling
|
||||
save_ac_tool_prefix=$ac_tool_prefix
|
||||
cross_compiling=no
|
||||
ac_tool_prefix=
|
||||
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CXXCPP
|
||||
|
||||
ac_tool_prefix=$save_ac_tool_prefix
|
||||
cross_compiling=$save_cross_compiling
|
||||
|
||||
dnl Restore the old definitions
|
||||
dnl
|
||||
popdef([ac_link])dnl
|
||||
popdef([ac_compile])dnl
|
||||
popdef([ac_cxxcpp])dnl
|
||||
popdef([ac_cv_host_os])dnl
|
||||
popdef([ac_cv_host_vendor])dnl
|
||||
popdef([ac_cv_host_cpu])dnl
|
||||
popdef([ac_cv_host_alias])dnl
|
||||
popdef([ac_cv_host])dnl
|
||||
popdef([host_os])dnl
|
||||
popdef([host_vendor])dnl
|
||||
popdef([host_cpu])dnl
|
||||
popdef([host_alias])dnl
|
||||
popdef([host])dnl
|
||||
popdef([CXXCPPFLAGS])dnl
|
||||
popdef([CPPFLAGS])dnl
|
||||
popdef([CXXFLAGS])dnl
|
||||
popdef([CXXCPP])dnl
|
||||
popdef([CXX])dnl
|
||||
popdef([ac_cv_prog_cxx_g])dnl
|
||||
popdef([ac_cv_prog_cxx_cross])dnl
|
||||
popdef([ac_cv_prog_cxx_works])dnl
|
||||
popdef([ac_cv_prog_gxx])dnl
|
||||
popdef([ac_cv_prog_CXXCPP])dnl
|
||||
|
||||
dnl Finally, set Makefile variables
|
||||
dnl
|
||||
AC_SUBST([CXXFLAGS_FOR_BUILD])dnl
|
||||
AC_SUBST([CXXCPPFLAGS_FOR_BUILD])dnl
|
||||
])
|
|
@ -265,6 +265,14 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
|
|||
-destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.1" # 64bit
|
||||
)
|
||||
;;
|
||||
8.2* )
|
||||
XCODEBUILD_TEST_BASE_IOS+=(
|
||||
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
|
||||
-destination "platform=iOS Simulator,name=iPhone 7,OS=10.2" # 64bit
|
||||
-destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
|
||||
-destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.2" # 64bit
|
||||
)
|
||||
;;
|
||||
* )
|
||||
echo "Time to update the simulator targets for Xcode ${XCODE_VERSION}"
|
||||
exit 2
|
||||
|
|
|
@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @return A newly initialized GPBInt32Array with a copy of the values.
|
||||
**/
|
||||
- (instancetype)initWithValues:(const int32_t [])values
|
||||
- (instancetype)initWithValues:(const int32_t [__nullable])values
|
||||
count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
|
@ -161,7 +161,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values The values to add to this array.
|
||||
* @param count The number of elements to add.
|
||||
**/
|
||||
- (void)addValues:(const int32_t [])values count:(NSUInteger)count;
|
||||
- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
* Adds the values from the given array to this array.
|
||||
|
@ -268,7 +268,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @return A newly initialized GPBUInt32Array with a copy of the values.
|
||||
**/
|
||||
- (instancetype)initWithValues:(const uint32_t [])values
|
||||
- (instancetype)initWithValues:(const uint32_t [__nullable])values
|
||||
count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
|
@ -333,7 +333,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values The values to add to this array.
|
||||
* @param count The number of elements to add.
|
||||
**/
|
||||
- (void)addValues:(const uint32_t [])values count:(NSUInteger)count;
|
||||
- (void)addValues:(const uint32_t [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
* Adds the values from the given array to this array.
|
||||
|
@ -440,7 +440,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @return A newly initialized GPBInt64Array with a copy of the values.
|
||||
**/
|
||||
- (instancetype)initWithValues:(const int64_t [])values
|
||||
- (instancetype)initWithValues:(const int64_t [__nullable])values
|
||||
count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
|
@ -505,7 +505,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values The values to add to this array.
|
||||
* @param count The number of elements to add.
|
||||
**/
|
||||
- (void)addValues:(const int64_t [])values count:(NSUInteger)count;
|
||||
- (void)addValues:(const int64_t [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
* Adds the values from the given array to this array.
|
||||
|
@ -612,7 +612,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @return A newly initialized GPBUInt64Array with a copy of the values.
|
||||
**/
|
||||
- (instancetype)initWithValues:(const uint64_t [])values
|
||||
- (instancetype)initWithValues:(const uint64_t [__nullable])values
|
||||
count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
|
@ -677,7 +677,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values The values to add to this array.
|
||||
* @param count The number of elements to add.
|
||||
**/
|
||||
- (void)addValues:(const uint64_t [])values count:(NSUInteger)count;
|
||||
- (void)addValues:(const uint64_t [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
* Adds the values from the given array to this array.
|
||||
|
@ -784,7 +784,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @return A newly initialized GPBFloatArray with a copy of the values.
|
||||
**/
|
||||
- (instancetype)initWithValues:(const float [])values
|
||||
- (instancetype)initWithValues:(const float [__nullable])values
|
||||
count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
|
@ -849,7 +849,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values The values to add to this array.
|
||||
* @param count The number of elements to add.
|
||||
**/
|
||||
- (void)addValues:(const float [])values count:(NSUInteger)count;
|
||||
- (void)addValues:(const float [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
* Adds the values from the given array to this array.
|
||||
|
@ -956,7 +956,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @return A newly initialized GPBDoubleArray with a copy of the values.
|
||||
**/
|
||||
- (instancetype)initWithValues:(const double [])values
|
||||
- (instancetype)initWithValues:(const double [__nullable])values
|
||||
count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
|
@ -1021,7 +1021,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values The values to add to this array.
|
||||
* @param count The number of elements to add.
|
||||
**/
|
||||
- (void)addValues:(const double [])values count:(NSUInteger)count;
|
||||
- (void)addValues:(const double [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
* Adds the values from the given array to this array.
|
||||
|
@ -1128,7 +1128,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @return A newly initialized GPBBoolArray with a copy of the values.
|
||||
**/
|
||||
- (instancetype)initWithValues:(const BOOL [])values
|
||||
- (instancetype)initWithValues:(const BOOL [__nullable])values
|
||||
count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
|
@ -1193,7 +1193,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values The values to add to this array.
|
||||
* @param count The number of elements to add.
|
||||
**/
|
||||
- (void)addValues:(const BOOL [])values count:(NSUInteger)count;
|
||||
- (void)addValues:(const BOOL [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
* Adds the values from the given array to this array.
|
||||
|
@ -1325,7 +1325,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @return A newly initialized GPBEnumArray with a copy of the values.
|
||||
**/
|
||||
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
|
||||
rawValues:(const int32_t [])values
|
||||
rawValues:(const int32_t [__nullable])values
|
||||
count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
|
@ -1435,7 +1435,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values The values to add to this array.
|
||||
* @param count The number of elements to add.
|
||||
**/
|
||||
- (void)addValues:(const int32_t [])values count:(NSUInteger)count;
|
||||
- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1486,7 +1486,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
* @param values Array containing the raw enum values to add to this array.
|
||||
* @param count The number of raw values to add.
|
||||
**/
|
||||
- (void)addRawValues:(const int32_t [])values count:(NSUInteger)count;
|
||||
- (void)addRawValues:(const int32_t [__nullable])values count:(NSUInteger)count;
|
||||
|
||||
/**
|
||||
* Inserts a raw enum value at the given index.
|
||||
|
@ -1613,7 +1613,7 @@ NS_ASSUME_NONNULL_END
|
|||
//% *
|
||||
//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
|
||||
//% **/
|
||||
//%- (instancetype)initWithValues:(const TYPE [])values
|
||||
//%- (instancetype)initWithValues:(const TYPE [__nullable])values
|
||||
//% count:(NSUInteger)count;
|
||||
//%
|
||||
//%/**
|
||||
|
@ -1730,7 +1730,7 @@ NS_ASSUME_NONNULL_END
|
|||
//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
|
||||
//% **/
|
||||
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
|
||||
//% rawValues:(const TYPE [])values
|
||||
//% rawValues:(const TYPE [__nullable])values
|
||||
//% count:(NSUInteger)count;
|
||||
//%
|
||||
//%/**
|
||||
|
@ -1849,7 +1849,7 @@ NS_ASSUME_NONNULL_END
|
|||
//% * @param values The values to add to this array.
|
||||
//% * @param count The number of elements to add.
|
||||
//% **/
|
||||
//%- (void)addValues:(const TYPE [])values count:(NSUInteger)count;
|
||||
//%- (void)addValues:(const TYPE [__nullable])values count:(NSUInteger)count;
|
||||
//%
|
||||
//%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE)
|
||||
//%/**
|
||||
|
@ -1939,7 +1939,7 @@ NS_ASSUME_NONNULL_END
|
|||
//% * @param values Array containing the raw enum values to add to this array.
|
||||
//% * @param count The number of raw values to add.
|
||||
//% **/
|
||||
//%- (void)addRawValues:(const TYPE [])values count:(NSUInteger)count;
|
||||
//%- (void)addRawValues:(const TYPE [__nullable])values count:(NSUInteger)count;
|
||||
//%
|
||||
//%/**
|
||||
//% * Inserts a raw enum value at the given index.
|
||||
|
|
|
@ -2519,14 +2519,14 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
|
|||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
if (_array == nil) {
|
||||
_array = [[NSMutableArray alloc] init];
|
||||
return [[NSMutableArray allocWithZone:zone] init];
|
||||
}
|
||||
return [_array copyWithZone:zone];
|
||||
}
|
||||
|
||||
- (id)mutableCopyWithZone:(NSZone *)zone {
|
||||
if (_array == nil) {
|
||||
_array = [[NSMutableArray alloc] init];
|
||||
return [[NSMutableArray allocWithZone:zone] init];
|
||||
}
|
||||
return [_array mutableCopyWithZone:zone];
|
||||
}
|
||||
|
|
|
@ -45,7 +45,12 @@ NSString *const GPBCodedInputStreamUnderlyingErrorKey =
|
|||
NSString *const GPBCodedInputStreamErrorDomain =
|
||||
GPBNSStringifySymbol(GPBCodedInputStreamErrorDomain);
|
||||
|
||||
static const NSUInteger kDefaultRecursionLimit = 64;
|
||||
// Matching:
|
||||
// https://github.com/google/protobuf/blob/master/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L62
|
||||
// private static final int DEFAULT_RECURSION_LIMIT = 100;
|
||||
// https://github.com/google/protobuf/blob/master/src/google/protobuf/io/coded_stream.cc#L86
|
||||
// int CodedInputStream::default_recursion_limit_ = 100;
|
||||
static const NSUInteger kDefaultRecursionLimit = 100;
|
||||
|
||||
static void RaiseException(NSInteger code, NSString *reason) {
|
||||
NSDictionary *errorInfo = nil;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13579,22 +13579,26 @@ void GPBDictionaryReadEntry(id mapDictionary,
|
|||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
if (_dictionary == nil) {
|
||||
_dictionary = [[NSMutableDictionary alloc] init];
|
||||
return [[NSMutableDictionary allocWithZone:zone] init];
|
||||
}
|
||||
return [_dictionary copyWithZone:zone];
|
||||
}
|
||||
|
||||
- (id)mutableCopyWithZone:(NSZone *)zone {
|
||||
if (_dictionary == nil) {
|
||||
_dictionary = [[NSMutableDictionary alloc] init];
|
||||
return [[NSMutableDictionary allocWithZone:zone] init];
|
||||
}
|
||||
return [_dictionary mutableCopyWithZone:zone];
|
||||
}
|
||||
|
||||
// Not really needed, but subscripting is likely common enough it doesn't hurt
|
||||
// to ensure it goes directly to the real NSMutableDictionary.
|
||||
- (id)objectForKeyedSubscript:(id)key {
|
||||
return [_dictionary objectForKeyedSubscript:key];
|
||||
}
|
||||
|
||||
// Not really needed, but subscripting is likely common enough it doesn't hurt
|
||||
// to ensure it goes directly to the real NSMutableDictionary.
|
||||
- (void)setObject:(id)obj forKeyedSubscript:(id<NSCopying>)key {
|
||||
if (_dictionary == nil) {
|
||||
_dictionary = [[NSMutableDictionary alloc] init];
|
||||
|
|
|
@ -738,6 +738,25 @@ void GPBClearMessageAutocreator(GPBMessage *self) {
|
|||
self->autocreatorExtension_ = nil;
|
||||
}
|
||||
|
||||
// Call this before using the readOnlySemaphore_. This ensures it is created only once.
|
||||
void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
// Create the semaphore on demand (rather than init) as developers might not cause them
|
||||
// to be needed, and the heap usage can add up. The atomic swap is used to avoid needing
|
||||
// another lock around creating it.
|
||||
if (self->readOnlySemaphore_ == nil) {
|
||||
dispatch_semaphore_t worker = dispatch_semaphore_create(1);
|
||||
if (!OSAtomicCompareAndSwapPtrBarrier(NULL, worker, (void * volatile *)&(self->readOnlySemaphore_))) {
|
||||
dispatch_release(worker);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
|
||||
if (!self->unknownFields_) {
|
||||
self->unknownFields_ = [[GPBUnknownFieldSet alloc] init];
|
||||
|
@ -1023,9 +1042,11 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
|
|||
if (arrayOrMap) {
|
||||
if (field.fieldType == GPBFieldTypeRepeated) {
|
||||
if (GPBFieldDataTypeIsObject(field)) {
|
||||
GPBAutocreatedArray *autoArray = arrayOrMap;
|
||||
if (autoArray->_autocreator == self) {
|
||||
autoArray->_autocreator = nil;
|
||||
if ([arrayOrMap isKindOfClass:[GPBAutocreatedArray class]]) {
|
||||
GPBAutocreatedArray *autoArray = arrayOrMap;
|
||||
if (autoArray->_autocreator == self) {
|
||||
autoArray->_autocreator = nil;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Type doesn't matter, it is a GPB*Array.
|
||||
|
@ -1037,9 +1058,11 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
|
|||
} else {
|
||||
if ((field.mapKeyDataType == GPBDataTypeString) &&
|
||||
GPBFieldDataTypeIsObject(field)) {
|
||||
GPBAutocreatedDictionary *autoDict = arrayOrMap;
|
||||
if (autoDict->_autocreator == self) {
|
||||
autoDict->_autocreator = nil;
|
||||
if ([arrayOrMap isKindOfClass:[GPBAutocreatedDictionary class]]) {
|
||||
GPBAutocreatedDictionary *autoDict = arrayOrMap;
|
||||
if (autoDict->_autocreator == self) {
|
||||
autoDict->_autocreator = nil;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Type doesn't matter, it is a GPB*Dictionary.
|
||||
|
@ -3148,8 +3171,17 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
|
|||
if (result.impToAdd) {
|
||||
const char *encoding =
|
||||
GPBMessageEncodingForSelector(result.encodingSelector, YES);
|
||||
BOOL methodAdded = class_addMethod(descriptor.messageClass, sel,
|
||||
result.impToAdd, encoding);
|
||||
Class msgClass = descriptor.messageClass;
|
||||
BOOL methodAdded = class_addMethod(msgClass, sel, result.impToAdd, encoding);
|
||||
// class_addMethod() is documented as also failing if the method was already
|
||||
// added; so we check if the method is already there and return success so
|
||||
// the method dispatch will still happen. Why would it already be added?
|
||||
// Two threads could cause the same method to be bound at the same time,
|
||||
// but only one will actually bind it; the other still needs to return true
|
||||
// so things will dispatch.
|
||||
if (!methodAdded) {
|
||||
methodAdded = GPBClassHasSel(msgClass, sel);
|
||||
}
|
||||
return methodAdded;
|
||||
}
|
||||
return [super resolveInstanceMethod:sel];
|
||||
|
|
|
@ -70,7 +70,6 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
|
|||
// Use of readOnlySemaphore_ must be prefaced by a call to
|
||||
// GPBPrepareReadOnlySemaphore to ensure it has been created. This allows
|
||||
// readOnlySemaphore_ to be only created when actually needed.
|
||||
dispatch_once_t readOnlySemaphoreCreationOnce_;
|
||||
dispatch_semaphore_t readOnlySemaphore_;
|
||||
}
|
||||
|
||||
|
@ -105,14 +104,7 @@ CF_EXTERN_C_BEGIN
|
|||
|
||||
|
||||
// Call this before using the readOnlySemaphore_. This ensures it is created only once.
|
||||
NS_INLINE void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
dispatch_once(&self->readOnlySemaphoreCreationOnce_, ^{
|
||||
self->readOnlySemaphore_ = dispatch_semaphore_create(1);
|
||||
});
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
void GPBPrepareReadOnlySemaphore(GPBMessage *self);
|
||||
|
||||
// Returns a new instance that was automatically created by |autocreator| for
|
||||
// its field |field|.
|
||||
|
|
|
@ -184,11 +184,10 @@ static id ExtensionForName(id self, SEL _cmd) {
|
|||
dispatch_semaphore_wait(gExtensionSingletonDictionarySemaphore,
|
||||
DISPATCH_TIME_FOREVER);
|
||||
id extension = (id)CFDictionaryGetValue(gExtensionSingletonDictionary, key);
|
||||
if (extension) {
|
||||
// The method is getting wired in to the class, so no need to keep it in
|
||||
// the dictionary.
|
||||
CFDictionaryRemoveValue(gExtensionSingletonDictionary, key);
|
||||
}
|
||||
// We can't remove the key from the dictionary here (as an optimization),
|
||||
// two threads could have gone into +resolveClassMethod: for the same method,
|
||||
// and ended up here; there's no way to ensure both return YES without letting
|
||||
// both try to wire in the method.
|
||||
dispatch_semaphore_signal(gExtensionSingletonDictionarySemaphore);
|
||||
return extension;
|
||||
}
|
||||
|
@ -212,9 +211,17 @@ BOOL GPBResolveExtensionClassMethod(Class self, SEL sel) {
|
|||
#pragma unused(obj)
|
||||
return extension;
|
||||
});
|
||||
if (class_addMethod(metaClass, sel, imp, encoding)) {
|
||||
return YES;
|
||||
BOOL methodAdded = class_addMethod(metaClass, sel, imp, encoding);
|
||||
// class_addMethod() is documented as also failing if the method was already
|
||||
// added; so we check if the method is already there and return success so
|
||||
// the method dispatch will still happen. Why would it already be added?
|
||||
// Two threads could cause the same method to be bound at the same time,
|
||||
// but only one will actually bind it; the other still needs to return true
|
||||
// so things will dispatch.
|
||||
if (!methodAdded) {
|
||||
methodAdded = GPBClassHasSel(metaClass, sel);
|
||||
}
|
||||
return methodAdded;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
|
|
@ -408,9 +408,11 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
|
|||
if (field.fieldType == GPBFieldTypeRepeated) {
|
||||
// If the old array was autocreated by us, then clear it.
|
||||
if (GPBDataTypeIsObject(fieldType)) {
|
||||
GPBAutocreatedArray *autoArray = oldValue;
|
||||
if (autoArray->_autocreator == self) {
|
||||
autoArray->_autocreator = nil;
|
||||
if ([oldValue isKindOfClass:[GPBAutocreatedArray class]]) {
|
||||
GPBAutocreatedArray *autoArray = oldValue;
|
||||
if (autoArray->_autocreator == self) {
|
||||
autoArray->_autocreator = nil;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Type doesn't matter, it is a GPB*Array.
|
||||
|
@ -423,9 +425,11 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
|
|||
// If the old map was autocreated by us, then clear it.
|
||||
if ((field.mapKeyDataType == GPBDataTypeString) &&
|
||||
GPBDataTypeIsObject(fieldType)) {
|
||||
GPBAutocreatedDictionary *autoDict = oldValue;
|
||||
if (autoDict->_autocreator == self) {
|
||||
autoDict->_autocreator = nil;
|
||||
if ([oldValue isKindOfClass:[GPBAutocreatedDictionary class]]) {
|
||||
GPBAutocreatedDictionary *autoDict = oldValue;
|
||||
if (autoDict->_autocreator == self) {
|
||||
autoDict->_autocreator = nil;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Type doesn't matter, it is a GPB*Dictionary.
|
||||
|
@ -1770,6 +1774,25 @@ NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
|
|||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
BOOL GPBClassHasSel(Class aClass, SEL sel) {
|
||||
// NOTE: We have to use class_copyMethodList, all other runtime method
|
||||
// lookups actually also resolve the method implementation and this
|
||||
// is called from within those methods.
|
||||
|
||||
BOOL result = NO;
|
||||
unsigned int methodCount = 0;
|
||||
Method *methodList = class_copyMethodList(aClass, &methodCount);
|
||||
for (unsigned int i = 0; i < methodCount; ++i) {
|
||||
SEL methodSelector = method_getName(methodList[i]);
|
||||
if (methodSelector == sel) {
|
||||
result = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(methodList);
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma mark - GPBMessageSignatureProtocol
|
||||
|
||||
// A series of selectors that are used solely to get @encoding values
|
||||
|
|
|
@ -345,4 +345,6 @@ GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Enum)
|
|||
+ (id)getClassValue;
|
||||
@end
|
||||
|
||||
BOOL GPBClassHasSel(Class aClass, SEL sel);
|
||||
|
||||
CF_EXTERN_C_END
|
||||
|
|
|
@ -112,16 +112,27 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
|
|||
* @note: Not all second/nanos combinations can be represented in a
|
||||
* NSTimeInterval, so getting this could be a lossy transform.
|
||||
**/
|
||||
@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970;
|
||||
@property(nonatomic, readwrite) NSTimeInterval timeInterval;
|
||||
|
||||
/**
|
||||
* Initializes a GPBDuration with the given NSTimeInterval.
|
||||
*
|
||||
* @param timeIntervalSince1970 Time interval to configure the GPBDuration with.
|
||||
* @param timeInterval Time interval to configure the GPBDuration with.
|
||||
*
|
||||
* @return A newly initialized GPBDuration.
|
||||
**/
|
||||
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970;
|
||||
- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval;
|
||||
|
||||
// These next two methods are deprecated because GBPDuration has no need of a
|
||||
// "base" time. The older methods were about symmetry with GBPTimestamp, but
|
||||
// the unix epoch usage is too confusing.
|
||||
|
||||
/** Deprecated, use timeInterval instead. */
|
||||
@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970
|
||||
__attribute__((deprecated("Use timeInterval")));
|
||||
/** Deprecated, use initWithTimeInterval: instead. */
|
||||
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970
|
||||
__attribute__((deprecated("Use initWithTimeInterval:")));
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -41,15 +41,25 @@ NSString *const GPBWellKnownTypesErrorDomain =
|
|||
|
||||
static NSString *kTypePrefixGoogleApisCom = @"type.googleapis.com/";
|
||||
|
||||
static NSTimeInterval TimeIntervalSince1970FromSecondsAndNanos(int64_t seconds,
|
||||
int32_t nanos) {
|
||||
static NSTimeInterval TimeIntervalFromSecondsAndNanos(int64_t seconds,
|
||||
int32_t nanos) {
|
||||
return seconds + (NSTimeInterval)nanos / 1e9;
|
||||
}
|
||||
|
||||
static int32_t SecondsAndNanosFromTimeIntervalSince1970(NSTimeInterval time,
|
||||
int64_t *outSeconds) {
|
||||
static int32_t SecondsAndNanosFromTimeInterval(NSTimeInterval time,
|
||||
int64_t *outSeconds,
|
||||
BOOL nanosMustBePositive) {
|
||||
NSTimeInterval seconds;
|
||||
NSTimeInterval nanos = modf(time, &seconds);
|
||||
|
||||
if (nanosMustBePositive && (nanos < 0)) {
|
||||
// Per Timestamp.proto, nanos is non-negative and "Negative second values with
|
||||
// fractions must still have non-negative nanos values that count forward in
|
||||
// time. Must be from 0 to 999,999,999 inclusive."
|
||||
--seconds;
|
||||
nanos = 1.0 + nanos;
|
||||
}
|
||||
|
||||
nanos *= 1e9;
|
||||
*outSeconds = (int64_t)seconds;
|
||||
return (int32_t)nanos;
|
||||
|
@ -88,8 +98,8 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
|
|||
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
|
||||
if ((self = [super init])) {
|
||||
int64_t seconds;
|
||||
int32_t nanos = SecondsAndNanosFromTimeIntervalSince1970(
|
||||
timeIntervalSince1970, &seconds);
|
||||
int32_t nanos = SecondsAndNanosFromTimeInterval(
|
||||
timeIntervalSince1970, &seconds, YES);
|
||||
self.seconds = seconds;
|
||||
self.nanos = nanos;
|
||||
}
|
||||
|
@ -105,13 +115,13 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
|
|||
}
|
||||
|
||||
- (NSTimeInterval)timeIntervalSince1970 {
|
||||
return TimeIntervalSince1970FromSecondsAndNanos(self.seconds, self.nanos);
|
||||
return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos);
|
||||
}
|
||||
|
||||
- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
|
||||
int64_t seconds;
|
||||
int32_t nanos =
|
||||
SecondsAndNanosFromTimeIntervalSince1970(timeIntervalSince1970, &seconds);
|
||||
SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES);
|
||||
self.seconds = seconds;
|
||||
self.nanos = nanos;
|
||||
}
|
||||
|
@ -122,27 +132,39 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
|
|||
|
||||
@implementation GPBDuration (GBPWellKnownTypes)
|
||||
|
||||
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
|
||||
- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval {
|
||||
if ((self = [super init])) {
|
||||
int64_t seconds;
|
||||
int32_t nanos = SecondsAndNanosFromTimeIntervalSince1970(
|
||||
timeIntervalSince1970, &seconds);
|
||||
int32_t nanos = SecondsAndNanosFromTimeInterval(
|
||||
timeInterval, &seconds, NO);
|
||||
self.seconds = seconds;
|
||||
self.nanos = nanos;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
|
||||
return [self initWithTimeInterval:timeIntervalSince1970];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)timeInterval {
|
||||
return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos);
|
||||
}
|
||||
|
||||
- (void)setTimeInterval:(NSTimeInterval)timeInterval {
|
||||
int64_t seconds;
|
||||
int32_t nanos =
|
||||
SecondsAndNanosFromTimeInterval(timeInterval, &seconds, NO);
|
||||
self.seconds = seconds;
|
||||
self.nanos = nanos;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)timeIntervalSince1970 {
|
||||
return TimeIntervalSince1970FromSecondsAndNanos(self.seconds, self.nanos);
|
||||
return self.timeInterval;
|
||||
}
|
||||
|
||||
- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
|
||||
int64_t seconds;
|
||||
int32_t nanos =
|
||||
SecondsAndNanosFromTimeIntervalSince1970(timeIntervalSince1970, &seconds);
|
||||
self.seconds = seconds;
|
||||
self.nanos = nanos;
|
||||
self.timeInterval = timeIntervalSince1970;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
F47476E51D21A524007C7B1A /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D41A92826400BC1EC6 /* Duration.pbobjc.m */; };
|
||||
F47476E61D21A524007C7B1A /* Timestamp.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D61A92826400BC1EC6 /* Timestamp.pbobjc.m */; };
|
||||
F4B51B1E1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B51B1D1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm */; };
|
||||
F4C4B9E41E1D976300D3B61D /* GPBDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */; };
|
||||
F4E675971B21D0000054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675871B21D0000054530B /* Any.pbobjc.m */; };
|
||||
F4E675991B21D0000054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675891B21D0000054530B /* Api.pbobjc.m */; };
|
||||
F4E6759B1B21D0000054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758B1B21D0000054530B /* Empty.pbobjc.m */; };
|
||||
|
@ -187,6 +188,7 @@
|
|||
F4B6B8B21A9CCBDA00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4B6B8B61A9CD1DE00892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
|
||||
F4B6B8B81A9CD1DE00892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
|
||||
F4CF31701B162ED800BD9B06 /* unittest_objc_startup.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc_startup.proto; sourceTree = "<group>"; };
|
||||
F4E675861B21D0000054530B /* Any.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Any.pbobjc.h; path = google/protobuf/Any.pbobjc.h; sourceTree = "<group>"; };
|
||||
F4E675871B21D0000054530B /* Any.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Any.pbobjc.m; path = google/protobuf/Any.pbobjc.m; sourceTree = "<group>"; };
|
||||
|
@ -393,6 +395,7 @@
|
|||
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
|
||||
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
|
||||
F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */,
|
||||
F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */,
|
||||
F4353D2C1AC06F10005A6198 /* GPBDictionaryTests.pddm */,
|
||||
F4353D2D1AC06F10005A6198 /* GPBDictionaryTests+Bool.m */,
|
||||
F4353D2E1AC06F10005A6198 /* GPBDictionaryTests+Int32.m */,
|
||||
|
@ -677,6 +680,7 @@
|
|||
F4353D371AC06F10005A6198 /* GPBDictionaryTests+String.m in Sources */,
|
||||
F4353D381AC06F10005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
|
||||
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */,
|
||||
F4C4B9E41E1D976300D3B61D /* GPBDictionaryTests.m in Sources */,
|
||||
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */,
|
||||
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */,
|
||||
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */,
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
F47476E91D21A537007C7B1A /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248DE1A929C7D00BC1EC6 /* Duration.pbobjc.m */; };
|
||||
F47476EA1D21A537007C7B1A /* Timestamp.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248E01A929C7D00BC1EC6 /* Timestamp.pbobjc.m */; };
|
||||
F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B51B1B1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm */; };
|
||||
F4C4B9E71E1D97BF00D3B61D /* GPBDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */; };
|
||||
F4E675D01B21D1620054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B71B21D1440054530B /* Any.pbobjc.m */; };
|
||||
F4E675D11B21D1620054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B91B21D1440054530B /* Api.pbobjc.m */; };
|
||||
F4E675D21B21D1620054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675BC1B21D1440054530B /* Empty.pbobjc.m */; };
|
||||
|
@ -209,6 +210,7 @@
|
|||
F4B6B8B11A9CCBBB00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4B6B8B31A9CD1C600892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
|
||||
F4B6B8B51A9CD1C600892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
|
||||
F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
|
||||
F4CF31711B162EF500BD9B06 /* unittest_objc_startup.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc_startup.proto; sourceTree = "<group>"; };
|
||||
F4E675B61B21D1440054530B /* Any.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Any.pbobjc.h; path = google/protobuf/Any.pbobjc.h; sourceTree = "<group>"; };
|
||||
F4E675B71B21D1440054530B /* Any.pbobjc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Any.pbobjc.m; path = google/protobuf/Any.pbobjc.m; sourceTree = "<group>"; };
|
||||
|
@ -431,6 +433,7 @@
|
|||
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
|
||||
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
|
||||
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */,
|
||||
F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */,
|
||||
F4353D3A1AC06F31005A6198 /* GPBDictionaryTests.pddm */,
|
||||
F4353D3B1AC06F31005A6198 /* GPBDictionaryTests+Bool.m */,
|
||||
F4353D3C1AC06F31005A6198 /* GPBDictionaryTests+Int32.m */,
|
||||
|
@ -773,6 +776,7 @@
|
|||
F4353D451AC06F31005A6198 /* GPBDictionaryTests+String.m in Sources */,
|
||||
F4353D461AC06F31005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
|
||||
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */,
|
||||
F4C4B9E71E1D97BF00D3B61D /* GPBDictionaryTests.m in Sources */,
|
||||
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */,
|
||||
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */,
|
||||
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */,
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "GPBArray.h"
|
||||
#import "GPBArray_PackagePrivate.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
|
@ -3436,3 +3437,175 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - GPBAutocreatedArray Tests
|
||||
|
||||
// These are hand written tests to double check some behaviors of the
|
||||
// GPBAutocreatedArray.
|
||||
|
||||
// NOTE: GPBAutocreatedArray is private to the library, users of the library
|
||||
// should never have to directly deal with this class.
|
||||
|
||||
@interface GPBAutocreatedArrayTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation GPBAutocreatedArrayTests
|
||||
|
||||
- (void)testEquality {
|
||||
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
|
||||
|
||||
XCTAssertTrue([array isEqual:@[]]);
|
||||
XCTAssertTrue([array isEqualToArray:@[]]);
|
||||
|
||||
XCTAssertFalse([array isEqual:@[ @"foo" ]]);
|
||||
XCTAssertFalse([array isEqualToArray:@[ @"foo" ]]);
|
||||
|
||||
[array addObject:@"foo"];
|
||||
|
||||
XCTAssertFalse([array isEqual:@[]]);
|
||||
XCTAssertFalse([array isEqualToArray:@[]]);
|
||||
XCTAssertTrue([array isEqual:@[ @"foo" ]]);
|
||||
XCTAssertTrue([array isEqualToArray:@[ @"foo" ]]);
|
||||
XCTAssertFalse([array isEqual:@[ @"bar" ]]);
|
||||
XCTAssertFalse([array isEqualToArray:@[ @"bar" ]]);
|
||||
|
||||
GPBAutocreatedArray *array2 = [[GPBAutocreatedArray alloc] init];
|
||||
|
||||
XCTAssertFalse([array isEqual:array2]);
|
||||
XCTAssertFalse([array isEqualToArray:array2]);
|
||||
|
||||
[array2 addObject:@"bar"];
|
||||
XCTAssertFalse([array isEqual:array2]);
|
||||
XCTAssertFalse([array isEqualToArray:array2]);
|
||||
|
||||
[array2 replaceObjectAtIndex:0 withObject:@"foo"];
|
||||
XCTAssertTrue([array isEqual:array2]);
|
||||
XCTAssertTrue([array isEqualToArray:array2]);
|
||||
|
||||
[array2 release];
|
||||
[array release];
|
||||
}
|
||||
|
||||
- (void)testCopy {
|
||||
{
|
||||
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
|
||||
|
||||
NSArray *cpy = [array copy];
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)0);
|
||||
|
||||
NSArray *cpy2 = [array copy];
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
// Can't compare cpy and cpy2 because NSArray has a singleton empty
|
||||
// array it uses, so the ptrs are the same.
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[array release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
|
||||
|
||||
NSMutableArray *cpy = [array mutableCopy];
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSMutableArray class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)0);
|
||||
|
||||
NSMutableArray *cpy2 = [array mutableCopy];
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSMutableArray class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[array release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
|
||||
[array addObject:@"foo"];
|
||||
[array addObject:@"bar"];
|
||||
|
||||
NSArray *cpy = [array copy];
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy[0], @"foo");
|
||||
XCTAssertEqualObjects(cpy[1], @"bar");
|
||||
|
||||
NSArray *cpy2 = [array copy];
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy2[0], @"foo");
|
||||
XCTAssertEqualObjects(cpy2[1], @"bar");
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[array release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
|
||||
[array addObject:@"foo"];
|
||||
[array addObject:@"bar"];
|
||||
|
||||
NSMutableArray *cpy = [array mutableCopy];
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy[0], @"foo");
|
||||
XCTAssertEqualObjects(cpy[1], @"bar");
|
||||
|
||||
NSMutableArray *cpy2 = [array mutableCopy];
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy2[0], @"foo");
|
||||
XCTAssertEqualObjects(cpy2[1], @"bar");
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[array release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testIndexedSubscriptSupport {
|
||||
// The base NSArray/NSMutableArray behaviors for *IndexedSubscript methods
|
||||
// should still work via the methods that one has to override to make an
|
||||
// NSMutableArray subclass. i.e. - this should "just work" and if these
|
||||
// crash/fail, then something is wrong in how NSMutableArray is subclassed.
|
||||
|
||||
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
|
||||
|
||||
[array addObject:@"foo"];
|
||||
[array addObject:@"bar"];
|
||||
XCTAssertEqual(array.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(array[0], @"foo");
|
||||
XCTAssertEqualObjects(array[1], @"bar");
|
||||
array[0] = @"foo2";
|
||||
array[2] = @"baz";
|
||||
XCTAssertEqual(array.count, (NSUInteger)3);
|
||||
XCTAssertEqualObjects(array[0], @"foo2");
|
||||
XCTAssertEqualObjects(array[1], @"bar");
|
||||
XCTAssertEqualObjects(array[2], @"baz");
|
||||
|
||||
[array release];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
186
objectivec/Tests/GPBDictionaryTests.m
Normal file
186
objectivec/Tests/GPBDictionaryTests.m
Normal file
|
@ -0,0 +1,186 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2017 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.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "GPBDictionary.h"
|
||||
#import "GPBDictionary_PackagePrivate.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#pragma mark - GPBAutocreatedDictionary Tests
|
||||
|
||||
// These are hand written tests to double check some behaviors of the
|
||||
// GPBAutocreatedDictionary. The GPBDictionary+[type]Tests files are generate
|
||||
// tests.
|
||||
|
||||
// NOTE: GPBAutocreatedDictionary is private to the library, users of the
|
||||
// library should never have to directly deal with this class.
|
||||
|
||||
@interface GPBAutocreatedDictionaryTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation GPBAutocreatedDictionaryTests
|
||||
|
||||
- (void)testEquality {
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
XCTAssertTrue([dict isEqual:@{}]);
|
||||
XCTAssertTrue([dict isEqualToDictionary:@{}]);
|
||||
|
||||
XCTAssertFalse([dict isEqual:@{ @"foo" : @"bar" }]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:@{ @"foo" : @"bar" }]);
|
||||
|
||||
[dict setObject:@"bar" forKey:@"foo"];
|
||||
|
||||
XCTAssertFalse([dict isEqual:@{}]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:@{}]);
|
||||
XCTAssertTrue([dict isEqual:@{ @"foo" : @"bar" }]);
|
||||
XCTAssertTrue([dict isEqualToDictionary:@{ @"foo" : @"bar" }]);
|
||||
XCTAssertFalse([dict isEqual:@{ @"bar" : @"baz" }]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:@{ @"bar" : @"baz" }]);
|
||||
|
||||
GPBAutocreatedDictionary *dict2 = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
XCTAssertFalse([dict isEqual:dict2]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:dict2]);
|
||||
|
||||
[dict2 setObject:@"mumble" forKey:@"foo"];
|
||||
XCTAssertFalse([dict isEqual:dict2]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:dict2]);
|
||||
|
||||
[dict2 setObject:@"bar" forKey:@"foo"];
|
||||
XCTAssertTrue([dict isEqual:dict2]);
|
||||
XCTAssertTrue([dict isEqualToDictionary:dict2]);
|
||||
|
||||
[dict2 release];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testCopy {
|
||||
{
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
NSDictionary *cpy = [dict copy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)0);
|
||||
|
||||
NSDictionary *cpy2 = [dict copy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
NSMutableDictionary *cpy = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)0);
|
||||
|
||||
NSMutableDictionary *cpy2 = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
dict[@"foo"] = @"bar";
|
||||
dict[@"baz"] = @"mumble";
|
||||
|
||||
NSDictionary *cpy = [dict copy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy[@"foo"], @"bar");
|
||||
XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
|
||||
|
||||
NSDictionary *cpy2 = [dict copy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
|
||||
XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
dict[@"foo"] = @"bar";
|
||||
dict[@"baz"] = @"mumble";
|
||||
|
||||
NSMutableDictionary *cpy = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy[@"foo"], @"bar");
|
||||
XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
|
||||
|
||||
NSMutableDictionary *cpy2 = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
|
||||
XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[dict release];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -948,15 +948,23 @@ static NSData *DataFromCStr(const char *str) {
|
|||
|
||||
- (void)testErrorRecursionDepthReached {
|
||||
NSData *data = DataFromCStr(
|
||||
"\x0A\x86\x01\x0A\x83\x01\x0A\x80\x01\x0A\x7E\x0A\x7C\x0A\x7A\x0A\x78"
|
||||
"\x0A\x76\x0A\x74\x0A\x72\x0A\x70\x0A\x6E\x0A\x6C\x0A\x6A\x0A\x68"
|
||||
"\x0A\x66\x0A\x64\x0A\x62\x0A\x60\x0A\x5E\x0A\x5C\x0A\x5A\x0A\x58"
|
||||
"\x0A\x56\x0A\x54\x0A\x52\x0A\x50\x0A\x4E\x0A\x4C\x0A\x4A\x0A\x48"
|
||||
"\x0A\x46\x0A\x44\x0A\x42\x0A\x40\x0A\x3E\x0A\x3C\x0A\x3A\x0A\x38"
|
||||
"\x0A\x36\x0A\x34\x0A\x32\x0A\x30\x0A\x2E\x0A\x2C\x0A\x2A\x0A\x28"
|
||||
"\x0A\x26\x0A\x24\x0A\x22\x0A\x20\x0A\x1E\x0A\x1C\x0A\x1A\x0A\x18"
|
||||
"\x0A\x16\x0A\x14\x0A\x12\x0A\x10\x0A\x0E\x0A\x0C\x0A\x0A\x0A\x08"
|
||||
"\x0A\x06\x12\x04\x72\x02\x4B\x50");
|
||||
"\x0A\xF2\x01\x0A\xEF\x01\x0A\xEC\x01\x0A\xE9\x01\x0A\xE6\x01"
|
||||
"\x0A\xE3\x01\x0A\xE0\x01\x0A\xDD\x01\x0A\xDA\x01\x0A\xD7\x01"
|
||||
"\x0A\xD4\x01\x0A\xD1\x01\x0A\xCE\x01\x0A\xCB\x01\x0A\xC8\x01"
|
||||
"\x0A\xC5\x01\x0A\xC2\x01\x0A\xBF\x01\x0A\xBC\x01\x0A\xB9\x01"
|
||||
"\x0A\xB6\x01\x0A\xB3\x01\x0A\xB0\x01\x0A\xAD\x01\x0A\xAA\x01"
|
||||
"\x0A\xA7\x01\x0A\xA4\x01\x0A\xA1\x01\x0A\x9E\x01\x0A\x9B\x01"
|
||||
"\x0A\x98\x01\x0A\x95\x01\x0A\x92\x01\x0A\x8F\x01\x0A\x8C\x01"
|
||||
"\x0A\x89\x01\x0A\x86\x01\x0A\x83\x01\x0A\x80\x01\x0A\x7E"
|
||||
"\x0A\x7C\x0A\x7A\x0A\x78\x0A\x76\x0A\x74\x0A\x72\x0A\x70"
|
||||
"\x0A\x6E\x0A\x6C\x0A\x6A\x0A\x68\x0A\x66\x0A\x64\x0A\x62"
|
||||
"\x0A\x60\x0A\x5E\x0A\x5C\x0A\x5A\x0A\x58\x0A\x56\x0A\x54"
|
||||
"\x0A\x52\x0A\x50\x0A\x4E\x0A\x4C\x0A\x4A\x0A\x48\x0A\x46"
|
||||
"\x0A\x44\x0A\x42\x0A\x40\x0A\x3E\x0A\x3C\x0A\x3A\x0A\x38"
|
||||
"\x0A\x36\x0A\x34\x0A\x32\x0A\x30\x0A\x2E\x0A\x2C\x0A\x2A"
|
||||
"\x0A\x28\x0A\x26\x0A\x24\x0A\x22\x0A\x20\x0A\x1E\x0A\x1C"
|
||||
"\x0A\x1A\x0A\x18\x0A\x16\x0A\x14\x0A\x12\x0A\x10\x0A\x0E"
|
||||
"\x0A\x0C\x0A\x0A\x0A\x08\x0A\x06\x12\x04\x72\x02\x4B\x50");
|
||||
NSError *error = nil;
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
|
||||
error:&error];
|
||||
|
|
|
@ -1082,6 +1082,20 @@
|
|||
[repeatedStringArray release];
|
||||
}
|
||||
|
||||
- (void)testSetOverAutocreatedArrayAndSetAgain {
|
||||
// Ensure when dealing with replacing an array it is handled being either
|
||||
// an autocreated one or a straight NSArray.
|
||||
|
||||
// The real test here is that nothing crashes while doing the work.
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
[message.repeatedStringArray addObject:@"foo"];
|
||||
XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
|
||||
message.repeatedStringArray = [NSMutableArray arrayWithObjects:@"bar", @"bar2", nil];
|
||||
XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)2);
|
||||
message.repeatedStringArray = [NSMutableArray arrayWithObject:@"baz"];
|
||||
XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
|
||||
}
|
||||
|
||||
- (void)testReplaceAutocreatedArray {
|
||||
// Replacing array should orphan the old one and cause its creator to become
|
||||
// visible.
|
||||
|
@ -1281,6 +1295,23 @@
|
|||
[strToStr release];
|
||||
}
|
||||
|
||||
- (void)testSetOverAutocreatedMapAndSetAgain {
|
||||
// Ensure when dealing with replacing a map it is handled being either
|
||||
// an autocreated one or a straight NSDictionary.
|
||||
|
||||
// The real test here is that nothing crashes while doing the work.
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
message.strToStr[@"foo"] = @"bar";
|
||||
XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
|
||||
message.strToStr =
|
||||
[NSMutableDictionary dictionaryWithObjectsAndKeys:@"bar", @"key1", @"baz", @"key2", nil];
|
||||
XCTAssertEqual(message.strToStr_Count, (NSUInteger)2);
|
||||
message.strToStr =
|
||||
[NSMutableDictionary dictionaryWithObject:@"baz" forKey:@"mumble"];
|
||||
XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
|
||||
}
|
||||
|
||||
- (void)testReplaceAutocreatedMap {
|
||||
// Replacing map should orphan the old one and cause its creator to become
|
||||
// visible.
|
||||
|
|
|
@ -32,11 +32,9 @@
|
|||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "google/protobuf/AnyTest.pbobjc.h"
|
||||
|
||||
// A basically random interval into the future for testing with.
|
||||
static const NSTimeInterval kFutureOffsetInterval = 15000;
|
||||
|
||||
// Nanosecond time accuracy
|
||||
static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
|
||||
|
@ -46,59 +44,117 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
|
|||
@implementation WellKnownTypesTest
|
||||
|
||||
- (void)testTimeStamp {
|
||||
// Test Creation.
|
||||
NSDate *date = [NSDate date];
|
||||
GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
|
||||
NSDate *timeStampDate = timeStamp.date;
|
||||
// Test negative and positive values.
|
||||
NSTimeInterval values[] = {
|
||||
-428027599.483999967, -1234567.0, -0.5, 0, 0.75, 54321.0, 2468086,483999967
|
||||
};
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
|
||||
NSTimeInterval value = values[i];
|
||||
|
||||
// Comparing timeIntervals instead of directly comparing dates because date
|
||||
// equality requires the time intervals to be exactly the same, and the
|
||||
// timeintervals go through a bit of floating point error as they are
|
||||
// converted back and forth from the internal representation.
|
||||
XCTAssertEqualWithAccuracy(date.timeIntervalSince1970,
|
||||
timeStampDate.timeIntervalSince1970,
|
||||
kTimeAccuracy);
|
||||
// Test Creation - date.
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSince1970:value];
|
||||
GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
|
||||
|
||||
NSTimeInterval time = [date timeIntervalSince1970];
|
||||
GPBTimestamp *timeStamp2 =
|
||||
[[GPBTimestamp alloc] initWithTimeIntervalSince1970:time];
|
||||
NSTimeInterval durationTime = timeStamp2.timeIntervalSince1970;
|
||||
XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
|
||||
[timeStamp release];
|
||||
XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
XCTAssertLessThan(timeStamp.nanos, 1e9,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
// Test Mutation.
|
||||
date = [NSDate dateWithTimeIntervalSinceNow:kFutureOffsetInterval];
|
||||
timeStamp2.date = date;
|
||||
timeStampDate = timeStamp2.date;
|
||||
XCTAssertEqualWithAccuracy(date.timeIntervalSince1970,
|
||||
timeStampDate.timeIntervalSince1970,
|
||||
kTimeAccuracy);
|
||||
// Comparing timeIntervals instead of directly comparing dates because date
|
||||
// equality requires the time intervals to be exactly the same, and the
|
||||
// timeintervals go through a bit of floating point error as they are
|
||||
// converted back and forth from the internal representation.
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
|
||||
kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
[timeStamp release];
|
||||
|
||||
time = date.timeIntervalSince1970;
|
||||
timeStamp2.timeIntervalSince1970 = time;
|
||||
durationTime = timeStamp2.timeIntervalSince1970;
|
||||
XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
|
||||
[timeStamp2 release];
|
||||
// Test Creation - timeIntervalSince1970.
|
||||
timeStamp = [[GPBTimestamp alloc] initWithTimeIntervalSince1970:value];
|
||||
|
||||
XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
XCTAssertLessThan(timeStamp.nanos, 1e9,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.timeIntervalSince1970,
|
||||
kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
[timeStamp release];
|
||||
|
||||
// Test Mutation - date.
|
||||
timeStamp = [[GPBTimestamp alloc] init];
|
||||
timeStamp.date = date;
|
||||
|
||||
XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
XCTAssertLessThan(timeStamp.nanos, 1e9,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
|
||||
kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
[timeStamp release];
|
||||
|
||||
// Test Mutation - timeIntervalSince1970.
|
||||
timeStamp = [[GPBTimestamp alloc] init];
|
||||
timeStamp.timeIntervalSince1970 = value;
|
||||
|
||||
XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
XCTAssertLessThan(timeStamp.nanos, 1e9,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
|
||||
kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
[timeStamp release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testDuration {
|
||||
// Test Creation.
|
||||
NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
|
||||
GPBDuration *duration =
|
||||
[[GPBDuration alloc] initWithTimeIntervalSince1970:time];
|
||||
NSTimeInterval durationTime = duration.timeIntervalSince1970;
|
||||
XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
|
||||
[duration release];
|
||||
// Test negative and positive values.
|
||||
NSTimeInterval values[] = { -1000.0001, -500.0, -0.5, 0, 0.75, 1000.0, 2000.0002 };
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
|
||||
NSTimeInterval value = values[i];
|
||||
|
||||
// Test Mutation.
|
||||
GPBDuration *duration2 =
|
||||
[[GPBDuration alloc] initWithTimeIntervalSince1970:time];
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:kFutureOffsetInterval];
|
||||
time = date.timeIntervalSince1970;
|
||||
duration2.timeIntervalSince1970 = time;
|
||||
durationTime = duration2.timeIntervalSince1970;
|
||||
XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
|
||||
[duration2 release];
|
||||
// Test Creation.
|
||||
GPBDuration *duration =
|
||||
[[GPBDuration alloc] initWithTimeInterval:value];
|
||||
XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy,
|
||||
@"For interval %f", (double)value);
|
||||
if (value > 0) {
|
||||
XCTAssertGreaterThanOrEqual(duration.seconds, 0,
|
||||
@"For interval %f", (double)value);
|
||||
XCTAssertGreaterThanOrEqual(duration.nanos, 0,
|
||||
@"For interval %f", (double)value);
|
||||
} else {
|
||||
XCTAssertLessThanOrEqual(duration.seconds, 0,
|
||||
@"For interval %f", (double)value);
|
||||
XCTAssertLessThanOrEqual(duration.nanos, 0,
|
||||
@"For interval %f", (double)value);
|
||||
}
|
||||
[duration release];
|
||||
|
||||
// Test Mutation.
|
||||
duration = [[GPBDuration alloc] init];
|
||||
duration.timeInterval = value;
|
||||
XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy,
|
||||
@"For interval %f", (double)value);
|
||||
if (value > 0) {
|
||||
XCTAssertGreaterThanOrEqual(duration.seconds, 0,
|
||||
@"For interval %f", (double)value);
|
||||
XCTAssertGreaterThanOrEqual(duration.nanos, 0,
|
||||
@"For interval %f", (double)value);
|
||||
} else {
|
||||
XCTAssertLessThanOrEqual(duration.seconds, 0,
|
||||
@"For interval %f", (double)value);
|
||||
XCTAssertLessThanOrEqual(duration.nanos, 0,
|
||||
@"For interval %f", (double)value);
|
||||
}
|
||||
[duration release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testAnyHelpers {
|
||||
|
|
|
@ -411,10 +411,20 @@ typedef GPB_ENUM(GPBOption_FieldNumber) {
|
|||
**/
|
||||
@interface GPBOption : GPBMessage
|
||||
|
||||
/** The option's name. For example, `"java_package"`. */
|
||||
/**
|
||||
* The option's name. For protobuf built-in options (options defined in
|
||||
* descriptor.proto), this is the short name. For example, `"map_entry"`.
|
||||
* For custom options, it should be the fully-qualified name. For example,
|
||||
* `"google.api.http"`.
|
||||
**/
|
||||
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
|
||||
|
||||
/** The option's value. For example, `"com.google.protobuf"`. */
|
||||
/**
|
||||
* The option's value packed in an Any message. If the value is a primitive,
|
||||
* the corresponding wrapper type defined in google/protobuf/wrappers.proto
|
||||
* should be used. If the value is an enum, it should be stored as an int32
|
||||
* value using the google.protobuf.Int32Value type.
|
||||
**/
|
||||
@property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
|
||||
/** Test to see if @c value has been set. */
|
||||
@property(nonatomic, readwrite) BOOL hasValue;
|
||||
|
|
|
@ -80,8 +80,6 @@ protoc --php_out=out_dir test.proto
|
|||
|
||||
## Usage
|
||||
|
||||
For general guide:
|
||||
https://developers.google.com/protocol-buffers/phptutorial/
|
||||
For generated code:
|
||||
https://developers.google.com/protocol-buffers/docs/reference/php-generated
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
<email>protobuf-opensource@google.com</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2016-09-23</date>
|
||||
<date>2017-01-13</date>
|
||||
<time>16:06:07</time>
|
||||
<version>
|
||||
<release>3.1.0a1</release>
|
||||
<api>3.1.0a1</api>
|
||||
<release>3.2.0a1</release>
|
||||
<api>3.2.0a1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>alpha</release>
|
||||
|
@ -22,7 +22,7 @@
|
|||
</stability>
|
||||
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
|
||||
<notes>
|
||||
First alpha release.
|
||||
Second alpha release.
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="/" name="/">
|
||||
|
@ -71,5 +71,21 @@ First alpha release.
|
|||
First alpha release
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>3.2.0a1</release>
|
||||
<api>3.2.0a1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>alpha</release>
|
||||
<api>alpha</api>
|
||||
</stability>
|
||||
<date>2017-01-13</date>
|
||||
<time>16:06:07</time>
|
||||
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
|
||||
<notes>
|
||||
Second alpha release.
|
||||
</notes>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "upb.h"
|
||||
|
||||
#define PHP_PROTOBUF_EXTNAME "protobuf"
|
||||
#define PHP_PROTOBUF_VERSION "3.1.0a1"
|
||||
#define PHP_PROTOBUF_VERSION "3.2.0a1"
|
||||
|
||||
#define MAX_LENGTH_OF_INT64 20
|
||||
#define SIZEOF_INT64 8
|
||||
|
|
|
@ -9728,7 +9728,7 @@ static size_t encode_strbuf(void *c, const void *hd, const char *buf,
|
|||
T(double, double, dbl2uint64, encode_fixed64)
|
||||
T(float, float, flt2uint32, encode_fixed32)
|
||||
T(int64, int64_t, uint64_t, encode_varint)
|
||||
T(int32, int32_t, uint32_t, encode_varint)
|
||||
T(int32, int32_t, int64_t, encode_varint)
|
||||
T(fixed64, uint64_t, uint64_t, encode_fixed64)
|
||||
T(fixed32, uint32_t, uint32_t, encode_fixed32)
|
||||
T(bool, bool, bool, encode_varint)
|
||||
|
|
|
@ -43,8 +43,15 @@ class GPBUtil
|
|||
if ($isNeg) {
|
||||
$value = bcsub(0, $value);
|
||||
}
|
||||
|
||||
$high = (int) bcdiv(bcadd($value, 1), 4294967296);
|
||||
$low = (int) bcmod($value, 4294967296);
|
||||
$low = bcmod($value, 4294967296);
|
||||
if (bccomp($low, 2147483647) > 0) {
|
||||
$low = (int) bcsub($low, 4294967296);
|
||||
} else {
|
||||
$low = (int) $low;
|
||||
}
|
||||
|
||||
if ($isNeg) {
|
||||
$high = ~$high;
|
||||
$low = ~$low;
|
||||
|
|
|
@ -403,10 +403,14 @@ class GPBWire
|
|||
return self::varint32Size($tag);
|
||||
}
|
||||
|
||||
public static function varint32Size($value)
|
||||
public static function varint32Size($value, $sign_extended = false)
|
||||
{
|
||||
if ($value < 0) {
|
||||
return 5;
|
||||
if ($sign_extended) {
|
||||
return 10;
|
||||
} else {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
if ($value < (1 << 7)) {
|
||||
return 1;
|
||||
|
@ -437,34 +441,65 @@ class GPBWire
|
|||
|
||||
public static function varint64Size($value)
|
||||
{
|
||||
if ($value < 0) {
|
||||
return 10;
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
if (bccomp($value, 0) < 0) {
|
||||
return 10;
|
||||
}
|
||||
if (bccomp($value, 1 << 7) < 0) {
|
||||
return 1;
|
||||
}
|
||||
if (bccomp($value, 1 << 14) < 0) {
|
||||
return 2;
|
||||
}
|
||||
if (bccomp($value, 1 << 21) < 0) {
|
||||
return 3;
|
||||
}
|
||||
if (bccomp($value, 1 << 28) < 0) {
|
||||
return 4;
|
||||
}
|
||||
if (bccomp($value, '34359738368') < 0) {
|
||||
return 5;
|
||||
}
|
||||
if (bccomp($value, '4398046511104') < 0) {
|
||||
return 6;
|
||||
}
|
||||
if (bccomp($value, '562949953421312') < 0) {
|
||||
return 7;
|
||||
}
|
||||
if (bccomp($value, '72057594037927936') < 0) {
|
||||
return 8;
|
||||
}
|
||||
return 9;
|
||||
} else {
|
||||
if ($value < 0) {
|
||||
return 10;
|
||||
}
|
||||
if ($value < (1 << 7)) {
|
||||
return 1;
|
||||
}
|
||||
if ($value < (1 << 14)) {
|
||||
return 2;
|
||||
}
|
||||
if ($value < (1 << 21)) {
|
||||
return 3;
|
||||
}
|
||||
if ($value < (1 << 28)) {
|
||||
return 4;
|
||||
}
|
||||
if ($value < (1 << 35)) {
|
||||
return 5;
|
||||
}
|
||||
if ($value < (1 << 42)) {
|
||||
return 6;
|
||||
}
|
||||
if ($value < (1 << 49)) {
|
||||
return 7;
|
||||
}
|
||||
if ($value < (1 << 56)) {
|
||||
return 8;
|
||||
}
|
||||
return 9;
|
||||
}
|
||||
if ($value < (1 << 7)) {
|
||||
return 1;
|
||||
}
|
||||
if ($value < (1 << 14)) {
|
||||
return 2;
|
||||
}
|
||||
if ($value < (1 << 21)) {
|
||||
return 3;
|
||||
}
|
||||
if ($value < (1 << 28)) {
|
||||
return 4;
|
||||
}
|
||||
if ($value < (1 << 35)) {
|
||||
return 5;
|
||||
}
|
||||
if ($value < (1 << 42)) {
|
||||
return 6;
|
||||
}
|
||||
if ($value < (1 << 49)) {
|
||||
return 7;
|
||||
}
|
||||
if ($value < (1 << 56)) {
|
||||
return 8;
|
||||
}
|
||||
return 9;
|
||||
}
|
||||
|
||||
public static function serializeFieldToStream(
|
||||
|
|
|
@ -46,6 +46,9 @@ function combineInt32ToInt64($high, $low)
|
|||
}
|
||||
}
|
||||
$result = bcadd(bcmul($high, 4294967296), $low);
|
||||
if ($low < 0) {
|
||||
$result = bcadd($result, 4294967296);
|
||||
}
|
||||
if ($isNeg) {
|
||||
$result = bcsub(0, $result);
|
||||
}
|
||||
|
@ -67,7 +70,6 @@ class InputStream
|
|||
private $total_bytes_read;
|
||||
|
||||
const MAX_VARINT_BYTES = 10;
|
||||
const MAX_VARINT32_BYTES = 5;
|
||||
const DEFAULT_RECURSION_LIMIT = 100;
|
||||
const DEFAULT_TOTAL_BYTES_LIMIT = 33554432; // 32 << 20, 32MB
|
||||
|
||||
|
@ -160,40 +162,59 @@ class InputStream
|
|||
*/
|
||||
public function readVarint64(&$var)
|
||||
{
|
||||
$high = 0;
|
||||
$low = 0;
|
||||
$count = 0;
|
||||
$b = 0;
|
||||
|
||||
do {
|
||||
if ($this->current === $this->buffer_end) {
|
||||
return false;
|
||||
}
|
||||
if ($count === self::MAX_VARINT_BYTES) {
|
||||
return false;
|
||||
}
|
||||
$b = ord($this->buffer[$this->current]);
|
||||
$bits = 7 * $count;
|
||||
if ($bits >= 32) {
|
||||
$high |= (($b & 0x7F) << ($bits - 32));
|
||||
} else if ($bits > 25){
|
||||
$high_bits = $bits - 25;
|
||||
$low = ($low | (($b & 0x7F) << $bits)) & (int) 0xFFFFFFFF;
|
||||
$high = $b & ((0x1 << $high_bits) -1);
|
||||
} else {
|
||||
$low |= (($b & 0x7F) << $bits);
|
||||
}
|
||||
|
||||
$this->advance(1);
|
||||
$count += 1;
|
||||
} while ($b & 0x80);
|
||||
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
$high = 0;
|
||||
$low = 0;
|
||||
$b = 0;
|
||||
|
||||
do {
|
||||
if ($this->current === $this->buffer_end) {
|
||||
return false;
|
||||
}
|
||||
if ($count === self::MAX_VARINT_BYTES) {
|
||||
return false;
|
||||
}
|
||||
$b = ord($this->buffer[$this->current]);
|
||||
$bits = 7 * $count;
|
||||
if ($bits >= 32) {
|
||||
$high |= (($b & 0x7F) << ($bits - 32));
|
||||
} else if ($bits > 25){
|
||||
// $bits is 28 in this case.
|
||||
$low |= (($b & 0x7F) << 28);
|
||||
$high = ($b & 0x7F) >> 4;
|
||||
} else {
|
||||
$low |= (($b & 0x7F) << $bits);
|
||||
}
|
||||
|
||||
$this->advance(1);
|
||||
$count += 1;
|
||||
} while ($b & 0x80);
|
||||
|
||||
$var = combineInt32ToInt64($high, $low);
|
||||
} else {
|
||||
$var = ($high & 0xFFFFFFFF) << 32 |
|
||||
($low & 0xFFFFFFFF);
|
||||
$result = 0;
|
||||
$shift = 0;
|
||||
|
||||
do {
|
||||
if ($this->current === $this->buffer_end) {
|
||||
return false;
|
||||
}
|
||||
if ($count === self::MAX_VARINT_BYTES) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$byte = ord($this->buffer[$this->current]);
|
||||
$result |= ($byte & 0x7f) << $shift;
|
||||
$shift += 7;
|
||||
$this->advance(1);
|
||||
$count += 1;
|
||||
} while ($byte > 0x7f);
|
||||
|
||||
$var = $result;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,17 +175,22 @@ class Message
|
|||
case GPBType::FLOAT:
|
||||
return 0.0;
|
||||
case GPBType::UINT32:
|
||||
case GPBType::UINT64:
|
||||
case GPBType::INT32:
|
||||
case GPBType::INT64:
|
||||
case GPBType::FIXED32:
|
||||
case GPBType::FIXED64:
|
||||
case GPBType::SFIXED32:
|
||||
case GPBType::SFIXED64:
|
||||
case GPBType::SINT32:
|
||||
case GPBType::SINT64:
|
||||
case GPBType::ENUM:
|
||||
return 0;
|
||||
case GPBType::INT64:
|
||||
case GPBType::UINT64:
|
||||
case GPBType::FIXED64:
|
||||
case GPBType::SFIXED64:
|
||||
case GPBType::SINT64:
|
||||
if (PHP_INT_SIZE === 4) {
|
||||
return '0';
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
case GPBType::BOOL:
|
||||
return false;
|
||||
case GPBType::STRING:
|
||||
|
@ -395,6 +400,11 @@ class Message
|
|||
$number = GPBWire::getTagFieldNumber($tag);
|
||||
$field = $this->desc->getFieldByNumber($number);
|
||||
|
||||
// Check whether we retrieved a known field
|
||||
if ($field === NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$this->parseFieldFromStream($tag, $input, $field)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -572,9 +582,11 @@ class Message
|
|||
case GPBType::SFIXED64:
|
||||
$size += 8;
|
||||
break;
|
||||
case GPBType::UINT32:
|
||||
case GPBType::INT32:
|
||||
case GPBType::ENUM:
|
||||
$size += GPBWire::varint32Size($value, true);
|
||||
break;
|
||||
case GPBType::UINT32:
|
||||
$size += GPBWire::varint32Size($value);
|
||||
break;
|
||||
case GPBType::UINT64:
|
||||
|
|
|
@ -39,7 +39,6 @@ class OutputStream
|
|||
private $buffer_size;
|
||||
private $current;
|
||||
|
||||
const MAX_VARINT32_BYTES = 5;
|
||||
const MAX_VARINT64_BYTES = 10;
|
||||
|
||||
public function __construct($size)
|
||||
|
@ -56,8 +55,8 @@ class OutputStream
|
|||
|
||||
public function writeVarint32($value)
|
||||
{
|
||||
$bytes = str_repeat(chr(0), self::MAX_VARINT32_BYTES);
|
||||
$size = self::writeVarintToArray($value, $bytes, true);
|
||||
$bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES);
|
||||
$size = self::writeVarintToArray($value, $bytes);
|
||||
return $this->writeRaw($bytes, $size);
|
||||
}
|
||||
|
||||
|
@ -102,20 +101,16 @@ class OutputStream
|
|||
return true;
|
||||
}
|
||||
|
||||
private static function writeVarintToArray($value, &$buffer, $trim = false)
|
||||
private static function writeVarintToArray($value, &$buffer)
|
||||
{
|
||||
$current = 0;
|
||||
|
||||
$high = 0;
|
||||
$low = 0;
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
GPBUtil::divideInt64ToInt32($value, $high, $low, $trim);
|
||||
GPBUtil::divideInt64ToInt32($value, $high, $low);
|
||||
} else {
|
||||
if ($trim) {
|
||||
$low = $value & 0xFFFFFFFF;
|
||||
} else {
|
||||
$low = $value;
|
||||
}
|
||||
$low = $value;
|
||||
}
|
||||
|
||||
while ($low >= 0x80 || $low < 0) {
|
||||
|
|
|
@ -155,7 +155,11 @@ class Descriptor
|
|||
|
||||
public function getFieldByNumber($number)
|
||||
{
|
||||
if (!isset($this->field[$number])) {
|
||||
return NULL;
|
||||
} else {
|
||||
return $this->field[$number];
|
||||
}
|
||||
}
|
||||
|
||||
public function setClass($klass)
|
||||
|
|
|
@ -22,7 +22,8 @@ class EncodeDecodeTest extends TestBase
|
|||
$this->expectFields($from);
|
||||
|
||||
$data = $from->encode();
|
||||
$this->assertSame(TestUtil::getGoldenTestMessage(), $data);
|
||||
$this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()),
|
||||
bin2hex($data));
|
||||
}
|
||||
|
||||
public function testDecode()
|
||||
|
@ -132,4 +133,66 @@ class EncodeDecodeTest extends TestBase
|
|||
$to->decode(TestUtil::getGoldenTestUnpackedMessage());
|
||||
TestUtil::assertTestPackedMessage($to);
|
||||
}
|
||||
|
||||
public function testDecodeInt64()
|
||||
{
|
||||
// Read 64 testing
|
||||
$testVals = array(
|
||||
'10' => '100a',
|
||||
'100' => '1064',
|
||||
'800' => '10a006',
|
||||
'6400' => '108032',
|
||||
'70400' => '1080a604',
|
||||
'774400' => '1080a22f',
|
||||
'9292800' => '108098b704',
|
||||
'74342400' => '1080c0b923',
|
||||
'743424000' => '108080bfe202',
|
||||
'8177664000' => '108080b5bb1e',
|
||||
'65421312000' => '108080a8dbf301',
|
||||
'785055744000' => '108080e0c7ec16',
|
||||
'9420668928000' => '10808080dd969202',
|
||||
'103627358208000' => '10808080fff9c717',
|
||||
'1139900940288000' => '10808080f5bd978302',
|
||||
'13678811283456000' => '10808080fce699a618',
|
||||
'109430490267648000' => '10808080e0b7ceb1c201',
|
||||
'984874412408832000' => '10808080e0f5c1bed50d',
|
||||
);
|
||||
|
||||
$msg = new TestMessage();
|
||||
foreach ($testVals as $original => $encoded) {
|
||||
$msg->setOptionalInt64($original);
|
||||
$data = $msg->encode();
|
||||
$this->assertSame($encoded, bin2hex($data));
|
||||
$msg->setOptionalInt64(0);
|
||||
$msg->decode($data);
|
||||
$this->assertEquals($original, $msg->getOptionalInt64());
|
||||
}
|
||||
}
|
||||
|
||||
public function testDecodeFieldNonExist() {
|
||||
$data = hex2bin('c80501');
|
||||
$m = new TestMessage();
|
||||
$m->decode($data);
|
||||
}
|
||||
|
||||
public function testEncodeNegativeInt32()
|
||||
{
|
||||
$m = new TestMessage();
|
||||
$m->setOptionalInt32(-1);
|
||||
$data = $m->encode();
|
||||
$this->assertSame("08ffffffffffffffffff01", bin2hex($data));
|
||||
}
|
||||
|
||||
public function testDecodeNegativeInt32()
|
||||
{
|
||||
$m = new TestMessage();
|
||||
$this->assertEquals(0, $m->getOptionalInt32());
|
||||
$m->decode(hex2bin("08ffffffffffffffffff01"));
|
||||
$this->assertEquals(-1, $m->getOptionalInt32());
|
||||
|
||||
$m = new TestMessage();
|
||||
$this->assertEquals(0, $m->getOptionalInt32());
|
||||
$m->decode(hex2bin("08ffffffff0f"));
|
||||
$this->assertEquals(-1, $m->getOptionalInt32());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once('generated/NoNameSpace.php');
|
||||
require_once('generated/NoNameSpaceEnum.php');
|
||||
require_once('generated/NoNameSpaceMessage.php');
|
||||
require_once('test_util.php');
|
||||
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
|
@ -601,10 +602,14 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
#########################################################
|
||||
# Test oneof field.
|
||||
# Test message/enum without namespace.
|
||||
#########################################################
|
||||
|
||||
public function testMessageWithoutNamespace() {
|
||||
$m = new NoNameSpace();
|
||||
$m = new NoNameSpaceMessage();
|
||||
}
|
||||
|
||||
public function testEnumWithoutNamespace() {
|
||||
$m = new NoNameSpaceEnum();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -366,6 +366,34 @@ class ImplementationTest extends TestBase
|
|||
$this->assertSame(32768, $var);
|
||||
}
|
||||
$this->assertFalse($input->readVarint64($var));
|
||||
|
||||
// Read 64 testing
|
||||
$testVals = array(
|
||||
'10' => '0a000000000000000000',
|
||||
'100' => '64000000000000000000',
|
||||
'800' => 'a0060000000000000000',
|
||||
'6400' => '80320000000000000000',
|
||||
'70400' => '80a60400000000000000',
|
||||
'774400' => '80a22f00000000000000',
|
||||
'9292800' => '8098b704000000000000',
|
||||
'74342400' => '80c0b923000000000000',
|
||||
'743424000' => '8080bfe2020000000000',
|
||||
'8177664000' => '8080b5bb1e0000000000',
|
||||
'65421312000' => '8080a8dbf30100000000',
|
||||
'785055744000' => '8080e0c7ec1600000000',
|
||||
'9420668928000' => '808080dd969202000000',
|
||||
'103627358208000' => '808080fff9c717000000',
|
||||
'1139900940288000' => '808080f5bd9783020000',
|
||||
'13678811283456000' => '808080fce699a6180000',
|
||||
'109430490267648000' => '808080e0b7ceb1c20100',
|
||||
'984874412408832000' => '808080e0f5c1bed50d00',
|
||||
);
|
||||
|
||||
foreach ($testVals as $original => $encoded) {
|
||||
$input = new InputStream(hex2bin($encoded));
|
||||
$this->assertTrue($input->readVarint64($var));
|
||||
$this->assertEquals($original, $var);
|
||||
}
|
||||
}
|
||||
|
||||
public function testReadVarint32()
|
||||
|
@ -441,6 +469,11 @@ class ImplementationTest extends TestBase
|
|||
$output = new OutputStream(3);
|
||||
$output->writeVarint32(16384);
|
||||
$this->assertSame(hex2bin('808001'), $output->getData());
|
||||
|
||||
// Negative numbers are padded to be compatible with int64.
|
||||
$output = new OutputStream(10);
|
||||
$output->writeVarint32(-43);
|
||||
$this->assertSame(hex2bin('D5FFFFFFFFFFFFFFFF01'), $output->getData());
|
||||
}
|
||||
|
||||
public function testWriteVarint64()
|
||||
|
@ -468,13 +501,13 @@ class ImplementationTest extends TestBase
|
|||
{
|
||||
$m = new TestMessage();
|
||||
TestUtil::setTestMessage($m);
|
||||
$this->assertSame(447, $m->byteSize());
|
||||
$this->assertSame(472, $m->byteSize());
|
||||
}
|
||||
|
||||
public function testPackedByteSize()
|
||||
{
|
||||
$m = new TestPackedMessage();
|
||||
TestUtil::setTestPackedMessage($m);
|
||||
$this->assertSame(156, $m->byteSize());
|
||||
$this->assertSame(166, $m->byteSize());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,8 @@ message TestMessage {
|
|||
int32 a = 1;
|
||||
}
|
||||
|
||||
// NestedMessage nested_message = 90;
|
||||
// Reserved for non-existing field test.
|
||||
// int32 non_exist = 89;
|
||||
}
|
||||
|
||||
enum TestEnum {
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message NoNameSpace {
|
||||
message NoNameSpaceMessage {
|
||||
int32 a = 1;
|
||||
}
|
||||
|
||||
enum NoNameSpaceEnum {
|
||||
VALUE_A = 0;
|
||||
VALUE_B = 1;
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ class TestUtil
|
|||
public static function getGoldenTestMessage()
|
||||
{
|
||||
return hex2bin(
|
||||
"08D6FFFFFF0F" .
|
||||
"08D6FFFFFFFFFFFFFFFF01" .
|
||||
"10D5FFFFFFFFFFFFFFFF01" .
|
||||
"182A" .
|
||||
"202B" .
|
||||
|
@ -253,8 +253,8 @@ class TestUtil
|
|||
"800101" .
|
||||
"8A01020821" .
|
||||
|
||||
"F801D6FFFFFF0F" .
|
||||
"F801CCFFFFFF0F" .
|
||||
"F801D6FFFFFFFFFFFFFFFF01" .
|
||||
"F801CCFFFFFFFFFFFFFFFF01" .
|
||||
"8002D5FFFFFFFFFFFFFFFF01" .
|
||||
"8002CBFFFFFFFFFFFFFFFF01" .
|
||||
"88022A" .
|
||||
|
@ -288,7 +288,7 @@ class TestUtil
|
|||
"FA02020822" .
|
||||
"FA02020823" .
|
||||
|
||||
"BA040C08C2FFFFFF0F10C2FFFFFF0F" .
|
||||
"BA041608C2FFFFFFFFFFFFFFFF0110C2FFFFFFFFFFFFFFFF01" .
|
||||
"C2041608C1FFFFFFFFFFFFFFFF0110C1FFFFFFFFFFFFFFFF01" .
|
||||
"CA0404083E103E" .
|
||||
"D20404083F103F" .
|
||||
|
@ -401,7 +401,7 @@ class TestUtil
|
|||
public static function getGoldenTestPackedMessage()
|
||||
{
|
||||
return hex2bin(
|
||||
"D2050AD6FFFFFF0FCCFFFFFF0F" .
|
||||
"D20514D6FFFFFFFFFFFFFFFF01CCFFFFFFFFFFFFFFFF01" .
|
||||
"DA0514D5FFFFFFFFFFFFFFFF01CBFFFFFFFFFFFFFFFF01" .
|
||||
"E205022A34" .
|
||||
"EA05022B35" .
|
||||
|
@ -421,7 +421,7 @@ class TestUtil
|
|||
public static function getGoldenTestUnpackedMessage()
|
||||
{
|
||||
return hex2bin(
|
||||
"D005D6FFFFFF0FD005CCFFFFFF0F" .
|
||||
"D005D6FFFFFFFFFFFFFFFF01D005CCFFFFFFFFFFFFFFFF01" .
|
||||
"D805D5FFFFFFFFFFFFFFFF01D805CBFFFFFFFFFFFFFFFF01" .
|
||||
"E0052AE00534" .
|
||||
"E8052BE80535" .
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protoc</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Protobuf Compiler</name>
|
||||
<description>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
# Copyright 2007 Google Inc. All Rights Reserved.
|
||||
|
||||
__version__ = '3.1.0'
|
||||
__version__ = '3.2.0'
|
||||
|
||||
if __name__ != '__main__':
|
||||
try:
|
||||
|
|
|
@ -56,17 +56,6 @@ import sys
|
|||
import weakref
|
||||
|
||||
import six
|
||||
try:
|
||||
import six.moves.copyreg as copyreg
|
||||
except ImportError:
|
||||
# On some platforms, for example gMac, we run native Python because there is
|
||||
# nothing like hermetic Python. This means lesser control on the system and
|
||||
# the six.moves package may be missing (is missing on 20150321 on gMac). Be
|
||||
# extra conservative and try to load the old replacement if it fails.
|
||||
try:
|
||||
import copy_reg as copyreg #PY26
|
||||
except ImportError:
|
||||
import copyreg
|
||||
|
||||
# We use "as" to avoid name collisions with variables.
|
||||
from google.protobuf.internal import containers
|
||||
|
@ -179,7 +168,6 @@ class GeneratedProtocolMessageType(type):
|
|||
_AddStaticMethods(cls)
|
||||
_AddMessageMethods(descriptor, cls)
|
||||
_AddPrivateHelperMethods(descriptor, cls)
|
||||
copyreg.pickle(cls, lambda obj: (cls, (), obj.__getstate__()))
|
||||
|
||||
superclass = super(GeneratedProtocolMessageType, cls)
|
||||
superclass.__init__(name, bases, dictionary)
|
||||
|
@ -1271,6 +1259,12 @@ def _AddWhichOneofMethod(message_descriptor, cls):
|
|||
cls.WhichOneof = WhichOneof
|
||||
|
||||
|
||||
def _AddReduceMethod(cls):
|
||||
def __reduce__(self): # pylint: disable=invalid-name
|
||||
return (type(self), (), self.__getstate__())
|
||||
cls.__reduce__ = __reduce__
|
||||
|
||||
|
||||
def _Clear(self):
|
||||
# Clear fields.
|
||||
self._fields = {}
|
||||
|
@ -1316,6 +1310,7 @@ def _AddMessageMethods(message_descriptor, cls):
|
|||
_AddIsInitializedMethod(message_descriptor, cls)
|
||||
_AddMergeFromMethod(cls)
|
||||
_AddWhichOneofMethod(message_descriptor, cls)
|
||||
_AddReduceMethod(cls)
|
||||
# Adds methods which do not depend on cls.
|
||||
cls.Clear = _Clear
|
||||
cls.DiscardUnknownFields = _DiscardUnknownFields
|
||||
|
|
|
@ -126,6 +126,8 @@ PyObject* subscript(ExtensionDict* self, PyObject* key) {
|
|||
CMessageClass* message_class = message_factory::GetOrCreateMessageClass(
|
||||
cmessage::GetFactoryForMessage(self->parent),
|
||||
descriptor->message_type());
|
||||
ScopedPyObjectPtr message_class_handler(
|
||||
reinterpret_cast<PyObject*>(message_class));
|
||||
if (message_class == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -2342,8 +2342,10 @@ PyObject* InternalGetSubMessage(
|
|||
const Message& sub_message = reflection->GetMessage(
|
||||
*self->message, field_descriptor, factory->message_factory);
|
||||
|
||||
CMessageClass* message_class = message_factory::GetMessageClass(
|
||||
CMessageClass* message_class = message_factory::GetOrCreateMessageClass(
|
||||
factory, field_descriptor->message_type());
|
||||
ScopedPyObjectPtr message_class_handler(
|
||||
reinterpret_cast<PyObject*>(message_class));
|
||||
if (message_class == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import glob
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import platform
|
||||
|
||||
# We must use setuptools, not distutils, because we need to use the
|
||||
# namespace_packages option for the "google" package.
|
||||
|
@ -189,6 +190,12 @@ if __name__ == '__main__':
|
|||
if "clang" in os.popen('$CC --version 2> /dev/null').read():
|
||||
extra_compile_args.append('-Wno-shorten-64-to-32')
|
||||
|
||||
v, _, _ = platform.mac_ver()
|
||||
if v:
|
||||
v = float('.'.join(v.split('.')[:2]))
|
||||
if v >= 10.12:
|
||||
extra_compile_args.append('-std=c++11')
|
||||
|
||||
if warnings_as_errors in sys.argv:
|
||||
extra_compile_args.append('-Werror')
|
||||
sys.argv.remove(warnings_as_errors)
|
||||
|
|
|
@ -64,13 +64,13 @@ else
|
|||
|
||||
task 'gem:windows' do
|
||||
require 'rake_compiler_dock'
|
||||
RakeCompilerDock.sh "bundle && IN_DOCKER=true rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0"
|
||||
RakeCompilerDock.sh "bundle && IN_DOCKER=true rake cross native gem RUBY_CC_VERSION=2.4.0:2.3.0:2.2.2:2.1.5:2.0.0"
|
||||
end
|
||||
|
||||
if RUBY_PLATFORM =~ /darwin/
|
||||
task 'gem:native' do
|
||||
system "rake genproto"
|
||||
system "rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0"
|
||||
system "rake cross native gem RUBY_CC_VERSION=2.4.0:2.3.0:2.2.2:2.1.5:2.0.0"
|
||||
end
|
||||
else
|
||||
task 'gem:native' => [:genproto, 'gem:windows']
|
||||
|
|
|
@ -101,7 +101,7 @@ void DescriptorPool_mark(void* _self) {
|
|||
|
||||
void DescriptorPool_free(void* _self) {
|
||||
DescriptorPool* self = _self;
|
||||
upb_symtab_unref(self->symtab, &self->symtab);
|
||||
upb_symtab_free(self->symtab);
|
||||
xfree(self);
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ void DescriptorPool_free(void* _self) {
|
|||
*/
|
||||
VALUE DescriptorPool_alloc(VALUE klass) {
|
||||
DescriptorPool* self = ALLOC(DescriptorPool);
|
||||
self->symtab = upb_symtab_new(&self->symtab);
|
||||
self->symtab = upb_symtab_new();
|
||||
return TypedData_Wrap_Struct(klass, &_DescriptorPool_type, self);
|
||||
}
|
||||
|
||||
|
|
|
@ -514,7 +514,7 @@ static void add_handlers_for_singular_field(upb_handlers *h,
|
|||
case UPB_TYPE_INT64:
|
||||
case UPB_TYPE_UINT64:
|
||||
case UPB_TYPE_DOUBLE:
|
||||
upb_shim_set(h, f, offset, -1);
|
||||
upb_msg_setscalarhandler(h, f, offset, -1);
|
||||
break;
|
||||
case UPB_TYPE_STRING:
|
||||
case UPB_TYPE_BYTES: {
|
||||
|
@ -925,7 +925,7 @@ static void putmsg(VALUE msg, const Descriptor* desc,
|
|||
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
|
||||
upb_selector_t ret;
|
||||
bool ok = upb_handlers_getselector(f, type, &ret);
|
||||
UPB_ASSERT_VAR(ok, ok);
|
||||
UPB_ASSERT(ok);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -939,9 +939,9 @@ static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) {
|
|||
// We should be guaranteed that the string has the correct encoding because
|
||||
// we ensured this at assignment time and then froze the string.
|
||||
if (upb_fielddef_type(f) == UPB_TYPE_STRING) {
|
||||
assert(rb_enc_from_index(ENCODING_GET(value)) == kRubyStringUtf8Encoding);
|
||||
assert(rb_enc_from_index(ENCODING_GET(str)) == kRubyStringUtf8Encoding);
|
||||
} else {
|
||||
assert(rb_enc_from_index(ENCODING_GET(value)) == kRubyString8bitEncoding);
|
||||
assert(rb_enc_from_index(ENCODING_GET(str)) == kRubyString8bitEncoding);
|
||||
}
|
||||
|
||||
upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), RSTRING_LEN(str),
|
||||
|
|
|
@ -4,7 +4,14 @@ require 'mkmf'
|
|||
|
||||
$CFLAGS += " -std=c99 -O3 -DNDEBUG"
|
||||
|
||||
|
||||
if RUBY_PLATFORM =~ /linux/
|
||||
# Instruct the linker to point memcpy calls at our __wrap_memcpy wrapper.
|
||||
$LDFLAGS += " -Wl,-wrap,memcpy"
|
||||
end
|
||||
|
||||
$objs = ["protobuf.o", "defs.o", "storage.o", "message.o",
|
||||
"repeated_field.o", "map.o", "encode_decode.o", "upb.o"]
|
||||
"repeated_field.o", "map.o", "encode_decode.o", "upb.o",
|
||||
"wrap_memcpy.o"]
|
||||
|
||||
create_makefile("google/protobuf_c")
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
51
ruby/ext/google/protobuf_c/wrap_memcpy.c
Normal file
51
ruby/ext/google/protobuf_c/wrap_memcpy.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2017 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.h>
|
||||
|
||||
// On x86-64 Linux, we link against the 2.2.5 version of memcpy so that we
|
||||
// avoid depending on the 2.14 version of the symbol. This way, distributions
|
||||
// that are using pre-2.14 versions of glibc can successfully use the gem we
|
||||
// distribute (https://github.com/google/protobuf/issues/2783).
|
||||
//
|
||||
// This wrapper is enabled by passing the linker flags -Wl,-wrap,memcpy in
|
||||
// extconf.rb.
|
||||
#ifdef __linux__
|
||||
#ifdef __x86_64__
|
||||
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
|
||||
void *__wrap_memcpy(void *dest, const void *src, size_t n) {
|
||||
return memcpy(dest, src, n);
|
||||
}
|
||||
#else
|
||||
void *__wrap_memcpy(void *dest, const void *src, size_t n) {
|
||||
return memmove(dest, src, n);
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
Gem::Specification.new do |s|
|
||||
s.name = "google-protobuf"
|
||||
s.version = "3.1.0"
|
||||
s.licenses = ["BSD"]
|
||||
s.version = "3.2.0.2"
|
||||
s.licenses = ["BSD-3-Clause"]
|
||||
s.summary = "Protocol Buffers"
|
||||
s.description = "Protocol Buffers are Google's data interchange format."
|
||||
s.homepage = "https://developers.google.com/protocol-buffers"
|
||||
|
@ -15,12 +15,12 @@ Gem::Specification.new do |s|
|
|||
else
|
||||
s.files += Dir.glob('ext/**/*')
|
||||
s.extensions= ["ext/google/protobuf_c/extconf.rb"]
|
||||
s.add_development_dependency "rake-compiler-dock", "~> 0.5.1"
|
||||
s.add_development_dependency "rake-compiler-dock", "~> 0.6.0"
|
||||
end
|
||||
s.test_files = ["tests/basic.rb",
|
||||
"tests/stress.rb",
|
||||
"tests/generated_code_test.rb"]
|
||||
s.add_development_dependency "rake-compiler", "~> 0.9.5"
|
||||
s.add_development_dependency "test-unit", "~> 3.0.9"
|
||||
s.add_development_dependency "test-unit", '~> 3.0', '>= 3.0.9'
|
||||
s.add_development_dependency "rubygems-tasks", "~> 0.2.4"
|
||||
end
|
||||
|
|
|
@ -667,6 +667,13 @@ module BasicTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_map_corruption
|
||||
# This pattern led to a crash in a previous version of upb/protobuf.
|
||||
m = MapMessage.new(map_string_int32: { "aaa" => 1 })
|
||||
m.map_string_int32['podid'] = 2
|
||||
m.map_string_int32['aaa'] = 3
|
||||
end
|
||||
|
||||
def test_map_encode_decode
|
||||
m = MapMessage.new(
|
||||
:map_string_int32 => {"a" => 1, "b" => 2},
|
||||
|
|
|
@ -56,7 +56,9 @@ clean-local:
|
|||
|
||||
CLEANFILES = $(protoc_outputs) unittest_proto_middleman \
|
||||
testzip.jar testzip.list testzip.proto testzip.zip \
|
||||
no_warning_test.cc
|
||||
no_warning_test.cc \
|
||||
google/protobuf/compiler/js/well_known_types_embed.cc \
|
||||
js_embed$(EXEEXT)
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in
|
||||
|
@ -178,7 +180,7 @@ nobase_include_HEADERS = \
|
|||
lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
|
||||
|
||||
libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
|
||||
libprotobuf_lite_la_LDFLAGS = -version-info 11:0:0 -export-dynamic -no-undefined
|
||||
libprotobuf_lite_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
|
||||
libprotobuf_lite_la_SOURCES = \
|
||||
google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
|
||||
google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
|
||||
|
@ -219,7 +221,7 @@ libprotobuf_lite_la_SOURCES = \
|
|||
google/protobuf/io/zero_copy_stream_impl_lite.cc
|
||||
|
||||
libprotobuf_la_LIBADD = $(PTHREAD_LIBS)
|
||||
libprotobuf_la_LDFLAGS = -version-info 11:0:0 -export-dynamic -no-undefined
|
||||
libprotobuf_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
|
||||
libprotobuf_la_SOURCES = \
|
||||
$(libprotobuf_lite_la_SOURCES) \
|
||||
google/protobuf/any.pb.cc \
|
||||
|
@ -303,7 +305,7 @@ libprotobuf_la_SOURCES = \
|
|||
nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)
|
||||
|
||||
libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la
|
||||
libprotoc_la_LDFLAGS = -version-info 11:0:0 -export-dynamic -no-undefined
|
||||
libprotoc_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
|
||||
libprotoc_la_SOURCES = \
|
||||
google/protobuf/compiler/code_generator.cc \
|
||||
google/protobuf/compiler/command_line_interface.cc \
|
||||
|
@ -483,19 +485,24 @@ libprotoc_la_SOURCES = \
|
|||
google/protobuf/compiler/csharp/csharp_wrapper_field.cc \
|
||||
google/protobuf/compiler/csharp/csharp_wrapper_field.h
|
||||
|
||||
bin_PROGRAMS = protoc js_embed
|
||||
bin_PROGRAMS = protoc
|
||||
protoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la
|
||||
protoc_SOURCES = google/protobuf/compiler/main.cc
|
||||
|
||||
# The special JS code for the well-known types is linked into the compiler via
|
||||
# well_known_types_embed.cc, which is generated from .js source files.
|
||||
js_embed_SOURCES = google/protobuf/compiler/js/embed.cc
|
||||
# well_known_types_embed.cc, which is generated from .js source files. We have
|
||||
# to build the js_embed binary using $(CXX_FOR_BUILD) so that it is executable
|
||||
# on the build machine in a cross-compilation setup.
|
||||
js_embed$(EXEEXT): $(srcdir)/google/protobuf/compiler/js/embed.cc
|
||||
$(CXX_FOR_BUILD) -o $@ $<
|
||||
js_well_known_types_sources = \
|
||||
google/protobuf/compiler/js/well_known_types/any.js \
|
||||
google/protobuf/compiler/js/well_known_types/struct.js \
|
||||
google/protobuf/compiler/js/well_known_types/timestamp.js
|
||||
# We have to cd to $(srcdir) so that out-of-tree builds work properly.
|
||||
google/protobuf/compiler/js/well_known_types_embed.cc: js_embed$(EXEEXT) $(js_well_known_types_sources)
|
||||
./js_embed$(EXEEXT) $(js_well_known_types_sources) > $@
|
||||
oldpwd=`pwd` && cd $(srcdir) && \
|
||||
$$oldpwd/js_embed$(EXEEXT) $(js_well_known_types_sources) > $$oldpwd/$@
|
||||
|
||||
# Tests ==============================================================
|
||||
|
||||
|
@ -549,6 +556,7 @@ protoc_inputs = \
|
|||
|
||||
EXTRA_DIST = \
|
||||
$(protoc_inputs) \
|
||||
$(js_well_known_types_sources) \
|
||||
solaris/libstdc++.la \
|
||||
google/protobuf/io/gzip_stream.h \
|
||||
google/protobuf/io/gzip_stream_unittest.sh \
|
||||
|
@ -568,6 +576,7 @@ EXTRA_DIST = \
|
|||
google/protobuf/package_info.h \
|
||||
google/protobuf/io/package_info.h \
|
||||
google/protobuf/util/package_info.h \
|
||||
google/protobuf/compiler/js/embed.cc \
|
||||
google/protobuf/compiler/ruby/ruby_generated_code.proto \
|
||||
google/protobuf/compiler/ruby/ruby_generated_code_pb.rb \
|
||||
google/protobuf/compiler/package_info.h \
|
||||
|
|
|
@ -19,8 +19,11 @@
|
|||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> {};
|
||||
AnyDefaultTypeInternal _Any_default_instance_;
|
||||
class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> {
|
||||
} _Any_default_instance_;
|
||||
|
||||
namespace protobuf_google_2fprotobuf_2fany_2eproto {
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -28,35 +31,30 @@ namespace {
|
|||
|
||||
} // namespace
|
||||
|
||||
|
||||
const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD;
|
||||
const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto() {
|
||||
static const ::google::protobuf::uint32 offsets[] = {
|
||||
~0u, // no _has_bits_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
~0u, // no _oneof_case_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_),
|
||||
};
|
||||
return offsets;
|
||||
}
|
||||
const ::google::protobuf::uint32 TableStruct::offsets[] = {
|
||||
~0u, // no _has_bits_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
~0u, // no _oneof_case_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_),
|
||||
};
|
||||
|
||||
static const ::google::protobuf::internal::MigrationSchema schemas[] = {
|
||||
{ 0, -1, sizeof(Any)},
|
||||
};
|
||||
|
||||
static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
|
||||
{reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_), NULL},
|
||||
static ::google::protobuf::Message const * const file_default_instances[] = {
|
||||
reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_),
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
void protobuf_AssignDescriptors() {
|
||||
protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
|
||||
AddDescriptors();
|
||||
::google::protobuf::MessageFactory* factory = NULL;
|
||||
AssignDescriptors(
|
||||
"google/protobuf/any.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fany_2eproto(), factory,
|
||||
"google/protobuf/any.proto", schemas, file_default_instances, TableStruct::offsets, factory,
|
||||
file_level_metadata, NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -73,24 +71,24 @@ void protobuf_RegisterTypes(const ::std::string&) {
|
|||
|
||||
} // namespace
|
||||
|
||||
void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() {
|
||||
void TableStruct::Shutdown() {
|
||||
_Any_default_instance_.Shutdown();
|
||||
delete file_level_metadata[0].reflection;
|
||||
}
|
||||
|
||||
void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl() {
|
||||
void TableStruct::InitDefaultsImpl() {
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
::google::protobuf::internal::InitProtobufDefaults();
|
||||
_Any_default_instance_.DefaultConstruct();
|
||||
}
|
||||
|
||||
void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto() {
|
||||
void InitDefaults() {
|
||||
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||
::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl);
|
||||
::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
|
||||
}
|
||||
void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
|
||||
void AddDescriptorsImpl() {
|
||||
InitDefaults();
|
||||
static const char descriptor[] = {
|
||||
"\n\031google/protobuf/any.proto\022\017google.prot"
|
||||
"obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002"
|
||||
|
@ -103,20 +101,22 @@ void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() {
|
|||
descriptor, 205);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"google/protobuf/any.proto", &protobuf_RegisterTypes);
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto);
|
||||
::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
|
||||
}
|
||||
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_);
|
||||
void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() {
|
||||
::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_,
|
||||
&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl);
|
||||
void AddDescriptors() {
|
||||
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
|
||||
}
|
||||
// Force AddDescriptors() to be called at static initialization time.
|
||||
struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto {
|
||||
StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto() {
|
||||
protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
|
||||
struct StaticDescriptorInitializer {
|
||||
StaticDescriptorInitializer() {
|
||||
AddDescriptors();
|
||||
}
|
||||
} static_descriptor_initializer_google_2fprotobuf_2fany_2eproto_;
|
||||
} static_descriptor_initializer;
|
||||
|
||||
} // namespace protobuf_google_2fprotobuf_2fany_2eproto
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
|
@ -141,7 +141,7 @@ const int Any::kValueFieldNumber;
|
|||
Any::Any()
|
||||
: ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) {
|
||||
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
|
||||
protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults();
|
||||
}
|
||||
SharedCtor();
|
||||
// @@protoc_insertion_point(constructor:google.protobuf.Any)
|
||||
|
@ -185,12 +185,12 @@ void Any::SetCachedSize(int size) const {
|
|||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* Any::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return file_level_metadata[0].descriptor;
|
||||
protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce();
|
||||
return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[0].descriptor;
|
||||
}
|
||||
|
||||
const Any& Any::default_instance() {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
|
||||
protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults();
|
||||
return *internal_default_instance();
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ void Any::SerializeWithCachedSizes(
|
|||
|
||||
::google::protobuf::uint8* Any::InternalSerializeWithCachedSizesToArray(
|
||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||
(void)deterministic; // Unused
|
||||
(void)deterministic; // Unused
|
||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any)
|
||||
// string type_url = 1;
|
||||
if (this->type_url().size() > 0) {
|
||||
|
@ -396,8 +396,8 @@ void Any::InternalSwap(Any* other) {
|
|||
}
|
||||
|
||||
::google::protobuf::Metadata Any::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return file_level_metadata[0];
|
||||
protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce();
|
||||
return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[0];
|
||||
}
|
||||
|
||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
||||
|
@ -416,6 +416,14 @@ void Any::set_type_url(const ::std::string& value) {
|
|||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Any::set_type_url(::std::string&& value) {
|
||||
|
||||
type_url_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url)
|
||||
}
|
||||
#endif
|
||||
void Any::set_type_url(const char* value) {
|
||||
|
||||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -460,6 +468,14 @@ void Any::set_value(const ::std::string& value) {
|
|||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Any::set_value(::std::string&& value) {
|
||||
|
||||
value_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value)
|
||||
}
|
||||
#endif
|
||||
void Any::set_value(const char* value) {
|
||||
|
||||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
|
|
@ -8,17 +8,18 @@
|
|||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
||||
#if GOOGLE_PROTOBUF_VERSION < 3002000
|
||||
#error This file was generated by a newer version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please update
|
||||
#error your headers.
|
||||
#endif
|
||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#error This file was generated by an older version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please
|
||||
#error regenerate this file with a newer version of protoc.
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/arena.h>
|
||||
#include <google/protobuf/arenastring.h>
|
||||
#include <google/protobuf/generated_message_util.h>
|
||||
|
@ -40,9 +41,16 @@ LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
|
|||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
namespace protobuf_google_2fprotobuf_2fany_2eproto {
|
||||
// Internal implementation detail -- do not call these.
|
||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
|
||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
|
||||
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||
static const ::google::protobuf::uint32 offsets[];
|
||||
static void InitDefaultsImpl();
|
||||
static void Shutdown();
|
||||
};
|
||||
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||
void LIBPROTOBUF_EXPORT InitDefaults();
|
||||
} // namespace protobuf_google_2fprotobuf_2fany_2eproto
|
||||
|
||||
// ===================================================================
|
||||
|
||||
|
@ -99,7 +107,8 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
|
|||
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
|
||||
const PROTOBUF_FINAL {
|
||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
||||
return InternalSerializeWithCachedSizesToArray(
|
||||
::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
|
||||
}
|
||||
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||
private:
|
||||
|
@ -127,6 +136,9 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
|
|||
static const int kTypeUrlFieldNumber = 1;
|
||||
const ::std::string& type_url() const;
|
||||
void set_type_url(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_type_url(::std::string&& value);
|
||||
#endif
|
||||
void set_type_url(const char* value);
|
||||
void set_type_url(const char* value, size_t size);
|
||||
::std::string* mutable_type_url();
|
||||
|
@ -138,6 +150,9 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
|
|||
static const int kValueFieldNumber = 2;
|
||||
const ::std::string& value() const;
|
||||
void set_value(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_value(::std::string&& value);
|
||||
#endif
|
||||
void set_value(const char* value);
|
||||
void set_value(const void* value, size_t size);
|
||||
::std::string* mutable_value();
|
||||
|
@ -152,11 +167,7 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
|
|||
::google::protobuf::internal::ArenaStringPtr value_;
|
||||
mutable int _cached_size_;
|
||||
::google::protobuf::internal::AnyMetadata _any_metadata_;
|
||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl();
|
||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl();
|
||||
friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto();
|
||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto();
|
||||
|
||||
friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fany_2eproto::TableStruct;
|
||||
};
|
||||
// ===================================================================
|
||||
|
||||
|
@ -179,6 +190,14 @@ inline void Any::set_type_url(const ::std::string& value) {
|
|||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Any::set_type_url(::std::string&& value) {
|
||||
|
||||
type_url_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url)
|
||||
}
|
||||
#endif
|
||||
inline void Any::set_type_url(const char* value) {
|
||||
|
||||
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -223,6 +242,14 @@ inline void Any::set_value(const ::std::string& value) {
|
|||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Any::set_value(::std::string&& value) {
|
||||
|
||||
value_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value)
|
||||
}
|
||||
#endif
|
||||
inline void Any::set_value(const char* value) {
|
||||
|
||||
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
|
|
@ -19,12 +19,15 @@
|
|||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> {};
|
||||
ApiDefaultTypeInternal _Api_default_instance_;
|
||||
class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> {};
|
||||
MethodDefaultTypeInternal _Method_default_instance_;
|
||||
class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> {};
|
||||
MixinDefaultTypeInternal _Mixin_default_instance_;
|
||||
class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> {
|
||||
} _Api_default_instance_;
|
||||
class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> {
|
||||
} _Method_default_instance_;
|
||||
class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> {
|
||||
} _Mixin_default_instance_;
|
||||
|
||||
namespace protobuf_google_2fprotobuf_2fapi_2eproto {
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -32,41 +35,36 @@ namespace {
|
|||
|
||||
} // namespace
|
||||
|
||||
|
||||
const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD;
|
||||
const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto() {
|
||||
static const ::google::protobuf::uint32 offsets[] = {
|
||||
~0u, // no _has_bits_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
~0u, // no _oneof_case_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_),
|
||||
~0u, // no _has_bits_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
~0u, // no _oneof_case_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_),
|
||||
~0u, // no _has_bits_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
~0u, // no _oneof_case_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_),
|
||||
};
|
||||
return offsets;
|
||||
}
|
||||
const ::google::protobuf::uint32 TableStruct::offsets[] = {
|
||||
~0u, // no _has_bits_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
~0u, // no _oneof_case_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_),
|
||||
~0u, // no _has_bits_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
~0u, // no _oneof_case_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_),
|
||||
~0u, // no _has_bits_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_),
|
||||
~0u, // no _extensions_
|
||||
~0u, // no _oneof_case_
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_),
|
||||
};
|
||||
|
||||
static const ::google::protobuf::internal::MigrationSchema schemas[] = {
|
||||
{ 0, -1, sizeof(Api)},
|
||||
|
@ -74,19 +72,19 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = {
|
|||
{ 22, -1, sizeof(Mixin)},
|
||||
};
|
||||
|
||||
static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = {
|
||||
{reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_), NULL},
|
||||
{reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_), NULL},
|
||||
{reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_), NULL},
|
||||
static ::google::protobuf::Message const * const file_default_instances[] = {
|
||||
reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_),
|
||||
reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_),
|
||||
reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_),
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
void protobuf_AssignDescriptors() {
|
||||
protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
|
||||
AddDescriptors();
|
||||
::google::protobuf::MessageFactory* factory = NULL;
|
||||
AssignDescriptors(
|
||||
"google/protobuf/api.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(), factory,
|
||||
"google/protobuf/api.proto", schemas, file_default_instances, TableStruct::offsets, factory,
|
||||
file_level_metadata, NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -103,7 +101,7 @@ void protobuf_RegisterTypes(const ::std::string&) {
|
|||
|
||||
} // namespace
|
||||
|
||||
void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() {
|
||||
void TableStruct::Shutdown() {
|
||||
_Api_default_instance_.Shutdown();
|
||||
delete file_level_metadata[0].reflection;
|
||||
_Method_default_instance_.Shutdown();
|
||||
|
@ -112,12 +110,12 @@ void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() {
|
|||
delete file_level_metadata[2].reflection;
|
||||
}
|
||||
|
||||
void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() {
|
||||
void TableStruct::InitDefaultsImpl() {
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
||||
::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
|
||||
::google::protobuf::internal::InitProtobufDefaults();
|
||||
::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
|
||||
::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
|
||||
_Api_default_instance_.DefaultConstruct();
|
||||
_Method_default_instance_.DefaultConstruct();
|
||||
_Mixin_default_instance_.DefaultConstruct();
|
||||
|
@ -125,12 +123,12 @@ void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() {
|
|||
::google::protobuf::SourceContext::internal_default_instance());
|
||||
}
|
||||
|
||||
void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto() {
|
||||
void InitDefaults() {
|
||||
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||
::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl);
|
||||
::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
|
||||
}
|
||||
void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
||||
void AddDescriptorsImpl() {
|
||||
InitDefaults();
|
||||
static const char descriptor[] = {
|
||||
"\n\031google/protobuf/api.proto\022\017google.prot"
|
||||
"obuf\032$google/protobuf/source_context.pro"
|
||||
|
@ -156,22 +154,24 @@ void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() {
|
|||
descriptor, 750);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"google/protobuf/api.proto", &protobuf_RegisterTypes);
|
||||
::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
|
||||
::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto);
|
||||
::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors();
|
||||
::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::AddDescriptors();
|
||||
::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
|
||||
}
|
||||
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_);
|
||||
void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() {
|
||||
::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_,
|
||||
&protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl);
|
||||
void AddDescriptors() {
|
||||
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
|
||||
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
|
||||
}
|
||||
// Force AddDescriptors() to be called at static initialization time.
|
||||
struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto {
|
||||
StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto() {
|
||||
protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
|
||||
struct StaticDescriptorInitializer {
|
||||
StaticDescriptorInitializer() {
|
||||
AddDescriptors();
|
||||
}
|
||||
} static_descriptor_initializer_google_2fprotobuf_2fapi_2eproto_;
|
||||
} static_descriptor_initializer;
|
||||
|
||||
} // namespace protobuf_google_2fprotobuf_2fapi_2eproto
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
|
@ -188,7 +188,7 @@ const int Api::kSyntaxFieldNumber;
|
|||
Api::Api()
|
||||
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
||||
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
|
||||
}
|
||||
SharedCtor();
|
||||
// @@protoc_insertion_point(constructor:google.protobuf.Api)
|
||||
|
@ -245,12 +245,12 @@ void Api::SetCachedSize(int size) const {
|
|||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* Api::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return file_level_metadata[0].descriptor;
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
|
||||
return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[0].descriptor;
|
||||
}
|
||||
|
||||
const Api& Api::default_instance() {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
|
||||
return *internal_default_instance();
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ void Api::SerializeWithCachedSizes(
|
|||
|
||||
::google::protobuf::uint8* Api::InternalSerializeWithCachedSizesToArray(
|
||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||
(void)deterministic; // Unused
|
||||
(void)deterministic; // Unused
|
||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api)
|
||||
// string name = 1;
|
||||
if (this->name().size() > 0) {
|
||||
|
@ -664,8 +664,8 @@ void Api::InternalSwap(Api* other) {
|
|||
}
|
||||
|
||||
::google::protobuf::Metadata Api::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return file_level_metadata[0];
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
|
||||
return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[0];
|
||||
}
|
||||
|
||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
||||
|
@ -684,6 +684,14 @@ void Api::set_name(const ::std::string& value) {
|
|||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Api.name)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Api::set_name(::std::string&& value) {
|
||||
|
||||
name_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name)
|
||||
}
|
||||
#endif
|
||||
void Api::set_name(const char* value) {
|
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -788,6 +796,14 @@ void Api::set_version(const ::std::string& value) {
|
|||
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Api.version)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Api::set_version(::std::string&& value) {
|
||||
|
||||
version_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version)
|
||||
}
|
||||
#endif
|
||||
void Api::set_version(const char* value) {
|
||||
|
||||
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -919,7 +935,7 @@ const int Method::kSyntaxFieldNumber;
|
|||
Method::Method()
|
||||
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
||||
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
|
||||
}
|
||||
SharedCtor();
|
||||
// @@protoc_insertion_point(constructor:google.protobuf.Method)
|
||||
|
@ -974,12 +990,12 @@ void Method::SetCachedSize(int size) const {
|
|||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* Method::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return file_level_metadata[1].descriptor;
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
|
||||
return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[1].descriptor;
|
||||
}
|
||||
|
||||
const Method& Method::default_instance() {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
|
||||
return *internal_default_instance();
|
||||
}
|
||||
|
||||
|
@ -1190,7 +1206,7 @@ void Method::SerializeWithCachedSizes(
|
|||
|
||||
::google::protobuf::uint8* Method::InternalSerializeWithCachedSizesToArray(
|
||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||
(void)deterministic; // Unused
|
||||
(void)deterministic; // Unused
|
||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method)
|
||||
// string name = 1;
|
||||
if (this->name().size() > 0) {
|
||||
|
@ -1388,8 +1404,8 @@ void Method::InternalSwap(Method* other) {
|
|||
}
|
||||
|
||||
::google::protobuf::Metadata Method::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return file_level_metadata[1];
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
|
||||
return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[1];
|
||||
}
|
||||
|
||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
||||
|
@ -1408,6 +1424,14 @@ void Method::set_name(const ::std::string& value) {
|
|||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.name)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Method::set_name(::std::string&& value) {
|
||||
|
||||
name_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name)
|
||||
}
|
||||
#endif
|
||||
void Method::set_name(const char* value) {
|
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -1452,6 +1476,14 @@ void Method::set_request_type_url(const ::std::string& value) {
|
|||
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Method::set_request_type_url(::std::string&& value) {
|
||||
|
||||
request_type_url_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url)
|
||||
}
|
||||
#endif
|
||||
void Method::set_request_type_url(const char* value) {
|
||||
|
||||
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -1510,6 +1542,14 @@ void Method::set_response_type_url(const ::std::string& value) {
|
|||
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Method::set_response_type_url(::std::string&& value) {
|
||||
|
||||
response_type_url_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url)
|
||||
}
|
||||
#endif
|
||||
void Method::set_response_type_url(const char* value) {
|
||||
|
||||
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -1611,7 +1651,7 @@ const int Mixin::kRootFieldNumber;
|
|||
Mixin::Mixin()
|
||||
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
|
||||
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
|
||||
}
|
||||
SharedCtor();
|
||||
// @@protoc_insertion_point(constructor:google.protobuf.Mixin)
|
||||
|
@ -1654,12 +1694,12 @@ void Mixin::SetCachedSize(int size) const {
|
|||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* Mixin::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return file_level_metadata[2].descriptor;
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
|
||||
return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[2].descriptor;
|
||||
}
|
||||
|
||||
const Mixin& Mixin::default_instance() {
|
||||
protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
|
||||
return *internal_default_instance();
|
||||
}
|
||||
|
||||
|
@ -1766,7 +1806,7 @@ void Mixin::SerializeWithCachedSizes(
|
|||
|
||||
::google::protobuf::uint8* Mixin::InternalSerializeWithCachedSizesToArray(
|
||||
bool deterministic, ::google::protobuf::uint8* target) const {
|
||||
(void)deterministic; // Unused
|
||||
(void)deterministic; // Unused
|
||||
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin)
|
||||
// string name = 1;
|
||||
if (this->name().size() > 0) {
|
||||
|
@ -1877,8 +1917,8 @@ void Mixin::InternalSwap(Mixin* other) {
|
|||
}
|
||||
|
||||
::google::protobuf::Metadata Mixin::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return file_level_metadata[2];
|
||||
protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
|
||||
return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[2];
|
||||
}
|
||||
|
||||
#if PROTOBUF_INLINE_NOT_IN_HEADERS
|
||||
|
@ -1897,6 +1937,14 @@ void Mixin::set_name(const ::std::string& value) {
|
|||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Mixin::set_name(::std::string&& value) {
|
||||
|
||||
name_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name)
|
||||
}
|
||||
#endif
|
||||
void Mixin::set_name(const char* value) {
|
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -1941,6 +1989,14 @@ void Mixin::set_root(const ::std::string& value) {
|
|||
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
void Mixin::set_root(::std::string&& value) {
|
||||
|
||||
root_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root)
|
||||
}
|
||||
#endif
|
||||
void Mixin::set_root(const char* value) {
|
||||
|
||||
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
|
|
@ -8,17 +8,18 @@
|
|||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 3001000
|
||||
#if GOOGLE_PROTOBUF_VERSION < 3002000
|
||||
#error This file was generated by a newer version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please update
|
||||
#error your headers.
|
||||
#endif
|
||||
#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#error This file was generated by an older version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please
|
||||
#error regenerate this file with a newer version of protoc.
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/arena.h>
|
||||
#include <google/protobuf/arenastring.h>
|
||||
#include <google/protobuf/generated_message_util.h>
|
||||
|
@ -65,9 +66,16 @@ LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
|
|||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
namespace protobuf_google_2fprotobuf_2fapi_2eproto {
|
||||
// Internal implementation detail -- do not call these.
|
||||
void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
|
||||
void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
|
||||
struct LIBPROTOBUF_EXPORT TableStruct {
|
||||
static const ::google::protobuf::uint32 offsets[];
|
||||
static void InitDefaultsImpl();
|
||||
static void Shutdown();
|
||||
};
|
||||
void LIBPROTOBUF_EXPORT AddDescriptors();
|
||||
void LIBPROTOBUF_EXPORT InitDefaults();
|
||||
} // namespace protobuf_google_2fprotobuf_2fapi_2eproto
|
||||
|
||||
// ===================================================================
|
||||
|
||||
|
@ -114,7 +122,8 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
|
||||
const PROTOBUF_FINAL {
|
||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
||||
return InternalSerializeWithCachedSizesToArray(
|
||||
::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
|
||||
}
|
||||
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||
private:
|
||||
|
@ -137,17 +146,6 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// string name = 1;
|
||||
void clear_name();
|
||||
static const int kNameFieldNumber = 1;
|
||||
const ::std::string& name() const;
|
||||
void set_name(const ::std::string& value);
|
||||
void set_name(const char* value);
|
||||
void set_name(const char* value, size_t size);
|
||||
::std::string* mutable_name();
|
||||
::std::string* release_name();
|
||||
void set_allocated_name(::std::string* name);
|
||||
|
||||
// repeated .google.protobuf.Method methods = 2;
|
||||
int methods_size() const;
|
||||
void clear_methods();
|
||||
|
@ -172,11 +170,40 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
|
||||
options() const;
|
||||
|
||||
// repeated .google.protobuf.Mixin mixins = 6;
|
||||
int mixins_size() const;
|
||||
void clear_mixins();
|
||||
static const int kMixinsFieldNumber = 6;
|
||||
const ::google::protobuf::Mixin& mixins(int index) const;
|
||||
::google::protobuf::Mixin* mutable_mixins(int index);
|
||||
::google::protobuf::Mixin* add_mixins();
|
||||
::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*
|
||||
mutable_mixins();
|
||||
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
|
||||
mixins() const;
|
||||
|
||||
// string name = 1;
|
||||
void clear_name();
|
||||
static const int kNameFieldNumber = 1;
|
||||
const ::std::string& name() const;
|
||||
void set_name(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_name(::std::string&& value);
|
||||
#endif
|
||||
void set_name(const char* value);
|
||||
void set_name(const char* value, size_t size);
|
||||
::std::string* mutable_name();
|
||||
::std::string* release_name();
|
||||
void set_allocated_name(::std::string* name);
|
||||
|
||||
// string version = 4;
|
||||
void clear_version();
|
||||
static const int kVersionFieldNumber = 4;
|
||||
const ::std::string& version() const;
|
||||
void set_version(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_version(::std::string&& value);
|
||||
#endif
|
||||
void set_version(const char* value);
|
||||
void set_version(const char* value, size_t size);
|
||||
::std::string* mutable_version();
|
||||
|
@ -192,18 +219,6 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||
::google::protobuf::SourceContext* release_source_context();
|
||||
void set_allocated_source_context(::google::protobuf::SourceContext* source_context);
|
||||
|
||||
// repeated .google.protobuf.Mixin mixins = 6;
|
||||
int mixins_size() const;
|
||||
void clear_mixins();
|
||||
static const int kMixinsFieldNumber = 6;
|
||||
const ::google::protobuf::Mixin& mixins(int index) const;
|
||||
::google::protobuf::Mixin* mutable_mixins(int index);
|
||||
::google::protobuf::Mixin* add_mixins();
|
||||
::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*
|
||||
mutable_mixins();
|
||||
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
|
||||
mixins() const;
|
||||
|
||||
// .google.protobuf.Syntax syntax = 7;
|
||||
void clear_syntax();
|
||||
static const int kSyntaxFieldNumber = 7;
|
||||
|
@ -222,11 +237,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
|
|||
::google::protobuf::SourceContext* source_context_;
|
||||
int syntax_;
|
||||
mutable int _cached_size_;
|
||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
|
||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
|
||||
friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto();
|
||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
|
||||
|
||||
friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
|
||||
};
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
@ -273,7 +284,8 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
|
|||
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
|
||||
const PROTOBUF_FINAL {
|
||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
||||
return InternalSerializeWithCachedSizesToArray(
|
||||
::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
|
||||
}
|
||||
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||
private:
|
||||
|
@ -296,51 +308,6 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
|
|||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// string name = 1;
|
||||
void clear_name();
|
||||
static const int kNameFieldNumber = 1;
|
||||
const ::std::string& name() const;
|
||||
void set_name(const ::std::string& value);
|
||||
void set_name(const char* value);
|
||||
void set_name(const char* value, size_t size);
|
||||
::std::string* mutable_name();
|
||||
::std::string* release_name();
|
||||
void set_allocated_name(::std::string* name);
|
||||
|
||||
// string request_type_url = 2;
|
||||
void clear_request_type_url();
|
||||
static const int kRequestTypeUrlFieldNumber = 2;
|
||||
const ::std::string& request_type_url() const;
|
||||
void set_request_type_url(const ::std::string& value);
|
||||
void set_request_type_url(const char* value);
|
||||
void set_request_type_url(const char* value, size_t size);
|
||||
::std::string* mutable_request_type_url();
|
||||
::std::string* release_request_type_url();
|
||||
void set_allocated_request_type_url(::std::string* request_type_url);
|
||||
|
||||
// bool request_streaming = 3;
|
||||
void clear_request_streaming();
|
||||
static const int kRequestStreamingFieldNumber = 3;
|
||||
bool request_streaming() const;
|
||||
void set_request_streaming(bool value);
|
||||
|
||||
// string response_type_url = 4;
|
||||
void clear_response_type_url();
|
||||
static const int kResponseTypeUrlFieldNumber = 4;
|
||||
const ::std::string& response_type_url() const;
|
||||
void set_response_type_url(const ::std::string& value);
|
||||
void set_response_type_url(const char* value);
|
||||
void set_response_type_url(const char* value, size_t size);
|
||||
::std::string* mutable_response_type_url();
|
||||
::std::string* release_response_type_url();
|
||||
void set_allocated_response_type_url(::std::string* response_type_url);
|
||||
|
||||
// bool response_streaming = 5;
|
||||
void clear_response_streaming();
|
||||
static const int kResponseStreamingFieldNumber = 5;
|
||||
bool response_streaming() const;
|
||||
void set_response_streaming(bool value);
|
||||
|
||||
// repeated .google.protobuf.Option options = 6;
|
||||
int options_size() const;
|
||||
void clear_options();
|
||||
|
@ -353,6 +320,60 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
|
|||
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
|
||||
options() const;
|
||||
|
||||
// string name = 1;
|
||||
void clear_name();
|
||||
static const int kNameFieldNumber = 1;
|
||||
const ::std::string& name() const;
|
||||
void set_name(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_name(::std::string&& value);
|
||||
#endif
|
||||
void set_name(const char* value);
|
||||
void set_name(const char* value, size_t size);
|
||||
::std::string* mutable_name();
|
||||
::std::string* release_name();
|
||||
void set_allocated_name(::std::string* name);
|
||||
|
||||
// string request_type_url = 2;
|
||||
void clear_request_type_url();
|
||||
static const int kRequestTypeUrlFieldNumber = 2;
|
||||
const ::std::string& request_type_url() const;
|
||||
void set_request_type_url(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_request_type_url(::std::string&& value);
|
||||
#endif
|
||||
void set_request_type_url(const char* value);
|
||||
void set_request_type_url(const char* value, size_t size);
|
||||
::std::string* mutable_request_type_url();
|
||||
::std::string* release_request_type_url();
|
||||
void set_allocated_request_type_url(::std::string* request_type_url);
|
||||
|
||||
// string response_type_url = 4;
|
||||
void clear_response_type_url();
|
||||
static const int kResponseTypeUrlFieldNumber = 4;
|
||||
const ::std::string& response_type_url() const;
|
||||
void set_response_type_url(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_response_type_url(::std::string&& value);
|
||||
#endif
|
||||
void set_response_type_url(const char* value);
|
||||
void set_response_type_url(const char* value, size_t size);
|
||||
::std::string* mutable_response_type_url();
|
||||
::std::string* release_response_type_url();
|
||||
void set_allocated_response_type_url(::std::string* response_type_url);
|
||||
|
||||
// bool request_streaming = 3;
|
||||
void clear_request_streaming();
|
||||
static const int kRequestStreamingFieldNumber = 3;
|
||||
bool request_streaming() const;
|
||||
void set_request_streaming(bool value);
|
||||
|
||||
// bool response_streaming = 5;
|
||||
void clear_response_streaming();
|
||||
static const int kResponseStreamingFieldNumber = 5;
|
||||
bool response_streaming() const;
|
||||
void set_response_streaming(bool value);
|
||||
|
||||
// .google.protobuf.Syntax syntax = 7;
|
||||
void clear_syntax();
|
||||
static const int kSyntaxFieldNumber = 7;
|
||||
|
@ -371,11 +392,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
|
|||
bool response_streaming_;
|
||||
int syntax_;
|
||||
mutable int _cached_size_;
|
||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
|
||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
|
||||
friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto();
|
||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
|
||||
|
||||
friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
|
||||
};
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
@ -422,7 +439,8 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
|
|||
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
|
||||
const PROTOBUF_FINAL {
|
||||
return InternalSerializeWithCachedSizesToArray(false, output);
|
||||
return InternalSerializeWithCachedSizesToArray(
|
||||
::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
|
||||
}
|
||||
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
|
||||
private:
|
||||
|
@ -450,6 +468,9 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
|
|||
static const int kNameFieldNumber = 1;
|
||||
const ::std::string& name() const;
|
||||
void set_name(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_name(::std::string&& value);
|
||||
#endif
|
||||
void set_name(const char* value);
|
||||
void set_name(const char* value, size_t size);
|
||||
::std::string* mutable_name();
|
||||
|
@ -461,6 +482,9 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
|
|||
static const int kRootFieldNumber = 2;
|
||||
const ::std::string& root() const;
|
||||
void set_root(const ::std::string& value);
|
||||
#if LANG_CXX11
|
||||
void set_root(::std::string&& value);
|
||||
#endif
|
||||
void set_root(const char* value);
|
||||
void set_root(const char* value, size_t size);
|
||||
::std::string* mutable_root();
|
||||
|
@ -474,11 +498,7 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
|
|||
::google::protobuf::internal::ArenaStringPtr name_;
|
||||
::google::protobuf::internal::ArenaStringPtr root_;
|
||||
mutable int _cached_size_;
|
||||
friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
|
||||
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
|
||||
friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto();
|
||||
friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
|
||||
|
||||
friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
|
||||
};
|
||||
// ===================================================================
|
||||
|
||||
|
@ -501,6 +521,14 @@ inline void Api::set_name(const ::std::string& value) {
|
|||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Api.name)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Api::set_name(::std::string&& value) {
|
||||
|
||||
name_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name)
|
||||
}
|
||||
#endif
|
||||
inline void Api::set_name(const char* value) {
|
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -605,6 +633,14 @@ inline void Api::set_version(const ::std::string& value) {
|
|||
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Api.version)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Api::set_version(::std::string&& value) {
|
||||
|
||||
version_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version)
|
||||
}
|
||||
#endif
|
||||
inline void Api::set_version(const char* value) {
|
||||
|
||||
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -736,6 +772,14 @@ inline void Method::set_name(const ::std::string& value) {
|
|||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.name)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Method::set_name(::std::string&& value) {
|
||||
|
||||
name_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name)
|
||||
}
|
||||
#endif
|
||||
inline void Method::set_name(const char* value) {
|
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -780,6 +824,14 @@ inline void Method::set_request_type_url(const ::std::string& value) {
|
|||
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Method::set_request_type_url(::std::string&& value) {
|
||||
|
||||
request_type_url_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url)
|
||||
}
|
||||
#endif
|
||||
inline void Method::set_request_type_url(const char* value) {
|
||||
|
||||
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -838,6 +890,14 @@ inline void Method::set_response_type_url(const ::std::string& value) {
|
|||
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Method::set_response_type_url(::std::string&& value) {
|
||||
|
||||
response_type_url_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url)
|
||||
}
|
||||
#endif
|
||||
inline void Method::set_response_type_url(const char* value) {
|
||||
|
||||
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -944,6 +1004,14 @@ inline void Mixin::set_name(const ::std::string& value) {
|
|||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Mixin::set_name(::std::string&& value) {
|
||||
|
||||
name_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name)
|
||||
}
|
||||
#endif
|
||||
inline void Mixin::set_name(const char* value) {
|
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
@ -988,6 +1056,14 @@ inline void Mixin::set_root(const ::std::string& value) {
|
|||
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
|
||||
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
|
||||
}
|
||||
#if LANG_CXX11
|
||||
inline void Mixin::set_root(::std::string&& value) {
|
||||
|
||||
root_.SetNoArena(
|
||||
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), std::move(value));
|
||||
// @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root)
|
||||
}
|
||||
#endif
|
||||
inline void Mixin::set_root(const char* value) {
|
||||
|
||||
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
|
||||
|
|
|
@ -62,6 +62,7 @@ void Arena::Init() {
|
|||
lifecycle_id_ = lifecycle_id_generator_.GetNext();
|
||||
blocks_ = 0;
|
||||
hint_ = 0;
|
||||
space_allocated_ = 0;
|
||||
owns_first_block_ = true;
|
||||
cleanup_list_ = 0;
|
||||
|
||||
|
@ -157,6 +158,7 @@ void Arena::AddBlockInternal(Block* b) {
|
|||
// Direct future allocations to this block.
|
||||
google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));
|
||||
}
|
||||
space_allocated_ += b->size;
|
||||
}
|
||||
|
||||
void Arena::AddListNode(void* elem, void (*cleanup)(void*)) {
|
||||
|
@ -225,13 +227,8 @@ void* Arena::SlowAlloc(size_t n) {
|
|||
}
|
||||
|
||||
uint64 Arena::SpaceAllocated() const {
|
||||
uint64 space_allocated = 0;
|
||||
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
|
||||
while (b != NULL) {
|
||||
space_allocated += (b->size);
|
||||
b = b->next;
|
||||
}
|
||||
return space_allocated;
|
||||
MutexLock l(&blocks_lock_);
|
||||
return space_allocated_;
|
||||
}
|
||||
|
||||
uint64 Arena::SpaceUsed() const {
|
||||
|
@ -245,16 +242,7 @@ uint64 Arena::SpaceUsed() const {
|
|||
}
|
||||
|
||||
std::pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const {
|
||||
uint64 allocated = 0;
|
||||
uint64 used = 0;
|
||||
|
||||
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
|
||||
while (b != NULL) {
|
||||
allocated += b->size;
|
||||
used += (b->pos - kHeaderSize);
|
||||
b = b->next;
|
||||
}
|
||||
return std::make_pair(allocated, used);
|
||||
return std::make_pair(SpaceAllocated(), SpaceUsed());
|
||||
}
|
||||
|
||||
uint64 Arena::FreeBlocks() {
|
||||
|
@ -288,6 +276,7 @@ uint64 Arena::FreeBlocks() {
|
|||
}
|
||||
blocks_ = 0;
|
||||
hint_ = 0;
|
||||
space_allocated_ = 0;
|
||||
if (!owns_first_block_) {
|
||||
// Make the first block that was passed in through ArenaOptions
|
||||
// available for reuse.
|
||||
|
|
|
@ -449,14 +449,17 @@ class LIBPROTOBUF_EXPORT Arena {
|
|||
}
|
||||
}
|
||||
|
||||
// Returns the total space used by the arena, which is the sums of the sizes
|
||||
// of the underlying blocks. The total space used may not include the new
|
||||
// blocks that are allocated by this arena from other threads concurrently
|
||||
// with the call to this method.
|
||||
GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceAllocated() const;
|
||||
// As above, but does not include any free space in underlying blocks.
|
||||
// Returns the total space allocated by the arena, which is the sum of the
|
||||
// sizes of the underlying blocks. This method is relatively fast; a counter
|
||||
// is kept as blocks are allocated.
|
||||
uint64 SpaceAllocated() const;
|
||||
// Returns the total space used by the arena. Similar to SpaceAllocated but
|
||||
// does not include free space and block overhead. The total space returned
|
||||
// may not include space used by other threads executing concurrently with
|
||||
// the call to this method.
|
||||
GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceUsed() const;
|
||||
|
||||
// DEPRECATED. Please use SpaceAllocated() and SpaceUsed().
|
||||
//
|
||||
// Combines SpaceAllocated and SpaceUsed. Returns a pair of
|
||||
// <space_allocated, space_used>.
|
||||
GOOGLE_ATTRIBUTE_NOINLINE std::pair<uint64, uint64> SpaceAllocatedAndUsed() const;
|
||||
|
@ -884,8 +887,9 @@ class LIBPROTOBUF_EXPORT Arena {
|
|||
|
||||
int64 lifecycle_id_; // Unique for each arena. Changes on Reset().
|
||||
|
||||
google::protobuf::internal::AtomicWord blocks_; // Head of linked list of all allocated blocks
|
||||
google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access
|
||||
google::protobuf::internal::AtomicWord blocks_; // Head of linked list of all allocated blocks
|
||||
google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access
|
||||
uint64 space_allocated_; // Sum of sizes of all allocated blocks.
|
||||
|
||||
// Node contains the ptr of the object to be cleaned up and the associated
|
||||
// cleanup function ptr.
|
||||
|
@ -899,7 +903,7 @@ class LIBPROTOBUF_EXPORT Arena {
|
|||
// ptrs and cleanup methods.
|
||||
|
||||
bool owns_first_block_; // Indicates that arena owns the first block
|
||||
Mutex blocks_lock_;
|
||||
mutable Mutex blocks_lock_;
|
||||
|
||||
void AddBlock(Block* b);
|
||||
// Access must be synchronized, either by blocks_lock_ or by being called from
|
||||
|
|
|
@ -210,6 +210,16 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||
}
|
||||
}
|
||||
|
||||
#if LANG_CXX11
|
||||
void SetNoArena(const ::std::string* default_value, ::std::string&& value) {
|
||||
if (IsDefault(default_value)) {
|
||||
ptr_ = new ::std::string(std::move(value));
|
||||
} else {
|
||||
*ptr_ = std::move(value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value);
|
||||
|
||||
inline const ::std::string& GetNoArena() const { return *ptr_; }
|
||||
|
@ -283,22 +293,15 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
|
|||
|
||||
GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena,
|
||||
const ::std::string* initial_value) {
|
||||
// Assumes ptr_ is not NULL.
|
||||
if (initial_value != NULL) {
|
||||
ptr_ = new ::std::string(*initial_value);
|
||||
} else {
|
||||
ptr_ = new ::std::string();
|
||||
}
|
||||
GOOGLE_DCHECK(initial_value != NULL);
|
||||
ptr_ = new ::std::string(*initial_value);
|
||||
if (arena != NULL) {
|
||||
arena->Own(ptr_);
|
||||
}
|
||||
}
|
||||
GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) {
|
||||
if (initial_value != NULL) {
|
||||
ptr_ = new ::std::string(*initial_value);
|
||||
} else {
|
||||
ptr_ = new ::std::string();
|
||||
}
|
||||
GOOGLE_DCHECK(initial_value != NULL);
|
||||
ptr_ = new ::std::string(*initial_value);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -116,6 +116,9 @@ static const char* kPathSeparator = ";";
|
|||
static const char* kPathSeparator = ":";
|
||||
#endif
|
||||
|
||||
static const char* kDefaultDirectDependenciesViolationMsg =
|
||||
"File is imported but not declared in --direct_dependencies: %s";
|
||||
|
||||
// Returns true if the text looks like a Windows-style absolute path, starting
|
||||
// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with
|
||||
// copy in importer.cc?
|
||||
|
@ -276,12 +279,13 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
|
|||
public io::ErrorCollector {
|
||||
public:
|
||||
ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL)
|
||||
: format_(format), tree_(tree) {}
|
||||
: format_(format), tree_(tree), found_errors_(false) {}
|
||||
~ErrorPrinter() {}
|
||||
|
||||
// implements MultiFileErrorCollector ------------------------------
|
||||
void AddError(const string& filename, int line, int column,
|
||||
const string& message) {
|
||||
found_errors_ = true;
|
||||
AddErrorOrWarning(filename, line, column, message, "error", std::cerr);
|
||||
}
|
||||
|
||||
|
@ -299,10 +303,12 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
|
|||
AddErrorOrWarning("input", line, column, message, "warning", std::clog);
|
||||
}
|
||||
|
||||
bool FoundErrors() const { return found_errors_; }
|
||||
|
||||
private:
|
||||
void AddErrorOrWarning(
|
||||
const string& filename, int line, int column,
|
||||
const string& message, const string& type, ostream& out) {
|
||||
void AddErrorOrWarning(const string& filename, int line, int column,
|
||||
const string& message, const string& type,
|
||||
std::ostream& out) {
|
||||
// Print full path when running under MSVS
|
||||
string dfile;
|
||||
if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS &&
|
||||
|
@ -337,6 +343,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
|
|||
|
||||
const ErrorFormat format_;
|
||||
DiskSourceTree *tree_;
|
||||
bool found_errors_;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
@ -708,14 +715,17 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
|
|||
// ===================================================================
|
||||
|
||||
CommandLineInterface::CommandLineInterface()
|
||||
: mode_(MODE_COMPILE),
|
||||
print_mode_(PRINT_NONE),
|
||||
error_format_(ERROR_FORMAT_GCC),
|
||||
direct_dependencies_explicitly_set_(false),
|
||||
imports_in_descriptor_set_(false),
|
||||
source_info_in_descriptor_set_(false),
|
||||
disallow_services_(false),
|
||||
inputs_are_proto_path_relative_(false) {}
|
||||
: mode_(MODE_COMPILE),
|
||||
print_mode_(PRINT_NONE),
|
||||
error_format_(ERROR_FORMAT_GCC),
|
||||
direct_dependencies_explicitly_set_(false),
|
||||
direct_dependencies_violation_msg_(
|
||||
kDefaultDirectDependenciesViolationMsg),
|
||||
imports_in_descriptor_set_(false),
|
||||
source_info_in_descriptor_set_(false),
|
||||
disallow_services_(false),
|
||||
inputs_are_proto_path_relative_(false) {
|
||||
}
|
||||
CommandLineInterface::~CommandLineInterface() {}
|
||||
|
||||
void CommandLineInterface::RegisterGenerator(const string& flag_name,
|
||||
|
@ -800,10 +810,11 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
|
|||
if (direct_dependencies_.find(parsed_file->dependency(i)->name()) ==
|
||||
direct_dependencies_.end()) {
|
||||
indirect_imports = true;
|
||||
cerr << parsed_file->name()
|
||||
<< ": File is imported but not declared in "
|
||||
<< "--direct_dependencies: "
|
||||
<< parsed_file->dependency(i)->name() << std::endl;
|
||||
cerr << parsed_file->name() << ": "
|
||||
<< StringReplace(direct_dependencies_violation_msg_, "%s",
|
||||
parsed_file->dependency(i)->name(),
|
||||
true /* replace_all */)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
if (indirect_imports) {
|
||||
|
@ -895,6 +906,10 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
if (error_collector.FoundErrors()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mode_ == MODE_PRINT) {
|
||||
switch (print_mode_) {
|
||||
case PRINT_FREE_FIELDS:
|
||||
|
@ -924,6 +939,7 @@ void CommandLineInterface::Clear() {
|
|||
proto_path_.clear();
|
||||
input_files_.clear();
|
||||
direct_dependencies_.clear();
|
||||
direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg;
|
||||
output_directives_.clear();
|
||||
codec_type_.clear();
|
||||
descriptor_set_name_.clear();
|
||||
|
@ -1015,16 +1031,34 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
|
|||
}
|
||||
|
||||
// Make sure each plugin option has a matching plugin output.
|
||||
bool foundUnknownPluginOption = false;
|
||||
for (map<string, string>::const_iterator i = plugin_parameters_.begin();
|
||||
i != plugin_parameters_.end(); ++i) {
|
||||
if (plugins_.find(i->first) == plugins_.end()) {
|
||||
if (plugins_.find(i->first) != plugins_.end()) {
|
||||
continue;
|
||||
}
|
||||
bool foundImplicitPlugin = false;
|
||||
for (std::vector<OutputDirective>::const_iterator j = output_directives_.cbegin();
|
||||
j != output_directives_.cend(); ++j) {
|
||||
if (j->generator == NULL) {
|
||||
string plugin_name = PluginName(plugin_prefix_ , j->name);
|
||||
if (plugin_name == i->first) {
|
||||
foundImplicitPlugin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!foundImplicitPlugin) {
|
||||
std::cerr << "Unknown flag: "
|
||||
// strip prefix + "gen-" and add back "_opt"
|
||||
<< "--" + i->first.substr(plugin_prefix_.size() + 4) + "_opt"
|
||||
<< std::endl;
|
||||
return PARSE_ARGUMENT_FAIL;
|
||||
foundUnknownPluginOption = true;
|
||||
}
|
||||
}
|
||||
if (foundUnknownPluginOption) {
|
||||
return PARSE_ARGUMENT_FAIL;
|
||||
}
|
||||
|
||||
// If no --proto_path was given, use the current working directory.
|
||||
if (proto_path_.empty()) {
|
||||
|
@ -1209,6 +1243,9 @@ CommandLineInterface::InterpretArgument(const string& name,
|
|||
GOOGLE_DCHECK(direct_dependencies_.empty());
|
||||
direct_dependencies_.insert(direct.begin(), direct.end());
|
||||
|
||||
} else if (name == "--direct_dependencies_violation_msg") {
|
||||
direct_dependencies_violation_msg_ = value;
|
||||
|
||||
} else if (name == "-o" || name == "--descriptor_set_out") {
|
||||
if (!descriptor_set_name_.empty()) {
|
||||
std::cerr << name << " may only be passed once." << std::endl;
|
||||
|
|
|
@ -365,6 +365,10 @@ class LIBPROTOC_EXPORT CommandLineInterface {
|
|||
std::set<string> direct_dependencies_;
|
||||
bool direct_dependencies_explicitly_set_;
|
||||
|
||||
// If there's a violation of depend-on-what-you-import, this string will be
|
||||
// presented to the user. "%s" will be replaced with the violating import.
|
||||
string direct_dependencies_violation_msg_;
|
||||
|
||||
// output_directives_ lists all the files we are supposed to output and what
|
||||
// generator to use for each.
|
||||
struct OutputDirective {
|
||||
|
|
|
@ -101,6 +101,7 @@ class CommandLineInterfaceTest : public testing::Test {
|
|||
// command is automatically split on spaces, and the string "$tmpdir"
|
||||
// is replaced with TestTempDir().
|
||||
void Run(const string& command);
|
||||
void RunWithArgs(vector<string> args);
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Methods to set up the test (called before Run()).
|
||||
|
@ -292,8 +293,10 @@ void CommandLineInterfaceTest::TearDown() {
|
|||
}
|
||||
|
||||
void CommandLineInterfaceTest::Run(const string& command) {
|
||||
std::vector<string> args = Split(command, " ", true);
|
||||
RunWithArgs(Split(command, " ", true));
|
||||
}
|
||||
|
||||
void CommandLineInterfaceTest::RunWithArgs(vector<string> args) {
|
||||
if (!disallow_plugins_) {
|
||||
cli_.AllowPlugins("prefix-");
|
||||
#ifndef GOOGLE_THIRD_PARTY_PROTOBUF
|
||||
|
@ -686,10 +689,36 @@ TEST_F(CommandLineInterfaceTest, UnrecognizedExtraParameters) {
|
|||
"message Foo {}\n");
|
||||
|
||||
Run("protocol_compiler --plug_out=TestParameter:$tmpdir "
|
||||
"--unknown_plug_a_opt=Foo "
|
||||
"--unknown_plug_b_opt=Bar "
|
||||
"--proto_path=$tmpdir foo.proto");
|
||||
|
||||
ExpectErrorSubstring("Unknown flag: --unknown_plug_a_opt");
|
||||
ExpectErrorSubstring("Unknown flag: --unknown_plug_b_opt");
|
||||
}
|
||||
|
||||
TEST_F(CommandLineInterfaceTest, ExtraPluginParametersForOutParameters) {
|
||||
// This doesn't rely on the plugin having been registred and instead that
|
||||
// the existence of --[name]_out is enough to make the --[name]_opt valid.
|
||||
// However, running out of process plugins found via the search path (i.e. -
|
||||
// not pre registered with --plugin) isn't support in this test suite, so we
|
||||
// list the options pre/post the _out directive, and then include _opt that
|
||||
// will be unknown, and confirm the failure output is about the expected
|
||||
// unknown directive, which means the other were accepted.
|
||||
// NOTE: UnrecognizedExtraParameters confirms that if two unknown _opt
|
||||
// directives appear, they both are reported.
|
||||
|
||||
CreateTempFile("foo.proto",
|
||||
"syntax = \"proto2\";\n"
|
||||
"message Foo {}\n");
|
||||
|
||||
Run("protocol_compiler --plug_out=TestParameter:$tmpdir "
|
||||
"--xyz_opt=foo=bar --xyz_out=$tmpdir "
|
||||
"--abc_out=$tmpdir --abc_opt=foo=bar "
|
||||
"--unknown_plug_opt=Foo "
|
||||
"--proto_path=$tmpdir foo.proto");
|
||||
|
||||
ExpectErrorSubstring("Unknown flag: --unknown_plug_opt");
|
||||
ExpectErrorText("Unknown flag: --unknown_plug_opt\n");
|
||||
}
|
||||
|
||||
TEST_F(CommandLineInterfaceTest, Insert) {
|
||||
|
@ -996,6 +1025,27 @@ TEST_F(CommandLineInterfaceTest, DirectDependencies_ProvidedMultipleTimes) {
|
|||
"':'.\n");
|
||||
}
|
||||
|
||||
TEST_F(CommandLineInterfaceTest, DirectDependencies_CustomErrorMessage) {
|
||||
CreateTempFile("foo.proto",
|
||||
"syntax = \"proto2\";\n"
|
||||
"import \"bar.proto\";\n"
|
||||
"message Foo { optional Bar bar = 1; }");
|
||||
CreateTempFile("bar.proto",
|
||||
"syntax = \"proto2\";\n"
|
||||
"message Bar { optional string text = 1; }");
|
||||
|
||||
vector<string> commands;
|
||||
commands.push_back("protocol_compiler");
|
||||
commands.push_back("--test_out=$tmpdir");
|
||||
commands.push_back("--proto_path=$tmpdir");
|
||||
commands.push_back("--direct_dependencies=");
|
||||
commands.push_back("--direct_dependencies_violation_msg=Bla \"%s\" Bla");
|
||||
commands.push_back("foo.proto");
|
||||
RunWithArgs(commands);
|
||||
|
||||
ExpectErrorText("foo.proto: Bla \"bar.proto\" Bla\n");
|
||||
}
|
||||
|
||||
TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) {
|
||||
// Test that we can accept working-directory-relative input files.
|
||||
|
||||
|
@ -1283,6 +1333,19 @@ TEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) {
|
|||
"foo.proto: Import \"baz.proto\" was not found or had errors.\n");
|
||||
}
|
||||
|
||||
TEST_F(CommandLineInterfaceTest, RecursiveImportFails) {
|
||||
// Create a proto file that imports itself.
|
||||
CreateTempFile("foo.proto",
|
||||
"syntax = \"proto2\";\n"
|
||||
"import \"foo.proto\";\n");
|
||||
|
||||
Run("protocol_compiler --test_out=$tmpdir "
|
||||
"--proto_path=$tmpdir foo.proto");
|
||||
|
||||
ExpectErrorSubstring(
|
||||
"foo.proto: File recursively imports itself: foo.proto -> foo.proto\n");
|
||||
}
|
||||
|
||||
TEST_F(CommandLineInterfaceTest, InputNotFoundError) {
|
||||
// Test what happens if the input file is not found.
|
||||
|
||||
|
|
|
@ -251,13 +251,15 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) {
|
|||
vars["classname"] = classname_;
|
||||
vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
|
||||
vars["constexpr"] = options_.proto_h ? "constexpr " : "";
|
||||
vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name());
|
||||
|
||||
if (HasDescriptorMethods(descriptor_->file(), options_)) {
|
||||
printer->Print(
|
||||
vars,
|
||||
"const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n"
|
||||
" protobuf_AssignDescriptorsOnce();\n"
|
||||
" return file_level_enum_descriptors[$index_in_metadata$];\n"
|
||||
" $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
|
||||
" return "
|
||||
"$file_namespace$::file_level_enum_descriptors[$index_in_metadata$];\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ void EnumOneofFieldGenerator::
|
|||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
printer->Print(
|
||||
variables_,
|
||||
" $classname$_default_oneof_instance_.$name$_ = $default$;\n");
|
||||
"_$classname$_default_instance_.$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue