This is needed to be able to round trip enums.
If there is no codegen for an enum that is read from the datastore we
now return a types.Enum which can be serialized back to the same
sequence.
The generated code for typed structs now uses a Go struct which
implements Value directly. The fields in this struct uses the "user"
type. (The union value still uses types.Value though.)
When a typed struct is created by the decoder, it asks for a struct
builder which returns a channel that the values of the fields of the
struct are sent to.
We now do a recursive call which bottoms out with a ref.Ref for RefKind
Values. This means that we traverse into nested structures consistently.
The effect of this is that we get all the refs that the current chunk
references.
The output file should always be emitted relative to -out-dir. I was
incorrectly appending the path to the input file onto that provided in
-out-dir to construct the path to the output file.
1) truncate filenames containing hash to only use first 7 chars of hash.
2) change output filename from <base>.go to <base>_noms.go
3) check for includes of file in same directory and don't generate twice.
Before encoding a compoundBlob we create a compoundBlobStruct and
encode that instead.
After decoding we check if the value is a compoundBlobStruct and if so
we convert it to a compoundBlob.
Fixes#455, #165
Ref Values now have a TargetRef() method that returns the ref.Ref of
the target the Value is referencing.
Note: This is a breaking change. In old code the Ref() of the Value was
the Ref of the underlying target.
Fixes#464
The implementation of structs is a Map and we used to reserve a key
with the name "$type" for the TypeRef. This is no longer needed since
the TypeRef is a constant per struct and needs no storage.
Fixes#450
This makes the new typed serialization the default (the old
serialization is not used but the code has not been cleaned up yet).
Some things are no working in the new world:
Chunking - The compound list is not working correctly any more. The
Chunks method is having issues because it assumed things based on the
old implicit chunking.
Commit - uses a `Set(Commit)` which means that the parent commit is
embedded. We need to change that to be `Set(Ref(Commit))` so that the
parent commit is referenced instead.
First cut at creating a shared Noms types package, by creating
'geotypes.noms' to define Geoposition and Georectangle. These are
shared by quad_tree and sfcrime_importer initially, but will also
by used by sfcrime_search and the stuff that works with photos.
quad_tree used to add methods to the generated Geoposition and
Georectangle types. This doesn't work anymore, since these types
are now generated as part of a separate Go package. Fortunately,
these methods are easily re-cast as pure functions.
Towards #409
We'd wound up in a spot where serialization code used 'TypeRefKind' to
mean one of two very different things...either an actual value that
describes some Noms type, or a reference to a type definition that
lives somewhere else. To get rid of this ambiguity, we introduce
'UnresolvedKind' to take over the latter meaning. Now, TypeRefKind
means _only_ a value that describes a type. If you want to point off
to a type definition elsewhere in the type package, or in another
type package, use UnresolvedKind.