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
3c80886f
Commit
3c80886f
authored
Sep 09, 2009
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Silverlight compatibility other than SortedList
parent
79a8c010
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
21 deletions
+74
-21
CodedInputStream.cs
src/ProtocolBuffers/CodedInputStream.cs
+5
-1
CodedOutputStream.cs
src/ProtocolBuffers/CodedOutputStream.cs
+8
-6
DescriptorPool.cs
src/ProtocolBuffers/Descriptors/DescriptorPool.cs
+1
-1
SilverlightCompatibility.cs
src/ProtocolBuffers/SilverlightCompatibility.cs
+50
-0
TextTokenizer.cs
src/ProtocolBuffers/TextTokenizer.cs
+10
-13
No files found.
src/ProtocolBuffers/CodedInputStream.cs
View file @
3c80886f
...
@@ -160,8 +160,12 @@ namespace Google.ProtocolBuffers {
...
@@ -160,8 +160,12 @@ namespace Google.ProtocolBuffers {
/// Read a double field from the stream.
/// Read a double field from the stream.
/// </summary>
/// </summary>
public
double
ReadDouble
()
{
public
double
ReadDouble
()
{
// TODO(jonskeet): Test this on different endiannesses
#if SILVERLIGHT2
byte
[]
bytes
=
ReadRawBytes
(
8
);
return
BitConverter
.
ToDouble
(
bytes
,
0
);
#else
return
BitConverter
.
Int64BitsToDouble
((
long
)
ReadRawLittleEndian64
());
return
BitConverter
.
Int64BitsToDouble
((
long
)
ReadRawLittleEndian64
());
#endif
}
}
/// <summary>
/// <summary>
...
...
src/ProtocolBuffers/CodedOutputStream.cs
View file @
3c80886f
...
@@ -114,9 +114,8 @@ namespace Google.ProtocolBuffers {
...
@@ -114,9 +114,8 @@ namespace Google.ProtocolBuffers {
/// Writes a double field value, including tag, to the stream.
/// Writes a double field value, including tag, to the stream.
/// </summary>
/// </summary>
public
void
WriteDouble
(
int
fieldNumber
,
double
value
)
{
public
void
WriteDouble
(
int
fieldNumber
,
double
value
)
{
// TODO(jonskeet): Test this on different endiannesses
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed64
);
Write
RawLittleEndian64
((
ulong
)
BitConverter
.
DoubleToInt64Bits
(
value
)
);
Write
DoubleNoTag
(
value
);
}
}
/// <summary>
/// <summary>
...
@@ -124,10 +123,7 @@ namespace Google.ProtocolBuffers {
...
@@ -124,10 +123,7 @@ namespace Google.ProtocolBuffers {
/// </summary>
/// </summary>
public
void
WriteFloat
(
int
fieldNumber
,
float
value
)
{
public
void
WriteFloat
(
int
fieldNumber
,
float
value
)
{
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
WriteTag
(
fieldNumber
,
WireFormat
.
WireType
.
Fixed32
);
// TODO(jonskeet): Test this on different endiannesses
WriteFloatNoTag
(
value
);
byte
[]
rawBytes
=
BitConverter
.
GetBytes
(
value
);
uint
asInteger
=
BitConverter
.
ToUInt32
(
rawBytes
,
0
);
WriteRawLittleEndian32
(
asInteger
);
}
}
/// <summary>
/// <summary>
...
@@ -332,7 +328,13 @@ namespace Google.ProtocolBuffers {
...
@@ -332,7 +328,13 @@ namespace Google.ProtocolBuffers {
/// Writes a double field value, including tag, to the stream.
/// Writes a double field value, including tag, to the stream.
/// </summary>
/// </summary>
public
void
WriteDoubleNoTag
(
double
value
)
{
public
void
WriteDoubleNoTag
(
double
value
)
{
// TODO(jonskeet): Test this on different endiannesses
#if SILVERLIGHT2
byte
[]
bytes
=
BitConverter
.
GetBytes
(
value
);
WriteRawBytes
(
bytes
,
0
,
8
);
#else
WriteRawLittleEndian64
((
ulong
)
BitConverter
.
DoubleToInt64Bits
(
value
));
WriteRawLittleEndian64
((
ulong
)
BitConverter
.
DoubleToInt64Bits
(
value
));
#endif
}
}
/// <summary>
/// <summary>
...
...
src/ProtocolBuffers/Descriptors/DescriptorPool.cs
View file @
3c80886f
...
@@ -139,7 +139,7 @@ namespace Google.ProtocolBuffers.Descriptors {
...
@@ -139,7 +139,7 @@ namespace Google.ProtocolBuffers.Descriptors {
descriptorsByName
[
fullName
]
=
descriptor
;
descriptorsByName
[
fullName
]
=
descriptor
;
}
}
private
static
readonly
Regex
ValidationRegex
=
new
Regex
(
"^[_A-Za-z][_A-Za-z0-9]*$"
,
RegexOptions
.
Compiled
);
private
static
readonly
Regex
ValidationRegex
=
new
Regex
(
"^[_A-Za-z][_A-Za-z0-9]*$"
,
SilverlightCompatibility
.
CompiledRegexWhereAvailable
);
/// <summary>
/// <summary>
/// Verifies that the descriptor's name is valid (i.e. it contains
/// Verifies that the descriptor's name is valid (i.e. it contains
...
...
src/ProtocolBuffers/SilverlightCompatibility.cs
0 → 100644
View file @
3c80886f
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// http://github.com/jskeet/dotnet-protobufs/
// Original C++/Java/Python code:
// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using
System.Text.RegularExpressions
;
namespace
Google.ProtocolBuffers
{
/// <summary>
/// Class containing helpful workarounds for Silverlight compatibility
/// </summary>
internal
static
class
SilverlightCompatibility
{
#if SILVERLIGHT2
internal
const
RegexOptions
CompiledRegexWhereAvailable
=
RegexOptions
.
None
;
#else
internal
const
RegexOptions
CompiledRegexWhereAvailable
=
RegexOptions
.
Compiled
;
#endif
}
}
src/ProtocolBuffers/TextTokenizer.cs
View file @
3c80886f
...
@@ -69,25 +69,22 @@ namespace Google.ProtocolBuffers {
...
@@ -69,25 +69,22 @@ namespace Google.ProtocolBuffers {
/// </summary>
/// </summary>
private
int
previousColumn
=
0
;
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
// Note: atomic groups used to mimic possessive quantifiers in Java in both of these regexes
private
static
readonly
Regex
WhitespaceAndCommentPattern
=
new
Regex
(
"\\G(?>(\\s|(#.*$))+)"
,
internal
static
readonly
Regex
WhitespaceAndCommentPattern
=
new
Regex
(
"\\G(?>(\\s|(#.*$))+)"
,
CompiledRegexWhereAvailable
|
RegexOptions
.
Multiline
);
SilverlightCompatibility
.
CompiledRegexWhereAvailable
|
RegexOptions
.
Multiline
);
private
static
readonly
Regex
TokenPattern
=
new
Regex
(
private
static
readonly
Regex
TokenPattern
=
new
Regex
(
"\\G[a-zA-Z_](?>[0-9a-zA-Z_+-]*)|"
+
// an identifier
"\\G[a-zA-Z_](?>[0-9a-zA-Z_+-]*)|"
+
// an identifier
"\\G[0-9+-](?>[0-9a-zA-Z_.+-]*)|"
+
// a number
"\\G[0-9+-](?>[0-9a-zA-Z_.+-]*)|"
+
// a number
"\\G\"(?>([^\"\\\n\\\\]|\\\\.)*)(\"|\\\\?$)|"
+
// a double-quoted string
"\\G\"(?>([^\"\\\n\\\\]|\\\\.)*)(\"|\\\\?$)|"
+
// a double-quoted string
"\\G\'(?>([^\"\\\n\\\\]|\\\\.)*)(\'|\\\\?$)"
,
// a single-quoted string
"\\G\'(?>([^\"\\\n\\\\]|\\\\.)*)(\'|\\\\?$)"
,
// a single-quoted string
RegexOptions
.
Compiled
|
RegexOptions
.
Multiline
);
SilverlightCompatibility
.
CompiledRegexWhereAvailable
|
RegexOptions
.
Multiline
);
private
static
readonly
Regex
DoubleInfinity
=
new
Regex
(
"^-?inf(inity)?$"
,
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
DoubleInfinity
=
new
Regex
(
"^-?inf(inity)?$"
,
private
static
readonly
Regex
FloatInfinity
=
new
Regex
(
"^-?inf(inity)?f?$"
,
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
SilverlightCompatibility
.
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
FloatNan
=
new
Regex
(
"^nanf?$"
,
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
FloatInfinity
=
new
Regex
(
"^-?inf(inity)?f?$"
,
SilverlightCompatibility
.
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
private
static
readonly
Regex
FloatNan
=
new
Regex
(
"^nanf?$"
,
SilverlightCompatibility
.
CompiledRegexWhereAvailable
|
RegexOptions
.
IgnoreCase
);
/** Construct a tokenizer that parses tokens from the given text. */
/** Construct a tokenizer that parses tokens from the given text. */
public
TextTokenizer
(
string
text
)
{
public
TextTokenizer
(
string
text
)
{
...
...
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