33#include < cwctype>
44#include < cassert>
55#include < cstring>
6+ #include < cstdint>
67
78namespace {
89
10+ // If we could somehow force the CI to use C++11, we could use decltype
11+ // instead of using this work-around of declaring aliases up-front.
12+ typedef uint32_t queued_dedent_count_type;
13+ typedef uint16_t indent_length_stack_element_type;
14+
915 using std::vector;
1016
1117 enum TokenType {
@@ -21,18 +27,17 @@ namespace {
2127
2228 unsigned serialize (char *buffer) {
2329 size_t n_copied_so_far = 0 ;
24- size_t n_to_copy = sizeof (decltype (queued_dedent_count) );
30+ size_t n_to_copy = sizeof (queued_dedent_count_type );
2531
2632 std::memcpy ((void *) &(buffer[n_copied_so_far]),
2733 (void *) &queued_dedent_count,
2834 n_to_copy);
2935 n_copied_so_far += n_to_copy;
3036
31- using element_type = decltype (indent_length_stack)::value_type;
32- n_to_copy = indent_length_stack.size () * sizeof (element_type);
37+ n_to_copy = indent_length_stack.size () * sizeof (indent_length_stack_element_type);
3338 if (n_copied_so_far + n_to_copy > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) {
3439 n_to_copy = TREE_SITTER_SERIALIZATION_BUFFER_SIZE - n_copied_so_far;
35- n_to_copy -= n_to_copy % sizeof (element_type );
40+ n_to_copy -= n_to_copy % sizeof (indent_length_stack_element_type );
3641 }
3742 std::memcpy ((void *) &(buffer[n_copied_so_far]),
3843 (void *) indent_length_stack.data (),
@@ -60,14 +65,13 @@ namespace {
6065 n_to_copy);
6166 n_copied_so_far += n_to_copy;
6267
63- using element_type = decltype (indent_length_stack)::value_type;
6468 n_to_copy = length - n_copied_so_far;
65- n_to_copy -= n_to_copy % sizeof (element_type );
69+ n_to_copy -= n_to_copy % sizeof (indent_length_stack_element_type );
6670 if (n_to_copy == 0 ) {
6771 indent_length_stack.push_back (0 );
6872 return ;
6973 }
70- indent_length_stack.resize (n_to_copy / sizeof (element_type ));
74+ indent_length_stack.resize (n_to_copy / sizeof (indent_length_stack_element_type ));
7175 std::memcpy ((void *) indent_length_stack.data (),
7276 (void *) &(buffer[n_copied_so_far]),
7377 n_to_copy);
@@ -225,8 +229,8 @@ namespace {
225229 return false ;
226230 }
227231
228- vector<uint16_t > indent_length_stack;
229- uint32_t queued_dedent_count;
232+ vector<indent_length_stack_element_type > indent_length_stack;
233+ queued_dedent_count_type queued_dedent_count;
230234
231235 // column_number : Maybe Int
232236 // -1 as Nothing,
0 commit comments