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)
|
CStringTypeHandler::SupportsType(Type* type)
|
||||||
{
|
{
|
||||||
AddressType* addressType = dynamic_cast<AddressType*>(type);
|
AddressType* addressType = dynamic_cast<AddressType*>(type);
|
||||||
|
ArrayType* arrayType = dynamic_cast<ArrayType*>(type);
|
||||||
|
PrimitiveType* baseType = NULL;
|
||||||
|
ModifiedType* modifiedType = NULL;
|
||||||
if (addressType != NULL && addressType->AddressKind()
|
if (addressType != NULL && addressType->AddressKind()
|
||||||
== DERIVED_TYPE_POINTER) {
|
== 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;
|
|
||||||
|
|
||||||
baseType = dynamic_cast<PrimitiveType*>(
|
baseType = dynamic_cast<PrimitiveType*>(
|
||||||
modifiedType->ResolveRawType(false));
|
addressType->BaseType());
|
||||||
if (baseType == NULL)
|
if (baseType == NULL) {
|
||||||
return 0.0f;
|
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;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,10 +67,8 @@ CStringTypeHandler::CreateValueNode(ValueNodeChild* nodeChild, Type* type,
|
|||||||
if (SupportsType(type) == 0.0f)
|
if (SupportsType(type) == 0.0f)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
AddressType* supportedType = dynamic_cast<AddressType*>(type);
|
|
||||||
|
|
||||||
ValueNode* node = new(std::nothrow) CStringValueNode(nodeChild,
|
ValueNode* node = new(std::nothrow) CStringValueNode(nodeChild,
|
||||||
supportedType);
|
type);
|
||||||
|
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
CStringValueNode::CStringValueNode(ValueNodeChild* nodeChild,
|
CStringValueNode::CStringValueNode(ValueNodeChild* nodeChild,
|
||||||
AddressType* type)
|
Type* type)
|
||||||
:
|
:
|
||||||
ChildlessValueNode(nodeChild),
|
ChildlessValueNode(nodeChild),
|
||||||
fType(type)
|
fType(type)
|
||||||
@@ -68,8 +68,13 @@ CStringValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
|||||||
|
|
||||||
BVariant addressData;
|
BVariant addressData;
|
||||||
BString valueData;
|
BString valueData;
|
||||||
status_t error = valueLoader->LoadValue(location, valueType, false,
|
status_t error = B_OK;
|
||||||
addressData);
|
if (dynamic_cast<AddressType*>(fType) != NULL) {
|
||||||
|
error = valueLoader->LoadValue(location, valueType, false,
|
||||||
|
addressData);
|
||||||
|
} else
|
||||||
|
addressData.SetTo(location->PieceAt(0).address);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class AddressType;
|
|||||||
class CStringValueNode : public ChildlessValueNode {
|
class CStringValueNode : public ChildlessValueNode {
|
||||||
public:
|
public:
|
||||||
CStringValueNode(ValueNodeChild* nodeChild,
|
CStringValueNode(ValueNodeChild* nodeChild,
|
||||||
AddressType* type);
|
Type* type);
|
||||||
virtual ~CStringValueNode();
|
virtual ~CStringValueNode();
|
||||||
|
|
||||||
virtual Type* GetType() const;
|
virtual Type* GetType() const;
|
||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
Value*& _value);
|
Value*& _value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AddressType* fType;
|
Type* fType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CSTRING_VALUE_NODE_H
|
#endif // CSTRING_VALUE_NODE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user