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
@@ -36,6 +36,7 @@ extern "C" {
/// Callback used to retrieve additional source files or data.
///
/// @param _context The readContext passed to solidity_compile. Can be NULL.
/// @param _kind The kind of callback (a string).
/// @param _data The data for the callback.
/// @param o_contents A pointer to the contents of the file, if found.
@@ -44,7 +45,7 @@ extern "C" {
/// If the callback is not supported, o_contents and o_error should be set to NULL.
///
/// The two pointers (o_contents and o_error) should be heap-allocated and are free'd by the caller.
typedef void (*CStyleReadFileCallback)(char const* _kind, char const* _data, char** o_contents, char** o_error);
typedef void (*CStyleReadFileCallback)(void* _context, char const* _kind, char const* _data, char** o_contents, char** o_error);
/// Returns the complete license document.
///
@@ -61,9 +62,10 @@ char const* solidity_version() SOLC_NOEXCEPT;
///
/// @param _input The input JSON to process.
/// @param _readCallback The optional callback pointer. Can be NULL.
/// @param _readContext An optional context pointer passed to _readCallback. Can be NULL.
///
/// @returns A pointer to the result. The pointer returned must not be freed by the caller.
char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback) SOLC_NOEXCEPT;
char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback, void* _readContext) SOLC_NOEXCEPT;
/// Frees up any allocated memory.
///