Add source files as proper object-oriented entities
At the moment, the SfgContext
collects all structurual components that should be written out to the generated source files, but the association of each component with the generated header file, implementation file, or both, is left implicit and only determined by the printer.
This is a significant limitation, as it makes it hard to place pieces of code specifically in certain files, and requires lots of special handling when doing header-only or inline-header code generation.
Proposal
- Implement classes for modelling C++ source files as individual objects, which shall explicitly contain all structural components that should be written to that file: prelude comment, header inclusions, definitions, regular and kernel namespaces.
- Change the
SfgContext
to hold one or more such source file instances. - Change the
SfgComposer
to add all code entities declared through its API to the correct file(s). - Split
SfgFunction
andSfgMethod
into a declaration and a definition part and haveSfgComposer
add the function declaration and definition to separate source files, or to the same source file in different places, depending on the requested inlining behavior.
This change automatically allows source files to contain multiple namespaces, although the SfgComposer
shall, for the time being, stick to modelling a single primary namespace. Also, this will allow kernel namespaces to be placed in header files.