Support direct counters and direct meters in p4RuntimeSerializer #317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for direct counters and direct meters in p4RuntimeSerializer and addresses something other existing issues along the way.
455c196 fixes #302 by adding an ExternInstance help class, akin to MethodInstance, which provides information about the extern instance referenced by an expression. It handles both PathExpressions which refer to a Declaration_Instance by name and ConstructorCallExpressions which create an anonymous extern instance. These are the two common cases that we need to support in p4RuntimeSerializer, though it's possible that in the future there would be others which would be useful to add.
3d3ce5c fixes #311 by actually adding support for serializing direct counters and meters in p4RuntimeSerializer. A little bit of metaprogramming is used to make this less repetitive, since the two cases are almost exactly the same.
Finally, a04ad31 is a small additional patch that fixes an issue Mihai noticed in #296: the existing action profile support in p4RuntimeSerializer handles only ConstructorCallExpressions, but we need to support Declaration_Instance references as well. The previous two commits add code that abstracts over the two cases; you can simply pass
getExternInstanceFromProperty()
a table and a property name and it will do the right thing. a04ad31 changes the action profile code to leveragegetExternInstanceFromProperty()
, which both simplifies the code and adds support for the case we previously didn't handle.