@@ -144,12 +144,26 @@ struct ProxyServerCustom : public ProxyServerBase<Interface, Impl>
144
144
using ProxyServerBase<Interface, Impl>::ProxyServerBase;
145
145
};
146
146
147
- // ! Function traits class used to get method parameter and result types in generated ProxyClient implementations from
148
- // ! proxy-codegen.cpp.
147
+ // ! Function traits class used to get method parameter and result types, used in
148
+ // ! generated ProxyClient and ProxyServer classes produced by gen.cpp to get C++
149
+ // ! method type information. The generated code accesses these traits via
150
+ // ! intermediate ProxyClientMethodTraits and ProxyServerMethodTraits classes,
151
+ // ! which it is possible to specialize to change the way method arguments and
152
+ // ! return values are handled.
153
+ // !
154
+ // ! Fields of the trait class are:
155
+ // !
156
+ // ! Params - TypeList of C++ ClassName::methodName parameter types
157
+ // ! Result - Return type of ClassName::method
158
+ // ! Param<N> - helper to access individual parameters by index number.
159
+ // ! Fields - helper alias that appends Result type to the Params typelist if
160
+ // ! it not void.
149
161
template <class Fn >
150
162
struct FunctionTraits ;
151
163
152
- // ! Specialization of above to extract result and params types.
164
+ // ! Specialization of above extracting result and params types assuming the
165
+ // ! template argument is a pointer-to-method type,
166
+ // ! decltype(&ClassName::methodName)
153
167
template <class _Class , class _Result , class ... _Params>
154
168
struct FunctionTraits <_Result (_Class::*const )(_Params...)>
155
169
{
@@ -161,16 +175,20 @@ struct FunctionTraits<_Result (_Class::*const)(_Params...)>
161
175
typename std::conditional<std::is_same<void , Result>::value, Params, TypeList<_Params..., _Result>>::type;
162
176
};
163
177
164
- // ! Traits class for a method specialized by method parameters.
178
+ // ! Traits class for a proxy method, providing the same
179
+ // ! Params/Result/Param/Fields described in the FunctionTraits class above, plus
180
+ // ! an additional invoke() method that calls the C++ method which is being
181
+ // ! proxied, forwarding any arguments.
165
182
// !
166
- // ! Param and Result typedefs can be customized to adjust parameter and return types on client side.
183
+ // ! The template argument should be the InterfaceName::MethodNameParams class
184
+ // ! (generated by Cap'n Proto) associated with the method.
167
185
// !
168
- // ! Invoke method customized to adjust parameter and return types on server side.
169
- // !
170
- // ! Normal method calls go through the ProxyMethodTraits struct specialization
171
- // ! below, not this default struct, which is only used if there is no
172
- // ! ProxyMethod::impl method pointer, which is only true for construct/destroy
173
- // ! methods .
186
+ // ! Note: The class definition here is just the fallback definition used when
187
+ // ! the other specialization below doesn't match. The fallback is only used for
188
+ // ! capnp methods which do not have corresponding C++ methods, which in practice
189
+ // ! is just the two special construct() and destroy() methods described in \ref
190
+ // ! ProxyClientBase. These methods don't have any C++ parameters or return
191
+ // ! types, so the trait information below reflects that .
174
192
template <typename MethodParams, typename Enable = void >
175
193
struct ProxyMethodTraits
176
194
{
@@ -184,7 +202,18 @@ struct ProxyMethodTraits
184
202
}
185
203
};
186
204
187
- // ! Specialization of above.
205
+ // ! Specialization of above for proxy methods that have a
206
+ // ! ProxyMethod<InterfaceName::MethodNameParams>::impl pointer-to-method
207
+ // ! constant defined by generated code. This includes all functions defined in
208
+ // ! the capnp interface except any construct() or destroy() methods, that are
209
+ // ! assumed not to correspond to real member functions in the C++ class, and
210
+ // ! will use the fallback traits definition above. The generated code this
211
+ // ! specialization relies on looks like:
212
+ // !
213
+ // ! struct ProxyMethod<InterfaceName::MethodNameParams>
214
+ // ! {
215
+ // ! static constexpr auto impl = &ClassName::methodName;
216
+ // ! };
188
217
template <typename MethodParams>
189
218
struct ProxyMethodTraits <MethodParams, Require<decltype (ProxyMethod<MethodParams>::impl)>>
190
219
: public FunctionTraits<decltype (ProxyMethod<MethodParams>::impl)>
0 commit comments