Browse Source

fixed the output of the test

cl-refactor
Liana Husikyan 10 years ago
parent
commit
f2502b01f7
  1. 6
      libsolidity/AST.cpp
  2. 3
      libsolidity/AST.h
  3. 14
      libsolidity/InterfaceHandler.cpp
  4. 19
      test/libsolidity/SolidityABIJSON.cpp

6
libsolidity/AST.cpp

@ -124,6 +124,12 @@ FunctionDefinition const* ContractDefinition::getConstructor() const
return nullptr;
}
FixedHash<4> ContractDefinition::getConstructorsInterface() const
{
return FixedHash<4>(dev::sha3(getConstructor()->externalSignature()));
//return hash;
}
FunctionDefinition const* ContractDefinition::getFallbackFunction() const
{
for (ContractDefinition const* contract: getLinearizedBaseContracts())

3
libsolidity/AST.h

@ -281,6 +281,9 @@ public:
/// Returns the fallback function or nullptr if no fallback function was specified.
FunctionDefinition const* getFallbackFunction() const;
///@returns hash of the constructor
FixedHash<4> getConstructorsInterface() const;
private:
/// Checks that two functions defined in this contract with the same name have different
/// arguments and that there is at most one constructor.

14
libsolidity/InterfaceHandler.cpp

@ -38,7 +38,17 @@ std::unique_ptr<std::string> InterfaceHandler::getDocumentation(ContractDefiniti
std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef)
{
Json::Value abi(Json::arrayValue);
for (auto const& it: _contractDef.getInterfaceFunctions())
auto allFunctions = _contractDef.getInterfaceFunctions();
FunctionTypePointer functionTypePointer = nullptr;
if (_contractDef.getConstructor())
{
functionTypePointer = make_shared<FunctionType>(*_contractDef.getConstructor(), false);
allFunctions.insert(make_pair(_contractDef.getConstructorsInterface(), functionTypePointer));
}
//allFunctions.insert(_contractDef.getConstructor());
for (auto it: allFunctions)
{
auto populateParameters = [](vector<string> const& _paramNames, vector<string> const& _paramTypes)
{
@ -55,7 +65,7 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
};
Json::Value method;
method["type"] = "function";
method["type"] = (functionTypePointer == it.second ? "constructor" : "function");
method["name"] = it.second->getDeclaration().getName();
method["constant"] = it.second->isConstant();
method["inputs"] = populateParameters(it.second->getParameterNames(),

19
test/libsolidity/SolidityABIJSON.cpp

@ -499,19 +499,18 @@ BOOST_AUTO_TEST_CASE(constructor_abi)
{
char const* sourceCode = R"(
contract test {
function test() {
function test() {
}
})";
char const* interface = R"("
[
{
"constant" : false,
"inputs" : [],
"name" : "test",
"outputs" : [],
"type" : "constructor"
}
char const* interface = R"([
{
"constant" : false,
"inputs" : [],
"name" : "test",
"outputs" : [],
"type" : "constructor"
}
])";
checkInterface(sourceCode, interface);
}

Loading…
Cancel
Save