Closed jwest115 closed 4 months ago
Currently, using a type defined in FPP looks like this:
{
"name": "MyModule.MyType",
"kind": "qualifiedIdentifier",
}
To figure out what MyType actually is (enum, struct, array) one has to go find the type MyType defined in one of those 3 sub-dictionary which isn't ideal, both for a machine and for human-readability. What if we added an entry to have something like this
{
"name": "MyModule.MyType",
"kind": "qualifiedIdentifier",
"kind_type": "array"
}
Probably this following would be sufficient too (since we know any of those 3 has to be looked up at a qualified identifier):
{
"name": "MyModule.MyType",
"kind": "array|struct|enum"
}
Thoughts? @jwest115 @bocchino @LeStarch
To figure out what MyType actually is (enum, struct, array) one has to go find the type MyType defined in one of those 3 sub-dictionary
I think we got rid of those sub-dictionaries, so you just look up the name in a single dictionary of type definitions.
Confirmed, there are no sub-dictionaries. See here: https://github.com/nasa/fprime/blob/a771b3540bcfa58c507b9d368fc91a3f0debaf2e/docs/Design/fpp-json-dict.md#dictionary-content.
Ok that helps. Still - do we not think it's relevant to add a field saying which of the three it is? It would help for both human readability and parsing. Probably just need an extra field there ?
I don't think we need that extra field repeating partial info about the type. The qualified type name points to the type definition, which has all the info, e.g., not just whether it's an array but the entire shape of the array. This is also how it works in FPP source.
Also, the JSON dictionary is not primarily designed for human readability. When generating human-readable dictionaries, we can inline the entire type definition at every type name, if we think that is useful. It's a tradeoff -- lookup vs. verbosity. I think this is a concern for a downstream tool, not the dictionary spec.
Recording the array/struct/enum info does not help with machine processing. It's just a name lookup in a table.
This PR adds:
fpp-to-dict
command line tool (#2276)fpp-to-dict
tool (#2501)