diff --git a/lib/filterx/filterx-object.h b/lib/filterx/filterx-object.h index 1677e44a9..418f3ab98 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 dd96fe6d4..87119101d 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 0ae14dc64..e80f10bec 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, );