add_property


Description:

public void add_property (string name, Type property_type, owned ClassGetPropertyCb? getter, owned ClassSetPropertyCb? setter)

Add a property with name to this.

When the property value needs to be getted, getter is called receiving the the class instance as first parameter and user_data as last parameter. When the property value needs to be set, setter is called receiving the the class instance as first parameter, followed by the value to be set and then user_data as the last parameter. When the property is cleared in the Class context, destroy_notify is called with user_data as parameter.

Note that the value returned by getter must be transfer full. In case of non-refcounted boxed types, you should use g_type_pointer instead of the actual boxed Type to ensure that the instance owned by Class is used. If you really want to return a new copy of the boxed type, use JSC_TYPE_VALUE and return a Value created with Value.object that receives the copy as the instance parameter.

Parameters:

this

a Class

name

the property name

property_type

the Type of the property value

getter

a ClassSetPropertyCb to be called to get the property value

setter

a ClassSetPropertyCb to be called to set the property value

destroy_notify

destroy notifier for user_data

user_data

user data to pass to getter and setter




2022 vala-language.org