nasa / fpp

F Prime Prime: A modeling language for F Prime
https://fprime.jpl.nasa.gov
Apache License 2.0
46 stars 31 forks source link

Revise C++ code gen for port string types #387

Closed bocchino closed 4 months ago

bocchino commented 7 months ago

For backwards compatibility with the XML autocoder, the C++ code generator generates type names for port string types as follows:

  1. Assume that port P has a string argument A with size S
  2. The code generator generates a concrete string type (derived class of StringBase) C with size S
  3. The code generator generates a typedef for C based on the name of the port formal parameter
  4. The generated name in item is an unqualified name in the global namespace.

We should fix item 4 so that the name is qualified by the port definition. This may break some code, which we should fix.

bocchino commented 4 months ago

I think a better solution is to eliminate all the generated auto-generated string types and attendant name management. We can do this as follows:

  1. When passing a string value, don't use a concrete string type; instead use Fw::StringBuffer&.
  2. When allocating a string of size s, (a) declare a char array A of size s and (b) pass A into an instance of an ExternalString class that implements the StringBuffer interface against A.
bocchino commented 4 months ago

Superseded by #406.