From b6858df0dd9fa06ec8fa56c5ba63925a790b4811 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 8 Nov 2011 13:47:08 -0800 Subject: LLHandle is now implicitly convertable to LLHandle and LLHandle can be downcast to LLHandle using the LLHandleProvider mixin --- indra/llui/llbutton.cpp | 2 +- indra/llui/llfloater.cpp | 22 +++++-------- indra/llui/llfloater.h | 11 ++----- indra/llui/llhandle.h | 67 ++++++++++++++++++++++++--------------- indra/llui/llmenugl.h | 2 +- indra/llui/llpanel.cpp | 2 -- indra/llui/llpanel.h | 3 +- indra/llui/lluictrl.cpp | 11 +++---- indra/llui/lluictrl.h | 3 +- indra/llui/llview.h | 9 +++--- indra/newview/llfloatercamera.cpp | 2 +- indra/newview/llnavigationbar.cpp | 2 +- indra/newview/lltoast.h | 4 +-- 13 files changed, 70 insertions(+), 70 deletions(-) diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 74b8885e1f..a01dccc7ab 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -115,7 +115,7 @@ LLButton::Params::Params() LLButton::LLButton(const LLButton::Params& p) : LLUICtrl(p), - LLBadgeOwner(LLView::getHandle()), + LLBadgeOwner(getHandle()), mMouseDownFrame(0), mMouseHeldDownCount(0), mBorderEnabled( FALSE ), diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 432397d3e9..07d2e1ed5f 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -111,7 +111,6 @@ LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] = LLMultiFloater* LLFloater::sHostp = NULL; BOOL LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting -LLFloater::handle_map_t LLFloater::sFloaterMap; LLFloaterView* gFloaterView = NULL; @@ -268,7 +267,6 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mMinimizeSignal(NULL) // mNotificationContext(NULL) { - mHandle.bind(this); // mNotificationContext = new LLFloaterNotificationContext(getHandle()); // Clicks stop here. @@ -323,9 +321,6 @@ void LLFloater::initFloater(const Params& p) // Floaters are created in the invisible state setVisible(FALSE); - // add self to handle->floater map - sFloaterMap[mHandle] = this; - if (!getParent()) { gFloaterView->addChild(this); @@ -532,8 +527,6 @@ LLFloater::~LLFloater() // correct, non-minimized positions. setMinimized( FALSE ); - sFloaterMap.erase(mHandle); - delete mDragHandle; for (S32 i = 0; i < 4; i++) { @@ -1038,7 +1031,9 @@ BOOL LLFloater::canSnapTo(const LLView* other_view) if (other_view != getParent()) { const LLFloater* other_floaterp = dynamic_cast(other_view); - if (other_floaterp && other_floaterp->getSnapTarget() == getHandle() && mDependents.find(other_floaterp->getHandle()) != mDependents.end()) + if (other_floaterp + && other_floaterp->getSnapTarget() == getHandle() + && mDependents.find(other_floaterp->getHandle()) != mDependents.end()) { // this is a dependent that is already snapped to us, so don't snap back to it return FALSE; @@ -1677,18 +1672,17 @@ void LLFloater::onClickHelp( LLFloater* self ) LLFloater* LLFloater::getClosableFloaterFromFocus() { LLFloater* focused_floater = NULL; - - handle_map_iter_t iter; - for(iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter) + LLInstanceTracker::instance_iter it = beginInstances(); + LLInstanceTracker::instance_iter end_it = endInstances(); + for (; it != end_it; ++it) { - focused_floater = iter->second; - if (focused_floater->hasFocus()) + if (it->hasFocus()) { break; } } - if (iter == sFloaterMap.end()) + if (it == endInstances()) { // nothing found, return return NULL; diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 73e9c9e831..b24ae1beb9 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -83,7 +83,7 @@ namespace LLInitParam } -class LLFloater : public LLPanel +class LLFloater : public LLPanel, public LLInstanceTracker { friend class LLFloaterView; friend class LLFloaterReg; @@ -282,7 +282,7 @@ public: void clearSnapTarget() { mSnappedTo.markDead(); } LLHandle getSnapTarget() const { return mSnappedTo; } - LLHandle getHandle() const { return mHandle; } + LLHandle getHandle() const { return getDerivedHandle(); } const LLSD& getKey() { return mKey; } virtual bool matchesKey(const LLSD& key) { return mSingleInstance || KeyCompare::equate(key, mKey); } @@ -460,16 +460,9 @@ private: typedef void(*click_callback)(LLFloater*); static click_callback sButtonCallbacks[BUTTON_COUNT]; - typedef std::map, LLFloater*> handle_map_t; - typedef std::map, LLFloater*>::iterator handle_map_iter_t; - static handle_map_t sFloaterMap; - BOOL mHasBeenDraggedWhileMinimized; S32 mPreviousMinimizedBottom; S32 mPreviousMinimizedLeft; - -// LLFloaterNotificationContext* mNotificationContext; - LLRootHandle mHandle; }; diff --git a/indra/llui/llhandle.h b/indra/llui/llhandle.h index 8c000eee48..c8fff72110 100644 --- a/indra/llui/llhandle.h +++ b/indra/llui/llhandle.h @@ -28,17 +28,18 @@ #define LLHANDLE_H #include "llpointer.h" +#include +#include -template class LLTombStone : public LLRefCount { public: - LLTombStone(T* target = NULL) : mTarget(target) {} + LLTombStone(void* target = NULL) : mTarget(target) {} - void setTarget(T* target) { mTarget = target; } - T* getTarget() const { return mTarget; } + void setTarget(void* target) { mTarget = target; } + void* getTarget() const { return mTarget; } private: - T* mTarget; + mutable void* mTarget; }; // LLHandles are used to refer to objects whose lifetime you do not control or influence. @@ -53,13 +54,15 @@ private: template class LLHandle { + template friend class LLHandle; + template friend class LLHandleProvider; public: LLHandle() : mTombStone(getDefaultTombStone()) {} - const LLHandle& operator =(const LLHandle& other) - { - mTombStone = other.mTombStone; - return *this; - } + + template + LLHandle(const LLHandle& other, typename boost::enable_if< typename boost::is_convertible >::type* dummy = 0) + : mTombStone(other.mTombStone) + {} bool isDead() const { @@ -73,7 +76,7 @@ public: T* get() const { - return mTombStone->getTarget(); + return reinterpret_cast(mTombStone->getTarget()); } friend bool operator== (const LLHandle& lhs, const LLHandle& rhs) @@ -94,12 +97,13 @@ public: } protected: - LLPointer > mTombStone; + LLPointer mTombStone; private: - static LLPointer >& getDefaultTombStone() + typedef T* pointer_t; + static LLPointer& getDefaultTombStone() { - static LLPointer > sDefaultTombStone = new LLTombStone; + static LLPointer sDefaultTombStone = new LLTombStone; return sDefaultTombStone; } }; @@ -108,23 +112,26 @@ template class LLRootHandle : public LLHandle { public: + typedef LLRootHandle self_t; + typedef LLHandle base_t; + LLRootHandle(T* object) { bind(object); } LLRootHandle() {}; ~LLRootHandle() { unbind(); } - // this is redundant, since a LLRootHandle *is* an LLHandle - LLHandle getHandle() { return LLHandle(*this); } + // this is redundant, since an LLRootHandle *is* an LLHandle + //LLHandle getHandle() { return LLHandle(*this); } void bind(T* object) { // unbind existing tombstone if (LLHandle::mTombStone.notNull()) { - if (LLHandle::mTombStone->getTarget() == object) return; + if (LLHandle::mTombStone->getTarget() == (void*)object) return; LLHandle::mTombStone->setTarget(NULL); } // tombstone reference counted, so no paired delete - LLHandle::mTombStone = new LLTombStone(object); + LLHandle::mTombStone = new LLTombStone((void*)object); } void unbind() @@ -142,6 +149,15 @@ private: template class LLHandleProvider { +public: + LLHandle getHandle() const + { + // perform lazy binding to avoid small tombstone allocations for handle + // providers whose handles are never referenced + mHandle.bind(static_cast(const_cast* >(this))); + return mHandle; + } + protected: typedef LLHandle handle_type_t; LLHandleProvider() @@ -149,16 +165,17 @@ protected: // provided here to enforce T deriving from LLHandleProvider } - LLHandle getHandle() - { - // perform lazy binding to avoid small tombstone allocations for handle - // providers whose handles are never referenced - mHandle.bind(static_cast(this)); - return mHandle; + template + typename LLHandle getDerivedHandle(typename boost::enable_if< typename boost::is_convertible >::type* dummy = 0) const + { + LLHandle downcast_handle; + downcast_handle.mTombStone = mHandle.mTombStone; + return downcast_handle; } + private: - LLRootHandle mHandle; + mutable LLRootHandle mHandle; }; #endif diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index bdae899933..36f3ba34b9 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -681,7 +681,7 @@ public: BOOL appendContextSubMenu(LLContextMenu *menu); - LLHandle getHandle() { mHandle.bind(this); return mHandle; } + LLHandle getHandle() { return getDerivedHandle(); } protected: BOOL mHoveredAnyItem; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index a45b617c2e..00318cec6b 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -122,8 +122,6 @@ LLPanel::LLPanel(const LLPanel::Params& p) { addBorder(p.border); } - - mPanelHandle.bind(this); } LLPanel::~LLPanel() diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index ab1c87caff..cd33938226 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -153,7 +153,7 @@ public: void setCtrlsEnabled(BOOL b); - LLHandle getHandle() const { return mPanelHandle; } + LLHandle getHandle() const { return getDerivedHandle(); } const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; } @@ -278,7 +278,6 @@ private: LLViewBorder* mBorder; LLButton* mDefaultBtn; LLUIString mLabel; - LLRootHandle mPanelHandle; typedef std::map ui_string_map_t; ui_string_map_t mUIStrings; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 2fa260ded1..b9c843e931 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -118,7 +118,6 @@ LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) mDoubleClickSignal(NULL), mTransparencyType(TT_DEFAULT) { - mUICtrlHandle.bind(this); } void LLUICtrl::initFromParams(const Params& p) @@ -460,7 +459,7 @@ void LLUICtrl::setControlVariable(LLControlVariable* control) if (control) { mControlVariable = control; - mControlConnection = mControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("value"))); + mControlConnection = mControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("value"))); setValue(mControlVariable->getValue()); } } @@ -491,7 +490,7 @@ void LLUICtrl::setEnabledControlVariable(LLControlVariable* control) if (control) { mEnabledControlVariable = control; - mEnabledControlConnection = mEnabledControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("enabled"))); + mEnabledControlConnection = mEnabledControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("enabled"))); setEnabled(mEnabledControlVariable->getValue().asBoolean()); } } @@ -506,7 +505,7 @@ void LLUICtrl::setDisabledControlVariable(LLControlVariable* control) if (control) { mDisabledControlVariable = control; - mDisabledControlConnection = mDisabledControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("disabled"))); + mDisabledControlConnection = mDisabledControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("disabled"))); setEnabled(!(mDisabledControlVariable->getValue().asBoolean())); } } @@ -521,7 +520,7 @@ void LLUICtrl::setMakeVisibleControlVariable(LLControlVariable* control) if (control) { mMakeVisibleControlVariable = control; - mMakeVisibleControlConnection = mMakeVisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("visible"))); + mMakeVisibleControlConnection = mMakeVisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("visible"))); setVisible(mMakeVisibleControlVariable->getValue().asBoolean()); } } @@ -536,7 +535,7 @@ void LLUICtrl::setMakeInvisibleControlVariable(LLControlVariable* control) if (control) { mMakeInvisibleControlVariable = control; - mMakeInvisibleControlConnection = mMakeInvisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getUICtrlHandle(), std::string("invisible"))); + mMakeInvisibleControlConnection = mMakeInvisibleControlVariable->getSignal()->connect(boost::bind(&controlListener, _2, getHandle(), std::string("invisible"))); setVisible(!(mMakeInvisibleControlVariable->getValue().asBoolean())); } } diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 3e055a9d06..fb2196bb16 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -223,7 +223,7 @@ public: BOOL focusLastItem(BOOL prefer_text_fields = FALSE); // Non Virtuals - LLHandle getUICtrlHandle() const { return mUICtrlHandle; } + LLHandle getHandle() const { return getDerivedHandle(); } BOOL getIsChrome() const; void setTabStop( BOOL b ); @@ -313,7 +313,6 @@ private: BOOL mRequestsFront; BOOL mTabStop; BOOL mTentative; - LLRootHandle mUICtrlHandle; ETypeTransparency mTransparencyType; diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 08828e55e6..13f118abec 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -97,7 +97,11 @@ private: static std::vector sDrawContextStack; }; -class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElement +class LLView +: public LLMouseHandler, // handles mouse events + public LLFocusableElement, // handles keyboard events + public LLMortician, // lazy deletion + public LLHandleProvider // passes out weak references to self { public: struct Follows : public LLInitParam::ChoiceBlock @@ -306,8 +310,6 @@ public: void popVisible() { setVisible(mLastVisible); } BOOL getLastVisible() const { return mLastVisible; } - LLHandle getHandle() { mHandle.bind(this); return mHandle; } - U32 getFollows() const { return mReshapeFlags; } BOOL followsLeft() const { return mReshapeFlags & FOLLOWS_LEFT; } BOOL followsRight() const { return mReshapeFlags & FOLLOWS_RIGHT; } @@ -606,7 +608,6 @@ private: BOOL mIsFocusRoot; BOOL mUseBoundingRect; // hit test against bounding rectangle that includes all child elements - LLRootHandle mHandle; BOOL mLastVisible; S32 mNextInsertionOrdinal; diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index b33dea4890..8c2dd73bd9 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -346,7 +346,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val) mCurrMode(CAMERA_CTRL_MODE_PAN), mPrevMode(CAMERA_CTRL_MODE_PAN) { - LLHints::registerHintTarget("view_popup", LLView::getHandle()); + LLHints::registerHintTarget("view_popup", getHandle()); mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2)); } diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp index fc264db5af..12428681bd 100644 --- a/indra/newview/llnavigationbar.cpp +++ b/indra/newview/llnavigationbar.cpp @@ -318,7 +318,7 @@ BOOL LLNavigationBar::postBuild() LLTeleportHistory::getInstance()->setHistoryChangedCallback( boost::bind(&LLNavigationBar::onTeleportHistoryChanged, this)); - LLHints::registerHintTarget("nav_bar", LLView::getHandle()); + LLHints::registerHintTarget("nav_bar", getHandle()); return TRUE; } diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index 242f786bf2..380c2c391a 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -196,7 +196,7 @@ public: virtual S32 notifyParent(const LLSD& info); - LLHandle getHandle() { mHandle.bind(this); return mHandle; } + LLHandle getHandle() const { return getDerivedHandle(); } protected: void updateTransparency(); @@ -215,7 +215,7 @@ private: LLUUID mSessionID; LLNotificationPtr mNotification; - LLRootHandle mHandle; + //LLRootHandle mHandle; LLPanel* mWrapperPanel; -- cgit v1.2.3 From 7e6e3d20f334547d8cea78e8e0b37106efebe028 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 8 Nov 2011 13:48:38 -0800 Subject: added Lazy modifier to params to support recursion ChoiceBlock can now derive from another param block Params with name/value support can be assigned directly in C++ code using param = "named_value" --- indra/llxuixml/llinitparam.h | 426 +++++++++++++++++++++++++++++++---------- indra/llxuixml/llxuiparser.cpp | 258 +++++++++++++++++++------ 2 files changed, 524 insertions(+), 160 deletions(-) diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 183472450d..169a724bca 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -51,7 +51,7 @@ namespace LLInitParam return a == b; } }; - + // boost function types are not comparable template struct ParamCompare @@ -74,6 +74,7 @@ namespace LLInitParam static bool equals(const Flag& a, const Flag& b) { return false; } }; + // helper functions and classes typedef ptrdiff_t param_handle_t; @@ -82,8 +83,11 @@ namespace LLInitParam template class TypeValues { + private: + struct Inaccessable{}; public: typedef std::map value_name_map_t; + typedef Inaccessable name_t; void setValueName(const std::string& key) {} std::string getValueName() const { return ""; } @@ -113,6 +117,7 @@ namespace LLInitParam { public: typedef typename std::map value_name_map_t; + typedef std::string name_t; //TODO: cache key by index to save on param block size void setValueName(const std::string& value_name) @@ -293,36 +298,7 @@ namespace LLInitParam parser_inspect_func_map_t* mParserInspectFuncs; }; - class BaseBlock; - - class Param - { - public: - // public to allow choice blocks to clear provided flag on stale choices - void setProvided(bool is_provided) { mIsProvided = is_provided; } - - protected: - bool anyProvided() const { return mIsProvided; } - - Param(BaseBlock* enclosing_block); - - // store pointer to enclosing block as offset to reduce space and allow for quick copying - BaseBlock& enclosingBlock() const - { - const U8* my_addr = reinterpret_cast(this); - // get address of enclosing BLOCK class using stored offset to enclosing BaseBlock class - return *const_cast - (reinterpret_cast - (my_addr - (ptrdiff_t)(S32)mEnclosingBlockOffset)); - } - - private: - friend class BaseBlock; - - U32 mEnclosingBlockOffset:31; - U32 mIsProvided:1; - - }; + class Param; // various callbacks and constraints associated with an individual param struct ParamDescriptor @@ -390,12 +366,91 @@ namespace LLInitParam all_params_list_t mAllParams; // all parameters, owns descriptors size_t mMaxParamOffset; EInitializationState mInitializationState; // whether or not static block data has been initialized - BaseBlock* mCurrentBlockPtr; // pointer to block currently being constructed + class BaseBlock* mCurrentBlockPtr; // pointer to block currently being constructed }; class BaseBlock { public: + //TODO: implement in terms of owned_ptr + template + class Lazy + { + public: + Lazy() + : mPtr(NULL) + {} + + ~Lazy() + { + delete mPtr; + } + + Lazy(const Lazy& other) + { + if (other.mPtr) + { + mPtr = new T(*other.mPtr); + } + else + { + mPtr = NULL; + } + } + + Lazy& operator = (const Lazy& other) + { + if (other.mPtr) + { + mPtr = new T(*other.mPtr); + } + else + { + mPtr = NULL; + } + return *this; + } + + bool empty() const + { + return mPtr == NULL; + } + + void set(const T& other) + { + delete mPtr; + mPtr = new T(other); + } + + const T& get() const + { + return ensureInstance(); + } + + T& get() + { + return ensureInstance(); + } + + private: + // lazily allocate an instance of T + T* ensureInstance() const + { + if (mPtr == NULL) + { + mPtr = new T(); + } + return mPtr; + } + + private: + // if you get a compilation error with this, that means you are using a forward declared struct for T + // unfortunately, the type traits we rely on don't work with forward declared typed + //static const int dummy = sizeof(T); + + mutable T* mPtr; + }; + // "Multiple" constraint types, put here in root class to avoid ambiguity during use struct AnyAmount { @@ -511,6 +566,44 @@ namespace LLInitParam const std::string& getParamName(const BlockDescriptor& block_data, const Param* paramp) const; }; + template + struct ParamCompare, false > + { + static bool equals(const BaseBlock::Lazy& a, const BaseBlock::Lazy& b) { return !a.empty() || !b.empty(); } + }; + + class Param + { + public: + void setProvided(bool is_provided = true) + { + mIsProvided = is_provided; + enclosingBlock().paramChanged(*this, is_provided); + } + protected: + + bool anyProvided() const { return mIsProvided; } + + Param(BaseBlock* enclosing_block); + + // store pointer to enclosing block as offset to reduce space and allow for quick copying + BaseBlock& enclosingBlock() const + { + const U8* my_addr = reinterpret_cast(this); + // get address of enclosing BLOCK class using stored offset to enclosing BaseBlock class + return *const_cast + (reinterpret_cast + (my_addr - (ptrdiff_t)(S32)mEnclosingBlockOffset)); + } + + private: + friend class BaseBlock; + + U32 mEnclosingBlockOffset:31; + U32 mIsProvided:1; + + }; + // these templates allow us to distinguish between template parameters // that derive from BaseBlock and those that don't template @@ -530,6 +623,7 @@ namespace LLInitParam { public: typedef const T& value_assignment_t; + typedef ParamValue self_t; ParamValue(): mValue() {} ParamValue(value_assignment_t other) : mValue(other) {} @@ -559,6 +653,25 @@ namespace LLInitParam return mValue; } + void operator ()(const typename NAME_VALUE_LOOKUP::name_t& name) + { + *this = name; + } + + self_t& operator =(const typename NAME_VALUE_LOOKUP::name_t& name) + { + if (NAME_VALUE_LOOKUP::getValueFromName(name, mValue)) + { + setValueName(name); + } + + return *this; + } + + self_t& operator =(const self_t& other) + { + mValue = other.mValue; + } private: T mValue; @@ -571,17 +684,16 @@ namespace LLInitParam { public: typedef const T& value_assignment_t; + typedef ParamValue self_t; ParamValue() : T(), - mKeyVersion(0), mValidatedVersion(-1), mValidated(false) {} ParamValue(value_assignment_t other) : T(other), - mKeyVersion(0), mValidatedVersion(-1), mValidated(false) {} @@ -611,8 +723,25 @@ namespace LLInitParam return *this; } - S32 mKeyVersion; + void operator ()(const typename NAME_VALUE_LOOKUP::name_t& name) + { + *this = name; + } + self_t& operator =(const typename NAME_VALUE_LOOKUP::name_t& name) + { + if (NAME_VALUE_LOOKUP::getValueFromName(name, mValue)) + { + setValueName(name); + } + + return *this; + } + + self_t& operator =(const self_t& other) + { + *(static_cast(this)) = other; + } protected: mutable S32 mValidatedVersion; mutable bool mValidated; // lazy validation flag @@ -671,8 +800,7 @@ namespace LLInitParam if (parser.readValue(typed_param.getValue())) { typed_param.clearValueName(); - typed_param.setProvided(true); - typed_param.enclosingBlock().paramChanged(param, true); + typed_param.setProvided(); return true; } @@ -687,8 +815,7 @@ namespace LLInitParam if (name_value_lookup_t::getValueFromName(name, typed_param.getValue())) { typed_param.setValueName(name); - typed_param.setProvided(true); - typed_param.enclosingBlock().paramChanged(param, true); + typed_param.setProvided(); return true; } @@ -744,12 +871,22 @@ namespace LLInitParam } } + self_t& operator =(typename const name_value_lookup_t::name_t& name) + { + if (name_value_lookup_t::getValueFromName(name, getValue())) + { + setValueName(name); + setProvided(); + } + + return *this; + } + void set(value_assignment_t val, bool flag_as_provided = true) { setValue(val); param_value_t::clearValueName(); setProvided(flag_as_provided); - Param::enclosingBlock().paramChanged(*this, flag_as_provided); } protected: @@ -808,8 +945,7 @@ namespace LLInitParam if(typed_param.deserializeBlock(parser, name_stack_range, new_name)) { typed_param.clearValueName(); - typed_param.enclosingBlock().paramChanged(param, true); - typed_param.setProvided(true); + typed_param.setProvided(); return true; } @@ -822,10 +958,8 @@ namespace LLInitParam // try to parse a per type named value if (name_value_lookup_t::getValueFromName(name, typed_param.getValue())) { - typed_param.enclosingBlock().paramChanged(param, true); typed_param.setValueName(name); - typed_param.setProvided(true); - typed_param.mKeyVersion = typed_param.getLastChangeVersion(); + typed_param.setProvided(); return true; } @@ -845,7 +979,7 @@ namespace LLInitParam } std::string key = typed_param.getValueName(); - if (!key.empty() && typed_param.mKeyVersion == typed_param.getLastChangeVersion()) + if (!key.empty()) { if (!parser.writeValue(key, name_stack)) { @@ -888,19 +1022,33 @@ namespace LLInitParam // next call to isProvided() will update provision status based on validity param_value_t::mValidatedVersion = -1; setProvided(flag_as_provided); - Param::enclosingBlock().paramChanged(*this, flag_as_provided); + } + + self_t& operator =(typename const name_value_lookup_t::name_t& name) + { + if (name_value_lookup_t::getValueFromName(name, getValue())) + { + setValueName(name); + setProvided(); + } + + return *this; } // propagate changed status up to enclosing block /*virtual*/ void paramChanged(const Param& changed_param, bool user_provided) { param_value_t::paramChanged(changed_param, user_provided); - Param::enclosingBlock().paramChanged(*this, user_provided); if (user_provided) { // a child param has been explicitly changed // so *some* aspect of this block is now provided - setProvided(true); + setProvided(); + param_value_t::clearValueName(); + } + else + { + Param::enclosingBlock().paramChanged(*this, user_provided); } } @@ -917,7 +1065,6 @@ namespace LLInitParam { dst_typed_param.clearValueName(); dst_typed_param.setProvided(true); - dst_typed_param.enclosingBlock().paramChanged(dst_typed_param, true); return true; } } @@ -1004,7 +1151,7 @@ namespace LLInitParam it != end_it; ++it) { - std::string key = it->getValue(); + std::string key = it->getValueName(); name_stack.back().second = true; if(key.empty()) @@ -1013,7 +1160,7 @@ namespace LLInitParam bool value_written = parser.writeValue(*it, name_stack); if (!value_written) { - std::string calculated_key = it->calcValueName(key); + std::string calculated_key = it->calcValueName(it->getValue()); if (!parser.writeValue(calculated_key, name_stack)) { break; @@ -1043,22 +1190,31 @@ namespace LLInitParam { mValues = val; setProvided(flag_as_provided); - Param::enclosingBlock().paramChanged(*this, flag_as_provided); } - value_t& add() + param_value_t& add() { mValues.push_back(param_value_t(value_t())); - setProvided(true); - Param::enclosingBlock().paramChanged(*this, true); + Param::setProvided(); return mValues.back(); } void add(const value_t& item) { mValues.push_back(param_value_t(item)); - setProvided(true); - Param::enclosingBlock().paramChanged(*this, true); + setProvided(); + } + + void add(typename const name_value_lookup_t::name_t& name) + { + value_t value; + + // try to parse a per type named value + if (name_value_lookup_t::getValueFromName(name, value)) + { + add(value); + mValues.back().setValueName(name); + } } // implicit conversion @@ -1099,8 +1255,7 @@ namespace LLInitParam if (src_typed_param.begin() != src_typed_param.end()) { - dst_typed_param.setProvided(true); - dst_typed_param.enclosingBlock().paramChanged(dst_typed_param, true); + dst_typed_param.setProvided(); } return true; } @@ -1116,7 +1271,7 @@ namespace LLInitParam public: typedef TypedParam self_t; typedef ParamValue param_value_t; - typedef typename std::vector container_t; + typedef typename std::vector container_t; typedef const container_t& value_assignment_t; typedef VALUE_TYPE value_t; typedef NAME_VALUE_LOOKUP name_value_lookup_t; @@ -1158,8 +1313,7 @@ namespace LLInitParam // attempt to parse block... if(value.deserializeBlock(parser, name_stack_range, new_name)) { - typed_param.enclosingBlock().paramChanged(param, true); - typed_param.setProvided(true); + typed_param.setProvided(); return true; } else if(name_value_lookup_t::valueNamesExist()) @@ -1172,9 +1326,7 @@ namespace LLInitParam if (name_value_lookup_t::getValueFromName(name, value.getValue())) { typed_param.mValues.back().setValueName(name); - typed_param.mValues.back().mKeyVersion = value.getLastChangeVersion(); - typed_param.enclosingBlock().paramChanged(param, true); - typed_param.setProvided(true); + typed_param.setProvided(); return true; } @@ -1201,7 +1353,7 @@ namespace LLInitParam name_stack.back().second = true; std::string key = it->getValueName(); - if (!key.empty() && it->mKeyVersion == it->getLastChangeVersion()) + if (!key.empty()) { parser.writeValue(key, name_stack); } @@ -1224,22 +1376,31 @@ namespace LLInitParam { mValues = val; setProvided(flag_as_provided); - Param::enclosingBlock().paramChanged(*this, flag_as_provided); } - value_t& add() + param_value_t& add() { mValues.push_back(value_t()); - setProvided(true); - Param::enclosingBlock().paramChanged(*this, true); + setProvided(); return mValues.back(); } void add(const value_t& item) { mValues.push_back(item); - setProvided(true); - Param::enclosingBlock().paramChanged(*this, true); + setProvided(); + } + + void add(typename const name_value_lookup_t::name_t& name) + { + value_t value; + + // try to parse a per type named value + if (name_value_lookup_t::getValueFromName(name, value)) + { + add(value); + mValues.back().setValueName(name); + } } // implicit conversion @@ -1288,8 +1449,7 @@ namespace LLInitParam if (src_typed_param.begin() != src_typed_param.end()) { - dst_typed_param.setProvided(true); - dst_typed_param.enclosingBlock().paramChanged(dst_typed_param, true); + dst_typed_param.setProvided(); } return true; @@ -1298,24 +1458,25 @@ namespace LLInitParam container_t mValues; }; - template - class ChoiceBlock : public BaseBlock + template + class ChoiceBlock : public BASE_BLOCK { - typedef ChoiceBlock self_t; - typedef ChoiceBlock enclosing_block_t; + typedef ChoiceBlock self_t; + typedef ChoiceBlock enclosing_block_t; + typedef BASE_BLOCK base_block_t; LOG_CLASS(self_t); public: // take all provided params from other and apply to self bool overwriteFrom(const self_t& other) { - return mergeBlock(selfBlockDescriptor(), other, true); + return static_cast(this)->mergeBlock(selfBlockDescriptor(), other, true); } // take all provided params that are not already provided, and apply to self bool fillFrom(const self_t& other) { - return mergeBlock(selfBlockDescriptor(), other, false); + return static_cast(this)->mergeBlock(selfBlockDescriptor(), other, false); } bool mergeBlockParam(bool source_provided, bool dest_provided, BlockDescriptor& block_data, const self_t& source, bool overwrite) @@ -1333,25 +1494,25 @@ namespace LLInitParam bool mergeBlock(BlockDescriptor& block_data, const self_t& other, bool overwrite) { mCurChoice = other.mCurChoice; - return BaseBlock::mergeBlock(selfBlockDescriptor(), other, overwrite); + return base_block_t::mergeBlock(selfBlockDescriptor(), other, overwrite); } // clear out old choice when param has changed /*virtual*/ void paramChanged(const Param& changed_param, bool user_provided) { - param_handle_t changed_param_handle = BaseBlock::getHandleFromParam(&changed_param); + param_handle_t changed_param_handle = base_block_t::getHandleFromParam(&changed_param); // if we have a new choice... if (changed_param_handle != mCurChoice) { // clear provided flag on previous choice - Param* previous_choice = BaseBlock::getParamFromHandle(mCurChoice); + Param* previous_choice = base_block_t::getParamFromHandle(mCurChoice); if (previous_choice) { previous_choice->setProvided(false); } mCurChoice = changed_param_handle; } - BaseBlock::paramChanged(changed_param, user_provided); + base_block_t::paramChanged(changed_param, user_provided); } virtual const BlockDescriptor& mostDerivedBlockDescriptor() const { return selfBlockDescriptor(); } @@ -1361,7 +1522,7 @@ namespace LLInitParam ChoiceBlock() : mCurChoice(0) { - BaseBlock::init(selfBlockDescriptor(), BaseBlock::selfBlockDescriptor(), sizeof(DERIVED_BLOCK)); + BaseBlock::init(selfBlockDescriptor(), base_block_t::selfBlockDescriptor(), sizeof(DERIVED_BLOCK)); } // Alternatives are mutually exclusive wrt other Alternatives in the same block. @@ -1447,7 +1608,7 @@ namespace LLInitParam const Param* getCurrentChoice() const { - return BaseBlock::getParamFromHandle(mCurChoice); + return base_block_t::getParamFromHandle(mCurChoice); } }; @@ -1493,6 +1654,9 @@ namespace LLInitParam typedef TypedParam >::value> super_t; typedef typename super_t::value_assignment_t value_assignment_t; + using super_t::operator(); + using super_t::operator=; + explicit Optional(const char* name = "", value_assignment_t val = defaultValue()) : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1) { @@ -1510,7 +1674,6 @@ namespace LLInitParam super_t::set(val); return static_cast(Param::enclosingBlock()); } - using super_t::operator(); }; template > @@ -1521,6 +1684,9 @@ namespace LLInitParam typedef Mandatory self_t; typedef typename super_t::value_assignment_t value_assignment_t; + using super_t::operator(); + using super_t::operator=; + // mandatory parameters require a name to be parseable explicit Mandatory(const char* name = "", value_assignment_t val = defaultValue()) : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, &validate, 1, 1) @@ -1537,7 +1703,6 @@ namespace LLInitParam super_t::set(val); return static_cast(Param::enclosingBlock()); } - using super_t::operator(); static bool validate(const Param* p) { @@ -1693,14 +1858,12 @@ namespace LLInitParam ParamValue() : block_t(), - mKeyVersion(0), mValidatedVersion(-1), mValidated(false) {} ParamValue(value_assignment_t other) : block_t(other), - mKeyVersion(0), mValidatedVersion(-1), mValidated(false) { @@ -1731,11 +1894,82 @@ namespace LLInitParam return *this; } - S32 mKeyVersion; + protected: + mutable S32 mValidatedVersion; + mutable bool mValidated; // lazy validation flag + }; + + template + class ParamValue , + TypeValues, + false> + { + public: + typedef ParamValue , TypeValues, false> self_t; + typedef const T& value_assignment_t; + + ParamValue() + : mValue(), + mValidatedVersion(-1), + mValidated(false) + {} + + ParamValue(value_assignment_t other) + : mValue(other), + mValidatedVersion(-1), + mValidated(false) + {} + + void setValue(value_assignment_t val) + { + mValue.set(val); + } + + value_assignment_t getValue() const + { + return mValue.get(); + } + + T& getValue() + { + return mValue.get(); + } + + operator value_assignment_t() const + { + return mValue.get(); + } + + value_assignment_t operator()() const + { + return mValue.get(); + } + + bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name) + { + return mValue.get().deserializeBlock(p, name_stack_range, new_name); + } + + void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const + { + if (mValue.empty()) return; + + mValue.get().serializeBlock(p, name_stack, diff_block); + } + + bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const + { + if (mValue.empty()) return false; + + return mValue.get().inspectBlock(p, name_stack, min_count, max_count); + } protected: mutable S32 mValidatedVersion; mutable bool mValidated; // lazy validation flag + + private: + BaseBlock::Lazy mValue; }; template <> @@ -1750,14 +1984,12 @@ namespace LLInitParam typedef const LLSD& value_assignment_t; ParamValue() - : mKeyVersion(0), - mValidatedVersion(-1), + : mValidatedVersion(-1), mValidated(false) {} ParamValue(value_assignment_t other) : mValue(other), - mKeyVersion(0), mValidatedVersion(-1), mValidated(false) {} @@ -1770,7 +2002,6 @@ namespace LLInitParam operator value_assignment_t() const { return mValue; } value_assignment_t operator()() const { return mValue; } - S32 mKeyVersion; // block param interface bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); @@ -1812,7 +2043,6 @@ namespace LLInitParam CustomParamValue(const T& value = T()) : mValue(value), mValueAge(VALUE_AUTHORITATIVE), - mKeyVersion(0), mValidatedVersion(-1), mValidated(false) {} @@ -1966,8 +2196,6 @@ namespace LLInitParam return getValue(); } - S32 mKeyVersion; - protected: // use this from within updateValueFromBlock() to set the value without making it authoritative diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index 878f992178..cdf578113a 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -59,28 +59,26 @@ const char* NO_VALUE_MARKER = "no_value"; const S32 LINE_NUMBER_HERE = 0; -struct MaxOccur : public LLInitParam::ChoiceBlock +struct MaxOccursValues : public LLInitParam::TypeValuesHelper { - Alternative count; - Alternative unbounded; - - MaxOccur() - : unbounded("", "unbounded") - {} + using TypeValuesHelper::operator =; + typedef std::string name_t; + static void declareValues() + { + declare("unbounded", U32_MAX); + } }; struct Occurs : public LLInitParam::Block { - Optional minOccurs; - Optional maxOccurs; + Optional minOccurs; + Optional maxOccurs; + Multiple foo; Occurs() - : minOccurs("minOccurs"), - maxOccurs("maxOccurs") - { - minOccurs = 0; - maxOccurs.unbounded.choose(); - } + : minOccurs("minOccurs", 0), + maxOccurs("maxOccurs", U32_MAX) + {} }; @@ -103,18 +101,15 @@ namespace LLInitParam }; } -struct Name : public LLInitParam::Block -{ - Mandatory name; - - Name() - : name("name") - {} -}; +struct Element; +struct Group; +struct Choice; +struct Sequence; +struct Any; struct Attribute : public LLInitParam::Block { - Mandatory name; + Mandatory name; Mandatory type; Mandatory use; @@ -122,41 +117,170 @@ struct Attribute : public LLInitParam::Block : name("name"), type("type"), use("use") + {} +}; + +struct Any : public LLInitParam::Block +{ + Optional _namespace; + + Any() + : _namespace("namespace") + {} +}; + +struct All : public LLInitParam::Block +{ + Multiple> elements; + + All() + : elements("element") { + maxOccurs = 1; } }; -struct ComplexType : public LLInitParam::Block +struct Choice : public LLInitParam::ChoiceBlock +{ + Alternative> element; + Alternative> group; + Alternative> choice; + Alternative> sequence; + Alternative> any; + + Choice() + : element("element"), + group("group"), + choice("choice"), + sequence("sequence"), + any("any") + {} + +}; + +struct Sequence : public LLInitParam::ChoiceBlock +{ + Alternative> element; + Alternative> group; + Alternative> choice; + Alternative> sequence; + Alternative> any; +}; + +struct GroupContents : public LLInitParam::ChoiceBlock { - Multiple attribute; - //Multiple elements; - Optional mixed; + Alternative all; + Alternative choice; + Alternative sequence; + + GroupContents() + : all("all"), + choice("choice"), + sequence("sequence") + {} +}; + +struct Group : public LLInitParam::Block +{ + Optional name, + ref; + + Group() + : name("name"), + ref("ref") + {} +}; + +struct Restriction : public LLInitParam::Block +{ +}; + +struct Extension : public LLInitParam::Block +{ +}; + +struct SimpleContent : public LLInitParam::ChoiceBlock +{ + Alternative restriction; + Alternative extension; + + SimpleContent() + : restriction("restriction"), + extension("extension") + {} +}; + +struct SimpleType : public LLInitParam::Block +{ + // TODO +}; + +struct ComplexContent : public LLInitParam::Block +{ + Optional mixed; + + ComplexContent() + : mixed("mixed", true) + {} +}; + +struct ComplexTypeContents : public LLInitParam::ChoiceBlock +{ + Alternative simple_content; + Alternative complex_content; + Alternative group; + Alternative all; + Alternative choice; + Alternative sequence; + + ComplexTypeContents() + : simple_content("simpleContent"), + complex_content("complexContent"), + group("group"), + all("all"), + choice("choice"), + sequence("sequence") + {} +}; + +struct ComplexType : public LLInitParam::Block +{ + Optional name; + Optional mixed; + + Multiple attribute; + Multiple> elements; ComplexType() - : attribute("xs:attribute"), - //elements("xs:element"), + : name("name"), + attribute("xs:attribute"), + elements("xs:element"), mixed("mixed") { - mixed = true; } }; -struct Element : public LLInitParam::Block +struct ElementContents : public LLInitParam::ChoiceBlock { - Mandatory complexType; - Mandatory name; + Alternative simpleType; + Alternative complexType; - Element() - : complexType("xs:complexType") + ElementContents() + : simpleType("simpleType"), + complexType("complexType") {} }; -struct Elements : public LLInitParam::Block +struct Element : public LLInitParam::Block { - Multiple elements; + Optional name, + ref, + type; - Elements() - : elements("xs:element") + Element() + : name("xs:name"), + ref("xs:ref"), + type("xs:type") {} }; @@ -164,28 +288,32 @@ struct Schema : public LLInitParam::Block { private: Mandatory targetNamespace, - xmlns; + xmlns, + xs; public: Optional attributeFormDefault, - elementFormDefault, - xs; + elementFormDefault; - Optional elements; + Mandatory root_element; void setNameSpace(const std::string& ns) {targetNamespace = ns; xmlns = ns;} - Schema() + Schema(const std::string& ns = LLStringUtil::null) : attributeFormDefault("attributeFormDefault"), elementFormDefault("elementFormDefault"), xs("xmlns:xs"), targetNamespace("targetNamespace"), xmlns("xmlns"), - elements("xs:choice") + root_element("xs:element") { attributeFormDefault = "unqualified"; elementFormDefault = "qualified"; xs = "http://www.w3.org/2001/XMLSchema"; + if (!ns.empty()) + { + setNameSpace(ns); + }; } }; @@ -214,22 +342,30 @@ LLXSDWriter::LLXSDWriter() void LLXSDWriter::writeXSD(const std::string& type_name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace) { + Schema schema(xml_namespace); + + schema.root_element.name = type_name; + Choice& choice = schema.root_element.complexType.choice; + + choice.minOccurs = 0; + choice.maxOccurs = "unbounded"; + mSchemaNode = node; - node->setName("xs:schema"); - node->createChild("attributeFormDefault", true)->setStringValue("unqualified"); - node->createChild("elementFormDefault", true)->setStringValue("qualified"); - node->createChild("targetNamespace", true)->setStringValue(xml_namespace); - node->createChild("xmlns:xs", true)->setStringValue("http://www.w3.org/2001/XMLSchema"); - node->createChild("xmlns", true)->setStringValue(xml_namespace); - - node = node->createChild("xs:complexType", false); - node->createChild("name", true)->setStringValue(type_name); - node->createChild("mixed", true)->setStringValue("true"); - - mAttributeNode = node; - mElementNode = node->createChild("xs:choice", false); - mElementNode->createChild("minOccurs", true)->setStringValue("0"); - mElementNode->createChild("maxOccurs", true)->setStringValue("unbounded"); + //node->setName("xs:schema"); + //node->createChild("attributeFormDefault", true)->setStringValue("unqualified"); + //node->createChild("elementFormDefault", true)->setStringValue("qualified"); + //node->createChild("targetNamespace", true)->setStringValue(xml_namespace); + //node->createChild("xmlns:xs", true)->setStringValue("http://www.w3.org/2001/XMLSchema"); + //node->createChild("xmlns", true)->setStringValue(xml_namespace); + + //node = node->createChild("xs:complexType", false); + //node->createChild("name", true)->setStringValue(type_name); + //node->createChild("mixed", true)->setStringValue("true"); + + //mAttributeNode = node; + //mElementNode = node->createChild("xs:choice", false); + //mElementNode->createChild("minOccurs", true)->setStringValue("0"); + //mElementNode->createChild("maxOccurs", true)->setStringValue("unbounded"); block.inspectBlock(*this); // duplicate element choices -- cgit v1.2.3 From 0c9d8d917a4281e2dea7fa2044e86735caca2aa9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 10 Nov 2011 16:02:57 -0800 Subject: fixed build fixed handle downcast not initiating handle --- indra/llui/llhandle.h | 2 +- indra/llxuixml/llinitparam.h | 2 ++ indra/newview/llfloaterwebcontent.cpp | 4 ++-- indra/newview/llfloaterwebcontent.h | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/indra/llui/llhandle.h b/indra/llui/llhandle.h index c8fff72110..e6390ee599 100644 --- a/indra/llui/llhandle.h +++ b/indra/llui/llhandle.h @@ -169,7 +169,7 @@ protected: typename LLHandle getDerivedHandle(typename boost::enable_if< typename boost::is_convertible >::type* dummy = 0) const { LLHandle downcast_handle; - downcast_handle.mTombStone = mHandle.mTombStone; + downcast_handle.mTombStone = getHandle().mTombStone; return downcast_handle; } diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 169a724bca..f5f6876736 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -671,6 +671,7 @@ namespace LLInitParam self_t& operator =(const self_t& other) { mValue = other.mValue; + return *this; } private: @@ -741,6 +742,7 @@ namespace LLInitParam self_t& operator =(const self_t& other) { *(static_cast(this)) = other; + return *this; } protected: mutable S32 mValidatedVersion; diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index f410c31f44..d6db7aa6ad 100644 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -167,7 +167,7 @@ LLFloater* LLFloaterWebContent::create( Params p) //static void LLFloaterWebContent::closeRequest(const std::string &uuid) { - LLFloaterWebContent* floaterp = getInstance(uuid); + LLFloaterWebContent* floaterp = instance_tracker_t::getInstance(uuid); if (floaterp) { floaterp->closeFloater(false); @@ -177,7 +177,7 @@ void LLFloaterWebContent::closeRequest(const std::string &uuid) //static void LLFloaterWebContent::geometryChanged(const std::string &uuid, S32 x, S32 y, S32 width, S32 height) { - LLFloaterWebContent* floaterp = getInstance(uuid); + LLFloaterWebContent* floaterp = instance_tracker_t::getInstance(uuid); if (floaterp) { floaterp->geometryChanged(x, y, width, height); diff --git a/indra/newview/llfloaterwebcontent.h b/indra/newview/llfloaterwebcontent.h index 6fc66d1ad8..9d90306a9c 100644 --- a/indra/newview/llfloaterwebcontent.h +++ b/indra/newview/llfloaterwebcontent.h @@ -43,6 +43,7 @@ class LLFloaterWebContent : public LLInstanceTracker { public: + typedef LLInstanceTracker instance_tracker_t; LOG_CLASS(LLFloaterWebContent); struct _Params : public LLInitParam::Block<_Params> -- cgit v1.2.3 From 267e75d8dc36386070ddb3ecebb31a7bbadd6d03 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 11 Nov 2011 11:17:44 -0800 Subject: support for assignment of named values to params --- indra/llxuixml/llinitparam.cpp | 1 + indra/llxuixml/llinitparam.h | 55 +++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index 482064ed7b..8880072f06 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -478,6 +478,7 @@ namespace LLInitParam if (merge_func) { Param* paramp = getParamFromHandle((*it)->mParamHandle); + llassert(paramp->mEnclosingBlockOffset == (*it)->mParamHandle); some_param_changed |= merge_func(*paramp, *other_paramp, overwrite); } } diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index f5f6876736..ec14bc2fdc 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -671,10 +671,11 @@ namespace LLInitParam self_t& operator =(const self_t& other) { mValue = other.mValue; + static_cast(*this) = other; return *this; } - private: + protected: T mValue; }; @@ -741,7 +742,10 @@ namespace LLInitParam self_t& operator =(const self_t& other) { - *(static_cast(this)) = other; + static_cast(*this) = other; + static_cast(*this) = other; + mValidatedVersion = other.mValidatedVersion; + mValidated = other.mValidated; return *this; } protected: @@ -875,24 +879,17 @@ namespace LLInitParam self_t& operator =(typename const name_value_lookup_t::name_t& name) { - if (name_value_lookup_t::getValueFromName(name, getValue())) - { - setValueName(name); - setProvided(); - } - - return *this; + return static_cast(param_value_t::operator =(name)); } void set(value_assignment_t val, bool flag_as_provided = true) { - setValue(val); param_value_t::clearValueName(); + setValue(val); setProvided(flag_as_provided); } protected: - static bool mergeWith(Param& dst, const Param& src, bool overwrite) { const self_t& src_typed_param = static_cast(src); @@ -1026,17 +1023,6 @@ namespace LLInitParam setProvided(flag_as_provided); } - self_t& operator =(typename const name_value_lookup_t::name_t& name) - { - if (name_value_lookup_t::getValueFromName(name, getValue())) - { - setValueName(name); - setProvided(); - } - - return *this; - } - // propagate changed status up to enclosing block /*virtual*/ void paramChanged(const Param& changed_param, bool user_provided) { @@ -1239,6 +1225,12 @@ namespace LLInitParam } protected: + self_t& operator=(const self_t& other) + { + mValues = other.mValues; + return *this; + } + static bool mergeWith(Param& dst, const Param& src, bool overwrite) { const self_t& src_typed_param = static_cast(src); @@ -1432,6 +1424,11 @@ namespace LLInitParam } protected: + self_t& operator=(const self_t& other) + { + mValues = other.mValues; + return *this; + } static bool mergeWith(Param& dst, const Param& src, bool overwrite) { @@ -1540,6 +1537,8 @@ namespace LLInitParam typedef TypedParam >::value> super_t; typedef typename super_t::value_assignment_t value_assignment_t; + using super_t::param_value_t::operator =; + explicit Alternative(const char* name = "", value_assignment_t val = defaultValue()) : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1), mOriginalValue(val) @@ -1565,7 +1564,7 @@ namespace LLInitParam super_t::set(val); } - void operator=(value_assignment_t val) + void operator =(value_assignment_t val) { super_t::set(val); } @@ -1657,7 +1656,7 @@ namespace LLInitParam typedef typename super_t::value_assignment_t value_assignment_t; using super_t::operator(); - using super_t::operator=; + using super_t::param_value_t::operator =; explicit Optional(const char* name = "", value_assignment_t val = defaultValue()) : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1) @@ -1665,7 +1664,7 @@ namespace LLInitParam //#pragma message("Parsing LLInitParam::Block::Optional") } - Optional& operator=(value_assignment_t val) + Optional& operator =(value_assignment_t val) { set(val); return *this; @@ -1687,14 +1686,14 @@ namespace LLInitParam typedef typename super_t::value_assignment_t value_assignment_t; using super_t::operator(); - using super_t::operator=; + using super_t::param_value_t::operator =; // mandatory parameters require a name to be parseable explicit Mandatory(const char* name = "", value_assignment_t val = defaultValue()) : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, &validate, 1, 1) {} - Mandatory& operator=(value_assignment_t val) + Mandatory& operator =(value_assignment_t val) { set(val); return *this; @@ -1729,7 +1728,7 @@ namespace LLInitParam : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, container_t(), &validate, RANGE::minCount, RANGE::maxCount) {} - Multiple& operator=(value_assignment_t val) + Multiple& operator =(value_assignment_t val) { set(val); return *this; -- cgit v1.2.3 From 2ee4bae1a39814467e4bd361211f7836266af880 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 16 Nov 2011 12:28:10 -0800 Subject: support for assignment of named values to params, works with string-typed params as well as () operator --- indra/llxuixml/llinitparam.h | 93 +++++++++++++++++++++++++++++++++++------- indra/llxuixml/llxuiparser.cpp | 4 +- 2 files changed, 80 insertions(+), 17 deletions(-) diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index ec14bc2fdc..575e8231bd 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -572,7 +572,7 @@ namespace LLInitParam static bool equals(const BaseBlock::Lazy& a, const BaseBlock::Lazy& b) { return !a.empty() || !b.empty(); } }; - class Param + class Param { public: void setProvided(bool is_provided = true) @@ -580,6 +580,12 @@ namespace LLInitParam mIsProvided = is_provided; enclosingBlock().paramChanged(*this, is_provided); } + + Param& operator =(const Param& other) + { + setProvided(other.mIsProvided); + return *this; + } protected: bool anyProvided() const { return mIsProvided; } @@ -671,7 +677,7 @@ namespace LLInitParam self_t& operator =(const self_t& other) { mValue = other.mValue; - static_cast(*this) = other; + NAME_VALUE_LOOKUP::operator =(other); return *this; } @@ -742,8 +748,8 @@ namespace LLInitParam self_t& operator =(const self_t& other) { - static_cast(*this) = other; - static_cast(*this) = other; + T::operator = (other); + NAME_VALUE_LOOKUP::operator =(other); mValidatedVersion = other.mValidatedVersion; mValidated = other.mValidated; return *this; @@ -753,6 +759,54 @@ namespace LLInitParam mutable bool mValidated; // lazy validation flag }; + template + class ParamValue + : public NAME_VALUE_LOOKUP + { + public: + typedef const std::string& value_assignment_t; + typedef ParamValue self_t; + + ParamValue(): mValue() {} + ParamValue(value_assignment_t other) : mValue(other) {} + + void setValue(value_assignment_t val) + { + if (NAME_VALUE_LOOKUP::getValueFromName(val, mValue)) + { + setValueName(val); + } + else + { + mValue = val; + } + } + + value_assignment_t getValue() const + { + return mValue; + } + + std::string& getValue() + { + return mValue; + } + + operator value_assignment_t() const + { + return mValue; + } + + value_assignment_t operator()() const + { + return mValue; + } + + protected: + std::string mValue; + }; + + template > struct ParamIterator { @@ -776,6 +830,8 @@ namespace LLInitParam typedef NAME_VALUE_LOOKUP name_value_lookup_t; typedef ParamValue param_value_t; + using param_value_t::operator(); + TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count) : Param(block_descriptor.mCurrentBlockPtr) { @@ -877,11 +933,6 @@ namespace LLInitParam } } - self_t& operator =(typename const name_value_lookup_t::name_t& name) - { - return static_cast(param_value_t::operator =(name)); - } - void set(value_assignment_t val, bool flag_as_provided = true) { param_value_t::clearValueName(); @@ -889,6 +940,11 @@ namespace LLInitParam setProvided(flag_as_provided); } + self_t& operator =(const typename NAME_VALUE_LOOKUP::name_t& name) + { + return static_cast(param_value_t::operator =(name)); + } + protected: static bool mergeWith(Param& dst, const Param& src, bool overwrite) { @@ -919,6 +975,8 @@ namespace LLInitParam typedef NAME_VALUE_LOOKUP name_value_lookup_t; typedef ParamValue param_value_t; + using param_value_t::operator(); + TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count) : Param(block_descriptor.mCurrentBlockPtr), param_value_t(value) @@ -1023,6 +1081,11 @@ namespace LLInitParam setProvided(flag_as_provided); } + self_t& operator =(const typename NAME_VALUE_LOOKUP::name_t& name) + { + return static_cast(param_value_t::operator =(name)); + } + // propagate changed status up to enclosing block /*virtual*/ void paramChanged(const Param& changed_param, bool user_provided) { @@ -1189,7 +1252,9 @@ namespace LLInitParam void add(const value_t& item) { - mValues.push_back(param_value_t(item)); + param_value_t param_value; + param_value.setValue(item); + mValues.push_back(param_value); setProvided(); } @@ -1537,7 +1602,7 @@ namespace LLInitParam typedef TypedParam >::value> super_t; typedef typename super_t::value_assignment_t value_assignment_t; - using super_t::param_value_t::operator =; + using super_t::operator =; explicit Alternative(const char* name = "", value_assignment_t val = defaultValue()) : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1), @@ -1656,8 +1721,8 @@ namespace LLInitParam typedef typename super_t::value_assignment_t value_assignment_t; using super_t::operator(); - using super_t::param_value_t::operator =; - + using super_t::operator =; + explicit Optional(const char* name = "", value_assignment_t val = defaultValue()) : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1) { @@ -1686,7 +1751,7 @@ namespace LLInitParam typedef typename super_t::value_assignment_t value_assignment_t; using super_t::operator(); - using super_t::param_value_t::operator =; + using super_t::operator =; // mandatory parameters require a name to be parseable explicit Mandatory(const char* name = "", value_assignment_t val = defaultValue()) diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index cdf578113a..90c2671242 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -61,8 +61,6 @@ const S32 LINE_NUMBER_HERE = 0; struct MaxOccursValues : public LLInitParam::TypeValuesHelper { - using TypeValuesHelper::operator =; - typedef std::string name_t; static void declareValues() { declare("unbounded", U32_MAX); @@ -73,11 +71,11 @@ struct Occurs : public LLInitParam::Block { Optional minOccurs; Optional maxOccurs; - Multiple foo; Occurs() : minOccurs("minOccurs", 0), maxOccurs("maxOccurs", U32_MAX) + {} }; -- cgit v1.2.3 From 4924306db50bdf0c621d19455c0d07fbf74859f8 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 18 Nov 2011 09:39:10 -0800 Subject: fix for notification buttons not being read --- indra/llxuixml/llinitparam.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 575e8231bd..2edb9b98c7 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -945,6 +945,12 @@ namespace LLInitParam return static_cast(param_value_t::operator =(name)); } + self_t& operator =(value_assignment_t val) + { + set(val); + return *this; + } + protected: static bool mergeWith(Param& dst, const Param& src, bool overwrite) { @@ -1086,6 +1092,12 @@ namespace LLInitParam return static_cast(param_value_t::operator =(name)); } + self_t& operator =(value_assignment_t val) + { + set(val); + return *this; + } + // propagate changed status up to enclosing block /*virtual*/ void paramChanged(const Param& changed_param, bool user_provided) { @@ -1290,12 +1302,6 @@ namespace LLInitParam } protected: - self_t& operator=(const self_t& other) - { - mValues = other.mValues; - return *this; - } - static bool mergeWith(Param& dst, const Param& src, bool overwrite) { const self_t& src_typed_param = static_cast(src); @@ -1489,11 +1495,6 @@ namespace LLInitParam } protected: - self_t& operator=(const self_t& other) - { - mValues = other.mValues; - return *this; - } static bool mergeWith(Param& dst, const Param& src, bool overwrite) { -- cgit v1.2.3 From 0bea8f2a9738502c8bc5482522de3b7ea49f989d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 19 Nov 2011 07:48:24 -0800 Subject: fix for notification dialog buttons not working --- indra/llxuixml/llinitparam.h | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 2edb9b98c7..5ed3337c45 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -583,7 +583,8 @@ namespace LLInitParam Param& operator =(const Param& other) { - setProvided(other.mIsProvided); + mIsProvided = other.mIsProvided; + // don't change mEnclosingblockoffset return *this; } protected: @@ -674,13 +675,6 @@ namespace LLInitParam return *this; } - self_t& operator =(const self_t& other) - { - mValue = other.mValue; - NAME_VALUE_LOOKUP::operator =(other); - return *this; - } - protected: T mValue; }; @@ -746,14 +740,6 @@ namespace LLInitParam return *this; } - self_t& operator =(const self_t& other) - { - T::operator = (other); - NAME_VALUE_LOOKUP::operator =(other); - mValidatedVersion = other.mValidatedVersion; - mValidated = other.mValidated; - return *this; - } protected: mutable S32 mValidatedVersion; mutable bool mValidated; // lazy validation flag @@ -945,13 +931,15 @@ namespace LLInitParam return static_cast(param_value_t::operator =(name)); } - self_t& operator =(value_assignment_t val) + protected: + + self_t& operator =(const self_t& other) { - set(val); + param_value_t::operator =(other); + Param::operator =(other); return *this; } - protected: static bool mergeWith(Param& dst, const Param& src, bool overwrite) { const self_t& src_typed_param = static_cast(src); @@ -1092,12 +1080,6 @@ namespace LLInitParam return static_cast(param_value_t::operator =(name)); } - self_t& operator =(value_assignment_t val) - { - set(val); - return *this; - } - // propagate changed status up to enclosing block /*virtual*/ void paramChanged(const Param& changed_param, bool user_provided) { @@ -1117,6 +1099,13 @@ namespace LLInitParam protected: + self_t& operator =(const self_t& other) + { + param_value_t::operator =(other); + Param::operator =(other); + return *this; + } + static bool mergeWith(Param& dst, const Param& src, bool overwrite) { const self_t& src_typed_param = static_cast(src); -- cgit v1.2.3 From 61570bf84fdf5edad1e34188111d551b262c67e8 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 26 Nov 2011 21:14:33 -0800 Subject: changed RelWithDebInfo config on Windows to not auto-inline, for easier debugging. --- indra/cmake/00-Common.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 0266239454..41656486d5 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -46,7 +46,7 @@ if (WINDOWS) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /MDd /MP -D_SCL_SECURE_NO_WARNINGS=1" CACHE STRING "C++ compiler debug options" FORCE) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO - "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Zi /MD /MP /Ob2 -D_SECURE_STL=0" + "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Zi /MD /MP /Ob0 -D_SECURE_STL=0" CACHE STRING "C++ compiler release-with-debug options" FORCE) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /MD /MP /Ob2 -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0" -- cgit v1.2.3 From 700277e00aa83506808f2128705143d7ae4937bd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 28 Nov 2011 22:30:12 -0800 Subject: removed unneeded changeversion tracking in param blocks in favor of a simpler dirty bit --- indra/llui/tests/llurlentry_stub.cpp | 3 -- indra/llui/tests/llurlmatch_test.cpp | 5 --- indra/llxuixml/llinitparam.cpp | 20 +--------- indra/llxuixml/llinitparam.h | 74 +++++++++++++++++------------------- 4 files changed, 36 insertions(+), 66 deletions(-) diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index 4f251db93b..c75df86891 100644 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -105,8 +105,6 @@ LLStyle::Params::Params() namespace LLInitParam { - BaseBlock::BaseBlock() {} - BaseBlock::~BaseBlock() {} Param::Param(BaseBlock* enclosing_block) : mIsProvided(false) { @@ -114,7 +112,6 @@ namespace LLInitParam const U8* block_addr = reinterpret_cast(enclosing_block); mEnclosingBlockOffset = (U16)(my_addr - block_addr); } - void BaseBlock::paramChanged(const Param& last_param, bool user_provided) {} void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name){} void BaseBlock::addSynonym(Param& param, const std::string& synonym) {} diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp index 627f3129e9..7183413463 100644 --- a/indra/llui/tests/llurlmatch_test.cpp +++ b/indra/llui/tests/llurlmatch_test.cpp @@ -63,9 +63,6 @@ S32 LLUIImage::getHeight() const namespace LLInitParam { - BaseBlock::BaseBlock() {} - BaseBlock::~BaseBlock() {} - BlockDescriptor::BlockDescriptor() {} ParamDescriptor::ParamDescriptor(param_handle_t p, merge_func_t merge_func, @@ -77,8 +74,6 @@ namespace LLInitParam S32 max_count){} ParamDescriptor::~ParamDescriptor() {} - void BaseBlock::paramChanged(const Param& last_param, bool user_provided) {} - void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name){} param_handle_t BaseBlock::getHandleFromParam(const Param* param) const {return 0;} void BaseBlock::addSynonym(Param& param, const std::string& synonym) {} diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index 8880072f06..db72aa19b9 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -40,7 +40,7 @@ namespace LLInitParam { const U8* my_addr = reinterpret_cast(this); const U8* block_addr = reinterpret_cast(enclosing_block); - mEnclosingBlockOffset = 0x7FFFffff & ((U32)(my_addr - block_addr)); + mEnclosingBlockOffset = 0x7FFFffff & (U32)(my_addr - block_addr); } // @@ -118,16 +118,6 @@ namespace LLInitParam mCurrentBlockPtr(NULL) {} - // - // BaseBlock - // - BaseBlock::BaseBlock() - : mChangeVersion(0) - {} - - BaseBlock::~BaseBlock() - {} - // called by each derived class in least to most derived order void BaseBlock::init(BlockDescriptor& descriptor, BlockDescriptor& base_descriptor, size_t block_size) { @@ -427,14 +417,6 @@ namespace LLInitParam } } - void BaseBlock::paramChanged(const Param& changed_param, bool user_provided) - { - if (user_provided) - { - mChangeVersion++; - } - } - const std::string& BaseBlock::getParamName(const BlockDescriptor& block_data, const Param* paramp) const { param_handle_t handle = getHandleFromParam(paramp); diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 5ed3337c45..80b6504c4f 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -491,8 +491,7 @@ namespace LLInitParam LOG_CLASS(BaseBlock); friend class Param; - BaseBlock(); - virtual ~BaseBlock(); + virtual ~BaseBlock() {} bool submitValue(Parser::name_stack_t& name_stack, Parser& p, bool silent=false); param_handle_t getHandleFromParam(const Param* param) const; @@ -515,9 +514,7 @@ namespace LLInitParam void addSynonym(Param& param, const std::string& synonym); // Blocks can override this to do custom tracking of changes - virtual void paramChanged(const Param& changed_param, bool user_provided); - - S32 getLastChangeVersion() const { return mChangeVersion; } + virtual void paramChanged(const Param& changed_param, bool user_provided) {} bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const; @@ -553,9 +550,6 @@ namespace LLInitParam // take all provided params from other and apply to self bool mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite); - // can be updated in getters - mutable S32 mChangeVersion; - static BlockDescriptor& selfBlockDescriptor() { static BlockDescriptor sBlockDescriptor; @@ -604,7 +598,7 @@ namespace LLInitParam } private: - friend class BaseBlock; + friend BaseBlock; U32 mEnclosingBlockOffset:31; U32 mIsProvided:1; @@ -617,12 +611,22 @@ namespace LLInitParam struct IsBlock { static const bool value = false; + struct EmptyBase {}; + typedef EmptyBase base_class_t; }; template struct IsBlock { static const bool value = true; + typedef BaseBlock base_class_t; + }; + + template + struct IsBlock, typename T::baseblock_base_class_t > + { + static const bool value = true; + typedef BaseBlock base_class_t; }; template::value> @@ -630,6 +634,7 @@ namespace LLInitParam { public: typedef const T& value_assignment_t; + typedef T value_t; typedef ParamValue self_t; ParamValue(): mValue() {} @@ -686,17 +691,16 @@ namespace LLInitParam { public: typedef const T& value_assignment_t; + typedef T value_t; typedef ParamValue self_t; ParamValue() : T(), - mValidatedVersion(-1), mValidated(false) {} ParamValue(value_assignment_t other) : T(other), - mValidatedVersion(-1), mValidated(false) {} @@ -741,7 +745,6 @@ namespace LLInitParam } protected: - mutable S32 mValidatedVersion; mutable bool mValidated; // lazy validation flag }; @@ -751,6 +754,7 @@ namespace LLInitParam { public: typedef const std::string& value_assignment_t; + typedef std::string value_t; typedef ParamValue self_t; ParamValue(): mValue() {} @@ -811,10 +815,10 @@ namespace LLInitParam public ParamValue { public: - typedef const T& value_assignment_t; typedef TypedParam self_t; - typedef NAME_VALUE_LOOKUP name_value_lookup_t; typedef ParamValue param_value_t; + typedef param_value_t::value_assignment_t value_assignment_t; + typedef NAME_VALUE_LOOKUP name_value_lookup_t; using param_value_t::operator(); @@ -962,12 +966,10 @@ namespace LLInitParam public ParamValue { public: - typedef const T value_const_t; - typedef T value_t; - typedef value_const_t& value_assignment_t; + typedef ParamValue param_value_t; + typedef typename param_value_t::value_assignment_t value_assignment_t; typedef TypedParam self_t; typedef NAME_VALUE_LOOKUP name_value_lookup_t; - typedef ParamValue param_value_t; using param_value_t::operator(); @@ -1055,11 +1057,10 @@ namespace LLInitParam bool isProvided() const { // only validate block when it hasn't already passed validation with current data - if (Param::anyProvided() && param_value_t::mValidatedVersion < param_value_t::getLastChangeVersion()) + if (Param::anyProvided() && !param_value_t::mValidated) { // a sub-block is "provided" when it has been filled in enough to be valid param_value_t::mValidated = param_value_t::validateBlock(false); - param_value_t::mValidatedVersion = param_value_t::getLastChangeVersion(); } return Param::anyProvided() && param_value_t::mValidated; } @@ -1069,9 +1070,9 @@ namespace LLInitParam { setValue(val); param_value_t::clearValueName(); - // force revalidation of block by clearing known provided version + // force revalidation of block // next call to isProvided() will update provision status based on validity - param_value_t::mValidatedVersion = -1; + param_value_t::mValidated = false; setProvided(flag_as_provided); } @@ -1088,6 +1089,7 @@ namespace LLInitParam { // a child param has been explicitly changed // so *some* aspect of this block is now provided + param_value_t::mValidated = false; setProvided(); param_value_t::clearValueName(); } @@ -1135,7 +1137,7 @@ namespace LLInitParam typedef typename std::vector container_t; typedef const container_t& value_assignment_t; - typedef VALUE_TYPE value_t; + typedef typename param_value_t::value_t value_t; typedef NAME_VALUE_LOOKUP name_value_lookup_t; TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count) @@ -1327,7 +1329,7 @@ namespace LLInitParam typedef ParamValue param_value_t; typedef typename std::vector container_t; typedef const container_t& value_assignment_t; - typedef VALUE_TYPE value_t; + typedef typename param_value_t::value_t value_t; typedef NAME_VALUE_LOOKUP name_value_lookup_t; TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count) @@ -1911,16 +1913,15 @@ namespace LLInitParam public: typedef BatchBlock block_t; typedef const BatchBlock& value_assignment_t; + typedef block_t value_t; ParamValue() : block_t(), - mValidatedVersion(-1), mValidated(false) {} ParamValue(value_assignment_t other) : block_t(other), - mValidatedVersion(-1), mValidated(false) { } @@ -1951,28 +1952,27 @@ namespace LLInitParam } protected: - mutable S32 mValidatedVersion; mutable bool mValidated; // lazy validation flag }; - template + template class ParamValue , TypeValues, - false> + IS_BLOCK> + : public IsBlock::base_class_t { public: typedef ParamValue , TypeValues, false> self_t; typedef const T& value_assignment_t; + typedef T value_t; ParamValue() : mValue(), - mValidatedVersion(-1), mValidated(false) {} ParamValue(value_assignment_t other) : mValue(other), - mValidatedVersion(-1), mValidated(false) {} @@ -2021,7 +2021,6 @@ namespace LLInitParam } protected: - mutable S32 mValidatedVersion; mutable bool mValidated; // lazy validation flag private: @@ -2040,13 +2039,11 @@ namespace LLInitParam typedef const LLSD& value_assignment_t; ParamValue() - : mValidatedVersion(-1), - mValidated(false) + : mValidated(false) {} ParamValue(value_assignment_t other) : mValue(other), - mValidatedVersion(-1), mValidated(false) {} @@ -2069,7 +2066,6 @@ namespace LLInitParam } protected: - mutable S32 mValidatedVersion; mutable bool mValidated; // lazy validation flag private: @@ -2093,13 +2089,14 @@ namespace LLInitParam typedef ParamValue > derived_t; typedef CustomParamValue self_t; - typedef Block block_t; + typedef Block block_t; typedef const T& value_assignment_t; + typedef T value_t; + CustomParamValue(const T& value = T()) : mValue(value), mValueAge(VALUE_AUTHORITATIVE), - mValidatedVersion(-1), mValidated(false) {} @@ -2285,7 +2282,6 @@ namespace LLInitParam return block_t::mergeBlock(block_data, source, overwrite); } - mutable S32 mValidatedVersion; mutable bool mValidated; // lazy validation flag private: -- cgit v1.2.3 From ff32ef773b19a6d0f7826c7edf7962e2fde492e6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 29 Nov 2011 23:53:28 -0800 Subject: fix for crash on startup (font system not initialized when first creating fonts) --- indra/llrender/llfontfreetype.cpp | 7 +++++-- indra/newview/llviewerwindow.cpp | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 91c8a37022..66d4ad2d87 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -55,7 +55,10 @@ FT_Library gFTLibrary = NULL; //static void LLFontManager::initClass() { - gFontManagerp = new LLFontManager; + if (!gFontManagerp) + { + gFontManagerp = new LLFontManager; + } } //static @@ -136,7 +139,7 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v FT_Done_Face(mFTFace); mFTFace = NULL; } - + int error; error = FT_New_Face( gFTLibrary, diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2479006eeb..22076417a6 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4745,6 +4745,9 @@ void LLViewerWindow::initFonts(F32 zoom_factor) { LLFontGL::destroyAllGL(); // Initialize with possibly different zoom factor + + LLFontManager::initClass(); + LLFontGL::initClass( gSavedSettings.getF32("FontScreenDPI"), mDisplayScale.mV[VX] * zoom_factor, mDisplayScale.mV[VY] * zoom_factor, -- cgit v1.2.3