support switch case in the generator
authorChristian Linhart <chris@demorecorder.com>
Tue, 19 Aug 2014 13:57:34 +0000 (15:57 +0200)
committerPeter Harris <pharris@opentext.com>
Wed, 20 Aug 2014 15:59:04 +0000 (11:59 -0400)
The implementation is rather simple:
When a <case> is used instead of a <bitcase>
then operator "==" is used instead of "&" in the if-condition.

So it creates a series of "if" statements
(instead of a switch-case statement in C )

In practice this does not matter because a good
optimizing compiler will create the same code
as for a switch-case.

With this simple implementation we get additional
flexibility in the following forms:
* a case value may appear in multiple case branches.
  for example:
case C1 will be selected by values 1, 4, or 5
case C2 will be selected by values 3, 4, or 7

* mixing of bitcase and case is possible
(this will usually make no sense but there may
be protocol specs where this is needed)

details of the impl:
* replaced "is_bitcase" with "is_case_or_bitcase" in all places
  so that cases are treated like bitcases.

* In function "_c_serialize_helper_switch": write operator "=="
  instead of operator "&" if it is a case.


No differences found