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

Replace obj_needs_destructor by more general concept #288

Closed
tmadlener opened this issue May 27, 2022 · 2 comments · Fixed by #291
Closed

Replace obj_needs_destructor by more general concept #288

tmadlener opened this issue May 27, 2022 · 2 comments · Fixed by #291
Assignees

Comments

@tmadlener
Copy link
Collaborator

Currently we only generate a destructor for the Obj objects if it is necessary, e.g. here:

{% if obj_needs_destructor %}
virtual ~{{ obj_type }}();
{% else %}
virtual ~{{ obj_type }}() = default;
{% endif %}

which is populated in the generator, here:

needs_destructor = datatype['VectorMembers'] or datatype['OneToManyRelations'] or datatype['OneToOneRelations']
datatype['obj_needs_destructor'] = needs_destructor

The condition in the generator describes a rather general class of datatypes, i.e. ones that have no relations or vector members. I think the name of obj_needs_destructor should be changed to something that better reflects this more general condition. E.g. is_trivial_type (or something similar).

@soumilbaldota
Copy link
Contributor

soumilbaldota commented May 28, 2022

We can fix it by changing the variable names to trivial_types instead of needs_destructor

 trivial_types = datatype['VectorMembers'] or datatype['OneToManyRelations'] or datatype['OneToOneRelations']
 datatype['is_trivial_type'] = trivial_types

And is_trivial_type instead of obj_needs_destructor

  {% if is_trivial_type %}
    virtual ~{{ obj_type }}();
  {% else %}
    virtual ~{{ obj_type }}() = default;
  {% endif %}

@soumilbaldota
Copy link
Contributor

I have opened a pull request with the above changes.

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

Successfully merging a pull request may close this issue.

2 participants