Remove callers of mojo::Array<size_t> constructor in favor of ::New This creates an ambiguity with Array(0) if we try to add a mojo::Array(std::nullptr_t) constructor. This just removes callers, it doesn't remove the constructor itself. I'll remove the constructor after verifying downstream consumers won't be broken. R=viettrungluu@chromium.org Review URL: https://codereview.chromium.org/1397133002 .
diff --git a/apps/moterm/moterm_driver.cc b/apps/moterm/moterm_driver.cc index c556719..a6af1da 100644 --- a/apps/moterm/moterm_driver.cc +++ b/apps/moterm/moterm_driver.cc
@@ -134,7 +134,7 @@ size_t data_size = std::min(static_cast<size_t>(pending_read.num_bytes), send_data_queue_.size()); - mojo::Array<uint8_t> data(data_size); + auto data = mojo::Array<uint8_t>::New(data_size); for (size_t i = 0; i < data_size; i++) { data[i] = send_data_queue_[i]; // In canonical mode, each read only gets a single line.
diff --git a/examples/moterm_example_app/moterm_example_app.cc b/examples/moterm_example_app/moterm_example_app.cc index 94ccac1..e52ea0f 100644 --- a/examples/moterm_example_app/moterm_example_app.cc +++ b/examples/moterm_example_app/moterm_example_app.cc
@@ -36,7 +36,7 @@ // Kind of like |fputs()| (doesn't wait for result). void Fputs(mojo::files::File* file, const char* s) { size_t length = strlen(s); - mojo::Array<uint8_t> a(length); + auto a = mojo::Array<uint8_t>::New(length); memcpy(&a[0], s, length); file->Write(a.Pass(), 0, mojo::files::Whence::FROM_CURRENT,
diff --git a/examples/native_run_app/native_run_app.cc b/examples/native_run_app/native_run_app.cc index a736dc3..306265f 100644 --- a/examples/native_run_app/native_run_app.cc +++ b/examples/native_run_app/native_run_app.cc
@@ -52,7 +52,7 @@ private: void Write(const char* s, mojo::files::File::WriteCallback callback) { size_t length = strlen(s); - mojo::Array<uint8_t> a(length); + auto a = mojo::Array<uint8_t>::New(length); memcpy(&a[0], s, length); terminal_->Write(a.Pass(), 0, mojo::files::Whence::FROM_CURRENT, callback); }
diff --git a/mojo/converters/array_string/array_string_type_converters.cc b/mojo/converters/array_string/array_string_type_converters.cc index 02019f0..84d3c2a 100644 --- a/mojo/converters/array_string/array_string_type_converters.cc +++ b/mojo/converters/array_string/array_string_type_converters.cc
@@ -21,7 +21,7 @@ Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert( const std::string& input) { - Array<uint8_t> result(input.size()); + auto result = Array<uint8_t>::New(input.size()); memcpy(&result.front(), input.c_str(), input.size()); return result.Pass(); }
diff --git a/mojo/converters/array_string/array_string_type_converters_unittest.cc b/mojo/converters/array_string/array_string_type_converters_unittest.cc index a28f571..219f981 100644 --- a/mojo/converters/array_string/array_string_type_converters_unittest.cc +++ b/mojo/converters/array_string/array_string_type_converters_unittest.cc
@@ -12,7 +12,7 @@ namespace { TEST(CommonTypeConvertersTest, ArrayUint8ToStdString) { - Array<uint8_t> data(4); + auto data = Array<uint8_t>::New(4); data[0] = 'd'; data[1] = 'a'; data[2] = 't';
diff --git a/mojo/converters/surfaces/surfaces_type_converters.cc b/mojo/converters/surfaces/surfaces_type_converters.cc index ecf6550..2c273dd 100644 --- a/mojo/converters/surfaces/surfaces_type_converters.cc +++ b/mojo/converters/surfaces/surfaces_type_converters.cc
@@ -299,7 +299,7 @@ PointF::From(texture_quad->uv_bottom_right); texture_state->background_color = Color::From(texture_quad->background_color); - Array<float> vertex_opacity(4); + auto vertex_opacity = Array<float>::New(4); for (size_t i = 0; i < 4; ++i) { vertex_opacity[i] = texture_quad->vertex_opacity[i]; } @@ -367,9 +367,9 @@ pass->transform_to_root_target = Transform::From(input.transform_to_root_target); pass->has_transparent_background = input.has_transparent_background; - Array<QuadPtr> quads(input.quad_list.size()); - Array<SharedQuadStatePtr> shared_quad_state( - input.shared_quad_state_list.size()); + auto quads = Array<QuadPtr>::New(input.quad_list.size()); + auto shared_quad_state = + Array<SharedQuadStatePtr>::New(input.shared_quad_state_list.size()); const cc::SharedQuadState* last_sqs = nullptr; cc::SharedQuadStateList::ConstIterator next_sqs_iter = input.shared_quad_state_list.begin(); @@ -424,7 +424,7 @@ // static MailboxPtr TypeConverter<MailboxPtr, gpu::Mailbox>::Convert( const gpu::Mailbox& input) { - Array<int8_t> name(64); + auto name = Array<int8_t>::New(64); for (int i = 0; i < 64; ++i) { name[i] = input.name[i]; } @@ -497,7 +497,7 @@ Array<TransferableResourcePtr>, cc::TransferableResourceArray>::Convert(const cc::TransferableResourceArray& input) { - Array<TransferableResourcePtr> resources(input.size()); + auto resources = Array<TransferableResourcePtr>::New(input.size()); for (size_t i = 0; i < input.size(); ++i) { resources[i] = TransferableResource::From(input[i]); } @@ -543,7 +543,7 @@ Array<ReturnedResourcePtr> TypeConverter<Array<ReturnedResourcePtr>, cc::ReturnedResourceArray>::Convert( const cc::ReturnedResourceArray& input) { - Array<ReturnedResourcePtr> resources(input.size()); + auto resources = Array<ReturnedResourcePtr>::New(input.size()); for (size_t i = 0; i < input.size(); ++i) { resources[i] = ReturnedResource::From(input[i]); }
diff --git a/mojo/dart/embedder/test/dart_to_cpp_tests.cc b/mojo/dart/embedder/test/dart_to_cpp_tests.cc index 12ae53c..40ed395 100644 --- a/mojo/dart/embedder/test/dart_to_cpp_tests.cc +++ b/mojo/dart/embedder/test/dart_to_cpp_tests.cc
@@ -96,7 +96,7 @@ args->double_inf = kExpectedDoubleInf; args->double_nan = kExpectedDoubleNan; args->name = "coming"; - Array<String> string_array(3); + auto string_array = Array<String>::New(3); string_array[0] = "one"; string_array[1] = "two"; string_array[2] = "three";
diff --git a/mojo/public/cpp/bindings/array.h b/mojo/public/cpp/bindings/array.h index e765bb1..b6b3f47 100644 --- a/mojo/public/cpp/bindings/array.h +++ b/mojo/public/cpp/bindings/array.h
@@ -56,7 +56,11 @@ // Creates a non-null array of the specified size. The elements will be // value-initialized (meaning that they will be initialized by their default // constructor, if any, or else zero-initialized). - static Array New(size_t size) { return Array(size).Pass(); } + static Array New(size_t size) { + Array ret; + ret.resize(size); + return ret; + } // Creates a new array with a copy of the contents of |other|. template <typename U> @@ -256,7 +260,7 @@ template <typename T, typename E> struct TypeConverter<Array<T>, std::vector<E>> { static Array<T> Convert(const std::vector<E>& input) { - Array<T> result(input.size()); + auto result = Array<T>::New(input.size()); for (size_t i = 0; i < input.size(); ++i) result[i] = TypeConverter<T, E>::Convert(input[i]); return result.Pass(); @@ -285,7 +289,7 @@ template <typename T, typename E> struct TypeConverter<Array<T>, std::set<E>> { static Array<T> Convert(const std::set<E>& input) { - Array<T> result(0u); + Array<T> result = Array<T>::New(0u); for (auto i : input) result.push_back(TypeConverter<T, E>::Convert(i)); return result.Pass();
diff --git a/mojo/public/cpp/bindings/lib/array_serialization.h b/mojo/public/cpp/bindings/lib/array_serialization.h index effec05..c6471e2 100644 --- a/mojo/public/cpp/bindings/lib/array_serialization.h +++ b/mojo/public/cpp/bindings/lib/array_serialization.h
@@ -115,7 +115,7 @@ static void DeserializeElements(Array_Data<bool>* input, Array<bool>* output) { - Array<bool> result(input->size()); + auto result = Array<bool>::New(input->size()); // TODO(darin): Can this be a memcpy somehow instead of a bit-by-bit copy? for (size_t i = 0; i < input->size(); ++i) result.at(i) = input->at(i); @@ -158,7 +158,7 @@ static void DeserializeElements(Array_Data<H>* input, Array<ScopedHandleBase<H>>* output) { - Array<ScopedHandleBase<H>> result(input->size()); + auto result = Array<ScopedHandleBase<H>>::New(input->size()); for (size_t i = 0; i < input->size(); ++i) result.at(i) = MakeScopedHandle(FetchAndReset(&input->at(i))); output->Swap(&result); @@ -213,7 +213,7 @@ static void DeserializeElements(Array_Data<S_Data*>* input, Array<S>* output) { - Array<S> result(input->size()); + auto result = Array<S>::New(input->size()); for (size_t i = 0; i < input->size(); ++i) { DeserializeCaller::Run(input->at(i), &result[i]); } @@ -335,7 +335,7 @@ } static void DeserializeElements(Array_Data<U_Data>* input, Array<U>* output) { - Array<U> result(input->size()); + auto result = Array<U>::New(input->size()); for (size_t i = 0; i < input->size(); ++i) { auto& elem = input->at(i); if (!elem.is_null()) {
diff --git a/mojo/public/cpp/bindings/tests/array_unittest.cc b/mojo/public/cpp/bindings/tests/array_unittest.cc index 3eecd52..b5439fc 100644 --- a/mojo/public/cpp/bindings/tests/array_unittest.cc +++ b/mojo/public/cpp/bindings/tests/array_unittest.cc
@@ -31,7 +31,7 @@ // Tests that basic Array operations work. TEST_F(ArrayTest, Basic) { - Array<char> array(8); + auto array = Array<char>::New(8); for (size_t i = 0; i < array.size(); ++i) { char val = static_cast<char>(i * 2); array[i] = val; @@ -41,7 +41,7 @@ // Tests that basic Array<bool> operations work. TEST_F(ArrayTest, Bool) { - Array<bool> array(64); + auto array = Array<bool>::New(64); for (size_t i = 0; i < array.size(); ++i) { bool val = i % 3 == 0; array[i] = val; @@ -52,7 +52,7 @@ // Tests that Array<ScopedMessagePipeHandle> supports transferring handles. TEST_F(ArrayTest, Handle) { MessagePipe pipe; - Array<ScopedMessagePipeHandle> handles(2); + auto handles = Array<ScopedMessagePipeHandle>::New(2); handles[0] = pipe.handle0.Pass(); handles[1].reset(pipe.handle1.release()); @@ -75,7 +75,7 @@ MojoHandle pipe1_value = pipe.handle0.get().value(); { - Array<ScopedMessagePipeHandle> handles(2); + auto handles = Array<ScopedMessagePipeHandle>::New(2); handles[0] = pipe.handle0.Pass(); handles[1].reset(pipe.handle0.release()); } @@ -88,7 +88,7 @@ TEST_F(ArrayTest, Clone) { { // Test POD. - Array<int32_t> array(3); + auto array = Array<int32_t>::New(3); for (size_t i = 0; i < array.size(); ++i) array[i] = static_cast<int32_t>(i); @@ -100,7 +100,7 @@ { // Test copyable object. - Array<String> array(2); + auto array = Array<String>::New(2); array[0] = "hello"; array[1] = "world"; @@ -112,7 +112,7 @@ { // Test struct. - Array<RectPtr> array(2); + auto array = Array<RectPtr>::New(2); array[1] = Rect::New(); array[1]->x = 1; array[1]->y = 2; @@ -130,8 +130,8 @@ { // Test array of array. - Array<Array<int8_t>> array(2); - array[1] = Array<int8_t>(2); + auto array = Array<Array<int8_t>>::New(2); + array[1] = Array<int8_t>::New(2); array[1][0] = 0; array[1][1] = 1; @@ -145,13 +145,13 @@ { // Test that array of handles still works although Clone() is not available. - Array<ScopedMessagePipeHandle> array(10); + auto array = Array<ScopedMessagePipeHandle>::New(10); EXPECT_FALSE(array[0].is_valid()); } } TEST_F(ArrayTest, Serialization_ArrayOfPOD) { - Array<int32_t> array(4); + auto array = Array<int32_t>::New(4); for (size_t i = 0; i < array.size(); ++i) array[i] = static_cast<int32_t>(i); @@ -173,7 +173,7 @@ } TEST_F(ArrayTest, Serialization_EmptyArrayOfPOD) { - Array<int32_t> array(0); + auto array = Array<int32_t>::New(0); size_t size = GetSerializedSize_(array); EXPECT_EQ(8U, size); @@ -189,9 +189,9 @@ } TEST_F(ArrayTest, Serialization_ArrayOfArrayOfPOD) { - Array<Array<int32_t>> array(2); + auto array = Array<Array<int32_t>>::New(2); for (size_t j = 0; j < array.size(); ++j) { - Array<int32_t> inner(4); + auto inner = Array<int32_t>::New(4); for (size_t i = 0; i < inner.size(); ++i) inner[i] = static_cast<int32_t>(i + (j * 10)); array[j] = inner.Pass(); @@ -220,7 +220,7 @@ } TEST_F(ArrayTest, Serialization_ArrayOfBool) { - Array<bool> array(10); + auto array = Array<bool>::New(10); for (size_t i = 0; i < array.size(); ++i) array[i] = i % 2 ? true : false; @@ -242,7 +242,7 @@ } TEST_F(ArrayTest, Serialization_ArrayOfString) { - Array<String> array(10); + auto array = Array<String>::New(10); for (size_t i = 0; i < array.size(); ++i) { char c = 'A' + static_cast<char>(i); array[i] = String(&c, 1); @@ -274,7 +274,7 @@ TEST_F(ArrayTest, Resize_Copyable) { ASSERT_EQ(0u, CopyableType::num_instances()); - mojo::Array<CopyableType> array(3); + auto array = mojo::Array<CopyableType>::New(3); std::vector<CopyableType*> value_ptrs; value_ptrs.push_back(array[0].ptr()); value_ptrs.push_back(array[1].ptr()); @@ -326,7 +326,7 @@ TEST_F(ArrayTest, Resize_MoveOnly) { ASSERT_EQ(0u, MoveOnlyType::num_instances()); - mojo::Array<MoveOnlyType> array(3); + auto array = mojo::Array<MoveOnlyType>::New(3); std::vector<MoveOnlyType*> value_ptrs; value_ptrs.push_back(array[0].ptr()); value_ptrs.push_back(array[1].ptr()); @@ -378,7 +378,7 @@ TEST_F(ArrayTest, PushBack_Copyable) { ASSERT_EQ(0u, CopyableType::num_instances()); - mojo::Array<CopyableType> array(2); + auto array = mojo::Array<CopyableType>::New(2); array.reset(); std::vector<CopyableType*> value_ptrs; size_t capacity = array.storage().capacity(); @@ -413,7 +413,7 @@ TEST_F(ArrayTest, PushBack_MoveOnly) { ASSERT_EQ(0u, MoveOnlyType::num_instances()); - mojo::Array<MoveOnlyType> array(2); + auto array = mojo::Array<MoveOnlyType>::New(2); array.reset(); std::vector<MoveOnlyType*> value_ptrs; size_t capacity = array.storage().capacity();
diff --git a/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc b/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc index f936361..5345cca 100644 --- a/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc +++ b/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
@@ -285,7 +285,7 @@ MojoHandle handle1_value = extra_pipe.handle1.get().value(); { - Array<ScopedMessagePipeHandle> pipes(2); + auto pipes = Array<ScopedMessagePipeHandle>::New(2); pipes[0] = extra_pipe.handle0.Pass(); pipes[1] = extra_pipe.handle1.Pass();
diff --git a/mojo/public/cpp/bindings/tests/map_unittest.cc b/mojo/public/cpp/bindings/tests/map_unittest.cc index 499a67b..d19b4ff 100644 --- a/mojo/public/cpp/bindings/tests/map_unittest.cc +++ b/mojo/public/cpp/bindings/tests/map_unittest.cc
@@ -85,7 +85,7 @@ for (size_t i = 0; i < kStringIntDataSize; ++i) { const char* key = kStringIntData[i].string_data; - Array<int32_t> array(1); + auto array = Array<int32_t>::New(1); array[0] = kStringIntData[i].int_data; map[key] = array.Pass(); EXPECT_TRUE(map); @@ -101,8 +101,8 @@ } TEST_F(MapTest, ConstructedFromArray) { - Array<String> keys(kStringIntDataSize); - Array<int> values(kStringIntDataSize); + auto keys = Array<String>::New(kStringIntDataSize); + auto values = Array<int>::New(kStringIntDataSize); for (size_t i = 0; i < kStringIntDataSize; ++i) { keys[i] = kStringIntData[i].string_data; values[i] = kStringIntData[i].int_data; @@ -238,7 +238,7 @@ TEST_F(MapTest, ArrayOfMap) { { - Array<Map<int32_t, int8_t>> array(1); + auto array = Array<Map<int32_t, int8_t>>::New(1); array[0].insert(1, 42); size_t size = GetSerializedSize_(array); @@ -258,8 +258,8 @@ } { - Array<Map<String, Array<bool>>> array(1); - Array<bool> map_value(2); + auto array = Array<Map<String, Array<bool>>>::New(1); + auto map_value = Array<bool>::New(2); map_value[0] = false; map_value[1] = true; array[0].insert("hello world", map_value.Pass());
diff --git a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc index 6fea3a4..296b83c 100644 --- a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc +++ b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
@@ -43,7 +43,7 @@ bar->gamma = 60; bar->type = Bar::Type::VERTICAL; - mojo::Array<BarPtr> extra_bars(3); + auto extra_bars = mojo::Array<BarPtr>::New(3); for (size_t i = 0; i < extra_bars.size(); ++i) { Bar::Type type = i % 2 == 0 ? Bar::Type::VERTICAL : Bar::Type::HORIZONTAL; BarPtr bar(Bar::New()); @@ -55,12 +55,12 @@ extra_bars[i] = bar.Pass(); } - mojo::Array<uint8_t> data(10); + auto data = mojo::Array<uint8_t>::New(10); for (size_t i = 0; i < data.size(); ++i) data[i] = static_cast<uint8_t>(data.size() - i); - mojo::Array<mojo::ScopedDataPipeConsumerHandle> input_streams(2); - mojo::Array<mojo::ScopedDataPipeProducerHandle> output_streams(2); + auto input_streams = mojo::Array<mojo::ScopedDataPipeConsumerHandle>::New(2); + auto output_streams = mojo::Array<mojo::ScopedDataPipeProducerHandle>::New(2); for (size_t i = 0; i < input_streams.size(); ++i) { MojoCreateDataPipeOptions options; options.struct_size = sizeof(MojoCreateDataPipeOptions); @@ -74,9 +74,9 @@ output_streams[i] = producer.Pass(); } - mojo::Array<mojo::Array<bool>> array_of_array_of_bools(2); + auto array_of_array_of_bools = mojo::Array<mojo::Array<bool>>::New(2); for (size_t i = 0; i < 2; ++i) { - mojo::Array<bool> array_of_bools(2); + auto array_of_bools = mojo::Array<bool>::New(2); for (size_t j = 0; j < 2; ++j) array_of_bools[j] = j; array_of_array_of_bools[i] = array_of_bools.Pass();
diff --git a/mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc b/mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc index 85b0924..c34819a 100644 --- a/mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc +++ b/mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc
@@ -24,9 +24,9 @@ // Creates an array of arrays of handles (2 X 3) for testing. Array<Array<ScopedHandle>> CreateTestNestedHandleArray() { - Array<Array<ScopedHandle>> array(2); + auto array = Array<Array<ScopedHandle>>::New(2); for (size_t i = 0; i < array.size(); ++i) { - Array<ScopedHandle> nested_array(3); + auto nested_array = Array<ScopedHandle>::New(3); for (size_t j = 0; j < nested_array.size(); ++j) { MessagePipe pipe; nested_array[j] = ScopedHandle::From(pipe.handle1.Pass()); @@ -190,7 +190,7 @@ } TEST_F(SerializationWarningTest, ArrayOfStrings) { - Array<String> test_array(3); + auto test_array = Array<String>::New(3); for (size_t i = 0; i < test_array.size(); ++i) test_array[i] = "hello"; @@ -199,14 +199,14 @@ TestArrayWarning(test_array.Pass(), mojo::internal::VALIDATION_ERROR_NONE, &validate_params_0); - test_array = Array<String>(3); + test_array = Array<String>::New(3); ArrayValidateParams validate_params_1( 0, false, new ArrayValidateParams(0, false, nullptr)); TestArrayWarning(test_array.Pass(), mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, &validate_params_1); - test_array = Array<String>(2); + test_array = Array<String>::New(2); ArrayValidateParams validate_params_2( 3, true, new ArrayValidateParams(0, false, nullptr)); TestArrayWarning(test_array.Pass(),
diff --git a/mojo/public/cpp/bindings/tests/struct_unittest.cc b/mojo/public/cpp/bindings/tests/struct_unittest.cc index 8a3dadf..31ea9e5 100644 --- a/mojo/public/cpp/bindings/tests/struct_unittest.cc +++ b/mojo/public/cpp/bindings/tests/struct_unittest.cc
@@ -36,7 +36,7 @@ output->f_int32 = 123; output->f_rect = MakeRect(5); output->f_string = "hello"; - output->f_array = Array<int8_t>(3); + output->f_array = Array<int8_t>::New(3); output->f_array[0] = 10; output->f_array[1] = 9; output->f_array[2] = 8; @@ -124,7 +124,7 @@ clone_region = region.Clone(); EXPECT_EQ(region->name, clone_region->name); - region->rects = Array<RectPtr>(2); + region->rects = Array<RectPtr>::New(2); region->rects[1] = MakeRect(); clone_region = region.Clone(); EXPECT_EQ(2u, clone_region->rects.size()); @@ -298,7 +298,7 @@ input->f_int32 = 123; input->f_rect = MakeRect(5); input->f_string = "hello"; - input->f_array = Array<int8_t>(3); + input->f_array = Array<int8_t>::New(3); input->f_array[0] = 10; input->f_array[1] = 9; input->f_array[2] = 8; @@ -306,7 +306,7 @@ expected_output->f_int32 = 123; expected_output->f_rect = MakeRect(5); expected_output->f_string = "hello"; - expected_output->f_array = Array<int8_t>(3); + expected_output->f_array = Array<int8_t>::New(3); expected_output->f_array[0] = 10; expected_output->f_array[1] = 9; expected_output->f_array[2] = 8; @@ -322,7 +322,7 @@ input->f_int32 = 123; input->f_rect = MakeRect(5); input->f_string = "hello"; - input->f_array = Array<int8_t>(3); + input->f_array = Array<int8_t>::New(3); input->f_array[0] = 10; input->f_array[1] = 9; input->f_array[2] = 8; @@ -333,7 +333,7 @@ expected_output->f_int32 = 123; expected_output->f_rect = MakeRect(5); expected_output->f_string = "hello"; - expected_output->f_array = Array<int8_t>(3); + expected_output->f_array = Array<int8_t>::New(3); expected_output->f_array[0] = 10; expected_output->f_array[1] = 9; expected_output->f_array[2] = 8; @@ -357,7 +357,7 @@ expected_output->f_int32 = 123; expected_output->f_rect = MakeRect(5); expected_output->f_string = "hello"; - expected_output->f_array = Array<int8_t>(3); + expected_output->f_array = Array<int8_t>::New(3); expected_output->f_array[0] = 10; expected_output->f_array[1] = 9; expected_output->f_array[2] = 8; @@ -378,7 +378,7 @@ expected_output->f_int32 = 123; expected_output->f_rect = MakeRect(5); expected_output->f_string = "hello"; - expected_output->f_array = Array<int8_t>(3); + expected_output->f_array = Array<int8_t>::New(3); expected_output->f_array[0] = 10; expected_output->f_array[1] = 9; expected_output->f_array[2] = 8;
diff --git a/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc b/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc index 776ac14..328f5b7 100644 --- a/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc +++ b/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc
@@ -158,7 +158,7 @@ TEST(TypeConversionTest, CustomTypeConverter_Array) { const RedmondRect kBase = {10, 20, 30, 40}; - Array<RectPtr> rects(10); + auto rects = Array<RectPtr>::New(10); for (size_t i = 0; i < rects.size(); ++i) { RedmondRect rr = kBase; rr.left += static_cast<int32_t>(i);
diff --git a/mojo/public/cpp/bindings/tests/union_unittest.cc b/mojo/public/cpp/bindings/tests/union_unittest.cc index afeb4a5..ba68b40 100644 --- a/mojo/public/cpp/bindings/tests/union_unittest.cc +++ b/mojo/public/cpp/bindings/tests/union_unittest.cc
@@ -387,7 +387,7 @@ // Array tests TEST(UnionTest, PodUnionInArray) { SmallStructPtr small_struct(SmallStruct::New()); - small_struct->pod_union_array = Array<PodUnionPtr>(2); + small_struct->pod_union_array = Array<PodUnionPtr>::New(2); small_struct->pod_union_array[0] = PodUnion::New(); small_struct->pod_union_array[1] = PodUnion::New(); @@ -400,7 +400,7 @@ TEST(UnionTest, PodUnionInArraySerialization) { Environment environment; - Array<PodUnionPtr> array(2); + auto array = Array<PodUnionPtr>::New(2); array[0] = PodUnion::New(); array[1] = PodUnion::New(); @@ -427,7 +427,7 @@ TEST(UnionTest, PodUnionInArrayValidation) { Environment environment; - Array<PodUnionPtr> array(2); + auto array = Array<PodUnionPtr>::New(2); array[0] = PodUnion::New(); array[1] = PodUnion::New(); @@ -455,7 +455,7 @@ } TEST(UnionTest, PodUnionInArraySerializationWithNull) { Environment environment; - Array<PodUnionPtr> array(2); + auto array = Array<PodUnionPtr>::New(2); array[0] = PodUnion::New(); array[0]->set_f_int8(10); @@ -808,7 +808,7 @@ TEST(UnionTest, ArrayInUnionGetterSetter) { Environment environment; - Array<int8_t> array(2); + auto array = Array<int8_t>::New(2); array[0] = 8; array[1] = 9; @@ -822,7 +822,7 @@ TEST(UnionTest, ArrayInUnionSerialization) { Environment environment; - Array<int8_t> array(2); + auto array = Array<int8_t>::New(2); array[0] = 8; array[1] = 9; @@ -850,7 +850,7 @@ TEST(UnionTest, ArrayInUnionValidation) { Environment environment; - Array<int8_t> array(2); + auto array = Array<int8_t>::New(2); array[0] = 8; array[1] = 9;
diff --git a/mojo/public/cpp/bindings/tests/versioning_apptest.cc b/mojo/public/cpp/bindings/tests/versioning_apptest.cc index 3937272..d3f111a 100644 --- a/mojo/public/cpp/bindings/tests/versioning_apptest.cc +++ b/mojo/public/cpp/bindings/tests/versioning_apptest.cc
@@ -98,7 +98,7 @@ TEST_F(VersioningApplicationTest, CallNonexistentMethod) { EXPECT_EQ(0u, database_.version()); - Array<uint8_t> new_finger_print(128); + auto new_finger_print = Array<uint8_t>::New(128); for (size_t i = 0; i < 128; ++i) new_finger_print[i] = i + 13;
diff --git a/mojo/services/files/public/c/lib/file_fd_impl.cc b/mojo/services/files/public/c/lib/file_fd_impl.cc index 1feabdd..d13cf6b 100644 --- a/mojo/services/files/public/c/lib/file_fd_impl.cc +++ b/mojo/services/files/public/c/lib/file_fd_impl.cc
@@ -181,7 +181,7 @@ } // TODO(vtl): Is there a more natural (or efficient) way to do this? - mojo::Array<uint8_t> bytes_to_write(count); + auto bytes_to_write = mojo::Array<uint8_t>::New(count); if (count > 0) memcpy(&bytes_to_write[0], buf, count);
diff --git a/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc b/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc index b488f1c..58a8849 100644 --- a/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc +++ b/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc
@@ -117,7 +117,7 @@ return; } cached_accounts_[origin] = account; - mojo::Array<mojo::String> scopes(1); + auto scopes = mojo::Array<mojo::String>::New(1); scopes[0] = "https://www.googleapis.com/auth/userinfo.email"; authentication_service_->GetOAuth2Token( account, scopes.Pass(),
diff --git a/services/clipboard/clipboard_standalone_impl.cc b/services/clipboard/clipboard_standalone_impl.cc index 138fd7a..4341a4a 100644 --- a/services/clipboard/clipboard_standalone_impl.cc +++ b/services/clipboard/clipboard_standalone_impl.cc
@@ -25,7 +25,7 @@ ~ClipboardData() {} Array<String> GetMimeTypes() const { - Array<String> types(data_types_.size()); + auto types = Array<String>::New(data_types_.size()); int i = 0; for (auto it = data_types_.cbegin(); it != data_types_.cend(); ++it, ++i) types[i] = it.GetKey();
diff --git a/services/files/directory_impl.cc b/services/files/directory_impl.cc index c903a75..79e523a 100644 --- a/services/files/directory_impl.cc +++ b/services/files/directory_impl.cc
@@ -125,7 +125,7 @@ return; } - Array<DirectoryEntryPtr> result(0); + auto result = Array<DirectoryEntryPtr>::New(0); // Warning: This is not portable (per POSIX.1 -- |buffer| may not be large // enough), but it's fine for Linux.
diff --git a/services/files/file_impl.cc b/services/files/file_impl.cc index ba70aad..6281633 100644 --- a/services/files/file_impl.cc +++ b/services/files/file_impl.cc
@@ -98,7 +98,7 @@ } } - Array<uint8_t> bytes_read(num_bytes_to_read); + auto bytes_read = Array<uint8_t>::New(num_bytes_to_read); ssize_t num_bytes_read = HANDLE_EINTR( read(file_fd_.get(), &bytes_read.front(), num_bytes_to_read)); if (num_bytes_read < 0) {
diff --git a/services/js/system/tests/js_to_cpp_tests.cc b/services/js/system/tests/js_to_cpp_tests.cc index cc707c8..50f01f6 100644 --- a/services/js/system/tests/js_to_cpp_tests.cc +++ b/services/js/system/tests/js_to_cpp_tests.cc
@@ -93,7 +93,7 @@ args->double_inf = kExpectedDoubleInf; args->double_nan = kExpectedDoubleNan; args->name = "coming"; - Array<String> string_array(3); + auto string_array = Array<String>::New(3); string_array[0] = "one"; string_array[1] = "two"; string_array[2] = "three";
diff --git a/services/native_support/redirectors.cc b/services/native_support/redirectors.cc index 4b9a59d..7024606 100644 --- a/services/native_support/redirectors.cc +++ b/services/native_support/redirectors.cc
@@ -77,7 +77,7 @@ size_t num_bytes_to_write = num_bytes_ - offset_; // TODO(vtl): Is there a more natural (or efficient) way to do this? - mojo::Array<uint8_t> bytes_to_write(num_bytes_to_write); + auto bytes_to_write = mojo::Array<uint8_t>::New(num_bytes_to_write); memcpy(&bytes_to_write[offset_], buffer_.get(), num_bytes_to_write); file_->Write(bytes_to_write.Pass(), 0, mojo::files::Whence::FROM_CURRENT,
diff --git a/services/reaper/reaper_impl.cc b/services/reaper/reaper_impl.cc index 08c33c0..ca683d4 100644 --- a/services/reaper/reaper_impl.cc +++ b/services/reaper/reaper_impl.cc
@@ -283,7 +283,7 @@ void ReaperImpl::DumpNodes( const mojo::Callback<void(mojo::Array<NodePtr>)>& callback) { - mojo::Array<NodePtr> result(0u); + auto result = mojo::Array<NodePtr>::New(0u); for (const auto& app : nodes_) { for (const auto& node_info : app.second) { NodePtr node(Node::New());
diff --git a/services/surfaces/display_impl.cc b/services/surfaces/display_impl.cc index 71c2d4c..ea45696 100644 --- a/services/surfaces/display_impl.cc +++ b/services/surfaces/display_impl.cc
@@ -127,7 +127,7 @@ return; DCHECK(returner_); - mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size()); + auto ret = mojo::Array<mojo::ReturnedResourcePtr>::New(resources.size()); for (size_t i = 0; i < resources.size(); ++i) { ret[i] = mojo::ReturnedResource::From(resources[i]); }
diff --git a/services/surfaces/surfaces_impl.cc b/services/surfaces/surfaces_impl.cc index 9b806e1..d096eba 100644 --- a/services/surfaces/surfaces_impl.cc +++ b/services/surfaces/surfaces_impl.cc
@@ -67,7 +67,7 @@ void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) { if (resources.empty() || !returner_) return; - mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size()); + auto ret = mojo::Array<mojo::ReturnedResourcePtr>::New(resources.size()); for (size_t i = 0; i < resources.size(); ++i) { ret[i] = mojo::ReturnedResource::From(resources[i]); }
diff --git a/services/url_response_disk_cache/url_response_disk_cache_impl.cc b/services/url_response_disk_cache/url_response_disk_cache_impl.cc index 795fda4..7b104b7 100644 --- a/services/url_response_disk_cache/url_response_disk_cache_impl.cc +++ b/services/url_response_disk_cache/url_response_disk_cache_impl.cc
@@ -83,7 +83,7 @@ if (path.empty()) return Array<uint8_t>(); const std::string& string = path.value(); - Array<uint8_t> result(string.size()); + auto result = Array<uint8_t>::New(string.size()); memcpy(&result.front(), string.data(), string.size()); return result.Pass(); }
diff --git a/services/view_manager/view_manager_service_impl.cc b/services/view_manager/view_manager_service_impl.cc index 5c81a13..f2e0fca 100644 --- a/services/view_manager/view_manager_service_impl.cc +++ b/services/view_manager/view_manager_service_impl.cc
@@ -403,7 +403,7 @@ Array<ViewDataPtr> ViewManagerServiceImpl::ViewsToViewDatas( const std::vector<const ServerView*>& views) { - Array<ViewDataPtr> array(views.size()); + auto array = Array<ViewDataPtr>::New(views.size()); for (size_t i = 0; i < views.size(); ++i) array[i] = ViewToViewData(views[i]).Pass(); return array.Pass();