From 638656a5970ed0d04f7074b30cb4d5bea8dd02ad Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 27 Jun 2013 13:41:20 -0700 Subject: [PATCH] Put modules in ripple namespace --- BeastConfig.h | 2 - Builds/VisualStudio2012/RippleD.props | 2 +- Builds/VisualStudio2012/RippleD.vcxproj | 1 + .../VisualStudio2012/RippleD.vcxproj.filters | 6 + SConstruct | 5 +- modules/ripple_app/ripple_app.cpp | 46 ++++-- .../containers/ripple_RangeSetUnitTests.cpp | 3 + modules/ripple_basics/ripple_basics.cpp | 10 +- modules/ripple_basics/ripple_basics.h | 7 +- .../system/ripple_BoostIncludes.h | 33 +++++ .../ripple_StringUtilitiesUnitTests.cpp | 2 + .../ripple_LoadFeeTrackUnitTests.cpp | 2 + modules/ripple_core/ripple_core.cpp | 4 - modules/ripple_core/ripple_core.h | 4 - .../ripple_CKeyDeterministicUnitTests.cpp | 2 + .../ripple_RippleAddressUnitTests.cpp | 2 + .../protocol/ripple_STAmountUnitTests.cpp | 135 ++++++++++-------- .../ripple_SerializedObjectUnitTests.cpp | 2 + .../protocol/ripple_SerializerUnitTests.cpp | 2 + modules/ripple_data/ripple_data.cpp | 4 - modules/ripple_data/ripple_data.h | 57 -------- modules/ripple_json/ripple_json.cpp | 4 - modules/ripple_json/ripple_json.h | 6 +- .../autosocket/ripple_AutoSocket.cpp | 4 - .../autosocket/ripple_AutoSocket.h | 8 -- .../autosocket/ripple_LogWebsockets.cpp | 32 ----- src/cpp/ripple/LedgerUnitTests.cpp | 2 + src/cpp/ripple/main.cpp | 2 +- src/cpp/ripple/ripple_LedgerEntrySet.h | 12 -- src/cpp/ripple/ripple_PathRequest.h | 2 - .../ripple_ProofOfWorkFactoryUnitTests.cpp | 2 + src/cpp/ripple/ripple_SHAMapSyncUnitTests.cpp | 7 + src/cpp/ripple/ripple_SHAMapUnitTests.cpp | 15 +- .../ripple_SerializedTransactionUnitTests.cpp | 2 + src/cpp/ripple/ripple_SqliteDatabase.h | 3 - 35 files changed, 198 insertions(+), 234 deletions(-) create mode 100644 modules/ripple_basics/system/ripple_BoostIncludes.h diff --git a/BeastConfig.h b/BeastConfig.h index 2d08bcb6e6..29fd836456 100644 --- a/BeastConfig.h +++ b/BeastConfig.h @@ -20,6 +20,4 @@ //#define BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES #endif -#define RIPPLE_USE_NAMESPACE 0 - #endif diff --git a/Builds/VisualStudio2012/RippleD.props b/Builds/VisualStudio2012/RippleD.props index 04758bdfe3..e97a5bdc9b 100644 --- a/Builds/VisualStudio2012/RippleD.props +++ b/Builds/VisualStudio2012/RippleD.props @@ -12,7 +12,7 @@ - BOOST_TEST_ALTERNATIVE_INIT_API;BOOST_TEST_NO_MAIN;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + _WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) true Level3 $(RepoDir);$(RepoDir)\src\cpp\protobuf\src;$(RepoDir)\src\cpp\protobuf\vsprojects;$(RepoDir)\build\proto;$(RepoDir)\Subtrees;$(RepoDir)\Subtrees\leveldb;$(RepoDir)\Subtrees\leveldb\include;$(RepoDir)\Subtrees\beast;%(AdditionalIncludeDirectories) diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj index 785a899b44..8b45e3d6b0 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj +++ b/Builds/VisualStudio2012/RippleD.vcxproj @@ -1593,6 +1593,7 @@ + diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters index 7f3718d115..8fcae53f3a 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters @@ -151,6 +151,9 @@ {bb14df5d-f96f-4572-9e79-5e330eed30c9} + + {2c4e5c32-0aab-4650-b9a1-22708e9ddc92} + @@ -1785,6 +1788,9 @@ 1. Modules\ripple_core\functional + + 1. Modules\ripple_basics\system + diff --git a/SConstruct b/SConstruct index 6d272413a7..6a3ce28715 100644 --- a/SConstruct +++ b/SConstruct @@ -9,8 +9,6 @@ import os import platform import re -LevelDB = bool(1) - OSX = bool(platform.mac_ver()[0]) FreeBSD = bool('FreeBSD' == platform.system()) Linux = bool('Linux' == platform.system()) @@ -162,11 +160,10 @@ env.Append( ) DEBUGFLAGS = ['-g', '-DDEBUG'] -BOOSTFLAGS = ['-DBOOST_TEST_DYN_LINK', '-DBOOST_FILESYSTEM_NO_DEPRECATED'] env.Append(LINKFLAGS = ['-rdynamic', '-pthread']) env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts']) -env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS) +env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+DEBUGFLAGS) # RTTI is required for Beast and CountedObject. # diff --git a/modules/ripple_app/ripple_app.cpp b/modules/ripple_app/ripple_app.cpp index 966044ab6b..25f12de9ab 100644 --- a/modules/ripple_app/ripple_app.cpp +++ b/modules/ripple_app/ripple_app.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -70,12 +69,6 @@ #include #include -#if ! defined (RIPPLE_MAIN_PART) || RIPPLE_MAIN_PART == 1 -#include -#endif - -#include - #include #include #include @@ -109,10 +102,8 @@ //------------------------------------------------------------------------------ -#if RIPPLE_USE_NAMESPACE namespace ripple { -#endif // VFALCO NOTE The order of these includes is critical, since they do not // include their own dependencies. This is what allows us to @@ -252,16 +243,30 @@ namespace ripple #include "src/cpp/ripple/WSHandler.h" #include "src/cpp/ripple/WalletAddTransactor.h" -#if RIPPLE_USE_NAMESPACE } -#endif //------------------------------------------------------------------------------ -#if RIPPLE_USE_NAMESPACE +// VFALCO TODO Move this to an appropriate header +namespace boost +{ + template <> + struct range_mutable_iterator + { + typedef ripple::LedgerEntrySet::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef ripple::LedgerEntrySet::const_iterator type; + }; +} + +//------------------------------------------------------------------------------ + namespace ripple { -#endif //------------------------------------------------------------------------------ @@ -415,9 +420,7 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength) //------------------------------------------------------------------------------ -#if RIPPLE_USE_NAMESPACE } -#endif //------------------------------------------------------------------------------ @@ -435,6 +438,19 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength) #include "src/cpp/ripple/ripple_ProofOfWorkFactoryUnitTests.cpp" #include "src/cpp/ripple/ripple_SerializedTransactionUnitTests.cpp" +//------------------------------------------------------------------------------ + +namespace ripple +{ + extern int rippleMain (int argc, char** argv); +} + +// Must be outside the namespace for obvious reasons +int main (int argc, char** argv) +{ + return ripple::rippleMain (argc, argv); +} + #endif //------------------------------------------------------------------------------ diff --git a/modules/ripple_basics/containers/ripple_RangeSetUnitTests.cpp b/modules/ripple_basics/containers/ripple_RangeSetUnitTests.cpp index 2a703a0dd7..87a50f2d03 100644 --- a/modules/ripple_basics/containers/ripple_RangeSetUnitTests.cpp +++ b/modules/ripple_basics/containers/ripple_RangeSetUnitTests.cpp @@ -3,10 +3,13 @@ Copyright (c) 2011-2013, OpenCoin, Inc. */ //============================================================================== + BOOST_AUTO_TEST_SUITE (RangeSet_suite) BOOST_AUTO_TEST_CASE (RangeSet_test) { + using namespace ripple; + WriteLog (lsTRACE, RangeSet) << "RangeSet test begins"; RangeSet r1, r2; diff --git a/modules/ripple_basics/ripple_basics.cpp b/modules/ripple_basics/ripple_basics.cpp index c97f44ca4a..7ed9355d59 100644 --- a/modules/ripple_basics/ripple_basics.cpp +++ b/modules/ripple_basics/ripple_basics.cpp @@ -34,6 +34,8 @@ #include // VFALCO NOTE just for parseIpPort (!) #include +//#include + // VFALCO TODO Replace OpenSSL randomness with a dependency-free implementation // Perhaps Schneier's Fortuna or a variant. Abstract the collection of // entropy and provide OS-specific implementation. We can re-use the @@ -50,10 +52,12 @@ #include // for ripple_ByteOrder.cpp #endif -#if RIPPLE_USE_NAMESPACE +// This brings in the definitions for the Unit Test Framework. +// +#include + namespace ripple { -#endif #include "containers/ripple_RangeSet.cpp" #include "containers/ripple_TaggedCache.cpp" @@ -74,9 +78,7 @@ namespace ripple #include "types/ripple_UInt256.cpp" -#if RIPPLE_USE_NAMESPACE } -#endif // These must be outside the namespace (because of boost) #include "containers/ripple_RangeSetUnitTests.cpp" diff --git a/modules/ripple_basics/ripple_basics.h b/modules/ripple_basics/ripple_basics.h index 4bcde707ce..6447fa9a94 100644 --- a/modules/ripple_basics/ripple_basics.h +++ b/modules/ripple_basics/ripple_basics.h @@ -38,11 +38,12 @@ #error Ripple requires Boost version 1.47 or later #endif +#include "system/ripple_BoostIncludes.h" + // VFALCO TODO Move all boost includes into ripple_BoostHeaders.h // #include #include -#include #include #include #include @@ -79,10 +80,8 @@ #include "../ripple_json/ripple_json.h" -#if RIPPLE_USE_NAMESPACE namespace ripple { -#endif #include "utility/ripple_IntegerTypes.h" // must come first #include "utility/ripple_Log.h" // Needed by others @@ -110,8 +109,6 @@ namespace ripple #include "containers/ripple_SecureAllocator.h" #include "containers/ripple_TaggedCache.h" -#if RIPPLE_USE_NAMESPACE } -#endif #endif diff --git a/modules/ripple_basics/system/ripple_BoostIncludes.h b/modules/ripple_basics/system/ripple_BoostIncludes.h new file mode 100644 index 0000000000..9d483c881a --- /dev/null +++ b/modules/ripple_basics/system/ripple_BoostIncludes.h @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. +*/ +//============================================================================== + +#ifndef RIPPLE_BOOSTINCLUDES_RIPPLEHEADER +#define RIPPLE_BOOSTINCLUDES_RIPPLEHEADER + +// All Boost includes used throughout Ripple. +// +// This shows all the dependencies in one place. Please do not add +// boost includes anywhere else in the source code. If possible, do +// not add any more includes. +// +// A long term goal is to reduce and hopefully eliminate the usage of boost. +// + +#define BOOST_FILESYSTEM_NO_DEPRECATED + +#include + +//------------------------------------------------------------------------------ + +// Boost Unit Test Framework + +#define BOOST_TEST_NO_LIB +#define BOOST_TEST_ALTERNATIVE_INIT_API +#define BOOST_TEST_NO_MAIN + +#include + +#endif diff --git a/modules/ripple_basics/utility/ripple_StringUtilitiesUnitTests.cpp b/modules/ripple_basics/utility/ripple_StringUtilitiesUnitTests.cpp index d11d0d531e..f16fc80c8a 100644 --- a/modules/ripple_basics/utility/ripple_StringUtilitiesUnitTests.cpp +++ b/modules/ripple_basics/utility/ripple_StringUtilitiesUnitTests.cpp @@ -8,6 +8,8 @@ BOOST_AUTO_TEST_SUITE ( Utils) BOOST_AUTO_TEST_CASE ( ParseUrl ) { + using namespace ripple; + std::string strScheme; std::string strDomain; int iPort; diff --git a/modules/ripple_core/functional/ripple_LoadFeeTrackUnitTests.cpp b/modules/ripple_core/functional/ripple_LoadFeeTrackUnitTests.cpp index 02207ad9e3..167c08be3a 100644 --- a/modules/ripple_core/functional/ripple_LoadFeeTrackUnitTests.cpp +++ b/modules/ripple_core/functional/ripple_LoadFeeTrackUnitTests.cpp @@ -7,6 +7,8 @@ BOOST_AUTO_TEST_SUITE (LoadManager_test) BOOST_AUTO_TEST_CASE (LoadFeeTrack_test) { + using namespace ripple; + WriteLog (lsDEBUG, LoadManager) << "Running load fee track test"; Config d; // get a default configuration object diff --git a/modules/ripple_core/ripple_core.cpp b/modules/ripple_core/ripple_core.cpp index 3790b97365..9fe879f32c 100644 --- a/modules/ripple_core/ripple_core.cpp +++ b/modules/ripple_core/ripple_core.cpp @@ -19,10 +19,8 @@ #include #include -#if RIPPLE_USE_NAMESPACE namespace ripple { -#endif #include "functional/ripple_Config.cpp" #include "functional/ripple_LoadFeeTrack.h" // private @@ -32,9 +30,7 @@ namespace ripple #include "functional/ripple_LoadEvent.cpp" #include "functional/ripple_LoadMonitor.cpp" -#if RIPPLE_USE_NAMESPACE } -#endif // These must be outside the namespace diff --git a/modules/ripple_core/ripple_core.h b/modules/ripple_core/ripple_core.h index 307af69651..6302e3dd07 100644 --- a/modules/ripple_core/ripple_core.h +++ b/modules/ripple_core/ripple_core.h @@ -32,10 +32,8 @@ #include #include -#if RIPPLE_USE_NAMESPACE namespace ripple { -#endif // VFALCO NOTE Indentation shows dependency hierarchy // @@ -46,8 +44,6 @@ namespace ripple /*.*/#include "functional/ripple_Job.h" /**/#include "functional/ripple_JobQueue.h" -#if RIPPLE_USE_NAMESPACE } -#endif #endif diff --git a/modules/ripple_data/crypto/ripple_CKeyDeterministicUnitTests.cpp b/modules/ripple_data/crypto/ripple_CKeyDeterministicUnitTests.cpp index c4e8be145b..0f37dd795c 100644 --- a/modules/ripple_data/crypto/ripple_CKeyDeterministicUnitTests.cpp +++ b/modules/ripple_data/crypto/ripple_CKeyDeterministicUnitTests.cpp @@ -7,6 +7,8 @@ BOOST_AUTO_TEST_SUITE (DeterministicKeys_test) BOOST_AUTO_TEST_CASE (DeterminsticKeys_test1) { + using namespace ripple; + Log (lsDEBUG) << "Beginning deterministic key test"; uint128 seed1, seed2; diff --git a/modules/ripple_data/protocol/ripple_RippleAddressUnitTests.cpp b/modules/ripple_data/protocol/ripple_RippleAddressUnitTests.cpp index a686e1080d..b35acb09d0 100644 --- a/modules/ripple_data/protocol/ripple_RippleAddressUnitTests.cpp +++ b/modules/ripple_data/protocol/ripple_RippleAddressUnitTests.cpp @@ -7,6 +7,8 @@ BOOST_AUTO_TEST_SUITE (ripple_address) BOOST_AUTO_TEST_CASE ( check_crypto ) { + using namespace ripple; + // Construct a seed. RippleAddress naSeed; diff --git a/modules/ripple_data/protocol/ripple_STAmountUnitTests.cpp b/modules/ripple_data/protocol/ripple_STAmountUnitTests.cpp index 3507f48b0b..fdc0960ef2 100644 --- a/modules/ripple_data/protocol/ripple_STAmountUnitTests.cpp +++ b/modules/ripple_data/protocol/ripple_STAmountUnitTests.cpp @@ -5,6 +5,9 @@ //============================================================================== // For unit tests: +namespace ripple +{ + static STAmount serdes (const STAmount& s) { Serializer ser; @@ -16,12 +19,75 @@ static STAmount serdes (const STAmount& s) return STAmount::deserialize (sit); } +static bool roundTest (int n, int d, int m) +{ + // check STAmount rounding + STAmount num (CURRENCY_ONE, ACCOUNT_ONE, n); + STAmount den (CURRENCY_ONE, ACCOUNT_ONE, d); + STAmount mul (CURRENCY_ONE, ACCOUNT_ONE, m); + STAmount quot = STAmount::divide (n, d, CURRENCY_ONE, ACCOUNT_ONE); + STAmount res = STAmount::multiply (quot, mul, CURRENCY_ONE, ACCOUNT_ONE); + + if (res.isNative ()) + BOOST_FAIL ("Product is native"); + + res.roundSelf (); + + STAmount cmp (CURRENCY_ONE, ACCOUNT_ONE, (n * m) / d); + + if (cmp.isNative ()) + BOOST_FAIL ("Comparison amount is native"); + + if (res == cmp) + return true; + + cmp.throwComparable (res); + WriteLog (lsWARNING, STAmount) << "(" << num.getText () << "/" << den.getText () << ") X " << mul.getText () << " = " + << res.getText () << " not " << cmp.getText (); + BOOST_FAIL ("Round fail"); + return false; +} + +static void mulTest (int a, int b) +{ + STAmount aa (CURRENCY_ONE, ACCOUNT_ONE, a); + STAmount bb (CURRENCY_ONE, ACCOUNT_ONE, b); + STAmount prod1 (STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE)); + + if (prod1.isNative ()) + BOOST_FAIL ("product is native"); + + STAmount prod2 (CURRENCY_ONE, ACCOUNT_ONE, static_cast (a) * static_cast (b)); + + if (prod1 != prod2) + { + WriteLog (lsWARNING, STAmount) << "nn(" << aa.getFullText () << " * " << bb.getFullText () << ") = " << prod1.getFullText () + << " not " << prod2.getFullText (); + BOOST_WARN ("Multiplication result is not exact"); + } + + aa = a; + prod1 = STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE); + + if (prod1 != prod2) + { + WriteLog (lsWARNING, STAmount) << "n(" << aa.getFullText () << " * " << bb.getFullText () << ") = " << prod1.getFullText () + << " not " << prod2.getFullText (); + BOOST_WARN ("Multiplication result is not exact"); + } + +} + +} + //------------------------------------------------------------------------------ BOOST_AUTO_TEST_SUITE (amount) BOOST_AUTO_TEST_CASE ( setValue_test ) { + using namespace ripple; + STAmount saTmp; #if 0 @@ -45,6 +111,8 @@ BOOST_AUTO_TEST_CASE ( setValue_test ) BOOST_AUTO_TEST_CASE ( NativeCurrency_test ) { + using namespace ripple; + STAmount zero, one (1), hundred (100); if (serdes (zero) != zero) BOOST_FAIL ("STAmount fail"); @@ -184,6 +252,8 @@ BOOST_AUTO_TEST_CASE ( NativeCurrency_test ) BOOST_AUTO_TEST_CASE ( CustomCurrency_test ) { + using namespace ripple; + STAmount zero (CURRENCY_ONE, ACCOUNT_ONE), one (CURRENCY_ONE, ACCOUNT_ONE, 1), hundred (CURRENCY_ONE, ACCOUNT_ONE, 100); serdes (one).getRaw (); @@ -364,67 +434,10 @@ BOOST_AUTO_TEST_CASE ( CustomCurrency_test ) //------------------------------------------------------------------------------ -static bool roundTest (int n, int d, int m) -{ - // check STAmount rounding - STAmount num (CURRENCY_ONE, ACCOUNT_ONE, n); - STAmount den (CURRENCY_ONE, ACCOUNT_ONE, d); - STAmount mul (CURRENCY_ONE, ACCOUNT_ONE, m); - STAmount quot = STAmount::divide (n, d, CURRENCY_ONE, ACCOUNT_ONE); - STAmount res = STAmount::multiply (quot, mul, CURRENCY_ONE, ACCOUNT_ONE); - - if (res.isNative ()) - BOOST_FAIL ("Product is native"); - - res.roundSelf (); - - STAmount cmp (CURRENCY_ONE, ACCOUNT_ONE, (n * m) / d); - - if (cmp.isNative ()) - BOOST_FAIL ("Comparison amount is native"); - - if (res == cmp) - return true; - - cmp.throwComparable (res); - WriteLog (lsWARNING, STAmount) << "(" << num.getText () << "/" << den.getText () << ") X " << mul.getText () << " = " - << res.getText () << " not " << cmp.getText (); - BOOST_FAIL ("Round fail"); - return false; -} - -static void mulTest (int a, int b) -{ - STAmount aa (CURRENCY_ONE, ACCOUNT_ONE, a); - STAmount bb (CURRENCY_ONE, ACCOUNT_ONE, b); - STAmount prod1 (STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE)); - - if (prod1.isNative ()) - BOOST_FAIL ("product is native"); - - STAmount prod2 (CURRENCY_ONE, ACCOUNT_ONE, static_cast (a) * static_cast (b)); - - if (prod1 != prod2) - { - WriteLog (lsWARNING, STAmount) << "nn(" << aa.getFullText () << " * " << bb.getFullText () << ") = " << prod1.getFullText () - << " not " << prod2.getFullText (); - BOOST_WARN ("Multiplication result is not exact"); - } - - aa = a; - prod1 = STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE); - - if (prod1 != prod2) - { - WriteLog (lsWARNING, STAmount) << "n(" << aa.getFullText () << " * " << bb.getFullText () << ") = " << prod1.getFullText () - << " not " << prod2.getFullText (); - BOOST_WARN ("Multiplication result is not exact"); - } - -} - BOOST_AUTO_TEST_CASE ( CurrencyMulDivTests ) { + using namespace ripple; + CBigNum b; for (int i = 0; i < 16; ++i) @@ -483,6 +496,8 @@ BOOST_AUTO_TEST_CASE ( CurrencyMulDivTests ) BOOST_AUTO_TEST_CASE ( UnderFlowTests ) { + using namespace ripple; + STAmount bigNative (STAmount::cMaxNative / 2); STAmount bigValue (CURRENCY_ONE, ACCOUNT_ONE, (STAmount::cMinValue + STAmount::cMaxValue) / 2, STAmount::cMaxOffset - 1); @@ -536,6 +551,8 @@ BOOST_AUTO_TEST_SUITE (amountRound) BOOST_AUTO_TEST_CASE ( amountRound_test ) { + using namespace ripple; + uint64 value = 25000000000000000ull; int offset = -14; STAmount::canonicalizeRound (false, value, offset, true); diff --git a/modules/ripple_data/protocol/ripple_SerializedObjectUnitTests.cpp b/modules/ripple_data/protocol/ripple_SerializedObjectUnitTests.cpp index fea23f7377..821328a68c 100644 --- a/modules/ripple_data/protocol/ripple_SerializedObjectUnitTests.cpp +++ b/modules/ripple_data/protocol/ripple_SerializedObjectUnitTests.cpp @@ -8,6 +8,8 @@ BOOST_AUTO_TEST_SUITE (SerializedObject) BOOST_AUTO_TEST_CASE ( FieldManipulation_test ) { + using namespace ripple; + if (sfGeneric.isUseful ()) BOOST_FAIL ("sfGeneric must not be useful"); diff --git a/modules/ripple_data/protocol/ripple_SerializerUnitTests.cpp b/modules/ripple_data/protocol/ripple_SerializerUnitTests.cpp index b95f2e1c15..df6bc3b834 100644 --- a/modules/ripple_data/protocol/ripple_SerializerUnitTests.cpp +++ b/modules/ripple_data/protocol/ripple_SerializerUnitTests.cpp @@ -8,6 +8,8 @@ BOOST_AUTO_TEST_SUITE (Serializer_suite) BOOST_AUTO_TEST_CASE ( Serializer_PrefixHash_test ) { + using namespace ripple; + Serializer s1; s1.add32 (3); s1.add256 (uint256 ()); diff --git a/modules/ripple_data/ripple_data.cpp b/modules/ripple_data/ripple_data.cpp index 77f0b49da2..27329e8f4d 100644 --- a/modules/ripple_data/ripple_data.cpp +++ b/modules/ripple_data/ripple_data.cpp @@ -54,10 +54,8 @@ #undef min #endif -#if RIPPLE_USE_NAMESPACE namespace ripple { -#endif #include "crypto/ripple_Base58.h" // for RippleAddress #include "crypto/ripple_CKey.h" // needs RippleAddress VFALCO TODO remove this dependency cycle @@ -93,9 +91,7 @@ static const uint64 tenTo17m1 = tenTo17 - 1; #include "utility/ripple_JSONCache.cpp" -#if RIPPLE_USE_NAMESPACE } -#endif // These must be outside the namespace because of boost #include "crypto/ripple_CKeyDeterministicUnitTests.cpp" diff --git a/modules/ripple_data/ripple_data.h b/modules/ripple_data/ripple_data.h index bfef508e51..8c8d5a06d4 100644 --- a/modules/ripple_data/ripple_data.h +++ b/modules/ripple_data/ripple_data.h @@ -52,10 +52,8 @@ // additional hierarchy via directories. #include "ripple.pb.h" -#if RIPPLE_USE_NAMESPACE namespace ripple { -#endif #include "crypto/ripple_CBigNum.h" #include "crypto/ripple_Base58.h" // VFALCO TODO Can be moved to .cpp if we clean up setAlphabet stuff @@ -80,11 +78,8 @@ namespace ripple #include "utility/ripple_JSONCache.h" #include "utility/ripple_UptimeTimerAdapter.h" -#if RIPPLE_USE_NAMESPACE } -#endif -#if RIPPLE_USE_NAMESPACE namespace boost { template <> @@ -135,57 +130,5 @@ namespace boost typedef ripple::STArray::const_iterator type; }; } -#else -namespace boost -{ - template <> - struct range_mutable_iterator - { - typedef std::vector ::iterator type; - }; - - template <> - struct range_const_iterator - { - typedef std::vector ::const_iterator type; - }; - - template <> - struct range_mutable_iterator - { - typedef std::vector ::iterator type; - }; - - template <> - struct range_const_iterator - { - typedef std::vector ::const_iterator type; - }; - - template <> - struct range_mutable_iterator - { - typedef STObject::iterator type; - }; - - template <> - struct range_const_iterator - { - typedef STObject::const_iterator type; - }; - - template <> - struct range_mutable_iterator - { - typedef STArray::iterator type; - }; - - template <> - struct range_const_iterator - { - typedef STArray::const_iterator type; - }; -} -#endif #endif diff --git a/modules/ripple_json/ripple_json.cpp b/modules/ripple_json/ripple_json.cpp index 6dabe12ff8..9c2bbc7038 100644 --- a/modules/ripple_json/ripple_json.cpp +++ b/modules/ripple_json/ripple_json.cpp @@ -30,15 +30,11 @@ #define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw #define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message ); -#if RIPPLE_USE_NAMESPACE namespace ripple { -#endif #include "json/json_reader.cpp" #include "json/json_value.cpp" #include "json/json_writer.cpp" -#if RIPPLE_USE_NAMESPACE } -#endif diff --git a/modules/ripple_json/ripple_json.h b/modules/ripple_json/ripple_json.h index ecbfa700f8..75b8c3df61 100644 --- a/modules/ripple_json/ripple_json.h +++ b/modules/ripple_json/ripple_json.h @@ -25,6 +25,8 @@ #include #include +#include "BeastConfig.h" + #include "json/json_config.h" // Needed before these cpptl includes #ifndef JSON_USE_CPPTL_SMALLMAP @@ -37,10 +39,8 @@ # include #endif -#if RIPPLE_USE_NAMESPACE namespace ripple { -#endif #include "json/json_forwards.h" #include "json/json_features.h" @@ -48,8 +48,6 @@ namespace ripple #include "json/json_reader.h" #include "json/json_writer.h" -#if RIPPLE_USE_NAMESPACE } -#endif #endif diff --git a/modules/ripple_websocket/autosocket/ripple_AutoSocket.cpp b/modules/ripple_websocket/autosocket/ripple_AutoSocket.cpp index b9d5415fee..84e2714fff 100644 --- a/modules/ripple_websocket/autosocket/ripple_AutoSocket.cpp +++ b/modules/ripple_websocket/autosocket/ripple_AutoSocket.cpp @@ -4,8 +4,4 @@ */ //============================================================================== -#if RIPPLE_USE_NAMESPACE ripple::LogPartition AutoSocket::AutoSocketPartition ("AutoSocket"); -#else -LogPartition AutoSocket::AutoSocketPartition ("AutoSocket"); -#endif diff --git a/modules/ripple_websocket/autosocket/ripple_AutoSocket.h b/modules/ripple_websocket/autosocket/ripple_AutoSocket.h index 30b20116ff..0c5c422b31 100644 --- a/modules/ripple_websocket/autosocket/ripple_AutoSocket.h +++ b/modules/ripple_websocket/autosocket/ripple_AutoSocket.h @@ -73,9 +73,7 @@ public: static bool rfc2818_verify (const std::string& domain, bool preverified, boost::asio::ssl::verify_context& ctx) { -#if RIPPLE_USE_NAMESPACE using namespace ripple; -#endif if (boost::asio::ssl::rfc2818_verification (domain) (preverified, ctx)) return true; @@ -228,9 +226,7 @@ public: protected: void handle_autodetect (callback cbFunc, const error_code& ec, size_t bytesTransferred) { -#if RIPPLE_USE_NAMESPACE using namespace ripple; -#endif if (ec) { @@ -261,11 +257,7 @@ protected: } private: -#if RIPPLE_USE_NAMESPACE static ripple::LogPartition AutoSocketPartition; -#else - static LogPartition AutoSocketPartition; -#endif socket_ptr mSocket; bool mSecure; diff --git a/modules/ripple_websocket/autosocket/ripple_LogWebsockets.cpp b/modules/ripple_websocket/autosocket/ripple_LogWebsockets.cpp index f917dfd58f..1e45ee75cf 100644 --- a/modules/ripple_websocket/autosocket/ripple_LogWebsockets.cpp +++ b/modules/ripple_websocket/autosocket/ripple_LogWebsockets.cpp @@ -12,7 +12,6 @@ namespace websocketpp namespace log { -#if RIPPLE_USE_NAMESPACE using namespace ripple; LogPartition websocketPartition ("WebSocket"); @@ -48,37 +47,6 @@ void websocketLog (websocketpp::log::elevel::value v, const std::string& entry) if (websocketPartition.doLog (s)) Log (s, websocketPartition) << entry; } -#else -LogPartition websocketPartition ("WebSocket"); - -void websocketLog (websocketpp::log::alevel::value v, const std::string& entry) -{ - if ((v == websocketpp::log::alevel::DEVEL) || (v == websocketpp::log::alevel::DEBUG_CLOSE)) - { - if (websocketPartition.doLog (lsTRACE)) - Log (lsDEBUG, websocketPartition) << entry; - } - else if (websocketPartition.doLog (lsDEBUG)) - Log (lsDEBUG, websocketPartition) << entry; -} - -void websocketLog (websocketpp::log::elevel::value v, const std::string& entry) -{ - LogSeverity s = lsDEBUG; - - if ((v & websocketpp::log::elevel::INFO) != 0) - s = lsINFO; - else if ((v & websocketpp::log::elevel::FATAL) != 0) - s = lsFATAL; - else if ((v & websocketpp::log::elevel::RERROR) != 0) - s = lsERROR; - else if ((v & websocketpp::log::elevel::WARN) != 0) - s = lsWARNING; - - if (websocketPartition.doLog (s)) - Log (s, websocketPartition) << entry; -} -#endif } } diff --git a/src/cpp/ripple/LedgerUnitTests.cpp b/src/cpp/ripple/LedgerUnitTests.cpp index 08d01189e6..52ed5eb484 100644 --- a/src/cpp/ripple/LedgerUnitTests.cpp +++ b/src/cpp/ripple/LedgerUnitTests.cpp @@ -8,6 +8,8 @@ BOOST_AUTO_TEST_SUITE (quality) BOOST_AUTO_TEST_CASE ( getquality ) { + using namespace ripple; + uint256 uBig ("D2DC44E5DC189318DB36EF87D2104CDF0A0FE3A4B698BEEE55038D7EA4C68000"); if (6125895493223874560 != Ledger::getQuality (uBig)) diff --git a/src/cpp/ripple/main.cpp b/src/cpp/ripple/main.cpp index bd4c586283..2336f2c83d 100644 --- a/src/cpp/ripple/main.cpp +++ b/src/cpp/ripple/main.cpp @@ -119,7 +119,7 @@ void printHelp (const po::options_description& desc) // cerr << " trust_set [] []" << endl; } -int main (int argc, char* argv[]) +int rippleMain (int argc, char** argv) { setCallingThreadName ("main"); int iResult = 0; diff --git a/src/cpp/ripple/ripple_LedgerEntrySet.h b/src/cpp/ripple/ripple_LedgerEntrySet.h index 6f1d9be64a..236c4af3eb 100644 --- a/src/cpp/ripple/ripple_LedgerEntrySet.h +++ b/src/cpp/ripple/ripple_LedgerEntrySet.h @@ -267,17 +267,5 @@ inline LedgerEntrySet::iterator range_end (LedgerEntrySet& x) { return x.end (); } -namespace boost -{ -template<> struct range_mutable_iterator -{ - typedef LedgerEntrySet::iterator type; -}; -template<> struct range_const_iterator -{ - typedef LedgerEntrySet::const_iterator type; -}; -} #endif -// vim:ts=4 diff --git a/src/cpp/ripple/ripple_PathRequest.h b/src/cpp/ripple/ripple_PathRequest.h index 9e48fed288..1f988049c7 100644 --- a/src/cpp/ripple/ripple_PathRequest.h +++ b/src/cpp/ripple/ripple_PathRequest.h @@ -10,8 +10,6 @@ // A pathfinding request submitted by a client // The request issuer must maintain a strong pointer -class InfoSub; -class STAmount; class RippleLineCache; // Return values from parseJson <0 = invalid, >0 = valid diff --git a/src/cpp/ripple/ripple_ProofOfWorkFactoryUnitTests.cpp b/src/cpp/ripple/ripple_ProofOfWorkFactoryUnitTests.cpp index 84a77def55..e96eccd485 100644 --- a/src/cpp/ripple/ripple_ProofOfWorkFactoryUnitTests.cpp +++ b/src/cpp/ripple/ripple_ProofOfWorkFactoryUnitTests.cpp @@ -8,6 +8,8 @@ BOOST_AUTO_TEST_SUITE (ProofOfWork_suite) BOOST_AUTO_TEST_CASE ( ProofOfWork_test ) { + using namespace ripple; + ProofOfWorkFactory gen; ProofOfWork pow = gen.getProof (); WriteLog (lsINFO, ProofOfWork) << "Estimated difficulty: " << pow.getDifficulty (); diff --git a/src/cpp/ripple/ripple_SHAMapSyncUnitTests.cpp b/src/cpp/ripple/ripple_SHAMapSyncUnitTests.cpp index 88f4faaa5c..805d494c14 100644 --- a/src/cpp/ripple/ripple_SHAMapSyncUnitTests.cpp +++ b/src/cpp/ripple/ripple_SHAMapSyncUnitTests.cpp @@ -8,6 +8,9 @@ #define SMS_DEBUG #endif +namespace ripple +{ + static SHAMapItem::pointer makeRandomAS () { Serializer s; @@ -55,10 +58,14 @@ static bool confuseMap (SHAMap& map, int count) return true; } +} + BOOST_AUTO_TEST_SUITE ( SHAMapSync ) BOOST_AUTO_TEST_CASE ( SHAMapSync_test ) { + using namespace ripple; + WriteLog (lsTRACE, SHAMap) << "begin sync test"; unsigned int seed; RAND_pseudo_bytes (reinterpret_cast (&seed), sizeof (seed)); diff --git a/src/cpp/ripple/ripple_SHAMapUnitTests.cpp b/src/cpp/ripple/ripple_SHAMapUnitTests.cpp index ad6410d1f9..24354baaca 100644 --- a/src/cpp/ripple/ripple_SHAMapUnitTests.cpp +++ b/src/cpp/ripple/ripple_SHAMapUnitTests.cpp @@ -6,20 +6,25 @@ // VFALCO TODO Rename this to createFilledVector and pass an unsigned char, tidy up // -static Blob IntToVUC (int v) +namespace ripple { - Blob vuc; + static Blob IntToVUC (int v) + { + Blob vuc; - for (int i = 0; i < 32; ++i) - vuc.push_back (static_cast (v)); + for (int i = 0; i < 32; ++i) + vuc.push_back (static_cast (v)); - return vuc; + return vuc; + } } BOOST_AUTO_TEST_SUITE (SHAMap_suite) BOOST_AUTO_TEST_CASE ( SHAMap_test ) { + using namespace ripple; + // h3 and h4 differ only in the leaf, same terminal node (level 19) WriteLog (lsTRACE, SHAMap) << "SHAMap test"; uint256 h1, h2, h3, h4, h5; diff --git a/src/cpp/ripple/ripple_SerializedTransactionUnitTests.cpp b/src/cpp/ripple/ripple_SerializedTransactionUnitTests.cpp index 72462cb7d9..4beb4c7f12 100644 --- a/src/cpp/ripple/ripple_SerializedTransactionUnitTests.cpp +++ b/src/cpp/ripple/ripple_SerializedTransactionUnitTests.cpp @@ -7,6 +7,8 @@ BOOST_AUTO_TEST_SUITE (SerializedTransactionTS) BOOST_AUTO_TEST_CASE ( STrans_test ) { + using namespace ripple; + RippleAddress seed; seed.setSeedRandom (); RippleAddress generator = RippleAddress::createGeneratorPublic (seed); diff --git a/src/cpp/ripple/ripple_SqliteDatabase.h b/src/cpp/ripple/ripple_SqliteDatabase.h index 05bf6c1ddb..a1bac93b56 100644 --- a/src/cpp/ripple/ripple_SqliteDatabase.h +++ b/src/cpp/ripple/ripple_SqliteDatabase.h @@ -7,9 +7,6 @@ #ifndef RIPPLE_SQLITEDATABASE_RIPPLEHEADER #define RIPPLE_SQLITEDATABASE_RIPPLEHEADER -struct sqlite3; -struct sqlite3_stmt; - class SqliteDatabase : public Database { public: