Repository navigation
Conversation
Changing one method of the API description makes everything that includes the monolithic generated C++ headers rebuild. splitclasses="true" on <implementation language="Cpp">: - writes <basename>_interface_<class>.hpp for every class, <basename>_interfaces.hpp stays as an umbrella header - new stubs include only the header of their own class splitclasses="true" on <binding language="CppDynamic">: - writes one header per class with the declarations only, and the method bodies, function table and polymorphic factory in a single source file, so the binding is no longer header-only: the source file has to be compiled and linked - no example is generated for this variant Without the attribute the generated output is unchanged. The attribute is documented in IDL.md and ACT.xsd. Build/build.sh and build.bat list the new source files.
| func writeSplitSourcePrologue(w LanguageWriter, umbrellaHeaderName string, tableHeaderName string) { | ||
| w.Writeln("#include \"%s\"", umbrellaHeaderName) | ||
| w.Writeln("#include \"%s\"", tableHeaderName) | ||
| w.Writeln("") |
There was a problem hiding this comment.
In split mode, _dynamic.cpp includes <windows.h> after the class headers. Any method named like a Win32 macro (GetMessage, CreateFile, …) then fails to compile in the .cpp, and client code that includes <windows.h> first fails to link (reproduced with SetValue → SetValueA). Fix: include the platform header (<windows.h>, or <dlfcn.h> on other platforms) at the top of _dynamic_fwd.hpp, as the header-only binding does, so declarations, definitions and clients all see the same macros.
gangatp
left a comment
There was a problem hiding this comment.
Nice work: the default output is byte-identical to develop, and split mode compiles and runs on clang/macOS as well, so the feature looks solid. Before merge: please fix the <windows.h> include order in the split .cpp (blocker, see the inline comment). Please also add split-mode variants of the Primes and Injection examples to the examples CI, since split mode hasn't been built on Linux or with imported components yet.
Closes #243
What
Adds an optional boolean attribute
splitclasses(defaultfalse) to<implementation language="Cpp">and<binding language="CppDynamic">.Without it the generated output is unchanged.
Output with
splitclasses="true"Cpp implementation:
<base>_interface_<class>.hppper class<base>_interfaces_fwd.hpp(forward declarations)<base>_interfaces.hppas an umbrella headerCppDynamic binding:
<base>_dynamic_<class>.hppper class_fwd,_wrapperand_tableheaders and the<base>_dynamic.hppumbrella<base>_dynamic.cppwith the method bodies (it must be compiled andlinked). The function table is private to
CWrapper..hheader and no example applicationClass names
fwd,wrapperandtableare rejected by the CppDynamicbinding in split mode because they would clash with the helper headers.
Why
For large components a single IDL edit regenerates multi-megabyte files and
forces every translation unit that includes them to rebuild. In our component
(about 450 classes) a simple method change (editing one method description)
took about 23 minutes to rebuild. When the files are synced by content,
unchanged class headers keep their timestamps and only their includers
rebuild. The same edit now takes about 1:20.
Implementation notes
buildbindingccpp.gogets a style parameter(header-only or split) instead of a copy of the code. The split-specific
code is in
buildbindingccppsplit.goandbuildimplementationcppsplit.go.Documentation/IDL.mdandSource/ACT.xsd.build.shandbuild.batinclude the new source files.Testing
Before rebasing onto the current
develop:develop(comparedon a ~450-class component, an RTTI example, and the thread safety and
injection examples).
components.
CWrapper::*WrapperTablehelpers.After the rebase:
pre-rebase build on the ~450-class component.
libPrimes(which has a journal method) generates withsplitclassesonboth the binding and the implementation. MSVC compiles the generated
wrapper, journal and exception sources without errors.
Not tested: macOS and Linux compilers, running a split build at runtime
(including the journal output), and the byte-identity comparison against
developafter the rebase.