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

160 Коммитов

Автор SHA1 Сообщение Дата
Christopher Warrington 0ee5285d7b [c++] Overhaul bond::maybe
`bond::maybe` now has better support for rvalue-references and allocator
propagation.

This implementation also avoids default initializing an instance of `T`
when creating an maybe that holds nothing

`bond::maybe` is now implemented in terms of `boost::optional`. We should be
able to `std::optional` with minimal effort when Bond requires a minimum
of C++17.

Additional changes:

* Removed a dangerous implicit conversion operator from `bond::maybe<T>`
  to `const T&`. To access a `bond::maybe<T>` value, use
* Added `noexcept` variants of `bond::maybe<T>::value`.
* Added `bond::maybe<T>::emplace` to construct a maybe's value in place.
* Added various rvalue-reference and allocator-aware constructors and
  assignment operators.
* Added `bond::maybe<T>::operator==(const T&)` to compare directly to
  instances of `T`.
* Improved test coverage of `set_value()`: it was only effectively
  constructing a new `T` the first time.
* Added tests for moved-from `bond::maybe` instances.
* Added tests for allocator propagation.
2018-04-18 15:57:52 -07:00
Christopher Warrington a256dbc319 [c++] Remove Boost min version from CHANGELOG
This change has not yet been made, as it breaks the current AppVeyor
build.

Issue https://github.com/Microsoft/bond/issues/845 has been opened to
remind us to bump the minimum version later.

[skip ci]
2018-04-10 09:57:45 -07:00
Christopher Warrington 3dc9704e9c [travis] Test Boost 1.61+ with clang & g++
Drops support for versions of Boost older than two years. Boost 1.61+ or
newer is now required. (Bond will likely continue to work with older
versions of Boost, but we'll no longer actively test against them.)

Using cron jobs, add coverage for all supported versions of Boost with
both Clang and G++.

This is the Travis-side fix for:
* https://github.com/Microsoft/bond/issues/666
* https://github.com/Microsoft/bond/issues/771
2018-04-05 20:25:17 -07:00
Ara Ayvazyan 4d351d04fa [c++ grpc] Avoid data coping during serialization
* Add `blob_prolong` function.
* Minimize copies when serializing for gRPC
2018-04-04 11:16:21 -07:00
Christopher Warrington 3221200462 [c++ c#] Remove Bond Comm 2018-03-20 15:42:42 -07:00
Christopher Warrington eca53e2278 [c#] Handle gbc from path on macOS
On macOS (and likely Linux), when gbc was not found under
BOND_COMPILER_DIRECTORY--typically when it was found on $PATH--the
output directory for the generated C# files ended up having inconsistent
directory separator translation applied to it.

gbc was invoked with an output directory like
`--output-dir="obj/Debug/net45/\."`, which placed the generated files in
a directory *under* `net45` named `\.`. However, when csc was invoked,
it was given generated file paths like `obj/Debug/net45//foo_types.cs`,
which did not exist, causing compilation to fail.

This inconsistency occurred because when the command line for gbc from
$PATH was constructed, none of the elements look like a path, so MSBuild
didn't translate the trailing `\.` added to the output-dir argument:

    <_BondCommand>&quot;$(_BondExe)&quot; $(BondCodegenMode) $(_BondImportDirs) --jobs=-2 --namespace=bond=Bond --output-dir="$(BondOutputDirectory)\."</_BondCommand>

The `\.` was added to guard against $(BondOutputDirectory) ending with a
slash and then having CMD treat a string like
`--output-dir="obj\Debug\net45\"` as having an escaped double-quote in
it.

When gbc came from BOND_COMPILER_PATH, it looked like a path, so the
added `\.` got translated to `/.`

As a fix, the codegen targets now use $(_BondOutputDirectoryNormalized),
which always has a trailing slash and always uses forward slashes.
Windows, macOS, and Linux can all handle forward slashes for paths.
2018-03-12 16:34:42 -07:00
Christopher Warrington 05b4ee170a [c#] Fully strong-name sign .NET Core assemblies
Previously, we were just [public signing][1] the .NET Core assemblies.
We intended to fully strong-name sign them, so this commit removes the
"publicSign": true entry from the project files.

[1]: ca61bad288
2018-03-12 16:24:18 -07:00
Christopher Warrington a8821da808 [c#] Add automatic codegen for .NET Core projects
* Enabled automatic codegen when implicit inclusion is turned on via the
  MSBuild property EnableDefaultCompileItems
* Added Visual Studio CPS UI integration so that .bond files appear in
  the Visual Studio 2017+ UI.

Fixes https://github.com/Microsoft/bond/issues/636
2018-03-07 14:11:00 -08:00
Christopher Warrington f92e31a209 [c# grpc] Upgrade to gRPC v1.10.0
Fixes https://github.com/Microsoft/bond/issues/812
2018-03-07 12:43:00 -08:00
Ara Ayvazyan ddc4855038 [c++] Fix bond::value's move ctor
The change fixes the `bond::value`'s move constructor to actually move
the underlying reader, unless it is a reference type. Also, fixes the
`noexcept` condition for `bond::bonded`'s move constructor that was
missed in 5131a950.
2018-03-06 23:11:02 -08:00
Greg Ravikovich 11904de593 [c++] Upgrade gRPC to version 1.10.0
Fixes https://github.com/Microsoft/bond/issues/810
Closes https://github.com/Microsoft/bond/issues/811
2018-03-06 13:28:38 -08:00
Ara Ayvazyan 5131a95042 [c++] Broken move .ctor of bonded<Reader&>
When moving a bonded<> backed by a reference to a reader, the bonded<>
move ctor wasn't building with Clang and newer versions of MSVC. This
fixes that error by not calling std::move on the reference.
2018-03-05 17:40:05 -08:00
Ara Ayvazyan 183f339007 [c++] Remove is_blob/is_nullable traits
The blob and nullable types are not customizable. Also is_blob and
is_nullable traits are not part of container concept.

Closes https://github.com/Microsoft/bond/pull/805
2018-02-27 16:58:44 -08:00
Ara Ayvazyan 8eebf59d88 [c++ grpc] Fix race in unary_call destruction 2018-01-08 16:13:38 -08:00
Ara Ayvazyan 55509efb11 [c++ grpc] Fix race in io_manager
Fixes a race condition when `bond::ext::gRPC::io_manager::shutdown` and
`bond::ext::gRPC::io_manager::wait` are called concurrently. The functions
are not mutually exclusive and the latter destroys the
`grpc::CompletionQueue` which is not necessary.

Fixes https://github.com/Microsoft/bond/issues/744
2018-01-05 17:14:38 -08:00
Ara Ayvazyan f2c105f279 [c++] Fix missing type param. in MapTo<T>::Field 2017-12-19 11:22:21 -08:00
Ara Ayvazyan 9ca99d45b8 [c++] Fix base to derived deserialization
With this change deserialization will now fail by throwing `bond::CoreException` when `BT_STOP` is encountered while deserializing a base struct.

Fixes https://github.com/Microsoft/bond/issues/742
2017-12-11 13:34:17 -08:00
Christopher Warrington 524921206a
[c# grpc] Allow [Bond.Attribute] on methods
* This fixes broken C# codegen when a service method has attributes.
* Add both C++ and C# unit test to make sure that service and method
  attributes are properly generated and accessible.

Fixes https://github.com/Microsoft/bond/issues/617
2017-12-07 17:38:40 -08:00
Christopher Warrington 95c4f9d6e4 [c++ grpc] Fix includes when bond::Void is used
When a service contains events or parameter-less methods, the generated
code uses `bond::Void` as the request/result type. To serialize
`bond::Void`, bond_reflection.h needs to be included.

The generated service code now includes bond_reflection.h if any service
contains an event or a parameter-less method.

Fixes https://github.com/Microsoft/bond/issues/735
2017-12-05 18:07:41 -08:00
Eduardo Salinas ce95a54265 [gbc] Improve parsing of import statements
* [gbc] Improve parsing of import statements
* add optional semi colon after an import statement
2017-11-21 16:30:03 -08:00
Ara Ayvazyan 55ca8fa7d1 [c++] Support custom types for enum name/value maps
Currently C++ enum's name-to-value and value-to-name maps use a `std::map`
and are always constructed, even when not used. This change:

- allows the user to provide custom map type (e.g.
  `boost::container::flat_map`)
- lazily constructs the map on first access
- changes the default generated conversion functions to use
  `std::unordered_map`
2017-11-17 11:28:46 -08:00
Ara Ayvazyan 653567edc4 [gbc c++] Add option for scoped_allocator_adaptor
C++ codegen now can use std::scoped_allocator_adaptor for strings and
containers when custom allocator is used and the --scoped-alloc flag is
passed to gbc.
2017-11-09 11:32:25 -08:00
Ara Ayvazyan a1e09c49a0 [gbc c++] Add generation of type aliases 2017-11-08 19:03:52 -08:00
Christopher Warrington 3988a9f170 [c++ grpc] Upgrade to gRPC v1.7.1
Pick up a bug fix in commit gRPC 7269667f (initially implemented for C++
in gRPC commit be9b8142) for channel disconnections we've been
observing.
2017-11-07 16:27:53 -08:00
Ara Ayvazyan 8a11835d07 [c++] Generate copy/move ctors with allocator arg
Add the ability to generate copy and move constructors with an allocator
argument. This is behind the gbc flag --alloc-ctors, as the generated copy
and move constructors pass the allocator to the constructors for collection
fields, among others. Not all STL implementations in use by users of Bond
provide these C++11 constructors yet for all collection types. In order to
avoid breaking existing code, these constructors are opt-in.
2017-11-03 11:29:48 -07:00
Ara Ayvazyan bae8b6f94e [c++ gbc] Cleanup the use of key comparer ctors
As of C++11, all the standard containers have a constructor that takes just
an allocator. The expectation is that custom containers will also provide
one.
2017-11-02 15:58:15 -07:00
Christopher Warrington cffce1f607 Merge 7.0.2 release changes into master 2017-10-30 16:53:11 -07:00
Christopher Warrington b5ee1c8592 Update CHANGELOG for 7.0.2 2017-10-30 16:47:47 -07:00
Christopher Warrington 4334416f6f [c++ grpc] Fix multi-slice deser. memory leak
The caller of grpc_byte_buffer_reader_next is responsible for calling
grpc_slice_unref on the slice. However, SerializationTraits::Deserialize
was only calling grpc_slice_unref on the last slice. Now, it is called
on each slice.

Also fixes a potential bug that would call grpc_slice_unref on an
uninitialized slice.
2017-10-30 16:46:27 -07:00
Christopher Warrington fec4da0a69 [c++ grpc] Fix multi-slice deser. memory leak
The caller of grpc_byte_buffer_reader_next is responsible for calling
grpc_slice_unref on the slice. However, SerializationTraits::Deserialize
was only calling grpc_slice_unref on the last slice. Now, it is called
on each slice.

Also fixes a potential bug that would call grpc_slice_unref on an
uninitialized slice.
2017-10-30 16:34:36 -07:00
Ara Ayvazyan fa02289f11 [c++] Cleanup C++11 feature checks
Since Bond now requires a C++11 compiler, many of the feature checks for
C++11 can be removed. Bond still supports MSVC 2013, which has some
limitations in its C++11 support, so checks for it to enable work-arounds
are still present.
2017-10-30 13:11:16 -07:00
Christopher Warrington b2a6d11fa1 [c++] Update changelog: minor bump needed
A minor version bump is needed due to the new `operator=` added in commit
0d911ca9.
2017-10-27 15:14:10 -07:00
Eduardo Salinas 9449fb4dcd Merge 7.0.1 release into master 2017-10-26 15:57:05 -07:00
Ara Ayvazyan 85e74143ed [cmake] Adjust the min boost version to 1.58
Closes https://github.com/Microsoft/bond/pull/667
2017-10-26 15:38:15 -07:00
Eduardo Salinas 84ff6a9d2a Prepare for 7.0.1 release
* Updated changelog
2017-10-26 14:06:58 -07:00
Ara Ayvazyan 0d911ca9f0 [gbc c++] Add missing move assignment operator
Also handle MSVC 2013, which doesn't support `= default` for move
assignment operators.
2017-10-26 12:34:21 -07:00
Eduardo Salinas 7049f1e1d4 Prepare for 7.0.0 release
* Updated changelog
2017-10-24 15:04:32 -07:00
Christopher Warrington bab0f2bb11 [c# grpc] Skip compilation for --structs=false
* The MSBuild codegen targets now detect --structs=false and skip
  automatic compilation of the non-existent `_types.cs` files.
* Added a gRPC example that show how to use a shared type assembly
  between a client and service.
2017-10-24 14:40:49 -07:00
Shuai Zhang a120cd9995 [c# grpc] Include grpc generated files automatically
* Two cases need to be handeled: $BondOptions contains --grpc for
  no-overridden BondCodegen items, the %BondCodegen.Options contains
  --grpc. Also --grpc=false needs to be handled in both cases.
* Updated the examples ad tests to no longer include the
  generated *_grpc.cs files.

Fixes https://github.com/Microsoft/bond/issues/448
Closes https://github.com/Microsoft/bond/pull/630
2017-10-24 14:40:49 -07:00
Ara Ayvazyan d8d581f177 [gbc c++] Use std::allocator_traits to rebind
C++ codegen now uses C++11's `std::allocator_traits` for rebinding allocator
types instead of the allocator's rebind.
2017-10-24 14:27:55 -07:00
Christopher Warrington a27009c9c3 [c++ grpc] Add shared_unary_call and example 2017-10-23 14:05:36 -07:00
Ara Ayvazyan 35fdea6c3b [c++] Add capped allocator, tests, and example
Full test coverage is currently only working on MSVC, as the Linux CI systems
need to be upgraded to work around some C++ standard library ABI issues.
2017-10-20 01:04:27 -07:00
Christopher Warrington 70ced821b3 [c++] Surround macro parameters with parenthesis
- Macro parameters with commas in them, like `std::map<int, std::string>`
need to be surrounded with parenthesis so they are treated as one
parameter instead of as two parameters to the macro.
- Use `always_false` as it is closer to the semantics we want to convey.
- Standardize where the ! is in parenthesized parameters.
2017-10-19 14:28:58 -07:00
Christopher Warrington 8f275f9a33 [c++] Support non-default-constructable allocators
- Now the generated type's default ctor is only compiled when it is
  actually used. This permits non-default-constructible allocators to be
  used. Ideally, the default ctor would be = default, but that doesn't
  work with MSVC 2013, so this workaround is needed.
- An additional defaulted `_bond_vc12_ctor_workaround_` parameter is
  used as a workaround for a bug in MSVC 2013 which fails to call the
  ctor in some cases.

Closes https://github.com/Microsoft/bond/pull/639
2017-10-16 14:52:42 -07:00
Chad Walters 64f63dfe77 [c#] Remove extra blob conversions when serializing
* [c#] Include aliased blob in expressions test
* [c#] Cut extra blob conversions in serialization

Aliased blobs were getting converted multiple times during serialization.
Now each blob only gets converted once.
2017-10-16 14:38:12 -07:00
Christopher Warrington ca0d1c63da [c#] Use null XmlResolver when possible
By setting XmlReaderSettings.XmlResolver to null, we can avoid having
XmlReader resolve external XML entities. Attempting to resolve these
external entities can potentially access the network, which is not
something we want to do during deserialization.

This API only exists when targeting the full .NET 4.5 framework, hence
the need for a net45-nonportable version of Bond.dll.
2017-10-02 15:23:15 -07:00
Christopher Warrington a8c2528f94 [c++ grpc] Fix missing headers; add scalar example
* If a service imported bond.bond or bond_const.bond, an #include of
  bond_grpc.h/bond_const_grpc.h was generated, but this header was
  missing. Now, when the CMake variable BOND_ENABLE_GRPC is true, these
  headers are generated.
* Other minor CMakeLists.txt cleanups.
* An example, demonstrating how to use bond.Box to wrap scalar service
  arguments has been added. This also serves to test the fixed headers.
* A helper function bond::make_box has been added to enable creation of
  bond::Box<T> instances via type deduction.
2017-09-29 13:59:59 -07:00
Christopher Warrington f1aa163eb1 [c# grpc] Fix codegen for generic collection args
If a service use a generic type like bond.Box<T> with a collection type
argument as a parameter/return type, the generated code was missing an
import of System.Collections.Generic. This has been fixed.

An example, demonstrating how to use bond.Box to wrap scalar service
arguments has been added. This also serves to test the fixed codegen.

A helper method Bond.Box.Create() has been added to enable creation of
Bond.Box<T> instances via type deduction.

Fixes https://github.com/Microsoft/bond/issues/623
2017-09-29 13:59:59 -07:00
Christopher Warrington 554125145d [c++ grpc] Drop client callback after executing
After executing the client callback upon receiving a response, clear the
stored callback to prevent a shared_ptr cycle.

Previously, when the callback function was not cleared, if the callback
happened to store the unary_call_result that it was invoked with (like
wait_callback does), there would be a shared_ptr cycle: the callback
would have a shared_ptr to the unary_call_result, which was keeping its
parent client_unary_call_data alive. This client_unary_call_data had a
copy of the callback function, which had a shared_ptr to the
unary_call_result.

This change resets the callback to empty after is has been executed,
breaking the cycle.
2017-09-28 13:53:10 -07:00
Chad Walters f96af1ffe1 Fix service/method attributes in C# and C++
In C#, attributes are now carried across to the service class and its
member methods. In C++, gRPC-based services now have compile-time metadata
with appropriate attribute support.

Fixes https://github.com/Microsoft/bond/issues/617
Closes https://github.com/Microsoft/bond/pull/618
2017-09-27 16:51:30 -07:00