|
|
@@ -144,201 +144,131 @@ private:
|
|
|
bool temporary_;
|
|
|
};
|
|
|
|
|
|
-/// Template implementation of the enum attribute accessor invoke helper class.
|
|
|
-template <typename T, typename U> class EnumAttributeAccessorImpl : public AttributeAccessor
|
|
|
+/// Template implementation of the variant attribute accessor.
|
|
|
+/// \tparam TClassType Serializable class type.
|
|
|
+/// \tparam TGetFunction `getFunction(const TClassType& self, Variant& value)`
|
|
|
+/// \tparam TSetFunction `setFunction(TClassType& self, const Variant& value)`
|
|
|
+template <class TClassType, class TGetFunction, class TSetFunction>
|
|
|
+class VariantAttributeAccessorImpl : public AttributeAccessor
|
|
|
{
|
|
|
public:
|
|
|
- using GetFunctionPtr = U (T::*)() const;
|
|
|
- using SetFunctionPtr = void (T::*)(U);
|
|
|
-
|
|
|
- /// Construct with function pointers.
|
|
|
- EnumAttributeAccessorImpl(GetFunctionPtr getFunction, SetFunctionPtr setFunction) :
|
|
|
- getFunction_(getFunction),
|
|
|
- setFunction_(setFunction)
|
|
|
- {
|
|
|
- assert(getFunction_);
|
|
|
- assert(setFunction_);
|
|
|
- }
|
|
|
+ /// Construct.
|
|
|
+ VariantAttributeAccessorImpl(TGetFunction getFunction, TSetFunction setFunction) : getFunction_(getFunction), setFunction_(setFunction) { }
|
|
|
|
|
|
/// Invoke getter function.
|
|
|
- virtual void Get(const Serializable* ptr, Variant& dest) const override
|
|
|
+ virtual void Get(const Serializable* ptr, Variant& value) const override
|
|
|
{
|
|
|
assert(ptr);
|
|
|
- const T* classPtr = static_cast<const T*>(ptr);
|
|
|
- dest = (int)(classPtr->*getFunction_)();
|
|
|
+ const auto classPtr = static_cast<const TClassType*>(ptr);
|
|
|
+ getFunction_(*classPtr, value);
|
|
|
}
|
|
|
|
|
|
/// Invoke setter function.
|
|
|
virtual void Set(Serializable* ptr, const Variant& value) override
|
|
|
{
|
|
|
assert(ptr);
|
|
|
- T* classPtr = static_cast<T*>(ptr);
|
|
|
- (classPtr->*setFunction_)((U)value.GetInt());
|
|
|
+ auto classPtr = static_cast<TClassType*>(ptr);
|
|
|
+ setFunction_(*classPtr, value);
|
|
|
}
|
|
|
|
|
|
- /// Class-specific pointer to getter function.
|
|
|
- GetFunctionPtr getFunction_;
|
|
|
- /// Class-specific pointer to setter function.
|
|
|
- SetFunctionPtr setFunction_;
|
|
|
+private:
|
|
|
+ /// Get functor.
|
|
|
+ TGetFunction getFunction_;
|
|
|
+ /// Set functor.
|
|
|
+ TSetFunction setFunction_;
|
|
|
};
|
|
|
|
|
|
-/// Template implementation of the enum attribute accessor that uses free functions invoke helper class.
|
|
|
-template <typename T, typename U> class EnumAttributeAccessorFreeImpl : public AttributeAccessor
|
|
|
+/// Make variant attribute accessor implementation.
|
|
|
+template <class TClassType, class TGetFunction, class TSetFunction>
|
|
|
+SharedPtr<AttributeAccessor> MakeVariantAttributeAccessorImpl(TGetFunction getFunction, TSetFunction setFunction)
|
|
|
{
|
|
|
-public:
|
|
|
- using GetFunctionPtr = U(*)(const T*);
|
|
|
- using SetFunctionPtr = void(*)(T*, U);
|
|
|
+ return SharedPtr<AttributeAccessor>(new VariantAttributeAccessorImpl<TClassType, TGetFunction, TSetFunction>(getFunction, setFunction));
|
|
|
+}
|
|
|
|
|
|
- /// Construct with function pointers.
|
|
|
- EnumAttributeAccessorFreeImpl(GetFunctionPtr getFunction, SetFunctionPtr setFunction) :
|
|
|
- getFunction_(getFunction),
|
|
|
- setFunction_(setFunction)
|
|
|
- {
|
|
|
- assert(getFunction_);
|
|
|
- assert(setFunction_);
|
|
|
- }
|
|
|
+#if 0
|
|
|
+/// Template implementation of the attribute accessor.
|
|
|
+/// \tparam TClassType Serializable class type.
|
|
|
+/// \tparam TVariantType Internal variant type.
|
|
|
+/// \tparam TAttributeType Real attribute type.
|
|
|
+/// \tparam TGetFunction Get function with signature `getFunction(const TClassType& self, TAttributeType& value)`
|
|
|
+/// \tparam TSetFunction Set function with signature `setFunction(TClassType& self, const TAttributeType& value)`
|
|
|
+template <class TClassType, class TVariantType, class TAttributeType, class TGetFunction, class TSetFunction>
|
|
|
+class AttributeAccessorImpl : public AttributeAccessor
|
|
|
+{
|
|
|
+public:
|
|
|
+ /// Construct.
|
|
|
+ AttributeAccessorImpl(TGetFunction getFunction, TSetFunction setFunction) : getFunction_(getFunction), setFunction_(setFunction) { }
|
|
|
|
|
|
/// Invoke getter function.
|
|
|
- virtual void Get(const Serializable* ptr, Variant& dest) const override
|
|
|
+ virtual void Get(const Serializable* ptr, Variant& value) const override
|
|
|
{
|
|
|
assert(ptr);
|
|
|
- const T* classPtr = static_cast<const T*>(ptr);
|
|
|
- dest = (*getFunction_)(classPtr);
|
|
|
+ const auto classPtr = static_cast<const TClassType*>(ptr);
|
|
|
+ TAttributeType attributeValue;
|
|
|
+ getFunction_(*classPtr, attributeValue);
|
|
|
+ value = static_cast<TVariantType>(attributeValue);
|
|
|
}
|
|
|
|
|
|
/// Invoke setter function.
|
|
|
virtual void Set(Serializable* ptr, const Variant& value) override
|
|
|
{
|
|
|
assert(ptr);
|
|
|
- T* classPtr = static_cast<T*>(ptr);
|
|
|
- (*setFunction_)(classPtr, (U)value.GetInt());
|
|
|
+ auto classPtr = static_cast<TClassType*>(ptr);
|
|
|
+ const TAttributeType attributeValue = static_cast<TAttributeType>(value.Get<TVariantType>());
|
|
|
+ setFunction_(*classPtr, value);
|
|
|
}
|
|
|
|
|
|
- /// Class-specific pointer to getter function.
|
|
|
- GetFunctionPtr getFunction_;
|
|
|
- /// Class-specific pointer to setter function.
|
|
|
- SetFunctionPtr setFunction_;
|
|
|
-};
|
|
|
-
|
|
|
-/// Attribute trait (default use const reference for object type).
|
|
|
-template <typename T> struct AttributeTrait
|
|
|
-{
|
|
|
- /// Get function return type.
|
|
|
- using ReturnType = const T&;
|
|
|
- /// Set function parameter type.
|
|
|
- using ParameterType = const T&;
|
|
|
-};
|
|
|
-
|
|
|
-/// Int attribute trait.
|
|
|
-template <> struct AttributeTrait<int>
|
|
|
-{
|
|
|
- using ReturnType = int;
|
|
|
- using ParameterType = int;
|
|
|
-};
|
|
|
-
|
|
|
-/// unsigned attribute trait.
|
|
|
-template <> struct AttributeTrait<unsigned>
|
|
|
-{
|
|
|
- using ReturnType = unsigned;
|
|
|
- using ParameterType = unsigned;
|
|
|
-};
|
|
|
-
|
|
|
-/// Bool attribute trait.
|
|
|
-template <> struct AttributeTrait<bool>
|
|
|
-{
|
|
|
- using ReturnType = bool;
|
|
|
- using ParameterType = bool;
|
|
|
-};
|
|
|
-
|
|
|
-/// Float attribute trait.
|
|
|
-template <> struct AttributeTrait<float>
|
|
|
-{
|
|
|
- using ReturnType = float;
|
|
|
- using ParameterType = float;
|
|
|
-};
|
|
|
-
|
|
|
-/// Mixed attribute trait (use const reference for set function only).
|
|
|
-template <typename T> struct MixedAttributeTrait
|
|
|
-{
|
|
|
- using ReturnType = T;
|
|
|
- using ParameterType = const T&;
|
|
|
+private:
|
|
|
+ /// Get functor.
|
|
|
+ TGetFunction getFunction_;
|
|
|
+ /// Set functor.
|
|
|
+ TSetFunction setFunction_;
|
|
|
};
|
|
|
|
|
|
-/// Template implementation of the attribute accessor invoke helper class.
|
|
|
-template <typename T, typename U, typename Trait> class AttributeAccessorImpl : public AttributeAccessor
|
|
|
+/// Make attribute accessor implementation.
|
|
|
+template <class TClassType, class TVariantType, class TAttributeType, class TGetFunction, class TSetFunction>
|
|
|
+SharedPtr<AttributeAccessor> MakeAttributeAccessorImpl(TGetFunction getFunction, TSetFunction setFunction)
|
|
|
{
|
|
|
-public:
|
|
|
- using GetFunctionPtr = typename Trait::ReturnType (T::*)() const;
|
|
|
- using SetFunctionPtr = void (T::*)(typename Trait::ParameterType);
|
|
|
+ return MakeShared<VariantAttributeAccessorImpl<TClassType, TVariantType, TAttributeType, TGetFunction, TSetFunction>>(getFunction, setFunction);
|
|
|
+}
|
|
|
|
|
|
- /// Construct with function pointers.
|
|
|
- AttributeAccessorImpl(GetFunctionPtr getFunction, SetFunctionPtr setFunction) :
|
|
|
- getFunction_(getFunction),
|
|
|
- setFunction_(setFunction)
|
|
|
- {
|
|
|
- assert(getFunction_);
|
|
|
- assert(setFunction_);
|
|
|
- }
|
|
|
+#endif
|
|
|
|
|
|
- /// Invoke getter function.
|
|
|
- virtual void Get(const Serializable* ptr, Variant& dest) const override
|
|
|
- {
|
|
|
- assert(ptr);
|
|
|
- const T* classPtr = static_cast<const T*>(ptr);
|
|
|
- dest = (classPtr->*getFunction_)();
|
|
|
- }
|
|
|
+/// Make variant attribute accessor with inline get and set code snippets.
|
|
|
+#define URHO3D_MAKE_INLINE_ATTRIBUTE_ACCESSOR(getSnippet, setSnippet) \
|
|
|
+ Urho3D::MakeVariantAttributeAccessorImpl<ClassName>( \
|
|
|
+ [](const ClassName& self, Variant& value) { getSnippet; }, \
|
|
|
+ [](ClassName& self, const Variant& value) { setSnippet; })
|
|
|
|
|
|
- /// Invoke setter function.
|
|
|
- virtual void Set(Serializable* ptr, const Variant& value) override
|
|
|
- {
|
|
|
- assert(ptr);
|
|
|
- T* classPtr = static_cast<T*>(ptr);
|
|
|
- (classPtr->*setFunction_)(value.Get<U>());
|
|
|
- }
|
|
|
-
|
|
|
- /// Class-specific pointer to getter function.
|
|
|
- GetFunctionPtr getFunction_;
|
|
|
- /// Class-specific pointer to setter function.
|
|
|
- SetFunctionPtr setFunction_;
|
|
|
-};
|
|
|
+/// Make member attribute accessor.
|
|
|
+#define URHO3D_MAKE_MEMBER_ATTRIBUTE_ACCESSOR(typeName, variable) URHO3D_MAKE_INLINE_ATTRIBUTE_ACCESSOR( \
|
|
|
+ value = self.variable, \
|
|
|
+ self.variable = value.Get<typeName>())
|
|
|
|
|
|
-/// Template implementation of the attribute accessor that uses free functions invoke helper class.
|
|
|
-template <typename T, typename U, typename Trait> class AttributeAccessorFreeImpl : public AttributeAccessor
|
|
|
-{
|
|
|
-public:
|
|
|
- using GetFunctionPtr = typename Trait::ReturnType(*)(const T*);
|
|
|
- using SetFunctionPtr = void(*)(T*, typename Trait::ParameterType);
|
|
|
+/// Make member attribute accessor with custom epilogue.
|
|
|
+#define URHO3D_MAKE_MEMBER_ATTRIBUTE_ACCESSOR_EX(typeName, variable, epilogue) URHO3D_MAKE_INLINE_ATTRIBUTE_ACCESSOR( \
|
|
|
+ value = self.variable, \
|
|
|
+ self.variable = value.Get<typeName>(); self.epilogue())
|
|
|
|
|
|
- /// Construct with function pointers.
|
|
|
- AttributeAccessorFreeImpl(GetFunctionPtr getFunction, SetFunctionPtr setFunction) :
|
|
|
- getFunction_(getFunction),
|
|
|
- setFunction_(setFunction)
|
|
|
- {
|
|
|
- assert(getFunction_);
|
|
|
- assert(setFunction_);
|
|
|
- }
|
|
|
+/// Make get/set attribute accessor.
|
|
|
+#define URHO3D_MAKE_GET_SET_ATTRIBUTE_ACCESSOR(getFunction, setFunction, typeName) URHO3D_MAKE_INLINE_ATTRIBUTE_ACCESSOR( \
|
|
|
+ value = self.getFunction(), \
|
|
|
+ self.setFunction(value.Get<typeName>()))
|
|
|
|
|
|
- /// Invoke getter function.
|
|
|
- virtual void Get(const Serializable* ptr, Variant& dest) const override
|
|
|
- {
|
|
|
- assert(ptr);
|
|
|
- const T* classPtr = static_cast<const T*>(ptr);
|
|
|
- dest = (*getFunction_)(classPtr);
|
|
|
- }
|
|
|
+/// Make member enum attribute accessor
|
|
|
+#define URHO3D_MAKE_MEMBER_ENUM_ATTRIBUTE_ACCESSOR(variable) URHO3D_MAKE_INLINE_ATTRIBUTE_ACCESSOR( \
|
|
|
+ value = static_cast<int>(self.variable), \
|
|
|
+ self.variable = static_cast<decltype(self.variable)>(value.Get<int>()))
|
|
|
|
|
|
- /// Invoke setter function.
|
|
|
- virtual void Set(Serializable* ptr, const Variant& value) override
|
|
|
- {
|
|
|
- assert(ptr);
|
|
|
- T* classPtr = static_cast<T*>(ptr);
|
|
|
- (*setFunction_)(classPtr, value.Get<U>());
|
|
|
- }
|
|
|
+/// Make member enum attribute accessor with custom epilogue.
|
|
|
+#define URHO3D_MAKE_MEMBER_ENUM_ATTRIBUTE_ACCESSOR_EX(variable, epilogue) URHO3D_MAKE_INLINE_ATTRIBUTE_ACCESSOR( \
|
|
|
+ value = static_cast<int>(self.variable), \
|
|
|
+ self.variable = static_cast<decltype(self.variable)>(value.Get<int>()); self.epilogue())
|
|
|
|
|
|
- /// Class-specific pointer to getter function.
|
|
|
- GetFunctionPtr getFunction_;
|
|
|
- /// Class-specific pointer to setter function.
|
|
|
- SetFunctionPtr setFunction_;
|
|
|
-};
|
|
|
+/// Make get/set enum attribute accessor.
|
|
|
+#define URHO3D_MAKE_GET_SET_ENUM_ATTRIBUTE_ACCESSOR(getFunction, setFunction, typeName) URHO3D_MAKE_INLINE_ATTRIBUTE_ACCESSOR( \
|
|
|
+ value = static_cast<int>(self.getFunction()), \
|
|
|
+ self.setFunction(static_cast<typeName>(value.Get<int>())))
|
|
|
|
|
|
/// Attribute metadata.
|
|
|
namespace AttributeMetadata
|
|
|
@@ -350,26 +280,46 @@ namespace AttributeMetadata
|
|
|
// The following macros need to be used within a class member function such as ClassName::RegisterObject().
|
|
|
// A variable called "context" needs to exist in the current scope and point to a valid Context object.
|
|
|
|
|
|
+/// Define an attribute with custom setter and getter functional objects.
|
|
|
+#define URHO3D_CUSTOM_ATTRIBUTE_IMPL(typeName, name, enumNames, defaultValue, mode, getFunction, setFunction) \
|
|
|
+ context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ Urho3D::GetVariantType<typeName >(), name, MakeVariantAttributeAccessorImpl<ClassName>(getFunction, setFunction), enumNames, defaultValue, mode))
|
|
|
+/// Define an attribute with getter and setter inline code snippets.
|
|
|
+#define URHO3D_INLINE_ATTRIBUTE_IMPL(typeName, name, enumNames, defaultValue, mode, getSnippet, setSnippet) \
|
|
|
+ URHO3D_CUSTOM_ATTRIBUTE_IMPL(typeName, name, enumNames, defaultValue, mode, \
|
|
|
+ [](const ClassName& self, Variant& value) { getSnippet; }, \
|
|
|
+ [](ClassName& self, const Variant& value) { setSnippet; })
|
|
|
+
|
|
|
/// Copy attributes from a base class.
|
|
|
#define URHO3D_COPY_BASE_ATTRIBUTES(sourceClassName) context->CopyBaseAttributes<sourceClassName, ClassName>()
|
|
|
/// Remove attribute by name.
|
|
|
#define URHO3D_REMOVE_ATTRIBUTE(name) context->RemoveAttribute<ClassName>(name)
|
|
|
-/// Define an attribute that points to a memory offset in the object.
|
|
|
-#define URHO3D_ATTRIBUTE(name, typeName, variable, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(Urho3D::GetVariantType<typeName >(), name, offsetof(ClassName, variable), defaultValue, mode))
|
|
|
-/// Define an attribute that points to a memory offset in the object, and uses zero-based enum values, which are mapped to names through an array of C string pointers.
|
|
|
-#define URHO3D_ENUM_ATTRIBUTE(name, variable, enumNames, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(name, offsetof(ClassName, variable), enumNames, defaultValue, mode))
|
|
|
+/// Define an object member attribute.
|
|
|
+#define URHO3D_ATTRIBUTE(name, typeName, variable, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ Urho3D::GetVariantType<typeName >(), name, URHO3D_MAKE_MEMBER_ATTRIBUTE_ACCESSOR(typeName, variable), nullptr, defaultValue, mode))
|
|
|
+/// Define an object member attribute. Custom epilogue member function is called when attribute set.
|
|
|
+#define URHO3D_ATTRIBUTE_EX(name, typeName, variable, epilogue, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ Urho3D::GetVariantType<typeName >(), name, URHO3D_MAKE_MEMBER_ATTRIBUTE_ACCESSOR_EX(typeName, variable, epilogue), nullptr, defaultValue, mode))
|
|
|
/// Define an attribute that uses get and set functions.
|
|
|
-#define URHO3D_ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(Urho3D::GetVariantType<typeName >(), name, new Urho3D::AttributeAccessorImpl<ClassName, typeName, Urho3D::AttributeTrait<typeName > >(&ClassName::getFunction, &ClassName::setFunction), defaultValue, mode))
|
|
|
-/// Define an attribute that uses get and set free functions.
|
|
|
-#define URHO3D_ACCESSOR_ATTRIBUTE_FREE(name, getFunction, setFunction, typeName, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(Urho3D::GetVariantType<typeName >(), name, new Urho3D::AttributeAccessorFreeImpl<ClassName, typeName, Urho3D::AttributeTrait<typeName > >(getFunction, setFunction), defaultValue, mode))
|
|
|
-/// Define an attribute that uses get and set functions, and uses zero-based enum values, which are mapped to names through an array of C string pointers.
|
|
|
-#define URHO3D_ENUM_ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, enumNames, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(name, new Urho3D::EnumAttributeAccessorImpl<ClassName, typeName >(&ClassName::getFunction, &ClassName::setFunction), enumNames, defaultValue, mode))
|
|
|
-/// Define an attribute that uses get and set free functions, and uses zero-based enum values, which are mapped to names through an array of C string pointers.
|
|
|
-#define URHO3D_ENUM_ACCESSOR_ATTRIBUTE_FREE(name, getFunction, setFunction, typeName, enumNames, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(name, new Urho3D::EnumAttributeAccessorFreeImpl<ClassName, typeName >(getFunction, setFunction), enumNames, defaultValue, mode))
|
|
|
-/// Define an attribute that uses get and set functions, where the get function returns by value, but the set function uses a reference.
|
|
|
-#define URHO3D_MIXED_ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(Urho3D::GetVariantType<typeName >(), name, new Urho3D::AttributeAccessorImpl<ClassName, typeName, Urho3D::MixedAttributeTrait<typeName > >(&ClassName::getFunction, &ClassName::setFunction), defaultValue, mode))
|
|
|
-/// Define an attribute that uses get and set free functions, where the get function returns by value, but the set function uses a reference.
|
|
|
-#define URHO3D_MIXED_ACCESSOR_ATTRIBUTE_FREE(name, getFunction, setFunction, typeName, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo(Urho3D::GetVariantType<typeName >(), name, new Urho3D::AttributeAccessorFreeImpl<ClassName, typeName, Urho3D::MixedAttributeTrait<typeName > >(getFunction, setFunction), defaultValue, mode))
|
|
|
+#define URHO3D_ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ Urho3D::GetVariantType<typeName >(), name, URHO3D_MAKE_GET_SET_ATTRIBUTE_ACCESSOR(getFunction, setFunction, typeName), nullptr, defaultValue, mode))
|
|
|
+/// Define an object member attribute. Zero-based enum values are mapped to names through an array of C string pointers.
|
|
|
+#define URHO3D_ENUM_ATTRIBUTE(name, variable, enumNames, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ VAR_INT, name, URHO3D_MAKE_MEMBER_ENUM_ATTRIBUTE_ACCESSOR(variable), enumNames, static_cast<int>(defaultValue), mode))
|
|
|
+/// Define an object member attribute. Zero-based enum values are mapped to names through an array of C string pointers. Custom epilogue member function is called when attribute set.
|
|
|
+#define URHO3D_ENUM_ATTRIBUTE_EX(name, variable, epilogue, enumNames, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ VAR_INT, name, URHO3D_MAKE_MEMBER_ENUM_ATTRIBUTE_ACCESSOR_EX(variable, epilogue), enumNames, static_cast<int>(defaultValue), mode))
|
|
|
+/// Define an attribute that uses get and set functions. Zero-based enum values are mapped to names through an array of C string pointers.
|
|
|
+#define URHO3D_ENUM_ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, enumNames, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ VAR_INT, name, URHO3D_MAKE_GET_SET_ENUM_ATTRIBUTE_ACCESSOR(getFunction, setFunction, typeName), enumNames, static_cast<int>(defaultValue), mode))
|
|
|
+/// Define an attribute with custom setter and getter.
|
|
|
+#define URHO3D_CUSTOM_ATTRIBUTE(name, typeName, getFunction, setFunction, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ URHO3D_CUSTOM_ATTRIBUTE_IMPL(typeName, name, nullptr, defaultValue, mode, getFunction, setFunction)
|
|
|
+/// Define an enum attribute with custom setter and getter. Zero-based enum values are mapped to names through an array of C string pointers.
|
|
|
+#define URHO3D_CUSTOM_ENUM_ATTRIBUTE(name, getFunction, setFunction, enumNames, defaultValue, mode) context->RegisterAttribute<ClassName>(Urho3D::AttributeInfo( \
|
|
|
+ URHO3D_CUSTOM_ATTRIBUTE_IMPL(int, name, enumNames, defaultValue, mode, getFunction, setFunction)
|
|
|
+/// Deprecated. Use URHO3D_ACCESSOR_ATTRIBUTE instead.
|
|
|
+#define URHO3D_MIXED_ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode) URHO3D_ACCESSOR_ATTRIBUTE(name, getFunction, setFunction, typeName, defaultValue, mode)
|
|
|
/// Update the default value of an already registered attribute.
|
|
|
#define URHO3D_UPDATE_ATTRIBUTE_DEFAULT_VALUE(name, defaultValue) context->UpdateAttributeDefaultValue<ClassName>(name, defaultValue)
|
|
|
|