aboutsummaryrefslogtreecommitdiff
path: root/pw_protobuf
diff options
context:
space:
mode:
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('_')