aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@github.mail.kapsi.fi>2016-02-20 16:17:51 +0200
committerPetteri Aimonen <jpa@github.mail.kapsi.fi>2016-02-20 16:17:51 +0200
commit21629738a89e3ba9aea8e503305fe293cf4517f3 (patch)
tree5247a6934651c001804d3b807413392c47bcbb40 /generator
parent275e7e868c0fdb2403d5b1754ccc8e628648d583 (diff)
parentdf3642b832dec73cf00e6a353ad134d3b132f4b1 (diff)
Merge pull request #194 from isotes/master
Generate MIN/MAX/ARRAYSIZE for enums
Diffstat (limited to 'generator')
-rwxr-xr-xgenerator/nanopb_generator.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 60dc7e87..357350f0 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -197,6 +197,10 @@ class Enum:
result += ' %s;' % self.names
+ result += '\n#define _%s_MIN %s' % (self.names, self.values[0][0])
+ result += '\n#define _%s_MAX %s' % (self.names, self.values[-1][0])
+ result += '\n#define _%s_ARRAYSIZE ((%s)(%s+1))' % (self.names, self.names, self.values[-1][0])
+
if not self.options.long_names:
# Define the long names always so that enum value references
# from other files work properly.