Lines Matching refs:obj

62     void (*instance_init)(Object *obj);
63 void (*instance_post_init)(Object *obj);
64 void (*instance_finalize)(Object *obj);
427 static void object_init_with_type(Object *obj, TypeImpl *ti) in object_init_with_type() argument
430 object_init_with_type(obj, type_get_parent(ti)); in object_init_with_type()
434 ti->instance_init(obj); in object_init_with_type()
438 static void object_post_init_with_type(Object *obj, TypeImpl *ti) in object_post_init_with_type() argument
441 ti->instance_post_init(obj); in object_post_init_with_type()
445 object_post_init_with_type(obj, type_get_parent(ti)); in object_post_init_with_type()
449 bool object_apply_global_props(Object *obj, const GPtrArray *props, in object_apply_global_props() argument
462 if (object_dynamic_cast(obj, p->driver) == NULL) { in object_apply_global_props()
465 if (p->optional && !object_property_find(obj, p->property)) { in object_apply_global_props()
469 if (!object_property_parse(obj, p->property, p->value, &err)) { in object_apply_global_props()
539 void object_apply_compat_props(Object *obj) in object_apply_compat_props() argument
544 object_apply_global_props(obj, object_compat_props[i], in object_apply_compat_props()
549 static void object_class_property_init_all(Object *obj) in object_class_property_init_all() argument
554 object_class_property_iter_init(&iter, object_get_class(obj)); in object_class_property_init_all()
557 prop->init(obj, prop); in object_class_property_init_all()
562 static void object_initialize_with_type(Object *obj, size_t size, TypeImpl *type) in object_initialize_with_type() argument
570 memset(obj, 0, type->instance_size); in object_initialize_with_type()
571 obj->class = type->class; in object_initialize_with_type()
572 object_ref(obj); in object_initialize_with_type()
573 object_class_property_init_all(obj); in object_initialize_with_type()
574 obj->properties = g_hash_table_new_full(g_str_hash, g_str_equal, in object_initialize_with_type()
576 object_init_with_type(obj, type); in object_initialize_with_type()
577 object_post_init_with_type(obj, type); in object_initialize_with_type()
611 Object *obj; in object_initialize_child_with_propsv() local
615 obj = OBJECT(childobj); in object_initialize_child_with_propsv()
617 if (!object_set_propv(obj, errp, vargs)) { in object_initialize_child_with_propsv()
621 object_property_add_child(parentobj, propname, obj); in object_initialize_child_with_propsv()
623 uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); in object_initialize_child_with_propsv()
626 object_unparent(obj); in object_initialize_child_with_propsv()
642 object_unref(obj); in object_initialize_child_with_propsv()
660 static void object_property_del_all(Object *obj) in object_property_del_all() argument
669 object_property_iter_init(&iter, obj); in object_property_del_all()
673 prop->release(obj, prop->name, prop->opaque); in object_property_del_all()
681 g_hash_table_unref(obj->properties); in object_property_del_all()
684 static void object_property_del_child(Object *obj, Object *child) in object_property_del_child() argument
690 g_hash_table_iter_init(&iter, obj->properties); in object_property_del_child()
695 prop->release(obj, prop->name, prop->opaque); in object_property_del_child()
701 g_hash_table_iter_init(&iter, obj->properties); in object_property_del_child()
711 void object_unparent(Object *obj) in object_unparent() argument
713 if (obj->parent) { in object_unparent()
714 object_property_del_child(obj->parent, obj); in object_unparent()
718 static void object_deinit(Object *obj, TypeImpl *type) in object_deinit() argument
721 type->instance_finalize(obj); in object_deinit()
725 object_deinit(obj, type_get_parent(type)); in object_deinit()
731 Object *obj = data; in object_finalize() local
732 TypeImpl *ti = obj->class->type; in object_finalize()
734 object_property_del_all(obj); in object_finalize()
735 object_deinit(obj, ti); in object_finalize()
737 g_assert(obj->ref == 0); in object_finalize()
738 g_assert(obj->parent == NULL); in object_finalize()
739 if (obj->free) { in object_finalize()
740 obj->free(obj); in object_finalize()
758 Object *obj; in object_new_with_type() local
773 obj = g_malloc(size); in object_new_with_type()
776 obj = qemu_memalign(align, size); in object_new_with_type()
780 object_initialize_with_type(obj, size, type); in object_new_with_type()
781 obj->free = obj_free; in object_new_with_type()
783 return obj; in object_new_with_type()
806 Object *obj; in object_new_with_props() local
809 obj = object_new_with_propv(typename, parent, id, errp, vargs); in object_new_with_props()
812 return obj; in object_new_with_props()
822 Object *obj; in object_new_with_propv() local
836 obj = object_new_with_type(klass->type); in object_new_with_propv()
838 if (!object_set_propv(obj, errp, vargs)) { in object_new_with_propv()
843 object_property_add_child(parent, id, obj); in object_new_with_propv()
846 uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); in object_new_with_propv()
850 object_unparent(obj); in object_new_with_propv()
856 object_unref(obj); in object_new_with_propv()
857 return obj; in object_new_with_propv()
860 object_unref(obj); in object_new_with_propv()
865 bool object_set_props(Object *obj, in object_set_props() argument
873 ret = object_set_propv(obj, errp, vargs); in object_set_props()
880 bool object_set_propv(Object *obj, in object_set_propv() argument
891 if (!object_property_parse(obj, propname, value, errp)) { in object_set_propv()
901 Object *object_dynamic_cast(Object *obj, const char *typename) in object_dynamic_cast() argument
903 if (obj && object_class_dynamic_cast(object_get_class(obj), typename)) { in object_dynamic_cast()
904 return obj; in object_dynamic_cast()
910 Object *object_dynamic_cast_assert(Object *obj, const char *typename, in object_dynamic_cast_assert() argument
913 trace_object_dynamic_cast_assert(obj ? obj->class->type->name : "(null)", in object_dynamic_cast_assert()
920 for (i = 0; obj && i < OBJECT_CLASS_CAST_CACHE; i++) { in object_dynamic_cast_assert()
921 if (qatomic_read(&obj->class->object_cast_cache[i]) == typename) { in object_dynamic_cast_assert()
926 inst = object_dynamic_cast(obj, typename); in object_dynamic_cast_assert()
928 if (!inst && obj) { in object_dynamic_cast_assert()
930 file, line, func, obj, typename); in object_dynamic_cast_assert()
934 assert(obj == inst); in object_dynamic_cast_assert()
936 if (obj && obj == inst) { in object_dynamic_cast_assert()
938 qatomic_set(&obj->class->object_cast_cache[i - 1], in object_dynamic_cast_assert()
939 qatomic_read(&obj->class->object_cast_cache[i])); in object_dynamic_cast_assert()
941 qatomic_set(&obj->class->object_cast_cache[i - 1], typename); in object_dynamic_cast_assert()
946 return obj; in object_dynamic_cast_assert()
1042 const char *object_get_typename(const Object *obj) in object_get_typename() argument
1044 return obj->class->type->name; in object_get_typename()
1047 ObjectClass *object_get_class(Object *obj) in object_get_class() argument
1049 return obj->class; in object_get_class()
1142 static int do_object_child_foreach(Object *obj, in do_object_child_foreach() argument
1150 g_hash_table_iter_init(&iter, obj->properties); in do_object_child_foreach()
1170 int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), in object_child_foreach() argument
1173 return do_object_child_foreach(obj, fn, opaque, false); in object_child_foreach()
1176 int object_child_foreach_recursive(Object *obj, in object_child_foreach_recursive() argument
1180 return do_object_child_foreach(obj, fn, opaque, true); in object_child_foreach_recursive()
1215 Object *obj = OBJECT(objptr); in object_ref() local
1218 if (!obj) { in object_ref()
1221 ref = qatomic_fetch_inc(&obj->ref); in object_ref()
1224 return obj; in object_ref()
1229 Object *obj = OBJECT(objptr); in object_unref() local
1230 if (!obj) { in object_unref()
1233 g_assert(obj->ref > 0); in object_unref()
1236 if (qatomic_fetch_dec(&obj->ref) == 1) { in object_unref()
1237 object_finalize(obj); in object_unref()
1242 object_property_try_add(Object *obj, const char *name, const char *type, in object_property_try_add() argument
1260 ret = object_property_try_add(obj, full_name, type, get, set, in object_property_try_add()
1272 if (object_property_find(obj, name) != NULL) { in object_property_try_add()
1274 name, object_get_typename(obj)); in object_property_try_add()
1288 g_hash_table_insert(obj->properties, prop->name, prop); in object_property_try_add()
1293 object_property_add(Object *obj, const char *name, const char *type, in object_property_add() argument
1299 return object_property_try_add(obj, name, type, get, set, release, in object_property_add()
1331 ObjectProperty *object_property_find(Object *obj, const char *name) in object_property_find() argument
1334 ObjectClass *klass = object_get_class(obj); in object_property_find()
1341 return g_hash_table_lookup(obj->properties, name); in object_property_find()
1344 ObjectProperty *object_property_find_err(Object *obj, const char *name, in object_property_find_err() argument
1347 ObjectProperty *prop = object_property_find(obj, name); in object_property_find_err()
1350 object_get_typename(obj), name); in object_property_find_err()
1356 Object *obj) in object_property_iter_init() argument
1358 g_hash_table_iter_init(&iter->iter, obj->properties); in object_property_iter_init()
1359 iter->nextclass = object_get_class(obj); in object_property_iter_init()
1410 void object_property_del(Object *obj, const char *name) in object_property_del() argument
1412 ObjectProperty *prop = g_hash_table_lookup(obj->properties, name); in object_property_del()
1415 prop->release(obj, name, prop->opaque); in object_property_del()
1417 g_hash_table_remove(obj->properties, name); in object_property_del()
1420 bool object_property_get(Object *obj, const char *name, Visitor *v, in object_property_get() argument
1424 ObjectProperty *prop = object_property_find_err(obj, name, errp); in object_property_get()
1432 object_get_typename(obj), name); in object_property_get()
1435 prop->get(obj, v, name, prop->opaque, &err); in object_property_get()
1440 bool object_property_set(Object *obj, const char *name, Visitor *v, in object_property_set() argument
1444 ObjectProperty *prop = object_property_find_err(obj, name, errp); in object_property_set()
1452 object_get_typename(obj), name); in object_property_set()
1455 prop->set(obj, v, name, prop->opaque, errp); in object_property_set()
1459 bool object_property_set_str(Object *obj, const char *name, in object_property_set_str() argument
1463 bool ok = object_property_set_qobject(obj, name, QOBJECT(qstr), errp); in object_property_set_str()
1469 char *object_property_get_str(Object *obj, const char *name, in object_property_get_str() argument
1472 QObject *ret = object_property_get_qobject(obj, name, errp); in object_property_get_str()
1492 bool object_property_set_link(Object *obj, const char *name, in object_property_set_link() argument
1500 return object_property_set_str(obj, name, path ?: "", errp); in object_property_set_link()
1503 Object *object_property_get_link(Object *obj, const char *name, in object_property_get_link() argument
1506 char *str = object_property_get_str(obj, name, errp); in object_property_get_link()
1521 bool object_property_set_bool(Object *obj, const char *name, in object_property_set_bool() argument
1525 bool ok = object_property_set_qobject(obj, name, QOBJECT(qbool), errp); in object_property_set_bool()
1531 bool object_property_get_bool(Object *obj, const char *name, in object_property_get_bool() argument
1534 QObject *ret = object_property_get_qobject(obj, name, errp); in object_property_get_bool()
1554 bool object_property_set_int(Object *obj, const char *name, in object_property_set_int() argument
1558 bool ok = object_property_set_qobject(obj, name, QOBJECT(qnum), errp); in object_property_set_int()
1564 int64_t object_property_get_int(Object *obj, const char *name, in object_property_get_int() argument
1567 QObject *ret = object_property_get_qobject(obj, name, errp); in object_property_get_int()
1586 static void object_property_init_defval(Object *obj, ObjectProperty *prop) in object_property_init_defval() argument
1591 prop->set(obj, v, prop->name, prop->opaque, &error_abort); in object_property_init_defval()
1630 bool object_property_set_uint(Object *obj, const char *name, in object_property_set_uint() argument
1634 bool ok = object_property_set_qobject(obj, name, QOBJECT(qnum), errp); in object_property_set_uint()
1640 uint64_t object_property_get_uint(Object *obj, const char *name, in object_property_get_uint() argument
1643 QObject *ret = object_property_get_qobject(obj, name, errp); in object_property_get_uint()
1667 int object_property_get_enum(Object *obj, const char *name, in object_property_get_enum() argument
1672 ObjectProperty *prop = object_property_find_err(obj, name, errp); in object_property_get_enum()
1682 object_get_class(obj)), typename); in object_property_get_enum()
1688 str = object_property_get_str(obj, name, errp); in object_property_get_enum()
1699 bool object_property_parse(Object *obj, const char *name, in object_property_parse() argument
1703 bool ok = object_property_set(obj, name, v, errp); in object_property_parse()
1709 char *object_property_print(Object *obj, const char *name, bool human, in object_property_print() argument
1716 if (!object_property_get(obj, name, v, errp)) { in object_property_print()
1727 const char *object_property_get_type(Object *obj, const char *name, Error **errp) in object_property_get_type() argument
1729 ObjectProperty *prop = object_property_find_err(obj, name, errp); in object_property_get_type()
1764 static void object_get_child_property(Object *obj, Visitor *v, in object_get_child_property() argument
1782 static void object_finalize_child_property(Object *obj, const char *name, in object_finalize_child_property() argument
1795 object_property_try_add_child(Object *obj, const char *name, in object_property_try_add_child() argument
1805 op = object_property_try_add(obj, name, type, object_get_child_property, in object_property_try_add_child()
1813 child->parent = obj; in object_property_try_add_child()
1818 object_property_add_child(Object *obj, const char *name, in object_property_add_child() argument
1821 return object_property_try_add_child(obj, name, child, &error_abort); in object_property_add_child()
1824 void object_property_allow_set_link(const Object *obj, const char *name, in object_property_allow_set_link() argument
1841 object_link_get_targetp(Object *obj, LinkProperty *lprop) in object_link_get_targetp() argument
1846 return (void *)obj + lprop->offset; in object_link_get_targetp()
1852 static void object_get_link_property(Object *obj, Visitor *v, in object_get_link_property() argument
1857 Object **targetp = object_link_get_targetp(obj, lprop); in object_get_link_property()
1879 static Object *object_resolve_link(Object *obj, const char *name, in object_resolve_link() argument
1888 type = object_property_get_type(obj, name, NULL); in object_resolve_link()
1911 static void object_set_link_property(Object *obj, Visitor *v, in object_set_link_property() argument
1917 Object **targetp = object_link_get_targetp(obj, prop); in object_set_link_property()
1927 new_target = object_resolve_link(obj, name, path, errp); in object_set_link_property()
1938 prop->check(obj, name, new_target, &local_err); in object_set_link_property()
1959 static void object_release_link_property(Object *obj, const char *name, in object_release_link_property() argument
1963 Object **targetp = object_link_get_targetp(obj, prop); in object_release_link_property()
1974 object_add_link_prop(Object *obj, const char *name, in object_add_link_prop() argument
1994 op = object_property_add(obj, name, full_type, in object_add_link_prop()
2004 object_property_add_link(Object *obj, const char *name, in object_property_add_link() argument
2010 return object_add_link_prop(obj, name, type, targetp, check, flags); in object_property_add_link()
2017 void (*check)(const Object *obj, const char *name, in object_class_property_add_link() argument
2044 object_property_add_const_link(Object *obj, const char *name, in object_property_add_const_link() argument
2047 return object_add_link_prop(obj, name, in object_property_add_const_link()
2052 const char *object_get_canonical_path_component(const Object *obj) in object_get_canonical_path_component() argument
2057 if (obj->parent == NULL) { in object_get_canonical_path_component()
2061 g_hash_table_iter_init(&iter, obj->parent->properties); in object_get_canonical_path_component()
2067 if (prop->opaque == obj) { in object_get_canonical_path_component()
2076 char *object_get_canonical_path(const Object *obj) in object_get_canonical_path() argument
2081 if (obj == root) { in object_get_canonical_path()
2086 const char *component = object_get_canonical_path_component(obj); in object_get_canonical_path()
2099 obj = obj->parent; in object_get_canonical_path()
2100 } while (obj != root); in object_get_canonical_path()
2146 Object *obj; in object_resolve_partial_path() local
2150 obj = object_resolve_abs_path(parent, parts, typename); in object_resolve_partial_path()
2163 if (obj) { in object_resolve_partial_path()
2167 obj = found; in object_resolve_partial_path()
2175 return obj; in object_resolve_partial_path()
2181 Object *obj; in object_resolve_path_type() local
2189 obj = object_resolve_partial_path(object_get_root(), parts, in object_resolve_path_type()
2195 obj = object_resolve_abs_path(object_get_root(), parts + 1, typename); in object_resolve_path_type()
2203 return obj; in object_resolve_path_type()
2244 static void property_get_str(Object *obj, Visitor *v, const char *name, in property_get_str() argument
2251 value = prop->get(obj, &err); in property_get_str()
2261 static void property_set_str(Object *obj, Visitor *v, const char *name, in property_set_str() argument
2271 prop->set(obj, value, errp); in property_set_str()
2275 static void property_release_data(Object *obj, const char *name, in property_release_data() argument
2282 object_property_add_str(Object *obj, const char *name, in object_property_add_str() argument
2291 return object_property_add(obj, name, "string", in object_property_add_str()
2322 static void property_get_bool(Object *obj, Visitor *v, const char *name, in property_get_bool() argument
2329 value = prop->get(obj, &err); in property_get_bool()
2338 static void property_set_bool(Object *obj, Visitor *v, const char *name, in property_set_bool() argument
2348 prop->set(obj, value, errp); in property_set_bool()
2352 object_property_add_bool(Object *obj, const char *name, in object_property_add_bool() argument
2361 return object_property_add(obj, name, "bool", in object_property_add_bool()
2385 static void property_get_enum(Object *obj, Visitor *v, const char *name, in property_get_enum() argument
2392 value = prop->get(obj, &err); in property_get_enum()
2401 static void property_set_enum(Object *obj, Visitor *v, const char *name, in property_set_enum() argument
2410 prop->set(obj, value, errp); in property_set_enum()
2414 object_property_add_enum(Object *obj, const char *name, in object_property_add_enum() argument
2426 return object_property_add(obj, name, typename, in object_property_add_enum()
2457 static void property_get_tm(Object *obj, Visitor *v, const char *name, in property_get_tm() argument
2464 prop->get(obj, &value, &err); in property_get_tm()
2497 object_property_add_tm(Object *obj, const char *name, in object_property_add_tm() argument
2504 return object_property_add(obj, name, "struct tm", in object_property_add_tm()
2523 static char *object_get_type(Object *obj, Error **errp) in object_get_type() argument
2525 return g_strdup(object_get_typename(obj)); in object_get_type()
2528 static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *name, in property_get_uint8_ptr() argument
2535 static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name, in property_set_uint8_ptr() argument
2548 static void property_get_uint16_ptr(Object *obj, Visitor *v, const char *name, in property_get_uint16_ptr() argument
2555 static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name, in property_set_uint16_ptr() argument
2568 static void property_get_uint32_ptr(Object *obj, Visitor *v, const char *name, in property_get_uint32_ptr() argument
2575 static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name, in property_set_uint32_ptr() argument
2588 static void property_get_uint64_ptr(Object *obj, Visitor *v, const char *name, in property_get_uint64_ptr() argument
2595 static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name, in property_set_uint64_ptr() argument
2609 object_property_add_uint8_ptr(Object *obj, const char *name, in object_property_add_uint8_ptr() argument
2624 return object_property_add(obj, name, "uint8", in object_property_add_uint8_ptr()
2649 object_property_add_uint16_ptr(Object *obj, const char *name, in object_property_add_uint16_ptr() argument
2664 return object_property_add(obj, name, "uint16", in object_property_add_uint16_ptr()
2689 object_property_add_uint32_ptr(Object *obj, const char *name, in object_property_add_uint32_ptr() argument
2704 return object_property_add(obj, name, "uint32", in object_property_add_uint32_ptr()
2729 object_property_add_uint64_ptr(Object *obj, const char *name, in object_property_add_uint64_ptr() argument
2744 return object_property_add(obj, name, "uint64", in object_property_add_uint64_ptr()
2773 static void property_get_alias(Object *obj, Visitor *v, const char *name, in property_get_alias() argument
2783 static void property_set_alias(Object *obj, Visitor *v, const char *name, in property_set_alias() argument
2793 static Object *property_resolve_alias(Object *obj, void *opaque, in property_resolve_alias() argument
2801 static void property_release_alias(Object *obj, const char *name, void *opaque) in property_release_alias() argument
2810 object_property_add_alias(Object *obj, const char *name, in object_property_add_alias() argument
2832 op = object_property_add(obj, name, prop_type, in object_property_add_alias()
2842 object_property_set_description(obj, op->name, in object_property_add_alias()
2847 void object_property_set_description(Object *obj, const char *name, in object_property_set_description() argument
2852 op = object_property_find_err(obj, name, &error_abort); in object_property_set_description()