cohtml::Property
Represents a property of a type exposed to the scripting. This interface type-erases access to a native property so the SDK can interact with it without knowing its concrete C++ type. More…
#include <Property.h>
Inherited by cohtml::AdjustPointer, cohtml::TypedProperty< ValueType >, cohtml::TypedProperty< const PropertyType &>, cohtml::TypedProperty< const PropertyType(&)[ArraySize]>, cohtml::TypedProperty< ReturnsByRef< Getter >::ValuePassType >
Public Functions
| Name | |
|---|---|
| Property(const char * name, bool isByRef =true) Create a new property. | |
| virtual | ~Property() |
| const char * | GetName() const Get the name of the property. |
| bool | IsByRef() const Can this property be exported By-Ref. Temporaries can not be exported by reference. |
| virtual void * | Bind(Binder * binder, void * object) const =0 Expose the property’s name and value to a binder. |
| virtual void * | BindValue(Binder * binder, void * object) const =0 Expose only the value of the property to a binder. |
| virtual void * | Read(Binder * binder, void * object) const =0 Read the value from a binder. |
| virtual void * | ReadValue(Binder * binder, void * object) const =0 Read only the value of the property from a binder. |
| virtual Property * | Clone() const =0 Clone the property. |
| virtual bool | ToBoolean(void * object, bool * boolean) const =0 Convert the property value to a boolean. |
| virtual bool | ToNumber(void * object, float * number) const =0 Convert the property value to a number. |
| virtual bool | ToNumber(void * object, double * number) const Convert the property value to a number with double precision. |
| virtual bool | ToString(void * object, char * buffer, size_t * length) const =0 Convert the property value to a string representation. |
| virtual bool | ToColor(void * object, renoir::Color * color) const =0 Convert the property value to a color value. Implementation is optional. Provides improved performance for data-bind-style-* attributes that accept color values, such as background-color. |
| virtual bool | ToTransformMatrix2D(void * object, float matrix[6]) const =0 Convert the property value to a matrix. Implementation is optional. Provides improved performance for data-bind-style-transform2d. |
| virtual bool | ToArray(Binder * binder, void * object, ArrayInfo * arrayInfo) const =0 Convert the property value to an array type information. Conversion should succeed only when the underlying type is an array. |
| virtual bool | ToPair(Binder * binder, void * object, PairInfo * pairInfo) const =0 Convert the property value to a pair type information. Conversion should succeed only when the underlying type is a pair. |
| virtual bool | ToMap(Binder * binder, void * object, MapInfo * mapInfo) const =0 Convert the property value to a map type information. Conversion should succeed only when the underlying type is a map. |
| virtual bool | ToObject(Binder * binder, void * object, ObjectInfo * typeInfo) const =0 Convert the property value to an object type information. Conversion should succeed only when the underlying type is an object (UserType). |
| void *COHERENT_CDECL | operator new(size_t bytes) |
| void COHERENT_CDECL | operator delete(void * memory) |
| void *COHERENT_CDECL | operator new[](size_t bytes) |
| void COHERENT_CDECL | operator delete[](void * memory) |
Protected Attributes
| Name | |
|---|---|
| const char * | m_Name |
| bool | m_IsByRef |
Detailed Description
class cohtml::Property;
Represents a property of a type exposed to the scripting. This interface type-erases access to a native property so the SDK can interact with it without knowing its concrete C++ type.
All virtual methods in this interface must be implemented by derived Property classes for data binding to function correctly. Conversion methods (ToString, ToBool, ToNumber, etc.) are invoked by the SDK only when a conversion is actually required; not all properties are expected to support every conversion, and unsupported conversions should simply fail gracefully. The Bind and Read methods perform the actual data exchange with the script. When the SDK requires knowledge of the underlying native type for type-sensitive operations such as expression evaluation, it obtains it through BindValue() using a dummy binder that does not expose the value to the script.
The object pointer arguments and, for non-primitive types, the UserData pointers in the various *Info structures are not required to reference concrete C++ objects. They may represent intermediate handles, wrapper pointers, or any abstraction meaningful to the property’s implementation. For example, when navigating a property chain such as model.prop1.prop2, the UserData stored in the typeInfo output parameter by prop1::ToObject(binder, modelUserData, prop1TypeInfo) will be passed as the object argument to prop2’s methods (e.g., prop2.ToString(binder, prop1TypeInfo.UserData)). Each property implementation is responsible for interpreting this pointer, resolving the correct underlying data, and exposing it through the binder. In Safe Data Binding mode, the SDK never caches these UserData pointers; each access re-queries them starting from the top-level object.
Public Functions Documentation
function Property
Property(
const char * name,
bool isByRef =true
)
Create a new property.
Parameters:
- name - name of the property. This name will be used in the scripting
- isByRef - whether this property can be exposed ByRef to the scripting
Note: name must live until cohtml::IViewListener::OnBindingsReleased is called.
function ~Property
virtual ~Property()
function GetName
inline const char * GetName() const
Get the name of the property.
Return: the name of the property
function IsByRef
inline bool IsByRef() const
Can this property be exported By-Ref. Temporaries can not be exported by reference.
Return: true if the property can be exported safely by reference.
function Bind
virtual void * Bind(
Binder * binder,
void * object
) const =0
Expose the property’s name and value to a binder.
Parameters:
- binder - the binder to use
- object - object to get the property value from
Return: - adjusted object pointer if necessary
Reimplemented by: cohtml::FieldProperty< PropertyType(Class::*)>::Bind, cohtml::FieldProperty< PropertyType(Class::*)[ArraySize]>::Bind, cohtml::ConcreteProperty::Bind, cohtml::ConcretePropertyReadOnly::Bind, cohtml::AdjustPointer::Bind
function BindValue
virtual void * BindValue(
Binder * binder,
void * object
) const =0
Expose only the value of the property to a binder.
Parameters:
- binder - the binder to use
- object - object to get the property value from
Return: - adjusted object pointer if necessary
Note: This method should always bind a value. If there is no valid value, the implementation must call binder->BindNull();
Reimplemented by: cohtml::FieldProperty< PropertyType(Class::*)>::BindValue, cohtml::FieldProperty< PropertyType(Class::*)[ArraySize]>::BindValue, cohtml::ConcreteProperty::BindValue, cohtml::ConcretePropertyReadOnly::BindValue, cohtml::AdjustPointer::BindValue
function Read
virtual void * Read(
Binder * binder,
void * object
) const =0
Read the value from a binder.
Parameters:
- binder - the binder to use
- object - the object to set the property into
Return: - adjusted object pointer if necessary
Reimplemented by: cohtml::FieldProperty< PropertyType(Class::*)>::Read, cohtml::FieldProperty< PropertyType(Class::*)[ArraySize]>::Read, cohtml::ConcreteProperty::Read, cohtml::ConcretePropertyReadOnly::Read, cohtml::AdjustPointer::Read
function ReadValue
virtual void * ReadValue(
Binder * binder,
void * object
) const =0
Read only the value of the property from a binder.
Parameters:
- binder - the binder to use
- object - the object to set the property into
Return: - adjusted object pointer if necessary
Reimplemented by: cohtml::FieldProperty< PropertyType(Class::*)>::ReadValue, cohtml::FieldProperty< PropertyType(Class::*)[ArraySize]>::ReadValue, cohtml::ConcreteProperty::ReadValue, cohtml::ConcretePropertyReadOnly::ReadValue, cohtml::AdjustPointer::ReadValue
function Clone
virtual Property * Clone() const =0
Clone the property.
Return: a heap allocated copy of the property
Reimplemented by: cohtml::FieldProperty< PropertyType(Class::*)>::Clone, cohtml::FieldProperty< PropertyType(Class::*)[ArraySize]>::Clone, cohtml::ConcreteProperty::Clone, cohtml::ConcretePropertyReadOnly::Clone, cohtml::AdjustPointer::Clone
function ToBoolean
virtual bool ToBoolean(
void * object,
bool * boolean
) const =0
Convert the property value to a boolean.
Parameters:
- object - object to get the property value from
- boolean - where to store the property value
Return: true if conversion is possible and successful
Reimplemented by: cohtml::TypedProperty::ToBoolean, cohtml::TypedProperty::ToBoolean, cohtml::TypedProperty::ToBoolean, cohtml::TypedProperty::ToBoolean, cohtml::AdjustPointer::ToBoolean
function ToNumber
virtual bool ToNumber(
void * object,
float * number
) const =0
Convert the property value to a number.
Parameters:
- object - object to get the property value from
- number - where to store the property value
Return: true if conversion is possible and successful
Reimplemented by: cohtml::TypedProperty::ToNumber, cohtml::TypedProperty::ToNumber, cohtml::TypedProperty::ToNumber, cohtml::TypedProperty::ToNumber, cohtml::AdjustPointer::ToNumber
function ToNumber
virtual bool ToNumber(
void * object,
double * number
) const
Convert the property value to a number with double precision.
Parameters:
- object - object to get the property value from
- number - where to store the property value
Return: true if conversion is possible and successful
Warning: The base implementation uses ToNumber(void*, float*), which truncates the value to a float and is retained only for backwards compatibility. This method will become pure virtual in the future, so derived classes must override it.
Reimplemented by: cohtml::TypedProperty::ToNumber, cohtml::TypedProperty::ToNumber, cohtml::TypedProperty::ToNumber, cohtml::TypedProperty::ToNumber, cohtml::AdjustPointer::ToNumber
function ToString
virtual bool ToString(
void * object,
char * buffer,
size_t * length
) const =0
Convert the property value to a string representation.
Parameters:
- object - object to get the property value from
- buffer - character buffer to receive the string data
- length - input/output parameter; on input, specifies the size of
bufferin bytes; on output, receives the total size required to store the full string (not including any null terminator)
Return: true if conversion is possible and successful
Note: The function writes up to *length bytes into buffer. These may or may not include a null terminator. The caller should append “\0'` if required. If the returned size is greater than the provided buffer capacity, the caller should allocate a larger buffer and call again.
Reimplemented by: cohtml::TypedProperty::ToString, cohtml::TypedProperty::ToString, cohtml::TypedProperty::ToString, cohtml::TypedProperty::ToString, cohtml::AdjustPointer::ToString
function ToColor
virtual bool ToColor(
void * object,
renoir::Color * color
) const =0
Convert the property value to a color value. Implementation is optional. Provides improved performance for data-bind-style-* attributes that accept color values, such as background-color.
Parameters:
- object - object to get the property value from
- color - where to store the property value
Return: true if conversion is possible and successful
Reimplemented by: cohtml::TypedProperty::ToColor, cohtml::TypedProperty::ToColor, cohtml::TypedProperty::ToColor, cohtml::TypedProperty::ToColor, cohtml::AdjustPointer::ToColor
function ToTransformMatrix2D
virtual bool ToTransformMatrix2D(
void * object,
float matrix[6]
) const =0
Convert the property value to a matrix. Implementation is optional. Provides improved performance for data-bind-style-transform2d.
Parameters:
- object - object to get the property value from
- matrix - where to store the property value
Return: true if conversion is possible and successful
Reimplemented by: cohtml::TypedProperty::ToTransformMatrix2D, cohtml::TypedProperty::ToTransformMatrix2D, cohtml::TypedProperty::ToTransformMatrix2D, cohtml::TypedProperty::ToTransformMatrix2D, cohtml::AdjustPointer::ToTransformMatrix2D
function ToArray
virtual bool ToArray(
Binder * binder,
void * object,
ArrayInfo * arrayInfo
) const =0
Convert the property value to an array type information. Conversion should succeed only when the underlying type is an array.
Parameters:
- binder - the binder to use
- object - object to get the property value from
- arrayInfo - output parameter. Information about array type - callbacks, properties, methods
Return: true if conversion is possible and successful
Reimplemented by: cohtml::TypedProperty::ToArray, cohtml::TypedProperty::ToArray, cohtml::TypedProperty::ToArray, cohtml::TypedProperty::ToArray, cohtml::FieldProperty< PropertyType(Class::*)>::ToArray, cohtml::FieldProperty< PropertyType(Class::*)[ArraySize]>::ToArray, cohtml::ConcreteProperty::ToArray, cohtml::ConcretePropertyReadOnly::ToArray, cohtml::AdjustPointer::ToArray
function ToPair
virtual bool ToPair(
Binder * binder,
void * object,
PairInfo * pairInfo
) const =0
Convert the property value to a pair type information. Conversion should succeed only when the underlying type is a pair.
Parameters:
- binder - the binder to use
- object - object to get the property value from
- pairInfo - output parameter. Information about pair type - callbacks, properties, methods
Return: true if conversion is possible and successful
Reimplemented by: cohtml::TypedProperty::ToPair, cohtml::TypedProperty::ToPair, cohtml::TypedProperty::ToPair, cohtml::TypedProperty::ToPair, cohtml::AdjustPointer::ToPair
function ToMap
virtual bool ToMap(
Binder * binder,
void * object,
MapInfo * mapInfo
) const =0
Convert the property value to a map type information. Conversion should succeed only when the underlying type is a map.
Parameters:
- binder - the binder to use
- object - object to get the property value from
- mapInfo - output parameter. Information about map type - callbacks, properties, methods
Return: true if conversion is possible and successful
Reimplemented by: cohtml::TypedProperty::ToMap, cohtml::TypedProperty::ToMap, cohtml::TypedProperty::ToMap, cohtml::TypedProperty::ToMap, cohtml::AdjustPointer::ToMap
function ToObject
virtual bool ToObject(
Binder * binder,
void * object,
ObjectInfo * typeInfo
) const =0
Convert the property value to an object type information. Conversion should succeed only when the underlying type is an object (UserType).
Parameters:
- binder - the binder to use
- object - object to get the property value from
- typeInfo - output parameter. Information about object type - properties and methods if it’s user defined type
Return: true if conversion is possible and successful
Reimplemented by: cohtml::TypedProperty::ToObject, cohtml::TypedProperty::ToObject, cohtml::TypedProperty::ToObject, cohtml::TypedProperty::ToObject, cohtml::AdjustPointer::ToObject
function operator new
static void *COHERENT_CDECL operator new(
size_t bytes
)
function operator delete
static void COHERENT_CDECL operator delete(
void * memory
)
function operator new[]
static void *COHERENT_CDECL operator new[](
size_t bytes
)
function operator delete[]
static void COHERENT_CDECL operator delete[](
void * memory
)
Protected Attributes Documentation
variable m_Name
const char * m_Name;
variable m_IsByRef
bool m_IsByRef;