Fix handling of string fields in BMessages.

We can't depend specifically on a generic array type of a primitive
being available in the global type cache, because there might not have
been a DIE for it. As such, simply look up the type for the character
primitive and then derive an array type from that instead.
This commit is contained in:
Rene Gollent
2013-04-16 22:57:22 -04:00
parent 1b74b08f75
commit f6c0237372
@@ -1,5 +1,5 @@
/*
* Copyright 2011, Rene Gollent, [email protected]
* Copyright 2011-2013, Rene Gollent, [email protected]
* Distributed under the terms of the MIT License.
*/
@@ -22,6 +22,9 @@
#include "ValueNodeContainer.h"
static const int64 kMaxStringSize = 64;
// #pragma mark - BMessageWhatNodeChild
@@ -471,12 +474,6 @@ BMessageValueNode::_GetTypeForTypeCode(type_code type,
constraints.SetTypeKind(TYPE_COMPOUND);
break;
case B_POINTER_TYPE:
typeName = "";
constraints.SetTypeKind(TYPE_ADDRESS);
constraints.SetBaseTypeName("void");
break;
case B_RECT_TYPE:
typeName = "BRect";
constraints.SetTypeKind(TYPE_COMPOUND);
@@ -493,13 +490,30 @@ BMessageValueNode::_GetTypeForTypeCode(type_code type,
break;
case B_STRING_TYPE:
typeName = "";
constraints.SetTypeKind(TYPE_ARRAY);
constraints.SetBaseTypeName("char");
break;
{
typeName = "char";
constraints.SetTypeKind(TYPE_PRIMITIVE);
Type* baseType = NULL;
status_t result = fLoader->LookupTypeByName(typeName, constraints,
baseType);
if (result != B_OK)
return result;
BReference<Type> typeReference(baseType, true);
ArrayType* arrayType;
result = baseType->CreateDerivedArrayType(0, kMaxStringSize, true,
arrayType);
if (result == B_OK)
_type = arrayType;
return result;
break;
}
case B_POINTER_TYPE:
default:
return B_BAD_VALUE;
typeName = "";
constraints.SetTypeKind(TYPE_ADDRESS);
constraints.SetBaseTypeName("void");
break;
}