Styling in libsolidity's InterfaceHandler

This commit is contained in:
Lefteris Karapetsas 2014-12-04 01:27:38 +01:00
parent a0ff2179d4
commit ba27dc7421
4 changed files with 10 additions and 10 deletions

View File

@ -84,12 +84,12 @@ void CompilerStack::streamAssembly(ostream& _outStream)
m_compiler->streamAssembly(_outStream); m_compiler->streamAssembly(_outStream);
} }
std::string const* CompilerStack::getJsonDocumentation(enum documentation_type _type) std::string const* CompilerStack::getJsonDocumentation(enum documentationType _type)
{ {
if (!m_parseSuccessful) if (!m_parseSuccessful)
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful.")); BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
auto createOrReturnDoc = [&, this](std::unique_ptr<string>& _doc) auto createOrReturnDoc = [this, _type](std::unique_ptr<string>& _doc)
{ {
if(!_doc) if(!_doc)
{ {

View File

@ -37,7 +37,7 @@ class Compiler;
class GlobalContext; class GlobalContext;
class InterfaceHandler; class InterfaceHandler;
enum documentation_type : unsigned short enum documentationType: unsigned short
{ {
NATSPEC_USER = 1, NATSPEC_USER = 1,
NATSPEC_DEV, NATSPEC_DEV,
@ -74,7 +74,7 @@ public:
/// Prerequisite: Successful call to parse or compile. /// Prerequisite: Successful call to parse or compile.
/// @param type The type of the documentation to get. /// @param type The type of the documentation to get.
/// Can be one of 3 types defined at @c documentation_type /// Can be one of 3 types defined at @c documentation_type
std::string const* getJsonDocumentation(enum documentation_type type); std::string const* getJsonDocumentation(enum documentationType type);
/// Returns the previously used scanner, useful for counting lines during error reporting. /// Returns the previously used scanner, useful for counting lines during error reporting.
Scanner const& getScanner() const { return *m_scanner; } Scanner const& getScanner() const { return *m_scanner; }

View File

@ -12,7 +12,7 @@ InterfaceHandler::InterfaceHandler()
} }
std::unique_ptr<std::string> InterfaceHandler::getDocumentation(std::shared_ptr<ContractDefinition> _contractDef, std::unique_ptr<std::string> InterfaceHandler::getDocumentation(std::shared_ptr<ContractDefinition> _contractDef,
enum documentation_type _type) enum documentationType _type)
{ {
switch(_type) switch(_type)
{ {
@ -39,7 +39,7 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(std::shared_ptr<C
Json::Value inputs(Json::arrayValue); Json::Value inputs(Json::arrayValue);
Json::Value outputs(Json::arrayValue); Json::Value outputs(Json::arrayValue);
auto streamVariables = [](std::vector<ASTPointer<VariableDeclaration>> const& _vars) auto populateParameters = [](std::vector<ASTPointer<VariableDeclaration>> const& _vars)
{ {
Json::Value params(Json::arrayValue); Json::Value params(Json::arrayValue);
for (ASTPointer<VariableDeclaration> const& var: _vars) for (ASTPointer<VariableDeclaration> const& var: _vars)
@ -53,8 +53,8 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(std::shared_ptr<C
}; };
method["name"] = f->getName(); method["name"] = f->getName();
method["inputs"] = streamVariables(f->getParameters()); method["inputs"] = populateParameters(f->getParameters());
method["outputs"] = streamVariables(f->getReturnParameters()); method["outputs"] = populateParameters(f->getReturnParameters());
methods.append(method); methods.append(method);
} }
return std::unique_ptr<std::string>(new std::string(m_writer.write(methods))); return std::unique_ptr<std::string>(new std::string(m_writer.write(methods)));

View File

@ -35,7 +35,7 @@ namespace solidity {
// Forward declarations // Forward declarations
class ContractDefinition; class ContractDefinition;
enum documentation_type: unsigned short; enum documentationType: unsigned short;
class InterfaceHandler class InterfaceHandler
{ {
@ -49,7 +49,7 @@ public:
/// @return A unique pointer contained string with the json /// @return A unique pointer contained string with the json
/// representation of provided type /// representation of provided type
std::unique_ptr<std::string> getDocumentation(std::shared_ptr<ContractDefinition> _contractDef, std::unique_ptr<std::string> getDocumentation(std::shared_ptr<ContractDefinition> _contractDef,
enum documentation_type _type); enum documentationType _type);
/// Get the ABI Interface of the contract /// Get the ABI Interface of the contract
/// @param _contractDef The contract definition /// @param _contractDef The contract definition
/// @return A unique pointer contained string with the json /// @return A unique pointer contained string with the json