From dfefe0cd330f22463c0eca4338da69762cae7b49 Mon Sep 17 00:00:00 2001 From: Jesse Rosenstock Date: Wed, 28 Nov 2018 13:04:20 -0500 Subject: [PATCH] Revert "Use cstdint types in integral_types.h" This reverts commit 101ae83c4c880e41434f4b812eb19bd1a706b4e9. This unbreaks pywraps2_test in Travis CI's configuration. https://travis-ci.org/google/s2geometry/jobs/460894006 ====================================================================== ERROR: testS2CellDistance (__main__.PyWrapS2TestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/google/s2geometry/src/python/pywraps2_test.py", line 213, in testS2CellDistance cell = s2.S2Cell(s2.S2CellId(0x1000000000000000)) File "/home/travis/build/google/s2geometry/build/python/pywraps2.py", line 311, in __init__ this = _pywraps2.new_S2CellId(*args) NotImplementedError: Wrong number or type of arguments for overloaded function 'new_S2CellId'. Possible C/C++ prototypes are: S2CellId::S2CellId(uint64) S2CellId::S2CellId(S2Point const &) S2CellId::S2CellId(S2LatLng const &) S2CellId::S2CellId() Possibly related to different SWIG or stdint.i versions. It looks like the uint64 -> uint64_t mapping is not being found. It worked when I tested. --- src/python/s2.i | 5 ++++- src/s2/base/integral_types.h | 24 +++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/python/s2.i b/src/python/s2.i index a58e0a41..248842b6 100644 --- a/src/python/s2.i +++ b/src/python/s2.i @@ -1,12 +1,15 @@ %include "std_vector.i" %include "std_string.i" -%include "stdint.i" +%template() std::vector; %template() std::vector; %template() std::vector; %template() std::vector; +%apply int {int32}; +%apply unsigned long long {uint64}; %apply std::string {string}; +%apply std::vector const & {std::vector const &}; // Standard Google convention is to ignore all functions and methods, and // selectively add back those for which wrapping is both required and diff --git a/src/s2/base/integral_types.h b/src/s2/base/integral_types.h index c60bb0bd..d20f35f5 100644 --- a/src/s2/base/integral_types.h +++ b/src/s2/base/integral_types.h @@ -16,22 +16,16 @@ #ifndef S2_BASE_INTEGRAL_TYPES_H_ #define S2_BASE_INTEGRAL_TYPES_H_ -#include -#include +using int8 = signed char; +using int16 = short; +using int32 = int; +using int64 = long long; -using int8 = int8_t; -using int16 = int16_t; -using int32 = int32_t; -using int64 = int64_t; +using uint8 = unsigned char; +using uint16 = unsigned short; +using uint32 = unsigned int; +using uint64 = unsigned long long; -using uint8 = uint8_t; -using uint16 = uint16_t; -using uint32 = uint32_t; -using uint64 = uint64_t; - -static_assert(sizeof(void *) == 8 || sizeof(void *) == 4, - "void * must be 32 or 64 bits."); -using uword_t = - std::conditional::type; +using uword_t = unsigned long; #endif // S2_BASE_INTEGRAL_TYPES_H_