object_define_property_accessor


Description:

public void object_define_property_accessor (string property_name, ValuePropertyFlags flags, Type property_type, Callback? getter, Callback? setter, void* user_data, DestroyNotify? destroy_notify)

Define or modify a property with property_name in object referenced by this.

When the property value needs to be getted or set, getter and setter callbacks will be called. When the property is cleared in the Class context, destroy_notify is called with user_data as parameter. This is equivalent to JavaScript <function>Object.defineProperty()</function> when used with an accessor descriptor.

Note that the value returned by getter must be fully transferred. In case of boxed types, you could 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 instance parameter.

Note that getter and setter are called as functions and not methods, so they don't receive an instance as first parameter. Use add_property if you want to add property accessor invoked as a method.

Parameters:

this

a Value

property_name

the name of the property to define

flags

ValuePropertyFlags

property_type

the Type of the property

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