Rename .read_fn, .seek_fn -> .read, .seek
This commit is contained in:
parent
f6da44fdbb
commit
38241d466b
6 changed files with 11 additions and 11 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<void *>(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", [&]() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue