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
828b7e61
Commit
828b7e61
authored
Jun 17, 2015
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the fact that we know the tag size and bytes at codegen time to optimize.
parent
fb1547b3
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
970 additions
and
1188 deletions
+970
-1188
Addressbook.cs
csharp/src/AddressBook/Addressbook.cs
+19
-12
Program.cs
csharp/src/ProtoMunge/Program.cs
+2
-0
CodedInputStreamTest.cs
csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs
+6
-3
CodedOutputStreamTest.cs
csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
+11
-25
UnittestImportProto3.cs
...c/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs
+3
-2
UnittestImportPublicProto3.cs
...ocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs
+3
-2
UnittestIssues.cs
csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs
+31
-24
UnittestProto3.cs
csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs
+357
-256
CodedOutputStream.ComputeSize.cs
csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
+20
-200
CodedOutputStream.cs
csharp/src/ProtocolBuffers/CodedOutputStream.cs
+163
-454
DescriptorProtoFile.cs
...c/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
+278
-180
csharp_enum_field.cc
src/google/protobuf/compiler/csharp/csharp_enum_field.cc
+6
-4
csharp_field_base.cc
src/google/protobuf/compiler/csharp/csharp_field_base.cc
+13
-2
csharp_message_field.cc
src/google/protobuf/compiler/csharp/csharp_message_field.cc
+3
-3
csharp_primitive_field.cc
...google/protobuf/compiler/csharp/csharp_primitive_field.cc
+18
-5
csharp_repeated_enum_field.cc
...le/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
+16
-6
csharp_repeated_message_field.cc
...protobuf/compiler/csharp/csharp_repeated_message_field.cc
+4
-4
csharp_repeated_primitive_field.cc
...otobuf/compiler/csharp/csharp_repeated_primitive_field.cc
+16
-5
wire_format.h
src/google/protobuf/wire_format.h
+1
-1
No files found.
csharp/src/AddressBook/Addressbook.cs
View file @
828b7e61
...
...
@@ -139,13 +139,16 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
if
(
Id
!=
0
)
{
output
.
WriteInt32
(
2
,
Id
);
output
.
WriteRawTag
(
16
);
output
.
WriteInt32
(
Id
);
}
if
(
Email
.
Length
!=
0
)
{
output
.
WriteString
(
3
,
Email
);
output
.
WriteRawTag
(
26
);
output
.
WriteString
(
Email
);
}
if
(
phone_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
4
,
phone_
);
...
...
@@ -155,18 +158,19 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
if
(
Id
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
2
,
Id
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Id
);
}
if
(
Email
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
3
,
Email
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Email
);
}
if
(
phone_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
ProtocolBuffers
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
element
in
phone_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
4
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
phone_
.
Count
;
}
return
size
;
}
...
...
@@ -286,20 +290,22 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Number
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Number
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Number
);
}
if
(
Type
!=
global
::
Google
.
ProtocolBuffers
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneType
.
HOME
)
{
output
.
WriteEnum
(
2
,
(
int
)
Type
);
output
.
WriteRawTag
(
16
);
output
.
WriteEnum
((
int
)
Type
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Number
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Number
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Number
);
}
if
(
Type
!=
global
::
Google
.
ProtocolBuffers
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneType
.
HOME
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
2
,
(
int
)
Type
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
Type
);
}
return
size
;
}
...
...
@@ -401,8 +407,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
int
size
=
0
;
if
(
person_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
ProtocolBuffers
.
Examples
.
AddressBook
.
Person
element
in
person_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
1
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
person_
.
Count
;
}
return
size
;
}
...
...
csharp/src/ProtoMunge/Program.cs
View file @
828b7e61
...
...
@@ -38,6 +38,8 @@ using System;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.IO
;
using
Google.Protobuf
;
using
Google.Protobuf.Descriptors
;
using
Google.ProtocolBuffers.Descriptors
;
namespace
Google.ProtocolBuffers.ProtoMunge
...
...
csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs
View file @
828b7e61
...
...
@@ -479,7 +479,8 @@ namespace Google.Protobuf
int
msgSize
=
1
+
1
+
arraySize
;
byte
[]
bytes
=
new
byte
[
msgSize
];
CodedOutputStream
output
=
CodedOutputStream
.
CreateInstance
(
bytes
);
output
.
WritePackedInt32Array
(
8
,
new
RepeatedField
<
int
>
{
0
,
-
1
,
-
2
,
-
3
,
-
4
,
-
5
});
output
.
WriteTag
(
8
,
WireFormat
.
WireType
.
LengthDelimited
);
output
.
WritePackedInt32Array
(
new
RepeatedField
<
int
>
{
0
,
-
1
,
-
2
,
-
3
,
-
4
,
-
5
});
Assert
.
AreEqual
(
0
,
output
.
SpaceLeft
);
...
...
@@ -527,8 +528,10 @@ namespace Google.Protobuf
using
(
var
ms
=
new
MemoryStream
())
{
CodedOutputStream
output
=
CodedOutputStream
.
CreateInstance
(
ms
);
output
.
WriteBytes
(
1
,
ByteString
.
CopyFrom
(
new
byte
[
100
]));
output
.
WriteBytes
(
2
,
ByteString
.
CopyFrom
(
new
byte
[
100
]));
output
.
WriteTag
(
1
,
WireFormat
.
WireType
.
LengthDelimited
);
output
.
WriteBytes
(
ByteString
.
CopyFrom
(
new
byte
[
100
]));
output
.
WriteTag
(
2
,
WireFormat
.
WireType
.
LengthDelimited
);
output
.
WriteBytes
(
ByteString
.
CopyFrom
(
new
byte
[
100
]));
output
.
Flush
();
ms
.
Position
=
0
;
...
...
csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
View file @
828b7e61
...
...
@@ -295,12 +295,12 @@ namespace Google.Protobuf
[
Test
]
public
void
TestNegativeEnumNoTag
()
{
Assert
.
AreEqual
(
10
,
CodedOutputStream
.
ComputeInt32Size
NoTag
(-
2
));
Assert
.
AreEqual
(
10
,
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
TestNegEnum
.
Value
));
Assert
.
AreEqual
(
10
,
CodedOutputStream
.
ComputeInt32Size
(-
2
));
Assert
.
AreEqual
(
10
,
CodedOutputStream
.
ComputeEnumSize
((
int
)
TestNegEnum
.
Value
));
byte
[]
bytes
=
new
byte
[
10
];
CodedOutputStream
output
=
CodedOutputStream
.
CreateInstance
(
bytes
);
output
.
WriteEnum
NoTag
((
int
)
TestNegEnum
.
Value
);
output
.
WriteEnum
((
int
)
TestNegEnum
.
Value
);
Assert
.
AreEqual
(
0
,
output
.
SpaceLeft
);
Assert
.
AreEqual
(
"FE-FF-FF-FF-FF-FF-FF-FF-FF-01"
,
BitConverter
.
ToString
(
bytes
));
...
...
@@ -308,21 +308,6 @@ namespace Google.Protobuf
enum
TestNegEnum
{
None
=
0
,
Value
=
-
2
}
[
Test
]
public
void
TestNegativeEnumWithTag
()
{
Assert
.
AreEqual
(
11
,
CodedOutputStream
.
ComputeInt32Size
(
8
,
-
2
));
Assert
.
AreEqual
(
11
,
CodedOutputStream
.
ComputeEnumSize
(
8
,
(
int
)
TestNegEnum
.
Value
));
byte
[]
bytes
=
new
byte
[
11
];
CodedOutputStream
output
=
CodedOutputStream
.
CreateInstance
(
bytes
);
output
.
WriteEnum
(
8
,
(
int
)
TestNegEnum
.
Value
);
Assert
.
AreEqual
(
0
,
output
.
SpaceLeft
);
//fyi, 0x40 == 0x08 << 3 + 0, field num + wire format shift
Assert
.
AreEqual
(
"40-FE-FF-FF-FF-FF-FF-FF-FF-FF-01"
,
BitConverter
.
ToString
(
bytes
));
}
[
Test
]
public
void
TestNegativeEnumArrayPacked
()
{
...
...
@@ -330,7 +315,8 @@ namespace Google.Protobuf
int
msgSize
=
1
+
1
+
arraySize
;
byte
[]
bytes
=
new
byte
[
msgSize
];
CodedOutputStream
output
=
CodedOutputStream
.
CreateInstance
(
bytes
);
output
.
WritePackedEnumArray
(
8
,
new
RepeatedField
<
TestNegEnum
>
{
output
.
WriteTag
(
8
,
WireFormat
.
WireType
.
LengthDelimited
);
output
.
WritePackedEnumArray
(
new
RepeatedField
<
TestNegEnum
>
{
0
,
(
TestNegEnum
)
(-
1
),
TestNegEnum
.
Value
,
(
TestNegEnum
)
(-
3
),
(
TestNegEnum
)
(-
4
),
(
TestNegEnum
)
(-
5
)
});
Assert
.
AreEqual
(
0
,
output
.
SpaceLeft
);
...
...
@@ -384,17 +370,17 @@ namespace Google.Protobuf
// Field 11: numeric value: 500
cout
.
WriteTag
(
11
,
WireFormat
.
WireType
.
Varint
);
Assert
.
AreEqual
(
1
,
cout
.
Position
);
cout
.
WriteInt32
NoTag
(
500
);
cout
.
WriteInt32
(
500
);
Assert
.
AreEqual
(
3
,
cout
.
Position
);
//Field 12: length delimited 120 bytes
cout
.
WriteTag
(
12
,
WireFormat
.
WireType
.
LengthDelimited
);
Assert
.
AreEqual
(
4
,
cout
.
Position
);
cout
.
WriteBytes
NoTag
(
ByteString
.
CopyFrom
(
content
));
cout
.
WriteBytes
(
ByteString
.
CopyFrom
(
content
));
Assert
.
AreEqual
(
115
,
cout
.
Position
);
// Field 13: fixed numeric value: 501
cout
.
WriteTag
(
13
,
WireFormat
.
WireType
.
Fixed32
);
Assert
.
AreEqual
(
116
,
cout
.
Position
);
cout
.
WriteSFixed32
NoTag
(
501
);
cout
.
WriteSFixed32
(
501
);
Assert
.
AreEqual
(
120
,
cout
.
Position
);
cout
.
Flush
();
}
...
...
@@ -405,17 +391,17 @@ namespace Google.Protobuf
// Field 1: numeric value: 500
cout
.
WriteTag
(
1
,
WireFormat
.
WireType
.
Varint
);
Assert
.
AreEqual
(
1
,
cout
.
Position
);
cout
.
WriteInt32
NoTag
(
500
);
cout
.
WriteInt32
(
500
);
Assert
.
AreEqual
(
3
,
cout
.
Position
);
//Field 2: length delimited 120 bytes
cout
.
WriteTag
(
2
,
WireFormat
.
WireType
.
LengthDelimited
);
Assert
.
AreEqual
(
4
,
cout
.
Position
);
cout
.
WriteBytes
NoTag
(
ByteString
.
CopyFrom
(
child
));
cout
.
WriteBytes
(
ByteString
.
CopyFrom
(
child
));
Assert
.
AreEqual
(
125
,
cout
.
Position
);
// Field 3: fixed numeric value: 500
cout
.
WriteTag
(
3
,
WireFormat
.
WireType
.
Fixed32
);
Assert
.
AreEqual
(
126
,
cout
.
Position
);
cout
.
WriteSFixed32
NoTag
(
501
);
cout
.
WriteSFixed32
(
501
);
Assert
.
AreEqual
(
130
,
cout
.
Position
);
cout
.
Flush
();
}
...
...
csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs
View file @
828b7e61
...
...
@@ -109,14 +109,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
D
!=
0
)
{
output
.
WriteInt32
(
1
,
D
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
D
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
D
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
D
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
D
);
}
return
size
;
}
...
...
csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs
View file @
828b7e61
...
...
@@ -94,14 +94,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
E
!=
0
)
{
output
.
WriteInt32
(
1
,
E
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
E
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
E
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
E
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
E
);
}
return
size
;
}
...
...
csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs
View file @
828b7e61
...
...
@@ -155,25 +155,27 @@ namespace UnitTest.Issues.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Value
!=
global
::
UnitTest
.
Issues
.
TestProtos
.
NegativeEnum
.
NEGATIVE_ENUM_ZERO
)
{
output
.
WriteEnum
(
1
,
(
int
)
Value
);
output
.
WriteRawTag
(
8
);
output
.
WriteEnum
((
int
)
Value
);
}
if
(
values_
.
Count
>
0
)
{
output
.
WriteEnumArray
(
2
,
values_
);
}
if
(
packedValues_
.
Count
>
0
)
{
output
.
WritePackedEnumArray
(
3
,
packedValues_
);
output
.
WriteRawTag
(
26
);
output
.
WritePackedEnumArray
(
packedValues_
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Value
!=
global
::
UnitTest
.
Issues
.
TestProtos
.
NegativeEnum
.
NEGATIVE_ENUM_ZERO
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
1
,
(
int
)
Value
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
Value
);
}
if
(
values_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
UnitTest
.
Issues
.
TestProtos
.
NegativeEnum
element
in
values_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
1
*
values_
.
Count
;
...
...
@@ -181,11 +183,10 @@ namespace UnitTest.Issues.TestProtos {
if
(
packedValues_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
UnitTest
.
Issues
.
TestProtos
.
NegativeEnum
element
in
packedValues_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
1
;
size
+=
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
}
return
size
;
}
...
...
@@ -305,7 +306,7 @@ namespace UnitTest.Issues.TestProtos {
public
static
pb
::
MessageParser
<
DeprecatedFieldsMessage
>
Parser
{
get
{
return
_parser
;
}
}
private
static
readonly
string
[]
_fieldNames
=
new
string
[]
{
"EnumArray"
,
"EnumValue"
,
"MessageArray"
,
"MessageValue"
,
"PrimitiveArray"
,
"PrimitiveValue"
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
48
,
40
,
34
,
26
,
16
,
8
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
50
,
40
,
34
,
26
,
18
,
8
};
public
static
pbd
::
MessageDescriptor
Descriptor
{
get
{
return
global
::
UnitTest
.
Issues
.
TestProtos
.
UnittestIssues
.
internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor
;
}
}
...
...
@@ -397,57 +398,62 @@ namespace UnitTest.Issues.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
PrimitiveValue
!=
0
)
{
output
.
WriteInt32
(
1
,
PrimitiveValue
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
PrimitiveValue
);
}
if
(
primitiveArray_
.
Count
>
0
)
{
output
.
WritePackedInt32Array
(
2
,
primitiveArray_
);
output
.
WriteRawTag
(
18
);
output
.
WritePackedInt32Array
(
primitiveArray_
);
}
if
(
messageValue_
!=
null
)
{
output
.
WriteMessage
(
3
,
MessageValue
);
output
.
WriteRawTag
(
26
);
output
.
WriteMessage
(
MessageValue
);
}
if
(
messageArray_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
4
,
messageArray_
);
}
if
(
EnumValue
!=
global
::
UnitTest
.
Issues
.
TestProtos
.
DeprecatedEnum
.
DEPRECATED_ZERO
)
{
output
.
WriteEnum
(
5
,
(
int
)
EnumValue
);
output
.
WriteRawTag
(
40
);
output
.
WriteEnum
((
int
)
EnumValue
);
}
if
(
enumArray_
.
Count
>
0
)
{
output
.
WritePackedEnumArray
(
6
,
enumArray_
);
output
.
WriteRawTag
(
50
);
output
.
WritePackedEnumArray
(
enumArray_
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
PrimitiveValue
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
PrimitiveValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
PrimitiveValue
);
}
if
(
primitiveArray_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
primitiveArray_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
messageValue_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
3
,
MessageValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
MessageValue
);
}
if
(
messageArray_
.
Count
>
0
)
{
foreach
(
global
::
UnitTest
.
Issues
.
TestProtos
.
DeprecatedChild
element
in
messageArray_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
4
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
messageArray_
.
Count
;
}
if
(
EnumValue
!=
global
::
UnitTest
.
Issues
.
TestProtos
.
DeprecatedEnum
.
DEPRECATED_ZERO
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
5
,
(
int
)
EnumValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
EnumValue
);
}
if
(
enumArray_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
UnitTest
.
Issues
.
TestProtos
.
DeprecatedEnum
element
in
enumArray_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
1
;
size
+=
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
}
return
size
;
}
...
...
@@ -568,14 +574,15 @@ namespace UnitTest.Issues.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Item
!=
0
)
{
output
.
WriteInt32
(
1
,
Item
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
Item
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Item
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
Item
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Item
);
}
return
size
;
}
...
...
csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs
View file @
828b7e61
...
...
@@ -407,7 +407,7 @@ namespace Google.Protobuf.TestProtos {
public
static
pb
::
MessageParser
<
TestAllTypes
>
Parser
{
get
{
return
_parser
;
}
}
private
static
readonly
string
[]
_fieldNames
=
new
string
[]
{
"oneof_bytes"
,
"oneof_nested_message"
,
"oneof_string"
,
"oneof_uint32"
,
"repeated_bool"
,
"repeated_bytes"
,
"repeated_double"
,
"repeated_fixed32"
,
"repeated_fixed64"
,
"repeated_float"
,
"repeated_foreign_enum"
,
"repeated_foreign_message"
,
"repeated_import_enum"
,
"repeated_import_message"
,
"repeated_int32"
,
"repeated_int64"
,
"repeated_nested_enum"
,
"repeated_nested_message"
,
"repeated_public_import_message"
,
"repeated_sfixed32"
,
"repeated_sfixed64"
,
"repeated_sint32"
,
"repeated_sint64"
,
"repeated_string"
,
"repeated_uint32"
,
"repeated_uint64"
,
"single_bool"
,
"single_bytes"
,
"single_double"
,
"single_fixed32"
,
"single_fixed64"
,
"single_float"
,
"single_foreign_enum"
,
"single_foreign_message"
,
"single_import_enum"
,
"single_import_message"
,
"single_int32"
,
"single_int64"
,
"single_nested_enum"
,
"single_nested_message"
,
"single_public_import_message"
,
"single_sfixed32"
,
"single_sfixed64"
,
"single_sint32"
,
"single_sint64"
,
"single_string"
,
"single_uint32"
,
"single_uint64"
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
914
,
898
,
906
,
888
,
34
4
,
362
,
337
,
301
,
305
,
333
,
416
,
394
,
424
,
402
,
248
,
256
,
408
,
386
,
434
,
317
,
321
,
280
,
288
,
354
,
264
,
272
,
104
,
122
,
97
,
61
,
65
,
93
,
176
,
154
,
184
,
162
,
8
,
16
,
168
,
146
,
210
,
77
,
81
,
40
,
48
,
114
,
24
,
32
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
914
,
898
,
906
,
888
,
34
6
,
362
,
338
,
298
,
306
,
330
,
418
,
394
,
426
,
402
,
250
,
258
,
410
,
386
,
434
,
314
,
322
,
282
,
290
,
354
,
266
,
274
,
104
,
122
,
97
,
61
,
65
,
93
,
176
,
154
,
184
,
162
,
8
,
16
,
168
,
146
,
210
,
77
,
81
,
40
,
48
,
114
,
24
,
32
};
public
static
pbd
::
MessageDescriptor
Descriptor
{
get
{
return
global
::
Google
.
Protobuf
.
TestProtos
.
UnittestProto3
.
internal__static_protobuf_unittest_TestAllTypes__Descriptor
;
}
}
...
...
@@ -890,109 +890,144 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
SingleInt32
!=
0
)
{
output
.
WriteInt32
(
1
,
SingleInt32
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
SingleInt32
);
}
if
(
SingleInt64
!=
0L
)
{
output
.
WriteInt64
(
2
,
SingleInt64
);
output
.
WriteRawTag
(
16
);
output
.
WriteInt64
(
SingleInt64
);
}
if
(
SingleUint32
!=
0
)
{
output
.
WriteUInt32
(
3
,
SingleUint32
);
output
.
WriteRawTag
(
24
);
output
.
WriteUInt32
(
SingleUint32
);
}
if
(
SingleUint64
!=
0U
L
)
{
output
.
WriteUInt64
(
4
,
SingleUint64
);
output
.
WriteRawTag
(
32
);
output
.
WriteUInt64
(
SingleUint64
);
}
if
(
SingleSint32
!=
0
)
{
output
.
WriteSInt32
(
5
,
SingleSint32
);
output
.
WriteRawTag
(
40
);
output
.
WriteSInt32
(
SingleSint32
);
}
if
(
SingleSint64
!=
0L
)
{
output
.
WriteSInt64
(
6
,
SingleSint64
);
output
.
WriteRawTag
(
48
);
output
.
WriteSInt64
(
SingleSint64
);
}
if
(
SingleFixed32
!=
0
)
{
output
.
WriteFixed32
(
7
,
SingleFixed32
);
output
.
WriteRawTag
(
61
);
output
.
WriteFixed32
(
SingleFixed32
);
}
if
(
SingleFixed64
!=
0U
L
)
{
output
.
WriteFixed64
(
8
,
SingleFixed64
);
output
.
WriteRawTag
(
65
);
output
.
WriteFixed64
(
SingleFixed64
);
}
if
(
SingleSfixed32
!=
0
)
{
output
.
WriteSFixed32
(
9
,
SingleSfixed32
);
output
.
WriteRawTag
(
77
);
output
.
WriteSFixed32
(
SingleSfixed32
);
}
if
(
SingleSfixed64
!=
0L
)
{
output
.
WriteSFixed64
(
10
,
SingleSfixed64
);
output
.
WriteRawTag
(
81
);
output
.
WriteSFixed64
(
SingleSfixed64
);
}
if
(
SingleFloat
!=
0F
)
{
output
.
WriteFloat
(
11
,
SingleFloat
);
output
.
WriteRawTag
(
93
);
output
.
WriteFloat
(
SingleFloat
);
}
if
(
SingleDouble
!=
0D
)
{
output
.
WriteDouble
(
12
,
SingleDouble
);
output
.
WriteRawTag
(
97
);
output
.
WriteDouble
(
SingleDouble
);
}
if
(
SingleBool
!=
false
)
{
output
.
WriteBool
(
13
,
SingleBool
);
output
.
WriteRawTag
(
104
);
output
.
WriteBool
(
SingleBool
);
}
if
(
SingleString
.
Length
!=
0
)
{
output
.
WriteString
(
14
,
SingleString
);
output
.
WriteRawTag
(
114
);
output
.
WriteString
(
SingleString
);
}
if
(
SingleBytes
.
Length
!=
0
)
{
output
.
WriteBytes
(
15
,
SingleBytes
);
output
.
WriteRawTag
(
122
);
output
.
WriteBytes
(
SingleBytes
);
}
if
(
singleNestedMessage_
!=
null
)
{
output
.
WriteMessage
(
18
,
SingleNestedMessage
);
output
.
WriteRawTag
(
146
,
1
);
output
.
WriteMessage
(
SingleNestedMessage
);
}
if
(
singleForeignMessage_
!=
null
)
{
output
.
WriteMessage
(
19
,
SingleForeignMessage
);
output
.
WriteRawTag
(
154
,
1
);
output
.
WriteMessage
(
SingleForeignMessage
);
}
if
(
singleImportMessage_
!=
null
)
{
output
.
WriteMessage
(
20
,
SingleImportMessage
);
output
.
WriteRawTag
(
162
,
1
);
output
.
WriteMessage
(
SingleImportMessage
);
}
if
(
SingleNestedEnum
!=
global
::
Google
.
Protobuf
.
TestProtos
.
TestAllTypes
.
Types
.
NestedEnum
.
NESTED_ENUM_UNSPECIFIED
)
{
output
.
WriteEnum
(
21
,
(
int
)
SingleNestedEnum
);
output
.
WriteRawTag
(
168
,
1
);
output
.
WriteEnum
((
int
)
SingleNestedEnum
);
}
if
(
SingleForeignEnum
!=
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignEnum
.
FOREIGN_UNSPECIFIED
)
{
output
.
WriteEnum
(
22
,
(
int
)
SingleForeignEnum
);
output
.
WriteRawTag
(
176
,
1
);
output
.
WriteEnum
((
int
)
SingleForeignEnum
);
}
if
(
SingleImportEnum
!=
global
::
Google
.
Protobuf
.
TestProtos
.
ImportEnum
.
IMPORT_ENUM_UNSPECIFIED
)
{
output
.
WriteEnum
(
23
,
(
int
)
SingleImportEnum
);
output
.
WriteRawTag
(
184
,
1
);
output
.
WriteEnum
((
int
)
SingleImportEnum
);
}
if
(
singlePublicImportMessage_
!=
null
)
{
output
.
WriteMessage
(
26
,
SinglePublicImportMessage
);
output
.
WriteRawTag
(
210
,
1
);
output
.
WriteMessage
(
SinglePublicImportMessage
);
}
if
(
repeatedInt32_
.
Count
>
0
)
{
output
.
WritePackedInt32Array
(
31
,
repeatedInt32_
);
output
.
WriteRawTag
(
250
,
1
);
output
.
WritePackedInt32Array
(
repeatedInt32_
);
}
if
(
repeatedInt64_
.
Count
>
0
)
{
output
.
WritePackedInt64Array
(
32
,
repeatedInt64_
);
output
.
WriteRawTag
(
130
,
2
);
output
.
WritePackedInt64Array
(
repeatedInt64_
);
}
if
(
repeatedUint32_
.
Count
>
0
)
{
output
.
WritePackedUInt32Array
(
33
,
repeatedUint32_
);
output
.
WriteRawTag
(
138
,
2
);
output
.
WritePackedUInt32Array
(
repeatedUint32_
);
}
if
(
repeatedUint64_
.
Count
>
0
)
{
output
.
WritePackedUInt64Array
(
34
,
repeatedUint64_
);
output
.
WriteRawTag
(
146
,
2
);
output
.
WritePackedUInt64Array
(
repeatedUint64_
);
}
if
(
repeatedSint32_
.
Count
>
0
)
{
output
.
WritePackedSInt32Array
(
35
,
repeatedSint32_
);
output
.
WriteRawTag
(
154
,
2
);
output
.
WritePackedSInt32Array
(
repeatedSint32_
);
}
if
(
repeatedSint64_
.
Count
>
0
)
{
output
.
WritePackedSInt64Array
(
36
,
repeatedSint64_
);
output
.
WriteRawTag
(
162
,
2
);
output
.
WritePackedSInt64Array
(
repeatedSint64_
);
}
if
(
repeatedFixed32_
.
Count
>
0
)
{
output
.
WritePackedFixed32Array
(
37
,
repeatedFixed32_
);
output
.
WriteRawTag
(
170
,
2
);
output
.
WritePackedFixed32Array
(
repeatedFixed32_
);
}
if
(
repeatedFixed64_
.
Count
>
0
)
{
output
.
WritePackedFixed64Array
(
38
,
repeatedFixed64_
);
output
.
WriteRawTag
(
178
,
2
);
output
.
WritePackedFixed64Array
(
repeatedFixed64_
);
}
if
(
repeatedSfixed32_
.
Count
>
0
)
{
output
.
WritePackedSFixed32Array
(
39
,
repeatedSfixed32_
);
output
.
WriteRawTag
(
186
,
2
);
output
.
WritePackedSFixed32Array
(
repeatedSfixed32_
);
}
if
(
repeatedSfixed64_
.
Count
>
0
)
{
output
.
WritePackedSFixed64Array
(
40
,
repeatedSfixed64_
);
output
.
WriteRawTag
(
194
,
2
);
output
.
WritePackedSFixed64Array
(
repeatedSfixed64_
);
}
if
(
repeatedFloat_
.
Count
>
0
)
{
output
.
WritePackedFloatArray
(
41
,
repeatedFloat_
);
output
.
WriteRawTag
(
202
,
2
);
output
.
WritePackedFloatArray
(
repeatedFloat_
);
}
if
(
repeatedDouble_
.
Count
>
0
)
{
output
.
WritePackedDoubleArray
(
42
,
repeatedDouble_
);
output
.
WriteRawTag
(
210
,
2
);
output
.
WritePackedDoubleArray
(
repeatedDouble_
);
}
if
(
repeatedBool_
.
Count
>
0
)
{
output
.
WritePackedBoolArray
(
43
,
repeatedBool_
);
output
.
WriteRawTag
(
218
,
2
);
output
.
WritePackedBoolArray
(
repeatedBool_
);
}
if
(
repeatedString_
.
Count
>
0
)
{
output
.
WriteStringArray
(
44
,
repeatedString_
);
...
...
@@ -1010,193 +1045,200 @@ namespace Google.Protobuf.TestProtos {
output
.
WriteMessageArray
(
50
,
repeatedImportMessage_
);
}
if
(
repeatedNestedEnum_
.
Count
>
0
)
{
output
.
WritePackedEnumArray
(
51
,
repeatedNestedEnum_
);
output
.
WriteRawTag
(
154
,
3
);
output
.
WritePackedEnumArray
(
repeatedNestedEnum_
);
}
if
(
repeatedForeignEnum_
.
Count
>
0
)
{
output
.
WritePackedEnumArray
(
52
,
repeatedForeignEnum_
);
output
.
WriteRawTag
(
162
,
3
);
output
.
WritePackedEnumArray
(
repeatedForeignEnum_
);
}
if
(
repeatedImportEnum_
.
Count
>
0
)
{
output
.
WritePackedEnumArray
(
53
,
repeatedImportEnum_
);
output
.
WriteRawTag
(
170
,
3
);
output
.
WritePackedEnumArray
(
repeatedImportEnum_
);
}
if
(
repeatedPublicImportMessage_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
54
,
repeatedPublicImportMessage_
);
}
if
(
oneofFieldCase_
==
OneofFieldOneofCase
.
OneofUint32
)
{
output
.
WriteUInt32
(
111
,
OneofUint32
);
output
.
WriteRawTag
(
248
,
6
);
output
.
WriteUInt32
(
OneofUint32
);
}
if
(
oneofFieldCase_
==
OneofFieldOneofCase
.
OneofNestedMessage
)
{
output
.
WriteMessage
(
112
,
OneofNestedMessage
);
output
.
WriteRawTag
(
130
,
7
);
output
.
WriteMessage
(
OneofNestedMessage
);
}
if
(
oneofFieldCase_
==
OneofFieldOneofCase
.
OneofString
)
{
output
.
WriteString
(
113
,
OneofString
);
output
.
WriteRawTag
(
138
,
7
);
output
.
WriteString
(
OneofString
);
}
if
(
oneofFieldCase_
==
OneofFieldOneofCase
.
OneofBytes
)
{
output
.
WriteBytes
(
114
,
OneofBytes
);
output
.
WriteRawTag
(
146
,
7
);
output
.
WriteBytes
(
OneofBytes
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
SingleInt32
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
SingleInt32
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
SingleInt32
);
}
if
(
SingleInt64
!=
0L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
2
,
SingleInt64
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt64Size
(
SingleInt64
);
}
if
(
SingleUint32
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
3
,
SingleUint32
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
SingleUint32
);
}
if
(
SingleUint64
!=
0U
L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
4
,
SingleUint64
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
SingleUint64
);
}
if
(
SingleSint32
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeSInt32Size
(
5
,
SingleSint32
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeSInt32Size
(
SingleSint32
);
}
if
(
SingleSint64
!=
0L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeSInt64Size
(
6
,
SingleSint64
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeSInt64Size
(
SingleSint64
);
}
if
(
SingleFixed32
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeFixed32Size
(
7
,
SingleFixed32
)
;
size
+=
1
+
4
;
}
if
(
SingleFixed64
!=
0U
L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeFixed64Size
(
8
,
SingleFixed64
)
;
size
+=
1
+
8
;
}
if
(
SingleSfixed32
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeSFixed32Size
(
9
,
SingleSfixed32
)
;
size
+=
1
+
4
;
}
if
(
SingleSfixed64
!=
0L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeSFixed64Size
(
10
,
SingleSfixed64
)
;
size
+=
1
+
8
;
}
if
(
SingleFloat
!=
0F
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeFloatSize
(
11
,
SingleFloat
)
;
size
+=
1
+
4
;
}
if
(
SingleDouble
!=
0D
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeDoubleSize
(
12
,
SingleDouble
)
;
size
+=
1
+
8
;
}
if
(
SingleBool
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
13
,
SingleBool
)
;
size
+=
1
+
1
;
}
if
(
SingleString
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
14
,
SingleString
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
SingleString
);
}
if
(
SingleBytes
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBytesSize
(
15
,
SingleBytes
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeBytesSize
(
SingleBytes
);
}
if
(
singleNestedMessage_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
18
,
SingleNestedMessage
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
SingleNestedMessage
);
}
if
(
singleForeignMessage_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
19
,
SingleForeignMessage
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
SingleForeignMessage
);
}
if
(
singleImportMessage_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
20
,
SingleImportMessage
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
SingleImportMessage
);
}
if
(
SingleNestedEnum
!=
global
::
Google
.
Protobuf
.
TestProtos
.
TestAllTypes
.
Types
.
NestedEnum
.
NESTED_ENUM_UNSPECIFIED
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
21
,
(
int
)
SingleNestedEnum
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
SingleNestedEnum
);
}
if
(
SingleForeignEnum
!=
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignEnum
.
FOREIGN_UNSPECIFIED
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
22
,
(
int
)
SingleForeignEnum
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
SingleForeignEnum
);
}
if
(
SingleImportEnum
!=
global
::
Google
.
Protobuf
.
TestProtos
.
ImportEnum
.
IMPORT_ENUM_UNSPECIFIED
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
23
,
(
int
)
SingleImportEnum
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
SingleImportEnum
);
}
if
(
singlePublicImportMessage_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
26
,
SinglePublicImportMessage
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
SinglePublicImportMessage
);
}
if
(
repeatedInt32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
repeatedInt32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedInt64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
long
element
in
repeatedInt64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedUint32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
uint
element
in
repeatedUint32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedUint64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
ulong
element
in
repeatedUint64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedSint32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
repeatedSint32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedSint64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
long
element
in
repeatedSint64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedFixed32_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
4
*
repeatedFixed32_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedFixed64_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
8
*
repeatedFixed64_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedSfixed32_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
4
*
repeatedSfixed32_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedSfixed64_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
8
*
repeatedSfixed64_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedFloat_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
4
*
repeatedFloat_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedDouble_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
8
*
repeatedDouble_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedBool_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
1
*
repeatedBool_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedString_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
string
element
in
repeatedString_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
element
);
}
size
+=
dataSize
;
size
+=
2
*
repeatedString_
.
Count
;
...
...
@@ -1204,69 +1246,70 @@ namespace Google.Protobuf.TestProtos {
if
(
repeatedBytes_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
pb
::
ByteString
element
in
repeatedBytes_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeBytesSize
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeBytesSize
(
element
);
}
size
+=
dataSize
;
size
+=
2
*
repeatedBytes_
.
Count
;
}
if
(
repeatedNestedMessage_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
TestAllTypes
.
Types
.
NestedMessage
element
in
repeatedNestedMessage_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
48
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
repeatedNestedMessage_
.
Count
;
}
if
(
repeatedForeignMessage_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignMessage
element
in
repeatedForeignMessage_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
49
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
repeatedForeignMessage_
.
Count
;
}
if
(
repeatedImportMessage_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
ImportMessage
element
in
repeatedImportMessage_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
50
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
repeatedImportMessage_
.
Count
;
}
if
(
repeatedNestedEnum_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
TestAllTypes
.
Types
.
NestedEnum
element
in
repeatedNestedEnum_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
2
;
size
+=
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
}
if
(
repeatedForeignEnum_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignEnum
element
in
repeatedForeignEnum_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
2
;
size
+=
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
}
if
(
repeatedImportEnum_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
ImportEnum
element
in
repeatedImportEnum_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
2
;
size
+=
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
}
if
(
repeatedPublicImportMessage_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
PublicImportMessage
element
in
repeatedPublicImportMessage_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
54
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
repeatedPublicImportMessage_
.
Count
;
}
if
(
oneofFieldCase_
==
OneofFieldOneofCase
.
OneofUint32
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
111
,
OneofUint32
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
OneofUint32
);
}
if
(
oneofFieldCase_
==
OneofFieldOneofCase
.
OneofNestedMessage
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
112
,
OneofNestedMessage
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
OneofNestedMessage
);
}
if
(
oneofFieldCase_
==
OneofFieldOneofCase
.
OneofString
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
113
,
OneofString
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
OneofString
);
}
if
(
oneofFieldCase_
==
OneofFieldOneofCase
.
OneofBytes
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBytesSize
(
114
,
OneofBytes
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeBytesSize
(
OneofBytes
);
}
return
size
;
}
...
...
@@ -1607,8 +1650,8 @@ namespace Google.Protobuf.TestProtos {
break
;
}
case
888
:
{
OneofUint32
=
input
.
ReadUInt32
()
;
break
;
OneofUint32
=
input
.
ReadUInt32
()
;
break
;
}
case
898
:
{
global
::
Google
.
Protobuf
.
TestProtos
.
TestAllTypes
.
Types
.
NestedMessage
subBuilder
=
new
global
::
Google
.
Protobuf
.
TestProtos
.
TestAllTypes
.
Types
.
NestedMessage
();
...
...
@@ -1620,12 +1663,12 @@ namespace Google.Protobuf.TestProtos {
break
;
}
case
906
:
{
OneofString
=
input
.
ReadString
()
;
break
;
OneofString
=
input
.
ReadString
()
;
break
;
}
case
914
:
{
OneofBytes
=
input
.
ReadBytes
()
;
break
;
OneofBytes
=
input
.
ReadBytes
()
;
break
;
}
}
}
...
...
@@ -1692,14 +1735,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Bb
!=
0
)
{
output
.
WriteInt32
(
1
,
Bb
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
Bb
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Bb
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
Bb
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Bb
);
}
return
size
;
}
...
...
@@ -1802,10 +1846,12 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
child_
!=
null
)
{
output
.
WriteMessage
(
1
,
Child
);
output
.
WriteRawTag
(
10
);
output
.
WriteMessage
(
Child
);
}
if
(
payload_
!=
null
)
{
output
.
WriteMessage
(
2
,
Payload
);
output
.
WriteRawTag
(
18
);
output
.
WriteMessage
(
Payload
);
}
if
(
repeatedChild_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
3
,
repeatedChild_
);
...
...
@@ -1815,15 +1861,16 @@ namespace Google.Protobuf.TestProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
child_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
1
,
Child
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Child
);
}
if
(
payload_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
2
,
Payload
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Payload
);
}
if
(
repeatedChild_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
NestedTestAllTypes
element
in
repeatedChild_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
3
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
repeatedChild_
.
Count
;
}
return
size
;
}
...
...
@@ -1932,14 +1979,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
DeprecatedInt32
!=
0
)
{
output
.
WriteInt32
(
1
,
DeprecatedInt32
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
DeprecatedInt32
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
DeprecatedInt32
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
DeprecatedInt32
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
DeprecatedInt32
);
}
return
size
;
}
...
...
@@ -2023,14 +2071,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
C
!=
0
)
{
output
.
WriteInt32
(
1
,
C
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
C
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
C
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
C
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
C
);
}
return
size
;
}
...
...
@@ -2180,14 +2229,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
foreignNested_
!=
null
)
{
output
.
WriteMessage
(
1
,
ForeignNested
);
output
.
WriteRawTag
(
10
);
output
.
WriteMessage
(
ForeignNested
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
foreignNested_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
1
,
ForeignNested
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
ForeignNested
);
}
return
size
;
}
...
...
@@ -2287,20 +2337,22 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
A
!=
0
)
{
output
.
WriteInt32
(
1
,
A
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
A
);
}
if
(
Bb
!=
0
)
{
output
.
WriteInt32
(
268435455
,
Bb
);
output
.
WriteRawTag
(
248
,
255
,
255
,
255
,
7
);
output
.
WriteInt32
(
Bb
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
A
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
A
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
A
);
}
if
(
Bb
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
268435455
,
Bb
);
size
+=
5
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Bb
);
}
return
size
;
}
...
...
@@ -2399,20 +2451,22 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
a_
!=
null
)
{
output
.
WriteMessage
(
1
,
A
);
output
.
WriteRawTag
(
10
);
output
.
WriteMessage
(
A
);
}
if
(
I
!=
0
)
{
output
.
WriteInt32
(
2
,
I
);
output
.
WriteRawTag
(
16
);
output
.
WriteInt32
(
I
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
a_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
1
,
A
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
A
);
}
if
(
I
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
2
,
I
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
I
);
}
return
size
;
}
...
...
@@ -2507,14 +2561,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
bb_
!=
null
)
{
output
.
WriteMessage
(
1
,
Bb
);
output
.
WriteRawTag
(
10
);
output
.
WriteMessage
(
Bb
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
bb_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
1
,
Bb
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Bb
);
}
return
size
;
}
...
...
@@ -2612,20 +2667,22 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
a_
!=
null
)
{
output
.
WriteMessage
(
1
,
A
);
output
.
WriteRawTag
(
10
);
output
.
WriteMessage
(
A
);
}
if
(
OptionalInt32
!=
0
)
{
output
.
WriteInt32
(
2
,
OptionalInt32
);
output
.
WriteRawTag
(
16
);
output
.
WriteInt32
(
OptionalInt32
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
a_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
1
,
A
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
A
);
}
if
(
OptionalInt32
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
2
,
OptionalInt32
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
OptionalInt32
);
}
return
size
;
}
...
...
@@ -2678,7 +2735,7 @@ namespace Google.Protobuf.TestProtos {
public
static
pb
::
MessageParser
<
TestCamelCaseFieldNames
>
Parser
{
get
{
return
_parser
;
}
}
private
static
readonly
string
[]
_fieldNames
=
new
string
[]
{
"EnumField"
,
"MessageField"
,
"PrimitiveField"
,
"RepeatedEnumField"
,
"RepeatedMessageField"
,
"RepeatedPrimitiveField"
,
"RepeatedStringField"
,
"StringField"
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
24
,
34
,
8
,
7
2
,
82
,
56
,
66
,
18
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
24
,
34
,
8
,
7
4
,
82
,
58
,
66
,
18
};
public
static
pbd
::
MessageDescriptor
Descriptor
{
get
{
return
global
::
Google
.
Protobuf
.
TestProtos
.
UnittestProto3
.
internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor
;
}
}
...
...
@@ -2782,25 +2839,31 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
PrimitiveField
!=
0
)
{
output
.
WriteInt32
(
1
,
PrimitiveField
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
PrimitiveField
);
}
if
(
StringField
.
Length
!=
0
)
{
output
.
WriteString
(
2
,
StringField
);
output
.
WriteRawTag
(
18
);
output
.
WriteString
(
StringField
);
}
if
(
EnumField
!=
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignEnum
.
FOREIGN_UNSPECIFIED
)
{
output
.
WriteEnum
(
3
,
(
int
)
EnumField
);
output
.
WriteRawTag
(
24
);
output
.
WriteEnum
((
int
)
EnumField
);
}
if
(
messageField_
!=
null
)
{
output
.
WriteMessage
(
4
,
MessageField
);
output
.
WriteRawTag
(
34
);
output
.
WriteMessage
(
MessageField
);
}
if
(
repeatedPrimitiveField_
.
Count
>
0
)
{
output
.
WritePackedInt32Array
(
7
,
repeatedPrimitiveField_
);
output
.
WriteRawTag
(
58
);
output
.
WritePackedInt32Array
(
repeatedPrimitiveField_
);
}
if
(
repeatedStringField_
.
Count
>
0
)
{
output
.
WriteStringArray
(
8
,
repeatedStringField_
);
}
if
(
repeatedEnumField_
.
Count
>
0
)
{
output
.
WritePackedEnumArray
(
9
,
repeatedEnumField_
);
output
.
WriteRawTag
(
74
);
output
.
WritePackedEnumArray
(
repeatedEnumField_
);
}
if
(
repeatedMessageField_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
10
,
repeatedMessageField_
);
...
...
@@ -2810,29 +2873,29 @@ namespace Google.Protobuf.TestProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
PrimitiveField
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
PrimitiveField
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
PrimitiveField
);
}
if
(
StringField
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
2
,
StringField
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
StringField
);
}
if
(
EnumField
!=
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignEnum
.
FOREIGN_UNSPECIFIED
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
3
,
(
int
)
EnumField
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
EnumField
);
}
if
(
messageField_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
4
,
MessageField
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
MessageField
);
}
if
(
repeatedPrimitiveField_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
repeatedPrimitiveField_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedStringField_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
string
element
in
repeatedStringField_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
element
);
}
size
+=
dataSize
;
size
+=
1
*
repeatedStringField_
.
Count
;
...
...
@@ -2840,16 +2903,16 @@ namespace Google.Protobuf.TestProtos {
if
(
repeatedEnumField_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignEnum
element
in
repeatedEnumField_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
1
;
size
+=
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
}
if
(
repeatedMessageField_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignMessage
element
in
repeatedMessageField_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
10
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
repeatedMessageField_
.
Count
;
}
return
size
;
}
...
...
@@ -3010,32 +3073,36 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
MyInt
!=
0L
)
{
output
.
WriteInt64
(
1
,
MyInt
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt64
(
MyInt
);
}
if
(
MyString
.
Length
!=
0
)
{
output
.
WriteString
(
11
,
MyString
);
output
.
WriteRawTag
(
90
);
output
.
WriteString
(
MyString
);
}
if
(
MyFloat
!=
0F
)
{
output
.
WriteFloat
(
101
,
MyFloat
);
output
.
WriteRawTag
(
173
,
6
);
output
.
WriteFloat
(
MyFloat
);
}
if
(
singleNestedMessage_
!=
null
)
{
output
.
WriteMessage
(
200
,
SingleNestedMessage
);
output
.
WriteRawTag
(
194
,
12
);
output
.
WriteMessage
(
SingleNestedMessage
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
MyString
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
11
,
MyString
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
MyString
);
}
if
(
MyInt
!=
0L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
1
,
MyInt
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt64Size
(
MyInt
);
}
if
(
MyFloat
!=
0F
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeFloatSize
(
101
,
MyFloat
)
;
size
+=
2
+
4
;
}
if
(
singleNestedMessage_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
200
,
SingleNestedMessage
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
SingleNestedMessage
);
}
return
size
;
}
...
...
@@ -3157,20 +3224,22 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Bb
!=
0
)
{
output
.
WriteInt32
(
1
,
Bb
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
Bb
);
}
if
(
Oo
!=
0L
)
{
output
.
WriteInt64
(
2
,
Oo
);
output
.
WriteRawTag
(
16
);
output
.
WriteInt64
(
Oo
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Oo
!=
0L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
2
,
Oo
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt64Size
(
Oo
);
}
if
(
Bb
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
Bb
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Bb
);
}
return
size
;
}
...
...
@@ -3266,14 +3335,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
SparseEnum
!=
global
::
Google
.
Protobuf
.
TestProtos
.
TestSparseEnum
.
TEST_SPARSE_ENUM_UNSPECIFIED
)
{
output
.
WriteEnum
(
1
,
(
int
)
SparseEnum
);
output
.
WriteRawTag
(
8
);
output
.
WriteEnum
((
int
)
SparseEnum
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
SparseEnum
!=
global
::
Google
.
Protobuf
.
TestProtos
.
TestSparseEnum
.
TEST_SPARSE_ENUM_UNSPECIFIED
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
1
,
(
int
)
SparseEnum
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
SparseEnum
);
}
return
size
;
}
...
...
@@ -3357,14 +3427,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Data
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Data
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Data
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Data
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Data
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Data
);
}
return
size
;
}
...
...
@@ -3455,7 +3526,7 @@ namespace Google.Protobuf.TestProtos {
if
(
data_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
string
element
in
data_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
element
);
}
size
+=
dataSize
;
size
+=
1
*
data_
.
Count
;
...
...
@@ -3540,14 +3611,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Data
.
Length
!=
0
)
{
output
.
WriteBytes
(
1
,
Data
);
output
.
WriteRawTag
(
10
);
output
.
WriteBytes
(
Data
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Data
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBytesSize
(
1
,
Data
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeBytesSize
(
Data
);
}
return
size
;
}
...
...
@@ -3631,14 +3703,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Data
.
Length
!=
0
)
{
output
.
WriteBytes
(
1
,
Data
);
output
.
WriteRawTag
(
10
);
output
.
WriteBytes
(
Data
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Data
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBytesSize
(
1
,
Data
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeBytesSize
(
Data
);
}
return
size
;
}
...
...
@@ -3722,14 +3795,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Data
!=
0
)
{
output
.
WriteInt32
(
1
,
Data
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
Data
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Data
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
Data
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Data
);
}
return
size
;
}
...
...
@@ -3813,14 +3887,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Data
!=
0
)
{
output
.
WriteUInt32
(
1
,
Data
);
output
.
WriteRawTag
(
8
);
output
.
WriteUInt32
(
Data
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Data
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
1
,
Data
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
Data
);
}
return
size
;
}
...
...
@@ -3904,14 +3979,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Data
!=
0L
)
{
output
.
WriteInt64
(
1
,
Data
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt64
(
Data
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Data
!=
0L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
1
,
Data
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt64Size
(
Data
);
}
return
size
;
}
...
...
@@ -3995,14 +4071,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Data
!=
0U
L
)
{
output
.
WriteUInt64
(
1
,
Data
);
output
.
WriteRawTag
(
8
);
output
.
WriteUInt64
(
Data
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Data
!=
0U
L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
1
,
Data
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
Data
);
}
return
size
;
}
...
...
@@ -4086,14 +4163,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Data
!=
false
)
{
output
.
WriteBool
(
1
,
Data
);
output
.
WriteRawTag
(
8
);
output
.
WriteBool
(
Data
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Data
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
1
,
Data
)
;
size
+=
1
+
1
;
}
return
size
;
}
...
...
@@ -4216,26 +4294,29 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
fooCase_
==
FooOneofCase
.
FooInt
)
{
output
.
WriteInt32
(
1
,
FooInt
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
FooInt
);
}
if
(
fooCase_
==
FooOneofCase
.
FooString
)
{
output
.
WriteString
(
2
,
FooString
);
output
.
WriteRawTag
(
18
);
output
.
WriteString
(
FooString
);
}
if
(
fooCase_
==
FooOneofCase
.
FooMessage
)
{
output
.
WriteMessage
(
3
,
FooMessage
);
output
.
WriteRawTag
(
26
);
output
.
WriteMessage
(
FooMessage
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
fooCase_
==
FooOneofCase
.
FooInt
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
FooInt
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
FooInt
);
}
if
(
fooCase_
==
FooOneofCase
.
FooString
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
2
,
FooString
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
FooString
);
}
if
(
fooCase_
==
FooOneofCase
.
FooMessage
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
3
,
FooMessage
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
FooMessage
);
}
return
size
;
}
...
...
@@ -4269,12 +4350,12 @@ namespace Google.Protobuf.TestProtos {
}
break
;
case
8
:
{
FooInt
=
input
.
ReadInt32
()
;
break
;
FooInt
=
input
.
ReadInt32
()
;
break
;
}
case
18
:
{
FooString
=
input
.
ReadString
()
;
break
;
FooString
=
input
.
ReadString
()
;
break
;
}
case
26
:
{
global
::
Google
.
Protobuf
.
TestProtos
.
TestAllTypes
subBuilder
=
new
global
::
Google
.
Protobuf
.
TestProtos
.
TestAllTypes
();
...
...
@@ -4443,46 +4524,60 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
packedInt32_
.
Count
>
0
)
{
output
.
WritePackedInt32Array
(
90
,
packedInt32_
);
output
.
WriteRawTag
(
210
,
5
);
output
.
WritePackedInt32Array
(
packedInt32_
);
}
if
(
packedInt64_
.
Count
>
0
)
{
output
.
WritePackedInt64Array
(
91
,
packedInt64_
);
output
.
WriteRawTag
(
218
,
5
);
output
.
WritePackedInt64Array
(
packedInt64_
);
}
if
(
packedUint32_
.
Count
>
0
)
{
output
.
WritePackedUInt32Array
(
92
,
packedUint32_
);
output
.
WriteRawTag
(
226
,
5
);
output
.
WritePackedUInt32Array
(
packedUint32_
);
}
if
(
packedUint64_
.
Count
>
0
)
{
output
.
WritePackedUInt64Array
(
93
,
packedUint64_
);
output
.
WriteRawTag
(
234
,
5
);
output
.
WritePackedUInt64Array
(
packedUint64_
);
}
if
(
packedSint32_
.
Count
>
0
)
{
output
.
WritePackedSInt32Array
(
94
,
packedSint32_
);
output
.
WriteRawTag
(
242
,
5
);
output
.
WritePackedSInt32Array
(
packedSint32_
);
}
if
(
packedSint64_
.
Count
>
0
)
{
output
.
WritePackedSInt64Array
(
95
,
packedSint64_
);
output
.
WriteRawTag
(
250
,
5
);
output
.
WritePackedSInt64Array
(
packedSint64_
);
}
if
(
packedFixed32_
.
Count
>
0
)
{
output
.
WritePackedFixed32Array
(
96
,
packedFixed32_
);
output
.
WriteRawTag
(
130
,
6
);
output
.
WritePackedFixed32Array
(
packedFixed32_
);
}
if
(
packedFixed64_
.
Count
>
0
)
{
output
.
WritePackedFixed64Array
(
97
,
packedFixed64_
);
output
.
WriteRawTag
(
138
,
6
);
output
.
WritePackedFixed64Array
(
packedFixed64_
);
}
if
(
packedSfixed32_
.
Count
>
0
)
{
output
.
WritePackedSFixed32Array
(
98
,
packedSfixed32_
);
output
.
WriteRawTag
(
146
,
6
);
output
.
WritePackedSFixed32Array
(
packedSfixed32_
);
}
if
(
packedSfixed64_
.
Count
>
0
)
{
output
.
WritePackedSFixed64Array
(
99
,
packedSfixed64_
);
output
.
WriteRawTag
(
154
,
6
);
output
.
WritePackedSFixed64Array
(
packedSfixed64_
);
}
if
(
packedFloat_
.
Count
>
0
)
{
output
.
WritePackedFloatArray
(
100
,
packedFloat_
);
output
.
WriteRawTag
(
162
,
6
);
output
.
WritePackedFloatArray
(
packedFloat_
);
}
if
(
packedDouble_
.
Count
>
0
)
{
output
.
WritePackedDoubleArray
(
101
,
packedDouble_
);
output
.
WriteRawTag
(
170
,
6
);
output
.
WritePackedDoubleArray
(
packedDouble_
);
}
if
(
packedBool_
.
Count
>
0
)
{
output
.
WritePackedBoolArray
(
102
,
packedBool_
);
output
.
WriteRawTag
(
178
,
6
);
output
.
WritePackedBoolArray
(
packedBool_
);
}
if
(
packedEnum_
.
Count
>
0
)
{
output
.
WritePackedEnumArray
(
103
,
packedEnum_
);
output
.
WriteRawTag
(
186
,
6
);
output
.
WritePackedEnumArray
(
packedEnum_
);
}
}
...
...
@@ -4491,101 +4586,100 @@ namespace Google.Protobuf.TestProtos {
if
(
packedInt32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
packedInt32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedInt64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
long
element
in
packedInt64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedUint32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
uint
element
in
packedUint32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedUint64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
ulong
element
in
packedUint64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedSint32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
packedSint32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedSint64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
long
element
in
packedSint64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedFixed32_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
4
*
packedFixed32_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedFixed64_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
8
*
packedFixed64_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedSfixed32_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
4
*
packedSfixed32_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedSfixed64_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
8
*
packedSfixed64_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedFloat_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
4
*
packedFloat_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedDouble_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
8
*
packedDouble_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedBool_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
1
*
packedBool_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
packedEnum_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignEnum
element
in
packedEnum_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
2
;
size
+=
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeRawVarint32Size
((
uint
)
dataSize
);
}
return
size
;
}
...
...
@@ -4896,7 +4990,7 @@ namespace Google.Protobuf.TestProtos {
if
(
unpackedInt32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
unpackedInt32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
*
unpackedInt32_
.
Count
;
...
...
@@ -4904,7 +4998,7 @@ namespace Google.Protobuf.TestProtos {
if
(
unpackedInt64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
long
element
in
unpackedInt64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
*
unpackedInt64_
.
Count
;
...
...
@@ -4912,7 +5006,7 @@ namespace Google.Protobuf.TestProtos {
if
(
unpackedUint32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
uint
element
in
unpackedUint32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
*
unpackedUint32_
.
Count
;
...
...
@@ -4920,7 +5014,7 @@ namespace Google.Protobuf.TestProtos {
if
(
unpackedUint64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
ulong
element
in
unpackedUint64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
*
unpackedUint64_
.
Count
;
...
...
@@ -4928,7 +5022,7 @@ namespace Google.Protobuf.TestProtos {
if
(
unpackedSint32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
unpackedSint32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
*
unpackedSint32_
.
Count
;
...
...
@@ -4936,7 +5030,7 @@ namespace Google.Protobuf.TestProtos {
if
(
unpackedSint64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
long
element
in
unpackedSint64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeSInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
*
unpackedSint64_
.
Count
;
...
...
@@ -4986,7 +5080,7 @@ namespace Google.Protobuf.TestProtos {
if
(
unpackedEnum_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
global
::
Google
.
Protobuf
.
TestProtos
.
ForeignEnum
element
in
unpackedEnum_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
NoTag
((
int
)
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
((
int
)
element
);
}
size
+=
dataSize
;
size
+=
2
*
unpackedEnum_
.
Count
;
...
...
@@ -5106,7 +5200,7 @@ namespace Google.Protobuf.TestProtos {
public
static
pb
::
MessageParser
<
TestRepeatedScalarDifferentTagSizes
>
Parser
{
get
{
return
_parser
;
}
}
private
static
readonly
string
[]
_fieldNames
=
new
string
[]
{
"repeated_fixed32"
,
"repeated_fixed64"
,
"repeated_float"
,
"repeated_int32"
,
"repeated_int64"
,
"repeated_uint64"
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
101
,
16369
,
2097141
,
104
,
16376
,
2097144
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
98
,
16370
,
2097138
,
106
,
16378
,
2097146
};
public
static
pbd
::
MessageDescriptor
Descriptor
{
get
{
return
global
::
Google
.
Protobuf
.
TestProtos
.
UnittestProto3
.
internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor
;
}
}
...
...
@@ -5188,22 +5282,28 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
repeatedFixed32_
.
Count
>
0
)
{
output
.
WritePackedFixed32Array
(
12
,
repeatedFixed32_
);
output
.
WriteRawTag
(
98
);
output
.
WritePackedFixed32Array
(
repeatedFixed32_
);
}
if
(
repeatedInt32_
.
Count
>
0
)
{
output
.
WritePackedInt32Array
(
13
,
repeatedInt32_
);
output
.
WriteRawTag
(
106
);
output
.
WritePackedInt32Array
(
repeatedInt32_
);
}
if
(
repeatedFixed64_
.
Count
>
0
)
{
output
.
WritePackedFixed64Array
(
2046
,
repeatedFixed64_
);
output
.
WriteRawTag
(
242
,
127
);
output
.
WritePackedFixed64Array
(
repeatedFixed64_
);
}
if
(
repeatedInt64_
.
Count
>
0
)
{
output
.
WritePackedInt64Array
(
2047
,
repeatedInt64_
);
output
.
WriteRawTag
(
250
,
127
);
output
.
WritePackedInt64Array
(
repeatedInt64_
);
}
if
(
repeatedFloat_
.
Count
>
0
)
{
output
.
WritePackedFloatArray
(
262142
,
repeatedFloat_
);
output
.
WriteRawTag
(
242
,
255
,
127
);
output
.
WritePackedFloatArray
(
repeatedFloat_
);
}
if
(
repeatedUint64_
.
Count
>
0
)
{
output
.
WritePackedUInt64Array
(
262143
,
repeatedUint64_
);
output
.
WriteRawTag
(
250
,
255
,
127
);
output
.
WritePackedUInt64Array
(
repeatedUint64_
);
}
}
...
...
@@ -5213,43 +5313,43 @@ namespace Google.Protobuf.TestProtos {
int
dataSize
=
0
;
dataSize
=
4
*
repeatedFixed32_
.
Count
;
size
+=
dataSize
;
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedInt32_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
repeatedInt32_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedFixed64_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
8
*
repeatedFixed64_
.
Count
;
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedInt64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
long
element
in
repeatedInt64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedFloat_
.
Count
>
0
)
{
int
dataSize
=
0
;
dataSize
=
4
*
repeatedFloat_
.
Count
;
size
+=
dataSize
;
size
+=
3
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
3
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
repeatedUint64_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
ulong
element
in
repeatedUint64_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
element
);
}
size
+=
dataSize
;
size
+=
3
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
3
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
return
size
;
}
...
...
@@ -5362,14 +5462,15 @@ namespace Google.Protobuf.TestProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
A
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
A
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
A
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
A
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
A
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
A
);
}
return
size
;
}
...
...
csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
View file @
828b7e61
...
...
@@ -47,193 +47,13 @@ namespace Google.Protobuf
public
sealed
partial
class
CodedOutputStream
{
private
const
int
LittleEndian64Size
=
8
;
private
const
int
LittleEndian32Size
=
4
;
private
const
int
LittleEndian32Size
=
4
;
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// double field, including the tag.
/// </summary>
public
static
int
ComputeDoubleSize
(
int
fieldNumber
,
double
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
LittleEndian64Size
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// float field, including the tag.
/// </summary>
public
static
int
ComputeFloatSize
(
int
fieldNumber
,
float
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
LittleEndian32Size
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// uint64 field, including the tag.
/// </summary>
public
static
int
ComputeUInt64Size
(
int
fieldNumber
,
ulong
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint64Size
(
value
);
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// int64 field, including the tag.
/// </summary>
public
static
int
ComputeInt64Size
(
int
fieldNumber
,
long
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint64Size
((
ulong
)
value
);
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// int32 field, including the tag.
/// </summary>
public
static
int
ComputeInt32Size
(
int
fieldNumber
,
int
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeInt32SizeNoTag
(
value
);
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// fixed64 field, including the tag.
/// </summary>
public
static
int
ComputeFixed64Size
(
int
fieldNumber
,
ulong
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
LittleEndian64Size
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// fixed32 field, including the tag.
/// </summary>
public
static
int
ComputeFixed32Size
(
int
fieldNumber
,
uint
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
LittleEndian32Size
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// bool field, including the tag.
/// </summary>
public
static
int
ComputeBoolSize
(
int
fieldNumber
,
bool
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
1
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// string field, including the tag.
/// </summary>
public
static
int
ComputeStringSize
(
int
fieldNumber
,
String
value
)
{
int
byteArraySize
=
UTF8
.
GetByteCount
(
value
);
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint32Size
((
uint
)
byteArraySize
)
+
byteArraySize
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// group field, including the tag.
/// </summary>
public
static
int
ComputeGroupSize
(
int
fieldNumber
,
IMessage
value
)
{
return
ComputeTagSize
(
fieldNumber
)*
2
+
value
.
CalculateSize
();
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// group field represented by an UnknownFieldSet, including the tag.
/// </summary>
[
Obsolete
]
public
static
int
ComputeUnknownGroupSize
(
int
fieldNumber
,
IMessage
value
)
{
return
ComputeTagSize
(
fieldNumber
)*
2
+
value
.
CalculateSize
();
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// embedded message field, including the tag.
/// </summary>
public
static
int
ComputeMessageSize
(
int
fieldNumber
,
IMessage
value
)
{
int
size
=
value
.
CalculateSize
();
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint32Size
((
uint
)
size
)
+
size
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// bytes field, including the tag.
/// </summary>
public
static
int
ComputeBytesSize
(
int
fieldNumber
,
ByteString
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint32Size
((
uint
)
value
.
Length
)
+
value
.
Length
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// uint32 field, including the tag.
/// </summary>
public
static
int
ComputeUInt32Size
(
int
fieldNumber
,
uint
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint32Size
(
value
);
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// enum field, including the tag. The caller is responsible for
/// converting the enum value to its numeric value.
/// </summary>
public
static
int
ComputeEnumSize
(
int
fieldNumber
,
int
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeEnumSizeNoTag
(
value
);
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// sfixed32 field, including the tag.
/// </summary>
public
static
int
ComputeSFixed32Size
(
int
fieldNumber
,
int
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
LittleEndian32Size
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// sfixed64 field, including the tag.
/// </summary>
public
static
int
ComputeSFixed64Size
(
int
fieldNumber
,
long
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
LittleEndian64Size
;
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// sint32 field, including the tag.
/// </summary>
public
static
int
ComputeSInt32Size
(
int
fieldNumber
,
int
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint32Size
(
EncodeZigZag32
(
value
));
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// sint64 field, including the tag.
/// </summary>
public
static
int
ComputeSInt64Size
(
int
fieldNumber
,
long
value
)
{
return
ComputeTagSize
(
fieldNumber
)
+
ComputeRawVarint64Size
(
EncodeZigZag64
(
value
));
}
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// double field, including the tag.
/// </summary>
public
static
int
ComputeDoubleSizeNoTag
(
double
value
)
public
static
int
ComputeDoubleSize
(
double
value
)
{
return
LittleEndian64Size
;
}
...
...
@@ -242,7 +62,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// float field, including the tag.
/// </summary>
public
static
int
ComputeFloatSize
NoTag
(
float
value
)
public
static
int
ComputeFloatSize
(
float
value
)
{
return
LittleEndian32Size
;
}
...
...
@@ -251,7 +71,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// uint64 field, including the tag.
/// </summary>
public
static
int
ComputeUInt64Size
NoTag
(
ulong
value
)
public
static
int
ComputeUInt64Size
(
ulong
value
)
{
return
ComputeRawVarint64Size
(
value
);
}
...
...
@@ -260,7 +80,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// int64 field, including the tag.
/// </summary>
public
static
int
ComputeInt64Size
NoTag
(
long
value
)
public
static
int
ComputeInt64Size
(
long
value
)
{
return
ComputeRawVarint64Size
((
ulong
)
value
);
}
...
...
@@ -269,7 +89,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// int32 field, including the tag.
/// </summary>
public
static
int
ComputeInt32Size
NoTag
(
int
value
)
public
static
int
ComputeInt32Size
(
int
value
)
{
if
(
value
>=
0
)
{
...
...
@@ -286,7 +106,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// fixed64 field, including the tag.
/// </summary>
public
static
int
ComputeFixed64Size
NoTag
(
ulong
value
)
public
static
int
ComputeFixed64Size
(
ulong
value
)
{
return
LittleEndian64Size
;
}
...
...
@@ -295,7 +115,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// fixed32 field, including the tag.
/// </summary>
public
static
int
ComputeFixed32Size
NoTag
(
uint
value
)
public
static
int
ComputeFixed32Size
(
uint
value
)
{
return
LittleEndian32Size
;
}
...
...
@@ -304,7 +124,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// bool field, including the tag.
/// </summary>
public
static
int
ComputeBoolSize
NoTag
(
bool
value
)
public
static
int
ComputeBoolSize
(
bool
value
)
{
return
1
;
}
...
...
@@ -313,7 +133,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// string field, including the tag.
/// </summary>
public
static
int
ComputeStringSize
NoTag
(
String
value
)
public
static
int
ComputeStringSize
(
String
value
)
{
int
byteArraySize
=
UTF8
.
GetByteCount
(
value
);
return
ComputeRawVarint32Size
((
uint
)
byteArraySize
)
+
...
...
@@ -324,7 +144,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// group field, including the tag.
/// </summary>
public
static
int
ComputeGroupSize
NoTag
(
IMessage
value
)
public
static
int
ComputeGroupSize
(
IMessage
value
)
{
return
value
.
CalculateSize
();
}
...
...
@@ -333,7 +153,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// embedded message field, including the tag.
/// </summary>
public
static
int
ComputeMessageSize
NoTag
(
IMessage
value
)
public
static
int
ComputeMessageSize
(
IMessage
value
)
{
int
size
=
value
.
CalculateSize
();
return
ComputeRawVarint32Size
((
uint
)
size
)
+
size
;
...
...
@@ -343,7 +163,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// bytes field, including the tag.
/// </summary>
public
static
int
ComputeBytesSize
NoTag
(
ByteString
value
)
public
static
int
ComputeBytesSize
(
ByteString
value
)
{
return
ComputeRawVarint32Size
((
uint
)
value
.
Length
)
+
value
.
Length
;
...
...
@@ -353,7 +173,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// uint32 field, including the tag.
/// </summary>
public
static
int
ComputeUInt32Size
NoTag
(
uint
value
)
public
static
int
ComputeUInt32Size
(
uint
value
)
{
return
ComputeRawVarint32Size
(
value
);
}
...
...
@@ -363,17 +183,17 @@ namespace Google.Protobuf
/// enum field, including the tag. The caller is responsible for
/// converting the enum value to its numeric value.
/// </summary>
public
static
int
ComputeEnumSize
NoTag
(
int
value
)
public
static
int
ComputeEnumSize
(
int
value
)
{
// Currently just a pass-through, but it's nice to separate it logically.
return
ComputeInt32Size
NoTag
(
value
);
return
ComputeInt32Size
(
value
);
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// sfixed32 field, including the tag.
/// </summary>
public
static
int
ComputeSFixed32Size
NoTag
(
int
value
)
public
static
int
ComputeSFixed32Size
(
int
value
)
{
return
LittleEndian32Size
;
}
...
...
@@ -382,7 +202,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// sfixed64 field, including the tag.
/// </summary>
public
static
int
ComputeSFixed64Size
NoTag
(
long
value
)
public
static
int
ComputeSFixed64Size
(
long
value
)
{
return
LittleEndian64Size
;
}
...
...
@@ -391,7 +211,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// sint32 field, including the tag.
/// </summary>
public
static
int
ComputeSInt32Size
NoTag
(
int
value
)
public
static
int
ComputeSInt32Size
(
int
value
)
{
return
ComputeRawVarint32Size
(
EncodeZigZag32
(
value
));
}
...
...
@@ -400,7 +220,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// sint64 field, including the tag.
/// </summary>
public
static
int
ComputeSInt64Size
NoTag
(
long
value
)
public
static
int
ComputeSInt64Size
(
long
value
)
{
return
ComputeRawVarint64Size
(
EncodeZigZag64
(
value
));
}
...
...
csharp/src/ProtocolBuffers/CodedOutputStream.cs
View file @
828b7e61
...
...
@@ -143,248 +143,12 @@ namespace Google.Protobuf
}
}
#
region
Writing
of
tags
and
fields
/// <summary>
/// Writes a double field value, including tag, to the stream.
/// </summary>
public
void
WriteDouble
(
int
fieldNumber
,
double
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteDoubleNoTag
(
value
);
}
/// <summary>
/// Writes a float field value, including tag, to the stream.
/// </summary>
public
void
WriteFloat
(
int
fieldNumber
,
float
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
WriteFloatNoTag
(
value
);
}
/// <summary>
/// Writes a uint64 field value, including tag, to the stream.
/// </summary>
public
void
WriteUInt64
(
int
fieldNumber
,
ulong
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteRawVarint64
(
value
);
}
/// <summary>
/// Writes an int64 field value, including tag, to the stream.
/// </summary>
public
void
WriteInt64
(
int
fieldNumber
,
long
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteRawVarint64
((
ulong
)
value
);
}
/// <summary>
/// Writes an int32 field value, including tag, to the stream.
/// </summary>
public
void
WriteInt32
(
int
fieldNumber
,
int
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
if
(
value
>=
0
)
{
WriteRawVarint32
((
uint
)
value
);
}
else
{
// Must sign-extend.
WriteRawVarint64
((
ulong
)
value
);
}
}
/// <summary>
/// Writes a fixed64 field value, including tag, to the stream.
/// </summary>
public
void
WriteFixed64
(
int
fieldNumber
,
ulong
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteRawLittleEndian64
(
value
);
}
/// <summary>
/// Writes a fixed32 field value, including tag, to the stream.
/// </summary>
public
void
WriteFixed32
(
int
fieldNumber
,
uint
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
WriteRawLittleEndian32
(
value
);
}
/// <summary>
/// Writes a bool field value, including tag, to the stream.
/// </summary>
public
void
WriteBool
(
int
fieldNumber
,
bool
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteRawByte
(
value
?
(
byte
)
1
:
(
byte
)
0
);
}
/// <summary>
/// Writes a string field value, including tag, to the stream.
/// </summary>
public
void
WriteString
(
int
fieldNumber
,
string
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
// Optimise the case where we have enough space to write
// the string directly to the buffer, which should be common.
int
length
=
UTF8
.
GetByteCount
(
value
);
WriteRawVarint32
((
uint
)
length
);
if
(
limit
-
position
>=
length
)
{
if
(
length
==
value
.
Length
)
// Must be all ASCII...
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
buffer
[
position
+
i
]
=
(
byte
)
value
[
i
];
}
}
else
{
UTF8
.
GetBytes
(
value
,
0
,
value
.
Length
,
buffer
,
position
);
}
position
+=
length
;
}
else
{
byte
[]
bytes
=
UTF8
.
GetBytes
(
value
);
WriteRawBytes
(
bytes
);
}
}
/// <summary>
/// Writes a group field value, including tag, to the stream.
/// </summary>
public
void
WriteGroup
(
int
fieldNumber
,
IMessage
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
StartGroup
);
value
.
WriteTo
(
this
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
EndGroup
);
}
public
void
WriteMessage
(
int
fieldNumber
,
IMessage
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
((
uint
)
value
.
CalculateSize
());
value
.
WriteTo
(
this
);
}
public
void
WriteBytes
(
int
fieldNumber
,
ByteString
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
((
uint
)
value
.
Length
);
value
.
WriteRawBytesTo
(
this
);
}
public
void
WriteUInt32
(
int
fieldNumber
,
uint
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteRawVarint32
(
value
);
}
public
void
WriteEnum
(
int
fieldNumber
,
int
value
)
{
// Currently just a pass-through, but it's nice to separate it logically from WriteInt32.
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteInt32NoTag
(
value
);
}
public
void
WriteSFixed32
(
int
fieldNumber
,
int
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
WriteRawLittleEndian32
((
uint
)
value
);
}
public
void
WriteSFixed64
(
int
fieldNumber
,
long
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteRawLittleEndian64
((
ulong
)
value
);
}
public
void
WriteSInt32
(
int
fieldNumber
,
int
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteRawVarint32
(
EncodeZigZag32
(
value
));
}
public
void
WriteSInt64
(
int
fieldNumber
,
long
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteRawVarint64
(
EncodeZigZag64
(
value
));
}
#
endregion
#
region
Writing
of
values
without
tags
// TODO(jonskeet): Remove this?
public
void
WriteFieldNoTag
(
FieldType
fieldType
,
object
value
)
{
switch
(
fieldType
)
{
case
FieldType
.
String
:
WriteStringNoTag
((
string
)
value
);
break
;
case
FieldType
.
Message
:
WriteMessageNoTag
((
IMessage
)
value
);
break
;
case
FieldType
.
Group
:
WriteGroupNoTag
((
IMessage
)
value
);
break
;
case
FieldType
.
Bytes
:
WriteBytesNoTag
((
ByteString
)
value
);
break
;
case
FieldType
.
Bool
:
WriteBoolNoTag
((
bool
)
value
);
break
;
case
FieldType
.
Enum
:
WriteEnumNoTag
((
int
)
value
);
break
;
case
FieldType
.
Int32
:
WriteInt32NoTag
((
int
)
value
);
break
;
case
FieldType
.
Int64
:
WriteInt64NoTag
((
long
)
value
);
break
;
case
FieldType
.
UInt32
:
WriteUInt32NoTag
((
uint
)
value
);
break
;
case
FieldType
.
UInt64
:
WriteUInt64NoTag
((
ulong
)
value
);
break
;
case
FieldType
.
SInt32
:
WriteSInt32NoTag
((
int
)
value
);
break
;
case
FieldType
.
SInt64
:
WriteSInt64NoTag
((
long
)
value
);
break
;
case
FieldType
.
Fixed32
:
WriteFixed32NoTag
((
uint
)
value
);
break
;
case
FieldType
.
Fixed64
:
WriteFixed64NoTag
((
ulong
)
value
);
break
;
case
FieldType
.
SFixed32
:
WriteSFixed32NoTag
((
int
)
value
);
break
;
case
FieldType
.
SFixed64
:
WriteSFixed64NoTag
((
long
)
value
);
break
;
case
FieldType
.
Double
:
WriteDoubleNoTag
((
double
)
value
);
break
;
case
FieldType
.
Float
:
WriteFloatNoTag
((
float
)
value
);
break
;
}
}
/// <summary>
/// Writes a double field value, including tag, to the stream.
/// </summary>
public
void
WriteDouble
NoTag
(
double
value
)
public
void
WriteDouble
(
double
value
)
{
WriteRawLittleEndian64
((
ulong
)
FrameworkPortability
.
DoubleToInt64
(
value
));
}
...
...
@@ -392,7 +156,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a float field value, without a tag, to the stream.
/// </summary>
public
void
WriteFloat
NoTag
(
float
value
)
public
void
WriteFloat
(
float
value
)
{
byte
[]
rawBytes
=
BitConverter
.
GetBytes
(
value
);
if
(!
BitConverter
.
IsLittleEndian
)
...
...
@@ -416,7 +180,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a uint64 field value, without a tag, to the stream.
/// </summary>
public
void
WriteUInt64
NoTag
(
ulong
value
)
public
void
WriteUInt64
(
ulong
value
)
{
WriteRawVarint64
(
value
);
}
...
...
@@ -424,7 +188,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes an int64 field value, without a tag, to the stream.
/// </summary>
public
void
WriteInt64
NoTag
(
long
value
)
public
void
WriteInt64
(
long
value
)
{
WriteRawVarint64
((
ulong
)
value
);
}
...
...
@@ -432,7 +196,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes an int32 field value, without a tag, to the stream.
/// </summary>
public
void
WriteInt32
NoTag
(
int
value
)
public
void
WriteInt32
(
int
value
)
{
if
(
value
>=
0
)
{
...
...
@@ -448,7 +212,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a fixed64 field value, without a tag, to the stream.
/// </summary>
public
void
WriteFixed64
NoTag
(
ulong
value
)
public
void
WriteFixed64
(
ulong
value
)
{
WriteRawLittleEndian64
(
value
);
}
...
...
@@ -456,7 +220,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a fixed32 field value, without a tag, to the stream.
/// </summary>
public
void
WriteFixed32
NoTag
(
uint
value
)
public
void
WriteFixed32
(
uint
value
)
{
WriteRawLittleEndian32
(
value
);
}
...
...
@@ -464,7 +228,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a bool field value, without a tag, to the stream.
/// </summary>
public
void
WriteBool
NoTag
(
bool
value
)
public
void
WriteBool
(
bool
value
)
{
WriteRawByte
(
value
?
(
byte
)
1
:
(
byte
)
0
);
}
...
...
@@ -472,485 +236,440 @@ namespace Google.Protobuf
/// <summary>
/// Writes a string field value, without a tag, to the stream.
/// </summary>
public
void
WriteString
NoTag
(
string
value
)
public
void
WriteString
(
string
value
)
{
// Optimise the case where we have enough space to write
// the string directly to the buffer, which should be common.
int
length
=
Encoding
.
UTF8
.
GetByteCount
(
value
);
WriteRawVarint32
((
uint
)
length
);
int
length
=
UTF8
.
GetByteCount
(
value
);
WriteRawVarint32
((
uint
)
length
);
if
(
limit
-
position
>=
length
)
{
Encoding
.
UTF8
.
GetBytes
(
value
,
0
,
value
.
Length
,
buffer
,
position
);
if
(
length
==
value
.
Length
)
// Must be all ASCII...
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
buffer
[
position
+
i
]
=
(
byte
)
value
[
i
];
}
}
else
{
UTF8
.
GetBytes
(
value
,
0
,
value
.
Length
,
buffer
,
position
);
}
position
+=
length
;
}
else
{
byte
[]
bytes
=
Encoding
.
UTF8
.
GetBytes
(
value
);
byte
[]
bytes
=
UTF8
.
GetBytes
(
value
);
WriteRawBytes
(
bytes
);
}
}
/// <summary>
/// Writes a group field value, without a tag, to the stream.
/// </summary>
public
void
WriteGroupNoTag
(
IMessage
value
)
{
value
.
WriteTo
(
this
);
}
public
void
WriteMessageNoTag
(
IMessage
value
)
public
void
WriteMessage
(
IMessage
value
)
{
WriteRawVarint32
((
uint
)
value
.
CalculateSize
());
value
.
WriteTo
(
this
);
}
public
void
WriteBytes
NoTag
(
ByteString
value
)
public
void
WriteBytes
(
ByteString
value
)
{
WriteRawVarint32
((
uint
)
value
.
Length
);
value
.
WriteRawBytesTo
(
this
);
}
public
void
WriteUInt32
NoTag
(
uint
value
)
public
void
WriteUInt32
(
uint
value
)
{
WriteRawVarint32
(
value
);
}
public
void
WriteEnum
NoTag
(
int
value
)
public
void
WriteEnum
(
int
value
)
{
WriteInt32
NoTag
(
value
);
WriteInt32
(
value
);
}
public
void
WriteSFixed32
NoTag
(
int
value
)
public
void
WriteSFixed32
(
int
value
)
{
WriteRawLittleEndian32
((
uint
)
value
);
}
public
void
WriteSFixed64
NoTag
(
long
value
)
public
void
WriteSFixed64
(
long
value
)
{
WriteRawLittleEndian64
((
ulong
)
value
);
}
public
void
WriteSInt32
NoTag
(
int
value
)
public
void
WriteSInt32
(
int
value
)
{
WriteRawVarint32
(
EncodeZigZag32
(
value
));
}
public
void
WriteSInt64
NoTag
(
long
value
)
public
void
WriteSInt64
(
long
value
)
{
WriteRawVarint64
(
EncodeZigZag64
(
value
));
}
#
endregion
#
region
Write
array
members
#
region
Write
array
members
,
with
fields
.
public
void
WriteMessageArray
<
T
>(
int
fieldNumber
,
RepeatedField
<
T
>
list
)
where
T
:
IMessage
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
T
value
in
list
)
{
WriteMessage
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteMessage
(
value
);
}
}
public
void
WriteStringArray
(
int
fieldNumber
,
RepeatedField
<
string
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteString
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteString
(
value
);
}
}
public
void
WriteBytesArray
(
int
fieldNumber
,
RepeatedField
<
ByteString
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteBytes
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteBytes
(
value
);
}
}
public
void
WriteBoolArray
(
int
fieldNumber
,
RepeatedField
<
bool
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteBool
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteBool
(
value
);
}
}
public
void
WriteInt32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteInt32
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteInt32
(
value
);
}
}
public
void
WriteSInt32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteSInt32
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteSInt32
(
value
);
}
}
public
void
WriteUInt32Array
(
int
fieldNumber
,
RepeatedField
<
uint
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteUInt32
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteUInt32
(
value
);
}
}
public
void
WriteFixed32Array
(
int
fieldNumber
,
RepeatedField
<
uint
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteFixed32
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
WriteFixed32
(
value
);
}
}
public
void
WriteSFixed32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteSFixed32
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
WriteSFixed32
(
value
);
}
}
public
void
WriteInt64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteInt64
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteInt64
(
value
);
}
}
public
void
WriteSInt64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteSInt64
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteSInt64
(
value
);
}
}
public
void
WriteUInt64Array
(
int
fieldNumber
,
RepeatedField
<
ulong
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteUInt64
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteUInt64
(
value
);
}
}
public
void
WriteFixed64Array
(
int
fieldNumber
,
RepeatedField
<
ulong
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteFixed64
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteFixed64
(
value
);
}
}
public
void
WriteSFixed64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteSFixed64
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteSFixed64
(
value
);
}
}
public
void
WriteDoubleArray
(
int
fieldNumber
,
RepeatedField
<
double
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteDouble
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteDouble
(
value
);
}
}
public
void
WriteFloatArray
(
int
fieldNumber
,
RepeatedField
<
float
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
foreach
(
var
value
in
list
)
{
WriteFloat
(
fieldNumber
,
value
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
WriteFloat
(
value
);
}
}
public
void
WriteEnumArray
<
T
>(
int
fieldNumber
,
RepeatedField
<
T
>
list
)
where
T
:
struct
,
IComparable
,
IFormattable
{
if
(
list
.
Count
==
0
)
{
return
;
}
// Bit of a hack, to access the values as ints
var
iterator
=
list
.
GetInt32Enumerator
();
while
(
iterator
.
MoveNext
())
{
WriteEnum
(
fieldNumber
,
iterator
.
Current
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Varint
);
WriteEnum
(
iterator
.
Current
);
}
}
#
endregion
#
region
Raw
tag
writing
/// <summary>
/// Encodes and writes a tag.
/// </summary>
public
void
WriteTag
(
int
fieldNumber
,
WireFormat
.
WireType
type
)
{
WriteRawVarint32
(
WireFormat
.
MakeTag
(
fieldNumber
,
type
));
}
/// <summary>
/// Writes the given single-byte tag directly to the stream.
/// </summary>
public
void
WriteRawTag
(
byte
b1
)
{
WriteRawByte
(
b1
);
}
/// <summary>
/// Writes the given two-byte tag directly to the stream.
/// </summary>
public
void
WriteRawTag
(
byte
b1
,
byte
b2
)
{
WriteRawByte
(
b1
);
WriteRawByte
(
b2
);
}
/// <summary>
/// Writes the given three-byte tag directly to the stream.
/// </summary>
public
void
WriteRawTag
(
byte
b1
,
byte
b2
,
byte
b3
)
{
WriteRawByte
(
b1
);
WriteRawByte
(
b2
);
WriteRawByte
(
b3
);
}
/// <summary>
/// Writes the given four-byte tag directly to the stream.
/// </summary>
public
void
WriteRawTag
(
byte
b1
,
byte
b2
,
byte
b3
,
byte
b4
)
{
WriteRawByte
(
b1
);
WriteRawByte
(
b2
);
WriteRawByte
(
b3
);
WriteRawByte
(
b4
);
}
/// <summary>
/// Writes the given five-byte tag directly to the stream.
/// </summary>
public
void
WriteRawTag
(
byte
b1
,
byte
b2
,
byte
b3
,
byte
b4
,
byte
b5
)
{
WriteRawByte
(
b1
);
WriteRawByte
(
b2
);
WriteRawByte
(
b3
);
WriteRawByte
(
b4
);
WriteRawByte
(
b5
);
}
#
endregion
#
region
Write
packed
array
members
// TODO(jonskeet): A lot of these are really inefficient, due to method group conversions. Fix!
public
void
WritePackedBoolArray
(
int
fieldNumber
,
RepeatedField
<
bool
>
list
)
// (Alternatively, add extension methods to RepeatedField, accepting the Write* methods via delegates too.)
public
void
WritePackedBoolArray
(
RepeatedField
<
bool
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
(
uint
)
list
.
Count
;
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteBool
NoTag
(
value
);
WriteBool
(
value
);
}
}
public
void
WritePackedInt32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
public
void
WritePackedInt32Array
(
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
list
.
CalculateSize
(
ComputeInt32SizeNoTag
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
uint
size
=
list
.
CalculateSize
(
ComputeInt32Size
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteInt32
NoTag
(
value
);
WriteInt32
(
value
);
}
}
public
void
WritePackedSInt32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
public
void
WritePackedSInt32Array
(
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
list
.
CalculateSize
(
ComputeSInt32SizeNoTag
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
uint
size
=
list
.
CalculateSize
(
ComputeSInt32Size
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteSInt32
NoTag
(
value
);
WriteSInt32
(
value
);
}
}
public
void
WritePackedUInt32Array
(
int
fieldNumber
,
RepeatedField
<
uint
>
list
)
public
void
WritePackedUInt32Array
(
RepeatedField
<
uint
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
list
.
CalculateSize
(
ComputeUInt32SizeNoTag
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
uint
size
=
list
.
CalculateSize
(
ComputeUInt32Size
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteUInt32
NoTag
(
value
);
WriteUInt32
(
value
);
}
}
public
void
WritePackedFixed32Array
(
int
fieldNumber
,
RepeatedField
<
uint
>
list
)
public
void
WritePackedFixed32Array
(
RepeatedField
<
uint
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
(
uint
)
list
.
Count
*
4
;
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteFixed32
NoTag
(
value
);
WriteFixed32
(
value
);
}
}
public
void
WritePackedSFixed32Array
(
int
fieldNumber
,
RepeatedField
<
int
>
list
)
public
void
WritePackedSFixed32Array
(
RepeatedField
<
int
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
(
uint
)
list
.
Count
*
4
;
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteSFixed32
NoTag
(
value
);
WriteSFixed32
(
value
);
}
}
public
void
WritePackedInt64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
public
void
WritePackedInt64Array
(
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
list
.
CalculateSize
(
ComputeInt64SizeNoTag
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
uint
size
=
list
.
CalculateSize
(
ComputeInt64Size
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteInt64
NoTag
(
value
);
WriteInt64
(
value
);
}
}
public
void
WritePackedSInt64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
public
void
WritePackedSInt64Array
(
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
list
.
CalculateSize
(
ComputeSInt64SizeNoTag
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
uint
size
=
list
.
CalculateSize
(
ComputeSInt64Size
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteSInt64
NoTag
(
value
);
WriteSInt64
(
value
);
}
}
public
void
WritePackedUInt64Array
(
int
fieldNumber
,
RepeatedField
<
ulong
>
list
)
public
void
WritePackedUInt64Array
(
RepeatedField
<
ulong
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
list
.
CalculateSize
(
ComputeUInt64SizeNoTag
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
uint
size
=
list
.
CalculateSize
(
ComputeUInt64Size
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteUInt64
NoTag
(
value
);
WriteUInt64
(
value
);
}
}
public
void
WritePackedFixed64Array
(
int
fieldNumber
,
RepeatedField
<
ulong
>
list
)
public
void
WritePackedFixed64Array
(
RepeatedField
<
ulong
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
(
uint
)
list
.
Count
*
8
;
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteFixed64
NoTag
(
value
);
WriteFixed64
(
value
);
}
}
public
void
WritePackedSFixed64Array
(
int
fieldNumber
,
RepeatedField
<
long
>
list
)
public
void
WritePackedSFixed64Array
(
RepeatedField
<
long
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
(
uint
)
list
.
Count
*
8
;
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteSFixed64
NoTag
(
value
);
WriteSFixed64
(
value
);
}
}
public
void
WritePackedDoubleArray
(
int
fieldNumber
,
RepeatedField
<
double
>
list
)
public
void
WritePackedDoubleArray
(
RepeatedField
<
double
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
(
uint
)
list
.
Count
*
8
;
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteDouble
NoTag
(
value
);
WriteDouble
(
value
);
}
}
public
void
WritePackedFloatArray
(
int
fieldNumber
,
RepeatedField
<
float
>
list
)
public
void
WritePackedFloatArray
(
RepeatedField
<
float
>
list
)
{
if
(
list
.
Count
==
0
)
{
return
;
}
uint
size
=
(
uint
)
list
.
Count
*
4
;
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
(
size
);
foreach
(
var
value
in
list
)
{
WriteFloat
NoTag
(
value
);
WriteFloat
(
value
);
}
}
public
void
WritePackedEnumArray
<
T
>(
int
fieldNumber
,
RepeatedField
<
T
>
list
)
public
void
WritePackedEnumArray
<
T
>(
RepeatedField
<
T
>
list
)
where
T
:
struct
,
IComparable
,
IFormattable
{
if
(
list
.
Count
==
0
)
...
...
@@ -962,29 +681,19 @@ namespace Google.Protobuf
uint
size
=
0
;
while
(
iterator
.
MoveNext
())
{
size
+=
(
uint
)
ComputeEnumSize
NoTag
(
iterator
.
Current
);
size
+=
(
uint
)
ComputeEnumSize
(
iterator
.
Current
);
}
iterator
.
Reset
();
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
LengthDelimited
);
WriteRawVarint32
(
size
);
while
(
iterator
.
MoveNext
())
{
WriteEnum
NoTag
(
iterator
.
Current
);
WriteEnum
(
iterator
.
Current
);
}
}
#
endregion
#
region
Underlying
writing
primitives
/// <summary>
/// Encodes and writes a tag.
/// </summary>
public
void
WriteTag
(
int
fieldNumber
,
WireFormat
.
WireType
type
)
{
WriteRawVarint32
(
WireFormat
.
MakeTag
(
fieldNumber
,
type
));
}
/// <summary>
/// Writes a 32 bit value as a varint. The fast route is taken when
/// there's enough buffer space left to whizz through without checking
...
...
csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
View file @
828b7e61
...
...
@@ -333,8 +333,9 @@ namespace Google.Protobuf.DescriptorProtos {
int
size
=
0
;
if
(
file_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FileDescriptorProto
element
in
file_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
1
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
file_
.
Count
;
}
return
size
;
}
...
...
@@ -508,10 +509,12 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
if
(
Package
.
Length
!=
0
)
{
output
.
WriteString
(
2
,
Package
);
output
.
WriteRawTag
(
18
);
output
.
WriteString
(
Package
);
}
if
(
dependency_
.
Count
>
0
)
{
output
.
WriteStringArray
(
3
,
dependency_
);
...
...
@@ -529,10 +532,12 @@ namespace Google.Protobuf.DescriptorProtos {
output
.
WriteMessageArray
(
7
,
extension_
);
}
if
(
options_
!=
null
)
{
output
.
WriteMessage
(
8
,
Options
);
output
.
WriteRawTag
(
66
);
output
.
WriteMessage
(
Options
);
}
if
(
sourceCodeInfo_
!=
null
)
{
output
.
WriteMessage
(
9
,
SourceCodeInfo
);
output
.
WriteRawTag
(
74
);
output
.
WriteMessage
(
SourceCodeInfo
);
}
if
(
publicDependency_
.
Count
>
0
)
{
output
.
WriteInt32Array
(
10
,
publicDependency_
);
...
...
@@ -541,22 +546,23 @@ namespace Google.Protobuf.DescriptorProtos {
output
.
WriteInt32Array
(
11
,
weakDependency_
);
}
if
(
Syntax
.
Length
!=
0
)
{
output
.
WriteString
(
12
,
Syntax
);
output
.
WriteRawTag
(
98
);
output
.
WriteString
(
Syntax
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
if
(
Package
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
2
,
Package
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Package
);
}
if
(
dependency_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
string
element
in
dependency_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
element
);
}
size
+=
dataSize
;
size
+=
1
*
dependency_
.
Count
;
...
...
@@ -564,7 +570,7 @@ namespace Google.Protobuf.DescriptorProtos {
if
(
publicDependency_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
publicDependency_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
1
*
publicDependency_
.
Count
;
...
...
@@ -572,39 +578,43 @@ namespace Google.Protobuf.DescriptorProtos {
if
(
weakDependency_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
weakDependency_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
1
*
weakDependency_
.
Count
;
}
if
(
messageType_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
DescriptorProto
element
in
messageType_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
4
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
messageType_
.
Count
;
}
if
(
enumType_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
EnumDescriptorProto
element
in
enumType_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
5
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
enumType_
.
Count
;
}
if
(
service_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
ServiceDescriptorProto
element
in
service_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
6
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
service_
.
Count
;
}
if
(
extension_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldDescriptorProto
element
in
extension_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
7
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
extension_
.
Count
;
}
if
(
options_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
8
,
Options
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Options
);
}
if
(
sourceCodeInfo_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
9
,
SourceCodeInfo
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
SourceCodeInfo
);
}
if
(
Syntax
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
12
,
Syntax
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Syntax
);
}
return
size
;
}
...
...
@@ -837,7 +847,8 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
if
(
field_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
2
,
field_
);
...
...
@@ -855,7 +866,8 @@ namespace Google.Protobuf.DescriptorProtos {
output
.
WriteMessageArray
(
6
,
extension_
);
}
if
(
options_
!=
null
)
{
output
.
WriteMessage
(
7
,
Options
);
output
.
WriteRawTag
(
58
);
output
.
WriteMessage
(
Options
);
}
if
(
oneofDecl_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
8
,
oneofDecl_
);
...
...
@@ -871,50 +883,57 @@ namespace Google.Protobuf.DescriptorProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
if
(
field_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldDescriptorProto
element
in
field_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
2
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
field_
.
Count
;
}
if
(
extension_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldDescriptorProto
element
in
extension_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
6
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
extension_
.
Count
;
}
if
(
nestedType_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
DescriptorProto
element
in
nestedType_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
3
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
nestedType_
.
Count
;
}
if
(
enumType_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
EnumDescriptorProto
element
in
enumType_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
4
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
enumType_
.
Count
;
}
if
(
extensionRange_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
DescriptorProto
.
Types
.
ExtensionRange
element
in
extensionRange_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
5
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
extensionRange_
.
Count
;
}
if
(
oneofDecl_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
OneofDescriptorProto
element
in
oneofDecl_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
8
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
oneofDecl_
.
Count
;
}
if
(
options_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
7
,
Options
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Options
);
}
if
(
reservedRange_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
DescriptorProto
.
Types
.
ReservedRange
element
in
reservedRange_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
9
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
reservedRange_
.
Count
;
}
if
(
reservedName_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
string
element
in
reservedName_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
element
);
}
size
+=
dataSize
;
size
+=
1
*
reservedName_
.
Count
;
...
...
@@ -1065,20 +1084,22 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Start
!=
0
)
{
output
.
WriteInt32
(
1
,
Start
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
Start
);
}
if
(
End
!=
0
)
{
output
.
WriteInt32
(
2
,
End
);
output
.
WriteRawTag
(
16
);
output
.
WriteInt32
(
End
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Start
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
Start
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Start
);
}
if
(
End
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
2
,
End
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
End
);
}
return
size
;
}
...
...
@@ -1179,20 +1200,22 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Start
!=
0
)
{
output
.
WriteInt32
(
1
,
Start
);
output
.
WriteRawTag
(
8
);
output
.
WriteInt32
(
Start
);
}
if
(
End
!=
0
)
{
output
.
WriteInt32
(
2
,
End
);
output
.
WriteRawTag
(
16
);
output
.
WriteInt32
(
End
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Start
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
1
,
Start
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Start
);
}
if
(
End
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
2
,
End
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
End
);
}
return
size
;
}
...
...
@@ -1366,62 +1389,71 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
if
(
Extendee
.
Length
!=
0
)
{
output
.
WriteString
(
2
,
Extendee
);
output
.
WriteRawTag
(
18
);
output
.
WriteString
(
Extendee
);
}
if
(
Number
!=
0
)
{
output
.
WriteInt32
(
3
,
Number
);
output
.
WriteRawTag
(
24
);
output
.
WriteInt32
(
Number
);
}
if
(
Label
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldDescriptorProto
.
Types
.
Label
.
LABEL_OPTIONAL
)
{
output
.
WriteEnum
(
4
,
(
int
)
Label
);
output
.
WriteRawTag
(
32
);
output
.
WriteEnum
((
int
)
Label
);
}
if
(
Type
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldDescriptorProto
.
Types
.
Type
.
TYPE_DOUBLE
)
{
output
.
WriteEnum
(
5
,
(
int
)
Type
);
output
.
WriteRawTag
(
40
);
output
.
WriteEnum
((
int
)
Type
);
}
if
(
TypeName
.
Length
!=
0
)
{
output
.
WriteString
(
6
,
TypeName
);
output
.
WriteRawTag
(
50
);
output
.
WriteString
(
TypeName
);
}
if
(
DefaultValue
.
Length
!=
0
)
{
output
.
WriteString
(
7
,
DefaultValue
);
output
.
WriteRawTag
(
58
);
output
.
WriteString
(
DefaultValue
);
}
if
(
options_
!=
null
)
{
output
.
WriteMessage
(
8
,
Options
);
output
.
WriteRawTag
(
66
);
output
.
WriteMessage
(
Options
);
}
if
(
OneofIndex
!=
0
)
{
output
.
WriteInt32
(
9
,
OneofIndex
);
output
.
WriteRawTag
(
72
);
output
.
WriteInt32
(
OneofIndex
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
if
(
Number
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
3
,
Number
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Number
);
}
if
(
Label
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldDescriptorProto
.
Types
.
Label
.
LABEL_OPTIONAL
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
4
,
(
int
)
Label
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
Label
);
}
if
(
Type
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldDescriptorProto
.
Types
.
Type
.
TYPE_DOUBLE
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
5
,
(
int
)
Type
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
Type
);
}
if
(
TypeName
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
6
,
TypeName
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
TypeName
);
}
if
(
Extendee
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
2
,
Extendee
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Extendee
);
}
if
(
DefaultValue
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
7
,
DefaultValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
DefaultValue
);
}
if
(
OneofIndex
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
9
,
OneofIndex
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
OneofIndex
);
}
if
(
options_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
8
,
Options
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Options
);
}
return
size
;
}
...
...
@@ -1600,14 +1632,15 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
return
size
;
}
...
...
@@ -1707,28 +1740,31 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
if
(
value_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
2
,
value_
);
}
if
(
options_
!=
null
)
{
output
.
WriteMessage
(
3
,
Options
);
output
.
WriteRawTag
(
26
);
output
.
WriteMessage
(
Options
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
if
(
value_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
EnumValueDescriptorProto
element
in
value_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
2
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
value_
.
Count
;
}
if
(
options_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
3
,
Options
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Options
);
}
return
size
;
}
...
...
@@ -1848,26 +1884,29 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
if
(
Number
!=
0
)
{
output
.
WriteInt32
(
2
,
Number
);
output
.
WriteRawTag
(
16
);
output
.
WriteInt32
(
Number
);
}
if
(
options_
!=
null
)
{
output
.
WriteMessage
(
3
,
Options
);
output
.
WriteRawTag
(
26
);
output
.
WriteMessage
(
Options
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
if
(
Number
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
2
,
Number
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
Number
);
}
if
(
options_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
3
,
Options
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Options
);
}
return
size
;
}
...
...
@@ -1987,28 +2026,31 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
if
(
method_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
2
,
method_
);
}
if
(
options_
!=
null
)
{
output
.
WriteMessage
(
3
,
Options
);
output
.
WriteRawTag
(
26
);
output
.
WriteMessage
(
Options
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
if
(
method_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
MethodDescriptorProto
element
in
method_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
2
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
method_
.
Count
;
}
if
(
options_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
3
,
Options
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Options
);
}
return
size
;
}
...
...
@@ -2158,44 +2200,50 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
Name
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
Name
);
}
if
(
InputType
.
Length
!=
0
)
{
output
.
WriteString
(
2
,
InputType
);
output
.
WriteRawTag
(
18
);
output
.
WriteString
(
InputType
);
}
if
(
OutputType
.
Length
!=
0
)
{
output
.
WriteString
(
3
,
OutputType
);
output
.
WriteRawTag
(
26
);
output
.
WriteString
(
OutputType
);
}
if
(
options_
!=
null
)
{
output
.
WriteMessage
(
4
,
Options
);
output
.
WriteRawTag
(
34
);
output
.
WriteMessage
(
Options
);
}
if
(
ClientStreaming
!=
false
)
{
output
.
WriteBool
(
5
,
ClientStreaming
);
output
.
WriteRawTag
(
40
);
output
.
WriteBool
(
ClientStreaming
);
}
if
(
ServerStreaming
!=
false
)
{
output
.
WriteBool
(
6
,
ServerStreaming
);
output
.
WriteRawTag
(
48
);
output
.
WriteBool
(
ServerStreaming
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
Name
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Name
);
}
if
(
InputType
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
2
,
InputType
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
InputType
);
}
if
(
OutputType
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
3
,
OutputType
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
OutputType
);
}
if
(
options_
!=
null
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
4
,
Options
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeMessageSize
(
Options
);
}
if
(
ClientStreaming
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
5
,
ClientStreaming
)
;
size
+=
1
+
1
;
}
if
(
ServerStreaming
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
6
,
ServerStreaming
)
;
size
+=
1
+
1
;
}
return
size
;
}
...
...
@@ -2458,46 +2506,60 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
JavaPackage
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
JavaPackage
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
JavaPackage
);
}
if
(
JavaOuterClassname
.
Length
!=
0
)
{
output
.
WriteString
(
8
,
JavaOuterClassname
);
output
.
WriteRawTag
(
66
);
output
.
WriteString
(
JavaOuterClassname
);
}
if
(
OptimizeFor
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FileOptions
.
Types
.
OptimizeMode
.
SPEED
)
{
output
.
WriteEnum
(
9
,
(
int
)
OptimizeFor
);
output
.
WriteRawTag
(
72
);
output
.
WriteEnum
((
int
)
OptimizeFor
);
}
if
(
JavaMultipleFiles
!=
false
)
{
output
.
WriteBool
(
10
,
JavaMultipleFiles
);
output
.
WriteRawTag
(
80
);
output
.
WriteBool
(
JavaMultipleFiles
);
}
if
(
GoPackage
.
Length
!=
0
)
{
output
.
WriteString
(
11
,
GoPackage
);
output
.
WriteRawTag
(
90
);
output
.
WriteString
(
GoPackage
);
}
if
(
CcGenericServices
!=
false
)
{
output
.
WriteBool
(
16
,
CcGenericServices
);
output
.
WriteRawTag
(
128
,
1
);
output
.
WriteBool
(
CcGenericServices
);
}
if
(
JavaGenericServices
!=
false
)
{
output
.
WriteBool
(
17
,
JavaGenericServices
);
output
.
WriteRawTag
(
136
,
1
);
output
.
WriteBool
(
JavaGenericServices
);
}
if
(
PyGenericServices
!=
false
)
{
output
.
WriteBool
(
18
,
PyGenericServices
);
output
.
WriteRawTag
(
144
,
1
);
output
.
WriteBool
(
PyGenericServices
);
}
if
(
JavaGenerateEqualsAndHash
!=
false
)
{
output
.
WriteBool
(
20
,
JavaGenerateEqualsAndHash
);
output
.
WriteRawTag
(
160
,
1
);
output
.
WriteBool
(
JavaGenerateEqualsAndHash
);
}
if
(
Deprecated
!=
false
)
{
output
.
WriteBool
(
23
,
Deprecated
);
output
.
WriteRawTag
(
184
,
1
);
output
.
WriteBool
(
Deprecated
);
}
if
(
JavaStringCheckUtf8
!=
false
)
{
output
.
WriteBool
(
27
,
JavaStringCheckUtf8
);
output
.
WriteRawTag
(
216
,
1
);
output
.
WriteBool
(
JavaStringCheckUtf8
);
}
if
(
CcEnableArenas
!=
false
)
{
output
.
WriteBool
(
31
,
CcEnableArenas
);
output
.
WriteRawTag
(
248
,
1
);
output
.
WriteBool
(
CcEnableArenas
);
}
if
(
ObjcClassPrefix
.
Length
!=
0
)
{
output
.
WriteString
(
36
,
ObjcClassPrefix
);
output
.
WriteRawTag
(
162
,
2
);
output
.
WriteString
(
ObjcClassPrefix
);
}
if
(
CsharpNamespace
.
Length
!=
0
)
{
output
.
WriteString
(
37
,
CsharpNamespace
);
output
.
WriteRawTag
(
170
,
2
);
output
.
WriteString
(
CsharpNamespace
);
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
999
,
uninterpretedOption_
);
...
...
@@ -2507,51 +2569,52 @@ namespace Google.Protobuf.DescriptorProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
JavaPackage
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
JavaPackage
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
JavaPackage
);
}
if
(
JavaOuterClassname
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
8
,
JavaOuterClassname
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
JavaOuterClassname
);
}
if
(
JavaMultipleFiles
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
10
,
JavaMultipleFiles
)
;
size
+=
1
+
1
;
}
if
(
JavaGenerateEqualsAndHash
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
20
,
JavaGenerateEqualsAndHash
)
;
size
+=
2
+
1
;
}
if
(
JavaStringCheckUtf8
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
27
,
JavaStringCheckUtf8
)
;
size
+=
2
+
1
;
}
if
(
OptimizeFor
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FileOptions
.
Types
.
OptimizeMode
.
SPEED
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
9
,
(
int
)
OptimizeFor
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
OptimizeFor
);
}
if
(
GoPackage
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
11
,
GoPackage
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
GoPackage
);
}
if
(
CcGenericServices
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
16
,
CcGenericServices
)
;
size
+=
2
+
1
;
}
if
(
JavaGenericServices
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
17
,
JavaGenericServices
)
;
size
+=
2
+
1
;
}
if
(
PyGenericServices
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
18
,
PyGenericServices
)
;
size
+=
2
+
1
;
}
if
(
Deprecated
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
23
,
Deprecated
)
;
size
+=
2
+
1
;
}
if
(
CcEnableArenas
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
31
,
CcEnableArenas
)
;
size
+=
2
+
1
;
}
if
(
ObjcClassPrefix
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
36
,
ObjcClassPrefix
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
ObjcClassPrefix
);
}
if
(
CsharpNamespace
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
37
,
CsharpNamespace
);
size
+=
2
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
CsharpNamespace
);
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
UninterpretedOption
element
in
uninterpretedOption_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
999
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
uninterpretedOption_
.
Count
;
}
return
size
;
}
...
...
@@ -2781,16 +2844,20 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
MessageSetWireFormat
!=
false
)
{
output
.
WriteBool
(
1
,
MessageSetWireFormat
);
output
.
WriteRawTag
(
8
);
output
.
WriteBool
(
MessageSetWireFormat
);
}
if
(
NoStandardDescriptorAccessor
!=
false
)
{
output
.
WriteBool
(
2
,
NoStandardDescriptorAccessor
);
output
.
WriteRawTag
(
16
);
output
.
WriteBool
(
NoStandardDescriptorAccessor
);
}
if
(
Deprecated
!=
false
)
{
output
.
WriteBool
(
3
,
Deprecated
);
output
.
WriteRawTag
(
24
);
output
.
WriteBool
(
Deprecated
);
}
if
(
MapEntry
!=
false
)
{
output
.
WriteBool
(
7
,
MapEntry
);
output
.
WriteRawTag
(
56
);
output
.
WriteBool
(
MapEntry
);
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
999
,
uninterpretedOption_
);
...
...
@@ -2800,21 +2867,22 @@ namespace Google.Protobuf.DescriptorProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
MessageSetWireFormat
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
1
,
MessageSetWireFormat
)
;
size
+=
1
+
1
;
}
if
(
NoStandardDescriptorAccessor
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
2
,
NoStandardDescriptorAccessor
)
;
size
+=
1
+
1
;
}
if
(
Deprecated
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
3
,
Deprecated
)
;
size
+=
1
+
1
;
}
if
(
MapEntry
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
7
,
MapEntry
)
;
size
+=
1
+
1
;
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
UninterpretedOption
element
in
uninterpretedOption_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
999
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
uninterpretedOption_
.
Count
;
}
return
size
;
}
...
...
@@ -2982,22 +3050,28 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Ctype
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldOptions
.
Types
.
CType
.
STRING
)
{
output
.
WriteEnum
(
1
,
(
int
)
Ctype
);
output
.
WriteRawTag
(
8
);
output
.
WriteEnum
((
int
)
Ctype
);
}
if
(
Packed
!=
false
)
{
output
.
WriteBool
(
2
,
Packed
);
output
.
WriteRawTag
(
16
);
output
.
WriteBool
(
Packed
);
}
if
(
Deprecated
!=
false
)
{
output
.
WriteBool
(
3
,
Deprecated
);
output
.
WriteRawTag
(
24
);
output
.
WriteBool
(
Deprecated
);
}
if
(
Lazy
!=
false
)
{
output
.
WriteBool
(
5
,
Lazy
);
output
.
WriteRawTag
(
40
);
output
.
WriteBool
(
Lazy
);
}
if
(
Jstype
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldOptions
.
Types
.
JSType
.
JS_NORMAL
)
{
output
.
WriteEnum
(
6
,
(
int
)
Jstype
);
output
.
WriteRawTag
(
48
);
output
.
WriteEnum
((
int
)
Jstype
);
}
if
(
Weak
!=
false
)
{
output
.
WriteBool
(
10
,
Weak
);
output
.
WriteRawTag
(
80
);
output
.
WriteBool
(
Weak
);
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
999
,
uninterpretedOption_
);
...
...
@@ -3007,27 +3081,28 @@ namespace Google.Protobuf.DescriptorProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Ctype
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldOptions
.
Types
.
CType
.
STRING
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
1
,
(
int
)
Ctype
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
Ctype
);
}
if
(
Packed
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
2
,
Packed
)
;
size
+=
1
+
1
;
}
if
(
Jstype
!=
global
::
Google
.
Protobuf
.
DescriptorProtos
.
FieldOptions
.
Types
.
JSType
.
JS_NORMAL
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeEnumSize
(
6
,
(
int
)
Jstype
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeEnumSize
(
(
int
)
Jstype
);
}
if
(
Lazy
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
5
,
Lazy
)
;
size
+=
1
+
1
;
}
if
(
Deprecated
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
3
,
Deprecated
)
;
size
+=
1
+
1
;
}
if
(
Weak
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
10
,
Weak
)
;
size
+=
1
+
1
;
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
UninterpretedOption
element
in
uninterpretedOption_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
999
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
uninterpretedOption_
.
Count
;
}
return
size
;
}
...
...
@@ -3187,10 +3262,12 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
AllowAlias
!=
false
)
{
output
.
WriteBool
(
2
,
AllowAlias
);
output
.
WriteRawTag
(
16
);
output
.
WriteBool
(
AllowAlias
);
}
if
(
Deprecated
!=
false
)
{
output
.
WriteBool
(
3
,
Deprecated
);
output
.
WriteRawTag
(
24
);
output
.
WriteBool
(
Deprecated
);
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
999
,
uninterpretedOption_
);
...
...
@@ -3200,15 +3277,16 @@ namespace Google.Protobuf.DescriptorProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
AllowAlias
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
2
,
AllowAlias
)
;
size
+=
1
+
1
;
}
if
(
Deprecated
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
3
,
Deprecated
)
;
size
+=
1
+
1
;
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
UninterpretedOption
element
in
uninterpretedOption_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
999
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
uninterpretedOption_
.
Count
;
}
return
size
;
}
...
...
@@ -3312,7 +3390,8 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Deprecated
!=
false
)
{
output
.
WriteBool
(
1
,
Deprecated
);
output
.
WriteRawTag
(
8
);
output
.
WriteBool
(
Deprecated
);
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
999
,
uninterpretedOption_
);
...
...
@@ -3322,12 +3401,13 @@ namespace Google.Protobuf.DescriptorProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Deprecated
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
1
,
Deprecated
)
;
size
+=
1
+
1
;
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
UninterpretedOption
element
in
uninterpretedOption_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
999
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
uninterpretedOption_
.
Count
;
}
return
size
;
}
...
...
@@ -3424,7 +3504,8 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Deprecated
!=
false
)
{
output
.
WriteBool
(
33
,
Deprecated
);
output
.
WriteRawTag
(
136
,
2
);
output
.
WriteBool
(
Deprecated
);
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
999
,
uninterpretedOption_
);
...
...
@@ -3434,12 +3515,13 @@ namespace Google.Protobuf.DescriptorProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Deprecated
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
33
,
Deprecated
)
;
size
+=
2
+
1
;
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
UninterpretedOption
element
in
uninterpretedOption_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
999
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
uninterpretedOption_
.
Count
;
}
return
size
;
}
...
...
@@ -3536,7 +3618,8 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Deprecated
!=
false
)
{
output
.
WriteBool
(
33
,
Deprecated
);
output
.
WriteRawTag
(
136
,
2
);
output
.
WriteBool
(
Deprecated
);
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
output
.
WriteMessageArray
(
999
,
uninterpretedOption_
);
...
...
@@ -3546,12 +3629,13 @@ namespace Google.Protobuf.DescriptorProtos {
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Deprecated
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
33
,
Deprecated
)
;
size
+=
2
+
1
;
}
if
(
uninterpretedOption_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
UninterpretedOption
element
in
uninterpretedOption_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
999
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
2
*
uninterpretedOption_
.
Count
;
}
return
size
;
}
...
...
@@ -3701,22 +3785,28 @@ namespace Google.Protobuf.DescriptorProtos {
output
.
WriteMessageArray
(
2
,
name_
);
}
if
(
IdentifierValue
.
Length
!=
0
)
{
output
.
WriteString
(
3
,
IdentifierValue
);
output
.
WriteRawTag
(
26
);
output
.
WriteString
(
IdentifierValue
);
}
if
(
PositiveIntValue
!=
0U
L
)
{
output
.
WriteUInt64
(
4
,
PositiveIntValue
);
output
.
WriteRawTag
(
32
);
output
.
WriteUInt64
(
PositiveIntValue
);
}
if
(
NegativeIntValue
!=
0L
)
{
output
.
WriteInt64
(
5
,
NegativeIntValue
);
output
.
WriteRawTag
(
40
);
output
.
WriteInt64
(
NegativeIntValue
);
}
if
(
DoubleValue
!=
0D
)
{
output
.
WriteDouble
(
6
,
DoubleValue
);
output
.
WriteRawTag
(
49
);
output
.
WriteDouble
(
DoubleValue
);
}
if
(
StringValue
.
Length
!=
0
)
{
output
.
WriteBytes
(
7
,
StringValue
);
output
.
WriteRawTag
(
58
);
output
.
WriteBytes
(
StringValue
);
}
if
(
AggregateValue
.
Length
!=
0
)
{
output
.
WriteString
(
8
,
AggregateValue
);
output
.
WriteRawTag
(
66
);
output
.
WriteString
(
AggregateValue
);
}
}
...
...
@@ -3724,26 +3814,27 @@ namespace Google.Protobuf.DescriptorProtos {
int
size
=
0
;
if
(
name_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
UninterpretedOption
.
Types
.
NamePart
element
in
name_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
2
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
name_
.
Count
;
}
if
(
IdentifierValue
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
3
,
IdentifierValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
IdentifierValue
);
}
if
(
PositiveIntValue
!=
0U
L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
4
,
PositiveIntValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeUInt64Size
(
PositiveIntValue
);
}
if
(
NegativeIntValue
!=
0L
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeInt64Size
(
5
,
NegativeIntValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt64Size
(
NegativeIntValue
);
}
if
(
DoubleValue
!=
0D
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeDoubleSize
(
6
,
DoubleValue
)
;
size
+=
1
+
8
;
}
if
(
StringValue
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBytesSize
(
7
,
StringValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeBytesSize
(
StringValue
);
}
if
(
AggregateValue
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
8
,
AggregateValue
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
AggregateValue
);
}
return
size
;
}
...
...
@@ -3878,20 +3969,22 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
NamePart_
.
Length
!=
0
)
{
output
.
WriteString
(
1
,
NamePart_
);
output
.
WriteRawTag
(
10
);
output
.
WriteString
(
NamePart_
);
}
if
(
IsExtension
!=
false
)
{
output
.
WriteBool
(
2
,
IsExtension
);
output
.
WriteRawTag
(
16
);
output
.
WriteBool
(
IsExtension
);
}
}
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
NamePart_
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
1
,
NamePart_
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
NamePart_
);
}
if
(
IsExtension
!=
false
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeBoolSize
(
2
,
IsExtension
)
;
size
+=
1
+
1
;
}
return
size
;
}
...
...
@@ -3993,8 +4086,9 @@ namespace Google.Protobuf.DescriptorProtos {
int
size
=
0
;
if
(
location_
.
Count
>
0
)
{
foreach
(
global
::
Google
.
Protobuf
.
DescriptorProtos
.
SourceCodeInfo
.
Types
.
Location
element
in
location_
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
1
,
element
);
size
+=
pb
::
CodedOutputStream
.
ComputeMessageSize
(
element
);
}
size
+=
1
*
location_
.
Count
;
}
return
size
;
}
...
...
@@ -4111,16 +4205,20 @@ namespace Google.Protobuf.DescriptorProtos {
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
path_
.
Count
>
0
)
{
output
.
WritePackedInt32Array
(
1
,
path_
);
output
.
WriteRawTag
(
10
);
output
.
WritePackedInt32Array
(
path_
);
}
if
(
span_
.
Count
>
0
)
{
output
.
WritePackedInt32Array
(
2
,
span_
);
output
.
WriteRawTag
(
18
);
output
.
WritePackedInt32Array
(
span_
);
}
if
(
LeadingComments
.
Length
!=
0
)
{
output
.
WriteString
(
3
,
LeadingComments
);
output
.
WriteRawTag
(
26
);
output
.
WriteString
(
LeadingComments
);
}
if
(
TrailingComments
.
Length
!=
0
)
{
output
.
WriteString
(
4
,
TrailingComments
);
output
.
WriteRawTag
(
34
);
output
.
WriteString
(
TrailingComments
);
}
if
(
leadingDetachedComments_
.
Count
>
0
)
{
output
.
WriteStringArray
(
6
,
leadingDetachedComments_
);
...
...
@@ -4132,29 +4230,29 @@ namespace Google.Protobuf.DescriptorProtos {
if
(
path_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
path_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
span_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
int
element
in
span_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeInt32Size
(
element
);
}
size
+=
dataSize
;
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
NoTag
(
dataSize
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeInt32Size
(
dataSize
);
}
if
(
LeadingComments
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
3
,
LeadingComments
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
LeadingComments
);
}
if
(
TrailingComments
.
Length
!=
0
)
{
size
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
4
,
TrailingComments
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
TrailingComments
);
}
if
(
leadingDetachedComments_
.
Count
>
0
)
{
int
dataSize
=
0
;
foreach
(
string
element
in
leadingDetachedComments_
)
{
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
NoTag
(
element
);
dataSize
+=
pb
::
CodedOutputStream
.
ComputeStringSize
(
element
);
}
size
+=
dataSize
;
size
+=
1
*
leadingDetachedComments_
.
Count
;
...
...
src/google/protobuf/compiler/csharp/csharp_enum_field.cc
View file @
828b7e61
...
...
@@ -61,7 +61,8 @@ void EnumFieldGenerator::GenerateParsingCode(io::Printer* printer) {
void
EnumFieldGenerator
::
GenerateSerializationCode
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"if ($has_property_check$) {
\n
"
" output.WriteEnum($number$, (int) $property_name$);
\n
"
" output.WriteRawTag($tag_bytes$);
\n
"
" output.WriteEnum((int) $property_name$);
\n
"
"}
\n
"
);
}
...
...
@@ -69,7 +70,7 @@ void EnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
printer
->
Print
(
variables_
,
"if ($has_property_check$) {
\n
"
" size +=
pb::CodedOutputStream.ComputeEnumSize($number$,
(int) $property_name$);
\n
"
" size +=
$tag_size$ + pb::CodedOutputStream.ComputeEnumSize(
(int) $property_name$);
\n
"
"}
\n
"
);
}
...
...
@@ -93,7 +94,8 @@ void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
printer
->
Print
(
variables_
,
"if ($has_property_check$) {
\n
"
" output.WriteEnum($number$, (int) $property_name$);
\n
"
" output.WriteRawTag($tag_bytes$);
\n
"
" output.WriteEnum((int) $property_name$);
\n
"
"}
\n
"
);
}
...
...
@@ -101,7 +103,7 @@ void EnumOneofFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
printer
->
Print
(
variables_
,
"if ($has_property_check$) {
\n
"
" size +=
pb::CodedOutputStream.ComputeEnumSize($number$,
(int) $property_name$);
\n
"
" size +=
$tag_size$ + pb::CodedOutputStream.ComputeEnumSize(
(int) $property_name$);
\n
"
"}
\n
"
);
}
...
...
src/google/protobuf/compiler/csharp/csharp_field_base.cc
View file @
828b7e61
...
...
@@ -35,6 +35,7 @@
#include <google/protobuf/compiler/plugin.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/strutil.h>
...
...
@@ -55,8 +56,18 @@ void FieldGeneratorBase::SetCommonFieldVariables(
// Note: this will be valid even though the tag emitted for packed and unpacked versions of
// repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which
// never effects the tag size.
int
tagSize
=
internal
::
WireFormat
::
TagSize
(
descriptor_
->
number
(),
descriptor_
->
type
());
(
*
variables
)[
"tag_size"
]
=
SimpleItoa
(
tagSize
);
int
tag_size
=
internal
::
WireFormat
::
TagSize
(
descriptor_
->
number
(),
descriptor_
->
type
());
uint
tag
=
internal
::
WireFormat
::
MakeTag
(
descriptor_
);
uint8
tag_array
[
5
];
io
::
CodedOutputStream
::
WriteTagToArray
(
tag
,
tag_array
);
string
tag_bytes
=
SimpleItoa
(
tag_array
[
0
]);
for
(
int
i
=
1
;
i
<
tag_size
;
i
++
)
{
tag_bytes
+=
", "
+
SimpleItoa
(
tag_array
[
i
]);
}
(
*
variables
)[
"tag_size"
]
=
SimpleItoa
(
tag_size
);
(
*
variables
)[
"tag_bytes"
]
=
tag_bytes
;
(
*
variables
)[
"property_name"
]
=
property_name
();
(
*
variables
)[
"type_name"
]
=
type_name
();
(
*
variables
)[
"name"
]
=
name
();
...
...
src/google/protobuf/compiler/csharp/csharp_message_field.cc
View file @
828b7e61
...
...
@@ -92,11 +92,11 @@ void MessageFieldGenerator::GenerateParsingCode(io::Printer* printer) {
}
void
MessageFieldGenerator
::
GenerateSerializationCode
(
io
::
Printer
*
printer
)
{
// TODO(jonskeet): Why are we using array access instead of a literal here?
printer
->
Print
(
variables_
,
"if ($has_property_check$) {
\n
"
" output.WriteMessage($number$, $property_name$);
\n
"
" output.WriteRawTag($tag_bytes$);
\n
"
" output.WriteMessage($property_name$);
\n
"
"}
\n
"
);
}
...
...
@@ -104,7 +104,7 @@ void MessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
printer
->
Print
(
variables_
,
"if ($has_property_check$) {
\n
"
" size +=
pb::CodedOutputStream.ComputeMessageSize($number$,
$property_name$);
\n
"
" size +=
$tag_size$ + pb::CodedOutputStream.ComputeMessageSize(
$property_name$);
\n
"
"}
\n
"
);
}
...
...
src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
View file @
828b7e61
...
...
@@ -105,16 +105,29 @@ void PrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
printer
->
Print
(
variables_
,
"if ($has_property_check$) {
\n
"
" output.Write$capitalized_type_name$($number$, $property_name$);
\n
"
" output.WriteRawTag($tag_bytes$);
\n
"
" output.Write$capitalized_type_name$($property_name$);
\n
"
"}
\n
"
);
}
void
PrimitiveFieldGenerator
::
GenerateSerializedSizeCode
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"if ($has_property_check$) {
\n
"
" size += pb::CodedOutputStream.Compute$capitalized_type_name$Size($number$, $property_name$);
\n
"
"}
\n
"
);
"if ($has_property_check$) {
\n
"
);
printer
->
Indent
();
int
fixedSize
=
GetFixedSize
(
descriptor_
->
type
());
if
(
fixedSize
==
-
1
)
{
printer
->
Print
(
variables_
,
"size += $tag_size$ + pb::CodedOutputStream.Compute$capitalized_type_name$Size($property_name$);
\n
"
);
}
else
{
printer
->
Print
(
"size += $tag_size$ + $fixed_size$;
\n
"
,
"fixed_size"
,
SimpleItoa
(
fixedSize
),
"tag_size"
,
variables_
[
"tag_size"
]);
}
printer
->
Outdent
();
printer
->
Print
(
"}
\n
"
);
}
void
PrimitiveFieldGenerator
::
WriteHash
(
io
::
Printer
*
printer
)
{
...
...
@@ -173,7 +186,7 @@ void PrimitiveOneofFieldGenerator::WriteToString(io::Printer* printer) {
void
PrimitiveOneofFieldGenerator
::
GenerateParsingCode
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"$property_name$ = input.Read$capitalized_type_name$()
\n
;
"
);
"$property_name$ = input.Read$capitalized_type_name$()
;
\n
"
);
}
}
// namespace csharp
...
...
src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
View file @
828b7e61
...
...
@@ -82,9 +82,20 @@ void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) {
void
RepeatedEnumFieldGenerator
::
GenerateSerializationCode
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"if ($name$_.Count > 0) {
\n
"
" output.Write$packed$EnumArray($number$, $name$_);
\n
"
"}
\n
"
);
"if ($name$_.Count > 0) {
\n
"
);
printer
->
Indent
();
if
(
descriptor_
->
is_packed
())
{
printer
->
Print
(
variables_
,
"output.WriteRawTag($tag_bytes$);
\n
"
"output.WritePackedEnumArray($name$_);
\n
"
);
}
else
{
printer
->
Print
(
variables_
,
"output.Write$capitalized_type_name$Array($number$, $name$_);
\n
"
);
}
printer
->
Outdent
();
printer
->
Print
(
"}
\n
"
);
}
void
RepeatedEnumFieldGenerator
::
GenerateSerializedSizeCode
(
io
::
Printer
*
printer
)
{
...
...
@@ -97,14 +108,13 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer
printer
->
Print
(
variables_
,
"foreach ($type_name$ element in $name$_) {
\n
"
" dataSize += pb::CodedOutputStream.ComputeEnumSize
NoTag
((int) element);
\n
"
" dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element);
\n
"
"}
\n
"
"size += dataSize;
\n
"
);
int
tagSize
=
internal
::
WireFormat
::
TagSize
(
descriptor_
->
number
(),
descriptor_
->
type
());
if
(
descriptor_
->
is_packed
())
{
printer
->
Print
(
"size += $tag_size$;
\n
"
"size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);
\n
"
,
"size += $tag_size$ + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);
\n
"
,
"tag_size"
,
SimpleItoa
(
tagSize
));
}
else
{
printer
->
Print
(
...
...
src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
View file @
828b7e61
...
...
@@ -79,8 +79,8 @@ void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) {
}
void
RepeatedMessageFieldGenerator
::
GenerateSerializationCode
(
io
::
Printer
*
printer
)
{
// TODO(jonskeet):
Originally, this checked for Count > 0 first.
//
The Write* call should make that cheap though - no need to generate it every time.
// TODO(jonskeet):
Bake the foreach loop into the generated code? We lose the
//
advantage of knowing the tag bytes this way :(
printer
->
Print
(
variables_
,
"if ($name$_.Count > 0) {
\n
"
...
...
@@ -89,13 +89,13 @@ void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* print
}
void
RepeatedMessageFieldGenerator
::
GenerateSerializedSizeCode
(
io
::
Printer
*
printer
)
{
// TODO(jonskeet): Put this into CodedOutputStream.
printer
->
Print
(
variables_
,
"if ($name$_.Count > 0) {
\n
"
" foreach ($type_name$ element in $name$_) {
\n
"
" size += pb::CodedOutputStream.ComputeMessageSize(
$number$,
element);
\n
"
" size += pb::CodedOutputStream.ComputeMessageSize(element);
\n
"
" }
\n
"
" size += $tag_size$ * $name$_.Count;
\n
"
"}
\n
"
);
}
...
...
src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
View file @
828b7e61
...
...
@@ -82,9 +82,20 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"if ($name$_.Count > 0) {
\n
"
" output.Write$packed$$capitalized_type_name$Array($number$, $name$_);
\n
"
"}
\n
"
);
"if ($name$_.Count > 0) {
\n
"
);
printer
->
Indent
();
if
(
descriptor_
->
is_packed
())
{
printer
->
Print
(
variables_
,
"output.WriteRawTag($tag_bytes$);
\n
"
"output.WritePacked$capitalized_type_name$Array($name$_);
\n
"
);
}
else
{
printer
->
Print
(
variables_
,
"output.Write$capitalized_type_name$Array($number$, $name$_);
\n
"
);
}
printer
->
Outdent
();
printer
->
Print
(
"}
\n
"
);
}
void
RepeatedPrimitiveFieldGenerator
::
GenerateSerializedSizeCode
(
...
...
@@ -100,7 +111,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode(
printer
->
Print
(
variables_
,
"foreach ($type_name$ element in $name$_) {
\n
"
" dataSize += pb::CodedOutputStream.Compute$capitalized_type_name$Size
NoTag
(element);
\n
"
" dataSize += pb::CodedOutputStream.Compute$capitalized_type_name$Size(element);
\n
"
"}
\n
"
);
}
else
{
printer
->
Print
(
...
...
@@ -111,7 +122,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode(
int
tagSize
=
internal
::
WireFormat
::
TagSize
(
descriptor_
->
number
(),
descriptor_
->
type
());
if
(
descriptor_
->
is_packed
())
{
printer
->
Print
(
"size += $tag_size$ + pb::CodedOutputStream.ComputeInt32Size
NoTag
(dataSize);
\n
"
,
"size += $tag_size$ + pb::CodedOutputStream.ComputeInt32Size(dataSize);
\n
"
,
"tag_size"
,
SimpleItoa
(
tagSize
));
}
else
{
printer
->
Print
(
...
...
src/google/protobuf/wire_format.h
View file @
828b7e61
...
...
@@ -290,7 +290,7 @@ class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {
inline
WireFormatLite
::
WireType
WireFormat
::
WireTypeForField
(
const
FieldDescriptor
*
field
)
{
if
(
field
->
options
().
packed
())
{
if
(
field
->
is_
packed
())
{
return
WireFormatLite
::
WIRETYPE_LENGTH_DELIMITED
;
}
else
{
return
WireTypeForFieldType
(
field
->
type
());
...
...
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