Commit Graph

100 Commits

Author SHA1 Message Date
Erik Arvidsson
0fa249e5ff Create README.md 2015-11-05 14:51:25 -05:00
Chris Masone
7b55efa9b6 Generated Code 2015-11-05 08:42:22 -08:00
Chris Masone
d66151b4c1 Add IterAllP() to all typed Lists and Sets
Also added IterAllP() to types.Set so it could be used by generated
set code.

Towards #564
2015-11-05 08:42:22 -08:00
Erik Arvidsson
9ba1c4a508 Remove InternalImplementation() from List, Map & Set
Instead register a function to extract the internal backing store.
2015-11-04 18:57:36 -05:00
Erik Arvidsson
8c98964fee Generated code 2015-11-04 18:57:27 -05:00
Erik Arvidsson
7d4e2df45d Add types.Enum
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.
2015-11-04 16:40:07 -05:00
Erik Arvidsson
07414d0a9e Remove InternalImplementation from structs
By adding a reader to structs we can remove the function that exposes
the internal implementation details of a struct.
2015-11-04 14:57:52 -05:00
Erik Arvidsson
756b893e8f Remove FromVal functions
The generated objects are all type.Values now so FromVal is not needed
2015-11-04 12:13:55 -05:00
Erik Arvidsson
9aadd85004 Add types.Struct and improve typed structs
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.
2015-11-04 11:55:07 -05:00
Erik Arvidsson
eeaac87d5f Make Chunks return all reachable Refs from the current Value
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.
2015-11-03 17:13:20 -05:00
Chris Masone
d3162c9081 Fix botched handling of -in with -out-dir
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.
2015-11-02 14:14:43 -08:00
Chris Masone
a64cee5aab Clean up codegen -out-dir flag handling
Get rid of -out and ensure that Go package names generated from -out-dir
are actually legal Go identifiers.

Fixes #476
2015-11-02 12:17:42 -08:00
Erik Arvidsson
62fad2d615 Merge pull request #536 from arv/equals-by-ref
Make Equals compare by Ref (after comparing TypeRef)
2015-10-30 18:35:08 -04:00
Aaron Boodman
894e615696 Merge pull request #535 from aboodman/blob-future
Convert NewBlob() away from using resolvedFutures
2015-10-30 15:05:09 -07:00
Erik Arvidsson
3c0ef5bcbb Make primitives reasonable 2015-10-30 17:33:47 -04:00
Erik Arvidsson
30cc7d518f Make Equals compare by Ref (after comparing TypeRef)
This changes equal to compare by ref. Since computing the ref can be
expensive we first check that the type refs are equal.

Fixes #532
2015-10-30 16:50:49 -04:00
Aaron Boodman
c52bf0bbf5 Convert NewBlob() away from using resolvedFutures
Instead, use a backing MemoryStore. This is part of removing Futures.
2015-10-30 12:50:56 -07:00
Dan Willhite
80be862fda Regroup common code. 2015-10-30 10:36:34 -07:00
Dan Willhite
42bac09422 Make sfcrime/quad_tree apps work with new nomsdl types.
Change generated files to <base>.noms.go
2015-10-30 10:23:15 -07:00
Aaron Boodman
a9bc416a2f Change Chunks() to return []ref.Ref 2015-10-30 09:24:58 -07:00
Rafael Weinstein
0e0be1c59b Remove trailing newline from json encoding in typed serialization 2015-10-28 17:07:34 -07:00
Dan Willhite
84b99fbc37 Check in generated files with new names and delete old ones. 2015-10-28 14:28:20 -07:00
Dan Willhite
13b2cf5702 Three mods to codegen.
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.
2015-10-28 14:28:15 -07:00
Erik Arvidsson
81f80d5ce6 NomDL: Encode compound blobs as structs
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
2015-10-27 17:53:16 -04:00
Erik Arvidsson
cdcf952270 Update TypeRef comment and get rid of useless param
The name param of MakeCompoundTypeRef is always the empty string.

I didn't change the underlying storage or serialization.

Fixes #436, #477
2015-10-26 15:35:45 -04:00
Erik Arvidsson
1d13a878c4 Fix types.Ref and RefKind objects
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
2015-10-26 11:18:02 -04:00
Chris Masone
2cd6831598 Changes codegen.go to emit all code in a single Go package
Fixes #467
2015-10-23 16:42:54 -07:00
Chris Masone
65c5b5c424 generated code 2015-10-23 16:33:52 -07:00
Erik Arvidsson
a60de44b13 Generated code 2015-10-23 11:04:41 -04:00
Erik Arvidsson
91e7ffb8e1 NomDL Codegen: Parameterize the types package
This allows us to use the codegen from types/ without manual touchups
2015-10-23 11:04:30 -04:00
Chris Masone
e810716e45 remove unreachable case 2015-10-22 10:56:13 -07:00
Chris Masone
612ca18cf5 generated code 2015-10-22 09:56:31 -07:00
Chris Masone
1486d84487 Make generated Enum types implement types.Value
Fixes #391
2015-10-22 09:56:26 -07:00
Erik Arvidsson
3b20144ed8 NomDL: Clean up namespace handling in New calls
Fixes #449
2015-10-22 12:38:56 -04:00
Erik Arvidsson
71197cb4e7 Generated code 2015-10-22 12:33:39 -04:00
Erik Arvidsson
8c4bc79fcd NomDL: Remove $type from struct impl
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
2015-10-22 12:33:39 -04:00
Erik Arvidsson
64217a8548 Generated files 2015-10-22 10:49:06 -04:00
Erik Arvidsson
3a5bb571fb NomDL: Remove NomsValue() 2015-10-22 10:47:14 -04:00
Erik Arvidsson
afeef44020 Updated generated code 2015-10-21 19:04:22 -04:00
Erik Arvidsson
16353f38f8 NomDL: Make the new serialization default
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.
2015-10-21 19:04:22 -04:00
Erik Arvidsson
91f720be81 NomDL: Need to include the deps in the package 2015-10-21 09:17:35 -04:00
Erik Arvidsson
d6869cef35 NomDL: Make Package a primitive type
This solves the bootstrapping problems we are encountering.

Previously Package was a Struct but structs depend on Package.
2015-10-20 10:26:00 -04:00
Chris Masone
4169f2af3a Create shared 'geo' Noms types package
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
2015-10-19 15:19:01 -07:00
cmasone-attic
272a4632c5 Merge pull request #429 from cmasone-attic/issue420
pkg.Parsed should embed a types.Package, not a types.PackageDef
2015-10-19 11:26:04 -07:00
Chris Masone
e249f11347 pkg.Parsed should embed a types.Package, not a types.PackageDef
Doing so makes it so we don't create new Package instances all over codegen.go

Fixes #420
2015-10-19 11:22:16 -07:00
Chris Masone
f9e39f1b89 NewDataset() should refuse to accept "" as the datasetID
Also, update codegen.go to use a sensical default if nothing is provided
on the command line.
2015-10-19 10:45:53 -07:00
Chris Masone
9b225dce9b Introduce UnresolvedKind, so TypeRefKind isn't overloaded.
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.
2015-10-19 09:58:27 -07:00
Erik Arvidsson
e9f5b1e2b5 NomDL codegen: Clean up write and improve ordering
Now we write the named types first, then the using types and finally
the inline type defs in the order that they were defined.
2015-10-19 11:39:58 -04:00
Erik Arvidsson
ba5139a5c4 NomDL codegen: Followup cleanup
Just renaming the parameters back to normal names
2015-10-19 09:35:34 -04:00
Erik Arvidsson
f064d35253 NomDL: Move pkgRef to UnresolvedDesc
Only unresolved type refs should have a package ref.
2015-10-16 19:39:49 -04:00