X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=pb.h;h=d839be5947c115699185ff404b94482e625bb3b7;hb=414e637867c513ba9aa199e106c6d576e5b60287;hp=a8e95e593bad9528e74d3dd2440b6d6c57ba269c;hpb=ee5b12c537115b113ce01708d4a86a4062cdb182;p=apps%2Fagl-service-can-low-level.git diff --git a/pb.h b/pb.h index a8e95e59..d839be59 100644 --- a/pb.h +++ b/pb.h @@ -162,6 +162,7 @@ typedef uint8_t pb_type_t; /**** Field allocation types ****/ #define PB_ATYPE_STATIC 0x00 +#define PB_ATYPE_POINTER 0x80 #define PB_ATYPE_CALLBACK 0x40 #define PB_ATYPE_MASK 0xC0 @@ -366,6 +367,22 @@ struct _pb_extension_t { pb_membersize(st, m[0]), \ pb_arraysize(st, m), ptr} +/* Allocated fields carry the size of the actual data, not the pointer */ +#define PB_REQUIRED_POINTER(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_REQUIRED | ltype, \ + fd, 0, pb_membersize(st, m[0]), 0, ptr} + +/* Optional fields don't need a has_ variable, as information would be redundant */ +#define PB_OPTIONAL_POINTER(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \ + fd, 0, pb_membersize(st, m[0]), 0, ptr} + +#define PB_REPEATED_POINTER(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_REPEATED | ltype, \ + fd, \ + pb_delta(st, m ## _count, m), \ + pb_membersize(st, m[0]), 0, ptr} + /* Callbacks are much like required fields except with special datatype. */ #define PB_REQUIRED_CALLBACK(tag, st, m, fd, ltype, ptr) \ {tag, PB_ATYPE_CALLBACK | PB_HTYPE_REQUIRED | ltype, \