1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */
8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkMemberInfo_DEFINED
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkMemberInfo_DEFINED
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined SK_BUILD_CONDENSED
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    #define SK_USE_CONDENSED_INFO 0
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDisplayType.h"
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScript.h"
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkString.h"
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkIntArray.h"
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAnimateMaker;
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDisplayable;
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkScriptEngine;
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// temporary hacks until name change is more complete
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkFloat SkScalar
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkInt SkS32
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkMemberInfo {
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //!!! alternative:
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // if fCount == 0, record is member property
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // then fType can be type, so caller doesn't have to check
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if SK_USE_CONDENSED_INFO == 0
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const char* fName;  // may be NULL for anonymous functions
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    size_t fOffset; // if negative, is index into member pointer table (for properties and functions)
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDisplayTypes fType;
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int fCount;         // for properties, actual type (count is always assumed to be 1)
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    unsigned char fName;
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    signed char fOffset;
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    unsigned char fType;
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    signed char fCount;
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDisplayTypes arrayType() const {
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkASSERT(fType == SkType_Array);
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return (SkDisplayTypes) fCount;  // hack, but worth it?
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int functionIndex() const {
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkASSERT(fType == SkType_MemberFunction);
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return (signed) fOffset > 0 ? -1 + (int) fOffset : -1 - (int) fOffset;
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool getArrayValue(const SkDisplayable* displayable, int index, SkOperand* value) const;
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int getCount() const {
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return fType == SkType_MemberProperty || fType == SkType_Array ||
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fType == SkType_MemberFunction ? 1 : fCount;
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const SkMemberInfo* getInherited() const;
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    size_t getSize(const SkDisplayable* ) const;
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void getString(const SkDisplayable* , SkString** string) const;
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDisplayTypes getType() const {
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return fType == SkType_MemberProperty || fType == SkType_Array ||
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fType == SkType_MemberFunction ? (SkDisplayTypes) fCount : (SkDisplayTypes) fType;
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void getValue(const SkDisplayable* , SkOperand values[], int count) const;
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isEnum() const;
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const char* mapEnums(const char* match, int* value) const;
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void* memberData(const SkDisplayable* displayable) const {
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkASSERT(fType != SkType_MemberProperty &&  fType != SkType_MemberFunction);
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return (void*) ((const char*) displayable + fOffset);
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int propertyIndex() const {
738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkASSERT(fType == SkType_MemberProperty);
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return (signed) fOffset > 0 ? -1 + (int) fOffset : -1 - (int) fOffset;
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDisplayTypes propertyType() const {
778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkASSERT(fType == SkType_MemberProperty || fType == SkType_Array);
788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return (SkDisplayTypes) fCount;  // hack, but worth it?
798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setMemberData(SkDisplayable* displayable, const void* child, size_t size) const {
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkASSERT(fType != SkType_MemberProperty &&  fType != SkType_MemberFunction);
828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        memcpy((char*) displayable + fOffset, child, size);
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setString(SkDisplayable* , SkString* ) const;
858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setValue(SkDisplayable* , const SkOperand values[], int count) const;
86d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    bool setValue(SkAnimateMaker& , SkTDOperandArray* storage,
87d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        int storageOffset, int maxStorage, SkDisplayable* ,
888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDisplayTypes outType, const char value[], size_t len) const;
89d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    bool setValue(SkAnimateMaker& , SkTDOperandArray* storage,
90d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        int storageOffset, int maxStorage, SkDisplayable* ,
918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDisplayTypes outType, SkString& str) const;
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//  void setValue(SkDisplayable* , const char value[], const char name[]) const;
93d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    bool writeValue(SkDisplayable* displayable, SkTDOperandArray* arrayStorage,
94d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        int storageOffset, int maxStorage, void* untypedStorage, SkDisplayTypes outType,
958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkScriptValue& scriptValue) const;
968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if SK_USE_CONDENSED_INFO == 0
978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo* Find(const SkMemberInfo [], int count, int* index);
988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo* Find(const SkMemberInfo [], int count, const char** name);
998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo* Find(SkDisplayTypes type, int* index);
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo* Find(SkDisplayTypes type, const char** name);
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static size_t GetSize(SkDisplayTypes type); // size of simple types only
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//  static bool SetValue(void* value, const char* name, SkDisplayTypes , int count);
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_MEMBER(_member, _type) \
1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    { #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_##_type, \
1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    sizeof(((BASE_CLASS*) 1)->_member) / sizeof(SkScalar) }
1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_MEMBER_ALIAS(_member, _alias, _type) \
1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    { #_member, SK_OFFSETOF(BASE_CLASS, _alias), SkType_##_type, \
1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    sizeof(((BASE_CLASS*) 1)->_alias) / sizeof(SkScalar) }
1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_MEMBER_ARRAY(_member, _type) \
1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    { #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_Array, \
1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    (int) SkType_##_type }
1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_MEMBER_INHERITED \
1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    { (const char*) INHERITED::fInfo, 0, SkType_BaseClassInfo, INHERITED::fInfoCount }
1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
122d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com// #define SK_MEMBER_KEY_TYPE(_member, _type)
1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//  {#_member, (size_t) -1, SkType_##_type, 0}
1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_FUNCTION(_member) \
1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    k_##_member##Function
1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_PROPERTY(_member) \
1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    k_##_member##Property
1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_MEMBER_DYNAMIC_FUNCTION(_member, _type) \
1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    {#_member, (size_t) (+1 + SK_FUNCTION(_member)), SkType_MemberFunction, \
1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    (int) SkType_##_type }
1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_MEMBER_DYNAMIC_PROPERTY(_member, _type) \
1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    {#_member, (size_t) (1 + SK_PROPERTY(_member)), SkType_MemberProperty, \
1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    (int) SkType_##_type }
1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_MEMBER_FUNCTION(_member, _type) \
1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    {#_member, (size_t) (-1 - SK_FUNCTION(_member)), SkType_MemberFunction, \
1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    (int) SkType_##_type }
1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_MEMBER_PROPERTY(_member, _type) \
1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    {#_member, (size_t) (-1 - SK_PROPERTY(_member)), SkType_MemberProperty, \
1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    (int) SkType_##_type }
1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if SK_USE_CONDENSED_INFO == 0
1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_PRIVATE_MEMBER_INFO(_type) \
1508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
1518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo fInfo[]; \
1528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const int fInfoCount; \
1538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index); \
1548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]); \
1558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef Sk##_type BASE_CLASS
1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_MEMBER_INFO(_type) \
1588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
1598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo fInfo[]; \
1608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const int fInfoCount; \
1618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index); \
1628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]); \
1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef Sk##_type BASE_CLASS
1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_DRAW_MEMBER_INFO(_type) \
1678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
1688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo fInfo[]; \
1698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const int fInfoCount; \
1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index); \
1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]); \
1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkDraw##_type BASE_CLASS
1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_DISPLAY_MEMBER_INFO(_type) \
1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo fInfo[]; \
1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const int fInfoCount; \
1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index); \
1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]); \
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkDisplay##_type BASE_CLASS
1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_EMPTY_MEMBER_INFO(_type) \
1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return SkType_##_type; }
187d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com
1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_EXTRAS_MEMBER_INFO(_type) \
1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo fInfo[]; \
1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const int fInfoCount; \
1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index); \
1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]); \
1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDisplayTypes fType; \
1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return fType; } \
1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef _type BASE_CLASS
1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_NO_VIRTUALS_MEMBER_INFO(_type) \
1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const SkMemberInfo fInfo[]; \
2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static const int fInfoCount; \
2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef Sk##_type BASE_CLASS
2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DEFINE_GET_MEMBER(_class) \
2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const SkMemberInfo* _class::getMember(int index) { \
2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const SkMemberInfo* result = SkMemberInfo::Find(fInfo, SK_ARRAY_COUNT(fInfo), &index); \
2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return result; \
2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    } \
2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const SkMemberInfo* _class::getMember(const char name[]) { \
2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const SkMemberInfo* result = SkMemberInfo::Find(fInfo, SK_ARRAY_COUNT(fInfo), &name); \
2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return result; \
2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    } \
2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const int _class::fInfoCount = SK_ARRAY_COUNT(fInfo)
2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DEFINE_NO_VIRTUALS_GET_MEMBER(_class) \
2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const int _class::fInfoCount = SK_ARRAY_COUNT(fInfo)
2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#else
2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_PRIVATE_MEMBER_INFO(_type) \
2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef Sk##_type BASE_CLASS
2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_MEMBER_INFO(_type) \
2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index) { \
2278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkDisplayType::GetMember(NULL, SkType_##_type, &index); } \
2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]) { \
2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkDisplayType::GetMember(NULL, SkType_##_type, &name); } \
2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef Sk##_type BASE_CLASS
2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_DRAW_MEMBER_INFO(_type) \
2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index) { \
2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkDisplayType::GetMember(NULL, SkType_##_type, &index); } \
2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]) { \
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkDisplayType::GetMember(NULL, SkType_##_type, &name); } \
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkDraw##_type BASE_CLASS
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_DISPLAY_MEMBER_INFO(_type) \
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index) { \
2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkDisplayType::GetMember(NULL, SkType_##_type, &index); } \
2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]) { \
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkDisplayType::GetMember(NULL, SkType_##_type, &name); } \
2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkDisplay##_type BASE_CLASS
2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_EXTRAS_MEMBER_INFO(_type) \
2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(int index) { \
2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkDisplayType::GetMember(NULL, SkType_##_type, &index); } \
2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual const SkMemberInfo* getMember(const char name[]) { \
2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkDisplayType::GetMember(NULL, fType, &name); } \
2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDisplayTypes fType; \
2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual SkDisplayTypes getType() const { return fType; } \
2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef _type BASE_CLASS
2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DECLARE_NO_VIRTUALS_MEMBER_INFO(_type) \
2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: \
2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef Sk##_type BASE_CLASS
2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DEFINE_GET_MEMBER(_class)
2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define DEFINE_NO_VIRTUALS_GET_MEMBER(_class)
2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif // SkMemberInfo_DEFINED
271