Introduce callback context in libsolc

This commit is contained in:
Alex Beregszaszi
2019-11-22 11:42:39 +00:00
parent 32c84fc3b6
commit eedfafbbc4
5 changed files with 16 additions and 11 deletions
+4 -2
View File
@@ -59,7 +59,7 @@ bool containsError(Json::Value const& _compilerResult, string const& _type, stri
Json::Value compile(string const& _input, CStyleReadFileCallback _callback = nullptr)
{
string output(solidity_compile(_input.c_str(), _callback));
string output(solidity_compile(_input.c_str(), _callback, nullptr));
Json::Value ret;
BOOST_REQUIRE(jsonParseStrict(output, ret));
solidity_free();
@@ -138,8 +138,10 @@ BOOST_AUTO_TEST_CASE(with_callback)
)";
CStyleReadFileCallback callback{
[](char const* _kind, char const* _path, char** o_contents, char** o_error)
[](void* _context, char const* _kind, char const* _path, char** o_contents, char** o_error)
{
// Passed in a nullptr in the compile() helper above.
BOOST_CHECK(_context == nullptr);
// Caller frees the pointers.
BOOST_CHECK(string(_kind) == ReadCallback::kindString(ReadCallback::Kind::ReadFile));
if (string(_path) == "found.sol")
+1 -1
View File
@@ -42,7 +42,7 @@ void FuzzerUtil::runCompiler(string const& _input, bool _quiet)
{
if (!_quiet)
cout << "Input JSON: " << _input << endl;
string outputString(solidity_compile(_input.c_str(), nullptr));
string outputString(solidity_compile(_input.c_str(), nullptr, nullptr));
if (!_quiet)
cout << "Output JSON: " << outputString << endl;