summaryrefslogtreecommitdiff
path: root/src/cr-om-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cr-om-parser.c')
-rw-r--r--src/cr-om-parser.c130
1 files changed, 57 insertions, 73 deletions
diff --git a/src/cr-om-parser.c b/src/cr-om-parser.c
index a62e98d..b8d70e3 100644
--- a/src/cr-om-parser.c
+++ b/src/cr-om-parser.c
@@ -25,9 +25,10 @@
#include "cr-utils.h"
#include "cr-om-parser.h"
+#define UNUSED(_param) ((void)(_param))
+
/**
- *@CROMParser:
- *
+ *@file
*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
@@ -111,9 +112,8 @@ struct _ParsingContext {
static ParsingContext *
new_parsing_context (void)
{
- ParsingContext *result = NULL;
-
- result = g_try_malloc (sizeof (ParsingContext));
+ ParsingContext *result =
+ (ParsingContext *)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;
- g_return_if_fail (a_this);
+ UNUSED(a_location);
g_return_if_fail (a_this);
ctxtptr = &ctxt;
@@ -315,6 +315,8 @@ 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);
@@ -349,6 +351,8 @@ 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);
@@ -426,6 +430,8 @@ 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);
@@ -493,6 +499,8 @@ 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);
@@ -762,19 +770,16 @@ unrecoverable_error (CRDocHandler * a_this)
********************************************/
/**
- * cr_om_parser_new:
- *@a_input: the input stream.
- *
*Constructor of the CROMParser.
- *Returns the newly built instance of #CROMParser.
+ *@param a_input the input stream.
+ *@return the newly built instance of #CROMParser.
*/
CROMParser *
cr_om_parser_new (CRInput * a_input)
{
- CROMParser *result = NULL;
enum CRStatus status = CR_OK;
- result = g_try_malloc (sizeof (CROMParser));
+ CROMParser *result = (CROMParser *)g_try_malloc (sizeof (CROMParser));
if (!result) {
cr_utils_trace_info ("Out of memory");
@@ -782,7 +787,7 @@ cr_om_parser_new (CRInput * a_input)
}
memset (result, 0, sizeof (CROMParser));
- PRIVATE (result) = g_try_malloc (sizeof (CROMParserPriv));
+ PRIVATE (result) = (CROMParserPriv *)g_try_malloc (sizeof (CROMParserPriv));
if (!PRIVATE (result)) {
cr_utils_trace_info ("Out of memory");
@@ -816,16 +821,13 @@ 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.
- *
- *Returns CR_OK upon successfull completion, an error code otherwise.
+ *@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.
*/
enum CRStatus
cr_om_parser_parse_buf (CROMParser * a_this,
@@ -866,15 +868,12 @@ 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.
- *
- *Returns CR_OK upon successfull completion, an error code otherwise.
+ *@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.
*/
enum CRStatus
cr_om_parser_simply_parse_buf (const guchar * a_buf,
@@ -904,18 +903,16 @@ cr_om_parser_simply_parse_buf (const guchar * a_buf,
}
/**
- * 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)
- *@a_enc: the encoding of the file.
- *@a_result: out parameter. A pointer
- *the build css object model.
- *
*Parses a css2 stylesheet contained
*in a file.
- *
- * Returns CR_OK upon succesful completion, an error code otherwise.
+ *@param a_this the current instance of the cssom parser.
+ *@param 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
+ *the build css object model.
+ *@param CR_OK upon successfull completion, an error code
+ *otherwise.
*/
enum CRStatus
cr_om_parser_parse_file (CROMParser * a_this,
@@ -955,15 +952,12 @@ cr_om_parser_parse_file (CROMParser * a_this,
}
/**
- * 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.
- *
*The simpler method to parse a css2 file.
- *
- *Returns CR_OK upon successfull completion, an error code otherwise.
+ *@param a_file_path the css2 local file path.
+ *@param a_enc the file encoding.
+ *@param 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.
*Note that this method uses cr_om_parser_parse_file() so both methods
*have the same return values.
*/
@@ -993,18 +987,14 @@ cr_om_parser_simply_parse_file (const guchar * a_file_path,
}
/**
- * 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
- *
*Parses three sheets located by their paths and build a cascade
- *
- *Returns CR_OK upon successful completion, an error code otherwise
+ *@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
+ *was okay
+ *@return CR_OK upon successful completion, an error code otherwise
*/
enum CRStatus
cr_om_parser_parse_paths_to_cascade (CROMParser * a_this,
@@ -1024,7 +1014,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 (CRStyleSheet*) * 3);
+ memset (sheets, 0, sizeof (sheets));
paths[0] = (guchar *) a_author_path;
paths[1] = (guchar *) a_user_path;
paths[2] = (guchar *) a_ua_path;
@@ -1053,17 +1043,13 @@ cr_om_parser_parse_paths_to_cascade (CROMParser * a_this,
}
/**
- * 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
- *
*Parses three sheets located by their paths and build a cascade
- *
- *Returns CR_OK upon successful completion, an error code otherwise
+ *@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
+ *was okay
+ *@return CR_OK upon successful completion, an error code otherwise
*/
enum CRStatus
cr_om_parser_simply_parse_paths_to_cascade (const guchar * a_author_path,
@@ -1094,10 +1080,8 @@ 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)