Modify the CString type/value handlers to accept character arrays as well as
character pointers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39785 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -23,28 +23,39 @@ float
|
||||
CStringTypeHandler::SupportsType(Type* type)
|
||||
{
|
||||
AddressType* addressType = dynamic_cast<AddressType*>(type);
|
||||
ArrayType* arrayType = dynamic_cast<ArrayType*>(type);
|
||||
PrimitiveType* baseType = NULL;
|
||||
ModifiedType* modifiedType = NULL;
|
||||
if (addressType != NULL && addressType->AddressKind()
|
||||
== DERIVED_TYPE_POINTER) {
|
||||
PrimitiveType* baseType = dynamic_cast<PrimitiveType*>(
|
||||
addressType->BaseType());
|
||||
|
||||
if (baseType == NULL) {
|
||||
ModifiedType* modifiedType = dynamic_cast<ModifiedType*>(
|
||||
addressType->BaseType());
|
||||
if (modifiedType == NULL)
|
||||
return 0.0f;
|
||||
|
||||
== DERIVED_TYPE_POINTER) {
|
||||
baseType = dynamic_cast<PrimitiveType*>(
|
||||
modifiedType->ResolveRawType(false));
|
||||
if (baseType == NULL)
|
||||
return 0.0f;
|
||||
addressType->BaseType());
|
||||
if (baseType == NULL) {
|
||||
modifiedType = dynamic_cast<ModifiedType*>(
|
||||
addressType->BaseType());
|
||||
}
|
||||
} else if (arrayType != NULL) {
|
||||
baseType = dynamic_cast<PrimitiveType*>(
|
||||
arrayType->BaseType());
|
||||
if (baseType == NULL) {
|
||||
modifiedType = dynamic_cast<ModifiedType*>(
|
||||
arrayType->BaseType());
|
||||
}
|
||||
|
||||
if (baseType->TypeConstant() == B_UINT8_TYPE
|
||||
|| baseType->TypeConstant() == B_INT8_TYPE)
|
||||
return 0.8f;
|
||||
}
|
||||
|
||||
if (baseType == NULL && modifiedType == NULL)
|
||||
return 0.0f;
|
||||
else if (modifiedType != NULL) {
|
||||
baseType = dynamic_cast<PrimitiveType*>(
|
||||
modifiedType->ResolveRawType(false));
|
||||
if (baseType == NULL)
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (baseType->TypeConstant() == B_UINT8_TYPE
|
||||
|| baseType->TypeConstant() == B_INT8_TYPE)
|
||||
return 0.8f;
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -56,10 +67,8 @@ CStringTypeHandler::CreateValueNode(ValueNodeChild* nodeChild, Type* type,
|
||||
if (SupportsType(type) == 0.0f)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
AddressType* supportedType = dynamic_cast<AddressType*>(type);
|
||||
|
||||
ValueNode* node = new(std::nothrow) CStringValueNode(nodeChild,
|
||||
supportedType);
|
||||
type);
|
||||
|
||||
if (node == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
CStringValueNode::CStringValueNode(ValueNodeChild* nodeChild,
|
||||
AddressType* type)
|
||||
Type* type)
|
||||
:
|
||||
ChildlessValueNode(nodeChild),
|
||||
fType(type)
|
||||
@@ -68,8 +68,13 @@ CStringValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
||||
|
||||
BVariant addressData;
|
||||
BString valueData;
|
||||
status_t error = valueLoader->LoadValue(location, valueType, false,
|
||||
addressData);
|
||||
status_t error = B_OK;
|
||||
if (dynamic_cast<AddressType*>(fType) != NULL) {
|
||||
error = valueLoader->LoadValue(location, valueType, false,
|
||||
addressData);
|
||||
} else
|
||||
addressData.SetTo(location->PieceAt(0).address);
|
||||
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class AddressType;
|
||||
class CStringValueNode : public ChildlessValueNode {
|
||||
public:
|
||||
CStringValueNode(ValueNodeChild* nodeChild,
|
||||
AddressType* type);
|
||||
Type* type);
|
||||
virtual ~CStringValueNode();
|
||||
|
||||
virtual Type* GetType() const;
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
Value*& _value);
|
||||
|
||||
private:
|
||||
AddressType* fType;
|
||||
Type* fType;
|
||||
};
|
||||
|
||||
#endif // CSTRING_VALUE_NODE_H
|
||||
|
||||
Reference in New Issue
Block a user