提交 6d761d3c 编写于 作者: N NazgulLee 提交者: Yanzhan Yang

add name protection for protobuf-c (#1641)

上级 ce00384f
...@@ -14,20 +14,22 @@ void paddle_mobile__framework__proto__version__init( ...@@ -14,20 +14,22 @@ void paddle_mobile__framework__proto__version__init(
*message = init_value; *message = init_value;
} }
PaddleMobile__Framework__Proto__Version * PaddleMobile__Framework__Proto__Version *
paddle_mobile__framework__proto__version__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__version__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data) { const uint8_t *data) {
return (PaddleMobile__Framework__Proto__Version *)protobuf_c_message_unpack( return (PaddleMobile__Framework__Proto__Version *)
PaddleMobile__Framework__protobuf_c_message_unpack(
&paddle_mobile__framework__proto__version__descriptor, allocator, len, &paddle_mobile__framework__proto__version__descriptor, allocator, len,
data); data);
} }
void paddle_mobile__framework__proto__version__free_unpacked( void paddle_mobile__framework__proto__version__free_unpacked(
PaddleMobile__Framework__Proto__Version *message, PaddleMobile__Framework__Proto__Version *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
if (!message) return; if (!message) return;
assert(message->base.descriptor == assert(message->base.descriptor ==
&paddle_mobile__framework__proto__version__descriptor); &paddle_mobile__framework__proto__version__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(
(PaddleMobile__Framework__ProtobufCMessage *)message, allocator);
} }
void paddle_mobile__framework__proto__op_desc__attr__init( void paddle_mobile__framework__proto__op_desc__attr__init(
PaddleMobile__Framework__Proto__OpDesc__Attr *message) { PaddleMobile__Framework__Proto__OpDesc__Attr *message) {
...@@ -48,20 +50,22 @@ void paddle_mobile__framework__proto__op_desc__init( ...@@ -48,20 +50,22 @@ void paddle_mobile__framework__proto__op_desc__init(
*message = init_value; *message = init_value;
} }
PaddleMobile__Framework__Proto__OpDesc * PaddleMobile__Framework__Proto__OpDesc *
paddle_mobile__framework__proto__op_desc__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__op_desc__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data) { const uint8_t *data) {
return (PaddleMobile__Framework__Proto__OpDesc *)protobuf_c_message_unpack( return (PaddleMobile__Framework__Proto__OpDesc *)
PaddleMobile__Framework__protobuf_c_message_unpack(
&paddle_mobile__framework__proto__op_desc__descriptor, allocator, len, &paddle_mobile__framework__proto__op_desc__descriptor, allocator, len,
data); data);
} }
void paddle_mobile__framework__proto__op_desc__free_unpacked( void paddle_mobile__framework__proto__op_desc__free_unpacked(
PaddleMobile__Framework__Proto__OpDesc *message, PaddleMobile__Framework__Proto__OpDesc *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
if (!message) return; if (!message) return;
assert(message->base.descriptor == assert(message->base.descriptor ==
&paddle_mobile__framework__proto__op_desc__descriptor); &paddle_mobile__framework__proto__op_desc__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(
(PaddleMobile__Framework__ProtobufCMessage *)message, allocator);
} }
void paddle_mobile__framework__proto__op_proto__var__init( void paddle_mobile__framework__proto__op_proto__var__init(
PaddleMobile__Framework__Proto__OpProto__Var *message) { PaddleMobile__Framework__Proto__OpProto__Var *message) {
...@@ -82,20 +86,22 @@ void paddle_mobile__framework__proto__op_proto__init( ...@@ -82,20 +86,22 @@ void paddle_mobile__framework__proto__op_proto__init(
*message = init_value; *message = init_value;
} }
PaddleMobile__Framework__Proto__OpProto * PaddleMobile__Framework__Proto__OpProto *
paddle_mobile__framework__proto__op_proto__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__op_proto__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data) { const uint8_t *data) {
return (PaddleMobile__Framework__Proto__OpProto *)protobuf_c_message_unpack( return (PaddleMobile__Framework__Proto__OpProto *)
&paddle_mobile__framework__proto__op_proto__descriptor, allocator, len, PaddleMobile__Framework__protobuf_c_message_unpack(
data); &paddle_mobile__framework__proto__op_proto__descriptor, allocator,
len, data);
} }
void paddle_mobile__framework__proto__op_proto__free_unpacked( void paddle_mobile__framework__proto__op_proto__free_unpacked(
PaddleMobile__Framework__Proto__OpProto *message, PaddleMobile__Framework__Proto__OpProto *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
if (!message) return; if (!message) return;
assert(message->base.descriptor == assert(message->base.descriptor ==
&paddle_mobile__framework__proto__op_proto__descriptor); &paddle_mobile__framework__proto__op_proto__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(
(PaddleMobile__Framework__ProtobufCMessage *)message, allocator);
} }
void paddle_mobile__framework__proto__var_type__tensor_desc__init( void paddle_mobile__framework__proto__var_type__tensor_desc__init(
PaddleMobile__Framework__Proto__VarType__TensorDesc *message) { PaddleMobile__Framework__Proto__VarType__TensorDesc *message) {
...@@ -142,20 +148,22 @@ void paddle_mobile__framework__proto__var_type__init( ...@@ -142,20 +148,22 @@ void paddle_mobile__framework__proto__var_type__init(
*message = init_value; *message = init_value;
} }
PaddleMobile__Framework__Proto__VarType * PaddleMobile__Framework__Proto__VarType *
paddle_mobile__framework__proto__var_type__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__var_type__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data) { const uint8_t *data) {
return (PaddleMobile__Framework__Proto__VarType *)protobuf_c_message_unpack( return (PaddleMobile__Framework__Proto__VarType *)
&paddle_mobile__framework__proto__var_type__descriptor, allocator, len, PaddleMobile__Framework__protobuf_c_message_unpack(
data); &paddle_mobile__framework__proto__var_type__descriptor, allocator,
len, data);
} }
void paddle_mobile__framework__proto__var_type__free_unpacked( void paddle_mobile__framework__proto__var_type__free_unpacked(
PaddleMobile__Framework__Proto__VarType *message, PaddleMobile__Framework__Proto__VarType *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
if (!message) return; if (!message) return;
assert(message->base.descriptor == assert(message->base.descriptor ==
&paddle_mobile__framework__proto__var_type__descriptor); &paddle_mobile__framework__proto__var_type__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(
(PaddleMobile__Framework__ProtobufCMessage *)message, allocator);
} }
void paddle_mobile__framework__proto__var_desc__init( void paddle_mobile__framework__proto__var_desc__init(
PaddleMobile__Framework__Proto__VarDesc *message) { PaddleMobile__Framework__Proto__VarDesc *message) {
...@@ -164,20 +172,22 @@ void paddle_mobile__framework__proto__var_desc__init( ...@@ -164,20 +172,22 @@ void paddle_mobile__framework__proto__var_desc__init(
*message = init_value; *message = init_value;
} }
PaddleMobile__Framework__Proto__VarDesc * PaddleMobile__Framework__Proto__VarDesc *
paddle_mobile__framework__proto__var_desc__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__var_desc__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data) { const uint8_t *data) {
return (PaddleMobile__Framework__Proto__VarDesc *)protobuf_c_message_unpack( return (PaddleMobile__Framework__Proto__VarDesc *)
&paddle_mobile__framework__proto__var_desc__descriptor, allocator, len, PaddleMobile__Framework__protobuf_c_message_unpack(
data); &paddle_mobile__framework__proto__var_desc__descriptor, allocator,
len, data);
} }
void paddle_mobile__framework__proto__var_desc__free_unpacked( void paddle_mobile__framework__proto__var_desc__free_unpacked(
PaddleMobile__Framework__Proto__VarDesc *message, PaddleMobile__Framework__Proto__VarDesc *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
if (!message) return; if (!message) return;
assert(message->base.descriptor == assert(message->base.descriptor ==
&paddle_mobile__framework__proto__var_desc__descriptor); &paddle_mobile__framework__proto__var_desc__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(
(PaddleMobile__Framework__ProtobufCMessage *)message, allocator);
} }
void paddle_mobile__framework__proto__block_desc__init( void paddle_mobile__framework__proto__block_desc__init(
PaddleMobile__Framework__Proto__BlockDesc *message) { PaddleMobile__Framework__Proto__BlockDesc *message) {
...@@ -187,18 +197,21 @@ void paddle_mobile__framework__proto__block_desc__init( ...@@ -187,18 +197,21 @@ void paddle_mobile__framework__proto__block_desc__init(
} }
PaddleMobile__Framework__Proto__BlockDesc * PaddleMobile__Framework__Proto__BlockDesc *
paddle_mobile__framework__proto__block_desc__unpack( paddle_mobile__framework__proto__block_desc__unpack(
ProtobufCAllocator *allocator, size_t len, const uint8_t *data) { PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
return (PaddleMobile__Framework__Proto__BlockDesc *)protobuf_c_message_unpack( const uint8_t *data) {
&paddle_mobile__framework__proto__block_desc__descriptor, allocator, len, return (PaddleMobile__Framework__Proto__BlockDesc *)
data); PaddleMobile__Framework__protobuf_c_message_unpack(
&paddle_mobile__framework__proto__block_desc__descriptor, allocator,
len, data);
} }
void paddle_mobile__framework__proto__block_desc__free_unpacked( void paddle_mobile__framework__proto__block_desc__free_unpacked(
PaddleMobile__Framework__Proto__BlockDesc *message, PaddleMobile__Framework__Proto__BlockDesc *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
if (!message) return; if (!message) return;
assert(message->base.descriptor == assert(message->base.descriptor ==
&paddle_mobile__framework__proto__block_desc__descriptor); &paddle_mobile__framework__proto__block_desc__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(
(PaddleMobile__Framework__ProtobufCMessage *)message, allocator);
} }
void paddle_mobile__framework__proto__program_desc__init( void paddle_mobile__framework__proto__program_desc__init(
PaddleMobile__Framework__Proto__ProgramDesc *message) { PaddleMobile__Framework__Proto__ProgramDesc *message) {
...@@ -208,23 +221,25 @@ void paddle_mobile__framework__proto__program_desc__init( ...@@ -208,23 +221,25 @@ void paddle_mobile__framework__proto__program_desc__init(
} }
PaddleMobile__Framework__Proto__ProgramDesc * PaddleMobile__Framework__Proto__ProgramDesc *
paddle_mobile__framework__proto__program_desc__unpack( paddle_mobile__framework__proto__program_desc__unpack(
ProtobufCAllocator *allocator, size_t len, const uint8_t *data) { PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data) {
return (PaddleMobile__Framework__Proto__ProgramDesc *) return (PaddleMobile__Framework__Proto__ProgramDesc *)
protobuf_c_message_unpack( PaddleMobile__Framework__protobuf_c_message_unpack(
&paddle_mobile__framework__proto__program_desc__descriptor, allocator, &paddle_mobile__framework__proto__program_desc__descriptor, allocator,
len, data); len, data);
} }
void paddle_mobile__framework__proto__program_desc__free_unpacked( void paddle_mobile__framework__proto__program_desc__free_unpacked(
PaddleMobile__Framework__Proto__ProgramDesc *message, PaddleMobile__Framework__Proto__ProgramDesc *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
if (!message) return; if (!message) return;
assert(message->base.descriptor == assert(message->base.descriptor ==
&paddle_mobile__framework__proto__program_desc__descriptor); &paddle_mobile__framework__proto__program_desc__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(
(PaddleMobile__Framework__ProtobufCMessage *)message, allocator);
} }
static const int64_t static const int64_t
paddle_mobile__framework__proto__version__version__default_value = 0ll; paddle_mobile__framework__proto__version__version__default_value = 0ll;
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__version__field_descriptors[1] = { paddle_mobile__framework__proto__version__field_descriptors[1] = {
{ {
"version", 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT64, "version", 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT64,
...@@ -239,10 +254,10 @@ static const unsigned ...@@ -239,10 +254,10 @@ static const unsigned
paddle_mobile__framework__proto__version__field_indices_by_name[] = { paddle_mobile__framework__proto__version__field_indices_by_name[] = {
0, /* field[0] = version */ 0, /* field[0] = version */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__version__number_ranges[1 + 1] = {{1, 0}, paddle_mobile__framework__proto__version__number_ranges[1 + 1] = {{1, 0},
{0, 1}}; {0, 1}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__version__descriptor = { paddle_mobile__framework__proto__version__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.Version", "paddle_mobile.framework.proto.Version",
...@@ -260,7 +275,7 @@ const ProtobufCMessageDescriptor ...@@ -260,7 +275,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_desc__attr__field_descriptors[14] = { paddle_mobile__framework__proto__op_desc__attr__field_descriptors[14] = {
{ {
"name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, "name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
...@@ -381,10 +396,10 @@ static const unsigned ...@@ -381,10 +396,10 @@ static const unsigned
7, /* field[7] = strings */ 7, /* field[7] = strings */
1, /* field[1] = type */ 1, /* field[1] = type */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__op_desc__attr__number_ranges[2 + 1] = { paddle_mobile__framework__proto__op_desc__attr__number_ranges[2 + 1] = {
{1, 0}, {10, 8}, {0, 14}}; {1, 0}, {10, 8}, {0, 14}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__attr__descriptor = { paddle_mobile__framework__proto__op_desc__attr__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpDesc.Attr", "paddle_mobile.framework.proto.OpDesc.Attr",
...@@ -403,7 +418,7 @@ const ProtobufCMessageDescriptor ...@@ -403,7 +418,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_desc__var__field_descriptors[2] = { paddle_mobile__framework__proto__op_desc__var__field_descriptors[2] = {
{ {
"parameter", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, "parameter", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
...@@ -425,10 +440,10 @@ static const unsigned ...@@ -425,10 +440,10 @@ static const unsigned
1, /* field[1] = arguments */ 1, /* field[1] = arguments */
0, /* field[0] = parameter */ 0, /* field[0] = parameter */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__op_desc__var__number_ranges[1 + 1] = { paddle_mobile__framework__proto__op_desc__var__number_ranges[1 + 1] = {
{1, 0}, {0, 2}}; {1, 0}, {0, 2}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__var__descriptor = { paddle_mobile__framework__proto__op_desc__var__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpDesc.Var", "paddle_mobile.framework.proto.OpDesc.Var",
...@@ -449,7 +464,7 @@ const ProtobufCMessageDescriptor ...@@ -449,7 +464,7 @@ const ProtobufCMessageDescriptor
}; };
static const protobuf_c_boolean static const protobuf_c_boolean
paddle_mobile__framework__proto__op_desc__is_target__default_value = 0; paddle_mobile__framework__proto__op_desc__is_target__default_value = 0;
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_desc__field_descriptors[5] = { paddle_mobile__framework__proto__op_desc__field_descriptors[5] = {
{ {
"inputs", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE, "inputs", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
...@@ -499,10 +514,10 @@ static const unsigned ...@@ -499,10 +514,10 @@ static const unsigned
1, /* field[1] = outputs */ 1, /* field[1] = outputs */
2, /* field[2] = type */ 2, /* field[2] = type */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__op_desc__number_ranges[1 + 1] = {{1, 0}, paddle_mobile__framework__proto__op_desc__number_ranges[1 + 1] = {{1, 0},
{0, 5}}; {0, 5}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__descriptor = { paddle_mobile__framework__proto__op_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpDesc", "paddle_mobile.framework.proto.OpDesc",
...@@ -529,7 +544,7 @@ static const protobuf_c_boolean ...@@ -529,7 +544,7 @@ static const protobuf_c_boolean
static const protobuf_c_boolean static const protobuf_c_boolean
paddle_mobile__framework__proto__op_proto__var__dispensable__default_value = paddle_mobile__framework__proto__op_proto__var__dispensable__default_value =
0; 0;
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_proto__var__field_descriptors[6] = { paddle_mobile__framework__proto__op_proto__var__field_descriptors[6] = {
{ {
"name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, "name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
...@@ -593,10 +608,10 @@ static const unsigned ...@@ -593,10 +608,10 @@ static const unsigned
0, /* field[0] = name */ 0, /* field[0] = name */
5, /* field[5] = reuse */ 5, /* field[5] = reuse */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__op_proto__var__number_ranges[1 + 1] = { paddle_mobile__framework__proto__op_proto__var__number_ranges[1 + 1] = {
{1, 0}, {0, 6}}; {1, 0}, {0, 6}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__var__descriptor = { paddle_mobile__framework__proto__op_proto__var__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpProto.Var", "paddle_mobile.framework.proto.OpProto.Var",
...@@ -618,7 +633,7 @@ const ProtobufCMessageDescriptor ...@@ -618,7 +633,7 @@ const ProtobufCMessageDescriptor
static const protobuf_c_boolean static const protobuf_c_boolean
paddle_mobile__framework__proto__op_proto__attr__generated__default_value = paddle_mobile__framework__proto__op_proto__attr__generated__default_value =
0; 0;
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_proto__attr__field_descriptors[4] = { paddle_mobile__framework__proto__op_proto__attr__field_descriptors[4] = {
{ {
"name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, "name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
...@@ -660,10 +675,10 @@ static const unsigned ...@@ -660,10 +675,10 @@ static const unsigned
0, /* field[0] = name */ 0, /* field[0] = name */
1, /* field[1] = type */ 1, /* field[1] = type */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__op_proto__attr__number_ranges[1 + 1] = { paddle_mobile__framework__proto__op_proto__attr__number_ranges[1 + 1] = {
{1, 0}, {0, 4}}; {1, 0}, {0, 4}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__attr__descriptor = { paddle_mobile__framework__proto__op_proto__attr__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpProto.Attr", "paddle_mobile.framework.proto.OpProto.Attr",
...@@ -682,7 +697,7 @@ const ProtobufCMessageDescriptor ...@@ -682,7 +697,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_proto__field_descriptors[5] = { paddle_mobile__framework__proto__op_proto__field_descriptors[5] = {
{ {
"type", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, "type", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
...@@ -731,10 +746,10 @@ static const unsigned ...@@ -731,10 +746,10 @@ static const unsigned
2, /* field[2] = outputs */ 2, /* field[2] = outputs */
0, /* field[0] = type */ 0, /* field[0] = type */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__op_proto__number_ranges[1 + 1] = {{1, 0}, paddle_mobile__framework__proto__op_proto__number_ranges[1 + 1] = {{1, 0},
{0, 5}}; {0, 5}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__descriptor = { paddle_mobile__framework__proto__op_proto__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpProto", "paddle_mobile.framework.proto.OpProto",
...@@ -752,7 +767,7 @@ const ProtobufCMessageDescriptor ...@@ -752,7 +767,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__tensor_desc__field_descriptors paddle_mobile__framework__proto__var_type__tensor_desc__field_descriptors
[2] = { [2] = {
{ {
...@@ -780,11 +795,11 @@ static const unsigned ...@@ -780,11 +795,11 @@ static const unsigned
0, /* field[0] = data_type */ 0, /* field[0] = data_type */
1, /* field[1] = dims */ 1, /* field[1] = dims */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_type__tensor_desc__number_ranges[1 + paddle_mobile__framework__proto__var_type__tensor_desc__number_ranges[1 +
1] = { 1] = {
{1, 0}, {0, 2}}; {1, 0}, {0, 2}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__tensor_desc__descriptor = { paddle_mobile__framework__proto__var_type__tensor_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.TensorDesc", "paddle_mobile.framework.proto.VarType.TensorDesc",
...@@ -806,7 +821,7 @@ const ProtobufCMessageDescriptor ...@@ -806,7 +821,7 @@ const ProtobufCMessageDescriptor
static const int32_t static const int32_t
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__lod_level__default_value = paddle_mobile__framework__proto__var_type__lo_dtensor_desc__lod_level__default_value =
0; 0;
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__field_descriptors paddle_mobile__framework__proto__var_type__lo_dtensor_desc__field_descriptors
[2] = { [2] = {
{ {
...@@ -837,10 +852,10 @@ static const unsigned ...@@ -837,10 +852,10 @@ static const unsigned
1, /* field[1] = lod_level */ 1, /* field[1] = lod_level */
0, /* field[0] = tensor */ 0, /* field[0] = tensor */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__number_ranges paddle_mobile__framework__proto__var_type__lo_dtensor_desc__number_ranges
[1 + 1] = {{1, 0}, {0, 2}}; [1 + 1] = {{1, 0}, {0, 2}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor = { paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.LoDTensorDesc", "paddle_mobile.framework.proto.VarType.LoDTensorDesc",
...@@ -862,7 +877,7 @@ const ProtobufCMessageDescriptor ...@@ -862,7 +877,7 @@ const ProtobufCMessageDescriptor
static const int32_t static const int32_t
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__lod_level__default_value = paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__lod_level__default_value =
0; 0;
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__field_descriptors paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__field_descriptors
[2] = { [2] = {
{ {
...@@ -896,10 +911,10 @@ static const unsigned ...@@ -896,10 +911,10 @@ static const unsigned
1, /* field[1] = lod_level */ 1, /* field[1] = lod_level */
0, /* field[0] = tensor */ 0, /* field[0] = tensor */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__number_ranges paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__number_ranges
[1 + 1] = {{1, 0}, {0, 2}}; [1 + 1] = {{1, 0}, {0, 2}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor = { paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.LoDTensorArrayDesc", "paddle_mobile.framework.proto.VarType.LoDTensorArrayDesc",
...@@ -918,7 +933,7 @@ const ProtobufCMessageDescriptor ...@@ -918,7 +933,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__reader_desc__field_descriptors[1] = { paddle_mobile__framework__proto__var_type__reader_desc__field_descriptors[1] = {
{ {
"lod_tensor", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE, "lod_tensor", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
...@@ -936,11 +951,11 @@ static const unsigned ...@@ -936,11 +951,11 @@ static const unsigned
[] = { [] = {
0, /* field[0] = lod_tensor */ 0, /* field[0] = lod_tensor */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_type__reader_desc__number_ranges[1 + paddle_mobile__framework__proto__var_type__reader_desc__number_ranges[1 +
1] = { 1] = {
{1, 0}, {0, 1}}; {1, 0}, {0, 1}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__reader_desc__descriptor = { paddle_mobile__framework__proto__var_type__reader_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.ReaderDesc", "paddle_mobile.framework.proto.VarType.ReaderDesc",
...@@ -959,7 +974,7 @@ const ProtobufCMessageDescriptor ...@@ -959,7 +974,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__channel_desc__field_descriptors paddle_mobile__framework__proto__var_type__channel_desc__field_descriptors
[2] = { [2] = {
{ {
...@@ -986,11 +1001,11 @@ static const unsigned ...@@ -986,11 +1001,11 @@ static const unsigned
1, /* field[1] = capacity */ 1, /* field[1] = capacity */
0, /* field[0] = data_type */ 0, /* field[0] = data_type */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_type__channel_desc__number_ranges[1 + paddle_mobile__framework__proto__var_type__channel_desc__number_ranges[1 +
1] = 1] =
{{1, 0}, {0, 2}}; {{1, 0}, {0, 2}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__channel_desc__descriptor = { paddle_mobile__framework__proto__var_type__channel_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.ChannelDesc", "paddle_mobile.framework.proto.VarType.ChannelDesc",
...@@ -1009,7 +1024,7 @@ const ProtobufCMessageDescriptor ...@@ -1009,7 +1024,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__tuple__field_descriptors[1] = { paddle_mobile__framework__proto__var_type__tuple__field_descriptors[1] = {
{ {
"element_type", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_ENUM, "element_type", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_ENUM,
...@@ -1027,10 +1042,10 @@ static const unsigned ...@@ -1027,10 +1042,10 @@ static const unsigned
{ {
0, /* field[0] = element_type */ 0, /* field[0] = element_type */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_type__tuple__number_ranges[1 + 1] = { paddle_mobile__framework__proto__var_type__tuple__number_ranges[1 + 1] = {
{1, 0}, {0, 1}}; {1, 0}, {0, 1}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__tuple__descriptor = { paddle_mobile__framework__proto__var_type__tuple__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.Tuple", "paddle_mobile.framework.proto.VarType.Tuple",
...@@ -1049,7 +1064,7 @@ const ProtobufCMessageDescriptor ...@@ -1049,7 +1064,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCEnumValue static const PaddleMobile__Framework__ProtobufCEnumValue
paddle_mobile__framework__proto__var_type__type__enum_values_by_number[22] = paddle_mobile__framework__proto__var_type__type__enum_values_by_number[22] =
{ {
{"BOOL", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL", {"BOOL", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL",
...@@ -1102,10 +1117,10 @@ static const ProtobufCEnumValue ...@@ -1102,10 +1117,10 @@ static const ProtobufCEnumValue
{"INT8", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__INT8", {"INT8", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__INT8",
21}, 21},
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_type__type__value_ranges[] = {{0, 0}, paddle_mobile__framework__proto__var_type__type__value_ranges[] = {{0, 0},
{0, 22}}; {0, 22}};
static const ProtobufCEnumValueIndex static const PaddleMobile__Framework__ProtobufCEnumValueIndex
paddle_mobile__framework__proto__var_type__type__enum_values_by_name[22] = { paddle_mobile__framework__proto__var_type__type__enum_values_by_name[22] = {
{"BOOL", 0}, {"CHANNEL", 16}, {"BOOL", 0}, {"CHANNEL", 16},
{"FEED_MINIBATCH", 9}, {"FETCH_LIST", 10}, {"FEED_MINIBATCH", 9}, {"FETCH_LIST", 10},
...@@ -1119,7 +1134,7 @@ static const ProtobufCEnumValueIndex ...@@ -1119,7 +1134,7 @@ static const ProtobufCEnumValueIndex
{"SIZE_T", 19}, {"STEP_SCOPES", 11}, {"SIZE_T", 19}, {"STEP_SCOPES", 11},
{"TUPLE", 18}, {"UINT8", 20}, {"TUPLE", 18}, {"UINT8", 20},
}; };
const ProtobufCEnumDescriptor const PaddleMobile__Framework__ProtobufCEnumDescriptor
paddle_mobile__framework__proto__var_type__type__descriptor = { paddle_mobile__framework__proto__var_type__type__descriptor = {
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.Type", "paddle_mobile.framework.proto.VarType.Type",
...@@ -1137,7 +1152,7 @@ const ProtobufCEnumDescriptor ...@@ -1137,7 +1152,7 @@ const ProtobufCEnumDescriptor
NULL, NULL,
NULL /* reserved[1234] */ NULL /* reserved[1234] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__field_descriptors[7] = { paddle_mobile__framework__proto__var_type__field_descriptors[7] = {
{ {
"type", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, "type", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM,
...@@ -1206,10 +1221,10 @@ static const unsigned ...@@ -1206,10 +1221,10 @@ static const unsigned
6, /* field[6] = tuple */ 6, /* field[6] = tuple */
0, /* field[0] = type */ 0, /* field[0] = type */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_type__number_ranges[1 + 1] = {{1, 0}, paddle_mobile__framework__proto__var_type__number_ranges[1 + 1] = {{1, 0},
{0, 7}}; {0, 7}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__descriptor = { paddle_mobile__framework__proto__var_type__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType", "paddle_mobile.framework.proto.VarType",
...@@ -1229,7 +1244,7 @@ const ProtobufCMessageDescriptor ...@@ -1229,7 +1244,7 @@ const ProtobufCMessageDescriptor
}; };
static const protobuf_c_boolean static const protobuf_c_boolean
paddle_mobile__framework__proto__var_desc__persistable__default_value = 0; paddle_mobile__framework__proto__var_desc__persistable__default_value = 0;
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_desc__field_descriptors[3] = { paddle_mobile__framework__proto__var_desc__field_descriptors[3] = {
{ {
"name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, "name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
...@@ -1262,10 +1277,10 @@ static const unsigned ...@@ -1262,10 +1277,10 @@ static const unsigned
2, /* field[2] = persistable */ 2, /* field[2] = persistable */
1, /* field[1] = type */ 1, /* field[1] = type */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__var_desc__number_ranges[1 + 1] = {{1, 0}, paddle_mobile__framework__proto__var_desc__number_ranges[1 + 1] = {{1, 0},
{0, 3}}; {0, 3}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_desc__descriptor = { paddle_mobile__framework__proto__var_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarDesc", "paddle_mobile.framework.proto.VarDesc",
...@@ -1286,7 +1301,7 @@ const ProtobufCMessageDescriptor ...@@ -1286,7 +1301,7 @@ const ProtobufCMessageDescriptor
static const int32_t static const int32_t
paddle_mobile__framework__proto__block_desc__forward_block_idx__default_value = paddle_mobile__framework__proto__block_desc__forward_block_idx__default_value =
-1; -1;
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__block_desc__field_descriptors[5] = { paddle_mobile__framework__proto__block_desc__field_descriptors[5] = {
{ {
"idx", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, "idx", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32,
...@@ -1339,10 +1354,10 @@ static const unsigned ...@@ -1339,10 +1354,10 @@ static const unsigned
1, /* field[1] = parent_idx */ 1, /* field[1] = parent_idx */
2, /* field[2] = vars */ 2, /* field[2] = vars */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__block_desc__number_ranges[1 + 1] = { paddle_mobile__framework__proto__block_desc__number_ranges[1 + 1] = {
{1, 0}, {0, 5}}; {1, 0}, {0, 5}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__block_desc__descriptor = { paddle_mobile__framework__proto__block_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.BlockDesc", "paddle_mobile.framework.proto.BlockDesc",
...@@ -1360,7 +1375,7 @@ const ProtobufCMessageDescriptor ...@@ -1360,7 +1375,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor static const PaddleMobile__Framework__ProtobufCFieldDescriptor
paddle_mobile__framework__proto__program_desc__field_descriptors[2] = { paddle_mobile__framework__proto__program_desc__field_descriptors[2] = {
{ {
"blocks", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE, "blocks", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
...@@ -1384,10 +1399,10 @@ static const unsigned ...@@ -1384,10 +1399,10 @@ static const unsigned
0, /* field[0] = blocks */ 0, /* field[0] = blocks */
1, /* field[1] = version */ 1, /* field[1] = version */
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__program_desc__number_ranges[1 + 1] = { paddle_mobile__framework__proto__program_desc__number_ranges[1 + 1] = {
{1, 0}, {0, 2}}; {1, 0}, {0, 2}};
const ProtobufCMessageDescriptor const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__program_desc__descriptor = { paddle_mobile__framework__proto__program_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.ProgramDesc", "paddle_mobile.framework.proto.ProgramDesc",
...@@ -1406,7 +1421,7 @@ const ProtobufCMessageDescriptor ...@@ -1406,7 +1421,7 @@ const ProtobufCMessageDescriptor
NULL, NULL,
NULL /* reserved[123] */ NULL /* reserved[123] */
}; };
static const ProtobufCEnumValue static const PaddleMobile__Framework__ProtobufCEnumValue
paddle_mobile__framework__proto__attr_type__enum_values_by_number[12] = { paddle_mobile__framework__proto__attr_type__enum_values_by_number[12] = {
{"INT", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT", 0}, {"INT", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT", 0},
{"FLOAT", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOAT", 1}, {"FLOAT", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOAT", 1},
...@@ -1421,16 +1436,16 @@ static const ProtobufCEnumValue ...@@ -1421,16 +1436,16 @@ static const ProtobufCEnumValue
{"BLOCKS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BLOCKS", 10}, {"BLOCKS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BLOCKS", 10},
{"LONGS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__LONGS", 11}, {"LONGS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__LONGS", 11},
}; };
static const ProtobufCIntRange static const PaddleMobile__Framework__ProtobufCIntRange
paddle_mobile__framework__proto__attr_type__value_ranges[] = {{0, 0}, paddle_mobile__framework__proto__attr_type__value_ranges[] = {{0, 0},
{0, 12}}; {0, 12}};
static const ProtobufCEnumValueIndex static const PaddleMobile__Framework__ProtobufCEnumValueIndex
paddle_mobile__framework__proto__attr_type__enum_values_by_name[12] = { paddle_mobile__framework__proto__attr_type__enum_values_by_name[12] = {
{"BLOCK", 8}, {"BLOCKS", 10}, {"BOOLEAN", 6}, {"BOOLEANS", 7}, {"BLOCK", 8}, {"BLOCKS", 10}, {"BOOLEAN", 6}, {"BOOLEANS", 7},
{"FLOAT", 1}, {"FLOATS", 4}, {"INT", 0}, {"INTS", 3}, {"FLOAT", 1}, {"FLOATS", 4}, {"INT", 0}, {"INTS", 3},
{"LONG", 9}, {"LONGS", 11}, {"STRING", 2}, {"STRINGS", 5}, {"LONG", 9}, {"LONGS", 11}, {"STRING", 2}, {"STRINGS", 5},
}; };
const ProtobufCEnumDescriptor const PaddleMobile__Framework__ProtobufCEnumDescriptor
paddle_mobile__framework__proto__attr_type__descriptor = { paddle_mobile__framework__proto__attr_type__descriptor = {
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.AttrType", "paddle_mobile.framework.proto.AttrType",
......
...@@ -117,7 +117,7 @@ typedef enum _PaddleMobile__Framework__Proto__AttrType { ...@@ -117,7 +117,7 @@ typedef enum _PaddleMobile__Framework__Proto__AttrType {
* that supports old versions following the version and compatibility policy. * that supports old versions following the version and compatibility policy.
*/ */
struct _PaddleMobile__Framework__Proto__Version { struct _PaddleMobile__Framework__Proto__Version {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
protobuf_c_boolean has_version; protobuf_c_boolean has_version;
int64_t version; int64_t version;
}; };
...@@ -129,7 +129,7 @@ struct _PaddleMobile__Framework__Proto__Version { ...@@ -129,7 +129,7 @@ struct _PaddleMobile__Framework__Proto__Version {
} }
struct _PaddleMobile__Framework__Proto__OpDesc__Attr { struct _PaddleMobile__Framework__Proto__OpDesc__Attr {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
char *name; char *name;
PaddleMobile__Framework__Proto__AttrType type; PaddleMobile__Framework__Proto__AttrType type;
protobuf_c_boolean has_i; protobuf_c_boolean has_i;
...@@ -165,7 +165,7 @@ struct _PaddleMobile__Framework__Proto__OpDesc__Attr { ...@@ -165,7 +165,7 @@ struct _PaddleMobile__Framework__Proto__OpDesc__Attr {
} }
struct _PaddleMobile__Framework__Proto__OpDesc__Var { struct _PaddleMobile__Framework__Proto__OpDesc__Var {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
char *parameter; char *parameter;
size_t n_arguments; size_t n_arguments;
char **arguments; char **arguments;
...@@ -182,7 +182,7 @@ struct _PaddleMobile__Framework__Proto__OpDesc__Var { ...@@ -182,7 +182,7 @@ struct _PaddleMobile__Framework__Proto__OpDesc__Var {
* derived class type. * derived class type.
*/ */
struct _PaddleMobile__Framework__Proto__OpDesc { struct _PaddleMobile__Framework__Proto__OpDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
char *type; char *type;
size_t n_inputs; size_t n_inputs;
PaddleMobile__Framework__Proto__OpDesc__Var **inputs; PaddleMobile__Framework__Proto__OpDesc__Var **inputs;
...@@ -204,7 +204,7 @@ struct _PaddleMobile__Framework__Proto__OpDesc { ...@@ -204,7 +204,7 @@ struct _PaddleMobile__Framework__Proto__OpDesc {
* VarProto describes the C++ type framework::Variable. * VarProto describes the C++ type framework::Variable.
*/ */
struct _PaddleMobile__Framework__Proto__OpProto__Var { struct _PaddleMobile__Framework__Proto__OpProto__Var {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
char *name; char *name;
char *comment; char *comment;
protobuf_c_boolean has_duplicable; protobuf_c_boolean has_duplicable;
...@@ -226,7 +226,7 @@ struct _PaddleMobile__Framework__Proto__OpProto__Var { ...@@ -226,7 +226,7 @@ struct _PaddleMobile__Framework__Proto__OpProto__Var {
* AttrProto describes the C++ type Attribute. * AttrProto describes the C++ type Attribute.
*/ */
struct _PaddleMobile__Framework__Proto__OpProto__Attr { struct _PaddleMobile__Framework__Proto__OpProto__Attr {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
char *name; char *name;
PaddleMobile__Framework__Proto__AttrType type; PaddleMobile__Framework__Proto__AttrType type;
char *comment; char *comment;
...@@ -249,7 +249,7 @@ struct _PaddleMobile__Framework__Proto__OpProto__Attr { ...@@ -249,7 +249,7 @@ struct _PaddleMobile__Framework__Proto__OpProto__Attr {
* OpProto describes a C++ framework::OperatorBase derived class. * OpProto describes a C++ framework::OperatorBase derived class.
*/ */
struct _PaddleMobile__Framework__Proto__OpProto { struct _PaddleMobile__Framework__Proto__OpProto {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
char *type; char *type;
size_t n_inputs; size_t n_inputs;
PaddleMobile__Framework__Proto__OpProto__Var **inputs; PaddleMobile__Framework__Proto__OpProto__Var **inputs;
...@@ -267,7 +267,7 @@ struct _PaddleMobile__Framework__Proto__OpProto { ...@@ -267,7 +267,7 @@ struct _PaddleMobile__Framework__Proto__OpProto {
} }
struct _PaddleMobile__Framework__Proto__VarType__TensorDesc { struct _PaddleMobile__Framework__Proto__VarType__TensorDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
/* /*
* Should only be PODType. Is enforced in C++ * Should only be PODType. Is enforced in C++
*/ */
...@@ -286,7 +286,7 @@ struct _PaddleMobile__Framework__Proto__VarType__TensorDesc { ...@@ -286,7 +286,7 @@ struct _PaddleMobile__Framework__Proto__VarType__TensorDesc {
} }
struct _PaddleMobile__Framework__Proto__VarType__LoDTensorDesc { struct _PaddleMobile__Framework__Proto__VarType__LoDTensorDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor; PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor;
protobuf_c_boolean has_lod_level; protobuf_c_boolean has_lod_level;
int32_t lod_level; int32_t lod_level;
...@@ -299,7 +299,7 @@ struct _PaddleMobile__Framework__Proto__VarType__LoDTensorDesc { ...@@ -299,7 +299,7 @@ struct _PaddleMobile__Framework__Proto__VarType__LoDTensorDesc {
} }
struct _PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc { struct _PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor; PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor;
protobuf_c_boolean has_lod_level; protobuf_c_boolean has_lod_level;
int32_t lod_level; int32_t lod_level;
...@@ -312,7 +312,7 @@ struct _PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc { ...@@ -312,7 +312,7 @@ struct _PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc {
} }
struct _PaddleMobile__Framework__Proto__VarType__ReaderDesc { struct _PaddleMobile__Framework__Proto__VarType__ReaderDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
size_t n_lod_tensor; size_t n_lod_tensor;
PaddleMobile__Framework__Proto__VarType__LoDTensorDesc **lod_tensor; PaddleMobile__Framework__Proto__VarType__LoDTensorDesc **lod_tensor;
}; };
...@@ -324,7 +324,7 @@ struct _PaddleMobile__Framework__Proto__VarType__ReaderDesc { ...@@ -324,7 +324,7 @@ struct _PaddleMobile__Framework__Proto__VarType__ReaderDesc {
} }
struct _PaddleMobile__Framework__Proto__VarType__ChannelDesc { struct _PaddleMobile__Framework__Proto__VarType__ChannelDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
PaddleMobile__Framework__Proto__VarType__Type data_type; PaddleMobile__Framework__Proto__VarType__Type data_type;
int64_t capacity; int64_t capacity;
}; };
...@@ -336,7 +336,7 @@ struct _PaddleMobile__Framework__Proto__VarType__ChannelDesc { ...@@ -336,7 +336,7 @@ struct _PaddleMobile__Framework__Proto__VarType__ChannelDesc {
} }
struct _PaddleMobile__Framework__Proto__VarType__Tuple { struct _PaddleMobile__Framework__Proto__VarType__Tuple {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
size_t n_element_type; size_t n_element_type;
PaddleMobile__Framework__Proto__VarType__Type *element_type; PaddleMobile__Framework__Proto__VarType__Type *element_type;
}; };
...@@ -348,7 +348,7 @@ struct _PaddleMobile__Framework__Proto__VarType__Tuple { ...@@ -348,7 +348,7 @@ struct _PaddleMobile__Framework__Proto__VarType__Tuple {
} }
struct _PaddleMobile__Framework__Proto__VarType { struct _PaddleMobile__Framework__Proto__VarType {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
PaddleMobile__Framework__Proto__VarType__Type type; PaddleMobile__Framework__Proto__VarType__Type type;
PaddleMobile__Framework__Proto__VarType__TensorDesc *selected_rows; PaddleMobile__Framework__Proto__VarType__TensorDesc *selected_rows;
PaddleMobile__Framework__Proto__VarType__LoDTensorDesc *lod_tensor; PaddleMobile__Framework__Proto__VarType__LoDTensorDesc *lod_tensor;
...@@ -366,7 +366,7 @@ struct _PaddleMobile__Framework__Proto__VarType { ...@@ -366,7 +366,7 @@ struct _PaddleMobile__Framework__Proto__VarType {
} }
struct _PaddleMobile__Framework__Proto__VarDesc { struct _PaddleMobile__Framework__Proto__VarDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
char *name; char *name;
PaddleMobile__Framework__Proto__VarType *type; PaddleMobile__Framework__Proto__VarType *type;
protobuf_c_boolean has_persistable; protobuf_c_boolean has_persistable;
...@@ -380,7 +380,7 @@ struct _PaddleMobile__Framework__Proto__VarDesc { ...@@ -380,7 +380,7 @@ struct _PaddleMobile__Framework__Proto__VarDesc {
} }
struct _PaddleMobile__Framework__Proto__BlockDesc { struct _PaddleMobile__Framework__Proto__BlockDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
int32_t idx; int32_t idx;
int32_t parent_idx; int32_t parent_idx;
size_t n_vars; size_t n_vars;
...@@ -405,7 +405,7 @@ struct _PaddleMobile__Framework__Proto__BlockDesc { ...@@ -405,7 +405,7 @@ struct _PaddleMobile__Framework__Proto__BlockDesc {
* way to distinguish them. Maybe ID or name? * way to distinguish them. Maybe ID or name?
*/ */
struct _PaddleMobile__Framework__Proto__ProgramDesc { struct _PaddleMobile__Framework__Proto__ProgramDesc {
ProtobufCMessage base; PaddleMobile__Framework__ProtobufCMessage base;
size_t n_blocks; size_t n_blocks;
PaddleMobile__Framework__Proto__BlockDesc **blocks; PaddleMobile__Framework__Proto__BlockDesc **blocks;
PaddleMobile__Framework__Proto__Version *version; PaddleMobile__Framework__Proto__Version *version;
...@@ -421,12 +421,12 @@ struct _PaddleMobile__Framework__Proto__ProgramDesc { ...@@ -421,12 +421,12 @@ struct _PaddleMobile__Framework__Proto__ProgramDesc {
void paddle_mobile__framework__proto__version__init( void paddle_mobile__framework__proto__version__init(
PaddleMobile__Framework__Proto__Version *message); PaddleMobile__Framework__Proto__Version *message);
PaddleMobile__Framework__Proto__Version * PaddleMobile__Framework__Proto__Version *
paddle_mobile__framework__proto__version__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__version__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data); const uint8_t *data);
void paddle_mobile__framework__proto__version__free_unpacked( void paddle_mobile__framework__proto__version__free_unpacked(
PaddleMobile__Framework__Proto__Version *message, PaddleMobile__Framework__Proto__Version *message,
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__OpDesc__Attr methods */ /* PaddleMobile__Framework__Proto__OpDesc__Attr methods */
void paddle_mobile__framework__proto__op_desc__attr__init( void paddle_mobile__framework__proto__op_desc__attr__init(
PaddleMobile__Framework__Proto__OpDesc__Attr *message); PaddleMobile__Framework__Proto__OpDesc__Attr *message);
...@@ -437,12 +437,12 @@ void paddle_mobile__framework__proto__op_desc__var__init( ...@@ -437,12 +437,12 @@ void paddle_mobile__framework__proto__op_desc__var__init(
void paddle_mobile__framework__proto__op_desc__init( void paddle_mobile__framework__proto__op_desc__init(
PaddleMobile__Framework__Proto__OpDesc *message); PaddleMobile__Framework__Proto__OpDesc *message);
PaddleMobile__Framework__Proto__OpDesc * PaddleMobile__Framework__Proto__OpDesc *
paddle_mobile__framework__proto__op_desc__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__op_desc__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data); const uint8_t *data);
void paddle_mobile__framework__proto__op_desc__free_unpacked( void paddle_mobile__framework__proto__op_desc__free_unpacked(
PaddleMobile__Framework__Proto__OpDesc *message, PaddleMobile__Framework__Proto__OpDesc *message,
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__OpProto__Var methods */ /* PaddleMobile__Framework__Proto__OpProto__Var methods */
void paddle_mobile__framework__proto__op_proto__var__init( void paddle_mobile__framework__proto__op_proto__var__init(
PaddleMobile__Framework__Proto__OpProto__Var *message); PaddleMobile__Framework__Proto__OpProto__Var *message);
...@@ -453,12 +453,12 @@ void paddle_mobile__framework__proto__op_proto__attr__init( ...@@ -453,12 +453,12 @@ void paddle_mobile__framework__proto__op_proto__attr__init(
void paddle_mobile__framework__proto__op_proto__init( void paddle_mobile__framework__proto__op_proto__init(
PaddleMobile__Framework__Proto__OpProto *message); PaddleMobile__Framework__Proto__OpProto *message);
PaddleMobile__Framework__Proto__OpProto * PaddleMobile__Framework__Proto__OpProto *
paddle_mobile__framework__proto__op_proto__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__op_proto__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data); const uint8_t *data);
void paddle_mobile__framework__proto__op_proto__free_unpacked( void paddle_mobile__framework__proto__op_proto__free_unpacked(
PaddleMobile__Framework__Proto__OpProto *message, PaddleMobile__Framework__Proto__OpProto *message,
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__VarType__TensorDesc methods */ /* PaddleMobile__Framework__Proto__VarType__TensorDesc methods */
void paddle_mobile__framework__proto__var_type__tensor_desc__init( void paddle_mobile__framework__proto__var_type__tensor_desc__init(
PaddleMobile__Framework__Proto__VarType__TensorDesc *message); PaddleMobile__Framework__Proto__VarType__TensorDesc *message);
...@@ -481,40 +481,42 @@ void paddle_mobile__framework__proto__var_type__tuple__init( ...@@ -481,40 +481,42 @@ void paddle_mobile__framework__proto__var_type__tuple__init(
void paddle_mobile__framework__proto__var_type__init( void paddle_mobile__framework__proto__var_type__init(
PaddleMobile__Framework__Proto__VarType *message); PaddleMobile__Framework__Proto__VarType *message);
PaddleMobile__Framework__Proto__VarType * PaddleMobile__Framework__Proto__VarType *
paddle_mobile__framework__proto__var_type__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__var_type__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data); const uint8_t *data);
void paddle_mobile__framework__proto__var_type__free_unpacked( void paddle_mobile__framework__proto__var_type__free_unpacked(
PaddleMobile__Framework__Proto__VarType *message, PaddleMobile__Framework__Proto__VarType *message,
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__VarDesc methods */ /* PaddleMobile__Framework__Proto__VarDesc methods */
void paddle_mobile__framework__proto__var_desc__init( void paddle_mobile__framework__proto__var_desc__init(
PaddleMobile__Framework__Proto__VarDesc *message); PaddleMobile__Framework__Proto__VarDesc *message);
PaddleMobile__Framework__Proto__VarDesc * PaddleMobile__Framework__Proto__VarDesc *
paddle_mobile__framework__proto__var_desc__unpack(ProtobufCAllocator *allocator, paddle_mobile__framework__proto__var_desc__unpack(
size_t len, PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data); const uint8_t *data);
void paddle_mobile__framework__proto__var_desc__free_unpacked( void paddle_mobile__framework__proto__var_desc__free_unpacked(
PaddleMobile__Framework__Proto__VarDesc *message, PaddleMobile__Framework__Proto__VarDesc *message,
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__BlockDesc methods */ /* PaddleMobile__Framework__Proto__BlockDesc methods */
void paddle_mobile__framework__proto__block_desc__init( void paddle_mobile__framework__proto__block_desc__init(
PaddleMobile__Framework__Proto__BlockDesc *message); PaddleMobile__Framework__Proto__BlockDesc *message);
PaddleMobile__Framework__Proto__BlockDesc * PaddleMobile__Framework__Proto__BlockDesc *
paddle_mobile__framework__proto__block_desc__unpack( paddle_mobile__framework__proto__block_desc__unpack(
ProtobufCAllocator *allocator, size_t len, const uint8_t *data); PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data);
void paddle_mobile__framework__proto__block_desc__free_unpacked( void paddle_mobile__framework__proto__block_desc__free_unpacked(
PaddleMobile__Framework__Proto__BlockDesc *message, PaddleMobile__Framework__Proto__BlockDesc *message,
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__ProgramDesc methods */ /* PaddleMobile__Framework__Proto__ProgramDesc methods */
void paddle_mobile__framework__proto__program_desc__init( void paddle_mobile__framework__proto__program_desc__init(
PaddleMobile__Framework__Proto__ProgramDesc *message); PaddleMobile__Framework__Proto__ProgramDesc *message);
PaddleMobile__Framework__Proto__ProgramDesc * PaddleMobile__Framework__Proto__ProgramDesc *
paddle_mobile__framework__proto__program_desc__unpack( paddle_mobile__framework__proto__program_desc__unpack(
ProtobufCAllocator *allocator, size_t len, const uint8_t *data); PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data);
void paddle_mobile__framework__proto__program_desc__free_unpacked( void paddle_mobile__framework__proto__program_desc__free_unpacked(
PaddleMobile__Framework__Proto__ProgramDesc *message, PaddleMobile__Framework__Proto__ProgramDesc *message,
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCAllocator *allocator);
/* --- per-message closures --- */ /* --- per-message closures --- */
typedef void (*PaddleMobile__Framework__Proto__Version_Closure)( typedef void (*PaddleMobile__Framework__Proto__Version_Closure)(
...@@ -569,43 +571,43 @@ typedef void (*PaddleMobile__Framework__Proto__ProgramDesc_Closure)( ...@@ -569,43 +571,43 @@ typedef void (*PaddleMobile__Framework__Proto__ProgramDesc_Closure)(
/* --- descriptors --- */ /* --- descriptors --- */
extern const ProtobufCEnumDescriptor extern const PaddleMobile__Framework__ProtobufCEnumDescriptor
paddle_mobile__framework__proto__attr_type__descriptor; paddle_mobile__framework__proto__attr_type__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__version__descriptor; paddle_mobile__framework__proto__version__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__descriptor; paddle_mobile__framework__proto__op_desc__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__attr__descriptor; paddle_mobile__framework__proto__op_desc__attr__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__var__descriptor; paddle_mobile__framework__proto__op_desc__var__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__descriptor; paddle_mobile__framework__proto__op_proto__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__var__descriptor; paddle_mobile__framework__proto__op_proto__var__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__attr__descriptor; paddle_mobile__framework__proto__op_proto__attr__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__descriptor; paddle_mobile__framework__proto__var_type__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__tensor_desc__descriptor; paddle_mobile__framework__proto__var_type__tensor_desc__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor; paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor; paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__reader_desc__descriptor; paddle_mobile__framework__proto__var_type__reader_desc__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__channel_desc__descriptor; paddle_mobile__framework__proto__var_type__channel_desc__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__tuple__descriptor; paddle_mobile__framework__proto__var_type__tuple__descriptor;
extern const ProtobufCEnumDescriptor extern const PaddleMobile__Framework__ProtobufCEnumDescriptor
paddle_mobile__framework__proto__var_type__type__descriptor; paddle_mobile__framework__proto__var_type__type__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_desc__descriptor; paddle_mobile__framework__proto__var_desc__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__block_desc__descriptor; paddle_mobile__framework__proto__block_desc__descriptor;
extern const ProtobufCMessageDescriptor extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
paddle_mobile__framework__proto__program_desc__descriptor; paddle_mobile__framework__proto__program_desc__descriptor;
PROTOBUF_C__END_DECLS PROTOBUF_C__END_DECLS
......
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
/** /**
* \todo 64-BIT OPTIMIZATION: certain implementations use 32-bit math * \todo 64-BIT OPTIMIZATION: certain implementations use 32-bit math
* even on 64-bit platforms (uint64_size, uint64_pack, parse_uint64). * even on 64-bit platforms (uint64_size, PaddleMobile__Framework__uint64_pack,
* PaddleMobile__Framework__parse_uint64).
* *
* \todo Use size_t consistently. * \todo Use size_t consistently.
*/ */
...@@ -84,31 +85,33 @@ ...@@ -84,31 +85,33 @@
#define PROTOBUF_C_UNPACK_ERROR(...) #define PROTOBUF_C_UNPACK_ERROR(...)
#endif #endif
const char protobuf_c_empty_string[] = ""; const char PaddleMobile__Framework__protobuf_c_empty_string[] = "";
/** /**
* Internal `ProtobufCMessage` manipulation macro. * Internal `PaddleMobile__Framework__ProtobufCMessage` manipulation macro.
* *
* Base macro for manipulating a `ProtobufCMessage`. Used by STRUCT_MEMBER() and * Base macro for manipulating a `PaddleMobile__Framework__ProtobufCMessage`.
* STRUCT_MEMBER_PTR(). * Used by STRUCT_MEMBER() and STRUCT_MEMBER_PTR().
*/ */
#define STRUCT_MEMBER_P(struct_p, struct_offset) \ #define STRUCT_MEMBER_P(struct_p, struct_offset) \
((void *)((uint8_t *)(struct_p) + (struct_offset))) ((void *)((uint8_t *)(struct_p) + (struct_offset)))
/** /**
* Return field in a `ProtobufCMessage` based on offset. * Return field in a `PaddleMobile__Framework__ProtobufCMessage` based on
* offset.
* *
* Take a pointer to a `ProtobufCMessage` and find the field at the offset. * Take a pointer to a `PaddleMobile__Framework__ProtobufCMessage` and find the
* Cast it to the passed type. * field at the offset. Cast it to the passed type.
*/ */
#define STRUCT_MEMBER(member_type, struct_p, struct_offset) \ #define STRUCT_MEMBER(member_type, struct_p, struct_offset) \
(*(member_type *)STRUCT_MEMBER_P((struct_p), (struct_offset))) (*(member_type *)STRUCT_MEMBER_P((struct_p), (struct_offset)))
/** /**
* Return field in a `ProtobufCMessage` based on offset. * Return field in a `PaddleMobile__Framework__ProtobufCMessage` based on
* offset.
* *
* Take a pointer to a `ProtobufCMessage` and find the field at the offset. Cast * Take a pointer to a `PaddleMobile__Framework__ProtobufCMessage` and find the
* it to a pointer to the passed type. * field at the offset. Cast it to a pointer to the passed type.
*/ */
#define STRUCT_MEMBER_PTR(member_type, struct_p, struct_offset) \ #define STRUCT_MEMBER_PTR(member_type, struct_p, struct_offset) \
((member_type *)STRUCT_MEMBER_P((struct_p), (struct_offset))) ((member_type *)STRUCT_MEMBER_P((struct_p), (struct_offset)))
...@@ -131,56 +134,68 @@ const char protobuf_c_empty_string[] = ""; ...@@ -131,56 +134,68 @@ const char protobuf_c_empty_string[] = "";
/* --- version --- */ /* --- version --- */
const char *protobuf_c_version(void) { return PROTOBUF_C_VERSION; } const char *PaddleMobile__Framework__protobuf_c_version(void) {
return PROTOBUF_C_VERSION;
}
uint32_t protobuf_c_version_number(void) { return PROTOBUF_C_VERSION_NUMBER; } uint32_t PaddleMobile__Framework__protobuf_c_version_number(void) {
return PROTOBUF_C_VERSION_NUMBER;
}
/* --- allocator --- */ /* --- allocator --- */
static void *system_alloc(void *allocator_data, size_t size) { static void *PaddleMobile__Framework__system_alloc(void *allocator_data,
size_t size) {
return malloc(size); return malloc(size);
} }
static void system_free(void *allocator_data, void *data) { free(data); } static void PaddleMobile__Framework__system_free(void *allocator_data,
void *data) {
free(data);
}
static inline void *do_alloc(ProtobufCAllocator *allocator, size_t size) { static inline void *PaddleMobile__Framework__do_alloc(
PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t size) {
return allocator->alloc(allocator->allocator_data, size); return allocator->alloc(allocator->allocator_data, size);
} }
static inline void do_free(ProtobufCAllocator *allocator, void *data) { static inline void PaddleMobile__Framework__do_free(
PaddleMobile__Framework__ProtobufCAllocator *allocator, void *data) {
if (data != NULL) allocator->free(allocator->allocator_data, data); if (data != NULL) allocator->free(allocator->allocator_data, data);
} }
/* /*
* This allocator uses the system's malloc() and free(). It is the default * This allocator uses the system's malloc() and free(). It is the default
* allocator used if NULL is passed as the ProtobufCAllocator to an exported * allocator used if NULL is passed as the
* function. * PaddleMobile__Framework__ProtobufCAllocator to an exported function.
*/ */
static ProtobufCAllocator protobuf_c__allocator = { static PaddleMobile__Framework__ProtobufCAllocator protobuf_c__allocator = {
.alloc = &system_alloc, .alloc = &PaddleMobile__Framework__system_alloc,
.free = &system_free, .free = &PaddleMobile__Framework__system_free,
.allocator_data = NULL, .allocator_data = NULL,
}; };
/* === buffer-simple === */ /* === buffer-simple === */
void protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer, size_t len, void PaddleMobile__Framework__protobuf_c_buffer_simple_append(
PaddleMobile__Framework__ProtobufCBuffer *buffer, size_t len,
const uint8_t *data) { const uint8_t *data) {
ProtobufCBufferSimple *simp = (ProtobufCBufferSimple *)buffer; PaddleMobile__Framework__ProtobufCBufferSimple *simp =
(PaddleMobile__Framework__ProtobufCBufferSimple *)buffer;
size_t new_len = simp->len + len; size_t new_len = simp->len + len;
if (new_len > simp->alloced) { if (new_len > simp->alloced) {
ProtobufCAllocator *allocator = simp->allocator; PaddleMobile__Framework__ProtobufCAllocator *allocator = simp->allocator;
size_t new_alloced = simp->alloced * 2; size_t new_alloced = simp->alloced * 2;
uint8_t *new_data; uint8_t *new_data;
if (allocator == NULL) allocator = &protobuf_c__allocator; if (allocator == NULL) allocator = &protobuf_c__allocator;
while (new_alloced < new_len) new_alloced += new_alloced; while (new_alloced < new_len) new_alloced += new_alloced;
new_data = do_alloc(allocator, new_alloced); new_data = PaddleMobile__Framework__do_alloc(allocator, new_alloced);
if (!new_data) return; if (!new_data) return;
memcpy(new_data, simp->data, simp->len); memcpy(new_data, simp->data, simp->len);
if (simp->must_free_data) if (simp->must_free_data)
do_free(allocator, simp->data); PaddleMobile__Framework__do_free(allocator, simp->data);
else else
simp->must_free_data = TRUE; simp->must_free_data = TRUE;
simp->data = new_data; simp->data = new_data;
...@@ -191,9 +206,11 @@ void protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer, size_t len, ...@@ -191,9 +206,11 @@ void protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer, size_t len,
} }
/** /**
* \defgroup packedsz protobuf_c_message_get_packed_size() implementation * \defgroup packedsz
* PaddleMobile__Framework__protobuf_c_message_get_packed_size() implementation
* *
* Routines mainly used by protobuf_c_message_get_packed_size(). * Routines mainly used by
* PaddleMobile__Framework__protobuf_c_message_get_packed_size().
* *
* \ingroup internal * \ingroup internal
* @{ * @{
...@@ -366,8 +383,9 @@ static inline size_t sint64_size(int64_t v) { return uint64_size(zigzag64(v)); } ...@@ -366,8 +383,9 @@ static inline size_t sint64_size(int64_t v) { return uint64_size(zigzag64(v)); }
* \return * \return
* Number of bytes required. * Number of bytes required.
*/ */
static size_t required_field_get_packed_size( static size_t PaddleMobile__Framework__required_field_get_packed_size(
const ProtobufCFieldDescriptor *field, const void *member) { const PaddleMobile__Framework__ProtobufCFieldDescriptor *field,
const void *member) {
size_t rv = get_tag_size(field->id); size_t rv = get_tag_size(field->id);
switch (field->type) { switch (field->type) {
...@@ -401,12 +419,16 @@ static size_t required_field_get_packed_size( ...@@ -401,12 +419,16 @@ static size_t required_field_get_packed_size(
return rv + uint32_size(len) + len; return rv + uint32_size(len) + len;
} }
case PROTOBUF_C_TYPE_BYTES: { case PROTOBUF_C_TYPE_BYTES: {
size_t len = ((const ProtobufCBinaryData *)member)->len; size_t len =
((const PaddleMobile__Framework__ProtobufCBinaryData *)member)->len;
return rv + uint32_size(len) + len; return rv + uint32_size(len) + len;
} }
case PROTOBUF_C_TYPE_MESSAGE: { case PROTOBUF_C_TYPE_MESSAGE: {
const ProtobufCMessage *msg = *(ProtobufCMessage *const *)member; const PaddleMobile__Framework__ProtobufCMessage *msg =
size_t subrv = msg ? protobuf_c_message_get_packed_size(msg) : 0; *(PaddleMobile__Framework__ProtobufCMessage *const *)member;
size_t subrv =
msg ? PaddleMobile__Framework__protobuf_c_message_get_packed_size(msg)
: 0;
return rv + uint32_size(subrv) + subrv; return rv + uint32_size(subrv) + subrv;
} }
} }
...@@ -428,9 +450,9 @@ static size_t required_field_get_packed_size( ...@@ -428,9 +450,9 @@ static size_t required_field_get_packed_size(
* \return * \return
* Number of bytes required. * Number of bytes required.
*/ */
static size_t oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field, static size_t PaddleMobile__Framework__oneof_field_get_packed_size(
uint32_t oneof_case, const PaddleMobile__Framework__ProtobufCFieldDescriptor *field,
const void *member) { uint32_t oneof_case, const void *member) {
if (oneof_case != field->id) { if (oneof_case != field->id) {
return 0; return 0;
} }
...@@ -439,7 +461,7 @@ static size_t oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field, ...@@ -439,7 +461,7 @@ static size_t oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field,
const void *ptr = *(const void *const *)member; const void *ptr = *(const void *const *)member;
if (ptr == NULL || ptr == field->default_value) return 0; if (ptr == NULL || ptr == field->default_value) return 0;
} }
return required_field_get_packed_size(field, member); return PaddleMobile__Framework__required_field_get_packed_size(field, member);
} }
/** /**
...@@ -456,9 +478,9 @@ static size_t oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field, ...@@ -456,9 +478,9 @@ static size_t oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field,
* \return * \return
* Number of bytes required. * Number of bytes required.
*/ */
static size_t optional_field_get_packed_size( static size_t PaddleMobile__Framework__optional_field_get_packed_size(
const ProtobufCFieldDescriptor *field, const protobuf_c_boolean has, const PaddleMobile__Framework__ProtobufCFieldDescriptor *field,
const void *member) { const protobuf_c_boolean has, const void *member) {
if (field->type == PROTOBUF_C_TYPE_MESSAGE || if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING) { field->type == PROTOBUF_C_TYPE_STRING) {
const void *ptr = *(const void *const *)member; const void *ptr = *(const void *const *)member;
...@@ -466,11 +488,12 @@ static size_t optional_field_get_packed_size( ...@@ -466,11 +488,12 @@ static size_t optional_field_get_packed_size(
} else { } else {
if (!has) return 0; if (!has) return 0;
} }
return required_field_get_packed_size(field, member); return PaddleMobile__Framework__required_field_get_packed_size(field, member);
} }
static protobuf_c_boolean field_is_zeroish( static protobuf_c_boolean PaddleMobile__Framework__field_is_zeroish(
const ProtobufCFieldDescriptor *field, const void *member) { const PaddleMobile__Framework__ProtobufCFieldDescriptor *field,
const void *member) {
protobuf_c_boolean ret = FALSE; protobuf_c_boolean ret = FALSE;
switch (field->type) { switch (field->type) {
...@@ -527,10 +550,11 @@ static protobuf_c_boolean field_is_zeroish( ...@@ -527,10 +550,11 @@ static protobuf_c_boolean field_is_zeroish(
* \return * \return
* Number of bytes required. * Number of bytes required.
*/ */
static size_t unlabeled_field_get_packed_size( static size_t PaddleMobile__Framework__unlabeled_field_get_packed_size(
const ProtobufCFieldDescriptor *field, const void *member) { const PaddleMobile__Framework__ProtobufCFieldDescriptor *field,
if (field_is_zeroish(field, member)) return 0; const void *member) {
return required_field_get_packed_size(field, member); if (PaddleMobile__Framework__field_is_zeroish(field, member)) return 0;
return PaddleMobile__Framework__required_field_get_packed_size(field, member);
} }
/** /**
...@@ -547,8 +571,9 @@ static size_t unlabeled_field_get_packed_size( ...@@ -547,8 +571,9 @@ static size_t unlabeled_field_get_packed_size(
* \return * \return
* Number of bytes required. * Number of bytes required.
*/ */
static size_t repeated_field_get_packed_size( static size_t PaddleMobile__Framework__repeated_field_get_packed_size(
const ProtobufCFieldDescriptor *field, size_t count, const void *member) { const PaddleMobile__Framework__ProtobufCFieldDescriptor *field,
size_t count, const void *member) {
size_t header_size; size_t header_size;
size_t rv = 0; size_t rv = 0;
unsigned i; unsigned i;
...@@ -597,14 +622,16 @@ static size_t repeated_field_get_packed_size( ...@@ -597,14 +622,16 @@ static size_t repeated_field_get_packed_size(
break; break;
case PROTOBUF_C_TYPE_BYTES: case PROTOBUF_C_TYPE_BYTES:
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
size_t len = ((ProtobufCBinaryData *)array)[i].len; size_t len =
((PaddleMobile__Framework__ProtobufCBinaryData *)array)[i].len;
rv += uint32_size(len) + len; rv += uint32_size(len) + len;
} }
break; break;
case PROTOBUF_C_TYPE_MESSAGE: case PROTOBUF_C_TYPE_MESSAGE:
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
size_t len = size_t len =
protobuf_c_message_get_packed_size(((ProtobufCMessage **)array)[i]); PaddleMobile__Framework__protobuf_c_message_get_packed_size(
((PaddleMobile__Framework__ProtobufCMessage **)array)[i]);
rv += uint32_size(len) + len; rv += uint32_size(len) + len;
} }
break; break;
...@@ -625,8 +652,8 @@ static size_t repeated_field_get_packed_size( ...@@ -625,8 +652,8 @@ static size_t repeated_field_get_packed_size(
* \return * \return
* Number of bytes required. * Number of bytes required.
*/ */
static inline size_t unknown_field_get_packed_size( static inline size_t PaddleMobile__Framework__unknown_field_get_packed_size(
const ProtobufCMessageUnknownField *field) { const PaddleMobile__Framework__ProtobufCMessageUnknownField *field) {
return get_tag_size(field->tag) + field->len; return get_tag_size(field->tag) + field->len;
} }
...@@ -635,35 +662,40 @@ static inline size_t unknown_field_get_packed_size( ...@@ -635,35 +662,40 @@ static inline size_t unknown_field_get_packed_size(
/* /*
* Calculate the serialized size of the message. * Calculate the serialized size of the message.
*/ */
size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message) { size_t PaddleMobile__Framework__protobuf_c_message_get_packed_size(
const PaddleMobile__Framework__ProtobufCMessage *message) {
unsigned i; unsigned i;
size_t rv = 0; size_t rv = 0;
ASSERT_IS_MESSAGE(message); ASSERT_IS_MESSAGE(message);
for (i = 0; i < message->descriptor->n_fields; i++) { for (i = 0; i < message->descriptor->n_fields; i++) {
const ProtobufCFieldDescriptor *field = message->descriptor->fields + i; const PaddleMobile__Framework__ProtobufCFieldDescriptor *field =
message->descriptor->fields + i;
const void *member = ((const char *)message) + field->offset; const void *member = ((const char *)message) + field->offset;
const void *qmember = ((const char *)message) + field->quantifier_offset; const void *qmember = ((const char *)message) + field->quantifier_offset;
if (field->label == PROTOBUF_C_LABEL_REQUIRED) { if (field->label == PROTOBUF_C_LABEL_REQUIRED) {
rv += required_field_get_packed_size(field, member); rv += PaddleMobile__Framework__required_field_get_packed_size(field,
member);
} else if ((field->label == PROTOBUF_C_LABEL_OPTIONAL || } else if ((field->label == PROTOBUF_C_LABEL_OPTIONAL ||
field->label == PROTOBUF_C_LABEL_NONE) && field->label == PROTOBUF_C_LABEL_NONE) &&
(0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF))) { (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF))) {
rv += oneof_field_get_packed_size(field, *(const uint32_t *)qmember, rv += PaddleMobile__Framework__oneof_field_get_packed_size(
member); field, *(const uint32_t *)qmember, member);
} else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) { } else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) {
rv += optional_field_get_packed_size( rv += PaddleMobile__Framework__optional_field_get_packed_size(
field, *(protobuf_c_boolean *)qmember, member); field, *(protobuf_c_boolean *)qmember, member);
} else if (field->label == PROTOBUF_C_LABEL_NONE) { } else if (field->label == PROTOBUF_C_LABEL_NONE) {
rv += unlabeled_field_get_packed_size(field, member); rv += PaddleMobile__Framework__unlabeled_field_get_packed_size(field,
} else {
rv += repeated_field_get_packed_size(field, *(const size_t *)qmember,
member); member);
} else {
rv += PaddleMobile__Framework__repeated_field_get_packed_size(
field, *(const size_t *)qmember, member);
} }
} }
for (i = 0; i < message->n_unknown_fields; i++) for (i = 0; i < message->n_unknown_fields; i++)
rv += unknown_field_get_packed_size(&message->unknown_fields[i]); rv += PaddleMobile__Framework__unknown_field_get_packed_size(
&message->unknown_fields[i]);
return rv; return rv;
} }
...@@ -687,7 +719,8 @@ size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message) { ...@@ -687,7 +719,8 @@ size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message) {
* \return * \return
* Number of bytes written to `out`. * Number of bytes written to `out`.
*/ */
static inline size_t uint32_pack(uint32_t value, uint8_t *out) { static inline size_t PaddleMobile__Framework__uint32_pack(uint32_t value,
uint8_t *out) {
unsigned rv = 0; unsigned rv = 0;
if (value >= 0x80) { if (value >= 0x80) {
...@@ -722,12 +755,13 @@ static inline size_t uint32_pack(uint32_t value, uint8_t *out) { ...@@ -722,12 +755,13 @@ static inline size_t uint32_pack(uint32_t value, uint8_t *out) {
* \return * \return
* Number of bytes written to `out`. * Number of bytes written to `out`.
*/ */
static size_t uint64_pack(uint64_t value, uint8_t *out) { static size_t PaddleMobile__Framework__uint64_pack(uint64_t value,
uint8_t *out) {
uint32_t hi = (uint32_t)(value >> 32); uint32_t hi = (uint32_t)(value >> 32);
uint32_t lo = (uint32_t)value; uint32_t lo = (uint32_t)value;
unsigned rv; unsigned rv;
if (hi == 0) return uint32_pack((uint32_t)lo, out); if (hi == 0) return PaddleMobile__Framework__uint32_pack((uint32_t)lo, out);
out[0] = (lo) | 0x80; out[0] = (lo) | 0x80;
out[1] = (lo >> 7) | 0x80; out[1] = (lo >> 7) | 0x80;
out[2] = (lo >> 14) | 0x80; out[2] = (lo >> 14) | 0x80;
...@@ -749,20 +783,20 @@ static size_t uint64_pack(uint64_t value, uint8_t *out) { ...@@ -749,20 +783,20 @@ static size_t uint64_pack(uint64_t value, uint8_t *out) {
} }
/** /**
* Pack a ProtobufCBinaryData and return the number of bytes written. The output * Pack a PaddleMobile__Framework__ProtobufCBinaryData and return the number of
* includes a length delimiter. * bytes written. The output includes a length delimiter.
* *
* \param bd * \param bd
* ProtobufCBinaryData to encode. * PaddleMobile__Framework__ProtobufCBinaryData to encode.
* \param[out] out * \param[out] out
* Packed value. * Packed value.
* \return * \return
* Number of bytes written to `out`. * Number of bytes written to `out`.
*/ */
static inline size_t binary_data_pack(const ProtobufCBinaryData *bd, static inline size_t PaddleMobile__Framework__binary_data_pack(
uint8_t *out) { const PaddleMobile__Framework__ProtobufCBinaryData *bd, uint8_t *out) {
size_t len = bd->len; size_t len = bd->len;
size_t rv = uint32_pack(len, out); size_t rv = PaddleMobile__Framework__uint32_pack(len, out);
memcpy(out + rv, bd->data, len); memcpy(out + rv, bd->data, len);
return rv + len; return rv + len;
} }
...@@ -772,7 +806,7 @@ static inline size_t binary_data_pack(const ProtobufCBinaryData *bd, ...@@ -772,7 +806,7 @@ static inline size_t binary_data_pack(const ProtobufCBinaryData *bd,
* *
* Wire-type will be added in required_field_pack(). * Wire-type will be added in required_field_pack().
* *
* \todo Just call uint64_pack on 64-bit platforms. * \todo Just call PaddleMobile__Framework__uint64_pack on 64-bit platforms.
* *
* \param id * \param id
* Tag value to encode. * Tag value to encode.
...@@ -781,11 +815,11 @@ static inline size_t binary_data_pack(const ProtobufCBinaryData *bd, ...@@ -781,11 +815,11 @@ static inline size_t binary_data_pack(const ProtobufCBinaryData *bd,
* \return * \return
* Number of bytes written to `out`. * Number of bytes written to `out`.
*/ */
static size_t tag_pack(uint32_t id, uint8_t *out) { static size_t PaddleMobile__Framework__tag_pack(uint32_t id, uint8_t *out) {
if (id < (1UL << (32 - 3))) if (id < (1UL << (32 - 3)))
return uint32_pack(id << 3, out); return PaddleMobile__Framework__uint32_pack(id << 3, out);
else else
return uint64_pack(((uint64_t)id) << 3, out); return PaddleMobile__Framework__uint64_pack(((uint64_t)id) << 3, out);
} }
/** /**
...@@ -798,7 +832,8 @@ static size_t tag_pack(uint32_t id, uint8_t *out) { ...@@ -798,7 +832,8 @@ static size_t tag_pack(uint32_t id, uint8_t *out) {
* \return * \return
* Size of the field. * Size of the field.
*/ */
static inline size_t sizeof_elt_in_repeated_array(ProtobufCType type) { static inline size_t PaddleMobile__Framework__sizeof_elt_in_repeated_array(
PaddleMobile__Framework__ProtobufCType type) {
switch (type) { switch (type) {
case PROTOBUF_C_TYPE_SINT32: case PROTOBUF_C_TYPE_SINT32:
case PROTOBUF_C_TYPE_INT32: case PROTOBUF_C_TYPE_INT32:
...@@ -821,14 +856,15 @@ static inline size_t sizeof_elt_in_repeated_array(ProtobufCType type) { ...@@ -821,14 +856,15 @@ static inline size_t sizeof_elt_in_repeated_array(ProtobufCType type) {
case PROTOBUF_C_TYPE_MESSAGE: case PROTOBUF_C_TYPE_MESSAGE:
return sizeof(void *); return sizeof(void *);
case PROTOBUF_C_TYPE_BYTES: case PROTOBUF_C_TYPE_BYTES:
return sizeof(ProtobufCBinaryData); return sizeof(PaddleMobile__Framework__ProtobufCBinaryData);
} }
PROTOBUF_C__ASSERT_NOT_REACHED(); PROTOBUF_C__ASSERT_NOT_REACHED();
return 0; return 0;
} }
static inline int int_range_lookup(unsigned n_ranges, static inline int PaddleMobile__Framework__int_range_lookup(
const ProtobufCIntRange *ranges, int value) { unsigned n_ranges, const PaddleMobile__Framework__ProtobufCIntRange *ranges,
int value) {
unsigned n; unsigned n;
unsigned start; unsigned start;
...@@ -861,9 +897,9 @@ static inline int int_range_lookup(unsigned n_ranges, ...@@ -861,9 +897,9 @@ static inline int int_range_lookup(unsigned n_ranges,
return -1; return -1;
} }
static size_t parse_tag_and_wiretype(size_t len, const uint8_t *data, static size_t PaddleMobile__Framework__parse_tag_and_wiretype(
uint32_t *tag_out, size_t len, const uint8_t *data, uint32_t *tag_out,
ProtobufCWireType *wiretype_out) { PaddleMobile__Framework__ProtobufCWireType *wiretype_out) {
unsigned max_rv = len > 5 ? 5 : len; unsigned max_rv = len > 5 ? 5 : len;
uint32_t tag = (data[0] & 0x7f) >> 3; uint32_t tag = (data[0] & 0x7f) >> 3;
unsigned shift = 4; unsigned shift = 4;
...@@ -889,20 +925,20 @@ static size_t parse_tag_and_wiretype(size_t len, const uint8_t *data, ...@@ -889,20 +925,20 @@ static size_t parse_tag_and_wiretype(size_t len, const uint8_t *data,
/* sizeof(ScannedMember) must be <= (1UL<<BOUND_SIZEOF_SCANNED_MEMBER_LOG2) */ /* sizeof(ScannedMember) must be <= (1UL<<BOUND_SIZEOF_SCANNED_MEMBER_LOG2) */
#define BOUND_SIZEOF_SCANNED_MEMBER_LOG2 5 #define BOUND_SIZEOF_SCANNED_MEMBER_LOG2 5
typedef struct _ScannedMember ScannedMember; typedef struct PaddleMobile__Framework___ScannedMember ScannedMember;
/** Field as it's being read. */ /** Field as it's being read. */
struct _ScannedMember { struct PaddleMobile__Framework___ScannedMember {
uint32_t tag; /**< Field tag. */ uint32_t tag; /**< Field tag. */
uint8_t wire_type; /**< Field type. */ uint8_t wire_type; /**< Field type. */
uint8_t length_prefix_len; /**< Prefix length. */ uint8_t length_prefix_len; /**< Prefix length. */
const ProtobufCFieldDescriptor *field; /**< Field descriptor. */ const PaddleMobile__Framework__ProtobufCFieldDescriptor
*field; /**< Field descriptor. */
size_t len; /**< Field length. */ size_t len; /**< Field length. */
const uint8_t *data; /**< Pointer to field data. */ const uint8_t *data; /**< Pointer to field data. */
}; };
static inline uint32_t scan_length_prefixed_data(size_t len, static inline uint32_t PaddleMobile__Framework__scan_length_prefixed_data(
const uint8_t *data, size_t len, const uint8_t *data, size_t *prefix_len_out) {
size_t *prefix_len_out) {
unsigned hdr_max = len < 5 ? len : 5; unsigned hdr_max = len < 5 ? len : 5;
unsigned hdr_len; unsigned hdr_len;
uint32_t val = 0; uint32_t val = 0;
...@@ -927,7 +963,8 @@ static inline uint32_t scan_length_prefixed_data(size_t len, ...@@ -927,7 +963,8 @@ static inline uint32_t scan_length_prefixed_data(size_t len,
return hdr_len + val; return hdr_len + val;
} }
static size_t max_b128_numbers(size_t len, const uint8_t *data) { static size_t PaddleMobile__Framework__max_b128_numbers(size_t len,
const uint8_t *data) {
size_t rv = 0; size_t rv = 0;
while (len--) while (len--)
if ((*data++ & 0x80) == 0) ++rv; if ((*data++ & 0x80) == 0) ++rv;
...@@ -950,11 +987,13 @@ static size_t max_b128_numbers(size_t len, const uint8_t *data) { ...@@ -950,11 +987,13 @@ static size_t max_b128_numbers(size_t len, const uint8_t *data) {
* some of its fields may have been reused and changed to their default * some of its fields may have been reused and changed to their default
* values during the merge. * values during the merge.
*/ */
static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg, static protobuf_c_boolean PaddleMobile__Framework__merge_messages(
ProtobufCMessage *latter_msg, PaddleMobile__Framework__ProtobufCMessage *earlier_msg,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCMessage *latter_msg,
PaddleMobile__Framework__ProtobufCAllocator *allocator) {
unsigned i; unsigned i;
const ProtobufCFieldDescriptor *fields = latter_msg->descriptor->fields; const PaddleMobile__Framework__ProtobufCFieldDescriptor *fields =
latter_msg->descriptor->fields;
for (i = 0; i < latter_msg->descriptor->n_fields; i++) { for (i = 0; i < latter_msg->descriptor->n_fields; i++) {
if (fields[i].label == PROTOBUF_C_LABEL_REPEATED) { if (fields[i].label == PROTOBUF_C_LABEL_REPEATED) {
size_t *n_earlier = size_t *n_earlier =
...@@ -969,18 +1008,21 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg, ...@@ -969,18 +1008,21 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg,
if (*n_earlier > 0) { if (*n_earlier > 0) {
if (*n_latter > 0) { if (*n_latter > 0) {
/* Concatenate the repeated field */ /* Concatenate the repeated field */
size_t el_size = sizeof_elt_in_repeated_array(fields[i].type); size_t el_size =
PaddleMobile__Framework__sizeof_elt_in_repeated_array(
fields[i].type);
uint8_t *new_field; uint8_t *new_field;
new_field = do_alloc(allocator, (*n_earlier + *n_latter) * el_size); new_field = PaddleMobile__Framework__do_alloc(
allocator, (*n_earlier + *n_latter) * el_size);
if (!new_field) return FALSE; if (!new_field) return FALSE;
memcpy(new_field, *p_earlier, *n_earlier * el_size); memcpy(new_field, *p_earlier, *n_earlier * el_size);
memcpy(new_field + *n_earlier * el_size, *p_latter, memcpy(new_field + *n_earlier * el_size, *p_latter,
*n_latter * el_size); *n_latter * el_size);
do_free(allocator, *p_latter); PaddleMobile__Framework__do_free(allocator, *p_latter);
do_free(allocator, *p_earlier); PaddleMobile__Framework__do_free(allocator, *p_earlier);
*p_latter = new_field; *p_latter = new_field;
*n_latter = *n_earlier + *n_latter; *n_latter = *n_earlier + *n_latter;
} else { } else {
...@@ -994,7 +1036,7 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg, ...@@ -994,7 +1036,7 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg,
} }
} else if (fields[i].label == PROTOBUF_C_LABEL_OPTIONAL || } else if (fields[i].label == PROTOBUF_C_LABEL_OPTIONAL ||
fields[i].label == PROTOBUF_C_LABEL_NONE) { fields[i].label == PROTOBUF_C_LABEL_NONE) {
const ProtobufCFieldDescriptor *field; const PaddleMobile__Framework__ProtobufCFieldDescriptor *field;
uint32_t *earlier_case_p = uint32_t *earlier_case_p =
STRUCT_MEMBER_PTR(uint32_t, earlier_msg, fields[i].quantifier_offset); STRUCT_MEMBER_PTR(uint32_t, earlier_msg, fields[i].quantifier_offset);
uint32_t *latter_case_p = uint32_t *latter_case_p =
...@@ -1007,7 +1049,7 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg, ...@@ -1007,7 +1049,7 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg,
if (fields[i].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) { if (fields[i].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) {
if (*latter_case_p == 0) { if (*latter_case_p == 0) {
/* lookup correct oneof field */ /* lookup correct oneof field */
int field_index = int_range_lookup( int field_index = PaddleMobile__Framework__int_range_lookup(
latter_msg->descriptor->n_field_ranges, latter_msg->descriptor->n_field_ranges,
latter_msg->descriptor->field_ranges, *earlier_case_p); latter_msg->descriptor->field_ranges, *earlier_case_p);
field = latter_msg->descriptor->fields + field_index; field = latter_msg->descriptor->fields + field_index;
...@@ -1025,11 +1067,14 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg, ...@@ -1025,11 +1067,14 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg,
switch (field->type) { switch (field->type) {
case PROTOBUF_C_TYPE_MESSAGE: { case PROTOBUF_C_TYPE_MESSAGE: {
ProtobufCMessage *em = *(ProtobufCMessage **)earlier_elem; PaddleMobile__Framework__ProtobufCMessage *em =
ProtobufCMessage *lm = *(ProtobufCMessage **)latter_elem; *(PaddleMobile__Framework__ProtobufCMessage **)earlier_elem;
PaddleMobile__Framework__ProtobufCMessage *lm =
*(PaddleMobile__Framework__ProtobufCMessage **)latter_elem;
if (em != NULL) { if (em != NULL) {
if (lm != NULL) { if (lm != NULL) {
if (!merge_messages(em, lm, allocator)) return FALSE; if (!PaddleMobile__Framework__merge_messages(em, lm, allocator))
return FALSE;
/* Already merged */ /* Already merged */
need_to_merge = FALSE; need_to_merge = FALSE;
} else { } else {
...@@ -1040,9 +1085,14 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg, ...@@ -1040,9 +1085,14 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg,
break; break;
} }
case PROTOBUF_C_TYPE_BYTES: { case PROTOBUF_C_TYPE_BYTES: {
uint8_t *e_data = ((ProtobufCBinaryData *)earlier_elem)->data; uint8_t *e_data =
uint8_t *l_data = ((ProtobufCBinaryData *)latter_elem)->data; ((PaddleMobile__Framework__ProtobufCBinaryData *)earlier_elem)
const ProtobufCBinaryData *d_bd = (ProtobufCBinaryData *)def_val; ->data;
uint8_t *l_data =
((PaddleMobile__Framework__ProtobufCBinaryData *)latter_elem)
->data;
const PaddleMobile__Framework__ProtobufCBinaryData *d_bd =
(PaddleMobile__Framework__ProtobufCBinaryData *)def_val;
need_to_merge = need_to_merge =
(e_data != NULL && (d_bd == NULL || e_data != d_bd->data)) && (e_data != NULL && (d_bd == NULL || e_data != d_bd->data)) &&
...@@ -1067,7 +1117,8 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg, ...@@ -1067,7 +1117,8 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg,
} }
if (need_to_merge) { if (need_to_merge) {
size_t el_size = sizeof_elt_in_repeated_array(field->type); size_t el_size =
PaddleMobile__Framework__sizeof_elt_in_repeated_array(field->type);
memcpy(latter_elem, earlier_elem, el_size); memcpy(latter_elem, earlier_elem, el_size);
/* /*
* Reset the element from the old message to 0 * Reset the element from the old message to 0
...@@ -1096,11 +1147,11 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg, ...@@ -1096,11 +1147,11 @@ static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg,
* Given a raw slab of packed-repeated values, determine the number of * Given a raw slab of packed-repeated values, determine the number of
* elements. This function detects certain kinds of errors but not * elements. This function detects certain kinds of errors but not
* others; the remaining error checking is done by * others; the remaining error checking is done by
* parse_packed_repeated_member(). * PaddleMobile__Framework__parse_packed_repeated_member().
*/ */
static protobuf_c_boolean count_packed_elements(ProtobufCType type, size_t len, static protobuf_c_boolean PaddleMobile__Framework__count_packed_elements(
const uint8_t *data, PaddleMobile__Framework__ProtobufCType type, size_t len,
size_t *count_out) { const uint8_t *data, size_t *count_out) {
switch (type) { switch (type) {
case PROTOBUF_C_TYPE_SFIXED32: case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32: case PROTOBUF_C_TYPE_FIXED32:
...@@ -1129,7 +1180,7 @@ static protobuf_c_boolean count_packed_elements(ProtobufCType type, size_t len, ...@@ -1129,7 +1180,7 @@ static protobuf_c_boolean count_packed_elements(ProtobufCType type, size_t len,
case PROTOBUF_C_TYPE_INT64: case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_SINT64: case PROTOBUF_C_TYPE_SINT64:
case PROTOBUF_C_TYPE_UINT64: case PROTOBUF_C_TYPE_UINT64:
*count_out = max_b128_numbers(len, data); *count_out = PaddleMobile__Framework__max_b128_numbers(len, data);
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_BOOL: case PROTOBUF_C_TYPE_BOOL:
*count_out = len; *count_out = len;
...@@ -1144,7 +1195,8 @@ static protobuf_c_boolean count_packed_elements(ProtobufCType type, size_t len, ...@@ -1144,7 +1195,8 @@ static protobuf_c_boolean count_packed_elements(ProtobufCType type, size_t len,
} }
} }
static inline uint32_t parse_uint32(unsigned len, const uint8_t *data) { static inline uint32_t PaddleMobile__Framework__parse_uint32(
unsigned len, const uint8_t *data) {
uint32_t rv = data[0] & 0x7f; uint32_t rv = data[0] & 0x7f;
if (len > 1) { if (len > 1) {
rv |= ((uint32_t)(data[1] & 0x7f) << 7); rv |= ((uint32_t)(data[1] & 0x7f) << 7);
...@@ -1159,8 +1211,9 @@ static inline uint32_t parse_uint32(unsigned len, const uint8_t *data) { ...@@ -1159,8 +1211,9 @@ static inline uint32_t parse_uint32(unsigned len, const uint8_t *data) {
return rv; return rv;
} }
static inline uint32_t parse_int32(unsigned len, const uint8_t *data) { static inline uint32_t PaddleMobile__Framework__parse_int32(
return parse_uint32(len, data); unsigned len, const uint8_t *data) {
return PaddleMobile__Framework__parse_uint32(len, data);
} }
static inline int32_t unzigzag32(uint32_t v) { static inline int32_t unzigzag32(uint32_t v) {
...@@ -1170,7 +1223,8 @@ static inline int32_t unzigzag32(uint32_t v) { ...@@ -1170,7 +1223,8 @@ static inline int32_t unzigzag32(uint32_t v) {
return v >> 1; return v >> 1;
} }
static inline uint32_t parse_fixed_uint32(const uint8_t *data) { static inline uint32_t PaddleMobile__Framework__parse_fixed_uint32(
const uint8_t *data) {
#if !defined(WORDS_BIGENDIAN) #if !defined(WORDS_BIGENDIAN)
uint32_t t; uint32_t t;
memcpy(&t, data, 4); memcpy(&t, data, 4);
...@@ -1181,11 +1235,12 @@ static inline uint32_t parse_fixed_uint32(const uint8_t *data) { ...@@ -1181,11 +1235,12 @@ static inline uint32_t parse_fixed_uint32(const uint8_t *data) {
#endif #endif
} }
static uint64_t parse_uint64(unsigned len, const uint8_t *data) { static uint64_t PaddleMobile__Framework__parse_uint64(unsigned len,
const uint8_t *data) {
unsigned shift, i; unsigned shift, i;
uint64_t rv; uint64_t rv;
if (len < 5) return parse_uint32(len, data); if (len < 5) return PaddleMobile__Framework__parse_uint32(len, data);
rv = ((uint64_t)(data[0] & 0x7f)) | ((uint64_t)(data[1] & 0x7f) << 7) | rv = ((uint64_t)(data[0] & 0x7f)) | ((uint64_t)(data[1] & 0x7f) << 7) |
((uint64_t)(data[2] & 0x7f) << 14) | ((uint64_t)(data[3] & 0x7f) << 21); ((uint64_t)(data[2] & 0x7f) << 14) | ((uint64_t)(data[3] & 0x7f) << 21);
shift = 28; shift = 28;
...@@ -1196,75 +1251,83 @@ static uint64_t parse_uint64(unsigned len, const uint8_t *data) { ...@@ -1196,75 +1251,83 @@ static uint64_t parse_uint64(unsigned len, const uint8_t *data) {
return rv; return rv;
} }
static inline int64_t unzigzag64(uint64_t v) { static inline int64_t PaddleMobile__Framework__unzigzag64(uint64_t v) {
if (v & 1) if (v & 1)
return -(v >> 1) - 1; return -(v >> 1) - 1;
else else
return v >> 1; return v >> 1;
} }
static inline uint64_t parse_fixed_uint64(const uint8_t *data) { static inline uint64_t PaddleMobile__Framework__parse_fixed_uint64(
const uint8_t *data) {
#if !defined(WORDS_BIGENDIAN) #if !defined(WORDS_BIGENDIAN)
uint64_t t; uint64_t t;
memcpy(&t, data, 8); memcpy(&t, data, 8);
return t; return t;
#else #else
return (uint64_t)parse_fixed_uint32(data) | return (uint64_t)PaddleMobile__Framework__parse_fixed_uint32(data) |
(((uint64_t)parse_fixed_uint32(data + 4)) << 32); (((uint64_t)PaddleMobile__Framework__parse_fixed_uint32(data + 4))
<< 32);
#endif #endif
} }
static protobuf_c_boolean parse_boolean(unsigned len, const uint8_t *data) { static protobuf_c_boolean PaddleMobile__Framework__parse_boolean(
unsigned len, const uint8_t *data) {
unsigned i; unsigned i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if (data[i] & 0x7f) return TRUE; if (data[i] & 0x7f) return TRUE;
return FALSE; return FALSE;
} }
static protobuf_c_boolean parse_required_member( static protobuf_c_boolean PaddleMobile__Framework__parse_required_member(
ScannedMember *scanned_member, void *member, ProtobufCAllocator *allocator, ScannedMember *scanned_member, void *member,
PaddleMobile__Framework__ProtobufCAllocator *allocator,
protobuf_c_boolean maybe_clear) { protobuf_c_boolean maybe_clear) {
unsigned len = scanned_member->len; unsigned len = scanned_member->len;
const uint8_t *data = scanned_member->data; const uint8_t *data = scanned_member->data;
ProtobufCWireType wire_type = scanned_member->wire_type; PaddleMobile__Framework__ProtobufCWireType wire_type =
scanned_member->wire_type;
switch (scanned_member->field->type) { switch (scanned_member->field->type) {
case PROTOBUF_C_TYPE_ENUM: case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32: case PROTOBUF_C_TYPE_INT32:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(int32_t *)member = parse_int32(len, data); *(int32_t *)member = PaddleMobile__Framework__parse_int32(len, data);
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_UINT32: case PROTOBUF_C_TYPE_UINT32:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(uint32_t *)member = parse_uint32(len, data); *(uint32_t *)member = PaddleMobile__Framework__parse_uint32(len, data);
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_SINT32: case PROTOBUF_C_TYPE_SINT32:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(int32_t *)member = unzigzag32(parse_uint32(len, data)); *(int32_t *)member =
unzigzag32(PaddleMobile__Framework__parse_uint32(len, data));
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_SFIXED32: case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32: case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_FLOAT: case PROTOBUF_C_TYPE_FLOAT:
if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT) return FALSE;
*(uint32_t *)member = parse_fixed_uint32(data); *(uint32_t *)member = PaddleMobile__Framework__parse_fixed_uint32(data);
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_INT64: case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64: case PROTOBUF_C_TYPE_UINT64:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(uint64_t *)member = parse_uint64(len, data); *(uint64_t *)member = PaddleMobile__Framework__parse_uint64(len, data);
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_SINT64: case PROTOBUF_C_TYPE_SINT64:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(int64_t *)member = unzigzag64(parse_uint64(len, data)); *(int64_t *)member = PaddleMobile__Framework__unzigzag64(
PaddleMobile__Framework__parse_uint64(len, data));
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_SFIXED64: case PROTOBUF_C_TYPE_SFIXED64:
case PROTOBUF_C_TYPE_FIXED64: case PROTOBUF_C_TYPE_FIXED64:
case PROTOBUF_C_TYPE_DOUBLE: case PROTOBUF_C_TYPE_DOUBLE:
if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT) return FALSE;
*(uint64_t *)member = parse_fixed_uint64(data); *(uint64_t *)member = PaddleMobile__Framework__parse_fixed_uint64(data);
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_BOOL: case PROTOBUF_C_TYPE_BOOL:
*(protobuf_c_boolean *)member = parse_boolean(len, data); *(protobuf_c_boolean *)member =
PaddleMobile__Framework__parse_boolean(len, data);
return TRUE; return TRUE;
case PROTOBUF_C_TYPE_STRING: { case PROTOBUF_C_TYPE_STRING: {
char **pstr = member; char **pstr = member;
...@@ -1274,17 +1337,18 @@ static protobuf_c_boolean parse_required_member( ...@@ -1274,17 +1337,18 @@ static protobuf_c_boolean parse_required_member(
if (maybe_clear && *pstr != NULL) { if (maybe_clear && *pstr != NULL) {
const char *def = scanned_member->field->default_value; const char *def = scanned_member->field->default_value;
if (*pstr != NULL && *pstr != def) do_free(allocator, *pstr); if (*pstr != NULL && *pstr != def)
PaddleMobile__Framework__do_free(allocator, *pstr);
} }
*pstr = do_alloc(allocator, len - pref_len + 1); *pstr = PaddleMobile__Framework__do_alloc(allocator, len - pref_len + 1);
if (*pstr == NULL) return FALSE; if (*pstr == NULL) return FALSE;
memcpy(*pstr, data + pref_len, len - pref_len); memcpy(*pstr, data + pref_len, len - pref_len);
(*pstr)[len - pref_len] = 0; (*pstr)[len - pref_len] = 0;
return TRUE; return TRUE;
} }
case PROTOBUF_C_TYPE_BYTES: { case PROTOBUF_C_TYPE_BYTES: {
ProtobufCBinaryData *bd = member; PaddleMobile__Framework__ProtobufCBinaryData *bd = member;
const ProtobufCBinaryData *def_bd; const PaddleMobile__Framework__ProtobufCBinaryData *def_bd;
unsigned pref_len = scanned_member->length_prefix_len; unsigned pref_len = scanned_member->length_prefix_len;
if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) return FALSE;
...@@ -1292,10 +1356,10 @@ static protobuf_c_boolean parse_required_member( ...@@ -1292,10 +1356,10 @@ static protobuf_c_boolean parse_required_member(
def_bd = scanned_member->field->default_value; def_bd = scanned_member->field->default_value;
if (maybe_clear && bd->data != NULL && if (maybe_clear && bd->data != NULL &&
(def_bd == NULL || bd->data != def_bd->data)) { (def_bd == NULL || bd->data != def_bd->data)) {
do_free(allocator, bd->data); PaddleMobile__Framework__do_free(allocator, bd->data);
} }
if (len - pref_len > 0) { if (len - pref_len > 0) {
bd->data = do_alloc(allocator, len - pref_len); bd->data = PaddleMobile__Framework__do_alloc(allocator, len - pref_len);
if (bd->data == NULL) return FALSE; if (bd->data == NULL) return FALSE;
memcpy(bd->data, data + pref_len, len - pref_len); memcpy(bd->data, data + pref_len, len - pref_len);
} else { } else {
...@@ -1305,24 +1369,26 @@ static protobuf_c_boolean parse_required_member( ...@@ -1305,24 +1369,26 @@ static protobuf_c_boolean parse_required_member(
return TRUE; return TRUE;
} }
case PROTOBUF_C_TYPE_MESSAGE: { case PROTOBUF_C_TYPE_MESSAGE: {
ProtobufCMessage **pmessage = member; PaddleMobile__Framework__ProtobufCMessage **pmessage = member;
ProtobufCMessage *subm; PaddleMobile__Framework__ProtobufCMessage *subm;
const ProtobufCMessage *def_mess; const PaddleMobile__Framework__ProtobufCMessage *def_mess;
protobuf_c_boolean merge_successful = TRUE; protobuf_c_boolean merge_successful = TRUE;
unsigned pref_len = scanned_member->length_prefix_len; unsigned pref_len = scanned_member->length_prefix_len;
if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) return FALSE; if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) return FALSE;
def_mess = scanned_member->field->default_value; def_mess = scanned_member->field->default_value;
subm = subm = PaddleMobile__Framework__protobuf_c_message_unpack(
protobuf_c_message_unpack(scanned_member->field->descriptor, scanned_member->field->descriptor, allocator, len - pref_len,
allocator, len - pref_len, data + pref_len); data + pref_len);
if (maybe_clear && *pmessage != NULL && *pmessage != def_mess) { if (maybe_clear && *pmessage != NULL && *pmessage != def_mess) {
if (subm != NULL) if (subm != NULL)
merge_successful = merge_messages(*pmessage, subm, allocator); merge_successful = PaddleMobile__Framework__merge_messages(
*pmessage, subm, allocator);
/* Delete the previous message */ /* Delete the previous message */
protobuf_c_message_free_unpacked(*pmessage, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(*pmessage,
allocator);
} }
*pmessage = subm; *pmessage = subm;
if (subm == NULL || !merge_successful) return FALSE; if (subm == NULL || !merge_successful) return FALSE;
...@@ -1332,43 +1398,48 @@ static protobuf_c_boolean parse_required_member( ...@@ -1332,43 +1398,48 @@ static protobuf_c_boolean parse_required_member(
return FALSE; return FALSE;
} }
static protobuf_c_boolean parse_oneof_member(ScannedMember *scanned_member, static protobuf_c_boolean PaddleMobile__Framework__parse_oneof_member(
void *member, ScannedMember *scanned_member, void *member,
ProtobufCMessage *message, PaddleMobile__Framework__ProtobufCMessage *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
uint32_t *oneof_case = STRUCT_MEMBER_PTR( uint32_t *oneof_case = STRUCT_MEMBER_PTR(
uint32_t, message, scanned_member->field->quantifier_offset); uint32_t, message, scanned_member->field->quantifier_offset);
/* If we have already parsed a member of this oneof, free it. */ /* If we have already parsed a member of this oneof, free it. */
if (*oneof_case != 0) { if (*oneof_case != 0) {
/* lookup field */ /* lookup field */
int field_index = int field_index = PaddleMobile__Framework__int_range_lookup(
int_range_lookup(message->descriptor->n_field_ranges, message->descriptor->n_field_ranges, message->descriptor->field_ranges,
message->descriptor->field_ranges, *oneof_case); *oneof_case);
const ProtobufCFieldDescriptor *old_field = const PaddleMobile__Framework__ProtobufCFieldDescriptor *old_field =
message->descriptor->fields + field_index; message->descriptor->fields + field_index;
size_t el_size = sizeof_elt_in_repeated_array(old_field->type); size_t el_size =
PaddleMobile__Framework__sizeof_elt_in_repeated_array(old_field->type);
switch (old_field->type) { switch (old_field->type) {
case PROTOBUF_C_TYPE_STRING: { case PROTOBUF_C_TYPE_STRING: {
char **pstr = member; char **pstr = member;
const char *def = old_field->default_value; const char *def = old_field->default_value;
if (*pstr != NULL && *pstr != def) do_free(allocator, *pstr); if (*pstr != NULL && *pstr != def)
PaddleMobile__Framework__do_free(allocator, *pstr);
break; break;
} }
case PROTOBUF_C_TYPE_BYTES: { case PROTOBUF_C_TYPE_BYTES: {
ProtobufCBinaryData *bd = member; PaddleMobile__Framework__ProtobufCBinaryData *bd = member;
const ProtobufCBinaryData *def_bd = old_field->default_value; const PaddleMobile__Framework__ProtobufCBinaryData *def_bd =
old_field->default_value;
if (bd->data != NULL && (def_bd == NULL || bd->data != def_bd->data)) { if (bd->data != NULL && (def_bd == NULL || bd->data != def_bd->data)) {
do_free(allocator, bd->data); PaddleMobile__Framework__do_free(allocator, bd->data);
} }
break; break;
} }
case PROTOBUF_C_TYPE_MESSAGE: { case PROTOBUF_C_TYPE_MESSAGE: {
ProtobufCMessage **pmessage = member; PaddleMobile__Framework__ProtobufCMessage **pmessage = member;
const ProtobufCMessage *def_mess = old_field->default_value; const PaddleMobile__Framework__ProtobufCMessage *def_mess =
old_field->default_value;
if (*pmessage != NULL && *pmessage != def_mess) if (*pmessage != NULL && *pmessage != def_mess)
protobuf_c_message_free_unpacked(*pmessage, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(*pmessage,
allocator);
break; break;
} }
default: default:
...@@ -1377,18 +1448,20 @@ static protobuf_c_boolean parse_oneof_member(ScannedMember *scanned_member, ...@@ -1377,18 +1448,20 @@ static protobuf_c_boolean parse_oneof_member(ScannedMember *scanned_member,
memset(member, 0, el_size); memset(member, 0, el_size);
} }
if (!parse_required_member(scanned_member, member, allocator, TRUE)) if (!PaddleMobile__Framework__parse_required_member(scanned_member, member,
allocator, TRUE))
return FALSE; return FALSE;
*oneof_case = scanned_member->tag; *oneof_case = scanned_member->tag;
return TRUE; return TRUE;
} }
static protobuf_c_boolean parse_optional_member(ScannedMember *scanned_member, static protobuf_c_boolean PaddleMobile__Framework__parse_optional_member(
void *member, ScannedMember *scanned_member, void *member,
ProtobufCMessage *message, PaddleMobile__Framework__ProtobufCMessage *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
if (!parse_required_member(scanned_member, member, allocator, TRUE)) if (!PaddleMobile__Framework__parse_required_member(scanned_member, member,
allocator, TRUE))
return FALSE; return FALSE;
if (scanned_member->field->quantifier_offset != 0) if (scanned_member->field->quantifier_offset != 0)
STRUCT_MEMBER(protobuf_c_boolean, message, STRUCT_MEMBER(protobuf_c_boolean, message,
...@@ -1396,24 +1469,27 @@ static protobuf_c_boolean parse_optional_member(ScannedMember *scanned_member, ...@@ -1396,24 +1469,27 @@ static protobuf_c_boolean parse_optional_member(ScannedMember *scanned_member,
return TRUE; return TRUE;
} }
static protobuf_c_boolean parse_repeated_member(ScannedMember *scanned_member, static protobuf_c_boolean PaddleMobile__Framework__parse_repeated_member(
void *member, ScannedMember *scanned_member, void *member,
ProtobufCMessage *message, PaddleMobile__Framework__ProtobufCMessage *message,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCAllocator *allocator) {
const ProtobufCFieldDescriptor *field = scanned_member->field; const PaddleMobile__Framework__ProtobufCFieldDescriptor *field =
scanned_member->field;
size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset);
size_t siz = sizeof_elt_in_repeated_array(field->type); size_t siz =
PaddleMobile__Framework__sizeof_elt_in_repeated_array(field->type);
char *array = *(char **)member; char *array = *(char **)member;
if (!parse_required_member(scanned_member, array + siz * (*p_n), allocator, if (!PaddleMobile__Framework__parse_required_member(
FALSE)) { scanned_member, array + siz * (*p_n), allocator, FALSE)) {
return FALSE; return FALSE;
} }
*p_n += 1; *p_n += 1;
return TRUE; return TRUE;
} }
static unsigned scan_varint(unsigned len, const uint8_t *data) { static unsigned PaddleMobile__Framework__scan_varint(unsigned len,
const uint8_t *data) {
unsigned i; unsigned i;
if (len > 10) len = 10; if (len > 10) len = 10;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
...@@ -1422,11 +1498,14 @@ static unsigned scan_varint(unsigned len, const uint8_t *data) { ...@@ -1422,11 +1498,14 @@ static unsigned scan_varint(unsigned len, const uint8_t *data) {
return i + 1; return i + 1;
} }
static protobuf_c_boolean parse_packed_repeated_member( static protobuf_c_boolean PaddleMobile__Framework__parse_packed_repeated_member(
ScannedMember *scanned_member, void *member, ProtobufCMessage *message) { ScannedMember *scanned_member, void *member,
const ProtobufCFieldDescriptor *field = scanned_member->field; PaddleMobile__Framework__ProtobufCMessage *message) {
const PaddleMobile__Framework__ProtobufCFieldDescriptor *field =
scanned_member->field;
size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset);
size_t siz = sizeof_elt_in_repeated_array(field->type); size_t siz =
PaddleMobile__Framework__sizeof_elt_in_repeated_array(field->type);
void *array = *(char **)member + siz * (*p_n); void *array = *(char **)member + siz * (*p_n);
const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len; const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len;
size_t rem = scanned_member->len - scanned_member->length_prefix_len; size_t rem = scanned_member->len - scanned_member->length_prefix_len;
...@@ -1442,7 +1521,8 @@ static protobuf_c_boolean parse_packed_repeated_member( ...@@ -1442,7 +1521,8 @@ static protobuf_c_boolean parse_packed_repeated_member(
goto no_unpacking_needed; goto no_unpacking_needed;
#else #else
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
((uint32_t *)array)[i] = parse_fixed_uint32(at); ((uint32_t *)array)[i] =
PaddleMobile__Framework__parse_fixed_uint32(at);
at += 4; at += 4;
} }
break; break;
...@@ -1455,7 +1535,8 @@ static protobuf_c_boolean parse_packed_repeated_member( ...@@ -1455,7 +1535,8 @@ static protobuf_c_boolean parse_packed_repeated_member(
goto no_unpacking_needed; goto no_unpacking_needed;
#else #else
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
((uint64_t *)array)[i] = parse_fixed_uint64(at); ((uint64_t *)array)[i] =
PaddleMobile__Framework__parse_fixed_uint64(at);
at += 8; at += 8;
} }
break; break;
...@@ -1463,36 +1544,39 @@ static protobuf_c_boolean parse_packed_repeated_member( ...@@ -1463,36 +1544,39 @@ static protobuf_c_boolean parse_packed_repeated_member(
case PROTOBUF_C_TYPE_ENUM: case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32: case PROTOBUF_C_TYPE_INT32:
while (rem > 0) { while (rem > 0) {
unsigned s = scan_varint(rem, at); unsigned s = PaddleMobile__Framework__scan_varint(rem, at);
if (s == 0) { if (s == 0) {
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int32 value"); PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int32 value");
return FALSE; return FALSE;
} }
((int32_t *)array)[count++] = parse_int32(s, at); ((int32_t *)array)[count++] =
PaddleMobile__Framework__parse_int32(s, at);
at += s; at += s;
rem -= s; rem -= s;
} }
break; break;
case PROTOBUF_C_TYPE_SINT32: case PROTOBUF_C_TYPE_SINT32:
while (rem > 0) { while (rem > 0) {
unsigned s = scan_varint(rem, at); unsigned s = PaddleMobile__Framework__scan_varint(rem, at);
if (s == 0) { if (s == 0) {
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint32 value"); PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint32 value");
return FALSE; return FALSE;
} }
((int32_t *)array)[count++] = unzigzag32(parse_uint32(s, at)); ((int32_t *)array)[count++] =
unzigzag32(PaddleMobile__Framework__parse_uint32(s, at));
at += s; at += s;
rem -= s; rem -= s;
} }
break; break;
case PROTOBUF_C_TYPE_UINT32: case PROTOBUF_C_TYPE_UINT32:
while (rem > 0) { while (rem > 0) {
unsigned s = scan_varint(rem, at); unsigned s = PaddleMobile__Framework__scan_varint(rem, at);
if (s == 0) { if (s == 0) {
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated enum or uint32 value"); PROTOBUF_C_UNPACK_ERROR("bad packed-repeated enum or uint32 value");
return FALSE; return FALSE;
} }
((uint32_t *)array)[count++] = parse_uint32(s, at); ((uint32_t *)array)[count++] =
PaddleMobile__Framework__parse_uint32(s, at);
at += s; at += s;
rem -= s; rem -= s;
} }
...@@ -1500,12 +1584,13 @@ static protobuf_c_boolean parse_packed_repeated_member( ...@@ -1500,12 +1584,13 @@ static protobuf_c_boolean parse_packed_repeated_member(
case PROTOBUF_C_TYPE_SINT64: case PROTOBUF_C_TYPE_SINT64:
while (rem > 0) { while (rem > 0) {
unsigned s = scan_varint(rem, at); unsigned s = PaddleMobile__Framework__scan_varint(rem, at);
if (s == 0) { if (s == 0) {
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint64 value"); PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint64 value");
return FALSE; return FALSE;
} }
((int64_t *)array)[count++] = unzigzag64(parse_uint64(s, at)); ((int64_t *)array)[count++] = PaddleMobile__Framework__unzigzag64(
PaddleMobile__Framework__parse_uint64(s, at));
at += s; at += s;
rem -= s; rem -= s;
} }
...@@ -1513,12 +1598,13 @@ static protobuf_c_boolean parse_packed_repeated_member( ...@@ -1513,12 +1598,13 @@ static protobuf_c_boolean parse_packed_repeated_member(
case PROTOBUF_C_TYPE_INT64: case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64: case PROTOBUF_C_TYPE_UINT64:
while (rem > 0) { while (rem > 0) {
unsigned s = scan_varint(rem, at); unsigned s = PaddleMobile__Framework__scan_varint(rem, at);
if (s == 0) { if (s == 0) {
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int64/uint64 value"); PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int64/uint64 value");
return FALSE; return FALSE;
} }
((int64_t *)array)[count++] = parse_uint64(s, at); ((int64_t *)array)[count++] =
PaddleMobile__Framework__parse_uint64(s, at);
at += s; at += s;
rem -= s; rem -= s;
} }
...@@ -1547,24 +1633,28 @@ no_unpacking_needed: ...@@ -1547,24 +1633,28 @@ no_unpacking_needed:
#endif #endif
} }
static protobuf_c_boolean is_packable_type(ProtobufCType type) { static protobuf_c_boolean PaddleMobile__Framework__is_packable_type(
PaddleMobile__Framework__ProtobufCType type) {
return type != PROTOBUF_C_TYPE_STRING && type != PROTOBUF_C_TYPE_BYTES && return type != PROTOBUF_C_TYPE_STRING && type != PROTOBUF_C_TYPE_BYTES &&
type != PROTOBUF_C_TYPE_MESSAGE; type != PROTOBUF_C_TYPE_MESSAGE;
} }
static protobuf_c_boolean parse_member(ScannedMember *scanned_member, static protobuf_c_boolean PaddleMobile__Framework__parse_member(
ProtobufCMessage *message, ScannedMember *scanned_member,
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCMessage *message,
const ProtobufCFieldDescriptor *field = scanned_member->field; PaddleMobile__Framework__ProtobufCAllocator *allocator) {
const PaddleMobile__Framework__ProtobufCFieldDescriptor *field =
scanned_member->field;
void *member; void *member;
if (field == NULL) { if (field == NULL) {
ProtobufCMessageUnknownField *ufield = PaddleMobile__Framework__ProtobufCMessageUnknownField *ufield =
message->unknown_fields + (message->n_unknown_fields++); message->unknown_fields + (message->n_unknown_fields++);
ufield->tag = scanned_member->tag; ufield->tag = scanned_member->tag;
ufield->wire_type = scanned_member->wire_type; ufield->wire_type = scanned_member->wire_type;
ufield->len = scanned_member->len; ufield->len = scanned_member->len;
ufield->data = do_alloc(allocator, scanned_member->len); ufield->data =
PaddleMobile__Framework__do_alloc(allocator, scanned_member->len);
if (ufield->data == NULL) return FALSE; if (ufield->data == NULL) return FALSE;
memcpy(ufield->data, scanned_member->data, ufield->len); memcpy(ufield->data, scanned_member->data, ufield->len);
return TRUE; return TRUE;
...@@ -1572,23 +1662,26 @@ static protobuf_c_boolean parse_member(ScannedMember *scanned_member, ...@@ -1572,23 +1662,26 @@ static protobuf_c_boolean parse_member(ScannedMember *scanned_member,
member = (char *)message + field->offset; member = (char *)message + field->offset;
switch (field->label) { switch (field->label) {
case PROTOBUF_C_LABEL_REQUIRED: case PROTOBUF_C_LABEL_REQUIRED:
return parse_required_member(scanned_member, member, allocator, TRUE); return PaddleMobile__Framework__parse_required_member(
scanned_member, member, allocator, TRUE);
case PROTOBUF_C_LABEL_OPTIONAL: case PROTOBUF_C_LABEL_OPTIONAL:
case PROTOBUF_C_LABEL_NONE: case PROTOBUF_C_LABEL_NONE:
if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF)) { if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF)) {
return parse_oneof_member(scanned_member, member, message, allocator); return PaddleMobile__Framework__parse_oneof_member(
scanned_member, member, message, allocator);
} else { } else {
return parse_optional_member(scanned_member, member, message, return PaddleMobile__Framework__parse_optional_member(
allocator); scanned_member, member, message, allocator);
} }
case PROTOBUF_C_LABEL_REPEATED: case PROTOBUF_C_LABEL_REPEATED:
if (scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED && if (scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED &&
(0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) || (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) ||
is_packable_type(field->type))) { PaddleMobile__Framework__is_packable_type(field->type))) {
return parse_packed_repeated_member(scanned_member, member, message); return PaddleMobile__Framework__parse_packed_repeated_member(
scanned_member, member, message);
} else { } else {
return parse_repeated_member(scanned_member, member, message, return PaddleMobile__Framework__parse_repeated_member(
allocator); scanned_member, member, message, allocator);
} }
} }
PROTOBUF_C__ASSERT_NOT_REACHED(); PROTOBUF_C__ASSERT_NOT_REACHED();
...@@ -1602,8 +1695,9 @@ static protobuf_c_boolean parse_member(ScannedMember *scanned_member, ...@@ -1602,8 +1695,9 @@ static protobuf_c_boolean parse_member(ScannedMember *scanned_member,
* for old code, and which would be useful to support allocating * for old code, and which would be useful to support allocating
* descriptors dynamically). * descriptors dynamically).
*/ */
static void message_init_generic(const ProtobufCMessageDescriptor *desc, static void PaddleMobile__Framework__message_init_generic(
ProtobufCMessage *message) { const PaddleMobile__Framework__ProtobufCMessageDescriptor *desc,
PaddleMobile__Framework__ProtobufCMessage *message) {
unsigned i; unsigned i;
memset(message, 0, desc->sizeof_message); memset(message, 0, desc->sizeof_message);
...@@ -1636,7 +1730,8 @@ static void message_init_generic(const ProtobufCMessageDescriptor *desc, ...@@ -1636,7 +1730,8 @@ static void message_init_generic(const ProtobufCMessageDescriptor *desc,
memcpy(field, dv, sizeof(protobuf_c_boolean)); memcpy(field, dv, sizeof(protobuf_c_boolean));
break; break;
case PROTOBUF_C_TYPE_BYTES: case PROTOBUF_C_TYPE_BYTES:
memcpy(field, dv, sizeof(ProtobufCBinaryData)); memcpy(field, dv,
sizeof(PaddleMobile__Framework__ProtobufCBinaryData));
break; break;
case PROTOBUF_C_TYPE_STRING: case PROTOBUF_C_TYPE_STRING:
...@@ -1680,13 +1775,16 @@ static void message_init_generic(const ProtobufCMessageDescriptor *desc, ...@@ -1680,13 +1775,16 @@ static void message_init_generic(const ProtobufCMessageDescriptor *desc,
#define REQUIRED_FIELD_BITMAP_IS_SET(index) \ #define REQUIRED_FIELD_BITMAP_IS_SET(index) \
(required_fields_bitmap[(index) / 8] & (1UL << ((index) % 8))) (required_fields_bitmap[(index) / 8] & (1UL << ((index) % 8)))
ProtobufCMessage *protobuf_c_message_unpack( PaddleMobile__Framework__ProtobufCMessage *
const ProtobufCMessageDescriptor *desc, ProtobufCAllocator *allocator, PaddleMobile__Framework__protobuf_c_message_unpack(
size_t len, const uint8_t *data) { const PaddleMobile__Framework__ProtobufCMessageDescriptor *desc,
ProtobufCMessage *rv; PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data) {
PaddleMobile__Framework__ProtobufCMessage *rv;
size_t rem = len; size_t rem = len;
const uint8_t *at = data; const uint8_t *at = data;
const ProtobufCFieldDescriptor *last_field = desc->fields + 0; const PaddleMobile__Framework__ProtobufCFieldDescriptor *last_field =
desc->fields + 0;
ScannedMember first_member_slab[1UL << FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2]; ScannedMember first_member_slab[1UL << FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2];
/* /*
...@@ -1712,15 +1810,16 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1712,15 +1810,16 @@ ProtobufCMessage *protobuf_c_message_unpack(
if (allocator == NULL) allocator = &protobuf_c__allocator; if (allocator == NULL) allocator = &protobuf_c__allocator;
rv = do_alloc(allocator, desc->sizeof_message); rv = PaddleMobile__Framework__do_alloc(allocator, desc->sizeof_message);
if (!rv) return (NULL); if (!rv) return (NULL);
scanned_member_slabs[0] = first_member_slab; scanned_member_slabs[0] = first_member_slab;
required_fields_bitmap_len = (desc->n_fields + 7) / 8; required_fields_bitmap_len = (desc->n_fields + 7) / 8;
if (required_fields_bitmap_len > sizeof(required_fields_bitmap_stack)) { if (required_fields_bitmap_len > sizeof(required_fields_bitmap_stack)) {
required_fields_bitmap = do_alloc(allocator, required_fields_bitmap_len); required_fields_bitmap = PaddleMobile__Framework__do_alloc(
allocator, required_fields_bitmap_len);
if (!required_fields_bitmap) { if (!required_fields_bitmap) {
do_free(allocator, rv); PaddleMobile__Framework__do_free(allocator, rv);
return (NULL); return (NULL);
} }
required_fields_bitmap_alloced = TRUE; required_fields_bitmap_alloced = TRUE;
...@@ -1734,15 +1833,16 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1734,15 +1833,16 @@ ProtobufCMessage *protobuf_c_message_unpack(
* source (most likely, direct construction from the .proto file). * source (most likely, direct construction from the .proto file).
*/ */
if (desc->message_init != NULL) if (desc->message_init != NULL)
protobuf_c_message_init(desc, rv); PaddleMobile__Framework__protobuf_c_message_init(desc, rv);
else else
message_init_generic(desc, rv); PaddleMobile__Framework__message_init_generic(desc, rv);
while (rem > 0) { while (rem > 0) {
uint32_t tag; uint32_t tag;
ProtobufCWireType wire_type; PaddleMobile__Framework__ProtobufCWireType wire_type;
size_t used = parse_tag_and_wiretype(rem, at, &tag, &wire_type); size_t used = PaddleMobile__Framework__parse_tag_and_wiretype(rem, at, &tag,
const ProtobufCFieldDescriptor *field; &wire_type);
const PaddleMobile__Framework__ProtobufCFieldDescriptor *field;
ScannedMember tmp; ScannedMember tmp;
if (used == 0) { if (used == 0) {
...@@ -1756,8 +1856,8 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1756,8 +1856,8 @@ ProtobufCMessage *protobuf_c_message_unpack(
*/ */
if (last_field == NULL || last_field->id != tag) { if (last_field == NULL || last_field->id != tag) {
/* lookup field */ /* lookup field */
int field_index = int field_index = PaddleMobile__Framework__int_range_lookup(
int_range_lookup(desc->n_field_ranges, desc->field_ranges, tag); desc->n_field_ranges, desc->field_ranges, tag);
if (field_index < 0) { if (field_index < 0) {
field = NULL; field = NULL;
n_unknown++; n_unknown++;
...@@ -1807,9 +1907,11 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1807,9 +1907,11 @@ ProtobufCMessage *protobuf_c_message_unpack(
case PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED: { case PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED: {
size_t pref_len; size_t pref_len;
tmp.len = scan_length_prefixed_data(rem, at, &pref_len); tmp.len = PaddleMobile__Framework__scan_length_prefixed_data(rem, at,
&pref_len);
if (tmp.len == 0) { if (tmp.len == 0) {
/* NOTE: scan_length_prefixed_data calls UNPACK_ERROR */ /* NOTE: PaddleMobile__Framework__scan_length_prefixed_data calls
* UNPACK_ERROR */
goto error_cleanup_during_scan; goto error_cleanup_during_scan;
} }
tmp.length_prefix_len = pref_len; tmp.length_prefix_len = pref_len;
...@@ -1841,7 +1943,8 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1841,7 +1943,8 @@ ProtobufCMessage *protobuf_c_message_unpack(
which_slab++; which_slab++;
size = sizeof(ScannedMember) size = sizeof(ScannedMember)
<< (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2); << (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2);
scanned_member_slabs[which_slab] = do_alloc(allocator, size); scanned_member_slabs[which_slab] =
PaddleMobile__Framework__do_alloc(allocator, size);
if (scanned_member_slabs[which_slab] == NULL) if (scanned_member_slabs[which_slab] == NULL)
goto error_cleanup_during_scan; goto error_cleanup_during_scan;
} }
...@@ -1851,9 +1954,10 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1851,9 +1954,10 @@ ProtobufCMessage *protobuf_c_message_unpack(
size_t *n = STRUCT_MEMBER_PTR(size_t, rv, field->quantifier_offset); size_t *n = STRUCT_MEMBER_PTR(size_t, rv, field->quantifier_offset);
if (wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED && if (wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED &&
(0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) || (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) ||
is_packable_type(field->type))) { PaddleMobile__Framework__is_packable_type(field->type))) {
size_t count; size_t count;
if (!count_packed_elements(field->type, tmp.len - tmp.length_prefix_len, if (!PaddleMobile__Framework__count_packed_elements(
field->type, tmp.len - tmp.length_prefix_len,
tmp.data + tmp.length_prefix_len, &count)) { tmp.data + tmp.length_prefix_len, &count)) {
PROTOBUF_C_UNPACK_ERROR("counting packed elements"); PROTOBUF_C_UNPACK_ERROR("counting packed elements");
goto error_cleanup_during_scan; goto error_cleanup_during_scan;
...@@ -1871,9 +1975,11 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1871,9 +1975,11 @@ ProtobufCMessage *protobuf_c_message_unpack(
/* allocate space for repeated fields, also check that all required fields /* allocate space for repeated fields, also check that all required fields
* have been set */ * have been set */
for (f = 0; f < desc->n_fields; f++) { for (f = 0; f < desc->n_fields; f++) {
const ProtobufCFieldDescriptor *field = desc->fields + f; const PaddleMobile__Framework__ProtobufCFieldDescriptor *field =
desc->fields + f;
if (field->label == PROTOBUF_C_LABEL_REPEATED) { if (field->label == PROTOBUF_C_LABEL_REPEATED) {
size_t siz = sizeof_elt_in_repeated_array(field->type); size_t siz =
PaddleMobile__Framework__sizeof_elt_in_repeated_array(field->type);
size_t *n_ptr = STRUCT_MEMBER_PTR(size_t, rv, field->quantifier_offset); size_t *n_ptr = STRUCT_MEMBER_PTR(size_t, rv, field->quantifier_offset);
if (*n_ptr != 0) { if (*n_ptr != 0) {
unsigned n = *n_ptr; unsigned n = *n_ptr;
...@@ -1886,7 +1992,7 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1886,7 +1992,7 @@ ProtobufCMessage *protobuf_c_message_unpack(
if (field->label == PROTOBUF_C_LABEL_REPEATED) \ if (field->label == PROTOBUF_C_LABEL_REPEATED) \
STRUCT_MEMBER(size_t, rv, field->quantifier_offset) = 0; \ STRUCT_MEMBER(size_t, rv, field->quantifier_offset) = 0; \
} }
a = do_alloc(allocator, siz * n); a = PaddleMobile__Framework__do_alloc(allocator, siz * n);
if (!a) { if (!a) {
CLEAR_REMAINING_N_PTRS(); CLEAR_REMAINING_N_PTRS();
goto error_cleanup; goto error_cleanup;
...@@ -1906,8 +2012,10 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1906,8 +2012,10 @@ ProtobufCMessage *protobuf_c_message_unpack(
/* allocate space for unknown fields */ /* allocate space for unknown fields */
if (n_unknown) { if (n_unknown) {
rv->unknown_fields = rv->unknown_fields = PaddleMobile__Framework__do_alloc(
do_alloc(allocator, n_unknown * sizeof(ProtobufCMessageUnknownField)); allocator,
n_unknown *
sizeof(PaddleMobile__Framework__ProtobufCMessageUnknownField));
if (rv->unknown_fields == NULL) goto error_cleanup; if (rv->unknown_fields == NULL) goto error_cleanup;
} }
...@@ -1918,7 +2026,7 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1918,7 +2026,7 @@ ProtobufCMessage *protobuf_c_message_unpack(
ScannedMember *slab = scanned_member_slabs[i_slab]; ScannedMember *slab = scanned_member_slabs[i_slab];
for (j = 0; j < max; j++) { for (j = 0; j < max; j++) {
if (!parse_member(slab + j, rv, allocator)) { if (!PaddleMobile__Framework__parse_member(slab + j, rv, allocator)) {
PROTOBUF_C_UNPACK_ERROR( PROTOBUF_C_UNPACK_ERROR(
"error parsing member %s of %s", "error parsing member %s of %s",
slab->field ? slab->field->name : "*unknown-field*", desc->name); slab->field ? slab->field->name : "*unknown-field*", desc->name);
...@@ -1928,29 +2036,33 @@ ProtobufCMessage *protobuf_c_message_unpack( ...@@ -1928,29 +2036,33 @@ ProtobufCMessage *protobuf_c_message_unpack(
} }
/* cleanup */ /* cleanup */
for (j = 1; j <= which_slab; j++) do_free(allocator, scanned_member_slabs[j]); for (j = 1; j <= which_slab; j++)
PaddleMobile__Framework__do_free(allocator, scanned_member_slabs[j]);
if (required_fields_bitmap_alloced) if (required_fields_bitmap_alloced)
do_free(allocator, required_fields_bitmap); PaddleMobile__Framework__do_free(allocator, required_fields_bitmap);
return rv; return rv;
error_cleanup: error_cleanup:
protobuf_c_message_free_unpacked(rv, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(rv, allocator);
for (j = 1; j <= which_slab; j++) do_free(allocator, scanned_member_slabs[j]); for (j = 1; j <= which_slab; j++)
PaddleMobile__Framework__do_free(allocator, scanned_member_slabs[j]);
if (required_fields_bitmap_alloced) if (required_fields_bitmap_alloced)
do_free(allocator, required_fields_bitmap); PaddleMobile__Framework__do_free(allocator, required_fields_bitmap);
return NULL; return NULL;
error_cleanup_during_scan: error_cleanup_during_scan:
do_free(allocator, rv); PaddleMobile__Framework__do_free(allocator, rv);
for (j = 1; j <= which_slab; j++) do_free(allocator, scanned_member_slabs[j]); for (j = 1; j <= which_slab; j++)
PaddleMobile__Framework__do_free(allocator, scanned_member_slabs[j]);
if (required_fields_bitmap_alloced) if (required_fields_bitmap_alloced)
do_free(allocator, required_fields_bitmap); PaddleMobile__Framework__do_free(allocator, required_fields_bitmap);
return NULL; return NULL;
} }
void protobuf_c_message_free_unpacked(ProtobufCMessage *message, void PaddleMobile__Framework__protobuf_c_message_free_unpacked(
ProtobufCAllocator *allocator) { PaddleMobile__Framework__ProtobufCMessage *message,
const ProtobufCMessageDescriptor *desc; PaddleMobile__Framework__ProtobufCAllocator *allocator) {
const PaddleMobile__Framework__ProtobufCMessageDescriptor *desc;
unsigned f; unsigned f;
if (message == NULL) return; if (message == NULL) return;
...@@ -1978,56 +2090,67 @@ void protobuf_c_message_free_unpacked(ProtobufCMessage *message, ...@@ -1978,56 +2090,67 @@ void protobuf_c_message_free_unpacked(ProtobufCMessage *message,
if (arr != NULL) { if (arr != NULL) {
if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) { if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) {
unsigned i; unsigned i;
for (i = 0; i < n; i++) do_free(allocator, ((char **)arr)[i]); for (i = 0; i < n; i++)
PaddleMobile__Framework__do_free(allocator, ((char **)arr)[i]);
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) { } else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) {
unsigned i; unsigned i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
do_free(allocator, ((ProtobufCBinaryData *)arr)[i].data); PaddleMobile__Framework__do_free(
allocator,
((PaddleMobile__Framework__ProtobufCBinaryData *)arr)[i].data);
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) { } else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) {
unsigned i; unsigned i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
protobuf_c_message_free_unpacked(((ProtobufCMessage **)arr)[i], PaddleMobile__Framework__protobuf_c_message_free_unpacked(
((PaddleMobile__Framework__ProtobufCMessage **)arr)[i],
allocator); allocator);
} }
do_free(allocator, arr); PaddleMobile__Framework__do_free(allocator, arr);
} }
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) { } else if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) {
char *str = STRUCT_MEMBER(char *, message, desc->fields[f].offset); char *str = STRUCT_MEMBER(char *, message, desc->fields[f].offset);
if (str && str != desc->fields[f].default_value) do_free(allocator, str); if (str && str != desc->fields[f].default_value)
PaddleMobile__Framework__do_free(allocator, str);
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) { } else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) {
void *data = void *data = STRUCT_MEMBER(PaddleMobile__Framework__ProtobufCBinaryData,
STRUCT_MEMBER(ProtobufCBinaryData, message, desc->fields[f].offset) message, desc->fields[f].offset)
.data; .data;
const ProtobufCBinaryData *default_bd; const PaddleMobile__Framework__ProtobufCBinaryData *default_bd;
default_bd = desc->fields[f].default_value; default_bd = desc->fields[f].default_value;
if (data != NULL && (default_bd == NULL || default_bd->data != data)) { if (data != NULL && (default_bd == NULL || default_bd->data != data)) {
do_free(allocator, data); PaddleMobile__Framework__do_free(allocator, data);
} }
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) { } else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) {
ProtobufCMessage *sm; PaddleMobile__Framework__ProtobufCMessage *sm;
sm = STRUCT_MEMBER(ProtobufCMessage *, message, desc->fields[f].offset); sm = STRUCT_MEMBER(PaddleMobile__Framework__ProtobufCMessage *, message,
desc->fields[f].offset);
if (sm && sm != desc->fields[f].default_value) if (sm && sm != desc->fields[f].default_value)
protobuf_c_message_free_unpacked(sm, allocator); PaddleMobile__Framework__protobuf_c_message_free_unpacked(sm,
allocator);
} }
} }
for (f = 0; f < message->n_unknown_fields; f++) for (f = 0; f < message->n_unknown_fields; f++)
do_free(allocator, message->unknown_fields[f].data); PaddleMobile__Framework__do_free(allocator,
message->unknown_fields[f].data);
if (message->unknown_fields != NULL) if (message->unknown_fields != NULL)
do_free(allocator, message->unknown_fields); PaddleMobile__Framework__do_free(allocator, message->unknown_fields);
do_free(allocator, message); PaddleMobile__Framework__do_free(allocator, message);
} }
void protobuf_c_message_init(const ProtobufCMessageDescriptor *descriptor, void PaddleMobile__Framework__protobuf_c_message_init(
const PaddleMobile__Framework__ProtobufCMessageDescriptor *descriptor,
void *message) { void *message) {
descriptor->message_init((ProtobufCMessage *)(message)); descriptor->message_init(
(PaddleMobile__Framework__ProtobufCMessage *)(message));
} }
protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) { protobuf_c_boolean PaddleMobile__Framework__protobuf_c_message_check(
const PaddleMobile__Framework__ProtobufCMessage *message) {
unsigned i; unsigned i;
if (!message || !message->descriptor || if (!message || !message->descriptor ||
...@@ -2036,9 +2159,10 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) { ...@@ -2036,9 +2159,10 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) {
} }
for (i = 0; i < message->descriptor->n_fields; i++) { for (i = 0; i < message->descriptor->n_fields; i++) {
const ProtobufCFieldDescriptor *f = message->descriptor->fields + i; const PaddleMobile__Framework__ProtobufCFieldDescriptor *f =
ProtobufCType type = f->type; message->descriptor->fields + i;
ProtobufCLabel label = f->label; PaddleMobile__Framework__ProtobufCType type = f->type;
PaddleMobile__Framework__ProtobufCLabel label = f->label;
void *field = STRUCT_MEMBER_P(message, f->offset); void *field = STRUCT_MEMBER_P(message, f->offset);
if (label == PROTOBUF_C_LABEL_REPEATED) { if (label == PROTOBUF_C_LABEL_REPEATED) {
...@@ -2049,10 +2173,12 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) { ...@@ -2049,10 +2173,12 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) {
} }
if (type == PROTOBUF_C_TYPE_MESSAGE) { if (type == PROTOBUF_C_TYPE_MESSAGE) {
ProtobufCMessage **submessage = *(ProtobufCMessage ***)field; PaddleMobile__Framework__ProtobufCMessage **submessage =
*(PaddleMobile__Framework__ProtobufCMessage ***)field;
unsigned j; unsigned j;
for (j = 0; j < *quantity; j++) { for (j = 0; j < *quantity; j++) {
if (!protobuf_c_message_check(submessage[j])) return FALSE; if (!PaddleMobile__Framework__protobuf_c_message_check(submessage[j]))
return FALSE;
} }
} else if (type == PROTOBUF_C_TYPE_STRING) { } else if (type == PROTOBUF_C_TYPE_STRING) {
char **string = *(char ***)field; char **string = *(char ***)field;
...@@ -2061,7 +2187,8 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) { ...@@ -2061,7 +2187,8 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) {
if (!string[j]) return FALSE; if (!string[j]) return FALSE;
} }
} else if (type == PROTOBUF_C_TYPE_BYTES) { } else if (type == PROTOBUF_C_TYPE_BYTES) {
ProtobufCBinaryData *bd = *(ProtobufCBinaryData **)field; PaddleMobile__Framework__ProtobufCBinaryData *bd =
*(PaddleMobile__Framework__ProtobufCBinaryData **)field;
unsigned j; unsigned j;
for (j = 0; j < *quantity; j++) { for (j = 0; j < *quantity; j++) {
if (bd[j].len > 0 && bd[j].data == NULL) return FALSE; if (bd[j].len > 0 && bd[j].data == NULL) return FALSE;
...@@ -2071,9 +2198,11 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) { ...@@ -2071,9 +2198,11 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) {
} else { /* PROTOBUF_C_LABEL_REQUIRED or PROTOBUF_C_LABEL_OPTIONAL */ } else { /* PROTOBUF_C_LABEL_REQUIRED or PROTOBUF_C_LABEL_OPTIONAL */
if (type == PROTOBUF_C_TYPE_MESSAGE) { if (type == PROTOBUF_C_TYPE_MESSAGE) {
ProtobufCMessage *submessage = *(ProtobufCMessage **)field; PaddleMobile__Framework__ProtobufCMessage *submessage =
*(PaddleMobile__Framework__ProtobufCMessage **)field;
if (label == PROTOBUF_C_LABEL_REQUIRED || submessage != NULL) { if (label == PROTOBUF_C_LABEL_REQUIRED || submessage != NULL) {
if (!protobuf_c_message_check(submessage)) return FALSE; if (!PaddleMobile__Framework__protobuf_c_message_check(submessage))
return FALSE;
} }
} else if (type == PROTOBUF_C_TYPE_STRING) { } else if (type == PROTOBUF_C_TYPE_STRING) {
char *string = *(char **)field; char *string = *(char **)field;
...@@ -2081,7 +2210,7 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) { ...@@ -2081,7 +2210,7 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) {
} else if (type == PROTOBUF_C_TYPE_BYTES) { } else if (type == PROTOBUF_C_TYPE_BYTES) {
protobuf_c_boolean *has = protobuf_c_boolean *has =
STRUCT_MEMBER_P(message, f->quantifier_offset); STRUCT_MEMBER_P(message, f->quantifier_offset);
ProtobufCBinaryData *bd = field; PaddleMobile__Framework__ProtobufCBinaryData *bd = field;
if (label == PROTOBUF_C_LABEL_REQUIRED || *has == TRUE) { if (label == PROTOBUF_C_LABEL_REQUIRED || *has == TRUE) {
if (bd->len > 0 && bd->data == NULL) return FALSE; if (bd->len > 0 && bd->data == NULL) return FALSE;
} }
...@@ -2094,5 +2223,6 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) { ...@@ -2094,5 +2223,6 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) {
/* === services === */ /* === services === */
typedef void (*GenericHandler)(void *service, const ProtobufCMessage *input, typedef void (*GenericHandler)(
void *service, const PaddleMobile__Framework__ProtobufCMessage *input,
ProtobufCClosure closure, void *closure_data); ProtobufCClosure closure, void *closure_data);
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
* \page gencode Generated Code * \page gencode Generated Code
* *
* For each enum, we generate a C enum. For each message, we generate a C * For each enum, we generate a C enum. For each message, we generate a C
* structure which can be cast to a `ProtobufCMessage`. * structure which can be cast to a `PaddleMobile__Framework__ProtobufCMessage`.
* *
* For each enum and message, we generate a descriptor object that allows us to * For each enum and message, we generate a descriptor object that allows us to
* implement a kind of reflection on the structures. * implement a kind of reflection on the structures.
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
~~~{.c} ~~~{.c}
Foo__Bar__BazBah * Foo__Bar__BazBah *
foo__bar__baz_bah__unpack foo__bar__baz_bah__unpack
(ProtobufCAllocator *allocator, (PaddleMobile__Framework__ProtobufCAllocator *allocator,
size_t len, size_t len,
const uint8_t *data); const uint8_t *data);
~~~ ~~~
...@@ -99,11 +99,14 @@ Foo__Bar__BazBah * ...@@ -99,11 +99,14 @@ Foo__Bar__BazBah *
* declared in the `.pb-c.h` files: * declared in the `.pb-c.h` files:
* *
~~~{.c} ~~~{.c}
extern const ProtobufCMessageDescriptor foo__bar__baz_bah__descriptor; extern const PaddleMobile__Framework__ProtobufCMessageDescriptor
foo__bar__baz_bah__descriptor;
~~~ ~~~
* *
* The message structures all begin with `ProtobufCMessageDescriptor *` which is * The message structures all begin with
* sufficient to allow them to be cast to `ProtobufCMessage`. `PaddleMobile__Framework__ProtobufCMessageDescriptor *` which is
* sufficient to allow them to be cast to
`PaddleMobile__Framework__ProtobufCMessage`.
* *
* For each message defined in a `.proto` file, we generate a number of * For each message defined in a `.proto` file, we generate a number of
* functions and macros. Each function name contains a prefix based on the * functions and macros. Each function name contains a prefix based on the
...@@ -133,7 +136,7 @@ void foo__bar__baz_bah__init ...@@ -133,7 +136,7 @@ void foo__bar__baz_bah__init
~~~{.c} ~~~{.c}
Foo__Bar__BazBah * Foo__Bar__BazBah *
foo__bar__baz_bah__unpack foo__bar__baz_bah__unpack
(ProtobufCAllocator *allocator, (PaddleMobile__Framework__ProtobufCAllocator *allocator,
size_t len, size_t len,
const uint8_t *data); const uint8_t *data);
~~~ ~~~
...@@ -144,7 +147,7 @@ Foo__Bar__BazBah * ...@@ -144,7 +147,7 @@ Foo__Bar__BazBah *
~~~{.c} ~~~{.c}
void foo__bar__baz_bah__free_unpacked void foo__bar__baz_bah__free_unpacked
(Foo__Bar__BazBah *message, (Foo__Bar__BazBah *message,
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCAllocator *allocator);
~~~ ~~~
* *
* - `get_packed_size()`. Calculates the length in bytes of the serialized * - `get_packed_size()`. Calculates the length in bytes of the serialized
...@@ -171,26 +174,29 @@ size_t foo__bar__baz_bah__pack ...@@ -171,26 +174,29 @@ size_t foo__bar__baz_bah__pack
~~~{.c} ~~~{.c}
size_t foo__bar__baz_bah__pack_to_buffer size_t foo__bar__baz_bah__pack_to_buffer
(const Foo__Bar__BazBah *message, (const Foo__Bar__BazBah *message,
ProtobufCBuffer *buffer); PaddleMobile__Framework__ProtobufCBuffer *buffer);
~~~ ~~~
* *
* \page pack Packing and unpacking messages * \page pack Packing and unpacking messages
* *
* To pack a message, first compute the packed size of the message with * To pack a message, first compute the packed size of the message with
* protobuf_c_message_get_packed_size(), then allocate a buffer of at least * PaddleMobile__Framework__protobuf_c_message_get_packed_size(), then allocate
a buffer of at least
* that size, then call protobuf_c_message_pack(). * that size, then call protobuf_c_message_pack().
* *
* Alternatively, a message can be serialized without calculating the final size * Alternatively, a message can be serialized without calculating the final size
* first. Use the protobuf_c_message_pack_to_buffer() function and provide a * first. Use the protobuf_c_message_pack_to_buffer() function and provide a
* ProtobufCBuffer object which implements an "append" method that consumes * PaddleMobile__Framework__ProtobufCBuffer object which implements an "append"
method that consumes
* data. * data.
* *
* To unpack a message, call the protobuf_c_message_unpack() function. The * To unpack a message, call the
PaddleMobile__Framework__protobuf_c_message_unpack() function. The
* result can be cast to an object of the type that matches the descriptor for * result can be cast to an object of the type that matches the descriptor for
* the message. * the message.
* *
* The result of unpacking a message should be freed with * The result of unpacking a message should be freed with
* protobuf_c_message_free_unpacked(). * PaddleMobile__Framework__protobuf_c_message_free_unpacked().
*/ */
#ifndef PROTOBUF_C_H #ifndef PROTOBUF_C_H
...@@ -238,7 +244,7 @@ PROTOBUF_C__BEGIN_DECLS ...@@ -238,7 +244,7 @@ PROTOBUF_C__BEGIN_DECLS
#define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af #define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af
/* Empty string used for initializers */ /* Empty string used for initializers */
extern const char protobuf_c_empty_string[]; extern const char PaddleMobile__Framework__protobuf_c_empty_string[];
/** /**
* \defgroup api Public API * \defgroup api Public API
...@@ -250,7 +256,8 @@ extern const char protobuf_c_empty_string[]; ...@@ -250,7 +256,8 @@ extern const char protobuf_c_empty_string[];
*/ */
/** /**
* Values for the `flags` word in `ProtobufCFieldDescriptor`. * Values for the `flags` word in
* `PaddleMobile__Framework__ProtobufCFieldDescriptor`.
*/ */
typedef enum { typedef enum {
/** Set if the field is repeated and marked with the `packed` option. */ /** Set if the field is repeated and marked with the `packed` option. */
...@@ -261,7 +268,7 @@ typedef enum { ...@@ -261,7 +268,7 @@ typedef enum {
/** Set if the field is a member of a oneof (union). */ /** Set if the field is a member of a oneof (union). */
PROTOBUF_C_FIELD_FLAG_ONEOF = (1 << 2), PROTOBUF_C_FIELD_FLAG_ONEOF = (1 << 2),
} ProtobufCFieldFlag; } PaddleMobile__Framework__ProtobufCFieldFlag;
/** /**
* Message field rules. * Message field rules.
...@@ -293,7 +300,7 @@ typedef enum { ...@@ -293,7 +300,7 @@ typedef enum {
* equivalent to OPTIONAL but no "has" quantifier will be consulted. * equivalent to OPTIONAL but no "has" quantifier will be consulted.
*/ */
PROTOBUF_C_LABEL_NONE, PROTOBUF_C_LABEL_NONE,
} ProtobufCLabel; } PaddleMobile__Framework__ProtobufCLabel;
/** /**
* Field value types. * Field value types.
...@@ -321,7 +328,7 @@ typedef enum { ...@@ -321,7 +328,7 @@ typedef enum {
PROTOBUF_C_TYPE_STRING, /**< UTF-8 or ASCII string */ PROTOBUF_C_TYPE_STRING, /**< UTF-8 or ASCII string */
PROTOBUF_C_TYPE_BYTES, /**< arbitrary byte sequence */ PROTOBUF_C_TYPE_BYTES, /**< arbitrary byte sequence */
PROTOBUF_C_TYPE_MESSAGE, /**< nested message */ PROTOBUF_C_TYPE_MESSAGE, /**< nested message */
} ProtobufCType; } PaddleMobile__Framework__ProtobufCType;
/** /**
* Field wire types. * Field wire types.
...@@ -337,51 +344,69 @@ typedef enum { ...@@ -337,51 +344,69 @@ typedef enum {
PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED = 2, PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED = 2,
/* "Start group" and "end group" wire types are unsupported. */ /* "Start group" and "end group" wire types are unsupported. */
PROTOBUF_C_WIRE_TYPE_32BIT = 5, PROTOBUF_C_WIRE_TYPE_32BIT = 5,
} ProtobufCWireType; } PaddleMobile__Framework__ProtobufCWireType;
struct ProtobufCAllocator; struct PaddleMobile__Framework__ProtobufCAllocator;
struct ProtobufCBinaryData; struct PaddleMobile__Framework__ProtobufCBinaryData;
struct ProtobufCBuffer; struct PaddleMobile__Framework__ProtobufCBuffer;
struct ProtobufCBufferSimple; struct PaddleMobile__Framework__ProtobufCBufferSimple;
struct ProtobufCEnumDescriptor; struct PaddleMobile__Framework__ProtobufCEnumDescriptor;
struct ProtobufCEnumValue; struct PaddleMobile__Framework__ProtobufCEnumValue;
struct ProtobufCEnumValueIndex; struct PaddleMobile__Framework__ProtobufCEnumValueIndex;
struct ProtobufCFieldDescriptor; struct PaddleMobile__Framework__ProtobufCFieldDescriptor;
struct ProtobufCIntRange; struct PaddleMobile__Framework__ProtobufCIntRange;
struct ProtobufCMessage; struct PaddleMobile__Framework__ProtobufCMessage;
struct ProtobufCMessageDescriptor; struct PaddleMobile__Framework__ProtobufCMessageDescriptor;
struct ProtobufCMessageUnknownField; struct PaddleMobile__Framework__ProtobufCMessageUnknownField;
struct ProtobufCMethodDescriptor; struct PaddleMobile__Framework__ProtobufCMethodDescriptor;
struct ProtobufCService; struct PaddleMobile__Framework__ProtobufCService;
struct ProtobufCServiceDescriptor; struct PaddleMobile__Framework__ProtobufCServiceDescriptor;
typedef struct ProtobufCAllocator ProtobufCAllocator; typedef struct PaddleMobile__Framework__ProtobufCAllocator
typedef struct ProtobufCBinaryData ProtobufCBinaryData; PaddleMobile__Framework__ProtobufCAllocator;
typedef struct ProtobufCBuffer ProtobufCBuffer; typedef struct PaddleMobile__Framework__ProtobufCBinaryData
typedef struct ProtobufCBufferSimple ProtobufCBufferSimple; PaddleMobile__Framework__ProtobufCBinaryData;
typedef struct ProtobufCEnumDescriptor ProtobufCEnumDescriptor; typedef struct PaddleMobile__Framework__ProtobufCBuffer
typedef struct ProtobufCEnumValue ProtobufCEnumValue; PaddleMobile__Framework__ProtobufCBuffer;
typedef struct ProtobufCEnumValueIndex ProtobufCEnumValueIndex; typedef struct PaddleMobile__Framework__ProtobufCBufferSimple
typedef struct ProtobufCFieldDescriptor ProtobufCFieldDescriptor; PaddleMobile__Framework__ProtobufCBufferSimple;
typedef struct ProtobufCIntRange ProtobufCIntRange; typedef struct PaddleMobile__Framework__ProtobufCEnumDescriptor
typedef struct ProtobufCMessage ProtobufCMessage; PaddleMobile__Framework__ProtobufCEnumDescriptor;
typedef struct ProtobufCMessageDescriptor ProtobufCMessageDescriptor; typedef struct PaddleMobile__Framework__ProtobufCEnumValue
typedef struct ProtobufCMessageUnknownField ProtobufCMessageUnknownField; PaddleMobile__Framework__ProtobufCEnumValue;
typedef struct ProtobufCMethodDescriptor ProtobufCMethodDescriptor; typedef struct PaddleMobile__Framework__ProtobufCEnumValueIndex
typedef struct ProtobufCService ProtobufCService; PaddleMobile__Framework__ProtobufCEnumValueIndex;
typedef struct ProtobufCServiceDescriptor ProtobufCServiceDescriptor; typedef struct PaddleMobile__Framework__ProtobufCFieldDescriptor
PaddleMobile__Framework__ProtobufCFieldDescriptor;
typedef struct PaddleMobile__Framework__ProtobufCIntRange
PaddleMobile__Framework__ProtobufCIntRange;
typedef struct PaddleMobile__Framework__ProtobufCMessage
PaddleMobile__Framework__ProtobufCMessage;
typedef struct PaddleMobile__Framework__ProtobufCMessageDescriptor
PaddleMobile__Framework__ProtobufCMessageDescriptor;
typedef struct PaddleMobile__Framework__ProtobufCMessageUnknownField
PaddleMobile__Framework__ProtobufCMessageUnknownField;
typedef struct PaddleMobile__Framework__ProtobufCMethodDescriptor
PaddleMobile__Framework__ProtobufCMethodDescriptor;
typedef struct PaddleMobile__Framework__ProtobufCService
PaddleMobile__Framework__ProtobufCService;
typedef struct PaddleMobile__Framework__ProtobufCServiceDescriptor
PaddleMobile__Framework__ProtobufCServiceDescriptor;
/** Boolean type. */ /** Boolean type. */
typedef int protobuf_c_boolean; typedef int protobuf_c_boolean;
typedef void (*ProtobufCClosure)(const ProtobufCMessage *, void *closure_data); typedef void (*ProtobufCClosure)(
typedef void (*ProtobufCMessageInit)(ProtobufCMessage *); const PaddleMobile__Framework__ProtobufCMessage *, void *closure_data);
typedef void (*ProtobufCServiceDestroy)(ProtobufCService *); typedef void (*ProtobufCMessageInit)(
PaddleMobile__Framework__ProtobufCMessage *);
typedef void (*ProtobufCServiceDestroy)(
PaddleMobile__Framework__ProtobufCService *);
/** /**
* Structure for defining a custom memory allocator. * Structure for defining a custom memory allocator.
*/ */
struct ProtobufCAllocator { struct PaddleMobile__Framework__ProtobufCAllocator {
/** Function to allocate memory. */ /** Function to allocate memory. */
void *(*alloc)(void *allocator_data, size_t size); void *(*alloc)(void *allocator_data, size_t size);
...@@ -395,11 +420,11 @@ struct ProtobufCAllocator { ...@@ -395,11 +420,11 @@ struct ProtobufCAllocator {
/** /**
* Structure for the protobuf `bytes` scalar type. * Structure for the protobuf `bytes` scalar type.
* *
* The data contained in a `ProtobufCBinaryData` is an arbitrary sequence of * The data contained in a `PaddleMobile__Framework__ProtobufCBinaryData` is an
* bytes. It may contain embedded `NUL` characters and is not required to be * arbitrary sequence of bytes. It may contain embedded `NUL` characters and is
* `NUL`-terminated. * not required to be `NUL`-terminated.
*/ */
struct ProtobufCBinaryData { struct PaddleMobile__Framework__ProtobufCBinaryData {
size_t len; /**< Number of bytes in the `data` field. */ size_t len; /**< Number of bytes in the `data` field. */
uint8_t *data; /**< Data bytes. */ uint8_t *data; /**< Data bytes. */
}; };
...@@ -409,17 +434,18 @@ struct ProtobufCBinaryData { ...@@ -409,17 +434,18 @@ struct ProtobufCBinaryData {
* protobuf_c_message_pack_to_buffer() to abstract the consumption of serialized * protobuf_c_message_pack_to_buffer() to abstract the consumption of serialized
* bytes. * bytes.
* *
* `ProtobufCBuffer` "subclasses" may be defined on the stack. For example, to * `PaddleMobile__Framework__ProtobufCBuffer` "subclasses" may be defined on the
stack. For example, to
* write to a `FILE` object: * write to a `FILE` object:
* *
~~~{.c} ~~~{.c}
typedef struct { typedef struct {
ProtobufCBuffer base; PaddleMobile__Framework__ProtobufCBuffer base;
FILE *fp; FILE *fp;
} BufferAppendToFile; } BufferAppendToFile;
static void static void
my_buffer_file_append(ProtobufCBuffer *buffer, my_buffer_file_append(PaddleMobile__Framework__ProtobufCBuffer *buffer,
size_t len, size_t len,
const uint8_t *data) const uint8_t *data)
{ {
...@@ -428,7 +454,8 @@ my_buffer_file_append(ProtobufCBuffer *buffer, ...@@ -428,7 +454,8 @@ my_buffer_file_append(ProtobufCBuffer *buffer,
} }
~~~ ~~~
* *
* To use this new type of ProtobufCBuffer, it could be called as follows: * To use this new type of PaddleMobile__Framework__ProtobufCBuffer, it could be
called as follows:
* *
~~~{.c} ~~~{.c}
... ...
...@@ -439,30 +466,36 @@ protobuf_c_message_pack_to_buffer(&message, &tmp); ...@@ -439,30 +466,36 @@ protobuf_c_message_pack_to_buffer(&message, &tmp);
... ...
~~~ ~~~
*/ */
struct ProtobufCBuffer { struct PaddleMobile__Framework__ProtobufCBuffer {
/** Append function. Consumes the `len` bytes stored at `data`. */ /** Append function. Consumes the `len` bytes stored at `data`. */
void (*append)(ProtobufCBuffer *buffer, size_t len, const uint8_t *data); void (*append)(PaddleMobile__Framework__ProtobufCBuffer *buffer, size_t len,
const uint8_t *data);
}; };
/** /**
* Simple buffer "subclass" of `ProtobufCBuffer`. * Simple buffer "subclass" of `PaddleMobile__Framework__ProtobufCBuffer`.
* *
* A `ProtobufCBufferSimple` object is declared on the stack and uses a * A `PaddleMobile__Framework__ProtobufCBufferSimple` object is declared on the
stack and uses a
* scratch buffer provided by the user for the initial allocation. It performs * scratch buffer provided by the user for the initial allocation. It performs
* exponential resizing, using dynamically allocated memory. A * exponential resizing, using dynamically allocated memory. A
* `ProtobufCBufferSimple` object can be created and used as follows: * `PaddleMobile__Framework__ProtobufCBufferSimple` object can be created and
used as follows:
* *
~~~{.c} ~~~{.c}
uint8_t pad[128]; uint8_t pad[128];
ProtobufCBufferSimple simple = PROTOBUF_C_BUFFER_SIMPLE_INIT(pad); PaddleMobile__Framework__ProtobufCBufferSimple simple =
ProtobufCBuffer *buffer = (ProtobufCBuffer *) &simple; PROTOBUF_C_BUFFER_SIMPLE_INIT(pad); PaddleMobile__Framework__ProtobufCBuffer
*buffer = (PaddleMobile__Framework__ProtobufCBuffer *) &simple;
~~~ ~~~
* *
* `buffer` can now be used with `protobuf_c_message_pack_to_buffer()`. Once a * `buffer` can now be used with `protobuf_c_message_pack_to_buffer()`. Once a
* message has been serialized to a `ProtobufCBufferSimple` object, the * message has been serialized to a
`PaddleMobile__Framework__ProtobufCBufferSimple` object, the
* serialized data bytes can be accessed from the `.data` field. * serialized data bytes can be accessed from the `.data` field.
* *
* To free the memory allocated by a `ProtobufCBufferSimple` object, if any, * To free the memory allocated by a
`PaddleMobile__Framework__ProtobufCBufferSimple` object, if any,
* call PROTOBUF_C_BUFFER_SIMPLE_CLEAR() on the object, for example: * call PROTOBUF_C_BUFFER_SIMPLE_CLEAR() on the object, for example:
* *
~~~{.c} ~~~{.c}
...@@ -472,9 +505,9 @@ PROTOBUF_C_BUFFER_SIMPLE_CLEAR(&simple); ...@@ -472,9 +505,9 @@ PROTOBUF_C_BUFFER_SIMPLE_CLEAR(&simple);
* \see PROTOBUF_C_BUFFER_SIMPLE_INIT * \see PROTOBUF_C_BUFFER_SIMPLE_INIT
* \see PROTOBUF_C_BUFFER_SIMPLE_CLEAR * \see PROTOBUF_C_BUFFER_SIMPLE_CLEAR
*/ */
struct ProtobufCBufferSimple { struct PaddleMobile__Framework__ProtobufCBufferSimple {
/** "Base class". */ /** "Base class". */
ProtobufCBuffer base; PaddleMobile__Framework__ProtobufCBuffer base;
/** Number of bytes allocated in `data`. */ /** Number of bytes allocated in `data`. */
size_t alloced; size_t alloced;
/** Number of bytes currently stored in `data`. */ /** Number of bytes currently stored in `data`. */
...@@ -484,13 +517,13 @@ struct ProtobufCBufferSimple { ...@@ -484,13 +517,13 @@ struct ProtobufCBufferSimple {
/** Whether `data` must be freed. */ /** Whether `data` must be freed. */
protobuf_c_boolean must_free_data; protobuf_c_boolean must_free_data;
/** Allocator to use. May be NULL to indicate the system allocator. */ /** Allocator to use. May be NULL to indicate the system allocator. */
ProtobufCAllocator *allocator; PaddleMobile__Framework__ProtobufCAllocator *allocator;
}; };
/** /**
* Describes an enumeration as a whole, with all of its values. * Describes an enumeration as a whole, with all of its values.
*/ */
struct ProtobufCEnumDescriptor { struct PaddleMobile__Framework__ProtobufCEnumDescriptor {
/** Magic value checked to ensure that the API is used correctly. */ /** Magic value checked to ensure that the API is used correctly. */
uint32_t magic; uint32_t magic;
...@@ -506,17 +539,17 @@ struct ProtobufCEnumDescriptor { ...@@ -506,17 +539,17 @@ struct ProtobufCEnumDescriptor {
/** Number elements in `values`. */ /** Number elements in `values`. */
unsigned n_values; unsigned n_values;
/** Array of distinct values, sorted by numeric value. */ /** Array of distinct values, sorted by numeric value. */
const ProtobufCEnumValue *values; const PaddleMobile__Framework__ProtobufCEnumValue *values;
/** Number of elements in `values_by_name`. */ /** Number of elements in `values_by_name`. */
unsigned n_value_names; unsigned n_value_names;
/** Array of named values, including aliases, sorted by name. */ /** Array of named values, including aliases, sorted by name. */
const ProtobufCEnumValueIndex *values_by_name; const PaddleMobile__Framework__ProtobufCEnumValueIndex *values_by_name;
/** Number of elements in `value_ranges`. */ /** Number of elements in `value_ranges`. */
unsigned n_value_ranges; unsigned n_value_ranges;
/** Value ranges, for faster lookups by numeric value. */ /** Value ranges, for faster lookups by numeric value. */
const ProtobufCIntRange *value_ranges; const PaddleMobile__Framework__ProtobufCIntRange *value_ranges;
/** Reserved for future use. */ /** Reserved for future use. */
void *reserved1; void *reserved1;
...@@ -531,7 +564,7 @@ struct ProtobufCEnumDescriptor { ...@@ -531,7 +564,7 @@ struct ProtobufCEnumDescriptor {
/** /**
* Represents a single value of an enumeration. * Represents a single value of an enumeration.
*/ */
struct ProtobufCEnumValue { struct PaddleMobile__Framework__ProtobufCEnumValue {
/** The string identifying this value in the .proto file. */ /** The string identifying this value in the .proto file. */
const char *name; const char *name;
...@@ -543,9 +576,10 @@ struct ProtobufCEnumValue { ...@@ -543,9 +576,10 @@ struct ProtobufCEnumValue {
}; };
/** /**
* Used by `ProtobufCEnumDescriptor` to look up enum values. * Used by `PaddleMobile__Framework__ProtobufCEnumDescriptor` to look up enum
* values.
*/ */
struct ProtobufCEnumValueIndex { struct PaddleMobile__Framework__ProtobufCEnumValueIndex {
/** Name of the enum value. */ /** Name of the enum value. */
const char *name; const char *name;
/** Index into values[] array. */ /** Index into values[] array. */
...@@ -555,7 +589,7 @@ struct ProtobufCEnumValueIndex { ...@@ -555,7 +589,7 @@ struct ProtobufCEnumValueIndex {
/** /**
* Describes a single field in a message. * Describes a single field in a message.
*/ */
struct ProtobufCFieldDescriptor { struct PaddleMobile__Framework__ProtobufCFieldDescriptor {
/** Name of the field as given in the .proto file. */ /** Name of the field as given in the .proto file. */
const char *name; const char *name;
...@@ -563,10 +597,10 @@ struct ProtobufCFieldDescriptor { ...@@ -563,10 +597,10 @@ struct ProtobufCFieldDescriptor {
uint32_t id; uint32_t id;
/** Whether the field is `REQUIRED`, `OPTIONAL`, or `REPEATED`. */ /** Whether the field is `REQUIRED`, `OPTIONAL`, or `REPEATED`. */
ProtobufCLabel label; PaddleMobile__Framework__ProtobufCLabel label;
/** The type of the field. */ /** The type of the field. */
ProtobufCType type; PaddleMobile__Framework__ProtobufCType type;
/** /**
* The offset in bytes of the message's C structure's quantifier field * The offset in bytes of the message's C structure's quantifier field
...@@ -585,10 +619,10 @@ struct ProtobufCFieldDescriptor { ...@@ -585,10 +619,10 @@ struct ProtobufCFieldDescriptor {
* A type-specific descriptor. * A type-specific descriptor.
* *
* If `type` is `PROTOBUF_C_TYPE_ENUM`, then `descriptor` points to the * If `type` is `PROTOBUF_C_TYPE_ENUM`, then `descriptor` points to the
* corresponding `ProtobufCEnumDescriptor`. * corresponding `PaddleMobile__Framework__ProtobufCEnumDescriptor`.
* *
* If `type` is `PROTOBUF_C_TYPE_MESSAGE`, then `descriptor` points to * If `type` is `PROTOBUF_C_TYPE_MESSAGE`, then `descriptor` points to
* the corresponding `ProtobufCMessageDescriptor`. * the corresponding `PaddleMobile__Framework__ProtobufCMessageDescriptor`.
* *
* Otherwise this field is NULL. * Otherwise this field is NULL.
*/ */
...@@ -599,7 +633,7 @@ struct ProtobufCFieldDescriptor { ...@@ -599,7 +633,7 @@ struct ProtobufCFieldDescriptor {
/** /**
* A flag word. Zero or more of the bits defined in the * A flag word. Zero or more of the bits defined in the
* `ProtobufCFieldFlag` enum may be set. * `PaddleMobile__Framework__ProtobufCFieldFlag` enum may be set.
*/ */
uint32_t flags; uint32_t flags;
...@@ -619,7 +653,7 @@ struct ProtobufCFieldDescriptor { ...@@ -619,7 +653,7 @@ struct ProtobufCFieldDescriptor {
* The data structures requires that the values in the original array are * The data structures requires that the values in the original array are
* sorted. * sorted.
*/ */
struct ProtobufCIntRange { struct PaddleMobile__Framework__ProtobufCIntRange {
int start_value; int start_value;
unsigned orig_index; unsigned orig_index;
/* /*
...@@ -632,31 +666,34 @@ struct ProtobufCIntRange { ...@@ -632,31 +666,34 @@ struct ProtobufCIntRange {
/** /**
* An instance of a message. * An instance of a message.
* *
* `ProtobufCMessage` is a light-weight "base class" for all messages. * `PaddleMobile__Framework__ProtobufCMessage` is a light-weight "base class"
* for all messages.
* *
* In particular, `ProtobufCMessage` doesn't have any allocation policy * In particular, `PaddleMobile__Framework__ProtobufCMessage` doesn't have any
* associated with it. That's because it's common to create `ProtobufCMessage` * allocation policy associated with it. That's because it's common to create
* objects on the stack. In fact, that's what we recommend for sending messages. * `PaddleMobile__Framework__ProtobufCMessage` objects on the stack. In fact,
* If the object is allocated from the stack, you can't really have a memory * that's what we recommend for sending messages. If the object is allocated
* leak. * from the stack, you can't really have a memory leak.
* *
* This means that calls to functions like protobuf_c_message_unpack() which * This means that calls to functions like
* return a `ProtobufCMessage` must be paired with a call to a free function, * PaddleMobile__Framework__protobuf_c_message_unpack() which return a
* like protobuf_c_message_free_unpacked(). * `PaddleMobile__Framework__ProtobufCMessage` must be paired with a call to a
* free function, like
* PaddleMobile__Framework__protobuf_c_message_free_unpacked().
*/ */
struct ProtobufCMessage { struct PaddleMobile__Framework__ProtobufCMessage {
/** The descriptor for this message type. */ /** The descriptor for this message type. */
const ProtobufCMessageDescriptor *descriptor; const PaddleMobile__Framework__ProtobufCMessageDescriptor *descriptor;
/** The number of elements in `unknown_fields`. */ /** The number of elements in `unknown_fields`. */
unsigned n_unknown_fields; unsigned n_unknown_fields;
/** The fields that weren't recognized by the parser. */ /** The fields that weren't recognized by the parser. */
ProtobufCMessageUnknownField *unknown_fields; PaddleMobile__Framework__ProtobufCMessageUnknownField *unknown_fields;
}; };
/** /**
* Describes a message. * Describes a message.
*/ */
struct ProtobufCMessageDescriptor { struct PaddleMobile__Framework__ProtobufCMessageDescriptor {
/** Magic value checked to ensure that the API is used correctly. */ /** Magic value checked to ensure that the API is used correctly. */
uint32_t magic; uint32_t magic;
...@@ -678,14 +715,14 @@ struct ProtobufCMessageDescriptor { ...@@ -678,14 +715,14 @@ struct ProtobufCMessageDescriptor {
/** Number of elements in `fields`. */ /** Number of elements in `fields`. */
unsigned n_fields; unsigned n_fields;
/** Field descriptors, sorted by tag number. */ /** Field descriptors, sorted by tag number. */
const ProtobufCFieldDescriptor *fields; const PaddleMobile__Framework__ProtobufCFieldDescriptor *fields;
/** Used for looking up fields by name. */ /** Used for looking up fields by name. */
const unsigned *fields_sorted_by_name; const unsigned *fields_sorted_by_name;
/** Number of elements in `field_ranges`. */ /** Number of elements in `field_ranges`. */
unsigned n_field_ranges; unsigned n_field_ranges;
/** Used for looking up fields by id. */ /** Used for looking up fields by id. */
const ProtobufCIntRange *field_ranges; const PaddleMobile__Framework__ProtobufCIntRange *field_ranges;
/** Message initialisation function. */ /** Message initialisation function. */
ProtobufCMessageInit message_init; ProtobufCMessageInit message_init;
...@@ -701,11 +738,11 @@ struct ProtobufCMessageDescriptor { ...@@ -701,11 +738,11 @@ struct ProtobufCMessageDescriptor {
/** /**
* An unknown message field. * An unknown message field.
*/ */
struct ProtobufCMessageUnknownField { struct PaddleMobile__Framework__ProtobufCMessageUnknownField {
/** The tag number. */ /** The tag number. */
uint32_t tag; uint32_t tag;
/** The wire type of the field. */ /** The wire type of the field. */
ProtobufCWireType wire_type; PaddleMobile__Framework__ProtobufCWireType wire_type;
/** Number of bytes in `data`. */ /** Number of bytes in `data`. */
size_t len; size_t len;
/** Field data. */ /** Field data. */
...@@ -715,33 +752,34 @@ struct ProtobufCMessageUnknownField { ...@@ -715,33 +752,34 @@ struct ProtobufCMessageUnknownField {
/** /**
* Method descriptor. * Method descriptor.
*/ */
struct ProtobufCMethodDescriptor { struct PaddleMobile__Framework__ProtobufCMethodDescriptor {
/** Method name. */ /** Method name. */
const char *name; const char *name;
/** Input message descriptor. */ /** Input message descriptor. */
const ProtobufCMessageDescriptor *input; const PaddleMobile__Framework__ProtobufCMessageDescriptor *input;
/** Output message descriptor. */ /** Output message descriptor. */
const ProtobufCMessageDescriptor *output; const PaddleMobile__Framework__ProtobufCMessageDescriptor *output;
}; };
/** /**
* Service. * Service.
*/ */
struct ProtobufCService { struct PaddleMobile__Framework__ProtobufCService {
/** Service descriptor. */ /** Service descriptor. */
const ProtobufCServiceDescriptor *descriptor; const PaddleMobile__Framework__ProtobufCServiceDescriptor *descriptor;
/** Function to invoke the service. */ /** Function to invoke the service. */
void (*invoke)(ProtobufCService *service, unsigned method_index, void (*invoke)(PaddleMobile__Framework__ProtobufCService *service,
const ProtobufCMessage *input, ProtobufCClosure closure, unsigned method_index,
void *closure_data); const PaddleMobile__Framework__ProtobufCMessage *input,
ProtobufCClosure closure, void *closure_data);
/** Function to destroy the service. */ /** Function to destroy the service. */
void (*destroy)(ProtobufCService *service); void (*destroy)(PaddleMobile__Framework__ProtobufCService *service);
}; };
/** /**
* Service descriptor. * Service descriptor.
*/ */
struct ProtobufCServiceDescriptor { struct PaddleMobile__Framework__ProtobufCServiceDescriptor {
/** Magic value checked to ensure that the API is used correctly. */ /** Magic value checked to ensure that the API is used correctly. */
uint32_t magic; uint32_t magic;
...@@ -756,7 +794,7 @@ struct ProtobufCServiceDescriptor { ...@@ -756,7 +794,7 @@ struct ProtobufCServiceDescriptor {
/** Number of elements in `methods`. */ /** Number of elements in `methods`. */
unsigned n_methods; unsigned n_methods;
/** Method descriptors, in the order defined in the .proto file. */ /** Method descriptors, in the order defined in the .proto file. */
const ProtobufCMethodDescriptor *methods; const PaddleMobile__Framework__ProtobufCMethodDescriptor *methods;
/** Sort index of methods. */ /** Sort index of methods. */
const unsigned *method_indices_by_name; const unsigned *method_indices_by_name;
}; };
...@@ -768,7 +806,7 @@ struct ProtobufCServiceDescriptor { ...@@ -768,7 +806,7 @@ struct ProtobufCServiceDescriptor {
* \return A string containing the version number of protobuf-c. * \return A string containing the version number of protobuf-c.
*/ */
PROTOBUF_C__API PROTOBUF_C__API
const char *protobuf_c_version(void); const char *PaddleMobile__Framework__protobuf_c_version(void);
/** /**
* Get the version of the protobuf-c library. Note that this is the version of * Get the version of the protobuf-c library. Note that this is the version of
...@@ -778,17 +816,17 @@ const char *protobuf_c_version(void); ...@@ -778,17 +816,17 @@ const char *protobuf_c_version(void);
* protobuf-c, represented in base-10 as (MAJOR*1E6) + (MINOR*1E3) + PATCH. * protobuf-c, represented in base-10 as (MAJOR*1E6) + (MINOR*1E3) + PATCH.
*/ */
PROTOBUF_C__API PROTOBUF_C__API
uint32_t protobuf_c_version_number(void); uint32_t PaddleMobile__Framework__protobuf_c_version_number(void);
/** /**
* The version of the protobuf-c headers, represented as a string using the same * The version of the protobuf-c headers, represented as a string using the same
* format as protobuf_c_version(). * format as PaddleMobile__Framework__protobuf_c_version().
*/ */
#define PROTOBUF_C_VERSION "1.3.0" #define PROTOBUF_C_VERSION "1.3.0"
/** /**
* The version of the protobuf-c headers, represented as an integer using the * The version of the protobuf-c headers, represented as an integer using the
* same format as protobuf_c_version_number(). * same format as PaddleMobile__Framework__protobuf_c_version_number().
*/ */
#define PROTOBUF_C_VERSION_NUMBER 1003000 #define PROTOBUF_C_VERSION_NUMBER 1003000
...@@ -807,7 +845,8 @@ uint32_t protobuf_c_version_number(void); ...@@ -807,7 +845,8 @@ uint32_t protobuf_c_version_number(void);
* Number of bytes. * Number of bytes.
*/ */
PROTOBUF_C__API PROTOBUF_C__API
size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message); size_t PaddleMobile__Framework__protobuf_c_message_get_packed_size(
const PaddleMobile__Framework__ProtobufCMessage *message);
/** /**
* Unpack a serialised message into an in-memory representation. * Unpack a serialised message into an in-memory representation.
...@@ -815,37 +854,35 @@ size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message); ...@@ -815,37 +854,35 @@ size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message);
* \param descriptor * \param descriptor
* The message descriptor. * The message descriptor.
* \param allocator * \param allocator
* `ProtobufCAllocator` to use for memory allocation. May be NULL to * `PaddleMobile__Framework__ProtobufCAllocator` to use for memory
* specify the default allocator. * allocation. May be NULL to specify the default allocator. \param len Length
* \param len * in bytes of the serialised message. \param data Pointer to the
* Length in bytes of the serialised message. * serialised message. \return An unpacked message object. \retval NULL If
* \param data * an error occurred during unpacking.
* Pointer to the serialised message.
* \return
* An unpacked message object.
* \retval NULL
* If an error occurred during unpacking.
*/ */
PROTOBUF_C__API PROTOBUF_C__API
ProtobufCMessage *protobuf_c_message_unpack( PaddleMobile__Framework__ProtobufCMessage *
const ProtobufCMessageDescriptor *descriptor, ProtobufCAllocator *allocator, PaddleMobile__Framework__protobuf_c_message_unpack(
size_t len, const uint8_t *data); const PaddleMobile__Framework__ProtobufCMessageDescriptor *descriptor,
PaddleMobile__Framework__ProtobufCAllocator *allocator, size_t len,
const uint8_t *data);
/** /**
* Free an unpacked message object. * Free an unpacked message object.
* *
* This function should be used to deallocate the memory used by a call to * This function should be used to deallocate the memory used by a call to
* protobuf_c_message_unpack(). * PaddleMobile__Framework__protobuf_c_message_unpack().
* *
* \param message * \param message
* The message object to free. May be NULL. * The message object to free. May be NULL.
* \param allocator * \param allocator
* `ProtobufCAllocator` to use for memory deallocation. May be NULL to * `PaddleMobile__Framework__ProtobufCAllocator` to use for memory
* specify the default allocator. * deallocation. May be NULL to specify the default allocator.
*/ */
PROTOBUF_C__API PROTOBUF_C__API
void protobuf_c_message_free_unpacked(ProtobufCMessage *message, void PaddleMobile__Framework__protobuf_c_message_free_unpacked(
ProtobufCAllocator *allocator); PaddleMobile__Framework__ProtobufCMessage *message,
PaddleMobile__Framework__ProtobufCAllocator *allocator);
/** /**
* Check the validity of a message object. * Check the validity of a message object.
...@@ -859,7 +896,8 @@ void protobuf_c_message_free_unpacked(ProtobufCMessage *message, ...@@ -859,7 +896,8 @@ void protobuf_c_message_free_unpacked(ProtobufCMessage *message,
* Message is invalid. * Message is invalid.
*/ */
PROTOBUF_C__API PROTOBUF_C__API
protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *); protobuf_c_boolean PaddleMobile__Framework__protobuf_c_message_check(
const PaddleMobile__Framework__ProtobufCMessage *);
/** Message initialiser. */ /** Message initialiser. */
#define PROTOBUF_C_MESSAGE_INIT(descriptor) \ #define PROTOBUF_C_MESSAGE_INIT(descriptor) \
...@@ -874,20 +912,22 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *); ...@@ -874,20 +912,22 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *);
* Allocated block of memory of size `descriptor->sizeof_message`. * Allocated block of memory of size `descriptor->sizeof_message`.
*/ */
PROTOBUF_C__API PROTOBUF_C__API
void protobuf_c_message_init(const ProtobufCMessageDescriptor *descriptor, void PaddleMobile__Framework__protobuf_c_message_init(
const PaddleMobile__Framework__ProtobufCMessageDescriptor *descriptor,
void *message); void *message);
/** /**
* Initialise a `ProtobufCBufferSimple` object. * Initialise a `PaddleMobile__Framework__ProtobufCBufferSimple` object.
*/ */
#define PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) \ #define PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) \
{ \ { \
{protobuf_c_buffer_simple_append}, sizeof(array_of_bytes), 0, \ {PaddleMobile__Framework__protobuf_c_buffer_simple_append}, \
(array_of_bytes), 0, NULL \ sizeof(array_of_bytes), 0, (array_of_bytes), 0, NULL \
} }
/** /**
* Clear a `ProtobufCBufferSimple` object, freeing any allocated memory. * Clear a `PaddleMobile__Framework__ProtobufCBufferSimple` object, freeing any
* allocated memory.
*/ */
#define PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) \ #define PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) \
do { \ do { \
...@@ -900,18 +940,19 @@ void protobuf_c_message_init(const ProtobufCMessageDescriptor *descriptor, ...@@ -900,18 +940,19 @@ void protobuf_c_message_init(const ProtobufCMessageDescriptor *descriptor,
} while (0) } while (0)
/** /**
* The `append` method for `ProtobufCBufferSimple`. * The `append` method for `PaddleMobile__Framework__ProtobufCBufferSimple`.
* *
* \param buffer * \param buffer
* The buffer object to append to. Must actually be a * The buffer object to append to. Must actually be a
* `ProtobufCBufferSimple` object. * `PaddleMobile__Framework__ProtobufCBufferSimple` object.
* \param len * \param len
* Number of bytes in `data`. * Number of bytes in `data`.
* \param data * \param data
* Data to append. * Data to append.
*/ */
PROTOBUF_C__API PROTOBUF_C__API
void protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer, size_t len, void PaddleMobile__Framework__protobuf_c_buffer_simple_append(
PaddleMobile__Framework__ProtobufCBuffer *buffer, size_t len,
const unsigned char *data); const unsigned char *data);
/**@}*/ /**@}*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册