aboutsummaryrefslogtreecommitdiff
path: root/pw_protobuf
diff options
context:
space:
mode:
authorWyatt Hepler <hepler@google.com>2021-11-10 09:34:46 -0800
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-11-15 18:16:03 +0000
commit9a5210dc2b5008149e774fb1dd756d78e2630319 (patch)
tree7e3dca8b067aa46b1f4657d248ec5705d62eced2 /pw_protobuf
parent1b69a4ec6ac61457e57e9bcb8591448b573f2ff4 (diff)
downloadpigweed-9a5210dc2b5008149e774fb1dd756d78e2630319.tar.gz
pw_rpc: Prefix Nanopb struct names with "::"
This prevents prevents Nanopb names from incorrectly resolving to names in namespaces. Change-Id: I7e44354df24e872095e8b9029312efd6a6f66555 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/68096 Commit-Queue: Wyatt Hepler <hepler@google.com> Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com> Reviewed-by: Alexei Frolov <frolv@google.com>
Diffstat (limited to 'pw_protobuf')
-rw-r--r--pw_protobuf/py/pw_protobuf/proto_tree.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/pw_protobuf/py/pw_protobuf/proto_tree.py b/pw_protobuf/py/pw_protobuf/proto_tree.py
index c33c33d71..9f8885527 100644
--- a/pw_protobuf/py/pw_protobuf/proto_tree.py
+++ b/pw_protobuf/py/pw_protobuf/proto_tree.py
@@ -75,8 +75,15 @@ class ProtoNode(abc.ABC):
path = '.'.join(self._attr_hierarchy(lambda node: node.name(), None))
return path.lstrip('.')
- def nanopb_name(self) -> str:
- """Full nanopb-style name of the node."""
+ def nanopb_fields(self) -> str:
+ """Name of the Nanopb variable that represents the proto fields."""
+ return self._nanopb_name() + '_fields'
+
+ def nanopb_struct(self) -> str:
+ """Name of the Nanopb struct for this proto."""
+ return '::' + self._nanopb_name()
+
+ def _nanopb_name(self) -> str:
name = '_'.join(self._attr_hierarchy(lambda node: node.name(), None))
return name.lstrip('_')