reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef SkSVGAttribute_DEFINED |
| 18 | #define SkSVGAttribute_DEFINED |
| 19 | |
| 20 | #include "SkTypes.h" |
| 21 | |
| 22 | struct SkSVGAttribute { |
| 23 | const char* fName; |
| 24 | #ifdef SK_DEBUG |
| 25 | size_t fOffset; |
| 26 | #endif |
| 27 | }; |
| 28 | |
| 29 | #ifndef SK_OFFSETOF |
| 30 | #define SK_OFFSETOF(a, b) (((size_t) (&(((a*) 1)->b)))-1) |
| 31 | #endif |
| 32 | |
| 33 | #ifdef SK_DEBUG |
| 34 | #define SVG_ATTRIBUTE(attr) { #attr, SK_OFFSETOF(BASE_CLASS, f_##attr) } |
| 35 | #define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr, SK_OFFSETOF(BASE_CLASS, cAttr) } |
| 36 | #else |
| 37 | #define SVG_ATTRIBUTE(attr) { #attr } |
| 38 | #define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr } |
| 39 | #endif |
| 40 | |
| 41 | #define SVG_ADD_ATTRIBUTE(attr) \ |
| 42 | if (f_##attr.size() > 0) \ |
| 43 | parser._addAttributeLen(#attr, f_##attr.c_str(), f_##attr.size()) |
| 44 | |
| 45 | #define SVG_ADD_ATTRIBUTE_ALIAS(attr, alias) \ |
| 46 | if (f_##alias.size() > 0) \ |
| 47 | parser._addAttributeLen(#attr, f_##alias.c_str(), f_##alias.size()) |
| 48 | |
| 49 | #endif // SkSVGAttribute_DEFINED |