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

279 Коммитов

Автор SHA1 Сообщение Дата
Christopher Warrington b0e490f62d Update changelog for 5.3.0 release 2017-04-12 15:36:43 -07:00
Chad Walters 3809d0acd7 [gbc] Include stdint.h in C++ enum header 2017-04-07 15:48:16 -07:00
Chad Walters 3721a3cd3b [gbc] Add test for C++ enum header option 2017-04-07 15:48:16 -07:00
Eduardo Salinas 3865e655c5 [gbc] gbc should reject methods with same name
- Functions and events should have unique names
- Add test
- Fixes https://github.com/Microsoft/bond/issues/381
- Closes https://github.com/Microsoft/bond/pull/388
2017-03-31 11:32:41 -07:00
Christopher Warrington 0ff6ddb204 [c#] Add Bond-over-gRPC
* gbc can now generate proxies and service stubs for gRPC
* The assembly Bond.Grpc.dll contains glue code
* Documentation updated
    * Bond Comm deprecation notice added

Closes https://github.com/Microsoft/bond/pull/386
2017-03-29 18:07:02 -07:00
Veselin Petrov 71b12c403e [c++] Pre-generate missing protocols in apply
Generated *_apply.h/cpp files were missing explicit `Apply<>`
instantiations for `CompactBinaryWriter<OutputCounter>` and
`SimpleBinaryWriter<Null>` protocols. They are now generated.

Closes https://github.com/Microsoft/bond/pull/373
2017-03-28 15:13:24 -07:00
Christopher Warrington 23fa450e05 [c++] Avoid name shadowing warnings
Bond's warning.h header was suppressing warnings about names shadowing
each other. The supressions have been removed, and renames have been
made in library code.

For generated member function parameters, a name that doesn't conflict
with any fields names is now chosen.
2017-03-17 12:58:26 -07:00
Christopher Warrington bd82359a46 [gbc] Temporarily pin derive dependency to < 2.6
gbc-tests no longer builds with derive 2.6 or later. While we
investigate that problem, pin the dependency to < 2.6 to keep gbc-tests
building.

Mitigates https://github.com/Microsoft/bond/issues/342
2017-03-09 16:52:33 -08:00
Christopher Warrington 31d88afa18 Prepare for the 5.2.0 release
Due to the C++ Boost dependency bump, both BOND_VERSION and
BOND_MIN_CODEGEN_VERSION in bond_version.h have been updated to the
current version.
2017-02-07 16:04:41 -08:00
Chad Walters 4f2e0557f3 [gbc] Update schema codegen for DLL support
Fixes https://github.com/Microsoft/bond/issues/314
2017-02-01 12:48:53 -08:00
Christopher Warrington 42fde481e3 [c# epoxy] Make generated interfaces public
The interfaces were inadvertently internal before.
2017-01-26 18:10:56 -08:00
Christopher Warrington cd4e08e347 [gbc] Rename Types_Comm_cpp to Comm_cpp
Renamed the file, the module, and the functions.
2017-01-20 11:14:54 -08:00
Jeff Dubrule 7e7cdf6919 [c++] Support `using Alias<T>=T` when T is an enum
Closes https://github.com/Microsoft/bond/pull/298
2017-01-13 16:30:10 -08:00
Chad Walters 5cde6f878b Add BOND_SKIP_GBC_TESTS for cmake scripts
Also, skip gbc tests on AppVeyor VC12 runs, testing via VC14 is good
enough.
2016-11-18 13:45:03 -08:00
Christopher Warrington 15d58be7fc Prepare for 5.1.0 release
* Update CHANGELOG
* Update some stale documentation
* Update golden test files with new gbc version

Closes https://github.com/Microsoft/bond/pull/269
2016-11-14 15:00:34 -08:00
Ted Stein 7a837b4b96 [C++ Comm] Initial commit of C++ Comm. 2016-10-31 14:47:20 -07:00
Christopher Warrington d5aefd2f78 Prepare for 5.0.0 release 2016-09-12 20:32:35 -07:00
Chad Walters c1e71e7313 [IDL Comm] Improve IDL for consistent naming
* [IDL Comm] Improve IDL for consistent naming

Conform to predominant IDL naming convention. Also pass service and method
names as separate strings. Minor fixups on empty string usage.

Closes [#231](https://github.com/Microsoft/bond/pull/231)
2016-09-12 19:43:01 -07:00
Christopher Warrington b6df009097 Remove bond.TypeDef.list_sub_type
The addition of `bond.TypeDef.list_sub_type` in commit
08fcff0c78 is causing compatibility issues
with users of Bond that have already serialized SchemaDef structs in
Simple Binary.

Until we can figure out a way around this, we're reverting the addition
of this field, returning `bond.TypeDef` to the schema is has had since
3.0.7.

The rest of the infrastructure for determining a ListSubType value
remains. Unit tests have been adjusted to exercise this infrastructure
directly instead of via SchemaDef/FieldDef/TypeDef.

Re-opens https://github.com/Microsoft/bond/issues/161
2016-09-06 17:28:41 -07:00
Christopher Warrington 9747a8d5ce [c++] Generate FromEnum for string conversions
* Generated enum types now have a `FromEnum` method that can be used to
  convert from an enum value to a string. Now generated enum types have
  all four of `ToEnum`, `FromEnum`, `ToString`, and `FromString`. (The
  `...Enum` variants return false on failure, while the `...String`
  variants throw.)
* enumerations example updated to demonstrate all four of these
  functions.
* Existing throwing `FromString` re-implemented in terms of non-throwing
  `ToEnum`.
* `ToString` is intentionally not implemented in terms of `FromEnum`, as
  `ToString` returns a reference to the name stored in the map.
  `FromEnum` copies this name into the output paramater.

Fixes https://github.com/Microsoft/bond/pull/223
2016-08-26 17:52:13 -07:00
Ted Stein 864ab3aeec [gbc] Fully qualify names in generated C++ swap()s
Merges https://github.com/Microsoft/bond/pull/207.
2016-07-22 11:56:08 -07:00
Ted Stein d1efb60104 [gbc] Fully qualify names in cpp apply overloads.
Fixes https://github.com/Microsoft/bond/issues/202, "gbc cpp generates ambiguous
references when a struct and enum val share a name"

Closes https://github.com/Microsoft/bond/pull/204
2016-07-14 15:58:24 -07:00
Christopher Warrington 8835732090 Version bump bond package preparing for release
This is a tentative version number for the bond Hackage package.
2016-07-06 14:48:33 -07:00
Christopher Warrington 897fa02091 Build gbc without optimization inside Travis
We've been seeing timeouts building gbc on the Travis infrastructure.
Building without optimizations reduces the build time significantly and
shouldn't affect build or test results.

Closes https://github.com/Microsoft/bond/issues/176, "ghc 7.8.4 OS X
Travis CI builds are failing"

Closes https://github.com/Microsoft/bond/pull/195, "Build gbc without
optimization inside Travis"
2016-07-06 11:49:20 -07:00
Christopher Warrington d88e346d6e [c++] generate `noexcept` move constructors
* Generated C++ code uses `= default` move constructors when possible.
  * This means that the move constructors of many of the generated types
    will now be `noexcept`.
  * For MSVC 2013, which supports neither `= default` for move
    constructors nor `noexcept`, we fall back to a generated
    member-by-member move constructor.
  * When there are `bond_meta` fields, we also use a generated
    `noexcept(false)` move constructor.
* Core Bond types' move constructors have been marked as
  `noexcept` (perhaps conditionally).
    * For a given type `Bar` with a member (or base) `Foo`, we've chosen
      to explicitly write out things like `Bar(Bar&& other)
      BOND_NOEXCEPT_IF(bond::is_nothrow_move_constructible<Foo>)`
      instead of analyzing `Foo` for its `noexcept` status. This should
      be more maintainable under future modifications. Otherwise, future
      editors of `Foo` would have to know to look in `Bar` and adjust
      the `noexcept` specifications if the `noexcept` status of `Foo`
      were to change.
2016-07-01 13:58:17 -07:00
Eduardo Salinas 90b8bad66f Add field default checking to GBC
- Validate default value type mistmatches (fixes #72, fixes #128)
- Validate default value out-of-range values (fixes #73)
- Fail when struct field has default value of 'nothing' (fixes #164)
- Fail when enum field doesn't have default value (fixes #177)
- Validate default value of type aliases
2016-06-22 13:10:58 -07:00
Eduardo Salinas 08fcff0c78 Add nullable/blob info to runtime SchemaDef
- Add `list_sub_type` to TypeDef definition.
- For Bond data types of BT_LIST the ListSubType value indicates whether the
  type is known to be nullable or a blob. Otherwise, the type should be
  treated as a list/vector if it is BT_LIST with NO_SUBTYPE. If the type is
  not BT_LIST, disregard ListSubType value.
- Added support in C++/C# and respective tests.

Closes [#161](https://github.com/Microsoft/bond/issues/161), "The type of
nullable<T> and vector<T> fields are indistinguishable using only a
SchemaDef".
2016-06-14 11:26:01 -07:00
Andrey Sverdlichenko b3597d0e27 Allow creation of user-defined TypeMappings
The reduces the amount of reimplementation that is needed when writing
templates for other languages.

Closes #172, "Allow creation of user-defined TypeMapping's.".
2016-06-07 22:29:38 -07:00
Eduardo Salinas 0fead8d8b6 Update GBC dependencies
- Update GBC to version 0.4.1.0
- Base 4.9 brought some impossible to fulfill dependencies
- Update tests that are affected by bump to aeson
- Update json golden test files to a pretty print consistent form and avoid ambiguity when encoding and comparing
2016-06-01 13:32:33 -07:00
Eduardo Salinas 7fb898a0c5 Add parsec dependency to gbc-test 2016-06-01 10:48:30 -07:00
Ted Stein bcb36cceb3 gbc: Print VS- and msbuild-compatible error messages. 2016-05-31 16:05:38 -07:00
Eduardo Salinas fc94fccc07 Improve codegen for void param methods
- User gets a convenient FooProxy.BarMethod() instead of FooProxy.BarMethod(new Bond.Void())
2016-05-02 14:48:48 -07:00
Eduardo Salinas 87d1f2480f Add event support to Epoxy
- Add codegen for events
- Add ServiceHost logic
- Add relevant tests
- Add event example
2016-04-29 17:08:17 -07:00
Christopher Warrington 6a166a770a Stop using async state machine for Task<T> upcasts
Before, there were some places where we use the full compiler-generated
async state machine (and all its attendent code and allocations) to
upcast a Task<TDerived> to Task<TBase>. Now, we use the simplier
CodegenHelpers.Upcast helper method to do this both in the generated
code and the library code.
2016-04-29 17:06:50 -07:00
Eduardo Salinas 13f72234ec Change codegen class names
- Proxy_Foo becomes FooProxy
- FooService becomes FooServiceBase
2016-04-29 17:06:50 -07:00
Christopher Warrington 1c4c66e601 Fix generic proxy codegen
* Add parameter to interface in _proxies.cs
2016-04-29 17:04:52 -07:00
Eduardo Salinas c8ce077f0a Fix generic service codegen
- update test
- add parameter to interface in _services.cs
2016-04-29 17:03:20 -07:00
Eduardo Salinas 6789a9556f Add C# Comm codegen tests 2016-04-29 17:01:45 -07:00
Eduardo Salinas 73aabd4f4e Add c# service codegen
- Request & response services
2016-04-29 16:58:21 -07:00
Eduardo Salinas 202eabaf9f Add support for parsing services
- Parse services
- Add tests related to services
- Generate JSON AST
2016-04-29 16:46:41 -07:00
Christopher Warrington d7d3e36fef Revert "Temporarily downgrade Diff to 0.3.2"
Version 0.3.4 of the Diff package has a fix for this problem. See also:
f218d47cb2

This reverts commit 4cba6dd6de.

Closes #162, "Unpin diff from 0.3.2"
2016-04-25 15:29:31 -07:00
Christopher Warrington 4cba6dd6de Temporarily downgrade Diff to 0.3.2
We're having problems building with Diff 0.3.3 on GHC versions older
than 7.10. Until we can resolve those, pin Diff to 0.3.2 so that we can
release Bond 4.1.0.
2016-04-22 17:45:52 -07:00
Christopher Warrington 5aaa20b85f Prepare for 4.1.0 release
* Bump gbc and bond package minor version to 0.4.0.2
  * Re-gen golden test files
* Bump C# minor version to 4.1.0
* Edit CHANGELOG to add release info
2016-04-21 23:21:06 -07:00
Christopher Warrington 616f73f4a0 Revert "Fix bond_meta generic support"
The fix for bond_meta generic support (#140) has a number of issues that
we need to resolve before we can release the fix.

* #158: Avoid polluting C# generated type with `_schemaName` and
  #`_schemaFullName` fields
* #160: Support for bond_meta and generics has added a sometimes
  #dependency on Bond.dll to the generated C# code

For now, reverting commit 46c96f4b38.
2016-04-21 23:21:04 -07:00
Christopher Warrington 679301a619 Add .gitattributes to help with newline issues
The list of extensions was generated by inspecting all the files in our
repository with git ls-files.
2016-04-18 16:11:57 -07:00
Eduardo Salinas 46c96f4b38 Fix bond_meta generic support
- add generic support when using bond_meta fields
- add flag to specify behaviour regarding bond_meta fields
- add codegen tests and unit tests that cover new behaviour

Closes #140, "Generic arguments are not propagated into bond_meta::full_name/name in generated C# code"
2016-04-13 11:22:24 -07:00
Christopher Warrington cfcd61b5ed Annotate that we test with GHC version >= 7.4.1
We are relying on some implementation details of GHC, like the minimum
size of Int and language extensions. gbc/bond might work with other
Haskell compilers, but we don't test with them.

We don't list all the GHC versions that we end up using, as Travis CI
can change the specific versions on us.
2016-04-01 15:35:13 -07:00
Christopher Warrington 1ed0d9241d Use scientific >= 0.3.4.6 for double serialization
Upgrade to scientific-0.3.4.6 or later so that when we serialize whole
numbers in JSON we don't get trailing ".0" values.

Before, 2 would serialize as "2", but 0 would serialize "0.0". Now, 2
serializes as "2", and 0 serializes as "0".

Since the golden tests have the results of JSON serialization commited,
we have to be on one side or the other of scientific-0.3.4.6. We're
after it now. (Unless, we needlessly complicate the tests with some sort
of custom comparisons or smudge/clean process.)

See also https://github.com/bos/aeson/issues/369 and
0f28347b4a
2016-03-21 19:44:24 -07:00
Christopher Warrington 629094389b Cast enum constants to 32-bit integers
When generating C++ and C# code, gbc now emits casts to allow uint32
enum constant values to be used without errors or warnings.

* Use explicit static_cast<int32_t> for C++ enum constants to avoid the
  Clang warning -Wc++11-narrowing when using uint32 enum constants.
* Use unchecked((int)value) for C# enum constants to avoid a compiler
  error.
2016-03-08 09:43:57 -08:00
Eduardo Salinas 6b5060c3a6 Add check for duplicate field names
Closes #123, issue "Field names should be rejected if they duplicate
another field name"

Closes #132, pull request "Add check for duplicate field names"
2016-02-25 21:16:44 -08:00
Eduardo Salinas b115211fc3 Reject field ordinals larger than 65535
gbc/the Bond library will now reject field ordinals larger than a Word16
with an error message.

Fixes #111.
2016-01-26 11:54:32 -08:00
Adam Sapek a7187e5e74 Revert "Work around cabal conflict for transformers 0.5"
This reverts commit 9598128.
2016-01-19 20:53:50 -08:00
Christopher Warrington 90105ea123 Suppress C# warning CS1591 in generated code
CS1591 is "Missing XML comment for publicly visible type or member".

Emit a 'pragma warning disable' line in generated C# code so that
projects that build will all warnings enabled don't have to add XML
documentation comments to their Bond-generated files.

Update the codegen golden master test files.

Add the test/codegen/no-warnings target that has all warnings enabled
and warnings as errors so that a new warning will fail to build.

Closes #82.
2016-01-19 18:59:51 -08:00
Adam Sapek 9598128e9e Work around cabal conflict for transformers 0.5
A temporary workaround until `exceptions` can be built with
`transformers` 0.5. The work is already in progress but it depends on
some bigger changes in transformers-compat
(see https://github.com/ekmett/exceptions/pull/51).
2016-01-15 11:52:18 -08:00
Adam Sapek 27b3f19978 Update Category metadata in bond.cabal 2015-12-16 12:22:56 -08:00
Adam Sapek ba9a3c0ed0 Fix grammar errors in the compiler library docs 2015-12-14 12:25:24 -08:00
Adam Sapek abfb3a7dff Bump compiler version to 0.4.0.1 2015-12-09 14:05:44 -08:00
Adam Sapek 4d27159f64 Update documentation of the compiler library APIs 2015-12-09 14:05:42 -08:00
Adam Sapek 439d376c5e Remove unused getDeclName API 2015-12-09 12:52:52 -08:00
Adam Sapek 03981ea26c Remove getGlobalQualifiedName API 2015-12-09 12:52:50 -08:00
Adam Sapek 3e03a70fed Remove IDL-specific type name builders
Replace usage of IDL-specific type name builders with regular builders
using IDL type mapping.
2015-12-09 12:52:48 -08:00
Adam Sapek 106d7ae1d2 Use Aeson.TH instead of DeriveGeneric
TemplateHaskell version compiles much faster than Generics based Aeson.
2015-12-09 12:52:46 -08:00
Adam Sapek 3152633a3c Allow generating Apply overloads for custom streams
Redefine the Protocol to specify the full type name of protocol reader
and writer, rather than hard-coding bond::Input/OutputBuffer in the
ccodegen template.
2015-12-04 17:31:25 -08:00
Adam Sapek b8134877b0 Remove redundant Tag.bonded<T> annotations
In regular codegen the [Type(typeof(Bond.Tag.bonded<Foo>)] annotation is
not necessary because IBonded<T> already identifies the type as bonded<T>.
2015-12-04 11:39:27 -08:00
Adam Sapek f392764959 Allow the word 'Schema' in namespace identifiers
The word 'Schema' is a reserved name in Bond lexer because it conflicts
with the Schema struct in the generated C++ code. In order to support
some legacy schema definitions we are relaxing the restriction, allowing
the word to be used as part of namespace identifiers. The word Schema in
a namespace identifier does not conflict with the Schema struct in the
generated C++ code.
2015-12-04 11:06:43 -08:00
Adam Sapek aeccf7dd02 Add gbc option to generate runtime schema from IDL
Running:

    gbc schema --runtime-schema example.bond

will generate SchemaDef for each non-generic struct defined in the .bond
file(s). The SchemaDef(s) will be serialized using Simple JSON protocol
into file(s) named <source-file-name>.<struct-name>.json.

Fixes #75.
2015-12-03 10:56:34 -08:00
Adam Sapek 7d3c94c304 Fix C++ enum codegen for -2147483648 2015-12-03 10:56:32 -08:00
Adam Sapek 25bfd294a5 Fix resolveAlias to handle nested type parameters 2015-12-02 17:14:27 -08:00
Adam Sapek 9f5b51aa72 Fix logic determining which C++ headers to include
The C++ codegen failed to detect the need to generate #include <blob.h>
when the only use of blob was a field with default `nothing`.

For aliases of types that require extra header files the trigger should
be the alias usage rather than alias declaration.

Types of fields of base schema should not be considered.
2015-12-02 17:14:26 -08:00
Adam Sapek 55cf387e2e Add cabal constraint: process < 1.4
Unfortunately the conflict between optparse-applicative, which sets an
upper bound on the version the process package dependency and cmdargs
which only has a lower bound is going to reappear on every release of
process.

The problem happens when gbc dependencies are first installed in the
sandbox and then we try to build gbc-tests using the same sandbox.
2015-11-14 12:28:08 -08:00
Adam Sapek 3c2a105ff4 Fix generated C++ code using custom allocator
When generating C++ code with custom allocator (--allocator compiler
flag) two cases resulted in invalid code:

- If the only field that required allocator ctor argument was of a
  struct type then the allocator parameter name in the ctor of
  containing struct was omitted.
- A field of type alias of a struct type was not initialized with custom
  allocator.
2015-11-10 14:33:31 -08:00
Adam Sapek a60b3c4a5e Make fieldModifier and fieldAttributes optional
In the JSON representation of schema AST the fieldModifier and
fieldAttributes properties can be omitted, simplifying field
representation in the common case.

Add to the documentation an example of AST in JSON format.
2015-11-10 14:33:29 -08:00
Adam Sapek a4201850a6 Group CMake targets into folders
CMake uses the `FOLDER` property to group the generated Visual Studio
projects into solution folders.

Removed bond_ and documentation_ prefix from project names. The prefixes
were intended to group projects by name which is no longer necessary.
2015-10-28 22:30:41 -07:00
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
Adam Sapek 761704514e Propagate cabal failures to the calling cmake script 2015-01-20 12:57:48 -08:00
Adam Sapek 389f7428a8 Fix parsing of enum default values starting with L
The bug in the parser caused it to interpret any default value starting
with the letter L as a string literal, resulting in a parsing error for
constructs like:

    struct Foo
    {
        0: Verbosity verbosity = Low;
    }
2015-01-19 15:45:32 -08:00
Adam Sapek fa37e7beda Merge pull request #9 from dnmiller/cmake-fix
Fix compiler CMake permissions for OSX
2015-01-12 17:51:44 -08:00
Adam Sapek 3d5905a8b2 Fix compiler build for non-ascii cabal path
CMake Visual Studio generator translates add_custom_command into a batch
file embedded in Visual Studio project. Batch files have problems with
paths that contain non-ascii characters because they are limited to DOS
encoding. It so happens that cabal is quite likely to be installed in
such a path because by default cabal installs into a directory under
%APPDATA% which contains user name. As a workaround we execute cmake
scripts as a custom commands and depend on CMake cache to get access to
variables set during configuration. This way embedded batch files are
free of non-ascii characters.
2015-01-12 17:45:57 -08:00
Dan Miller 013bf9b29b Fixing CMake permissions for OSX 2015-01-12 16:43:56 -08:00
Adam Sapek 222e20fd00 Initial commit 2015-01-09 11:21:05 -08:00