From fc23dd2ca28748edc82b1beb170e2a5c3e66eb22 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 27 Apr 2013 14:21:13 -0400 Subject: [PATCH] Implement ranged container hooks for B{Object}List handler. --- .../value/value_nodes/BListValueNode.cpp | 69 +++++++++++++++---- .../value/value_nodes/BListValueNode.h | 9 ++- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/src/apps/debugger/value/value_nodes/BListValueNode.cpp b/src/apps/debugger/value/value_nodes/BListValueNode.cpp index 86f3c8e4c9..1e949b21cb 100644 --- a/src/apps/debugger/value/value_nodes/BListValueNode.cpp +++ b/src/apps/debugger/value/value_nodes/BListValueNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012, Rene Gollent, rene@gollent.com + * Copyright 2012-2013, Rene Gollent, rene@gollent.com * Distributed under the terms of the MIT License. */ @@ -165,7 +165,8 @@ BListValueNode::BListValueNode(ValueNodeChild* nodeChild, fType(type), fLoader(NULL), fItemCountType(NULL), - fItemCount(0) + fItemCount(0), + fCountChildCreated(false) { fType->AcquireReference(); } @@ -304,19 +305,60 @@ BListValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, status_t BListValueNode::CreateChildren() { - if (fChildrenCreated) - return B_OK; + return CreateChildrenInRange(0, kMaxArrayElementCount); +} + +int32 +BListValueNode::CountChildren() const +{ + return fChildren.CountItems(); +} + + +ValueNodeChild* +BListValueNode::ChildAt(int32 index) const +{ + return fChildren.ItemAt(index); +} + + +bool +BListValueNode::IsRangedContainer() const +{ + return true; +} + + +void +BListValueNode::ClearChildren() +{ + fChildren.MakeEmpty(); + fCountChildCreated = false; + if (fContainer != NULL) + fContainer->NotifyValueNodeChildrenDeleted(this); +} + + +status_t +BListValueNode::CreateChildrenInRange(int32 lowIndex, int32 highIndex) +{ if (fLocationResolutionState != B_OK) return fLocationResolutionState; - if (fItemCountType != NULL) { + if (lowIndex < 0) + lowIndex = 0; + if (highIndex >= fItemCount) + highIndex = fItemCount - 1; + + if (!fCountChildCreated && fItemCountType != NULL) { BListItemCountNodeChild* countChild = new(std::nothrow) BListItemCountNodeChild(fItemCountLocation, this, fItemCountType); if (countChild == NULL) return B_NO_MEMORY; + fCountChildCreated = true; countChild->SetContainer(fContainer); fChildren.AddItem(countChild); } @@ -343,7 +385,7 @@ BListValueNode::CreateChildren() return result; } - for (int32 i = 0; i < fItemCount && i < kMaxArrayElementCount; i++) + for (int32 i = lowIndex; i <= highIndex; i++) { BListElementNodeChild* child = new(std::nothrow) BListElementNodeChild(this, i, type); @@ -362,15 +404,12 @@ BListValueNode::CreateChildren() } -int32 -BListValueNode::CountChildren() const +status_t +BListValueNode::SupportedChildRange(int32& lowIndex, int32& highIndex) const { - return fChildren.CountItems(); + lowIndex = 0; + highIndex = fItemCount - 1; + + return B_OK; } - -ValueNodeChild* -BListValueNode::ChildAt(int32 index) const -{ - return fChildren.ItemAt(index); -} diff --git a/src/apps/debugger/value/value_nodes/BListValueNode.h b/src/apps/debugger/value/value_nodes/BListValueNode.h index 697c666726..e4347b68f3 100644 --- a/src/apps/debugger/value/value_nodes/BListValueNode.h +++ b/src/apps/debugger/value/value_nodes/BListValueNode.h @@ -1,5 +1,5 @@ /* - * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2012-2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef BLIST_VALUE_NODE_H @@ -36,6 +36,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; private: class BListElementNodeChild; class BListItemCountNodeChild; @@ -55,6 +61,7 @@ private: BVariant fItemCountLocation; Type* fItemCountType; int32 fItemCount; + bool fCountChildCreated; };