mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename "JSON Documentation" -> Metadata.
solc integration for Solidity-format ABI.
This commit is contained in:
parent
d7873d9cd0
commit
6de29142ef
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @author Lefteris <lefteris@ethdev.com>
|
* @author Lefteris <lefteris@ethdev.com>
|
||||||
|
* @author Gav Wood <g@ethdev.com>
|
||||||
* @date 2014
|
* @date 2014
|
||||||
* Solidity command line interface.
|
* Solidity command line interface.
|
||||||
*/
|
*/
|
||||||
@ -51,6 +52,7 @@ namespace solidity
|
|||||||
// LTODO: Maybe some argument class pairing names with
|
// LTODO: Maybe some argument class pairing names with
|
||||||
// extensions and other attributes would be a better choice here?
|
// extensions and other attributes would be a better choice here?
|
||||||
static string const g_argAbiStr = "abi";
|
static string const g_argAbiStr = "abi";
|
||||||
|
static string const g_argSolAbiStr = "sol-abi";
|
||||||
static string const g_argAsmStr = "asm";
|
static string const g_argAsmStr = "asm";
|
||||||
static string const g_argAstStr = "ast";
|
static string const g_argAstStr = "ast";
|
||||||
static string const g_argBinaryStr = "binary";
|
static string const g_argBinaryStr = "binary";
|
||||||
@ -60,7 +62,7 @@ static string const g_argNatspecUserStr = "natspec-user";
|
|||||||
|
|
||||||
static void version()
|
static void version()
|
||||||
{
|
{
|
||||||
cout << "solc, the solidity complier commandline interface " << dev::Version << endl
|
cout << "solc, the solidity compiler commandline interface " << dev::Version << endl
|
||||||
<< " by Christian <c@ethdev.com> and Lefteris <lefteris@ethdev.com>, (c) 2014." << endl
|
<< " by Christian <c@ethdev.com> and Lefteris <lefteris@ethdev.com>, (c) 2014." << endl
|
||||||
<< "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
|
<< "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -73,7 +75,9 @@ static inline bool argToStdout(po::variables_map const& _args, string const& _na
|
|||||||
|
|
||||||
static bool needStdout(po::variables_map const& _args)
|
static bool needStdout(po::variables_map const& _args)
|
||||||
{
|
{
|
||||||
return argToStdout(_args, g_argAbiStr) || argToStdout(_args, g_argNatspecUserStr) ||
|
return
|
||||||
|
argToStdout(_args, g_argAbiStr) || argToStdout(_args, g_argSolAbiStr) ||
|
||||||
|
argToStdout(_args, g_argNatspecUserStr) ||
|
||||||
argToStdout(_args, g_argNatspecDevStr) || argToStdout(_args, g_argAsmStr) ||
|
argToStdout(_args, g_argNatspecDevStr) || argToStdout(_args, g_argAsmStr) ||
|
||||||
argToStdout(_args, g_argOpcodesStr) || argToStdout(_args, g_argBinaryStr);
|
argToStdout(_args, g_argOpcodesStr) || argToStdout(_args, g_argBinaryStr);
|
||||||
}
|
}
|
||||||
@ -146,8 +150,7 @@ void CommandLineInterface::handleBytecode(string const& _contract)
|
|||||||
handleBinary(_contract);
|
handleBinary(_contract);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineInterface::handleJson(DocumentationType _type,
|
void CommandLineInterface::handleMeta(DocumentationType _type, string const& _contract)
|
||||||
string const& _contract)
|
|
||||||
{
|
{
|
||||||
std::string argName;
|
std::string argName;
|
||||||
std::string suffix;
|
std::string suffix;
|
||||||
@ -159,8 +162,13 @@ void CommandLineInterface::handleJson(DocumentationType _type,
|
|||||||
suffix = ".abi";
|
suffix = ".abi";
|
||||||
title = "Contract ABI";
|
title = "Contract ABI";
|
||||||
break;
|
break;
|
||||||
|
case DocumentationType::ABI_SOLIDITY_INTERFACE:
|
||||||
|
argName = g_argSolAbiStr;
|
||||||
|
suffix = ".sol";
|
||||||
|
title = "Contract Solidity ABI";
|
||||||
|
break;
|
||||||
case DocumentationType::NATSPEC_USER:
|
case DocumentationType::NATSPEC_USER:
|
||||||
argName = "g_argNatspecUserStr";
|
argName = g_argNatspecUserStr;
|
||||||
suffix = ".docuser";
|
suffix = ".docuser";
|
||||||
title = "User Documentation";
|
title = "User Documentation";
|
||||||
break;
|
break;
|
||||||
@ -180,13 +188,13 @@ void CommandLineInterface::handleJson(DocumentationType _type,
|
|||||||
if (outputToStdout(choice))
|
if (outputToStdout(choice))
|
||||||
{
|
{
|
||||||
cout << title << endl;
|
cout << title << endl;
|
||||||
cout << m_compiler.getJsonDocumentation(_contract, _type);
|
cout << m_compiler.getMetadata(_contract, _type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputToFile(choice))
|
if (outputToFile(choice))
|
||||||
{
|
{
|
||||||
ofstream outFile(_contract + suffix);
|
ofstream outFile(_contract + suffix);
|
||||||
outFile << m_compiler.getJsonDocumentation(_contract, _type);
|
outFile << m_compiler.getMetadata(_contract, _type);
|
||||||
outFile.close();
|
outFile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +222,9 @@ bool CommandLineInterface::parseArguments(int argc, char** argv)
|
|||||||
(g_argBinaryStr.c_str(), po::value<OutputType>(),
|
(g_argBinaryStr.c_str(), po::value<OutputType>(),
|
||||||
"Request to output the contract in binary (hexadecimal). " OUTPUT_TYPE_STR)
|
"Request to output the contract in binary (hexadecimal). " OUTPUT_TYPE_STR)
|
||||||
(g_argAbiStr.c_str(), po::value<OutputType>(),
|
(g_argAbiStr.c_str(), po::value<OutputType>(),
|
||||||
"Request to output the contract's ABI interface. " OUTPUT_TYPE_STR)
|
"Request to output the contract's JSON ABI interface. " OUTPUT_TYPE_STR)
|
||||||
|
(g_argSolAbiStr.c_str(), po::value<OutputType>(),
|
||||||
|
"Request to output the contract's Solidity ABI interface. " OUTPUT_TYPE_STR)
|
||||||
(g_argNatspecUserStr.c_str(), po::value<OutputType>(),
|
(g_argNatspecUserStr.c_str(), po::value<OutputType>(),
|
||||||
"Request to output the contract's Natspec user documentation. " OUTPUT_TYPE_STR)
|
"Request to output the contract's Natspec user documentation. " OUTPUT_TYPE_STR)
|
||||||
(g_argNatspecDevStr.c_str(), po::value<OutputType>(),
|
(g_argNatspecDevStr.c_str(), po::value<OutputType>(),
|
||||||
@ -384,9 +394,10 @@ void CommandLineInterface::actOnInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleBytecode(contract);
|
handleBytecode(contract);
|
||||||
handleJson(DocumentationType::ABI_INTERFACE, contract);
|
handleMeta(DocumentationType::ABI_INTERFACE, contract);
|
||||||
handleJson(DocumentationType::NATSPEC_DEV, contract);
|
handleMeta(DocumentationType::ABI_SOLIDITY_INTERFACE, contract);
|
||||||
handleJson(DocumentationType::NATSPEC_USER, contract);
|
handleMeta(DocumentationType::NATSPEC_DEV, contract);
|
||||||
|
handleMeta(DocumentationType::NATSPEC_USER, contract);
|
||||||
} // end of contracts iteration
|
} // end of contracts iteration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ private:
|
|||||||
void handleBinary(std::string const& _contract);
|
void handleBinary(std::string const& _contract);
|
||||||
void handleOpcode(std::string const& _contract);
|
void handleOpcode(std::string const& _contract);
|
||||||
void handleBytecode(std::string const& _contract);
|
void handleBytecode(std::string const& _contract);
|
||||||
void handleJson(DocumentationType _type,
|
void handleMeta(DocumentationType _type,
|
||||||
std::string const& _contract);
|
std::string const& _contract);
|
||||||
|
|
||||||
/// Compiler arguments variable map
|
/// Compiler arguments variable map
|
||||||
|
Loading…
Reference in New Issue
Block a user