Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add std::span implementation for cxxsupport #13881

Merged
merged 25 commits into from
Jan 19, 2021

Conversation

marcemmers
Copy link
Contributor

@marcemmers marcemmers commented Nov 9, 2020

Summary of changes

Adds std::span implementation to cxxsupport folder in namespace mstd.
See discussion in #13868.

Impact of changes

Migration actions required

Documentation

None

Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[X] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[X] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@kjbracey-arm

@ciarmcom
Copy link
Member

ciarmcom commented Nov 9, 2020

@marcemmers, thank you for your changes.
@pan- @kjbracey-arm @ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good to me. A few comments for starters.

platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Show resolved Hide resolved
typename mstd::enable_if_t<detail::is_container<R>::value &&
detail::is_compatible<R&, ElementType>::value, int> = 0>
constexpr span(R&& r) :
_storage( mstd::data( r ), mstd::size( r ))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No spaces inside parentheses.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still assorted spaces here, and line 206.

Copy link
Member

@pan- pan- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @marcemmers for this submission; it looks quite good, I really like the use of the storage class.
I have few questions:

  • Should we mark mbed::Span as deprecated ? I'm not seeing much value in promoting both.
  • What is the transition path from mbed::Span to mstd::span ?
  • @kjbracey-arm What are the expectations in term of documentation for mstd ?

I'll review the details of the code tomorrow.

platform/cxxsupport/mstd_span Show resolved Hide resolved
@kjbracey
Copy link
Contributor

  • Should we mark mbed::Span as deprecated ? I'm not seeing much value in promoting both.

Yes, that should follow on.

  • What is the transition path from mbed::Span to mstd::span ?

Don't quite understand the question. Before or when we deprecate it, we'd need to convert the Mbed code base.

  • @kjbracey-arm What are the expectations in term of documentation for mstd ?

cxxsupport could do with a proper docs site section - at the minute all it has is its own README.md and comments in the files themselves.

However, for the individual components like this, I believe you don't really need to say much or anything usually. Everything in mstd is supposed to function exactly as its std equivalent, following the principles described in the README.md. If that's what a class does, no special documentation necessary, just as a toolchain wouldn't include any for <span>. Some parts that are replacements for C++14 bits with different characteristics, like mstd::atomic, need comments explaining those and why you wouldn't just use std, but straight backports like this don't need anything, IMO.

Extensions like make_span should get some Doxygen text. Although I'm not sure these files make it to any generated Doxygen output...

@pan-
Copy link
Member

pan- commented Nov 11, 2020

Before or when we deprecate it, we'd need to convert the Mbed code base.

I was thinking of users of Mbed OS that use mbed::Span today. We should discover more when mbed::Span is replaced with mstd::span.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 12, 2020

As this is new feature, if we want to have this in the next release (it will be feature release), please let us know (code freeze end of today).

@marcemmers
Copy link
Contributor Author

So what's the plan here guys? Should I add the doxygen for the make_Span functions. Is there anything else I can do?

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 30, 2020

@marcemmers doxygen docs always good to have.

@pan- @kjbracey-arm What would you suggest, what else is to be done here ?

@pan-
Copy link
Member

pan- commented Nov 30, 2020

@0xc0170 It seems fairly complete to me.

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty happy with this - just want to lose the nonconformant as_bytes.

platform/cxxsupport/mstd_span Show resolved Hide resolved
platform/cxxsupport/mstd_span Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Show resolved Hide resolved
@adbridge
Copy link
Contributor

adbridge commented Jan 7, 2021

@marcemmers can you take a look at the review comments please.

@marcemmers
Copy link
Contributor Author

@marcemmers can you take a look at the review comments please.

Thanks for the reminder, I'll take a look this weekend.

@mergify mergify bot dismissed kjbracey’s stale review January 16, 2021 20:05

Pull request has been modified.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 18, 2021

Thank you @marcemmers , I started CI

0xc0170
0xc0170 previously approved these changes Jan 18, 2021
@mbed-ci
Copy link

mbed-ci commented Jan 18, 2021

Jenkins CI Test : ❌ FAILED

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM
jenkins-ci/mbed-os-ci_build-example-ARM
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM
jenkins-ci/mbed-os-ci_build-cloud-example-ARM
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM

@mergify mergify bot added needs: work and removed needs: CI labels Jan 18, 2021
Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there - shouldn't take much longer if we can just get the iteration cycle down :)

Main problem is the missing definitions - see comment thread elsewhere.

platform/cxxsupport/mstd_iterator Show resolved Hide resolved
platform/cxxsupport/mstd_span Outdated Show resolved Hide resolved
platform/cxxsupport/mstd_span Show resolved Hide resolved
typename mstd::enable_if_t<detail::is_container<R>::value &&
detail::is_compatible<R&, ElementType>::value, int> = 0>
constexpr span(R&& r) :
_storage( mstd::data( r ), mstd::size( r ))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still assorted spaces here, and line 206.

Marc Emmers added 4 commits January 18, 2021 14:33
@mergify mergify bot dismissed stale reviews from kjbracey and 0xc0170 January 18, 2021 13:37

Pull request has been modified.

@mergify mergify bot added needs: CI and removed needs: work labels Jan 18, 2021
@0xc0170
Copy link
Contributor

0xc0170 commented Jan 18, 2021

CI started

@mbed-ci
Copy link

mbed-ci commented Jan 18, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-test ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants