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
This commit is contained in:
Chad Walters 2017-09-18 13:48:52 -07:00 коммит произвёл Christopher Warrington
Родитель 5f8058753e
Коммит f96af1ffe1
61 изменённых файлов: 624 добавлений и 51 удалений

Просмотреть файл

@ -12,12 +12,17 @@ different versioning scheme, following the Haskell community's
[package versioning policy](https://wiki.haskell.org/Package_versioning_policy).
## Unreleased ##
* `gbc` & compiler library: TBD
* `gbc` & compiler library: TBD (minor bump needed)
* IDL core version: TBD
* IDL comm version: TBD
* C++ version: TBD (bug fix bump needed)
* C++ version: TBD (minor bump needed)
* C# NuGet version: TBD (bug fix bump needed)
* C# Comm NuGet version: TBD
* C# Comm NuGet version: (minor bump needed)
### `gbc` and Bond compiler library ###
* Add service/method annotations in C# for Comm and gRPC.
* Add service/method metadata support in C++ for gRPC.
### C++ ###
@ -34,6 +39,8 @@ different versioning scheme, following the Haskell community's
* Use RapidJSON's iterative parser to handle deeply nested JSON data without
causing a stack overflow.
* Guard against min/max being function-style macros in more places.
* Provide compile-time access to metadata about gRPC services and methods.
### C# ###
@ -50,11 +57,17 @@ different versioning scheme, following the Haskell community's
* Fix a bug in CompactBinaryWriter when using v2 that repeated first pass
when a bonded field was serailized, resulting in extra work and extra
state left in the CompactBinaryWriter.
* Apply IDL annotations to services and methods for gRPC.
[Issue #617](https://github.com/Microsoft/bond/issues/617)
[msdn-gzipstream]: https://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream(v=vs.110).aspx
[msdn-stream-canseek]: https://msdn.microsoft.com/en-us/library/system.io.stream.canseek(v=vs.110).aspx
[msdn-stream-seek]: https://msdn.microsoft.com/en-us/library/system.io.stream.seek(v=vs.110).aspx
### C# Comm ###
* Apply IDL annotations to services and methods for Comm.
## 6.0.1 ##
This version was not used.

Просмотреть файл

@ -57,6 +57,7 @@ function (add_bond_codegen)
list(APPEND outputs "${outputDir}/${name}_comm.h")
endif()
if (arg_GRPC)
list(APPEND outputs "${outputDir}/${name}_grpc.cpp")
list(APPEND outputs "${outputDir}/${name}_grpc.h")
endif()
endforeach()
@ -100,6 +101,9 @@ function (add_bond_executable target)
if (arg_COMM)
list (APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${name}_comm.cpp")
endif()
if (arg_GRPC)
list (APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${name}_grpc.cpp")
endif()
endif()
endforeach()
if (schemas)

Просмотреть файл

@ -87,7 +87,7 @@ cppCodegen options@Cpp {..} = do
templates = concat $ map snd $ filter fst codegen_templates
codegen_templates = [ (core_enabled, core_files)
, (comm_enabled, [comm_h export_attribute, comm_cpp])
, (grpc_enabled, [grpc_h export_attribute])
, (grpc_enabled, [grpc_h export_attribute, grpc_cpp])
]
core_files = [
reflection_h export_attribute

Просмотреть файл

@ -65,6 +65,7 @@ library
Language.Bond.Codegen.Cpp.Types_h
Language.Bond.Codegen.Cpp.Comm_cpp
Language.Bond.Codegen.Cpp.Comm_h
Language.Bond.Codegen.Cpp.Grpc_cpp
Language.Bond.Codegen.Cpp.Grpc_h
Language.Bond.Codegen.Cs.Types_cs
Language.Bond.Codegen.Cs.Comm_cs

Просмотреть файл

@ -20,7 +20,6 @@ comm_cpp :: MappingContext -> String -> [Import] -> [Declaration] -> (String, Te
comm_cpp cpp file _imports declarations = ("_comm.cpp", [lt|
#include "#{file}_reflection.h"
#include "#{file}_comm.h"
#include <bond/core/exception.h>
#{CPP.openNamespace cpp}
#{doubleLineSepEnd 1 statics declarations}

Просмотреть файл

@ -0,0 +1,33 @@
-- Copyright (c) Microsoft. All rights reserved.
-- Licensed under the MIT license. See LICENSE file in the project root for full license information.
{-# LANGUAGE QuasiQuotes, OverloadedStrings, RecordWildCards #-}
module Language.Bond.Codegen.Cpp.Grpc_cpp (grpc_cpp) where
import Data.Monoid
import Prelude
import Data.Text.Lazy (Text)
import Text.Shakespeare.Text
import Language.Bond.Syntax.Types
import Language.Bond.Codegen.TypeMapping
import Language.Bond.Codegen.Util
import qualified Language.Bond.Codegen.Cpp.Util as CPP
-- | Codegen template for generating /base_name/_grpc.cpp containing
-- definitions of helper functions and schema metadata static variables.
grpc_cpp :: MappingContext -> String -> [Import] -> [Declaration] -> (String, Text)
grpc_cpp cpp file _imports declarations = ("_grpc.cpp", [lt|
#include "#{file}_reflection.h"
#include "#{file}_grpc.h"
#{CPP.openNamespace cpp}
#{doubleLineSepEnd 1 statics declarations}
#{CPP.closeNamespace cpp}
|])
where
-- definitions of Schema statics for non-generic services
statics s@Service {..} =
if null declParams then CPP.schemaMetadata cpp s else mempty
statics _ = mempty

Просмотреть файл

@ -11,6 +11,7 @@ import Prelude
import qualified Data.Text.Lazy as L
import Data.Text.Lazy.Builder
import Text.Shakespeare.Text
import Language.Bond.Util
import Language.Bond.Syntax.Types
import Language.Bond.Codegen.Util
import Language.Bond.Codegen.TypeMapping
@ -20,7 +21,7 @@ import qualified Language.Bond.Codegen.Cpp.Util as CPP
-- | Codegen template for generating /base_name/_grpc.h containing declarations of
-- of service interface and proxy.
grpc_h :: Maybe String -> MappingContext -> String -> [Import] -> [Declaration] -> (String, L.Text)
grpc_h _ cpp file imports declarations = ("_grpc.h", [lt|
grpc_h export_attribute cpp file imports declarations = ("_grpc.h", [lt|
#pragma once
#include "#{file}_reflection.h"
@ -30,6 +31,7 @@ grpc_h _ cpp file imports declarations = ("_grpc.h", [lt|
#include <bond/ext/grpc/bond_utils.h>
#include <bond/ext/grpc/client_callback.h>
#include <bond/ext/grpc/io_manager.h>
#include <bond/ext/grpc/reflection.h>
#include <bond/ext/grpc/thread_pool.h>
#include <bond/ext/grpc/unary_call.h>
#include <bond/ext/grpc/detail/client_call_data.h>
@ -81,6 +83,8 @@ grpc_h _ cpp file imports declarations = ("_grpc.h", [lt|
#{template}class #{declName} final
{
public:
struct Schema;
template <typename TThreadPool>
class #{proxyName}
{
@ -141,10 +145,68 @@ inline #{className}::#{proxyName}<TThreadPool>::#{proxyName}(
{ }
#{doubleLineSep 0 methodDecl serviceMethods}
#{template}struct #{className}::Schema
{
#{export_attr}static const ::bond::Metadata metadata;
#{newlineSep 1 methodMetadata serviceMethods}
public: struct service
{
#{doubleLineSep 2 methodTemplate serviceMethods}
};
private: typedef boost::mpl::list<> methods0;
#{newlineSep 1 pushMethod indexedMethods}
public: typedef #{typename}methods#{length serviceMethods}::type methods;
#{constructor}
};
#{onlyTemplate $ CPP.schemaMetadata cpp s}
|]
where
className = CPP.className s
template = CPP.template s
onlyTemplate x = if null declParams then mempty else x
typename = onlyTemplate [lt|typename |]
export_attr = optional (\a -> [lt|#{a}
|]) export_attribute
methodMetadataVar m = [lt|s_#{methodName m}_metadata|]
methodMetadata m =
[lt|private: #{export_attr}static const ::bond::Metadata #{methodMetadataVar m};|]
-- reversed list of method names zipped with indexes
indexedMethods :: [(String, Int)]
indexedMethods = zipWith ((,) . methodName) (reverse serviceMethods) [0..]
pushMethod (method, i) =
[lt|private: typedef #{typename}boost::mpl::push_front<methods#{i}, #{typename}service::#{method}>::type methods#{i + 1};|]
-- constructor, generated only for service templates
constructor = onlyTemplate [lt|Schema()
{
// Force instantiation of template statics
(void)metadata;
#{newlineSep 3 static serviceMethods}
}|]
where
static m = [lt|(void)#{methodMetadataVar m};|]
methodTemplate m = [lt|typedef ::bond::ext::gRPC::reflection::MethodTemplate<
#{className},
#{bonded $ methodInput m},
#{result m},
&#{methodMetadataVar m}
> #{methodName m};|]
where
result Event{} = "void"
result Function{..} = bonded methodResult
proxyName = "ClientCore" :: String
serviceName = "ServiceCore" :: String

Просмотреть файл

@ -57,12 +57,12 @@ namespace #{csNamespace}
where
generics = angles $ sepBy ", " paramName declParams
methodDeclaration Function{..} = [lt|global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<#{getMessageResultTypeName}>> #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param, global::System.Threading.CancellationToken ct);|]
methodDeclaration Function{..} = [lt|#{CS.schemaAttributes 2 methodAttributes}global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<#{getMessageResultTypeName}>> #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param, global::System.Threading.CancellationToken ct);|]
where
getMessageResultTypeName = getMessageTypeName cs methodResult
getMessageInputTypeName = getMessageTypeName cs methodInput
methodDeclaration Event{..} = [lt|void #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param);|]
methodDeclaration Event{..} = [lt|#{CS.schemaAttributes 2 methodAttributes}void #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param);|]
where
getMessageInputTypeName = getMessageTypeName cs methodInput
@ -103,7 +103,7 @@ namespace #{csNamespace}
interfaceGenerics = angles $ sepBy "," paramName declParams -- of the form "<T1, T2, T3>"
proxyGenerics = sepEndBy ", " paramName declParams -- of the form "T1, T2, T3, "
proxyMethod Function{..} = [lt|public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<#{getMessageResultTypeName}>> #{methodName}Async(#{getMessageProxyInputParam cs methodInput})
proxyMethod Function{..} = [lt|#{CS.schemaAttributes 2 methodAttributes}public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<#{getMessageResultTypeName}>> #{methodName}Async(#{getMessageProxyInputParam cs methodInput})
{
var message = new global::Bond.Comm.Message<#{getMessageInputTypeName}>(#{paramOrBondVoid methodInput});
return #{methodName}Async(message, global::System.Threading.CancellationToken.None);
@ -121,7 +121,7 @@ namespace #{csNamespace}
getMessageResultTypeName = getMessageTypeName cs methodResult
getMessageInputTypeName = getMessageTypeName cs methodInput
proxyMethod Event{..} = [lt|public void #{methodName}Async(#{getMessageProxyInputParam cs methodInput})
proxyMethod Event{..} = [lt|#{CS.schemaAttributes 2 methodAttributes}public void #{methodName}Async(#{getMessageProxyInputParam cs methodInput})
{
var message = new global::Bond.Comm.Message<#{getMessageInputTypeName}>(#{paramOrBondVoid methodInput});
#{methodName}Async(message);
@ -173,7 +173,7 @@ namespace #{csNamespace}
methodInfo Function{..} = [lt|yield return new global::Bond.Comm.ServiceMethodInfo {MethodName="#{getDeclTypeName idl s}.#{methodName}", Callback = #{methodName}Async_Glue, CallbackType = global::Bond.Comm.ServiceCallbackType.RequestResponse};|]
methodInfo Event{..} = [lt|yield return new global::Bond.Comm.ServiceMethodInfo {MethodName="#{getDeclTypeName idl s}.#{methodName}", Callback = #{methodName}Async_Glue, CallbackType = global::Bond.Comm.ServiceCallbackType.Event};|]
methodAbstract Function{..} = [lt|public abstract global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<#{getMessageResultTypeName}>> #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param, global::System.Threading.CancellationToken ct);|]
methodAbstract Function{..} = [lt|#{CS.schemaAttributes 2 methodAttributes}public abstract global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<#{getMessageResultTypeName}>> #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param, global::System.Threading.CancellationToken ct);|]
where
getMessageResultTypeName = getMessageTypeName cs methodResult
getMessageInputTypeName = getMessageTypeName cs methodInput
@ -192,7 +192,7 @@ namespace #{csNamespace}
getMessageResultTypeName = getMessageTypeName cs methodResult
getMessageInputTypeName = getMessageTypeName cs methodInput
methodGlue Event{..} = [lt|private global::System.Threading.Tasks.Task #{methodName}Async_Glue(global::Bond.Comm.IMessage param, global::Bond.Comm.ReceiveContext context, global::System.Threading.CancellationToken ct)
methodGlue Event{..} = [lt|#{CS.schemaAttributes 2 methodAttributes}private global::System.Threading.Tasks.Task #{methodName}Async_Glue(global::Bond.Comm.IMessage param, global::Bond.Comm.ReceiveContext context, global::System.Threading.CancellationToken ct)
{
#{methodName}Async(param.Convert<#{getMessageInputTypeName}>());
return global::Bond.Comm.CodegenHelpers.CompletedTask;

Просмотреть файл

@ -103,9 +103,9 @@ namespace #{csNamespace}
global::Bond.Grpc.Marshaller<#{getMessageTypeName methodInput}>.Instance,
global::Bond.Grpc.Marshaller<#{getMessageTypeName Nothing}>.Instance);|]
serverBaseMethods Function{..} = [lt|public abstract global::System.Threading.Tasks.Task<global::Bond.Grpc.IMessage<#{getMessageTypeName methodResult}>> #{methodName}(global::Bond.Grpc.IMessage<#{getMessageTypeName methodInput}> request, global::Grpc.Core.ServerCallContext context);|]
serverBaseMethods Function{..} = [lt|#{CS.schemaAttributes 3 methodAttributes}public abstract global::System.Threading.Tasks.Task<global::Bond.Grpc.IMessage<#{getMessageTypeName methodResult}>> #{methodName}(global::Bond.Grpc.IMessage<#{getMessageTypeName methodInput}> request, global::Grpc.Core.ServerCallContext context);|]
serverBaseMethods Event{..} = [lt|public abstract global::System.Threading.Tasks.Task #{methodName}(global::Bond.Grpc.IMessage<#{getMessageTypeName methodInput}> request, global::Grpc.Core.ServerCallContext context);
serverBaseMethods Event{..} = [lt|#{CS.schemaAttributes 3 methodAttributes}public abstract global::System.Threading.Tasks.Task #{methodName}(global::Bond.Grpc.IMessage<#{getMessageTypeName methodInput}> request, global::Grpc.Core.ServerCallContext context);
internal global::System.Threading.Tasks.Task<global::Bond.Grpc.IMessage<#{getMessageTypeName Nothing}>> #{uniqImplName methodName}(global::Bond.Grpc.IMessage<#{getMessageTypeName methodInput}> request, global::Grpc.Core.ServerCallContext context) {
return global::Bond.Grpc.Internal.NothingCallHandler.Handle(#{methodName}, request, context);
@ -117,7 +117,7 @@ namespace #{csNamespace}
requestOrVoidConstructor Nothing = [lt|global::Bond.Grpc.Message.Void|]
requestOrVoidConstructor _ = [lt|global::Bond.Grpc.Message.From(request)|]
clientMethods Function{..} = [lt|public virtual global::Grpc.Core.AsyncUnaryCall<global::Bond.Grpc.IMessage<#{getMessageTypeName methodResult}>> #{methodName}Async(#{firstParam methodInput}global::Grpc.Core.Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
clientMethods Function{..} = [lt|#{CS.schemaAttributes 3 methodAttributes}public virtual global::Grpc.Core.AsyncUnaryCall<global::Bond.Grpc.IMessage<#{getMessageTypeName methodResult}>> #{methodName}Async(#{firstParam methodInput}global::Grpc.Core.Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
var message = #{requestOrVoidConstructor methodInput};
return #{methodName}Async(message, new global::Grpc.Core.CallOptions(headers, deadline, cancellationToken));
@ -128,7 +128,7 @@ namespace #{csNamespace}
return CallInvoker.AsyncUnaryCall(Method_#{methodName}, null, options, request);
}|]
clientMethods Event{..} = [lt|public virtual void #{methodName}Async(#{firstParam methodInput}global::Grpc.Core.Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
clientMethods Event{..} = [lt|#{CS.schemaAttributes 3 methodAttributes}public virtual void #{methodName}Async(#{firstParam methodInput}global::Grpc.Core.Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
var message = #{requestOrVoidConstructor methodInput};
#{methodName}Async(message, new global::Grpc.Core.CallOptions(headers, deadline, cancellationToken));

Просмотреть файл

@ -75,7 +75,9 @@ typeAttributes cs e@Enum {..} =
<> generatedCodeAttr
-- C# service attributes
typeAttributes _ Service {..} = generatedCodeAttr
typeAttributes cs s@Service {..} =
optionalTypeAttributes cs s
<> generatedCodeAttr
typeAttributes _ _ = error "typeAttributes: impossible happened."

Просмотреть файл

@ -45,6 +45,7 @@ module Language.Bond.Codegen.Templates
, comm_h
, comm_cpp
, grpc_h
, grpc_cpp
-- ** C#
, FieldMapping(..)
, StructMapping(..)
@ -65,6 +66,7 @@ import Language.Bond.Codegen.Cpp.Types_cpp
import Language.Bond.Codegen.Cpp.Types_h
import Language.Bond.Codegen.Cpp.Comm_cpp
import Language.Bond.Codegen.Cpp.Comm_h
import Language.Bond.Codegen.Cpp.Grpc_cpp
import Language.Bond.Codegen.Cpp.Grpc_h
import Language.Bond.Codegen.Cs.Types_cs
import Language.Bond.Codegen.Cs.Comm_cs

Просмотреть файл

@ -96,6 +96,7 @@ verifyCppGrpcCodegen args baseName =
options = processOptions args
templates =
[ grpc_h (export_attribute options)
, grpc_cpp
, types_cpp
]

Просмотреть файл

@ -1,7 +1,6 @@
#include "alias_key_reflection.h"
#include "alias_key_comm.h"
#include <bond/core/exception.h>
namespace test
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "alias_with_allocator_reflection.h"
#include "alias_with_allocator_comm.h"
#include <bond/core/exception.h>
namespace test
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "aliases_reflection.h"
#include "aliases_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "alias_key_reflection.h"
#include "alias_key_comm.h"
#include <bond/core/exception.h>
namespace test
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "aliases_reflection.h"
#include "aliases_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "attributes_reflection.h"
#include "attributes_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "basic_types_reflection.h"
#include "basic_types_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "bond_meta_reflection.h"
#include "bond_meta_comm.h"
#include <bond/core/exception.h>
namespace deprecated
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "complex_types_reflection.h"
#include "complex_types_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "defaults_reflection.h"
#include "defaults_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "empty_reflection.h"
#include "empty_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "field_modifiers_reflection.h"
#include "field_modifiers_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "generics_reflection.h"
#include "generics_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "inheritance_reflection.h"
#include "inheritance_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "maybe_blob_reflection.h"
#include "maybe_blob_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "with_enum_header_reflection.h"
#include "with_enum_header_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "attributes_reflection.h"
#include "attributes_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "basic_types_reflection.h"
#include "basic_types_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "bond_meta_reflection.h"
#include "bond_meta_comm.h"
#include <bond/core/exception.h>
namespace deprecated
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "complex_types_reflection.h"
#include "complex_types_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "custom_alias_with_allocator_reflection.h"
#include "custom_alias_with_allocator_comm.h"
#include <bond/core/exception.h>
namespace test
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "custom_alias_without_allocator_reflection.h"
#include "custom_alias_without_allocator_comm.h"
#include <bond/core/exception.h>
namespace test
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "defaults_reflection.h"
#include "defaults_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "empty_reflection.h"
#include "empty_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "field_modifiers_reflection.h"
#include "field_modifiers_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "generic_service_reflection.h"
#include "generic_service_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -0,0 +1,8 @@
#include "generic_service_reflection.h"
#include "generic_service_grpc.h"
namespace tests
{
} // namespace tests

Просмотреть файл

@ -8,6 +8,7 @@
#include <bond/ext/grpc/bond_utils.h>
#include <bond/ext/grpc/client_callback.h>
#include <bond/ext/grpc/io_manager.h>
#include <bond/ext/grpc/reflection.h>
#include <bond/ext/grpc/thread_pool.h>
#include <bond/ext/grpc/unary_call.h>
#include <bond/ext/grpc/detail/client_call_data.h>
@ -40,6 +41,8 @@ template <typename Payload>
class Foo final
{
public:
struct Schema;
template <typename TThreadPool>
class ClientCore
{
@ -242,6 +245,73 @@ inline void Foo<Payload>::ClientCore<TThreadPool>::Asyncfoo33(
calldata->dispatch(rpcmethod_foo33_, request);
}
template <typename Payload>
struct Foo<Payload>::Schema
{
static const ::bond::Metadata metadata;
private: static const ::bond::Metadata s_foo31_metadata;
private: static const ::bond::Metadata s_foo32_metadata;
private: static const ::bond::Metadata s_foo33_metadata;
public: struct service
{
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo<Payload>,
::bond::bonded<Payload>,
::bond::bonded< ::bond::Void>,
&s_foo31_metadata
> foo31;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo<Payload>,
::bond::bonded< ::bond::Void>,
::bond::bonded<Payload>,
&s_foo32_metadata
> foo32;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo<Payload>,
::bond::bonded<Payload>,
::bond::bonded<Payload>,
&s_foo33_metadata
> foo33;
};
private: typedef boost::mpl::list<> methods0;
private: typedef typename boost::mpl::push_front<methods0, typename service::foo33>::type methods1;
private: typedef typename boost::mpl::push_front<methods1, typename service::foo32>::type methods2;
private: typedef typename boost::mpl::push_front<methods2, typename service::foo31>::type methods3;
public: typedef typename methods3::type methods;
Schema()
{
// Force instantiation of template statics
(void)metadata;
(void)s_foo31_metadata;
(void)s_foo32_metadata;
(void)s_foo33_metadata;
}
};
template <typename Payload>
const ::bond::Metadata Foo<Payload>::Schema::metadata
= ::bond::reflection::MetadataInit<boost::mpl::list<Payload> >("Foo", "tests.Foo",
::bond::reflection::Attributes());
template <typename Payload>
const ::bond::Metadata Foo<Payload>::Schema::s_foo31_metadata
= ::bond::reflection::MetadataInit("foo31");
template <typename Payload>
const ::bond::Metadata Foo<Payload>::Schema::s_foo32_metadata
= ::bond::reflection::MetadataInit("foo32");
template <typename Payload>
const ::bond::Metadata Foo<Payload>::Schema::s_foo33_metadata
= ::bond::reflection::MetadataInit("foo33");
} // namespace tests

Просмотреть файл

@ -1,7 +1,6 @@
#include "generics_reflection.h"
#include "generics_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "inheritance_reflection.h"
#include "inheritance_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "maybe_blob_reflection.h"
#include "maybe_blob_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -1,7 +1,6 @@
#include "service_attributes_reflection.h"
#include "service_attributes_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -0,0 +1,20 @@
#include "service_attributes_reflection.h"
#include "service_attributes_grpc.h"
namespace tests
{
const ::bond::Metadata Foo::Schema::metadata
= ::bond::reflection::MetadataInit("Foo", "tests.Foo",
boost::assign::map_list_of<std::string, std::string>
("FooAttribute", "Bar"));
const ::bond::Metadata Foo::Schema::s_foo_metadata
= ::bond::reflection::MetadataInit("foo",
boost::assign::map_list_of<std::string, std::string>
("foo", "method")
("method", ""));
} // namespace tests

Просмотреть файл

@ -16,6 +16,7 @@
namespace tests
{
[global::Bond.Attribute("FooAttribute", "Bar")]
[System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")]
public static class Foo
{
@ -30,6 +31,8 @@ namespace tests
public abstract class FooBase
{
[global::Bond.Attribute("foo", "method")]
[global::Bond.Attribute("method", "")]
public abstract global::System.Threading.Tasks.Task<global::Bond.Grpc.IMessage<Result>> foo(global::Bond.Grpc.IMessage<Param> request, global::Grpc.Core.ServerCallContext context);
}
@ -47,6 +50,8 @@ namespace tests
{
}
[global::Bond.Attribute("foo", "method")]
[global::Bond.Attribute("method", "")]
public virtual global::Grpc.Core.AsyncUnaryCall<global::Bond.Grpc.IMessage<Result>> fooAsync(Param request, global::Grpc.Core.Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
var message = global::Bond.Grpc.Message.From(request);

Просмотреть файл

@ -8,6 +8,7 @@
#include <bond/ext/grpc/bond_utils.h>
#include <bond/ext/grpc/client_callback.h>
#include <bond/ext/grpc/io_manager.h>
#include <bond/ext/grpc/reflection.h>
#include <bond/ext/grpc/thread_pool.h>
#include <bond/ext/grpc/unary_call.h>
#include <bond/ext/grpc/detail/client_call_data.h>
@ -39,6 +40,8 @@ namespace tests
class Foo final
{
public:
struct Schema;
template <typename TThreadPool>
class ClientCore
{
@ -147,6 +150,31 @@ inline void Foo::ClientCore<TThreadPool>::Asyncfoo(
calldata->dispatch(rpcmethod_foo_, request);
}
struct Foo::Schema
{
static const ::bond::Metadata metadata;
private: static const ::bond::Metadata s_foo_metadata;
public: struct service
{
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::Param>,
::bond::bonded< ::tests::Result>,
&s_foo_metadata
> foo;
};
private: typedef boost::mpl::list<> methods0;
private: typedef boost::mpl::push_front<methods0, service::foo>::type methods1;
public: typedef methods1::type methods;
};
} // namespace tests

Просмотреть файл

@ -15,9 +15,12 @@
namespace tests
{
[global::Bond.Attribute("FooAttribute", "Bar")]
[System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")]
public interface IFoo
{
[global::Bond.Attribute("foo", "method")]
[global::Bond.Attribute("method", "")]
global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<Result>> fooAsync(global::Bond.Comm.IMessage<Param> param, global::System.Threading.CancellationToken ct);
}

Просмотреть файл

@ -15,6 +15,7 @@
namespace tests
{
[global::Bond.Attribute("FooAttribute", "Bar")]
[System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")]
public class FooProxy<TConnection> : IFoo where TConnection : global::Bond.Comm.IRequestResponseConnection
{
@ -25,6 +26,8 @@ namespace tests
m_connection = connection;
}
[global::Bond.Attribute("foo", "method")]
[global::Bond.Attribute("method", "")]
public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<Result>> fooAsync(Param param)
{
var message = new global::Bond.Comm.Message<Param>(param);

Просмотреть файл

@ -15,6 +15,7 @@
namespace tests
{
[global::Bond.Attribute("FooAttribute", "Bar")]
[System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")]
public abstract class FooServiceBase : IFoo, global::Bond.Comm.IService
{
@ -26,6 +27,8 @@ namespace tests
}
}
[global::Bond.Attribute("foo", "method")]
[global::Bond.Attribute("method", "")]
public abstract global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<Result>> fooAsync(global::Bond.Comm.IMessage<Param> param, global::System.Threading.CancellationToken ct);
private global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage> fooAsync_Glue(global::Bond.Comm.IMessage param, global::Bond.Comm.ReceiveContext context, global::System.Threading.CancellationToken ct)

Просмотреть файл

@ -1,7 +1,6 @@
#include "service_reflection.h"
#include "service_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -0,0 +1,73 @@
#include "service_reflection.h"
#include "service_grpc.h"
namespace tests
{
const ::bond::Metadata Foo::Schema::metadata
= ::bond::reflection::MetadataInit("Foo", "tests.Foo",
::bond::reflection::Attributes());
const ::bond::Metadata Foo::Schema::s_foo11_metadata
= ::bond::reflection::MetadataInit("foo11");
const ::bond::Metadata Foo::Schema::s_foo12_metadata
= ::bond::reflection::MetadataInit("foo12");
const ::bond::Metadata Foo::Schema::s_foo12_impl_metadata
= ::bond::reflection::MetadataInit("foo12_impl");
const ::bond::Metadata Foo::Schema::s_foo13_metadata
= ::bond::reflection::MetadataInit("foo13");
const ::bond::Metadata Foo::Schema::s_foo14_metadata
= ::bond::reflection::MetadataInit("foo14");
const ::bond::Metadata Foo::Schema::s_foo15_metadata
= ::bond::reflection::MetadataInit("foo15");
const ::bond::Metadata Foo::Schema::s_foo21_metadata
= ::bond::reflection::MetadataInit("foo21");
const ::bond::Metadata Foo::Schema::s_foo22_metadata
= ::bond::reflection::MetadataInit("foo22");
const ::bond::Metadata Foo::Schema::s_foo23_metadata
= ::bond::reflection::MetadataInit("foo23");
const ::bond::Metadata Foo::Schema::s_foo24_metadata
= ::bond::reflection::MetadataInit("foo24");
const ::bond::Metadata Foo::Schema::s_foo31_metadata
= ::bond::reflection::MetadataInit("foo31");
const ::bond::Metadata Foo::Schema::s_foo32_metadata
= ::bond::reflection::MetadataInit("foo32");
const ::bond::Metadata Foo::Schema::s_foo33_metadata
= ::bond::reflection::MetadataInit("foo33");
const ::bond::Metadata Foo::Schema::s__rd_foo33_metadata
= ::bond::reflection::MetadataInit("_rd_foo33");
const ::bond::Metadata Foo::Schema::s_foo34_metadata
= ::bond::reflection::MetadataInit("foo34");
const ::bond::Metadata Foo::Schema::s_foo41_metadata
= ::bond::reflection::MetadataInit("foo41");
const ::bond::Metadata Foo::Schema::s_foo42_metadata
= ::bond::reflection::MetadataInit("foo42");
const ::bond::Metadata Foo::Schema::s_foo43_metadata
= ::bond::reflection::MetadataInit("foo43");
const ::bond::Metadata Foo::Schema::s_foo44_metadata
= ::bond::reflection::MetadataInit("foo44");
const ::bond::Metadata Foo::Schema::s_cq_metadata
= ::bond::reflection::MetadataInit("cq");
} // namespace tests

Просмотреть файл

@ -9,6 +9,7 @@
#include <bond/ext/grpc/bond_utils.h>
#include <bond/ext/grpc/client_callback.h>
#include <bond/ext/grpc/io_manager.h>
#include <bond/ext/grpc/reflection.h>
#include <bond/ext/grpc/thread_pool.h>
#include <bond/ext/grpc/unary_call.h>
#include <bond/ext/grpc/detail/client_call_data.h>
@ -40,6 +41,8 @@ namespace tests
class Foo final
{
public:
struct Schema;
template <typename TThreadPool>
class ClientCore
{
@ -987,6 +990,202 @@ inline void Foo::ClientCore<TThreadPool>::Asynccq(
calldata->dispatch(rpcmethod_cq_, request);
}
struct Foo::Schema
{
static const ::bond::Metadata metadata;
private: static const ::bond::Metadata s_foo11_metadata;
private: static const ::bond::Metadata s_foo12_metadata;
private: static const ::bond::Metadata s_foo12_impl_metadata;
private: static const ::bond::Metadata s_foo13_metadata;
private: static const ::bond::Metadata s_foo14_metadata;
private: static const ::bond::Metadata s_foo15_metadata;
private: static const ::bond::Metadata s_foo21_metadata;
private: static const ::bond::Metadata s_foo22_metadata;
private: static const ::bond::Metadata s_foo23_metadata;
private: static const ::bond::Metadata s_foo24_metadata;
private: static const ::bond::Metadata s_foo31_metadata;
private: static const ::bond::Metadata s_foo32_metadata;
private: static const ::bond::Metadata s_foo33_metadata;
private: static const ::bond::Metadata s__rd_foo33_metadata;
private: static const ::bond::Metadata s_foo34_metadata;
private: static const ::bond::Metadata s_foo41_metadata;
private: static const ::bond::Metadata s_foo42_metadata;
private: static const ::bond::Metadata s_foo43_metadata;
private: static const ::bond::Metadata s_foo44_metadata;
private: static const ::bond::Metadata s_cq_metadata;
public: struct service
{
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
void,
&s_foo11_metadata
> foo11;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
void,
&s_foo12_metadata
> foo12;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
void,
&s_foo12_impl_metadata
> foo12_impl;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::BasicTypes>,
void,
&s_foo13_metadata
> foo13;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::dummy>,
void,
&s_foo14_metadata
> foo14;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests2::OtherBasicTypes>,
void,
&s_foo15_metadata
> foo15;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
::bond::bonded< ::bond::Void>,
&s_foo21_metadata
> foo21;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
::bond::bonded< ::bond::Void>,
&s_foo22_metadata
> foo22;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::BasicTypes>,
::bond::bonded< ::bond::Void>,
&s_foo23_metadata
> foo23;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::dummy>,
::bond::bonded< ::bond::Void>,
&s_foo24_metadata
> foo24;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
::bond::bonded< ::tests::BasicTypes>,
&s_foo31_metadata
> foo31;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
::bond::bonded< ::tests::BasicTypes>,
&s_foo32_metadata
> foo32;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::BasicTypes>,
::bond::bonded< ::tests::BasicTypes>,
&s_foo33_metadata
> foo33;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::BasicTypes>,
::bond::bonded< ::tests::BasicTypes>,
&s__rd_foo33_metadata
> _rd_foo33;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::dummy>,
::bond::bonded< ::tests::BasicTypes>,
&s_foo34_metadata
> foo34;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
::bond::bonded< ::tests::dummy>,
&s_foo41_metadata
> foo41;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
::bond::bonded< ::tests::dummy>,
&s_foo42_metadata
> foo42;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::BasicTypes>,
::bond::bonded< ::tests::dummy>,
&s_foo43_metadata
> foo43;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::tests::dummy>,
::bond::bonded< ::tests::dummy>,
&s_foo44_metadata
> foo44;
typedef ::bond::ext::gRPC::reflection::MethodTemplate<
Foo,
::bond::bonded< ::bond::Void>,
::bond::bonded< ::tests::BasicTypes>,
&s_cq_metadata
> cq;
};
private: typedef boost::mpl::list<> methods0;
private: typedef boost::mpl::push_front<methods0, service::cq>::type methods1;
private: typedef boost::mpl::push_front<methods1, service::foo44>::type methods2;
private: typedef boost::mpl::push_front<methods2, service::foo43>::type methods3;
private: typedef boost::mpl::push_front<methods3, service::foo42>::type methods4;
private: typedef boost::mpl::push_front<methods4, service::foo41>::type methods5;
private: typedef boost::mpl::push_front<methods5, service::foo34>::type methods6;
private: typedef boost::mpl::push_front<methods6, service::_rd_foo33>::type methods7;
private: typedef boost::mpl::push_front<methods7, service::foo33>::type methods8;
private: typedef boost::mpl::push_front<methods8, service::foo32>::type methods9;
private: typedef boost::mpl::push_front<methods9, service::foo31>::type methods10;
private: typedef boost::mpl::push_front<methods10, service::foo24>::type methods11;
private: typedef boost::mpl::push_front<methods11, service::foo23>::type methods12;
private: typedef boost::mpl::push_front<methods12, service::foo22>::type methods13;
private: typedef boost::mpl::push_front<methods13, service::foo21>::type methods14;
private: typedef boost::mpl::push_front<methods14, service::foo15>::type methods15;
private: typedef boost::mpl::push_front<methods15, service::foo14>::type methods16;
private: typedef boost::mpl::push_front<methods16, service::foo13>::type methods17;
private: typedef boost::mpl::push_front<methods17, service::foo12_impl>::type methods18;
private: typedef boost::mpl::push_front<methods18, service::foo12>::type methods19;
private: typedef boost::mpl::push_front<methods19, service::foo11>::type methods20;
public: typedef methods20::type methods;
};
} // namespace tests

Просмотреть файл

@ -1,7 +1,6 @@
#include "with_enum_header_reflection.h"
#include "with_enum_header_comm.h"
#include <bond/core/exception.h>
namespace tests
{

Просмотреть файл

@ -109,6 +109,22 @@ if (BOND_ENABLE_COMM)
${comm_transport_detail_headers})
endif(BOND_ENABLE_COMM)
if (BOND_ENABLE_GRPC)
file (GLOB ext_detail_headers "inc/bond/ext/detail/*.h")
source_group ("ext\\detail" FILES ${ext_detail_headers})
file (GLOB ext_grpc_headers "inc/bond/ext/grpc/*.h")
source_group ("ext\\grpc" FILES ${ext_grpc_headers})
file (GLOB ext_grpc_detail_headers "inc/bond/ext/grpc/detail/*.h")
source_group ("ext\\grpc\\detail" FILES ${ext_grpc_detail_headers})
list (APPEND headers
${ext_detail_headers}
${ext_grpc_headers}
${ext_grpc_detail_headers})
endif()
source_group ("generated" FILES ${generated_files})
add_library (bond

Просмотреть файл

@ -0,0 +1,42 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#pragma once
#include <bond/core/reflection.h>
namespace bond { namespace ext { namespace gRPC { namespace reflection {
/// @brief Method description in compile-time schema
template <
typename Service,
typename Input,
typename Result,
const Metadata* metadata_ptr>
struct MethodTemplate
{
/// @brief Type of the service
typedef Service service_type;
/// @brief Type of the request
typedef Input input_type;
/// @brief Type of the response
typedef Result result_type;
/// @brief Static data member describing method metadata
static const Metadata& metadata;
};
template <
typename Service,
typename Input,
typename Result,
const bond::Metadata* metadata_ptr>
const bond::Metadata&
MethodTemplate<Service, Input, Result, metadata_ptr>::metadata = *metadata_ptr;
} } } } // namespace bond::ext::gRPC::reflection

Просмотреть файл

@ -67,6 +67,7 @@ if %errorlevel% neq 0 goto :VCEnd
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Comm_cpp.hs" />
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Comm_h.hs" />
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Enum_h.hs" />
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Grpc_cpp.hs" />
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Grpc_h.hs" />
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Reflection_h.hs" />
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Types_cpp.hs" />

Просмотреть файл

@ -62,6 +62,9 @@
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Enum_h.hs">
<Filter>Bond\Codegen\Cpp</Filter>
</None>
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Grpc_cpp.hs">
<Filter>Bond\Codegen\Cpp</Filter>
</None>
<None Include="$(ProjectDir)..\compiler\src\Language\Bond\Codegen\Cpp\Grpc_h.hs">
<Filter>Bond\Codegen\Cpp</Filter>
</None>

Просмотреть файл

@ -5,7 +5,8 @@ add_bond_codegen (grpc_dll.bond
add_library (grpc_dll_example_lib EXCLUDE_FROM_ALL
SHARED
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/grpc_dll_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/grpc_dll_apply.cpp)
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/grpc_dll_apply.cpp
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/grpc_dll_grpc.cpp)
target_include_directories(grpc_dll_example_lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

Просмотреть файл

@ -33,6 +33,8 @@
#include <iostream>
#include <memory>
#include <boost/mpl/list.hpp>
using grpc::Channel;
using grpc::Server;
@ -56,6 +58,12 @@ struct TestServiceImpl : TestService::Service
}
};
struct print_metadata {
template<typename T> void operator()(const T&) {
std::cout << T::metadata.name << std::endl;
}
};
int main()
{
{ // Exercise Core facilities
@ -96,6 +104,10 @@ int main()
bond::RuntimeSchema schema = bond::GetRuntimeSchema<MyStruct>();
std::cout << schema.GetSchema().structs[schema.GetSchema().root.struct_def].fields[0].metadata.name << std::endl;
print_metadata()(TestService::Schema());
boost::mpl::for_each<TestService::Schema::methods>(print_metadata());
}
{ // Exercise gRPC facilities

Просмотреть файл

@ -5,7 +5,8 @@ add_bond_codegen (lib/grpc_static_library.bond
add_library (grpc_static_library_lib EXCLUDE_FROM_ALL
STATIC
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/grpc_static_library_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/grpc_static_library_apply.cpp)
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/grpc_static_library_apply.cpp
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/grpc_static_library_grpc.cpp)
add_target_to_folder (grpc_static_library_lib)