[object] Add "writable"
This commit is contained in:
parent
b8a78ce201
commit
ee351a38ec
|
@ -194,9 +194,10 @@ struct hb_user_data_array_t
|
||||||
struct hb_object_header_t
|
struct hb_object_header_t
|
||||||
{
|
{
|
||||||
hb_reference_count_t ref_count;
|
hb_reference_count_t ref_count;
|
||||||
|
hb_atomic_int_t writable;
|
||||||
hb_atomic_ptr_t<hb_user_data_array_t> user_data;
|
hb_atomic_ptr_t<hb_user_data_array_t> user_data;
|
||||||
};
|
};
|
||||||
#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, HB_ATOMIC_PTR_INIT (nullptr)}
|
#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, HB_ATOMIC_INT_INIT (0), HB_ATOMIC_PTR_INIT (nullptr)}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -228,6 +229,7 @@ template <typename Type>
|
||||||
static inline void hb_object_init (Type *obj)
|
static inline void hb_object_init (Type *obj)
|
||||||
{
|
{
|
||||||
obj->header.ref_count.init ();
|
obj->header.ref_count.init ();
|
||||||
|
obj->header.writable.set_relaxed (true);
|
||||||
obj->header.user_data.init ();
|
obj->header.user_data.init ();
|
||||||
}
|
}
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
|
@ -241,6 +243,16 @@ static inline bool hb_object_is_valid (const Type *obj)
|
||||||
return likely (obj->header.ref_count.is_valid ());
|
return likely (obj->header.ref_count.is_valid ());
|
||||||
}
|
}
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
|
static inline bool hb_object_is_immutable (const Type *obj)
|
||||||
|
{
|
||||||
|
return !obj->header.writable.get_relaxed ();
|
||||||
|
}
|
||||||
|
template <typename Type>
|
||||||
|
static inline bool hb_object_make_immutable (const Type *obj)
|
||||||
|
{
|
||||||
|
return !obj->header.writable.set_relaxed (false);
|
||||||
|
}
|
||||||
|
template <typename Type>
|
||||||
static inline Type *hb_object_reference (Type *obj)
|
static inline Type *hb_object_reference (Type *obj)
|
||||||
{
|
{
|
||||||
hb_object_trace (obj, HB_FUNC);
|
hb_object_trace (obj, HB_FUNC);
|
||||||
|
|
Loading…
Reference in New Issue