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 {
@@ -22,18 +28,17 @@ namespace {
2228
2329 unsigned serialize (char *buffer) {
2430 size_t n_copied_so_far = 0 ;
25- size_t n_to_copy = sizeof (decltype (queued_dedent_count) );
31+ size_t n_to_copy = sizeof (queued_dedent_count_type );
2632
2733 std::memcpy ((void *) &(buffer[n_copied_so_far]),
2834 (void *) &queued_dedent_count,
2935 n_to_copy);
3036 n_copied_so_far += n_to_copy;
3137
32- using element_type = decltype (indent_length_stack)::value_type;
33- n_to_copy = indent_length_stack.size () * sizeof (element_type);
38+ n_to_copy = indent_length_stack.size () * sizeof (indent_length_stack_element_type);
3439 if (n_copied_so_far + n_to_copy > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) {
3540 n_to_copy = TREE_SITTER_SERIALIZATION_BUFFER_SIZE - n_copied_so_far;
36- n_to_copy -= n_to_copy % sizeof (element_type );
41+ n_to_copy -= n_to_copy % sizeof (indent_length_stack_element_type );
3742 }
3843 std::memcpy ((void *) &(buffer[n_copied_so_far]),
3944 (void *) indent_length_stack.data (),
@@ -61,14 +66,13 @@ namespace {
6166 n_to_copy);
6267 n_copied_so_far += n_to_copy;
6368
64- using element_type = decltype (indent_length_stack)::value_type;
6569 n_to_copy = length - n_copied_so_far;
66- n_to_copy -= n_to_copy % sizeof (element_type );
70+ n_to_copy -= n_to_copy % sizeof (indent_length_stack_element_type );
6771 if (n_to_copy == 0 ) {
6872 indent_length_stack.push_back (0 );
6973 return ;
7074 }
71- indent_length_stack.resize (n_to_copy / sizeof (element_type ));
75+ indent_length_stack.resize (n_to_copy / sizeof (indent_length_stack_element_type ));
7276 std::memcpy ((void *) indent_length_stack.data (),
7377 (void *) &(buffer[n_copied_so_far]),
7478 n_to_copy);
@@ -264,8 +268,8 @@ namespace {
264268 return false ;
265269 }
266270
267- vector<uint16_t > indent_length_stack;
268- uint32_t queued_dedent_count;
271+ vector<indent_length_stack_element_type > indent_length_stack;
272+ queued_dedent_count_type queued_dedent_count;
269273
270274 // column_number : Maybe Int
271275 // -1 as Nothing,
0 commit comments