Value.objectDefinePropertyAccessor

Define or modify a property with @property_name in object referenced by @value. When the property value needs to be getted or set, @getter and @setter callbacks will be called. When the property is cleared in the #JSCClass 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 #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as instance parameter.

class Value
void
objectDefinePropertyAccessor
(,
JSCValuePropertyFlags flags
,,
GCallback getter
,
GCallback setter
,
void* userData
,
GDestroyNotify destroyNotify
)

Parameters

propertyName string

the name of the property to define

flags JSCValuePropertyFlags

#JSCValuePropertyFlags

propertyType GType

the #GType of the property

getter GCallback

a #GCallback to be called to get the property value

setter GCallback

a #GCallback to be called to set the property value

userData void*

user data to pass to @getter and @setter

destroyNotify GDestroyNotify

destroy notifier for @user_data

Meta