aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2015-02-25 15:28:44 -0800
committerGravatar Jisi Liu <jisi.liu@gmail.com>2015-02-25 15:56:58 -0800
commitdf184fba00acc7d4aa7b9d64693c53c815a64eda (patch)
tree43fd810851d46f16d54f5f0aa6a5017115c0b707 /src
parent581a5266ee592eaed28a24d4aa58c59d4d0135e8 (diff)
Make maps fields work on installed C++ protobufs.
Change-Id: Id937e25bbb35968ee76c92bd4a8ce6247408c443
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am25
-rw-r--r--src/google/protobuf/stubs/hash.h44
2 files changed, 44 insertions, 25 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0f0bd089..5179846c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,12 +31,24 @@ nobase_dist_proto_DATA = google/protobuf/descriptor.proto \
clean-local:
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
MAINTAINERCLEANFILES = \
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 = \
google/protobuf/stubs/atomic_sequence_num.h \
google/protobuf/stubs/atomicops.h \
@@ -54,11 +66,12 @@ nobase_include_HEADERS = \
google/protobuf/stubs/atomicops_internals_x86_gcc.h \
google/protobuf/stubs/atomicops_internals_x86_msvc.h \
google/protobuf/stubs/casts.h \
- google/protobuf/stubs/singleton.h \
google/protobuf/stubs/common.h \
google/protobuf/stubs/fastmem.h \
+ google/protobuf/stubs/hash.h \
google/protobuf/stubs/once.h \
google/protobuf/stubs/platform_macros.h \
+ google/protobuf/stubs/singleton.h \
google/protobuf/stubs/stl_util.h \
google/protobuf/stubs/template_util.h \
google/protobuf/stubs/type_traits.h \
@@ -111,6 +124,9 @@ nobase_include_HEADERS = \
google/protobuf/compiler/python/python_generator.h \
google/protobuf/compiler/ruby/ruby_generator.h
+nobase_nodist_include_HEADERS = \
+ $(public_config)
+
lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
@@ -135,7 +151,8 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/io/coded_stream.cc \
google/protobuf/io/coded_stream_inl.h \
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_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined
@@ -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.h
-BUILT_SOURCES = $(protoc_outputs)
+BUILT_SOURCES = $(protoc_outputs) $(public_config)
if USE_EXTERNAL_PROTOC
diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h
index 5b6a073d..badcb6a5 100644
--- a/src/google/protobuf/stubs/hash.h
+++ b/src/google/protobuf/stubs/hash.h
@@ -37,13 +37,14 @@
#include <string.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)
-#include HASH_MAP_H
-#include HASH_SET_H
+#if defined(GOOGLE_PROTOBUF_HAVE_HASH_MAP) && \
+ defined(GOOGLE_PROTOBUF_HAVE_HASH_SET)
+#include GOOGLE_PROTOBUF_HASH_MAP_H
+#include GOOGLE_PROTOBUF_HASH_SET_H
#else
-#define MISSING_HASH
+#define GOOGLE_PROTOBUF_MISSING_HASH
#include <map>
#include <set>
#endif
@@ -51,7 +52,7 @@
namespace google {
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
// set.
@@ -105,7 +106,7 @@ class hash_set : public std::set<Key, HashFcn> {
#elif defined(_MSC_VER) && !defined(_STLPORT_VERSION)
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
@@ -119,13 +120,13 @@ class CstringLess {
template <>
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,
typename HashFcn = hash<Key>,
typename EqualKey = int >
-class hash_map : public HASH_NAMESPACE::hash_map<
+class hash_map : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_map<
Key, Data, HashFcn> {
public:
hash_map(int = 0) {}
@@ -134,7 +135,7 @@ class hash_map : public HASH_NAMESPACE::hash_map<
template <typename Key,
typename HashFcn = hash<Key>,
typename EqualKey = int >
-class hash_set : public HASH_NAMESPACE::hash_set<
+class hash_set : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash_set<
Key, HashFcn> {
public:
hash_set(int = 0) {}
@@ -143,7 +144,7 @@ class hash_set : public HASH_NAMESPACE::hash_set<
#else
template <typename Key>
-struct hash : public HASH_NAMESPACE::hash<Key> {
+struct hash : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash<Key> {
};
template <typename Key>
@@ -166,25 +167,26 @@ struct hash<const char*> {
}
};
-template <typename Key, typename Data,
- typename HashFcn = hash<Key>,
+template <typename Key, typename Data, typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key> >
-class hash_map : public HASH_NAMESPACE::HASH_MAP_CLASS<
- Key, Data, HashFcn, EqualKey> {
+class hash_map
+ : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<
+ Key, Data, HashFcn, EqualKey> {
public:
hash_map(int = 0) {}
};
-template <typename Key,
- typename HashFcn = hash<Key>,
+template <typename Key, typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key> >
-class hash_set : public HASH_NAMESPACE::HASH_SET_CLASS<
- Key, HashFcn, EqualKey> {
+class hash_set
+ : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<
+ Key, HashFcn, EqualKey> {
public:
hash_set(int = 0) {}
};
-#endif
+#undef GOOGLE_PROTOBUF_MISSING_HASH
+#endif // !GOOGLE_PROTOBUF_MISSING_HASH
template <>
struct hash<string> {