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
be20ae0b
Commit
be20ae0b
authored
Dec 05, 2014
by
Feng Xiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compile issues and test failures in VS2008.
parent
7c939bcb
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
112 additions
and
90 deletions
+112
-90
arena.cc
src/google/protobuf/arena.cc
+1
-1
arena_unittest.cc
src/google/protobuf/arena_unittest.cc
+6
-6
arenastring.h
src/google/protobuf/arenastring.h
+0
-1
cpp_message.cc
src/google/protobuf/compiler/cpp/cpp_message.cc
+1
-1
map_field_test.cc
src/google/protobuf/map_field_test.cc
+0
-35
map_test_util.cc
src/google/protobuf/map_test_util.cc
+17
-17
preserve_unknown_enum_test.cc
src/google/protobuf/preserve_unknown_enum_test.cc
+2
-0
repeated_field.h
src/google/protobuf/repeated_field.h
+9
-4
repeated_field_reflection_unittest.cc
src/google/protobuf/repeated_field_reflection_unittest.cc
+1
-2
repeated_field_unittest.cc
src/google/protobuf/repeated_field_unittest.cc
+2
-2
fastmem.h
src/google/protobuf/stubs/fastmem.h
+0
-1
type_traits.h
src/google/protobuf/stubs/type_traits.h
+4
-3
unknown_field_set_unittest.cc
src/google/protobuf/unknown_field_set_unittest.cc
+1
-1
libprotoc.vcproj
vsprojects/libprotoc.vcproj
+68
-16
No files found.
src/google/protobuf/arena.cc
View file @
be20ae0b
...
@@ -38,7 +38,7 @@ namespace google {
...
@@ -38,7 +38,7 @@ namespace google {
namespace
protobuf
{
namespace
protobuf
{
google
::
protobuf
::
internal
::
SequenceNumber
Arena
::
lifecycle_id_generator_
;
google
::
protobuf
::
internal
::
SequenceNumber
Arena
::
lifecycle_id_generator_
;
__thread
Arena
::
ThreadCache
Arena
::
thread_cache_
=
{
-
1
,
NULL
};
GOOGLE_THREAD_LOCAL
Arena
::
ThreadCache
Arena
::
thread_cache_
=
{
-
1
,
NULL
};
void
Arena
::
Init
(
const
ArenaOptions
&
options
)
{
void
Arena
::
Init
(
const
ArenaOptions
&
options
)
{
lifecycle_id_
=
lifecycle_id_generator_
.
GetNext
();
lifecycle_id_
=
lifecycle_id_generator_
.
GetNext
();
...
...
src/google/protobuf/arena_unittest.cc
View file @
be20ae0b
...
@@ -128,7 +128,7 @@ TEST(ArenaTest, InitialBlockTooSmall) {
...
@@ -128,7 +128,7 @@ TEST(ArenaTest, InitialBlockTooSmall) {
// initial block.
// initial block.
std
::
vector
<
char
>
arena_block
(
64
);
std
::
vector
<
char
>
arena_block
(
64
);
ArenaOptions
options
;
ArenaOptions
options
;
options
.
initial_block
=
arena_block
.
data
()
;
options
.
initial_block
=
&
arena_block
[
0
]
;
options
.
initial_block_size
=
arena_block
.
size
();
options
.
initial_block_size
=
arena_block
.
size
();
Arena
arena
(
options
);
Arena
arena
(
options
);
...
@@ -137,7 +137,7 @@ TEST(ArenaTest, InitialBlockTooSmall) {
...
@@ -137,7 +137,7 @@ TEST(ArenaTest, InitialBlockTooSmall) {
// Ensure that the arena allocator did not return memory pointing into the
// Ensure that the arena allocator did not return memory pointing into the
// initial block of memory.
// initial block of memory.
uintptr_t
arena_start
=
reinterpret_cast
<
uintptr_t
>
(
arena_block
.
data
()
);
uintptr_t
arena_start
=
reinterpret_cast
<
uintptr_t
>
(
&
arena_block
[
0
]
);
uintptr_t
arena_end
=
arena_start
+
arena_block
.
size
();
uintptr_t
arena_end
=
arena_start
+
arena_block
.
size
();
EXPECT_FALSE
(
allocation
>=
arena_start
&&
allocation
<
arena_end
);
EXPECT_FALSE
(
allocation
>=
arena_start
&&
allocation
<
arena_end
);
...
@@ -771,7 +771,7 @@ TEST(ArenaTest, RepeatedFieldOnArena) {
...
@@ -771,7 +771,7 @@ TEST(ArenaTest, RepeatedFieldOnArena) {
// Preallocate an initial arena block to avoid mallocs during hooked region.
// Preallocate an initial arena block to avoid mallocs during hooked region.
std
::
vector
<
char
>
arena_block
(
1024
*
1024
);
std
::
vector
<
char
>
arena_block
(
1024
*
1024
);
ArenaOptions
options
;
ArenaOptions
options
;
options
.
initial_block
=
arena_block
.
data
()
;
options
.
initial_block
=
&
arena_block
[
0
]
;
options
.
initial_block_size
=
arena_block
.
size
();
options
.
initial_block_size
=
arena_block
.
size
();
Arena
arena
(
options
);
Arena
arena
(
options
);
...
@@ -898,7 +898,7 @@ TEST(ArenaTest, NoHeapAllocationsTest) {
...
@@ -898,7 +898,7 @@ TEST(ArenaTest, NoHeapAllocationsTest) {
// Allocate a large initial block to avoid mallocs during hooked test.
// Allocate a large initial block to avoid mallocs during hooked test.
std
::
vector
<
char
>
arena_block
(
128
*
1024
);
std
::
vector
<
char
>
arena_block
(
128
*
1024
);
ArenaOptions
options
;
ArenaOptions
options
;
options
.
initial_block
=
arena_block
.
data
()
;
options
.
initial_block
=
&
arena_block
[
0
]
;
options
.
initial_block_size
=
arena_block
.
size
();
options
.
initial_block_size
=
arena_block
.
size
();
Arena
arena
(
options
);
Arena
arena
(
options
);
...
@@ -918,7 +918,7 @@ TEST(ArenaTest, NoHeapAllocationsTest) {
...
@@ -918,7 +918,7 @@ TEST(ArenaTest, NoHeapAllocationsTest) {
TEST
(
ArenaTest
,
MessageLiteOnArena
)
{
TEST
(
ArenaTest
,
MessageLiteOnArena
)
{
std
::
vector
<
char
>
arena_block
(
128
*
1024
);
std
::
vector
<
char
>
arena_block
(
128
*
1024
);
ArenaOptions
options
;
ArenaOptions
options
;
options
.
initial_block
=
arena_block
.
data
()
;
options
.
initial_block
=
&
arena_block
[
0
]
;
options
.
initial_block_size
=
arena_block
.
size
();
options
.
initial_block_size
=
arena_block
.
size
();
Arena
arena
(
options
);
Arena
arena
(
options
);
const
google
::
protobuf
::
MessageLite
*
prototype
=
dynamic_cast
<
const
google
::
protobuf
::
MessageLite
*
prototype
=
dynamic_cast
<
...
@@ -977,7 +977,7 @@ TEST(ArenaTest, SpaceUsed) {
...
@@ -977,7 +977,7 @@ TEST(ArenaTest, SpaceUsed) {
// Test with initial block.
// Test with initial block.
std
::
vector
<
char
>
arena_block
(
1024
);
std
::
vector
<
char
>
arena_block
(
1024
);
options
.
initial_block
=
arena_block
.
data
()
;
options
.
initial_block
=
&
arena_block
[
0
]
;
options
.
initial_block_size
=
arena_block
.
size
();
options
.
initial_block_size
=
arena_block
.
size
();
Arena
arena_2
(
options
);
Arena
arena_2
(
options
);
EXPECT_EQ
(
1024
,
arena_2
.
SpaceUsed
());
EXPECT_EQ
(
1024
,
arena_2
.
SpaceUsed
());
...
...
src/google/protobuf/arenastring.h
View file @
be20ae0b
...
@@ -31,7 +31,6 @@
...
@@ -31,7 +31,6 @@
#ifndef GOOGLE_PROTOBUF_ARENASTRING_H__
#ifndef GOOGLE_PROTOBUF_ARENASTRING_H__
#define GOOGLE_PROTOBUF_ARENASTRING_H__
#define GOOGLE_PROTOBUF_ARENASTRING_H__
#include <stdint.h>
#include <string>
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/common.h>
...
...
src/google/protobuf/compiler/cpp/cpp_message.cc
View file @
be20ae0b
...
@@ -1226,7 +1226,7 @@ GenerateDescriptorDeclarations(io::Printer* printer) {
...
@@ -1226,7 +1226,7 @@ GenerateDescriptorDeclarations(io::Printer* printer) {
for
(
int
j
=
0
;
j
<
descriptor_
->
oneof_decl
(
i
)
->
field_count
();
j
++
)
{
for
(
int
j
=
0
;
j
<
descriptor_
->
oneof_decl
(
i
)
->
field_count
();
j
++
)
{
const
FieldDescriptor
*
field
=
descriptor_
->
oneof_decl
(
i
)
->
field
(
j
);
const
FieldDescriptor
*
field
=
descriptor_
->
oneof_decl
(
i
)
->
field
(
j
);
printer
->
Print
(
" "
);
printer
->
Print
(
" "
);
if
(
IsStringOrMessage
(
field
)
)
{
if
(
field
->
cpp_type
()
==
FieldDescriptor
::
CPPTYPE_MESSAGE
)
{
printer
->
Print
(
"const "
);
printer
->
Print
(
"const "
);
}
}
field_generators_
.
get
(
field
).
GeneratePrivateMembers
(
printer
);
field_generators_
.
get
(
field
).
GeneratePrivateMembers
(
printer
);
...
...
src/google/protobuf/map_field_test.cc
View file @
be20ae0b
...
@@ -430,41 +430,6 @@ TEST_P(MapFieldStateTest, MutableMapField) {
...
@@ -430,41 +430,6 @@ TEST_P(MapFieldStateTest, MutableMapField) {
}
}
}
}
class
MapFieldBaseStateStub
:
public
MapFieldBaseStub
{
public
:
MapFieldBaseStateStub
(
Mutex
*
mutex
,
int
*
clean_counter
,
int
*
completed_counter
)
:
mutex_
(
mutex
),
clean_counter_
(
clean_counter
),
completed_counter_
(
completed_counter
)
{}
~
MapFieldBaseStateStub
()
{}
protected
:
void
SyncRepeatedFieldWithMapNoLock
()
const
{
Clean
();
}
void
SyncMapWithRepeatedFieldNoLock
()
const
{
Clean
();
}
private
:
void
Clean
()
const
{
{
MutexLock
lock
(
mutex_
);
++
(
*
clean_counter_
);
}
struct
timespec
tm
;
tm
.
tv_sec
=
0
;
tm
.
tv_nsec
=
100000000
;
// 100ms
nanosleep
(
&
tm
,
NULL
);
{
MutexLock
lock
(
mutex_
);
// No other thread should have completed while this one was initializing.
EXPECT_EQ
(
0
,
*
completed_counter_
);
}
}
Mutex
*
mutex_
;
int
*
clean_counter_
;
int
*
completed_counter_
;
};
}
// namespace internal
}
// namespace internal
}
// namespace protobuf
}
// namespace protobuf
}
// namespace google
}
// namespace google
src/google/protobuf/map_test_util.cc
View file @
be20ae0b
...
@@ -1020,7 +1020,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1020,7 +1020,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_int32_int32_key_
);
*
sub_message
,
map_int32_int32_key_
);
int32
val
=
sub_message
->
GetReflection
()
->
GetInt32
(
int32
val
=
sub_message
->
GetReflection
()
->
GetInt32
(
*
sub_message
,
map_int32_int32_val_
);
*
sub_message
,
map_int32_int32_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1034,7 +1034,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1034,7 +1034,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_int64_int64_key_
);
*
sub_message
,
map_int64_int64_key_
);
int64
val
=
sub_message
->
GetReflection
()
->
GetInt64
(
int64
val
=
sub_message
->
GetReflection
()
->
GetInt64
(
*
sub_message
,
map_int64_int64_val_
);
*
sub_message
,
map_int64_int64_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1048,7 +1048,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1048,7 +1048,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_uint32_uint32_key_
);
*
sub_message
,
map_uint32_uint32_key_
);
uint32
val
=
sub_message
->
GetReflection
()
->
GetUInt32
(
uint32
val
=
sub_message
->
GetReflection
()
->
GetUInt32
(
*
sub_message
,
map_uint32_uint32_val_
);
*
sub_message
,
map_uint32_uint32_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1062,7 +1062,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1062,7 +1062,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_uint64_uint64_key_
);
*
sub_message
,
map_uint64_uint64_key_
);
uint64
val
=
sub_message
->
GetReflection
()
->
GetUInt64
(
uint64
val
=
sub_message
->
GetReflection
()
->
GetUInt64
(
*
sub_message
,
map_uint64_uint64_val_
);
*
sub_message
,
map_uint64_uint64_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1076,7 +1076,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1076,7 +1076,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_sint32_sint32_key_
);
*
sub_message
,
map_sint32_sint32_key_
);
int32
val
=
sub_message
->
GetReflection
()
->
GetInt32
(
int32
val
=
sub_message
->
GetReflection
()
->
GetInt32
(
*
sub_message
,
map_sint32_sint32_val_
);
*
sub_message
,
map_sint32_sint32_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1090,7 +1090,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1090,7 +1090,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_sint64_sint64_key_
);
*
sub_message
,
map_sint64_sint64_key_
);
int64
val
=
sub_message
->
GetReflection
()
->
GetInt64
(
int64
val
=
sub_message
->
GetReflection
()
->
GetInt64
(
*
sub_message
,
map_sint64_sint64_val_
);
*
sub_message
,
map_sint64_sint64_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1104,7 +1104,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1104,7 +1104,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_fixed32_fixed32_key_
);
*
sub_message
,
map_fixed32_fixed32_key_
);
uint32
val
=
sub_message
->
GetReflection
()
->
GetUInt32
(
uint32
val
=
sub_message
->
GetReflection
()
->
GetUInt32
(
*
sub_message
,
map_fixed32_fixed32_val_
);
*
sub_message
,
map_fixed32_fixed32_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1118,7 +1118,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1118,7 +1118,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_fixed64_fixed64_key_
);
*
sub_message
,
map_fixed64_fixed64_key_
);
uint64
val
=
sub_message
->
GetReflection
()
->
GetUInt64
(
uint64
val
=
sub_message
->
GetReflection
()
->
GetUInt64
(
*
sub_message
,
map_fixed64_fixed64_val_
);
*
sub_message
,
map_fixed64_fixed64_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1132,7 +1132,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1132,7 +1132,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_sfixed32_sfixed32_key_
);
*
sub_message
,
map_sfixed32_sfixed32_key_
);
int32
val
=
sub_message
->
GetReflection
()
->
GetInt32
(
int32
val
=
sub_message
->
GetReflection
()
->
GetInt32
(
*
sub_message
,
map_sfixed32_sfixed32_val_
);
*
sub_message
,
map_sfixed32_sfixed32_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1146,7 +1146,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1146,7 +1146,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_sfixed64_sfixed64_key_
);
*
sub_message
,
map_sfixed64_sfixed64_key_
);
int64
val
=
sub_message
->
GetReflection
()
->
GetInt64
(
int64
val
=
sub_message
->
GetReflection
()
->
GetInt64
(
*
sub_message
,
map_sfixed64_sfixed64_val_
);
*
sub_message
,
map_sfixed64_sfixed64_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1160,7 +1160,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1160,7 +1160,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_int32_float_key_
);
*
sub_message
,
map_int32_float_key_
);
float
val
=
sub_message
->
GetReflection
()
->
GetFloat
(
float
val
=
sub_message
->
GetReflection
()
->
GetFloat
(
*
sub_message
,
map_int32_float_val_
);
*
sub_message
,
map_int32_float_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1174,7 +1174,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1174,7 +1174,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_int32_double_key_
);
*
sub_message
,
map_int32_double_key_
);
double
val
=
sub_message
->
GetReflection
()
->
GetDouble
(
double
val
=
sub_message
->
GetReflection
()
->
GetDouble
(
*
sub_message
,
map_int32_double_val_
);
*
sub_message
,
map_int32_double_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1188,7 +1188,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1188,7 +1188,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_bool_bool_key_
);
*
sub_message
,
map_bool_bool_key_
);
bool
val
=
sub_message
->
GetReflection
()
->
GetBool
(
bool
val
=
sub_message
->
GetReflection
()
->
GetBool
(
*
sub_message
,
map_bool_bool_val_
);
*
sub_message
,
map_bool_bool_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1202,7 +1202,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1202,7 +1202,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_string_string_key_
);
*
sub_message
,
map_string_string_key_
);
string
val
=
sub_message
->
GetReflection
()
->
GetString
(
string
val
=
sub_message
->
GetReflection
()
->
GetString
(
*
sub_message
,
map_string_string_val_
);
*
sub_message
,
map_string_string_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1216,7 +1216,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1216,7 +1216,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_int32_bytes_key_
);
*
sub_message
,
map_int32_bytes_key_
);
string
val
=
sub_message
->
GetReflection
()
->
GetString
(
string
val
=
sub_message
->
GetReflection
()
->
GetString
(
*
sub_message
,
map_int32_bytes_val_
);
*
sub_message
,
map_int32_bytes_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1230,7 +1230,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1230,7 +1230,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_int32_enum_key_
);
*
sub_message
,
map_int32_enum_key_
);
const
EnumValueDescriptor
*
val
=
sub_message
->
GetReflection
()
->
GetEnum
(
const
EnumValueDescriptor
*
val
=
sub_message
->
GetReflection
()
->
GetEnum
(
*
sub_message
,
map_int32_enum_val_
);
*
sub_message
,
map_int32_enum_val_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
{
{
...
@@ -1246,7 +1246,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
...
@@ -1246,7 +1246,7 @@ void MapTestUtil::MapReflectionTester::ExpectMapFieldsSetViaReflection(
*
sub_message
,
map_int32_foreign_message_val_
);
*
sub_message
,
map_int32_foreign_message_val_
);
int32
val
=
foreign_message
.
GetReflection
()
->
GetInt32
(
int32
val
=
foreign_message
.
GetReflection
()
->
GetInt32
(
foreign_message
,
foreign_c_
);
foreign_message
,
foreign_c_
);
EXPECT_EQ
(
map
.
at
(
key
)
,
val
);
EXPECT_EQ
(
map
[
key
]
,
val
);
}
}
}
}
}
}
...
...
src/google/protobuf/preserve_unknown_enum_test.cc
View file @
be20ae0b
...
@@ -200,6 +200,7 @@ TEST(PreserveUnknownEnumTest, Proto2CatchesUnknownValues) {
...
@@ -200,6 +200,7 @@ TEST(PreserveUnknownEnumTest, Proto2CatchesUnknownValues) {
EXPECT_TRUE
(
enum_value
!=
NULL
);
EXPECT_TRUE
(
enum_value
!=
NULL
);
r
->
AddEnum
(
&
message
,
repeated_field
,
enum_value
);
r
->
AddEnum
(
&
message
,
repeated_field
,
enum_value
);
#ifdef PROTOBUF_HAS_DEATH_TEST
// Enum-field integer-based setters GOOGLE_DCHECK-fail on invalid values, in order to
// Enum-field integer-based setters GOOGLE_DCHECK-fail on invalid values, in order to
// remain consistent with proto2 generated code.
// remain consistent with proto2 generated code.
EXPECT_DEBUG_DEATH
({
EXPECT_DEBUG_DEATH
({
...
@@ -214,6 +215,7 @@ TEST(PreserveUnknownEnumTest, Proto2CatchesUnknownValues) {
...
@@ -214,6 +215,7 @@ TEST(PreserveUnknownEnumTest, Proto2CatchesUnknownValues) {
r
->
AddEnumValue
(
&
message
,
repeated_field
,
4242
);
r
->
AddEnumValue
(
&
message
,
repeated_field
,
4242
);
r
->
GetRepeatedEnum
(
message
,
repeated_field
,
1
);
r
->
GetRepeatedEnum
(
message
,
repeated_field
,
1
);
},
"AddEnumValue accepts only valid integer values"
);
},
"AddEnumValue accepts only valid integer values"
);
#endif // PROTOBUF_HAS_DEATH_TEST
}
}
TEST
(
PreserveUnknownEnumTest
,
SupportsUnknownEnumValuesAPI
)
{
TEST
(
PreserveUnknownEnumTest
,
SupportsUnknownEnumValuesAPI
)
{
...
...
src/google/protobuf/repeated_field.h
View file @
be20ae0b
...
@@ -236,10 +236,11 @@ class RepeatedField {
...
@@ -236,10 +236,11 @@ class RepeatedField {
Arena
*
arena
;
Arena
*
arena
;
Element
elements
[
1
];
Element
elements
[
1
];
};
};
// Why not sizeof(Rep) - sizeof(Element)? Because this is not accurate w.r.t.
// We can not use sizeof(Rep) - sizeof(Element) due to the trailing padding on
// trailing padding on the struct -- e.g. if Element is int, this would yield
// the struct. We can not use sizeof(Arena*) as well because there might be
// 12 on x86-64, not 8 as we want.
// a "gap" after the field arena and before the field elements (e.g., when
static
const
size_t
kRepHeaderSize
=
sizeof
(
Arena
*
);
// Element is double and pointer is 32bit).
static
const
size_t
kRepHeaderSize
;
// Contains arena ptr and the elements array. We also keep the invariant that
// Contains arena ptr and the elements array. We also keep the invariant that
// if rep_ is NULL, then arena is NULL.
// if rep_ is NULL, then arena is NULL.
Rep
*
rep_
;
Rep
*
rep_
;
...
@@ -263,6 +264,10 @@ class RepeatedField {
...
@@ -263,6 +264,10 @@ class RepeatedField {
}
}
};
};
template
<
typename
Element
>
const
size_t
RepeatedField
<
Element
>::
kRepHeaderSize
=
reinterpret_cast
<
size_t
>
(
&
reinterpret_cast
<
Rep
*>
(
16
)
->
elements
[
0
])
-
16
;
namespace
internal
{
namespace
internal
{
template
<
typename
It
>
class
RepeatedPtrIterator
;
template
<
typename
It
>
class
RepeatedPtrIterator
;
template
<
typename
It
,
typename
VoidPtr
>
class
RepeatedPtrOverPtrsIterator
;
template
<
typename
It
,
typename
VoidPtr
>
class
RepeatedPtrOverPtrsIterator
;
...
...
src/google/protobuf/repeated_field_reflection_unittest.cc
View file @
be20ae0b
...
@@ -196,8 +196,7 @@ void TestRepeatedFieldRefIterator(
...
@@ -196,8 +196,7 @@ void TestRepeatedFieldRefIterator(
int
index
=
0
;
int
index
=
0
;
for
(
typename
Ref
::
const_iterator
it
=
handle
.
begin
();
for
(
typename
Ref
::
const_iterator
it
=
handle
.
begin
();
it
!=
handle
.
end
();
++
it
)
{
it
!=
handle
.
end
();
++
it
)
{
ValueType
value
=
static_cast
<
ValueType
>
(
*
it
);
EXPECT_EQ
((
message
.
*
GetFunc
)(
index
),
*
it
);
EXPECT_EQ
((
message
.
*
GetFunc
)(
index
),
value
);
++
index
;
++
index
;
}
}
EXPECT_EQ
(
handle
.
size
(),
index
);
EXPECT_EQ
(
handle
.
size
(),
index
);
...
...
src/google/protobuf/repeated_field_unittest.cc
View file @
be20ae0b
...
@@ -92,8 +92,8 @@ TEST(RepeatedField, Small) {
...
@@ -92,8 +92,8 @@ TEST(RepeatedField, Small) {
EXPECT_TRUE
(
field
.
empty
());
EXPECT_TRUE
(
field
.
empty
());
EXPECT_EQ
(
field
.
size
(),
0
);
EXPECT_EQ
(
field
.
size
(),
0
);
// Additional
8
bytes are for 'struct Rep' header.
// Additional bytes are for 'struct Rep' header.
int
expected_usage
=
4
*
sizeof
(
int
)
+
8
;
int
expected_usage
=
4
*
sizeof
(
int
)
+
sizeof
(
Arena
*
)
;
EXPECT_EQ
(
field
.
SpaceUsedExcludingSelf
(),
expected_usage
);
EXPECT_EQ
(
field
.
SpaceUsedExcludingSelf
(),
expected_usage
);
}
}
...
...
src/google/protobuf/stubs/fastmem.h
View file @
be20ae0b
...
@@ -46,7 +46,6 @@
...
@@ -46,7 +46,6 @@
#define GOOGLE_PROTOBUF_STUBS_FASTMEM_H_
#define GOOGLE_PROTOBUF_STUBS_FASTMEM_H_
#include <stddef.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
...
...
src/google/protobuf/stubs/type_traits.h
View file @
be20ae0b
...
@@ -339,6 +339,9 @@ struct ConvertHelper {
...
@@ -339,6 +339,9 @@ struct ConvertHelper {
static
small_
Test
(
To
);
static
small_
Test
(
To
);
static
big_
Test
(...);
static
big_
Test
(...);
static
From
Create
();
static
From
Create
();
enum
{
value
=
sizeof
(
Test
(
Create
()))
==
sizeof
(
small_
)
};
};
};
}
// namespace type_traits_internal
}
// namespace type_traits_internal
...
@@ -346,9 +349,7 @@ struct ConvertHelper {
...
@@ -346,9 +349,7 @@ struct ConvertHelper {
template
<
typename
From
,
typename
To
>
template
<
typename
From
,
typename
To
>
struct
is_convertible
struct
is_convertible
:
integral_constant
<
bool
,
:
integral_constant
<
bool
,
sizeof
(
type_traits_internal
::
ConvertHelper
<
From
,
To
>::
Test
(
type_traits_internal
::
ConvertHelper
<
From
,
To
>::
value
>
{
type_traits_internal
::
ConvertHelper
<
From
,
To
>::
Create
()))
==
sizeof
(
small_
)
>
{
};
};
#endif
#endif
...
...
src/google/protobuf/unknown_field_set_unittest.cc
View file @
be20ae0b
...
@@ -485,7 +485,7 @@ TEST_F(UnknownFieldSetTest, UnknownEnumValue) {
...
@@ -485,7 +485,7 @@ TEST_F(UnknownFieldSetTest, UnknownEnumValue) {
TEST_F
(
UnknownFieldSetTest
,
SpaceUsedExcludingSelf
)
{
TEST_F
(
UnknownFieldSetTest
,
SpaceUsedExcludingSelf
)
{
UnknownFieldSet
empty
;
UnknownFieldSet
empty
;
empty
.
AddVarint
(
1
,
0
);
empty
.
AddVarint
(
1
,
0
);
EXPECT_EQ
(
/* vector<UnknownField> */
24
+
/* sizeof(UnknownField) */
16
,
EXPECT_EQ
(
sizeof
(
vector
<
UnknownField
>
)
+
sizeof
(
UnknownField
)
,
empty
.
SpaceUsedExcludingSelf
());
empty
.
SpaceUsedExcludingSelf
());
}
}
...
...
vsprojects/libprotoc.vcproj
View file @
be20ae0b
...
@@ -323,22 +323,6 @@
...
@@ -323,22 +323,6 @@
RelativePath=
"..\src\google\protobuf\compiler\command_line_interface.cc"
RelativePath=
"..\src\google\protobuf\compiler\command_line_interface.cc"
>
>
</File>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\subprocess.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\zip_writer.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\plugin.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\plugin.pb.cc"
>
</File>
<File
<File
RelativePath=
"..\src\google\protobuf\compiler\cpp\cpp_enum.cc"
RelativePath=
"..\src\google\protobuf\compiler\cpp\cpp_enum.cc"
>
>
...
@@ -367,6 +351,10 @@
...
@@ -367,6 +351,10 @@
RelativePath=
"..\src\google\protobuf\compiler\cpp\cpp_helpers.cc"
RelativePath=
"..\src\google\protobuf\compiler\cpp\cpp_helpers.cc"
>
>
</File>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\cpp\cpp_map_field.cc"
>
</File>
<File
<File
RelativePath=
"..\src\google\protobuf\compiler\cpp\cpp_message.cc"
RelativePath=
"..\src\google\protobuf\compiler\cpp\cpp_message.cc"
>
>
...
@@ -391,6 +379,10 @@
...
@@ -391,6 +379,10 @@
RelativePath=
"..\src\google\protobuf\compiler\java\java_context.cc"
RelativePath=
"..\src\google\protobuf\compiler\java\java_context.cc"
>
>
</File>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\java\java_doc_comment.cc"
>
</File>
<File
<File
RelativePath=
"..\src\google\protobuf\compiler\java\java_enum.cc"
RelativePath=
"..\src\google\protobuf\compiler\java\java_enum.cc"
>
>
...
@@ -427,6 +419,10 @@
...
@@ -427,6 +419,10 @@
RelativePath=
"..\src\google\protobuf\compiler\java\java_lazy_message_field.cc"
RelativePath=
"..\src\google\protobuf\compiler\java\java_lazy_message_field.cc"
>
>
</File>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\java\java_map_field.cc"
>
</File>
<File
<File
RelativePath=
"..\src\google\protobuf\compiler\java\java_message.cc"
RelativePath=
"..\src\google\protobuf\compiler\java\java_message.cc"
>
>
...
@@ -455,10 +451,66 @@
...
@@ -455,10 +451,66 @@
RelativePath=
"..\src\google\protobuf\compiler\java\java_string_field.cc"
RelativePath=
"..\src\google\protobuf\compiler\java\java_string_field.cc"
>
>
</File>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_enum.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_enum_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_extension.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_file.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_generator.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_helpers.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_message.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_message_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_primitive_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\plugin.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\plugin.pb.cc"
>
</File>
<File
<File
RelativePath=
"..\src\google\protobuf\compiler\python\python_generator.cc"
RelativePath=
"..\src\google\protobuf\compiler\python\python_generator.cc"
>
>
</File>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\subprocess.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\zip_writer.cc"
>
</File>
</Filter>
</Filter>
</Files>
</Files>
<Globals>
<Globals>
...
...
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