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

Support for marshaling optional fields in interchange messages #2526

Merged
merged 22 commits into from
Apr 24, 2020

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Apr 11, 2020

  • On the C# side, these optionals are represented as T?. On the C++ side, as T*. Note that in C++ the pointers cannot default to nullptr (because POD), so the client must null these fields as needed ({} is your friend).
  • If an interchange message has optional fields, it needs a generated marshaler and must therefore be a class.
  • The basic class for marshaling optionals is OptionalMarshaler. If an optional field is_produced, the OptionalMarshaler is wrapped into an OwnershipTransferMarshaler.
  • Ownership transfer of interchange messages is achieved by giving them an operator new and deleting them with a new interface function, DeleteInterchange.
  • When replaying a journal, optional fields need "storage" objects, just like repeated fields. Previously this was hacked with "unique_ptr" but that doesn't work in all cases. So we now have proper storage, filled with lambdas.
  • A message that is a C# class is now returned by T* on the C++ side, and ownership may be transferred to C#.

Fix #2339.

analysis.elements.mean_semimajor_axis =
ToInterval(elements.mean_semimajor_axis_interval());
analysis->elements = new OrbitalElements{
/*sidereal_period=*/elements.sidereal_period() / Second,
Copy link
Member

Choose a reason for hiding this comment

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

Can we use designated initializers here?

Same question elsewhere.

@eggrobin eggrobin added the LGTM label Apr 23, 2020
@pleroy
Copy link
Member Author

pleroy commented Apr 24, 2020

retest this please

Sorry, something went wrong.

@pleroy pleroy merged commit e1a1240 into mockingbirdnest:master Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for optional fields in the auxiliary interface messages
2 participants