Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: third_party/protobuf/src/google/protobuf/stubs/common.h

Issue 21208003: Update protobuf to r428, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // http://code.google.com/p/protobuf/ 3 // http://code.google.com/p/protobuf/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (false) { 349 if (false) {
350 implicit_cast<From*, To>(0); 350 implicit_cast<From*, To>(0);
351 } 351 }
352 352
353 #if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI) 353 #if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
354 assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only! 354 assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only!
355 #endif 355 #endif
356 return static_cast<To>(f); 356 return static_cast<To>(f);
357 } 357 }
358 358
359 // Simplified down_cast for reference type.
360 template<typename To, typename From>
361 inline To down_cast(From& f) {
362 return static_cast<To>(f);
363 }
364
359 } // namespace internal 365 } // namespace internal
360 366
361 // We made these internal so that they would show up as such in the docs, 367 // We made these internal so that they would show up as such in the docs,
362 // but we don't want to stick "internal::" in front of them everywhere. 368 // but we don't want to stick "internal::" in front of them everywhere.
363 using internal::implicit_cast; 369 using internal::implicit_cast;
364 using internal::down_cast; 370 using internal::down_cast;
365 371
366 // The COMPILE_ASSERT macro can be used to verify that a compile time 372 // The COMPILE_ASSERT macro can be used to verify that a compile time
367 // expression is true. For example, you could use it to verify the 373 // expression is true. For example, you could use it to verify the
368 // size of a static array: 374 // size of a static array:
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 #undef GOOGLE_LOG 700 #undef GOOGLE_LOG
695 #undef GOOGLE_LOG_IF 701 #undef GOOGLE_LOG_IF
696 702
697 #undef GOOGLE_CHECK 703 #undef GOOGLE_CHECK
698 #undef GOOGLE_CHECK_EQ 704 #undef GOOGLE_CHECK_EQ
699 #undef GOOGLE_CHECK_NE 705 #undef GOOGLE_CHECK_NE
700 #undef GOOGLE_CHECK_LT 706 #undef GOOGLE_CHECK_LT
701 #undef GOOGLE_CHECK_LE 707 #undef GOOGLE_CHECK_LE
702 #undef GOOGLE_CHECK_GT 708 #undef GOOGLE_CHECK_GT
703 #undef GOOGLE_CHECK_GE 709 #undef GOOGLE_CHECK_GE
710 #undef GOOGLE_CHECK_NOTNULL
704 711
705 #undef GOOGLE_DLOG 712 #undef GOOGLE_DLOG
706 #undef GOOGLE_DCHECK 713 #undef GOOGLE_DCHECK
707 #undef GOOGLE_DCHECK_EQ 714 #undef GOOGLE_DCHECK_EQ
708 #undef GOOGLE_DCHECK_NE 715 #undef GOOGLE_DCHECK_NE
709 #undef GOOGLE_DCHECK_LT 716 #undef GOOGLE_DCHECK_LT
710 #undef GOOGLE_DCHECK_LE 717 #undef GOOGLE_DCHECK_LE
711 #undef GOOGLE_DCHECK_GT 718 #undef GOOGLE_DCHECK_GT
712 #undef GOOGLE_DCHECK_GE 719 #undef GOOGLE_DCHECK_GE
713 720
714 #define GOOGLE_LOG(LEVEL) \ 721 #define GOOGLE_LOG(LEVEL) \
715 ::google::protobuf::internal::LogFinisher() = \ 722 ::google::protobuf::internal::LogFinisher() = \
716 ::google::protobuf::internal::LogMessage( \ 723 ::google::protobuf::internal::LogMessage( \
717 ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__) 724 ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__)
718 #define GOOGLE_LOG_IF(LEVEL, CONDITION) \ 725 #define GOOGLE_LOG_IF(LEVEL, CONDITION) \
719 !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL) 726 !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL)
720 727
721 #define GOOGLE_CHECK(EXPRESSION) \ 728 #define GOOGLE_CHECK(EXPRESSION) \
722 GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": " 729 GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": "
723 #define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B)) 730 #define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B))
724 #define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B)) 731 #define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B))
725 #define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) < (B)) 732 #define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) < (B))
726 #define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B)) 733 #define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B))
727 #define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) > (B)) 734 #define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) > (B))
728 #define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B)) 735 #define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B))
729 736
737 namespace internal {
738 template<typename T>
739 T* CheckNotNull(const char *file, int line, const char *name, T* val) {
740 if (val == NULL) {
741 GOOGLE_LOG(FATAL) << name;
742 }
743 return val;
744 }
745 } // namespace internal
746 #define GOOGLE_CHECK_NOTNULL(A) \
747 internal::CheckNotNull(__FILE__, __LINE__, "'" #A "' must not be NULL", (A))
748
730 #ifdef NDEBUG 749 #ifdef NDEBUG
731 750
732 #define GOOGLE_DLOG GOOGLE_LOG_IF(INFO, false) 751 #define GOOGLE_DLOG GOOGLE_LOG_IF(INFO, false)
733 752
734 #define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION) 753 #define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION)
735 #define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B)) 754 #define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B))
736 #define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B)) 755 #define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B))
737 #define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) < (B)) 756 #define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) < (B))
738 #define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B)) 757 #define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B))
739 #define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) > (B)) 758 #define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) > (B))
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 1163
1145 // We made these internal so that they would show up as such in the docs, 1164 // We made these internal so that they would show up as such in the docs,
1146 // but we don't want to stick "internal::" in front of them everywhere. 1165 // but we don't want to stick "internal::" in front of them everywhere.
1147 using internal::Mutex; 1166 using internal::Mutex;
1148 using internal::MutexLock; 1167 using internal::MutexLock;
1149 using internal::ReaderMutexLock; 1168 using internal::ReaderMutexLock;
1150 using internal::WriterMutexLock; 1169 using internal::WriterMutexLock;
1151 using internal::MutexLockMaybe; 1170 using internal::MutexLockMaybe;
1152 1171
1153 // =================================================================== 1172 // ===================================================================
1154 // from google3/base/type_traits.h 1173 // from google3/util/utf8/public/unilib.h
1155 1174
1156 namespace internal { 1175 namespace internal {
1157 1176
1158 // Specified by TR1 [4.7.4] Pointer modifications.
1159 template<typename T> struct remove_pointer { typedef T type; };
1160 template<typename T> struct remove_pointer<T*> { typedef T type; };
1161 template<typename T> struct remove_pointer<T* const> { typedef T type; };
1162 template<typename T> struct remove_pointer<T* volatile> { typedef T type; };
1163 template<typename T> struct remove_pointer<T* const volatile> {
1164 typedef T type; };
1165
1166 // ===================================================================
1167
1168 // Checks if the buffer contains structurally-valid UTF-8. Implemented in 1177 // Checks if the buffer contains structurally-valid UTF-8. Implemented in
1169 // structurally_valid.cc. 1178 // structurally_valid.cc.
1170 LIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len); 1179 LIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);
1171 1180
1172 } // namespace internal 1181 } // namespace internal
1173 1182
1174 // =================================================================== 1183 // ===================================================================
1184 // from google3/util/endian/endian.h
1185 LIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x);
1186
1187 // ===================================================================
1175 // Shutdown support. 1188 // Shutdown support.
1176 1189
1177 // Shut down the entire protocol buffers library, deleting all static-duration 1190 // Shut down the entire protocol buffers library, deleting all static-duration
1178 // objects allocated by the library or by generated .pb.cc files. 1191 // objects allocated by the library or by generated .pb.cc files.
1179 // 1192 //
1180 // There are two reasons you might want to call this: 1193 // There are two reasons you might want to call this:
1181 // * You use a draconian definition of "memory leak" in which you expect 1194 // * You use a draconian definition of "memory leak" in which you expect
1182 // every single malloc() to have a corresponding free(), even for objects 1195 // every single malloc() to have a corresponding free(), even for objects
1183 // which live until program exit. 1196 // which live until program exit.
1184 // * You are writing a dynamically-loaded library which needs to clean up 1197 // * You are writing a dynamically-loaded library which needs to clean up
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 #endif 1230 #endif
1218 1231
1219 // This is at the end of the file instead of the beginning to work around a bug 1232 // This is at the end of the file instead of the beginning to work around a bug
1220 // in some versions of MSVC. 1233 // in some versions of MSVC.
1221 using namespace std; // Don't do this at home, kids. 1234 using namespace std; // Don't do this at home, kids.
1222 1235
1223 } // namespace protobuf 1236 } // namespace protobuf
1224 } // namespace google 1237 } // namespace google
1225 1238
1226 #endif // GOOGLE_PROTOBUF_COMMON_H__ 1239 #endif // GOOGLE_PROTOBUF_COMMON_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698