mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4761 from ethereum/libsolc-exceptions
Mark libsolc external C functions as noexcept
This commit is contained in:
commit
efeffa8083
@ -270,46 +270,46 @@ static string s_outputBuffer;
|
|||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
extern char const* license()
|
extern char const* license() noexcept
|
||||||
{
|
{
|
||||||
static string fullLicenseText = otherLicenses + licenseText;
|
static string fullLicenseText = otherLicenses + licenseText;
|
||||||
return fullLicenseText.c_str();
|
return fullLicenseText.c_str();
|
||||||
}
|
}
|
||||||
extern char const* version()
|
extern char const* version() noexcept
|
||||||
{
|
{
|
||||||
return VersionString.c_str();
|
return VersionString.c_str();
|
||||||
}
|
}
|
||||||
extern char const* compileJSON(char const* _input, bool _optimize)
|
extern char const* compileJSON(char const* _input, bool _optimize) noexcept
|
||||||
{
|
{
|
||||||
s_outputBuffer = compileSingle(_input, _optimize);
|
s_outputBuffer = compileSingle(_input, _optimize);
|
||||||
return s_outputBuffer.c_str();
|
return s_outputBuffer.c_str();
|
||||||
}
|
}
|
||||||
extern char const* compileJSONMulti(char const* _input, bool _optimize)
|
extern char const* compileJSONMulti(char const* _input, bool _optimize) noexcept
|
||||||
{
|
{
|
||||||
s_outputBuffer = compileMulti(_input, _optimize);
|
s_outputBuffer = compileMulti(_input, _optimize);
|
||||||
return s_outputBuffer.c_str();
|
return s_outputBuffer.c_str();
|
||||||
}
|
}
|
||||||
extern char const* compileJSONCallback(char const* _input, bool _optimize, CStyleReadFileCallback _readCallback)
|
extern char const* compileJSONCallback(char const* _input, bool _optimize, CStyleReadFileCallback _readCallback) noexcept
|
||||||
{
|
{
|
||||||
s_outputBuffer = compileMulti(_input, _optimize, _readCallback);
|
s_outputBuffer = compileMulti(_input, _optimize, _readCallback);
|
||||||
return s_outputBuffer.c_str();
|
return s_outputBuffer.c_str();
|
||||||
}
|
}
|
||||||
extern char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback)
|
extern char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback) noexcept
|
||||||
{
|
{
|
||||||
s_outputBuffer = compileStandardInternal(_input, _readCallback);
|
s_outputBuffer = compileStandardInternal(_input, _readCallback);
|
||||||
return s_outputBuffer.c_str();
|
return s_outputBuffer.c_str();
|
||||||
}
|
}
|
||||||
extern char const* solidity_license()
|
extern char const* solidity_license() noexcept
|
||||||
{
|
{
|
||||||
/// todo: make this the default or an alias
|
/// todo: make this the default or an alias
|
||||||
return license();
|
return license();
|
||||||
}
|
}
|
||||||
extern char const* solidity_version()
|
extern char const* solidity_version() noexcept
|
||||||
{
|
{
|
||||||
/// todo: make this the default or an alias
|
/// todo: make this the default or an alias
|
||||||
return version();
|
return version();
|
||||||
}
|
}
|
||||||
extern char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback)
|
extern char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback) noexcept
|
||||||
{
|
{
|
||||||
/// todo: make this the default or an alias
|
/// todo: make this the default or an alias
|
||||||
return compileStandard(_input, _readCallback);
|
return compileStandard(_input, _readCallback);
|
||||||
|
@ -22,6 +22,12 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define SOLC_NOEXCEPT noexcept
|
||||||
|
#else
|
||||||
|
#define SOLC_NOEXCEPT
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -30,16 +36,16 @@ extern "C" {
|
|||||||
/// heap-allocated and are free'd by the caller.
|
/// 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);
|
||||||
|
|
||||||
char const* license();
|
char const* license() SOLC_NOEXCEPT;
|
||||||
char const* version();
|
char const* version() SOLC_NOEXCEPT;
|
||||||
char const* compileJSON(char const* _input, bool _optimize);
|
char const* compileJSON(char const* _input, bool _optimize) SOLC_NOEXCEPT;
|
||||||
char const* compileJSONMulti(char const* _input, bool _optimize);
|
char const* compileJSONMulti(char const* _input, bool _optimize) SOLC_NOEXCEPT;
|
||||||
char const* compileJSONCallback(char const* _input, bool _optimize, CStyleReadFileCallback _readCallback);
|
char const* compileJSONCallback(char const* _input, bool _optimize, CStyleReadFileCallback _readCallback) SOLC_NOEXCEPT;
|
||||||
char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback);
|
char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback) SOLC_NOEXCEPT;
|
||||||
|
|
||||||
char const* solidity_license();
|
char const* solidity_license() SOLC_NOEXCEPT;
|
||||||
char const* solidity_version();
|
char const* solidity_version() SOLC_NOEXCEPT;
|
||||||
char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback);
|
char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback) SOLC_NOEXCEPT;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value StandardCompiler::compile(Json::Value const& _input)
|
Json::Value StandardCompiler::compile(Json::Value const& _input) noexcept
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -591,7 +591,7 @@ Json::Value StandardCompiler::compile(Json::Value const& _input)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string StandardCompiler::compile(string const& _input)
|
string StandardCompiler::compile(string const& _input) noexcept
|
||||||
{
|
{
|
||||||
Json::Value input;
|
Json::Value input;
|
||||||
string errors;
|
string errors;
|
||||||
|
@ -47,10 +47,10 @@ public:
|
|||||||
|
|
||||||
/// Sets all input parameters according to @a _input which conforms to the standardized input
|
/// Sets all input parameters according to @a _input which conforms to the standardized input
|
||||||
/// format, performs compilation and returns a standardized output.
|
/// format, performs compilation and returns a standardized output.
|
||||||
Json::Value compile(Json::Value const& _input);
|
Json::Value compile(Json::Value const& _input) noexcept;
|
||||||
/// Parses input as JSON and peforms the above processing steps, returning a serialized JSON
|
/// Parses input as JSON and peforms the above processing steps, returning a serialized JSON
|
||||||
/// output. Parsing errors are returned as regular errors.
|
/// output. Parsing errors are returned as regular errors.
|
||||||
std::string compile(std::string const& _input);
|
std::string compile(std::string const& _input) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Json::Value compileInternal(Json::Value const& _input);
|
Json::Value compileInternal(Json::Value const& _input);
|
||||||
|
Loading…
Reference in New Issue
Block a user