mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #834 from chriseth/devcorecleanup
Some cleanup regarding libdevcore. Also rename to avoid conflicts.
This commit is contained in:
commit
c3ed550eb6
@ -22,9 +22,9 @@ function(eth_apply TARGET REQUIRED SUBMODULE)
|
||||
|
||||
endif()
|
||||
|
||||
if (${SUBMODULE} STREQUAL "devcore")
|
||||
if (${SUBMODULE} STREQUAL "soldevcore")
|
||||
eth_use(${TARGET} ${REQUIRED} Dev::base)
|
||||
target_link_libraries(${TARGET} devcore)
|
||||
target_link_libraries(${TARGET} soldevcore)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
@ -25,7 +25,7 @@ function(eth_apply TARGET REQUIRED SUBMODULE)
|
||||
endif()
|
||||
|
||||
if (${SUBMODULE} STREQUAL "solidity" OR ${SUBMODULE} STREQUAL "")
|
||||
eth_use(${TARGET} ${REQUIRED} Dev::devcore Solidity::evmasm)
|
||||
eth_use(${TARGET} ${REQUIRED} Dev::soldevcore Solidity::evmasm)
|
||||
target_link_libraries(${TARGET} ${Solidity_SOLIDITY_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
*/
|
||||
/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c
|
||||
/// Originally by René Nyffenegger, modified by some other guy and then devified by Gav Wood.
|
||||
|
||||
#include "Base64.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
|
||||
static inline bool is_base64(byte c)
|
||||
{
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
}
|
||||
|
||||
static inline byte find_base64_char_index(byte c)
|
||||
{
|
||||
if ('A' <= c && c <= 'Z') return c - 'A';
|
||||
else if ('a' <= c && c <= 'z') return c - 'a' + 1 + find_base64_char_index('Z');
|
||||
else if ('0' <= c && c <= '9') return c - '0' + 1 + find_base64_char_index('z');
|
||||
else if (c == '+') return 1 + find_base64_char_index('9');
|
||||
else if (c == '/') return 1 + find_base64_char_index('+');
|
||||
else return 1 + find_base64_char_index('/');
|
||||
}
|
||||
|
||||
string dev::toBase64(bytesConstRef _in)
|
||||
{
|
||||
static const char base64_chars[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
byte char_array_3[3];
|
||||
byte char_array_4[4];
|
||||
|
||||
auto buf = _in.data();
|
||||
auto bufLen = _in.size();
|
||||
|
||||
while (bufLen--)
|
||||
{
|
||||
char_array_3[i++] = *(buf++);
|
||||
if (i == 3)
|
||||
{
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
ret += base64_chars[char_array_4[i]];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
for (j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for (j = 0; j < i + 1; j++)
|
||||
ret += base64_chars[char_array_4[j]];
|
||||
|
||||
while (i++ < 3)
|
||||
ret += '=';
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bytes dev::fromBase64(string const& encoded_string)
|
||||
{
|
||||
auto in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int in_ = 0;
|
||||
byte char_array_3[3];
|
||||
byte char_array_4[4];
|
||||
bytes ret;
|
||||
|
||||
while (in_len-- && encoded_string[in_] != '=' && is_base64(encoded_string[in_]))
|
||||
{
|
||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||
if (i == 4)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
char_array_4[i] = find_base64_char_index(char_array_4[i]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (i = 0; (i < 3); i++)
|
||||
ret.push_back(char_array_3[i]);
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
for (j = i; j < 4; j++)
|
||||
char_array_4[j] = 0;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
char_array_4[j] = find_base64_char_index(char_array_4[j]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (j = 0; j < i - 1; j++)
|
||||
ret.push_back(char_array_3[j]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
*/
|
||||
/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c
|
||||
/// Originally by René Nyffenegger.
|
||||
/// DEVified by Gav Wood.
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "Common.h"
|
||||
#include "FixedHash.h"
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
std::string toBase64(bytesConstRef _in);
|
||||
bytes fromBase64(std::string const& _in);
|
||||
|
||||
|
||||
}
|
@ -9,6 +9,6 @@ file(GLOB HEADERS "*.h")
|
||||
include_directories(..)
|
||||
add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
|
||||
|
||||
eth_use(${EXECUTABLE} REQUIRED Jsoncpp Dev::base)
|
||||
eth_use(${EXECUTABLE} REQUIRED Dev::base)
|
||||
|
||||
install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
|
||||
|
@ -1,27 +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/>.
|
||||
*/
|
||||
/** @file Common.cpp
|
||||
* @author Gav Wood <i@gavwood.com>
|
||||
* @date 2014
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace dev
|
||||
{
|
||||
const u256 Invalid256 = ~(u256)0;
|
||||
}
|
@ -156,7 +156,6 @@ using string32 = std::array<char, 32>;
|
||||
|
||||
// Null/Invalid values for convenience.
|
||||
static const bytes NullBytes;
|
||||
extern const u256 Invalid256;
|
||||
|
||||
/// Interprets @a _u as a two's complement signed number and returns the resulting s256.
|
||||
inline s256 u2s(u256 _u)
|
||||
|
@ -1,50 +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/>.
|
||||
*/
|
||||
/** @file FixedHash.cpp
|
||||
* @author Gav Wood <i@gavwood.com>
|
||||
* @date 2014
|
||||
*/
|
||||
|
||||
#include "FixedHash.h"
|
||||
#include <ctime>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
|
||||
boost::random_device dev::s_fixedHashEngine;
|
||||
|
||||
h128 dev::fromUUID(std::string const& _uuid)
|
||||
{
|
||||
try
|
||||
{
|
||||
return h128(boost::replace_all_copy(_uuid, "-", ""));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return h128();
|
||||
}
|
||||
}
|
||||
|
||||
std::string dev::toUUID(h128 const& _uuid)
|
||||
{
|
||||
std::string ret = toHex(_uuid.ref());
|
||||
for (unsigned i: {20, 16, 12, 8})
|
||||
ret.insert(ret.begin() + i, '-');
|
||||
return ret;
|
||||
}
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <algorithm>
|
||||
#include <boost/random/random_device.hpp>
|
||||
#include <boost/random/uniform_int_distribution.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include "CommonData.h"
|
||||
|
||||
@ -38,8 +36,6 @@ namespace dev
|
||||
template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; };
|
||||
template <> struct StaticLog2<1> { enum { result = 0 }; };
|
||||
|
||||
extern boost::random_device s_fixedHashEngine;
|
||||
|
||||
/// Fixed-size raw-byte array container type, with an API optimised for storing hashes.
|
||||
/// Transparently converts to/from the corresponding arithmetic type; this will
|
||||
/// assume the data contained in the hash is big-endian.
|
||||
@ -150,17 +146,6 @@ public:
|
||||
/// @returns a constant reference to the object's data as an STL array.
|
||||
std::array<byte, N> const& asArray() const { return m_data; }
|
||||
|
||||
/// Populate with random data.
|
||||
template <class Engine>
|
||||
void randomize(Engine& _eng)
|
||||
{
|
||||
for (auto& i: m_data)
|
||||
i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng);
|
||||
}
|
||||
|
||||
/// @returns a random valued object.
|
||||
static FixedHash random() { FixedHash ret; ret.randomize(s_fixedHashEngine); return ret; }
|
||||
|
||||
struct hash
|
||||
{
|
||||
/// Make a hash of the object's data.
|
||||
@ -279,10 +264,6 @@ inline h160 left160(h256 const& _t)
|
||||
return ret;
|
||||
}
|
||||
|
||||
h128 fromUUID(std::string const& _uuid);
|
||||
|
||||
std::string toUUID(h128 const& _uuid);
|
||||
|
||||
inline std::string toString(h256s const& _bs)
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
@ -33,10 +33,6 @@
|
||||
#include "Exceptions.h"
|
||||
#include <json/json.h>
|
||||
|
||||
namespace Json
|
||||
{
|
||||
class Value;
|
||||
}
|
||||
namespace dev
|
||||
{
|
||||
namespace eth
|
||||
|
@ -8,6 +8,6 @@ file(GLOB HEADERS "*.h")
|
||||
|
||||
include_directories(BEFORE ..)
|
||||
add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
|
||||
eth_use(${EXECUTABLE} REQUIRED Dev::devcore)
|
||||
eth_use(${EXECUTABLE} REQUIRED Jsoncpp Dev::soldevcore)
|
||||
|
||||
install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
|
||||
|
@ -15,7 +15,7 @@ file(GLOB HEADERS "*/*.h")
|
||||
include_directories(BEFORE ..)
|
||||
add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
|
||||
|
||||
eth_use(${EXECUTABLE} REQUIRED Dev::devcore Solidity::evmasm)
|
||||
eth_use(${EXECUTABLE} REQUIRED Dev::soldevcore Solidity::evmasm)
|
||||
|
||||
install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
|
||||
|
||||
|
@ -116,7 +116,7 @@ emcmake cmake \
|
||||
-DJSONCPP_INCLUDE_DIR="$WORKSPACE"/jsoncpp/include/ \
|
||||
-DCRYPTOPP_LIBRARY="$WORKSPACE"/cryptopp/src/libcryptlib.a \
|
||||
-DCRYPTOPP_INCLUDE_DIR="$WORKSPACE"/cryptopp/src/ \
|
||||
-DDev_DEVCORE_LIBRARY="$WORKSPACE"/solidity/build/libdevcore/libdevcore.a \
|
||||
-DDev_DEVCORE_LIBRARY="$WORKSPACE"/solidity/build/libdevcore/libsoldevcore.a \
|
||||
-DEth_EVMASM_LIBRARY="$WORKSPACE"/solidity/build/libevmasm/libevmasm.a \
|
||||
-DETH_STATIC=1 -DTESTS=0 \
|
||||
..
|
||||
|
Loading…
Reference in New Issue
Block a user