Skip to content

Commit 65c16bf

Browse files
mattmassicotteahlinc
authored andcommitted
query casts
1 parent cde4526 commit 65c16bf

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/src/query.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static bool stream_advance(Stream *self) {
331331
if (self->input < self->end) {
332332
uint32_t size = ts_decode_utf8(
333333
(const uint8_t *)self->input,
334-
self->end - self->input,
334+
(uint32_t)(self->end - self->input),
335335
&self->next
336336
);
337337
if (size > 0) {
@@ -398,7 +398,7 @@ static void stream_scan_identifier(Stream *stream) {
398398
}
399399

400400
static uint32_t stream_offset(Stream *self) {
401-
return self->input - self->start;
401+
return (uint32_t)(self->input - self->start);
402402
}
403403

404404
/******************
@@ -2064,7 +2064,7 @@ static TSQueryError ts_query__parse_predicate(
20642064
if (!stream_is_ident_start(stream)) return TSQueryErrorSyntax;
20652065
const char *predicate_name = stream->input;
20662066
stream_scan_identifier(stream);
2067-
uint32_t length = stream->input - predicate_name;
2067+
uint32_t length = (uint32_t)(stream->input - predicate_name);
20682068
uint16_t id = symbol_table_insert_name(
20692069
&self->predicate_values,
20702070
predicate_name,
@@ -2095,7 +2095,7 @@ static TSQueryError ts_query__parse_predicate(
20952095
if (!stream_is_ident_start(stream)) return TSQueryErrorSyntax;
20962096
const char *capture_name = stream->input;
20972097
stream_scan_identifier(stream);
2098-
uint32_t length = stream->input - capture_name;
2098+
uint32_t length = (uint32_t)(stream->input - capture_name);
20992099

21002100
// Add the capture id to the first step of the pattern
21012101
int capture_id = symbol_table_id_for_name(
@@ -2133,7 +2133,7 @@ static TSQueryError ts_query__parse_predicate(
21332133
else if (stream_is_ident_start(stream)) {
21342134
const char *symbol_start = stream->input;
21352135
stream_scan_identifier(stream);
2136-
uint32_t length = stream->input - symbol_start;
2136+
uint32_t length = (uint32_t)(stream->input - symbol_start);
21372137
uint16_t id = symbol_table_insert_name(
21382138
&self->predicate_values,
21392139
symbol_start,
@@ -2302,7 +2302,7 @@ static TSQueryError ts_query__parse_pattern(
23022302
if (stream_is_ident_start(stream)) {
23032303
const char *node_name = stream->input;
23042304
stream_scan_identifier(stream);
2305-
uint32_t length = stream->input - node_name;
2305+
uint32_t length = (uint32_t)(stream->input - node_name);
23062306

23072307
// TODO - remove.
23082308
// For temporary backward compatibility, handle predicates without the leading '#' sign.
@@ -2353,7 +2353,7 @@ static TSQueryError ts_query__parse_pattern(
23532353

23542354
const char *node_name = stream->input;
23552355
stream_scan_identifier(stream);
2356-
uint32_t length = stream->input - node_name;
2356+
uint32_t length = (uint32_t)(stream->input - node_name);
23572357

23582358
step->symbol = ts_language_symbol_for_name(
23592359
self->language,
@@ -2386,7 +2386,7 @@ static TSQueryError ts_query__parse_pattern(
23862386
}
23872387
const char *field_name = stream->input;
23882388
stream_scan_identifier(stream);
2389-
uint32_t length = stream->input - field_name;
2389+
uint32_t length = (uint32_t)(stream->input - field_name);
23902390
stream_skip_whitespace(stream);
23912391

23922392
TSFieldId field_id = ts_language_field_id_for_name(
@@ -2497,7 +2497,7 @@ static TSQueryError ts_query__parse_pattern(
24972497
// Parse the field name
24982498
const char *field_name = stream->input;
24992499
stream_scan_identifier(stream);
2500-
uint32_t length = stream->input - field_name;
2500+
uint32_t length = (uint32_t)(stream->input - field_name);
25012501
stream_skip_whitespace(stream);
25022502

25032503
if (stream->next != ':') {
@@ -2616,7 +2616,7 @@ static TSQueryError ts_query__parse_pattern(
26162616
if (!stream_is_ident_start(stream)) return TSQueryErrorSyntax;
26172617
const char *capture_name = stream->input;
26182618
stream_scan_identifier(stream);
2619-
uint32_t length = stream->input - capture_name;
2619+
uint32_t length = (uint32_t)(stream->input - capture_name);
26202620
stream_skip_whitespace(stream);
26212621

26222622
// Add the capture id to the first step of the pattern
@@ -3323,7 +3323,7 @@ static QueryState *ts_query_cursor__copy_state(
33233323
QueryState **state_ref
33243324
) {
33253325
const QueryState *state = *state_ref;
3326-
uint32_t state_index = state - self->states.contents;
3326+
uint32_t state_index = (uint32_t)(state - self->states.contents);
33273327
QueryState copy = *state;
33283328
copy.capture_list_id = NONE;
33293329

0 commit comments

Comments
 (0)