Closed pljakobs closed 3 weeks ago
It's the code generator. I've got a work-in-progress to address some of these issues, these are the main ones:
properties
optional for definition-only schema$defs
gets generated as a direct parent of its containing database, but this doesn't always get tracked correctly.incomplete type
with ContainedHsvct::Struct
arise because the object definition order isn't correct.I'll use your provided schema for testing, hopefully get this fixed.
would an explicit "include" for cfgdb files make this easier because it would create a defined order of generation?
would an explicit "include" for cfgdb files make this easier because it would create a defined order of generation?
Short answer
No, the order of parsing doesn't matter. It's the order in which the generated C++ classes are emitted which is the issue.
Long answer
The code generator loads all the schemas as a first step, so as long as they're all in the same project then there's no need to explicitly provide a path. If you wanted to start using schemas from other locations, perhaps even shared between projects, then that can be accommodated by invoking the generator manually.
After loading schemas, the generator parses the properties
value from each database in turn. Stuff from other locations in the schema (typically $defs
) only gets parsed when referenced. Note: This means unused definitions won't appear in .h or .cpp files.
As each object is parsed they are added to an internal list which is then iterated in reverse order during code generation. That generally works OK because dependent objects appear after the class which first uses them. However, with your example above, last-color
refers directly to the hsvct
so that appears first in the list. That means it gets emitted after everything else. However, it's also a dependent of color
, which gets emitted earlier. So the generator now actually has to do some work to establish the correct order of definition rather than just winging it.
those changes mostly work, but since I import both app-data and app-config, defs gets iported twice, adding #pragma once
to the defs.h works.
I figured I'd put all my re-used definitions in one devs.cfgdb schema module (even though, for reasons, this one, hsvct, ended up not really being re-used)
I then use those in my actual database schemas (I'm still thinking to have two databases, one for the app configuration, the other for working data)
so here, I create a root property
last-color
that uses thehsvct
definition. It took me a while (and your answer yesterday) to understand that, even if only used to store defs, the schema file requires aproperties
section, so I've added an empty one - this file only holds the definitions that I use on both databases.compiling this gives me quite a few errors in ConfigDB even though the code generator does not report an error:
is this a fault on my side or with the generator?