Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
protobuf-c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
protobuf-c
Commits
9c6f2fe4
Commit
9c6f2fe4
authored
Apr 02, 2014
by
Andrei Nigmatulin
Committed by
Robert Edmonds
Apr 03, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
turned ProtobufCFieldDescriptor->packed into ->flags
parent
db49f8e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
11 deletions
+15
-11
protobuf-c/protobuf-c.c
protobuf-c/protobuf-c.c
+6
-6
protobuf-c/protobuf-c.h
protobuf-c/protobuf-c.h
+5
-1
protoc-c/c_field.cc
protoc-c/c_field.cc
+4
-4
No files found.
protobuf-c/protobuf-c.c
View file @
9c6f2fe4
...
@@ -388,7 +388,7 @@ repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field,
...
@@ -388,7 +388,7 @@ repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field,
if
(
count
==
0
)
if
(
count
==
0
)
return
0
;
return
0
;
header_size
=
get_tag_size
(
field
->
id
);
header_size
=
get_tag_size
(
field
->
id
);
if
(
!
field
->
packed
)
if
(
0
==
(
field
->
flags
&
PROTOBUF_C_FIELD_FLAGS_PACKED
)
)
header_size
*=
count
;
header_size
*=
count
;
switch
(
field
->
type
)
{
switch
(
field
->
type
)
{
...
@@ -449,7 +449,7 @@ repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field,
...
@@ -449,7 +449,7 @@ repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field,
/* case PROTOBUF_C_TYPE_GROUP: -- NOT SUPPORTED */
/* case PROTOBUF_C_TYPE_GROUP: -- NOT SUPPORTED */
}
}
if
(
field
->
packed
)
if
(
0
!=
(
field
->
flags
&
PROTOBUF_C_FIELD_FLAGS_PACKED
)
)
header_size
+=
uint32_size
(
rv
);
header_size
+=
uint32_size
(
rv
);
return
header_size
+
rv
;
return
header_size
+
rv
;
}
}
...
@@ -872,7 +872,7 @@ repeated_field_pack(const ProtobufCFieldDescriptor *field,
...
@@ -872,7 +872,7 @@ repeated_field_pack(const ProtobufCFieldDescriptor *field,
void
*
array
=
*
(
void
*
const
*
)
member
;
void
*
array
=
*
(
void
*
const
*
)
member
;
unsigned
i
;
unsigned
i
;
if
(
field
->
packed
)
{
if
(
0
!=
(
field
->
flags
&
PROTOBUF_C_FIELD_FLAGS_PACKED
)
)
{
unsigned
header_len
;
unsigned
header_len
;
unsigned
len_start
;
unsigned
len_start
;
unsigned
min_length
;
unsigned
min_length
;
...
@@ -1300,7 +1300,7 @@ repeated_field_pack_to_buffer(const ProtobufCFieldDescriptor *field,
...
@@ -1300,7 +1300,7 @@ repeated_field_pack_to_buffer(const ProtobufCFieldDescriptor *field,
if
(
count
==
0
)
if
(
count
==
0
)
return
0
;
return
0
;
if
(
field
->
packed
)
{
if
(
0
!=
(
field
->
flags
&
PROTOBUF_C_FIELD_FLAGS_PACKED
)
)
{
uint8_t
scratch
[
MAX_UINT64_ENCODED_SIZE
*
2
];
uint8_t
scratch
[
MAX_UINT64_ENCODED_SIZE
*
2
];
size_t
rv
=
tag_pack
(
field
->
id
,
scratch
);
size_t
rv
=
tag_pack
(
field
->
id
,
scratch
);
size_t
payload_len
=
get_packed_payload_length
(
field
,
count
,
array
);
size_t
payload_len
=
get_packed_payload_length
(
field
,
count
,
array
);
...
@@ -2169,7 +2169,7 @@ parse_member(ScannedMember *scanned_member,
...
@@ -2169,7 +2169,7 @@ parse_member(ScannedMember *scanned_member,
case
PROTOBUF_C_LABEL_REPEATED
:
case
PROTOBUF_C_LABEL_REPEATED
:
if
(
scanned_member
->
wire_type
==
if
(
scanned_member
->
wire_type
==
PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED
&&
PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED
&&
(
field
->
packed
||
is_packable_type
(
field
->
type
)))
(
0
!=
(
field
->
flags
&
PROTOBUF_C_FIELD_FLAGS_PACKED
)
||
is_packable_type
(
field
->
type
)))
{
{
return
parse_packed_repeated_member
(
scanned_member
,
return
parse_packed_repeated_member
(
scanned_member
,
member
,
message
);
member
,
message
);
...
@@ -2446,7 +2446,7 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
...
@@ -2446,7 +2446,7 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
size_t
*
n
=
STRUCT_MEMBER_PTR
(
size_t
,
rv
,
size_t
*
n
=
STRUCT_MEMBER_PTR
(
size_t
,
rv
,
field
->
quantifier_offset
);
field
->
quantifier_offset
);
if
(
wire_type
==
PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED
&&
if
(
wire_type
==
PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED
&&
(
field
->
packed
||
is_packable_type
(
field
->
type
)))
(
0
!=
(
field
->
flags
&
PROTOBUF_C_FIELD_FLAGS_PACKED
)
||
is_packable_type
(
field
->
type
)))
{
{
size_t
count
;
size_t
count
;
if
(
!
count_packed_elements
(
field
->
type
,
if
(
!
count_packed_elements
(
field
->
type
,
...
...
protobuf-c/protobuf-c.h
View file @
9c6f2fe4
...
@@ -240,13 +240,17 @@ struct _ProtobufCFieldDescriptor {
...
@@ -240,13 +240,17 @@ struct _ProtobufCFieldDescriptor {
unsigned
offset
;
unsigned
offset
;
const
void
*
descriptor
;
/* for MESSAGE and ENUM types */
const
void
*
descriptor
;
/* for MESSAGE and ENUM types */
const
void
*
default_value
;
/* can be NULL */
const
void
*
default_value
;
/* can be NULL */
protobuf_c_boolean
packed
;
unsigned
flags
;
unsigned
reserved_flags
;
unsigned
reserved_flags
;
void
*
reserved2
;
void
*
reserved2
;
void
*
reserved3
;
void
*
reserved3
;
};
};
typedef
enum
{
PROTOBUF_C_FIELD_FLAGS_PACKED
=
(
1
<<
0
),
}
ProtobufCFieldFlagType
;
/*
/*
* ProtobufCMessageDescriptor: description of a message.
* ProtobufCMessageDescriptor: description of a message.
*
*
...
...
protoc-c/c_field.cc
View file @
9c6f2fe4
...
@@ -123,12 +123,12 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer,
...
@@ -123,12 +123,12 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer,
variables
[
"default_value"
]
=
"NULL"
;
variables
[
"default_value"
]
=
"NULL"
;
}
}
variables
[
"flags"
]
=
"0"
;
if
(
descriptor_
->
label
()
==
FieldDescriptor
::
LABEL_REPEATED
if
(
descriptor_
->
label
()
==
FieldDescriptor
::
LABEL_REPEATED
&&
is_packable_type
(
descriptor_
->
type
())
&&
is_packable_type
(
descriptor_
->
type
())
&&
descriptor_
->
options
().
packed
())
&&
descriptor_
->
options
().
packed
())
variables
[
"packed"
]
=
"1"
;
variables
[
"flags"
]
+=
" | PROTOBUF_C_FIELD_FLAGS_PACKED"
;
else
variables
[
"packed"
]
=
"0"
;
printer
->
Print
(
variables
,
printer
->
Print
(
variables
,
"{
\n
"
"{
\n
"
...
@@ -154,7 +154,7 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer,
...
@@ -154,7 +154,7 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer,
printer
->
Print
(
variables
,
" PROTOBUF_C_OFFSETOF($classname$, $name$),
\n
"
);
printer
->
Print
(
variables
,
" PROTOBUF_C_OFFSETOF($classname$, $name$),
\n
"
);
printer
->
Print
(
variables
,
" $descriptor_addr$,
\n
"
);
printer
->
Print
(
variables
,
" $descriptor_addr$,
\n
"
);
printer
->
Print
(
variables
,
" $default_value$,
\n
"
);
printer
->
Print
(
variables
,
" $default_value$,
\n
"
);
printer
->
Print
(
variables
,
" $
packed$, /* packed
*/
\n
"
);
printer
->
Print
(
variables
,
" $
flags$, /* flags
*/
\n
"
);
printer
->
Print
(
variables
,
" 0,NULL,NULL /* reserved1,reserved2, etc */
\n
"
);
printer
->
Print
(
variables
,
" 0,NULL,NULL /* reserved1,reserved2, etc */
\n
"
);
printer
->
Print
(
"},
\n
"
);
printer
->
Print
(
"},
\n
"
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment