-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1
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.
Implementation@traversaro , this PR is a result of 2 steps:
TestsThe tests on simple examples work fine:
generates:
But it's failing with the yarp-matlab-bindings files. Checking again now it's not an issue with the install. |
I think we can also just try to merge the |
The bindings generation is working fine, the problems I had earlier were probably due to leftover temporary objects involved in the SWIG processing. After rebuilding
|
Last updates on the PR:"Our" So we just need to merge the PR to |
I had an issue with a missing |
@traversaro , the issue with the missing Since we now have and will maintain our own fork of SWIG, I'll apply the changes directly to the SWIG source files |
I will make the change in a different PR, in case anyone needs the fix in this current PR just by doing a single commit cherry-pick. So I'm merging this PR now. |
Oh fak, my fault in accumulating technical debt. Let's proceed with your solution of patching our branch, but this will be problematic once the matlab branch will be merged in SWIG upstream. I think we should open an issue discussing robotology/idyntree#188 (comment) in either https://github.com/jaeandersson/swig or https://github.com/swig/swig . |
I suggest we open it in https://github.com/jaeandersson/swig so that we avoid diverging from his |
@nunoguedelha I agree. |
Ok, for now opened an iDynTree bug to track the problem on iDynTree's side: robotology/idyntree#448 . |
This PR merges the fix swig#781, after the discussion on the issue regarding the wrapping of global defines and enums having
char
type elements, or being expanded withchar
type inputs. The chars would lose the quotes and become variables.