aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-06-10 17:25:59 +0800
committerchriseth <c@ethdev.com>2015-06-10 17:25:59 +0800
commit3588709e4e89de0ad5428a28209f699100e8ebc3 (patch)
treed829d6294949bf1c94b73c1666ba930bb8d29bc8
parentc447245cc5c8f50d76d927f32ba68ccc2c981627 (diff)
parentf5808185f084c17ea19a85af93fdf80e38d53b73 (diff)
downloaddexon-solidity-3588709e4e89de0ad5428a28209f699100e8ebc3.tar.gz
dexon-solidity-3588709e4e89de0ad5428a28209f699100e8ebc3.tar.zst
dexon-solidity-3588709e4e89de0ad5428a28209f699100e8ebc3.zip
Merge pull request #2126 from LianaHus/sol_Natspec_warnings_instead_of_exceptions
Some style fixes.
-rw-r--r--InterfaceHandler.cpp111
-rw-r--r--InterfaceHandler.h48
2 files changed, 94 insertions, 65 deletions
diff --git a/InterfaceHandler.cpp b/InterfaceHandler.cpp
index 9a2acd5b..a9d54cdc 100644
--- a/InterfaceHandler.cpp
+++ b/InterfaceHandler.cpp
@@ -16,8 +16,10 @@ InterfaceHandler::InterfaceHandler()
m_lastTag = DocTagType::None;
}
-std::unique_ptr<std::string> InterfaceHandler::getDocumentation(ContractDefinition const& _contractDef,
- DocumentationType _type)
+unique_ptr<string> InterfaceHandler::getDocumentation(
+ ContractDefinition const& _contractDef,
+ DocumentationType _type
+)
{
switch(_type)
{
@@ -35,7 +37,7 @@ std::unique_ptr<std::string> InterfaceHandler::getDocumentation(ContractDefiniti
return nullptr;
}
-std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef)
+unique_ptr<string> InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef)
{
Json::Value abi(Json::arrayValue);
@@ -101,7 +103,7 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
event["inputs"] = params;
abi.append(event);
}
- return std::unique_ptr<std::string>(new std::string(Json::FastWriter().write(abi)));
+ return unique_ptr<string>(new string(Json::FastWriter().write(abi)));
}
unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef)
@@ -141,7 +143,7 @@ unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition
return unique_ptr<string>(new string(ret + "}"));
}
-std::unique_ptr<std::string> InterfaceHandler::getUserDocumentation(ContractDefinition const& _contractDef)
+unique_ptr<string> InterfaceHandler::getUserDocumentation(ContractDefinition const& _contractDef)
{
Json::Value doc;
Json::Value methods(Json::objectValue);
@@ -163,10 +165,10 @@ std::unique_ptr<std::string> InterfaceHandler::getUserDocumentation(ContractDefi
}
doc["methods"] = methods;
- return std::unique_ptr<std::string>(new std::string(Json::FastWriter().write(doc)));
+ return unique_ptr<string>(new string(Json::FastWriter().write(doc)));
}
-std::unique_ptr<std::string> InterfaceHandler::getDevDocumentation(ContractDefinition const& _contractDef)
+unique_ptr<string> InterfaceHandler::getDevDocumentation(ContractDefinition const& _contractDef)
{
// LTODO: Somewhere in this function warnings for mismatch of param names
// should be thrown
@@ -203,7 +205,7 @@ std::unique_ptr<std::string> InterfaceHandler::getDevDocumentation(ContractDefin
method["author"] = m_author;
Json::Value params(Json::objectValue);
- std::vector<std::string> paramNames = it.second->getParameterNames();
+ vector<string> paramNames = it.second->getParameterNames();
for (auto const& pair: m_params)
{
if (find(paramNames.begin(), paramNames.end(), pair.first) == paramNames.end())
@@ -227,7 +229,7 @@ std::unique_ptr<std::string> InterfaceHandler::getDevDocumentation(ContractDefin
}
doc["methods"] = methods;
- return std::unique_ptr<std::string>(new std::string(Json::FastWriter().write(doc)));
+ return unique_ptr<string>(new string(Json::FastWriter().write(doc)));
}
/* -- private -- */
@@ -244,48 +246,56 @@ void InterfaceHandler::resetDev()
m_params.clear();
}
-static inline std::string::const_iterator skipLineOrEOS(std::string::const_iterator _nlPos,
- std::string::const_iterator _end)
+static inline string::const_iterator skipLineOrEOS(
+ string::const_iterator _nlPos,
+ string::const_iterator _end
+)
{
return (_nlPos == _end) ? _end : ++_nlPos;
}
-std::string::const_iterator InterfaceHandler::parseDocTagLine(std::string::const_iterator _pos,
- std::string::const_iterator _end,
- std::string& _tagString,
- DocTagType _tagType,
- bool _appending)
+string::const_iterator InterfaceHandler::parseDocTagLine(
+ string::const_iterator _pos,
+ string::const_iterator _end,
+ string& _tagString,
+ DocTagType _tagType,
+ bool _appending
+)
{
- auto nlPos = std::find(_pos, _end, '\n');
+ auto nlPos = find(_pos, _end, '\n');
if (_appending && _pos < _end && *_pos != ' ')
_tagString += " ";
- std::copy(_pos, nlPos, back_inserter(_tagString));
+ copy(_pos, nlPos, back_inserter(_tagString));
m_lastTag = _tagType;
return skipLineOrEOS(nlPos, _end);
}
-std::string::const_iterator InterfaceHandler::parseDocTagParam(std::string::const_iterator _pos,
- std::string::const_iterator _end)
+string::const_iterator InterfaceHandler::parseDocTagParam(
+ string::const_iterator _pos,
+ string::const_iterator _end
+)
{
// find param name
- auto currPos = std::find(_pos, _end, ' ');
+ auto currPos = find(_pos, _end, ' ');
if (currPos == _end)
- BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("End of param name not found" + std::string(_pos, _end)));
+ BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("End of param name not found" + string(_pos, _end)));
- auto paramName = std::string(_pos, currPos);
+ auto paramName = string(_pos, currPos);
currPos += 1;
- auto nlPos = std::find(currPos, _end, '\n');
- auto paramDesc = std::string(currPos, nlPos);
- m_params.push_back(std::make_pair(paramName, paramDesc));
+ auto nlPos = find(currPos, _end, '\n');
+ auto paramDesc = string(currPos, nlPos);
+ m_params.push_back(make_pair(paramName, paramDesc));
m_lastTag = DocTagType::Param;
return skipLineOrEOS(nlPos, _end);
}
-std::string::const_iterator InterfaceHandler::appendDocTagParam(std::string::const_iterator _pos,
- std::string::const_iterator _end)
+string::const_iterator InterfaceHandler::appendDocTagParam(
+ string::const_iterator _pos,
+ string::const_iterator _end
+)
{
// Should never be called with an empty vector
solAssert(!m_params.empty(), "Internal: Tried to append to empty parameter");
@@ -293,18 +303,20 @@ std::string::const_iterator InterfaceHandler::appendDocTagParam(std::string::con
auto pair = m_params.back();
if (_pos < _end && *_pos != ' ')
pair.second += " ";
- auto nlPos = std::find(_pos, _end, '\n');
- std::copy(_pos, nlPos, back_inserter(pair.second));
+ auto nlPos = find(_pos, _end, '\n');
+ copy(_pos, nlPos, back_inserter(pair.second));
m_params.at(m_params.size() - 1) = pair;
return skipLineOrEOS(nlPos, _end);
}
-std::string::const_iterator InterfaceHandler::parseDocTag(std::string::const_iterator _pos,
- std::string::const_iterator _end,
- std::string const& _tag,
- CommentOwner _owner)
+string::const_iterator InterfaceHandler::parseDocTag(
+ string::const_iterator _pos,
+ string::const_iterator _end,
+ string const& _tag,
+ CommentOwner _owner
+)
{
// LTODO: need to check for @(start of a tag) between here and the end of line
// for all cases. Also somehow automate list of acceptable tags for each
@@ -345,9 +357,11 @@ std::string::const_iterator InterfaceHandler::parseDocTag(std::string::const_ite
return appendDocTag(_pos, _end, _owner);
}
-std::string::const_iterator InterfaceHandler::appendDocTag(std::string::const_iterator _pos,
- std::string::const_iterator _end,
- CommentOwner _owner)
+string::const_iterator InterfaceHandler::appendDocTag(
+ string::const_iterator _pos,
+ string::const_iterator _end,
+ CommentOwner _owner
+)
{
switch (m_lastTag)
{
@@ -379,33 +393,36 @@ std::string::const_iterator InterfaceHandler::appendDocTag(std::string::const_it
}
}
-static inline std::string::const_iterator getFirstSpaceOrNl(std::string::const_iterator _pos,
- std::string::const_iterator _end)
+static inline string::const_iterator getFirstSpaceOrNl(
+ string::const_iterator _pos,
+ string::const_iterator _end
+)
{
- auto spacePos = std::find(_pos, _end, ' ');
- auto nlPos = std::find(_pos, _end, '\n');
+ auto spacePos = find(_pos, _end, ' ');
+ auto nlPos = find(_pos, _end, '\n');
return (spacePos < nlPos) ? spacePos : nlPos;
}
-void InterfaceHandler::parseDocString(std::string const& _string, CommentOwner _owner)
+void InterfaceHandler::parseDocString(string const& _string, CommentOwner _owner)
{
auto currPos = _string.begin();
auto end = _string.end();
while (currPos != end)
{
- auto tagPos = std::find(currPos, end, '@');
- auto nlPos = std::find(currPos, end, '\n');
+ auto tagPos = find(currPos, end, '@');
+ auto nlPos = find(currPos, end, '\n');
if (tagPos != end && tagPos < nlPos)
{
// we found a tag
auto tagNameEndPos = getFirstSpaceOrNl(tagPos, end);
if (tagNameEndPos == end)
- BOOST_THROW_EXCEPTION(DocstringParsingError() <<
- errinfo_comment("End of tag " + std::string(tagPos, tagNameEndPos) + "not found"));
+ BOOST_THROW_EXCEPTION(
+ DocstringParsingError() <<
+ errinfo_comment("End of tag " + string(tagPos, tagNameEndPos) + "not found"));
- currPos = parseDocTag(tagNameEndPos + 1, end, std::string(tagPos + 1, tagNameEndPos), _owner);
+ currPos = parseDocTag(tagNameEndPos + 1, end, string(tagPos + 1, tagNameEndPos), _owner);
}
else if (m_lastTag != DocTagType::None) // continuation of the previous tag
currPos = appendDocTag(currPos, end, _owner);
diff --git a/InterfaceHandler.h b/InterfaceHandler.h
index 40518189..ca9807d7 100644
--- a/InterfaceHandler.h
+++ b/InterfaceHandler.h
@@ -67,8 +67,10 @@ public:
/// types provided by @c DocumentationType
/// @return A unique pointer contained string with the json
/// representation of provided type
- std::unique_ptr<std::string> getDocumentation(ContractDefinition const& _contractDef,
- DocumentationType _type);
+ std::unique_ptr<std::string> getDocumentation(
+ ContractDefinition const& _contractDef,
+ DocumentationType _type
+ );
/// Get the ABI Interface of the contract
/// @param _contractDef The contract definition
/// @return A unique pointer contained string with the json
@@ -90,23 +92,33 @@ private:
void resetUser();
void resetDev();
- std::string::const_iterator parseDocTagLine(std::string::const_iterator _pos,
- std::string::const_iterator _end,
- std::string& _tagString,
- DocTagType _tagType,
- bool _appending);
- std::string::const_iterator parseDocTagParam(std::string::const_iterator _pos,
- std::string::const_iterator _end);
- std::string::const_iterator appendDocTagParam(std::string::const_iterator _pos,
- std::string::const_iterator _end);
+ std::string::const_iterator parseDocTagLine(
+ std::string::const_iterator _pos,
+ std::string::const_iterator _end,
+ std::string& _tagString,
+ DocTagType _tagType,
+ bool _appending
+ );
+ std::string::const_iterator parseDocTagParam(
+ std::string::const_iterator _pos,
+ std::string::const_iterator _end
+ );
+ std::string::const_iterator appendDocTagParam(
+ std::string::const_iterator _pos,
+ std::string::const_iterator _end
+ );
void parseDocString(std::string const& _string, CommentOwner _owner);
- std::string::const_iterator appendDocTag(std::string::const_iterator _pos,
- std::string::const_iterator _end,
- CommentOwner _owner);
- std::string::const_iterator parseDocTag(std::string::const_iterator _pos,
- std::string::const_iterator _end,
- std::string const& _tag,
- CommentOwner _owner);
+ std::string::const_iterator appendDocTag(
+ std::string::const_iterator _pos,
+ std::string::const_iterator _end,
+ CommentOwner _owner
+ );
+ std::string::const_iterator parseDocTag(
+ std::string::const_iterator _pos,
+ std::string::const_iterator _end,
+ std::string const& _tag,
+ CommentOwner _owner
+ );
// internal state
DocTagType m_lastTag;