aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-17 23:55:40 +0800
committerGitHub <noreply@github.com>2016-08-17 23:55:40 +0800
commitc282ab379aac4a6b14f59a957c6261e2edb8b1ce (patch)
treedadf901d13c864ae4f5cb0dbdf1036fc0e33b087
parentb2507e9f105ab701c417f8f2d125edf8f3022698 (diff)
parente5e2597702bcffb52222304638836a1c4302bc77 (diff)
downloaddexon-solidity-c282ab379aac4a6b14f59a957c6261e2edb8b1ce.tar
dexon-solidity-c282ab379aac4a6b14f59a957c6261e2edb8b1ce.tar.gz
dexon-solidity-c282ab379aac4a6b14f59a957c6261e2edb8b1ce.tar.bz2
dexon-solidity-c282ab379aac4a6b14f59a957c6261e2edb8b1ce.tar.lz
dexon-solidity-c282ab379aac4a6b14f59a957c6261e2edb8b1ce.tar.xz
dexon-solidity-c282ab379aac4a6b14f59a957c6261e2edb8b1ce.tar.zst
dexon-solidity-c282ab379aac4a6b14f59a957c6261e2edb8b1ce.zip
Merge pull request #918 from winsvega/solremove4
remove solidity --interface
-rw-r--r--libsolidity/interface/CompilerStack.cpp8
-rw-r--r--libsolidity/interface/CompilerStack.h7
-rw-r--r--libsolidity/interface/InterfaceHandler.cpp70
-rw-r--r--libsolidity/interface/InterfaceHandler.h1
-rw-r--r--solc/CommandLineInterface.cpp11
-rw-r--r--solc/jsonCompiler.cpp1
-rw-r--r--test/libsolidity/SolidityInterface.cpp165
7 files changed, 1 insertions, 262 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index f7982872..0e5ead2b 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -358,11 +358,6 @@ string const& CompilerStack::interface(string const& _contractName) const
return metadata(_contractName, DocumentationType::ABIInterface);
}
-string const& CompilerStack::solidityInterface(string const& _contractName) const
-{
- return metadata(_contractName, DocumentationType::ABISolidityInterface);
-}
-
string const& CompilerStack::metadata(string const& _contractName, DocumentationType _type) const
{
if (!m_parseSuccessful)
@@ -383,9 +378,6 @@ string const& CompilerStack::metadata(string const& _contractName, Documentation
case DocumentationType::ABIInterface:
doc = &currentContract.interface;
break;
- case DocumentationType::ABISolidityInterface:
- doc = &currentContract.solidityInterface;
- break;
default:
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal documentation type."));
}
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h
index a4b8447f..b3c4450c 100644
--- a/libsolidity/interface/CompilerStack.h
+++ b/libsolidity/interface/CompilerStack.h
@@ -63,8 +63,7 @@ enum class DocumentationType: uint8_t
{
NatspecUser = 1,
NatspecDev,
- ABIInterface,
- ABISolidityInterface
+ ABIInterface
};
/**
@@ -167,9 +166,6 @@ public:
/// @returns a string representing the contract interface in JSON.
/// Prerequisite: Successful call to parse or compile.
std::string const& interface(std::string const& _contractName = "") const;
- /// @returns a string representing the contract interface in Solidity.
- /// Prerequisite: Successful call to parse or compile.
- std::string const& solidityInterface(std::string const& _contractName = "") const;
/// @returns a string representing the contract's documentation in JSON.
/// Prerequisite: Successful call to parse or compile.
/// @param type The type of the documentation to get.
@@ -219,7 +215,6 @@ private:
eth::LinkerObject runtimeObject;
eth::LinkerObject cloneObject;
mutable std::unique_ptr<std::string const> interface;
- mutable std::unique_ptr<std::string const> solidityInterface;
mutable std::unique_ptr<std::string const> userDocumentation;
mutable std::unique_ptr<std::string const> devDocumentation;
mutable std::unique_ptr<std::string const> sourceMapping;
diff --git a/libsolidity/interface/InterfaceHandler.cpp b/libsolidity/interface/InterfaceHandler.cpp
index e254137f..f5c10356 100644
--- a/libsolidity/interface/InterfaceHandler.cpp
+++ b/libsolidity/interface/InterfaceHandler.cpp
@@ -21,8 +21,6 @@ string InterfaceHandler::documentation(
return devDocumentation(_contractDef);
case DocumentationType::ABIInterface:
return abiInterface(_contractDef);
- case DocumentationType::ABISolidityInterface:
- return ABISolidityInterface(_contractDef);
}
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type"));
@@ -98,74 +96,6 @@ string InterfaceHandler::abiInterface(ContractDefinition const& _contractDef)
return Json::FastWriter().write(abi);
}
-string InterfaceHandler::ABISolidityInterface(ContractDefinition const& _contractDef)
-{
- string ret = (_contractDef.isLibrary() ? "library " : "contract ") + _contractDef.name() + "{";
-
- auto populateParameters = [](vector<string> const& _paramNames, vector<string> const& _paramTypes)
- {
- string ret = "(";
- for (size_t i = 0; i < _paramNames.size(); ++i)
- ret += _paramTypes[i] + " " + _paramNames[i] + ",";
- if (ret.size() != 1)
- ret.pop_back();
- return ret + ")";
- };
- // If this is a library, include all its enum and struct types. Should be more intelligent
- // in the future and check what is actually used (it might even use types from other libraries
- // or contracts or in the global scope).
- if (_contractDef.isLibrary())
- {
- for (auto const& stru: _contractDef.definedStructs())
- {
- ret += "struct " + stru->name() + "{";
- for (ASTPointer<VariableDeclaration> const& _member: stru->members())
- ret += _member->type()->canonicalName(false) + " " + _member->name() + ";";
- ret += "}";
- }
- for (auto const& enu: _contractDef.definedEnums())
- {
- ret += "enum " + enu->name() + "{";
- for (ASTPointer<EnumValue> const& val: enu->members())
- ret += val->name() + ",";
- if (ret.back() == ',')
- ret.pop_back();
- ret += "}";
- }
- }
- if (_contractDef.constructor())
- {
- auto externalFunction = FunctionType(*_contractDef.constructor()).interfaceFunctionType();
- solAssert(!!externalFunction, "");
- ret +=
- "function " +
- _contractDef.name() +
- populateParameters(
- externalFunction->parameterNames(),
- externalFunction->parameterTypeNames(_contractDef.isLibrary())
- ) +
- ";";
- }
- for (auto const& it: _contractDef.interfaceFunctions())
- {
- ret += "function " + it.second->declaration().name() +
- populateParameters(
- it.second->parameterNames(),
- it.second->parameterTypeNames(_contractDef.isLibrary())
- ) + (it.second->isConstant() ? "constant " : "");
- if (it.second->returnParameterTypes().size())
- ret += "returns" + populateParameters(
- it.second->returnParameterNames(),
- it.second->returnParameterTypeNames(_contractDef.isLibrary())
- );
- else if (ret.back() == ' ')
- ret.pop_back();
- ret += ";";
- }
-
- return ret + "}";
-}
-
string InterfaceHandler::userDocumentation(ContractDefinition const& _contractDef)
{
Json::Value doc;
diff --git a/libsolidity/interface/InterfaceHandler.h b/libsolidity/interface/InterfaceHandler.h
index 3e0a1660..54199e4e 100644
--- a/libsolidity/interface/InterfaceHandler.h
+++ b/libsolidity/interface/InterfaceHandler.h
@@ -73,7 +73,6 @@ public:
/// @param _contractDef The contract definition
/// @return A string with the json representation of the contract's ABI Interface
static std::string abiInterface(ContractDefinition const& _contractDef);
- static std::string ABISolidityInterface(ContractDefinition const& _contractDef);
/// Get the User documentation of the contract
/// @param _contractDef The contract definition
/// @return A string with the json representation of the contract's user documentation
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index d1834794..08c08797 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -65,7 +65,6 @@ namespace solidity
{
static string const g_argAbiStr = "abi";
-static string const g_argSolInterfaceStr = "interface";
static string const g_argSignatureHashes = "hashes";
static string const g_argGas = "gas";
static string const g_argAsmStr = "asm";
@@ -116,7 +115,6 @@ static bool needsHumanTargetedStdout(po::variables_map const& _args)
return false;
for (string const& arg: {
g_argAbiStr,
- g_argSolInterfaceStr,
g_argSignatureHashes,
g_argNatspecUserStr,
g_argAstJson,
@@ -215,11 +213,6 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co
suffix = ".abi";
title = "Contract JSON ABI";
break;
- case DocumentationType::ABISolidityInterface:
- argName = g_argSolInterfaceStr;
- suffix = "_interface.sol";
- title = "Contract Solidity ABI";
- break;
case DocumentationType::NatspecUser:
argName = g_argNatspecUserStr;
suffix = ".docuser";
@@ -461,7 +454,6 @@ Allowed options)",
(g_argRuntimeBinaryStr.c_str(), "Binary of the runtime part of the contracts in hex.")
(g_argCloneBinaryStr.c_str(), "Binary of the clone contracts in hex.")
(g_argAbiStr.c_str(), "ABI specification of the contracts.")
- (g_argSolInterfaceStr.c_str(), "Solidity interface of the contracts.")
(g_argSignatureHashes.c_str(), "Function signature hashes of the contracts.")
(g_argNatspecUserStr.c_str(), "Natspec user documentation of all contracts.")
(g_argNatspecDevStr.c_str(), "Natspec developer documentation of all contracts.")
@@ -649,8 +641,6 @@ void CommandLineInterface::handleCombinedJSON()
for (string const& contractName: contracts)
{
Json::Value contractData(Json::objectValue);
- if (requests.count("interface"))
- contractData["interface"] = m_compiler->solidityInterface(contractName);
if (requests.count("abi"))
contractData["abi"] = m_compiler->interface(contractName);
if (requests.count("bin"))
@@ -907,7 +897,6 @@ void CommandLineInterface::outputCompilationResults()
handleBytecode(contract);
handleSignatureHashes(contract);
handleMeta(DocumentationType::ABIInterface, contract);
- handleMeta(DocumentationType::ABISolidityInterface, contract);
handleMeta(DocumentationType::NatspecDev, contract);
handleMeta(DocumentationType::NatspecUser, contract);
} // end of contracts iteration
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index 0a1b9a87..896a5922 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -207,7 +207,6 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
for (string const& contractName: compiler.contractNames())
{
Json::Value contractData(Json::objectValue);
- contractData["solidityInterface"] = compiler.solidityInterface(contractName);
contractData["interface"] = compiler.interface(contractName);
contractData["bytecode"] = compiler.object(contractName).toHex();
contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex();
diff --git a/test/libsolidity/SolidityInterface.cpp b/test/libsolidity/SolidityInterface.cpp
deleted file mode 100644
index 9a1c104d..00000000
--- a/test/libsolidity/SolidityInterface.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
- */
-/**
- * @author Christian <c@ethdev.com>
- * @date 2015
- * Unit tests for generating source interfaces for Solidity contracts.
- */
-
-#include "../TestHelper.h"
-#include <libsolidity/interface/CompilerStack.h>
-#include <libsolidity/ast/AST.h>
-
-using namespace std;
-
-namespace dev
-{
-namespace solidity
-{
-namespace test
-{
-
-class SolidityInterfaceChecker
-{
-public:
- SolidityInterfaceChecker(): m_compilerStack(false) {}
-
- /// Compiles the given code, generates the interface and parses that again.
- ContractDefinition const& checkInterface(string const& _code, string const& _contractName = "")
- {
- m_code = _code;
- ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse(_code), "Parsing failed");
- m_interface = m_compilerStack.metadata("", DocumentationType::ABISolidityInterface);
- ETH_TEST_REQUIRE_NO_THROW(m_reCompiler.parse(m_interface), "Interface parsing failed");
- return m_reCompiler.contractDefinition(_contractName);
- }
-
- string sourcePart(ASTNode const& _node) const
- {
- SourceLocation location = _node.location();
- BOOST_REQUIRE(!location.isEmpty());
- return m_interface.substr(location.start, location.end - location.start);
- }
-
-protected:
- string m_code;
- string m_interface;
- CompilerStack m_compilerStack;
- CompilerStack m_reCompiler;
-};
-
-BOOST_FIXTURE_TEST_SUITE(SolidityInterface, SolidityInterfaceChecker)
-
-BOOST_AUTO_TEST_CASE(empty_contract)
-{
- ContractDefinition const& contract = checkInterface("contract test {}");
- BOOST_CHECK_EQUAL(sourcePart(contract), "contract test{}");
-}
-
-BOOST_AUTO_TEST_CASE(single_function)
-{
- ContractDefinition const& contract = checkInterface(
- "contract test {\n"
- " function f(uint a) returns(uint d) { return a * 7; }\n"
- "}\n");
- BOOST_REQUIRE_EQUAL(1, contract.definedFunctions().size());
- BOOST_CHECK_EQUAL(sourcePart(*contract.definedFunctions().front()),
- "function f(uint256 a)returns(uint256 d);");
-}
-
-BOOST_AUTO_TEST_CASE(single_constant_function)
-{
- ContractDefinition const& contract = checkInterface(
- "contract test { function f(uint a) constant returns(bytes1 x) { 1==2; } }");
- BOOST_REQUIRE_EQUAL(1, contract.definedFunctions().size());
- BOOST_CHECK_EQUAL(sourcePart(*contract.definedFunctions().front()),
- "function f(uint256 a)constant returns(bytes1 x);");
-}
-
-BOOST_AUTO_TEST_CASE(multiple_functions)
-{
- char const* sourceCode = "contract test {\n"
- " function f(uint a) returns(uint d) { return a * 7; }\n"
- " function g(uint b) returns(uint e) { return b * 8; }\n"
- "}\n";
- ContractDefinition const& contract = checkInterface(sourceCode);
- set<string> expectation({"function f(uint256 a)returns(uint256 d);",
- "function g(uint256 b)returns(uint256 e);"});
- BOOST_REQUIRE_EQUAL(2, contract.definedFunctions().size());
- BOOST_CHECK(expectation == set<string>({sourcePart(*contract.definedFunctions().at(0)),
- sourcePart(*contract.definedFunctions().at(1))}));
-}
-
-BOOST_AUTO_TEST_CASE(exclude_fallback_function)
-{
- char const* sourceCode = "contract test { function() {} }";
- ContractDefinition const& contract = checkInterface(sourceCode);
- BOOST_CHECK_EQUAL(sourcePart(contract), "contract test{}");
-}
-
-BOOST_AUTO_TEST_CASE(events)
-{
- char const* sourceCode = "contract test {\n"
- " function f(uint a) returns(uint d) { return a * 7; }\n"
- " event e1(uint b, address indexed c); \n"
- " event e2(); \n"
- "}\n";
- ContractDefinition const& contract = checkInterface(sourceCode);
- // events should not appear in the Solidity Interface
- BOOST_REQUIRE_EQUAL(0, contract.events().size());
-}
-
-BOOST_AUTO_TEST_CASE(inheritance)
-{
- char const* sourceCode =
- " contract Base { \n"
- " function baseFunction(uint p) returns (uint i) { return p; } \n"
- " event baseEvent(bytes32 indexed evtArgBase); \n"
- " } \n"
- " contract Derived is Base { \n"
- " function derivedFunction(bytes32 p) returns (bytes32 i) { return p; } \n"
- " event derivedEvent(uint indexed evtArgDerived); \n"
- " }";
- ContractDefinition const& contract = checkInterface(sourceCode);
- set<string> expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i);",
- "function derivedFunction(bytes32 p)returns(bytes32 i);"});
- BOOST_REQUIRE_EQUAL(2, contract.definedFunctions().size());
- BOOST_CHECK(expectedFunctions == set<string>({sourcePart(*contract.definedFunctions().at(0)),
- sourcePart(*contract.definedFunctions().at(1))}));
-}
-
-BOOST_AUTO_TEST_CASE(libraries)
-{
- char const* sourceCode = R"(
- library Lib {
- struct Str { uint a; }
- enum E { E1, E2 }
- function f(uint[] x,Str storage y,E z) external;
- }
- )";
- ContractDefinition const& contract = checkInterface(sourceCode);
- BOOST_CHECK(contract.isLibrary());
- set<string> expectedFunctions({"function f(uint256[] x,Lib.Str storage y,Lib.E z);"});
- BOOST_REQUIRE_EQUAL(1, contract.definedFunctions().size());
- BOOST_CHECK(expectedFunctions == set<string>({sourcePart(*contract.definedFunctions().at(0))}));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
-}