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:
@@ -20,29 +20,8 @@ BMessageTypeHandler::~BMessageTypeHandler()
|
|||||||
float
|
float
|
||||||
BMessageTypeHandler::SupportsType(Type* type)
|
BMessageTypeHandler::SupportsType(Type* type)
|
||||||
{
|
{
|
||||||
AddressType* addressType = dynamic_cast<AddressType*>(type);
|
if (dynamic_cast<CompoundType*>(type) != NULL
|
||||||
CompoundType* baseType = dynamic_cast<CompoundType*>(type);
|
&& type->Name() == "BMessage")
|
||||||
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")
|
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
{
|
{
|
||||||
ValueLocation* parentLocation = fParent->Location();
|
ValueLocation* parentLocation = fParent->Location();
|
||||||
ValueLocation* location;
|
ValueLocation* location;
|
||||||
CompoundType* type = fParent->GetMessageType();
|
CompoundType* type = dynamic_cast<CompoundType*>(fParent->GetType());
|
||||||
|
|
||||||
status_t error = type->ResolveDataMemberLocation(fMember,
|
status_t error = type->ResolveDataMemberLocation(fMember,
|
||||||
*parentLocation, location);
|
*parentLocation, location);
|
||||||
@@ -92,7 +92,6 @@ BMessageValueNode::BMessageValueNode(ValueNodeChild* nodeChild,
|
|||||||
:
|
:
|
||||||
ValueNode(nodeChild),
|
ValueNode(nodeChild),
|
||||||
fType(type),
|
fType(type),
|
||||||
fMessageType(NULL),
|
|
||||||
fLoader(NULL),
|
fLoader(NULL),
|
||||||
fHeader(NULL),
|
fHeader(NULL),
|
||||||
fFields(NULL),
|
fFields(NULL),
|
||||||
@@ -131,7 +130,6 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
|||||||
if (location == NULL)
|
if (location == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
TRACE_LOCALS(" TYPE_ADDRESS (BMessage)\n");
|
|
||||||
|
|
||||||
// get the value type
|
// get the value type
|
||||||
type_code valueType;
|
type_code valueType;
|
||||||
@@ -146,24 +144,6 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
|||||||
// load the value data
|
// load the value data
|
||||||
|
|
||||||
status_t error = B_OK;
|
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;
|
_location = location;
|
||||||
_value = NULL;
|
_value = NULL;
|
||||||
|
|
||||||
@@ -173,6 +153,8 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
|||||||
BVariant fieldAddress;
|
BVariant fieldAddress;
|
||||||
BVariant what;
|
BVariant what;
|
||||||
|
|
||||||
|
CompoundType* baseType = dynamic_cast<CompoundType*>(fType);
|
||||||
|
|
||||||
for (int32 i = 0; i < baseType->CountDataMembers(); i++) {
|
for (int32 i = 0; i < baseType->CountDataMembers(); i++) {
|
||||||
DataMember* member = baseType->DataMemberAt(i);
|
DataMember* member = baseType->DataMemberAt(i);
|
||||||
if (strcmp(member->Name(), "fHeader") == 0) {
|
if (strcmp(member->Name(), "fHeader") == 0) {
|
||||||
@@ -313,14 +295,12 @@ BMessageValueNode::CreateChildren()
|
|||||||
if (!fChildren.IsEmpty())
|
if (!fChildren.IsEmpty())
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
if (fMessageType == NULL)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
DataMember* member = NULL;
|
DataMember* member = NULL;
|
||||||
Type* whatType = NULL;
|
Type* whatType = NULL;
|
||||||
|
|
||||||
for (int32 i = 0; i < fMessageType->CountDataMembers(); i++) {
|
CompoundType* messageType = dynamic_cast<CompoundType*>(fType);
|
||||||
member = fMessageType->DataMemberAt(i);
|
for (int32 i = 0; i < messageType->CountDataMembers(); i++) {
|
||||||
|
member = messageType->DataMemberAt(i);
|
||||||
if (strcmp(member->Name(), "what") == 0) {
|
if (strcmp(member->Name(), "what") == 0) {
|
||||||
whatType = member->GetType();
|
whatType = member->GetType();
|
||||||
break;
|
break;
|
||||||
@@ -346,8 +326,9 @@ BMessageValueNode::CreateChildren()
|
|||||||
_GetTypeForTypeCode(type, fieldType);
|
_GetTypeForTypeCode(type, fieldType);
|
||||||
|
|
||||||
BMessageFieldNodeChild* node = new(std::nothrow)
|
BMessageFieldNodeChild* node = new(std::nothrow)
|
||||||
BMessageFieldNodeChild(this, fieldType != NULL ? fieldType : fType,
|
BMessageFieldNodeChild(this,
|
||||||
name, type, count);
|
fieldType != NULL ? fieldType : fType, name, type,
|
||||||
|
count);
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
@@ -589,7 +570,7 @@ BMessageValueNode::BMessageFieldNode::BMessageFieldNode(
|
|||||||
:
|
:
|
||||||
ValueNode(child),
|
ValueNode(child),
|
||||||
fName(name),
|
fName(name),
|
||||||
fType(parent->fMessageType),
|
fType(parent->GetType()),
|
||||||
fParent(parent),
|
fParent(parent),
|
||||||
fFieldType(type),
|
fFieldType(type),
|
||||||
fFieldCount(count)
|
fFieldCount(count)
|
||||||
@@ -694,7 +675,7 @@ BMessageValueNode::BMessageFieldNodeChild::Parent() const
|
|||||||
bool
|
bool
|
||||||
BMessageValueNode::BMessageFieldNodeChild::IsInternal() const
|
BMessageValueNode::BMessageFieldNodeChild::IsInternal() const
|
||||||
{
|
{
|
||||||
return fFieldCount > 1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,6 @@ public:
|
|||||||
virtual int32 CountChildren() const;
|
virtual int32 CountChildren() const;
|
||||||
virtual ValueNodeChild* ChildAt(int32 index) const;
|
virtual ValueNodeChild* ChildAt(int32 index) const;
|
||||||
|
|
||||||
CompoundType* GetMessageType() const
|
|
||||||
{ return fMessageType; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _GetTypeForTypeCode(type_code type,
|
status_t _GetTypeForTypeCode(type_code type,
|
||||||
Type*& _type);
|
Type*& _type);
|
||||||
@@ -61,7 +58,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Type* fType;
|
Type* fType;
|
||||||
CompoundType* fMessageType;
|
|
||||||
ChildNodeList fChildren;
|
ChildNodeList fChildren;
|
||||||
ValueLoader* fLoader;
|
ValueLoader* fLoader;
|
||||||
BVariant fDataLocation;
|
BVariant fDataLocation;
|
||||||
|
|||||||
Reference in New Issue
Block a user