Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(961)

Unified Diff: src/animator/SkMemberInfo.h

Issue 1309523003: Remove SK_OFFSETOF from SkTypes, clean up offsetof usage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Speling Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/animator/SkDisplayInclude.cpp ('k') | src/core/SkMatrix.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/animator/SkMemberInfo.h
diff --git a/src/animator/SkMemberInfo.h b/src/animator/SkMemberInfo.h
index e07c32270d2ab65393bb7ffdf4a9dd35a0bda9c5..3588da2515b09ffc228714477ed95c62f1c2330a 100644
--- a/src/animator/SkMemberInfo.h
+++ b/src/animator/SkMemberInfo.h
@@ -104,13 +104,18 @@ struct SkMemberInfo {
// static bool SetValue(void* value, const char* name, SkDisplayTypes , int count);
};
+#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
+
#define SK_MEMBER(_member, _type) \
{ #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_##_type, \
- sizeof(((BASE_CLASS*) 1)->_member) / sizeof(SkScalar) }
+ sizeof(skstd::declval<BASE_CLASS>()._member) / sizeof(SkScalar) }
#define SK_MEMBER_ALIAS(_member, _alias, _type) \
{ #_member, SK_OFFSETOF(BASE_CLASS, _alias), SkType_##_type, \
- sizeof(((BASE_CLASS*) 1)->_alias) / sizeof(SkScalar) }
+ sizeof(skstd::declval<BASE_CLASS>()._alias) / sizeof(SkScalar) }
#define SK_MEMBER_ARRAY(_member, _type) \
{ #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_Array, \
« no previous file with comments | « src/animator/SkDisplayInclude.cpp ('k') | src/core/SkMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698