CppAst.NET icon indicating copy to clipboard operation
CppAst.NET copied to clipboard

preserve order when auto-squashing typedefs

Open dallinbeutler opened this issue 6 years ago • 2 comments

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 avatar Oct 16 '19 16:10 dallinbeutler

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?

dallinbeutler avatar Oct 16 '19 17:10 dallinbeutler

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.

xoofx avatar Nov 01 '19 18:11 xoofx