Support versions of GTypes

This adds support for registrating multiple versions of the same
typename by adding "@@" and a version name when you register the type.

This allows you to include a static library in your module that uses
gtypes. Normally such types would conflicts if another library also
statically linked to the library with the same gtype names, but a
different version. However, since the version names are different
we avoid this conflict.

You can also use this in public types if you want to allow using two
libraries with similarly named types to be used in the same process.
However, in addition to the gtype versions you then need to solve the
symbol name conflicts. This can be done for instance by using dlopen
with RTLD_LOCAL, or by introducing ELF symbol versioning.

You can query the versions of a type with g_type_[q]version (), and
you can look up a name by name and version with
g_type_from_name_and_version(). g_type_from_name() returns the
unversioned name if one exists (thus putting the burden of using
from_name_and_version on the person introducing versioned symbols),
and in the case of conflicting versions the alphabetically largest
version is used to guarantee stable results.
4 files changed