Commit df184fba authored by Jisi Liu's avatar Jisi Liu

Make maps fields work on installed C++ protobufs.

Change-Id: Id937e25bbb35968ee76c92bd4a8ce6247408c443
parent 581a5266
...@@ -310,10 +310,12 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ ...@@ -310,10 +310,12 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
LICENSE \ LICENSE \
CONTRIBUTORS.txt \ CONTRIBUTORS.txt \
CHANGES.txt \ CHANGES.txt \
config.h.include \
editors/README.txt \ editors/README.txt \
editors/proto.vim \ editors/proto.vim \
editors/protobuf-mode.el \ editors/protobuf-mode.el \
vsprojects/config.h \ vsprojects/config.h \
vsprojects/google/protobuf/stubs/pbconfig.h \
vsprojects/extract_includes.bat \ vsprojects/extract_includes.bat \
vsprojects/libprotobuf.vcproj \ vsprojects/libprotobuf.vcproj \
vsprojects/libprotobuf-lite.vcproj \ vsprojects/libprotobuf-lite.vcproj \
......
HASH_MAP_CLASS
HASH_MAP_H
HASH_NAMESPACE
HASH_SET_CLASS
HASH_SET_H
HAVE_HASH_MAP
HAVE_HASH_SET
...@@ -31,12 +31,24 @@ nobase_dist_proto_DATA = google/protobuf/descriptor.proto \ ...@@ -31,12 +31,24 @@ nobase_dist_proto_DATA = google/protobuf/descriptor.proto \
clean-local: clean-local:
rm -f *.loT rm -f *.loT
CLEANFILES = $(protoc_outputs) unittest_proto_middleman \ public_config = google/protobuf/stubs/pbconfig.h
CLEANFILES = $(protoc_outputs) $(public_config) unittest_proto_middleman \
testzip.jar testzip.list testzip.proto testzip.zip testzip.jar testzip.list testzip.proto testzip.zip
MAINTAINERCLEANFILES = \ MAINTAINERCLEANFILES = \
Makefile.in Makefile.in
# Generate and distribute a minimum config.h file to make hash_map work.
# The autoheader config has too much info, which might conflict with other
# macros applications might include. Thus, we create a stubs/pbconfig.h, that
# only #defines what we really need, and prefix it with GOOGLE_PROTOBUF_ to
# avoid conflicts.
$(public_config): $(top_builddir)/config.h $(top_srcdir)/config.h.include
echo "// Note: Google Protobuf internal only. Do NOT include." > $@
cat $(top_builddir)/config.h | grep -f $(top_srcdir)/config.h.include | \
sed 's,#define , #define GOOGLE_PROTOBUF_,' >> $@
nobase_include_HEADERS = \ nobase_include_HEADERS = \
google/protobuf/stubs/atomic_sequence_num.h \ google/protobuf/stubs/atomic_sequence_num.h \
google/protobuf/stubs/atomicops.h \ google/protobuf/stubs/atomicops.h \
...@@ -54,11 +66,12 @@ nobase_include_HEADERS = \ ...@@ -54,11 +66,12 @@ nobase_include_HEADERS = \
google/protobuf/stubs/atomicops_internals_x86_gcc.h \ google/protobuf/stubs/atomicops_internals_x86_gcc.h \
google/protobuf/stubs/atomicops_internals_x86_msvc.h \ google/protobuf/stubs/atomicops_internals_x86_msvc.h \
google/protobuf/stubs/casts.h \ google/protobuf/stubs/casts.h \
google/protobuf/stubs/singleton.h \
google/protobuf/stubs/common.h \ google/protobuf/stubs/common.h \
google/protobuf/stubs/fastmem.h \ google/protobuf/stubs/fastmem.h \
google/protobuf/stubs/hash.h \
google/protobuf/stubs/once.h \ google/protobuf/stubs/once.h \
google/protobuf/stubs/platform_macros.h \ google/protobuf/stubs/platform_macros.h \
google/protobuf/stubs/singleton.h \
google/protobuf/stubs/stl_util.h \ google/protobuf/stubs/stl_util.h \
google/protobuf/stubs/template_util.h \ google/protobuf/stubs/template_util.h \
google/protobuf/stubs/type_traits.h \ google/protobuf/stubs/type_traits.h \
...@@ -111,6 +124,9 @@ nobase_include_HEADERS = \ ...@@ -111,6 +124,9 @@ nobase_include_HEADERS = \
google/protobuf/compiler/python/python_generator.h \ google/protobuf/compiler/python/python_generator.h \
google/protobuf/compiler/ruby/ruby_generator.h google/protobuf/compiler/ruby/ruby_generator.h
nobase_nodist_include_HEADERS = \
$(public_config)
lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS) libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
...@@ -135,7 +151,8 @@ libprotobuf_lite_la_SOURCES = \ ...@@ -135,7 +151,8 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/io/coded_stream.cc \ google/protobuf/io/coded_stream.cc \
google/protobuf/io/coded_stream_inl.h \ google/protobuf/io/coded_stream_inl.h \
google/protobuf/io/zero_copy_stream.cc \ google/protobuf/io/zero_copy_stream.cc \
google/protobuf/io/zero_copy_stream_impl_lite.cc google/protobuf/io/zero_copy_stream_impl_lite.cc \
$(public_config)
libprotobuf_la_LIBADD = $(PTHREAD_LIBS) libprotobuf_la_LIBADD = $(PTHREAD_LIBS)
libprotobuf_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined libprotobuf_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined
...@@ -374,7 +391,7 @@ protoc_outputs = \ ...@@ -374,7 +391,7 @@ protoc_outputs = \
google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc \ google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc \
google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h
BUILT_SOURCES = $(protoc_outputs) BUILT_SOURCES = $(protoc_outputs) $(public_config)
if USE_EXTERNAL_PROTOC if USE_EXTERNAL_PROTOC
......
...@@ -37,13 +37,14 @@ ...@@ -37,13 +37,14 @@
#include <string.h> #include <string.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include "config.h" #include <google/protobuf/stubs/pbconfig.h>
#if defined(HAVE_HASH_MAP) && defined(HAVE_HASH_SET) #if defined(GOOGLE_PROTOBUF_HAVE_HASH_MAP) && \
#include HASH_MAP_H defined(GOOGLE_PROTOBUF_HAVE_HASH_SET)
#include HASH_SET_H #include GOOGLE_PROTOBUF_HASH_MAP_H
#include GOOGLE_PROTOBUF_HASH_SET_H
#else #else
#define MISSING_HASH #define GOOGLE_PROTOBUF_MISSING_HASH
#include <map> #include <map>
#include <set> #include <set>
#endif #endif
...@@ -51,7 +52,7 @@ ...@@ -51,7 +52,7 @@
namespace google { namespace google {
namespace protobuf { namespace protobuf {
#ifdef MISSING_HASH #ifdef GOOGLE_PROTOBUF_MISSING_HASH
// This system doesn't have hash_map or hash_set. Emulate them using map and // This system doesn't have hash_map or hash_set. Emulate them using map and
// set. // set.
...@@ -105,7 +106,7 @@ class hash_set : public std::set<Key, HashFcn> { ...@@ -105,7 +106,7 @@ class hash_set : public std::set<Key, HashFcn> {
#elif defined(_MSC_VER) && !defined(_STLPORT_VERSION) #elif defined(_MSC_VER) && !defined(_STLPORT_VERSION)
template <typename Key> template <typename Key>
struct hash : public HASH_NAMESPACE::hash_compare<Key> { struct hash : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_compare<Key> {
}; };
// MSVC's hash_compare<const char*> hashes based on the string contents but // MSVC's hash_compare<const char*> hashes based on the string contents but
...@@ -119,13 +120,13 @@ class CstringLess { ...@@ -119,13 +120,13 @@ class CstringLess {
template <> template <>
struct hash<const char*> struct hash<const char*>
: public HASH_NAMESPACE::hash_compare<const char*, CstringLess> { : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_compare<
}; const char*, CstringLess> {};
template <typename Key, typename Data, template <typename Key, typename Data,
typename HashFcn = hash<Key>, typename HashFcn = hash<Key>,
typename EqualKey = int > typename EqualKey = int >
class hash_map : public HASH_NAMESPACE::hash_map< class hash_map : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_map<
Key, Data, HashFcn> { Key, Data, HashFcn> {
public: public:
hash_map(int = 0) {} hash_map(int = 0) {}
...@@ -134,7 +135,7 @@ class hash_map : public HASH_NAMESPACE::hash_map< ...@@ -134,7 +135,7 @@ class hash_map : public HASH_NAMESPACE::hash_map<
template <typename Key, template <typename Key,
typename HashFcn = hash<Key>, typename HashFcn = hash<Key>,
typename EqualKey = int > typename EqualKey = int >
class hash_set : public HASH_NAMESPACE::hash_set< class hash_set : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_set<
Key, HashFcn> { Key, HashFcn> {
public: public:
hash_set(int = 0) {} hash_set(int = 0) {}
...@@ -143,7 +144,7 @@ class hash_set : public HASH_NAMESPACE::hash_set< ...@@ -143,7 +144,7 @@ class hash_set : public HASH_NAMESPACE::hash_set<
#else #else
template <typename Key> template <typename Key>
struct hash : public HASH_NAMESPACE::hash<Key> { struct hash : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash<Key> {
}; };
template <typename Key> template <typename Key>
...@@ -166,25 +167,26 @@ struct hash<const char*> { ...@@ -166,25 +167,26 @@ struct hash<const char*> {
} }
}; };
template <typename Key, typename Data, template <typename Key, typename Data, typename HashFcn = hash<Key>,
typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key> > typename EqualKey = std::equal_to<Key> >
class hash_map : public HASH_NAMESPACE::HASH_MAP_CLASS< class hash_map
: public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
Key, Data, HashFcn, EqualKey> { Key, Data, HashFcn, EqualKey> {
public: public:
hash_map(int = 0) {} hash_map(int = 0) {}
}; };
template <typename Key, template <typename Key, typename HashFcn = hash<Key>,
typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key> > typename EqualKey = std::equal_to<Key> >
class hash_set : public HASH_NAMESPACE::HASH_SET_CLASS< class hash_set
: public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<
Key, HashFcn, EqualKey> { Key, HashFcn, EqualKey> {
public: public:
hash_set(int = 0) {} hash_set(int = 0) {}
}; };
#endif #undef GOOGLE_PROTOBUF_MISSING_HASH
#endif // !GOOGLE_PROTOBUF_MISSING_HASH
template <> template <>
struct hash<string> { struct hash<string> {
......
...@@ -72,6 +72,7 @@ copy ..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastme ...@@ -72,6 +72,7 @@ copy ..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastme
copy ..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h copy ..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h
copy ..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h copy ..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h
copy ..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h copy ..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h
copy ..\src\google\protobuf\stubs\hash.h include\google\protobuf\stubs\hash.h
copy ..\src\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h copy ..\src\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h
copy ..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h copy ..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h
copy ..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h copy ..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h
...@@ -80,3 +81,4 @@ copy ..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_ ...@@ -80,3 +81,4 @@ copy ..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_
copy ..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h copy ..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h
copy ..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h copy ..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h
copy ..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h copy ..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h
copy google\protobuf\stubs\pbconfig.h include\google\protobuf\stubs\pbconfig.h
/* protobuf config.h for MSVC. On other platforms, this is generated
* automatically by autoheader / autoconf / configure. */
/* the location of <hash_map> */
#define GOOGLE_PROTOBUF_HASH_MAP_H <hash_map>
/* the namespace of hash_map/hash_set */
// Apparently Microsoft decided to move hash_map *back* to the std namespace
// in MSVC 2010:
// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx
// TODO(kenton): Use unordered_map instead, which is available in MSVC 2010.
#if _MSC_VER < 1310 || _MSC_VER >= 1600
#define GOOGLE_PROTOBUF_HASH_NAMESPACE std
#else
#define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
#endif
/* the location of <hash_set> */
#define GOOGLE_PROTOBUF_HASH_SET_H <hash_set>
/* define if the compiler has hash_map */
#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
/* define if the compiler has hash_set */
#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
/* define if you want to use zlib. See readme.txt for additional
* requirements. */
// #define HAVE_ZLIB 1
...@@ -163,6 +163,10 @@ ...@@ -163,6 +163,10 @@
RelativePath=".\config.h" RelativePath=".\config.h"
> >
</File> </File>
<File
RelativePath=".\google\protobuf\stubs\pbconfig.h"
>
</File>
<File <File
RelativePath="..\src\google\protobuf\extension_set.h" RelativePath="..\src\google\protobuf\extension_set.h"
> >
......
...@@ -163,6 +163,10 @@ ...@@ -163,6 +163,10 @@
RelativePath=".\config.h" RelativePath=".\config.h"
> >
</File> </File>
<File
RelativePath=".\google\protobuf\stubs\pbconfig.h"
>
</File>
<File <File
RelativePath="..\src\google\protobuf\descriptor.h" RelativePath="..\src\google\protobuf\descriptor.h"
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment