Skip to content
  • Christian Linhart's avatar
    support switch case in the generator · 355d4d6a
    Christian Linhart authored and Peter Harris's avatar Peter Harris committed
    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.
    355d4d6a