-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wrapping of %define and #define expressions containing chars #93
base: matlab
Are you sure you want to change the base?
Fix wrapping of %define and #define expressions containing chars #93
Conversation
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.
This reverts commit b2bf0b3.
Fix wrapping of %define and #define expressions containing chars
@jaeandersson , if I may, I suggest you do a fast-forward merge in case you accept the PR. This way we avoid diverging our |
CC @traversaro |
Who and where from is the original source of these changes? Shouldn't Go and C# pull requests be submitted to SWIG proper? |
This PR merges the fix swig#781, please refer to robotology-dependencies#1 for more details. |
Hi @wsfulton , the original fix swig#781 is already in the master branch of the original repo https://github.com/swig/swig, but not on the |
That's okay, it wasn't clear to me when I first saw this that they came from swig/swig originally. |
Thank you for your contribution. I'll check in the next couple of days. The Matlab branch really needs to get the last push for merging with swig proper. I'll make it a priority. My last couple of months have been pretty crazy, but it's starting to calm down now. |
Can this be closed please? It's obsolete after merging |
Hi @jaeandersson , as per our short discussion, here is the PR fixing the wrapping of global defines and enums having char type elements, or being expanded with char type inputs. Before the fix, the chars would lose the quotes and become variables.
Please refer to robotology-dependencies#1 for more details.