-void object_property_add(Object *obj, const char *name, const char *type,
+void object_property_add_full(Object *obj, const char *name, const char *type,
ObjectPropertyAccessor *get,
ObjectPropertyAccessor *set,
+ ObjectPropertyResolve *resolve,
ObjectPropertyRelease *release,
void *opaque, Error **errp)
{
@@ -751,12 +747,23 @@ void object_property_add(Object *obj, const char *name,
const char *type,
prop->get = get;
prop->set = set;
+ prop->resolve = resolve;
prop->release = release;
prop->opaque = opaque;
QTAILQ_INSERT_TAIL(&obj->properties, prop, node);
}
+void object_property_add(Object *obj, const char *name, const char *type,
+ ObjectPropertyAccessor *get,
+ ObjectPropertyAccessor *set,
+ ObjectPropertyRelease *release,
+ void *opaque, Error **errp)
+{
+ object_property_add_full(obj, name, type, get, set, NULL, release,
+ opaque, errp);
+}
+
ObjectProperty *object_property_find(Object *obj, const char *name,
Error **errp)
{
@@ -993,6 +1000,11 @@ static void object_get_child_property(Object *obj,
Visitor *v, void *opaque,
g_free(path);
}
+static Object *object_resolve_child_property(Object *parent, void *opaque,
const gchar *part)
+{
+ return opaque;
+}
+
static void object_finalize_child_property(Object *obj, const char *name,
void *opaque)
{
@@ -1009,8 +1021,9 @@ void object_property_add_child(Object *obj, const char
*name,
type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
- object_property_add(obj, name, type, object_get_child_property, NULL,
- object_finalize_child_property, child, &local_err);
+ object_property_add_full(obj, name, type, object_get_child_property, NULL,
+ object_resolve_child_property,
+ object_finalize_child_property, child,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
@@ -1128,6 +1141,12 @@ static void object_set_link_property(Object *obj,
Visitor *v, void *opaque,
}
}
+static Object *object_resolve_link_property(Object *parent, void *opaque,
const gchar *part)
+{
+ LinkProperty *lprop = opaque;
+ return *lprop->child;
+}
+
static void object_release_link_property(Object *obj, const char *name,
void *opaque)
{
@@ -1156,12 +1175,13 @@ void object_property_add_link(Object *obj, const char
*name,
full_type = g_strdup_printf("link<%s>", type);
- object_property_add(obj, name, full_type,
- object_get_link_property,
- check ? object_set_link_property : NULL,
- object_release_link_property,
- prop,
- &local_err);
+ object_property_add_full(obj, name, full_type,
+ object_get_link_property,
+ check ? object_set_link_property : NULL,
+ object_resolve_link_property,
+ object_release_link_property,
+ prop,
+ &local_err);
if (local_err) {
error_propagate(errp, local_err);
g_free(prop);
@@ -1225,11 +1245,8 @@ Object *object_resolve_path_component(Object *parent,
const gchar *part)
return NULL;
}
- if (object_property_is_link(prop)) {
- LinkProperty *lprop = prop->opaque;
- return *lprop->child;
- } else if (object_property_is_child(prop)) {
- return prop->opaque;
+ if (prop->resolve) {
+ return prop->resolve(parent, prop->opaque, part);
} else {
return NULL;
}