From 5dff21695d3c008510186a54b0b7a335f68fb6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Fri, 18 Oct 2024 16:49:36 +0200 Subject: [PATCH] filterx-object: move make_readonly() into type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- lib/filterx/filterx-object.h | 6 +++--- lib/filterx/object-json-array.c | 2 +- lib/filterx/object-json-object.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/filterx/filterx-object.h b/lib/filterx/filterx-object.h index 1677e44a9a..418f3ab983 100644 --- a/lib/filterx/filterx-object.h +++ b/lib/filterx/filterx-object.h @@ -53,6 +53,7 @@ struct _FilterXType gboolean (*repr)(FilterXObject *self, GString *repr); gboolean (*len)(FilterXObject *self, guint64 *len); FilterXObject *(*add)(FilterXObject *self, FilterXObject *object); + void (*make_readonly)(FilterXObject *self); void (*free_fn)(FilterXObject *self); }; @@ -86,7 +87,6 @@ struct _FilterXObject */ guint modified_in_place:1, readonly:1, weak_referenced:1; FilterXType *type; - void (*make_readonly)(FilterXObject *self); }; FilterXObject *filterx_object_getattr_string(FilterXObject *self, const gchar *attr_name); @@ -117,8 +117,8 @@ filterx_object_is_type(FilterXObject *object, FilterXType *type) static inline void filterx_object_make_readonly(FilterXObject *self) { - if (self->make_readonly) - self->make_readonly(self); + if (self->type->make_readonly) + self->type->make_readonly(self); self->readonly = TRUE; } diff --git a/lib/filterx/object-json-array.c b/lib/filterx/object-json-array.c index dd96fe6d4f..87119101d4 100644 --- a/lib/filterx/object-json-array.c +++ b/lib/filterx/object-json-array.c @@ -259,7 +259,6 @@ filterx_json_array_new_sub(struct json_object *jso, FilterXObject *root) FilterXJsonArray *self = g_new0(FilterXJsonArray, 1); filterx_list_init_instance(&self->super, &FILTERX_TYPE_NAME(json_array)); - self->super.super.make_readonly = _make_readonly; self->super.get_subscript = _get_subscript; self->super.set_subscript = _set_subscript; self->super.append = _append; @@ -381,4 +380,5 @@ FILTERX_DEFINE_TYPE(json_array, FILTERX_TYPE_NAME(list), .clone = _clone, .list_factory = filterx_json_array_new_empty, .dict_factory = filterx_json_object_new_empty, + .make_readonly = _make_readonly, ); diff --git a/lib/filterx/object-json-object.c b/lib/filterx/object-json-object.c index 0ae14dc64f..e80f10becb 100644 --- a/lib/filterx/object-json-object.c +++ b/lib/filterx/object-json-object.c @@ -245,7 +245,6 @@ filterx_json_object_new_sub(struct json_object *jso, FilterXObject *root) FilterXJsonObject *self = g_new0(FilterXJsonObject, 1); filterx_dict_init_instance(&self->super, &FILTERX_TYPE_NAME(json_object)); - self->super.super.make_readonly = _make_readonly; self->super.get_subscript = _get_subscript; self->super.set_subscript = _set_subscript; self->super.unset_key = _unset_key; @@ -320,4 +319,5 @@ FILTERX_DEFINE_TYPE(json_object, FILTERX_TYPE_NAME(dict), .clone = _clone, .list_factory = filterx_json_array_new_empty, .dict_factory = filterx_json_object_new_empty, + .make_readonly = _make_readonly, );