diff --git a/include/tree_sitter/runtime.h b/include/tree_sitter/runtime.h index 1b2c90b6..e2a1dd3f 100644 --- a/include/tree_sitter/runtime.h +++ b/include/tree_sitter/runtime.h @@ -19,8 +19,8 @@ typedef enum { typedef struct { void *payload; - const char *(*read_fn)(void *payload, size_t *bytes_read); - int (*seek_fn)(void *payload, size_t character, size_t byte); + const char *(*read)(void *payload, size_t *bytes_read); + int (*seek)(void *payload, size_t character_index, size_t byte_index); TSInputEncoding encoding; } TSInput; diff --git a/spec/helpers/spy_input.cc b/spec/helpers/spy_input.cc index 3968bcc2..d5d4bf96 100644 --- a/spec/helpers/spy_input.cc +++ b/spec/helpers/spy_input.cc @@ -63,8 +63,8 @@ TSInput SpyInput::input() { TSInput result; result.payload = this; result.encoding = encoding; - result.seek_fn = seek; - result.read_fn = read; + result.seek = seek; + result.read = read; return result; } diff --git a/spec/runtime/document_spec.cc b/spec/runtime/document_spec.cc index 8b50e33b..ec479b4e 100644 --- a/spec/runtime/document_spec.cc +++ b/spec/runtime/document_spec.cc @@ -69,8 +69,8 @@ describe("Document", [&]() { it("allows the input to be retrieved later", [&]() { ts_document_set_input(doc, spy_input->input()); AssertThat(ts_document_input(doc).payload, Equals(spy_input)); - AssertThat(ts_document_input(doc).read_fn, Equals(spy_input->input().read_fn)); - AssertThat(ts_document_input(doc).seek_fn, Equals(spy_input->input().seek_fn)); + AssertThat(ts_document_input(doc).read, Equals(spy_input->input().read)); + AssertThat(ts_document_input(doc).seek, Equals(spy_input->input().seek)); }); it("does not assume that the document's text has changed", [&]() { diff --git a/src/runtime/document.c b/src/runtime/document.c index 0da347c1..1211eb5e 100644 --- a/src/runtime/document.c +++ b/src/runtime/document.c @@ -90,7 +90,7 @@ void ts_document_edit(TSDocument *self, TSInputEdit edit) { } int ts_document_parse(TSDocument *self) { - if (!self->input.read_fn || !self->parser.language) + if (!self->input.read || !self->parser.language) return -1; TSTree *reusable_tree = self->valid ? self->tree : NULL; diff --git a/src/runtime/lexer.c b/src/runtime/lexer.c index 7a3c2f04..d87ebd9c 100644 --- a/src/runtime/lexer.c +++ b/src/runtime/lexer.c @@ -24,11 +24,11 @@ static void ts_lexer__get_chunk(TSLexer *self) { TSInput input = self->input; if (!self->chunk || self->current_position.bytes != self->chunk_start + self->chunk_size) - input.seek_fn(input.payload, self->current_position.chars, + input.seek(input.payload, self->current_position.chars, self->current_position.bytes); self->chunk_start = self->current_position.bytes; - self->chunk = input.read_fn(input.payload, &self->chunk_size); + self->chunk = input.read(input.payload, &self->chunk_size); if (!self->chunk_size) self->chunk = empty_chunk; } diff --git a/src/runtime/string_input.c b/src/runtime/string_input.c index b1b87edc..338047c9 100644 --- a/src/runtime/string_input.c +++ b/src/runtime/string_input.c @@ -36,8 +36,8 @@ TSInput ts_string_input_make(const char *string) { input->length = strlen(string); return (TSInput){ .payload = input, - .read_fn = ts_string_input_read, - .seek_fn = ts_string_input_seek, + .read = ts_string_input_read, + .seek = ts_string_input_seek, .encoding = TSInputEncodingUTF8, };