diff options
-rw-r--r-- | indra/llcommon/llsd.cpp | 14 | ||||
-rw-r--r-- | indra/llcommon/llsd.h | 30 | ||||
-rw-r--r-- | indra/test/llsd_new_tut.cpp | 13 |
3 files changed, 32 insertions, 25 deletions
diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 1bd5d06d29..08cb7bd2a8 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -91,7 +91,7 @@ protected: bool shared() const { return (mUseCount > 1) && (mUseCount != STATIC_USAGE_COUNT); } U32 mUseCount; - + public: static void reset(Impl*& var, Impl* impl); ///< safely set var to refer to the new impl (possibly shared) @@ -901,11 +901,6 @@ LLSD& LLSD::operator[](Integer i) const LLSD& LLSD::operator[](Integer i) const { return safe(impl).ref(i); } -#ifdef LLSD_DEBUG_INFO -U32 LLSD::allocationCount() { return Impl::sAllocationCount; } -U32 LLSD::outstandingCount() { return Impl::sOutstandingCount; } -#endif - static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat) { // sStorage is used to hold the string representation of the llsd last @@ -954,6 +949,13 @@ LLSD::array_iterator LLSD::endArray() { return makeArray(impl).endArray(); } LLSD::array_const_iterator LLSD::beginArray() const{ return safe(impl).beginArray(); } LLSD::array_const_iterator LLSD::endArray() const { return safe(impl).endArray(); } +namespace llsd +{ + +U32 allocationCount() { return LLSD::Impl::sAllocationCount; } +U32 outstandingCount() { return LLSD::Impl::sOutstandingCount; } + +} // namespace llsd // Diagnostic dump of contents in an LLSD object #ifdef LLSD_DEBUG_INFO diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 3519b134c2..ae083dd629 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -389,19 +389,6 @@ private: Impl* impl; friend class LLSD::Impl; //@} - - /** @name Unit Testing Interface */ - //@{ -public: -#ifdef LLSD_DEBUG_INFO - /// @warn THESE COUNTS WILL NOT BE ACCURATE IN A MULTI-THREADED - /// ENVIRONMENT. - /// - /// These counts track LLSD::Impl (hidden) objects. - static U32 allocationCount(); ///< how many Impls have been made - static U32 outstandingCount(); ///< how many Impls are still alive -#endif - //@} private: /** @name Debugging Interface */ @@ -475,6 +462,23 @@ struct llsd_select_string : public std::unary_function<LLSD, LLSD::String> LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLSD& llsd); +namespace llsd +{ + +/** @name Unit Testing Interface */ +//@{ +#ifdef LLSD_DEBUG_INFO + /// @warn THESE COUNTS WILL NOT BE ACCURATE IN A MULTI-THREADED + /// ENVIRONMENT. + /// + /// These counts track LLSD::Impl (hidden) objects. + LL_COMMON_API U32 allocationCount(); ///< how many Impls have been made + LL_COMMON_API U32 outstandingCount(); ///< how many Impls are still alive +#endif +//@} + +} // namespace llsd + /** QUESTIONS & TO DOS - Would Binary be more convenient as unsigned char* buffer semantics? - Should Binary be convertible to/from String, and if so how? diff --git a/indra/test/llsd_new_tut.cpp b/indra/test/llsd_new_tut.cpp index f332ad0ee2..b55a562e98 100644 --- a/indra/test/llsd_new_tut.cpp +++ b/indra/test/llsd_new_tut.cpp @@ -25,6 +25,7 @@ * $/LicenseInfo$ */ +#define LLSD_DEBUG_INFO #include <tut/tut.hpp> #include "linden_common.h" #include "lltut.h" @@ -39,11 +40,11 @@ namespace tut private: U32 mOutstandingAtStart; public: - SDCleanupCheck() : mOutstandingAtStart(LLSD::outstandingCount()) { } + SDCleanupCheck() : mOutstandingAtStart(llsd::outstandingCount()) { } ~SDCleanupCheck() { ensure_equals("SDCleanupCheck", - LLSD::outstandingCount(), mOutstandingAtStart); + llsd::outstandingCount(), mOutstandingAtStart); } }; @@ -57,12 +58,12 @@ namespace tut SDAllocationCheck(const std::string& message, int expectedAllocations) : mMessage(message), mExpectedAllocations(expectedAllocations), - mAllocationAtStart(LLSD::allocationCount()) + mAllocationAtStart(llsd::allocationCount()) { } ~SDAllocationCheck() { ensure_equals(mMessage + " SDAllocationCheck", - LLSD::allocationCount() - mAllocationAtStart, + llsd::allocationCount() - mAllocationAtStart, mExpectedAllocations); } }; @@ -746,7 +747,7 @@ namespace tut { SDAllocationCheck check("shared values test for threaded work", 9); - //U32 start_llsd_count = LLSD::outstandingCount(); + //U32 start_llsd_count = llsd::outstandingCount(); LLSD m = LLSD::emptyMap(); @@ -773,7 +774,7 @@ namespace tut m["string_two"] = "string two value"; m["string_one_copy"] = m["string_one"]; // 9 - //U32 llsd_object_count = LLSD::outstandingCount(); + //U32 llsd_object_count = llsd::outstandingCount(); //std::cout << "Using " << (llsd_object_count - start_llsd_count) << " LLSD objects" << std::endl; //m.dumpStats(); |