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
60fb63e3
Commit
60fb63e3
authored
Jun 20, 2009
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial Silverlight compatibility work
parent
36721730
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
16 deletions
+23
-16
ByteString.cs
src/ProtocolBuffers/ByteString.cs
+1
-1
CodedInputStream.cs
src/ProtocolBuffers/CodedInputStream.cs
+1
-1
FieldSet.cs
src/ProtocolBuffers/FieldSet.cs
+3
-3
GeneratedMessage.cs
src/ProtocolBuffers/GeneratedMessage.cs
+2
-2
NameHelpers.cs
src/ProtocolBuffers/NameHelpers.cs
+3
-2
TextFormat.cs
src/ProtocolBuffers/TextFormat.cs
+1
-1
TextTokenizer.cs
src/ProtocolBuffers/TextTokenizer.cs
+10
-4
UnknownFieldSet.cs
src/ProtocolBuffers/UnknownFieldSet.cs
+2
-2
No files found.
src/ProtocolBuffers/ByteString.cs
View file @
60fb63e3
...
...
@@ -116,7 +116,7 @@ namespace Google.ProtocolBuffers {
}
public
string
ToString
(
Encoding
encoding
)
{
return
encoding
.
GetString
(
bytes
);
return
encoding
.
GetString
(
bytes
,
0
,
bytes
.
Length
);
}
public
string
ToStringUtf8
()
{
...
...
src/ProtocolBuffers/CodedInputStream.cs
View file @
60fb63e3
...
...
@@ -236,7 +236,7 @@ namespace Google.ProtocolBuffers {
return
result
;
}
// Slow path: Build a byte array first then copy it.
return
Encoding
.
UTF8
.
GetString
(
ReadRawBytes
(
size
));
return
Encoding
.
UTF8
.
GetString
(
ReadRawBytes
(
size
)
,
0
,
size
);
}
/// <summary>
...
...
src/ProtocolBuffers/FieldSet.cs
View file @
60fb63e3
...
...
@@ -62,8 +62,8 @@ namespace Google.ProtocolBuffers {
}
public
static
FieldSet
CreateInstance
()
{
// Use Sorted
List
to keep fields in the canonical order
return
new
FieldSet
(
new
Sorted
List
<
FieldDescriptor
,
object
>());
// Use Sorted
Dictionary
to keep fields in the canonical order
return
new
FieldSet
(
new
Sorted
Dictionary
<
FieldDescriptor
,
object
>());
}
/// <summary>
...
...
@@ -82,7 +82,7 @@ namespace Google.ProtocolBuffers {
}
if
(
hasRepeats
)
{
var
tmp
=
new
Sorted
List
<
FieldDescriptor
,
object
>();
var
tmp
=
new
Sorted
Dictionary
<
FieldDescriptor
,
object
>();
foreach
(
KeyValuePair
<
FieldDescriptor
,
object
>
entry
in
fields
)
{
IList
<
object
>
list
=
entry
.
Value
as
IList
<
object
>;
tmp
[
entry
.
Key
]
=
list
==
null
?
entry
.
Value
:
Lists
.
AsReadOnly
(
list
);
...
...
src/ProtocolBuffers/GeneratedMessage.cs
View file @
60fb63e3
...
...
@@ -66,8 +66,8 @@ namespace Google.ProtocolBuffers {
internal
IDictionary
<
FieldDescriptor
,
Object
>
GetMutableFieldMap
()
{
// Use a Sorted
List
so we'll end up serializing fields in order
var
ret
=
new
Sorted
List
<
FieldDescriptor
,
object
>();
// Use a Sorted
Dictionary
so we'll end up serializing fields in order
var
ret
=
new
Sorted
Dictionary
<
FieldDescriptor
,
object
>();
MessageDescriptor
descriptor
=
DescriptorForType
;
foreach
(
FieldDescriptor
field
in
descriptor
.
Fields
)
{
IFieldAccessor
<
TMessage
,
TBuilder
>
accessor
=
InternalFieldAccessors
[
field
];
...
...
src/ProtocolBuffers/NameHelpers.cs
View file @
60fb63e3
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Globalization
;
namespace
Google.ProtocolBuffers
{
/// <summary>
...
...
@@ -31,7 +32,7 @@ namespace Google.ProtocolBuffers {
char
c
=
input
[
i
];
if
(
'a'
<=
c
&&
c
<=
'z'
)
{
if
(
capitaliseNext
)
{
result
.
Append
(
char
.
ToUpper
Invariant
(
c
));
result
.
Append
(
char
.
ToUpper
(
c
,
CultureInfo
.
InvariantCulture
));
}
else
{
result
.
Append
(
c
);
}
...
...
@@ -40,7 +41,7 @@ namespace Google.ProtocolBuffers {
if
(
i
==
0
&&
!
pascal
)
{
// Force first letter to lower-case unless explicitly told to
// capitalize it.
result
.
Append
(
char
.
ToLower
Invariant
(
c
));
result
.
Append
(
char
.
ToLower
(
c
,
CultureInfo
.
InvariantCulture
));
}
else
{
// Capital letters after the first are left as-is.
result
.
Append
(
c
);
...
...
src/ProtocolBuffers/TextFormat.cs
View file @
60fb63e3
...
...
@@ -537,7 +537,7 @@ namespace Google.ProtocolBuffers {
if
(
field
==
null
)
{
// Explicitly specify the invariant culture so that this code does not break when
// executing in Turkey.
String
lowerName
=
name
.
ToLower
Invariant
(
);
String
lowerName
=
name
.
ToLower
(
CultureInfo
.
InvariantCulture
);
field
=
type
.
FindDescriptor
<
FieldDescriptor
>(
lowerName
);
// If the case-insensitive match worked but the field is NOT a group,
// TODO(jonskeet): What? Java comment ends here!
...
...
src/ProtocolBuffers/TextTokenizer.cs
View file @
60fb63e3
...
...
@@ -69,9 +69,15 @@ namespace Google.ProtocolBuffers {
/// </summary>
private
int
previousColumn
=
0
;
#if SILVERLIGHT
private
const
RegexOptions
CompiledRegexWhereAvailable
=
RegexOptions
.
None
;
#else
private
const
RegexOptions
CompiledRegexWhereAvailable
=
RegexOptions
.
Compiled
;
#endif
// Note: atomic groups used to mimic possessive quantifiers in Java in both of these regexes
private
static
readonly
Regex
WhitespaceAndCommentPattern
=
new
Regex
(
"\\G(?>(\\s|(#.*$))+)"
,
RegexOptions
.
Compiled
|
RegexOptions
.
Multiline
);
CompiledRegexWhereAvailable
|
RegexOptions
.
Multiline
);
private
static
readonly
Regex
TokenPattern
=
new
Regex
(
"\\G[a-zA-Z_](?>[0-9a-zA-Z_+-]*)|"
+
// an identifier
"\\G[0-9+-](?>[0-9a-zA-Z_.+-]*)|"
+
// a number
...
...
@@ -79,9 +85,9 @@ namespace Google.ProtocolBuffers {
"\\G\'(?>([^\"\\\n\\\\]|\\\\.)*)(\'|\\\\?$)"
,
// a single-quoted string
RegexOptions
.
Compiled
|
RegexOptions
.
Multiline
);
private
static
readonly
Regex
DoubleInfinity
=
new
Regex
(
"^-?inf(inity)?$"
,
RegexOptions
.
Compiled
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
FloatInfinity
=
new
Regex
(
"^-?inf(inity)?f?$"
,
RegexOptions
.
Compiled
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
FloatNan
=
new
Regex
(
"^nanf?$"
,
RegexOptions
.
Compiled
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
DoubleInfinity
=
new
Regex
(
"^-?inf(inity)?$"
,
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
FloatInfinity
=
new
Regex
(
"^-?inf(inity)?f?$"
,
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
FloatNan
=
new
Regex
(
"^nanf?$"
,
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
/** Construct a tokenizer that parses tokens from the given text. */
public
TextTokenizer
(
string
text
)
{
...
...
src/ProtocolBuffers/UnknownFieldSet.cs
View file @
60fb63e3
...
...
@@ -240,10 +240,10 @@ namespace Google.ProtocolBuffers {
public
sealed
class
Builder
{
/// <summary>
/// Mapping from number to field. Note that by using a Sorted
List
we ensure
/// Mapping from number to field. Note that by using a Sorted
Dictionary
we ensure
/// that the fields will be serialized in ascending order.
/// </summary>
private
IDictionary
<
int
,
UnknownField
>
fields
=
new
Sorted
List
<
int
,
UnknownField
>();
private
IDictionary
<
int
,
UnknownField
>
fields
=
new
Sorted
Dictionary
<
int
,
UnknownField
>();
// Optimization: We keep around a builder for the last field that was
// modified so that we can efficiently add to it multiple times in a
...
...
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