Skip to content
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

preserve order when auto-squashing typedefs #8

Open
dallinbeutler opened this issue Oct 16, 2019 · 2 comments
Open

preserve order when auto-squashing typedefs #8

dallinbeutler opened this issue Oct 16, 2019 · 2 comments

Comments

@dallinbeutler
Copy link

I'm using F# where the order of declaring functions, structs, etc somewhat matters. If I can, I'd like to preserve that order (coming from a C header). the auto-squashing type defs would be nice, but when I iterate through the parsed children ICppDeclaration s they are thrown in after all the squashed classes, causing the order to break.
Would this be an easy fix, or should I just turn off auto-squashing and parse the typedefs?

by the way, thanks for making this! it's saving me a lot of time.

@dallinbeutler
Copy link
Author

dallinbeutler commented Oct 16, 2019

Also worth noting, if I turn of the auto-squashing, then CppEnums inside CppCompilation.children don't have their Name property set. and .GetDisplayName() also yields nothing.
I just reallized this is part of the typedef squashing.
Is there a function to squash a typedef after the parsing stage?
Or will I need to parse once with squashing, one without, and then cross-reference?

@xoofx
Copy link
Owner

xoofx commented Nov 1, 2019

Would this be an easy fix, or should I just turn off auto-squashing and parse the typedefs?

order is going to be a problem because I don't maintain the order, the AST is logical. You can for example pre-declare a struct without any body, use pointers to it in another struct, and then define this struct later.

If you turn off auto-squashing, you should be able to at least a few more indirection on your way, but you won't have any order preserved (e.g TypeDefs are defined in a separate collections than structs)

The bug with enum and auto-squashing is certainly something fixable, if you could take a look, don't have much time for this project atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants