/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */ #include "stdafx.h" #include "V8DataModel/ContentProvider.h" #include "Util/AnimationId.h" #include "V8DataModel/Workspace.h" #include "V8DataModel/Camera.h" #include "util/standardout.h" namespace RBX { // TODO: Refactor: It is a little ugly to have to implement these 6 functions for each "ContentID" derived class // Potentially we can template this a little. Maybe define a templated ContentIDPropDescriptor or something. template<> std::string StringConverter::convertToString(const AnimationId& value) { return value.toString(); } template<> bool StringConverter::convertToValue(const std::string& text, AnimationId& value) { value = text; return true; } namespace Reflection { template<> const Type& Type::getSingleton() { return Type::singleton(); } template<> void TypedPropertyDescriptor::readValue(DescribedBase* instance, const XmlElement* element, IReferenceBinder& binder) const { if (!element->isXsiNil()) { ContentId value; if (element->getValue(value)) setValue(instance, value); } } template<> void TypedPropertyDescriptor::writeValue(const DescribedBase* instance, XmlElement* element) const { element->setValue(ContentId(getValue(instance))); } template<> RBX::AnimationId& Variant::convert(void) { if (_type->isType()) { value = RBX::AnimationId(cast()); _type = &Type::singleton(); } return genericConvert(); } template<> int TypedPropertyDescriptor::getDataSize(const DescribedBase* instance) const { return sizeof(RBX::AnimationId) + getValue(instance).toString().size(); } template<> bool TypedPropertyDescriptor::hasStringValue() const { return true; } template<> std::string TypedPropertyDescriptor::getStringValue(const DescribedBase* instance) const{ return StringConverter::convertToString(getValue(instance)); } template<> bool TypedPropertyDescriptor::setStringValue(DescribedBase* instance, const std::string& text) const { RBX::AnimationId value; if (StringConverter::convertToValue(text, value)) { setValue(instance, value); return true; } else return false; } } // namespace Reflection } // namespace RBX