[devhelp] DhLink: more logical param order for dh_link_new()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] DhLink: more logical param order for dh_link_new()
- Date: Sat, 3 Jun 2017 16:16:59 +0000 (UTC)
commit 8933681046ca18e547314b94e14be422684cc39c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jun 3 18:11:42 2017 +0200
DhLink: more logical param order for dh_link_new()
docs/reference/api-breaks.xml | 2 ++
src/dh-link.c | 18 +++++++++---------
src/dh-link.h | 2 +-
src/dh-parser.c | 6 +++---
4 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/docs/reference/api-breaks.xml b/docs/reference/api-breaks.xml
index b8b7666..a93d6be 100644
--- a/docs/reference/api-breaks.xml
+++ b/docs/reference/api-breaks.xml
@@ -113,6 +113,8 @@
<para>
The <code>page</code> parameter of <link linkend="dh-link-new">dh_link_new()</link>
has been removed because it was broken in <code>dh-parser.c</code>.
+ The <code>book</code> parameter has also been moved, to group related
+ parameters together.
</para>
</listitem>
<listitem>
diff --git a/src/dh-link.c b/src/dh-link.c
index 4d4f236..bf828e9 100644
--- a/src/dh-link.c
+++ b/src/dh-link.c
@@ -43,12 +43,12 @@ struct _DhLink {
gchar *book_id;
gchar *base_path;
+ DhLink *book;
+
gchar *name;
gchar *name_collation_key;
gchar *relative_url;
- DhLink *book;
-
guint ref_count;
DhLinkType type : 8;
@@ -98,15 +98,12 @@ DhLink *
dh_link_new (DhLinkType type,
const gchar *base_path,
const gchar *book_id,
- const gchar *name,
DhLink *book,
+ const gchar *name,
const gchar *relative_url)
{
DhLink *link;
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (relative_url != NULL, NULL);
-
if (type == DH_LINK_TYPE_BOOK) {
g_return_val_if_fail (base_path != NULL, NULL);
g_return_val_if_fail (book_id != NULL, NULL);
@@ -117,6 +114,9 @@ dh_link_new (DhLinkType type,
g_return_val_if_fail (book != NULL, NULL);
}
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (relative_url != NULL, NULL);
+
link = g_slice_new0 (DhLink);
link->ref_count = 1;
@@ -127,12 +127,12 @@ dh_link_new (DhLinkType type,
link->book_id = g_strdup (book_id);
}
- link->name = g_strdup (name);
- link->relative_url = g_strdup (relative_url);
-
if (book != NULL)
link->book = dh_link_ref (book);
+ link->name = g_strdup (name);
+ link->relative_url = g_strdup (relative_url);
+
return link;
}
diff --git a/src/dh-link.h b/src/dh-link.h
index 778959c..81970cb 100644
--- a/src/dh-link.h
+++ b/src/dh-link.h
@@ -70,8 +70,8 @@ GType dh_link_get_type (void);
DhLink * dh_link_new (DhLinkType type,
const gchar *base_path,
const gchar *book_id,
- const gchar *name,
DhLink *book,
+ const gchar *name,
const gchar *relative_url);
DhLink * dh_link_ref (DhLink *link);
void dh_link_unref (DhLink *link);
diff --git a/src/dh-parser.c b/src/dh-parser.c
index e3daaed..534e722 100644
--- a/src/dh-parser.c
+++ b/src/dh-parser.c
@@ -205,8 +205,8 @@ parser_start_node_book (DhParser *parser,
link = dh_link_new (DH_LINK_TYPE_BOOK,
base,
parser->book_name,
- parser->book_title,
NULL,
+ parser->book_title,
uri);
g_free (base);
parser->all_links = g_list_prepend (parser->all_links, link);
@@ -267,8 +267,8 @@ parser_start_node_chapter (DhParser *parser,
link = dh_link_new (DH_LINK_TYPE_PAGE,
NULL,
NULL,
- name,
parser->book_node->data,
+ name,
uri);
parser->all_links = g_list_prepend (parser->all_links, link);
@@ -431,8 +431,8 @@ parser_start_node_keyword (DhParser *parser,
link = dh_link_new (link_type,
NULL,
NULL,
- name,
parser->book_node->data,
+ name,
uri);
g_free (name_to_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]