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

improvements to templated streaming #76

Conversation

reicheratwork
Copy link
Contributor

@reicheratwork reicheratwork commented May 11, 2021

Improvements for the following:

  • array declarators not being parsed correctly
  • template streamers are more compatible with user-supplied container classes
  • processing of typedefs
  • safety of reading bounded sequences
  • more descriptive exceptions thrown
  • improved generated comparison operators for structs
  • added generation of comparison operators for unions

@k0ekk0ek
Copy link
Contributor

Thanks @reicheratwork! Changes look mostly fine. I'm currently in the process of getting API tests to run. Unfortunately not all of them pass yet. There's a memory leak and such. If you don't mind, I want to get that work in first, and then rebase this PR on that. If you're curious, the work is being done here: https://github.com/k0ekk0ek/cyclonedds-cxx/tree/port-ddscxx-tests.

src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/types.c Show resolved Hide resolved
src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
@k0ekk0ek
Copy link
Contributor

Thanks @reicheratwork. I'm mostly fine with the logic, but there are some comments. Also, I generally dislike PRs that contain commits with fixes that introduce mistakes made in the same PR. Please consolidate those. I'll have another read once the initial comments have been processed.

- set travis' cyclone build branch to master, as this contains
  the version of idlc that is used by idlcxx
- fix for streaming functions in inherit specs missing streamer
  parameter
- fix for getter functions returning references to complex types,
  as described in C++ language mapping v1.4 section 6.14
- fix for not generating a constructor if there are no members in
  a struct, as this will conflict with the "default" constructor

Signed-off-by: Martijn Reicher <martijn.reicher@adlinktech.com>
@reicheratwork reicheratwork force-pushed the templated_streaming_improved branch 2 times, most recently from 9775edd to a612187 Compare May 17, 2021 16:34
Copy link
Contributor

@k0ekk0ek k0ekk0ek left a comment

Choose a reason for hiding this comment

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

I think we're almost there. Couple of small remarks. If you fix those, I'll be happy to merge these changes. Thanks @reicheratwork!

src/idlcxx/src/streamers.c Outdated Show resolved Hide resolved
src/idlcxx/src/streamers.c Show resolved Hide resolved
src/idlcxx/src/streamers.c Show resolved Hide resolved
src/idlcxx/src/streamers.c Show resolved Hide resolved
Since some typedefs might map onto the same C++ types, which
causes the compiler to have difficulty distinguishing, there
are now streaming functions generated for each typedef in the
C++ namespace where it is defined
The stream setup and cleanup has been moved to their own
functions, to reduce verbosity in the code

Signed-off-by: Martijn Reicher <martijn.reicher@adlinktech.com>
@reicheratwork reicheratwork force-pushed the templated_streaming_improved branch 2 times, most recently from 64bc474 to 6c5f556 Compare May 18, 2021 12:54
- This causes issues in the default constructors and getters/setters
  of members with array declarators as well as typedefs generated
  "skipping" the array part

Signed-off-by: Martijn Reicher <martijn.reicher@adlinktech.com>
- removed sequence and array template streamers, these will be
  unrolled in the generated code, not the template streamer functions,
  the maximum length checks will also be done there
- reset default template classes and includes to the STL versions
- added more descriptive exceptions in streamers

Signed-off-by: Martijn Reicher <martijn.reicher@adlinktech.com>
- added getter functions for the different accessor strings which
  can be used IDL_PRINTA, avoiding heap allocation of accessor strings
- arrays are unrolled using simple auto ranged for loops
- sequences are unrolled in two different manners:
  - for bounded sequences they create a dummy instance where the
    contents of the stream are read into, and based on the entry
    number in the sequence it will be added to the bounded sequence
  - for unbounded sequences the sequence is resized at the beginning
    of the read cycle to the number of entities indicated by the
    stream, and reads are done on the entity at the index in the stream

Signed-off-by: Martijn Reicher <martijn.reicher@adlinktech.com>
- added check for presence of members to compare
- added comparison of inherited types in structs
- if there is nothing to compare, "true" is returned as default

Signed-off-by: Martijn Reicher <martijn.reicher@adlinktech.com>
- first comparison between discriminators
- if discriminators match, comparison between values for the branch
- if there is no branch which matches the discriminator, return false

Signed-off-by: Martijn Reicher <martijn.reicher@adlinktech.com>
@k0ekk0ek
Copy link
Contributor

Regarding bounded sequences, like we discussed, we should reject the entire sample and not fill it as far as allowed, but let's worry about that in a follow-up PR.

One minor thing you forgot to fix, other than that I'll happily accept the changes.

@k0ekk0ek
Copy link
Contributor

Follow items are listed on #83. Some tests are known to fail, but fixing those was not part of this PR.

@k0ekk0ek k0ekk0ek merged commit 899f4ef into eclipse-cyclonedds:templated-streaming May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants