Skip to content

Commit e863c6c

Browse files
doc: Add comments to FIELD_* constants in proxy.h
1 parent 3c69d12 commit e863c6c

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

include/mp/proxy.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,20 +304,31 @@ struct ProxyServerMethodTraits : public ProxyMethodTraits<MethodParams>
304304
{
305305
};
306306

307-
static constexpr int FIELD_IN = 1;
308-
static constexpr int FIELD_OUT = 2;
309-
static constexpr int FIELD_OPTIONAL = 4;
310-
static constexpr int FIELD_REQUESTED = 8;
311-
static constexpr int FIELD_BOXED = 16;
307+
static constexpr int FIELD_IN = 1; //!< See Accessor::in.
308+
static constexpr int FIELD_OUT = 2; //!< See Accessor::out.
309+
static constexpr int FIELD_OPTIONAL = 4; //!< See Accessor::optional.
310+
static constexpr int FIELD_REQUESTED = 8; //!< See Accessor::requested.
311+
static constexpr int FIELD_BOXED = 16; //!< See Accessor::boxed.
312312

313313
//! Accessor type holding flags that determine how to access a message field.
314314
template <typename Field, int flags>
315315
struct Accessor : public Field
316316
{
317+
//! Field is present from the Cap'n Proto Params struct (client -> server).
317318
static const bool in = flags & FIELD_IN;
319+
//! Field is present from the Cap'n Proto Results struct (server -> client).
318320
static const bool out = flags & FIELD_OUT;
321+
//! Field has a companion has{Name} boolean field in the Cap'n Proto struct.
322+
//! This is used to represent optional primitive values (e.g. C++
323+
//! std::optional<int>) because Cap'n Proto doesn't allow primitive fields to
324+
//! be unset.
319325
static const bool optional = flags & FIELD_OPTIONAL;
326+
//! Results field has a companion want{Name} boolean field in the Params
327+
//! struct. Used for optional output parameters (e.g. C++ int*) and set to
328+
//! true if the caller passed a non-null pointer and wants the result.
320329
static const bool requested = flags & FIELD_REQUESTED;
330+
//! Field is a Cap'n Proto pointer type (struct, list, text, data,
331+
//! interface) as opposed to a primitive type (bool, int, float, enum).
321332
static const bool boxed = flags & FIELD_BOXED;
322333
};
323334

0 commit comments

Comments
 (0)