Skip to content
New issue

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

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

Already on GitHub? # to your account

Inconsistent reference access for Mutable types #551

Closed
tmadlener opened this issue Feb 5, 2024 · 0 comments · Fixed by #553
Closed

Inconsistent reference access for Mutable types #551

tmadlener opened this issue Feb 5, 2024 · 0 comments · Fixed by #553

Comments

@tmadlener
Copy link
Collaborator

tmadlener commented Feb 5, 2024

The generated interface for our mutable types allows to access component members by reference, but not for primitive types, i.e.

components:
  SimpleStruct:
    Members:
      -  int i // integer

datatypes:
  SimpleDatatype:
    Members:
      - int j // integer
      - SimpleStruct s // component

will generate to (assuming getter syntax is turned on)

class MutableSimpleDataType {
  // many other things
  // ...
  
  int getJ() const;
  const  SimpleStruct& getS() const;

  // this mutable accessor only exists for non-builtin types
  SimpleStruct& s();
};

This is inconsistent in two ways with the rest of the generated code:

  • the mutable accessors do not respect the getSyntax setting
  • the mutable accessors do not expose their primitive members by non-const reference

After some discussion with @paulgessinger (who actually found this), I think the easiest solution is to

  • deprecate the existing mutable reference accessors
  • introduce new mutable accessors for all members that respect the getSyntax option (i.e. effectively adding the non-const overloads for our mutable classes).

This doesn't affect const-correctness of generated EDMs and will make the Mutable handles more consistent (and a bit more useful).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant