summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhishek Sharma <sharma.abhishek.it@gmail.com>2011-11-06 00:28:22 +0530
committerAbhishek Sharma <sharma.abhishek.it@gmail.com>2011-11-06 00:28:22 +0530
commit511a09dfcc59cbec7f5f2e50d17eb833d2fd6628 (patch)
treea3b8e46c917fc4562f1da479158bfecb9239cb72
parent50584f3b30393a9c3bbf0a183c663b459d6fa6c6 (diff)
downloadlibcroco-511a09dfcc59cbec7f5f2e50d17eb833d2fd6628.tar.gz
Revert "Sending recent tested changes from inkscape developers to libcroco upstream"
This reverts commit ac3e66fa2bb416507b5b5cf114c1edaa3455f105.
-rw-r--r--src/cr-additional-sel.c144
-rw-r--r--src/cr-additional-sel.h34
-rw-r--r--src/cr-attr-sel.c84
-rw-r--r--src/cr-attr-sel.h6
-rw-r--r--src/cr-cascade.c66
-rw-r--r--src/cr-cascade.h2
-rw-r--r--src/cr-declaration.c284
-rw-r--r--src/cr-declaration.h14
-rw-r--r--src/cr-doc-handler.c92
-rw-r--r--src/cr-doc-handler.h14
-rw-r--r--src/cr-enc-handler.c46
-rw-r--r--src/cr-enc-handler.h6
-rw-r--r--src/cr-fonts.c293
-rw-r--r--src/cr-fonts.h13
-rw-r--r--src/cr-input.c412
-rw-r--r--src/cr-input.h26
-rw-r--r--src/cr-num.c99
-rw-r--r--src/cr-num.h8
-rw-r--r--src/cr-om-parser.c130
-rw-r--r--src/cr-om-parser.h2
-rw-r--r--src/cr-parser.c443
-rw-r--r--src/cr-parser.h4
-rw-r--r--src/cr-parsing-location.c64
-rw-r--r--src/cr-parsing-location.h8
-rw-r--r--src/cr-prop-list.c126
-rw-r--r--src/cr-prop-list.h4
-rw-r--r--src/cr-pseudo.c48
-rw-r--r--src/cr-pseudo.h4
-rw-r--r--src/cr-rgb.c473
-rw-r--r--src/cr-rgb.h16
-rw-r--r--src/cr-sel-eng.h4
-rw-r--r--src/cr-selector.c87
-rw-r--r--src/cr-selector.h6
-rw-r--r--src/cr-simple-sel.c75
-rw-r--r--src/cr-simple-sel.h14
-rw-r--r--src/cr-statement.c788
-rw-r--r--src/cr-statement.h44
-rw-r--r--src/cr-string.c25
-rw-r--r--src/cr-string.h10
-rw-r--r--src/cr-style.c101
-rw-r--r--src/cr-style.h2
-rw-r--r--src/cr-stylesheet.c14
-rw-r--r--src/cr-stylesheet.h6
-rw-r--r--src/cr-term.c50
-rw-r--r--src/cr-term.h10
-rw-r--r--src/cr-tknzr.c172
-rw-r--r--src/cr-token.c5
-rw-r--r--src/cr-utils.c19
-rw-r--r--src/cr-utils.h9
49 files changed, 2656 insertions, 1750 deletions
diff --git a/src/cr-additional-sel.c b/src/cr-additional-sel.c
index 80a4767..5a37eba 100644
--- a/src/cr-additional-sel.c
+++ b/src/cr-additional-sel.c
@@ -26,15 +26,28 @@
#include "string.h"
/**
- *Default constructor of #CRAdditionalSel.
- *@return the newly build instance of #CRAdditionalSel.
+ * CRAdditionalSel:
+ *
+ * #CRAdditionalSel abstracts an additionnal selector.
+ * An additional selector is the selector part
+ * that comes after the combination of type selectors.
+ * It can be either "a class selector (the .class part),
+ * a pseudo class selector, an attribute selector
+ * or an id selector.
+ */
+
+/**
+ * cr_additional_sel_new:
+ *
+ * Default constructor of #CRAdditionalSel.
+ * Returns the newly build instance of #CRAdditionalSel.
*/
CRAdditionalSel *
cr_additional_sel_new (void)
{
CRAdditionalSel *result = NULL;
- result = (CRAdditionalSel *)g_try_malloc (sizeof (CRAdditionalSel));
+ result = g_try_malloc (sizeof (CRAdditionalSel));
if (result == NULL) {
cr_utils_trace_debug ("Out of memory");
@@ -47,10 +60,12 @@ cr_additional_sel_new (void)
}
/**
- *Constructor of #CRAdditionalSel.
- *@param a_sel_type the type of the newly built instance
- *of #CRAdditionalSel.
- *@return the newly built instance of #CRAdditionalSel.
+ * cr_additional_sel_new_with_type:
+ * @a_sel_type: the type of the newly built instance
+ * of #CRAdditionalSel.
+ *
+ * Constructor of #CRAdditionalSel.
+ * Returns the newly built instance of #CRAdditionalSel.
*/
CRAdditionalSel *
cr_additional_sel_new_with_type (enum AddSelectorType a_sel_type)
@@ -67,12 +82,13 @@ cr_additional_sel_new_with_type (enum AddSelectorType a_sel_type)
}
/**
- *Sets a new class name to a
- *CLASS additional selector.
- *@param a_this the "this pointer" of the current instance
- *of #CRAdditionalSel .
- *@param a_class_name the new class name to set.
+ * cr_additional_sel_set_class_name:
+ * @a_this: the "this pointer" of the current instance
+ * of #CRAdditionalSel .
+ * @a_class_name: the new class name to set.
*
+ * Sets a new class name to a
+ * CLASS additional selector.
*/
void
cr_additional_sel_set_class_name (CRAdditionalSel * a_this,
@@ -88,11 +104,13 @@ cr_additional_sel_set_class_name (CRAdditionalSel * a_this,
}
/**
- *Sets a new id name to an
- *ID additional selector.
- *@param a_this the "this pointer" of the current instance
- *of #CRAdditionalSel .
- *@param a_id the new id to set.
+ * cr_additional_sel_set_id_name:
+ * @a_this: the "this pointer" of the current instance
+ * of #CRAdditionalSel .
+ * @a_id: the new id to set.
+ *
+ * Sets a new id name to an
+ * ID additional selector.
*/
void
cr_additional_sel_set_id_name (CRAdditionalSel * a_this, CRString * a_id)
@@ -107,11 +125,13 @@ cr_additional_sel_set_id_name (CRAdditionalSel * a_this, CRString * a_id)
}
/**
- *Sets a new pseudo to a
- *PSEUDO additional selector.
- *@param a_this the "this pointer" of the current instance
- *of #CRAdditionalSel .
- *@param a_pseudo the new pseudo to set.
+ * cr_additional_sel_set_pseudo:
+ * @a_this: the "this pointer" of the current instance
+ * of #CRAdditionalSel .
+ * @a_pseudo: the new pseudo to set.
+ *
+ * Sets a new pseudo to a
+ * PSEUDO additional selector.
*/
void
cr_additional_sel_set_pseudo (CRAdditionalSel * a_this, CRPseudo * a_pseudo)
@@ -127,11 +147,13 @@ cr_additional_sel_set_pseudo (CRAdditionalSel * a_this, CRPseudo * a_pseudo)
}
/**
- *Sets a new instance of #CRAttrSel to
- *a ATTRIBUTE additional selector.
- *@param a_this the "this pointer" of the current instance
- *of #CRAdditionalSel .
- *@param a_sel the new instance of #CRAttrSel to set.
+ * cr_additional_sel_set_attr_sel:
+ * @a_this: the "this pointer" of the current instance
+ * of #CRAdditionalSel .
+ * @a_sel: the new instance of #CRAttrSel to set.
+ *
+ * Sets a new instance of #CRAttrSel to
+ * a ATTRIBUTE additional selector.
*/
void
cr_additional_sel_set_attr_sel (CRAdditionalSel * a_this, CRAttrSel * a_sel)
@@ -146,12 +168,15 @@ cr_additional_sel_set_attr_sel (CRAdditionalSel * a_this, CRAttrSel * a_sel)
}
/**
- *Appends a new instance of #CRAdditional to the
- *current list of #CRAdditional.
- *@param a_this the "this pointer" of the current instance
- *of #CRAdditionalSel .
- *@param a_sel the new instance to #CRAdditional to append.
- *@return the new list of CRAdditionalSel or NULL if an error arises.
+ * cr_additional_sel_append:
+ * @a_this: the "this pointer" of the current instance
+ * of #CRAdditionalSel .
+ * @a_sel: the new instance to #CRAdditional to append.
+ *
+ * Appends a new instance of #CRAdditional to the
+ * current list of #CRAdditional.
+ *
+ * Returns the new list of CRAdditionalSel or NULL if an error arises.
*/
CRAdditionalSel *
cr_additional_sel_append (CRAdditionalSel * a_this, CRAdditionalSel * a_sel)
@@ -179,12 +204,15 @@ cr_additional_sel_append (CRAdditionalSel * a_this, CRAdditionalSel * a_sel)
}
/**
- *Preppends a new instance of #CRAdditional to the
- *current list of #CRAdditional.
- *@param a_this the "this pointer" of the current instance
- *of #CRAdditionalSel .
- *@param a_sel the new instance to #CRAdditional to preappend.
- *@return the new list of CRAdditionalSel or NULL if an error arises.
+ * cr_additional_sel_prepend:
+ * @a_this: the "this pointer" of the current instance
+ * of #CRAdditionalSel .
+ * @a_sel: the new instance to #CRAdditional to preappend.
+ *
+ * Preppends a new instance of #CRAdditional to the
+ * current list of #CRAdditional.
+ *
+ * Returns the new list of CRAdditionalSel or NULL if an error arises.
*/
CRAdditionalSel *
cr_additional_sel_prepend (CRAdditionalSel * a_this, CRAdditionalSel * a_sel)
@@ -202,11 +230,11 @@ cr_additional_sel_prepend (CRAdditionalSel * a_this, CRAdditionalSel * a_sel)
}
guchar *
-cr_additional_sel_to_string (CRAdditionalSel * a_this)
+cr_additional_sel_to_string (CRAdditionalSel const * a_this)
{
guchar *result = NULL;
GString *str_buf = NULL;
- CRAdditionalSel *cur = NULL;
+ CRAdditionalSel const *cur = NULL;
g_return_val_if_fail (a_this, NULL);
@@ -219,7 +247,7 @@ cr_additional_sel_to_string (CRAdditionalSel * a_this)
guchar *name = NULL;
if (cur->content.class_name) {
- name = (guchar *)g_strndup
+ name = g_strndup
(cur->content.class_name->stryng->str,
cur->content.class_name->stryng->len);
@@ -239,7 +267,7 @@ cr_additional_sel_to_string (CRAdditionalSel * a_this)
guchar *name = NULL;
if (cur->content.class_name) {
- name = (guchar *)g_strndup
+ name = g_strndup
(cur->content.id_name->stryng->str,
cur->content.id_name->stryng->len);
@@ -295,7 +323,7 @@ cr_additional_sel_to_string (CRAdditionalSel * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -304,7 +332,7 @@ cr_additional_sel_to_string (CRAdditionalSel * a_this)
}
guchar *
-cr_additional_sel_one_to_string (CRAdditionalSel *a_this)
+cr_additional_sel_one_to_string (CRAdditionalSel const *a_this)
{
guchar *result = NULL;
GString *str_buf = NULL;
@@ -319,7 +347,7 @@ cr_additional_sel_one_to_string (CRAdditionalSel *a_this)
guchar *name = NULL;
if (a_this->content.class_name) {
- name = (guchar *)g_strndup
+ name = g_strndup
(a_this->content.class_name->stryng->str,
a_this->content.class_name->stryng->len);
@@ -339,7 +367,7 @@ cr_additional_sel_one_to_string (CRAdditionalSel *a_this)
guchar *name = NULL;
if (a_this->content.class_name) {
- name = (guchar *)g_strndup
+ name = g_strndup
(a_this->content.id_name->stryng->str,
a_this->content.id_name->stryng->len);
@@ -394,7 +422,7 @@ cr_additional_sel_one_to_string (CRAdditionalSel *a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -403,13 +431,15 @@ cr_additional_sel_one_to_string (CRAdditionalSel *a_this)
}
/**
- *Dumps the current instance of #CRAdditionalSel to a file
- *@param a_this the "this pointer" of the current instance of
- *#CRAdditionalSel.
- *@param a_fp the destination file.
+ * cr_additional_sel_dump:
+ * @a_this: the "this pointer" of the current instance of
+ * #CRAdditionalSel.
+ * @a_fp: the destination file.
+ *
+ * Dumps the current instance of #CRAdditionalSel to a file
*/
void
-cr_additional_sel_dump (CRAdditionalSel * a_this, FILE * a_fp)
+cr_additional_sel_dump (CRAdditionalSel const * a_this, FILE * a_fp)
{
guchar *tmp_str = NULL;
@@ -426,9 +456,11 @@ cr_additional_sel_dump (CRAdditionalSel * a_this, FILE * a_fp)
}
/**
- *Destroys an instance of #CRAdditional.
- *@param a_this the "this pointer" of the current instance
- *of #CRAdditionalSel .
+ * cr_additional_sel_destroy:
+ * @a_this: the "this pointer" of the current instance
+ * of #CRAdditionalSel .
+ *
+ * Destroys an instance of #CRAdditional.
*/
void
cr_additional_sel_destroy (CRAdditionalSel * a_this)
diff --git a/src/cr-additional-sel.h b/src/cr-additional-sel.h
index 6f6ee49..7ca3e07 100644
--- a/src/cr-additional-sel.h
+++ b/src/cr-additional-sel.h
@@ -22,16 +22,6 @@
*/
-/**
- *@file
- *This file holds the declaration of the
- *#CRAddSel class.
- */
-/**
- *@file
- *This file holds the declaration of the
- *#CRAddSel class.
- */
#ifndef __CR_ADD_SEL_H__
#define __CR_ADD_SEL_H__
@@ -58,29 +48,11 @@ union CRAdditionalSelectorContent
CRString *class_name ;
CRString *id_name ;
CRPseudo *pseudo ;
-/**
- *#CRAdditionalSel abstracts
- *an additionnal selector.
- *An additional selector is the selector part
- *that comes after the combination of type selectors.
- *It can be either "a class selector (the .class part),
- *a pseudo class selector, an attribute selector
- *or an id selector.
- */
CRAttrSel *attr_sel ;
} ;
typedef struct _CRAdditionalSel CRAdditionalSel ;
-/**
- *#CRAdditionalSel abstracts
- *an additionnal selector.
- *An additional selector is the selector part
- *that comes after the combination of type selectors.
- *It can be either "a class selector (the .class part),
- *a pseudo class selector, an attribute selector
- *or an id selector.
- */
struct _CRAdditionalSel
{
enum AddSelectorType type ;
@@ -113,11 +85,11 @@ void cr_additional_sel_set_attr_sel (CRAdditionalSel *a_this,
CRAdditionalSel * cr_additional_sel_prepend (CRAdditionalSel *a_this,
CRAdditionalSel *a_sel) ;
-guchar * cr_additional_sel_to_string (CRAdditionalSel *a_this) ;
+guchar * cr_additional_sel_to_string (CRAdditionalSel const *a_this) ;
-guchar * cr_additional_sel_one_to_string (CRAdditionalSel *a_this) ;
+guchar * cr_additional_sel_one_to_string (CRAdditionalSel const *a_this) ;
-void cr_additional_sel_dump (CRAdditionalSel *a_this, FILE *a_fp) ;
+void cr_additional_sel_dump (CRAdditionalSel const *a_this, FILE *a_fp) ;
void cr_additional_sel_destroy (CRAdditionalSel *a_this) ;
diff --git a/src/cr-attr-sel.c b/src/cr-attr-sel.c
index 3c4800e..787f0c0 100644
--- a/src/cr-attr-sel.c
+++ b/src/cr-attr-sel.c
@@ -24,34 +24,38 @@
#include "cr-attr-sel.h"
/**
- *@file
- *The class that abstracts an attribute selector.
- *Attributes selectors are described in the css2 spec [5.8].
- *There are more generally used in the css2 selectors described in
- *css2 spec [5] .
+ * CRAttrSel:
+ *
+ * #CRAdditionalSel abstracts an attribute selector.
+ * Attributes selectors are described in the css2 spec [5.8].
+ * There are more generally used in the css2 selectors described in
+ * css2 spec [5] .
*/
/**
- *The constructor of #CRAttrSel.
- *@return the newly allocated instance
- *of #CRAttrSel.
+ * cr_attr_sel_new:
+ * The constructor of #CRAttrSel.
+ * Returns the newly allocated instance
+ * of #CRAttrSel.
*/
CRAttrSel *
cr_attr_sel_new (void)
{
- CRAttrSel *result = (CRAttrSel *)g_malloc0 (sizeof (CRAttrSel));
+ CRAttrSel *result = NULL;
+
+ result = g_malloc0 (sizeof (CRAttrSel));
return result;
}
/**
- *Appends an attribute selector to the current list of
- *attribute selectors represented by a_this.
+ * cr_attr_sel_append_attr_sel:
+ * @a_this: the this pointer of the current instance of #CRAttrSel.
+ * @a_attr_sel: selector to append.
*
- *@param a_this the this pointer of the current instance of
- *#CRAttrSel.
- *@param a_attr_sel selector to append.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ * Appends an attribute selector to the current list of
+ * attribute selectors represented by a_this.
+ * Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_attr_sel_append_attr_sel (CRAttrSel * a_this, CRAttrSel * a_attr_sel)
@@ -72,13 +76,13 @@ cr_attr_sel_append_attr_sel (CRAttrSel * a_this, CRAttrSel * a_attr_sel)
}
/**
+ * cr_attr_sel_prepend_attr_sel:
+ *@a_this: the "this pointer" of the current instance *of #CRAttrSel.
+ *@a_attr_sel: the attribute selector to append.
+ *
*Prepends an attribute selector to the list of
*attributes selector represented by a_this.
- *
- *@param a_this the "this pointer" of the current instance
- *of #CRAttrSel.
- *@param a_attr_sel the attribute selector to append.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_attr_sel_prepend_attr_sel (CRAttrSel * a_this,
@@ -93,10 +97,17 @@ cr_attr_sel_prepend_attr_sel (CRAttrSel * a_this,
return CR_OK;
}
+/**
+ * cr_attr_sel_to_string:
+ * @a_this: the current instance of #CRAttrSel.
+ *
+ * Serializes an attribute selector into a string
+ * Returns the serialized attribute selector.
+ */
guchar *
-cr_attr_sel_to_string (CRAttrSel * a_this)
+cr_attr_sel_to_string (CRAttrSel const * a_this)
{
- CRAttrSel *cur = NULL;
+ CRAttrSel const *cur = NULL;
guchar *result = NULL;
GString *str_buf = NULL;
@@ -110,7 +121,9 @@ cr_attr_sel_to_string (CRAttrSel * a_this)
}
if (cur->name) {
- gchar *name = g_strndup (cur->name->stryng->str,
+ guchar *name = NULL;
+
+ name = g_strndup (cur->name->stryng->str,
cur->name->stryng->len);
if (name) {
g_string_append (str_buf, name);
@@ -120,7 +133,9 @@ cr_attr_sel_to_string (CRAttrSel * a_this)
}
if (cur->value) {
- gchar *value = g_strndup (cur->value->stryng->str,
+ guchar *value = NULL;
+
+ value = g_strndup (cur->value->stryng->str,
cur->value->stryng->len);
if (value) {
switch (cur->match_way) {
@@ -153,7 +168,7 @@ cr_attr_sel_to_string (CRAttrSel * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
}
@@ -161,13 +176,15 @@ cr_attr_sel_to_string (CRAttrSel * a_this)
}
/**
- *Dumps the current instance of #CRAttrSel to a file.
- *@param a_this the "this pointer" of the current instance of
- *#CRAttrSel.
- *@param a_fp the destination file.
+ * cr_attr_sel_dump:
+ * @a_this: the "this pointer" of the current instance of
+ * #CRAttrSel.
+ * @a_fp: the destination file.
+ *
+ * Dumps the current instance of #CRAttrSel to a file.
*/
void
-cr_attr_sel_dump (CRAttrSel * a_this, FILE * a_fp)
+cr_attr_sel_dump (CRAttrSel const * a_this, FILE * a_fp)
{
guchar *tmp_str = NULL;
@@ -183,10 +200,12 @@ cr_attr_sel_dump (CRAttrSel * a_this, FILE * a_fp)
}
/**
+ *cr_attr_sel_destroy:
+ *@a_this: the "this pointer" of the current
+ *instance of #CRAttrSel.
+ *
*Destroys the current instance of #CRAttrSel.
*Frees all the fields if they are non null.
- *@param a_this the "this pointer" of the current
- *instance of #CRAttrSel.
*/
void
cr_attr_sel_destroy (CRAttrSel * a_this)
@@ -213,3 +232,4 @@ cr_attr_sel_destroy (CRAttrSel * a_this)
a_this = NULL;
}
}
+
diff --git a/src/cr-attr-sel.h b/src/cr-attr-sel.h
index 9cc03d3..82d5a87 100644
--- a/src/cr-attr-sel.h
+++ b/src/cr-attr-sel.h
@@ -58,14 +58,14 @@ struct _CRAttrSel
CRAttrSel * cr_attr_sel_new (void) ;
enum CRStatus cr_attr_sel_append_attr_sel (CRAttrSel * a_this,
- CRAttrSel *a_new) ;
+ CRAttrSel *a_attr_sel) ;
enum CRStatus cr_attr_sel_prepend_attr_sel (CRAttrSel *a_this,
CRAttrSel *a_attr_sel) ;
-guchar * cr_attr_sel_to_string (CRAttrSel *a_this) ;
+guchar * cr_attr_sel_to_string (CRAttrSel const *a_this) ;
-void cr_attr_sel_dump (CRAttrSel *a_this, FILE *a_fp) ;
+void cr_attr_sel_dump (CRAttrSel const *a_this, FILE *a_fp) ;
void cr_attr_sel_destroy (CRAttrSel *a_this) ;
diff --git a/src/cr-cascade.c b/src/cr-cascade.c
index 7fef86c..4fa69bb 100644
--- a/src/cr-cascade.c
+++ b/src/cr-cascade.c
@@ -23,7 +23,7 @@
*/
/*
- *$Id: cr-cascade.c,v 1.6 2004/03/07 13:22:47 dodji Exp $
+ *$Id$
*/
#include <string.h>
@@ -44,6 +44,11 @@ struct _CRCascadePriv {
};
/**
+ * cr_cascade_new:
+ *@a_author_sheet: the author origin style sheet. May be NULL.
+ *@a_user_sheet: the user origin style sheet. May be NULL.
+ *@a_ua_sheet: the user agent origin style sheet. May be NULL.
+ *
*Constructor of the #CRCascade class.
*Note that all three parameters of this
*method are ref counted and their refcount is increased.
@@ -51,26 +56,25 @@ struct _CRCascadePriv {
*the instance of #CRCascade.
*So the caller should not call their destructor. The caller
*should call their ref/unref method instead if it wants
- *@param a_author_sheet the autor origin style sheet
- *@param a_user_sheet the user origin style sheet.
- *@param a_ua_sheet the user agent origin style sheet.
- *@return the newly built instance of CRCascade or NULL if
+ *
+ *Returns the newly built instance of CRCascade or NULL if
*an error arose during constrution.
*/
CRCascade *
cr_cascade_new (CRStyleSheet * a_author_sheet,
CRStyleSheet * a_user_sheet, CRStyleSheet * a_ua_sheet)
{
- CRCascade *result = (CRCascade *)g_try_malloc (sizeof (CRCascade));
+ CRCascade *result = NULL;
+
+ result = g_try_malloc (sizeof (CRCascade));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
}
memset (result, 0, sizeof (CRCascade));
- PRIVATE (result) = (CRCascadePriv *)g_try_malloc (sizeof (CRCascadePriv));
+ PRIVATE (result) = g_try_malloc (sizeof (CRCascadePriv));
if (!PRIVATE (result)) {
- g_free(result);
cr_utils_trace_info ("Out of memory");
return NULL;
}
@@ -90,33 +94,40 @@ cr_cascade_new (CRStyleSheet * a_author_sheet,
}
/**
+ * cr_cascade_get_sheet:
+ *@a_this: the current instance of #CRCascade.
+ *@a_origin: the origin of the style sheet as
+ *defined in the css2 spec in chapter 6.4.
*Gets a given origin sheet.
+ *
+ *Gets a sheet, part of the cascade.
*Note that the returned stylesheet
*is refcounted so if the caller wants
- *to manage its lifecycle, it must use
+ *to manage it's lifecycle, it must use
*cr_stylesheet_ref()/cr_stylesheet_unref() instead
*of the cr_stylesheet_destroy() method.
- *@param a_this the current instance of #CRCascade.
- *@param a_origin the origin of the style sheet as
- *defined in the css2 spec in chapter 6.4.
- *@return the style sheet, or NULL if it does not
+ *Returns the style sheet, or NULL if it does not
*exist.
*/
CRStyleSheet *
cr_cascade_get_sheet (CRCascade * a_this, enum CRStyleOrigin a_origin)
{
g_return_val_if_fail (a_this
- && (unsigned)a_origin < NB_ORIGINS, NULL);
+ && a_origin >= ORIGIN_UA
+ && a_origin < NB_ORIGINS, NULL);
return PRIVATE (a_this)->sheets[a_origin];
}
/**
+ * cr_cascade_set_sheet:
+ *@a_this: the current instance of #CRCascade.
+ *@a_sheet: the stylesheet to set.
+ *@a_origin: the origin of the stylesheet.
+ *
*Sets a stylesheet in the cascade
- *@param a_this the current instance of #CRCascade.
- *@param a_sheet the stylesheet to set.
- *@param a_origin the origin of the stylesheet.
- *@return CR_OK upon successfull completion, an error
+ *
+ *Returns CR_OK upon successfull completion, an error
*code otherwise.
*/
enum CRStatus
@@ -125,7 +136,8 @@ cr_cascade_set_sheet (CRCascade * a_this,
{
g_return_val_if_fail (a_this
&& a_sheet
- && (unsigned)a_origin < NB_ORIGINS, CR_BAD_PARAM_ERROR);
+ && a_origin >= ORIGIN_UA
+ && a_origin < NB_ORIGINS, CR_BAD_PARAM_ERROR);
if (PRIVATE (a_this)->sheets[a_origin])
cr_stylesheet_unref (PRIVATE (a_this)->sheets[a_origin]);
@@ -136,10 +148,11 @@ cr_cascade_set_sheet (CRCascade * a_this,
}
/**
+ *cr_cascade_ref:
+ *@a_this: the current instance of #CRCascade
+ *
*Increases the reference counter of the current instance
*of #CRCascade.
- *@param a_this the current instance of #CRCascade
- *
*/
void
cr_cascade_ref (CRCascade * a_this)
@@ -150,12 +163,14 @@ cr_cascade_ref (CRCascade * a_this)
}
/**
+ * cr_cascade_unref:
+ *@a_this: the current instance of
+ *#CRCascade.
+ *
*Decrements the reference counter associated
*to this instance of #CRCascade. If the reference
*counter reaches zero, the instance is destroyed
*using cr_cascade_destroy()
- *@param a_this the current instance of
- *#CRCascade.
*/
void
cr_cascade_unref (CRCascade * a_this)
@@ -170,7 +185,10 @@ cr_cascade_unref (CRCascade * a_this)
}
/**
- *Destructor of #CRCascade.
+ * cr_cascade_destroy:
+ * @a_this: the current instance of #CRCascade
+ *
+ * Destructor of #CRCascade.
*/
void
cr_cascade_destroy (CRCascade * a_this)
diff --git a/src/cr-cascade.h b/src/cr-cascade.h
index 5e71842..3119ae8 100644
--- a/src/cr-cascade.h
+++ b/src/cr-cascade.h
@@ -22,7 +22,7 @@
*/
/*
- *$Id: cr-cascade.h,v 1.6 2004/01/29 22:05:14 dodji Exp $
+ *$Id$
*/
#ifndef __CR_CASCADE_H__
diff --git a/src/cr-declaration.c b/src/cr-declaration.c
index 530085b..8079aa0 100644
--- a/src/cr-declaration.c
+++ b/src/cr-declaration.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -28,22 +28,27 @@
#include "cr-parser.h"
/**
- *@file
+ *@CRDeclaration:
+ *
*The definition of the #CRDeclaration class.
*/
/**
+ * dump:
+ *@a_this: the current instance of #CRDeclaration.
+ *@a_fp: the destination file pointer.
+ *@a_indent: the number of indentation white char.
+ *
*Dumps (serializes) one css declaration to a file.
- *@param a_this the current instance of #CRDeclaration.
- *@param a_fp the destination file pointer.
- *@param a_indent the number of indentation white char.
*/
static void
-dump (CRDeclaration * a_this, FILE * a_fp, glong a_indent)
+dump (CRDeclaration const * a_this, FILE * a_fp, glong a_indent)
{
+ guchar *str = NULL;
+
g_return_if_fail (a_this);
- gchar *str = cr_declaration_to_string (a_this, a_indent);
+ str = cr_declaration_to_string (a_this, a_indent);
if (str) {
fprintf (a_fp, "%s", str);
g_free (str);
@@ -52,16 +57,25 @@ dump (CRDeclaration * a_this, FILE * a_fp, glong a_indent)
}
/**
+ * cr_declaration_new:
+ * @a_statement: the statement this declaration belongs to. can be NULL.
+ *@a_property: the property string of the declaration
+ *@a_value: the value expression of the declaration.
*Constructor of #CRDeclaration.
- *@param a_property the property string of the declaration
- *@param a_value the value expression of the declaration.
- *@return the newly built instance of #CRDeclaration, or NULL in
+ *
+ *Returns the newly built instance of #CRDeclaration, or NULL in
*case of error.
+ *
+ *The returned CRDeclaration takes ownership of @a_property and @a_value.
+ *(E.g. cr_declaration_destroy on this CRDeclaration will also free
+ *@a_property and @a_value.)
*/
CRDeclaration *
cr_declaration_new (CRStatement * a_statement,
CRString * a_property, CRTerm * a_value)
{
+ CRDeclaration *result = NULL;
+
g_return_val_if_fail (a_property, NULL);
if (a_statement)
@@ -72,7 +86,7 @@ cr_declaration_new (CRStatement * a_statement,
|| (a_statement->type
== AT_PAGE_RULE_STMT)), NULL);
- CRDeclaration * result = (CRDeclaration *)g_try_malloc (sizeof (CRDeclaration));
+ result = g_try_malloc (sizeof (CRDeclaration));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
@@ -89,15 +103,16 @@ cr_declaration_new (CRStatement * a_statement,
}
/**
- *Parses a text buffer that contains
- *a css declaration.
- *
- *@param a_statement the parent css2 statement of this
+ * cr_declaration_parse_from_buf:
+ *@a_statement: the parent css2 statement of this
*this declaration. Must be non NULL and of type
*RULESET_STMT (must be a ruleset).
- *@param a_str the string that contains the statement.
- *@param a_enc the encoding of a_str.
- *@return the parsed declaration, or NULL in case of error.
+ *@a_str: the string that contains the statement.
+ *@a_enc: the encoding of a_str.
+ *
+ *Parses a text buffer that contains
+ *a css declaration.
+ *Returns the parsed declaration, or NULL in case of error.
*/
CRDeclaration *
cr_declaration_parse_from_buf (CRStatement * a_statement,
@@ -107,6 +122,7 @@ cr_declaration_parse_from_buf (CRStatement * a_statement,
CRTerm *value = NULL;
CRString *property = NULL;
CRDeclaration *result = NULL;
+ CRParser *parser = NULL;
gboolean important = FALSE;
g_return_val_if_fail (a_str, NULL);
@@ -114,9 +130,7 @@ cr_declaration_parse_from_buf (CRStatement * a_statement,
g_return_val_if_fail (a_statement->type == RULESET_STMT,
NULL);
- CRParser *parser = (CRParser *)
- cr_parser_new_from_buf ((guchar*)a_str,
- strlen ((char *)a_str), a_enc, FALSE);
+ parser = cr_parser_new_from_buf ((guchar*)a_str, strlen (a_str), a_enc, FALSE);
g_return_val_if_fail (parser, NULL);
status = cr_parser_try_to_skip_spaces_and_comments (parser);
@@ -156,11 +170,13 @@ cr_declaration_parse_from_buf (CRStatement * a_statement,
}
/**
- *Parses a ';' separated list of properties declaration.
- *@param a_str the input buffer that contains the list of declaration to
+ * cr_declaration_parse_list_from_buf:
+ *@a_str: the input buffer that contains the list of declaration to
*parse.
- *@param a_enc the encoding of a_str
- *@return the parsed list of declaration, NULL if parsing failed.
+ *@a_enc: the encoding of a_str
+ *
+ *Parses a ';' separated list of properties declaration.
+ *Returns the parsed list of declaration, NULL if parsing failed.
*/
CRDeclaration *
cr_declaration_parse_list_from_buf (const guchar * a_str,
@@ -172,13 +188,13 @@ cr_declaration_parse_list_from_buf (const guchar * a_str,
CRString *property = NULL;
CRDeclaration *result = NULL,
*cur_decl = NULL;
+ CRParser *parser = NULL;
CRTknzr *tokenizer = NULL;
gboolean important = FALSE;
g_return_val_if_fail (a_str, NULL);
- CRParser *parser = (CRParser *)cr_parser_new_from_buf
- ((guchar*)a_str, strlen ((char *)a_str), a_enc, FALSE);
+ parser = cr_parser_new_from_buf ((guchar*)a_str, strlen (a_str), a_enc, FALSE);
g_return_val_if_fail (parser, NULL);
status = cr_parser_get_tknzr (parser, &tokenizer);
if (status != CR_OK || !tokenizer) {
@@ -210,15 +226,14 @@ cr_declaration_parse_list_from_buf (const guchar * a_str,
cr_parser_try_to_skip_spaces_and_comments (parser);
status = cr_tknzr_peek_char (tokenizer, &c);
if (status != CR_OK) {
- if (status == CR_END_OF_INPUT_ERROR)
+ if (status == CR_END_OF_INPUT_ERROR)
status = CR_OK;
goto cleanup;
}
if (c == ';') {
status = cr_tknzr_read_char (tokenizer, &c);
} else {
- cr_tknzr_read_char (tokenizer, &c);
- continue; // try to keep reading until we reach the end or a ;
+ break;
}
important = FALSE;
cr_parser_try_to_skip_spaces_and_comments (parser);
@@ -226,11 +241,9 @@ cr_declaration_parse_list_from_buf (const guchar * a_str,
&value, &important);
if (status != CR_OK || !property) {
if (status == CR_END_OF_INPUT_ERROR) {
- status = CR_OK; // simply the end of input, do not delete what we got so far, just finish
- break;
- } else {
- continue; // even if one declaration is broken, it's no reason to discard others (see http://www.w3.org/TR/CSS21/syndata.html#declaration)
- }
+ status = CR_OK;
+ }
+ break;
}
cur_decl = cr_declaration_new (NULL, property, value);
if (cur_decl) {
@@ -269,10 +282,12 @@ cr_declaration_parse_list_from_buf (const guchar * a_str,
}
/**
+ * cr_declaration_append:
+ *@a_this: the current declaration list.
+ *@a_new: the declaration to append.
+ *
*Appends a new declaration to the current declarations list.
- *@param a_this the current declaration list.
- *@param a_new the declaration to append.
- *@return the declaration list with a_new appended to it, or NULL
+ *Returns the declaration list with a_new appended to it, or NULL
*in case of error.
*/
CRDeclaration *
@@ -294,10 +309,13 @@ cr_declaration_append (CRDeclaration * a_this, CRDeclaration * a_new)
}
/**
+ * cr_declaration_unlink:
+ *@a_decls: the declaration to unlink.
+ *
*Unlinks the declaration from the declaration list.
- *@param a_decl the declaration to unlink.
- *@return a pointer to the unlinked declaration in
*case of a successfull completion, NULL otherwise.
+ *
+ *Returns a pointer to the unlinked declaration in
*/
CRDeclaration *
cr_declaration_unlink (CRDeclaration * a_decl)
@@ -369,10 +387,13 @@ cr_declaration_unlink (CRDeclaration * a_decl)
}
/**
- *prepends a declaration to the current declaration list.
- *@param a_this the current declaration list.
- *@param a_new the declaration to prepend.
- *@return the list with a_new prepended or NULL in case of error.
+ * cr_declaration_prepend:
+ * @a_this: the current declaration list.
+ * @a_new: the declaration to prepend.
+ *
+ * prepends a declaration to the current declaration list.
+ *
+ * Returns the list with a_new prepended or NULL in case of error.
*/
CRDeclaration *
cr_declaration_prepend (CRDeclaration * a_this, CRDeclaration * a_new)
@@ -393,11 +414,13 @@ cr_declaration_prepend (CRDeclaration * a_this, CRDeclaration * a_new)
}
/**
+ * cr_declaration_append2:
+ *@a_this: the current declaration list.
+ *@a_prop: the property string of the declaration to append.
+ *@a_value: the value of the declaration to append.
+ *
*Appends a declaration to the current declaration list.
- *@param a_this the current declaration list.
- *@param a_prop the property string of the declaration to append.
- *@param a_value the value of the declaration to append.
- *@return the list with the new property appended to it, or NULL in
+ *Returns the list with the new property appended to it, or NULL in
*case of an error.
*/
CRDeclaration *
@@ -419,16 +442,20 @@ cr_declaration_append2 (CRDeclaration * a_this,
}
/**
+ * cr_declaration_dump:
+ *@a_this: the current instance of #CRDeclaration.
+ *@a_fp: the destination file.
+ *@a_indent: the number of indentation white char.
+ *@a_one_per_line: whether to put one declaration per line of not .
+ *
+ *
*Dumps a declaration list to a file.
- *@param a_this the current instance of #CRDeclaration.
- *@param a_fp the destination file.
- *@param a_indent the number of indentation white char.
*/
void
-cr_declaration_dump (CRDeclaration * a_this, FILE * a_fp, glong a_indent,
+cr_declaration_dump (CRDeclaration const * a_this, FILE * a_fp, glong a_indent,
gboolean a_one_per_line)
{
- CRDeclaration *cur = NULL;
+ CRDeclaration const *cur = NULL;
g_return_if_fail (a_this);
@@ -444,13 +471,15 @@ cr_declaration_dump (CRDeclaration * a_this, FILE * a_fp, glong a_indent,
}
/**
+ * cr_declaration_dump_one:
+ *@a_this: the current instance of #CRDeclaration.
+ *@a_fp: the destination file.
+ *@a_indent: the number of indentation white char.
+ *
*Dumps the first declaration of the declaration list to a file.
- *@param a_this the current instance of #CRDeclaration.
- *@param a_fp the destination file.
- *@param a_indent the number of indentation white char.
*/
void
-cr_declaration_dump_one (CRDeclaration * a_this, FILE * a_fp, glong a_indent)
+cr_declaration_dump_one (CRDeclaration const * a_this, FILE * a_fp, glong a_indent)
{
g_return_if_fail (a_this);
@@ -458,17 +487,21 @@ cr_declaration_dump_one (CRDeclaration * a_this, FILE * a_fp, glong a_indent)
}
/**
- *Serializes the declaration into a string
- *@param a_this the current instance of #CRDeclaration.
- *@param a_indent the number of indentation white char
+ * cr_declaration_to_string:
+ *@a_this: the current instance of #CRDeclaration.
+ *@a_indent: the number of indentation white char
*to put before the actual serialisation.
+ *
+ *Serializes the declaration into a string
+ *Returns the serialized form the declaration. The caller must
+ *free the string using g_free().
*/
gchar *
-cr_declaration_to_string (CRDeclaration * a_this, gulong a_indent)
+cr_declaration_to_string (CRDeclaration const * a_this, gulong a_indent)
{
GString *stringue = NULL;
- gchar *str = NULL,
+ guchar *str = NULL,
*result = NULL;
g_return_val_if_fail (a_this, NULL);
@@ -525,17 +558,19 @@ cr_declaration_to_string (CRDeclaration * a_this, gulong a_indent)
}
/**
- *Serializes the declaration list into a string
- *@param a_this the current instance of #CRDeclaration.
- *@param a_indent the number of indentation white char
+ * cr_declaration_list_to_string:
+ *@a_this: the current instance of #CRDeclaration.
+ *@a_indent: the number of indentation white char
*to put before the actual serialisation.
+ *
+ *Serializes the declaration list into a string
*/
guchar *
-cr_declaration_list_to_string (CRDeclaration * a_this, gulong a_indent)
+cr_declaration_list_to_string (CRDeclaration const * a_this, gulong a_indent)
{
- CRDeclaration *cur = NULL;
+ CRDeclaration const *cur = NULL;
GString *stringue = NULL;
- gchar *str = NULL,
+ guchar *str = NULL,
*result = NULL;
g_return_val_if_fail (a_this, NULL);
@@ -555,22 +590,26 @@ cr_declaration_list_to_string (CRDeclaration * a_this, gulong a_indent)
g_string_free (stringue, FALSE);
}
- return (guchar *)result;
+ return result;
}
/**
- *Serializes the declaration list into a string
- *@param a_this the current instance of #CRDeclaration.
- *@param a_indent the number of indentation white char
+ * cr_declaration_list_to_string2:
+ *@a_this: the current instance of #CRDeclaration.
+ *@a_indent: the number of indentation white char
+ *@a_one_decl_per_line: whether to output one doc per line or not.
*to put before the actual serialisation.
+ *
+ *Serializes the declaration list into a string
+ *Returns the serialized form the declararation.
*/
guchar *
-cr_declaration_list_to_string2 (CRDeclaration * a_this,
+cr_declaration_list_to_string2 (CRDeclaration const * a_this,
gulong a_indent, gboolean a_one_decl_per_line)
{
- CRDeclaration *cur = NULL;
+ CRDeclaration const *cur = NULL;
GString *stringue = NULL;
- gchar *str = NULL,
+ guchar *str = NULL,
*result = NULL;
g_return_val_if_fail (a_this, NULL);
@@ -604,18 +643,18 @@ cr_declaration_list_to_string2 (CRDeclaration * a_this,
g_string_free (stringue, FALSE);
}
- return (guchar *)result;
+ return result;
}
/**
- *Return the number of properties in the declaration;
- *@param a_this the current instance of #CRDeclaration.
- *@return number of properties in the declaration list.
+ * cr_declaration_nr_props:
+ *@a_this: the current instance of #CRDeclaration.
+ *Return the number of properties in the declaration
*/
gint
-cr_declaration_nr_props (CRDeclaration * a_this)
+cr_declaration_nr_props (CRDeclaration const * a_this)
{
- CRDeclaration *cur = NULL;
+ CRDeclaration const *cur = NULL;
int nr = 0;
g_return_val_if_fail (a_this, -1);
@@ -626,10 +665,14 @@ cr_declaration_nr_props (CRDeclaration * a_this)
}
/**
+ * cr_declaration_get_from_list:
+ *@a_this: the current instance of #CRDeclaration.
+ *@itemnr: the index into the declaration list.
+ *
*Use an index to get a CRDeclaration from the declaration list.
- *@param a_this the current instance of #CRDeclaration.
- *@param itemnr the index into the declaration list.
- *@return CRDeclaration at position itemnr, if itemnr > number of declarations - 1,
+ *
+ *Returns #CRDeclaration at position itemnr,
+ *if itemnr > number of declarations - 1,
*it will return NULL.
*/
CRDeclaration *
@@ -647,10 +690,12 @@ cr_declaration_get_from_list (CRDeclaration * a_this, int itemnr)
}
/**
+ * cr_declaration_get_by_prop_name:
+ *@a_this: the current instance of #CRDeclaration.
+ *@a_prop: the property name to search for.
+ *
*Use property name to get a CRDeclaration from the declaration list.
- *@param a_this the current instance of #CRDeclaration.
- *@param a_prop the property name to search for.
- *@return CRDeclaration with property name a_prop, or NULL if not found.
+ *Returns #CRDeclaration with property name a_prop, or NULL if not found.
*/
CRDeclaration *
cr_declaration_get_by_prop_name (CRDeclaration * a_this,
@@ -666,7 +711,7 @@ cr_declaration_get_by_prop_name (CRDeclaration * a_this,
&& cur->property->stryng
&& cur->property->stryng->str) {
if (!strcmp (cur->property->stryng->str,
- (char *)a_prop)) {
+ a_prop)) {
return cur;
}
}
@@ -675,8 +720,10 @@ cr_declaration_get_by_prop_name (CRDeclaration * a_this,
}
/**
+ * cr_declaration_ref:
+ *@a_this: the current instance of #CRDeclaration.
+ *
*Increases the ref count of the current instance of #CRDeclaration.
- *@param a_this the current instance of #CRDeclaration.
*/
void
cr_declaration_ref (CRDeclaration * a_this)
@@ -687,12 +734,14 @@ cr_declaration_ref (CRDeclaration * a_this)
}
/**
+ * cr_declaration_unref:
+ *@a_this: the current instance of #CRDeclaration.
+ *
*Decrements the ref count of the current instance of #CRDeclaration.
*If the ref count reaches zero, the current instance of #CRDeclaration
*if destroyed.
- *@param a_this the current instance of #CRDeclaration.
- *@return TRUE if the current instance of #CRDeclaration has been destroyed
- *(ref count reached zero), FALSE otherwise.
+ *Returns TRUE if @a_this was destroyed (ref count reached zero),
+ *FALSE otherwise.
*/
gboolean
cr_declaration_unref (CRDeclaration * a_this)
@@ -711,8 +760,10 @@ cr_declaration_unref (CRDeclaration * a_this)
}
/**
+ * cr_declaration_destroy:
+ *@a_this: the current instance of #CRDeclaration.
+ *
*Destructor of the declaration list.
- *@param a_this the current instance of #CRDeclaration.
*/
void
cr_declaration_destroy (CRDeclaration * a_this)
@@ -722,22 +773,19 @@ cr_declaration_destroy (CRDeclaration * a_this)
g_return_if_fail (a_this);
/*
- *Go get the tail of the list.
- *Meanwhile, free each property/value pair contained in the list.
+ * Go to the last element of the list.
*/
- for (cur = a_this; cur && cur->next; cur = cur->next) {
- if (cur->property) {
- cr_string_destroy (cur->property);
- cur->property = NULL;
- }
+ for (cur = a_this; cur->next; cur = cur->next)
+ g_assert (cur->next->prev == cur);
- if (cur->value) {
- cr_term_destroy (cur->value);
- cur->value = NULL;
- }
- }
+ /*
+ * Walk backward the list and free each "next" element.
+ * Meanwhile, free each property/value pair contained in the list.
+ */
+ for (; cur; cur = cur->prev) {
+ g_free (cur->next);
+ cur->next = NULL;
- if (cur) {
if (cur->property) {
cr_string_destroy (cur->property);
cur->property = NULL;
@@ -749,27 +797,5 @@ cr_declaration_destroy (CRDeclaration * a_this)
}
}
- /*in case the list contains only one element */
- if (cur && !cur->prev) {
- g_free (cur);
- return;
- }
-
- /*walk backward the list and free each "next" element */
- for (cur = cur->prev; cur && cur->prev; cur = cur->prev) {
- if (cur->next) {
- g_free (cur->next);
- cur->next = NULL;
- }
- }
-
- if (!cur)
- return;
-
- if (cur->next) {
- g_free (cur->next);
- cur->next = NULL;
- }
-
- g_free (cur);
+ g_free (a_this);
}
diff --git a/src/cr-declaration.h b/src/cr-declaration.h
index 0052395..eee8be3 100644
--- a/src/cr-declaration.h
+++ b/src/cr-declaration.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -100,14 +100,14 @@ CRDeclaration * cr_declaration_prepend (CRDeclaration *a_this,
CRDeclaration * cr_declaration_unlink (CRDeclaration * a_decl) ;
void
-cr_declaration_dump (CRDeclaration *a_this,
+cr_declaration_dump (CRDeclaration const *a_this,
FILE *a_fp, glong a_indent,
gboolean a_one_per_line) ;
-void cr_declaration_dump_one (CRDeclaration *a_this,
+void cr_declaration_dump_one (CRDeclaration const *a_this,
FILE *a_fp, glong a_indent) ;
-gint cr_declaration_nr_props (CRDeclaration *a_this) ;
+gint cr_declaration_nr_props (CRDeclaration const *a_this) ;
CRDeclaration * cr_declaration_get_from_list (CRDeclaration *a_this,
int itemnr) ;
@@ -115,13 +115,13 @@ CRDeclaration * cr_declaration_get_from_list (CRDeclaration *a_this,
CRDeclaration * cr_declaration_get_by_prop_name (CRDeclaration *a_this,
const guchar *a_str) ;
-gchar * cr_declaration_to_string (CRDeclaration *a_this,
+gchar * cr_declaration_to_string (CRDeclaration const *a_this,
gulong a_indent) ;
-guchar * cr_declaration_list_to_string (CRDeclaration *a_this,
+guchar * cr_declaration_list_to_string (CRDeclaration const *a_this,
gulong a_indent) ;
-guchar * cr_declaration_list_to_string2 (CRDeclaration *a_this,
+guchar * cr_declaration_list_to_string2 (CRDeclaration const *a_this,
gulong a_indent,
gboolean a_one_decl_per_line) ;
diff --git a/src/cr-doc-handler.c b/src/cr-doc-handler.c
index 00357c0..bbb1582 100644
--- a/src/cr-doc-handler.c
+++ b/src/cr-doc-handler.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -25,7 +25,8 @@
#include "cr-parser.h"
/**
- *@file
+ *@CRDocHandler:
+ *
*The definition of the CRDocHandler class.
*Contains methods to instantiate, destroy,
*and initialyze instances of #CRDocHandler
@@ -58,20 +59,26 @@ struct _CRDocHandlerPriv {
};
/**
+ * cr_doc_handler_new:
*Constructor of #CRDocHandler.
- *@return the newly built instance of
+ *
+ *Returns the newly built instance of
*#CRDocHandler
+ *
*/
CRDocHandler *
cr_doc_handler_new (void)
{
- CRDocHandler *result = ( CRDocHandler *)g_try_malloc (sizeof (CRDocHandler));
+ CRDocHandler *result = NULL;
+
+ result = g_try_malloc (sizeof (CRDocHandler));
g_return_val_if_fail (result, NULL);
memset (result, 0, sizeof (CRDocHandler));
+ result->ref_count++;
- result->priv = (CRDocHandlerPriv *)g_try_malloc (sizeof (CRDocHandlerPriv));
+ result->priv = g_try_malloc (sizeof (CRDocHandlerPriv));
if (!result->priv) {
cr_utils_trace_info ("Out of memory exception");
g_free (result);
@@ -84,15 +91,17 @@ cr_doc_handler_new (void)
}
/**
- *Returns the private parsing context.
+ * cr_doc_handler_get_ctxt:
+ *@a_this: the current instance of #CRDocHandler.
+ *@a_ctxt: out parameter. The new parsing context.
+ *
+ *Gets the private parsing context associated to the document handler
*The private parsing context is used by libcroco only.
- *@param a_this the current instance of #CRDocHandler.
- *@param a_ctxt out parameter. The new parsing context.
- *@return CR_OK upon successfull completion, an error code otherwise.
- *@return the parsing context, or NULL if an error occured.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
-cr_doc_handler_get_ctxt (CRDocHandler * a_this, gpointer * a_ctxt)
+cr_doc_handler_get_ctxt (CRDocHandler const * a_this, gpointer * a_ctxt)
{
g_return_val_if_fail (a_this && a_this->priv, CR_BAD_PARAM_ERROR);
@@ -102,11 +111,13 @@ cr_doc_handler_get_ctxt (CRDocHandler * a_this, gpointer * a_ctxt)
}
/**
+ * cr_doc_handler_set_ctxt:
+ *@a_this: the current instance of #CRDocHandler
+ *@a_ctxt: a pointer to the parsing context.
+ *
*Sets the private parsing context.
*This is used by libcroco only.
- *@param a_this the current instance of #CRDocHandler
- *@param a_ctxt a pointer to the parsing context.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_doc_handler_set_ctxt (CRDocHandler * a_this, gpointer a_ctxt)
@@ -117,14 +128,17 @@ cr_doc_handler_set_ctxt (CRDocHandler * a_this, gpointer a_ctxt)
}
/**
- *Returns the private parsing result.
+ * cr_doc_handler_get_result:
+ *@a_this: the current instance of #CRDocHandler
+ *@a_result: out parameter. The returned result.
+ *
+ *Gets the private parsing result.
*The private parsing result is used by libcroco only.
- *@param a_this the current instance of #CRDocHandler
- *@param a_result out parameter. The returned result.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
-cr_doc_handler_get_result (CRDocHandler * a_this, gpointer * a_result)
+cr_doc_handler_get_result (CRDocHandler const * a_this, gpointer * a_result)
{
g_return_val_if_fail (a_this && a_this->priv, CR_BAD_PARAM_ERROR);
@@ -134,11 +148,14 @@ cr_doc_handler_get_result (CRDocHandler * a_this, gpointer * a_result)
}
/**
+ * cr_doc_handler_set_result:
+ *@a_this: the current instance of #CRDocHandler
+ *@a_result: the new result.
+ *
*Sets the private parsing context.
*This is used by libcroco only.
- *@param a_this the current instance of #CRDocHandler
- *@param a_result the new result.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_doc_handler_set_result (CRDocHandler * a_this, gpointer a_result)
@@ -149,14 +166,16 @@ cr_doc_handler_set_result (CRDocHandler * a_this, gpointer a_result)
}
/**
+ *cr_doc_handler_set_default_sac_handler:
+ *@a_this: a pointer to the current instance of #CRDocHandler.
+ *
*Sets the sac handlers contained in the current
*instance of DocHandler to the default handlers.
*For the time being the default handlers are
*test handlers. This is expected to change in a
*near future, when the libcroco gets a bit debugged.
*
- *@param a_this a pointer to the current instance of #CRDocHandler.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_doc_handler_set_default_sac_handler (CRDocHandler * a_this)
@@ -184,8 +203,8 @@ cr_doc_handler_set_default_sac_handler (CRDocHandler * a_this)
}
/**
- *Increases the reference count of the doc handler
- *@param a_this the current instance of #CRDocHandler.
+ * cr_doc_handler_ref:
+ *@a_this: the current instance of #CRDocHandler.
*/
void
cr_doc_handler_ref (CRDocHandler * a_this)
@@ -196,10 +215,13 @@ cr_doc_handler_ref (CRDocHandler * a_this)
}
/**
+ * cr_doc_handler_unref:
+ *@a_this: the currrent instance of #CRDocHandler.
+ *
*Decreases the ref count of the current instance of #CRDocHandler.
*If the ref count reaches '0' then, destroys the instance.
- *@param a_this the currrent instance of #CRDocHandler.
- *@return TRUE if the instance as been destroyed, FALSE otherwise.
+ *
+ *Returns TRUE if the instance as been destroyed, FALSE otherwise.
*/
gboolean
cr_doc_handler_unref (CRDocHandler * a_this)
@@ -218,9 +240,11 @@ cr_doc_handler_unref (CRDocHandler * a_this)
}
/**
- *The destructor of the #CRDocHandler class.
- *@param a_this the instance of #CRDocHandler to
+ * cr_doc_handler_destroy:
+ *@a_this: the instance of #CRDocHandler to
*destroy.
+ *
+ *The destructor of the #CRDocHandler class.
*/
void
cr_doc_handler_destroy (CRDocHandler * a_this)
@@ -235,9 +259,11 @@ cr_doc_handler_destroy (CRDocHandler * a_this)
}
/**
+ * cr_doc_handler_associate_a_parser:
*Associates a parser to the current document handler
- *@param a_this the current instance of document handler.
- *@param a_parser the parser to associate.
+ *
+ *@a_this: the current instance of document handler.
+ *@a_parser: the parser to associate.
*/
void
cr_doc_handler_associate_a_parser (CRDocHandler *a_this,
@@ -246,5 +272,5 @@ cr_doc_handler_associate_a_parser (CRDocHandler *a_this,
g_return_if_fail (a_this && PRIVATE (a_this)
&& a_parser) ;
- PRIVATE (a_this)->parser = (CRParser *)a_parser ;
+ PRIVATE (a_this)->parser = a_parser ;
}
diff --git a/src/cr-doc-handler.h b/src/cr-doc-handler.h
index 704f186..d12673f 100644
--- a/src/cr-doc-handler.h
+++ b/src/cr-doc-handler.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -92,7 +92,7 @@ struct _CRDocHandler
*destination media for style information.
*@param a_uri the uri of the imported style sheet.
*@param a_uri_default_ns the default namespace of URI
- *@param a_location the parsing location of the '@import'
+ *@param a_location the parsing location of the '\@import'
*keyword.
*of the imported style sheet.
*/
@@ -175,7 +175,7 @@ struct _CRDocHandler
*
*@param a_this a pointer to the current instance of
*#CRDocHandler.
- *@param a_location the parsing location of the "@font-face"
+ *@param a_location the parsing location of the "\@font-face"
*keyword.
*/
void (*start_font_face) (CRDocHandler *a_this,
@@ -227,7 +227,7 @@ struct _CRDocHandler
*#CRDocHandler.
*@param a_name the name of the page (if any, null otherwise).
*@param a_pseudo_page the pseudo page (if any, null otherwise).
- *@param a_location the parsing location of the "@page" keyword.
+ *@param a_location the parsing location of the "\@page" keyword.
*/
void (*start_page) (CRDocHandler *a_this,
CRString *a_name,
@@ -239,7 +239,7 @@ struct _CRDocHandler
*@param a_this a pointer to the current instance of
*#CRDocHandler.
*@param a_name the name of the page (if any, null otherwise).
- *@parap a_pseudo_page the pseudo page (if any, null otherwise).
+ *@param a_pseudo_page the pseudo page (if any, null otherwise).
*/
void (*end_page) (CRDocHandler *a_this,
CRString *a_name,
@@ -276,11 +276,11 @@ CRDocHandler * cr_doc_handler_new (void) ;
enum CRStatus cr_doc_handler_set_result (CRDocHandler *a_this, gpointer a_result) ;
-enum CRStatus cr_doc_handler_get_result (CRDocHandler *a_this, gpointer * a_result) ;
+enum CRStatus cr_doc_handler_get_result (CRDocHandler const *a_this, gpointer * a_result) ;
enum CRStatus cr_doc_handler_set_ctxt (CRDocHandler *a_this, gpointer a_ctxt) ;
-enum CRStatus cr_doc_handler_get_ctxt (CRDocHandler *a_this, gpointer * a_ctxt) ;
+enum CRStatus cr_doc_handler_get_ctxt (CRDocHandler const *a_this, gpointer * a_ctxt) ;
enum CRStatus cr_doc_handler_set_default_sac_handler (CRDocHandler *a_this) ;
diff --git a/src/cr-enc-handler.c b/src/cr-enc-handler.c
index 973a5f3..b3e5b7e 100644
--- a/src/cr-enc-handler.c
+++ b/src/cr-enc-handler.c
@@ -21,7 +21,7 @@
*/
/*
- *$Id: cr-enc-handler.c,v 1.7 2004/03/07 13:22:47 dodji Exp $
+ *$Id$
*/
/**
@@ -57,7 +57,7 @@ static struct CREncAlias gv_default_aliases[] = {
{"UCS-4", CR_UCS_4},
{"UCS_4", CR_UCS_4},
{"ASCII", CR_ASCII},
- {(char *)0, (enum CREncoding)0}
+ {0, 0}
};
static CREncHandler gv_default_enc_handlers[] = {
@@ -70,14 +70,17 @@ static CREncHandler gv_default_enc_handlers[] = {
{CR_ASCII, cr_utils_ucs1_to_utf8, cr_utils_utf8_to_ucs1,
cr_utils_ucs1_str_len_as_utf8, cr_utils_utf8_str_len_as_ucs1},
- {(enum CREncoding)0, NULL, NULL, NULL, NULL}
+ {0, NULL, NULL, NULL, NULL}
};
/**
+ * cr_enc_handler_get_instance:
+ *@a_enc: the encoding of the Handler.
+ *
*Gets the instance of encoding handler.
*This function implements a singleton pattern.
- *@param a_enc the encoding of the Handler.
- *@return the instance of #CREncHandler.
+ *
+ *Returns the instance of #CREncHandler.
*/
CREncHandler *
cr_enc_handler_get_instance (enum CREncoding a_enc)
@@ -95,23 +98,27 @@ cr_enc_handler_get_instance (enum CREncoding a_enc)
}
/**
+ * cr_enc_handler_resolve_enc_alias:
+ *@a_alias_name: the encoding name.
+ *@a_enc: output param. The returned encoding type
+ *or 0 if the alias is not supported.
+ *
*Given an encoding name (called an alias name)
*the function returns the matching encoding type.
- *@param a_alias_name the encoding name
- *@param a_enc output param. The returned encoding type
- *or 0 if the alias is not supported.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_enc_handler_resolve_enc_alias (const guchar * a_alias_name,
enum CREncoding *a_enc)
{
gulong i = 0;
+ guchar *alias_name_up = NULL;
enum CRStatus status = CR_ENCODING_NOT_FOUND_ERROR;
g_return_val_if_fail (a_alias_name != NULL, CR_BAD_PARAM_ERROR);
- gchar *alias_name_up = g_strdup ((gchar *)a_alias_name);
+ alias_name_up = g_strdup (a_alias_name);
g_ascii_strup (alias_name_up, -1);
for (i = 0; gv_default_aliases[i].name; i++) {
@@ -126,16 +133,19 @@ cr_enc_handler_resolve_enc_alias (const guchar * a_alias_name,
}
/**
- *Converts a raw input buffer into an utf8 buffer.
- *@param a_this the current instance of #CREncHandler.
- *@param a_in the input buffer to convert.
- *@param a_in_len in/out parameter. The len of the input
+ * cr_enc_handler_convert_input:
+ *@a_this: the current instance of #CREncHandler.
+ *@a_in: the input buffer to convert.
+ *@a_in_len: in/out parameter. The len of the input
*buffer to convert. After return, contains the number of
*bytes actually consumed.
- *@param @a_out output parameter. The converted output buffer.
+ *@a_out: output parameter. The converted output buffer.
*Must be freed by the buffer.
- *@param a_out_len output parameter. The length of the output buffer.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *@a_out_len: output parameter. The length of the output buffer.
+ *
+ *Converts a raw input buffer into an utf8 buffer.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_enc_handler_convert_input (CREncHandler * a_this,
@@ -161,7 +171,7 @@ cr_enc_handler_convert_input (CREncHandler * a_this,
*a_out_len = *a_in_len;
}
- *a_out = (guchar *)g_malloc0 (*a_out_len);
+ *a_out = g_malloc0 (*a_out_len);
status = a_this->decode_input (a_in, a_in_len, *a_out, a_out_len);
diff --git a/src/cr-enc-handler.h b/src/cr-enc-handler.h
index 2f5da69..0727764 100644
--- a/src/cr-enc-handler.h
+++ b/src/cr-enc-handler.h
@@ -21,7 +21,7 @@
*/
/*
- *$Id: cr-enc-handler.h,v 1.5 2004/01/24 19:24:01 dodji Exp $
+ *$Id$
*/
/**
@@ -79,10 +79,8 @@ CREncHandler *
cr_enc_handler_get_instance (enum CREncoding a_enc) ;
enum CRStatus
-cr_enc_handler_resolve_enc_alias (const guchar *a_en_alias,
+cr_enc_handler_resolve_enc_alias (const guchar *a_alias_name,
enum CREncoding *a_enc) ;
-void
-cr_enc_handler_destroy (CREncHandler * a_enc_hdlr) ;
enum CRStatus
cr_enc_handler_convert_input (CREncHandler *a_this,
diff --git a/src/cr-fonts.c b/src/cr-fonts.c
index 14438c3..6ef347e 100644
--- a/src/cr-fonts.c
+++ b/src/cr-fonts.c
@@ -27,10 +27,10 @@
#include <string.h>
static enum CRStatus
-cr_font_family_to_string_real (CRFontFamily * a_this,
+cr_font_family_to_string_real (CRFontFamily const * a_this,
gboolean a_walk_list, GString ** a_string)
{
- gchar *name = NULL;
+ guchar const *name = NULL;
enum CRStatus result = CR_OK;
if (!*a_string) {
@@ -46,31 +46,31 @@ cr_font_family_to_string_real (CRFontFamily * a_this,
switch (a_this->type) {
case FONT_FAMILY_SANS_SERIF:
- name = (gchar *) "sans-serif";
+ name = (guchar const *) "sans-serif";
break;
case FONT_FAMILY_SERIF:
- name = (gchar *) "sans-serif";
+ name = (guchar const *) "sans-serif";
break;
case FONT_FAMILY_CURSIVE:
- name = (gchar *) "cursive";
+ name = (guchar const *) "cursive";
break;
case FONT_FAMILY_FANTASY:
- name = (gchar *) "fantasy";
+ name = (guchar const *) "fantasy";
break;
case FONT_FAMILY_MONOSPACE:
- name = (gchar *) "monospace";
+ name = (guchar const *) "monospace";
break;
case FONT_FAMILY_NON_GENERIC:
- name = (gchar *) a_this->name;
+ name = (guchar const *) a_this->name;
break;
default:
- name = (gchar *) NULL;
+ name = NULL;
break;
}
@@ -92,32 +92,32 @@ static const gchar *
cr_predefined_absolute_font_size_to_string (enum CRPredefinedAbsoluteFontSize
a_code)
{
- gchar *str = NULL;
+ gchar const *str = NULL;
switch (a_code) {
case FONT_SIZE_XX_SMALL:
- str = (gchar *) "xx-small";
+ str = "xx-small";
break;
case FONT_SIZE_X_SMALL:
- str = (gchar *) "x-small";
+ str = "x-small";
break;
case FONT_SIZE_SMALL:
- str = (gchar *) "small";
+ str = "small";
break;
case FONT_SIZE_MEDIUM:
- str = (gchar *) "medium";
+ str = "medium";
break;
case FONT_SIZE_LARGE:
- str = (gchar *) "large";
+ str = "large";
break;
case FONT_SIZE_X_LARGE:
- str = (gchar *) "x-large";
+ str = "x-large";
break;
case FONT_SIZE_XX_LARGE:
- str = (gchar *) "xx-large";
+ str = "xx-large";
break;
default:
- str = (gchar *) "unknown absolute font size value";
+ str = "unknown absolute font size value";
}
return str;
}
@@ -125,26 +125,37 @@ cr_predefined_absolute_font_size_to_string (enum CRPredefinedAbsoluteFontSize
static const gchar *
cr_relative_font_size_to_string (enum CRRelativeFontSize a_code)
{
- gchar *str = NULL;
+ gchar const *str = NULL;
switch (a_code) {
case FONT_SIZE_LARGER:
- str = (gchar *) "larger";
+ str = "larger";
break;
case FONT_SIZE_SMALLER:
- str = (gchar *) "smaller";
+ str = "smaller";
break;
default:
- str = (gchar *) "unknown relative font size value";
+ str = "unknown relative font size value";
break;
}
return str;
}
+/**
+ * cr_font_family_new:
+ * @a_type: the type of font family to create.
+ * @a_name: the name of the font family.
+ *
+ * create a font family.
+ *
+ * Returns the newly built font family.
+ */
CRFontFamily *
cr_font_family_new (enum CRFontFamilyType a_type, guchar * a_name)
{
- CRFontFamily *result = (CRFontFamily *)g_try_malloc (sizeof (CRFontFamily));
+ CRFontFamily *result = NULL;
+
+ result = g_try_malloc (sizeof (CRFontFamily));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -159,18 +170,26 @@ cr_font_family_new (enum CRFontFamilyType a_type, guchar * a_name)
return result;
}
+/**
+ * cr_font_family_to_string:
+ * @a_this: the current instance of #CRFontFamily.
+ * @a_walk_font_family_list: wether the serialize the entire list.
+ *
+ * Returns the seriliazed font family. The caller has to free it using
+ * g_free().
+ */
guchar *
-cr_font_family_to_string (CRFontFamily * a_this,
+cr_font_family_to_string (CRFontFamily const * a_this,
gboolean a_walk_font_family_list)
{
enum CRStatus status = CR_OK;
- gchar *result = NULL;
+ guchar *result = NULL;
GString *stringue = NULL;
if (!a_this) {
result = g_strdup ("NULL");
g_return_val_if_fail (result, NULL);
- return (guchar *)result;
+ return result;
}
status = cr_font_family_to_string_real (a_this,
a_walk_font_family_list,
@@ -188,8 +207,16 @@ cr_font_family_to_string (CRFontFamily * a_this,
}
}
- return (guchar *)result;
+ return result;
}
+
+/**
+ * cr_font_family_set_name:
+ * @a_this: the current instance of #CRFontFamily.
+ * @a_name: the new name
+ *
+ * Returns CR_OK upon sucessful completion, an error code otherwise.
+ */
enum CRStatus
cr_font_family_set_name (CRFontFamily * a_this, guchar * a_name)
{
@@ -212,6 +239,13 @@ cr_font_family_set_name (CRFontFamily * a_this, guchar * a_name)
return CR_OK;
}
+/**
+ * cr_font_family_append:
+ * @a_this: the current instance of #CRFontFamily.
+ * @a_family_to_append: the font family to append to the list
+ *
+ * Returns the new font family list.
+ */
CRFontFamily *
cr_font_family_append (CRFontFamily * a_this,
CRFontFamily * a_family_to_append)
@@ -232,6 +266,13 @@ cr_font_family_append (CRFontFamily * a_this,
}
+/**
+ * cr_font_family_prepend:
+ * @a_this: the current instance #CRFontFamily.
+ * @a_family_to_prepend: the font family to prepend to the list.
+ *
+ * Returns the font family list.
+ */
CRFontFamily *
cr_font_family_prepend (CRFontFamily * a_this,
CRFontFamily * a_family_to_prepend)
@@ -247,6 +288,12 @@ cr_font_family_prepend (CRFontFamily * a_this,
return a_family_to_prepend;
}
+/**
+ * cr_font_family_destroy:
+ * @a_this: the current instance of #CRFontFamily.
+ *
+ * Returns CR_OK upon sucessful completion, an error code otherwise.
+ */
enum CRStatus
cr_font_family_destroy (CRFontFamily * a_this)
{
@@ -279,10 +326,17 @@ cr_font_family_destroy (CRFontFamily * a_this)
*'font-size' manipulation functions definitions
***************************************************/
+/**
+ * cr_font_size_new:
+ *
+ * Returns the newly created font size.
+ */
CRFontSize *
cr_font_size_new (void)
{
- CRFontSize *result = (CRFontSize *)g_try_malloc (sizeof (CRFontSize));
+ CRFontSize *result = NULL;
+
+ result = g_try_malloc (sizeof (CRFontSize));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
@@ -292,6 +346,12 @@ cr_font_size_new (void)
return result;
}
+/**
+ * cr_font_size_clear:
+ * @a_this: the current instance of #CRFontSize
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
+ */
enum CRStatus
cr_font_size_clear (CRFontSize * a_this)
{
@@ -315,8 +375,15 @@ cr_font_size_clear (CRFontSize * a_this)
return CR_OK;
}
+/**
+ * cr_font_size_copy:
+ * @a_dst: the destination #CRFontSize (where to copy to).
+ * @a_src: the source #CRFontSize (where to copy from).
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
+ */
enum CRStatus
-cr_font_size_copy (CRFontSize * a_dst, CRFontSize * a_src)
+cr_font_size_copy (CRFontSize * a_dst, CRFontSize const * a_src)
{
g_return_val_if_fail (a_dst && a_src, CR_BAD_PARAM_ERROR);
@@ -341,12 +408,20 @@ cr_font_size_copy (CRFontSize * a_dst, CRFontSize * a_src)
return CR_OK;
}
+/**
+ * cr_font_size_set_predefined_absolute_font_size:
+ * @a_this: the current instance of #CRFontSize.
+ * @a_predefined: what to set.
+ *
+ * Returns CR_OK upon sucessful completion, an error code otherwise.
+ */
enum CRStatus
cr_font_size_set_predefined_absolute_font_size (CRFontSize *a_this,
enum CRPredefinedAbsoluteFontSize a_predefined)
{
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
- g_return_val_if_fail ((unsigned)a_predefined < NB_FONT_SIZE_TYPE,
+ g_return_val_if_fail (a_predefined >= PREDEFINED_ABSOLUTE_FONT_SIZE
+ && a_predefined < NB_FONT_SIZE_TYPE,
CR_BAD_PARAM_ERROR) ;
a_this->type = PREDEFINED_ABSOLUTE_FONT_SIZE ;
@@ -355,12 +430,20 @@ cr_font_size_set_predefined_absolute_font_size (CRFontSize *a_this,
return CR_OK ;
}
+/**
+ * cr_font_size_set_relative_font_size:
+ * @a_this: the current instance of #CRFontSize
+ * @a_relative: the new relative font size
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
+ */
enum CRStatus
cr_font_size_set_relative_font_size (CRFontSize *a_this,
enum CRRelativeFontSize a_relative)
{
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
- g_return_val_if_fail ((unsigned)a_relative < NB_RELATIVE_FONT_SIZE,
+ g_return_val_if_fail (a_relative >= FONT_SIZE_LARGER
+ && a_relative < NB_RELATIVE_FONT_SIZE,
CR_BAD_PARAM_ERROR) ;
a_this->type = RELATIVE_FONT_SIZE ;
@@ -368,13 +451,22 @@ cr_font_size_set_relative_font_size (CRFontSize *a_this,
return CR_OK ;
}
+/**
+ * cr_font_size_set_absolute_font_size:
+ * @a_this: the current instance of #CRFontSize
+ * @a_num_type: the type of number to set.
+ * @a_value: the actual value to set.
+ *
+ * Returns CR_OK upon succesful completion, an error code otherwise.
+ */
enum CRStatus
cr_font_size_set_absolute_font_size (CRFontSize *a_this,
enum CRNumType a_num_type,
gdouble a_value)
{
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
- g_return_val_if_fail ((unsigned)a_num_type < NB_NUM_TYPE,
+ g_return_val_if_fail (a_num_type >= NUM_AUTO
+ && a_num_type < NB_NUM_TYPE,
CR_BAD_PARAM_ERROR) ;
a_this->type = ABSOLUTE_FONT_SIZE ;
@@ -383,6 +475,12 @@ cr_font_size_set_absolute_font_size (CRFontSize *a_this,
return CR_OK ;
}
+/**
+ * cr_font_size_set_to_inherit:
+ * @a_this: the current instance of #CRFontSize
+ *
+ * Returns CR_OK upon succesful completion, an error code otherwise.
+ */
enum CRStatus
cr_font_size_set_to_inherit (CRFontSize *a_this)
{
@@ -394,16 +492,29 @@ cr_font_size_set_to_inherit (CRFontSize *a_this)
return CR_OK ;
}
+/**
+ * cr_font_size_is_set_to_inherit:
+ * @a_this: the current instance of #CRFontSize.
+ *
+ * Returns TRUE if the current instance is set to 'inherit'.
+ */
gboolean
-cr_font_size_is_set_to_inherit (CRFontSize *a_this)
+cr_font_size_is_set_to_inherit (CRFontSize const *a_this)
{
g_return_val_if_fail (a_this, FALSE) ;
return a_this->type == INHERITED_FONT_SIZE ;
}
+/**
+ * cr_font_size_to_string:
+ * @a_this: the current instance of #CRFontSize
+ *
+ * Returns the serialized form of #CRFontSize. The returned string
+ * has to bee freed using g_free().
+ */
gchar *
-cr_font_size_to_string (CRFontSize * a_this)
+cr_font_size_to_string (CRFontSize const * a_this)
{
gchar *str = NULL;
@@ -418,7 +529,7 @@ cr_font_size_to_string (CRFontSize * a_this)
(a_this->value.predefined));
break;
case ABSOLUTE_FONT_SIZE:
- str = (gchar *)cr_num_to_string (&a_this->value.absolute);
+ str = cr_num_to_string (&a_this->value.absolute);
break;
case RELATIVE_FONT_SIZE:
str = g_strdup (cr_relative_font_size_to_string
@@ -433,14 +544,21 @@ cr_font_size_to_string (CRFontSize * a_this)
return str;
}
+/**
+ * cr_font_size_get_smaller_predefined:
+ * @a_font_size: the font size to consider.
+ * @a_smaller_size: out parameter. The a smaller value than @a_font_size.
+ */
void
-cr_font_size_get_smaller_predefined_font_size (enum CRPredefinedAbsoluteFontSize a_font_size,
- enum CRPredefinedAbsoluteFontSize *a_smaller_size)
+cr_font_size_get_smaller_predefined_font_size
+ (enum CRPredefinedAbsoluteFontSize a_font_size,
+ enum CRPredefinedAbsoluteFontSize *a_smaller_size)
{
enum CRPredefinedAbsoluteFontSize result = FONT_SIZE_MEDIUM ;
g_return_if_fail (a_smaller_size) ;
- g_return_if_fail ((unsigned)a_font_size < NB_PREDEFINED_ABSOLUTE_FONT_SIZES) ;
+ g_return_if_fail (a_font_size < NB_PREDEFINED_ABSOLUTE_FONT_SIZES
+ && a_font_size >= FONT_SIZE_XX_SMALL) ;
switch (a_font_size) {
case FONT_SIZE_XX_SMALL:
@@ -477,14 +595,23 @@ cr_font_size_get_smaller_predefined_font_size (enum CRPredefinedAbsoluteFontSize
}
+/**
+ * cr_font_size_get_larger_predefined_font_size:
+ * @a_font_size: the font size to consider.
+ * @a_larger_size: out parameter. the font size considered larger than
+ * @a_font_size.
+ *
+ */
void
-cr_font_size_get_larger_predefined_font_size (enum CRPredefinedAbsoluteFontSize a_font_size,
- enum CRPredefinedAbsoluteFontSize *a_larger_size)
+cr_font_size_get_larger_predefined_font_size
+ (enum CRPredefinedAbsoluteFontSize a_font_size,
+ enum CRPredefinedAbsoluteFontSize *a_larger_size)
{
enum CRPredefinedAbsoluteFontSize result = FONT_SIZE_MEDIUM ;
g_return_if_fail (a_larger_size) ;
- g_return_if_fail ((unsigned)a_font_size < NB_PREDEFINED_ABSOLUTE_FONT_SIZES) ;
+ g_return_if_fail (a_font_size >= FONT_SIZE_XX_SMALL
+ && a_font_size < NB_PREDEFINED_ABSOLUTE_FONT_SIZES) ;
switch (a_font_size) {
case FONT_SIZE_XX_SMALL:
@@ -520,18 +647,33 @@ cr_font_size_get_larger_predefined_font_size (enum CRPredefinedAbsoluteFontSize
*a_larger_size = result ;
}
+/**
+ * cr_font_size_is_predefined_absolute_font_size:
+ * @a_font_size: the font size to consider.
+ *
+ * Returns TRUE if the instance is an predefined absolute font size, FALSE
+ * otherwise.
+ */
gboolean
-cr_font_size_is_predefined_absolute_font_size (enum CRPredefinedAbsoluteFontSize a_font_size)
+cr_font_size_is_predefined_absolute_font_size
+ (enum CRPredefinedAbsoluteFontSize a_font_size)
{
- if ((unsigned)a_font_size < NB_PREDEFINED_ABSOLUTE_FONT_SIZES) {
+ if (a_font_size >= FONT_SIZE_XX_SMALL
+ && a_font_size < NB_PREDEFINED_ABSOLUTE_FONT_SIZES) {
return TRUE ;
} else {
return FALSE ;
}
}
+/**
+ * cr_font_size_adjust_to_string:
+ * @a_this: the instance of #CRFontSizeAdjust.
+ *
+ * Returns the serialized form of #CRFontSizeAdjust
+ */
gchar *
-cr_font_size_adjust_to_string (CRFontSizeAdjust * a_this)
+cr_font_size_adjust_to_string (CRFontSizeAdjust const * a_this)
{
gchar *str = NULL;
@@ -547,9 +689,9 @@ cr_font_size_adjust_to_string (CRFontSizeAdjust * a_this)
break;
case FONT_SIZE_ADJUST_NUMBER:
if (a_this->num)
- str = (gchar *)cr_num_to_string (a_this->num);
+ str = cr_num_to_string (a_this->num);
else
- str = g_strdup ("unknow font-size-adjust property value"); // Should raise an error no?
+ str = g_strdup ("unknow font-size-adjust property value"); /* Should raise an error no?*/
break;
case FONT_SIZE_ADJUST_INHERIT:
str = g_strdup ("inherit");
@@ -557,6 +699,13 @@ cr_font_size_adjust_to_string (CRFontSizeAdjust * a_this)
return str;
}
+/**
+ * cr_font_style_to_string:
+ * @a_code: the current instance of #CRFontStyle .
+ *
+ * Returns the serialized #CRFontStyle. The caller must free the returned
+ * string using g_free().
+ */
const gchar *
cr_font_style_to_string (enum CRFontStyle a_code)
{
@@ -582,6 +731,13 @@ cr_font_style_to_string (enum CRFontStyle a_code)
return str;
}
+/**
+ * cr_font_variant_to_string:
+ * @a_code: the current instance of #CRFontVariant.
+ *
+ * Returns the serialized form of #CRFontVariant. The caller has
+ * to free the returned string using g_free().
+ */
const gchar *
cr_font_variant_to_string (enum CRFontVariant a_code)
{
@@ -601,10 +757,19 @@ cr_font_variant_to_string (enum CRFontVariant a_code)
return str;
}
+/**
+ * cr_font_weight_get_bolder:
+ * @a_weight: the #CRFontWeight to consider.
+ *
+ * Returns a font weight bolder than @a_weight
+ */
enum CRFontWeight
cr_font_weight_get_bolder (enum CRFontWeight a_weight)
{
- if (a_weight >= NB_FONT_WEIGHTS) {
+ if (a_weight == FONT_WEIGHT_INHERIT) {
+ cr_utils_trace_info ("can't return a bolder weight for FONT_WEIGHT_INHERIT") ;
+ return a_weight;
+ } else if (a_weight >= FONT_WEIGHT_900) {
return FONT_WEIGHT_900 ;
} else if (a_weight < FONT_WEIGHT_NORMAL) {
return FONT_WEIGHT_NORMAL ;
@@ -613,10 +778,16 @@ cr_font_weight_get_bolder (enum CRFontWeight a_weight)
cr_utils_trace_info ("FONT_WEIGHT_BOLDER or FONT_WEIGHT_LIGHTER should not appear here") ;
return FONT_WEIGHT_NORMAL ;
} else {
- return (enum CRFontWeight)(a_weight << 1) ;
+ return a_weight << 1 ;
}
}
+/**
+ * cr_font_weight_to_string:
+ * @a_code: the font weight to consider.
+ *
+ * Returns the serialized form of #CRFontWeight.
+ */
const gchar *
cr_font_weight_to_string (enum CRFontWeight a_code)
{
@@ -672,6 +843,12 @@ cr_font_weight_to_string (enum CRFontWeight a_code)
return str;
}
+/**
+ * cr_font_stretch_to_string:
+ * @a_code: the instance of #CRFontStretch to consider.
+ *
+ * Returns the serialized form of #CRFontStretch.
+ */
const gchar *
cr_font_stretch_to_string (enum CRFontStretch a_code)
{
@@ -718,6 +895,11 @@ cr_font_stretch_to_string (enum CRFontStretch a_code)
return str;
}
+/**
+ * cr_font_size_destroy:
+ * @a_font_size: the font size to destroy
+ *
+ */
void
cr_font_size_destroy (CRFontSize * a_font_size)
{
@@ -730,11 +912,17 @@ cr_font_size_destroy (CRFontSize * a_font_size)
*'font-size-adjust' manipulation function definition
*******************************************************/
+/**
+ * cr_font_size_adjust_new:
+ *
+ * Returns a newly built instance of #CRFontSizeAdjust
+ */
CRFontSizeAdjust *
cr_font_size_adjust_new (void)
{
- CRFontSizeAdjust *result =
- (CRFontSizeAdjust *)g_try_malloc (sizeof (CRFontSizeAdjust));
+ CRFontSizeAdjust *result = NULL;
+
+ result = g_try_malloc (sizeof (CRFontSizeAdjust));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
@@ -744,6 +932,11 @@ cr_font_size_adjust_new (void)
return result;
}
+/**
+ * cr_font_size_adjust_destroy:
+ * @a_this: the current instance of #CRFontSizeAdjust.
+ *
+ */
void
cr_font_size_adjust_destroy (CRFontSizeAdjust * a_this)
{
diff --git a/src/cr-fonts.h b/src/cr-fonts.h
index 4544618..9eaeeeb 100644
--- a/src/cr-fonts.h
+++ b/src/cr-fonts.h
@@ -25,7 +25,6 @@
#ifndef __CR_FONTS_H__
#define __CR_FONTS_H__
-#endif
#include "cr-utils.h"
#include "cr-num.h"
@@ -236,7 +235,7 @@ cr_font_family_append (CRFontFamily *a_this,
CRFontFamily *a_family_to_append) ;
guchar *
-cr_font_family_to_string (CRFontFamily *a_this,
+cr_font_family_to_string (CRFontFamily const *a_this,
gboolean a_walk_font_family_list) ;
CRFontFamily *
@@ -259,7 +258,7 @@ CRFontSize * cr_font_size_new (void) ;
enum CRStatus cr_font_size_clear (CRFontSize *a_this) ;
enum CRStatus cr_font_size_copy (CRFontSize *a_dst,
- CRFontSize *a_src) ;
+ CRFontSize const *a_src) ;
enum CRStatus cr_font_size_set_predefined_absolute_font_size (CRFontSize *a_this,
enum CRPredefinedAbsoluteFontSize a_predefined) ;
enum CRStatus cr_font_size_set_relative_font_size (CRFontSize *a_this,
@@ -271,9 +270,9 @@ enum CRStatus cr_font_size_set_absolute_font_size (CRFontSize *a_this,
enum CRStatus cr_font_size_set_to_inherit (CRFontSize *a_this) ;
-gboolean cr_font_size_is_set_to_inherit (CRFontSize *a_this) ;
+gboolean cr_font_size_is_set_to_inherit (CRFontSize const *a_this) ;
-gchar* cr_font_size_to_string (CRFontSize *a_this) ;
+gchar* cr_font_size_to_string (CRFontSize const *a_this) ;
void cr_font_size_destroy (CRFontSize *a_font_size) ;
@@ -283,7 +282,7 @@ void cr_font_size_destroy (CRFontSize *a_font_size) ;
CRFontSizeAdjust * cr_font_size_adjust_new (void) ;
-gchar * cr_font_size_adjust_to_string (CRFontSizeAdjust *a_this) ;
+gchar * cr_font_size_adjust_to_string (CRFontSizeAdjust const *a_this) ;
void cr_font_size_adjust_destroy (CRFontSizeAdjust *a_this) ;
@@ -312,3 +311,5 @@ const gchar * cr_font_variant_to_string (enum CRFontVariant a_code) ;
const gchar * cr_font_stretch_to_string (enum CRFontStretch a_code) ;
G_END_DECLS
+
+#endif
diff --git a/src/cr-input.c b/src/cr-input.c
index 8613292..3cc283e 100644
--- a/src/cr-input.c
+++ b/src/cr-input.c
@@ -27,7 +27,8 @@
#include "cr-enc-handler.h"
/**
- *@file
+ *@CRInput:
+ *
*The definition of the #CRInput class.
*/
@@ -87,14 +88,16 @@ static CRInput *cr_input_new_real (void);
static CRInput *
cr_input_new_real (void)
{
- CRInput *result = (CRInput *)g_try_malloc (sizeof (CRInput));
+ CRInput *result = NULL;
+
+ result = g_try_malloc (sizeof (CRInput));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
}
memset (result, 0, sizeof (CRInput));
- PRIVATE (result) = (CRInputPriv *)g_try_malloc (sizeof (CRInputPriv));
+ PRIVATE (result) = g_try_malloc (sizeof (CRInputPriv));
if (!PRIVATE (result)) {
cr_utils_trace_info ("Out of memory");
g_free (result);
@@ -110,15 +113,17 @@ cr_input_new_real (void)
***************/
/**
- *Creates a new input stream from a memory buffer.
- *@param a_buf the memory buffer to create the input stream from.
+ * cr_input_new_from_buf:
+ *@a_buf: the memory buffer to create the input stream from.
*The #CRInput keeps this pointer so user should not free it !.
- *@param a_len the size of the input buffer.
- *@param a_enc the buffer's encoding.
- *@param a_free_buf if set to TRUE, this a_buf will be freed
+ *@a_len: the size of the input buffer.
+ *@a_enc: the buffer's encoding.
+ *@a_free_buf: if set to TRUE, this a_buf will be freed
*at the destruction of this instance. If set to false, it is up
*to the caller to free it.
- *@return the newly built instance of #CRInput.
+ *
+ *Creates a new input stream from a memory buffer.
+ *Returns the newly built instance of #CRInput.
*/
CRInput *
cr_input_new_from_buf (guchar * a_buf,
@@ -175,13 +180,14 @@ cr_input_new_from_buf (guchar * a_buf,
}
/**
+ * cr_input_new_from_uri:
+ *@a_file_uri: the file to create *the input stream from.
+ *@a_enc: the encoding of the file *to create the input from.
+ *
*Creates a new input stream from
*a file.
- *@param a_file_uri the file to create
- *the input stream from.
- *@param a_enc the encoding of the file
- *to create the input from
- *@return the newly created input stream if
+ *
+ *Returns the newly created input stream if
*this method could read the file and create it,
*NULL otherwise.
*/
@@ -234,7 +240,7 @@ cr_input_new_from_uri (const gchar * a_file_uri, enum CREncoding a_enc)
if (status == CR_OK) {
/*read went well */
- buf = (guchar *)g_realloc (buf, len + CR_INPUT_MEM_CHUNK_SIZE);
+ buf = g_realloc (buf, len + CR_INPUT_MEM_CHUNK_SIZE);
memcpy (buf + len, tmp_buf, nb_read);
len += nb_read;
buf_size += CR_INPUT_MEM_CHUNK_SIZE;
@@ -268,8 +274,10 @@ cr_input_new_from_uri (const gchar * a_file_uri, enum CREncoding a_enc)
}
/**
+ * cr_input_destroy:
+ *@a_this: the current instance of #CRInput.
+ *
*The destructor of the #CRInput class.
- *@param a_this the current instance of #CRInput.
*/
void
cr_input_destroy (CRInput * a_this)
@@ -291,9 +299,11 @@ cr_input_destroy (CRInput * a_this)
}
/**
+ * cr_input_ref:
+ *@a_this: the current instance of #CRInput.
+ *
*Increments the reference count of the current
*instance of #CRInput.
- *@param a_this the current instance of #CRInput.
*/
void
cr_input_ref (CRInput * a_this)
@@ -304,11 +314,14 @@ cr_input_ref (CRInput * a_this)
}
/**
+ * cr_input_unref:
+ *@a_this: the current instance of #CRInput.
+ *
*Decrements the reference count of this instance
*of #CRInput. If the reference count goes down to
*zero, this instance is destroyed.
- *@param a_this the current instance of #CRInput.
*
+ * Returns TRUE if the instance of #CRInput got destroyed, false otherwise.
*/
gboolean
cr_input_unref (CRInput * a_this)
@@ -327,18 +340,21 @@ cr_input_unref (CRInput * a_this)
}
/**
- *Tests wether the current instance of
- *#CRInput has reached its input buffer.
- *@param a_this the current instance of #CRInput.
- *@param a_end_of_input out parameter. Is set to TRUE if
+ * cr_input_end_of_input:
+ *@a_this: the current instance of #CRInput.
+ *@a_end_of_input: out parameter. Is set to TRUE if
*the current instance has reached the end of its input buffer,
*FALSE otherwise.
- *@param CR_OK upon successful completion, an error code otherwise.
- *Note that all the out parameters of this method are valid if
- *and only if this method returns CR_OK.
+ *
+ *Tests wether the current instance of
+ *#CRInput has reached its input buffer.
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
+ * Note that all the out parameters of this method are valid if
+ * and only if this method returns CR_OK.
*/
enum CRStatus
-cr_input_end_of_input (CRInput * a_this, gboolean * a_end_of_input)
+cr_input_end_of_input (CRInput const * a_this, gboolean * a_end_of_input)
{
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_end_of_input, CR_BAD_PARAM_ERROR);
@@ -350,13 +366,14 @@ cr_input_end_of_input (CRInput * a_this, gboolean * a_end_of_input)
}
/**
+ * cr_input_get_nb_bytes_left:
+ *@a_this: the current instance of #CRInput.
+ *
*Returns the number of bytes left in the input stream
- *before the end.
- *@param a_this the current instance of #CRInput.
- *@return the number of characters left or -1 in case of error.
+ *before the end, -1 in case of error.
*/
glong
-cr_input_get_nb_bytes_left (CRInput * a_this)
+cr_input_get_nb_bytes_left (CRInput const * a_this)
{
g_return_val_if_fail (a_this && PRIVATE (a_this), -1);
g_return_val_if_fail (PRIVATE (a_this)->nb_bytes
@@ -371,14 +388,16 @@ cr_input_get_nb_bytes_left (CRInput * a_this)
}
/**
- *Returns the next byte of the input.
- *Update the state of the input so that
+ * cr_input_read_byte:
+ *@a_this: the current instance of #CRInput.
+ *@a_byte: out parameter the returned byte.
+ *
+ *Gets the next byte of the input.
+ *Updates the state of the input so that
*the next invocation of this method returns
*the next coming byte.
*
- *@param a_this the current instance of #CRInput.
- *@param a_byte out parameter the returned byte.
- *@return CR_OK upon successful completion, an error code
+ *Returns CR_OK upon successful completion, an error code
*otherwise. All the out parameters of this method are valid if
*and only if this method returns CR_OK.
*/
@@ -407,11 +426,14 @@ cr_input_read_byte (CRInput * a_this, guchar * a_byte)
}
/**
+ * cr_input_read_char:
+ *@a_this: the current instance of CRInput.
+ *@a_char: out parameter. The read character.
+ *
*Reads an unicode character from the current instance of
*#CRInput.
- *@param a_this the current instance of CRInput.
- *@param a_char out parameter. The read character.
- *@return CR_OK upon successful completion, an error code
+ *
+ *Returns CR_OK upon successful completion, an error code
*otherwise.
*/
enum CRStatus
@@ -462,11 +484,13 @@ cr_input_read_char (CRInput * a_this, guint32 * a_char)
}
/**
+ * cr_input_set_line_num:
+ *@a_this: the "this pointer" of the current instance of #CRInput.
+ *@a_line_num: the new line number.
+ *
*Setter of the current line number.
- *@param a_this the "this pointer" of the current instance of
- *#CRInput.
- *@param a_line_num the new line number.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Return CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_input_set_line_num (CRInput * a_this, glong a_line_num)
@@ -479,14 +503,16 @@ cr_input_set_line_num (CRInput * a_this, glong a_line_num)
}
/**
+ * cr_input_get_line_num:
+ *@a_this: the "this pointer" of the current instance of #CRInput.
+ *@a_line_num: the returned line number.
+ *
*Getter of the current line number.
- *@param a_this the "this pointer" of the current instance of
- *#CRInput.
- *@param a_line_num the returned line number.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
-cr_input_get_line_num (CRInput * a_this, glong * a_line_num)
+cr_input_get_line_num (CRInput const * a_this, glong * a_line_num)
{
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_line_num, CR_BAD_PARAM_ERROR);
@@ -497,11 +523,13 @@ cr_input_get_line_num (CRInput * a_this, glong * a_line_num)
}
/**
+ * cr_input_set_column_num:
+ *@a_this: the "this pointer" of the current instance of #CRInput.
+ *@a_col: the new column number.
+ *
*Setter of the current column number.
- *@param a_this the "this pointer" of the current instance of
- *#CRInput.
- *@param a_col the new column number.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_input_set_column_num (CRInput * a_this, glong a_col)
@@ -514,14 +542,16 @@ cr_input_set_column_num (CRInput * a_this, glong a_col)
}
/**
+ * cr_input_get_column_num:
+ *@a_this: the "this pointer" of the current instance of #CRInput.
+ *@a_col: out parameter
+ *
*Getter of the current column number.
- *@param a_this the "this pointer" of the current instance of
- *#CRInput.
- *@param a_col out parameter
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
-cr_input_get_column_num (CRInput * a_this, glong * a_col)
+cr_input_get_column_num (CRInput const * a_this, glong * a_col)
{
g_return_val_if_fail (a_this && PRIVATE (a_this) && a_col,
CR_BAD_PARAM_ERROR);
@@ -532,10 +562,13 @@ cr_input_get_column_num (CRInput * a_this, glong * a_col)
}
/**
+ * cr_input_increment_line_num:
+ *@a_this: the "this pointer" of the current instance of #CRInput.
+ *@a_increment: the increment to add to the line number.
+ *
*Increments the current line number.
- *@param a_this the "this pointer" of the current instance of
- *#CRInput.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_input_increment_line_num (CRInput * a_this, glong a_increment)
@@ -548,10 +581,13 @@ cr_input_increment_line_num (CRInput * a_this, glong a_increment)
}
/**
+ * cr_input_increment_col_num:
+ *@a_this: the "this pointer" of the current instance of #CRInput.
+ *@a_increment: the increment to add to the column number.
+ *
*Increments the current column number.
- *@param a_this the "this pointer" of the current instance of
- *#CRInput.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_input_increment_col_num (CRInput * a_this, glong a_increment)
@@ -564,13 +600,15 @@ cr_input_increment_col_num (CRInput * a_this, glong a_increment)
}
/**
+ * cr_input_consume_char:
+ *@a_this: the this pointer.
+ *@a_char: the character to consume. If set to zero,
+ *consumes any character.
+ *
*Consumes the next character of the input stream if
*and only if that character equals a_char.
*
- *@param a_this the this pointer.
- *@param a_char the character to consume. If set to zero,
- *consumes any character.
- *@return CR_OK upon successful completion, CR_PARSING_ERROR if
+ *Returns CR_OK upon successful completion, CR_PARSING_ERROR if
*next char is different from a_char, an other error code otherwise
*/
enum CRStatus
@@ -595,21 +633,23 @@ cr_input_consume_char (CRInput * a_this, guint32 a_char)
}
/**
+ * cr_input_consume_chars:
+ *@a_this: the this pointer of the current instance of #CRInput.
+ *@a_char: the character to consume.
+ *@a_nb_char: in/out parameter. The number of characters to consume.
+ *If set to a negative value, the function will consume all the occurences
+ *of a_char found.
+ *After return, if the return value equals CR_OK, this variable contains
+ *the number of characters actually consumed.
+ *
*Consumes up to a_nb_char occurences of the next contiguous characters
*which equal a_char. Note that the next character of the input stream
**MUST* equal a_char to trigger the consumption, or else, the error
*code CR_PARSING_ERROR is returned.
*If the number of contiguous characters that equals a_char is less than
*a_nb_char, then this function consumes all the characters it can consume.
- *
- *@param a_this the this pointer of the current instance of #CRInput.
- *@param a_char the character to consume.
- *@param a_nb_char in/out parameter. The number of characters to consume.
- *If set to a negative value, the function will consume all the occurences
- *of a_char found.
- *After return, if the return value equals CR_OK, this variable contains
- *the number of characters actually consumed.
- *@return CR_OK if at least one character has been consumed, an error code
+ *
+ *Returns CR_OK if at least one character has been consumed, an error code
*otherwise.
*/
enum CRStatus
@@ -643,13 +683,15 @@ cr_input_consume_chars (CRInput * a_this, guint32 a_char, gulong * a_nb_char)
}
/**
+ * cr_input_consume_white_spaces:
+ *@a_this: the "this pointer" of the current instance of #CRInput.
+ *@a_nb_chars: in/out parameter. The number of white spaces to
+ *consume. After return, holds the number of white spaces actually consumed.
+ *
*Same as cr_input_consume_chars() but this one consumes white
*spaces.
*
- *@param a_this the "this pointer" of the current instance of #CRInput.
- *@param a_nb_chars in/out parameter. The number of white spaces to
- *consume. After return, holds the number of white spaces actually consumed.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_input_consume_white_spaces (CRInput * a_this, gulong * a_nb_chars)
@@ -688,17 +730,20 @@ cr_input_consume_white_spaces (CRInput * a_this, gulong * a_nb_chars)
}
/**
+ * cr_input_peek_char:
+ *@a_this: the current instance of #CRInput.
+ *@a_char: out parameter. The returned character.
+ *
*Same as cr_input_read_char() but does not update the
*internal state of the input stream. The next call
*to cr_input_peek_char() or cr_input_read_char() will thus
*return the same character as the current one.
- *@param a_this the current instance of #CRInput.
- *@param a_char out parameter. The returned character.
- *@return CR_OK upon successful completion, an error code
+ *
+ *Returns CR_OK upon successful completion, an error code
*otherwise.
*/
enum CRStatus
-cr_input_peek_char (CRInput * a_this, guint32 * a_char)
+cr_input_peek_char (CRInput const * a_this, guint32 * a_char)
{
enum CRStatus status = CR_OK;
glong consumed = 0,
@@ -721,12 +766,20 @@ cr_input_peek_char (CRInput * a_this, guint32 * a_char)
status = cr_utils_read_char_from_utf8_buf
(PRIVATE (a_this)->in_buf +
PRIVATE (a_this)->next_byte_index,
- nb_bytes_left, a_char, (gulong *)&consumed);
+ nb_bytes_left, a_char, &consumed);
return status;
}
/**
+ * cr_input_peek_byte:
+ *@a_this: the current instance of #CRInput.
+ *@a_origin: the origin to consider in the calculation
+ *of the position of the byte to peek.
+ *@a_offset: the offset of the byte to peek, starting from
+ *the origin specified by a_origin.
+ *@a_byte: out parameter the peeked byte.
+ *
*Gets a byte from the input stream,
*starting from the current position in the input stream.
*Unlike cr_input_peek_next_byte() this method
@@ -734,21 +787,12 @@ cr_input_peek_char (CRInput * a_this, guint32 * a_char)
*Subsequent calls to cr_input_peek_byte with the same arguments
*will return the same byte.
*
- *@param a_this the current instance of #CRInput.
- *@param a_origin the origin to consider in the calculation
- *of the position of the byte to peek.
- *@param a_offset the offset of the byte to peek, starting from
- *the origin specified by a_origin.
- *@param a_byte out parameter the peeked byte.
- *@return CR_OK upon successful completion or,
- *
- *<ul>
- *<li>CR_BAD_PARAM_ERROR if at least one of the parameters is invalid</li>
- *<li>CR_OUT_OF_BOUNDS_ERROR if the indexed byte is out of bounds</li>
- *</ul>
+ *Returns CR_OK upon successful completion or,
+ *CR_BAD_PARAM_ERROR if at least one of the parameters is invalid;
+ *CR_OUT_OF_BOUNDS_ERROR if the indexed byte is out of bounds.
*/
enum CRStatus
-cr_input_peek_byte (CRInput * a_this, enum CRSeekPos a_origin,
+cr_input_peek_byte (CRInput const * a_this, enum CRSeekPos a_origin,
gulong a_offset, guchar * a_byte)
{
gulong abs_offset = 0;
@@ -786,18 +830,21 @@ cr_input_peek_byte (CRInput * a_this, enum CRSeekPos a_origin,
}
/**
- *Same as cr_input_peek_byte() but with a simplified
- *interface.
- *@param a_this the current byte input stream.
- *@param a_offset the offset of the byte to peek, starting
+ * cr_input_peek_byte2:
+ *@a_this: the current byte input stream.
+ *@a_offset: the offset of the byte to peek, starting
*from the current input position pointer.
- *@param a_eof out parameter. Is set to true is we reach end of
+ *@a_eof: out parameter. Is set to true is we reach end of
*stream. If set to NULL by the caller, this parameter is not taken
*in account.
- *@return the read byte or 0 if something bad happened.
+ *
+ *Same as cr_input_peek_byte() but with a simplified
+ *interface.
+ *
+ *Returns the read byte or 0 if something bad happened.
*/
guchar
-cr_input_peek_byte2 (CRInput * a_this, gulong a_offset, gboolean * a_eof)
+cr_input_peek_byte2 (CRInput const * a_this, gulong a_offset, gboolean * a_eof)
{
guchar result = 0;
enum CRStatus status = CR_ERROR;
@@ -817,12 +864,15 @@ cr_input_peek_byte2 (CRInput * a_this, gulong a_offset, gboolean * a_eof)
}
/**
- *Returns the memory address of the byte located at a given offset
- *in the input stream.
- *@param a_this the current instance of #CRInput.
- *@param a_offset the offset of the byte in the input stream starting
+ * cr_input_get_byte_addr:
+ *@a_this: the current instance of #CRInput.
+ *@a_offset: the offset of the byte in the input stream starting
*from the beginning of the stream.
- *@return the address, otherwise NULL if an error occured.
+ *
+ *Gets the memory address of the byte located at a given offset
+ *in the input stream.
+ *
+ *Returns the address, otherwise NULL if an error occured.
*/
guchar *
cr_input_get_byte_addr (CRInput * a_this, gulong a_offset)
@@ -837,10 +887,13 @@ cr_input_get_byte_addr (CRInput * a_this, gulong a_offset)
}
/**
- *Returns the address of the current character pointer.
- *@param a_this the current input stream
- *@param a_offset out parameter. The returned address.
- *@return CR_OK upon successful completion, an error code otherwise.
+ * cr_input_get_cur_byte_addr:
+ *@a_this: the current input stream
+ *@a_offset: out parameter. The returned address.
+ *
+ *Gets the address of the current character pointer.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_input_get_cur_byte_addr (CRInput * a_this, guchar ** a_offset)
@@ -859,23 +912,20 @@ cr_input_get_cur_byte_addr (CRInput * a_this, guchar ** a_offset)
}
/**
+ * cr_input_seek_index:
+ *@a_this: the current instance of #CRInput.
+ *@a_origin: the origin to consider during the calculation
+ *of the absolute position of the new "current byte index".
+ *@a_pos: the relative offset of the new "current byte index."
+ *This offset is relative to the origin a_origin.
+ *
*Sets the "current byte index" of the current instance
*of #CRInput. Next call to cr_input_get_byte() will return
*the byte next after the new "current byte index".
*
- *@param a_this the current instance of #CRInput.
- *
- *@param a_origin the origin to consider during the calculation
- *of the absolute position of the new "current byte index".
- *
- *@param a_pos the relative offset of the new "current byte index."
- *This offset is relative to the origin a_origin.
- *
- *@return CR_OK upon successful completion otherwise returns
- *<ul>
- *<li>CR_BAD_PARAM_ERROR if at least one of the parameters is not valid</li>
- *<li>CR_OUT_BOUNDS_ERROR</li>
- *</ul>
+ *Returns CR_OK upon successful completion otherwise returns
+ *CR_BAD_PARAM_ERROR if at least one of the parameters is not valid
+ *or CR_OUT_BOUNDS_ERROR in case of error.
*/
enum CRStatus
cr_input_seek_index (CRInput * a_this, enum CRSeekPos a_origin, gint a_pos)
@@ -916,26 +966,24 @@ cr_input_seek_index (CRInput * a_this, enum CRSeekPos a_origin, gint a_pos)
}
/**
+ * cr_input_get_cur_pos:
+ *@a_this: the current instance of #CRInput.
+ *@a_pos: out parameter. The returned position.
+ *
*Gets the position of the "current byte index" which
*is basically the position of the last returned byte in the
*input stream.
*
- *@param a_this the current instance of #CRInput.
- *
- *@param a_pos out parameter. The returned position.
- *
- *@return CR_OK upon successful completion. Otherwise,
- *<ul>
- *<li>CR_BAD_PARAMETER_ERROR if at least one of the arguments is invalid.</li>
- *<li>CR_START_OF_INPUT if no call to either cr_input_read_byte()
+ *Returns CR_OK upon successful completion. Otherwise,
+ *CR_BAD_PARAMETER_ERROR if at least one of the arguments is invalid.
+ *CR_START_OF_INPUT if no call to either cr_input_read_byte()
*or cr_input_seek_index() have been issued before calling
- *cr_input_get_cur_pos()</li>
- *</ul>
+ *cr_input_get_cur_pos()
*Note that the out parameters of this function are valid if and only if this
*function returns CR_OK.
*/
enum CRStatus
-cr_input_get_cur_pos (CRInput * a_this, CRInputPos * a_pos)
+cr_input_get_cur_pos (CRInput const * a_this, CRInputPos * a_pos)
{
g_return_val_if_fail (a_this && PRIVATE (a_this) && a_pos,
CR_BAD_PARAM_ERROR);
@@ -950,17 +998,20 @@ cr_input_get_cur_pos (CRInput * a_this, CRInputPos * a_pos)
}
/**
+ * cr_input_get_parsing_location:
+ *@a_this: the current instance of #CRInput
+ *@a_loc: the set parsing location.
+ *
*Gets the current parsing location.
*The Parsing location is a public datastructure that
*represents the current line/column/byte offset/ in the input
*stream.
- *@param a_this the current instance of #CRInput
- *@param a_loc the set parsing location.
- *@return CR_OK upon successful completion, an error
+ *
+ *Returns CR_OK upon successful completion, an error
*code otherwise.
*/
enum CRStatus
-cr_input_get_parsing_location (CRInput *a_this,
+cr_input_get_parsing_location (CRInput const *a_this,
CRParsingLocation *a_loc)
{
g_return_val_if_fail (a_this
@@ -979,17 +1030,20 @@ cr_input_get_parsing_location (CRInput *a_this,
}
/**
+ * cr_input_get_cur_index:
+ *@a_this: the "this pointer" of the current instance of
+ *#CRInput
+ *@a_index: out parameter. The returned index.
+ *
*Getter of the next byte index.
*It actually returns the index of the
*next byte to be read.
- *@param a_this the "this pointer" of the current instance of
- *#CRInput
- *@param a_index out parameter. The returned index.
- *@return CR_OK upon successful completion, an error code
+ *
+ *Returns CR_OK upon successful completion, an error code
*otherwise.
*/
enum CRStatus
-cr_input_get_cur_index (CRInput * a_this, glong * a_index)
+cr_input_get_cur_index (CRInput const * a_this, glong * a_index)
{
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_index, CR_BAD_PARAM_ERROR);
@@ -1000,12 +1054,15 @@ cr_input_get_cur_index (CRInput * a_this, glong * a_index)
}
/**
+ * cr_input_set_cur_index:
+ *@a_this: the "this pointer" of the current instance
+ *of #CRInput .
+ *@a_index: the new index to set.
+ *
*Setter of the next byte index.
*It sets the index of the next byte to be read.
- *@param a_this the "this pointer" of the current instance
- *of #CRInput .
- *@param a_index the new index to set.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_input_set_cur_index (CRInput * a_this, glong a_index)
@@ -1018,10 +1075,13 @@ cr_input_set_cur_index (CRInput * a_this, glong a_index)
}
/**
+ * cr_input_set_end_of_file:
+ *@a_this: the current instance of #CRInput.
+ *@a_eof: the new end of file flag.
+ *
*Sets the end of file flag.
- *@param a_this the current instance of #CRInput.
- *@param a_eof the new end of file flag.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_input_set_end_of_file (CRInput * a_this, gboolean a_eof)
@@ -1034,14 +1094,17 @@ cr_input_set_end_of_file (CRInput * a_this, gboolean a_eof)
}
/**
- *Gets the end of file flag.
- *@param a_this the current instance of #CRInput.
- *@param a_eof out parameter the place to put the end of
+ * cr_input_get_end_of_file:
+ *@a_this: the current instance of #CRInput.
+ *@a_eof: out parameter the place to put the end of
*file flag.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Gets the end of file flag.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
-cr_input_get_end_of_file (CRInput * a_this, gboolean * a_eof)
+cr_input_get_end_of_file (CRInput const * a_this, gboolean * a_eof)
{
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_eof, CR_BAD_PARAM_ERROR);
@@ -1052,10 +1115,13 @@ cr_input_get_end_of_file (CRInput * a_this, gboolean * a_eof)
}
/**
+ * cr_input_set_end_of_line:
+ *@a_this: the current instance of #CRInput.
+ *@a_eol: the new end of line flag.
+ *
*Sets the end of line flag.
- *@param a_this the current instance of #CRInput.
- *@param a_eol the new end of line flag.
- *@return CR_OK upon successful completion, an error code
+ *
+ *Returns CR_OK upon successful completion, an error code
*otherwise.
*/
enum CRStatus
@@ -1069,15 +1135,18 @@ cr_input_set_end_of_line (CRInput * a_this, gboolean a_eol)
}
/**
- *Gets the end of line flag of the current input.
- *@param a_this the current instance of #CRInput
- *@param a_eol out parameter. The place to put
+ * cr_input_get_end_of_line:
+ *@a_this: the current instance of #CRInput
+ *@a_eol: out parameter. The place to put
*the returned flag
- *@return CR_OK upon successful completion, an error code
+ *
+ *Gets the end of line flag of the current input.
+ *
+ *Returns CR_OK upon successful completion, an error code
*otherwise.
*/
enum CRStatus
-cr_input_get_end_of_line (CRInput * a_this, gboolean * a_eol)
+cr_input_get_end_of_line (CRInput const * a_this, gboolean * a_eol)
{
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_eol, CR_BAD_PARAM_ERROR);
@@ -1088,14 +1157,17 @@ cr_input_get_end_of_line (CRInput * a_this, gboolean * a_eol)
}
/**
+ * cr_input_set_cur_pos:
+ *@a_this: the "this pointer" of the current instance of
+ *#CRInput.
+ *@a_pos: the new position.
+ *
*Sets the current position in the input stream.
*
- *@param a_this the "this pointer" of the current instance of
- *#CRInput.
- *@param a_pos the new position.
+ * Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
-cr_input_set_cur_pos (CRInput * a_this, CRInputPos * a_pos)
+cr_input_set_cur_pos (CRInput * a_this, CRInputPos const * a_pos)
{
g_return_val_if_fail (a_this && PRIVATE (a_this) && a_pos,
CR_BAD_PARAM_ERROR);
diff --git a/src/cr-input.h b/src/cr-input.h
index 976b73f..9eb402a 100644
--- a/src/cr-input.h
+++ b/src/cr-input.h
@@ -93,15 +93,15 @@ enum CRStatus
cr_input_consume_white_spaces (CRInput *a_this, gulong *a_nb_chars) ;
enum CRStatus
-cr_input_peek_byte (CRInput *a_this, enum CRSeekPos a_origin,
+cr_input_peek_byte (CRInput const *a_this, enum CRSeekPos a_origin,
gulong a_offset, guchar *a_byte) ;
guchar
-cr_input_peek_byte2 (CRInput *a_this, gulong a_offset,
+cr_input_peek_byte2 (CRInput const *a_this, gulong a_offset,
gboolean *a_eof) ;
enum CRStatus
-cr_input_peek_char (CRInput *a_this, guint32 *a_char) ;
+cr_input_peek_char (CRInput const *a_this, guint32 *a_char) ;
guchar *
cr_input_get_byte_addr (CRInput *a_this,
@@ -115,29 +115,29 @@ cr_input_seek_index (CRInput *a_this,
enum CRSeekPos a_origin, gint a_pos) ;
enum CRStatus
-cr_input_get_cur_index (CRInput *a_this, glong *a_index) ;
+cr_input_get_cur_index (CRInput const *a_this, glong *a_index) ;
enum CRStatus
cr_input_set_cur_index (CRInput *a_this, glong a_index) ;
enum CRStatus
-cr_input_get_cur_pos (CRInput *a_this, CRInputPos * a_pos) ;
+cr_input_get_cur_pos (CRInput const *a_this, CRInputPos * a_pos) ;
enum CRStatus
-cr_input_set_cur_pos (CRInput *a_this, CRInputPos *a_pos) ;
+cr_input_set_cur_pos (CRInput *a_this, CRInputPos const *a_pos) ;
enum CRStatus
-cr_input_get_parsing_location (CRInput *a_this,
+cr_input_get_parsing_location (CRInput const *a_this,
CRParsingLocation *a_loc) ;
enum CRStatus
-cr_input_get_end_of_line (CRInput *a_this, gboolean *a_eol) ;
+cr_input_get_end_of_line (CRInput const *a_this, gboolean *a_eol) ;
enum CRStatus
cr_input_set_end_of_line (CRInput *a_this, gboolean a_eol) ;
enum CRStatus
-cr_input_get_end_of_file (CRInput *a_this, gboolean *a_eof) ;
+cr_input_get_end_of_file (CRInput const *a_this, gboolean *a_eof) ;
enum CRStatus
cr_input_set_end_of_file (CRInput *a_this, gboolean a_eof) ;
@@ -146,13 +146,13 @@ enum CRStatus
cr_input_set_line_num (CRInput *a_this, glong a_line_num) ;
enum CRStatus
-cr_input_get_line_num (CRInput *a_this, glong *a_line_num) ;
+cr_input_get_line_num (CRInput const *a_this, glong *a_line_num) ;
enum CRStatus
cr_input_set_column_num (CRInput *a_this, glong a_col) ;
enum CRStatus
-cr_input_get_column_num (CRInput *a_this, glong *a_col) ;
+cr_input_get_column_num (CRInput const *a_this, glong *a_col) ;
enum CRStatus
cr_input_increment_line_num (CRInput *a_this,
@@ -163,10 +163,10 @@ cr_input_increment_col_num (CRInput *a_this,
glong a_increment) ;
glong
-cr_input_get_nb_bytes_left (CRInput *a_this) ;
+cr_input_get_nb_bytes_left (CRInput const *a_this) ;
enum CRStatus
-cr_input_end_of_input (CRInput *a_this, gboolean *a_end_of_input) ;
+cr_input_end_of_input (CRInput const *a_this, gboolean *a_end_of_input) ;
G_END_DECLS
diff --git a/src/cr-num.c b/src/cr-num.c
index fb412a9..28c5df0 100644
--- a/src/cr-num.c
+++ b/src/cr-num.c
@@ -23,7 +23,8 @@
*/
/**
- *@file
+ *@CRNum:
+ *
*The definition
*of the #CRNum class.
*/
@@ -32,15 +33,19 @@
#include "string.h"
/**
- *The default constructor of
+ * cr_num_new:
+ *
*#CRNum.
- *@return the newly built instance of
+ *
+ *Returns the newly built instance of
*#CRNum.
*/
CRNum *
cr_num_new (void)
{
- CRNum *result = (CRNum *)g_try_malloc (sizeof (CRNum));
+ CRNum *result = NULL;
+
+ result = g_try_malloc (sizeof (CRNum));
if (result == NULL) {
cr_utils_trace_info ("Out of memory");
@@ -53,16 +58,14 @@ cr_num_new (void)
}
/**
- *A constructor of #CRNum.
- *@param a_is_natural indicates whether the intance of #CRNum is
- *a natural number or not.
- *@param a_integer_part the integer part of the instance
- *of #CRNum
- *@param a_decimal_part in case the instance of #CRNum
- *natural number (but a decimal one) this parameter
- *is the decimal part of the instance of #CRNum.
- *@return the newly built instance of #CRNum or
- *NULL if an error arises.
+ * cr_num_new_with_val:
+ * @a_val: the numerical value of the number.
+ * @a_type: the type of number.
+ *
+ * A constructor of #CRNum.
+ *
+ * Returns the newly built instance of #CRNum or
+ * NULL if an error arises.
*/
CRNum *
cr_num_new_with_val (gdouble a_val, enum CRNumType a_type)
@@ -80,16 +83,16 @@ cr_num_new_with_val (gdouble a_val, enum CRNumType a_type)
}
/**
- *Returns the string representation of the
- *current instance of #CRNum.
- *@param a_this the current instance of #CRNum.
- *@return the newly built string representation
+ * cr_num_to_string:
+ *@a_this: the current instance of #CRNum.
+ *
+ *Returns the newly built string representation
*of the current instance of #CRNum. The returned
*string is NULL terminated. The caller *must*
*free the returned string.
*/
guchar *
-cr_num_to_string (CRNum * a_this)
+cr_num_to_string (CRNum const * a_this)
{
gdouble test_val = 0.0;
@@ -102,13 +105,11 @@ cr_num_to_string (CRNum * a_this)
test_val = a_this->val - (glong) a_this->val;
if (!test_val) {
- tmp_char1 = (guchar *)g_strdup_printf ("%ld", (glong) a_this->val);
+ tmp_char1 = g_strdup_printf ("%ld", (glong) a_this->val);
} else {
- /* We can't use g_ascii_dtostr, because that sometimes uses
- e notation (which wouldn't be a valid number in CSS). */
- size_t const buflen = 35; /* fairly arbitrary. */
- tmp_char1 = (guchar *)g_malloc (buflen);
- g_ascii_formatd ((gchar *)tmp_char1, buflen, "%.15g", a_this->val);
+ tmp_char1 = g_new0 (char, G_ASCII_DTOSTR_BUF_SIZE + 1);
+ if (tmp_char1 != NULL)
+ g_ascii_dtostr (tmp_char1, G_ASCII_DTOSTR_BUF_SIZE, a_this->val);
}
g_return_val_if_fail (tmp_char1, NULL);
@@ -192,8 +193,7 @@ cr_num_to_string (CRNum * a_this)
}
if (tmp_char2) {
- result = (guchar *)g_strconcat (
- (gchar *)tmp_char1, (gchar *)tmp_char2, NULL);
+ result = g_strconcat (tmp_char1, tmp_char2, NULL);
g_free (tmp_char1);
} else {
result = tmp_char1;
@@ -203,16 +203,19 @@ cr_num_to_string (CRNum * a_this)
}
/**
- *Copies an instance of #CRNum.
- *@param a_src the instance of #CRNum to copy.
+ * cr_num_copy:
+ *@a_src: the instance of #CRNum to copy.
*Must be non NULL.
- *@param a_dst the destination of the copy.
+ *@a_dest: the destination of the copy.
*Must be non NULL
- *@return CR_OK upon successful completion, an
+ *
+ *Copies an instance of #CRNum.
+ *
+ *Returns CR_OK upon successful completion, an
*error code otherwise.
*/
enum CRStatus
-cr_num_copy (CRNum * a_dest, CRNum * a_src)
+cr_num_copy (CRNum * a_dest, CRNum const * a_src)
{
g_return_val_if_fail (a_dest && a_src, CR_BAD_PARAM_ERROR);
@@ -222,13 +225,16 @@ cr_num_copy (CRNum * a_dest, CRNum * a_src)
}
/**
+ * cr_num_dup:
+ *@a_this: the instance of #CRNum to duplicate.
+ *
*Duplicates an instance of #CRNum
- *@param a_this the instance of #CRNum to duplicate.
- *@return the newly created (duplicated) instance of #CRNum.
+ *
+ *Returns the newly created (duplicated) instance of #CRNum.
*Must be freed by cr_num_destroy().
*/
CRNum *
-cr_num_dup (CRNum * a_this)
+cr_num_dup (CRNum const * a_this)
{
CRNum *result = NULL;
enum CRStatus status = CR_OK;
@@ -245,11 +251,14 @@ cr_num_dup (CRNum * a_this)
}
/**
+ * cr_num_set:
*Sets an instance of #CRNum.
- *@param a_this the current instance of #CRNum to be set.
- *@param a_val the new numerical value to be hold by the current
+ *@a_this: the current instance of #CRNum to be set.
+ *@a_val: the new numerical value to be hold by the current
*instance of #CRNum
- *@param a_type the new type of #CRNum.
+ *@a_type: the new type of #CRNum.
+ *
+ * Returns CR_OK upon succesful completion, an error code otherwise.
*/
enum CRStatus
cr_num_set (CRNum * a_this, gdouble a_val, enum CRNumType a_type)
@@ -263,15 +272,19 @@ cr_num_set (CRNum * a_this, gdouble a_val, enum CRNumType a_type)
}
/**
+ * cr_num_is_fixed_length:
+ * @a_this: the current instance of #CRNum .
+ *
*Tests if the current instance of #CRNum is a fixed
*length value or not. Typically a fixed length value
*is anything from NUM_LENGTH_EM to NUM_LENGTH_PC.
*See the definition of #CRNumType to see what we mean.
- *@return TRUE if the instance of #CRNum is a fixed length number,
+ *
+ *Returns TRUE if the instance of #CRNum is a fixed length number,
*FALSE otherwise.
*/
gboolean
-cr_num_is_fixed_length (CRNum * a_this)
+cr_num_is_fixed_length (CRNum const * a_this)
{
gboolean result = FALSE;
@@ -285,9 +298,11 @@ cr_num_is_fixed_length (CRNum * a_this)
}
/**
- *The destructor of #CRNum.
- *@param a_this the this pointer of
+ * cr_num_destroy:
+ *@a_this: the this pointer of
*the current instance of #CRNum.
+ *
+ *The destructor of #CRNum.
*/
void
cr_num_destroy (CRNum * a_this)
diff --git a/src/cr-num.h b/src/cr-num.h
index 83e9dc7..2b73aaf 100644
--- a/src/cr-num.h
+++ b/src/cr-num.h
@@ -102,20 +102,20 @@ cr_num_new_with_val (gdouble a_val,
enum CRNumType a_type) ;
CRNum *
-cr_num_dup (CRNum *a_this) ;
+cr_num_dup (CRNum const *a_this) ;
guchar *
-cr_num_to_string (CRNum *a_this) ;
+cr_num_to_string (CRNum const *a_this) ;
enum CRStatus
-cr_num_copy (CRNum *a_dest, CRNum *a_src) ;
+cr_num_copy (CRNum *a_dest, CRNum const *a_src) ;
enum CRStatus
cr_num_set (CRNum *a_this, gdouble a_val,
enum CRNumType a_type) ;
gboolean
-cr_num_is_fixed_length (CRNum *a_this) ;
+cr_num_is_fixed_length (CRNum const *a_this) ;
void
cr_num_destroy (CRNum *a_this) ;
diff --git a/src/cr-om-parser.c b/src/cr-om-parser.c
index b8d70e3..a62e98d 100644
--- a/src/cr-om-parser.c
+++ b/src/cr-om-parser.c
@@ -25,10 +25,9 @@
#include "cr-utils.h"
#include "cr-om-parser.h"
-#define UNUSED(_param) ((void)(_param))
-
/**
- *@file
+ *@CROMParser:
+ *
*The definition of the CSS Object Model Parser.
*This parser uses (and sits) the SAC api of libcroco defined
*in cr-parser.h and cr-doc-handler.h
@@ -112,8 +111,9 @@ struct _ParsingContext {
static ParsingContext *
new_parsing_context (void)
{
- ParsingContext *result =
- (ParsingContext *)g_try_malloc (sizeof (ParsingContext));
+ ParsingContext *result = NULL;
+
+ result = g_try_malloc (sizeof (ParsingContext));
if (!result) {
cr_utils_trace_info ("Out of Memory");
return NULL;
@@ -216,7 +216,7 @@ start_font_face (CRDocHandler * a_this,
ParsingContext *ctxt = NULL;
ParsingContext **ctxtptr = NULL;
- UNUSED(a_location);
+ g_return_if_fail (a_this);
g_return_if_fail (a_this);
ctxtptr = &ctxt;
@@ -315,8 +315,6 @@ charset (CRDocHandler * a_this, CRString * a_charset,
ParsingContext *ctxt = NULL;
ParsingContext **ctxtptr = NULL;
- UNUSED(a_location);
-
g_return_if_fail (a_this);
ctxtptr = &ctxt;
status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr);
@@ -351,8 +349,6 @@ start_page (CRDocHandler * a_this,
ParsingContext *ctxt = NULL;
ParsingContext **ctxtptr = NULL;
- UNUSED(a_location);
-
g_return_if_fail (a_this);
ctxtptr = &ctxt;
status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr);
@@ -430,8 +426,6 @@ start_media (CRDocHandler * a_this,
ParsingContext **ctxtptr = NULL;
GList *media_list = NULL;
- UNUSED(a_location);
-
g_return_if_fail (a_this);
ctxtptr = &ctxt;
status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr);
@@ -499,8 +493,6 @@ import_style (CRDocHandler * a_this,
ParsingContext **ctxtptr = NULL;
GList *media_list = NULL ;
- UNUSED(a_location);
-
g_return_if_fail (a_this);
ctxtptr = &ctxt;
status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr);
@@ -770,16 +762,19 @@ unrecoverable_error (CRDocHandler * a_this)
********************************************/
/**
+ * cr_om_parser_new:
+ *@a_input: the input stream.
+ *
*Constructor of the CROMParser.
- *@param a_input the input stream.
- *@return the newly built instance of #CROMParser.
+ *Returns the newly built instance of #CROMParser.
*/
CROMParser *
cr_om_parser_new (CRInput * a_input)
{
+ CROMParser *result = NULL;
enum CRStatus status = CR_OK;
- CROMParser *result = (CROMParser *)g_try_malloc (sizeof (CROMParser));
+ result = g_try_malloc (sizeof (CROMParser));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -787,7 +782,7 @@ cr_om_parser_new (CRInput * a_input)
}
memset (result, 0, sizeof (CROMParser));
- PRIVATE (result) = (CROMParserPriv *)g_try_malloc (sizeof (CROMParserPriv));
+ PRIVATE (result) = g_try_malloc (sizeof (CROMParserPriv));
if (!PRIVATE (result)) {
cr_utils_trace_info ("Out of memory");
@@ -821,13 +816,16 @@ cr_om_parser_new (CRInput * a_input)
}
/**
+ * cr_om_parser_parse_buf:
+ *@a_this: the current instance of #CROMParser.
+ *@a_buf: the in memory buffer to parse.
+ *@a_len: the length of the in memory buffer in number of bytes.
+ *@a_enc: the encoding of the in memory buffer.
+ *@a_result: out parameter the resulting style sheet
+ *
*Parses the content of an in memory buffer.
- *@param a_this the current instance of #CROMParser.
- *@param a_buf the in memory buffer to parse.
- *@param a_len the length of the in memory buffer in number of bytes.
- *@param a_enc the encoding of the in memory buffer.
- *@param a_result out parameter the resulting style sheet
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_om_parser_parse_buf (CROMParser * a_this,
@@ -868,12 +866,15 @@ cr_om_parser_parse_buf (CROMParser * a_this,
}
/**
+ * cr_om_parser_simply_parse_buf:
+ *@a_buf: the css2 in memory buffer.
+ *@a_len: the length of the in memory buffer.
+ *@a_enc: the encoding of the in memory buffer.
+ *@a_result: out parameter. The resulting css2 style sheet.
+ *
*The simpler way to parse an in memory css2 buffer.
- *@param a_buf the css2 in memory buffer.
- *@param a_len the length of the in memory buffer.
- *@param a_enc the encoding of the in memory buffer.
- *@param a_result out parameter. The resulting css2 style sheet.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_om_parser_simply_parse_buf (const guchar * a_buf,
@@ -903,16 +904,18 @@ cr_om_parser_simply_parse_buf (const guchar * a_buf,
}
/**
- *Parses a css2 stylesheet contained
- *in a file.
- *@param a_this the current instance of the cssom parser.
- *@param a_file_uri the uri of the file.
+ * cr_om_parser_parse_file:
+ *@a_this: the current instance of the cssom parser.
+ *@a_file_uri: the uri of the file.
*(only local file paths are suppported so far)
- *@param a_enc the encoding of the file.
- *@param a_result out parameter. A pointer
+ *@a_enc: the encoding of the file.
+ *@a_result: out parameter. A pointer
*the build css object model.
- *@param CR_OK upon successfull completion, an error code
- *otherwise.
+ *
+ *Parses a css2 stylesheet contained
+ *in a file.
+ *
+ * Returns CR_OK upon succesful completion, an error code otherwise.
*/
enum CRStatus
cr_om_parser_parse_file (CROMParser * a_this,
@@ -952,12 +955,15 @@ cr_om_parser_parse_file (CROMParser * a_this,
}
/**
- *The simpler method to parse a css2 file.
- *@param a_file_path the css2 local file path.
- *@param a_enc the file encoding.
- *@param a_result out parameter. The returned css stylesheet.
+ * cr_om_parser_simply_parse_file:
+ *@a_file_path: the css2 local file path.
+ *@a_enc: the file encoding.
+ *@a_result: out parameter. The returned css stylesheet.
*Must be freed by the caller using cr_stylesheet_destroy.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *The simpler method to parse a css2 file.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*Note that this method uses cr_om_parser_parse_file() so both methods
*have the same return values.
*/
@@ -987,14 +993,18 @@ cr_om_parser_simply_parse_file (const guchar * a_file_path,
}
/**
- *Parses three sheets located by their paths and build a cascade
- *@param a_this the current instance of #CROMParser
- *@param a_author_path the path to the author stylesheet
- *@param a_user_path the path to the user stylesheet
- *@param a_ua_path the path to the User Agent stylesheet
- *@param a_result out parameter. The resulting cascade if the parsing
+ * cr_om_parser_parse_paths_to_cascade:
+ *@a_this: the current instance of #CROMParser
+ *@a_author_path: the path to the author stylesheet
+ *@a_user_path: the path to the user stylesheet
+ *@a_ua_path: the path to the User Agent stylesheet
+ *@a_encoding: the encoding of the sheets.
+ *@a_result: out parameter. The resulting cascade if the parsing
*was okay
- *@return CR_OK upon successful completion, an error code otherwise
+ *
+ *Parses three sheets located by their paths and build a cascade
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise
*/
enum CRStatus
cr_om_parser_parse_paths_to_cascade (CROMParser * a_this,
@@ -1014,7 +1024,7 @@ cr_om_parser_parse_paths_to_cascade (CROMParser * a_this,
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
- memset (sheets, 0, sizeof (sheets));
+ memset (sheets, 0, sizeof (CRStyleSheet*) * 3);
paths[0] = (guchar *) a_author_path;
paths[1] = (guchar *) a_user_path;
paths[2] = (guchar *) a_ua_path;
@@ -1043,13 +1053,17 @@ cr_om_parser_parse_paths_to_cascade (CROMParser * a_this,
}
/**
- *Parses three sheets located by their paths and build a cascade
- *@param a_author_path the path to the author stylesheet
- *@param a_user_path the path to the user stylesheet
- *@param a_ua_path the path to the User Agent stylesheet
- *@param a_result out parameter. The resulting cascade if the parsing
+ * cr_om_parser_simply_parse_paths_to_cascade:
+ *@a_author_path: the path to the author stylesheet
+ *@a_user_path: the path to the user stylesheet
+ *@a_ua_path: the path to the User Agent stylesheet
+ *@a_encoding: the encoding of the sheets.
+ *@a_result: out parameter. The resulting cascade if the parsing
*was okay
- *@return CR_OK upon successful completion, an error code otherwise
+ *
+ *Parses three sheets located by their paths and build a cascade
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise
*/
enum CRStatus
cr_om_parser_simply_parse_paths_to_cascade (const guchar * a_author_path,
@@ -1080,8 +1094,10 @@ cr_om_parser_simply_parse_paths_to_cascade (const guchar * a_author_path,
}
/**
+ * cr_om_parser_destroy:
+ *@a_this: the current instance of #CROMParser.
+ *
*Destructor of the #CROMParser.
- *@param a_this the current instance of #CROMParser.
*/
void
cr_om_parser_destroy (CROMParser * a_this)
diff --git a/src/cr-om-parser.h b/src/cr-om-parser.h
index 4fc6301..13d35b1 100644
--- a/src/cr-om-parser.h
+++ b/src/cr-om-parser.h
@@ -22,7 +22,7 @@
*/
/*
- *$Id: cr-om-parser.h,v 1.9 2004/01/29 22:05:14 dodji Exp $
+ *$Id$
*/
#ifndef __CR_OM_PARSER_H__
diff --git a/src/cr-parser.c b/src/cr-parser.c
index 5b0a56f..0fa1ffa 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -24,7 +24,8 @@
*/
/**
- *@file
+ *@CRParser:
+ *
*The definition of the #CRParser class.
*/
@@ -41,7 +42,7 @@
*=====================================
*
*One must keep in mind
- *that css UA must comply with two syntax.
+ *that css UA must comply with two syntaxes.
*
*1/the specific syntax that defines the css language
*for a given level of specificatin (e.g css2 syntax
@@ -136,8 +137,9 @@ struct _CRParserPriv {
#define CHARS_TAB_SIZE 12
/**
+ * IS_NUM:
+ *@a_char: the char to test.
*return TRUE if the character is a number ([0-9]), FALSE otherwise
- *@param a_char the char to test.
*/
#define IS_NUM(a_char) (((a_char) >= '0' && (a_char) <= '9')?TRUE:FALSE)
@@ -161,16 +163,18 @@ if ((status) != CR_OK) \
}
/**
- *same as CHECK_PARSING_STATUS() but this one pushes an error
- *on the parser error stack when an error arises.
- *@param a_this the current instance of #CRParser .
- *@param a_status the status to check. Is of type enum #CRStatus.
- *@param a_is_exception in case of error, if is TRUE, the status
+ * CHECK_PARSING_STATUS_ERR:
+ *@a_this: the current instance of #CRParser .
+ *@a_status: the status to check. Is of type enum #CRStatus.
+ *@a_is_exception: in case of error, if is TRUE, the status
*is set to CR_PARSING_ERROR before goto error. If is false, the
*real low level status is kept and will be returned by the
*upper level function that called this macro. Usally,this must
*be set to FALSE.
*
+ *same as CHECK_PARSING_STATUS() but this one pushes an error
+ *on the parser error stack when an error arises.
+ *
*/
#define CHECK_PARSING_STATUS_ERR(a_this, a_status, a_is_exception,\
a_err_msg, a_err_status) \
@@ -409,7 +413,9 @@ static enum CRStatus
static CRParserError *
cr_parser_error_new (const guchar * a_msg, enum CRStatus a_status)
{
- CRParserError *result = (CRParserError *)g_try_malloc (sizeof (CRParserError));
+ CRParserError *result = NULL;
+
+ result = g_try_malloc (sizeof (CRParserError));
if (result == NULL) {
cr_utils_trace_info ("Out of memory");
@@ -438,7 +444,7 @@ cr_parser_error_set_msg (CRParserError * a_this, const guchar * a_msg)
g_free (a_this->msg);
}
- a_this->msg = (guchar *)g_strdup ((gchar *)a_msg);
+ a_this->msg = g_strdup (a_msg);
}
/**
@@ -505,7 +511,7 @@ cr_parser_error_destroy (CRParserError * a_this)
*@param a_this the current instance of #CRParser.
*@param a_msg the error message.
*@param a_status the error status.
- *@return CR_OK upon successful completion, an error code otherwise.
+ *@return CR_OK upon successfull completion, an error code otherwise.
*/
static enum CRStatus
cr_parser_push_error (CRParser * a_this,
@@ -547,7 +553,7 @@ cr_parser_push_error (CRParser * a_this,
}
/**
- *Dumps the error stack using g_printerr.
+ *Dumps the error stack on stdout.
*@param a_this the current instance of #CRParser.
*@param a_clear_errs whether to clear the error stack
*after the dump or not.
@@ -603,11 +609,13 @@ cr_parser_clear_errors (CRParser * a_this)
}
/**
+ * cr_parser_try_to_skip_spaces_and_comments:
+ *@a_this: the current instance of #CRParser.
+ *
*Same as cr_parser_try_to_skip_spaces() but this one skips
*spaces and comments.
*
- *@param a_this the current instance of #CRParser.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_try_to_skip_spaces_and_comments (CRParser * a_this)
@@ -725,7 +733,7 @@ cr_parser_parse_stylesheet_core (CRParser * a_this)
error:
cr_parser_push_error
- (a_this, (guchar *)"could not recognize next production", CR_ERROR);
+ (a_this, "could not recognize next production", CR_ERROR);
cr_parser_dump_err_stack (a_this, TRUE);
@@ -1321,7 +1329,7 @@ cr_parser_parse_attribute_selector (CRParser * a_this,
CRInputPos init_pos;
CRToken *token = NULL;
CRAttrSel *result = NULL;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this && a_sel, CR_BAD_PARAM_ERROR);
@@ -1483,6 +1491,9 @@ cr_parser_parse_property (CRParser * a_this,
}
/**
+ * cr_parser_parse_term:
+ *@a_term: out parameter. The successfully parsed term.
+ *
*Parses a "term" as defined in the css2 spec, appendix D.1:
*term ::= unary_operator? [NUMBER S* | PERCENTAGE S* | LENGTH S* |
*EMS S* | EXS S* | ANGLE S* | TIME S* | FREQ S* | function ] |
@@ -1490,8 +1501,7 @@ cr_parser_parse_property (CRParser * a_this,
*
*TODO: handle parsing of 'RGB'
*
- *@param a_term out parameter. The successfully parsed term.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_term (CRParser * a_this, CRTerm ** a_term)
@@ -1502,7 +1512,7 @@ cr_parser_parse_term (CRParser * a_this, CRTerm ** a_term)
CRTerm *param = NULL;
CRToken *token = NULL;
CRString *func_name = NULL;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this && a_term, CR_BAD_PARAM_ERROR);
@@ -1636,15 +1646,17 @@ cr_parser_parse_term (CRParser * a_this, CRTerm ** a_term)
}
/**
+ * cr_parser_parse_simple_selector:
+ *@a_this: the "this pointer" of the current instance of #CRParser.
+ *@a_sel: out parameter. Is set to the successfully parsed simple
+ *selector.
+ *
*Parses a "simple_selector" as defined by the css2 spec in appendix D.1 :
*element_name? [ HASH | class | attrib | pseudo ]* S*
*and where pseudo is:
*pseudo ::= ':' [ IDENT | FUNCTION S* IDENT S* ')' ]
*
- *@Param a_this the "this pointer" of the current instance of #CRParser.
- *@param a_sel out parameter. Is set to the successfully parsed simple
- *selector.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
static enum CRStatus
cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
@@ -1674,16 +1686,12 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
if (token && token->type == DELIM_TK
&& token->u.unichar == '*') {
- int comb = (int)sel->type_mask | (int) UNIVERSAL_SELECTOR;
- sel->type_mask = (enum SimpleSelectorType)comb;
- //sel->type_mask |= UNIVERSAL_SELECTOR;
+ sel->type_mask |= UNIVERSAL_SELECTOR;
sel->name = cr_string_new_from_string ("*");
found_sel = TRUE;
} else if (token && token->type == IDENT_TK) {
sel->name = token->u.str;
- int comb = (int)sel->type_mask | (int) TYPE_SELECTOR;
- sel->type_mask = (enum SimpleSelectorType)comb;
- //sel->type_mask |= TYPE_SELECTOR;
+ sel->type_mask |= TYPE_SELECTOR;
token->u.str = NULL;
found_sel = TRUE;
} else {
@@ -1904,16 +1912,18 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
}
/**
- *Parses a "selector" as defined by the css2 spec in appendix D.1:
- *selector ::= simple_selector [ combinator simple_selector ]*
- *
- *@param a_this the this pointer of the current instance of #CRParser.
- *@param a_start a pointer to the
+ * cr_parser_parse_simple_sels:
+ *@a_this: the this pointer of the current instance of #CRParser.
+ *@a_start: a pointer to the
*first chararcter of the successfully parsed
*string.
- *@param a_end a pointer to the last character of the successfully parsed
+ *@a_end: a pointer to the last character of the successfully parsed
*string.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Parses a "selector" as defined by the css2 spec in appendix D.1:
+ *selector ::= simple_selector [ combinator simple_selector ]*
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
static enum CRStatus
cr_parser_parse_simple_sels (CRParser * a_this,
@@ -1938,7 +1948,7 @@ cr_parser_parse_simple_sels (CRParser * a_this,
for (;;) {
guint32 next_char = 0;
- int comb = 0;
+ enum Combinator comb = 0;
sel = NULL;
@@ -1961,7 +1971,7 @@ cr_parser_parse_simple_sels (CRParser * a_this,
break;
if (comb && sel) {
- sel->combinator = (enum Combinator)comb;
+ sel->combinator = comb;
comb = 0;
}
if (sel) {
@@ -1980,11 +1990,14 @@ cr_parser_parse_simple_sels (CRParser * a_this,
}
/**
- *Parses a comma separated list of selectors.
- *@param a_this the current instance of #CRParser.
- *@param a_selector the parsed list of comma separated
+ * cr_parser_parse_selector:
+ *@a_this: the current instance of #CRParser.
+ *@a_selector: the parsed list of comma separated
*selectors.
- *@return CR_OK upon successful completion, an error
+ *
+ *Parses a comma separated list of selectors.
+ *
+ *Returns CR_OK upon successful completion, an error
*code otherwise.
*/
static enum CRStatus
@@ -2098,16 +2111,17 @@ cr_parser_parse_selector (CRParser * a_this,
}
/**
+ * cr_parser_parse_function:
+ *@a_this: the "this pointer" of the current instance of #CRParser.
+ *
+ *@a_func_name: out parameter. The parsed function name
+ *@a_expr: out parameter. The successfully parsed term.
+ *
*Parses a "function" as defined in css spec at appendix D.1:
*function ::= FUNCTION S* expr ')' S*
*FUNCTION ::= ident'('
*
- *@param a_this the "this pointer" of the current instance of
- *#CRParser.
- *
- *@param a_func_name out parameter. The parsed function name
- *@param a_expr out parameter. The successfully parsed term.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
static enum CRStatus
cr_parser_parse_function (CRParser * a_this,
@@ -2185,13 +2199,15 @@ cr_parser_parse_function (CRParser * a_this,
}
/**
+ * cr_parser_parse_uri:
+ *@a_this: the current instance of #CRParser.
+ *@a_str: the successfully parsed url.
+ *
*Parses an uri as defined by the css spec [4.1.1]:
* URI ::= url\({w}{string}{w}\)
* |url\({w}([!#$%&*-~]|{nonascii}|{escape})*{w}\)
*
- *@param a_this the current instance of #CRParser.
- *@param a_str the successfully parsed url.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
static enum CRStatus
cr_parser_parse_uri (CRParser * a_this, CRString ** a_str)
@@ -2208,19 +2224,21 @@ cr_parser_parse_uri (CRParser * a_this, CRString ** a_str)
}
/**
+ * cr_parser_parse_string:
+ *@a_this: the current instance of #CRParser.
+ *@a_start: out parameter. Upon successfull completion,
+ *points to the beginning of the string, points to an undefined value
+ *otherwise.
+ *@a_end: out parameter. Upon successfull completion, points to
+ *the beginning of the string, points to an undefined value otherwise.
+ *
*Parses a string type as defined in css spec [4.1.1]:
*
*string ::= {string1}|{string2}
*string1 ::= \"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\"
*string2 ::= \'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\'
*
- *@param a_this the current instance of #CRParser.
- *@param a_start out parameter. Upon successfull completion,
- *points to the beginning of the string, points to an undefined value
- *otherwise.
- *@param a_end out parameter. Upon successfull completion, points to
- *the beginning of the string, points to an undefined value otherwise.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
static enum CRStatus
cr_parser_parse_string (CRParser * a_this, CRString ** a_str)
@@ -2311,7 +2329,7 @@ cr_parser_parse_stylesheet (CRParser * a_this)
CHECK_PARSING_STATUS (status, TRUE);
if (token && token->type == CHARSET_SYM_TK) {
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
status = cr_tknzr_unget_token (PRIVATE (a_this)->tknzr,
token);
CHECK_PARSING_STATUS (status, TRUE);
@@ -2387,7 +2405,7 @@ cr_parser_parse_stylesheet (CRParser * a_this)
if (token && token->type == IMPORT_SYM_TK) {
GList *media_list = NULL;
CRString *import_string = NULL;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
status = cr_tknzr_unget_token
(PRIVATE (a_this)->tknzr, token);
@@ -2445,7 +2463,7 @@ cr_parser_parse_stylesheet (CRParser * a_this)
/*free the medium list */
for (cur = media_list; cur; cur = cur->next) {
if (cur->data) {
- cr_string_destroy ((CRString *)cur->data);
+ cr_string_destroy (cur->data);
}
}
@@ -2685,7 +2703,7 @@ cr_parser_parse_stylesheet (CRParser * a_this)
}
cr_parser_push_error
- (a_this, (guchar *)"could not recognize next production", CR_ERROR);
+ (a_this, "could not recognize next production", CR_ERROR);
if (PRIVATE (a_this)->sac_handler
&& PRIVATE (a_this)->sac_handler->unrecoverable_error) {
@@ -2720,23 +2738,24 @@ cr_parser_parse_stylesheet (CRParser * a_this)
****************************************/
/**
+ * cr_parser_new:
+ * @a_tknzr: the tokenizer to use for the parsing.
+ *
*Creates a new parser to parse data
*coming the input stream given in parameter.
- *@param a_input the input stream of the parser.
- *Note that the newly created parser will ref
- *a_input and unref it when parsing reaches the
- *end of the input stream.
- *@return the newly created instance of #CRParser,
+ *
+ *Returns the newly created instance of #CRParser,
*or NULL if an error occured.
*/
CRParser *
cr_parser_new (CRTknzr * a_tknzr)
{
+ CRParser *result = NULL;
enum CRStatus status = CR_OK;
- CRParser *result = (CRParser *)g_malloc0 (sizeof (CRParser));
+ result = g_malloc0 (sizeof (CRParser));
- PRIVATE (result) = (CRParserPriv *)g_malloc0 (sizeof (CRParserPriv));
+ PRIVATE (result) = g_malloc0 (sizeof (CRParserPriv));
if (a_tknzr) {
status = cr_parser_set_tknzr (result, a_tknzr);
@@ -2748,15 +2767,18 @@ cr_parser_new (CRTknzr * a_tknzr)
}
/**
- *Instanciates a new parser from a memory buffer.
- *@param a_buf the buffer to parse.
- *@param a_len the length of the data in the buffer.
- *@param a_enc the encoding of the input buffer a_buf.
- *@param a_free_buf if set to TRUE, a_buf will be freed
+ * cr_parser_new_from_buf:
+ *@a_buf: the buffer to parse.
+ *@a_len: the length of the data in the buffer.
+ *@a_enc: the encoding of the input buffer a_buf.
+ *@a_free_buf: if set to TRUE, a_buf will be freed
*during the destruction of the newly built instance
*of #CRParser. If set to FALSE, it is up to the caller to
*eventually free it.
- *@return the newly built parser, or NULL if an error arises.
+ *
+ *Instanciates a new parser from a memory buffer.
+ *
+ *Returns the newly built parser, or NULL if an error arises.
*/
CRParser *
cr_parser_new_from_buf (guchar * a_buf,
@@ -2767,7 +2789,7 @@ cr_parser_new_from_buf (guchar * a_buf,
CRParser *result = NULL;
CRInput *input = NULL;
- g_return_val_if_fail (a_buf, NULL);
+ g_return_val_if_fail (a_buf && a_len, NULL);
input = cr_input_new_from_buf (a_buf, a_len, a_enc, a_free_buf);
g_return_val_if_fail (input, NULL);
@@ -2781,6 +2803,12 @@ cr_parser_new_from_buf (guchar * a_buf,
return result;
}
+/**
+ * cr_parser_new_from_input:
+ * @a_input: the parser input stream to use.
+ *
+ * Returns a newly built parser input.
+ */
CRParser *
cr_parser_new_from_input (CRInput * a_input)
{
@@ -2798,6 +2826,13 @@ cr_parser_new_from_input (CRInput * a_input)
return result;
}
+/**
+ * cr_parser_new_from_file:
+ * @a_file_uri: the uri of the file to parse.
+ * @a_enc: the file encoding to use.
+ *
+ * Returns the newly built parser.
+ */
CRParser *
cr_parser_new_from_file (const guchar * a_file_uri, enum CREncoding a_enc)
{
@@ -2816,10 +2851,13 @@ cr_parser_new_from_file (const guchar * a_file_uri, enum CREncoding a_enc)
}
/**
+ * cr_parser_set_sac_handler:
+ *@a_this: the "this pointer" of the current instance of #CRParser.
+ *@a_handler: the handler to set.
+ *
*Sets a SAC document handler to the parser.
- *@param a_this the "this pointer" of the current instance of #CRParser.
- *@param a_handler the handler to set.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_set_sac_handler (CRParser * a_this, CRDocHandler * a_handler)
@@ -2837,11 +2875,14 @@ cr_parser_set_sac_handler (CRParser * a_this, CRDocHandler * a_handler)
}
/**
- *Gets the SAC document handler.
- *@param a_this the "this pointer" of the current instance of
+ * cr_parser_get_sac_handler:
+ *@a_this: the "this pointer" of the current instance of
*#CRParser.
- *@param a_handler out parameter. The returned handler.
- *@return CR_OK upon successfull completion, an error code
+ *@a_handler: out parameter. The returned handler.
+ *
+ *Gets the SAC document handler.
+ *
+ *Returns CR_OK upon successfull completion, an error code
*otherwise.
*/
enum CRStatus
@@ -2855,10 +2896,13 @@ cr_parser_get_sac_handler (CRParser * a_this, CRDocHandler ** a_handler)
}
/**
+ * cr_parser_set_default_sac_handler:
+ *@a_this: a pointer to the current instance of #CRParser.
+ *
*Sets the SAC handler associated to the current instance
*of #CRParser to the default SAC handler.
- *@param a_this a pointer to the current instance of #CRParser.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_set_default_sac_handler (CRParser * a_this)
@@ -2882,6 +2926,13 @@ cr_parser_set_default_sac_handler (CRParser * a_this)
return status;
}
+/**
+ * cr_parser_set_use_core_grammar:
+ * @a_this: the current instance of #CRParser.
+ * @a_use_core_grammar: where to parse against the css core grammar.
+ *
+ * Returns CR_OK upon succesful completion, an error code otherwise.
+ */
enum CRStatus
cr_parser_set_use_core_grammar (CRParser * a_this,
gboolean a_use_core_grammar)
@@ -2893,8 +2944,15 @@ cr_parser_set_use_core_grammar (CRParser * a_this,
return CR_OK;
}
+/**
+ * cr_parser_get_use_core_grammar:
+ * @a_this: the current instance of #CRParser.
+ * @a_use_core_grammar: wether to use the core grammar or not.
+ *
+ * Returns CR_OK upon succesful completion, an error code otherwise.
+ */
enum CRStatus
-cr_parser_get_use_core_grammar (CRParser * a_this,
+cr_parser_get_use_core_grammar (CRParser const * a_this,
gboolean * a_use_core_grammar)
{
g_return_val_if_fail (a_this && PRIVATE (a_this), CR_BAD_PARAM_ERROR);
@@ -2905,11 +2963,15 @@ cr_parser_get_use_core_grammar (CRParser * a_this,
}
/**
- *Parses a the given in parameter.
- *@param a_this a pointer to the current instance of #CRParser.
- *@param a_file_uri the uri to the file to load. For the time being,
+ * cr_parser_parse_file:
+ *@a_this: a pointer to the current instance of #CRParser.
+ *@a_file_uri: the uri to the file to load. For the time being,
+ *@a_enc: the encoding of the file to parse.
*only local files are supported.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Parses a the given in parameter.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_file (CRParser * a_this,
@@ -2934,9 +2996,16 @@ cr_parser_parse_file (CRParser * a_this,
}
/**
+ * cr_parser_parse_expr:
+ * @a_this: the current instance of #CRParser.
+ * @a_expr: out parameter. the parsed expression.
+ *
*Parses an expression as defined by the css2 spec in appendix
*D.1:
*expr: term [ operator term ]*
+ *
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr)
@@ -2958,7 +3027,7 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr)
CHECK_PARSING_STATUS (status, FALSE);
for (;;) {
- guchar operatr = 0;
+ guchar operator = 0;
status = cr_tknzr_peek_byte (PRIVATE (a_this)->tknzr,
1, &next_byte);
@@ -2978,7 +3047,7 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr)
}
if (next_byte == '/' || next_byte == ',') {
- READ_NEXT_BYTE (a_this, &operatr);
+ READ_NEXT_BYTE (a_this, &operator);
}
cr_parser_try_to_skip_spaces_and_comments (a_this);
@@ -2990,7 +3059,7 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr)
break;
}
- switch (operatr) {
+ switch (operator) {
case '/':
expr2->the_operator = DIVIDE;
break;
@@ -3003,7 +3072,7 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr)
expr = cr_term_append_term (expr, expr2);
expr2 = NULL;
- operatr = 0;
+ operator = 0;
nb_terms++;
}
@@ -3033,13 +3102,17 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr)
}
/**
+ * cr_parser_parse_prio:
+ *@a_this: the current instance of #CRParser.
+ *@a_prio: a string representing the priority.
+ *Today, only "!important" is returned as only this
+ *priority is defined by css2.
+ *
*Parses a declaration priority as defined by
*the css2 grammar in appendix C:
*prio: IMPORTANT_SYM S*
- *@param a_this the current instance of #CRParser.
- *@param a_prio a string representing the priority.
- *Today, only "!important" is returned as only this
- *priority is defined by css2.
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_prio (CRParser * a_this, CRString ** a_prio)
@@ -3078,17 +3151,19 @@ cr_parser_parse_prio (CRParser * a_this, CRString ** a_prio)
}
/**
+ * cr_parser_parse_declaration:
+ *@a_this: the "this pointer" of the current instance of #CRParser.
+ *@a_property: the successfully parsed property. The caller
+ * *must* free the returned pointer.
+ *@a_expr: the expression that represents the attribute value.
+ *The caller *must* free the returned pointer.
+ *
*TODO: return the parsed priority, so that
*upper layers can take benefit from it.
*Parses a "declaration" as defined by the css2 spec in appendix D.1:
*declaration ::= [property ':' S* expr prio?]?
*
- *@param a_this the "this pointer" of the current instance of #CRParser.
- *@param a_property the successfully parsed property. The caller
- * *must* free the returned pointer.
- *@param a_expr the expression that represents the attribute value.
- *The caller *must* free the returned pointer.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_declaration (CRParser * a_this,
@@ -3114,7 +3189,7 @@ cr_parser_parse_declaration (CRParser * a_this,
CHECK_PARSING_STATUS_ERR
(a_this, status, FALSE,
- (guchar *)"while parsing declaration: next property is malformed",
+ "while parsing declaration: next property is malformed",
CR_SYNTAX_ERROR);
READ_NEXT_CHAR (a_this, &cur_char);
@@ -3123,7 +3198,7 @@ cr_parser_parse_declaration (CRParser * a_this,
status = CR_PARSING_ERROR;
cr_parser_push_error
(a_this,
- (guchar *)"while parsing declaration: this char must be ':'",
+ "while parsing declaration: this char must be ':'",
CR_SYNTAX_ERROR);
goto error;
}
@@ -3134,7 +3209,7 @@ cr_parser_parse_declaration (CRParser * a_this,
CHECK_PARSING_STATUS_ERR
(a_this, status, FALSE,
- (guchar *)"while parsing declaration: next expression is malformed",
+ "while parsing declaration: next expression is malformed",
CR_SYNTAX_ERROR);
cr_parser_try_to_skip_spaces_and_comments (a_this);
@@ -3175,11 +3250,14 @@ cr_parser_parse_declaration (CRParser * a_this,
}
/**
+ * cr_parser_parse_statement_core:
+ *@a_this: the current instance of #CRParser.
+ *
*Parses a statement as defined by the css core grammar in
*chapter 4.1 of the css2 spec.
*statement : ruleset | at-rule;
- *@param a_this the current instance of #CRParser.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_statement_core (CRParser * a_this)
@@ -3231,6 +3309,9 @@ cr_parser_parse_statement_core (CRParser * a_this)
}
/**
+ * cr_parser_parse_ruleset:
+ *@a_this: the "this pointer" of the current instance of #CRParser.
+ *
*Parses a "ruleset" as defined in the css2 spec at appendix D.1.
*ruleset ::= selector [ ',' S* selector ]*
*'{' S* declaration? [ ';' S* declaration? ]* '}' S*;
@@ -3239,8 +3320,8 @@ cr_parser_parse_statement_core (CRParser * a_this)
*callbacks whenever it encounters some specific constructions.
*See the documentation of #CRDocHandler (the SAC handler) to know
*when which SAC handler is called.
- *@param a_this the "this pointer" of the current instance of #CRParser.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_ruleset (CRParser * a_this)
@@ -3255,6 +3336,7 @@ cr_parser_parse_ruleset (CRParser * a_this)
CRSelector *selector = NULL;
gboolean start_selector = FALSE,
is_important = FALSE;
+ CRParsingLocation end_parsing_location;
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
@@ -3267,7 +3349,7 @@ cr_parser_parse_ruleset (CRParser * a_this)
ENSURE_PARSING_COND_ERR
(a_this, cur_char == '{',
- (guchar *)"while parsing rulset: current char should be '{'",
+ "while parsing rulset: current char should be '{'",
CR_SYNTAX_ERROR);
if (PRIVATE (a_this)->sac_handler
@@ -3331,7 +3413,7 @@ cr_parser_parse_ruleset (CRParser * a_this)
}
CHECK_PARSING_STATUS_ERR
(a_this, status, FALSE,
- (guchar *)"while parsing ruleset: next construction should be a declaration",
+ "while parsing ruleset: next construction should be a declaration",
CR_SYNTAX_ERROR);
for (;;) {
@@ -3369,12 +3451,14 @@ cr_parser_parse_ruleset (CRParser * a_this)
end_of_ruleset:
cr_parser_try_to_skip_spaces_and_comments (a_this);
+ cr_parser_get_parsing_location (a_this, &end_parsing_location);
READ_NEXT_CHAR (a_this, &cur_char);
ENSURE_PARSING_COND_ERR
(a_this, cur_char == '}',
- (guchar *)"while parsing rulset: current char must be a '}'",
+ "while parsing rulset: current char must be a '}'",
CR_SYNTAX_ERROR);
+ selector->location = end_parsing_location;
if (PRIVATE (a_this)->sac_handler
&& PRIVATE (a_this)->sac_handler->end_selector) {
PRIVATE (a_this)->sac_handler->end_selector
@@ -3431,29 +3515,29 @@ cr_parser_parse_ruleset (CRParser * a_this)
}
/**
- *Parses an 'import' declaration as defined in the css2 spec
- *in appendix D.1:
- *
- *import ::=
- *@import [STRING|URI] S* [ medium [ ',' S* medium]* ]? ';' S*
- *
- *@param a_this the "this pointer" of the current instance
+ * cr_parser_parse_import:
+ *@a_this: the "this pointer" of the current instance
*of #CRParser.
- *
- *@param a_medium_list out parameter. A linked list of
+ *@a_media_list: out parameter. A linked list of
*#CRString
*Each CRString is a string that contains
*a 'medium' declaration part of the successfully
*parsed 'import' declaration.
- *
- *@param a_import_string out parameter.
+ *@a_import_string: out parameter.
*A string that contains the 'import
*string". The import string can be either an uri (if it starts with
*the substring "uri(") or a any other css2 string. Note that
* *a_import_string must be initially set to NULL or else, this function
*will return CR_BAD_PARAM_ERROR.
+ *@a_location: the location (line, column) where the import has been parsed
*
- *@return CR_OK upon sucessfull completion, an error code otherwise.
+ *Parses an 'import' declaration as defined in the css2 spec
+ *in appendix D.1:
+ *
+ *import ::=
+ *\@import [STRING|URI] S* [ medium [ ',' S* medium]* ]? ';' S*
+ *
+ *Returns CR_OK upon sucessfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_import (CRParser * a_this,
@@ -3578,7 +3662,7 @@ cr_parser_parse_import (CRParser * a_this,
*/
for (cur = *a_media_list; cur; cur = cur->next) {
if (cur->data) {
- cr_string_destroy ((CRString *)cur->data);
+ cr_string_destroy (cur->data);
}
}
@@ -3602,16 +3686,19 @@ cr_parser_parse_import (CRParser * a_this,
}
/**
+ * cr_parser_parse_media:
+ *@a_this: the "this pointer" of the current instance of #CRParser.
+ *
*Parses a 'media' declaration as specified in the css2 spec at
*appendix D.1:
*
- *media ::= @media S* medium [ ',' S* medium ]* '{' S* ruleset* '}' S*
+ *media ::= \@media S* medium [ ',' S* medium ]* '{' S* ruleset* '}' S*
*
*Note that this function calls the required sac handlers during the parsing
*to notify media productions. See #CRDocHandler to know the callback called
- *during @media parsing.
- *@param a_this the "this pointer" of the current instance of #CRParser.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *during \@media parsing.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_media (CRParser * a_this)
@@ -3623,7 +3710,7 @@ cr_parser_parse_media (CRParser * a_this)
cur_char = 0;
CRString *medium = NULL;
GList *media_list = NULL;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this
&& PRIVATE (a_this),
@@ -3729,7 +3816,7 @@ cr_parser_parse_media (CRParser * a_this)
GList *cur = NULL;
for (cur = media_list; cur; cur = cur->next) {
- cr_string_destroy ((CRString *)cur->data);
+ cr_string_destroy (cur->data);
}
g_list_free (media_list);
@@ -3757,7 +3844,7 @@ cr_parser_parse_media (CRParser * a_this)
GList *cur = NULL;
for (cur = media_list; cur; cur = cur->next) {
- cr_string_destroy ((CRString *)cur->data);
+ cr_string_destroy (cur->data);
}
g_list_free (media_list);
@@ -3770,15 +3857,18 @@ cr_parser_parse_media (CRParser * a_this)
}
/**
- *Parses '@page' rule as specified in the css2 spec in appendix D.1:
+ * cr_parser_parse_page:
+ *@a_this: the "this pointer" of the current instance of #CRParser.
+ *
+ *Parses '\@page' rule as specified in the css2 spec in appendix D.1:
*page ::= PAGE_SYM S* IDENT? pseudo_page? S*
*'{' S* declaration [ ';' S* declaration ]* '}' S*
*
*This function also calls the relevant SAC handlers whenever it
*encounters a construction that must
*be reported to the calling application.
- *@param a_this the "this pointer" of the current instance of #CRParser.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_page (CRParser * a_this)
@@ -3791,7 +3881,7 @@ cr_parser_parse_page (CRParser * a_this)
*page_pseudo_class = NULL,
*property = NULL;
gboolean important = TRUE;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
@@ -4018,16 +4108,18 @@ cr_parser_parse_page (CRParser * a_this)
}
/**
+ * cr_parser_parse_charset:
+ *@a_this: the "this pointer" of the current instance of #CRParser.
+ *@a_value: out parameter. The actual parsed value of the charset
+ *declararation. Note that for safety check reasons, *a_value must be
+ *set to NULL.
+ *@a_charset_sym_location: the parsing location of the charset rule
+ *
*Parses a charset declaration as defined implictly by the css2 spec in
*appendix D.1:
*charset ::= CHARSET_SYM S* STRING S* ';'
*
- *@param a_this the "this pointer" of the current instance of #CRParser.
- *@param a_value out parameter. The actual parsed value of the charset
- *declararation. Note that for safety check reasons, *a_value must be
- *set to NULL.
- *@param a_charset_sym_location the parsing location of
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_charset (CRParser * a_this, CRString ** a_value,
@@ -4107,14 +4199,18 @@ cr_parser_parse_charset (CRParser * a_this, CRString ** a_value,
}
/**
- *Parses the "@font-face" rule specified in the css1 spec in
+ * cr_parser_parse_font_face:
+ *@a_this: the current instance of #CRParser.
+ *
+ *Parses the "\@font-face" rule specified in the css1 spec in
*appendix D.1:
*
*font_face ::= FONT_FACE_SYM S*
*'{' S* declaration [ ';' S* declaration ]* '}' S*
*
*This function will call SAC handlers whenever it is necessary.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_font_face (CRParser * a_this)
@@ -4127,7 +4223,7 @@ cr_parser_parse_font_face (CRParser * a_this)
gboolean important = FALSE;
guint32 next_char = 0,
cur_char = 0;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
@@ -4264,11 +4360,14 @@ cr_parser_parse_font_face (CRParser * a_this)
}
/**
+ * cr_parser_parse:
+ *@a_this: the current instance of #CRParser.
+ *
*Parses the data that comes from the
*input previously associated to the current instance of
*#CRParser.
- *@param a_this the current instance of #CRParser.
- *@return CR_OK ;
+ *
+ *Returns CR_OK upon succesful completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse (CRParser * a_this)
@@ -4287,6 +4386,13 @@ cr_parser_parse (CRParser * a_this)
return status;
}
+/**
+ * cr_parser_set_tknzr:
+ * @a_this: the current instance of #CRParser;
+ * @a_tknzr: the new tokenizer.
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
+ */
enum CRStatus
cr_parser_set_tknzr (CRParser * a_this, CRTknzr * a_tknzr)
{
@@ -4305,10 +4411,13 @@ cr_parser_set_tknzr (CRParser * a_this, CRTknzr * a_tknzr)
}
/**
+ * cr_parser_get_tknzr:
+ *@a_this: the current instance of #CRParser
+ *@a_tknzr: out parameter. The returned tokenizer
+ *
*Getter of the parser's underlying tokenizer
- *@param a_this the current instance of #CRParser
- *@param a_tknzr out parameter. The returned tokenizer
- *@return CR_OK upon succesful completion, an error code
+ *
+ *Returns CR_OK upon succesful completion, an error code
*otherwise
*/
enum CRStatus
@@ -4322,14 +4431,17 @@ cr_parser_get_tknzr (CRParser * a_this, CRTknzr ** a_tknzr)
}
/**
+ * cr_parser_get_parsing_location:
+ *@a_this: the current instance of #CRParser
+ *@a_loc: the parsing location to get.
+ *
*Gets the current parsing location.
- *@param a_this the current instance of #CRParser
- *@param a_loc the parsing location to get.
- *@return CR_OK upon succesful completion, an error code
+ *
+ *Returns CR_OK upon succesful completion, an error code
*otherwise.
*/
enum CRStatus
-cr_parser_get_parsing_location (CRParser *a_this,
+cr_parser_get_parsing_location (CRParser const *a_this,
CRParsingLocation *a_loc)
{
g_return_val_if_fail (a_this
@@ -4341,12 +4453,15 @@ cr_parser_get_parsing_location (CRParser *a_this,
}
/**
+ * cr_parser_parse_buf:
+ *@a_this: the current instance of #CRparser
+ *@a_buf: the input buffer
+ *@a_len: the length of the input buffer
+ *@a_enc: the encoding of the buffer
+ *
*Parses a stylesheet from a buffer
- *@param a_this the current instance of #CRparser
- *@param a_buf the input buffer
- *@param a_len the length of the input buffer
- *@param a_enc the encoding of the buffer
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_parser_parse_buf (CRParser * a_this,
@@ -4372,10 +4487,12 @@ cr_parser_parse_buf (CRParser * a_this,
}
/**
+ * cr_parser_destroy:
+ *@a_this: the current instance of #CRParser to
+ *destroy.
+ *
*Destroys the current instance
*of #CRParser.
- *@param a_this the current instance of #CRParser to
- *destroy.
*/
void
cr_parser_destroy (CRParser * a_this)
diff --git a/src/cr-parser.h b/src/cr-parser.h
index 1534afb..6dce943 100644
--- a/src/cr-parser.h
+++ b/src/cr-parser.h
@@ -68,7 +68,7 @@ enum CRStatus cr_parser_set_tknzr (CRParser *a_this, CRTknzr *a_tknzr) ;
enum CRStatus cr_parser_get_tknzr (CRParser *a_this, CRTknzr **a_tknzr) ;
-enum CRStatus cr_parser_get_parsing_location (CRParser *a_this, CRParsingLocation *a_loc) ;
+enum CRStatus cr_parser_get_parsing_location (CRParser const *a_this, CRParsingLocation *a_loc) ;
enum CRStatus cr_parser_try_to_skip_spaces_and_comments (CRParser *a_this) ;
@@ -81,7 +81,7 @@ enum CRStatus cr_parser_get_sac_handler (CRParser *a_this,
enum CRStatus cr_parser_set_use_core_grammar (CRParser *a_this,
gboolean a_use_core_grammar) ;
-enum CRStatus cr_parser_get_use_core_grammar (CRParser *a_this,
+enum CRStatus cr_parser_get_use_core_grammar (CRParser const *a_this,
gboolean *a_use_core_grammar) ;
enum CRStatus cr_parser_parse (CRParser *a_this) ;
diff --git a/src/cr-parsing-location.c b/src/cr-parsing-location.c
index 38a75a6..4fe4acc 100644
--- a/src/cr-parsing-location.c
+++ b/src/cr-parsing-location.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -25,21 +25,25 @@
#include "cr-parsing-location.h"
/**
- *@file
+ *@CRParsingLocation:
+ *
*Definition of the #CRparsingLocation class.
*/
/**
+ * cr_parsing_location_new:
*Instanciates a new parsing location.
- *@return the newly instanciated #CRParsingLocation.
+ *
+ *Returns the newly instanciated #CRParsingLocation.
*Must be freed by cr_parsing_location_destroy()
*/
CRParsingLocation *
cr_parsing_location_new (void)
{
- CRParsingLocation *result =
- (CRParsingLocation *)g_try_malloc (sizeof (CRParsingLocation)) ;
+ CRParsingLocation * result = NULL ;
+
+ result = g_try_malloc (sizeof (CRParsingLocation)) ;
if (!result) {
cr_utils_trace_info ("Out of memory error") ;
return NULL ;
@@ -49,9 +53,12 @@ cr_parsing_location_new (void)
}
/**
+ * cr_parsing_location_init:
+ *@a_this: the current instance of #CRParsingLocation.
+ *
*Initializes the an instance of #CRparsingLocation.
- *@param a_this the current instance of #CRParsingLocation.
- *@return CR_OK upon
+ *
+ *Returns CR_OK upon succesful completion, an error code otherwise.
*/
enum CRStatus
cr_parsing_location_init (CRParsingLocation *a_this)
@@ -63,16 +70,19 @@ cr_parsing_location_init (CRParsingLocation *a_this)
}
/**
- *Copies an instance of CRParsingLocation into another one.
- *@param a_to the destination of the copy.
+ * cr_parsing_location_copy:
+ *@a_to: the destination of the copy.
*Must be allocated by the caller.
- *@param a_from the source of the copy.
- *@return CR_OK upon succesful completion, an error code
+ *@a_from: the source of the copy.
+ *
+ *Copies an instance of CRParsingLocation into another one.
+ *
+ *Returns CR_OK upon succesful completion, an error code
*otherwise.
*/
enum CRStatus
cr_parsing_location_copy (CRParsingLocation *a_to,
- CRParsingLocation *a_from)
+ CRParsingLocation const *a_from)
{
g_return_val_if_fail (a_to && a_from, CR_BAD_PARAM_ERROR) ;
@@ -81,24 +91,26 @@ cr_parsing_location_copy (CRParsingLocation *a_to,
}
/**
- *@param a_this the current instance of #CRParsingLocation.
- *@param a_mask a bitmap that defines which parts of the
+ * cr_parsing_location_to_string:
+ *@a_this: the current instance of #CRParsingLocation.
+ *@a_mask: a bitmap that defines which parts of the
*parsing location are to be serialized (line, column or byte offset)
- *@return the serialized string or NULL in case of an error.
+ *
+ *Returns the serialized string or NULL in case of an error.
*/
gchar *
-cr_parsing_location_to_string (CRParsingLocation *a_this,
+cr_parsing_location_to_string (CRParsingLocation const *a_this,
enum CRParsingLocationSerialisationMask a_mask)
{
+ GString *result = NULL ;
gchar *str = NULL ;
g_return_val_if_fail (a_this, NULL) ;
if (!a_mask) {
- a_mask = (enum CRParsingLocationSerialisationMask)
- ((int)DUMP_LINE | (int)DUMP_COLUMN | (int)DUMP_BYTE_OFFSET) ;
+ a_mask = DUMP_LINE | DUMP_COLUMN | DUMP_BYTE_OFFSET ;
}
- GString *result = (GString *)g_string_new (NULL) ;
+ result =g_string_new (NULL) ;
if (!result)
return NULL ;
if (a_mask & DUMP_LINE) {
@@ -122,8 +134,14 @@ cr_parsing_location_to_string (CRParsingLocation *a_this,
return str ;
}
+/**
+ * cr_parsing_location_dump:
+ * @a_this: current instance of #CRParsingLocation
+ * @a_mask: the serialization mask.
+ * @a_fp: the file pointer to dump the parsing location to.
+ */
void
-cr_parsing_location_dump (CRParsingLocation *a_this,
+cr_parsing_location_dump (CRParsingLocation const *a_this,
enum CRParsingLocationSerialisationMask a_mask,
FILE *a_fp)
{
@@ -139,9 +157,11 @@ cr_parsing_location_dump (CRParsingLocation *a_this,
}
/**
- *Destroys the current instance of #CRParsingLocation
- *@param a_this the current instance of #CRParsingLocation. Must
+ * cr_parsing_location_destroy:
+ *@a_this: the current instance of #CRParsingLocation. Must
*have been allocated with cr_parsing_location_new().
+ *
+ *Destroys the current instance of #CRParsingLocation
*/
void
cr_parsing_location_destroy (CRParsingLocation *a_this)
diff --git a/src/cr-parsing-location.h b/src/cr-parsing-location.h
index 877c050..b8064a5 100644
--- a/src/cr-parsing-location.h
+++ b/src/cr-parsing-location.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -54,11 +54,11 @@ CRParsingLocation * cr_parsing_location_new (void) ;
enum CRStatus cr_parsing_location_init (CRParsingLocation *a_this) ;
enum CRStatus cr_parsing_location_copy (CRParsingLocation *a_to,
- CRParsingLocation *a_from) ;
+ CRParsingLocation const *a_from) ;
-gchar * cr_parsing_location_to_string (CRParsingLocation *a_this,
+gchar * cr_parsing_location_to_string (CRParsingLocation const *a_this,
enum CRParsingLocationSerialisationMask a_mask) ;
-void cr_parsing_location_dump (CRParsingLocation *a_this,
+void cr_parsing_location_dump (CRParsingLocation const *a_this,
enum CRParsingLocationSerialisationMask a_mask,
FILE *a_fp) ;
diff --git a/src/cr-prop-list.c b/src/cr-prop-list.c
index 0768379..0ce57fa 100644
--- a/src/cr-prop-list.c
+++ b/src/cr-prop-list.c
@@ -41,13 +41,15 @@ static CRPropList *cr_prop_list_allocate (void);
static CRPropList *
cr_prop_list_allocate (void)
{
- CRPropList *result = (CRPropList *)g_try_malloc (sizeof (CRPropList));
+ CRPropList *result = NULL;
+
+ result = g_try_malloc (sizeof (CRPropList));
if (!result) {
cr_utils_trace_info ("could not allocate CRPropList");
return NULL;
}
memset (result, 0, sizeof (CRPropList));
- PRIVATE (result) = (CRPropListPriv *)g_try_malloc (sizeof (CRPropListPriv));
+ PRIVATE (result) = g_try_malloc (sizeof (CRPropListPriv));
if (!result) {
cr_utils_trace_info ("could not allocate CRPropListPriv");
g_free (result);
@@ -62,10 +64,13 @@ cr_prop_list_allocate (void)
***************/
/**
+ * cr_prop_list_append:
+ *@a_this: the current instance of #CRPropList
+ *@a_to_append: the property list to append
+ *
*Appends a property list to the current one.
- *@param a_this the current instance of #CRPropList
- *@param a_to_append the property list to append
- *@return the resulting prop list, or NULL if an error
+ *
+ *Returns the resulting prop list, or NULL if an error
*occured
*/
CRPropList *
@@ -89,12 +94,14 @@ cr_prop_list_append (CRPropList * a_this, CRPropList * a_to_append)
}
/**
+ * cr_prop_list_append2:
*Appends a pair of prop/declaration to
*the current prop list.
- *@param a_this the current instance of #CRPropList
- *@param a_prop the property to consider
- *@param a_decl the declaration to consider
- *@return the resulting property list, or NULL in case
+ *@a_this: the current instance of #CRPropList
+ *@a_prop: the property to consider
+ *@a_decl: the declaration to consider
+ *
+ *Returns the resulting property list, or NULL in case
*of an error.
*/
CRPropList *
@@ -118,9 +125,12 @@ cr_prop_list_append2 (CRPropList * a_this,
}
/**
+ * cr_prop_list_prepend:
+ *@a_this: the current instance of #CRPropList
+ *@a_to_prepend: the new list to prepend.
+ *
*Prepends a list to the current list
- *@param a_this the current instance of #CRPropList
- *@param the new list to prepend.
+ *Returns the new properties list.
*/
CRPropList *
cr_prop_list_prepend (CRPropList * a_this, CRPropList * a_to_prepend)
@@ -141,32 +151,39 @@ cr_prop_list_prepend (CRPropList * a_this, CRPropList * a_to_prepend)
}
/**
- *Prepends a list to the current list
- *@param a_this the current instance of #CRPropList
- *@param the new list to prepend.
+ * cr_prop_list_prepend2:
+ *@a_this: the current instance of #CRPropList
+ *@a_prop_name: property name to append
+ *@a_decl: the property value to append.
+ *
+ *Prepends a propertie to a list of properties
+ *
+ *Returns the new property list.
*/
CRPropList *
cr_prop_list_prepend2 (CRPropList * a_this,
- CRString * a_prop, CRDeclaration * a_decl)
+ CRString * a_prop_name, CRDeclaration * a_decl)
{
CRPropList *list = NULL,
*result = NULL;
g_return_val_if_fail (a_this && PRIVATE (a_this)
- && a_prop && a_decl, NULL);
+ && a_prop_name && a_decl, NULL);
list = cr_prop_list_allocate ();
g_return_val_if_fail (list, NULL);
- PRIVATE (list)->prop = a_prop;
+ PRIVATE (list)->prop = a_prop_name;
PRIVATE (list)->decl = a_decl;
result = cr_prop_list_prepend (a_this, list);
return result;
}
/**
+ * cr_prop_list_set_prop:
+ *@a_this: the current instance of #CRPropList
+ *@a_prop: the property to set
+ *
*Sets the property of a CRPropList
- *@param a_this the current instance of #CRPropList
- *@param a_prop the property to set
*/
enum CRStatus
cr_prop_list_set_prop (CRPropList * a_this, CRString * a_prop)
@@ -179,15 +196,18 @@ cr_prop_list_set_prop (CRPropList * a_this, CRString * a_prop)
}
/**
+ * cr_prop_list_get_prop:
+ *@a_this: the current instance of #CRPropList
+ *@a_prop: out parameter. The returned property
+ *
*Getter of the property associated to the current instance
*of #CRPropList
- *@param a_this the current instance of #CRPropList
- *@param a_prop out parameter. The returned property
- *@return CR_OK upon successful completion, an error code
+ *
+ *Returns CR_OK upon successful completion, an error code
*otherwise.
*/
enum CRStatus
-cr_prop_list_get_prop (CRPropList * a_this, CRString ** a_prop)
+cr_prop_list_get_prop (CRPropList const * a_this, CRString ** a_prop)
{
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_prop, CR_BAD_PARAM_ERROR);
@@ -196,6 +216,13 @@ cr_prop_list_get_prop (CRPropList * a_this, CRString ** a_prop)
return CR_OK;
}
+/**
+ * cr_prop_list_set_decl:
+ * @a_this: the current instance of #CRPropList
+ * @a_decl: the new property value.
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
+ */
enum CRStatus
cr_prop_list_set_decl (CRPropList * a_this, CRDeclaration * a_decl)
{
@@ -206,8 +233,15 @@ cr_prop_list_set_decl (CRPropList * a_this, CRDeclaration * a_decl)
return CR_OK;
}
+/**
+ * cr_prop_list_get_decl:
+ * @a_this: the current instance of #CRPropList
+ * @a_decl: out parameter. The property value
+ *
+ * Returns CR_OK upon successful completion.
+ */
enum CRStatus
-cr_prop_list_get_decl (CRPropList * a_this, CRDeclaration ** a_decl)
+cr_prop_list_get_decl (CRPropList const * a_this, CRDeclaration ** a_decl)
{
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_decl, CR_BAD_PARAM_ERROR);
@@ -217,12 +251,15 @@ cr_prop_list_get_decl (CRPropList * a_this, CRDeclaration ** a_decl)
}
/**
- *Lookup a given property/declaration pair
- *@param a_this the current instance of #CRPropList
- *@param a_prop the property to lookup
- *@param a_prop_list out parameter. The property/declaration
+ * cr_prop_list_lookup_prop:
+ *@a_this: the current instance of #CRPropList
+ *@a_prop: the property to lookup
+ *@a_prop_list: out parameter. The property/declaration
*pair found (if and only if the function returned code if CR_OK)
- *@return CR_OK if a prop/decl pair has been found,
+ *
+ *Lookup a given property/declaration pair
+ *
+ *Returns CR_OK if a prop/decl pair has been found,
*CR_VALUE_NOT_FOUND_ERROR if not, or an error code if something
*bad happens.
*/
@@ -259,11 +296,12 @@ cr_prop_list_lookup_prop (CRPropList * a_this,
}
/**
+ * cr_prop_list_get_next:
+ *@a_this: the current instance of CRPropList
+ *
*Gets the next prop/decl pair in the list
- *@param a_this the current instance of CRPropList
- *@param the next prop/decl pair, or NULL if we
- *reached the end of the list.
- *@return the next prop/declaration pair of the list,
+ *
+ *Returns the next prop/declaration pair of the list,
*or NULL if we reached end of list (or if an error occurs)
*/
CRPropList *
@@ -275,11 +313,12 @@ cr_prop_list_get_next (CRPropList * a_this)
}
/**
+ * cr_prop_list_get_prev:
+ *@a_this: the current instance of CRPropList
+ *
*Gets the previous prop/decl pair in the list
- *@param a_this the current instance of CRPropList
- *@param the previous prop/decl pair, or NULL if we
- *reached the end of the list.
- *@return the previous prop/declaration pair of the list,
+ *
+ *Returns the previous prop/declaration pair of the list,
*or NULL if we reached end of list (or if an error occurs)
*/
CRPropList *
@@ -291,10 +330,13 @@ cr_prop_list_get_prev (CRPropList * a_this)
}
/**
+ * cr_prop_list_unlink:
+ *@a_this: the current list of prop/decl pairs
+ *@a_pair: the prop/decl pair to unlink.
+ *
*Unlinks a prop/decl pair from the list
- *@param a_this the current list of prop/decl pairs
- *@param a_pair the prop/decl pair to unlink.
- *@return the new list or NULL in case of an error.
+ *
+ *Returns the new list or NULL in case of an error.
*/
CRPropList *
cr_prop_list_unlink (CRPropList * a_this, CRPropList * a_pair)
@@ -330,6 +372,10 @@ cr_prop_list_unlink (CRPropList * a_this, CRPropList * a_pair)
return a_this;
}
+/**
+ * cr_prop_list_destroy:
+ * @a_this: the current instance of #CRPropList
+ */
void
cr_prop_list_destroy (CRPropList * a_this)
{
diff --git a/src/cr-prop-list.h b/src/cr-prop-list.h
index a003be2..797ba43 100644
--- a/src/cr-prop-list.h
+++ b/src/cr-prop-list.h
@@ -53,7 +53,7 @@ CRPropList * cr_prop_list_prepend2 (CRPropList *a_this,
enum CRStatus cr_prop_list_set_prop (CRPropList *a_this,
CRString *a_prop) ;
-enum CRStatus cr_prop_list_get_prop (CRPropList *a_this,
+enum CRStatus cr_prop_list_get_prop (CRPropList const *a_this,
CRString **a_prop) ;
enum CRStatus cr_prop_list_lookup_prop (CRPropList *a_this,
@@ -67,7 +67,7 @@ CRPropList * cr_prop_list_get_prev (CRPropList *a_this) ;
enum CRStatus cr_prop_list_set_decl (CRPropList *a_this,
CRDeclaration *a_decl);
-enum CRStatus cr_prop_list_get_decl (CRPropList *a_this,
+enum CRStatus cr_prop_list_get_decl (CRPropList const *a_this,
CRDeclaration **a_decl) ;
CRPropList * cr_prop_list_unlink (CRPropList *a_this,
diff --git a/src/cr-pseudo.c b/src/cr-pseudo.c
index abb4f9b..a46e69e 100644
--- a/src/cr-pseudo.c
+++ b/src/cr-pseudo.c
@@ -24,37 +24,51 @@
#include "cr-pseudo.h"
/**
- *@file
+ *@CRPseudo:
*The definition of the #CRPseudo class.
*/
/**
+ * cr_pseudo_new:
*Constructor of the #CRPseudo class.
- *@return the newly build instance.
+ *
+ *Returns the newly build instance.
*/
CRPseudo *
cr_pseudo_new (void)
{
- CRPseudo *result = (CRPseudo *)g_malloc0 (sizeof (CRPseudo));
+ CRPseudo *result = NULL;
+
+ result = g_malloc0 (sizeof (CRPseudo));
return result;
}
+/**
+ * cr_pseudo_to_string:
+ * @a_this: the current instance of #CRPseud.
+ *
+ * Returns the serialized pseudo. Caller must free the returned
+ * string using g_free().
+ */
guchar *
-cr_pseudo_to_string (CRPseudo * a_this)
+cr_pseudo_to_string (CRPseudo const * a_this)
{
guchar *result = NULL;
+ GString *str_buf = NULL;
g_return_val_if_fail (a_this, NULL);
- GString *str_buf = (GString *)g_string_new (NULL);
+ str_buf = g_string_new (NULL);
if (a_this->type == IDENT_PSEUDO) {
+ guchar *name = NULL;
- if (a_this->name == NULL)
+ if (a_this->name == NULL) {
goto error;
+ }
- gchar *name = g_strndup (a_this->name->stryng->str,
+ name = g_strndup (a_this->name->stryng->str,
a_this->name->stryng->len);
if (name) {
@@ -63,12 +77,13 @@ cr_pseudo_to_string (CRPseudo * a_this)
name = NULL;
}
} else if (a_this->type == FUNCTION_PSEUDO) {
- gchar *arg = NULL;
+ guchar *name = NULL,
+ *arg = NULL;
if (a_this->name == NULL)
goto error;
- gchar *name = g_strndup (a_this->name->stryng->str,
+ name = g_strndup (a_this->name->stryng->str,
a_this->name->stryng->len);
if (a_this->extra) {
@@ -92,7 +107,7 @@ cr_pseudo_to_string (CRPseudo * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -105,12 +120,15 @@ cr_pseudo_to_string (CRPseudo * a_this)
}
/**
+ * cr_pseudo_dump:
+ *@a_this: the current instance of pseudo
+ *@a_fp: the destination file pointer.
+ *
*Dumps the pseudo to a file.
- *@param a_this the current instance of pseudo
- *@param a_fp the destination file pointer.
+ *
*/
void
-cr_pseudo_dump (CRPseudo * a_this, FILE * a_fp)
+cr_pseudo_dump (CRPseudo const * a_this, FILE * a_fp)
{
guchar *tmp_str = NULL;
@@ -125,8 +143,10 @@ cr_pseudo_dump (CRPseudo * a_this, FILE * a_fp)
}
/**
+ * cr_pseudo_destroy:
+ *@a_this: the current instance to destroy.
+ *
*destructor of the #CRPseudo class.
- *@param a_this the current instance to destroy.
*/
void
cr_pseudo_destroy (CRPseudo * a_this)
diff --git a/src/cr-pseudo.h b/src/cr-pseudo.h
index 6de6c9e..8917da4 100644
--- a/src/cr-pseudo.h
+++ b/src/cr-pseudo.h
@@ -53,9 +53,9 @@ struct _CRPseudo
CRPseudo * cr_pseudo_new (void) ;
-guchar * cr_pseudo_to_string (CRPseudo *a_this) ;
+guchar * cr_pseudo_to_string (CRPseudo const *a_this) ;
-void cr_pseudo_dump (CRPseudo *a_this, FILE *a_fp) ;
+void cr_pseudo_dump (CRPseudo const *a_this, FILE *a_fp) ;
void cr_pseudo_destroy (CRPseudo *a_this) ;
diff --git a/src/cr-rgb.c b/src/cr-rgb.c
index 893c208..6313a58 100644
--- a/src/cr-rgb.c
+++ b/src/cr-rgb.c
@@ -29,164 +29,169 @@
#include "cr-parser.h"
static CRRgb gv_standard_colors[] = {
- {"aliceblue", 240, 248, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"antiquewhite", 250, 235, 215, FALSE, FALSE, FALSE, {0,0,0}},
- {"aqua", 0, 255, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"aquamarine", 127, 255, 212, FALSE, FALSE, FALSE, {0,0,0}},
- {"azure", 240, 255, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"beige", 245, 245, 220, FALSE, FALSE, FALSE, {0,0,0}},
- {"bisque", 255, 228, 196, FALSE, FALSE, FALSE, {0,0,0}},
- {"black", 0, 0, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"blanchedalmond", 255, 235, 205, FALSE, FALSE, FALSE, {0,0,0}},
- {"blue", 0, 0, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"blueviolet", 138, 43, 226, FALSE, FALSE, FALSE, {0,0,0}},
- {"brown", 165, 42, 42, FALSE, FALSE, FALSE, {0,0,0}},
- {"burlywood", 222, 184, 135, FALSE, FALSE, FALSE, {0,0,0}},
- {"cadetblue", 95, 158, 160, FALSE, FALSE, FALSE, {0,0,0}},
- {"chartreuse", 127, 255, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"chocolate", 210, 105, 30, FALSE, FALSE, FALSE, {0,0,0}},
- {"coral", 255, 127, 80, FALSE, FALSE, FALSE, {0,0,0}},
- {"cornflowerblue", 100, 149, 237, FALSE, FALSE, FALSE, {0,0,0}},
- {"cornsilk", 255, 248, 220, FALSE, FALSE, FALSE, {0,0,0}},
- {"crimson", 220, 20, 60, FALSE, FALSE, FALSE, {0,0,0}},
- {"cyan", 0, 255, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkblue", 0, 0, 139, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkcyan", 0, 139, 139, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkgoldenrod", 184, 134, 11, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkgray", 169, 169, 169, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkgreen", 0, 100, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkgrey", 169, 169, 169, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkkhaki", 189, 183, 107, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkmagenta", 139, 0, 139, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkolivegreen", 85, 107, 47, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkorange", 255, 140, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkorchid", 153, 50, 204, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkred", 139, 0, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"darksalmon", 233, 150, 122, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkseagreen", 143, 188, 143, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkslateblue", 72, 61, 139, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkslategray", 47, 79, 79, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkslategrey", 47, 79, 79, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkturquoise", 0, 206, 209, FALSE, FALSE, FALSE, {0,0,0}},
- {"darkviolet", 148, 0, 211, FALSE, FALSE, FALSE, {0,0,0}},
- {"deeppink", 255, 20, 147, FALSE, FALSE, FALSE, {0,0,0}},
- {"deepskyblue", 0, 191, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"dimgray", 105, 105, 105, FALSE, FALSE, FALSE, {0,0,0}},
- {"dimgrey", 105, 105, 105, FALSE, FALSE, FALSE, {0,0,0}},
- {"dodgerblue", 30, 144, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"firebrick", 178, 34, 34, FALSE, FALSE, FALSE, {0,0,0}},
- {"floralwhite", 255, 250, 240, FALSE, FALSE, FALSE, {0,0,0}},
- {"forestgreen", 34, 139, 34, FALSE, FALSE, FALSE, {0,0,0}},
- {"fuchsia", 255, 0, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"gainsboro", 220, 220, 220, FALSE, FALSE, FALSE, {0,0,0}},
- {"ghostwhite", 248, 248, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"gold", 255, 215, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"goldenrod", 218, 165, 32, FALSE, FALSE, FALSE, {0,0,0}},
- {"gray", 128, 128, 128, FALSE, FALSE, FALSE, {0,0,0}},
- {"grey", 128, 128, 128, FALSE, FALSE, FALSE, {0,0,0}},
- {"green", 0, 128, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"greenyellow", 173, 255, 47, FALSE, FALSE, FALSE, {0,0,0}},
- {"honeydew", 240, 255, 240, FALSE, FALSE, FALSE, {0,0,0}},
- {"hotpink", 255, 105, 180, FALSE, FALSE, FALSE, {0,0,0}},
- {"indianred", 205, 92, 92, FALSE, FALSE, FALSE, {0,0,0}},
- {"indigo", 75, 0, 130, FALSE, FALSE, FALSE, {0,0,0}},
- {"ivory", 255, 255, 240, FALSE, FALSE, FALSE, {0,0,0}},
- {"khaki", 240, 230, 140, FALSE, FALSE, FALSE, {0,0,0}},
- {"lavender", 230, 230, 250, FALSE, FALSE, FALSE, {0,0,0}},
- {"lavenderblush", 255, 240, 245, FALSE, FALSE, FALSE, {0,0,0}},
- {"lawngreen", 124, 252, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"lemonchiffon", 255, 250, 205, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightblue", 173, 216, 230, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightcoral", 240, 128, 128, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightcyan", 224, 255, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightgoldenrodyellow", 250, 250, 210, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightgray", 211, 211, 211, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightgreen", 144, 238, 144, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightgrey", 211, 211, 211, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightpink", 255, 182, 193, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightsalmon", 255, 160, 122, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightseagreen", 32, 178, 170, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightskyblue", 135, 206, 250, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightslategray", 119, 136, 153, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightslategrey", 119, 136, 153, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightsteelblue", 176, 196, 222, FALSE, FALSE, FALSE, {0,0,0}},
- {"lightyellow", 255, 255, 224, FALSE, FALSE, FALSE, {0,0,0}},
- {"lime", 0, 255, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"limegreen", 50, 205, 50, FALSE, FALSE, FALSE, {0,0,0}},
- {"linen", 250, 240, 230, FALSE, FALSE, FALSE, {0,0,0}},
- {"magenta", 255, 0, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"maroon", 128, 0, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumaquamarine", 102, 205, 170, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumblue", 0, 0, 205, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumorchid", 186, 85, 211, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumpurple", 147, 112, 219, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumseagreen", 60, 179, 113, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumslateblue", 123, 104, 238, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumspringgreen", 0, 250, 154, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumturquoise", 72, 209, 204, FALSE, FALSE, FALSE, {0,0,0}},
- {"mediumvioletred", 199, 21, 133, FALSE, FALSE, FALSE, {0,0,0}},
- {"midnightblue", 25, 25, 112, FALSE, FALSE, FALSE, {0,0,0}},
- {"mintcream", 245, 255, 250, FALSE, FALSE, FALSE, {0,0,0}},
- {"mistyrose", 255, 228, 225, FALSE, FALSE, FALSE, {0,0,0}},
- {"moccasin", 255, 228, 181, FALSE, FALSE, FALSE, {0,0,0}},
- {"navajowhite", 255, 222, 173, FALSE, FALSE, FALSE, {0,0,0}},
- {"navy", 0, 0, 128, FALSE, FALSE, FALSE, {0,0,0}},
- {"oldlace", 253, 245, 230, FALSE, FALSE, FALSE, {0,0,0}},
- {"olive", 128, 128, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"olivedrab", 107, 142, 35, FALSE, FALSE, FALSE, {0,0,0}},
- {"orange", 255, 165, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"orangered", 255, 69, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"orchid", 218, 112, 214, FALSE, FALSE, FALSE, {0,0,0}},
- {"palegoldenrod", 238, 232, 170, FALSE, FALSE, FALSE, {0,0,0}},
- {"palegreen", 152, 251, 152, FALSE, FALSE, FALSE, {0,0,0}},
- {"paleturquoise", 175, 238, 238, FALSE, FALSE, FALSE, {0,0,0}},
- {"palevioletred", 219, 112, 147, FALSE, FALSE, FALSE, {0,0,0}},
- {"papayawhip", 255, 239, 213, FALSE, FALSE, FALSE, {0,0,0}},
- {"peachpuff", 255, 218, 185, FALSE, FALSE, FALSE, {0,0,0}},
- {"peru", 205, 133, 63, FALSE, FALSE, FALSE, {0,0,0}},
- {"pink", 255, 192, 203, FALSE, FALSE, FALSE, {0,0,0}},
- {"plum", 221, 160, 221, FALSE, FALSE, FALSE, {0,0,0}},
- {"powderblue", 176, 224, 230, FALSE, FALSE, FALSE, {0,0,0}},
- {"purple", 128, 0, 128, FALSE, FALSE, FALSE, {0,0,0}},
- {"red", 255, 0, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"rosybrown", 188, 143, 143, FALSE, FALSE, FALSE, {0,0,0}},
- {"royalblue", 65, 105, 225, FALSE, FALSE, FALSE, {0,0,0}},
- {"saddlebrown", 139, 69, 19, FALSE, FALSE, FALSE, {0,0,0}},
- {"salmon", 250, 128, 114, FALSE, FALSE, FALSE, {0,0,0}},
- {"sandybrown", 244, 164, 96, FALSE, FALSE, FALSE, {0,0,0}},
- {"seagreen", 46, 139, 87, FALSE, FALSE, FALSE, {0,0,0}},
- {"seashell", 255, 245, 238, FALSE, FALSE, FALSE, {0,0,0}},
- {"sienna", 160, 82, 45, FALSE, FALSE, FALSE, {0,0,0}},
- {"silver", 192, 192, 192, FALSE, FALSE, FALSE, {0,0,0}},
- {"skyblue", 135, 206, 235, FALSE, FALSE, FALSE, {0,0,0}},
- {"slateblue", 106, 90, 205, FALSE, FALSE, FALSE, {0,0,0}},
- {"slategray", 112, 128, 144, FALSE, FALSE, FALSE, {0,0,0}},
- {"slategrey", 112, 128, 144, FALSE, FALSE, FALSE, {0,0,0}},
- {"snow", 255, 250, 250, FALSE, FALSE, FALSE, {0,0,0}},
- {"springgreen", 0, 255, 127, FALSE, FALSE, FALSE, {0,0,0}},
- {"steelblue", 70, 130, 180, FALSE, FALSE, FALSE, {0,0,0}},
- {"tan", 210, 180, 140, FALSE, FALSE, FALSE, {0,0,0}},
- {"teal", 0, 128, 128, FALSE, FALSE, FALSE, {0,0,0}},
- {"thistle", 216, 191, 216, FALSE, FALSE, FALSE, {0,0,0}},
- {"tomato", 255, 99, 71, FALSE, FALSE, FALSE, {0,0,0}},
- {"turquoise", 64, 224, 208, FALSE, FALSE, FALSE, {0,0,0}},
- {"violet", 238, 130, 238, FALSE, FALSE, FALSE, {0,0,0}},
- {"wheat", 245, 222, 179, FALSE, FALSE, FALSE, {0,0,0}},
- {"white", 255, 255, 255, FALSE, FALSE, FALSE, {0,0,0}},
- {"whitesmoke", 245, 245, 245, FALSE, FALSE, FALSE, {0,0,0}},
- {"yellow", 255, 255, 0, FALSE, FALSE, FALSE, {0,0,0}},
- {"yellowgreen", 154, 205, 50, FALSE, FALSE, FALSE, {0,0,0}},
- {"transparent", 255, 255, 255, FALSE, FALSE, TRUE, {0,0,0}}
+ {"aliceblue", 240, 248, 255, 0,},
+ {"antiquewhite", 250, 235, 215, 0},
+ {"aqua", 0, 255, 255, 0},
+ {"aquamarine", 127, 255, 212, 0},
+ {"azure", 240, 255, 255, 0},
+ {"beige", 245, 245, 220, 0},
+ {"bisque", 255, 228, 196, 0},
+ {"black", 0, 0, 0, 0},
+ {"blanchedalmond", 255, 235, 205, 0},
+ {"blue", 0, 0, 255, 0},
+ {"blueviolet", 138, 43, 226, 0},
+ {"brown", 165, 42, 42, 0},
+ {"burlywood", 222, 184, 135, 0},
+ {"cadetblue", 95, 158, 160, 0},
+ {"chartreuse", 127, 255, 0, 0},
+ {"chocolate", 210, 105, 30, 0},
+ {"coral", 255, 127, 80, 0},
+ {"cornflowerblue", 100, 149, 237, 0},
+ {"cornsilk", 255, 248, 220, 0},
+ {"crimson", 220, 20, 60, 0},
+ {"cyan", 0, 255, 255, 0},
+ {"darkblue", 0, 0, 139, 0},
+ {"darkcyan", 0, 139, 139, 0},
+ {"darkgoldenrod", 184, 134, 11, 0},
+ {"darkgray", 169, 169, 169, 0},
+ {"darkgreen", 0, 100, 0, 0},
+ {"darkgrey", 169, 169, 169, 0},
+ {"darkkhaki", 189, 183, 107, 0},
+ {"darkmagenta", 139, 0, 139, 0},
+ {"darkolivegreen", 85, 107, 47, 0},
+ {"darkorange", 255, 140, 0, 0},
+ {"darkorchid", 153, 50, 204, 0},
+ {"darkred", 139, 0, 0, 0},
+ {"darksalmon", 233, 150, 122, 0},
+ {"darkseagreen", 143, 188, 143, 0},
+ {"darkslateblue", 72, 61, 139, 0},
+ {"darkslategray", 47, 79, 79, 0},
+ {"darkslategrey", 47, 79, 79, 0},
+ {"darkturquoise", 0, 206, 209, 0},
+ {"darkviolet", 148, 0, 211, 0},
+ {"deeppink", 255, 20, 147, 0},
+ {"deepskyblue", 0, 191, 255, 0},
+ {"dimgray", 105, 105, 105, 0},
+ {"dimgrey", 105, 105, 105, 0},
+ {"dodgerblue", 30, 144, 255, 0},
+ {"firebrick", 178, 34, 34, 0},
+ {"floralwhite", 255, 250, 240, 0},
+ {"forestgreen", 34, 139, 34, 0},
+ {"fuchsia", 255, 0, 255, 0},
+ {"gainsboro", 220, 220, 220, 0},
+ {"ghostwhite", 248, 248, 255, 0},
+ {"gold", 255, 215, 0, 0},
+ {"goldenrod", 218, 165, 32, 0},
+ {"gray", 128, 128, 128, 0},
+ {"grey", 128, 128, 128, 0},
+ {"green", 0, 128, 0, 0},
+ {"greenyellow", 173, 255, 47, 0},
+ {"honeydew", 240, 255, 240, 0},
+ {"hotpink", 255, 105, 180, 0},
+ {"indianred", 205, 92, 92, 0},
+ {"indigo", 75, 0, 130, 0},
+ {"ivory", 255, 255, 240, 0},
+ {"khaki", 240, 230, 140, 0},
+ {"lavender", 230, 230, 250, 0},
+ {"lavenderblush", 255, 240, 245, 0},
+ {"lawngreen", 124, 252, 0, 0},
+ {"lemonchiffon", 255, 250, 205, 0},
+ {"lightblue", 173, 216, 230, 0},
+ {"lightcoral", 240, 128, 128, 0},
+ {"lightcyan", 224, 255, 255, 0},
+ {"lightgoldenrodyellow", 250, 250, 210, 0},
+ {"lightgray", 211, 211, 211, 0},
+ {"lightgreen", 144, 238, 144, 0},
+ {"lightgrey", 211, 211, 211, 0},
+ {"lightpink", 255, 182, 193, 0},
+ {"lightsalmon", 255, 160, 122, 0},
+ {"lightseagreen", 32, 178, 170, 0},
+ {"lightskyblue", 135, 206, 250, 0},
+ {"lightslategray", 119, 136, 153, 0},
+ {"lightslategrey", 119, 136, 153, 0},
+ {"lightsteelblue", 176, 196, 222, 0},
+ {"lightyellow", 255, 255, 224, 0},
+ {"lime", 0, 255, 0, 0},
+ {"limegreen", 50, 205, 50, 0},
+ {"linen", 250, 240, 230, 0},
+ {"magenta", 255, 0, 255, 0},
+ {"maroon", 128, 0, 0, 0},
+ {"mediumaquamarine", 102, 205, 170, 0},
+ {"mediumblue", 0, 0, 205, 0},
+ {"mediumorchid", 186, 85, 211, 0},
+ {"mediumpurple", 147, 112, 219, 0},
+ {"mediumseagreen", 60, 179, 113, 0},
+ {"mediumslateblue", 123, 104, 238, 0},
+ {"mediumspringgreen", 0, 250, 154, 0},
+ {"mediumturquoise", 72, 209, 204, 0},
+ {"mediumvioletred", 199, 21, 133, 0},
+ {"midnightblue", 25, 25, 112, 0},
+ {"mintcream", 245, 255, 250, 0},
+ {"mistyrose", 255, 228, 225, 0},
+ {"moccasin", 255, 228, 181, 0},
+ {"navajowhite", 255, 222, 173, 0},
+ {"navy", 0, 0, 128, 0},
+ {"oldlace", 253, 245, 230, 0},
+ {"olive", 128, 128, 0, 0},
+ {"olivedrab", 107, 142, 35, 0},
+ {"orange", 255, 165, 0, 0},
+ {"orangered", 255, 69, 0, 0},
+ {"orchid", 218, 112, 214, 0},
+ {"palegoldenrod", 238, 232, 170, 0},
+ {"palegreen", 152, 251, 152, 0},
+ {"paleturquoise", 175, 238, 238, 0},
+ {"palevioletred", 219, 112, 147, 0},
+ {"papayawhip", 255, 239, 213, 0},
+ {"peachpuff", 255, 218, 185, 0},
+ {"peru", 205, 133, 63, 0},
+ {"pink", 255, 192, 203, 0},
+ {"plum", 221, 160, 221, 0},
+ {"powderblue", 176, 224, 230, 0},
+ {"purple", 128, 0, 128, 0},
+ {"red", 255, 0, 0, 0},
+ {"rosybrown", 188, 143, 143, 0},
+ {"royalblue", 65, 105, 225, 0},
+ {"saddlebrown", 139, 69, 19, 0},
+ {"salmon", 250, 128, 114, 0},
+ {"sandybrown", 244, 164, 96, 0},
+ {"seagreen", 46, 139, 87, 0},
+ {"seashell", 255, 245, 238, 0},
+ {"sienna", 160, 82, 45, 0},
+ {"silver", 192, 192, 192, 0},
+ {"skyblue", 135, 206, 235, 0},
+ {"slateblue", 106, 90, 205, 0},
+ {"slategray", 112, 128, 144, 0},
+ {"slategrey", 112, 128, 144, 0},
+ {"snow", 255, 250, 250, 0},
+ {"springgreen", 0, 255, 127, 0},
+ {"steelblue", 70, 130, 180, 0},
+ {"tan", 210, 180, 140, 0},
+ {"teal", 0, 128, 128, 0},
+ {"thistle", 216, 191, 216, 0},
+ {"tomato", 255, 99, 71, 0},
+ {"turquoise", 64, 224, 208, 0},
+ {"violet", 238, 130, 238, 0},
+ {"wheat", 245, 222, 179, 0},
+ {"white", 255, 255, 255, 0},
+ {"whitesmoke", 245, 245, 245, 0,},
+ {"yellow", 255, 255, 0, 0,},
+ {"yellowgreen", 154, 205, 50, 0,},
+ {"transparent", 255, 255, 255, 0, 0, 1}
};
/**
+ * cr_rgb_new:
+ *
*The default constructor of #CRRgb.
- *@return the newly built instance of #CRRgb
+ *
+ *Returns the newly built instance of #CRRgb
*/
CRRgb *
cr_rgb_new (void)
{
- CRRgb *result = (CRRgb *)g_try_malloc (sizeof (CRRgb));
+ CRRgb *result = NULL;
+
+ result = g_try_malloc (sizeof (CRRgb));
if (result == NULL) {
cr_utils_trace_info ("No more memory");
@@ -199,13 +204,16 @@ cr_rgb_new (void)
}
/**
- *A constructor of #CRRgb.
- *@param a_red the red component of the color.
- *@param a_green the green component of the color.
- *@param a_blue the blue component of the color.
- *@param a_unit the unit of the rgb values.
+ * cr_rgb_new_with_vals:
+ *@a_red: the red component of the color.
+ *@a_green: the green component of the color.
+ *@a_blue: the blue component of the color.
+ *@a_unit: the unit of the rgb values.
*(either percentage or integer values)
- *@return the newly built instance of #CRRgb.
+ *
+ *A constructor of #CRRgb.
+ *
+ *Returns the newly built instance of #CRRgb.
*/
CRRgb *
cr_rgb_new_with_vals (gulong a_red, gulong a_green,
@@ -226,16 +234,21 @@ cr_rgb_new_with_vals (gulong a_red, gulong a_green,
}
/**
+ * cr_rgb_to_string:
+ *@a_this: the instance of #CRRgb to serialize.
+ *
*Serializes the rgb into a zero terminated string.
- *@param a_this the instance of #CRRgb to serialize.
- *@return the zero terminated string containing the serialized
+ *
+ *Returns the zero terminated string containing the serialized
*rgb. MUST BE FREED by the caller using g_free().
*/
guchar *
-cr_rgb_to_string (CRRgb * a_this)
+cr_rgb_to_string (CRRgb const * a_this)
{
- gchar *result = NULL;
- GString *str_buf = (GString *)g_string_new (NULL);
+ guchar *result = NULL;
+ GString *str_buf = NULL;
+
+ str_buf = g_string_new (NULL);
g_return_val_if_fail (str_buf, NULL);
if (a_this->is_percentage == 1) {
@@ -263,18 +276,20 @@ cr_rgb_to_string (CRRgb * a_this)
g_string_free (str_buf, FALSE);
}
- return (guchar *)result;
+ return result;
}
/**
+ * cr_rgb_dump:
+ *@a_this: the "this pointer" of
+ *the current instance of #CRRgb.
+ *@a_fp: the destination file pointer.
+ *
*Dumps the current instance of #CRRgb
*to a file.
- *@param a_this the "this pointer" of
- *the current instance of #CRRgb.
- *@param a_fp the destination file pointer.
*/
void
-cr_rgb_dump (CRRgb * a_this, FILE * a_fp)
+cr_rgb_dump (CRRgb const * a_this, FILE * a_fp)
{
guchar *str = NULL;
@@ -290,10 +305,13 @@ cr_rgb_dump (CRRgb * a_this, FILE * a_fp)
}
/**
+ * cr_rgb_compute_from_percentage:
+ *@a_this: the current instance of #CRRgb
+ *
*If the rgb values are expressed in percentage,
*compute their real value.
- *@param a_this the current instance of #CRRgb
- *@return
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_rgb_compute_from_percentage (CRRgb * a_this)
@@ -310,12 +328,15 @@ cr_rgb_compute_from_percentage (CRRgb * a_this)
}
/**
+ * cr_rgb_set:
+ *@a_this: the current instance of #CRRgb.
+ *@a_red: the red value.
+ *@a_green: the green value.
+ *@a_blue: the blue value.
+ *
*Sets rgb values to the RGB.
- *@param a_this the current instance of #CRRgb.
- *@param a_red the red value.
- *@param a_green the green value.
- *@param a_blue the blue value.
- *@return CR_OK upon successful completion, an error code
+ *
+ *Returns CR_OK upon successful completion, an error code
*otherwise.
*/
enum CRStatus
@@ -340,11 +361,14 @@ cr_rgb_set (CRRgb * a_this, gulong a_red,
}
/**
+ * cr_rgb_set_to_inherit:
+ *@a_this: the current instance of #CRRgb
+ *
*sets the value of the rgb to inherit.
*Look at the css spec from chapter 6.1 to 6.2 to understand
*the meaning of "inherit".
- *@param a_this the current instance of #CRRgb
*
+ * Returns CR_OK upon succesful completion, an error code otherwise.
*/
enum CRStatus
cr_rgb_set_to_inherit (CRRgb *a_this, gboolean a_inherit)
@@ -356,8 +380,15 @@ cr_rgb_set_to_inherit (CRRgb *a_this, gboolean a_inherit)
return CR_OK ;
}
+/**
+ * cr_rgb_is_set_to_inherit:
+ *
+ * @a_this: the current instance of #CRRgb.
+ *
+ * Returns TRUE if the rgb is set to the value "inherit", FALSE otherwise.
+ */
gboolean
-cr_rgb_is_set_to_inherit (CRRgb *a_this)
+cr_rgb_is_set_to_inherit (CRRgb const *a_this)
{
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
@@ -365,15 +396,18 @@ cr_rgb_is_set_to_inherit (CRRgb *a_this)
}
/**
+ * cr_rgb_is_set_to_transparent:
+ *@a_this: the current instance of
+ *#CRRgb
+ *
*Tests if the the rgb is set to the
*value "transparent" or not.
- *@param a_this the current instance of
- *#CRRgb
- *@return TRUE if the rgb has been set to
+ *
+ *Returns TRUE if the rgb has been set to
*transparent, FALSE otherwise.
*/
gboolean
-cr_rgb_is_set_to_transparent (CRRgb *a_this)
+cr_rgb_is_set_to_transparent (CRRgb const *a_this)
{
g_return_val_if_fail (a_this, FALSE) ;
return a_this->is_transparent ;
@@ -381,9 +415,12 @@ cr_rgb_is_set_to_transparent (CRRgb *a_this)
/**
+ * cr_rgb_set_to_transparent:
+ *@a_this: the current instance of #CRRgb
+ *@a_is_transparent: set to transparent or not.
+ *
*Sets the rgb to the "transparent" value (or not)
- *@param a_this the current instance of #CRRgb
- *@param a_is_transparent set to transparent or not.
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_rgb_set_to_transparent (CRRgb *a_this,
@@ -395,13 +432,16 @@ cr_rgb_set_to_transparent (CRRgb *a_this,
}
/**
+ * cr_rgb_set_from_rgb:
+ *@a_this: the current instance of #CRRgb.
+ *@a_rgb: the rgb to "copy"
+ *
*Sets the rgb from an other one.
- *@param a_this the current instance of #CRRgb.
- *@param a_rgb the rgb to "copy"
- *@return CR_OK upon successful completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
-cr_rgb_set_from_rgb (CRRgb * a_this, CRRgb * a_rgb)
+cr_rgb_set_from_rgb (CRRgb * a_this, CRRgb const * a_rgb)
{
g_return_val_if_fail (a_this && a_rgb, CR_BAD_PARAM_ERROR);
@@ -410,6 +450,13 @@ cr_rgb_set_from_rgb (CRRgb * a_this, CRRgb * a_rgb)
return CR_OK;
}
+/**
+ * cr_rgb_set_from_name:
+ * @a_this: the current instance of #CRRgb
+ * @a_color_name: the color name
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
+ */
enum CRStatus
cr_rgb_set_from_name (CRRgb * a_this, const guchar * a_color_name)
{
@@ -418,14 +465,14 @@ cr_rgb_set_from_name (CRRgb * a_this, const guchar * a_color_name)
g_return_val_if_fail (a_this && a_color_name, CR_BAD_PARAM_ERROR);
- for (i = 0; i < sizeof (gv_standard_colors); i++) {
- if (!strcmp ((char *)a_color_name, gv_standard_colors[i].name)) {
+ for (i = 0; i < G_N_ELEMENTS (gv_standard_colors); i++) {
+ if (!strcmp (a_color_name, gv_standard_colors[i].name)) {
cr_rgb_set_from_rgb (a_this, &gv_standard_colors[i]);
break;
}
}
- if (i < sizeof (gv_standard_colors))
+ if (i < G_N_ELEMENTS (gv_standard_colors))
status = CR_OK;
else
status = CR_UNKNOWN_TYPE_ERROR;
@@ -433,6 +480,13 @@ cr_rgb_set_from_name (CRRgb * a_this, const guchar * a_color_name)
return status;
}
+/**
+ * cr_rgb_set_from_hex_str:
+ * @a_this: the current instance of #CRRgb
+ * @a_hex: the hexadecimal value to set.
+ *
+ * Returns CR_OK upon successful completion.
+ */
enum CRStatus
cr_rgb_set_from_hex_str (CRRgb * a_this, const guchar * a_hex)
{
@@ -442,7 +496,7 @@ cr_rgb_set_from_hex_str (CRRgb * a_this, const guchar * a_hex)
g_return_val_if_fail (a_this && a_hex, CR_BAD_PARAM_ERROR);
- if (strlen ((char *)a_hex) == 3) {
+ if (strlen (a_hex) == 3) {
for (i = 0; i < 3; i++) {
if (a_hex[i] >= '0' && a_hex[i] <= '9') {
colors[i] = a_hex[i] - '0';
@@ -457,7 +511,7 @@ cr_rgb_set_from_hex_str (CRRgb * a_this, const guchar * a_hex)
status = CR_UNKNOWN_TYPE_ERROR;
}
}
- } else if (strlen ((char *)a_hex) == 6) {
+ } else if (strlen (a_hex) == 6) {
for (i = 0; i < 6; i++) {
if (a_hex[i] >= '0' && a_hex[i] <= '9') {
colors[i / 2] <<= 4;
@@ -488,15 +542,19 @@ cr_rgb_set_from_hex_str (CRRgb * a_this, const guchar * a_hex)
}
/**
+ * cr_rgb_set_from_term:
+ *@a_this: the instance of #CRRgb to set
+ *@a_value: the terminal from which to set
+ *
*Set the rgb from a terminal symbol
- *@param a_this the instance of #CRRgb to set
- *@param a_value the terminal from which to set
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value)
{
- enum CRStatus status = CR_OK ;
- g_return_val_if_fail (a_this && a_value,
+ enum CRStatus status = CR_OK ;
+ g_return_val_if_fail (a_this && a_value,
CR_BAD_PARAM_ERROR) ;
switch(a_value->type) {
@@ -518,7 +576,7 @@ cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value)
} else {
status = cr_rgb_set_from_name
(a_this,
- (guchar *)a_value->content.str->stryng->str) ;
+ a_value->content.str->stryng->str) ;
}
} else {
cr_utils_trace_info
@@ -531,7 +589,7 @@ cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value)
&& a_value->content.str->stryng->str) {
status = cr_rgb_set_from_hex_str
(a_this,
- (guchar *)a_value->content.str->stryng->str) ;
+ a_value->content.str->stryng->str) ;
} else {
cr_utils_trace_info
("a_value has NULL string value") ;
@@ -544,7 +602,7 @@ cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value)
}
enum CRStatus
-cr_rgb_copy (CRRgb *a_dest, CRRgb*a_src)
+cr_rgb_copy (CRRgb *a_dest, CRRgb const *a_src)
{
g_return_val_if_fail (a_dest && a_src,
CR_BAD_PARAM_ERROR) ;
@@ -554,9 +612,11 @@ cr_rgb_copy (CRRgb *a_dest, CRRgb*a_src)
}
/**
- *Destructor of #CRRgb.
- *@param a_this the "this pointer" of the
+ * cr_rgb_destroy:
+ *@a_this: the "this pointer" of the
*current instance of #CRRgb.
+ *
+ *Destructor of #CRRgb.
*/
void
cr_rgb_destroy (CRRgb * a_this)
@@ -566,13 +626,16 @@ cr_rgb_destroy (CRRgb * a_this)
}
/**
+ * cr_rgb_parse_from_buf:
+ *@a_str: a string that contains a color description
+ *@a_enc: the encoding of a_str
+ *
*Parses a text buffer that contains a rgb color
*
- *@param a_str a string that contains a color description
- *@param a_enc the encoding of a_str
- *@return the parsed color, or NULL in case of error
+ *Returns the parsed color, or NULL in case of error
*/
-CRRgb *cr_rgb_parse_from_buf (const guchar *a_str,
+CRRgb *
+cr_rgb_parse_from_buf (const guchar *a_str,
enum CREncoding a_enc)
{
enum CRStatus status = CR_OK ;
@@ -582,7 +645,7 @@ CRRgb *cr_rgb_parse_from_buf (const guchar *a_str,
g_return_val_if_fail (a_str, NULL);
- parser = cr_parser_new_from_buf ((guchar *)a_str, strlen ((char *)a_str),
+ parser = cr_parser_new_from_buf ((guchar*)a_str, strlen (a_str),
a_enc, FALSE) ;
g_return_val_if_fail (parser, NULL);
@@ -612,6 +675,4 @@ cleanup:
}
return result ;
}
-
-
diff --git a/src/cr-rgb.h b/src/cr-rgb.h
index 50cec94..a127a44 100644
--- a/src/cr-rgb.h
+++ b/src/cr-rgb.h
@@ -39,12 +39,12 @@ struct _CRRgb
*Either NO_UNIT (integer) or
*UNIT_PERCENTAGE (percentage).
*/
- const gchar *name ;
+ const guchar *name ;
glong red ;
glong green ;
glong blue ;
gboolean is_percentage ;
- gboolean inherit ;
+ gboolean inherit ;
gboolean is_transparent ;
CRParsingLocation location ;
} ;
@@ -63,17 +63,17 @@ enum CRStatus cr_rgb_set (CRRgb *a_this, gulong a_red,
gulong a_green, gulong a_blue,
gboolean a_is_percentage) ;
-enum CRStatus cr_rgb_copy (CRRgb *a_dest, CRRgb*a_src) ;
+enum CRStatus cr_rgb_copy (CRRgb *a_dest, CRRgb const *a_src) ;
enum CRStatus cr_rgb_set_to_inherit (CRRgb *a_this, gboolean a_inherit) ;
-gboolean cr_rgb_is_set_to_inherit (CRRgb *a_this) ;
+gboolean cr_rgb_is_set_to_inherit (CRRgb const *a_this) ;
-gboolean cr_rgb_is_set_to_transparent (CRRgb *a_this) ;
+gboolean cr_rgb_is_set_to_transparent (CRRgb const *a_this) ;
enum CRStatus cr_rgb_set_to_transparent (CRRgb *a_this,
gboolean a_is_transparent) ;
-enum CRStatus cr_rgb_set_from_rgb (CRRgb *a_this, CRRgb *a_rgb) ;
+enum CRStatus cr_rgb_set_from_rgb (CRRgb *a_this, CRRgb const *a_rgb) ;
enum CRStatus cr_rgb_set_from_name (CRRgb *a_this, const guchar *a_color_name) ;
@@ -83,9 +83,9 @@ struct _CRTerm;
enum CRStatus cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value);
-guchar * cr_rgb_to_string (CRRgb *a_this) ;
+guchar * cr_rgb_to_string (CRRgb const *a_this) ;
-void cr_rgb_dump (CRRgb *a_this, FILE *a_fp) ;
+void cr_rgb_dump (CRRgb const *a_this, FILE *a_fp) ;
void cr_rgb_destroy (CRRgb *a_this) ;
diff --git a/src/cr-sel-eng.h b/src/cr-sel-eng.h
index 1b025d8..e64d133 100644
--- a/src/cr-sel-eng.h
+++ b/src/cr-sel-eng.h
@@ -30,9 +30,9 @@
#include "cr-style.h"
#include "cr-prop-list.h"
-//#ifdef CROCO_HAVE_LIBXML2
+#ifdef CROCO_HAVE_LIBXML2
#include <libxml/tree.h>
-//#endif
+#endif
diff --git a/src/cr-selector.c b/src/cr-selector.c
index d85b3ef..a3603e3 100644
--- a/src/cr-selector.c
+++ b/src/cr-selector.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -25,16 +25,22 @@
#include "cr-parser.h"
/**
- *Creates a new instance of #CRSelector.
- *@param a_simple_sel the initial simple selector list
+ * cr_selector_new:
+ *
+ *@a_simple_sel: the initial simple selector list
*of the current instance of #CRSelector.
- *@return the newly built instance of #CRSelector, or
+ *
+ *Creates a new instance of #CRSelector.
+ *
+ *Returns the newly built instance of #CRSelector, or
*NULL in case of failure.
*/
CRSelector *
cr_selector_new (CRSimpleSel * a_simple_sel)
{
- CRSelector *result = (CRSelector *)g_try_malloc (sizeof (CRSelector));
+ CRSelector *result = NULL;
+
+ result = g_try_malloc (sizeof (CRSelector));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
@@ -51,8 +57,7 @@ cr_selector_parse_from_buf (const guchar * a_char_buf, enum CREncoding a_enc)
g_return_val_if_fail (a_char_buf, NULL);
- parser = cr_parser_new_from_buf ((guchar*)a_char_buf,
- strlen ((char *)a_char_buf),
+ parser = cr_parser_new_from_buf ((guchar*)a_char_buf, strlen (a_char_buf),
a_enc, FALSE);
g_return_val_if_fail (parser, NULL);
@@ -60,10 +65,14 @@ cr_selector_parse_from_buf (const guchar * a_char_buf, enum CREncoding a_enc)
}
/**
+ * cr_selector_append:
+ *
+ *@a_this: the current instance of #CRSelector.
+ *@a_new: the instance of #CRSelector to be appended.
+ *
*Appends a new instance of #CRSelector to the current selector list.
- *@param a_this the current instance of #CRSelector.
- *@param a_new the instance of #CRSelector to be appended.
- *@return the new list.
+ *
+ *Returns the new list.
*/
CRSelector *
cr_selector_append (CRSelector * a_this, CRSelector * a_new)
@@ -84,10 +93,14 @@ cr_selector_append (CRSelector * a_this, CRSelector * a_new)
}
/**
+ * cr_selector_prepend:
+ *
+ *@a_this: the current instance of #CRSelector list.
+ *@a_new: the instance of #CRSelector.
+ *
*Prepends an element to the #CRSelector list.
- *@param a_this the current instance of #CRSelector list.
- *@param a_new the instance of #CRSelector.
- *@return the new list.
+ *
+ *Returns the new list.
*/
CRSelector *
cr_selector_prepend (CRSelector * a_this, CRSelector * a_new)
@@ -103,10 +116,14 @@ cr_selector_prepend (CRSelector * a_this, CRSelector * a_new)
}
/**
+ * cr_selector_append_simple_sel:
+ *
+ *@a_this: the current instance of #CRSelector.
+ *@a_simple_sel: the simple selector to append.
+ *
*append a simple selector to the current #CRSelector list.
- *@param a_this the current instance of #CRSelector.
- *@param a_simple_sel the simple selector to append.
- *@return the new list or NULL in case of failure.
+ *
+ *Returns the new list or NULL in case of failure.
*/
CRSelector *
cr_selector_append_simple_sel (CRSelector * a_this,
@@ -121,15 +138,16 @@ cr_selector_append_simple_sel (CRSelector * a_this,
}
guchar *
-cr_selector_to_string (CRSelector * a_this)
+cr_selector_to_string (CRSelector const * a_this)
{
guchar *result = NULL;
+ GString *str_buf = NULL;
- GString *str_buf = (GString *)g_string_new (NULL);
+ str_buf = g_string_new (NULL);
g_return_val_if_fail (str_buf, NULL);
if (a_this) {
- CRSelector *cur = NULL;
+ CRSelector const *cur = NULL;
for (cur = a_this; cur; cur = cur->next) {
if (cur->simple_sel) {
@@ -143,7 +161,7 @@ cr_selector_to_string (CRSelector * a_this)
g_string_append (str_buf,
", ");
- g_string_append (str_buf, (gchar *)tmp_str);
+ g_string_append (str_buf, tmp_str);
g_free (tmp_str);
tmp_str = NULL;
@@ -153,7 +171,7 @@ cr_selector_to_string (CRSelector * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -162,12 +180,15 @@ cr_selector_to_string (CRSelector * a_this)
}
/**
+ * cr_selector_dump:
+ *
+ *@a_this: the current instance of #CRSelector.
+ *@a_fp: the destination file.
+ *
*Serializes the current instance of #CRSelector to a file.
- *@param a_this the current instance of #CRSelector.
- *@param a_fp the destination file.
*/
void
-cr_selector_dump (CRSelector * a_this, FILE * a_fp)
+cr_selector_dump (CRSelector const * a_this, FILE * a_fp)
{
guchar *tmp_buf = NULL;
@@ -182,9 +203,12 @@ cr_selector_dump (CRSelector * a_this, FILE * a_fp)
}
/**
+ * cr_selector_ref:
+ *
+ *@a_this: the current instance of #CRSelector.
+ *
*Increments the ref count of the current instance
*of #CRSelector.
- *@param a_this the current instance of #CRSelector.
*/
void
cr_selector_ref (CRSelector * a_this)
@@ -195,12 +219,16 @@ cr_selector_ref (CRSelector * a_this)
}
/**
+ * cr_selector_unref:
+ *
+ *@a_this: the current instance of #CRSelector.
+ *
*Decrements the ref count of the current instance of
*#CRSelector.
*If the ref count reaches zero, the current instance of
*#CRSelector is destroyed.
- *@param a_this the current instance of #CRSelector.
- *@return TRUE if this function destroyed the current instance
+ *
+ *Returns TRUE if this function destroyed the current instance
*of #CRSelector, FALSE otherwise.
*/
gboolean
@@ -221,8 +249,11 @@ cr_selector_unref (CRSelector * a_this)
}
/**
+ * cr_selector_destroy:
+ *
+ *@a_this: the current instance of #CRSelector.
+ *
*Destroys the selector list.
- *@param a_this the current instance of #CRSelector.
*/
void
cr_selector_destroy (CRSelector * a_this)
diff --git a/src/cr-selector.h b/src/cr-selector.h
index 6bf7697..dd6a7f7 100644
--- a/src/cr-selector.h
+++ b/src/cr-selector.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -80,9 +80,9 @@ CRSelector* cr_selector_append_simple_sel (CRSelector *a_this,
CRSelector* cr_selector_prepend (CRSelector *a_this, CRSelector *a_new) ;
-guchar * cr_selector_to_string (CRSelector *a_this) ;
+guchar * cr_selector_to_string (CRSelector const *a_this) ;
-void cr_selector_dump (CRSelector *a_this, FILE *a_fp) ;
+void cr_selector_dump (CRSelector const *a_this, FILE *a_fp) ;
void cr_selector_ref (CRSelector *a_this) ;
diff --git a/src/cr-simple-sel.c b/src/cr-simple-sel.c
index 18dd340..e8d57af 100644
--- a/src/cr-simple-sel.c
+++ b/src/cr-simple-sel.c
@@ -26,14 +26,18 @@
#include "cr-simple-sel.h"
/**
+ * cr_simple_sel_new:
+ *
*The constructor of #CRSimpleSel.
*
- *@return the new instance of #CRSimpleSel.
+ *Returns the new instance of #CRSimpleSel.
*/
CRSimpleSel *
cr_simple_sel_new (void)
{
- CRSimpleSel *result = (CRSimpleSel *)g_try_malloc (sizeof (CRSimpleSel));
+ CRSimpleSel *result = NULL;
+
+ result = g_try_malloc (sizeof (CRSimpleSel));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
@@ -44,11 +48,14 @@ cr_simple_sel_new (void)
}
/**
+ * cr_simple_sel_append_simple_sel:
+ *
*Appends a simpe selector to the current list of simple selector.
*
- *@param a_this the this pointer of the current instance of #CRSimpleSel.
- *@param a_sel the simple selector to append.
- *@return the new list upon successfull completion, an error code otherwise.
+ *@a_this: the this pointer of the current instance of #CRSimpleSel.
+ *@a_sel: the simple selector to append.
+ *
+ *Returns: the new list upon successfull completion, an error code otherwise.
*/
CRSimpleSel *
cr_simple_sel_append_simple_sel (CRSimpleSel * a_this, CRSimpleSel * a_sel)
@@ -69,10 +76,14 @@ cr_simple_sel_append_simple_sel (CRSimpleSel * a_this, CRSimpleSel * a_sel)
}
/**
+ * cr_simple_sel_prepend_simple_sel:
+ *
+ *@a_this: the this pointer of the current instance of #CRSimpleSel.
+ *@a_sel: the simple selector to prepend.
+ *
*Prepends a simple selector to the current list of simple selectors.
- *@param a_this the this pointer of the current instance of #CRSimpleSel.
- *@param a_sel the simple selector to prepend.
- *@return the new list upon successfull completion, an error code otherwise.
+ *
+ *Returns the new list upon successfull completion, an error code otherwise.
*/
CRSimpleSel *
cr_simple_sel_prepend_simple_sel (CRSimpleSel * a_this, CRSimpleSel * a_sel)
@@ -89,19 +100,19 @@ cr_simple_sel_prepend_simple_sel (CRSimpleSel * a_this, CRSimpleSel * a_sel)
}
guchar *
-cr_simple_sel_to_string (CRSimpleSel * a_this)
+cr_simple_sel_to_string (CRSimpleSel const * a_this)
{
GString *str_buf = NULL;
guchar *result = NULL;
- CRSimpleSel *cur = NULL;
+ CRSimpleSel const *cur = NULL;
g_return_val_if_fail (a_this, NULL);
str_buf = g_string_new (NULL);
for (cur = a_this; cur; cur = cur->next) {
if (cur->name) {
- gchar *str = g_strndup (cur->name->stryng->str,
+ guchar *str = g_strndup (cur->name->stryng->str,
cur->name->stryng->len);
if (str) {
@@ -129,8 +140,9 @@ cr_simple_sel_to_string (CRSimpleSel * a_this)
}
if (cur->add_sel) {
+ guchar *tmp_str = NULL;
- gchar *tmp_str = (gchar *)cr_additional_sel_to_string (cur->add_sel);
+ tmp_str = cr_additional_sel_to_string (cur->add_sel);
if (tmp_str) {
g_string_append (str_buf, tmp_str);
g_free (tmp_str);
@@ -140,7 +152,7 @@ cr_simple_sel_to_string (CRSimpleSel * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -150,7 +162,7 @@ cr_simple_sel_to_string (CRSimpleSel * a_this)
guchar *
-cr_simple_sel_one_to_string (CRSimpleSel * a_this)
+cr_simple_sel_one_to_string (CRSimpleSel const * a_this)
{
GString *str_buf = NULL;
guchar *result = NULL;
@@ -159,7 +171,7 @@ cr_simple_sel_one_to_string (CRSimpleSel * a_this)
str_buf = g_string_new (NULL);
if (a_this->name) {
- gchar *str = g_strndup (a_this->name->stryng->str,
+ guchar *str = g_strndup (a_this->name->stryng->str,
a_this->name->stryng->len);
if (str) {
@@ -170,8 +182,9 @@ cr_simple_sel_one_to_string (CRSimpleSel * a_this)
}
if (a_this->add_sel) {
+ guchar *tmp_str = NULL;
- gchar *tmp_str = (gchar *)cr_additional_sel_to_string (a_this->add_sel);
+ tmp_str = cr_additional_sel_to_string (a_this->add_sel);
if (tmp_str) {
g_string_append_printf
(str_buf, "%s", tmp_str);
@@ -181,7 +194,7 @@ cr_simple_sel_one_to_string (CRSimpleSel * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -190,16 +203,18 @@ cr_simple_sel_one_to_string (CRSimpleSel * a_this)
}
/**
+ * cr_simple_sel_dump:
+ *@a_this: the current instance of #CRSimpleSel.
+ *@a_fp: the destination file pointer.
+ *
*Dumps the selector to a file.
*TODO: add the support of unicode in the dump.
*
- *@param a_this the current instance of #CRSimpleSel.
- *@param a_fp the destination file pointer.
- *@return CR_OK upon successfull completion, an error code
+ *Returns CR_OK upon successfull completion, an error code
*otherwise.
*/
enum CRStatus
-cr_simple_sel_dump (CRSimpleSel * a_this, FILE * a_fp)
+cr_simple_sel_dump (CRSimpleSel const * a_this, FILE * a_fp)
{
guchar *tmp_str = NULL;
@@ -218,16 +233,20 @@ cr_simple_sel_dump (CRSimpleSel * a_this, FILE * a_fp)
}
/**
+ * cr_simple_sel_compute_specificity:
+ *
+ *@a_this: the current instance of #CRSimpleSel
+ *
*Computes the selector (combinator separated list of simple selectors)
*as defined in the css2 spec in chapter 6.4.3
- *@param a_this the current instance of #CRSimpleSel
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
cr_simple_sel_compute_specificity (CRSimpleSel * a_this)
{
- CRAdditionalSel *cur_add_sel = NULL;
- CRSimpleSel *cur_sel = NULL;
+ CRAdditionalSel const *cur_add_sel = NULL;
+ CRSimpleSel const *cur_sel = NULL;
gulong a = 0,
b = 0,
c = 0;
@@ -274,10 +293,12 @@ cr_simple_sel_compute_specificity (CRSimpleSel * a_this)
}
/**
+ * cr_simple_sel_destroy:
+ *
+ *@a_this: the this pointer of the current instance of #CRSimpleSel.
+ *
*The destructor of the current instance of
*#CRSimpleSel.
- *@param a_this the this pointer of the current instance of #CRSimpleSel.
- *
*/
void
cr_simple_sel_destroy (CRSimpleSel * a_this)
diff --git a/src/cr-simple-sel.h b/src/cr-simple-sel.h
index 29033af..d8edc00 100644
--- a/src/cr-simple-sel.h
+++ b/src/cr-simple-sel.h
@@ -40,9 +40,9 @@ G_BEGIN_DECLS
enum Combinator
{
NO_COMBINATOR,
- COMB_WS,/*whitesape*/
- COMB_PLUS,
- COMB_GT/*greater than*/
+ COMB_WS,/*whitespace: descendent*/
+ COMB_PLUS,/*'+': preceded by*/
+ COMB_GT/*greater than ('>'): child*/
} ;
enum SimpleSelectorType
@@ -112,13 +112,13 @@ CRSimpleSel * cr_simple_sel_append_simple_sel (CRSimpleSel *a_this,
CRSimpleSel * cr_simple_sel_prepend_simple_sel (CRSimpleSel *a_this,
CRSimpleSel *a_sel) ;
-guchar * cr_simple_sel_to_string (CRSimpleSel *a_this) ;
+guchar * cr_simple_sel_to_string (CRSimpleSel const *a_this) ;
-guchar * cr_simple_sel_one_to_string (CRSimpleSel * a_this) ;
+guchar * cr_simple_sel_one_to_string (CRSimpleSel const * a_this) ;
-enum CRStatus cr_simple_sel_dump (CRSimpleSel *a_this, FILE *a_fp) ;
+enum CRStatus cr_simple_sel_dump (CRSimpleSel const *a_this, FILE *a_fp) ;
-enum CRStatus cr_simple_sel_dump_attr_sel_list (CRSimpleSel *a_this) ;
+enum CRStatus cr_simple_sel_dump_attr_sel_list (CRSimpleSel const *a_this) ;
enum CRStatus cr_simple_sel_compute_specificity (CRSimpleSel *a_this) ;
diff --git a/src/cr-statement.c b/src/cr-statement.c
index 40df498..a1b8259 100644
--- a/src/cr-statement.c
+++ b/src/cr-statement.c
@@ -25,8 +25,6 @@
#include "cr-statement.h"
#include "cr-parser.h"
-#define UNUSED(_param) ((void)(_param))
-
/**
*@file
*Definition of the #CRStatement class.
@@ -38,13 +36,11 @@ static void cr_statement_clear (CRStatement * a_this);
static void
parse_font_face_start_font_face_cb (CRDocHandler * a_this,
- CRParsingLocation * a_location)
+ CRParsingLocation *a_location)
{
CRStatement *stmt = NULL;
enum CRStatus status = CR_OK;
- UNUSED(a_location);
-
stmt = cr_statement_new_at_font_face_rule (NULL, NULL);
g_return_if_fail (stmt);
@@ -86,8 +82,6 @@ parse_font_face_property_cb (CRDocHandler * a_this,
CRStatement *stmt = NULL;
CRStatement **stmtptr = NULL;
- UNUSED(a_important);
-
g_return_if_fail (a_this && a_name);
stmtptr = &stmt;
@@ -144,14 +138,12 @@ static void
parse_page_start_page_cb (CRDocHandler * a_this,
CRString * a_name,
CRString * a_pseudo_page,
- CRParsingLocation * a_location)
+ CRParsingLocation *a_location)
{
CRStatement *stmt = NULL;
enum CRStatus status = CR_OK;
CRString *page_name = NULL, *pseudo_name = NULL ;
- UNUSED(a_location);
-
if (a_name)
page_name = cr_string_dup (a_name) ;
if (a_pseudo_page)
@@ -225,9 +217,6 @@ parse_page_end_page_cb (CRDocHandler * a_this,
CRStatement *stmt = NULL;
CRStatement **stmtptr = NULL;
- UNUSED(a_name);
- UNUSED(a_pseudo_page);
-
stmtptr = &stmt;
status = cr_doc_handler_get_ctxt (a_this, (gpointer *) stmtptr);
g_return_if_fail (status == CR_OK && stmt);
@@ -240,14 +229,12 @@ parse_page_end_page_cb (CRDocHandler * a_this,
static void
parse_at_media_start_media_cb (CRDocHandler * a_this,
GList * a_media_list,
- CRParsingLocation * a_location)
+ CRParsingLocation *a_location)
{
enum CRStatus status = CR_OK;
CRStatement *at_media = NULL;
GList *media_list = NULL;
- UNUSED(a_location);
-
g_return_if_fail (a_this && a_this->priv);
if (a_media_list) {
@@ -380,8 +367,6 @@ parse_at_media_end_media_cb (CRDocHandler * a_this,
CRStatement *at_media = NULL;
CRStatement **at_media_ptr = NULL;
- UNUSED(a_media_list);
-
g_return_if_fail (a_this && a_this->priv);
at_media_ptr = &at_media;
@@ -590,27 +575,32 @@ cr_statement_clear (CRStatement * a_this)
}
/**
+ * cr_statement_ruleset_to_string:
+ *
+ *@a_this: the current instance of #CRStatement
+ *@a_indent: the number of whitespace to use for indentation
+ *
*Serializes the ruleset statement into a string
- *@param a_this the current instance of #CRStatement
- *@param a_indent the number of whitespace to use for indentation
- *@return the newly allocated serialised string. Must be freed
+ *
+ *Returns the newly allocated serialised string. Must be freed
*by the caller, using g_free().
*/
static gchar *
-cr_statement_ruleset_to_string (CRStatement * a_this, glong a_indent)
+cr_statement_ruleset_to_string (CRStatement const * a_this, glong a_indent)
{
+ GString *stringue = NULL;
gchar *tmp_str = NULL,
*result = NULL;
g_return_val_if_fail (a_this && a_this->type == RULESET_STMT, NULL);
- GString *stringue = (GString *)g_string_new (NULL);
+ stringue = g_string_new (NULL);
if (a_this->kind.ruleset->sel_list) {
if (a_indent)
cr_utils_dump_n_chars2 (' ', stringue, a_indent);
- tmp_str = (gchar *)
+ tmp_str =
cr_selector_to_string (a_this->kind.ruleset->
sel_list);
if (tmp_str) {
@@ -621,7 +611,7 @@ cr_statement_ruleset_to_string (CRStatement * a_this, glong a_indent)
}
g_string_append (stringue, " {\n");
if (a_this->kind.ruleset->decl_list) {
- tmp_str = (gchar *)cr_declaration_list_to_string2
+ tmp_str = cr_declaration_list_to_string2
(a_this->kind.ruleset->decl_list,
a_indent + DECLARATION_INDENT_NB, TRUE);
if (tmp_str) {
@@ -648,15 +638,19 @@ cr_statement_ruleset_to_string (CRStatement * a_this, glong a_indent)
/**
- *Serializes a font face rule statement into a string.
- *@param a_this the current instance of #CRStatement to consider
+ * cr_statement_font_face_rule_to_string:
+ *
+ *@a_this: the current instance of #CRStatement to consider
*It must be a font face rule statement.
- *@param a_indent the number of white spaces of indentation.
- *@return the serialized string. Must be deallocated by the caller
+ *@a_indent: the number of white spaces of indentation.
+ *
+ *Serializes a font face rule statement into a string.
+ *
+ *Returns the serialized string. Must be deallocated by the caller
*using g_free().
*/
static gchar *
-cr_statement_font_face_rule_to_string (CRStatement * a_this,
+cr_statement_font_face_rule_to_string (CRStatement const * a_this,
glong a_indent)
{
gchar *result = NULL, *tmp_str = NULL ;
@@ -667,13 +661,13 @@ cr_statement_font_face_rule_to_string (CRStatement * a_this,
NULL);
if (a_this->kind.font_face_rule->decl_list) {
- stringue = (GString *)g_string_new (NULL) ;
+ stringue = g_string_new (NULL) ;
g_return_val_if_fail (stringue, NULL) ;
if (a_indent)
cr_utils_dump_n_chars2 (' ', stringue,
a_indent);
g_string_append (stringue, "@font-face {\n");
- tmp_str = (gchar *)cr_declaration_list_to_string2
+ tmp_str = cr_declaration_list_to_string2
(a_this->kind.font_face_rule->decl_list,
a_indent + DECLARATION_INDENT_NB, TRUE) ;
if (tmp_str) {
@@ -694,13 +688,17 @@ cr_statement_font_face_rule_to_string (CRStatement * a_this,
/**
- *Serialises an @charset statement into a string.
- *@param a_this the statement to serialize.
- *@return the serialized charset statement. Must be
+ * cr_statement_charset_to_string:
+ *
+ *Serialises an \@charset statement into a string.
+ *@a_this: the statement to serialize.
+ *@a_indent: the number of indentation spaces
+ *
+ *Returns the serialized charset statement. Must be
*freed by the caller using g_free().
*/
static gchar *
-cr_statement_charset_to_string (CRStatement *a_this,
+cr_statement_charset_to_string (CRStatement const *a_this,
gulong a_indent)
{
gchar *str = NULL ;
@@ -736,18 +734,22 @@ cr_statement_charset_to_string (CRStatement *a_this,
/**
+ * cr_statement_at_page_rule_to_string:
+ *
*Serialises the at page rule statement into a string
- *@param a_this the current instance of #CRStatement. Must
- *be an "@page" rule statement.
- *@return the serialized string. Must be freed by the caller
+ *@a_this: the current instance of #CRStatement. Must
+ *be an "\@page" rule statement.
+ *
+ *Returns the serialized string. Must be freed by the caller
*/
static gchar *
-cr_statement_at_page_rule_to_string (CRStatement *a_this,
+cr_statement_at_page_rule_to_string (CRStatement const *a_this,
gulong a_indent)
{
+ GString *stringue = NULL;
gchar *result = NULL ;
- GString *stringue = (GString *)g_string_new (NULL) ;
+ stringue = g_string_new (NULL) ;
cr_utils_dump_n_chars2 (' ', stringue, a_indent) ;
g_string_append (stringue, "@page");
@@ -768,7 +770,7 @@ cr_statement_at_page_rule_to_string (CRStatement *a_this,
if (a_this->kind.page_rule->decl_list) {
gchar *str = NULL ;
g_string_append (stringue, " {\n");
- str = (gchar *)cr_declaration_list_to_string2
+ str = cr_declaration_list_to_string2
(a_this->kind.page_rule->decl_list,
a_indent + DECLARATION_INDENT_NB, TRUE) ;
if (str) {
@@ -786,33 +788,33 @@ cr_statement_at_page_rule_to_string (CRStatement *a_this,
/**
- *Serializes an @media statement.
+ *Serializes an \@media statement.
*@param a_this the current instance of #CRStatement
*@param a_indent the number of spaces of indentation.
- *@return the serialized @media statement. Must be freed
+ *@return the serialized \@media statement. Must be freed
*by the caller using g_free().
*/
static gchar *
-cr_statement_media_rule_to_string (CRStatement *a_this,
+cr_statement_media_rule_to_string (CRStatement const *a_this,
gulong a_indent)
{
gchar *str = NULL ;
GString *stringue = NULL ;
- GList *cur = NULL;
+ GList const *cur = NULL;
g_return_val_if_fail (a_this->type == AT_MEDIA_RULE_STMT,
NULL);
if (a_this->kind.media_rule) {
- stringue = (GString *)g_string_new (NULL) ;
+ stringue = g_string_new (NULL) ;
cr_utils_dump_n_chars2 (' ', stringue, a_indent);
g_string_append (stringue, "@media");
for (cur = a_this->kind.media_rule->media_list; cur;
cur = cur->next) {
if (cur->data) {
- gchar *str = cr_string_dup2
- ((CRString *) cur->data);
+ guchar *str = cr_string_dup2
+ ((CRString const *) cur->data);
if (str) {
if (cur->prev) {
@@ -848,11 +850,11 @@ cr_statement_media_rule_to_string (CRStatement *a_this,
static gchar *
-cr_statement_import_rule_to_string (CRStatement *a_this,
+cr_statement_import_rule_to_string (CRStatement const *a_this,
gulong a_indent)
{
GString *stringue = NULL ;
- gchar *str = NULL;
+ guchar *str = NULL;
g_return_val_if_fail (a_this
&& a_this->type == AT_IMPORT_RULE_STMT
@@ -861,7 +863,7 @@ cr_statement_import_rule_to_string (CRStatement *a_this,
if (a_this->kind.import_rule->url
&& a_this->kind.import_rule->url->stryng) {
- stringue = (GString *)g_string_new (NULL) ;
+ stringue = g_string_new (NULL) ;
g_return_val_if_fail (stringue, NULL) ;
str = g_strndup (a_this->kind.import_rule->url->stryng->str,
a_this->kind.import_rule->url->stryng->len);
@@ -876,12 +878,12 @@ cr_statement_import_rule_to_string (CRStatement *a_this,
return NULL;
if (a_this->kind.import_rule->media_list) {
- GList *cur = NULL;
+ GList const *cur = NULL;
for (cur = a_this->kind.import_rule->media_list;
cur; cur = cur->next) {
if (cur->data) {
- CRString *crstr = (CRString *)cur->data;
+ CRString const *crstr = cur->data;
if (cur->prev) {
g_string_append
@@ -914,12 +916,16 @@ cr_statement_import_rule_to_string (CRStatement *a_this,
******************/
/**
+ * cr_statement_does_buf_parses_against_core:
+ *
+ *@a_buf: the buffer to parse.
+ *@a_encoding: the character encoding of a_buf.
+ *
*Tries to parse a buffer and says whether if the content of the buffer
*is a css statement as defined by the "Core CSS Grammar" (chapter 4 of the
*css spec) or not.
- *@param a_buf the buffer to parse.
- *@param a_encoding the character encoding of a_buf.
- *@return TRUE if the buffer parses against the core grammar, false otherwise.
+ *
+ *Returns TRUE if the buffer parses against the core grammar, false otherwise.
*/
gboolean
cr_statement_does_buf_parses_against_core (const guchar * a_buf,
@@ -929,8 +935,7 @@ cr_statement_does_buf_parses_against_core (const guchar * a_buf,
enum CRStatus status = CR_OK;
gboolean result = FALSE;
- parser = cr_parser_new_from_buf ((guchar*)a_buf,
- strlen ((char *)a_buf),
+ parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf),
a_encoding, FALSE);
g_return_val_if_fail (parser, FALSE);
@@ -953,13 +958,17 @@ cr_statement_does_buf_parses_against_core (const guchar * a_buf,
}
/**
+ * cr_statement_parse_from_buf:
+ *
+ *@a_buf: the buffer to parse.
+ *@a_encoding: the character encoding of a_buf.
+ *
*Parses a buffer that contains a css statement and returns
- *an instance of #CRStatement in case of successfull parsing.
- *TODO: at support of "@import" rules.
- *@param a_buf the buffer to parse.
- *@param a_encoding the character encoding of a_buf.
- *@return the newly built instance of #CRStatement in case
- *of successfull parsing, NULL otherwise.
+ *an instance of #CRStatement in case of successful parsing.
+ *TODO: at support of "\@import" rules.
+ *
+ *Returns the newly built instance of #CRStatement in case
+ *of successful parsing, NULL otherwise.
*/
CRStatement *
cr_statement_parse_from_buf (const guchar * a_buf, enum CREncoding a_encoding)
@@ -968,7 +977,7 @@ cr_statement_parse_from_buf (const guchar * a_buf, enum CREncoding a_encoding)
/*
*The strategy of this function is "brute force".
- *It tries to parse all the types of #CRStatement it knows about.
+ *It tries to parse all the types of CRStatement it knows about.
*I could do this a smarter way but I don't have the time now.
*I think I will revisit this when time of performances and
*pull based incremental parsing comes.
@@ -1023,11 +1032,15 @@ cr_statement_parse_from_buf (const guchar * a_buf, enum CREncoding a_encoding)
}
/**
- *Parses a buffer that contains a ruleset statement and instanciates
+ * cr_statement_ruleset_parse_from_buf:
+ *
+ *@a_buf: the buffer to parse.
+ *@a_enc: the character encoding of a_buf.
+ *
+ *Parses a buffer that contains a ruleset statement an instanciates
*a #CRStatement of type RULESET_STMT.
- *@param a_buf the buffer to parse.
- *@param a_enc the character encoding of a_buf.
- *@param the newly built instance of #CRStatement in case of successful parsing,
+ *
+ *Returns the newly built instance of #CRStatement in case of successful parsing,
*NULL otherwise.
*/
CRStatement *
@@ -1042,14 +1055,13 @@ cr_statement_ruleset_parse_from_buf (const guchar * a_buf,
g_return_val_if_fail (a_buf, NULL);
- parser = cr_parser_new_from_buf ((guchar*)a_buf,
- strlen ((char *)a_buf),
+ parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf),
a_enc, FALSE);
g_return_val_if_fail (parser, NULL);
sac_handler = cr_doc_handler_new ();
- g_return_val_if_fail (sac_handler, NULL);
+ g_return_val_if_fail (parser, NULL);
sac_handler->start_selector = parse_ruleset_start_selector_cb;
sac_handler->end_selector = parse_ruleset_end_selector_cb;
@@ -1088,15 +1100,19 @@ cr_statement_ruleset_parse_from_buf (const guchar * a_buf,
}
/**
- *Creates a new instance of #CRStatement of type
- *#CRRulSet.
- *@param a_sel_list the list of #CRSimpleSel (selectors)
+ * cr_statement_new_ruleset:
+ *
+ *@a_sel_list: the list of #CRSimpleSel (selectors)
*the rule applies to.
- *@param a_decl_list the list of instances of #CRDeclaration
+ *@a_decl_list: the list of instances of #CRDeclaration
*that composes the ruleset.
- *@param a_media_types a list of instances of GString that
+ *@a_media_types: a list of instances of GString that
*describe the media list this ruleset applies to.
- *@return the new instance of #CRStatement or NULL if something
+ *
+ *Creates a new instance of #CRStatement of type
+ *#CRRulSet.
+ *
+ *Returns the new instance of #CRStatement or NULL if something
*went wrong.
*/
CRStatement *
@@ -1105,6 +1121,8 @@ cr_statement_new_ruleset (CRStyleSheet * a_sheet,
CRDeclaration * a_decl_list,
CRStatement * a_parent_media_rule)
{
+ CRStatement *result = NULL;
+
g_return_val_if_fail (a_sel_list, NULL);
if (a_parent_media_rule) {
@@ -1115,7 +1133,7 @@ cr_statement_new_ruleset (CRStyleSheet * a_sheet,
NULL);
}
- CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement));
+ result = g_try_malloc (sizeof (CRStatement));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -1124,7 +1142,7 @@ cr_statement_new_ruleset (CRStyleSheet * a_sheet,
memset (result, 0, sizeof (CRStatement));
result->type = RULESET_STMT;
- result->kind.ruleset = (CRRuleSet *)g_try_malloc (sizeof (CRRuleSet));
+ result->kind.ruleset = g_try_malloc (sizeof (CRRuleSet));
if (!result->kind.ruleset) {
cr_utils_trace_info ("Out of memory");
@@ -1153,11 +1171,15 @@ cr_statement_new_ruleset (CRStyleSheet * a_sheet,
}
/**
- *Parses a buffer that contains an "@media" declaration
- *and builds an @media css statement.
- *@param a_buf the input to parse.
- *@param a_enc the encoding of the buffer.
- *@return the @media statement, or NULL if the buffer could not
+ * cr_statement_at_media_rule_parse_from_buf:
+ *
+ *@a_buf: the input to parse.
+ *@a_enc: the encoding of the buffer.
+ *
+ *Parses a buffer that contains an "\@media" declaration
+ *and builds an \@media css statement.
+ *
+ *Returns the \@media statement, or NULL if the buffer could not
*be successfully parsed.
*/
CRStatement *
@@ -1170,8 +1192,7 @@ cr_statement_at_media_rule_parse_from_buf (const guchar * a_buf,
CRDocHandler *sac_handler = NULL;
enum CRStatus status = CR_OK;
- parser = cr_parser_new_from_buf ((guchar*)a_buf,
- strlen ((char *)a_buf),
+ parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf),
a_enc, FALSE);
if (!parser) {
cr_utils_trace_info ("Instanciation of the parser failed");
@@ -1227,22 +1248,27 @@ cr_statement_at_media_rule_parse_from_buf (const guchar * a_buf,
}
/**
+ * cr_statement_new_at_media_rule:
+ *
+ *@a_ruleset: the ruleset statements contained
+ *in the \@media rule.
+ *@a_media: the media string list. A list of GString pointers.
+ *
*Instanciates an instance of #CRStatement of type
- *AT_MEDIA_RULE_STMT (@media ruleset).
- *@param a_ruleset the ruleset statements contained
- *in the @media rule.
- *@param a_media, the media string list. A list of GString pointers.
+ *AT_MEDIA_RULE_STMT (\@media ruleset).
+ *
*/
CRStatement *
cr_statement_new_at_media_rule (CRStyleSheet * a_sheet,
CRStatement * a_rulesets, GList * a_media)
{
- CRStatement *cur = NULL;
+ CRStatement *result = NULL,
+ *cur = NULL;
if (a_rulesets)
g_return_val_if_fail (a_rulesets->type == RULESET_STMT, NULL);
- CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement));
+ result = g_try_malloc (sizeof (CRStatement));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -1252,7 +1278,7 @@ cr_statement_new_at_media_rule (CRStyleSheet * a_sheet,
memset (result, 0, sizeof (CRStatement));
result->type = AT_MEDIA_RULE_STMT;
- result->kind.media_rule = (CRAtMediaRule *)g_try_malloc (sizeof (CRAtMediaRule));
+ result->kind.media_rule = g_try_malloc (sizeof (CRAtMediaRule));
if (!result->kind.media_rule) {
cr_utils_trace_info ("Out of memory");
g_free (result);
@@ -1282,12 +1308,16 @@ cr_statement_new_at_media_rule (CRStyleSheet * a_sheet,
}
/**
+ * cr_statement_new_at_import_rule:
+ *
+ *@a_url: the url to connect to the get the file
+ *to be imported.
+ *@a_sheet: the imported parsed stylesheet.
+ *
*Creates a new instance of #CRStatment of type
*#CRAtImportRule.
- *@param a_url the url to connect to the get the file
- *to be imported.
- *@param a_sheet the imported parsed stylesheet.
- *@return the newly built instance of #CRStatement.
+ *
+ *Returns the newly built instance of #CRStatement.
*/
CRStatement *
cr_statement_new_at_import_rule (CRStyleSheet * a_container_sheet,
@@ -1295,7 +1325,9 @@ cr_statement_new_at_import_rule (CRStyleSheet * a_container_sheet,
GList * a_media_list,
CRStyleSheet * a_imported_sheet)
{
- CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement));
+ CRStatement *result = NULL;
+
+ result = g_try_malloc (sizeof (CRStatement));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -1305,7 +1337,7 @@ cr_statement_new_at_import_rule (CRStyleSheet * a_container_sheet,
memset (result, 0, sizeof (CRStatement));
result->type = AT_IMPORT_RULE_STMT;
- result->kind.import_rule = (CRAtImportRule *)g_try_malloc (sizeof (CRAtImportRule));
+ result->kind.import_rule = g_try_malloc (sizeof (CRAtImportRule));
if (!result->kind.import_rule) {
cr_utils_trace_info ("Out of memory");
@@ -1324,12 +1356,16 @@ cr_statement_new_at_import_rule (CRStyleSheet * a_container_sheet,
}
/**
- *Parses a buffer that contains an "@import" rule and
+ * cr_statement_at_import_rule_parse_from_buf:
+ *
+ *@a_buf: the buffer to parse.
+ *@a_encoding: the encoding of a_buf.
+ *
+ *Parses a buffer that contains an "\@import" rule and
*instanciate a #CRStatement of type AT_IMPORT_RULE_STMT
- *@param a_buf the buffer to parse.
- *@param a_encoding the encoding of a_buf.
- *@return the newly built instance of #CRStatement in case of
- *a successfull parsing, NULL otherwise.
+ *
+ *Returns the newly built instance of #CRStatement in case of
+ *a successful parsing, NULL otherwise.
*/
CRStatement *
cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf,
@@ -1340,10 +1376,9 @@ cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf,
CRStatement *result = NULL;
GList *media_list = NULL;
CRString *import_string = NULL;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
- parser = cr_parser_new_from_buf ((guchar*)a_buf,
- strlen ((char *)a_buf),
+ parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf),
a_encoding, FALSE);
if (!parser) {
cr_utils_trace_info ("Instanciation of parser failed.");
@@ -1397,13 +1432,17 @@ cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf,
}
/**
- *Creates a new instance of #CRStatement of type
- *#CRAtPageRule.
- *@param a_decl_list a list of instances of #CRDeclarations
+ * cr_statement_new_at_page_rule:
+ *
+ *@a_decl_list: a list of instances of #CRDeclarations
*which is actually the list of declarations that applies to
*this page rule.
- *@param a_selector the page rule selector.
- *@return the newly built instance of #CRStatement or NULL
+ *@a_selector: the page rule selector.
+ *
+ *Creates a new instance of #CRStatement of type
+ *#CRAtPageRule.
+ *
+ *Returns the newly built instance of #CRStatement or NULL
*in case of error.
*/
CRStatement *
@@ -1411,7 +1450,9 @@ cr_statement_new_at_page_rule (CRStyleSheet * a_sheet,
CRDeclaration * a_decl_list,
CRString * a_name, CRString * a_pseudo)
{
- CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement));
+ CRStatement *result = NULL;
+
+ result = g_try_malloc (sizeof (CRStatement));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -1421,7 +1462,7 @@ cr_statement_new_at_page_rule (CRStyleSheet * a_sheet,
memset (result, 0, sizeof (CRStatement));
result->type = AT_PAGE_RULE_STMT;
- result->kind.page_rule = (CRAtPageRule *)g_try_malloc (sizeof (CRAtPageRule));
+ result->kind.page_rule = g_try_malloc (sizeof (CRAtPageRule));
if (!result->kind.page_rule) {
cr_utils_trace_info ("Out of memory");
@@ -1443,11 +1484,15 @@ cr_statement_new_at_page_rule (CRStyleSheet * a_sheet,
}
/**
- *Parses a buffer that contains an "@page" production and,
+ * cr_statement_at_page_rule_parse_from_buf:
+ *
+ *@a_buf: the character buffer to parse.
+ *@a_encoding: the character encoding of a_buf.
+ *
+ *Parses a buffer that contains an "\@page" production and,
*if the parsing succeeds, builds the page statement.
- *@param a_buf the character buffer to parse.
- *@param a_encoding the character encoding of a_buf.
- *@return the newly built at page statement in case of successfull parsing,
+ *
+ *Returns the newly built at page statement in case of successful parsing,
*NULL otherwise.
*/
CRStatement *
@@ -1455,14 +1500,14 @@ cr_statement_at_page_rule_parse_from_buf (const guchar * a_buf,
enum CREncoding a_encoding)
{
enum CRStatus status = CR_OK;
+ CRParser *parser = NULL;
CRDocHandler *sac_handler = NULL;
CRStatement *result = NULL;
CRStatement **resultptr = NULL;
g_return_val_if_fail (a_buf, NULL);
- CRParser *parser = cr_parser_new_from_buf ((guchar*)a_buf,
- strlen ((char *)a_buf),
+ parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf),
a_encoding, FALSE);
if (!parser) {
cr_utils_trace_info ("Instanciation of the parser failed.");
@@ -1512,21 +1557,27 @@ cr_statement_at_page_rule_parse_from_buf (const guchar * a_buf,
}
/**
- *Creates a new instance of #CRStatement of type
- *#CRAtCharsetRule.
- *@param a_charset the string representing the charset.
+ * cr_statement_new_at_charset_rule:
+ *
+ *@a_charset: the string representing the charset.
*Note that the newly built instance of #CRStatement becomes
*the owner of a_charset. The caller must not free a_charset !!!.
- *@return the newly built instance of #CRStatement or NULL
+ *
+ *Creates a new instance of #CRStatement of type
+ *#CRAtCharsetRule.
+ *
+ *Returns the newly built instance of #CRStatement or NULL
*if an error arises.
*/
CRStatement *
cr_statement_new_at_charset_rule (CRStyleSheet * a_sheet,
CRString * a_charset)
{
+ CRStatement *result = NULL;
+
g_return_val_if_fail (a_charset, NULL);
- CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement));
+ result = g_try_malloc (sizeof (CRStatement));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -1536,7 +1587,7 @@ cr_statement_new_at_charset_rule (CRStyleSheet * a_sheet,
memset (result, 0, sizeof (CRStatement));
result->type = AT_CHARSET_RULE_STMT;
- result->kind.charset_rule = (CRAtCharsetRule *)g_try_malloc (sizeof (CRAtCharsetRule));
+ result->kind.charset_rule = g_try_malloc (sizeof (CRAtCharsetRule));
if (!result->kind.charset_rule) {
cr_utils_trace_info ("Out of memory");
@@ -1551,24 +1602,28 @@ cr_statement_new_at_charset_rule (CRStyleSheet * a_sheet,
}
/**
- *Parses a buffer that contains an '@charset' rule and
+ * cr_statement_at_charset_rule_parse_from_buf:
+ *
+ *@a_buf: the buffer to parse.
+ *@a_encoding: the character encoding of the buffer.
+ *
+ *Parses a buffer that contains an '\@charset' rule and
*creates an instance of #CRStatement of type AT_CHARSET_RULE_STMT.
- *@param a_buf the buffer to parse.
- *@param the character encoding of the buffer.
- *@return the newly built instance of #CRStatement.
+ *
+ *Returns the newly built instance of #CRStatement.
*/
CRStatement *
cr_statement_at_charset_rule_parse_from_buf (const guchar * a_buf,
enum CREncoding a_encoding)
{
enum CRStatus status = CR_OK;
+ CRParser *parser = NULL;
CRStatement *result = NULL;
CRString *charset = NULL;
g_return_val_if_fail (a_buf, NULL);
- CRParser *parser = cr_parser_new_from_buf ((guchar*)a_buf,
- strlen ((char *)a_buf),
+ parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf),
a_encoding, FALSE);
if (!parser) {
cr_utils_trace_info ("Instanciation of the parser failed.");
@@ -1601,16 +1656,22 @@ cr_statement_at_charset_rule_parse_from_buf (const guchar * a_buf,
}
/**
- *Creates an instance of #CRStatement of type #CRAtFontFaceRule.
- *@param a_font_decls a list of instances of #CRDeclaration. Each declaration
+ * cr_statement_new_at_font_face_rule:
+ *
+ *@a_font_decls: a list of instances of #CRDeclaration. Each declaration
*is actually a font declaration.
- *@return the newly built instance of #CRStatement.
+ *
+ *Creates an instance of #CRStatement of type #CRAtFontFaceRule.
+ *
+ *Returns the newly built instance of #CRStatement.
*/
CRStatement *
cr_statement_new_at_font_face_rule (CRStyleSheet * a_sheet,
CRDeclaration * a_font_decls)
{
- CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement));
+ CRStatement *result = NULL;
+
+ result = g_try_malloc (sizeof (CRStatement));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -1619,7 +1680,7 @@ cr_statement_new_at_font_face_rule (CRStyleSheet * a_sheet,
memset (result, 0, sizeof (CRStatement));
result->type = AT_FONT_FACE_RULE_STMT;
- result->kind.font_face_rule = (CRAtFontFaceRule *)g_try_malloc
+ result->kind.font_face_rule = g_try_malloc
(sizeof (CRAtFontFaceRule));
if (!result->kind.font_face_rule) {
@@ -1637,11 +1698,16 @@ cr_statement_new_at_font_face_rule (CRStyleSheet * a_sheet,
}
/**
- *Parses a buffer that contains an "@font-face" rule and builds
+ * cr_statement_font_face_rule_parse_from_buf:
+ *
+ *
+ *@a_buf: the buffer to parse.
+ *@a_encoding: the character encoding of a_buf.
+ *
+ *Parses a buffer that contains an "\@font-face" rule and builds
*an instance of #CRStatement of type AT_FONT_FACE_RULE_STMT out of it.
- *@param a_buf the buffer to parse.
- *@param a_encoding the character encoding of a_buf.
- *@return the newly built instance of #CRStatement in case of successufull
+ *
+ *Returns the newly built instance of #CRStatement in case of successufull
*parsing, NULL otherwise.
*/
CRStatement *
@@ -1650,12 +1716,11 @@ cr_statement_font_face_rule_parse_from_buf (const guchar * a_buf,
{
CRStatement *result = NULL;
CRStatement **resultptr = NULL;
+ CRParser *parser = NULL;
CRDocHandler *sac_handler = NULL;
enum CRStatus status = CR_OK;
- CRParser *parser = (CRParser *)cr_parser_new_from_buf (
- (guchar*)a_buf,
- strlen ((char *)a_buf),
+ parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf),
a_encoding, FALSE);
if (!parser)
goto cleanup;
@@ -1709,10 +1774,14 @@ cr_statement_font_face_rule_parse_from_buf (const guchar * a_buf,
}
/**
+ * cr_statement_set_parent_sheet:
+ *
+ *@a_this: the current instance of #CRStatement.
+ *@a_sheet: the sheet that contains the current statement.
+ *
*Sets the container stylesheet.
- *@param a_this the current instance of #CRStatement.
- *@param a_sheet the sheet that contains the current statement.
- *@return CR_OK upon successfull completion, an errror code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_set_parent_sheet (CRStatement * a_this, CRStyleSheet * a_sheet)
@@ -1723,10 +1792,14 @@ cr_statement_set_parent_sheet (CRStatement * a_this, CRStyleSheet * a_sheet)
}
/**
+ * cr_statement_get_parent_sheet:
+ *
+ *@a_this: the current #CRStatement.
+ *@a_sheet: out parameter. A pointer to the sheets that
+ *
*Gets the sheets that contains the current statement.
- *@param a_this the current #CRStatement.
- *@param a_sheet out parameter. A pointer to the sheets that
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_get_parent_sheet (CRStatement * a_this, CRStyleSheet ** a_sheet)
@@ -1737,10 +1810,14 @@ cr_statement_get_parent_sheet (CRStatement * a_this, CRStyleSheet ** a_sheet)
}
/**
+ * cr_statement_append:
+ *
+ *@a_this: the current instance of the statement list.
+ *@a_new: a_new the new instance of #CRStatement to append.
+ *
*Appends a new statement to the statement list.
- *@param a_this the current instance of the statement list.
- *@param a_this a_new the new instance of #CRStatement to append.
- *@return the new list statement list, or NULL in cas of failure.
+ *
+ *Returns the new list statement list, or NULL in cas of failure.
*/
CRStatement *
cr_statement_append (CRStatement * a_this, CRStatement * a_new)
@@ -1763,11 +1840,15 @@ cr_statement_append (CRStatement * a_this, CRStatement * a_new)
}
/**
+ * cr_statement_prepend:
+ *
+ *@a_this: the current instance of #CRStatement.
+ *@a_new: the new statement to prepend.
+ *
*Prepends the an instance of #CRStatement to
*the current statement list.
- *@param a_this the current instance of #CRStatement.
- *@param a_new the new statement to prepend.
- *@return the new list with the new statement prepended,
+ *
+ *Returns the new list with the new statement prepended,
*or NULL in case of an error.
*/
CRStatement *
@@ -1790,10 +1871,14 @@ cr_statement_prepend (CRStatement * a_this, CRStatement * a_new)
}
/**
+ * cr_statement_unlink:
+ *
+ *@a_this: the current statements list.
+ *@a_to_unlink: the statement to unlink from the list.
+ *
*Unlinks a statement from the statements list.
- *@param a_this the current statements list.
- *@param a_to_unlink the statement to unlink from the list.
- *@return the new list where a_to_unlink has been unlinked
+ *
+ *Returns the new list where a_to_unlink has been unlinked
*from, or NULL in case of error.
*/
CRStatement *
@@ -1837,14 +1922,18 @@ cr_statement_unlink (CRStatement * a_stmt)
}
/**
- *Return the number of rules in the statement list;
- *@param a_this the current instance of #CRStatement.
- *@return number of rules in the statement list.
+ * cr_statement_nr_rules:
+ *
+ *@a_this: the current instance of #CRStatement.
+ *
+ *Gets the number of rules in the statement list;
+ *
+ *Returns number of rules in the statement list.
*/
gint
-cr_statement_nr_rules (CRStatement * a_this)
+cr_statement_nr_rules (CRStatement const * a_this)
{
- CRStatement *cur = NULL;
+ CRStatement const *cur = NULL;
int nr = 0;
g_return_val_if_fail (a_this, -1);
@@ -1855,10 +1944,14 @@ cr_statement_nr_rules (CRStatement * a_this)
}
/**
+ * cr_statement_get_from_list:
+ *
+ *@a_this: the current instance of #CRStatement.
+ *@itemnr: the index into the statement list.
+ *
*Use an index to get a CRStatement from the statement list.
- *@param a_this the current instance of #CRStatement.
- *@param itemnr the index into the statement list.
- *@return CRStatement at position itemnr, if itemnr > number of statements - 1,
+ *
+ *Returns CRStatement at position itemnr, if itemnr > number of statements - 1,
*it will return NULL.
*/
CRStatement *
@@ -1876,13 +1969,17 @@ cr_statement_get_from_list (CRStatement * a_this, int itemnr)
}
/**
- *Sets a selector list to a ruleset statement.
- *@param a_this the current ruleset statement.
- *@param a_sel_list the selector list to set. Note
+ * cr_statement_ruleset_set_sel_list:
+ *
+ *@a_this: the current ruleset statement.
+ *@a_sel_list: the selector list to set. Note
*that this function increments the ref count of a_sel_list.
*The sel list will be destroyed at the destruction of the
*current instance of #CRStatement.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Sets a selector list to a ruleset statement.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_ruleset_set_sel_list (CRStatement * a_this,
@@ -1903,12 +2000,16 @@ cr_statement_ruleset_set_sel_list (CRStatement * a_this,
}
/**
+ * cr_statement_ruleset_get_declarations:
+ *
+ *@a_this: the current instance of #CRStatement.
+ *@a_decl_list: out parameter. A pointer to the the returned
+ *list of declaration. Must not be NULL.
+ *
*Gets a pointer to the list of declaration contained
*in the ruleset statement.
- *@param a_this the current instance of #CRStatement.
- *@a_decl_list out parameter. A pointer to the the returned
- *list of declaration. Must not be NULL.
- *@return CR_OK upon successfull completion, an error code if something
+ *
+ *Returns CR_OK upon successful completion, an error code if something
*bad happened.
*/
enum CRStatus
@@ -1926,15 +2027,19 @@ cr_statement_ruleset_get_declarations (CRStatement * a_this,
}
/**
+ * cr_statement_ruleset_get_sel_list:
+ *
+ *@a_this: the current ruleset statement.
+ *@a_list: out parameter. The returned selector list,
+ *if and only if the function returned CR_OK.
+ *
*Gets a pointer to the selector list contained in
*the current ruleset statement.
- *@param a_this the current ruleset statement.
- *@param a_list out parameter. The returned selector list,
- *if and only if the function returned CR_OK.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
-cr_statement_ruleset_get_sel_list (CRStatement * a_this, CRSelector ** a_list)
+cr_statement_ruleset_get_sel_list (CRStatement const * a_this, CRSelector ** a_list)
{
g_return_val_if_fail (a_this && a_this->type == RULESET_STMT
&& a_this->kind.ruleset, CR_BAD_PARAM_ERROR);
@@ -1945,11 +2050,15 @@ cr_statement_ruleset_get_sel_list (CRStatement * a_this, CRSelector ** a_list)
}
/**
- *Sets a declaration list to the current ruleset statement.
- *@param a_this the current ruleset statement.
- *@param a_list the declaration list to be added to the current
+ * cr_statement_ruleset_set_decl_list:
+ *
+ *@a_this: the current ruleset statement.
+ *@a_list: the declaration list to be added to the current
*ruleset statement.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Sets a declaration list to the current ruleset statement.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_ruleset_set_decl_list (CRStatement * a_this,
@@ -1971,11 +2080,15 @@ cr_statement_ruleset_set_decl_list (CRStatement * a_this,
}
/**
+ * cr_statement_ruleset_append_decl2:
+ *
+ *@a_this: the current statement.
+ *@a_prop: the property of the declaration.
+ *@a_value: the value of the declaration.
+ *
*Appends a declaration to the current ruleset statement.
- *@param a_this the current statement.
- *@param a_prop the property of the declaration.
- *@param a_value the value of the declaration.
- *@return CR_OK uppon successfull completion, an error code
+ *
+ *Returns CR_OK upon successful completion, an error code
*otherwise.
*/
enum CRStatus
@@ -1998,10 +2111,14 @@ cr_statement_ruleset_append_decl2 (CRStatement * a_this,
}
/**
+ * cr_statement_ruleset_append_decl:
+ *
*Appends a declaration to the current statement.
- *@param a_this the current statement.
- *@param a_declaration the declaration to append.
- *@return CR_OK upon sucessfull completion, an error code
+ *
+ *@a_this: the current statement.
+ *@a_declaration: the declaration to append.
+ *
+ *Returns CR_OK upon sucessful completion, an error code
*otherwise.
*/
enum CRStatus
@@ -2022,13 +2139,16 @@ cr_statement_ruleset_append_decl (CRStatement * a_this,
}
/**
- *Sets a stylesheet to the current @import rule.
- *@param a_this the current @import rule.
- *@param a_sheet the stylesheet. The stylesheet is owned
+ * cr_statement_at_import_rule_set_imported_sheet:
+ *
+ *Sets a stylesheet to the current \@import rule.
+ *@a_this: the current \@import rule.
+ *@a_sheet: the stylesheet. The stylesheet is owned
*by the current instance of #CRStatement, that is, the
*stylesheet will be destroyed when the current instance
- *of #CRStatement will be destroyed.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *of #CRStatement is destroyed.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_import_rule_set_imported_sheet (CRStatement * a_this,
@@ -2045,11 +2165,14 @@ cr_statement_at_import_rule_set_imported_sheet (CRStatement * a_this,
}
/**
- *Gets the stylesheet contained by the @import rule statement.
- *@param a_this the current @import rule statement.
- *@param a_sheet out parameter. The returned stylesheet if and
+ * cr_statement_at_import_rule_get_imported_sheet:
+ *
+ *@a_this: the current \@import rule statement.
+ *@a_sheet: out parameter. The returned stylesheet if and
*only if the function returns CR_OK.
- *@return CR_OK upon sucessfull completion, an error code otherwise.
+ *
+ *Gets the stylesheet contained by the \@import rule statement.
+ *Returns CR_OK upon sucessful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_import_rule_get_imported_sheet (CRStatement * a_this,
@@ -2065,10 +2188,14 @@ cr_statement_at_import_rule_get_imported_sheet (CRStatement * a_this,
}
/**
- *Sets an url to the current @import rule statement.
- *@param a_this the current @import rule statement.
- *@param a_url the url to set.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ * cr_statement_at_import_rule_set_url:
+ *
+ *@a_this: the current \@import rule statement.
+ *@a_url: the url to set.
+ *
+ *Sets an url to the current \@import rule statement.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_import_rule_set_url (CRStatement * a_this,
@@ -2089,13 +2216,17 @@ cr_statement_at_import_rule_set_url (CRStatement * a_this,
}
/**
- *Gets the url of the @import rule statement.
- *@param the current @import rule statement.
- *@param a_url out parameter. The returned url if
+ * cr_statement_at_import_rule_get_url:
+ *
+ *@a_this: the current \@import rule statement.
+ *@a_url: out parameter. The returned url if
*and only if the function returned CR_OK.
+ *
+ *Gets the url of the \@import rule statement.
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
-cr_statement_at_import_rule_get_url (CRStatement * a_this,
+cr_statement_at_import_rule_get_url (CRStatement const * a_this,
CRString ** a_url)
{
g_return_val_if_fail (a_this
@@ -2109,12 +2240,14 @@ cr_statement_at_import_rule_get_url (CRStatement * a_this,
}
/**
- *Return the number of rules in the media rule;
- *@param a_this the current instance of #CRStatement.
- *@return number of rules in the media rule.
+ * cr_statement_at_media_nr_rules:
+ *
+ *@a_this: the current instance of #CRStatement.
+ *
+ *Returns the number of rules in the media rule;
*/
int
-cr_statement_at_media_nr_rules (CRStatement * a_this)
+cr_statement_at_media_nr_rules (CRStatement const * a_this)
{
g_return_val_if_fail (a_this
&& a_this->type == AT_MEDIA_RULE_STMT
@@ -2124,10 +2257,14 @@ cr_statement_at_media_nr_rules (CRStatement * a_this)
}
/**
+ * cr_statement_at_media_get_from_list:
+ *
+ *@a_this: the current instance of #CRStatement.
+ *@itemnr: the index into the media rule list of rules.
+ *
*Use an index to get a CRStatement from the media rule list of rules.
- *@param a_this the current instance of #CRStatement.
- *@param itemnr the index into the media rule list of rules.
- *@return CRStatement at position itemnr, if itemnr > number of rules - 1,
+ *
+ *Returns CRStatement at position itemnr, if itemnr > number of rules - 1,
*it will return NULL.
*/
CRStatement *
@@ -2142,11 +2279,15 @@ cr_statement_at_media_get_from_list (CRStatement * a_this, int itemnr)
}
/**
- *Sets a declaration list to the current @page rule statement.
- *@param a_this the current @page rule statement.
- *@param a_decl_list the declaration list to add. Will be freed
+ * cr_statement_at_page_rule_set_declarations:
+ *
+ *@a_this: the current \@page rule statement.
+ *@a_decl_list: the declaration list to add. Will be freed
*by the current instance of #CRStatement when it is destroyed.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Sets a declaration list to the current \@page rule statement.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_page_rule_set_declarations (CRStatement * a_this,
@@ -2170,11 +2311,15 @@ cr_statement_at_page_rule_set_declarations (CRStatement * a_this,
}
/**
- *Gets the declaration list associated to the current @page rule
+ * cr_statement_at_page_rule_get_declarations:
+ *
+ *@a_this: the current \@page rule statement.
+ *@a_decl_list: out parameter. The returned declaration list.
+ *
+ *Gets the declaration list associated to the current \@page rule
*statement.
- *@param a_this the current @page rule statement.
- *@param a_decl_list out parameter. The returned declaration list.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_page_rule_get_declarations (CRStatement * a_this,
@@ -2190,10 +2335,15 @@ cr_statement_at_page_rule_get_declarations (CRStatement * a_this,
}
/**
- *Sets the charset of the current @charset rule statement.
- *@param a_this the current @charset rule statement.
- *@param a_charset the charset to set.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ * cr_statement_at_charset_rule_set_charset:
+ *
+ *
+ *@a_this: the current \@charset rule statement.
+ *@a_charset: the charset to set.
+ *
+ *Sets the charset of the current \@charset rule statement.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_charset_rule_set_charset (CRStatement * a_this,
@@ -2212,14 +2362,18 @@ cr_statement_at_charset_rule_set_charset (CRStatement * a_this,
}
/**
- *Gets the charset string associated to the current
- *@charset rule statement.
- *@param a_this the current @charset rule statement.
- *@param a_charset out parameter. The returned charset string if
+ * cr_statement_at_charset_rule_get_charset:
+ *@a_this: the current \@charset rule statement.
+ *@a_charset: out parameter. The returned charset string if
*and only if the function returned CR_OK.
+ *
+ *Gets the charset string associated to the current
+ *\@charset rule statement.
+ *
+ * Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
-cr_statement_at_charset_rule_get_charset (CRStatement * a_this,
+cr_statement_at_charset_rule_get_charset (CRStatement const * a_this,
CRString ** a_charset)
{
g_return_val_if_fail (a_this
@@ -2233,10 +2387,14 @@ cr_statement_at_charset_rule_get_charset (CRStatement * a_this,
}
/**
- *Sets a declaration list to the current @font-face rule statement.
- *@param a_this the current @font-face rule statement.
- *@param a_decls the declarations list to set.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ * cr_statement_at_font_face_rule_set_decls:
+ *
+ *@a_this: the current \@font-face rule statement.
+ *@a_decls: the declarations list to set.
+ *
+ *Sets a declaration list to the current \@font-face rule statement.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_font_face_rule_set_decls (CRStatement * a_this,
@@ -2258,12 +2416,16 @@ cr_statement_at_font_face_rule_set_decls (CRStatement * a_this,
}
/**
- *Gets the declaration list associated to the current instance
- *of @font-face rule statement.
- *@param a_this the current @font-face rule statement.
- *@param a_decls out parameter. The returned declaration list if
+ * cr_statement_at_font_face_rule_get_decls:
+ *
+ *@a_this: the current \@font-face rule statement.
+ *@a_decls: out parameter. The returned declaration list if
*and only if this function returns CR_OK.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Gets the declaration list associated to the current instance
+ *of \@font-face rule statement.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_font_face_rule_get_decls (CRStatement * a_this,
@@ -2280,12 +2442,16 @@ cr_statement_at_font_face_rule_get_decls (CRStatement * a_this,
}
/**
- *Adds a declaration to the current @font-face rule
+ * cr_statement_at_font_face_rule_add_decl:
+ *
+ *@a_this: the current \@font-face rule statement.
+ *@a_prop: the property of the declaration.
+ *@a_value: the value of the declaration.
+ *
+ *Adds a declaration to the current \@font-face rule
*statement.
- *@param a_this the current @font-face rule statement.
- *@param a_prop the property of the declaration.
- *@param a_value the value of the declaration.
- *@return CR_OK upon successfull completion, an error code otherwise.
+ *
+ *Returns CR_OK upon successful completion, an error code otherwise.
*/
enum CRStatus
cr_statement_at_font_face_rule_add_decl (CRStatement * a_this,
@@ -2312,15 +2478,20 @@ cr_statement_at_font_face_rule_add_decl (CRStatement * a_this,
return CR_OK;
}
+
/**
+ * cr_statement_to_string:
+ *
+ *@a_this: the current statement to serialize
+ *@a_indent: the number of white space of indentation.
+ *
*Serializes a css statement into a string
- *@param a_this the current statement to serialize
- *@param a_indent the number of white space of indentation.
- *@return the serialized statement. Must be freed by the caller
+ *
+ *Returns the serialized statement. Must be freed by the caller
*using g_free().
*/
gchar *
-cr_statement_to_string (CRStatement * a_this, gulong a_indent)
+cr_statement_to_string (CRStatement const * a_this, gulong a_indent)
{
gchar *str = NULL ;
@@ -2366,9 +2537,9 @@ cr_statement_to_string (CRStatement * a_this, gulong a_indent)
}
gchar*
-cr_statement_list_to_string (CRStatement *a_this, gulong a_indent)
+cr_statement_list_to_string (CRStatement const *a_this, gulong a_indent)
{
- CRStatement *cur_stmt = NULL ;
+ CRStatement const *cur_stmt = NULL ;
GString *stringue = NULL ;
gchar *str = NULL ;
@@ -2399,13 +2570,16 @@ cr_statement_list_to_string (CRStatement *a_this, gulong a_indent)
}
/**
+ * cr_statement_dump:
+ *
+ *@a_this: the current css2 statement.
+ *@a_fp: the destination file pointer.
+ *@a_indent: the number of white space indentation characters.
+ *
*Dumps the css2 statement to a file.
- *@param a_this the current css2 statement.
- *@param a_fp the destination file pointer.
- *@param a_indent the number of white space indentation characters.
*/
void
-cr_statement_dump (CRStatement * a_this, FILE * a_fp, gulong a_indent)
+cr_statement_dump (CRStatement const * a_this, FILE * a_fp, gulong a_indent)
{
gchar *str = NULL ;
@@ -2421,31 +2595,39 @@ cr_statement_dump (CRStatement * a_this, FILE * a_fp, gulong a_indent)
}
/**
+ * cr_statement_dump_ruleset:
+ *
+ *@a_this: the current instance of #CRStatement.
+ *@a_fp: the destination file pointer.
+ *@a_indent: the number of indentation white spaces to add.
+ *
*Dumps a ruleset statement to a file.
- *@param a_this the current instance of #CRStatement.
- *@param a_fp the destination file pointer.
- *@param a_indent the number of indentation white spaces to add.
*/
void
-cr_statement_dump_ruleset (CRStatement * a_this, FILE * a_fp, glong a_indent)
+cr_statement_dump_ruleset (CRStatement const * a_this, FILE * a_fp, glong a_indent)
{
+ guchar *str = NULL;
+
g_return_if_fail (a_fp && a_this);
- gchar *str = cr_statement_ruleset_to_string (a_this, a_indent);
+ str = cr_statement_ruleset_to_string (a_this, a_indent);
if (str) {
- fprintf (a_fp, "%s", str);
+ fprintf (a_fp, str);
g_free (str);
str = NULL;
}
}
/**
+ * cr_statement_dump_font_face_rule:
+ *
+ *@a_this: the current instance of font face rule statement.
+ *@a_fp: the destination file pointer.
+ *@a_indent: the number of white space indentation.
+ *
*Dumps a font face rule statement to a file.
- *@param a_this the current instance of font face rule statement.
- *@param a_fp the destination file pointer.
- *@param a_indent the number of white space indentation.
*/
void
-cr_statement_dump_font_face_rule (CRStatement * a_this, FILE * a_fp,
+cr_statement_dump_font_face_rule (CRStatement const * a_this, FILE * a_fp,
glong a_indent)
{
gchar *str = NULL ;
@@ -2462,20 +2644,25 @@ cr_statement_dump_font_face_rule (CRStatement * a_this, FILE * a_fp,
}
/**
- *Dumps an @charset rule statement to a file.
- *@param a_this the current instance of the @charset rule statement.
- *@param a_fp the destination file pointer.
- *@param a_indent the number of indentation white spaces.
+ * cr_statement_dump_charset:
+ *
+ *@a_this: the current instance of the \@charset rule statement.
+ *@a_fp: the destination file pointer.
+ *@a_indent: the number of indentation white spaces.
+ *
+ *Dumps an \@charset rule statement to a file.
*/
void
-cr_statement_dump_charset (CRStatement * a_this, FILE * a_fp, gulong a_indent)
+cr_statement_dump_charset (CRStatement const * a_this, FILE * a_fp, gulong a_indent)
{
+ guchar *str = NULL;
+
g_return_if_fail (a_this && a_this->type == AT_CHARSET_RULE_STMT);
- gchar *str = cr_statement_charset_to_string (a_this,
+ str = cr_statement_charset_to_string (a_this,
a_indent) ;
if (str) {
- fprintf (a_fp, "%s", str) ;
+ fprintf (a_fp, str) ;
g_free (str) ;
str = NULL ;
}
@@ -2483,21 +2670,26 @@ cr_statement_dump_charset (CRStatement * a_this, FILE * a_fp, gulong a_indent)
/**
- *Dumps an @page rule statement on stdout.
- *@param a_this the statement to dump on stdout.
- *@param a_fp the destination file pointer.
- *@param a_indent the number of indentation white spaces.
+ * cr_statement_dump_page:
+ *
+ *@a_this: the statement to dump on stdout.
+ *@a_fp: the destination file pointer.
+ *@a_indent: the number of indentation white spaces.
+ *
+ *Dumps an \@page rule statement on stdout.
*/
void
-cr_statement_dump_page (CRStatement * a_this, FILE * a_fp, gulong a_indent)
+cr_statement_dump_page (CRStatement const * a_this, FILE * a_fp, gulong a_indent)
{
+ guchar *str = NULL;
+
g_return_if_fail (a_this
&& a_this->type == AT_PAGE_RULE_STMT
&& a_this->kind.page_rule);
- gchar *str = cr_statement_at_page_rule_to_string (a_this, a_indent) ;
+ str = cr_statement_at_page_rule_to_string (a_this, a_indent) ;
if (str) {
- fprintf (a_fp, "%s", str);
+ fprintf (a_fp, str);
g_free (str) ;
str = NULL ;
}
@@ -2505,13 +2697,16 @@ cr_statement_dump_page (CRStatement * a_this, FILE * a_fp, gulong a_indent)
/**
- *Dumps an @media rule statement to a file.
- *@param a_this the statement to dump.
- *@param a_fp the destination file pointer
- *@param a_indent the number of white spaces indentation.
+ * cr_statement_dump_media_rule:
+ *
+ *@a_this: the statement to dump.
+ *@a_fp: the destination file pointer
+ *@a_indent: the number of white spaces indentation.
+ *
+ *Dumps an \@media rule statement to a file.
*/
void
-cr_statement_dump_media_rule (CRStatement * a_this,
+cr_statement_dump_media_rule (CRStatement const * a_this,
FILE * a_fp,
gulong a_indent)
{
@@ -2520,19 +2715,22 @@ cr_statement_dump_media_rule (CRStatement * a_this,
str = cr_statement_media_rule_to_string (a_this, a_indent) ;
if (str) {
- fprintf (a_fp, "%s", str) ;
+ fprintf (a_fp, str) ;
g_free (str) ;
str = NULL ;
}
}
/**
- *Dumps an @import rule statement to a file.
- *@param a_fp the destination file pointer.
- *@param a_indent the number of white space indentations.
+ * cr_statement_dump_import_rule:
+ *
+ *@a_fp: the destination file pointer.
+ *@a_indent: the number of white space indentations.
+ *
+ *Dumps an \@import rule statement to a file.
*/
void
-cr_statement_dump_import_rule (CRStatement * a_this, FILE * a_fp,
+cr_statement_dump_import_rule (CRStatement const * a_this, FILE * a_fp,
gulong a_indent)
{
gchar *str = NULL ;
@@ -2543,13 +2741,17 @@ cr_statement_dump_import_rule (CRStatement * a_this, FILE * a_fp,
str = cr_statement_import_rule_to_string (a_this, a_indent) ;
if (str) {
- fprintf (a_fp, "%s", str) ;
+ fprintf (a_fp, str) ;
g_free (str) ;
str = NULL ;
}
}
/**
+ * cr_statement_destroy:
+ *
+ * @a_this: the current instance of #CRStatement.
+ *
*Destructor of #CRStatement.
*/
void
diff --git a/src/cr-statement.h b/src/cr-statement.h
index 5639ab7..74a2330 100644
--- a/src/cr-statement.h
+++ b/src/cr-statement.h
@@ -84,7 +84,7 @@ struct _CRStyleSheet ;
typedef struct _CRStyleSheet CRStyleSheet;
-/**The @import rule abstraction.*/
+/**The \@import rule abstraction.*/
typedef struct _CRAtImportRule CRAtImportRule ;
struct _CRAtImportRule
{
@@ -102,7 +102,7 @@ struct _CRAtImportRule
};
-/**abstraction of an @media rule*/
+/**abstraction of an \@media rule*/
struct _CRAtMediaRule
{
GList *media_list ;
@@ -111,7 +111,7 @@ struct _CRAtMediaRule
typedef struct _CRAtPageRule CRAtPageRule ;
-/**The @page rule abstraction*/
+/**The \@page rule abstraction*/
struct _CRAtPageRule
{
/**a list of instances of #CRDeclaration*/
@@ -122,14 +122,14 @@ struct _CRAtPageRule
CRString *pseudo ;
} ;
-/**The @charset rule abstraction*/
+/**The \@charset rule abstraction*/
typedef struct _CRAtCharsetRule CRAtCharsetRule ;
struct _CRAtCharsetRule
{
CRString * charset ;
};
-/**The abstaction of the @font-face rule.*/
+/**The abstaction of the \@font-face rule.*/
typedef struct _CRAtFontFaceRule CRAtFontFaceRule ;
struct _CRAtFontFaceRule
{
@@ -176,8 +176,8 @@ enum CRStatementType
*The abstraction of css statement as defined
*in the chapter 4 and appendix D.1 of the css2 spec.
*A statement is actually a double chained list of
- *statements.A statement can be a ruleset, an @import
- *rule, an @page rule etc ...
+ *statements.A statement can be a ruleset, an \@import
+ *rule, an \@page rule etc ...
*/
struct _CRStatement
{
@@ -314,7 +314,7 @@ cr_statement_ruleset_set_sel_list (CRStatement *a_this,
CRSelector *a_sel_list) ;
enum CRStatus
-cr_statement_ruleset_get_sel_list (CRStatement *a_this,
+cr_statement_ruleset_get_sel_list (CRStatement const *a_this,
CRSelector **a_list) ;
enum CRStatus
@@ -346,11 +346,11 @@ cr_statement_at_import_rule_set_url (CRStatement *a_this,
CRString *a_url) ;
enum CRStatus
-cr_statement_at_import_rule_get_url (CRStatement *a_this,
+cr_statement_at_import_rule_get_url (CRStatement const *a_this,
CRString **a_url) ;
gint
-cr_statement_at_media_nr_rules (CRStatement *a_this) ;
+cr_statement_at_media_nr_rules (CRStatement const *a_this) ;
CRStatement *
cr_statement_at_media_get_from_list (CRStatement *a_this, int itemnr) ;
@@ -360,7 +360,7 @@ cr_statement_at_page_rule_set_sel (CRStatement *a_this,
CRSelector *a_sel) ;
enum CRStatus
-cr_statement_at_page_rule_get_sel (CRStatement *a_this,
+cr_statement_at_page_rule_get_sel (CRStatement const *a_this,
CRSelector **a_sel) ;
enum CRStatus
@@ -376,7 +376,7 @@ cr_statement_at_charset_rule_set_charset (CRStatement *a_this,
CRString *a_charset) ;
enum CRStatus
-cr_statement_at_charset_rule_get_charset (CRStatement *a_this,
+cr_statement_at_charset_rule_get_charset (CRStatement const *a_this,
CRString **a_charset) ;
enum CRStatus
@@ -393,41 +393,41 @@ cr_statement_at_font_face_rule_add_decl (CRStatement *a_this,
CRTerm *a_value) ;
gchar *
-cr_statement_to_string (CRStatement * a_this, gulong a_indent) ;
+cr_statement_to_string (CRStatement const * a_this, gulong a_indent) ;
gchar*
-cr_statement_list_to_string (CRStatement *a_this, gulong a_indent) ;
+cr_statement_list_to_string (CRStatement const *a_this, gulong a_indent) ;
void
-cr_statement_dump (CRStatement *a_this, FILE *a_fp, gulong a_indent) ;
+cr_statement_dump (CRStatement const *a_this, FILE *a_fp, gulong a_indent) ;
void
-cr_statement_dump_ruleset (CRStatement * a_this, FILE * a_fp,
+cr_statement_dump_ruleset (CRStatement const * a_this, FILE * a_fp,
glong a_indent) ;
void
-cr_statement_dump_font_face_rule (CRStatement * a_this,
+cr_statement_dump_font_face_rule (CRStatement const * a_this,
FILE * a_fp,
glong a_indent) ;
void
-cr_statement_dump_page (CRStatement * a_this, FILE * a_fp,
+cr_statement_dump_page (CRStatement const * a_this, FILE * a_fp,
gulong a_indent) ;
void
-cr_statement_dump_media_rule (CRStatement * a_this,
+cr_statement_dump_media_rule (CRStatement const * a_this,
FILE * a_fp,
gulong a_indent) ;
void
-cr_statement_dump_import_rule (CRStatement * a_this, FILE * a_fp,
+cr_statement_dump_import_rule (CRStatement const * a_this, FILE * a_fp,
gulong a_indent) ;
void
-cr_statement_dump_charset (CRStatement * a_this, FILE * a_fp,
+cr_statement_dump_charset (CRStatement const * a_this, FILE * a_fp,
gulong a_indent) ;
gint
-cr_statement_nr_rules (CRStatement *a_this) ;
+cr_statement_nr_rules (CRStatement const *a_this) ;
CRStatement *
cr_statement_get_from_list (CRStatement *a_this, int itemnr) ;
diff --git a/src/cr-string.c b/src/cr-string.c
index 7c656f5..633fcab 100644
--- a/src/cr-string.c
+++ b/src/cr-string.c
@@ -32,7 +32,9 @@
CRString *
cr_string_new (void)
{
- CRString *result = (CRString *)g_try_malloc (sizeof (CRString)) ;
+ CRString *result = NULL ;
+
+ result = g_try_malloc (sizeof (CRString)) ;
if (!result) {
cr_utils_trace_info ("Out of memory") ;
return NULL ;
@@ -51,7 +53,9 @@ cr_string_new (void)
CRString *
cr_string_new_from_string (const gchar * a_string)
{
- CRString *result = cr_string_new () ;
+ CRString *result = NULL ;
+
+ result = cr_string_new () ;
if (!result) {
cr_utils_trace_info ("Out of memory") ;
return NULL ;
@@ -68,9 +72,11 @@ cr_string_new_from_string (const gchar * a_string)
*@return the newly instanciated #CRString.
*/
CRString *
-cr_string_new_from_gstring (GString *a_string)
+cr_string_new_from_gstring (GString const *a_string)
{
- CRString *result = cr_string_new () ;
+ CRString *result = NULL ;
+
+ result = cr_string_new () ;
if (!result) {
cr_utils_trace_info ("Out of memory") ;
return NULL ;
@@ -85,11 +91,12 @@ cr_string_new_from_gstring (GString *a_string)
}
CRString *
-cr_string_dup (CRString *a_this)
+cr_string_dup (CRString const *a_this)
{
+ CRString *result = NULL ;
g_return_val_if_fail (a_this, NULL) ;
- CRString *result = cr_string_new_from_gstring (a_this->stryng) ;
+ result = cr_string_new_from_gstring (a_this->stryng) ;
if (!result) {
cr_utils_trace_info ("Out of memory") ;
return NULL ;
@@ -100,7 +107,7 @@ cr_string_dup (CRString *a_this)
}
gchar *
-cr_string_dup2 (CRString *a_this)
+cr_string_dup2 (CRString const *a_this)
{
gchar *result = NULL ;
@@ -121,7 +128,7 @@ cr_string_dup2 (CRString *a_this)
*@param a_this the current instance of #CRString
*/
const gchar *
-cr_string_peek_raw_str (CRString *a_this)
+cr_string_peek_raw_str (CRString const *a_this)
{
g_return_val_if_fail (a_this, NULL) ;
@@ -138,7 +145,7 @@ cr_string_peek_raw_str (CRString *a_this)
*of -1 if no length can be returned.
*/
gint
-cr_string_peek_raw_str_len (CRString *a_this)
+cr_string_peek_raw_str_len (CRString const *a_this)
{
g_return_val_if_fail (a_this && a_this->stryng,
-1) ;
diff --git a/src/cr-string.h b/src/cr-string.h
index 2564534..2700f0e 100644
--- a/src/cr-string.h
+++ b/src/cr-string.h
@@ -64,11 +64,11 @@ struct _CRString {
CRString * cr_string_new (void) ;
CRString *cr_string_new_from_string (const gchar * a_string) ;
-CRString * cr_string_new_from_gstring (GString *a_string) ;
-CRString *cr_string_dup (CRString *a_this) ;
-gchar *cr_string_dup2 (CRString *a_this) ;
-const gchar *cr_string_peek_raw_str (CRString *a_this) ;
-gint cr_string_peek_raw_str_len (CRString *a_this) ;
+CRString * cr_string_new_from_gstring (GString const *a_string) ;
+CRString *cr_string_dup (CRString const *a_this) ;
+gchar *cr_string_dup2 (CRString const *a_this) ;
+const gchar *cr_string_peek_raw_str (CRString const *a_this) ;
+gint cr_string_peek_raw_str_len (CRString const *a_this) ;
void cr_string_destroy (CRString *a_this) ;
G_END_DECLS
diff --git a/src/cr-style.c b/src/cr-style.c
index e0abba8..fa3306a 100644
--- a/src/cr-style.c
+++ b/src/cr-style.c
@@ -92,7 +92,7 @@ enum CRPropertyID {
typedef struct _CRPropertyDesc CRPropertyDesc;
struct _CRPropertyDesc {
- const gchar *name;
+ const guchar *name;
enum CRPropertyID prop_id;
};
@@ -140,9 +140,9 @@ static CRPropertyDesc gv_prop_table[] = {
{"font-size", PROP_ID_FONT_SIZE},
{"font-style", PROP_ID_FONT_STYLE},
{"font-weight", PROP_ID_FONT_WEIGHT},
- {"white-space", PROP_ID_WHITE_SPACE},
+ {"white-space", PROP_ID_WHITE_SPACE},
/*must be the last one */
- {NULL, (enum CRPropertyID)0}
+ {NULL, 0}
};
/**
@@ -185,7 +185,7 @@ static struct CRNumPropEnumDumpInfo gv_num_props_dump_infos[] = {
{NUM_PROP_MARGIN_BOTTOM, "margin-bottom"},
{NUM_PROP_MARGIN_LEFT, "margin-left"},
{NUM_PROP_WIDTH, "width"},
- {(enum CRNumProp)0, NULL}
+ {0, NULL}
};
struct CRRgbPropEnumDumpInfo {
@@ -200,7 +200,7 @@ static struct CRRgbPropEnumDumpInfo gv_rgb_props_dump_infos[] = {
{RGB_PROP_BORDER_LEFT_COLOR, "left-color"},
{RGB_PROP_COLOR, "color"},
{RGB_PROP_BACKGROUND_COLOR, "background-color"},
- {(enum CRRgbProp)0, NULL}
+ {0, NULL}
};
struct CRBorderStylePropEnumDumpInfo {
@@ -215,7 +215,7 @@ static struct CRBorderStylePropEnumDumpInfo gv_border_style_props_dump_infos[]
{BORDER_STYLE_PROP_RIGHT, "border-style-right"},
{BORDER_STYLE_PROP_BOTTOM, "boder-style-bottom"},
{BORDER_STYLE_PROP_LEFT, "border-style-left"},
- {(enum CRBorderStyleProp)0, NULL}
+ {0, NULL}
};
static enum CRStatus
@@ -319,9 +319,9 @@ set_prop_font_weight_from_value (CRStyle * a_style, CRTerm * a_value);
static const gchar *
num_prop_code_to_string (enum CRNumProp a_code)
{
- int len = sizeof (gv_num_props_dump_infos) /
+ gint len = sizeof (gv_num_props_dump_infos) /
sizeof (struct CRNumPropEnumDumpInfo);
- if ((int)a_code >= len) {
+ if (a_code >= len) {
cr_utils_trace_info ("A field has been added "
"to 'enum CRNumProp' and no matching"
" entry has been "
@@ -342,10 +342,10 @@ num_prop_code_to_string (enum CRNumProp a_code)
static const gchar *
rgb_prop_code_to_string (enum CRRgbProp a_code)
{
- int len = sizeof (gv_rgb_props_dump_infos) /
+ gint len = sizeof (gv_rgb_props_dump_infos) /
sizeof (struct CRRgbPropEnumDumpInfo);
- if ((int)a_code >= len) {
+ if (a_code >= len) {
cr_utils_trace_info ("A field has been added "
"to 'enum CRRgbProp' and no matching"
" entry has been "
@@ -366,10 +366,10 @@ rgb_prop_code_to_string (enum CRRgbProp a_code)
static const gchar *
border_style_prop_code_to_string (enum CRBorderStyleProp a_code)
{
- int len = sizeof (gv_border_style_props_dump_infos) /
+ gint len = sizeof (gv_border_style_props_dump_infos) /
sizeof (struct CRBorderStylePropEnumDumpInfo);
- if ((int)a_code >= len) {
+ if (a_code >= len) {
cr_utils_trace_info ("A field has been added "
"to 'enum CRBorderStyleProp' and no matching"
" entry has been "
@@ -421,11 +421,11 @@ cr_style_get_prop_id (const guchar * a_prop)
cr_style_init_properties ();
}
- raw_id = (gpointer *)g_hash_table_lookup (gv_prop_hash, a_prop);
+ raw_id = g_hash_table_lookup (gv_prop_hash, a_prop);
if (!raw_id) {
return PROP_ID_NOT_KNOWN;
}
- return (enum CRPropertyID)GPOINTER_TO_INT (raw_id);
+ return GPOINTER_TO_INT (raw_id);
}
static enum CRStatus
@@ -465,7 +465,7 @@ set_prop_padding_x_from_value (CRStyle * a_style,
if (a_value->content.str
&& a_value->content.str->stryng
&& a_value->content.str->stryng->str
- && !strncmp ("inherit",
+ && !strncmp ((guchar *) "inherit",
a_value->content.str->stryng->str,
sizeof ("inherit")-1)) {
status = cr_num_set (num_val, 0.0, NUM_INHERIT);
@@ -569,17 +569,19 @@ static enum CRStatus
set_prop_border_width_from_value (CRStyle *a_style,
CRTerm *a_value)
{
+ CRTerm *cur_term = NULL ;
+ enum CRDirection direction = DIR_TOP ;
+
g_return_val_if_fail (a_style && a_value,
CR_BAD_PARAM_ERROR) ;
- CRTerm *cur_term = a_value ;
+ cur_term = a_value ;
if (!cur_term)
return CR_ERROR ;
- int dir;
- for (dir = (int) DIR_TOP ; dir < (int)NB_DIRS ; dir++) {
- enum CRDirection direction = (enum CRDirection)dir;
- set_prop_border_x_width_from_value (a_style,
+ for (direction = DIR_TOP ;
+ direction < NB_DIRS ; direction ++) {
+ set_prop_border_x_width_from_value (a_style,
cur_term,
direction) ;
}
@@ -696,17 +698,20 @@ static enum CRStatus
set_prop_border_style_from_value (CRStyle *a_style,
CRTerm *a_value)
{
+ CRTerm *cur_term = NULL ;
+ enum CRDirection direction = DIR_TOP ;
+
g_return_val_if_fail (a_style && a_value,
CR_BAD_PARAM_ERROR) ;
- CRTerm *cur_term = a_value ;
+ cur_term = a_value ;
if (!cur_term || cur_term->type != TERM_IDENT) {
return CR_ERROR ;
}
- int dir;
- for (dir = (int)DIR_TOP ; dir < (int)NB_DIRS ; dir++) {
- enum CRDirection direction = (enum CRDirection)dir;
+ for (direction = DIR_TOP ;
+ direction < NB_DIRS ;
+ direction ++) {
set_prop_border_x_style_from_value (a_style,
cur_term,
direction) ;
@@ -799,7 +804,7 @@ set_prop_margin_x_from_value (CRStyle * a_style, CRTerm * a_value,
}
struct CRPropDisplayValPair {
- const gchar *prop_name;
+ const guchar *prop_name;
enum CRDisplayType type;
};
@@ -860,7 +865,7 @@ set_prop_display_from_value (CRStyle * a_style, CRTerm * a_value)
}
struct CRPropPositionValPair {
- const gchar *name;
+ const guchar *name;
enum CRPositionType type;
};
@@ -1115,11 +1120,11 @@ set_prop_border_x_color_from_value (CRStyle * a_style, CRTerm * a_value,
&& a_value->content.str->stryng->str) {
status = cr_rgb_set_from_name
(rgb_color,
- (guchar *)a_value->content.str->stryng->str);
+ a_value->content.str->stryng->str);
}
if (status != CR_OK) {
- cr_rgb_set_from_name (rgb_color, (guchar *)"black");
+ cr_rgb_set_from_name (rgb_color, "black");
}
} else if (a_value->type == TERM_RGB) {
if (a_value->content.rgb) {
@@ -1161,13 +1166,14 @@ set_prop_border_x_from_value (CRStyle * a_style, CRTerm * a_value,
static enum CRStatus
set_prop_border_from_value (CRStyle * a_style, CRTerm * a_value)
{
+ enum CRDirection direction = 0;
+
g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR);
- int dir;
- for (dir = 0; dir < (int)NB_DIRS; dir++) {
+ for (direction = 0; direction < NB_DIRS; direction++) {
set_prop_border_x_from_value (a_style,
a_value,
- (enum CRDirection)dir);
+ direction);
}
return CR_OK;
@@ -1177,6 +1183,7 @@ static enum CRStatus
set_prop_padding_from_value (CRStyle * a_style, CRTerm * a_value)
{
CRTerm *cur_term = NULL;
+ enum CRDirection direction = 0;
enum CRStatus status = CR_OK;
g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR);
@@ -1190,10 +1197,8 @@ set_prop_padding_from_value (CRStyle * a_style, CRTerm * a_value)
if (!cur_term)
return CR_ERROR ;
- int dir;
- for (dir = 0; dir < (int)NB_DIRS; dir++) {
- set_prop_padding_x_from_value (a_style,
- cur_term, (enum CRDirection)dir);
+ for (direction = 0; direction < NB_DIRS; direction++) {
+ set_prop_padding_x_from_value (a_style, cur_term, direction);
}
cur_term = cur_term->next;
@@ -1229,6 +1234,7 @@ static enum CRStatus
set_prop_margin_from_value (CRStyle * a_style, CRTerm * a_value)
{
CRTerm *cur_term = NULL;
+ enum CRDirection direction = 0;
enum CRStatus status = CR_OK;
g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR);
@@ -1242,10 +1248,8 @@ set_prop_margin_from_value (CRStyle * a_style, CRTerm * a_value)
if (!cur_term)
return CR_OK;
- int dir;
- for (dir = 0; dir < (int)NB_DIRS; dir++) {
- set_prop_margin_x_from_value(a_style,
- cur_term, (enum CRDirection)dir);
+ for (direction = 0; direction < NB_DIRS; direction++) {
+ set_prop_margin_x_from_value (a_style, cur_term, direction);
}
cur_term = cur_term->next;
@@ -1354,7 +1358,7 @@ set_prop_font_family_from_value (CRStyle * a_style, CRTerm * a_value)
&& cur_term->content.str->stryng->str) {
cur_ff = cr_font_family_new
(FONT_FAMILY_NON_GENERIC,
- (guchar *)cur_term->content.str->stryng->str);
+ cur_term->content.str->stryng->str);
}
}
break;
@@ -1672,7 +1676,7 @@ set_prop_white_space_from_value (CRStyle * a_style, CRTerm * a_value)
a_style->white_space = WHITE_SPACE_NORMAL;
} else if (!strcmp (a_value->content.str->stryng->str,
"pre")) {
- a_style->white_space = WHITE_SPACE_PRE;
+ a_style->font_weight = WHITE_SPACE_PRE;
} else if (!strcmp (a_value->content.str->stryng->str,
"nowrap")) {
a_style->white_space = WHITE_SPACE_NOWRAP;
@@ -1707,7 +1711,9 @@ set_prop_white_space_from_value (CRStyle * a_style, CRTerm * a_value)
CRStyle *
cr_style_new (gboolean a_set_props_to_initial_values)
{
- CRStyle *result = (CRStyle *)g_try_malloc (sizeof (CRStyle));
+ CRStyle *result = NULL;
+
+ result = g_try_malloc (sizeof (CRStyle));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
@@ -2018,7 +2024,7 @@ cr_style_set_style_from_decl (CRStyle * a_this, CRDeclaration * a_decl)
CR_BAD_PARAM_ERROR);
prop_id = cr_style_get_prop_id
- ((guchar *)a_decl->property->stryng->str);
+ (a_decl->property->stryng->str);
value = a_decl->value;
switch (prop_id) {
@@ -2676,7 +2682,7 @@ cr_style_to_string (CRStyle * a_this, GString ** a_str, guint a_nb_indent)
*before outputing it value
*/
cr_utils_dump_n_chars2 (' ', str, indent);
- tmp_str = (gchar *) num_prop_code_to_string ((enum CRNumProp)i);
+ tmp_str = (gchar *) num_prop_code_to_string (i);
if (tmp_str) {
g_string_append_printf (str, "%s: ", tmp_str);
} else {
@@ -2690,7 +2696,7 @@ cr_style_to_string (CRStyle * a_this, GString ** a_str, guint a_nb_indent)
}
/*loop over the rgb_props and to_string() them all */
for (i = RGB_PROP_BORDER_TOP_COLOR; i < NB_RGB_PROPS; i++) {
- tmp_str = (gchar *) rgb_prop_code_to_string ((enum CRRgbProp)i);
+ tmp_str = (gchar *) rgb_prop_code_to_string (i);
cr_utils_dump_n_chars2 (' ', str, indent);
if (tmp_str) {
g_string_append_printf (str, "%s: ", tmp_str);
@@ -2705,8 +2711,7 @@ cr_style_to_string (CRStyle * a_this, GString ** a_str, guint a_nb_indent)
}
/*loop over the border_style_props and to_string() them */
for (i = BORDER_STYLE_PROP_TOP; i < NB_BORDER_STYLE_PROPS; i++) {
- tmp_str = (gchar *)
- border_style_prop_code_to_string ((enum CRBorderStyleProp)i);
+ tmp_str = (gchar *) border_style_prop_code_to_string (i);
cr_utils_dump_n_chars2 (' ', str, indent);
if (tmp_str) {
g_string_append_printf (str, "%s: ", tmp_str);
@@ -2741,7 +2746,7 @@ cr_style_to_string (CRStyle * a_this, GString ** a_str, guint a_nb_indent)
cr_utils_dump_n_chars2 (' ', str, indent);
g_string_append (str, "font-family: ");
- tmp_str = (gchar *)cr_font_family_to_string (a_this->font_family, TRUE);
+ tmp_str = cr_font_family_to_string (a_this->font_family, TRUE);
if (tmp_str) {
g_string_append (str, tmp_str);
g_free (tmp_str);
diff --git a/src/cr-style.h b/src/cr-style.h
index 9abdef6..18aeaad 100644
--- a/src/cr-style.h
+++ b/src/cr-style.h
@@ -80,7 +80,7 @@ enum CRPositionType
POSITION_RELATIVE,
POSITION_ABSOLUTE,
POSITION_FIXED,
- POSITION_INHERIT,
+ POSITION_INHERIT
} ;
enum CRFloatType
diff --git a/src/cr-stylesheet.c b/src/cr-stylesheet.c
index 06b27fc..69909da 100644
--- a/src/cr-stylesheet.c
+++ b/src/cr-stylesheet.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
@@ -36,7 +36,9 @@
CRStyleSheet *
cr_stylesheet_new (CRStatement * a_stmts)
{
- CRStyleSheet *result = (CRStyleSheet *)g_try_malloc (sizeof (CRStyleSheet));
+ CRStyleSheet *result;
+
+ result = g_try_malloc (sizeof (CRStyleSheet));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
@@ -55,11 +57,11 @@ cr_stylesheet_new (CRStatement * a_stmts)
*@return the serialized stylesheet.
*/
gchar *
-cr_stylesheet_to_string (CRStyleSheet *a_this)
+cr_stylesheet_to_string (CRStyleSheet const *a_this)
{
gchar *str = NULL;
GString *stringue = NULL;
- CRStatement *cur_stmt = NULL;
+ CRStatement const *cur_stmt = NULL;
g_return_val_if_fail (a_this, NULL);
@@ -93,7 +95,7 @@ cr_stylesheet_to_string (CRStyleSheet *a_this)
*@param a_fp the destination file
*/
void
-cr_stylesheet_dump (CRStyleSheet * a_this, FILE * a_fp)
+cr_stylesheet_dump (CRStyleSheet const * a_this, FILE * a_fp)
{
gchar *str = NULL ;
@@ -113,7 +115,7 @@ cr_stylesheet_dump (CRStyleSheet * a_this, FILE * a_fp)
*@return number of rules in the stylesheet.
*/
gint
-cr_stylesheet_nr_rules (CRStyleSheet * a_this)
+cr_stylesheet_nr_rules (CRStyleSheet const * a_this)
{
g_return_val_if_fail (a_this, -1);
diff --git a/src/cr-stylesheet.h b/src/cr-stylesheet.h
index 3766a28..f35c94e 100644
--- a/src/cr-stylesheet.h
+++ b/src/cr-stylesheet.h
@@ -84,10 +84,10 @@ struct _CRStyleSheet
CRStyleSheet * cr_stylesheet_new (CRStatement *a_stmts) ;
-gchar * cr_stylesheet_to_string (CRStyleSheet *a_this) ;
-void cr_stylesheet_dump (CRStyleSheet *a_this, FILE *a_fp) ;
+gchar * cr_stylesheet_to_string (CRStyleSheet const *a_this) ;
+void cr_stylesheet_dump (CRStyleSheet const *a_this, FILE *a_fp) ;
-gint cr_stylesheet_nr_rules (CRStyleSheet *a_this) ;
+gint cr_stylesheet_nr_rules (CRStyleSheet const *a_this) ;
CRStatement * cr_stylesheet_statement_get_from_list (CRStyleSheet *a_this, int itemnr) ;
diff --git a/src/cr-term.c b/src/cr-term.c
index 63b3927..d6db51a 100644
--- a/src/cr-term.c
+++ b/src/cr-term.c
@@ -84,7 +84,9 @@ cr_term_clear (CRTerm * a_this)
CRTerm *
cr_term_new (void)
{
- CRTerm *result = (CRTerm *)g_try_malloc (sizeof (CRTerm));
+ CRTerm *result = NULL;
+
+ result = g_try_malloc (sizeof (CRTerm));
if (!result) {
cr_utils_trace_info ("Out of memory");
return NULL;
@@ -104,15 +106,14 @@ CRTerm *
cr_term_parse_expression_from_buf (const guchar * a_buf,
enum CREncoding a_encoding)
{
+ CRParser *parser = NULL;
CRTerm *result = NULL;
enum CRStatus status = CR_OK;
g_return_val_if_fail (a_buf, NULL);
- CRParser *parser = cr_parser_new_from_buf (
- (guchar*)a_buf,
- strlen ((char *)a_buf),
- a_encoding, FALSE);
+ parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf),
+ a_encoding, FALSE);
g_return_val_if_fail (parser, NULL);
status = cr_parser_try_to_skip_spaces_and_comments (parser);
@@ -275,12 +276,12 @@ cr_term_prepend_term (CRTerm * a_this, CRTerm * a_new_term)
*form of #CRTerm. MUST BE FREED BY THE CALLER using g_free().
*/
guchar *
-cr_term_to_string (CRTerm * a_this)
+cr_term_to_string (CRTerm const * a_this)
{
GString *str_buf = NULL;
- CRTerm *cur = NULL;
- guchar *result = NULL;
- gchar *content = NULL;
+ CRTerm const *cur = NULL;
+ guchar *result = NULL,
+ *content = NULL;
g_return_val_if_fail (a_this, NULL);
@@ -329,7 +330,7 @@ cr_term_to_string (CRTerm * a_this)
switch (cur->type) {
case TERM_NUMBER:
if (cur->content.num) {
- content = (gchar *)cr_num_to_string (cur->content.num);
+ content = cr_num_to_string (cur->content.num);
}
if (content) {
@@ -360,7 +361,7 @@ cr_term_to_string (CRTerm * a_this)
if (tmp_str) {
g_string_append (str_buf,
- (gchar *)tmp_str);
+ tmp_str);
g_free (tmp_str);
tmp_str = NULL;
}
@@ -405,8 +406,8 @@ cr_term_to_string (CRTerm * a_this)
case TERM_URI:
if (cur->content.str) {
content = g_strndup
- (cur->content.str->stryng->str,
- cur->content.str->stryng->len);
+ (cur->content.str->stryng->str,
+ cur->content.str->stryng->len);
}
if (content) {
@@ -425,7 +426,7 @@ cr_term_to_string (CRTerm * a_this)
tmp_str = cr_rgb_to_string (cur->content.rgb);
if (tmp_str) {
- g_string_append (str_buf, (gchar *)tmp_str);
+ g_string_append (str_buf, tmp_str);
g_free (tmp_str);
tmp_str = NULL;
}
@@ -463,7 +464,7 @@ cr_term_to_string (CRTerm * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -472,11 +473,11 @@ cr_term_to_string (CRTerm * a_this)
}
guchar *
-cr_term_one_to_string (CRTerm * a_this)
+cr_term_one_to_string (CRTerm const * a_this)
{
GString *str_buf = NULL;
- guchar *result = NULL;
- gchar *content = NULL;
+ guchar *result = NULL,
+ *content = NULL;
g_return_val_if_fail (a_this, NULL);
@@ -524,7 +525,7 @@ cr_term_one_to_string (CRTerm * a_this)
switch (a_this->type) {
case TERM_NUMBER:
if (a_this->content.num) {
- content = (gchar *)cr_num_to_string (a_this->content.num);
+ content = cr_num_to_string (a_this->content.num);
}
if (content) {
@@ -615,9 +616,10 @@ cr_term_one_to_string (CRTerm * a_this)
case TERM_RGB:
if (a_this->content.rgb) {
+ guchar *tmp_str = NULL;
g_string_append_printf (str_buf, "rgb(");
- gchar *tmp_str = (gchar *)cr_rgb_to_string (a_this->content.rgb);
+ tmp_str = cr_rgb_to_string (a_this->content.rgb);
if (tmp_str) {
g_string_append (str_buf, tmp_str);
@@ -658,7 +660,7 @@ cr_term_one_to_string (CRTerm * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -675,7 +677,7 @@ cr_term_one_to_string (CRTerm * a_this)
*@param a_fp the destination file pointer.
*/
void
-cr_term_dump (CRTerm * a_this, FILE * a_fp)
+cr_term_dump (CRTerm const * a_this, FILE * a_fp)
{
guchar *content = NULL;
@@ -695,9 +697,9 @@ cr_term_dump (CRTerm * a_this, FILE * a_fp)
*@return number of terms in the expression.
*/
int
-cr_term_nr_values (CRTerm *a_this)
+cr_term_nr_values (CRTerm const *a_this)
{
- CRTerm *cur = NULL ;
+ CRTerm const *cur = NULL ;
int nr = 0;
g_return_val_if_fail (a_this, -1) ;
diff --git a/src/cr-term.h b/src/cr-term.h
index ae8b234..0f22dda 100644
--- a/src/cr-term.h
+++ b/src/cr-term.h
@@ -35,7 +35,7 @@ G_BEGIN_DECLS
/**
*@file
- *Declaration of the #CRTerm class.
+ *Declaration of the #CRTem class.
*/
enum CRTermType
@@ -169,13 +169,13 @@ CRTerm * cr_term_append_term (CRTerm *a_this, CRTerm *a_new_term) ;
CRTerm * cr_term_prepend_term (CRTerm *a_this, CRTerm *a_new_term) ;
-guchar * cr_term_to_string (CRTerm *a_this) ;
+guchar * cr_term_to_string (CRTerm const *a_this) ;
-guchar * cr_term_one_to_string (CRTerm * a_this) ;
+guchar * cr_term_one_to_string (CRTerm const * a_this) ;
-void cr_term_dump (CRTerm *a_this, FILE *a_fp) ;
+void cr_term_dump (CRTerm const *a_this, FILE *a_fp) ;
-int cr_term_nr_values (CRTerm *a_this) ;
+int cr_term_nr_values (CRTerm const *a_this) ;
CRTerm * cr_term_get_from_list (CRTerm *a_this, int itemnr) ;
diff --git a/src/cr-tknzr.c b/src/cr-tknzr.c
index 859b6c5..64924ed 100644
--- a/src/cr-tknzr.c
+++ b/src/cr-tknzr.c
@@ -195,7 +195,7 @@ CHECK_PARSING_STATUS (status, TRUE) ;
*/
#define SKIP_CHARS(a_tknzr, a_nb_chars) \
{ \
-gulong nb_chars = a_nb_chars ; \
+glong nb_chars = a_nb_chars ; \
status = cr_input_consume_chars \
(PRIVATE (a_tknzr)->input,0, &nb_chars) ; \
CHECK_PARSING_STATUS (status, TRUE) ; \
@@ -408,7 +408,7 @@ cr_tknzr_try_to_skip_spaces (CRTknzr * a_this)
}
if (cr_utils_is_white_space (cur_char) == TRUE) {
- gulong nb_chars = -1; /*consume all spaces */
+ glong nb_chars = -1; /*consume all spaces */
status = cr_input_consume_white_spaces
(PRIVATE (a_this)->input, &nb_chars);
@@ -434,7 +434,7 @@ cr_tknzr_parse_comment (CRTknzr * a_this,
CRInputPos init_pos;
guint32 cur_char = 0, next_char= 0;
CRString *comment = NULL;
- CRParsingLocation loc = {0,0,0} ;
+ CRParsingLocation loc = {0} ;
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& PRIVATE (a_this)->input,
@@ -448,38 +448,49 @@ cr_tknzr_parse_comment (CRTknzr * a_this,
READ_NEXT_CHAR (a_this, &cur_char);
ENSURE_PARSING_COND (cur_char == '*');
comment = cr_string_new ();
- for (;;) {
+ for (;;) { /* [^*]* */
+ PEEK_NEXT_CHAR (a_this, &next_char);
+ if (next_char == '*')
+ break;
READ_NEXT_CHAR (a_this, &cur_char);
-
- /*make sure there are no nested comments */
- if (cur_char == '/') {
+ g_string_append_unichar (comment->stryng, cur_char);
+ }
+ /* Stop condition: next_char == '*' */
+ for (;;) { /* \*+ */
+ READ_NEXT_CHAR(a_this, &cur_char);
+ ENSURE_PARSING_COND (cur_char == '*');
+ g_string_append_unichar (comment->stryng, cur_char);
+ PEEK_NEXT_CHAR (a_this, &next_char);
+ if (next_char != '*')
+ break;
+ }
+ /* Stop condition: next_char != '*' */
+ for (;;) { /* ([^/][^*]*\*+)* */
+ if (next_char == '/')
+ break;
+ READ_NEXT_CHAR(a_this, &cur_char);
+ g_string_append_unichar (comment->stryng, cur_char);
+ for (;;) { /* [^*]* */
+ PEEK_NEXT_CHAR (a_this, &next_char);
+ if (next_char == '*')
+ break;
READ_NEXT_CHAR (a_this, &cur_char);
- ENSURE_PARSING_COND (cur_char != '*');
- g_string_append_c (comment->stryng, '/');
- g_string_append_unichar (comment->stryng,
- cur_char);
- continue;
+ g_string_append_unichar (comment->stryng, cur_char);
}
-
- /*Detect the end of the comments region */
- if (cur_char == '*') {
+ /* Stop condition: next_char = '*', no need to verify, because peek and read exit to error anyway */
+ for (;;) { /* \*+ */
+ READ_NEXT_CHAR(a_this, &cur_char);
+ ENSURE_PARSING_COND (cur_char == '*');
+ g_string_append_unichar (comment->stryng, cur_char);
PEEK_NEXT_CHAR (a_this, &next_char);
-
- if (next_char == '/') {
- /*
- *end of comments region
- *Now, call the right SAC callback.
- */
- SKIP_CHARS (a_this, 1) ;
- status = CR_OK;
+ if (next_char != '*')
break;
- } else {
- g_string_append_c (comment->stryng,
- '*');
- }
}
- g_string_append_unichar (comment->stryng, cur_char);
+ /* Continue condition: next_char != '*' */
}
+ /* Stop condition: next_char == '\/' */
+ READ_NEXT_CHAR(a_this, &cur_char);
+ g_string_append_unichar (comment->stryng, cur_char);
if (status == CR_OK) {
cr_parsing_location_copy (&comment->location,
@@ -562,39 +573,16 @@ cr_tknzr_parse_unicode_escape (CRTknzr * a_this,
cur_char_val = 10 + (cur_char - 'A');
}
- unicode = unicode * 10 + cur_char_val;
+ unicode = unicode * 16 + cur_char_val;
PEEK_NEXT_CHAR (a_this, &cur_char);
}
- if (occur == 5) {
- /*
- *the unicode escape is 6 digit length
- */
-
- /*
- *parse one space that may
- *appear just after the unicode
- *escape.
- */
- cr_tknzr_parse_w (a_this, &tmp_char_ptr1,
- &tmp_char_ptr2, NULL);
- status = CR_OK;
- } else {
- /*
- *The unicode escape is less than
- *6 digit length. The character
- *that comes right after the escape
- *must be a white space.
- */
- status = cr_tknzr_parse_w (a_this, &tmp_char_ptr1,
- &tmp_char_ptr2, NULL);
- }
-
- if (status == CR_OK) {
- *a_unicode = unicode;
- return CR_OK;
- }
+ /* Eat a whitespace if possible. */
+ cr_tknzr_parse_w (a_this, &tmp_char_ptr1,
+ &tmp_char_ptr2, NULL);
+ *a_unicode = unicode;
+ return CR_OK;
error:
/*
@@ -711,14 +699,13 @@ cr_tknzr_parse_string (CRTknzr * a_this, CRString ** a_str)
guchar next_chars[2] = { 0 };
PEEK_BYTE (a_this, 1, &next_chars[0]);
+ PEEK_BYTE (a_this, 2, &next_chars[1]);
if (next_chars[0] == '\\') {
guchar *tmp_char_ptr1 = NULL,
*tmp_char_ptr2 = NULL;
guint32 esc_code = 0;
- PEEK_BYTE (a_this, 2, &next_chars[1]);
-
if (next_chars[1] == '\'' || next_chars[1] == '"') {
g_string_append_unichar (str->stryng,
next_chars[1]);
@@ -1036,7 +1023,7 @@ cr_tknzr_parse_name (CRTknzr * a_this,
gboolean str_needs_free = FALSE,
is_first_nmchar=TRUE ;
glong i = 0;
- CRParsingLocation loc = {0,0,0} ;
+ CRParsingLocation loc = {0} ;
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& PRIVATE (a_this)->input
@@ -1088,7 +1075,7 @@ cr_tknzr_parse_hash (CRTknzr * a_this, CRString ** a_str)
CRInputPos init_pos;
enum CRStatus status = CR_OK;
gboolean str_needs_free = FALSE;
- CRParsingLocation loc = {0,0,0} ;
+ CRParsingLocation loc = {0} ;
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& PRIVATE (a_this)->input,
@@ -1141,7 +1128,7 @@ cr_tknzr_parse_uri (CRTknzr * a_this,
enum CRStatus status = CR_PARSING_ERROR;
guchar tab[4] = { 0 }, *tmp_ptr1 = NULL, *tmp_ptr2 = NULL;
CRString *str = NULL;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this
&& PRIVATE (a_this)
@@ -1266,7 +1253,7 @@ cr_tknzr_parse_rgb (CRTknzr * a_this, CRRgb ** a_rgb)
blue = 0,
i = 0;
gboolean is_percentage = FALSE;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this && PRIVATE (a_this), CR_BAD_PARAM_ERROR);
@@ -1293,7 +1280,7 @@ cr_tknzr_parse_rgb (CRTknzr * a_this, CRRgb ** a_rgb)
status = cr_tknzr_parse_num (a_this, &num);
ENSURE_PARSING_COND ((status == CR_OK) && (num != NULL));
- red = (glong)num->val;
+ red = num->val;
cr_num_destroy (num);
num = NULL;
@@ -1319,9 +1306,9 @@ cr_tknzr_parse_rgb (CRTknzr * a_this, CRRgb ** a_rgb)
}
if (i == 0) {
- green = (glong)num->val;
+ green = num->val;
} else if (i == 1) {
- blue = (glong)num->val;
+ blue = num->val;
}
if (num) {
@@ -1492,7 +1479,7 @@ cr_tknzr_parse_num (CRTknzr * a_this,
next_char = 0;
gdouble numerator, denominator = 1;
CRInputPos init_pos;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& PRIVATE (a_this)->input,
@@ -1583,7 +1570,9 @@ cr_tknzr_parse_num (CRTknzr * a_this,
CRTknzr *
cr_tknzr_new (CRInput * a_input)
{
- CRTknzr *result = (CRTknzr *)g_try_malloc (sizeof (CRTknzr));
+ CRTknzr *result = NULL;
+
+ result = g_try_malloc (sizeof (CRTknzr));
if (result == NULL) {
cr_utils_trace_info ("Out of memory");
@@ -1592,7 +1581,7 @@ cr_tknzr_new (CRInput * a_input)
memset (result, 0, sizeof (CRTknzr));
- result->priv = (CRTknzrPriv *)g_try_malloc (sizeof (CRTknzrPriv));
+ result->priv = g_try_malloc (sizeof (CRTknzrPriv));
if (result->priv == NULL) {
cr_utils_trace_info ("Out of memory");
@@ -1633,7 +1622,9 @@ cr_tknzr_new_from_uri (const guchar * a_file_uri,
enum CREncoding a_enc)
{
CRTknzr *result = NULL;
- CRInput *input = cr_input_new_from_uri ((gchar *)a_file_uri, a_enc);
+ CRInput *input = NULL;
+
+ input = cr_input_new_from_uri (a_file_uri, a_enc);
g_return_val_if_fail (input != NULL, NULL);
result = cr_tknzr_new (input);
@@ -1906,7 +1897,7 @@ cr_tknzr_consume_chars (CRTknzr * a_this, guint32 a_char, glong * a_nb_char)
}
return cr_input_consume_chars (PRIVATE (a_this)->input,
- a_char, (gulong *)a_nb_char);
+ a_char, a_nb_char);
}
enum CRStatus
@@ -1958,7 +1949,7 @@ cr_tknzr_get_next_token (CRTknzr * a_this, CRToken ** a_tk)
CRInput *input = NULL;
CRString *str = NULL;
CRRgb *rgb = NULL;
- CRParsingLocation location = {0,0,0} ;
+ CRParsingLocation location = {0} ;
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_tk && *a_tk == NULL
@@ -2106,18 +2097,8 @@ cr_tknzr_get_next_token (CRTknzr * a_this, CRToken ** a_tk)
}
goto done;
}
- } else {
- status = cr_tknzr_parse_ident (a_this, &str);
- if (status == CR_OK && str) {
- status = cr_token_set_ident (token, str);
- CHECK_PARSING_STATUS (status, TRUE);
- if (str) {
- cr_parsing_location_copy (&token->location,
- &str->location) ;
- }
- goto done;
- }
- }
+ }
+ goto fallback;
break;
case 'r':
@@ -2136,28 +2117,18 @@ cr_tknzr_get_next_token (CRTknzr * a_this, CRToken ** a_tk)
goto done;
}
- } else {
- status = cr_tknzr_parse_ident (a_this, &str);
- if (status == CR_OK) {
- status = cr_token_set_ident (token, str);
- CHECK_PARSING_STATUS (status, TRUE);
- if (str) {
- cr_parsing_location_copy (&token->location,
- &str->location) ;
- }
- str = NULL;
- goto done;
- }
}
+ goto fallback;
break;
case '<':
- if (BYTE (input, 2, NULL) == '-'
- && BYTE (input, 3, NULL) == '-') {
+ if (BYTE (input, 2, NULL) == '!'
+ && BYTE (input, 3, NULL) == '-'
+ && BYTE (input, 4, NULL) == '-') {
SKIP_CHARS (a_this, 1);
cr_tknzr_get_parsing_location (a_this,
&location) ;
- SKIP_CHARS (a_this, 2);
+ SKIP_CHARS (a_this, 3);
status = cr_token_set_cdo (token);
CHECK_PARSING_STATUS (status, TRUE);
cr_parsing_location_copy (&token->location,
@@ -2390,7 +2361,7 @@ cr_tknzr_get_next_token (CRTknzr * a_this, CRToken ** a_tk)
next_bytes[0] = BYTE (input, 1, NULL);
next_bytes[1] = BYTE (input, 2, NULL);
next_bytes[2] = BYTE (input, 3, NULL);
- next_bytes[3] = BYTE (input, 4, NULL);
+ next_bytes[3] = BYTE (input, 3, NULL);
if (next_bytes[0] == 'e'
&& next_bytes[1] == 'm') {
@@ -2538,6 +2509,7 @@ cr_tknzr_get_next_token (CRTknzr * a_this, CRToken ** a_tk)
break;
default:
+ fallback:
/*process the fallback cases here */
if (next_char == '\\'
diff --git a/src/cr-token.c b/src/cr-token.c
index af95751..e240ab8 100644
--- a/src/cr-token.c
+++ b/src/cr-token.c
@@ -46,6 +46,7 @@ cr_token_clear (CRToken * a_this)
switch (a_this->type) {
case S_TK:
case CDO_TK:
+ case CDC_TK:
case INCLUDES_TK:
case DASHMATCH_TK:
case PAGE_SYM_TK:
@@ -132,7 +133,9 @@ cr_token_clear (CRToken * a_this)
CRToken *
cr_token_new (void)
{
- CRToken *result = (CRToken *)g_try_malloc (sizeof (CRToken));
+ CRToken *result = NULL;
+
+ result = g_try_malloc (sizeof (CRToken));
if (result == NULL) {
cr_utils_trace_info ("Out of memory");
diff --git a/src/cr-utils.c b/src/cr-utils.c
index 487cf4b..ed4be3e 100644
--- a/src/cr-utils.c
+++ b/src/cr-utils.c
@@ -725,7 +725,7 @@ cr_utils_utf8_str_to_ucs4 (const guchar * a_in,
g_return_val_if_fail (status == CR_OK, status);
- *a_out = (guint32 *) g_malloc0 (*a_out_len * sizeof (guint32));
+ *a_out = g_malloc0 (*a_out_len * sizeof (guint32));
status = cr_utils_utf8_to_ucs4 (a_in, a_in_len, *a_out, a_out_len);
@@ -971,7 +971,7 @@ cr_utils_ucs1_str_to_utf8 (const guchar * a_in,
in_len = *a_in_len;
- *a_out = (guchar *) g_malloc0 (out_len);
+ *a_out = g_malloc0 (out_len);
status = cr_utils_ucs1_to_utf8 (a_in, a_in_len, *a_out, &out_len);
@@ -1172,7 +1172,7 @@ cr_utils_utf8_str_to_ucs1 (const guchar * a_in,
g_return_val_if_fail (status == CR_OK, status);
- *a_out = (guchar *) g_malloc0 (*a_out_len * sizeof (guint32));
+ *a_out = g_malloc0 (*a_out_len * sizeof (guint32));
status = cr_utils_utf8_to_ucs1 (a_in, a_in_len, *a_out, a_out_len);
return status;
@@ -1299,10 +1299,10 @@ cr_utils_dump_n_chars2 (guchar a_char, GString * a_string, glong a_nb)
*@param a_list_of_strings the list of strings to be duplicated.
*/
GList *
-cr_utils_dup_glist_of_string (GList * a_list_of_strings)
+cr_utils_dup_glist_of_string (GList const * a_list_of_strings)
{
- GList *cur = NULL,
- *result = NULL;
+ GList const *cur = NULL;
+ GList *result = NULL;
g_return_val_if_fail (a_list_of_strings, NULL);
@@ -1325,16 +1325,17 @@ cr_utils_dup_glist_of_string (GList * a_list_of_strings)
*happened.
*/
GList *
-cr_utils_dup_glist_of_cr_string (GList * a_list_of_strings)
+cr_utils_dup_glist_of_cr_string (GList const * a_list_of_strings)
{
- GList *cur = NULL, *result = NULL;
+ GList const *cur = NULL;
+ GList *result = NULL;
g_return_val_if_fail (a_list_of_strings, NULL);
for (cur = a_list_of_strings; cur; cur = cur->next) {
CRString *str = NULL;
- str = cr_string_dup ((CRString *) cur->data) ;
+ str = cr_string_dup ((CRString const *) cur->data) ;
if (str)
result = g_list_append (result, str);
}
diff --git a/src/cr-utils.h b/src/cr-utils.h
index 060842a..54aa249 100644
--- a/src/cr-utils.h
+++ b/src/cr-utils.h
@@ -26,10 +26,7 @@
#include <stdio.h>
#include <glib.h>
-/*
- * We're disabling this #include for Inkscape: see comment in libcroco.h.
-//#include "libcroco-config.h"
- */
+#include "libcroco-config.h"
G_BEGIN_DECLS
@@ -239,10 +236,10 @@ cr_utils_dump_n_chars2 (guchar a_char,
GString *a_string,
glong a_nb) ;
GList *
-cr_utils_dup_glist_of_string (GList *a_list) ;
+cr_utils_dup_glist_of_string (GList const *a_list) ;
GList *
-cr_utils_dup_glist_of_cr_string (GList * a_list_of_strings) ;
+cr_utils_dup_glist_of_cr_string (GList const * a_list_of_strings) ;
G_END_DECLS