Debugger: Cleanups, no functional change.

- Remove out-of-place accessor to type lookup info on ValueLoader.
  Instead, adjust CreateChildren() and CreateChildrenInRange() to take a
  TeamTypeInformation parameter. This can then be used by value nodes that
  need to be able to look up type information in order to properly
  publish their children, such as BList and BMessage. Refactor subclasses
  and callers accordingly
This commit is contained in:
Rene Gollent
2015-06-07 21:40:05 -04:00
parent 5ea6993dc2
commit d2a6418f63
17 changed files with 76 additions and 114 deletions
@@ -1,5 +1,5 @@
/* /*
* Copyright 2012, Rene Gollent, [email protected]. * Copyright 2012-2015, Rene Gollent, [email protected].
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -9,6 +9,7 @@
#include "AutoLocker.h" #include "AutoLocker.h"
#include "StackFrame.h" #include "StackFrame.h"
#include "Team.h"
#include "Thread.h" #include "Thread.h"
#include "TypeHandlerRoster.h" #include "TypeHandlerRoster.h"
#include "ValueNode.h" #include "ValueNode.h"
@@ -107,7 +108,7 @@ ValueNodeManager::ValueNodeChanged(ValueNodeChild* nodeChild,
fListeners.ItemAt(i)->ValueNodeChanged(nodeChild, oldNode, newNode); fListeners.ItemAt(i)->ValueNodeChanged(nodeChild, oldNode, newNode);
if (oldNode != NULL) if (oldNode != NULL)
newNode->CreateChildren(); newNode->CreateChildren(fThread->GetTeam()->GetTeamTypeInformation());
} }
@@ -149,7 +150,8 @@ ValueNodeManager::ValueNodeValueChanged(ValueNode* valueNode)
if (valueNode->ChildCreationNeedsValue() if (valueNode->ChildCreationNeedsValue()
&& !valueNode->ChildrenCreated()) { && !valueNode->ChildrenCreated()) {
status_t error = valueNode->CreateChildren(); status_t error = valueNode->CreateChildren(
fThread->GetTeam()->GetTeamTypeInformation());
if (error == B_OK) { if (error == B_OK) {
for (int32 i = 0; i < valueNode->CountChildren(); i++) { for (int32 i = 0; i < valueNode->CountChildren(); i++) {
ValueNodeChild* child = valueNode->ChildAt(i); ValueNodeChild* child = valueNode->ChildAt(i);
@@ -230,5 +232,6 @@ ValueNodeManager::AddChildNodes(ValueNodeChild* nodeChild)
if (valueNode->ChildrenCreated()) if (valueNode->ChildrenCreated())
return B_OK; return B_OK;
return valueNode->CreateChildren(); return valueNode->CreateChildren(
fThread->GetTeam()->GetTeamTypeInformation());
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2013, Rene Gollent, [email protected]. * Copyright 2012-2015, Rene Gollent, [email protected].
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -154,8 +154,7 @@ ResolveValueNodeValueJob::_ResolveNodeValue()
// resolve the node location and value // resolve the node location and value
ValueLoader valueLoader(fArchitecture, fDebuggerInterface, ValueLoader valueLoader(fArchitecture, fDebuggerInterface,
fTypeInformation, variableCpuState != NULL ? variableCpuState variableCpuState != NULL ? variableCpuState : fCpuState);
: fCpuState);
ValueLocation* location; ValueLocation* location;
Value* value; Value* value;
status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader, status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader,
@@ -186,8 +185,7 @@ status_t
ResolveValueNodeValueJob::_ResolveNodeChildLocation(ValueNodeChild* nodeChild) ResolveValueNodeValueJob::_ResolveNodeChildLocation(ValueNodeChild* nodeChild)
{ {
// resolve the location // resolve the location
ValueLoader valueLoader(fArchitecture, fDebuggerInterface, ValueLoader valueLoader(fArchitecture, fDebuggerInterface, fCpuState);
fTypeInformation, fCpuState);
ValueLocation* location = NULL; ValueLocation* location = NULL;
status_t error = nodeChild->ResolveLocation(&valueLoader, location); status_t error = nodeChild->ResolveLocation(&valueLoader, location);
BReference<ValueLocation> locationReference(location, true); BReference<ValueLocation> locationReference(location, true);
@@ -2027,6 +2027,7 @@ VariablesView::MessageReceived(BMessage* message)
for (int32 i = 0; i < ranges.CountRanges(); i++) { for (int32 i = 0; i < ranges.CountRanges(); i++) {
const Range* range = ranges.RangeAt(i); const Range* range = ranges.RangeAt(i);
result = valueNode->CreateChildrenInRange( result = valueNode->CreateChildrenInRange(
fThread->GetTeam()->GetTeamTypeInformation(),
range->lowerBound, range->upperBound); range->lowerBound, range->upperBound);
if (result != B_OK) if (result != B_OK)
break; break;
+2 -30
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com. * Copyright 2013-2015, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -12,38 +12,19 @@
#include "CpuState.h" #include "CpuState.h"
#include "Register.h" #include "Register.h"
#include "TeamMemory.h" #include "TeamMemory.h"
#include "TeamTypeInformation.h"
#include "Tracing.h" #include "Tracing.h"
#include "TypeLookupConstraints.h"
#include "ValueLocation.h" #include "ValueLocation.h"
ValueLoader::ValueLoader(Architecture* architecture, TeamMemory* teamMemory, ValueLoader::ValueLoader(Architecture* architecture, TeamMemory* teamMemory,
TeamTypeInformation* typeInformation, CpuState* cpuState) CpuState* cpuState)
: :
fArchitecture(architecture), fArchitecture(architecture),
fTeamMemory(teamMemory), fTeamMemory(teamMemory),
fTypeInformation(typeInformation),
fCpuState(cpuState) fCpuState(cpuState)
{ {
fArchitecture->AcquireReference(); fArchitecture->AcquireReference();
fTeamMemory->AcquireReference(); fTeamMemory->AcquireReference();
fTypeInformation->AcquireReference();
if (fCpuState != NULL)
fCpuState->AcquireReference();
}
ValueLoader::ValueLoader(const ValueLoader& other)
:
fArchitecture(other.fArchitecture),
fTeamMemory(other.fTeamMemory),
fTypeInformation(other.fTypeInformation),
fCpuState(other.fCpuState)
{
fArchitecture->AcquireReference();
fTeamMemory->AcquireReference();
fTypeInformation->AcquireReference();
if (fCpuState != NULL) if (fCpuState != NULL)
fCpuState->AcquireReference(); fCpuState->AcquireReference();
} }
@@ -53,7 +34,6 @@ ValueLoader::~ValueLoader()
{ {
fArchitecture->ReleaseReference(); fArchitecture->ReleaseReference();
fTeamMemory->ReleaseReference(); fTeamMemory->ReleaseReference();
fTypeInformation->ReleaseReference();
if (fCpuState != NULL) if (fCpuState != NULL)
fCpuState->ReleaseReference(); fCpuState->ReleaseReference();
} }
@@ -252,11 +232,3 @@ ValueLoader::LoadStringValue(BVariant& location, size_t maxSize, BString& _value
return fTeamMemory->ReadMemoryString(location.ToUInt64(), return fTeamMemory->ReadMemoryString(location.ToUInt64(),
std::min(maxSize, kMaxStringSize), _value); std::min(maxSize, kMaxStringSize), _value);
} }
status_t
ValueLoader::LookupTypeByName(const BString& name,
const TypeLookupConstraints& constraints, Type*& _type)
{
return fTypeInformation->LookupTypeByName(name, constraints, _type);
}
+1 -12
View File
@@ -1,4 +1,5 @@
/* /*
* Copyright 2015, Rene Gollent, rene@gollent.com.
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -14,9 +15,6 @@
class Architecture; class Architecture;
class CpuState; class CpuState;
class TeamMemory; class TeamMemory;
class TeamTypeInformation;
class Type;
class TypeLookupConstraints;
class ValueLocation; class ValueLocation;
@@ -24,10 +22,8 @@ class ValueLoader {
public: public:
ValueLoader(Architecture* architecture, ValueLoader(Architecture* architecture,
TeamMemory* teamMemory, TeamMemory* teamMemory,
TeamTypeInformation* typeInformation,
CpuState* cpuState); CpuState* cpuState);
// cpuState can be NULL // cpuState can be NULL
ValueLoader(const ValueLoader& other);
~ValueLoader(); ~ValueLoader();
Architecture* GetArchitecture() const Architecture* GetArchitecture() const
@@ -43,16 +39,9 @@ public:
status_t LoadStringValue(BVariant& location, status_t LoadStringValue(BVariant& location,
size_t maxSize, BString& _value); size_t maxSize, BString& _value);
status_t LookupTypeByName(const BString& name,
const TypeLookupConstraints& constraints,
Type*& _type);
// returns reference
private: private:
Architecture* fArchitecture; Architecture* fArchitecture;
TeamMemory* fTeamMemory; TeamMemory* fTeamMemory;
TeamTypeInformation*
fTypeInformation;
CpuState* fCpuState; CpuState* fCpuState;
}; };
+4 -2
View File
@@ -1,4 +1,5 @@
/* /*
* Copyright 2015, Rene Gollent, rene@gollent.com.
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -85,7 +86,8 @@ ValueNode::ClearChildren()
status_t status_t
ValueNode::CreateChildrenInRange(int32 lowIndex, int32 highIndex) ValueNode::CreateChildrenInRange(TeamTypeInformation* info, int32 lowIndex,
int32 highIndex)
{ {
return B_NOT_SUPPORTED; return B_NOT_SUPPORTED;
} }
@@ -245,7 +247,7 @@ ChildlessValueNode::ChildlessValueNode(ValueNodeChild* nodeChild)
status_t status_t
ChildlessValueNode::CreateChildren() ChildlessValueNode::CreateChildren(TeamTypeInformation* info)
{ {
return B_OK; return B_OK;
} }
+7 -4
View File
@@ -1,4 +1,5 @@
/* /*
* Copyright 2015, Rene Gollent, rene@gollent.com.
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -11,6 +12,7 @@
#include <Referenceable.h> #include <Referenceable.h>
class TeamTypeInformation;
class Type; class Type;
class Value; class Value;
class ValueLoader; class ValueLoader;
@@ -52,7 +54,7 @@ public:
bool ChildrenCreated() const bool ChildrenCreated() const
{ return fChildrenCreated; } { return fChildrenCreated; }
virtual status_t CreateChildren() = 0; virtual status_t CreateChildren(TeamTypeInformation* info) = 0;
virtual int32 CountChildren() const = 0; virtual int32 CountChildren() const = 0;
virtual ValueNodeChild* ChildAt(int32 index) const = 0; virtual ValueNodeChild* ChildAt(int32 index) const = 0;
@@ -67,8 +69,9 @@ public:
// arbitrarily go outside of the // arbitrarily go outside of the
// specified/supported range. // specified/supported range.
virtual void ClearChildren(); virtual void ClearChildren();
virtual status_t CreateChildrenInRange(int32 lowIndex, virtual status_t CreateChildrenInRange(
int32 highIndex); TeamTypeInformation* info,
int32 lowIndex, int32 highIndex);
virtual status_t SupportedChildRange(int32& lowIndex, virtual status_t SupportedChildRange(int32& lowIndex,
int32& highIndex) const; int32& highIndex) const;
@@ -134,7 +137,7 @@ class ChildlessValueNode : public ValueNode {
public: public:
ChildlessValueNode(ValueNodeChild* nodeChild); ChildlessValueNode(ValueNodeChild* nodeChild);
virtual status_t CreateChildren(); virtual status_t CreateChildren(TeamTypeInformation* info);
virtual int32 CountChildren() const; virtual int32 CountChildren() const;
virtual ValueNodeChild* ChildAt(int32 index) const; virtual ValueNodeChild* ChildAt(int32 index) const;
}; };
@@ -1,4 +1,5 @@
/* /*
* Copyright 2015, Rene Gollent, rene@gollent.com.
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -87,7 +88,7 @@ AddressValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
status_t status_t
AddressValueNode::CreateChildren() AddressValueNode::CreateChildren(TeamTypeInformation* info)
{ {
if (fChild != NULL) if (fChild != NULL)
return B_OK; return B_OK;
@@ -1,4 +1,5 @@
/* /*
* Copyright 2015, Rene Gollent, rene@gollent.com.
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -28,7 +29,7 @@ public:
// locking required // locking required
virtual status_t CreateChildren(); virtual status_t CreateChildren(TeamTypeInformation* info);
virtual int32 CountChildren() const; virtual int32 CountChildren() const;
virtual ValueNodeChild* ChildAt(int32 index) const; virtual ValueNodeChild* ChildAt(int32 index) const;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2013, Rene Gollent, rene@gollent.com. * Copyright 2013-2015, Rene Gollent, rene@gollent.com.
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -75,12 +75,12 @@ AbstractArrayValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
status_t status_t
AbstractArrayValueNode::CreateChildren() AbstractArrayValueNode::CreateChildren(TeamTypeInformation* info)
{ {
if (!fChildren.IsEmpty()) if (!fChildren.IsEmpty())
return B_OK; return B_OK;
return CreateChildrenInRange(0, kMaxArrayElementCount - 1); return CreateChildrenInRange(info, 0, kMaxArrayElementCount - 1);
} }
@@ -117,8 +117,8 @@ AbstractArrayValueNode::ClearChildren()
status_t status_t
AbstractArrayValueNode::CreateChildrenInRange(int32 lowIndex, AbstractArrayValueNode::CreateChildrenInRange(TeamTypeInformation* info,
int32 highIndex) int32 lowIndex, int32 highIndex)
{ {
// TODO: ensure that we don't already have children in the specified // TODO: ensure that we don't already have children in the specified
// index range. These need to be skipped if so. // index range. These need to be skipped if so.
@@ -1,5 +1,5 @@
/* /*
* Copyright 2013, Rene Gollent, rene@gollent.com. * Copyright 2013-2015, Rene Gollent, rene@gollent.com.
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -37,14 +37,15 @@ public:
// locking required // locking required
virtual status_t CreateChildren(); virtual status_t CreateChildren(TeamTypeInformation* info);
virtual int32 CountChildren() const; virtual int32 CountChildren() const;
virtual ValueNodeChild* ChildAt(int32 index) const; virtual ValueNodeChild* ChildAt(int32 index) const;
virtual bool IsRangedContainer() const; virtual bool IsRangedContainer() const;
virtual void ClearChildren(); virtual void ClearChildren();
virtual status_t CreateChildrenInRange(int32 lowIndex, virtual status_t CreateChildrenInRange(
int32 highIndex); TeamTypeInformation* info,
int32 lowIndex, int32 highIndex);
virtual status_t SupportedChildRange(int32& lowIndex, virtual status_t SupportedChildRange(int32& lowIndex,
int32& highIndex) const; int32& highIndex) const;
protected: protected:
@@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2013, Rene Gollent, rene@gollent.com * Copyright 2012-2015, Rene Gollent, rene@gollent.com
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -13,6 +13,7 @@
#include "AddressValueNode.h" #include "AddressValueNode.h"
#include "Architecture.h" #include "Architecture.h"
#include "StringValue.h" #include "StringValue.h"
#include "TeamTypeInformation.h"
#include "Tracing.h" #include "Tracing.h"
#include "Type.h" #include "Type.h"
#include "TypeLookupConstraints.h" #include "TypeLookupConstraints.h"
@@ -163,7 +164,6 @@ BListValueNode::BListValueNode(ValueNodeChild* nodeChild,
: :
ValueNode(nodeChild), ValueNode(nodeChild),
fType(type), fType(type),
fLoader(NULL),
fItemCountType(NULL), fItemCountType(NULL),
fItemCount(0), fItemCount(0),
fCountChildCreated(false) fCountChildCreated(false)
@@ -180,8 +180,6 @@ BListValueNode::~BListValueNode()
if (fItemCountType != NULL) if (fItemCountType != NULL)
fItemCountType->ReleaseReference(); fItemCountType->ReleaseReference();
delete fLoader;
} }
@@ -292,20 +290,14 @@ BListValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
memberLocation = NULL; memberLocation = NULL;
} }
if (fLoader == NULL) {
fLoader = new(std::nothrow)ValueLoader(*valueLoader);
if (fLoader == NULL)
return B_NO_MEMORY;
}
return B_OK; return B_OK;
} }
status_t status_t
BListValueNode::CreateChildren() BListValueNode::CreateChildren(TeamTypeInformation* info)
{ {
return CreateChildrenInRange(0, kMaxArrayElementCount); return CreateChildrenInRange(info, 0, kMaxArrayElementCount);
} }
@@ -348,7 +340,8 @@ BListValueNode::ClearChildren()
status_t status_t
BListValueNode::CreateChildrenInRange(int32 lowIndex, int32 highIndex) BListValueNode::CreateChildrenInRange(TeamTypeInformation* info,
int32 lowIndex, int32 highIndex)
{ {
if (fLocationResolutionState != B_OK) if (fLocationResolutionState != B_OK)
return fLocationResolutionState; return fLocationResolutionState;
@@ -387,7 +380,8 @@ BListValueNode::CreateChildrenInRange(int32 lowIndex, int32 highIndex)
TypeLookupConstraints constraints; TypeLookupConstraints constraints;
constraints.SetTypeKind(TYPE_ADDRESS); constraints.SetTypeKind(TYPE_ADDRESS);
constraints.SetBaseTypeName("void"); constraints.SetBaseTypeName("void");
status_t result = fLoader->LookupTypeByName(typeName, constraints, type); status_t result = info->LookupTypeByName(typeName, constraints,
type);
if (result != B_OK) if (result != B_OK)
return result; return result;
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2013, Rene Gollent, rene@gollent.com. * Copyright 2012-2015, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef BLIST_VALUE_NODE_H #ifndef BLIST_VALUE_NODE_H
@@ -32,15 +32,16 @@ public:
virtual bool ChildCreationNeedsValue() const virtual bool ChildCreationNeedsValue() const
{ return true; } { return true; }
virtual status_t CreateChildren(); virtual status_t CreateChildren(TeamTypeInformation* info);
virtual int32 CountChildren() const; virtual int32 CountChildren() const;
virtual ValueNodeChild* ChildAt(int32 index) const; virtual ValueNodeChild* ChildAt(int32 index) const;
virtual bool IsRangedContainer() const; virtual bool IsRangedContainer() const;
virtual bool IsContainerRangeFixed() const; virtual bool IsContainerRangeFixed() const;
virtual void ClearChildren(); virtual void ClearChildren();
virtual status_t CreateChildrenInRange(int32 lowIndex, virtual status_t CreateChildrenInRange(
int32 highIndex); TeamTypeInformation* info,
int32 lowIndex, int32 highIndex);
virtual status_t SupportedChildRange(int32& lowIndex, virtual status_t SupportedChildRange(int32& lowIndex,
int32& highIndex) const; int32& highIndex) const;
private: private:
@@ -57,7 +58,6 @@ private:
Type* fType; Type* fType;
ChildNodeList fChildren; ChildNodeList fChildren;
ValueLoader* fLoader;
BVariant fDataLocation; BVariant fDataLocation;
BVariant fItemCountLocation; BVariant fItemCountLocation;
Type* fItemCountType; Type* fItemCountType;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2013, Rene Gollent, rene@gollent.com * Copyright 2011-2015, Rene Gollent, rene@gollent.com
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -14,6 +14,7 @@
#include "Architecture.h" #include "Architecture.h"
#include "StringValue.h" #include "StringValue.h"
#include "TeamTypeInformation.h"
#include "Tracing.h" #include "Tracing.h"
#include "Type.h" #include "Type.h"
#include "TypeLookupConstraints.h" #include "TypeLookupConstraints.h"
@@ -109,7 +110,6 @@ BMessageValueNode::BMessageValueNode(ValueNodeChild* nodeChild,
: :
ValueNode(nodeChild), ValueNode(nodeChild),
fType(type), fType(type),
fLoader(NULL),
fHeader(NULL), fHeader(NULL),
fFields(NULL), fFields(NULL),
fData(NULL), fData(NULL),
@@ -125,7 +125,6 @@ BMessageValueNode::~BMessageValueNode()
for (int32 i = 0; i < fChildren.CountItems(); i++) for (int32 i = 0; i < fChildren.CountItems(); i++)
fChildren.ItemAt(i)->ReleaseReference(); fChildren.ItemAt(i)->ReleaseReference();
delete fLoader;
delete fHeader; delete fHeader;
delete[] fFields; delete[] fFields;
delete[] fData; delete[] fData;
@@ -319,18 +318,12 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
if (error != B_OK) if (error != B_OK)
return error; return error;
if (fLoader == NULL) {
fLoader = new(std::nothrow)ValueLoader(*valueLoader);
if (fLoader == NULL)
return B_NO_MEMORY;
}
return B_OK; return B_OK;
} }
status_t status_t
BMessageValueNode::CreateChildren() BMessageValueNode::CreateChildren(TeamTypeInformation* info)
{ {
DataMember* member = NULL; DataMember* member = NULL;
CompoundType* messageType = dynamic_cast<CompoundType*>(fType); CompoundType* messageType = dynamic_cast<CompoundType*>(fType);
@@ -358,7 +351,7 @@ BMessageValueNode::CreateChildren()
&count) == B_OK; i++) { &count) == B_OK; i++) {
fieldType = NULL; fieldType = NULL;
_GetTypeForTypeCode(type, fieldType); _GetTypeForTypeCode(info, type, fieldType);
if (fieldType != NULL) if (fieldType != NULL)
typeRef.SetTo(fieldType, true); typeRef.SetTo(fieldType, true);
@@ -397,8 +390,8 @@ BMessageValueNode::ChildAt(int32 index) const
status_t status_t
BMessageValueNode::_GetTypeForTypeCode(type_code type, BMessageValueNode::_GetTypeForTypeCode(TeamTypeInformation* info,
Type*& _type) type_code type, Type*& _type)
{ {
BString typeName; BString typeName;
TypeLookupConstraints constraints; TypeLookupConstraints constraints;
@@ -494,7 +487,7 @@ BMessageValueNode::_GetTypeForTypeCode(type_code type,
typeName = "char"; typeName = "char";
constraints.SetTypeKind(TYPE_PRIMITIVE); constraints.SetTypeKind(TYPE_PRIMITIVE);
Type* baseType = NULL; Type* baseType = NULL;
status_t result = fLoader->LookupTypeByName(typeName, constraints, status_t result = info->LookupTypeByName(typeName, constraints,
baseType); baseType);
if (result != B_OK) if (result != B_OK)
return result; return result;
@@ -517,7 +510,7 @@ BMessageValueNode::_GetTypeForTypeCode(type_code type,
break; break;
} }
return fLoader->LookupTypeByName(typeName, constraints, _type); return info->LookupTypeByName(typeName, constraints, _type);
} }
@@ -647,17 +640,18 @@ BMessageValueNode::BMessageFieldNode::GetType() const
status_t status_t
BMessageValueNode::BMessageFieldNode::CreateChildren() BMessageValueNode::BMessageFieldNode::CreateChildren(TeamTypeInformation* info)
{ {
Type* type = NULL; Type* type = NULL;
status_t error = fParent->_GetTypeForTypeCode(fFieldType, type); status_t error = fParent->_GetTypeForTypeCode(info, fFieldType, type);
if (error != B_OK) if (error != B_OK)
return error; return error;
BReference<Type> typeRef(type, true); BReference<Type> typeRef(type, true);
for (int32 i = 0; i < fFieldCount; i++) { for (int32 i = 0; i < fFieldCount; i++) {
BMessageFieldNodeChild* child = new(std::nothrow) BMessageFieldNodeChild* child = new(std::nothrow)
BMessageFieldNodeChild(fParent, type, fName, fFieldType, fFieldCount, i); BMessageFieldNodeChild(fParent, type, fName, fFieldType,
fFieldCount, i);
if (child == NULL) if (child == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2011, Rene Gollent, rene@gollent.com. * Copyright 2011-2015, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef BMESSAGE_VALUE_NODE_H #ifndef BMESSAGE_VALUE_NODE_H
@@ -19,8 +19,8 @@ class CompoundType;
class BMessageValueNode : public ValueNode { class BMessageValueNode : public ValueNode {
public: public:
BMessageValueNode(ValueNodeChild* nodeChild, BMessageValueNode(
Type* type); ValueNodeChild* nodeChild, Type* type);
virtual ~BMessageValueNode(); virtual ~BMessageValueNode();
virtual Type* GetType() const; virtual Type* GetType() const;
@@ -31,13 +31,15 @@ public:
virtual bool ChildCreationNeedsValue() const virtual bool ChildCreationNeedsValue() const
{ return true; } { return true; }
virtual status_t CreateChildren(); virtual status_t CreateChildren(TeamTypeInformation* info);
virtual int32 CountChildren() const; virtual int32 CountChildren() const;
virtual ValueNodeChild* ChildAt(int32 index) const; virtual ValueNodeChild* ChildAt(int32 index) const;
private: private:
status_t _GetTypeForTypeCode(type_code type, status_t _GetTypeForTypeCode(
TeamTypeInformation* info,
type_code type,
Type*& _type); Type*& _type);
status_t _FindField(const char* name, status_t _FindField(const char* name,
type_code type, type_code type,
@@ -61,7 +63,6 @@ private:
private: private:
Type* fType; Type* fType;
ChildNodeList fChildren; ChildNodeList fChildren;
ValueLoader* fLoader;
BVariant fDataLocation; BVariant fDataLocation;
BMessage::message_header* BMessage::message_header*
fHeader; fHeader;
@@ -89,7 +90,7 @@ public:
ValueLocation *& _location, ValueLocation *& _location,
Value*& _value); Value*& _value);
virtual status_t CreateChildren(); virtual status_t CreateChildren(TeamTypeInformation* info);
virtual int32 CountChildren() const; virtual int32 CountChildren() const;
virtual ValueNodeChild* ChildAt(int32 index) const; virtual ValueNodeChild* ChildAt(int32 index) const;
@@ -1,4 +1,5 @@
/* /*
* Copyright 2015, Rene Gollent, rene@gollent.com.
* Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -191,7 +192,7 @@ CompoundValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
status_t status_t
CompoundValueNode::CreateChildren() CompoundValueNode::CreateChildren(TeamTypeInformation* info)
{ {
if (!fChildren.IsEmpty()) if (!fChildren.IsEmpty())
return B_OK; return B_OK;
@@ -1,4 +1,5 @@
/* /*
* Copyright 2015, Rene Gollent, rene@gollent.com.
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -29,7 +30,7 @@ public:
// locking required // locking required
virtual status_t CreateChildren(); virtual status_t CreateChildren(TeamTypeInformation* info);
virtual int32 CountChildren() const; virtual int32 CountChildren() const;
virtual ValueNodeChild* ChildAt(int32 index) const; virtual ValueNodeChild* ChildAt(int32 index) const;