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

Regression: maintain object key order of parser document JSON #88

Merged
merged 1 commit into from
Sep 7, 2020

Conversation

HertzDevil
Copy link
Contributor

Follow-up to #84.

Some processors rely on the object key order of the JSON document generated by the Clang parser; most notably, the Crystal wrapper generators assume that every class appears before its subclasses, so that subclasses never inherit from undefined base classes. This class order is directly derived from the Clang parser. However, using std::map means the keys are always sorted in alphabetical order, so code like below breaks because A will be added to the JSON before B:

struct B { };
struct A : B { };
# cannot use `B` before it is defined
class A < B
end

class B
end

The simplest fix is to use a custom std::map-like container in the Document struct that keeps track of the key insertion order. This patch requires no changes on the Crystal side.

@Papierkorb Papierkorb merged commit 52df952 into Papierkorb:master Sep 7, 2020
@HertzDevil HertzDevil deleted the parser-document-fix branch September 7, 2020 12:46
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

Successfully merging this pull request may close these issues.

2 participants