Wed 31 July 2024

🏖️ Sane C++ July 24

SC

Welcome to the update post for July 2024!
The focus of the month has been building a nicer showcase for SC::Plugin and SC::Serialization libraries.

📄 Sane C++ Libraries Documentation
💻 Sane C++ Libraries Repository
📹 Sane Coding Youtube channel
💬 Sane Coding Discord

SCExample#

Serializer example

The hot-reload system of SCExample has been tuned so that each internal example is just an hot-reloaded Plugin. It's now very convenient to iteratively build them and experiment! A nice serialization example has been added to SCExample, based on a very well known piece of code from the official imgui demo. State of the canvas control is saved to binary and json using the automatic serialization provided by the reflection system. It's also showing a somewhat advanced usage of the Reflection system, that is how to wrap a "custom" vector implementation (ImVector) There is a video where I've been recording the most important bits of this development:

And as a last nicety, SCExample has been fully ported to iOS! Hot-reload obviously requires root access to install clang compiler and a sysroot on iOS, so it will work only if you have an active jailbreak. Also here I've been recording a video on finalizing porting SCExample to iOS.

This is the list of SCExample related commits:

SC::Serialization#

Serialize all the things

While building the Serialization example, a few fixes have been made necessary to SC::SerializationBinary. The first has been supporting the bool data type that for some obscure reason was missing from the primitive types. Some helpers to read and write the schema together with serialized data have been added to make it easy supporting versioned binary serialization. Fields can be added or removed, and the serializer will still try to load data that can be converted assuming a matching order. There is also some support for changing field types. For example a float field that is converted to int (or vice-versa) will receive a truncated value on deserialization.

SC::Plugin#

Hot-Reload like there is no tomorrow

SC::Plugin library has received a few improvements, like the ability to specify a path for the sysroot under clang (needed on iOS), and it's capturing compiler and linker outputs. This last one allows showing compile errors in the plugin host app, that is a nice addition to SCExample. Finally some dynamic export clauses have been added to many libraries in order for Plugins to find symbols in the host application that is loading them. This will for sure increase the executable size as the linker will not be able to trim such classes as "unused" code, even if they're not referenced by any Plugin. Probably some macro to disable this "export by default" behavior will be added for anyone that wants to use Sane C++ Libraries without the Plugin Library or without needing to use Sane C++ Libraries type across dynamic library boundaries.

SC::Build#

Actually got a promotion!

SC::Build library has received some improvements too, supporting generation of iOS project and application icon for Xcode app bundle. There are still many missing features and too many hardcoded defaults but I feel that the library deserves more than a Draft status. For this reason I've been promoting it to MVP status: maybe this will become an incentive to add more features to make it usable!

Contributions#

Together we can build more!

This month Jeremy Laumon has been adding .natvis support for Arrays!

Additional fixes#

Fix fix fix

And then the usual amount of monthly fixes! I can never stress how important is to use the libraries in a real project or even just in an example app to trigger issues and identify missing bits!