afd7c74972
The motivation for this was to remove SK_OFFSETOF from SkTypes, but this CL is mostly about cleaning up our use of offsetof generally. SK_OFFSETOF is removed to SkTypes and added to the two places it is actually used (for the non standard behavior of finding the offset of fields in types which are not standard layout). Older versions of gcc required POD for offsetof to be used without warning. Newer versions require the more relaxed standard layout. Now that we no longer build on older versions of gcc, remove the old warning suppressions. PODMatrix is renamed to AggregateMatrix. SkMatrix is already POD (trivial and standard layout). The PODMatrix name implies that the POD-ness is needed for the offsetof, but it is actually the aggregate attribute which is needed for compile time constant initialization. This makes it more obvious that this can be revisited after we can rely on constexpr constructors. This also adds skstd::declval since this allows removal of existing awkward code which casts a constant to a pointer to find the size of a field. TBR=reed@google.com No API change, only removes unused macro. Review URL: https://codereview.chromium.org/1309523003
44 lines
1.1 KiB
C
44 lines
1.1 KiB
C
|
|
/*
|
|
* Copyright 2006 The Android Open Source Project
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
#ifndef SkSVGAttribute_DEFINED
|
|
#define SkSVGAttribute_DEFINED
|
|
|
|
#include "SkTypes.h"
|
|
|
|
struct SkSVGAttribute {
|
|
const char* fName;
|
|
#ifdef SK_DEBUG
|
|
size_t fOffset;
|
|
#endif
|
|
};
|
|
|
|
#ifndef SK_OFFSETOF
|
|
// This is offsetof for types which are not standard layout.
|
|
#define SK_OFFSETOF(type, field) (size_t)((char*)&(((type*)1024)->field) - (char*)1024)
|
|
#endif
|
|
|
|
#ifdef SK_DEBUG
|
|
#define SVG_ATTRIBUTE(attr) { #attr, SK_OFFSETOF(BASE_CLASS, f_##attr) }
|
|
#define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr, SK_OFFSETOF(BASE_CLASS, cAttr) }
|
|
#else
|
|
#define SVG_ATTRIBUTE(attr) { #attr }
|
|
#define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr }
|
|
#endif
|
|
|
|
#define SVG_ADD_ATTRIBUTE(attr) \
|
|
if (f_##attr.size() > 0) \
|
|
parser._addAttributeLen(#attr, f_##attr.c_str(), f_##attr.size())
|
|
|
|
#define SVG_ADD_ATTRIBUTE_ALIAS(attr, alias) \
|
|
if (f_##alias.size() > 0) \
|
|
parser._addAttributeLen(#attr, f_##alias.c_str(), f_##alias.size())
|
|
|
|
#endif // SkSVGAttribute_DEFINED
|