g_free(prop);
}
-void object_property_add_link(Object *obj, const char *name,
- const char *type, Object **targetp,
- void (*check)(const Object *, const char *,
- Object *, Error **),
- ObjectPropertyLinkFlags flags,
- Error **errp)
+static void object_add_link_prop(Object *obj, const char *name,
+ const char *type, void *ptr,
+ void (*check)(const Object *, const char *,
+ Object *, Error **),
+ ObjectPropertyLinkFlags flags,
+ Error **errp)
{
Error *local_err = NULL;
LinkProperty *prop = g_malloc(sizeof(*prop));
gchar *full_type;
ObjectProperty *op;
- prop->targetp = targetp;
+ if (flags & OBJ_PROP_LINK_DIRECT) {
+ prop->target = ptr;
+ } else {
+ prop->targetp = ptr;
+ }
prop->check = check;
prop->flags = flags;
g_free(full_type);
}
+void object_property_add_link(Object *obj, const char *name,
+ const char *type, Object **targetp,
+ void (*check)(const Object *, const char *,
+ Object *, Error **),
+ ObjectPropertyLinkFlags flags,
+ Error **errp)
+{
+ object_add_link_prop(obj, name, type, targetp, check, flags, errp);
+}
+
void object_property_add_const_link(Object *obj, const char *name,
Object *target, Error **errp)
{
- char *link_type;
- ObjectProperty *op;
-
- link_type = g_strdup_printf("link<%s>", object_get_typename(target));
- op = object_property_add(obj, name, link_type,
- object_get_child_property, NULL,
- NULL, target, errp);
- if (op != NULL) {
- op->resolve = object_resolve_child_property;
- }
- g_free(link_type);
+ object_add_link_prop(obj, name, object_get_typename(target), target,
+ NULL, OBJ_PROP_LINK_DIRECT, errp);
}
gchar *object_get_canonical_path_component(Object *obj)