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
12d8a514
Commit
12d8a514
authored
Feb 07, 2015
by
Jisi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get the map factory per mergeFrom() call for JavaNano.
parent
d9a6f27b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
2 deletions
+23
-2
InternalNano.java
.../src/main/java/com/google/protobuf/nano/InternalNano.java
+4
-1
javanano_helpers.cc
src/google/protobuf/compiler/javanano/javanano_helpers.cc
+11
-0
javanano_helpers.h
src/google/protobuf/compiler/javanano/javanano_helpers.h
+2
-0
javanano_map_field.cc
src/google/protobuf/compiler/javanano/javanano_map_field.cc
+1
-1
javanano_message.cc
src/google/protobuf/compiler/javanano/javanano_message.cc
+5
-0
No files found.
javanano/src/main/java/com/google/protobuf/nano/InternalNano.java
View file @
12d8a514
...
...
@@ -30,6 +30,8 @@
package
com
.
google
.
protobuf
.
nano
;
import
com.google.protobuf.nano.MapFactories.MapFactory
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Arrays
;
...
...
@@ -406,12 +408,13 @@ public final class InternalNano {
public
static
final
<
K
,
V
>
Map
<
K
,
V
>
mergeMapEntry
(
CodedInputByteBufferNano
input
,
Map
<
K
,
V
>
map
,
MapFactory
mapFactory
,
int
keyType
,
int
valueType
,
V
value
,
int
keyTag
,
int
valueTag
)
throws
IOException
{
map
=
MapFactories
.
getMapFactory
()
.
forMap
(
map
);
map
=
mapFactory
.
forMap
(
map
);
final
int
length
=
input
.
readRawVarint32
();
final
int
oldLimit
=
input
.
pushLimit
(
length
);
K
key
=
null
;
...
...
src/google/protobuf/compiler/javanano/javanano_helpers.cc
View file @
12d8a514
...
...
@@ -560,6 +560,17 @@ void SetBitOperationVariables(const string name,
(
*
variables
)[
"different_"
+
name
]
=
GenerateDifferentBit
(
bitIndex
);
}
bool
HasMapField
(
const
Descriptor
*
descriptor
)
{
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
++
i
)
{
const
FieldDescriptor
*
field
=
descriptor
->
field
(
i
);
if
(
field
->
type
()
==
FieldDescriptor
::
TYPE_MESSAGE
&&
IsMapEntry
(
field
->
message_type
()))
{
return
true
;
}
}
return
false
;
}
}
// namespace javanano
}
// namespace compiler
}
// namespace protobuf
...
...
src/google/protobuf/compiler/javanano/javanano_helpers.h
View file @
12d8a514
...
...
@@ -187,6 +187,8 @@ inline bool IsMapEntry(const Descriptor* descriptor) {
descriptor
->
file
()
->
syntax
()
==
FileDescriptor
::
SYNTAX_PROTO3
;
}
bool
HasMapField
(
const
Descriptor
*
descriptor
);
}
// namespace javanano
}
// namespace compiler
}
// namespace protobuf
...
...
src/google/protobuf/compiler/javanano/javanano_map_field.cc
View file @
12d8a514
...
...
@@ -134,7 +134,7 @@ void MapFieldGenerator::
GenerateMergingCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"this.$name$ = com.google.protobuf.nano.InternalNano.mergeMapEntry(
\n
"
" input, this.$name$,
\n
"
" input, this.$name$,
mapFactory,
\n
"
" com.google.protobuf.nano.InternalNano.$key_desc_type$,
\n
"
" com.google.protobuf.nano.InternalNano.$value_desc_type$,
\n
"
" $value_default$,
\n
"
...
...
src/google/protobuf/compiler/javanano/javanano_message.cc
View file @
12d8a514
...
...
@@ -345,6 +345,11 @@ void MessageGenerator::GenerateMergeFromMethods(io::Printer* printer) {
"classname"
,
descriptor_
->
name
());
printer
->
Indent
();
if
(
HasMapField
(
descriptor_
))
{
printer
->
Print
(
"com.google.protobuf.nano.MapFactories.MapFactory mapFactory =
\n
"
" com.google.protobuf.nano.MapFactories.getMapFactory();
\n
"
);
}
printer
->
Print
(
"while (true) {
\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