From: Christian Linhart Date: Tue, 19 Aug 2014 13:57:34 +0000 (+0200) Subject: support switch case in the generator X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=355d4d6ab9f5c12c2ee4a91e8cf6eb4a2854d73c;hp=355d4d6ab9f5c12c2ee4a91e8cf6eb4a2854d73c;p=free-sw%2Fxcb%2Flibxcb support switch case in the generator The implementation is rather simple: When a is used instead of a 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. ---