DescriptionMojom runtime type info: New implementation for Go.
Our implementation of runtime type information is changing and this CL implements the change for Go. The older implementation still exists for Dart. (Those are the only two languages for which the runtime type info has yet been implemented.)
In the older implementation the runtime type structures are computed and constructed by the code generators (thus in Python and the Jinja 2 templates).
In this newer implementation the Mojom parser computes the information and stores it in a mojom_types.RuntimeTypeInfo
structure. Then the code generators insert a literal array of bytes representing a serialized RuntimeTypeInfo into the generated Go code. At runtime all a Mojo application needs to do
is deserialize the RuntimeTypeInfo struct and use it to answer queries.
- In mojom_translator.py copy serialized_runtime_type_info into the mojom.Module.
- In mojom_go_generator.py we compute a Go literal string defining this array of bytes.
- In source.tmpl we generate Go code to deserialize this array of bytes into a RuntimeTypeInfo
struct and use this struct to answer queries about runtime type info.
- We delete the old implementation from source.tmpl and delete the files mojom_reference_macros.tmpl
and mojom_type_macros.tmpl.
- We fix up validation_type_test.go in accordance with these changes. The main change is that we use the format
of the type key currently being generated by the mojom parser. Also the old implementation was apparently
setting field names in DeclData incorrectly so we modify the tests to look for the correct names.
- The new implementation does not support generating the function GetTopLevelInterface() on interfaces that
are not top-level interfaces. Therefore we add the "ServiceName" annotation to the interface that is being
used to test this function: the BoundsCheckTestInterface in validation_test_interfaces.mojom.
BUG=#448
R=alexfandrianto@google.com, azani@chromium.org
Committed: https://chromium.googlesource.com/external/mojo/+/4970253149a7bc1d057c13fd8f173f2c795b3bfd
Patch Set 1 #Patch Set 2 : Remove TODO. #
Total comments: 14
Patch Set 3 : Adds mojom_type_key field and deletes GetMojomTypeValue() function. #Patch Set 4 : Avoid possibility of nil pointer in test. #Patch Set 5 : Rebasing #Messages
Total messages: 29 (17 generated)
|