Merge pull request #7769 from ethereum/libsolc-doc

Document and clarify libsolc's interface
This commit is contained in:
chriseth 2019-11-21 22:57:32 +01:00 committed by GitHub
commit 0201ff5a02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -53,7 +53,7 @@ ReadCallback::Callback wrapReadCallback(CStyleReadFileCallback _readCallback = n
if (!contents_c && !error_c) if (!contents_c && !error_c)
{ {
result.success = false; result.success = false;
result.responseOrErrorMessage = "File not found."; result.responseOrErrorMessage = "Callback not supported.";
} }
if (contents_c) if (contents_c)
{ {

View File

@ -36,7 +36,13 @@ extern "C" {
/// Callback used to retrieve additional source files. /// Callback used to retrieve additional source files.
/// ///
/// "Returns" two pointers that should be heap-allocated and are free'd by the caller. /// @param _path The path for loading.
/// @param o_contents A pointer to the contents of the file, if found.
/// @param o_error A pointer to an error message, if there is one.
///
/// 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* _path, char** o_contents, char** o_error); typedef void (*CStyleReadFileCallback)(char const* _path, char** o_contents, char** o_error);
/// Returns the complete license document. /// Returns the complete license document.
@ -52,7 +58,10 @@ char const* solidity_version() SOLC_NOEXCEPT;
/// Takes a "Standard Input JSON" and an optional callback (can be set to null). Returns /// Takes a "Standard Input JSON" and an optional callback (can be set to null). Returns
/// a "Standard Output JSON". Both are to be UTF-8 encoded. /// a "Standard Output JSON". Both are to be UTF-8 encoded.
/// ///
/// The pointer returned must not be freed by the caller. /// @param _input
/// @param _readCallback
///
/// @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) SOLC_NOEXCEPT;
/// Frees up any allocated memory. /// Frees up any allocated memory.

View File

@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(with_callback)
BOOST_CHECK(containsError(result, "ParserError", "Source \"missing.sol\" not found: Missing file.")); BOOST_CHECK(containsError(result, "ParserError", "Source \"missing.sol\" not found: Missing file."));
// This should be placed due to the missing "notfound.sol" which sets both pointers to null. // This should be placed due to the missing "notfound.sol" which sets both pointers to null.
BOOST_CHECK(containsError(result, "ParserError", "Source \"notfound.sol\" not found: File not found.")); BOOST_CHECK(containsError(result, "ParserError", "Source \"notfound.sol\" not found: Callback not supported."));
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()