From afd7c749724ccceb88761c52c196ba371be5fb1c Mon Sep 17 00:00:00 2001 From: bungeman Date: Tue, 25 Aug 2015 12:05:55 -0700 Subject: Remove SK_OFFSETOF from SkTypes, clean up offsetof usage. 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 --- include/svg/parser/SkSVGAttribute.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/svg') diff --git a/include/svg/parser/SkSVGAttribute.h b/include/svg/parser/SkSVGAttribute.h index 940ca5a951..5ba2916b74 100644 --- a/include/svg/parser/SkSVGAttribute.h +++ b/include/svg/parser/SkSVGAttribute.h @@ -20,7 +20,8 @@ struct SkSVGAttribute { }; #ifndef SK_OFFSETOF -#define SK_OFFSETOF(a, b) (((size_t) (&(((a*) 1)->b)))-1) + // 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 -- cgit v1.2.3