hrev45535 adds 3 changesets to branch 'master' old head: be1038406b35253e2b7320597b8f5a0d1e6006a3 new head: d519acd691cecc5a3958190e75d482e7e3d1bcc1 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=d519acd+%5Ebe10384 ---------------------------------------------------------------------------- 7d151f6: Extend ValueNode API. - Add several new optional hook functions to ValueNode. These allow implementing subclasses to specify that they're a container type that can export a range of items (i.e. arrays, lists, etc.), and expose several operations on said ranges of child items. 758a63d: Implement ranged container hooks in ArrayValueNode. d519acd: Some refactoring of Settings classes. - Rename the current RangeSetting -> BoundedSetting and add an appropriate setting type enum, since that one actually describes a single value clamped to a range, rather than an actual range. - Add RangeSetting class that has both a lower/upper bound and a pair of values representing the lower and upper ends of the range currently selected. [ Rene Gollent <anevilyak@xxxxxxxxx> ] ---------------------------------------------------------------------------- 6 files changed, 216 insertions(+), 19 deletions(-) src/apps/debugger/settings/generic/Setting.cpp | 69 +++++++++++++++++- src/apps/debugger/settings/generic/Setting.h | 41 ++++++++++- src/apps/debugger/value/ValueNode.cpp | 28 +++++++ src/apps/debugger/value/ValueNode.h | 13 ++++ .../value/value_nodes/ArrayValueNode.cpp | 77 ++++++++++++++++---- .../debugger/value/value_nodes/ArrayValueNode.h | 7 ++ ############################################################################ Commit: 7d151f694c88f35e19d96efe62640ad03ccf3bb2 URL: http://cgit.haiku-os.org/haiku/commit/?id=7d151f6 Author: Rene Gollent <anevilyak@xxxxxxxxx> Date: Sat Apr 20 02:57:55 2013 UTC Extend ValueNode API. - Add several new optional hook functions to ValueNode. These allow implementing subclasses to specify that they're a container type that can export a range of items (i.e. arrays, lists, etc.), and expose several operations on said ranges of child items. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/value/ValueNode.cpp b/src/apps/debugger/value/ValueNode.cpp index a88ce6d..1166f4c 100644 --- a/src/apps/debugger/value/ValueNode.cpp +++ b/src/apps/debugger/value/ValueNode.cpp @@ -63,6 +63,34 @@ ValueNode::SetContainer(ValueNodeContainer* container) } +bool +ValueNode::IsRangedContainer() const +{ + return false; +} + + +void +ValueNode::ClearChildren() +{ + // do nothing +} + + +status_t +ValueNode::CreateChildrenInRange(int32 lowIndex, int32 highIndex) +{ + return B_NOT_SUPPORTED; +} + + +status_t +ValueNode::SupportedChildRange(int32& lowIndex, int32& highIndex) const +{ + return B_NOT_SUPPORTED; +} + + void ValueNode::SetLocationAndValue(ValueLocation* location, Value* value, status_t resolutionState) diff --git a/src/apps/debugger/value/ValueNode.h b/src/apps/debugger/value/ValueNode.h index 449aba7..9b88b77 100644 --- a/src/apps/debugger/value/ValueNode.h +++ b/src/apps/debugger/value/ValueNode.h @@ -51,10 +51,23 @@ public: { return false; } bool ChildrenCreated() const { return fChildrenCreated; } + virtual status_t CreateChildren() = 0; virtual int32 CountChildren() const = 0; virtual ValueNodeChild* ChildAt(int32 index) const = 0; + // optional virtual hooks for container type value nodes such as + // arrays that may contain a variable (and potentially quite large) + // number of children. The calls below should be implemented for such + // node types to allow the upper layers to be aware of this, and to be + // able to request that only a subset of children be created. + virtual bool IsRangedContainer() const; + virtual void ClearChildren(); + virtual status_t CreateChildrenInRange(int32 lowIndex, + int32 highIndex); + virtual status_t SupportedChildRange(int32& lowIndex, + int32& highIndex) const; + status_t LocationAndValueResolutionState() const { return fLocationResolutionState; } void SetLocationAndValue(ValueLocation* location, ############################################################################ Commit: 758a63dc709b5f22c7397ef966937fd8f3dfe0ce URL: http://cgit.haiku-os.org/haiku/commit/?id=758a63d Author: Rene Gollent <anevilyak@xxxxxxxxx> Date: Sun Apr 21 15:45:39 2013 UTC Implement ranged container hooks in ArrayValueNode. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp b/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp index e8f5c62..b0f7e48 100644 --- a/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp +++ b/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2013, Rene Gollent, rene@xxxxxxxxxxx. * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx. * Distributed under the terms of the MIT License. */ @@ -76,18 +77,62 @@ AbstractArrayValueNode::CreateChildren() if (!fChildren.IsEmpty()) return B_OK; + return CreateChildrenInRange(0, kMaxArrayElementCount - 1); +} + + +int32 +AbstractArrayValueNode::CountChildren() const +{ + return fChildren.CountItems(); +} + + +ValueNodeChild* +AbstractArrayValueNode::ChildAt(int32 index) const +{ + return fChildren.ItemAt(index); +} + + +bool +AbstractArrayValueNode::IsRangedContainer() const +{ + return true; +} + + +void +AbstractArrayValueNode::ClearChildren() +{ + fChildren.MakeEmpty(); + if (fContainer != NULL) + fContainer->NotifyValueNodeChildrenDeleted(this); +} + + +status_t +AbstractArrayValueNode::CreateChildrenInRange(int32 lowIndex, + int32 highIndex) +{ + // TODO: ensure that we don't already have children in the specified + // index range. These need to be skipped if so. TRACE_LOCALS("TYPE_ARRAY\n"); int32 dimensionCount = fType->CountDimensions(); bool isFinalDimension = fDimension + 1 == dimensionCount; - ArrayDimension* dimension = fType->DimensionAt(fDimension); - uint64 elementCount = dimension->CountElements(); - if (elementCount == 0 || elementCount > kMaxArrayElementCount) - elementCount = kMaxArrayElementCount; + int32 lowerBound, upperBound; + if (SupportedChildRange(lowerBound, upperBound) == B_OK) { + // clamp inputs to supported range. + if (lowIndex < lowerBound) + lowIndex = lowerBound; + if (highIndex > upperBound) + highIndex = upperBound; + } // create children for the array elements - for (int32 i = 0; i < (int32)elementCount; i++) { + for (int32 i = lowIndex; i <= (int32)highIndex; i++) { BString name(Name()); name << '[' << i << ']'; if (name.Length() <= Name().Length()) @@ -117,17 +162,23 @@ AbstractArrayValueNode::CreateChildren() } -int32 -AbstractArrayValueNode::CountChildren() const +status_t +AbstractArrayValueNode::SupportedChildRange(int32& lowIndex, + int32& highIndex) const { - return fChildren.CountItems(); -} + ArrayDimension* dimension = fType->DimensionAt(fDimension); + SubrangeType* dimensionType = dynamic_cast<SubrangeType*>( + dimension->GetType()); -ValueNodeChild* -AbstractArrayValueNode::ChildAt(int32 index) const -{ - return fChildren.ItemAt(index); + if (dimensionType != NULL) { + lowIndex = dimensionType->LowerBound().ToInt32(); + highIndex = dimensionType->UpperBound().ToInt32(); + + return B_OK; + } + + return B_UNSUPPORTED; } diff --git a/src/apps/debugger/value/value_nodes/ArrayValueNode.h b/src/apps/debugger/value/value_nodes/ArrayValueNode.h index dcef1e9..cc305e7 100644 --- a/src/apps/debugger/value/value_nodes/ArrayValueNode.h +++ b/src/apps/debugger/value/value_nodes/ArrayValueNode.h @@ -1,4 +1,5 @@ /* + * Copyright 2013, Rene Gollent, rene@xxxxxxxxxxx. * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx. * Distributed under the terms of the MIT License. */ @@ -40,6 +41,12 @@ public: virtual int32 CountChildren() const; virtual ValueNodeChild* ChildAt(int32 index) const; + virtual bool IsRangedContainer() const; + virtual void ClearChildren(); + virtual status_t CreateChildrenInRange(int32 lowIndex, + int32 highIndex); + virtual status_t SupportedChildRange(int32& lowIndex, + int32& highIndex) const; protected: typedef BObjectList<AbstractArrayValueNodeChild> ChildList; ############################################################################ Revision: hrev45535 Commit: d519acd691cecc5a3958190e75d482e7e3d1bcc1 URL: http://cgit.haiku-os.org/haiku/commit/?id=d519acd Author: Rene Gollent <anevilyak@xxxxxxxxx> Date: Sun Apr 21 16:01:17 2013 UTC Some refactoring of Settings classes. - Rename the current RangeSetting -> BoundedSetting and add an appropriate setting type enum, since that one actually describes a single value clamped to a range, rather than an actual range. - Add RangeSetting class that has both a lower/upper bound and a pair of values representing the lower and upper ends of the range currently selected. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/settings/generic/Setting.cpp b/src/apps/debugger/settings/generic/Setting.cpp index f704699..3213649 100644 --- a/src/apps/debugger/settings/generic/Setting.cpp +++ b/src/apps/debugger/settings/generic/Setting.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2013, Rene Gollent, rene@xxxxxxxxxxx. * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx. * Distributed under the terms of the MIT License. */ @@ -78,6 +79,16 @@ OptionsSetting::DefaultValue() const } +// #pragma mark - BoundedSetting + + +setting_type +BoundedSetting::Type() const +{ + return SETTING_TYPE_BOUNDED; +} + + // #pragma mark - RangeSetting @@ -284,7 +295,7 @@ OptionsSettingImpl::SetDefaultOption(SettingsOption* option) // #pragma mark - RangeSettingImpl -RangeSettingImpl::RangeSettingImpl(const BString& id, const BString& name, +BoundedSettingImpl::BoundedSettingImpl(const BString& id, const BString& name, const BVariant& lowerBound, const BVariant& upperBound, const BVariant& defaultValue) : @@ -297,13 +308,53 @@ RangeSettingImpl::RangeSettingImpl(const BString& id, const BString& name, BVariant -RangeSettingImpl::DefaultValue() const +BoundedSettingImpl::DefaultValue() const { return fDefaultValue; } BVariant +BoundedSettingImpl::LowerBound() const +{ + return fLowerBound; +} + + +BVariant +BoundedSettingImpl::UpperBound() const +{ + return fUpperBound; +} + + +// #pragma mark - RangeSettingImpl + + +RangeSettingImpl::RangeSettingImpl(const BString& id, const BString& name, + const BVariant& lowerBound, const BVariant& upperBound, + const BVariant& lowerValue, const BVariant& upperValue) + : + AbstractSetting(id, name), + fLowerBound(lowerBound), + fUpperBound(upperBound), + fLowerValue(lowerValue), + fUpperValue(upperValue) +{ +} + + +BVariant +RangeSettingImpl::DefaultValue() const +{ + // this one doesn't really make sense for RangeSetting since it + // describes a pair of values, which BVariant can't readily + // represent. + return BVariant(); +} + + +BVariant RangeSettingImpl::LowerBound() const { return fLowerBound; @@ -317,6 +368,20 @@ RangeSettingImpl::UpperBound() const } +BVariant +RangeSettingImpl::LowerValue() const +{ + return fLowerValue; +} + + +BVariant +RangeSettingImpl::UpperValue() const +{ + return fUpperValue; +} + + // #pragma mark - RectSettingImpl diff --git a/src/apps/debugger/settings/generic/Setting.h b/src/apps/debugger/settings/generic/Setting.h index e779451..baa8803 100644 --- a/src/apps/debugger/settings/generic/Setting.h +++ b/src/apps/debugger/settings/generic/Setting.h @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx. - * Copyright 2011, Rene Gollent, rene@xxxxxxxxxxx. + * Copyright 2011-2013, Rene Gollent, rene@xxxxxxxxxxx. * Distributed under the terms of the MIT License. */ #ifndef SETTING_H @@ -18,6 +18,7 @@ enum setting_type { SETTING_TYPE_BOOL, SETTING_TYPE_FLOAT, SETTING_TYPE_OPTIONS, + SETTING_TYPE_BOUNDED, SETTING_TYPE_RANGE, SETTING_TYPE_RECT }; @@ -78,7 +79,7 @@ public: }; -class RangeSetting : public virtual Setting { +class BoundedSetting : public virtual Setting { public: virtual setting_type Type() const; @@ -87,6 +88,14 @@ public: }; +class RangeSetting : public virtual BoundedSetting { + virtual setting_type Type() const; + + virtual BVariant LowerValue() const = 0; + virtual BVariant UpperValue() const = 0; +}; + + class RectSetting : public virtual Setting { public: virtual setting_type Type() const; @@ -164,9 +173,9 @@ private: }; -class RangeSettingImpl : public AbstractSetting, public RangeSetting { +class BoundedSettingImpl : public AbstractSetting, public BoundedSetting { public: - RangeSettingImpl(const BString& id, + BoundedSettingImpl(const BString& id, const BString& name, const BVariant& lowerBound, const BVariant& upperBound, @@ -184,6 +193,30 @@ private: }; +class RangeSettingImpl : public AbstractSetting, public RangeSetting { +public: + RangeSettingImpl(const BString& id, + const BString& name, + const BVariant& lowerBound, + const BVariant& upperBound, + const BVariant& lowerValue, + const BVariant& upperValue); + + virtual BVariant DefaultValue() const; + + virtual BVariant LowerBound() const; + virtual BVariant UpperBound() const; + virtual BVariant LowerValue() const; + virtual BVariant UpperValue() const; + +private: + BVariant fLowerBound; + BVariant fUpperBound; + BVariant fLowerValue; + BVariant fUpperValue; +}; + + class RectSettingImpl : public AbstractSetting, public RectSetting { public: RectSettingImpl(const BString& id,