Publishing nanopb-0.2.2
[apps/low-level-can-service.git] / pb.h
diff --git a/pb.h b/pb.h
index 15c346d..9174003 100644 (file)
--- a/pb.h
+++ b/pb.h
@@ -43,7 +43,7 @@
 
 /* Version of the nanopb library. Just in case you want to check it in
  * your own program. */
-#define NANOPB_VERSION nanopb-0.2.2-dev
+#define NANOPB_VERSION nanopb-0.2.2
 
 /* Include all the system headers needed by nanopb. You will need the
  * definitions of the following:
@@ -298,7 +298,7 @@ struct _pb_extension_type_t {
      * If you run into an error, return false.
      * Set to NULL for default handler.
      */
-    bool (*encode)(pb_ostream_t *stream, pb_extension_t *extension);
+    bool (*encode)(pb_ostream_t *stream, const pb_extension_t *extension);
     
     /* Free field for use by the callback. */
     const void *arg;
@@ -364,6 +364,17 @@ struct _pb_extension_t {
     {tag, PB_ATYPE_CALLBACK | PB_HTYPE_REPEATED | ltype, \
     pb_delta_end(st, m, pm), 0, pb_membersize(st, m), 0, ptr}
 
+/* Optional extensions don't have the has_ field, as that would be redundant. */
+#define PB_OPTEXT_STATIC(tag, st, m, pm, ltype, ptr) \
+    {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \
+    0, \
+    0, \
+    pb_membersize(st, m), 0, ptr}
+
+#define PB_OPTEXT_CALLBACK(tag, st, m, pm, ltype, ptr) \
+    {tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \
+    0, 0, pb_membersize(st, m), 0, ptr}
+
 /* The mapping from protobuf types to LTYPEs is done using these macros. */
 #define PB_LTYPE_MAP_BOOL       PB_LTYPE_VARINT
 #define PB_LTYPE_MAP_BYTES      PB_LTYPE_BYTES