Method
JavaScriptCoreValueobject_define_property_accessor
Declaration [src]
void
jsc_value_object_define_property_accessor (
JSCValue* value,
const char* property_name,
JSCValuePropertyFlags flags,
GType property_type,
GCallback getter,
GCallback setter,
gpointer user_data,
GDestroyNotify destroy_notify
)
Description [src]
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
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.
Note that getter
and setter
are called as functions and not methods, so they don’t receive an instance as
first parameter. Use jsc_class_add_property()
if you want to add property accessor invoked as a method.
Parameters
property_name
-
Type:
const char*
The name of the property to define.
The data is owned by the caller of the function. The value is a NUL terminated UTF-8 string. flags
-
Type:
JSCValuePropertyFlags
JSCValuePropertyFlags
. property_type
-
Type:
GType
The
GType
of the property. getter
-
Type:
GCallback
A
GCallback
to be called to get the property value.The argument can be NULL
. setter
-
Type:
GCallback
A
GCallback
to be called to set the property value.The argument can be NULL
. user_data
-
Type:
gpointer
User data to pass to
getter
andsetter
.The argument can be NULL
.The data is owned by the caller of the function. destroy_notify
-
Type:
GDestroyNotify
Destroy notifier for
user_data
.The argument can be NULL
.