Skip to content

Commit

Permalink
Merge pull request #346 from MrAnno/filterx-move-make-readonly
Browse files Browse the repository at this point in the history
filterx-object: move make_readonly() into type
  • Loading branch information
alltilla authored Oct 24, 2024
2 parents ec46f67 + 5dff216 commit 2421b38
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/filterx/filterx-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/filterx/object-json-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
);
2 changes: 1 addition & 1 deletion lib/filterx/object-json-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
);

0 comments on commit 2421b38

Please sign in to comment.