Граф коммитов

56 Коммитов

Автор SHA1 Сообщение Дата
Adam Sapek 28c75802f3 Revert "Add cabal constraint: process < 1.3"
This reverts commit f0d23a001d, which was
a workaround for overly strict constraint in optparse-applicative that
was fixed with pcapriotti/optparse-applicative@22a71d8.
2015-10-13 14:22:26 -07:00
Adam Sapek 7808a284a5 Fix fields of alias type with the default `nothing`
Incorrect [Type] attribute annotation on fields with default `nothing`
lead to failure to find the type converter for type aliases with a
custom type mapping.
2015-10-02 12:31:17 -07:00
Adam Sapek 9570e06edc Add codegen test for alias fields with default nothing 2015-10-01 18:05:02 -07:00
Adam Sapek f0301997e4 Document the @listfile syntax in gbc usage help 2015-09-20 14:56:31 -07:00
Adam Sapek f0d23a001d Add cabal constraint: process < 1.3
The gbc-tests dependencies require process < 1.3 leading to dependency
conflicts if the sandbox has been first populated with dependencies of
Bond library before configuring the test suite.

This is a (hopefully) temporary workaround until
pcapriotti/optparse-applicative#150 is merged.
2015-08-25 18:58:23 -07:00
Adam Sapek 58addc32e5 Revamp C# type mappings and codegen
- Add support for type mapping specific annotated type name and
  declaration type name.
- Rename collection interfaces type mapping.
- Clean up white spaces in the generated _types.cs.
- Allow omitting [Bond.Default] attribute for scalar properties on
  interfaces.
2015-07-01 15:18:09 -07:00
Adam Sapek 856c3a92f2 Reimplement code generation tests with Tasty.Golden
Make each generated file comparison into a goldenTest case. Golden files
can be updated/added for changes in codegen/tests using --accept command
line switch.
2015-06-29 14:52:48 -07:00
Adam Sapek 1e95d49511 Convert compiler tests from test-framework to tasty 2015-06-28 11:30:52 -07:00
Adam Sapek 7d53e1a2db Expand code generation test coverage
1) Add custom allocator variant for all C++ cases.
2) Add collection interfaces variant for all C# cases.
3) Generated _apply.h/cpp is not schema content specific so it is
sufficient to test for one schema file.
2015-06-27 11:18:05 -07:00
Adam Sapek 979183d22f Create cmake source groups for compiler sources 2015-06-22 12:32:32 -07:00
Adam Sapek c9367aef58 Fix formating of compiler errors
Use putStrLn instead of print to output parser errors from gbc.
2015-06-22 12:32:31 -07:00
Adam Sapek d2f12c291d Remove an unused Language constructor 2015-06-22 12:32:27 -07:00
Adam Sapek 286a3c7def Add Haddock documentation comments
Rearranged and renamed some public APIs and moved some symbols to
private, unexposed modules.
2015-06-22 12:32:26 -07:00
Adam Sapek d181a0d731 Remove internal functions from exposed modules
Some of the functions are used only internally by the parser while
others are used by the built-in codegen templates but are to specific to
expose them as public APIs. If a custom codegen needs similar
functionality it can be easily implemented using the more generic
helpers.
2015-06-22 12:32:24 -07:00
Adam Sapek 9fe9eeca89 Refactor compiler/codegen as a Haskell library 2015-06-22 12:32:23 -07:00
Adam Sapek 99d622090d Use version number from cabal generated module
Remove the manually maintained Bond.Version module and use the cabal
generated Paths_bond module instead.
2015-06-22 12:32:22 -07:00
Adam Sapek 556ce21603 Fix build races
1) When running the generated makefile with multiple jobs the `cabal
install` could start before `cabal sandbox` finished initializing the
sandbox leading to packages being installed globally and not available
during `cabal build` which expects dependencies in the sandbox.

2) Tarvis CI build sometimes would fail because nuget couldn't reach the
online repository. Added `travis_retry` to mitigate the problem.
2015-05-29 17:34:32 -07:00
Adam Sapek 3d82ae2e98 Explicitly specify short names of compiler options
The cmdargs library silently skips short names for options if more than
one option starts with the same letter. This can lead to inadvertent
breaks when a new option is added, like happened with adding
`--no-banner` option, breaking the short name -n for the `--namespace`
option.
2015-04-27 22:08:03 -07:00
Adam Sapek f1b59f2e09 Work around the unused import warnings
Prelude changes implementing the Functor/Applicative/Monad-Proposal as
well as the Foldable/Traversable-Proposal cause unused import
warnings on GHC 7.10.
2015-04-22 21:09:50 -07:00
Adam Sapek e882d286c9 Fix various type alias bugs
Parser:
- map<Alias, T> should be valid for type aliases of the string
type.

C# codegen:
- nullable<Alias> should generate Type? for aliases of scalar
types.

C++ codegen:
- Fields of an alias type can have default value if the aliased type
  allows explicit defaults.
- The allocator constructor had unused allocator parameter in some
  cases.
2015-04-22 21:09:49 -07:00
Adam Sapek f78ccea2b6 Add type alias codegen tests 2015-04-20 22:45:13 -07:00
Adam Sapek be14e5596d Move test schema files to a separate directory 2015-04-20 22:45:11 -07:00
Adam Sapek aa5f28ca78 Build gbc with -Wall -Werror 2015-04-20 22:45:10 -07:00
Adam Sapek 6d04dc7cc1 Add code generation tests
The tests compare checked-in generated files with code generated using
the current compiler.

Discrepancy indicates a change in the generated code which may be a
bug or an intentional change. In the latter case the generated file(s)
should be re-generated and updated in the same commit as the change.

Note that the checked-in files are generated with --no-banner option.
2015-04-20 22:45:08 -07:00
Adam Sapek 7a14f45fcd Update CI configuration files
AppVeyor:
1. Work around memory limitations in Haskell build
2. Run subset of C# test matrix if the sandbox wasn't in cache

Travis CI
1. Change project type to C++
2. Install Mono manually in Linux
3. Use Clang as C++ compiler
4. cabal install happy
2015-04-02 20:11:42 -07:00
Adam Sapek 91db1c4f12 Fix parser bug for bonded<T> with forward declaration
A forward declaration is a valid type argument for bonded.
2015-04-02 03:45:11 -07:00
Adam Sapek 6fb30c9b1c Add gbc-tests to CMake tests 2015-04-02 03:43:57 -07:00
Adam Sapek f63159172a Add unit tests comparing AST from .json and .bond 2015-03-31 22:46:31 -07:00
Adam Sapek 48e1a55847 Simplify the JSON representation of AST 2015-03-31 22:46:29 -07:00
Adam Sapek 0944a12502 Improve errors when parsing invalid schema AST file 2015-03-24 03:38:55 -07:00
Adam Sapek c921a23cd0 Add support for using schema AST as compiler input
File(s) with the `.json` extension are assumed to contain the JSON
representation of schema abstract syntax tree in the format produced by
`gbc schema`
2015-03-20 03:21:57 -07:00
Adam Sapek 8555e498c4 Remove helper functions to modify MappingContext 2015-03-20 02:19:24 -07:00
Adam Sapek f7020b0d8f Customize JSON representation of Default 2015-03-20 02:19:23 -07:00
Adam Sapek 860c1084fd Hide parser environment and ReaderT behind parseBond 2015-03-20 02:19:20 -07:00
Adam Sapek 5881640769 Use standalone deriving Generic declarations
The Generic instance is needed only to derive generic implementations of
FromJSON and ToJSON typeclasses so we move the declarations to
Schema/JSON.hs and only derive Generic for data types that need it.
2015-03-20 02:19:19 -07:00
Adam Sapek ff01c24556 Add round-trip unit test for AST JSON representation
Derived show typeclass for schema types in order to support QuickCheck.
Added custom ShowPretty typeclass for printing Declarations in parser
error messages. Implemented custom JSON parsing for types that had
custom JSON serialization.
2015-03-20 02:19:18 -07:00
Adam Sapek e30c89854b Reduce code duplication around codegen 2015-03-20 02:19:16 -07:00
Adam Sapek 45a37d5bde Add compiler support for schema AST output
The schema AST is written in JSON format. We foresee two classes of
scenarios that will use it.

Tools that need to process Bond schema files using languages other than
Haskell can avoid recreating Bond parser. Example might be schema
repositories, lints, etc.

The schema AST will also be used to allow users to inject schema
transformations into codegen process. This in many cases can be a
lightweight alternative to custom codegen.
2015-03-20 02:19:15 -07:00
Adam Sapek f13b706f9b Improve parser error handling for user defined types 2015-03-20 02:19:14 -07:00
Adam Sapek c2adfae6ee Separate schema data definitions and helper functions 2015-03-19 01:30:29 -07:00
Adam Sapek f710ceb39f Add test suite to Bond compiler 2015-03-19 01:30:28 -07:00
Adam Sapek 2450f5fb73 Define type alias for mapping parsers 2015-03-05 00:46:12 -08:00
Adam Sapek a852f6a36b Merge branch 'qnikst-warning-cleanup' 2015-03-05 00:45:51 -08:00
Alexander Vershilov 312be3b73a Fix warnings in the Bond compiler code 2015-03-04 23:56:40 -08:00
Adam Sapek 1e3653a8dc Add comment explaining negative value for jobs number 2015-02-27 01:07:13 -08:00
Adam Sapek c764d993e0 Avoid parsing the same import multiple times
In some scenarios the hierarchy of schemas may be very interconnected
and redundant parsing of the same imported files is a huge performance
overhead for code generation (this change showed 20x improvement when
compiling a sample set of ~900 interconnected schemas).
2015-02-12 12:16:12 -08:00
Adam Sapek 0c4d4ad4fd Add --jobs option to gbc
When compiling multiple .bond files at once, the `--jobs=[NUM]` command
line option can be used to specify how many jobs should be run
concurrently. When used without arguments, the default is to run as many
jobs as there are processors. The option also accepts negative numbers
to specify fewer jobs than the number of processors. Often the optimal
performance is achieved by leaving one or more cores for other processes
on the machine.
2015-02-12 12:16:08 -08:00
Adam Sapek 4bd6d042b8 Update appveyor.yml for the open source plan
Made the following changes for the open source AppVeyor plan which
runs on very slow and memory limited VMs:
- Limit ghc heap size to 192MB when installing dependencies
- Use `appveyor DownloadFile` instead `Start-Download`
- Download Boost in the smaller 7Zip format
- Cache cabal sandbox and boost download
- Disable C++ build
2015-02-05 19:03:53 -08:00
Adam Sapek 546499996d Relax cabal version requirement to 1.18+
The cabal version 1.20+ was required only for the --required-sandbox
flag. However since the make files are setting up the sandbox we know
that we are always building using sandbox. The current Haskell Platform
comes with cabal 1.18 so this way installing cabal update is not needed.
2015-02-03 21:16:11 -08:00
Adam Sapek f01eed1e08 Fix symbol lookup logic in the parser
This change fixes a bug in lookup of an unqualified symbol from an
imported schema file when one of the files is using a language specific
namespace. Language specific namespaces are not documented and their
use is not recommended, but the compiler supports them for backward
compatibility with legacy code.
2015-01-20 13:49:16 -08:00