Commit Graph

38 Commits

Author SHA1 Message Date
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
Chris Masone
6f8126c741 Only build each Package object once
The initial, naive generated code that adds type info to Noms structs
built a new Package object every time a new struct instance was
created. They always had the same ref, so the result was correct, but
there was a lot of work for nothing. This patch caches Package objects
so that we only build them once.
2015-09-24 08:43:04 -07:00
Erik Arvidsson
8294a77ead NomDL Codegen: Make sure we keep the original key names
The underlying map for structs should use the original field names as
the map keys.
2015-09-24 11:16:46 -04:00
Chris Masone
63c956a5c5 Add types.TypeRef
We want to explore encoding type information about Noms data in
the Noms database. So, we need some way to describe types. This
takes the shortest path to making a Noms type called "TypeRef" that
is a peer of Set, Map et al and can describe all the types we currently
use.
2015-09-22 16:19:38 -07:00
Erik Arvidsson
bcdba6f79e Revert "Direct recursive struct" 2015-09-22 17:01:05 -04:00
Erik Arvidsson
a4a29fca7b NomDL codegen: Disallow Defs when we get a recursive go struct
go does not allow recursive struct types

Issue #320
2015-09-22 16:53:58 -04:00
Erik Arvidsson
9e7fa76506 NomDL Codegen: Partial support for recursive types
When computing if a Map/Set key contains another Map/Set/List we need
to ensure that we are not hitting a recursive type or we hit an i-loop.

Partial fix for #320
2015-09-22 09:17:14 -04:00
Erik Arvidsson
2769353a55 NomDL Codegen: Do not create a Def if non comparable
Due to limitations in Go we cannot create a Def for a Map or Set that
has a key that is a Map, Set or a List. This is because the key if a Go
map needs to be a comparable and maps and slices are not comparable.
2015-09-21 19:04:53 -04:00
Erik Arvidsson
8358bfe33a NomDL Codegen: Title case field names for go
Fixes #311
2015-09-21 13:29:16 -04:00
Erik Arvidsson
6e369b85cd NomDL: Change command line to process all .noms files
The codegen.go command line utility now detects the package name from
the file that it was invoked from if `--package` was not provided.

It also processes all `.noms` files in the current directory in case
the `--in` flag was not provided.
2015-09-21 12:19:14 -04:00
Erik Arvidsson
91ac2ef236 NomDL: Ref support
A Ref has a SetValue(v, cs) and a GetValue(cs)

Fixes #306
2015-09-18 17:02:41 -04:00
Erik Arvidsson
b52ba691e6 NomDL CodeGen: Struct should use Map for now
This is so that we can transition awapy from nongen

Fixes #312
2015-09-17 18:44:49 -04:00
Erik Arvidsson
bbe396fb94 Merge pull request #308 from arv/set-extras
NomDL: Codegen for Set extras
2015-09-17 17:25:59 -04:00
Erik Arvidsson
f64f6ae81c NomDL: CodeGen for Map extras
This adds Iter, IterAll and Filter to Maps

Issue #303
2015-09-17 17:20:49 -04:00
Erik Arvidsson
175cc7ccc1 NomDL: Codegen for Set extras
This adds Iter, IterAll and Filter to Sets

Issue #303
2015-09-17 16:49:22 -04:00
Erik Arvidsson
5a83b23f29 NomDL: Codegen for List extras
Adds Iter, IterAll and Filter to the List(T) types

Depends on PR #298

Issue #303
2015-09-17 14:24:36 -04:00
Erik Arvidsson
e10e6224b0 Codegen for NomDL
This adds a new codegen that reads .noms files and generates Go
API for these types

Issue #304
2015-09-17 14:01:49 -04:00