From 5bb4bfb08b7157ef79aaa673881638c809adf6a7 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 18 Jul 2017 21:05:34 +0100 Subject: [PATCH] Remove unneccesary interface from Natspec --- libsolidity/interface/CompilerStack.cpp | 10 ++++++---- libsolidity/interface/Natspec.cpp | 17 ----------------- libsolidity/interface/Natspec.h | 10 ---------- 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index e25078217..8b08377be 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -451,18 +451,20 @@ Json::Value const& CompilerStack::natspec(Contract const& _contract, Documentati { case DocumentationType::NatspecUser: doc = &_contract.userDocumentation; + // caches the result + if (!*doc) + doc->reset(new Json::Value(Natspec::userDocumentation(*_contract.contract))); break; case DocumentationType::NatspecDev: doc = &_contract.devDocumentation; + // caches the result + if (!*doc) + doc->reset(new Json::Value(Natspec::devDocumentation(*_contract.contract))); break; default: BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal documentation type.")); } - // caches the result - if (!*doc) - doc->reset(new Json::Value(Natspec::documentation(*_contract.contract, _type))); - return *(*doc); } diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 70486e23a..7f7084ef3 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -26,28 +26,11 @@ #include #include #include -#include using namespace std; using namespace dev; using namespace dev::solidity; -Json::Value Natspec::documentation( - ContractDefinition const& _contractDef, - DocumentationType _type -) -{ - switch(_type) - { - case DocumentationType::NatspecUser: - return userDocumentation(_contractDef); - case DocumentationType::NatspecDev: - return devDocumentation(_contractDef); - } - - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type")); -} - Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) { Json::Value doc; diff --git a/libsolidity/interface/Natspec.h b/libsolidity/interface/Natspec.h index bec9acd25..9ac3efea5 100644 --- a/libsolidity/interface/Natspec.h +++ b/libsolidity/interface/Natspec.h @@ -39,7 +39,6 @@ class ContractDefinition; class Type; using TypePointer = std::shared_ptr; struct DocTag; -enum class DocumentationType: uint8_t; enum class DocTagType: uint8_t { @@ -61,15 +60,6 @@ enum class CommentOwner class Natspec { public: - /// Get the given type of documentation - /// @param _contractDef The contract definition - /// @param _type The type of the documentation. Can be one of the - /// types provided by @c DocumentationType - /// @return A JSON representation of provided type - static Json::Value documentation( - ContractDefinition const& _contractDef, - DocumentationType _type - ); /// Get the User documentation of the contract /// @param _contractDef The contract definition /// @return A JSON representation of the contract's user documentation