diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-04-03 11:06:52 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-04-03 11:06:52 +0200 |
commit | ebb1e79d46cbea5def1bcb7c54346e6e44e4c830 (patch) | |
tree | fa659948be1a0b4a89fcbaa632e0f3ce8c1029aa | |
parent | cc46c77036d3208d717a243e7a97e48609dfaebf (diff) |
NanoPB benchmark generator: add encode/decode of float values
-rwxr-xr-x | lib/protocol_benchmarks.py | 6 |
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) |