memory-stack: _memalign(), free sub-stacks, _foreach_region()

This adds support for aligned stack allocations via a new
rut_memory_stack_memalign() function which takes an additional alignment
argument. This new function and rut_memory_stack_alloc() are now
declared as static inline functions in rut-memory-stack.h and they share
a _rut_memory_stack_alloc_in_next_sub_stack() function for the cases
where the allocation doesn't simply fit in the current sub-stack.

rut_memory_stack_rewind() now also frees all but the largest sub-stack
which should help reduce memory fragmentation.

A new rut_memory_stack_foreach_region() api has been added for iterating
through all data currently stored in a stack which is just a small
utility for iterating the sub-stacks up-until the current sub-stack
and passing a pointer and size for each sub-stack to a given callback.
Support new github upstream for protobuf-c

The protobuf-c maintainers changed recently and it is now hosted on
github. This updates Rig to build with the latest version on github.
Since the upsream now better differentiates the protobuf-c library from
the protobuf-c-rpc code and since we already had our own copy of most of
the rpc related code under rig/jni/protobuf-c this takes a copy of the
remaining bits (the dispatch apis) so that we don't need to depend on
building the rpc code from upstream.
remove the rig/jni sub-directory

The jni/ directory was put in place when adding Android build support
for Rig, but the plan for updating our Android support is that we will
only be supporting building Rig in device mode and that we will support
building at runtime using the user's chosen Android NDK. This means the
necessary source will be available at runtime and we will have full
control over its layout without needing to affect the source code layout
of this repo.
rpc: avoid closing negative listening_fd

For peer to peer connections there may not be an open listening fd
associated with a "server" so we need to check if it's >=0 before trying
to close it otherwise we end up hitting ensure_fd_map_big_enough()
which effectively tries to create an fd map big enough to include an
fd of UINT_MAX.
simulator: Add support for logging + serializing property changes

This starts adding support for logging all property changes using a
RutMemoryStack in the RutPropertyContext which can be used for
synchronizing property changes made in the Rig simulator process with
the frontend process each frame.

At the end of rig_simulator_run_frame() we now serialize all changed
properties and send them to the frontend process.
reorganise engine, frontend and simulator relationships

RigFrontend and RigSimulator are now conceptually more of a top-level objects
than RigEngine. rig-simulator owns the RigSimulator state and creates a
RigEngine which hangs of the simulator. rig-device, rig-slave and rig
(editor) now create RigFrontend objects instead of directly creating a
RigEngine.

We should look out for opportunities to migrate state from RigEngine
into other objects like RigSimulator, RigFrontend, RigDevice, RigSlave
and RigEditor.
Add a RutMagazine utility api

This adds a simple, but very fast memory allocation api for allocating
objects of a pre-determined size.

This allocator builds on RutMemoryStack for making all initial
allocations but never frees memory back to the stack.

Memory chunks that haven't been allocated yet are stored in a singly
linked, fifo, list.

Allocating from a magazine is simply a question of popping an entry from
the head of the fifo list. If no entries are available then instead
allocate from the memory stack instead.

When an entry is freed, it is put back into the fifo list for re-use.

No attempt is ever made to shrink the amount of memory associated with a
RutMagazine.
start reading property changes in frontend

Adds initial code for sending property changes from the simulator to the
frontend and iterating through those changes in the frontend. Currently
though we don't have a way of looking up object properties using a
property id though, we have to use a name so we'll need to update the
introspectable interface a bit for this.
major overhaul of RutType and RutObject

The renames the widespread use of the term "interface" in Rut with
"trait". This is inspired by the Rust language whose trait model seems
similar to our mix-in model. The term interface was starting to seem
misleading.

This adds the ability for each trait of an object to optionally have a
corresponding destructor. This is because it's easier to forget to clean
up state for a trait in the _free function which it's disconnected from
the code that adds the trait. It's also just more convenient.

This adds the ability to associate a type with a RutMagazine for faster
allocation performance and also better data locality for objects of the
same type.

This gets rid of the refable interface and moves the ref_count into the
base object. This removes quite a bit of unnecessary indirection and
reduces the boilerplate needed when creating new types.

This removes the need for _rut_init() since all types are now
initialized lazily in the same way.
introspectable: simplify + allow _get_property with id

This consolidates RUT_TRAIT_ID_INTROSPECTABLE and
RUT_TRAIT_ID_SIMPLE_INTROSPECTABLE into one _ID_INTROSPECTABLE trait for
simplicity which also allows us to assume now that all introspectables
simply have a packed array of properties and we can therefore support
looking up a property with an id.

This will be useful for synchronizing property changes from the Rig
simulator process with the frontend process since it lets us efficiently
serialize property changes based on property ids instead of names.
frontend: apply property changes from the simulator

This makes it so property changes received from the simulator process
are now applied by the frontend. rig-device now no longer dispatches
input events in the frontend and instead relies on the input dispatching
in the simulator process instead.
fix: start reading property changes in frontend
fix: major overhaul of RutType and RutObject
stash: comment about addressing undo-redo issue
path: add missing math.h include
Adds a RutMatrixStack api

This adds a matrix stack utility api based on the CoglMatrixStack api
but not dependant on a CoglContext so it can be used in the rig
simulator process.
stash: starting to get the editor working with the simulator
pb: make rig_pb_serialize_input_events() take serializer

This updates rig_pb_serialize_input_events() to take a serializer
argument and we assume the serialization stack is rewound in
rig_pb_serializer_new().
load-save: fix initialization from incompatible pointer warning
stash