Commit Graph

66 Commits

Author SHA1 Message Date
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
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
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
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
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
71197cb4e7 Generated code 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
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
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
f064d35253 NomDL: Move pkgRef to UnresolvedDesc
Only unresolved type refs should have a package ref.
2015-10-16 19:39:49 -04:00
Erik Arvidsson
36d9362628 NomDL: Use ordinal for unresolved type refs
Instead of using the name of the type we now use the index of the type
in the Package that defines it.
2015-10-16 17:46:15 -04:00
Chris Masone
3e43c58320 Import .noms files by path
.noms files can now import other .noms files by relative or absolute path.

Fixes #399
2015-10-14 15:03:50 -07:00
Chris Masone
30422eaa33 Fix a few issues with switching from NamedTypes -> Types and re-run go generate
grammar.peg didn't get updated along with grammar.peg.go in arv's last patch,
so that needed to be fixed. Also, pkg.Parsed had its own field named Types, which
shadowed the one it got by embedded types.Package. This only came into play when
generating code for packages pulled out of a dataset. Since arv had to manually
patch up all generated code in his last patch, he never hit this issue and I
missed it in review.

Now, go generate passes once more. Yay
2015-10-14 14:31:06 -07:00
Erik Arvidsson
6185ea1ddb NomDL: Use a list for the types in the package
This does not yet update the serialization to use the ordinal.
2015-10-14 14:49:04 -04:00
Erik Arvidsson
8565f175ee Make sure Chunks includes type.Refs and the TypeRef
Chunks shold return the futures for types.Ref values.

For typed values that have a TypeRef which has a package ref, also
include that.
2015-10-13 11:00:51 -04:00
Chris Masone
56cd548328 Support compounding types with imported types.
Sets, Lists, Refs and Maps of imported types work now.

This PR also factors some of codegen.go into a separate package, to slim down
that file a bit.

Towards issue #294
2015-10-12 15:29:45 -07:00
Chris Masone
ea34bfaaea check in generated test dependency code 2015-10-09 17:23:03 -07:00
Chris Masone
cc15992778 Initial support for importing type pacakges by ref
Towards #294
2015-10-09 15:19:06 -07:00
Erik Arvidsson
37336f41be NomDL serializing
This now handles serializing TypeRef values
2015-10-09 14:09:49 -07:00
Dan Willhite
b20b1c42cd Add MaybeGet method to generated Map types. 2015-10-07 13:40:34 -07:00
Erik Arvidsson
9cb7596409 NomDL: Make NomsValue a Value
This means that when we ReadValue we can now return a NomsValue

Towards #281
2015-10-06 16:38:11 -07:00
Erik Arvidsson
2dec53453e NomDL: Add new serialization format
The new serialization format use "t " as in typed. The rest of the
message is a JSON array describing the typed data. The type is
described by types.TypeRef

Fixes #384
Issues #281, #304
2015-10-06 15:56:10 -07:00
Erik Arvidsson
72f4cd3a7a NomDL Codegen: Make the TypeRef return a package ref
The TypeRef function for a Noms Struct should be the (Name, PkgRef) and
not the description of the struct fields. This is important because
when serializing we need to write the package ref.

Towards #281 #304
2015-10-05 14:24:25 -07:00
Erik Arvidsson
096ac4a224 Add index to List Iter, IterAll, Map, MapP
Fixes #376
2015-10-01 17:53:21 -04:00
Erik Arvidsson
8c2caa3b27 NomDL Codegen: Add TypeRef method to typed objects 2015-09-30 17:48:32 -04:00
Chris Masone
9168a902f9 Modify codegen to include pacakge refs for unresolved types
Also, switch to using a ref.Ref when getting/setting the package
ref in a TypeRef. Using a types.Ref just led to lots of manual
boxing and unboxing every time I wanted to use the reference.

Toward issue #294
2015-09-29 12:58:56 -07:00
Chris Masone
5ce93dad2e Beginning of import support in NomDL
This patch mostly merges parse.Package and types.Package, though it
can't quite go all the way. A types.Package doesn't have 'using'
declarations, while the parsed representation of a .noms file needs to
have that information. Hence, the parse package is moved to the 'pkg'
package, and pkg.Parsed is introduced. This type embeds types.Package
and adds the necessary additional information.

To make inroads on handling imports, I enhanced ParsePackage() (now
called ParseNomDL()) to actually process the 'alias' and 'import'
statements in the input and go replace namespaced type names in the
package with refs of imported packages. For example, the TypeRef for
'Bar' generated in the following package

alias Foo = import "sha1-ffffffff"

struct Bar {
  f: Foo.RockinStruct
}

will actually return types.Ref{sha1-ffffffff} when you call PackageRef()
on it.

In addition, I've added a function to the new 'pkg' package,
which allows the caller to get the dependencies of a type package
from a chunk store.

Fixes issue #353, towards issue #294
2015-09-28 16:08:22 -07:00
Chris Masone
c80a1c55b3 Merge parse.TypeRef and types.TypeRef
These were two representations of, essentially, the same information.
They were separate because they provided different APIs to similar
information, but the APIs became more similar once we started using
native types (as opposed to Noms types) for the various Make*TypeRef()
functions.

Unifying these is a big step to unifying parse.Package and types.Package,
which is pretty necessary for dealing with imported packages.

Fixes issue #338
2015-09-25 15:17:49 -07:00
Erik Arvidsson
bf095dab3c Merge branch 'master' into nomdl-optional-codegen 2015-09-25 17:20:23 -04:00
Erik Arvidsson
d17dc67a73 NomDL CodeGen: Rename self 2015-09-25 17:17:12 -04:00
Erik Arvidsson
c254a1391a Codegen for optional fields in structs 2015-09-25 17:08:57 -04:00
Erik Arvidsson
5b3f611104 NomDL Codegen: Add optional flag to Field 2015-09-25 14:38:41 -04:00
cmasone-attic
44a5d53f74 Merge pull request #340 from cmasone-attic/apicleanup
Change types.TypeRef creation API to use native types instead of Noms.
Towards issue #338
2015-09-24 13:56:10 -07:00
Erik Arvidsson
fe790b1043 NomDL Codegen: More recursive types issues
Issue #320
2015-09-24 16:52:23 -04:00
Chris Masone
b12a89c0df Change types.TypeRef creation API to use native types instead of Noms.
These are just easier to work with. The internal representation remains
the same.

Towards issue #338
2015-09-24 12:57:51 -07:00
Chris Masone
b3307b4feb Always generate Package ref and cache it
The initial patch did this lazily, but that's kinda dumb.
People won't compile in generated code they don't use.
2015-09-24 08:45:58 -07:00