Skip to content

Commit dedcc93

Browse files
authored
Merge pull request #4 from theindigamer/debug-ci
WIP: Fix flaky CI
2 parents e34e004 + 08cf249 commit dedcc93

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

.travis.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ matrix:
1111
osx_image: xcode9.2
1212
compiler: clang
1313
- os: linux
14-
env: CXX=clang-3.6
15-
compiler: clang-3.6
14+
env: CXX=clang-5.0
15+
compiler: clang-5.0
1616
addons:
1717
apt:
1818
sources:
19-
- llvm-toolchain-precise-3.6
19+
- llvm-toolchain-trusty-5.0
2020
- ubuntu-toolchain-r-test
2121
packages:
22-
- clang-3.6
22+
- clang-5.0
2323
branches:
2424
only:
25-
- master
26-
- "/^v.*$/"
25+
- /.*/
26+
# - master
27+
# - "/^v.*$/"
2728
deploy:
2829
provider: script
29-
script: npm run prebuild && npm run prebuild:upload -u ${PREBUILD_UPLOAD}
30+
script: |
31+
npm run prebuild && npm run prebuild:upload -u ${PREBUILD_UPLOAD}
3032
skip_cleanup: true
3133
on:
3234
all_branches: true

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"rebuild": "npx tree-sitter generate && npx node-gyp rebuild",
8-
"install": "prebuild-install || npx node-gyp rebuild",
8+
"install": "CXXFLAGS=\"-std=c++11\" prebuild-install || npx node-gyp rebuild",
99
"prebuild": "prebuild --all --strip --verbose",
1010
"prebuild:upload": "prebuild --upload-all",
1111
"test": "npx tree-sitter test",

src/scanner.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
#include <cwctype>
44
#include <cassert>
55
#include <cstring>
6+
#include <cstdint>
67

78
namespace {
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

Comments
 (0)