summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-04-03 11:06:52 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-04-03 11:06:52 +0200
commitebb1e79d46cbea5def1bcb7c54346e6e44e4c830 (patch)
treefa659948be1a0b4a89fcbaa632e0f3ce8c1029aa /lib
parentcc46c77036d3208d717a243e7a97e48609dfaebf (diff)
NanoPB benchmark generator: add encode/decode of float values
Diffstat (limited to 'lib')
-rwxr-xr-xlib/protocol_benchmarks.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/protocol_benchmarks.py b/lib/protocol_benchmarks.py
index 2761699..c509e83 100755
--- a/lib/protocol_benchmarks.py
+++ b/lib/protocol_benchmarks.py
@@ -881,6 +881,12 @@ class NanoPB(DummyProtocol):
self.enc_buf += 'msg.{}{} = {};\n'.format(self.cc_prefix, key, value)
self.dec_buf += 'kout << msg.{}{};\n'.format(self.cc_prefix, key)
self.assign_and_kout(self.int_type, 'msg.{}{}'.format(self.cc_prefix, key))
+ elif fieldtype == float:
+ if cardinality == 'optional':
+ self.enc_buf += 'msg.{}has_{} = true;\n'.format(self.cc_prefix, key)
+ self.enc_buf += 'msg.{}{} = {};\n'.format(self.cc_prefix, key, value)
+ self.dec_buf += 'kout << msg.{}{};\n'.format(self.cc_prefix, key)
+ self.assign_and_kout(self.float_type, 'msg.{}{}'.format(self.cc_prefix, key))
elif fieldtype == dict:
if cardinality == 'optional':
self.enc_buf += 'msg.{}has_{} = true;\n'.format(self.cc_prefix, key)