Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * This file was generated by LibCSS gen_parser
  3.  *
  4.  * Generated from:
  5.  *
  6.  * side:op GENERIC: IDENT:( INHERIT: AUTO:0,BOTTOM_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:BOTTOM_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ LENGTH_UNIT:)
  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 <assert.h>
  14. #include <string.h>
  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 side
  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.  * \param op     Bytecode OpCode for CSS property to encode
  29.  * \return CSS_OK on success,
  30.  *         CSS_NOMEM on memory exhaustion,
  31.  *         CSS_INVALID if the input is not valid
  32.  *
  33.  * Post condition: \a *ctx is updated with the next token to process
  34.  *                 If the input is invalid, then \a *ctx remains unchanged.
  35.  */
  36. css_error css__parse_side(css_language *c,
  37.                 const parserutils_vector *vector, int *ctx,
  38.                 css_style *result, enum css_properties_e op)
  39. {
  40.         int orig_ctx = *ctx;
  41.         css_error error;
  42.         const css_token *token;
  43.         bool match;
  44.  
  45.         token = parserutils_vector_iterate(vector, ctx);
  46.         if (token == NULL) {
  47.                 *ctx = orig_ctx;
  48.                 return CSS_INVALID;
  49.         }
  50.  
  51.         if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[INHERIT], &match) == lwc_error_ok && match)) {
  52.                         error = css_stylesheet_style_inherit(result, op);
  53.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[AUTO], &match) == lwc_error_ok && match)) {
  54.                         error = css__stylesheet_style_appendOPV(result, op, 0,BOTTOM_AUTO);
  55.         } else {
  56.                 css_fixed length = 0;
  57.                 uint32_t unit = 0;
  58.                 *ctx = orig_ctx;
  59.  
  60.                 error = css__parse_unit_specifier(c, vector, ctx, UNIT_PX, &length, &unit);
  61.                 if (error != CSS_OK) {
  62.                         *ctx = orig_ctx;
  63.                         return error;
  64.                 }
  65.  
  66.                 if (unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ) {
  67.                         *ctx = orig_ctx;
  68.                         return CSS_INVALID;
  69.                 }
  70.  
  71.                 error = css__stylesheet_style_appendOPV(result, op, 0, BOTTOM_SET);
  72.                 if (error != CSS_OK) {
  73.                         *ctx = orig_ctx;
  74.                         return error;
  75.                 }
  76.  
  77.                 error = css__stylesheet_style_vappend(result, 2, length, unit);
  78.         }
  79.  
  80.         if (error != CSS_OK)
  81.                 *ctx = orig_ctx;
  82.        
  83.         return error;
  84. }
  85.  
  86.