diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-11-21 22:46:55 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-11-24 19:57:58 -0500 |
commit | 6349912d021a8f2cf0c963952736baed72a6aa83 (patch) | |
tree | e7026c1247f0b282190a0856b38a0e722dfbd46e /pango | |
parent | c33714521a0139529d1c3fa7223d72108f157b95 (diff) | |
download | pango-6349912d021a8f2cf0c963952736baed72a6aa83.tar.gz |
Rename the serialize errors
They are produced by deserialization,
so call them that.
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-layout.h | 39 | ||||
-rw-r--r-- | pango/serializer.c | 41 |
2 files changed, 49 insertions, 31 deletions
diff --git a/pango/pango-layout.h b/pango/pango-layout.h index 3b725adc..5e8d8784 100644 --- a/pango/pango-layout.h +++ b/pango/pango-layout.h @@ -351,25 +351,38 @@ GSList * pango_layout_get_lines (PangoLayout *layout); PANGO_AVAILABLE_IN_1_16 GSList * pango_layout_get_lines_readonly (PangoLayout *layout); -#define PANGO_LAYOUT_SERIALIZE_ERROR (pango_layout_serialize_error_quark ()) +PANGO_AVAILABLE_IN_1_50 +GBytes * pango_layout_serialize (PangoLayout *layout); -typedef enum { - PANGO_LAYOUT_SERIALIZE_INVALID, - PANGO_LAYOUT_SERIALIZE_INVALID_SYNTAX, - PANGO_LAYOUT_SERIALIZE_INVALID_VALUE, - PANGO_LAYOUT_SERIALIZE_MISSING_VALUE, -} PangoLayoutSerializeError; +#define PANGO_LAYOUT_DESERIALIZE_ERROR (pango_layout_deserialize_error_quark ()) -PANGO_AVAILABLE_IN_1_50 -GQuark pango_layout_serialize_error_quark (void); +/** + * PangoLayoutDeserializeError: + * @PANGO_LAYOUT_SERIALIZE_INVALID: Unspecified error + * @PANGO_LAYOUT_SERIALIZE_INVALID_SYNTAX: The serialized data had + * the wrong structure (e.g. a member was expected to be a JSon object, + * but was an array) + * @PANGO_LAYOUT_SERIALIZE_INVALID_VALUE: A JSon value could not be + * interpreted + * @PANGO_LAYOUT_SERIALIZE_MISSING_VALUE: A required JSon member was + * not found + * + * Errors that can be returned by [func@Pango.Layout.deserialize]. + */ +typedef enum { + PANGO_LAYOUT_DESERIALIZE_INVALID, + PANGO_LAYOUT_DESERIALIZE_INVALID_SYNTAX, + PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE, + PANGO_LAYOUT_DESERIALIZE_MISSING_VALUE, +} PangoLayoutDeserializeError; PANGO_AVAILABLE_IN_1_50 -GBytes * pango_layout_serialize (PangoLayout *layout); +GQuark pango_layout_deserialize_error_quark (void); PANGO_AVAILABLE_IN_1_50 -PangoLayout * pango_layout_deserialize (PangoContext *context, - GBytes *bytes, - GError **error); +PangoLayout * pango_layout_deserialize (PangoContext *context, + GBytes *bytes, + GError **error); PANGO_AVAILABLE_IN_1_50 gboolean pango_layout_write_to_file (PangoLayout *layout, diff --git a/pango/serializer.c b/pango/serializer.c index bf3e6595..b9696060 100644 --- a/pango/serializer.c +++ b/pango/serializer.c @@ -29,7 +29,7 @@ /* {{{ Error handling */ -G_DEFINE_QUARK(pango-layout-serialize-error-quark, pango_layout_serialize_error) +G_DEFINE_QUARK(pango-layout-deserialize-error-quark, pango_layout_deserialize_error) /* }}} */ /* {{{ Serialization */ @@ -368,7 +368,8 @@ json_to_attribute (JsonReader *reader, if (!json_reader_is_object (reader)) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, PANGO_LAYOUT_SERIALIZE_INVALID_SYNTAX, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_SYNTAX, "Attribute must be a Json object"); return NULL; } @@ -387,7 +388,8 @@ json_to_attribute (JsonReader *reader, if (type == -1 || type == PANGO_ATTR_INVALID) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, PANGO_LAYOUT_SERIALIZE_INVALID_VALUE, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE, "Attribute \"type\" invalid: %s", json_reader_get_string_value (reader)); return NULL; @@ -397,7 +399,8 @@ json_to_attribute (JsonReader *reader, else { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, PANGO_LAYOUT_SERIALIZE_MISSING_VALUE, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_MISSING_VALUE, "Attribute \"type\" missing"); json_reader_end_member (reader); return NULL; @@ -406,7 +409,8 @@ json_to_attribute (JsonReader *reader, if (!json_reader_read_member (reader, "value")) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, PANGO_LAYOUT_SERIALIZE_MISSING_VALUE, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_MISSING_VALUE, "Attribute \"value\" missing"); json_reader_end_member (reader); return NULL; @@ -556,7 +560,8 @@ json_to_attr_list (JsonReader *reader, if (!json_reader_is_array (reader)) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, PANGO_LAYOUT_SERIALIZE_INVALID_SYNTAX, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_SYNTAX, "\"attributes\" must be a Json array"); goto fail; } @@ -600,8 +605,8 @@ json_to_tab_array (JsonReader *reader, if (!json_reader_is_array (reader)) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, - PANGO_LAYOUT_SERIALIZE_INVALID_SYNTAX, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_SYNTAX, "Tab \"positions\" must be a Json array"); goto fail; } @@ -640,8 +645,8 @@ json_to_layout (PangoContext *context, if (!json_reader_is_object (reader)) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, - PANGO_LAYOUT_SERIALIZE_INVALID_SYNTAX, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_SYNTAX, "Layout must be a Json object"); goto fail; } @@ -672,8 +677,8 @@ json_to_layout (PangoContext *context, if (!desc) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, - PANGO_LAYOUT_SERIALIZE_INVALID_VALUE, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE, "Could not parse \"font\" value: %s", json_reader_get_string_value (reader)); goto fail; @@ -721,8 +726,8 @@ json_to_layout (PangoContext *context, if (align == -1) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, - PANGO_LAYOUT_SERIALIZE_INVALID_VALUE, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE, "Could not parse \"alignment\" value: %s", json_reader_get_string_value (reader)); goto fail; @@ -742,8 +747,8 @@ json_to_layout (PangoContext *context, if (wrap == -1) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, - PANGO_LAYOUT_SERIALIZE_INVALID_VALUE, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE, "Could not parse \"wrap\" value: %s", json_reader_get_string_value (reader)); goto fail; @@ -763,8 +768,8 @@ json_to_layout (PangoContext *context, if (ellipsize == -1) { g_set_error (error, - PANGO_LAYOUT_SERIALIZE_ERROR, - PANGO_LAYOUT_SERIALIZE_INVALID_VALUE, + PANGO_LAYOUT_DESERIALIZE_ERROR, + PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE, "Could not parse \"ellipsize\" value: %s", json_reader_get_string_value (reader)); goto fail; |