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.
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 becauseA
will be added to the JSON beforeB
:The simplest fix is to use a custom
std::map
-like container in theDocument
struct that keeps track of the key insertion order. This patch requires no changes on the Crystal side.