Skip to content

Commit

Permalink
Revert "Use cstdint types in integral_types.h"
Browse files Browse the repository at this point in the history
This reverts commit 101ae83.

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.
  • Loading branch information
jmr committed Nov 28, 2018
1 parent 101ae83 commit dfefe0c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
5 changes: 4 additions & 1 deletion src/python/s2.i
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
%include "std_vector.i"
%include "std_string.i"
%include "stdint.i"

%template() std::vector<unsigned long long>;
%template() std::vector<S2CellId>;
%template() std::vector<S2Point>;
%template() std::vector<S2LatLng>;

%apply int {int32};
%apply unsigned long long {uint64};
%apply std::string {string};
%apply std::vector<unsigned long long> const & {std::vector<uint64> const &};

// Standard Google convention is to ignore all functions and methods, and
// selectively add back those for which wrapping is both required and
Expand Down
24 changes: 9 additions & 15 deletions src/s2/base/integral_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,16 @@
#ifndef S2_BASE_INTEGRAL_TYPES_H_
#define S2_BASE_INTEGRAL_TYPES_H_

#include <cstdint>
#include <type_traits>
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<sizeof(void *) == 8, uint64_t, uint32_t>::type;
using uword_t = unsigned long;

#endif // S2_BASE_INTEGRAL_TYPES_H_

0 comments on commit dfefe0c

Please sign in to comment.