Skip to content

Commit 101ae83

Browse files
committed
Use cstdint types in integral_types.h
Include stdint.i in s2.i to get SWIG mappings.
1 parent 2c02e21 commit 101ae83

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/python/s2.i

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
%include "std_vector.i"
22
%include "std_string.i"
3+
%include "stdint.i"
34

4-
%template() std::vector<unsigned long long>;
55
%template() std::vector<S2CellId>;
66
%template() std::vector<S2Point>;
77
%template() std::vector<S2LatLng>;
88

9-
%apply int {int32};
10-
%apply unsigned long long {uint64};
119
%apply std::string {string};
12-
%apply std::vector<unsigned long long> const & {std::vector<uint64> const &};
1310

1411
// Standard Google convention is to ignore all functions and methods, and
1512
// selectively add back those for which wrapping is both required and

src/s2/base/integral_types.h

+15-9
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,22 @@
1616
#ifndef S2_BASE_INTEGRAL_TYPES_H_
1717
#define S2_BASE_INTEGRAL_TYPES_H_
1818

19-
using int8 = signed char;
20-
using int16 = short;
21-
using int32 = int;
22-
using int64 = long long;
19+
#include <cstdint>
20+
#include <type_traits>
2321

24-
using uint8 = unsigned char;
25-
using uint16 = unsigned short;
26-
using uint32 = unsigned int;
27-
using uint64 = unsigned long long;
22+
using int8 = int8_t;
23+
using int16 = int16_t;
24+
using int32 = int32_t;
25+
using int64 = int64_t;
2826

29-
using uword_t = unsigned long;
27+
using uint8 = uint8_t;
28+
using uint16 = uint16_t;
29+
using uint32 = uint32_t;
30+
using uint64 = uint64_t;
31+
32+
static_assert(sizeof(void *) == 8 || sizeof(void *) == 4,
33+
"void * must be 32 or 64 bits.");
34+
using uword_t =
35+
std::conditional<sizeof(void *) == 8, uint64_t, uint32_t>::type;
3036

3137
#endif // S2_BASE_INTEGRAL_TYPES_H_

0 commit comments

Comments
 (0)