summaryrefslogtreecommitdiffstats
path: root/docs/reference.rst
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-08-08 20:37:59 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-08-08 20:42:46 +0300
commitf15093e8bde18bb9fc6f56a7f6fff727eef74e6c (patch)
tree34d576d792bb2aa3f33676eafe4a29c37c2e5cc3 /docs/reference.rst
parentb663909fb6e86f0ae0f450523e72fb7fbfb719ab (diff)
Document field extensions support
Update issue 17 Status: FixedInGit
Diffstat (limited to 'docs/reference.rst')
-rw-r--r--docs/reference.rst35
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/reference.rst b/docs/reference.rst
index 6c38f6b4..51556d35 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -304,6 +304,41 @@ Protocol Buffers wire types. These are used with `pb_encode_tag`_. ::
PB_WT_32BIT = 5
} pb_wire_type_t;
+pb_extension_type_t
+-------------------
+Defines the handler functions and auxiliary data for a field that extends
+another message. Usually autogenerated by *nanopb_generator.py*::
+
+ typedef struct {
+ bool (*decode)(pb_istream_t *stream, pb_extension_t *extension,
+ uint32_t tag, pb_wire_type_t wire_type);
+ bool (*encode)(pb_ostream_t *stream, const pb_extension_t *extension);
+ const void *arg;
+ } pb_extension_type_t;
+
+In the normal case, the function pointers are *NULL* and the decoder and
+encoder use their internal implementations. The internal implementations
+assume that *arg* points to a *pb_field_t* that describes the field in question.
+
+To implement custom processing of unknown fields, you can provide pointers
+to your own functions. Their functionality is mostly the same as for normal
+callback fields, except that they get called for any unknown field when decoding.
+
+pb_extension_t
+--------------
+Ties together the extension field type and the storage for the field value::
+
+ typedef struct {
+ const pb_extension_type_t *type;
+ void *dest;
+ pb_extension_t *next;
+ } pb_extension_t;
+
+:type: Pointer to the structure that defines the callback functions.
+:dest: Pointer to the variable that stores the field value
+ (as used by the default extension callback functions.)
+:next: Pointer to the next extension handler, or *NULL*.
+
PB_GET_ERROR
------------
Get the current error message from a stream, or a placeholder string if