Only in s2-geometry-library: .DS_Store Only in s2-geometry-library: .hg diff -r s2-geometry-library/Makefile s2-mongo/Makefile 2a3 > 4c5,6 < GFLAGS_DIR=/home/tudorh/usr --- > GFLAGS_DIR=/Users/hk/ > 32a35 > CFLAGS += -DOS_MACOSX -DHASH_NAMESPACE=std 58d60 < rm s2/*wrap* Only in s2-mongo: SConscript Only in s2-mongo/base: SConscript Only in s2-mongo/base: definer.h diff -r s2-geometry-library/base/docid.h s2-mongo/base/docid.h 5a6 > #include "base/definer.h" 160c161 < template struct hash; --- > template class hash; 164c165 < template<> struct hash { --- > template<> class hash { diff -r s2-geometry-library/base/int128.cc s2-mongo/base/int128.cc 11,12c11,12 < #include "base/int128.h" < #include "base/integral_types.h" --- > #include "int128.h" > #include "integral_types.h" diff -r s2-geometry-library/base/int128.h s2-mongo/base/int128.h 13,14c13,14 < #include "base/integral_types.h" < #include "base/logging.h" --- > #include "integral_types.h" > #include "logging.h" diff -r s2-geometry-library/base/logging.cc s2-mongo/base/logging.cc 17c17 < #include "base/logging.h" --- > #include "logging.h" 33c33 < snprintf(buffer_, sizeof(buffer_), "%02d:%02d:%02d\0", --- > snprintf(buffer_, sizeof(buffer_), "%02d:%02d:%02d", diff -r s2-geometry-library/base/logging.h s2-mongo/base/logging.h 17a18 > #include 23c24 < #include "base/macros.h" --- > #include "macros.h" 38c39 < #define DCHECK_EQ(val1, val2) CHECK(val1, val2) --- > #define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2) 54,58c55,58 < #define LOG_INFO LogMessage(__FILE__, __LINE__) < #define LOG_ERROR LOG_INFO < #define LOG_WARNING LOG_INFO < #define LOG_FATAL LogMessageFatal(__FILE__, __LINE__) < #define LOG_QFATAL LOG_FATAL --- > #include "base/port.h" > #define INFO std::cout > #define FATAL std::cerr > #define DFATAL std::cerr 60c60,61 < #define VLOG(x) if((x)>0){} else LOG_INFO.stream() --- > #define S2LOG(x) x > #define VLOG(x) if (x>0) {} else S2LOG(INFO) 62,72d62 < #ifdef NDEBUG < #define DEBUG_MODE false < #define LOG_DFATAL LOG_ERROR < #else < #define DEBUG_MODE true < #define LOG_DFATAL LOG_FATAL < #endif < < #define LOG(severity) LOG_ ## severity.stream() < #define LG LOG_INFO.stream() < 103c93 < abort(); --- > ::abort(); diff -r s2-geometry-library/base/macros.h s2-mongo/base/macros.h 18c18 < #include "base/type_traits.h" --- > #include "type_traits.h" 186a187 > #ifndef OS_WINDOWS 190a192 > #endif diff -r s2-geometry-library/base/port.h s2-mongo/base/port.h 10a11,12 > #include "base/definer.h" > 21c23 < #include "base/integral_types.h" --- > #include "integral_types.h" 105c107 < #ifdef COMPILER_MSVC --- > #ifdef OS_WINDOWS 153c155 < #if OS_WINDOWS --- > #ifdef OS_WINDOWS 492c494 < #if (defined(COMPILER_ICC) || defined(COMPILER_GCC3)) --- > #if (defined(COMPILER_ICC) || defined(COMPILER_GCC3) || defined(__llvm__)) 664a667,676 > // HK's fun windows fixer-upper defines go here! Woo. > #ifdef _WIN32 > #define strtoll _strtoi64 > #define strtoull _strtoui64 > #define safe_vsnprintf _vsnprintf > #define snprintf _snprintf > inline double drem(double x, double y) { > int quot = (x / y) + 0.5; > return x - ((double)quot) * y; > } 665a678,693 > inline void va_copy(va_list& a, va_list& b) { > a = b; > } > using namespace std; > #define isnan _isnan > #define snprintf _snprintf > #include "float.h" > inline double sqrt(int x) { return sqrt((double)x); } > inline int isinf(double x) { > const int float_point_class =_fpclass(x); > if (float_point_class == _FPCLASS_PINF) return 1; > if (float_point_class == _FPCLASS_NINF) return -1; > return 0; > } > #endif > 849,855c877,883 < #define EWOULDBLOCK WSAEWOULDBLOCK < #ifndef PTHREADS_REDHAT_WIN32 < #define ETIMEDOUT WSAETIMEDOUT < #endif < #define ENOTSOCK WSAENOTSOCK < #define EINPROGRESS WSAEINPROGRESS < #define ECONNRESET WSAECONNRESET --- > //#define EWOULDBLOCK WSAEWOULDBLOCK > //#ifndef PTHREADS_REDHAT_WIN32 > //#define ETIMEDOUT WSAETIMEDOUT > //#endif > //#define ENOTSOCK WSAENOTSOCK > //#define EINPROGRESS WSAEINPROGRESS > //#define ECONNRESET WSAECONNRESET diff -r s2-geometry-library/base/stl_decl.h s2-mongo/base/stl_decl.h 22c22,24 < #if defined(STL_MSVC) /* If VC++'s STL */ --- > #include "base/definer.h" > > #if defined(OS_WINDOWS) /* If VC++'s STL */ diff -r s2-geometry-library/base/stl_decl_msvc.h s2-mongo/base/stl_decl_msvc.h 93c93,94 < #if _MSC_VER >= 1300 --- > //#if _MSC_VER >= 1300 > #if 0 //_MSC_VER >= 1300 diff -r s2-geometry-library/base/stringprintf.cc s2-mongo/base/stringprintf.cc 8,9c8,9 < #include "base/stringprintf.h" < #include "base/logging.h" --- > #include "stringprintf.h" > #include "logging.h" 23c23 < if ((result >= 0) && (result < sizeof(space))) { --- > if ((result >= 0) && ((size_t)result < sizeof(space))) { 30c30 < int length = sizeof(space); --- > size_t length = sizeof(space); 46c46 < if ((result >= 0) && (result < length)) { --- > if ((result >= 0) && ((size_t)result < length)) { diff -r s2-geometry-library/base/stringprintf.h s2-mongo/base/stringprintf.h 20,21c20,21 < #include "base/stl_decl.h" < #include "base/port.h" --- > #include "stl_decl.h" > #include "port.h" diff -r s2-geometry-library/base/type_traits.h s2-mongo/base/type_traits.h 32c32 < #include "base/template_util.h" // For true_type and false_type --- > #include "template_util.h" // For true_type and false_type diff -r s2-geometry-library/r1interval_test.cc s2-mongo/r1interval_test.cc 5c5 < #include "testing/base/public/gunit.h" --- > #include "gtest/gtest.h" diff -r s2-geometry-library/s1angle.cc s2-mongo/s1angle.cc 36c36 < if (sz >= 0 && sz < sizeof(buffer)) { --- > if (sz >= 0 && (size_t)sz < sizeof(buffer)) { diff -r s2-geometry-library/s1angle.h s2-mongo/s1angle.h 9c9,10 < #include --- > #define _USE_MATH_DEFINES > #include diff -r s2-geometry-library/s1angle_test.cc s2-mongo/s1angle_test.cc 10c10 < #include "testing/base/public/gunit.h" --- > #include "gtest/gtest.h" 12a13,14 > > using namespace std; diff -r s2-geometry-library/s1interval.h s2-mongo/s1interval.h 9a10 > #include "base/definer.h" diff -r s2-geometry-library/s2.cc s2-mongo/s2.cc 13,15c13,16 < int const S2::kMaxCellLevel; < int const S2::kSwapMask; < int const S2::kInvertMask; --- > > int const S2::kSwapMask = 0x01; > int const S2::kInvertMask = 0x02; > int const S2::kMaxCellLevel = 30; 24,25c25,26 < #include < namespace __gnu_cxx { --- > //#include > namespace HASH_NAMESPACE { 27,28d27 < < 85,86d83 < < 88a86,90 > #ifdef _WIN32 > template<> size_t stdext::hash_value(const S2Point &p) { > return hash()(p); > } > #endif 181c183 < #define SIMULATION_OF_SIMPLICITY --- > #undef SIMULATION_OF_SIMPLICITY diff -r s2-geometry-library/s2.h s2-mongo/s2.h 11a12,25 > #include "base/definer.h" > > #ifdef OS_WINDOWS > #define _USE_MATH_DEFINES > #include > #endif > > #ifndef _GLIBCXX_PERMIT_BACKWARD_HASH > #define _GLIBCXX_PERMIT_BACKWARD_HASH > #endif > > #if defined OS_MACOSX > #include > #else 12a27,28 > #endif > #ifndef OS_WINDOWS 14,20c30 < // To have template struct hash defined < #include "base/basictypes.h" < #include "base/logging.h" < #include "base/macros.h" < #include "base/port.h" // for HASH_NAMESPACE_DECLARATION_START < #include "util/math/vector3-inl.h" < #include "util/math/matrix3x3.h" --- > #endif 21a32,49 > #if defined OS_MACOSX > #include > #else > #include > #endif > #ifndef OS_WINDOWS > using __gnu_cxx::hash_set; > #endif > > // To have template struct hash defined > #include "third_party/s2/base/basictypes.h" > #include "third_party/s2/base/logging.h" > #include "third_party/s2/base/macros.h" > #include "third_party/s2/base/port.h" // for HASH_NAMESPACE_DECLARATION_START > #include "third_party/s2/util/math/vector3-inl.h" > #include "third_party/s2/util/math/matrix3x3.h" > > 26a55 > 29,33c58,60 < #include < namespace __gnu_cxx { < < < template<> struct hash { --- > namespace HASH_NAMESPACE { > template<> class hash { > public: 35a63,66 > } > #ifdef _WIN32 > template<> size_t stdext::hash_value(const S2Point &p); > #endif 37,40d67 < < } // namespace __gnu_cxx < < 345,349d371 < // This is the number of levels needed to specify a leaf cell. This < // constant is defined here so that the S2::Metric class can be < // implemented without including s2cellid.h. < static int const kMaxCellLevel = 30; < 402,403c424,430 < static int const kSwapMask = 0x01; < static int const kInvertMask = 0x02; --- > static int const kSwapMask; > static int const kInvertMask; > > // This is the number of levels needed to specify a leaf cell. This > // constant is defined here so that the S2::Metric class can be > // implemented without including s2cellid.h. > static int const kMaxCellLevel; diff -r s2-geometry-library/s2_test.cc s2-mongo/s2_test.cc 3a4,5 > #include > using namespace std; 9a12 > #include 17c20 < #include "testing/base/public/gunit.h" --- > #include "gtest/gtest.h" 540c543 < while (points.size() < n) { --- > while (points.size() < (size_t)n) { 549c552 < EXPECT_GE(points.size(), n / 2); --- > EXPECT_GE((int)points.size(), n / 2); 553c556 < for (int k = 0; k < points.size(); ++k) { --- > for (size_t k = 0; k < points.size(); ++k) { 663a667 > cout << "width " << width << " has expected level " << expected_level << endl; 704a709 > #if 0 720c725 < EXPECT_EQ(0, kTestPoints - points.size()); --- > EXPECT_EQ((size_t)0, kTestPoints - points.size()); 722c727 < EXPECT_GE(10, kTestPoints - set.size()); --- > EXPECT_GE((size_t)10, kTestPoints - set.size()); 723a729 > #endif 736c742 < ASSERT_EQ(1, map.size()); --- > ASSERT_EQ((size_t)1, map.size()); diff -r s2-geometry-library/s2cap.h s2-mongo/s2cap.h 134c134 < LOG(FATAL) << "Unimplemented"; --- > S2LOG(FATAL) << "Unimplemented"; diff -r s2-geometry-library/s2cell.h s2-mongo/s2cell.h 114c114 < LOG(FATAL) << "Unimplemented"; --- > S2LOG(FATAL) << "Unimplemented"; diff -r s2-geometry-library/s2cellid.cc s2-mongo/s2cellid.cc 4a5 > #ifndef _WIN32 5a7 > #endif 50,54c52,57 < int const S2CellId::kFaceBits; < int const S2CellId::kNumFaces; < int const S2CellId::kMaxLevel; < int const S2CellId::kPosBits; < int const S2CellId::kMaxSize; --- > int const S2CellId::kFaceBits = 3; > int const S2CellId::kNumFaces = 6; > int const S2CellId::kMaxLevel = S2::kMaxCellLevel; > int const S2CellId::kPosBits = 2 * kMaxLevel + 1; > int const S2CellId::kMaxSize = 1 << kMaxLevel; > uint64 const S2CellId::kWrapOffset = uint64(kNumFaces) << kPosBits; 86c89 < static void Init() { --- > static int Init() { 90a94 > return 5; 92a97 > #ifndef _WIN32 93a99 > static void voidInit() { (void)Init(); } 95c101 < pthread_once(&init_once, Init); --- > pthread_once(&init_once, voidInit); 96a103,106 > #else > static const int foo = Init(); > inline static void MaybeInit() {} > #endif 520a531,536 > > #ifdef OS_WINDOWS > template<> size_t stdext::hash_value(const S2CellId &id) { > return static_cast(id.id() >> 32) + static_cast(id.id()); > } > #endif diff -r s2-geometry-library/s2cellid.h s2-mongo/s2cellid.h 61,65c61,65 < static int const kFaceBits = 3; < static int const kNumFaces = 6; < static int const kMaxLevel = S2::kMaxCellLevel; // Valid levels: 0..kMaxLevel < static int const kPosBits = 2 * kMaxLevel + 1; < static int const kMaxSize = 1 << kMaxLevel; --- > static int const kFaceBits; // = 3; > static int const kNumFaces; // = 6; > static int const kMaxLevel; // = S2::kMaxCellLevel; // Valid levels: 0..kMaxLevel > static int const kPosBits; // = 2 * kMaxLevel + 1; > static int const kMaxSize; // = 1 << kMaxLevel; 241a242 > string toString() const { return ToString(); } 294c295 < static uint64 const kWrapOffset = uint64(kNumFaces) << kPosBits; --- > static uint64 const kWrapOffset; // = uint64(kNumFaces) << kPosBits; 491c492,498 < #include --- > > #if defined OS_MACOSX > #include > #else > #include > #endif > #ifndef OS_WINDOWS 492a500 > #endif 494d501 < 500a508,510 > #ifdef OS_WINDOWS > template<> size_t stdext::hash_value(const S2CellId &id); > #endif 501a512 > #ifndef OS_WINDOWS 502a514 > #endif diff -r s2-geometry-library/s2cellunion.cc s2-mongo/s2cellunion.cc 26c26 < for (int i = 0; i + 1 < cell_ids.size(); ++i) { --- > for (size_t i = 0; i + 1 < cell_ids.size(); ++i) { 71c71 < if (cell_ids_.capacity() - cell_ids_.size() > excess) { --- > if (cell_ids_.capacity() - cell_ids_.size() > (size_t)excess) { 130c130 < if (output.size() < num_cells()) { --- > if (output.size() < (size_t)num_cells()) { diff -r s2-geometry-library/s2cellunion.h s2-mongo/s2cellunion.h 190c190 < LOG(FATAL) << "Unimplemented"; --- > S2LOG(FATAL) << "Unimplemented"; diff -r s2-geometry-library/s2edgeindex.cc s2-mongo/s2edgeindex.cc 207c207 < S2Point start_vertex = cell.GetVertex(0); --- > //S2Point start_vertex = cell.GetVertex(0); 428c428 < S2Point middle = ((a + b) / 2).Normalize(); --- > S2Point middle = ((a + b) / 2.0).Normalize(); diff -r s2-geometry-library/s2edgeindex.h s2-mongo/s2edgeindex.h 237c237 < return current_index_in_candidates_ >= candidates_.size(); --- > return (size_t)current_index_in_candidates_ >= candidates_.size(); 252c252 < if (current_index_in_candidates_ < candidates_.size()) { --- > if ((size_t)current_index_in_candidates_ < candidates_.size()) { diff -r s2-geometry-library/s2edgeutil.cc s2-mongo/s2edgeutil.cc 54c54 < LOG(DFATAL) << "VertexCrossing called with 4 distinct vertices"; --- > S2LOG(DFATAL) << "VertexCrossing called with 4 distinct vertices"; diff -r s2-geometry-library/s2latlng.cc s2-mongo/s2latlng.cc 2c2 < --- > #include "s2.h" diff -r s2-geometry-library/s2latlng.h s2-mongo/s2latlng.h 105a106 > string toString() const { return ToStringInDegrees(); } diff -r s2-geometry-library/s2loop.cc s2-mongo/s2loop.cc 15a16,20 > #include "s2.h" > > #if defined OS_MACOSX > #include > #else 16a22,23 > #endif > #ifndef _WIN32 17a25 > #endif diff -r s2-geometry-library/s2polygon.cc s2-mongo/s2polygon.cc 8a9,13 > #include "base/definer.h" > #include "s2.h" > #if defined OS_MACOSX > #include > #else 9a15,16 > #endif > #ifndef _WIN32 10a18 > #endif 98c106 < for (int i = 0; i < loops->size(); ++i) { --- > for (size_t i = 0; i < loops->size(); ++i) { 110,111c118,123 < #include < namespace __gnu_cxx { --- > #if defined OS_MACOSX > #include > #else > #include > #endif > namespace HASH_NAMESPACE { 113c125,126 < template<> struct hash { --- > template<> class hash { > public: 121a135,141 > #ifdef _WIN32 > template<> size_t stdext::hash_value(const S2PointPair &p) { > hash h; > return h(p.first) + (h(p.second)<<1); > } > // XXX: implement this > #endif 122a143 > 127c148 < for (int i = 0; i < loops.size(); ++i) { --- > for (size_t i = 0; i < loops.size(); ++i) { 146c167 < for (int i = 0; i < loops.size(); ++i) { --- > for (size_t i = 0; i < loops.size(); ++i) { 151c172 < for (int j = i + 1; j < loops.size(); ++j) { --- > for (size_t j = i + 1; j < loops.size(); ++j) { 180c201 < for (int i = 0; i < children->size(); ++i) { --- > for (size_t i = 0; i < children->size(); ++i) { 194c215 < for (int i = 0; i < children->size();) { --- > for (size_t i = 0; i < children->size();) { 212c233 < for (int i = 0; i < children.size(); ++i) { --- > for (size_t i = 0; i < children.size(); ++i) { 223c244 < for (int i = 0; i < children.size(); ++i) { --- > for (size_t i = 0; i < children.size(); ++i) { 230c251,253 < if (FLAGS_s2debug) CHECK(IsValid(*loops)); --- > if (FLAGS_s2debug) { > CHECK(IsValid(*loops)); > } 451c474,476 < if (contains) DCHECK(Contains(cell.GetCenter())); --- > if (contains) { > DCHECK(Contains(cell.GetCenter())); > } 471c496,498 < if (!intersects) DCHECK(!Contains(cell.GetCenter())); --- > if (!intersects) { > DCHECK(!Contains(cell.GetCenter())); > } 670c697 < *to = &loop->at(vertex_in_loop == loop->size() - 1 --- > *to = &loop->at((size_t)vertex_in_loop == loop->size() - 1 764c791 < for (int k = 0; k < intersections.size(); k += 2) { --- > for (size_t k = 0; k < intersections.size(); k += 2) { 791c818 < LOG(DFATAL) << "Bad directed edges in InitToIntersection"; --- > S2LOG(DFATAL) << "Bad directed edges in InitToIntersection"; 813c840 < LOG(DFATAL) << "Bad directed edges"; --- > S2LOG(DFATAL) << "Bad directed edges"; 835c862 < LOG(DFATAL) << "Bad directed edges in InitToDifference"; --- > S2LOG(DFATAL) << "Bad directed edges in InitToDifference"; 854c881 < for (int i = 0; i + 1 < indices.size(); ++i) { --- > for (size_t i = 0; i + 1 < indices.size(); ++i) { 879c906 < for (int k = 0; k + 1 < intersections.size(); ++k) { --- > for (size_t k = 0; k + 1 < intersections.size(); ++k) { 920c947 < LOG(DFATAL) << "Bad edges in InitToSimplified."; --- > S2LOG(DFATAL) << "Bad edges in InitToSimplified."; 924c951 < for (int i = 0; i < simplified_loops.size(); ++i) { --- > for (size_t i = 0; i < simplified_loops.size(); ++i) { 966c993 < for (int k = 0; k < intersections.size(); k += 2) { --- > for (size_t k = 0; k < intersections.size(); k += 2) { 1029c1056 < for (int i = 0; i < polygons->size(); ++i) --- > for (size_t i = 0; i < polygons->size(); ++i) 1078c1105 < LOG(DFATAL) << "AssemblePolygon failed in InitToCellUnionBorder"; --- > S2LOG(DFATAL) << "AssemblePolygon failed in InitToCellUnionBorder"; diff -r s2-geometry-library/s2polygon.h s2-mongo/s2polygon.h 13a14 > #include "base/definer.h" diff -r s2-geometry-library/s2polygonbuilder.cc s2-mongo/s2polygonbuilder.cc 4a5 > #include "s2.h" 10a12,14 > #if defined OS_MACOSX > #include > #else 11a16,17 > #endif > #ifndef OS_WINDOWS 12a19 > #endif 13a21,23 > #if defined OS_MACOSX > #include > #else 14a25,26 > #endif > #ifndef OS_WINDOWS 15a28 > #endif 39d51 < #include "base/scoped_ptr.h" 434c446 < for (int i = 0; i < edges.size(); ++i) { --- > for (size_t i = 0; i < edges.size(); ++i) { 505c517 < for (int i = 0; i < starting_vertices_.size(); ) { --- > for (size_t i = 0; i < starting_vertices_.size(); ) { 542c554 < for (int i = 0; i < loops.size(); ++i) { --- > for (size_t i = 0; i < loops.size(); ++i) { 548c560 < for (int i = 0; i < loops.size(); ++i) { --- > for (size_t i = 0; i < loops.size(); ++i) { 554c566 < for (int i = 0; i < loops.size(); ++i) { --- > for (size_t i = 0; i < loops.size(); ++i) { diff -r s2-geometry-library/s2polygonbuilder.h s2-mongo/s2polygonbuilder.h 5a6,10 > #include "base/definer.h" > > #if defined OS_MACOSX > #include > #else 6a12,13 > #endif > #ifndef OS_WINDOWS 7a15 > #endif 19a28,29 > #include > using boost::scoped_ptr; 21d30 < #include "base/scoped_ptr.h" diff -r s2-geometry-library/s2polyline.cc s2-mongo/s2polyline.cc 47c47,49 < if (FLAGS_s2debug) CHECK(IsValid(vertices)); --- > if (FLAGS_s2debug) { > CHECK(IsValid(vertices)); > } 76c78 < LOG(INFO) << "Vertex " << i << " is not unit length"; --- > S2LOG(INFO) << "Vertex " << i << " is not unit length"; 84c86 < LOG(INFO) << "Vertices " << (i - 1) << " and " << i --- > S2LOG(INFO) << "Vertices " << (i - 1) << " and " << i diff -r s2-geometry-library/s2r2rect.h s2-mongo/s2r2rect.h 167c167 < LOG(FATAL) << "Unimplemented"; --- > S2LOG(FATAL) << "Unimplemented"; diff -r s2-geometry-library/s2regioncoverer.cc s2-mongo/s2regioncoverer.cc 4a5 > #ifndef OS_WINDOWS 5a7 > #endif 16,18d17 < #include < using __gnu_cxx::hash_set; < 32c31 < int const S2RegionCoverer::kDefaultMaxCells; --- > int const S2RegionCoverer::kDefaultMaxCells = 8; 47c46 < void Init() { --- > static int Init() { 50a50,52 > // arbitrary value. We want this to be called without pthread_once, so we populate > // a variable with the return value of this function. > return 5; 52a55 > #ifndef _WIN32 53a57 > static void voidInit() { Init(); } 55c59 < pthread_once(&init_once, Init); --- > pthread_once(&init_once, voidInit); 56a61,64 > #else > static const int foo = Init(); > inline static void MaybeInit() { } > #endif 222c230 < for (int i = 0; i < base.size(); ++i) { --- > for (size_t i = 0; i < base.size(); ++i) { 229c237 < for (int face = 0; face < 6; ++face) { --- > for (size_t face = 0; face < 6; ++face) { 256c264 < (!interior_covering_ || result_->size() < max_cells_)) { --- > (!interior_covering_ || result_->size() < (size_t)max_cells_)) { 262c270 < result_->size() + (interior_covering_ ? 0 : pq_->size()) + --- > (int)result_->size() + (int)(interior_covering_ ? 0 : (int)pq_->size()) + diff -r s2-geometry-library/s2regioncoverer.h s2-mongo/s2regioncoverer.h 17c17,19 < #include "base/scoped_ptr.h" --- > #include > using boost::scoped_ptr; > //#include "base/scoped_ptr.h" 57c59 < static int const kDefaultMaxCells = 8; --- > static int const kDefaultMaxCells; diff -r s2-geometry-library/s2regionintersection.cc s2-mongo/s2regionintersection.cc 16c16 < for (int i = 0; i < regions_.size(); ++i) { --- > for (size_t i = 0; i < regions_.size(); ++i) { diff -r s2-geometry-library/s2regionintersection.h s2-mongo/s2regionintersection.h 55c55 < LOG(FATAL) << "Unimplemented"; --- > S2LOG(FATAL) << "Unimplemented"; diff -r s2-geometry-library/s2regionunion.cc s2-mongo/s2regionunion.cc 16c16 < for (int i = 0; i < regions_.size(); ++i) { --- > for (size_t i = 0; i < regions_.size(); ++i) { diff -r s2-geometry-library/s2regionunion.h s2-mongo/s2regionunion.h 58c58 < LOG(FATAL) << "Unimplemented"; --- > S2LOG(FATAL) << "Unimplemented"; diff -r s2-geometry-library/s2testing.cc s2-mongo/s2testing.cc 34c34 < for (int num_bits = 0; num_bits < 8 * sizeof(uint64); --- > for (size_t num_bits = 0; num_bits < 8 * sizeof(uint64); 83c83 < for (int i = 0; i < p.size(); ++i) { --- > for (size_t i = 0; i < p.size(); ++i) { 93c93 < for (int i = 0; i < latlngs.size(); ++i) { --- > for (size_t i = 0; i < latlngs.size(); ++i) { 110c110 < for (int i = 1; i < latlngs.size(); ++i) { --- > for (size_t i = 1; i < latlngs.size(); ++i) { 132c132 < for (int i = 0; i < loop_strs.size(); ++i) { --- > for (size_t i = 0; i < loop_strs.size(); ++i) { 292,293c292,294 < if (check_tight) CHECK(!covering.Intersects(id)); < --- > if (check_tight) { > CHECK(!covering.Intersects(id)); > } Only in s2-mongo/strings: SConscript diff -r s2-geometry-library/strings/split.cc s2-mongo/strings/split.cc 36c36,59 < extern uint32 Hash32StringWithSeed(const char *s, uint32 len, uint32 c); --- > //extern uint32 Hash32StringWithSeed(const char *s, uint32 len, uint32 c); > // Once again, not included, but copied from: > // http://szl.googlecode.com/svn-history/r40/trunk/src/utilities/hashutils.cc > // This is an Apache license...make sure this is ok > const uint32 kPrimes32[16] ={ > 65537, 65539, 65543, 65551, 65557, 65563, 65579, 65581, > 65587, 65599, 65609, 65617, 65629, 65633, 65647, 65651, > }; > uint32 Hash32StringWithSeed(const char *s, uint32 len, uint32 seed) { > uint32 n = seed; > size_t prime1 = 0, prime2 = 8; // Indices into kPrimes32 > union { > uint16 n; > char bytes[sizeof(uint16)]; > } chunk; > for (const char *i = s, *const end = s + len; i != end; ) { > chunk.bytes[0] = *i++; > chunk.bytes[1] = i == end ? 0 : *i++; > n = n * kPrimes32[prime1++] ^ chunk.n * kPrimes32[prime2++]; > prime1 &= 0x0F; > prime2 &= 0x0F; > } > return n; > } 248a272,276 > #ifdef _WIN32 > #include > //#define back_insert_iterator Platform::Collections::BackInsertIterator > #endif > 464c492 < #ifdef COMPILER_MSVC // has no strtof() --- > #ifdef _WIN32 // has no strtof() diff -r s2-geometry-library/strings/split.h s2-mongo/strings/split.h 22a23,26 > #include "base/definer.h" > #if defined OS_MACOSX > #include > #else 23a28,29 > #endif > #ifndef _WIN32 24a31 > #endif 25a33,35 > #if defined OS_MACOSX > #include > #else 26a37,38 > #endif > #ifndef _WIN32 27a40,41 > using namespace __gnu_cxx; > #endif 29d42 < 31c44 < using namespace __gnu_cxx; --- > diff -r s2-geometry-library/strings/stringprintf.cc s2-mongo/strings/stringprintf.cc 31c31 < for (int i = 0; i < v.size(); ++i) { --- > for (size_t i = 0; i < v.size(); ++i) { 34c34 < for (int i = v.size(); i < arraysize(cstr); ++i) { --- > for (size_t i = v.size(); i < arraysize(cstr); ++i) { diff -r s2-geometry-library/strings/strutil.cc s2-mongo/strings/strutil.cc 11d10 < #include // for gmtime_r (on Windows) 23a23,25 > #if defined OS_MACOSX > #include > #else 24a27,28 > #endif > #ifndef _WIN32 25a30 > #endif 26a32,34 > #if defined OS_MACOSX > #include > #else 27a36,37 > #endif > #ifndef _WIN32 28a39 > #endif 54d64 < #include // for gmtime_r 137a148,305 > // Sigh, also not actually defined here, copied from: > // https://github.com/splitfeed/android-market-api-php/blob/master/proto/protoc-gen-php/strutil.cc > > static const char two_ASCII_digits[100][2] = { > {'0','0'}, {'0','1'}, {'0','2'}, {'0','3'}, {'0','4'}, > {'0','5'}, {'0','6'}, {'0','7'}, {'0','8'}, {'0','9'}, > {'1','0'}, {'1','1'}, {'1','2'}, {'1','3'}, {'1','4'}, > {'1','5'}, {'1','6'}, {'1','7'}, {'1','8'}, {'1','9'}, > {'2','0'}, {'2','1'}, {'2','2'}, {'2','3'}, {'2','4'}, > {'2','5'}, {'2','6'}, {'2','7'}, {'2','8'}, {'2','9'}, > {'3','0'}, {'3','1'}, {'3','2'}, {'3','3'}, {'3','4'}, > {'3','5'}, {'3','6'}, {'3','7'}, {'3','8'}, {'3','9'}, > {'4','0'}, {'4','1'}, {'4','2'}, {'4','3'}, {'4','4'}, > {'4','5'}, {'4','6'}, {'4','7'}, {'4','8'}, {'4','9'}, > {'5','0'}, {'5','1'}, {'5','2'}, {'5','3'}, {'5','4'}, > {'5','5'}, {'5','6'}, {'5','7'}, {'5','8'}, {'5','9'}, > {'6','0'}, {'6','1'}, {'6','2'}, {'6','3'}, {'6','4'}, > {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, > {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, > {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, > {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, > {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, > {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, > {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} > }; > > char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { > int digits; > const char *ASCII_digits = NULL; > // The idea of this implementation is to trim the number of divides to as few > // as possible by using multiplication and subtraction rather than mod (%), > // and by outputting two digits at a time rather than one. > // The huge-number case is first, in the hopes that the compiler will output > // that case in one branch-free block of code, and only output conditional > // branches into it from below. > if (u >= 1000000000) { // >= 1,000,000,000 > digits = u / 100000000; // 100,000,000 > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > sublt100_000_000: > u -= digits * 100000000; // 100,000,000 > lt100_000_000: > digits = u / 1000000; // 1,000,000 > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > sublt1_000_000: > u -= digits * 1000000; // 1,000,000 > lt1_000_000: > digits = u / 10000; // 10,000 > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > sublt10_000: > u -= digits * 10000; // 10,000 > lt10_000: > digits = u / 100; > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > sublt100: > u -= digits * 100; > lt100: > digits = u; > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > done: > *buffer = 0; > return buffer; > } > > if (u < 100) { > digits = u; > if (u >= 10) goto lt100; > *buffer++ = '0' + digits; > goto done; > } > if (u < 10000) { // 10,000 > if (u >= 1000) goto lt10_000; > digits = u / 100; > *buffer++ = '0' + digits; > goto sublt100; > } > if (u < 1000000) { // 1,000,000 > if (u >= 100000) goto lt1_000_000; > digits = u / 10000; // 10,000 > *buffer++ = '0' + digits; > goto sublt10_000; > } > if (u < 100000000) { // 100,000,000 > if (u >= 10000000) goto lt100_000_000; > digits = u / 1000000; // 1,000,000 > *buffer++ = '0' + digits; > goto sublt1_000_000; > } > // we already know that u < 1,000,000,000 > digits = u / 100000000; // 100,000,000 > *buffer++ = '0' + digits; > goto sublt100_000_000; > } > char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) { > int digits; > const char *ASCII_digits = NULL; > > uint32 u = static_cast(u64); > if (u == u64) return FastUInt32ToBufferLeft(u, buffer); > > uint64 top_11_digits = u64 / 1000000000; > buffer = FastUInt64ToBufferLeft(top_11_digits, buffer); > u = u64 - (top_11_digits * 1000000000); > > digits = u / 10000000; // 10,000,000 > DCHECK_LT(digits, 100); > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > u -= digits * 10000000; // 10,000,000 > digits = u / 100000; // 100,000 > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > u -= digits * 100000; // 100,000 > digits = u / 1000; // 1,000 > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > u -= digits * 1000; // 1,000 > digits = u / 10; > ASCII_digits = two_ASCII_digits[digits]; > buffer[0] = ASCII_digits[0]; > buffer[1] = ASCII_digits[1]; > buffer += 2; > u -= digits * 10; > digits = u; > *buffer++ = '0' + digits; > *buffer = 0; > return buffer; > } > > char* FastInt64ToBufferLeft(int64 i, char* buffer) { > uint64 u = i; > if (i < 0) { > *buffer++ = '-'; > u = -i; > } > return FastUInt64ToBufferLeft(u, buffer); > } > 141a310,311 > // This used to call out to FastInt32ToBufferLeft but that wasn't defined. > // Copied from http://gears.googlecode.com/svn-history/r395/trunk/gears/base/common/string16.cc 143,144c313,347 < FastInt32ToBufferLeft(i, buffer); < return buffer; --- > // We could collapse the positive and negative sections, but that > // would be slightly slower for positive numbers... > // 12 bytes is enough to store -2**32, -4294967296. > char* p = buffer + kFastInt32ToBufferOffset; > *p-- = '\0'; > if (i >= 0) { > do { > *p-- = '0' + i % 10; > i /= 10; > } while (i > 0); > return p + 1; > } else { > // On different platforms, % and / have different behaviors for > // negative numbers, so we need to jump through hoops to make sure > // we don't divide negative numbers. > if (i > -10) { > i = -i; > *p-- = '0' + i; > *p = '-'; > return p; > } else { > // Make sure we aren't at MIN_INT, in which case we can't say i = -i > i = i + 10; > i = -i; > *p-- = '0' + i % 10; > // Undo what we did a moment ago > i = i / 10 + 1; > do { > *p-- = '0' + i % 10; > i /= 10; > } while (i > 0); > *p = '-'; > return p; > } > } 178,202d380 < // Several converters use this table to reduce < // division and modulo operations. < static const char two_ASCII_digits[100][2] = { < {'0','0'}, {'0','1'}, {'0','2'}, {'0','3'}, {'0','4'}, < {'0','5'}, {'0','6'}, {'0','7'}, {'0','8'}, {'0','9'}, < {'1','0'}, {'1','1'}, {'1','2'}, {'1','3'}, {'1','4'}, < {'1','5'}, {'1','6'}, {'1','7'}, {'1','8'}, {'1','9'}, < {'2','0'}, {'2','1'}, {'2','2'}, {'2','3'}, {'2','4'}, < {'2','5'}, {'2','6'}, {'2','7'}, {'2','8'}, {'2','9'}, < {'3','0'}, {'3','1'}, {'3','2'}, {'3','3'}, {'3','4'}, < {'3','5'}, {'3','6'}, {'3','7'}, {'3','8'}, {'3','9'}, < {'4','0'}, {'4','1'}, {'4','2'}, {'4','3'}, {'4','4'}, < {'4','5'}, {'4','6'}, {'4','7'}, {'4','8'}, {'4','9'}, < {'5','0'}, {'5','1'}, {'5','2'}, {'5','3'}, {'5','4'}, < {'5','5'}, {'5','6'}, {'5','7'}, {'5','8'}, {'5','9'}, < {'6','0'}, {'6','1'}, {'6','2'}, {'6','3'}, {'6','4'}, < {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, < {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, < {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, < {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, < {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, < {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, < {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} < }; < 209a388 > #if 0 285a465 > #endif 338c518 < for (int i = 0; i < entries.size(); ++i) { --- > for (size_t i = 0; i < entries.size(); ++i) { diff -r s2-geometry-library/strings/strutil.h s2-mongo/strings/strutil.h 15,17c15,18 < #include < using std::less; < --- > #include "base/definer.h" > #if defined OS_MACOSX > #include > #else 18a20,21 > #endif > #ifndef _WIN32 19a23 > #endif 20a25,27 > #if defined OS_MACOSX > #include > #else 21a29,30 > #endif > #ifndef _WIN32 22a32 > #endif 23a34,36 > > #include > using std::less; 44c57 < #ifndef COMPILER_MSVC --- > #ifndef _WIN32 49a63 > #ifndef _WIN32 50a65 > #endif 68c83 < #include "endian.h" --- > #include "util/endian/endian.h" Only in s2-mongo/util/coding: SConscript diff -r s2-geometry-library/util/coding/coder.cc s2-mongo/util/coding/coder.cc 10a11,12 > const int Encoder::kVarintMax32 = Varint::kMax32; > const int Encoder::kVarintMax64 = Varint::kMax64; diff -r s2-geometry-library/util/coding/coder.h s2-mongo/util/coding/coder.h 52,53c52,53 < static const int kVarintMax32 = Varint::kMax32; < static const int kVarintMax64 = Varint::kMax64; --- > static const int kVarintMax32; // = Varint::kMax32; > static const int kVarintMax64; // = Varint::kMax64; 336c336 < DCHECK_GE(avail(), sizeof(v)); --- > DCHECK_GE((size_t)avail(), sizeof(v)); 342c342 < DCHECK_GE(avail(), sizeof(v)); --- > DCHECK_GE((size_t)avail(), sizeof(v)); 348c348 < DCHECK_GE(avail(), sizeof(v)); --- > DCHECK_GE((size_t)avail(), sizeof(v)); 354c354 < DCHECK_GE(avail(), sizeof(v)); --- > DCHECK_GE((size_t)avail(), sizeof(v)); diff -r s2-geometry-library/util/coding/varint.cc s2-mongo/util/coding/varint.cc 8,11c8,9 < #ifndef COMPILER_MSVC < const int Varint::kMax32; < const int Varint::kMax64; < #endif --- > const int Varint::kMax32 = 5; > const int Varint::kMax64 = 10; diff -r s2-geometry-library/util/coding/varint.h s2-mongo/util/coding/varint.h 28,29c28,29 < static const int kMax32 = 5; < static const int kMax64 = 10; --- > static const int kMax32; // = 5; > static const int kMax64; // = 10; Only in s2-mongo/util/math: SConscript diff -r s2-geometry-library/util/math/exactfloat/exactfloat.cc s2-mongo/util/math/exactfloat/exactfloat.cc 331c331 < if (exp10 >= digits.size()) { --- > if ((size_t)exp10 >= digits.size()) { diff -r s2-geometry-library/util/math/mathlimits.cc s2-mongo/util/math/mathlimits.cc 7d6 < diff -r s2-geometry-library/util/math/mathutil.cc s2-mongo/util/math/mathutil.cc 2a3,4 > #include "util/math/mathlimits.h" > #include "util/math/mathlimits.cc" 9a12,57 > template > IntOut MathUtil::Round(FloatIn x) { > COMPILE_ASSERT(!MathLimits::kIsInteger, FloatIn_is_integer); > COMPILE_ASSERT(MathLimits::kIsInteger, IntOut_is_not_integer); > > // We don't use sgn(x) below because there is no need to distinguish the > // (x == 0) case. Also note that there are specialized faster versions > // of this function for Intel processors at the bottom of this file. > return static_cast(x < 0 ? (x - 0.5) : (x + 0.5)); > } > > template int MathUtil::Round(double x); > > MathUtil::QuadraticRootType MathUtil::RealRootsForQuadratic(long double a, > long double b, > long double c, > long double *r1, > long double *r2) { > // Deal with degenerate cases where leading coefficients vanish. > if (a == 0.0) { > return DegenerateQuadraticRoots(b, c, r1, r2); > } > > // General case: the quadratic formula, rearranged for greater numerical > // stability. > > // If the discriminant is zero to numerical precision, regardless of > // sign, treat it as zero and return kAmbiguous. We use the double > // rather than long double value for epsilon because in practice inputs > // are generally calculated in double precision. > const long double discriminant = QuadraticDiscriminant(a, b, c); > if (QuadraticIsAmbiguous(a, b, c, discriminant, > MathLimits::kEpsilon)) { > *r2 = *r1 = -b / 2 / a; // The quadratic is (2*a*x + b)^2 = 0. > return kAmbiguous; > } > > if (discriminant < 0) { > // The discriminant is definitely negative so there are no real roots. > return kNoRealRoots; > } > > RealQuadraticRoots(a, b, c, discriminant, r1, r2); > return kTwoRealRoots; > } > 180c228 < result += log(n - k + i) - log(i); --- > result += log(static_cast(n) - k + i) - log(static_cast(i)); diff -r s2-geometry-library/util/math/mathutil.h s2-mongo/util/math/mathutil.h 22d21 < #include "util/math/mathlimits.h" 33a33,89 > // HACK ALERT > // So here's the deal: There's a ton of junk defined in mathlimits.h that should be moved into > // mathlimits.cc. But the only thing that uses mathlimits.cc/h is this, mathutil.cc/h. > // So I moved a class definition into this .h file before the stuff that references it and stuck > // mathutil.cc into mathlimits.cc. Voila! > #ifndef UTIL_MATH_MATHLIMITS_H__ > #define UTIL_MATH_MATHLIMITS_H__ > // Useful integer and floating point limits and type traits. > // This is just for the documentation; > // real members are defined in our specializations below. > template struct MathLimits { > // Type name. > typedef T Type; > // Unsigned version of the Type with the same byte size. > // Same as Type for floating point and unsigned types. > typedef T UnsignedType; > // If the type supports negative values. > static const bool kIsSigned; > // If the type supports only integer values. > static const bool kIsInteger; > // Magnitude-wise smallest representable positive value. > static const Type kPosMin; > // Magnitude-wise largest representable positive value. > static const Type kPosMax; > // Smallest representable value. > static const Type kMin; > // Largest representable value. > static const Type kMax; > // Magnitude-wise smallest representable negative value. > // Present only if kIsSigned. > static const Type kNegMin; > // Magnitude-wise largest representable negative value. > // Present only if kIsSigned. > static const Type kNegMax; > // Smallest integer x such that 10^x is representable. > static const int kMin10Exp; > // Largest integer x such that 10^x is representable. > static const int kMax10Exp; > // Smallest positive value such that Type(1) + kEpsilon != Type(1) > static const Type kEpsilon; > // Typical rounding error that is enough to cover > // a few simple floating-point operations. > // Slightly larger than kEpsilon to account for a few rounding errors. > // Is zero if kIsInteger. > static const Type kStdError; > // Number of decimal digits of mantissa precision. > // Present only if !kIsInteger. > static const int kPrecisionDigits; > // Not a number, i.e. result of 0/0. > // Present only if !kIsInteger. > static const Type kNaN; > // Positive infinity, i.e. result of 1/0. > // Present only if !kIsInteger. > static const Type kPosInf; > // Negative infinity, i.e. result of -1/0. > // Present only if !kIsInteger. > static const Type kNegInf; 34a91,105 > // NOTE: Special floating point values behave > // in a special (but mathematically-logical) way > // in terms of (in)equalty comparison and mathematical operations > // -- see out unittest for examples. > > // Special floating point value testers. > // Present in integer types for convenience. > static bool IsFinite(const Type x); > static bool IsNaN(const Type x); > static bool IsInf(const Type x); > static bool IsPosInf(const Type x); > static bool IsNegInf(const Type x); > }; > // END HACK ALERT > #endif //UTIL_MATH_MATHLIMITS_H 56c127 < static inline QuadraticRootType RealRootsForQuadratic(long double a, --- > static QuadraticRootType RealRootsForQuadratic(long double a, 60,64c131 < long double *r2) { < // Deal with degenerate cases where leading coefficients vanish. < if (a == 0.0) { < return DegenerateQuadraticRoots(b, c, r1, r2); < } --- > long double *r2); 66,88d132 < // General case: the quadratic formula, rearranged for greater numerical < // stability. < < // If the discriminant is zero to numerical precision, regardless of < // sign, treat it as zero and return kAmbiguous. We use the double < // rather than long double value for epsilon because in practice inputs < // are generally calculated in double precision. < const long double discriminant = QuadraticDiscriminant(a, b, c); < if (QuadraticIsAmbiguous(a, b, c, discriminant, < MathLimits::kEpsilon)) { < *r2 = *r1 = -b / 2 / a; // The quadratic is (2*a*x + b)^2 = 0. < return kAmbiguous; < } < < if (discriminant < 0) { < // The discriminant is definitely negative so there are no real roots. < return kNoRealRoots; < } < < RealQuadraticRoots(a, b, c, discriminant, r1, r2); < return kTwoRealRoots; < } < 290,292c334 < static IntOut Round(FloatIn x) { < COMPILE_ASSERT(!MathLimits::kIsInteger, FloatIn_is_integer); < COMPILE_ASSERT(MathLimits::kIsInteger, IntOut_is_not_integer); --- > static IntOut Round(FloatIn x); 294,299d335 < // We don't use sgn(x) below because there is no need to distinguish the < // (x == 0) case. Also note that there are specialized faster versions < // of this function for Intel processors at the bottom of this file. < return static_cast(x < 0 ? (x - 0.5) : (x + 0.5)); < } < 654d689 <