changeset 1000:e9718df7942c

replace CSS_LENGTH_* macros with inline functions
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Thu, 12 Mar 2009 22:23:00 +0100
parents bec68cc06ae2
children d466f3665808
files src/css.hh src/cssparser.cc
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/css.hh	Thu Mar 12 21:18:00 2009 +0100
+++ b/src/css.hh	Thu Mar 12 22:23:00 2009 +0100
@@ -56,7 +56,7 @@
 
 typedef int CssLength;
 
-enum {
+typedef enum {
    CSS_LENGTH_TYPE_PX,
    CSS_LENGTH_TYPE_MM,         /* "cm", "in", "pt" and "pc" are converted into
                                   millimeters. */
@@ -66,11 +66,19 @@
    CSS_LENGTH_TYPE_RELATIVE,   /* This does not exist in CSS but
                                   is used in HTML */
    CSS_LENGTH_TYPE_AUTO        /* This can be used as a simple value. */
-};
+} CssLengthType;
 
-#define CSS_CREATE_LENGTH(v, t) ( ( (int)((v) * (1 << 19)) & ~7 ) | (t) )
-#define CSS_LENGTH_VALUE(l)     ( ( (float)((l) & ~7) ) / (1 << 19) )
-#define CSS_LENGTH_TYPE(l)      ((l) & 7)
+inline CssLength CSS_CREATE_LENGTH (float v, CssLengthType t) {
+   return ((int) (v * (1 << 19)) & ~7 ) | t;
+}
+
+inline float CSS_LENGTH_VALUE (CssLength l) {
+   return  ((float)(l & ~7)) / (1 << 19);
+}
+
+inline CssLengthType CSS_LENGTH_TYPE (CssLength l) {
+   return (CssLengthType) (l & 7);
+}
 
 typedef enum {
    CSS_PROPERTY_BACKGROUND_ATTACHMENT,
--- a/src/cssparser.cc	Thu Mar 12 21:18:00 2009 +0100
+++ b/src/cssparser.cc	Thu Mar 12 22:23:00 2009 +0100
@@ -670,10 +670,10 @@
                             CssValueType type,
                             CssPropertyValue * val)
 {
-   int i, lentype;
+   CssLengthType lentype;
    bool found, ret = false;
    float fval;
-   int ival, err = 1;
+   int i, ival, err = 1;
 
    switch (type) {
    case CSS_TYPE_ENUM: