Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
9de35e74
Commit
9de35e74
authored
Jan 26, 2015
by
Chris Fallin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addressed code-review comments.
parent
e2debef5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
defs.c
ruby/ext/google/protobuf_c/defs.c
+2
-2
encode_decode.c
ruby/ext/google/protobuf_c/encode_decode.c
+3
-3
storage.c
ruby/ext/google/protobuf_c/storage.c
+7
-2
No files found.
ruby/ext/google/protobuf_c/defs.c
View file @
9de35e74
...
...
@@ -58,11 +58,11 @@ static upb_def* check_notfrozen(const upb_def* def) {
}
static
upb_msgdef
*
check_msg_notfrozen
(
const
upb_msgdef
*
def
)
{
return
(
upb_msgdef
*
)
check_notfrozen
((
const
upb_def
*
)
def
);
return
upb_downcast_msgdef_mutable
(
check_notfrozen
((
const
upb_def
*
)
def
)
);
}
static
upb_fielddef
*
check_field_notfrozen
(
const
upb_fielddef
*
def
)
{
return
(
upb_fielddef
*
)
check_notfrozen
((
const
upb_def
*
)
def
);
return
upb_downcast_fielddef_mutable
(
check_notfrozen
((
const
upb_def
*
)
def
)
);
}
static
upb_oneofdef
*
check_oneof_notfrozen
(
const
upb_oneofdef
*
def
)
{
...
...
ruby/ext/google/protobuf_c/encode_decode.c
View file @
9de35e74
...
...
@@ -558,11 +558,11 @@ static void add_handlers_for_message(const void *closure, upb_handlers *h) {
const
upb_fielddef
*
f
=
upb_msg_iter_field
(
&
i
);
size_t
offset
=
desc
->
layout
->
fields
[
upb_fielddef_index
(
f
)].
offset
+
sizeof
(
MessageHeader
);
size_t
oneof_case_offset
=
desc
->
layout
->
fields
[
upb_fielddef_index
(
f
)].
case_offset
+
sizeof
(
MessageHeader
);
if
(
upb_fielddef_containingoneof
(
f
))
{
size_t
oneof_case_offset
=
desc
->
layout
->
fields
[
upb_fielddef_index
(
f
)].
case_offset
+
sizeof
(
MessageHeader
);
add_handlers_for_oneof_field
(
h
,
f
,
offset
,
oneof_case_offset
);
}
else
if
(
is_map_field
(
f
))
{
add_handlers_for_mapfield
(
h
,
f
,
offset
,
desc
);
...
...
ruby/ext/google/protobuf_c/storage.c
View file @
9de35e74
...
...
@@ -366,6 +366,11 @@ const upb_fielddef* map_entry_value(const upb_msgdef* msgdef) {
// Memory layout management.
// -----------------------------------------------------------------------------
static
size_t
align_up_to
(
size_t
offset
,
size_t
granularity
)
{
// Granularity must be a power of two.
return
(
offset
+
granularity
-
1
)
&
~
(
granularity
-
1
);
}
MessageLayout
*
create_layout
(
const
upb_msgdef
*
msgdef
)
{
MessageLayout
*
layout
=
ALLOC
(
MessageLayout
);
int
nfields
=
upb_msgdef_numfields
(
msgdef
);
...
...
@@ -391,7 +396,7 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) {
field_size
=
native_slot_size
(
upb_fielddef_type
(
field
));
}
// Align current offset up to |size| granularity.
off
=
(
off
+
field_size
-
1
)
&
~
(
field_size
-
1
);
off
=
align_up_to
(
off
,
field_size
);
layout
->
fields
[
upb_fielddef_index
(
field
)].
offset
=
off
;
layout
->
fields
[
upb_fielddef_index
(
field
)].
case_offset
=
MESSAGE_FIELD_NO_CASE
;
off
+=
field_size
;
...
...
@@ -413,7 +418,7 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) {
// all fields.
size_t
field_size
=
NATIVE_SLOT_MAX_SIZE
;
// Align the offset.
off
=
(
off
+
field_size
-
1
)
&
~
(
field_size
-
1
);
off
=
align_up_to
(
off
,
field_size
);
// Assign all fields in the oneof this same offset.
upb_oneof_iter
fit
;
for
(
upb_oneof_begin
(
&
fit
,
oneof
);
...
...
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