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

Consider to remove pre-write actions in C++ #342

Closed
mikir opened this issue Sep 20, 2021 · 3 comments
Closed

Consider to remove pre-write actions in C++ #342

mikir opened this issue Sep 20, 2021 · 3 comments
Assignees
Labels
c++ C++ language generator enhancement New feature or request
Milestone

Comments

@mikir
Copy link
Contributor

mikir commented Sep 20, 2021

The C++ BitStreamWriter does not allocate memory by itself. This allows applications to control memory allocation strategy.

However, this causes that application needs to call bitSizeOf() method before write() method. So, application must call as well
initializeChildren() and initializeOffsets() methods. Because of that, pre-write actions in write() method which calls automatically also initializeChildren() and initializeOffsets() are not useful anymore.

Moreover, write() method cannot be const because of these pre-write actions. Therefore, consider to remove completely pre-write actions.

@mikir mikir added enhancement New feature or request c++ C++ language generator labels Sep 20, 2021
@mikir mikir added this to the 2.5 milestone Sep 20, 2021
@mikir
Copy link
Contributor Author

mikir commented Nov 2, 2021

Consider to introduce some new user friendly method which will initialize offsets and children which could be generated in all zserio objects.

@josephbirkner
Copy link

Maybe we can also think about marking the offset info in C++ as mutable to allow for serializing const objects? Or have you already decided against this? 🤔

@Mi-La Mi-La assigned Mi-La and mikir and unassigned Mi-La Feb 10, 2022
mikir added a commit that referenced this issue Feb 18, 2022
This improves SerializeUtils to call all initialization methods
automatically.
@mikir
Copy link
Contributor Author

mikir commented Feb 18, 2022

We have decided to remove all pre-write actions completely. This allows to have write() method const which is expected. Beside of that, write() method won't have any side effects anymore which was not expected.

Together with this change, we have improved serialize() and deserialize() methods in C++ runtime library. Now, the method serialize() automatically calls before serialization the following initialization methods:

  • initialize() method for types with parameters
  • initializeChildren() method for types which contain types with parameters
  • initializeOffsets() method for all types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ C++ language generator enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants