diff --git a/spec/runtime/helpers/spy_reader.cc b/spec/runtime/helpers/spy_reader.cc index 1aa34db0..d9b14fdf 100644 --- a/spec/runtime/helpers/spy_reader.cc +++ b/spec/runtime/helpers/spy_reader.cc @@ -26,18 +26,21 @@ SpyReader::SpyReader(string content, size_t chunk_size) : buffer(new char[chunk_size]), content(content), position(0), - chunk_size(chunk_size), - input({ - this, - spy_read, - spy_seek, - nullptr, - }) {} + chunk_size(chunk_size) {} void SpyReader::clear() { strings_read.clear(); } +TSInput SpyReader::input() { + TSInput result; + result.data = this; + result.seek_fn = spy_seek; + result.read_fn = spy_read; + result.release_fn = nullptr; + return result; +} + SpyReader::~SpyReader() { delete buffer; } diff --git a/spec/runtime/helpers/spy_reader.h b/spec/runtime/helpers/spy_reader.h index c3578f3a..b583ab56 100644 --- a/spec/runtime/helpers/spy_reader.h +++ b/spec/runtime/helpers/spy_reader.h @@ -11,12 +11,12 @@ class SpyReader { ~SpyReader(); void clear(); + TSInput input(); char *buffer; std::string content; size_t position; size_t chunk_size; - TSInput input; std::vector strings_read; }; diff --git a/spec/runtime/parser_spec.cc b/spec/runtime/parser_spec.cc index f499cc06..16a6425f 100644 --- a/spec/runtime/parser_spec.cc +++ b/spec/runtime/parser_spec.cc @@ -27,7 +27,7 @@ describe("Parser", [&]() { auto set_text = [&](const char *text) { reader = new SpyReader(text, chunk_size); - ts_document_set_input(doc, reader->input); + ts_document_set_input(doc, reader->input()); root = ts_document_root_node(doc); reader->clear(); };