Consolidate TSInput interface down to one function
This commit is contained in:
parent
2a507f0739
commit
b0b3b2e5f3
8 changed files with 39 additions and 65 deletions
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue