swig/Source/CParse
Jiulong Wang e1afb6fdbe Fix enum error when value contains char in compound expression
Problem: When enum value contains compound expression with a char
constant, the quotes around char constant is missing in the generated
expression. Example:

enum media_type {
  YUY2 = ((('2' << 24) | ('Y' << 16)) | ('U' << 8)) | 'Y'
};

The generated C# enum becomes:

public enum media_type {
  YUY2 = (((2 << 24)|(Y << 16))|(U << 8))|Y
}

While the correct representation (after this fix) should be:

public enum media_type {
  YUY2 = ((('2' << 24)|('Y' << 16))|('U' << 8))|'Y'
}

Causes: the exprcompound promotes the expression type from char to int
and uses $1.val in the generated expression. However $1.val does not
contain the quotes. Since the type is promoted to int, there's no way to
know there's char component in the compound expression.

Solution: in exprcomound, use $1.rawval if $1.type is T_CHAR or T_WCHAR.
The rawval contains quotes which yield correct expression.
2016-09-07 15:46:16 -07:00
..
cparse.h Fix enum error when value contains char in compound expression 2016-09-07 15:46:16 -07:00
cscanner.c Cosmetic rename COPERATOR to CONVERSIONOPERATOR 2015-05-01 19:26:09 +01:00
parser.y Fix enum error when value contains char in compound expression 2016-09-07 15:46:16 -07:00
templ.c Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +01:00
util.c smartptr feature support - factor out common code 2015-09-25 22:57:59 +01:00