Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3584 sourcerer 1
/*
2
 * This file was generated by LibCSS gen_parser
3
 *
4
 * Generated from:
5
 *
6
 * counter_increment:CSS_PROP_COUNTER_INCREMENT IDENT:( INHERIT: NONE:0,COUNTER_INCREMENT_NONE IDENT:) IDENT_LIST:( STRING_OPTNUM:COUNTER_INCREMENT_NAMED 1:COUNTER_INCREMENT_NONE IDENT_LIST:)
7
 *
8
 * Licensed under the MIT License,
9
 *		  http://www.opensource.org/licenses/mit-license.php
10
 * Copyright 2010 The NetSurf Browser Project.
11
 */
12
 
13
#include 
14
#include 
15
 
16
#include "bytecode/bytecode.h"
17
#include "bytecode/opcodes.h"
18
#include "parse/properties/properties.h"
19
#include "parse/properties/utils.h"
20
 
21
/**
22
 * Parse counter_increment
23
 *
24
 * \param c	  Parsing context
25
 * \param vector  Vector of tokens to process
26
 * \param ctx	  Pointer to vector iteration context
27
 * \param result  resulting style
28
 * \return CSS_OK on success,
29
 *	   CSS_NOMEM on memory exhaustion,
30
 *	   CSS_INVALID if the input is not valid
31
 *
32
 * Post condition: \a *ctx is updated with the next token to process
33
 *		   If the input is invalid, then \a *ctx remains unchanged.
34
 */
35
css_error css__parse_counter_increment(css_language *c,
36
		const parserutils_vector *vector, int *ctx,
37
		css_style *result)
38
{
39
	int orig_ctx = *ctx;
40
	css_error error;
41
	const css_token *token;
42
	bool match;
43
 
44
	token = parserutils_vector_iterate(vector, ctx);
45
	if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT))) {
46
		*ctx = orig_ctx;
47
		return CSS_INVALID;
48
	}
49
 
50
	if ((lwc_string_caseless_isequal(token->idata, c->strings[INHERIT], &match) == lwc_error_ok && match)) {
51
			error = css_stylesheet_style_inherit(result, CSS_PROP_COUNTER_INCREMENT);
52
	} else if ((lwc_string_caseless_isequal(token->idata, c->strings[NONE], &match) == lwc_error_ok && match)) {
53
			error = css__stylesheet_style_appendOPV(result, CSS_PROP_COUNTER_INCREMENT, 0,COUNTER_INCREMENT_NONE);
54
	} else {
55
		error = css__stylesheet_style_appendOPV(result, CSS_PROP_COUNTER_INCREMENT, 0, COUNTER_INCREMENT_NAMED);
56
		if (error != CSS_OK) {
57
			*ctx = orig_ctx;
58
			return error;
59
		}
60
 
61
		while ((token != NULL) && (token->type == CSS_TOKEN_IDENT)) {
62
			uint32_t snumber;
63
			css_fixed num;
64
			int pctx;
65
 
66
			error = css__stylesheet_string_add(c->sheet, lwc_string_ref(token->idata), &snumber);
67
			if (error != CSS_OK) {
68
				*ctx = orig_ctx;
69
				return error;
70
			}
71
 
72
			error = css__stylesheet_style_append(result, snumber);
73
			if (error != CSS_OK) {
74
				*ctx = orig_ctx;
75
				return error;
76
			}
77
 
78
			consumeWhitespace(vector, ctx);
79
 
80
			pctx = *ctx;
81
			token = parserutils_vector_iterate(vector, ctx);
82
			if ((token != NULL) && (token->type == CSS_TOKEN_NUMBER)) {
83
				size_t consumed = 0;
84
 
85
				num = css__number_from_lwc_string(token->idata, true, &consumed);
86
				if (consumed != lwc_string_length(token->idata)) {
87
					*ctx = orig_ctx;
88
					return CSS_INVALID;
89
				}
90
				consumeWhitespace(vector, ctx);
91
 
92
				pctx = *ctx;
93
				token = parserutils_vector_iterate(vector, ctx);
94
			} else {
95
				num = INTTOFIX(1);
96
			}
97
 
98
			error = css__stylesheet_style_append(result, num);
99
			if (error != CSS_OK) {
100
				*ctx = orig_ctx;
101
				return error;
102
			}
103
 
104
			if (token == NULL)
105
				break;
106
 
107
			if (token->type == CSS_TOKEN_IDENT) {
108
				error = css__stylesheet_style_append(result, COUNTER_INCREMENT_NAMED);
109
				if (error != CSS_OK) {
110
					*ctx = orig_ctx;
111
					return error;
112
				}
113
			} else {
114
				*ctx = pctx; /* rewind one token back */
115
			}
116
		}
117
 
118
		error = css__stylesheet_style_append(result, COUNTER_INCREMENT_NONE);
119
	}
120
 
121
	if (error != CSS_OK)
122
		*ctx = orig_ctx;
123
 
124
	return error;
125
}
126