New issue
Advanced search Search tips

Issue 754077 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Tracking bug for implementing some version of Span in //base

Project Member Reported by dcheng@chromium.org, Aug 10 2017

Issue description

This is the array equivalent of StringPiece. It's based on the C++ proposal for span (http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0122r1.pdf) which has been implemented in gsl (https://github.com/Microsoft/GSL/blob/master/include/gsl/span).

For now, we'll start with the simplest possible API, to allow spans to be constructed from:
- a pointer + size pair
- a statically sized array

With factory methods for creating spans.

We'll maybe also add:
- a container with data() and size() members (implicit)
 
Project Member

Comment 1 by bugdroid1@chromium.org, Aug 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/02908b60bce2cf9ffdc5d3b4d10da201da4de83f

commit 02908b60bce2cf9ffdc5d3b4d10da201da4de83f
Author: Daniel Cheng <dcheng@chromium.org>
Date: Fri Aug 11 08:13:29 2017

Rename mojo::CArray to base::Span and move it to //base.

Bug:  754077 
Change-Id: I2b297b991cce390c44e4dcfb7f6c2a2e3262c3bc
Reviewed-on: https://chromium-review.googlesource.com/609386
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#493684}
[modify] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/base/BUILD.gn
[add] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/base/containers/span.h
[add] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/base/containers/span_unittest.cc
[modify] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/chrome/common/extensions/media_parser_struct_traits.h
[modify] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/content/common/message_port_message.h
[modify] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/device/gamepad/public/interfaces/gamepad_struct_traits.h
[modify] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/mojo/public/cpp/bindings/BUILD.gn
[delete] https://crrev.com/42c3d2a9e44b422c0ef4c9516a4011aca229a862/mojo/public/cpp/bindings/array_traits_carray.h
[add] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/mojo/public/cpp/bindings/array_traits_span.h
[modify] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/mojo/public/cpp/bindings/lib/array_serialization.h
[modify] https://crrev.com/02908b60bce2cf9ffdc5d3b4d10da201da4de83f/mojo/public/cpp/bindings/lib/serialization.h

Project Member

Comment 2 by bugdroid1@chromium.org, Aug 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/14923dda9c11a13645cc35e0efaf61ead5f87a1a

commit 14923dda9c11a13645cc35e0efaf61ead5f87a1a
Author: Daniel Cheng <dcheng@chromium.org>
Date: Tue Aug 15 19:04:26 2017

Add type-deducing MakeSpan helper.

Also implements:
- iterator, begin(), end()
- const_iterator, cbegin(), cend()
- operator[](size_t)
- operator==(const Span<T>&, const Span<T>&) and
  operator!=(const Span<T>&, const Span<T>&)
to make it less painful to write tests.

Bug:  754077 
Change-Id: Ie1165566177b865f0b9e829d3dfea99105e5476b
Reviewed-on: https://chromium-review.googlesource.com/611852
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#494476}
[modify] https://crrev.com/14923dda9c11a13645cc35e0efaf61ead5f87a1a/base/containers/span.h
[modify] https://crrev.com/14923dda9c11a13645cc35e0efaf61ead5f87a1a/base/containers/span_unittest.cc

Project Member

Comment 3 by bugdroid1@chromium.org, Aug 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3aae9a05d87b8e658fe6a3f956c17344b1bee7a9

commit 3aae9a05d87b8e658fe6a3f956c17344b1bee7a9
Author: Daniel Cheng <dcheng@chromium.org>
Date: Fri Aug 18 01:07:23 2017

base::Span: Implement conversion constructors.

- Implement Span<U> to Span<T> conversions if U* is
  convertible to T*. This allows a Span<int> to be
  used as a Span<const int> without hassle.
- Implement container-like to Span<T> conversions if
  the container in question implements a data() and
  size() member and is not Span or std::array<T, N>.

Bug:  754077 
Change-Id: Iaf98a2a1f5b6ad4cf331447fed5ae20200b7a253
Reviewed-on: https://chromium-review.googlesource.com/618448
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#495412}
[modify] https://crrev.com/3aae9a05d87b8e658fe6a3f956c17344b1bee7a9/base/BUILD.gn
[modify] https://crrev.com/3aae9a05d87b8e658fe6a3f956c17344b1bee7a9/base/containers/span.h
[modify] https://crrev.com/3aae9a05d87b8e658fe6a3f956c17344b1bee7a9/base/containers/span_unittest.cc
[add] https://crrev.com/3aae9a05d87b8e658fe6a3f956c17344b1bee7a9/base/containers/span_unittest.nc

Project Member

Comment 4 by bugdroid1@chromium.org, Aug 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e4ec6449851584c9f8e1d3bfa286d51ee311ed4d

commit e4ec6449851584c9f8e1d3bfa286d51ee311ed4d
Author: Daniel Cheng <dcheng@chromium.org>
Date: Fri Aug 18 23:28:33 2017

base::Span: document and fix some differences from latest WG proposal

base::Span was written against an older version of the proposal. This
updates the documentation on differences from the proposal, and fixes
some differences from the proposal with the container conversion
constructor.

Bug:  754077 
Change-Id: I1ad055406d7b7b520f46b3d19b025abb07eae41d
Reviewed-on: https://chromium-review.googlesource.com/621826
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#495744}
[modify] https://crrev.com/e4ec6449851584c9f8e1d3bfa286d51ee311ed4d/base/containers/span.h
[modify] https://crrev.com/e4ec6449851584c9f8e1d3bfa286d51ee311ed4d/base/containers/span_unittest.cc
[modify] https://crrev.com/e4ec6449851584c9f8e1d3bfa286d51ee311ed4d/base/containers/span_unittest.nc

Project Member

Comment 5 by bugdroid1@chromium.org, Aug 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d5b7fa601756ef962938c7a2e9b2ca31ec60bf56

commit d5b7fa601756ef962938c7a2e9b2ca31ec60bf56
Author: Daniel Cheng <dcheng@chromium.org>
Date: Sun Aug 20 19:27:27 2017

Rename base::Span to base::span to match //base/containers guidelines.

For consistency, base::MakeSpan is named base::make_span as well, even
though base::MakeSpan has a less clear path to standardization.

Bug:  754077 
Change-Id: I3a3e8f124f43924f7ced778df0a880d9a37be445
Reviewed-on: https://chromium-review.googlesource.com/622451
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Brett Wilson <brettw@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#495846}
[modify] https://crrev.com/d5b7fa601756ef962938c7a2e9b2ca31ec60bf56/base/containers/span.h
[modify] https://crrev.com/d5b7fa601756ef962938c7a2e9b2ca31ec60bf56/base/containers/span_unittest.cc
[modify] https://crrev.com/d5b7fa601756ef962938c7a2e9b2ca31ec60bf56/base/containers/span_unittest.nc
[modify] https://crrev.com/d5b7fa601756ef962938c7a2e9b2ca31ec60bf56/mojo/public/cpp/bindings/array_traits_span.h

Project Member

Comment 6 by bugdroid1@chromium.org, Aug 23 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6c77413f204a5dd88782d8594d99e43b932ad40d

commit 6c77413f204a5dd88782d8594d99e43b932ad40d
Author: jdoerrie <jdoerrie@chromium.org>
Date: Wed Aug 23 08:34:13 2017

Add more features from std::span proposal

This change makes the following modifications to base::span to reduce
differences from the standardization proposal:
  - Add (const) reverse iterators
  - Enable construction from nullptr
  - Add non-templated |first| and |last|
  - Set a default value for |subspan|'s |count| argument
  - Add |length| and |empty|
  - Add missing comparison operators

Furthermore, it updates the documentation with regard to the missing
byte methods and the recent rename from base::Span to base::span.

Bug:  754077 
Change-Id: I7f867595e7b1d8b9349bf930a8d4ba7900ecf113
Reviewed-on: https://chromium-review.googlesource.com/626498
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496628}
[modify] https://crrev.com/6c77413f204a5dd88782d8594d99e43b932ad40d/base/containers/span.h
[modify] https://crrev.com/6c77413f204a5dd88782d8594d99e43b932ad40d/base/containers/span_unittest.cc

Project Member

Comment 7 by bugdroid1@chromium.org, Aug 23 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a2e3e05e0418ce2d9d6676ab5f0bfa1bddacb37e

commit a2e3e05e0418ce2d9d6676ab5f0bfa1bddacb37e
Author: jdoerrie <jdoerrie@chromium.org>
Date: Wed Aug 23 08:47:10 2017

Update base::span usage guidelines and examples

This change updates the documentation of base::span to include more
usage guidelines and examples.

Bug:  754077 
Change-Id: I1eef2c1d0d08857814d69cdb7283f03fe11dee05
Reviewed-on: https://chromium-review.googlesource.com/625657
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496633}
[modify] https://crrev.com/a2e3e05e0418ce2d9d6676ab5f0bfa1bddacb37e/base/containers/span.h

Project Member

Comment 8 by bugdroid1@chromium.org, Aug 25 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f

commit ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f
Author: Daniel Cheng <dcheng@chromium.org>
Date: Fri Aug 25 20:19:10 2017

Switch Mojo struct traits over to using base::span

Bug:  754077 
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I54900486db36558a62a144aefe0dcc5ede099c1c
Reviewed-on: https://chromium-review.googlesource.com/620447
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Ken Rockot <rockot@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#497517}
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/cc/ipc/filter_operation_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/chrome/common/extensions/media_parser_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/components/arc/bitmap/bitmap_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/components/arc/intent_helper/intent_filter_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/components/chrome_cleaner/public/typemaps/DEPS
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.cc
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/content/common/message_port.cc
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/content/common/message_port_message.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/content/common/message_port_message_struct_traits.cc
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/content/common/message_port_message_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/device/gamepad/public/interfaces/gamepad_struct_traits.cc
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/device/gamepad/public/interfaces/gamepad_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/gpu/ipc/common/mailbox_struct_traits.cc
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/gpu/ipc/common/mailbox_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/mojo/common/common_custom_types_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/mojo/common/values_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/mojo/public/cpp/bindings/array_traits_span.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/net/interfaces/ip_address_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/services/viz/public/cpp/compositing/quads_struct_traits.cc
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/services/viz/public/cpp/compositing/quads_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/skia/public/interfaces/bitmap_skbitmap_struct_traits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.cpp
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h
[modify] https://crrev.com/ed5f6716a0014b3634ff3c7dbd1d6b94df81bd5f/third_party/WebKit/Source/platform/mojo/DEPS

Comment 9 by dcheng@chromium.org, Sep 12 2017

Status: Fixed (was: Started)

Sign in to add a comment