Browse Source

Rename "JSON Documentation" -> Metadata.

solc integration for Solidity-format ABI.
cl-refactor
Gav Wood 10 years ago
parent
commit
0de1fe5b02
  1. 37
      solc/CommandLineInterface.cpp
  2. 2
      solc/CommandLineInterface.h
  3. 2
      test/SolidityABIJSON.cpp
  4. 4
      test/SolidityNatspecJSON.cpp

37
solc/CommandLineInterface.cpp

@ -16,6 +16,7 @@
*/
/**
* @author Lefteris <lefteris@ethdev.com>
* @author Gav Wood <g@ethdev.com>
* @date 2014
* Solidity command line interface.
*/
@ -51,6 +52,7 @@ namespace solidity
// LTODO: Maybe some argument class pairing names with
// extensions and other attributes would be a better choice here?
static string const g_argAbiStr = "abi";
static string const g_argSolAbiStr = "sol-abi";
static string const g_argAsmStr = "asm";
static string const g_argAstStr = "ast";
static string const g_argBinaryStr = "binary";
@ -60,7 +62,7 @@ static string const g_argNatspecUserStr = "natspec-user";
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
<< "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
exit(0);
@ -73,9 +75,11 @@ static inline bool argToStdout(po::variables_map const& _args, string const& _na
static bool needStdout(po::variables_map const& _args)
{
return argToStdout(_args, g_argAbiStr) || argToStdout(_args, g_argNatspecUserStr) ||
argToStdout(_args, g_argNatspecDevStr) || argToStdout(_args, g_argAsmStr) ||
argToStdout(_args, g_argOpcodesStr) || argToStdout(_args, g_argBinaryStr);
return
argToStdout(_args, g_argAbiStr) || argToStdout(_args, g_argSolAbiStr) ||
argToStdout(_args, g_argNatspecUserStr) ||
argToStdout(_args, g_argNatspecDevStr) || argToStdout(_args, g_argAsmStr) ||
argToStdout(_args, g_argOpcodesStr) || argToStdout(_args, g_argBinaryStr);
}
static inline bool outputToFile(OutputType type)
@ -146,8 +150,7 @@ void CommandLineInterface::handleBytecode(string const& _contract)
handleBinary(_contract);
}
void CommandLineInterface::handleJson(DocumentationType _type,
string const& _contract)
void CommandLineInterface::handleMeta(DocumentationType _type, string const& _contract)
{
std::string argName;
std::string suffix;
@ -159,8 +162,13 @@ void CommandLineInterface::handleJson(DocumentationType _type,
suffix = ".abi";
title = "Contract ABI";
break;
case DocumentationType::ABI_SOLIDITY_INTERFACE:
argName = g_argSolAbiStr;
suffix = ".sol";
title = "Contract Solidity ABI";
break;
case DocumentationType::NATSPEC_USER:
argName = "g_argNatspecUserStr";
argName = g_argNatspecUserStr;
suffix = ".docuser";
title = "User Documentation";
break;
@ -180,13 +188,13 @@ void CommandLineInterface::handleJson(DocumentationType _type,
if (outputToStdout(choice))
{
cout << title << endl;
cout << m_compiler.getJsonDocumentation(_contract, _type);
cout << m_compiler.getMetadata(_contract, _type);
}
if (outputToFile(choice))
{
ofstream outFile(_contract + suffix);
outFile << m_compiler.getJsonDocumentation(_contract, _type);
outFile << m_compiler.getMetadata(_contract, _type);
outFile.close();
}
}
@ -214,7 +222,9 @@ bool CommandLineInterface::parseArguments(int argc, char** argv)
(g_argBinaryStr.c_str(), po::value<OutputType>(),
"Request to output the contract in binary (hexadecimal). " OUTPUT_TYPE_STR)
(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>(),
"Request to output the contract's Natspec user documentation. " OUTPUT_TYPE_STR)
(g_argNatspecDevStr.c_str(), po::value<OutputType>(),
@ -384,9 +394,10 @@ void CommandLineInterface::actOnInput()
}
handleBytecode(contract);
handleJson(DocumentationType::ABI_INTERFACE, contract);
handleJson(DocumentationType::NATSPEC_DEV, contract);
handleJson(DocumentationType::NATSPEC_USER, contract);
handleMeta(DocumentationType::ABI_INTERFACE, contract);
handleMeta(DocumentationType::ABI_SOLIDITY_INTERFACE, contract);
handleMeta(DocumentationType::NATSPEC_DEV, contract);
handleMeta(DocumentationType::NATSPEC_USER, contract);
} // end of contracts iteration
}

2
solc/CommandLineInterface.h

@ -56,7 +56,7 @@ private:
void handleBinary(std::string const& _contract);
void handleOpcode(std::string const& _contract);
void handleBytecode(std::string const& _contract);
void handleJson(DocumentationType _type,
void handleMeta(DocumentationType _type,
std::string const& _contract);
/// Compiler arguments variable map

2
test/SolidityABIJSON.cpp

@ -50,7 +50,7 @@ public:
msg += *extra;
BOOST_FAIL(msg);
}
std::string generatedInterfaceString = m_compilerStack.getJsonDocumentation("", DocumentationType::ABI_INTERFACE);
std::string generatedInterfaceString = m_compilerStack.getMetadata("", DocumentationType::ABI_INTERFACE);
Json::Value generatedInterface;
m_reader.parse(generatedInterfaceString, generatedInterface);
Json::Value expectedInterface;

4
test/SolidityNatspecJSON.cpp

@ -56,9 +56,9 @@ public:
}
if (_userDocumentation)
generatedDocumentationString = m_compilerStack.getJsonDocumentation("", DocumentationType::NATSPEC_USER);
generatedDocumentationString = m_compilerStack.getMetadata("", DocumentationType::NATSPEC_USER);
else
generatedDocumentationString = m_compilerStack.getJsonDocumentation("", DocumentationType::NATSPEC_DEV);
generatedDocumentationString = m_compilerStack.getMetadata("", DocumentationType::NATSPEC_DEV);
Json::Value generatedDocumentation;
m_reader.parse(generatedDocumentationString, generatedDocumentation);
Json::Value expectedDocumentation;

Loading…
Cancel
Save