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

[C++ code gen, dictionary] Make instance names more consistent #349

Closed
bocchino opened this issue Nov 9, 2023 · 1 comment · Fixed by #470
Closed

[C++ code gen, dictionary] Make instance names more consistent #349

bocchino opened this issue Nov 9, 2023 · 1 comment · Fixed by #470
Assignees
Labels
code generation Issues related to code generation
Milestone

Comments

@bocchino
Copy link
Collaborator

bocchino commented Nov 9, 2023

When an instance I is defined in a module M, the name of the instance is M_I. However, the code generation is not entirely consistent:

  1. In the dictionary, the name becomes I instead of M_I. This makes the name shorter, but it can create ambiguity because it deletes the module prefix. E.g., M_I and N_I have the same name I in the dictionary. We should be consistent and use M_I in this case; a user who wants the unqualified name I can define the instance I outside of any module scope.
  2. In the generated C++, the name becomes I inside the namespace M and M_I outside the namespace M. This makes it hard to write initialization code that works in all cases. We should either (1) use M_I consistently in all cases or (2) use a C++ namespace qualifier M::I instead of M_I.

We can fix (1) as we develop the new JSON dictionary. We can fix (2) by updating fpp-to-cpp.

@bocchino bocchino added the code generation Issues related to code generation label Nov 16, 2023
@jwest115 jwest115 self-assigned this Jun 24, 2024
@jwest115
Copy link
Collaborator

jwest115 commented Jun 26, 2024

For part 2 of this issue - there are a few ways to go about this:

  • Use C++ qualification, i.e. M::M::i
  • Use underscore qualification (what we currently have), i.e. M::M_i
    • Easier to see that topology qualifier is M and component instance name is M_i
  • Make component instance names fully qualified - would be consistent with dictionary

Example:

module M {
  passive component C { }
  instance i: C base id 0x100
  topology T { 
     instance i 
  }
}

C++ qualification

namespace M {
  //! M::i
  extern C M::i;
}
M::M::i

vs.

Underscore qualification

namespace M {
  //! M_i
  extern C M_i;
}
M::M_i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code generation Issues related to code generation
Projects
Development

Successfully merging a pull request may close this issue.

2 participants