Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
pango
Commits
6349912d
Commit
6349912d
authored
Nov 21, 2021
by
Matthias Clasen
Browse files
Rename the serialize errors
They are produced by deserialization, so call them that.
parent
c3371452
Changes
3
Hide whitespace changes
Inline
Side-by-side
pango/pango-layout.h
View file @
6349912d
...
...
@@ -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
G
Bytes
*
pango_layout_serialize
(
PangoLayout
*
layout
);
G
Quark
pango_layout_
de
serialize
_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
,
...
...
pango/serializer.c
View file @
6349912d
...
...
@@ -29,7 +29,7 @@
/* {{{ Error handling */
G_DEFINE_QUARK
(
pango
-
layout
-
serialize
-
error
-
quark
,
pango_layout_serialize_error
)
G_DEFINE_QUARK
(
pango
-
layout
-
de
serialize
-
error
-
quark
,
pango_layout_
de
serialize_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_
DE
SERIALIZE_ERROR
,
PANGO_LAYOUT_
DE
SERIALIZE_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_
DE
SERIALIZE_ERROR
,
PANGO_LAYOUT_
DE
SERIALIZE_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_
DE
SERIALIZE_ERROR
,
PANGO_LAYOUT_
DE
SERIALIZE_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_
DE
SERIALIZE_ERROR
,
PANGO_LAYOUT_
DE
SERIALIZE_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_
DE
SERIALIZE_ERROR
,
PANGO_LAYOUT_
DE
SERIALIZE_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_
DE
SERIALIZE_ERROR
,
PANGO_LAYOUT_
DE
SERIALIZE_INVALID_VALUE
,
"Could not parse
\"
ellipsize
\"
value: %s"
,
json_reader_get_string_value
(
reader
));
goto
fail
;
...
...
tests/testserialize.c
View file @
6349912d
...
...
@@ -257,7 +257,7 @@ test_serialize_layout_invalid (void)
" }
\n
"
" ]
\n
"
"}"
,
PANGO_LAYOUT_SERIALIZE_INVALID_VALUE
PANGO_LAYOUT_
DE
SERIALIZE_INVALID_VALUE
},
{
"{
\n
"
...
...
@@ -267,7 +267,7 @@ test_serialize_layout_invalid (void)
" }
\n
"
" ]
\n
"
"}"
,
PANGO_LAYOUT_SERIALIZE_MISSING_VALUE
PANGO_LAYOUT_
DE
SERIALIZE_MISSING_VALUE
},
{
"{
\n
"
...
...
@@ -278,13 +278,13 @@ test_serialize_layout_invalid (void)
" }
\n
"
" ]
\n
"
"}"
,
PANGO_LAYOUT_SERIALIZE_INVALID_VALUE
PANGO_LAYOUT_
DE
SERIALIZE_INVALID_VALUE
},
{
"{
\n
"
"
\"
alignment
\"
:
\"
nonsense
\"\n
"
"}"
,
PANGO_LAYOUT_SERIALIZE_INVALID_VALUE
PANGO_LAYOUT_
DE
SERIALIZE_INVALID_VALUE
}
};
...
...
@@ -301,7 +301,7 @@ test_serialize_layout_invalid (void)
bytes
=
g_bytes_new_static
(
test
[
i
].
json
,
-
1
);
layout
=
pango_layout_deserialize
(
context
,
bytes
,
&
error
);
g_assert_null
(
layout
);
g_assert_error
(
error
,
PANGO_LAYOUT_SERIALIZE_ERROR
,
test
[
i
].
expected_error
);
g_assert_error
(
error
,
PANGO_LAYOUT_
DE
SERIALIZE_ERROR
,
test
[
i
].
expected_error
);
g_bytes_unref
(
bytes
);
g_clear_error
(
&
error
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment