diff options
author | Gav Wood <i@gavwood.com> | 2015-01-09 07:22:06 +0800 |
---|---|---|
committer | Gav Wood <i@gavwood.com> | 2015-01-09 07:22:06 +0800 |
commit | ffce12b7ee412cbd29dd0873a3e894dd7133ca4e (patch) | |
tree | 867881a37367a42b910a6182499054d8ae127170 /InterfaceHandler.cpp | |
parent | d18fa27b6a48540298e835ad324152566586c65c (diff) | |
download | dexon-solidity-ffce12b7ee412cbd29dd0873a3e894dd7133ca4e.tar dexon-solidity-ffce12b7ee412cbd29dd0873a3e894dd7133ca4e.tar.gz dexon-solidity-ffce12b7ee412cbd29dd0873a3e894dd7133ca4e.tar.bz2 dexon-solidity-ffce12b7ee412cbd29dd0873a3e894dd7133ca4e.tar.lz dexon-solidity-ffce12b7ee412cbd29dd0873a3e894dd7133ca4e.tar.xz dexon-solidity-ffce12b7ee412cbd29dd0873a3e894dd7133ca4e.tar.zst dexon-solidity-ffce12b7ee412cbd29dd0873a3e894dd7133ca4e.zip |
Basic logging in Solidity (though no tests yet).
Diffstat (limited to 'InterfaceHandler.cpp')
-rw-r--r-- | InterfaceHandler.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/InterfaceHandler.cpp b/InterfaceHandler.cpp index 224234cb..06b9824c 100644 --- a/InterfaceHandler.cpp +++ b/InterfaceHandler.cpp @@ -2,6 +2,7 @@ #include <libsolidity/InterfaceHandler.h> #include <libsolidity/AST.h> #include <libsolidity/CompilerStack.h> +using namespace std; namespace dev { @@ -26,6 +27,8 @@ std::unique_ptr<std::string> InterfaceHandler::getDocumentation(ContractDefiniti return getDevDocumentation(_contractDef); case DocumentationType::ABI_INTERFACE: return getABIInterface(_contractDef); + case DocumentationType::ABI_SOLIDITY_INTERFACE: + return getABISolidityInterface(_contractDef); } BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type")); @@ -64,6 +67,28 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio return std::unique_ptr<std::string>(new std::string(m_writer.write(methods))); } +unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef) +{ + string ret = "contract " + _contractDef.getName() + "{"; + for (FunctionDefinition const* f: _contractDef.getInterfaceFunctions()) + { + auto populateParameters = [](vector<ASTPointer<VariableDeclaration>> const& _vars) + { + string r = ""; + for (ASTPointer<VariableDeclaration> const& var: _vars) + r += (r.size() ? "," : "(") + var->getType()->toString() + " " + var->getName(); + return r.size() ? r + ")" : "()"; + }; + ret += "function " + f->getName() + populateParameters(f->getParameters()) + (f->isDeclaredConst() ? "constant " : ""); + if (f->getReturnParameters().size()) + ret += "returns" + populateParameters(f->getReturnParameters()); + else if (ret.back() == ' ') + ret.pop_back(); + ret += "{}"; + } + return unique_ptr<string>(new string(ret + "}")); +} + std::unique_ptr<std::string> InterfaceHandler::getUserDocumentation(ContractDefinition const& _contractDef) { Json::Value doc; |