Consolidate TSInput interface down to one function

This commit is contained in:
Max Brunsfeld 2018-06-19 09:34:40 -07:00
parent 2a507f0739
commit b0b3b2e5f3
8 changed files with 39 additions and 65 deletions

View file

@ -630,15 +630,12 @@ describe("Parser", [&]() {
size_t read_count = 0;
TSInput infinite_input = {
&read_count,
[](void *payload, uint32_t *bytes_read) {
[](void *payload, uint32_t byte, TSPoint position, uint32_t *bytes_read) {
size_t *read_count = static_cast<size_t *>(payload);
assert((*read_count)++ < 100000);
*bytes_read = 1;
return "[";
},
[](void *payload, unsigned byte, TSPoint position) -> int {
return true;
},
TSInputEncodingUTF8
};
@ -681,15 +678,12 @@ describe("Parser", [&]() {
// it has been read.
TSInput infinite_input = {
&state,
[](void *payload, uint32_t *bytes_read) {
[](void *payload, uint32_t byte, TSPoint position, uint32_t *bytes_read) {
InputState *state = static_cast<InputState *>(payload);
assert(state->read_count++ <= 10);
*bytes_read = strlen(state->string);
return state->string;
},
[](void *payload, unsigned byte, TSPoint position) -> int {
return true;
},
TSInputEncodingUTF8
};