libfoundation: Always retain (and release) the __MCValue.typeinfo.
libfoundation: Always retain (and release) the __MCTypeInfo.named.
libfoundation: Include a record's typeinfo in its value hash.

It's possible for multiple record types to have fields named the same
with the same contents, but still be of differing underlying types.
libfoundation: MCRecordCreateMutable(): Store the record's typeinfo.
libfoundation: MCRecordTypeInfoIsDerivedFrom(): Initialise the loop variable.
libfoundation: MCRecordTypeInfoCreate(): Count fields before allocating array.
libfoundation: Remove extraneous semicolon.
libfoundation: MCTypeInfoBindAndRelease(): Correct handling of base typeinfo.
libfoundation: Use __MCTypeInfoGetTypeCode() instead of directly masking flags.
libfoundation: Unify record field-counting algorithms.

It doesn't make sense to have two implementations of the "count all
fields in record type and base types" algorithm, one in
foundation-record.cpp and one in foundation-typeinfo.cpp.

This patch adds a __MCRecordTypeInfoGetFieldCount() function, which
assumes that the typeinfo it is passed has already been resolved.

The implemented algorithm is iterative rather than recursive, for two reasons:

1) In the original __count_fields() implementation, the recursive call
   was not in a tail position; optimisation to a loop would have been
   non-trivial, and therefore an explicit loop is more efficient.

2) Infinite loops are easier to debug than stack overflows.
libfoundation: MCHandlerTypeInfoCreate(): Count args before allocating array.
Merge pull request #1529 from peter-b/misc-records

libfoundation: More records API fixes and improvements.