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
4041600a
Commit
4041600a
authored
Nov 13, 2017
by
Jisi Liu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '3.5.x' of github.com:google/protobuf into 3.5.x
parents
4493595f
2761122b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
9 deletions
+67
-9
CHANGES.txt
CHANGES.txt
+1
-0
conformance_test.cc
conformance/conformance_test.cc
+16
-0
MessageExtensions.cs
csharp/src/Google.Protobuf/MessageExtensions.cs
+16
-0
MessageParser.cs
csharp/src/Google.Protobuf/MessageParser.cs
+28
-4
Message.php
php/src/Google/Protobuf/Internal/Message.php
+6
-5
No files found.
CHANGES.txt
View file @
4041600a
...
...
@@ -62,6 +62,7 @@
C#
* Added unknown field support in JsonParser.
* Fixed oneof message field merge.
* Simplify parsing messages from array slices.
Ruby
* Unknown fields are now preserved by default.
...
...
conformance/conformance_test.cc
View file @
4041600a
...
...
@@ -1842,6 +1842,14 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"optionalInt64": null,
"optionalUint32": null,
"optionalUint64": null,
"optionalSint32": null,
"optionalSint64": null,
"optionalFixed32": null,
"optionalFixed64": null,
"optionalSfixed32": null,
"optionalSfixed64": null,
"optionalFloat": null,
"optionalDouble": null,
"optionalBool": null,
"optionalString": null,
"optionalBytes": null,
...
...
@@ -1851,6 +1859,14 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"repeatedInt64": null,
"repeatedUint32": null,
"repeatedUint64": null,
"repeatedSint32": null,
"repeatedSint64": null,
"repeatedFixed32": null,
"repeatedFixed64": null,
"repeatedSfixed32": null,
"repeatedSfixed64": null,
"repeatedFloat": null,
"repeatedDouble": null,
"repeatedBool": null,
"repeatedString": null,
"repeatedBytes": null,
...
...
csharp/src/Google.Protobuf/MessageExtensions.cs
View file @
4041600a
...
...
@@ -53,6 +53,22 @@ namespace Google.Protobuf
input
.
CheckReadEndOfStreamTag
();
}
/// <summary>
/// Merges data from the given byte array slice into an existing message.
/// </summary>
/// <param name="message">The message to merge the data into.</param>
/// <param name="data">The data containing the slice to merge, which must be protobuf-encoded binary data.</param>
/// <param name="offset">The offset of the slice to merge.</param>
/// <param name="length">The length of the slice to merge.</param>
public
static
void
MergeFrom
(
this
IMessage
message
,
byte
[]
data
,
int
offset
,
int
length
)
{
ProtoPreconditions
.
CheckNotNull
(
message
,
"message"
);
ProtoPreconditions
.
CheckNotNull
(
data
,
"data"
);
CodedInputStream
input
=
new
CodedInputStream
(
data
,
offset
,
length
);
message
.
MergeFrom
(
input
);
input
.
CheckReadEndOfStreamTag
();
}
/// <summary>
/// Merges data from the given byte string into an existing message.
/// </summary>
...
...
csharp/src/Google.Protobuf/MessageParser.cs
View file @
4041600a
...
...
@@ -64,12 +64,25 @@ namespace Google.Protobuf
/// <returns>The newly parsed message.</returns>
public
IMessage
ParseFrom
(
byte
[]
data
)
{
ProtoPreconditions
.
CheckNotNull
(
data
,
"data"
);
IMessage
message
=
factory
();
message
.
MergeFrom
(
data
);
return
message
;
}
/// <summary>
/// Parses a message from a byte array slice.
/// </summary>
/// <param name="data">The byte array containing the message. Must not be null.</param>
/// <param name="offset">The offset of the slice to parse.</param>
/// <param name="length">The length of the slice to parse.</param>
/// <returns>The newly parsed message.</returns>
public
IMessage
ParseFrom
(
byte
[]
data
,
int
offset
,
int
length
)
{
IMessage
message
=
factory
();
message
.
MergeFrom
(
data
,
offset
,
length
);
return
message
;
}
/// <summary>
/// Parses a message from the given byte string.
/// </summary>
...
...
@@ -77,7 +90,6 @@ namespace Google.Protobuf
/// <returns>The parsed message.</returns>
public
IMessage
ParseFrom
(
ByteString
data
)
{
ProtoPreconditions
.
CheckNotNull
(
data
,
"data"
);
IMessage
message
=
factory
();
message
.
MergeFrom
(
data
);
return
message
;
...
...
@@ -191,12 +203,25 @@ namespace Google.Protobuf
/// <returns>The newly parsed message.</returns>
public
new
T
ParseFrom
(
byte
[]
data
)
{
ProtoPreconditions
.
CheckNotNull
(
data
,
"data"
);
T
message
=
factory
();
message
.
MergeFrom
(
data
);
return
message
;
}
/// <summary>
/// Parses a message from a byte array slice.
/// </summary>
/// <param name="data">The byte array containing the message. Must not be null.</param>
/// <param name="offset">The offset of the slice to parse.</param>
/// <param name="length">The length of the slice to parse.</param>
/// <returns>The newly parsed message.</returns>
public
new
T
ParseFrom
(
byte
[]
data
,
int
offset
,
int
length
)
{
T
message
=
factory
();
message
.
MergeFrom
(
data
,
offset
,
length
);
return
message
;
}
/// <summary>
/// Parses a message from the given byte string.
/// </summary>
...
...
@@ -204,7 +229,6 @@ namespace Google.Protobuf
/// <returns>The parsed message.</returns>
public
new
T
ParseFrom
(
ByteString
data
)
{
ProtoPreconditions
.
CheckNotNull
(
data
,
"data"
);
T
message
=
factory
();
message
.
MergeFrom
(
data
);
return
message
;
...
...
php/src/Google/Protobuf/Internal/Message.php
View file @
4041600a
...
...
@@ -833,6 +833,8 @@ class Message
}
return
$value
;
case
GPBType
::
INT32
:
case
GPBType
::
SINT32
:
case
GPBType
::
SFIXED32
:
if
(
is_null
(
$value
))
{
return
$this
->
defaultValue
(
$field
);
}
...
...
@@ -850,6 +852,7 @@ class Message
}
return
$value
;
case
GPBType
::
UINT32
:
case
GPBType
::
FIXED32
:
if
(
is_null
(
$value
))
{
return
$this
->
defaultValue
(
$field
);
}
...
...
@@ -863,6 +866,8 @@ class Message
}
return
$value
;
case
GPBType
::
INT64
:
case
GPBType
::
SINT64
:
case
GPBType
::
SFIXED64
:
if
(
is_null
(
$value
))
{
return
$this
->
defaultValue
(
$field
);
}
...
...
@@ -880,6 +885,7 @@ class Message
}
return
$value
;
case
GPBType
::
UINT64
:
case
GPBType
::
FIXED64
:
if
(
is_null
(
$value
))
{
return
$this
->
defaultValue
(
$field
);
}
...
...
@@ -895,11 +901,6 @@ class Message
$value
=
bcsub
(
$value
,
"18446744073709551616"
);
}
return
$value
;
case
GPBType
::
FIXED64
:
if
(
is_null
(
$value
))
{
return
$this
->
defaultValue
(
$field
);
}
return
$value
;
default
:
return
$value
;
}
...
...
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