Gio: fix a typo in an error path

log must only be called with one argument. At the same time,
improve the log message to be in the usual "prefix: message" format.

https://bugzilla.gnome.org/show_bug.cgi?id=680759
Assorted memory leak fixes

Spotted by valgrind.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Fix memory leaks

GValues inside flat arrays must be unset when not transferring
ownership, and GErrors must be freed after setting the exception.

https://bugzilla.gnome.org/show_bug.cgi?id=669350
Use a GTypeModule for registering custom types

This makes so that the types are installed as dynamic types, and
thus loaded and unloaded on demand. In particular, resources such
as signal class closures are now properly released when the use count
of these types drops to zero.
Additionally, to avoid unloading too early, each GObject prototype
has a now a reference on the GObjectClass. This means that the above
only applies at context destruction, and preserves previous semantics
wrt property and signal installation.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Fix object counters

Previously object counters were defined as int, which allowed them
to be negative. Replacing with unsigned int revealed a number of
places where we weren't incrementing properly, in particular in
dynamic class definitions (prototypes are finalized, and thus would
decrement the counter).

https://bugzilla.gnome.org/show_bug.cgi?id=679688
GIRepositoryFunction: don't install a resolve hook

GI functions don't have lazy properties, so they don't need a
resolve hook.
This is mainly a code cleanup.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Keep Alive: add a debugging method to print all active roots

Adds a print_roots() to keep-alive objects (such as
__gc_this_on_context_destroy, where GObjects are stored), which
prints a dump of all objects known to it on stderr.
This is primarily meant to debug GObject cycles and leaks that
are not detected.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Boxed: cache the GType in the internal structure

Accessing the GType from the GIRegisteredTypeInfo is not free,
while caching it in the instance structure is also cleaner.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Rework typechecking and private data access

Previously, all type safety checks were inside priv_from_js, which
returned NULL if the object was of the wrong class. Except that a
lot of code was not checking for NULL, causing potential crashes.
Also, we were only checking the JSClass, not the actual type of
object, so for example a function accepting a boxed would take in
any boxed instance, not just the right one (and then that could
crash JS code).
Rework this by splitting typechecking and private data access.
Internal API for typechecking is provided by all object classes
(object, boxed, union, param, gerror) and it takes the necessary
amount of information (GType, GIBaseInfo) to ensure type safety.
priv_from_js becomes unsafe, and thus ok to call in dangerous
data paths such as tracing and finalization.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Associate callbacks with the object on which their installed

Callbacks installed with GObject methods are now traced from that
object instead of being rooted, so cycles no longer cause leaks.
This implementing by making GjsCallbackTrampoline use GjsClosure
internally, and generalizing the existing code that dealt with
signal connections.
Also, to keep tests ok, we now have class finalization functions
for custom types (to unregister the closures).

https://bugzilla.gnome.org/show_bug.cgi?id=679688
GObject: don't use toggle references unless necessary

Many GObject (such as widgets and actors) don't have JS state, but
they're kept alive by C code. We can therefore save some memory
by GCing these objects, and creating new wrappers when needed.
If state is ever set, we transparently switch to toggle refs, so
no change should be visible at the JS level.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Don't use deprecated JSCLASS_CONSTRUCT_PROTOTYPE flags

Not only that flag is removed in newer versions of libjs, it will
break with the new dynamic class system.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Don't use JS_ConstructObject

JS_ConstructObject is deprecated with modern JSAPI, and should be
replaced by JS_NewObject and JS_New. Also, while we're there,
replace constructors with functions that throw, as it is generally
an error to call them from JS anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=679688
Rework dynamic class system

Stop creating multiple JS classes on demand, and instead use the
same JS class and create multiple constructors with different
prototypes, but hand-rolling our own version of JS_InitClass, that
also avoids polluting the global object.
This means that JS_ConstructObject is no longer usable with dynamic
classes, use gjs_construct_object_dynamic or JS_New instead.

https://bugzilla.gnome.org/show_bug.cgi?id=679688