mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add new libsolc entry points (solidity_license/version/compile)
This commit is contained in:
parent
7d525620d8
commit
328554a4f9
@ -37,6 +37,7 @@ Language Features:
|
|||||||
* General: Scoping rules now follow the C99-style.
|
* General: Scoping rules now follow the C99-style.
|
||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
|
* C API (``libsolc``): Export the ``solidity_license``, ``solidity_version`` and ``solidity_compile`` methods.
|
||||||
* Type Checker: Show named argument in case of error.
|
* Type Checker: Show named argument in case of error.
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_compileJSON\",\"_license\",\"_version\",\"_compileJSONMulti\",\"_compileJSONCallback\",\"_compileStandard\"]' -s RESERVED_FUNCTION_POINTERS=20")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_solidity_license\",\"_solidity_version\",\"_solidity_compile\",\"_license\",\"_version\",\"_compileJSON\",\"_compileJSONMulti\",\"_compileJSONCallback\",\"_compileStandard\"]' -s RESERVED_FUNCTION_POINTERS=20")
|
||||||
add_executable(soljson libsolc.cpp)
|
add_executable(soljson libsolc.cpp)
|
||||||
target_link_libraries(soljson PRIVATE solidity)
|
target_link_libraries(soljson PRIVATE solidity)
|
||||||
else()
|
else()
|
||||||
|
@ -299,4 +299,19 @@ extern char const* compileStandard(char const* _input, CStyleReadFileCallback _r
|
|||||||
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()
|
||||||
|
{
|
||||||
|
/// todo: make this the default or an alias
|
||||||
|
return license();
|
||||||
|
}
|
||||||
|
extern char const* solidity_version()
|
||||||
|
{
|
||||||
|
/// todo: make this the default or an alias
|
||||||
|
return version();
|
||||||
|
}
|
||||||
|
extern char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback)
|
||||||
|
{
|
||||||
|
/// todo: make this the default or an alias
|
||||||
|
return compileStandard(_input, _readCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,10 @@ char const* compileJSONMulti(char const* _input, bool _optimize);
|
|||||||
char const* compileJSONCallback(char const* _input, bool _optimize, CStyleReadFileCallback _readCallback);
|
char const* compileJSONCallback(char const* _input, bool _optimize, CStyleReadFileCallback _readCallback);
|
||||||
char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback);
|
char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback);
|
||||||
|
|
||||||
|
char const* solidity_license();
|
||||||
|
char const* solidity_version();
|
||||||
|
char const* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -201,6 +201,26 @@ BOOST_AUTO_TEST_CASE(standard_compilation)
|
|||||||
BOOST_CHECK(result.isMember("contracts"));
|
BOOST_CHECK(result.isMember("contracts"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(new_api)
|
||||||
|
{
|
||||||
|
char const* input = R"(
|
||||||
|
{
|
||||||
|
"language": "Solidity",
|
||||||
|
"sources": {
|
||||||
|
"fileA": {
|
||||||
|
"content": "contract A { }"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK_EQUAL(string(version()), string(solidity_version()));
|
||||||
|
BOOST_CHECK_EQUAL(string(license()), string(solidity_license()));
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
string(compileStandard(input, nullptr)),
|
||||||
|
string(solidity_compile(input, nullptr))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user