aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs16
-rw-r--r--csharp/src/Google.Protobuf/Collections/MapField.cs11
-rw-r--r--csharp/src/Google.Protobuf/Google.Protobuf.csproj2
-rw-r--r--js/README.md10
-rw-r--r--php/ext/google/protobuf/map.c93
-rw-r--r--php/ext/google/protobuf/protobuf.c2
-rw-r--r--php/ext/google/protobuf/protobuf.h17
-rw-r--r--php/ext/google/protobuf/storage.c37
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto.php18
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptorProto.php4
-rw-r--r--php/src/Google/Protobuf/Internal/EnumOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumValueOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FieldDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FieldOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FileDescriptorProto.php18
-rw-r--r--php/src/Google/Protobuf/Internal/FileDescriptorSet.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FileOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php2
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MapFieldIter.php5
-rw-r--r--php/src/Google/Protobuf/Internal/MessageOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MethodDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MethodOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/OneofDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/OneofOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php4
-rw-r--r--php/src/Google/Protobuf/Internal/ServiceOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo.php2
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php6
-rw-r--r--php/src/Google/Protobuf/Internal/UninterpretedOption.php2
-rw-r--r--php/tests/array_test.php36
-rw-r--r--php/tests/encode_decode_test.php8
-rw-r--r--php/tests/map_field_test.php34
-rw-r--r--php/tests/memory_leak_test.php1
-rw-r--r--php/tests/proto/test.proto6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.cc18
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_primitive_field.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_message_builder.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_message_lite.cc4
-rw-r--r--src/google/protobuf/compiler/php/php_generator.cc9
-rw-r--r--src/google/protobuf/descriptor.pb.cc30
-rw-r--r--src/google/protobuf/io/coded_stream.h2
-rw-r--r--src/google/protobuf/map.h7
-rw-r--r--src/google/protobuf/stubs/hash.h2
45 files changed, 329 insertions, 117 deletions
diff --git a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
index 9d3d69af..68b4de45 100644
--- a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
@@ -540,6 +540,22 @@ namespace Google.Protobuf.Collections
Assert.Throws<ArgumentException>(() => map.ToString());
}
+#if !NET35
+ [Test]
+ public void IDictionaryKeys_Equals_IReadOnlyDictionaryKeys()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ CollectionAssert.AreEquivalent(((IDictionary<string, string>)map).Keys, ((IReadOnlyDictionary<string, string>)map).Keys);
+ }
+
+ [Test]
+ public void IDictionaryValues_Equals_IReadOnlyDictionaryValues()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ CollectionAssert.AreEquivalent(((IDictionary<string, string>)map).Values, ((IReadOnlyDictionary<string, string>)map).Values);
+ }
+#endif
+
private static KeyValuePair<TKey, TValue> NewKeyValuePair<TKey, TValue>(TKey key, TValue value)
{
return new KeyValuePair<TKey, TValue>(key, value);
diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs
index ef5651c9..8dac8e30 100644
--- a/csharp/src/Google.Protobuf/Collections/MapField.cs
+++ b/csharp/src/Google.Protobuf/Collections/MapField.cs
@@ -67,6 +67,9 @@ namespace Google.Protobuf.Collections
/// </para>
/// </remarks>
public sealed class MapField<TKey, TValue> : IDeepCloneable<MapField<TKey, TValue>>, IDictionary<TKey, TValue>, IEquatable<MapField<TKey, TValue>>, IDictionary
+#if !NET35
+ , IReadOnlyDictionary<TKey, TValue>
+#endif
{
// TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.)
private readonly Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>> map =
@@ -548,6 +551,14 @@ namespace Google.Protobuf.Collections
}
#endregion
+ #region IReadOnlyDictionary explicit interface implementation
+#if !NET35
+ IEnumerable<TKey> IReadOnlyDictionary<TKey, TValue>.Keys => Keys;
+
+ IEnumerable<TValue> IReadOnlyDictionary<TKey, TValue>.Values => Values;
+#endif
+ #endregion
+
private class DictionaryEnumerator : IDictionaryEnumerator
{
private readonly IEnumerator<KeyValuePair<TKey, TValue>> enumerator;
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
index 4eebd99e..46418e39 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/google/protobuf</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
- <RepositoryUrl>https://github.com/nodatime/nodatime.git</RepositoryUrl>
+ <RepositoryUrl>https://github.com/google/protobuf.git</RepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<IncludeSource>true</IncludeSource>
</PropertyGroup>
diff --git a/js/README.md b/js/README.md
index f4184621..24386dc7 100644
--- a/js/README.md
+++ b/js/README.md
@@ -19,7 +19,9 @@ resolve imports at compile time.
To use Protocol Buffers with JavaScript, you need two main components:
1. The protobuf runtime library. You can install this with
- `npm install google-protobuf`, or use the files in this directory.
+ `npm install google-protobuf`, or use the files in this directory.
+ If npm is not being used, as of 3.3.0, the files needed are located in binary subdirectory;
+ arith.js, constants.js, decoder.js, encoder.js, map.js, message.js, reader.js, utils.js, writer.js
2. The Protocol Compiler `protoc`. This translates `.proto` files
into `.js` files. The compiler is not currently available via
npm, but you can download a pre-built binary
@@ -93,6 +95,12 @@ statements like:
var message = proto.my.package.MyMessage();
+If unfamiliar with Closure or it's compiler, consider reviewing Closure documentation
+https://developers.google.com/closure/library/docs/tutorial
+https://developers.google.com/closure/library/docs/closurebuilder
+https://developers.google.com/closure/library/docs/depswriter
+At a high level, closurebuilder.py can walk dependencies, and compile your code, and all dependencies for Protobuf into a single .js file. Using depsbuilder.py to generate a dependency file can also be considered for non-production dev environments.
+
CommonJS imports
----------------
diff --git a/php/ext/google/protobuf/map.c b/php/ext/google/protobuf/map.c
index a5d48446..4a524864 100644
--- a/php/ext/google/protobuf/map.c
+++ b/php/ext/google/protobuf/map.c
@@ -143,6 +143,7 @@ static zend_function_entry map_field_methods[] = {
PHP_ME(MapField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetUnset, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, count, arginfo_void, ZEND_ACC_PUBLIC)
+ PHP_ME(MapField, getIterator, arginfo_void, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
@@ -156,7 +157,10 @@ static void map_field_write_dimension(zval *object, zval *key,
// -----------------------------------------------------------------------------
zend_class_entry* map_field_type;
+zend_class_entry* map_field_iter_type;
+
zend_object_handlers* map_field_handlers;
+zend_object_handlers* map_field_iter_handlers;
static void map_begin_internal(Map *map, MapIter *iter) {
iter->self = map;
@@ -231,8 +235,8 @@ PHP_PROTO_OBJECT_CREATE_END(Map, map_field)
// Init class entry.
PHP_PROTO_INIT_CLASS_START("Google\\Protobuf\\Internal\\MapField", Map,
map_field)
-zend_class_implements(map_field_type TSRMLS_CC, 2, spl_ce_ArrayAccess,
- spl_ce_Countable);
+zend_class_implements(map_field_type TSRMLS_CC, 3, spl_ce_ArrayAccess,
+ zend_ce_aggregate, spl_ce_Countable);
map_field_handlers->write_dimension = map_field_write_dimension;
map_field_handlers->get_gc = map_field_get_gc;
PHP_PROTO_INIT_CLASS_END
@@ -444,6 +448,15 @@ PHP_METHOD(MapField, count) {
RETURN_LONG(upb_strtable_count(&intern->table));
}
+PHP_METHOD(MapField, getIterator) {
+ CREATE_OBJ_ON_ALLOCATED_ZVAL_PTR(return_value,
+ map_field_iter_type);
+
+ Map *intern = UNBOX(Map, getThis());
+ MapIter *iter = UNBOX(MapIter, return_value);
+ map_begin(getThis(), iter TSRMLS_CC);
+}
+
// -----------------------------------------------------------------------------
// Map Iterator
// -----------------------------------------------------------------------------
@@ -470,3 +483,79 @@ upb_value map_iter_value(MapIter *iter, int *len) {
*len = native_slot_size(iter->self->value_type);
return upb_strtable_iter_value(&iter->it);
}
+
+// -----------------------------------------------------------------------------
+// MapFieldIter methods
+// -----------------------------------------------------------------------------
+static zend_function_entry map_field_iter_methods[] = {
+ PHP_ME(MapFieldIter, rewind, arginfo_void, ZEND_ACC_PUBLIC)
+ PHP_ME(MapFieldIter, current, arginfo_void, ZEND_ACC_PUBLIC)
+ PHP_ME(MapFieldIter, key, arginfo_void, ZEND_ACC_PUBLIC)
+ PHP_ME(MapFieldIter, next, arginfo_void, ZEND_ACC_PUBLIC)
+ PHP_ME(MapFieldIter, valid, arginfo_void, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+// -----------------------------------------------------------------------------
+// MapFieldIter creation/desctruction
+// -----------------------------------------------------------------------------
+
+// Define object free method.
+PHP_PROTO_OBJECT_FREE_START(MapIter, map_field_iter)
+PHP_PROTO_OBJECT_FREE_END
+
+PHP_PROTO_OBJECT_DTOR_START(MapIter, map_field_iter)
+PHP_PROTO_OBJECT_DTOR_END
+
+// Define object create method.
+PHP_PROTO_OBJECT_CREATE_START(MapIter, map_field_iter)
+intern->self = NULL;
+PHP_PROTO_OBJECT_CREATE_END(MapIter, map_field_iter)
+
+// Init class entry.
+PHP_PROTO_INIT_CLASS_START("Google\\Protobuf\\Internal\\MapFieldIter",
+ MapIter, map_field_iter)
+zend_class_implements(map_field_iter_type TSRMLS_CC, 1, zend_ce_iterator);
+PHP_PROTO_INIT_CLASS_END
+
+// -----------------------------------------------------------------------------
+// PHP MapFieldIter Methods
+// -----------------------------------------------------------------------------
+
+PHP_METHOD(MapFieldIter, rewind) {
+ MapIter *intern = UNBOX(MapIter, getThis());
+ map_begin_internal(intern->self, intern);
+}
+
+PHP_METHOD(MapFieldIter, current) {
+ MapIter *intern = UNBOX(MapIter, getThis());
+ Map *map_field = intern->self;
+
+ int value_length = 0;
+ upb_value value = map_iter_value(intern, &value_length);
+
+ void* mem = upb_value_memory(&value);
+ native_slot_get_by_array(map_field->value_type, mem,
+ ZVAL_PTR_TO_CACHED_PTR(return_value) TSRMLS_CC);
+}
+
+PHP_METHOD(MapFieldIter, key) {
+ MapIter *intern = UNBOX(MapIter, getThis());
+ Map *map_field = intern->self;
+
+ int key_length = 0;
+ const char* key = map_iter_key(intern, &key_length);
+
+ native_slot_get_by_map_key(map_field->key_type, key, key_length,
+ ZVAL_PTR_TO_CACHED_PTR(return_value) TSRMLS_CC);
+}
+
+PHP_METHOD(MapFieldIter, next) {
+ MapIter *intern = UNBOX(MapIter, getThis());
+ map_next(intern);
+}
+
+PHP_METHOD(MapFieldIter, valid) {
+ MapIter *intern = UNBOX(MapIter, getThis());
+ RETURN_BOOL(!map_done(intern));
+}
diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c
index 6a848b27..5de9cfe9 100644
--- a/php/ext/google/protobuf/protobuf.c
+++ b/php/ext/google/protobuf/protobuf.c
@@ -189,6 +189,7 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) {
static PHP_MINIT_FUNCTION(protobuf) {
map_field_init(TSRMLS_C);
+ map_field_iter_init(TSRMLS_C);
repeated_field_init(TSRMLS_C);
repeated_field_iter_init(TSRMLS_C);
gpb_type_init(TSRMLS_C);
@@ -206,6 +207,7 @@ static PHP_MSHUTDOWN_FUNCTION(protobuf) {
PEFREE(repeated_field_handlers);
PEFREE(repeated_field_iter_handlers);
PEFREE(map_field_handlers);
+ PEFREE(map_field_iter_handlers);
return 0;
}
diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h
index 406a09a5..eecae136 100644
--- a/php/ext/google/protobuf/protobuf.h
+++ b/php/ext/google/protobuf/protobuf.h
@@ -373,6 +373,7 @@ struct MessageLayout;
struct RepeatedField;
struct RepeatedFieldIter;
struct Map;
+struct MapIter;
struct Oneof;
typedef struct DescriptorPool DescriptorPool;
@@ -385,6 +386,7 @@ typedef struct MessageLayout MessageLayout;
typedef struct RepeatedField RepeatedField;
typedef struct RepeatedFieldIter RepeatedFieldIter;
typedef struct Map Map;
+typedef struct MapIter MapIter;
typedef struct Oneof Oneof;
// -----------------------------------------------------------------------------
@@ -400,6 +402,7 @@ void enum_descriptor_init(TSRMLS_D);
void descriptor_pool_init(TSRMLS_D);
void gpb_type_init(TSRMLS_D);
void map_field_init(TSRMLS_D);
+void map_field_iter_init(TSRMLS_D);
void repeated_field_init(TSRMLS_D);
void repeated_field_iter_init(TSRMLS_D);
void util_init(TSRMLS_D);
@@ -637,7 +640,7 @@ bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass,
bool native_slot_set_by_array(upb_fieldtype_t type,
const zend_class_entry* klass, void* memory,
zval* value TSRMLS_DC);
-void native_slot_init(upb_fieldtype_t type, void* memory, void* cache);
+void native_slot_init(upb_fieldtype_t type, void* memory, CACHED_VALUE* cache);
// For each property, in order to avoid conversion between the zval object and
// the actual data type during parsing/serialization, the containing message
// object use the custom memory layout to store the actual data type for each
@@ -659,6 +662,7 @@ void native_slot_get_default(upb_fieldtype_t type,
// -----------------------------------------------------------------------------
extern zend_object_handlers* map_field_handlers;
+extern zend_object_handlers* map_field_iter_handlers;
PHP_PROTO_WRAP_OBJECT_START(Map)
upb_fieldtype_t key_type;
@@ -667,10 +671,10 @@ PHP_PROTO_WRAP_OBJECT_START(Map)
upb_strtable table;
PHP_PROTO_WRAP_OBJECT_END
-typedef struct {
+PHP_PROTO_WRAP_OBJECT_START(MapIter)
Map* self;
upb_strtable_iter it;
-} MapIter;
+PHP_PROTO_WRAP_OBJECT_END
void map_begin(zval* self, MapIter* iter TSRMLS_DC);
void map_next(MapIter* iter);
@@ -709,6 +713,13 @@ PHP_METHOD(MapField, offsetGet);
PHP_METHOD(MapField, offsetSet);
PHP_METHOD(MapField, offsetUnset);
PHP_METHOD(MapField, count);
+PHP_METHOD(MapField, getIterator);
+
+PHP_METHOD(MapFieldIter, rewind);
+PHP_METHOD(MapFieldIter, current);
+PHP_METHOD(MapFieldIter, key);
+PHP_METHOD(MapFieldIter, next);
+PHP_METHOD(MapFieldIter, valid);
// -----------------------------------------------------------------------------
// Repeated Field.
diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c
index 6318f88c..6c789bcb 100644
--- a/php/ext/google/protobuf/storage.c
+++ b/php/ext/google/protobuf/storage.c
@@ -210,7 +210,7 @@ bool native_slot_set_by_array(upb_fieldtype_t type,
return true;
}
-void native_slot_init(upb_fieldtype_t type, void* memory, void* cache) {
+void native_slot_init(upb_fieldtype_t type, void* memory, CACHED_VALUE* cache) {
zval* tmp = NULL;
switch (type) {
case UPB_TYPE_FLOAT:
@@ -224,6 +224,9 @@ void native_slot_init(upb_fieldtype_t type, void* memory, void* cache) {
break;
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES:
+ DEREF(memory, CACHED_VALUE*) = cache;
+ ZVAL_EMPTY_STRING(CACHED_PTR_TO_ZVAL_PTR(cache));
+ break;
case UPB_TYPE_MESSAGE:
DEREF(memory, CACHED_VALUE*) = cache;
break;
@@ -355,6 +358,19 @@ void native_slot_get_by_array(upb_fieldtype_t type, const void* memory,
}
}
+void native_slot_get_by_map_key(upb_fieldtype_t type, const void* memory,
+ int length, CACHED_VALUE* cache TSRMLS_DC) {
+ switch (type) {
+ case UPB_TYPE_STRING:
+ case UPB_TYPE_BYTES: {
+ PHP_PROTO_ZVAL_STRINGL(CACHED_PTR_TO_ZVAL_PTR(cache), memory, length, 1);
+ return;
+ }
+ default:
+ native_slot_get(type, memory, cache TSRMLS_CC);
+ }
+}
+
void native_slot_get_default(upb_fieldtype_t type,
CACHED_VALUE* cache TSRMLS_DC) {
switch (type) {
@@ -608,6 +624,21 @@ void layout_init(MessageLayout* layout, void* storage,
int cache_index = slot_property_cache(layout, storage, field);
CACHED_VALUE* property_ptr = &properties_table[cache_index];
+ // Clean up initial value by generated code. In the generated code of
+ // previous versions, each php field is given an initial value. However, the
+ // order to initialize these fields may not be consistent with the order of
+ // upb fields.
+ if (Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR(property_ptr)) == IS_STRING) {
+#if PHP_MAJOR_VERSION < 7
+ if (!IS_INTERNED(Z_STRVAL_PP(property_ptr))) {
+ FREE(Z_STRVAL_PP(property_ptr));
+ }
+#else
+ zend_string_release(Z_STR_P(property_ptr));
+#endif
+ }
+ ZVAL_NULL(CACHED_PTR_TO_ZVAL_PTR(property_ptr));
+
if (upb_fielddef_containingoneof(field)) {
memset(memory, 0, NATIVE_SLOT_MAX_SIZE);
*oneof_case = ONEOF_CASE_NONE;
@@ -731,7 +762,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header,
}
}
-static native_slot_merge(const upb_fielddef* field, const void* from_memory,
+static void native_slot_merge(const upb_fielddef* field, const void* from_memory,
void* to_memory PHP_PROTO_TSRMLS_DC) {
upb_fieldtype_t type = upb_fielddef_type(field);
zend_class_entry* ce = NULL;
@@ -788,7 +819,7 @@ static native_slot_merge(const upb_fielddef* field, const void* from_memory,
}
}
-static native_slot_merge_by_array(const upb_fielddef* field, const void* from_memory,
+static void native_slot_merge_by_array(const upb_fielddef* field, const void* from_memory,
void* to_memory PHP_PROTO_TSRMLS_DC) {
upb_fieldtype_t type = upb_fielddef_type(field);
switch (type) {
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php
index 0fdaecfc..3f975b8a 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php
@@ -119,7 +119,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setField(&$var)
+ public function setField($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
$this->field = $arr;
@@ -147,7 +147,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setExtension(&$var)
+ public function setExtension($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
$this->extension = $arr;
@@ -175,7 +175,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\DescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setNestedType(&$var)
+ public function setNestedType($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
$this->nested_type = $arr;
@@ -203,7 +203,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\EnumDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setEnumType(&$var)
+ public function setEnumType($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
$this->enum_type = $arr;
@@ -231,7 +231,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\DescriptorProto_ExtensionRange[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setExtensionRange(&$var)
+ public function setExtensionRange($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class);
$this->extension_range = $arr;
@@ -259,7 +259,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\OneofDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setOneofDecl(&$var)
+ public function setOneofDecl($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class);
$this->oneof_decl = $arr;
@@ -287,7 +287,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\MessageOptions $var
* @return $this
*/
- public function setOptions(&$var)
+ public function setOptions($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class);
$this->options = $var;
@@ -315,7 +315,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\DescriptorProto_ReservedRange[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setReservedRange(&$var)
+ public function setReservedRange($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class);
$this->reserved_range = $arr;
@@ -349,7 +349,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* @param string[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setReservedName(&$var)
+ public function setReservedName($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->reserved_name = $arr;
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
index 6cdaf2df..adc21fc6 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
@@ -81,7 +81,7 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\EnumValueDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setValue(&$var)
+ public function setValue($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class);
$this->value = $arr;
@@ -109,7 +109,7 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\EnumOptions $var
* @return $this
*/
- public function setOptions(&$var)
+ public function setOptions($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class);
$this->options = $var;
diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php
index 3c3a9e22..6067d5a0 100644
--- a/php/src/Google/Protobuf/Internal/EnumOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumOptions.php
@@ -137,7 +137,7 @@ class EnumOptions extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setUninterpretedOption(&$var)
+ public function setUninterpretedOption($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr;
diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
index 89d6707f..b761fbcf 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
@@ -109,7 +109,7 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\EnumValueOptions $var
* @return $this
*/
- public function setOptions(&$var)
+ public function setOptions($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class);
$this->options = $var;
diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
index 3b5c58e4..b7bcd237 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
@@ -95,7 +95,7 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setUninterpretedOption(&$var)
+ public function setUninterpretedOption($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr;
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
index ae61be47..fbe4e1bf 100644
--- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
@@ -418,7 +418,7 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\FieldOptions $var
* @return $this
*/
- public function setOptions(&$var)
+ public function setOptions($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class);
$this->options = $var;
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php
index 157c0f82..593536ff 100644
--- a/php/src/Google/Protobuf/Internal/FieldOptions.php
+++ b/php/src/Google/Protobuf/Internal/FieldOptions.php
@@ -404,7 +404,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setUninterpretedOption(&$var)
+ public function setUninterpretedOption($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr;
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
index 3b1567d1..c61cf917 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
@@ -187,7 +187,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param string[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setDependency(&$var)
+ public function setDependency($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->dependency = $arr;
@@ -219,7 +219,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param int[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setPublicDependency(&$var)
+ public function setPublicDependency($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->public_dependency = $arr;
@@ -253,7 +253,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param int[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setWeakDependency(&$var)
+ public function setWeakDependency($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->weak_dependency = $arr;
@@ -285,7 +285,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\DescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setMessageType(&$var)
+ public function setMessageType($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
$this->message_type = $arr;
@@ -313,7 +313,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\EnumDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setEnumType(&$var)
+ public function setEnumType($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
$this->enum_type = $arr;
@@ -341,7 +341,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\ServiceDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setService(&$var)
+ public function setService($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class);
$this->service = $arr;
@@ -369,7 +369,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setExtension(&$var)
+ public function setExtension($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
$this->extension = $arr;
@@ -397,7 +397,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\FileOptions $var
* @return $this
*/
- public function setOptions(&$var)
+ public function setOptions($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class);
$this->options = $var;
@@ -435,7 +435,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\SourceCodeInfo $var
* @return $this
*/
- public function setSourceCodeInfo(&$var)
+ public function setSourceCodeInfo($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class);
$this->source_code_info = $var;
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
index 591e2a81..2b6ed0ab 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
@@ -44,7 +44,7 @@ class FileDescriptorSet extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\FileDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setFile(&$var)
+ public function setFile($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class);
$this->file = $arr;
diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php
index 2202102b..200ee9de 100644
--- a/php/src/Google/Protobuf/Internal/FileOptions.php
+++ b/php/src/Google/Protobuf/Internal/FileOptions.php
@@ -812,7 +812,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setUninterpretedOption(&$var)
+ public function setUninterpretedOption($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr;
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
index 35b47526..a69bef85 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
@@ -54,7 +54,7 @@ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setAnnotation(&$var)
+ public function setAnnotation($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class);
$this->annotation = $arr;
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
index c2e22e89..86c9f629 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
@@ -74,7 +74,7 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message
* @param int[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setPath(&$var)
+ public function setPath($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->path = $arr;
diff --git a/php/src/Google/Protobuf/Internal/MapFieldIter.php b/php/src/Google/Protobuf/Internal/MapFieldIter.php
index cb707955..88e6c8b2 100644
--- a/php/src/Google/Protobuf/Internal/MapFieldIter.php
+++ b/php/src/Google/Protobuf/Internal/MapFieldIter.php
@@ -91,9 +91,12 @@ class MapFieldIter implements \Iterator
public function key()
{
$key = key($this->container);
- // PHP associative array stores bool as integer for key.
if ($this->key_type === GPBType::BOOL) {
+ // PHP associative array stores bool as integer for key.
return boolval($key);
+ } elseif ($this->key_type === GPBType::STRING) {
+ // PHP associative array stores int string as int for key.
+ return strval($key);
} else {
return $key;
}
diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php
index 3677ca38..0a0bfb2d 100644
--- a/php/src/Google/Protobuf/Internal/MessageOptions.php
+++ b/php/src/Google/Protobuf/Internal/MessageOptions.php
@@ -311,7 +311,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setUninterpretedOption(&$var)
+ public function setUninterpretedOption($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr;
diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
index 69c25b69..95b614f3 100644
--- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
@@ -165,7 +165,7 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\MethodOptions $var
* @return $this
*/
- public function setOptions(&$var)
+ public function setOptions($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class);
$this->options = $var;
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php
index 5b2db776..17a8b453 100644
--- a/php/src/Google/Protobuf/Internal/MethodOptions.php
+++ b/php/src/Google/Protobuf/Internal/MethodOptions.php
@@ -128,7 +128,7 @@ class MethodOptions extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setUninterpretedOption(&$var)
+ public function setUninterpretedOption($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr;
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
index 0d4f3bdc..255ff572 100644
--- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
@@ -76,7 +76,7 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\OneofOptions $var
* @return $this
*/
- public function setOptions(&$var)
+ public function setOptions($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class);
$this->options = $var;
diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php
index aa8c934c..fb8c3bfa 100644
--- a/php/src/Google/Protobuf/Internal/OneofOptions.php
+++ b/php/src/Google/Protobuf/Internal/OneofOptions.php
@@ -47,7 +47,7 @@ class OneofOptions extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setUninterpretedOption(&$var)
+ public function setUninterpretedOption($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr;
diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
index 963cd650..e10bd533 100644
--- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
@@ -81,7 +81,7 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\MethodDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setMethod(&$var)
+ public function setMethod($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class);
$this->method = $arr;
@@ -109,7 +109,7 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\ServiceOptions $var
* @return $this
*/
- public function setOptions(&$var)
+ public function setOptions($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class);
$this->options = $var;
diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php
index ea649865..a2319170 100644
--- a/php/src/Google/Protobuf/Internal/ServiceOptions.php
+++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php
@@ -95,7 +95,7 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setUninterpretedOption(&$var)
+ public function setUninterpretedOption($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr;
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
index 65530586..d21fe8eb 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
@@ -170,7 +170,7 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\SourceCodeInfo_Location[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setLocation(&$var)
+ public function setLocation($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo_Location::class);
$this->location = $arr;
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
index b33013b8..210bf073 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
@@ -170,7 +170,7 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
* @param int[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setPath(&$var)
+ public function setPath($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->path = $arr;
@@ -210,7 +210,7 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
* @param int[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setSpan(&$var)
+ public function setSpan($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->span = $arr;
@@ -368,7 +368,7 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
* @param string[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setLeadingDetachedComments(&$var)
+ public function setLeadingDetachedComments($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->leading_detached_comments = $arr;
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
index a4fab343..daa730d0 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
@@ -81,7 +81,7 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message
* @param \Google\Protobuf\Internal\UninterpretedOption_NamePart[]|\Google\Protobuf\Internal\RepeatedField $var
* @return $this
*/
- public function setName(&$var)
+ public function setName($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption_NamePart::class);
$this->name = $arr;
diff --git a/php/tests/array_test.php b/php/tests/array_test.php
index 271389ba..e57f0a7e 100644
--- a/php/tests/array_test.php
+++ b/php/tests/array_test.php
@@ -521,21 +521,23 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase
# Test memory leak
#########################################################
- public function testCycleLeak()
- {
- $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class);
- $arr[] = new TestMessage;
- $arr[0]->SetRepeatedRecursive($arr);
-
- // Clean up memory before test.
- gc_collect_cycles();
- $start = memory_get_usage();
- unset($arr);
-
- // Explicitly trigger garbage collection.
- gc_collect_cycles();
-
- $end = memory_get_usage();
- $this->assertLessThan($start, $end);
- }
+ // COMMENTED OUT BY @bshaffer
+ // @see https://github.com/google/protobuf/pull/3344#issuecomment-315162761
+ // public function testCycleLeak()
+ // {
+ // $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class);
+ // $arr[] = new TestMessage;
+ // $arr[0]->SetRepeatedRecursive($arr);
+
+ // // Clean up memory before test.
+ // gc_collect_cycles();
+ // $start = memory_get_usage();
+ // unset($arr);
+
+ // // Explicitly trigger garbage collection.
+ // gc_collect_cycles();
+
+ // $end = memory_get_usage();
+ // $this->assertLessThan($start, $end);
+ // }
}
diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php
index 2ea360b2..b43dffb4 100644
--- a/php/tests/encode_decode_test.php
+++ b/php/tests/encode_decode_test.php
@@ -9,6 +9,7 @@ use Foo\TestEnum;
use Foo\TestMessage;
use Foo\TestMessage_Sub;
use Foo\TestPackedMessage;
+use Foo\TestRandomFieldOrder;
use Foo\TestUnpackedMessage;
class EncodeDecodeTest extends TestBase
@@ -235,6 +236,13 @@ class EncodeDecodeTest extends TestBase
$this->assertEquals(-1, $m->getOptionalInt32());
}
+ public function testRandomFieldOrder()
+ {
+ $m = new TestRandomFieldOrder();
+ $data = $m->serializeToString();
+ $this->assertSame("", $data);
+ }
+
/**
* @expectedException Exception
*/
diff --git a/php/tests/map_field_test.php b/php/tests/map_field_test.php
index c5d21264..120b1bde 100644
--- a/php/tests/map_field_test.php
+++ b/php/tests/map_field_test.php
@@ -56,6 +56,23 @@ class MapFieldTest extends PHPUnit_Framework_TestCase {
unset($arr['3.1']);
unset($arr[MAX_INT32_STRING]);
$this->assertEquals(0, count($arr));
+
+ // Test foreach.
+ $arr = new MapField(GPBType::INT32, GPBType::INT32);
+ for ($i = 0; $i < 3; $i++) {
+ $arr[$i] = $i;
+ }
+ $i = 0;
+ $arr_test = [];
+ foreach ($arr as $key => $val) {
+ $this->assertSame($key, $val);
+ $arr_test[] = $key;
+ $i++;
+ }
+ $this->assertTrue(isset($arr_test[0]));
+ $this->assertTrue(isset($arr_test[1]));
+ $this->assertTrue(isset($arr_test[2]));
+ $this->assertSame(3, $i);
}
#########################################################
@@ -366,6 +383,23 @@ class MapFieldTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(1, count($arr));
unset($arr[True]);
$this->assertEquals(0, count($arr));
+
+ // Test foreach.
+ $arr = new MapField(GPBType::STRING, GPBType::STRING);
+ for ($i = 0; $i < 3; $i++) {
+ $arr[$i] = $i;
+ }
+ $i = 0;
+ $arr_test = [];
+ foreach ($arr as $key => $val) {
+ $this->assertSame($key, $val);
+ $arr_test[] = $key;
+ $i++;
+ }
+ $this->assertTrue(isset($arr_test['0']));
+ $this->assertTrue(isset($arr_test['1']));
+ $this->assertTrue(isset($arr_test['2']));
+ $this->assertSame(3, $i);
}
#########################################################
diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php
index 6572fdd0..faa1833d 100644
--- a/php/tests/memory_leak_test.php
+++ b/php/tests/memory_leak_test.php
@@ -20,6 +20,7 @@ require_once('generated/Foo/TestMessage_NestedEnum.php');
require_once('generated/Foo/TestMessage_Sub.php');
require_once('generated/Foo/TestPackedMessage.php');
require_once('generated/Foo/TestPhpDoc.php');
+require_once('generated/Foo/TestRandomFieldOrder.php');
require_once('generated/Foo/TestUnpackedMessage.php');
require_once('generated/GPBMetadata/Proto/Test.php');
require_once('generated/GPBMetadata/Proto/TestEmptyPhpNamespace.php');
diff --git a/php/tests/proto/test.proto b/php/tests/proto/test.proto
index dada8b48..d81f66f5 100644
--- a/php/tests/proto/test.proto
+++ b/php/tests/proto/test.proto
@@ -181,3 +181,9 @@ message TestIncludeNamespaceMessage {
TestNamespace namespace_message = 1;
TestEmptyNamespace empty_namespace_message = 2;
}
+
+// This will cause upb fields not ordered by the order in the generated code.
+message TestRandomFieldOrder {
+ int64 tag13 = 150;
+ string tag14 = 160;
+}
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index 0d3fdcbe..960730ca 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -144,13 +144,13 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
"} else {\n"
" mutable_unknown_fields()->AddVarint(\n"
- " $number$, static_cast<::google::protobuf::uint64>(value));\n");
+ " $number$, static_cast< ::google::protobuf::uint64>(value));\n");
} else {
printer->Print(
"} else {\n"
" unknown_fields_stream.WriteVarint32($tag$u);\n"
" unknown_fields_stream.WriteVarint32(\n"
- " static_cast<::google::protobuf::uint32>(value));\n",
+ " static_cast< ::google::protobuf::uint32>(value));\n",
"tag", SimpleItoa(internal::WireFormat::MakeTag(descriptor_)));
}
printer->Print(variables_,
@@ -347,13 +347,13 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
"} else {\n"
" mutable_unknown_fields()->AddVarint(\n"
- " $number$, static_cast<::google::protobuf::uint64>(value));\n");
+ " $number$, static_cast< ::google::protobuf::uint64>(value));\n");
} else {
printer->Print(
"} else {\n"
" unknown_fields_stream.WriteVarint32(tag);\n"
" unknown_fields_stream.WriteVarint32(\n"
- " static_cast<::google::protobuf::uint32>(value));\n");
+ " static_cast< ::google::protobuf::uint32>(value));\n");
}
printer->Print("}\n");
}
@@ -412,12 +412,12 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(variables_,
" mutable_unknown_fields()->AddVarint(\n"
- " $number$, static_cast<::google::protobuf::uint64>(value));\n");
+ " $number$, static_cast< ::google::protobuf::uint64>(value));\n");
} else {
printer->Print(variables_,
" unknown_fields_stream.WriteVarint32(tag);\n"
" unknown_fields_stream.WriteVarint32(\n"
- " static_cast<::google::protobuf::uint32>(value));\n");
+ " static_cast< ::google::protobuf::uint32>(value));\n");
}
printer->Print(
" }\n");
@@ -439,7 +439,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
" output);\n"
" output->WriteVarint32(\n"
- " static_cast<::google::protobuf::uint32>(_$name$_cached_byte_size_));\n"
+ " static_cast< ::google::protobuf::uint32>(_$name$_cached_byte_size_));\n"
"}\n");
}
printer->Print(variables_,
@@ -467,7 +467,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
" target);\n"
" target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray("
- " static_cast<::google::protobuf::uint32>(\n"
+ " static_cast< ::google::protobuf::uint32>(\n"
" _$name$_cached_byte_size_), target);\n"
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n"
" this->$name$_, target);\n"
@@ -497,7 +497,7 @@ GenerateByteSize(io::Printer* printer) const {
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
" ::google::protobuf::internal::WireFormatLite::Int32Size(\n"
- " static_cast<google::protobuf::int32>(data_size));\n"
+ " static_cast< ::google::protobuf::int32>(data_size));\n"
"}\n"
"int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n"
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n"
diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index 83bc096f..e45f35b3 100644
--- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -382,7 +382,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
"$number$, "
"::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, "
"output);\n"
- " output->WriteVarint32(static_cast<::google::protobuf::uint32>(\n"
+ " output->WriteVarint32(static_cast< ::google::protobuf::uint32>(\n"
" _$name$_cached_byte_size_));\n");
if (FixedSize(descriptor_->type()) > 0) {
@@ -423,7 +423,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
" target);\n"
" target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\n"
- " static_cast<::google::protobuf::uint32>(\n"
+ " static_cast< ::google::protobuf::uint32>(\n"
" _$name$_cached_byte_size_), target);\n"
" target = ::google::protobuf::internal::WireFormatLite::\n"
" Write$declared_type$NoTagToArray(this->$name$_, target);\n"
@@ -455,7 +455,7 @@ GenerateByteSize(io::Printer* printer) const {
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
" ::google::protobuf::internal::WireFormatLite::Int32Size(\n"
- " static_cast<google::protobuf::int32>(data_size));\n"
+ " static_cast< ::google::protobuf::int32>(data_size));\n"
"}\n"
"int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n"
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n"
diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc
index f5643abc..56017171 100644
--- a/src/google/protobuf/compiler/java/java_message_builder.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder.cc
@@ -472,7 +472,7 @@ GenerateCommonBuilderMethods(io::Printer* printer) {
"}\n"
"public Builder setField(\n"
" com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " Object value) {\n"
+ " java.lang.Object value) {\n"
" return (Builder) super.setField(field, value);\n"
"}\n"
"public Builder clearField(\n"
@@ -485,12 +485,12 @@ GenerateCommonBuilderMethods(io::Printer* printer) {
"}\n"
"public Builder setRepeatedField(\n"
" com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " int index, Object value) {\n"
+ " int index, java.lang.Object value) {\n"
" return (Builder) super.setRepeatedField(field, index, value);\n"
"}\n"
"public Builder addRepeatedField(\n"
" com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " Object value) {\n"
+ " java.lang.Object value) {\n"
" return (Builder) super.addRepeatedField(field, value);\n"
"}\n");
diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc
index 5007ecee..aad10bb1 100644
--- a/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -346,9 +346,9 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
printer->Print(
"@java.lang.SuppressWarnings({\"unchecked\", \"fallthrough\"})\n"
- "protected final Object dynamicMethod(\n"
+ "protected final java.lang.Object dynamicMethod(\n"
" com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n"
- " Object arg0, Object arg1) {\n"
+ " java.lang.Object arg0, java.lang.Object arg1) {\n"
" switch (method) {\n"
" case NEW_MUTABLE_INSTANCE: {\n"
" return new $classname$();\n"
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index 03aebdb9..17d8ebad 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -534,12 +534,9 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor,
// Generate setter.
GenerateFieldDocComment(printer, field, is_descriptor, kFieldSetter);
printer->Print(
- "public function set^camel_name^(^var^)\n"
+ "public function set^camel_name^($var)\n"
"{\n",
- "camel_name", UnderscoresToCamelCase(field->name(), true),
- "var", (field->is_repeated() ||
- field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ?
- "&$var": "$var");
+ "camel_name", UnderscoresToCamelCase(field->name(), true));
Indent(printer);
@@ -844,7 +841,7 @@ void GenerateUseDeclaration(bool is_descriptor, io::Printer* printer) {
"use Google\\Protobuf\\Internal\\GPBType;\n"
"use Google\\Protobuf\\Internal\\GPBWire;\n"
"use Google\\Protobuf\\Internal\\RepeatedField;\n"
- "use Google\\Protobuf\\Internal\\InputStream;\n\n"
+ "use Google\\Protobuf\\Internal\\InputStream;\n"
"use Google\\Protobuf\\Internal\\GPBUtil;\n\n");
}
}
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc
index 6e4e4088..48a256dd 100644
--- a/src/google/protobuf/descriptor.pb.cc
+++ b/src/google/protobuf/descriptor.pb.cc
@@ -4565,7 +4565,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
set_label(static_cast< ::google::protobuf::FieldDescriptorProto_Label >(value));
} else {
mutable_unknown_fields()->AddVarint(
- 4, static_cast<::google::protobuf::uint64>(value));
+ 4, static_cast< ::google::protobuf::uint64>(value));
}
} else {
goto handle_unusual;
@@ -4585,7 +4585,7 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
set_type(static_cast< ::google::protobuf::FieldDescriptorProto_Type >(value));
} else {
mutable_unknown_fields()->AddVarint(
- 5, static_cast<::google::protobuf::uint64>(value));
+ 5, static_cast< ::google::protobuf::uint64>(value));
}
} else {
goto handle_unusual;
@@ -8513,7 +8513,7 @@ bool FileOptions::MergePartialFromCodedStream(
set_optimize_for(static_cast< ::google::protobuf::FileOptions_OptimizeMode >(value));
} else {
mutable_unknown_fields()->AddVarint(
- 9, static_cast<::google::protobuf::uint64>(value));
+ 9, static_cast< ::google::protobuf::uint64>(value));
}
} else {
goto handle_unusual;
@@ -10774,7 +10774,7 @@ bool FieldOptions::MergePartialFromCodedStream(
set_ctype(static_cast< ::google::protobuf::FieldOptions_CType >(value));
} else {
mutable_unknown_fields()->AddVarint(
- 1, static_cast<::google::protobuf::uint64>(value));
+ 1, static_cast< ::google::protobuf::uint64>(value));
}
} else {
goto handle_unusual;
@@ -10836,7 +10836,7 @@ bool FieldOptions::MergePartialFromCodedStream(
set_jstype(static_cast< ::google::protobuf::FieldOptions_JSType >(value));
} else {
mutable_unknown_fields()->AddVarint(
- 6, static_cast<::google::protobuf::uint64>(value));
+ 6, static_cast< ::google::protobuf::uint64>(value));
}
} else {
goto handle_unusual;
@@ -12917,7 +12917,7 @@ bool MethodOptions::MergePartialFromCodedStream(
set_idempotency_level(static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(value));
} else {
mutable_unknown_fields()->AddVarint(
- 34, static_cast<::google::protobuf::uint64>(value));
+ 34, static_cast< ::google::protobuf::uint64>(value));
}
} else {
goto handle_unusual;
@@ -14703,7 +14703,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
// repeated int32 path = 1 [packed = true];
if (this->path_size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
- output->WriteVarint32(static_cast<::google::protobuf::uint32>(
+ output->WriteVarint32(static_cast< ::google::protobuf::uint32>(
_path_cached_byte_size_));
}
for (int i = 0, n = this->path_size(); i < n; i++) {
@@ -14714,7 +14714,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
// repeated int32 span = 2 [packed = true];
if (this->span_size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
- output->WriteVarint32(static_cast<::google::protobuf::uint32>(
+ output->WriteVarint32(static_cast< ::google::protobuf::uint32>(
_span_cached_byte_size_));
}
for (int i = 0, n = this->span_size(); i < n; i++) {
@@ -14773,7 +14773,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
target);
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
- static_cast<::google::protobuf::uint32>(
+ static_cast< ::google::protobuf::uint32>(
_path_cached_byte_size_), target);
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->path_, target);
@@ -14786,7 +14786,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
target);
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
- static_cast<::google::protobuf::uint32>(
+ static_cast< ::google::protobuf::uint32>(
_span_cached_byte_size_), target);
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->span_, target);
@@ -14849,7 +14849,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
- static_cast<google::protobuf::int32>(data_size));
+ static_cast< ::google::protobuf::int32>(data_size));
}
int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -14865,7 +14865,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
- static_cast<google::protobuf::int32>(data_size));
+ static_cast< ::google::protobuf::int32>(data_size));
}
int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -15707,7 +15707,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes(
// repeated int32 path = 1 [packed = true];
if (this->path_size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
- output->WriteVarint32(static_cast<::google::protobuf::uint32>(
+ output->WriteVarint32(static_cast< ::google::protobuf::uint32>(
_path_cached_byte_size_));
}
for (int i = 0, n = this->path_size(); i < n; i++) {
@@ -15756,7 +15756,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
target);
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
- static_cast<::google::protobuf::uint32>(
+ static_cast< ::google::protobuf::uint32>(
_path_cached_byte_size_), target);
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->path_, target);
@@ -15808,7 +15808,7 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
- static_cast<google::protobuf::int32>(data_size));
+ static_cast< ::google::protobuf::int32>(data_size));
}
int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index 20d86143..9f1cf88c 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -1434,7 +1434,7 @@ inline bool CodedInputStream::IsFlat() const {
} // namespace protobuf
-#if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
+#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
#pragma runtime_checks("c", restore)
#endif // _MSC_VER && !defined(__INTEL_COMPILER)
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index 28eaf031..6a88600c 100644
--- a/src/google/protobuf/map.h
+++ b/src/google/protobuf/map.h
@@ -862,14 +862,7 @@ class Map {
size_type BucketNumber(const Key& k) const {
// We inherit from hasher, so one-arg operator() provides a hash function.
size_type h = (*const_cast<InnerMap*>(this))(k);
- // To help prevent people from making assumptions about the hash function,
- // we use the seed differently depending on NDEBUG. The default hash
- // function, the seeding, etc., are all likely to change in the future.
-#ifndef NDEBUG
- return (h * (seed_ | 1)) & (num_buckets_ - 1);
-#else
return (h + seed_) & (num_buckets_ - 1);
-#endif
}
bool IsMatch(const Key& k0, const Key& k1) const {
diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h
index 5924de98..612b5861 100644
--- a/src/google/protobuf/stubs/hash.h
+++ b/src/google/protobuf/stubs/hash.h
@@ -42,7 +42,7 @@
#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
// Use C++11 unordered_{map|set} if available.
-#if ((_LIBCPP_STD_VER >= 11) || \
+#if ((defined(_LIBCPP_STD_VER) && _LIBCPP_STD_VER >= 11) || \
(((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \
(__GLIBCXX__ > 20090421)))
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH