Implement special handling for BObjectList.

- BListValueNode now also handles BObjectLists. In the latter's case
  however, it uses the template type parameters to map the array
  elements to their actual type. As before, this requires a debug
  libbe to function.
This commit is contained in:
Rene Gollent 2012-12-03 22:00:54 -05:00
parent ada60b4e3d
commit ede21af844
2 changed files with 42 additions and 9 deletions

View File

@ -21,7 +21,8 @@ float
BListTypeHandler::SupportsType(Type* type)
{
if (dynamic_cast<CompoundType*>(type) != NULL
&& type->Name() == "BList")
&& (type->Name() == "BList"
|| type->Name().Compare("BObjectList", 11) == 0))
return 1.0f;
return 0.0f;

View File

@ -101,7 +101,8 @@ BListValueNode::BListValueNode(ValueNodeChild* nodeChild,
:
ValueNode(nodeChild),
fType(type),
fLoader(NULL)
fLoader(NULL),
fItemCount(0)
{
fType->AcquireReference();
}
@ -153,6 +154,21 @@ BListValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
ValueLocation* memberLocation = NULL;
CompoundType* baseType = dynamic_cast<CompoundType*>(fType);
if (baseType->CountTemplateParameters()) {
// for BObjectList we need to walk up
// the hierarchy: BObjectList -> _PointerList_ -> BList
baseType = dynamic_cast<CompoundType*>(baseType->BaseTypeAt(0)
->GetType());
if (baseType == NULL || baseType->Name() != "_PointerList_")
return B_BAD_DATA;
baseType = dynamic_cast<CompoundType*>(baseType->BaseTypeAt(0)
->GetType());
if (baseType == NULL || baseType->Name() != "BList")
return B_BAD_DATA;
}
for (int32 i = 0; i < baseType->CountDataMembers(); i++) {
DataMember* member = baseType->DataMemberAt(i);
if (strcmp(member->Name(), "fObjectList") == 0) {
@ -213,14 +229,30 @@ BListValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
status_t
BListValueNode::CreateChildren()
{
BString typeName;
TypeLookupConstraints constraints;
constraints.SetTypeKind(TYPE_ADDRESS);
constraints.SetBaseTypeName("void");
if (fItemCount == 0 || fChildrenCreated) {
fChildrenCreated = true;
return B_OK;
}
Type* type = NULL;
status_t result = fLoader->LookupTypeByName(typeName, constraints, type);
if (result != B_OK)
return result;
CompoundType* objectType = dynamic_cast<CompoundType*>(fType);
if (objectType->CountTemplateParameters() != 0) {
AddressType* addressType = NULL;
status_t result = objectType->TemplateParameterAt(0)->GetType()
->CreateDerivedAddressType(DERIVED_TYPE_POINTER, addressType);
if (result != B_OK)
return result;
type = addressType;
} else {
BString typeName;
TypeLookupConstraints constraints;
constraints.SetTypeKind(TYPE_ADDRESS);
constraints.SetBaseTypeName("void");
status_t result = fLoader->LookupTypeByName(typeName, constraints, type);
if (result != B_OK)
return result;
}
for (int32 i = 0; i < fItemCount && i < kMaxArrayElementCount; i++)
{