Simplification due to better understanding of the node system.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42370 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
aa069e23fa
commit
140b05c8ec
@ -20,29 +20,8 @@ BMessageTypeHandler::~BMessageTypeHandler()
|
||||
float
|
||||
BMessageTypeHandler::SupportsType(Type* type)
|
||||
{
|
||||
AddressType* addressType = dynamic_cast<AddressType*>(type);
|
||||
CompoundType* baseType = dynamic_cast<CompoundType*>(type);
|
||||
ModifiedType* modifiedType = NULL;
|
||||
if (addressType != NULL && addressType->AddressKind()
|
||||
== DERIVED_TYPE_POINTER) {
|
||||
baseType = dynamic_cast<CompoundType*>(
|
||||
addressType->BaseType());
|
||||
if (baseType == NULL) {
|
||||
modifiedType = dynamic_cast<ModifiedType*>(
|
||||
addressType->BaseType());
|
||||
}
|
||||
}
|
||||
|
||||
if (baseType == NULL && modifiedType == NULL)
|
||||
return 0.0f;
|
||||
else if (modifiedType != NULL) {
|
||||
baseType = dynamic_cast<CompoundType*>(
|
||||
modifiedType->ResolveRawType(false));
|
||||
if (baseType == NULL)
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (baseType->ResolveRawType(true)->Name() == "BMessage")
|
||||
if (dynamic_cast<CompoundType*>(type) != NULL
|
||||
&& type->Name() == "BMessage")
|
||||
return 1.0f;
|
||||
|
||||
return 0.0f;
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
{
|
||||
ValueLocation* parentLocation = fParent->Location();
|
||||
ValueLocation* location;
|
||||
CompoundType* type = fParent->GetMessageType();
|
||||
CompoundType* type = dynamic_cast<CompoundType*>(fParent->GetType());
|
||||
|
||||
status_t error = type->ResolveDataMemberLocation(fMember,
|
||||
*parentLocation, location);
|
||||
@ -92,7 +92,6 @@ BMessageValueNode::BMessageValueNode(ValueNodeChild* nodeChild,
|
||||
:
|
||||
ValueNode(nodeChild),
|
||||
fType(type),
|
||||
fMessageType(NULL),
|
||||
fLoader(NULL),
|
||||
fHeader(NULL),
|
||||
fFields(NULL),
|
||||
@ -131,7 +130,6 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
||||
if (location == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
TRACE_LOCALS(" TYPE_ADDRESS (BMessage)\n");
|
||||
|
||||
// get the value type
|
||||
type_code valueType;
|
||||
@ -146,24 +144,6 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
||||
// load the value data
|
||||
|
||||
status_t error = B_OK;
|
||||
CompoundType* baseType = dynamic_cast<CompoundType*>(
|
||||
fType->ResolveRawType(false));
|
||||
AddressType* addressType = dynamic_cast<AddressType*>(fType);
|
||||
if (addressType != NULL) {
|
||||
BVariant address;
|
||||
baseType = dynamic_cast<CompoundType*>(addressType->BaseType()
|
||||
->ResolveRawType(false));
|
||||
error = valueLoader->LoadValue(location, valueType, false,
|
||||
address);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
ValuePieceLocation pieceLocation;
|
||||
pieceLocation.SetToMemory(address.ToUInt64());
|
||||
location->SetPieceAt(0, pieceLocation);
|
||||
}
|
||||
fMessageType = baseType;
|
||||
|
||||
_location = location;
|
||||
_value = NULL;
|
||||
|
||||
@ -173,6 +153,8 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
||||
BVariant fieldAddress;
|
||||
BVariant what;
|
||||
|
||||
CompoundType* baseType = dynamic_cast<CompoundType*>(fType);
|
||||
|
||||
for (int32 i = 0; i < baseType->CountDataMembers(); i++) {
|
||||
DataMember* member = baseType->DataMemberAt(i);
|
||||
if (strcmp(member->Name(), "fHeader") == 0) {
|
||||
@ -313,14 +295,12 @@ BMessageValueNode::CreateChildren()
|
||||
if (!fChildren.IsEmpty())
|
||||
return B_OK;
|
||||
|
||||
if (fMessageType == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
DataMember* member = NULL;
|
||||
Type* whatType = NULL;
|
||||
|
||||
for (int32 i = 0; i < fMessageType->CountDataMembers(); i++) {
|
||||
member = fMessageType->DataMemberAt(i);
|
||||
CompoundType* messageType = dynamic_cast<CompoundType*>(fType);
|
||||
for (int32 i = 0; i < messageType->CountDataMembers(); i++) {
|
||||
member = messageType->DataMemberAt(i);
|
||||
if (strcmp(member->Name(), "what") == 0) {
|
||||
whatType = member->GetType();
|
||||
break;
|
||||
@ -346,8 +326,9 @@ BMessageValueNode::CreateChildren()
|
||||
_GetTypeForTypeCode(type, fieldType);
|
||||
|
||||
BMessageFieldNodeChild* node = new(std::nothrow)
|
||||
BMessageFieldNodeChild(this, fieldType != NULL ? fieldType : fType,
|
||||
name, type, count);
|
||||
BMessageFieldNodeChild(this,
|
||||
fieldType != NULL ? fieldType : fType, name, type,
|
||||
count);
|
||||
if (node == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@ -589,7 +570,7 @@ BMessageValueNode::BMessageFieldNode::BMessageFieldNode(
|
||||
:
|
||||
ValueNode(child),
|
||||
fName(name),
|
||||
fType(parent->fMessageType),
|
||||
fType(parent->GetType()),
|
||||
fParent(parent),
|
||||
fFieldType(type),
|
||||
fFieldCount(count)
|
||||
@ -694,7 +675,7 @@ BMessageValueNode::BMessageFieldNodeChild::Parent() const
|
||||
bool
|
||||
BMessageValueNode::BMessageFieldNodeChild::IsInternal() const
|
||||
{
|
||||
return fFieldCount > 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,9 +35,6 @@ public:
|
||||
virtual int32 CountChildren() const;
|
||||
virtual ValueNodeChild* ChildAt(int32 index) const;
|
||||
|
||||
CompoundType* GetMessageType() const
|
||||
{ return fMessageType; }
|
||||
|
||||
private:
|
||||
status_t _GetTypeForTypeCode(type_code type,
|
||||
Type*& _type);
|
||||
@ -61,7 +58,6 @@ private:
|
||||
|
||||
private:
|
||||
Type* fType;
|
||||
CompoundType* fMessageType;
|
||||
ChildNodeList fChildren;
|
||||
ValueLoader* fLoader;
|
||||
BVariant fDataLocation;
|
||||
|
Loading…
Reference in New Issue
Block a user