Home | History | Annotate | Download | only in parser
      1 
      2 /*
      3  * Copyright 2006 The Android Open Source Project
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 #ifndef SkSVGAttribute_DEFINED
     11 #define SkSVGAttribute_DEFINED
     12 
     13 #include "SkTypes.h"
     14 
     15 struct SkSVGAttribute {
     16     const char* fName;
     17 #ifdef SK_DEBUG
     18     size_t fOffset;
     19 #endif
     20 };
     21 
     22 #ifndef SK_OFFSETOF
     23     // This is offsetof for types which are not standard layout.
     24     #define SK_OFFSETOF(type, field) (size_t)((char*)&(((type*)1024)->field) - (char*)1024)
     25 #endif
     26 
     27 #ifdef SK_DEBUG
     28 #define SVG_ATTRIBUTE(attr) { #attr, SK_OFFSETOF(BASE_CLASS, f_##attr) }
     29 #define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr, SK_OFFSETOF(BASE_CLASS, cAttr) }
     30 #else
     31 #define SVG_ATTRIBUTE(attr) { #attr }
     32 #define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr }
     33 #endif
     34 
     35 #define SVG_ADD_ATTRIBUTE(attr) \
     36     if (f_##attr.size() > 0) \
     37         parser._addAttributeLen(#attr, f_##attr.c_str(), f_##attr.size())
     38 
     39 #define SVG_ADD_ATTRIBUTE_ALIAS(attr, alias) \
     40     if (f_##alias.size() > 0) \
     41         parser._addAttributeLen(#attr, f_##alias.c_str(), f_##alias.size())
     42 
     43 #endif // SkSVGAttribute_DEFINED
     44