forked from swig/swig
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
23 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters