summaryrefslogtreecommitdiffstats
path: root/pb.h
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-02-11 21:55:55 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-02-11 21:55:55 +0200
commitec4a7a0ccef07266cdd3e309e1d3b7233413142c (patch)
tree91cf2a7d83b19f8502f76a467d78b61bd333bf9b /pb.h
parentc1a355b23e3aa57bab901f0efd0604030ac50a4c (diff)
Replace pb_type_t enum with #defines.
See issue #57.
Diffstat (limited to 'pb.h')
-rw-r--r--pb.h108
1 files changed, 54 insertions, 54 deletions
diff --git a/pb.h b/pb.h
index e28db6af..29aed850 100644
--- a/pb.h
+++ b/pb.h
@@ -6,7 +6,7 @@
* see pb_encode.h or pb_decode.h
*/
-#define NANOPB_VERSION 0.2.0-dev
+#define NANOPB_VERSION nanopb-0.2.0-dev
#include <stdint.h>
#include <stddef.h>
@@ -53,59 +53,59 @@
* SINT* is different, though, because it is zig-zag coded.
*/
-typedef enum {
- /************************
- * Field contents types *
- ************************/
-
- /* Numeric types */
- PB_LTYPE_VARINT = 0x00, /* int32, uint32, int64, uint64, bool, enum */
- PB_LTYPE_SVARINT = 0x01, /* sint32, sint64 */
- PB_LTYPE_FIXED32 = 0x02, /* fixed32, sfixed32, float */
- PB_LTYPE_FIXED64 = 0x03, /* fixed64, sfixed64, double */
-
- /* Marker for last packable field type. */
- PB_LTYPE_LAST_PACKABLE = 0x03,
-
- /* Byte array with pre-allocated buffer.
- * data_size is the length of the allocated PB_BYTES_ARRAY structure. */
- PB_LTYPE_BYTES = 0x04,
-
- /* String with pre-allocated buffer.
- * data_size is the maximum length. */
- PB_LTYPE_STRING = 0x05,
-
- /* Submessage
- * submsg_fields is pointer to field descriptions */
- PB_LTYPE_SUBMESSAGE = 0x06,
-
- /* Number of declared LTYPES */
- PB_LTYPES_COUNT = 7,
- PB_LTYPE_MASK = 0x0F,
-
- /******************
- * Modifier flags *
- ******************/
-
- /* Just the basic, write data at data_offset */
- PB_HTYPE_REQUIRED = 0x00,
-
- /* Write true at size_offset */
- PB_HTYPE_OPTIONAL = 0x10,
-
- /* Read to pre-allocated array
- * Maximum number of entries is array_size,
- * actual number is stored at size_offset */
- PB_HTYPE_ARRAY = 0x20,
-
- /* Works for all required/optional/repeated fields.
- * data_offset points to pb_callback_t structure.
- * LTYPE should be valid or 0 (it is ignored, but
- * sometimes used to speculatively index an array). */
- PB_HTYPE_CALLBACK = 0x30,
-
- PB_HTYPE_MASK = 0xF0
-} pb_packed pb_type_t;
+typedef uint8_t pb_type_t;
+
+/************************
+ * Field contents types *
+ ************************/
+
+/* Numeric types */
+#define PB_LTYPE_VARINT 0x00 /* int32, uint32, int64, uint64, bool, enum */
+#define PB_LTYPE_SVARINT 0x01 /* sint32, sint64 */
+#define PB_LTYPE_FIXED32 0x02 /* fixed32, sfixed32, float */
+#define PB_LTYPE_FIXED64 0x03 /* fixed64, sfixed64, double */
+
+/* Marker for last packable field type. */
+#define PB_LTYPE_LAST_PACKABLE 0x03
+
+/* Byte array with pre-allocated buffer.
+ * data_size is the length of the allocated PB_BYTES_ARRAY structure. */
+#define PB_LTYPE_BYTES 0x04
+
+/* String with pre-allocated buffer.
+ * data_size is the maximum length. */
+#define PB_LTYPE_STRING 0x05
+
+/* Submessage
+ * submsg_fields is pointer to field descriptions */
+#define PB_LTYPE_SUBMESSAGE 0x06
+
+/* Number of declared LTYPES */
+#define PB_LTYPES_COUNT 7
+#define PB_LTYPE_MASK 0x0F
+
+/******************
+ * Modifier flags *
+ ******************/
+
+/* Just the basic, write data at data_offset */
+#define PB_HTYPE_REQUIRED 0x00
+
+/* Write true at size_offset */
+#define PB_HTYPE_OPTIONAL 0x10
+
+/* Read to pre-allocated array
+ * Maximum number of entries is array_size,
+ * actual number is stored at size_offset */
+#define PB_HTYPE_ARRAY 0x20
+
+/* Works for all required/optional/repeated fields.
+ * data_offset points to pb_callback_t structure.
+ * LTYPE should be valid or 0 (it is ignored, but
+ * sometimes used to speculatively index an array). */
+#define PB_HTYPE_CALLBACK 0x30
+
+#define PB_HTYPE_MASK 0xF0
#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)