Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filterx-object: move make_readonly() into type #346

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
);
Loading