Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Generate type for anonymous structs, unions and inner enums #134

Merged
merged 1 commit into from
Jul 28, 2018

Conversation

kornilova203
Copy link
Member

Closes #77

@kornilova203 kornilova203 changed the base branch from 0.3 to recursive-structs July 27, 2018 06:23
@kornilova203 kornilova203 changed the title [WIP] Generate type for inner anonymous records Generate type for inner anonymous records Jul 27, 2018
@kornilova203 kornilova203 changed the title Generate type for inner anonymous records [WIP] Generate type for anonymous structs, unions and inner enums Jul 27, 2018
@kornilova203
Copy link
Member Author

It was not clear how to match anonymous structs/unions visited by TypeVisitor and translated by TypeTranslator
But it is possible to get clang::RecordDecl from QualType in TypeTranslator, so I moved code that creates instances of ir/Struct and ir/Union to TypeTranslator.

@kornilova203
Copy link
Member Author

Fields of inner anonymous enums used to be translated incorrectly:

struct s {
    enum { A, B } innerEnum;
};
type enum_(anonymous enum at /Users/lk/projects/scala-native-bindgen/bindgen/cmake-build-debug/../my.h:2:5) = native.CStruct0 // incomplete type
type struct_s = native.CStruct1[enum_(anonymous enum at /Users/lk/projects/scala-native-bindgen/bindgen/cmake-build-debug/../my.h:2:5)]

This PR fixes it:

type struct_s = native.CStruct1[native.CUnsignedInt]

@kornilova203 kornilova203 changed the title [WIP] Generate type for anonymous structs, unions and inner enums Generate type for anonymous structs, unions and inner enums Jul 27, 2018
@kornilova203 kornilova203 requested a review from jonas July 27, 2018 07:10
Copy link
Member

@jonas jonas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kornilova203 kornilova203 merged commit 607f4fc into recursive-structs Jul 28, 2018
@kornilova203 kornilova203 deleted the anonymous-types branch July 28, 2018 07:52
@kornilova203 kornilova203 restored the anonymous-types branch July 28, 2018 07:53
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants