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
d2fd0638
Commit
d2fd0638
authored
Jul 24, 2009
by
kenton@google.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Down-integrate some code from an internal branch. (More to come.)
parent
31afcd73
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
7 deletions
+47
-7
CHANGES.txt
CHANGES.txt
+3
-0
add_person.cc
examples/add_person.cc
+3
-0
list_people.cc
examples/list_people.cc
+3
-0
CodedOutputStream.java
.../src/main/java/com/google/protobuf/CodedOutputStream.java
+0
-1
cpp_helpers.cc
src/google/protobuf/compiler/cpp/cpp_helpers.cc
+9
-1
cpp_unittest.cc
src/google/protobuf/compiler/cpp/cpp_unittest.cc
+14
-0
message.h
src/google/protobuf/message.h
+5
-5
unittest.proto
src/google/protobuf/unittest.proto
+10
-0
No files found.
CHANGES.txt
View file @
d2fd0638
...
@@ -7,6 +7,9 @@
...
@@ -7,6 +7,9 @@
* Added RemoveLast and SwapElements(index1, index2) to Reflection
* Added RemoveLast and SwapElements(index1, index2) to Reflection
interface for repeated elements.
interface for repeated elements.
* Added Swap(Message) to Reflection interface.
* Added Swap(Message) to Reflection interface.
* Floating-point literals in generated code that are intended to be
single-precision now explicitly have 'f' suffix to avoid pedantic warnings
produced by some compilers.
2009-05-13 version 2.1.0:
2009-05-13 version 2.1.0:
...
...
examples/add_person.cc
View file @
d2fd0638
...
@@ -88,5 +88,8 @@ int main(int argc, char* argv[]) {
...
@@ -88,5 +88,8 @@ int main(int argc, char* argv[]) {
}
}
}
}
// Optional: Delete all global objects allocated by libprotobuf.
google
::
protobuf
::
ShutdownProtobufLibrary
();
return
0
;
return
0
;
}
}
examples/list_people.cc
View file @
d2fd0638
...
@@ -61,5 +61,8 @@ int main(int argc, char* argv[]) {
...
@@ -61,5 +61,8 @@ int main(int argc, char* argv[]) {
ListPeople
(
address_book
);
ListPeople
(
address_book
);
// Optional: Delete all global objects allocated by libprotobuf.
google
::
protobuf
::
ShutdownProtobufLibrary
();
return
0
;
return
0
;
}
}
java/src/main/java/com/google/protobuf/CodedOutputStream.java
View file @
d2fd0638
...
@@ -808,7 +808,6 @@ public final class CodedOutputStream {
...
@@ -808,7 +808,6 @@ public final class CodedOutputStream {
* field of arbitrary type, excluding tag, to the stream.
* field of arbitrary type, excluding tag, to the stream.
*
*
* @param type The field's type.
* @param type The field's type.
* @param number The field's number.
* @param value Object representing the field's value. Must be of the exact
* @param value Object representing the field's value. Must be of the exact
* type which would be returned by
* type which would be returned by
* {@link Message#getField(Descriptors.FieldDescriptor)} for
* {@link Message#getField(Descriptors.FieldDescriptor)} for
...
...
src/google/protobuf/compiler/cpp/cpp_helpers.cc
View file @
d2fd0638
...
@@ -227,7 +227,15 @@ string DefaultValue(const FieldDescriptor* field) {
...
@@ -227,7 +227,15 @@ string DefaultValue(const FieldDescriptor* field) {
case
FieldDescriptor
:
:
CPPTYPE_DOUBLE
:
case
FieldDescriptor
:
:
CPPTYPE_DOUBLE
:
return
SimpleDtoa
(
field
->
default_value_double
());
return
SimpleDtoa
(
field
->
default_value_double
());
case
FieldDescriptor
:
:
CPPTYPE_FLOAT
:
case
FieldDescriptor
:
:
CPPTYPE_FLOAT
:
return
SimpleFtoa
(
field
->
default_value_float
());
{
// If floating point value contains a period (.) or an exponent (either
// E or e), then append suffix 'f' to make it a floating-point literal.
string
float_value
=
SimpleFtoa
(
field
->
default_value_float
());
if
(
float_value
.
find_first_of
(
".eE"
)
!=
string
::
npos
)
{
float_value
.
push_back
(
'f'
);
}
return
float_value
;
}
case
FieldDescriptor
:
:
CPPTYPE_BOOL
:
case
FieldDescriptor
:
:
CPPTYPE_BOOL
:
return
field
->
default_value_bool
()
?
"true"
:
"false"
;
return
field
->
default_value_bool
()
?
"true"
:
"false"
;
case
FieldDescriptor
:
:
CPPTYPE_ENUM
:
case
FieldDescriptor
:
:
CPPTYPE_ENUM
:
...
...
src/google/protobuf/compiler/cpp/cpp_unittest.cc
View file @
d2fd0638
...
@@ -50,9 +50,11 @@
...
@@ -50,9 +50,11 @@
#include <google/protobuf/unittest_optimize_for.pb.h>
#include <google/protobuf/unittest_optimize_for.pb.h>
#include <google/protobuf/unittest_embed_optimize_for.pb.h>
#include <google/protobuf/unittest_embed_optimize_for.pb.h>
#include <google/protobuf/test_util.h>
#include <google/protobuf/test_util.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h>
#include <google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h>
#include <google/protobuf/compiler/importer.h>
#include <google/protobuf/compiler/importer.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.pb.h>
...
@@ -73,6 +75,18 @@ namespace cpp {
...
@@ -73,6 +75,18 @@ namespace cpp {
// Can't use an anonymous namespace here due to brokenness of Tru64 compiler.
// Can't use an anonymous namespace here due to brokenness of Tru64 compiler.
namespace
cpp_unittest
{
namespace
cpp_unittest
{
TEST
(
ExtremeDefaultValues
,
FloatingPoint
)
{
const
unittest
::
TestExtremeDefaultValues
&
extreme_default
=
unittest
::
TestExtremeDefaultValues
::
default_instance
();
EXPECT_EQ
(
0.0
f
,
extreme_default
.
zero_float
());
EXPECT_EQ
(
1.0
f
,
extreme_default
.
one_float
());
EXPECT_EQ
(
1.5
f
,
extreme_default
.
small_float
());
EXPECT_EQ
(
-
1.0
f
,
extreme_default
.
negative_one_float
());
EXPECT_EQ
(
-
1.5
f
,
extreme_default
.
negative_float
());
EXPECT_EQ
(
2.0e8
f
,
extreme_default
.
large_float
());
EXPECT_EQ
(
-
8e-28
f
,
extreme_default
.
small_negative_float
());
}
class
MockErrorCollector
:
public
MultiFileErrorCollector
{
class
MockErrorCollector
:
public
MultiFileErrorCollector
{
public
:
public
:
...
...
src/google/protobuf/message.h
View file @
d2fd0638
...
@@ -223,6 +223,11 @@ class LIBPROTOBUF_EXPORT Message {
...
@@ -223,6 +223,11 @@ class LIBPROTOBUF_EXPORT Message {
// See Reflection::GetUnknownFields() for more on unknown fields.
// See Reflection::GetUnknownFields() for more on unknown fields.
virtual
void
DiscardUnknownFields
();
virtual
void
DiscardUnknownFields
();
// Computes (an estimate of) the total number of bytes currently used for
// storing the message in memory. The default implementation calls the
// Reflection object's SpaceUsed() method.
virtual
int
SpaceUsed
()
const
;
// Debugging -------------------------------------------------------
// Debugging -------------------------------------------------------
// Generates a human readable form of this message, useful for debugging
// Generates a human readable form of this message, useful for debugging
...
@@ -362,11 +367,6 @@ class LIBPROTOBUF_EXPORT Message {
...
@@ -362,11 +367,6 @@ class LIBPROTOBUF_EXPORT Message {
// this, it MUST override SetCachedSize().
// this, it MUST override SetCachedSize().
virtual
int
ByteSize
()
const
;
virtual
int
ByteSize
()
const
;
// Computes (an estimate of) the total number of bytes currently used for
// storing the message in memory. The default implementation calls the
// Reflection object's SpaceUsed() method.
virtual
int
SpaceUsed
()
const
;
// Serializes the message without recomputing the size. The message must
// Serializes the message without recomputing the size. The message must
// not have changed since the last call to ByteSize(); if it has, the results
// not have changed since the last call to ByteSize(); if it has, the results
// are undefined.
// are undefined.
...
...
src/google/protobuf/unittest.proto
View file @
d2fd0638
...
@@ -458,6 +458,16 @@ message TestExtremeDefaultValues {
...
@@ -458,6 +458,16 @@ message TestExtremeDefaultValues {
// the UTF-8 text directly into this text file rather than escape it, but
// the UTF-8 text directly into this text file rather than escape it, but
// lots of people use editors that would be confused by this.)
// lots of people use editors that would be confused by this.)
optional
string
utf8_string
=
6
[
default
=
"\341\210\264"
];
optional
string
utf8_string
=
6
[
default
=
"\341\210\264"
];
// Tests for single-precision floating-point values.
optional
float
zero_float
=
7
[
default
=
0
];
optional
float
one_float
=
8
[
default
=
1
];
optional
float
small_float
=
9
[
default
=
1.5
];
optional
float
negative_one_float
=
10
[
default
=
-
1
];
optional
float
negative_float
=
11
[
default
=
-
1.5
];
// Using exponents
optional
float
large_float
=
12
[
default
=
2E8
];
optional
float
small_negative_float
=
13
[
default
=
-
8e-28
];
}
}
// Test String and Bytes: string is for valid UTF-8 strings
// Test String and Bytes: string is for valid UTF-8 strings
...
...
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