| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | // |
| 6 | |
| 7 | #ifndef __CAHLPR_H__ |
| 8 | #define __CAHLPR_H__ |
| 9 | |
| 10 | #include "sarray.h" |
| 11 | #include "caparser.h" |
| 12 | |
| 13 | //***************************************************************************** |
| 14 | // This class assists in the parsing of CustomAttribute blobs. |
| 15 | //***************************************************************************** |
| 16 | struct CaType |
| 17 | { |
| 18 | void Init(CorSerializationType _type) |
| 19 | { |
| 20 | _ASSERTE(_type != SERIALIZATION_TYPE_SZARRAY && _type != SERIALIZATION_TYPE_ENUM); |
| 21 | tag = _type; |
| 22 | arrayType = SERIALIZATION_TYPE_UNDEFINED; |
| 23 | enumType = SERIALIZATION_TYPE_UNDEFINED; |
| 24 | szEnumName = NULL; |
| 25 | cEnumName = 0; |
| 26 | } |
| 27 | |
| 28 | void Init(CorSerializationType _type, CorSerializationType _arrayType, CorSerializationType _enumType, LPCSTR _szEnumName, ULONG _cEnumName) |
| 29 | { |
| 30 | tag = _type; |
| 31 | arrayType = _arrayType; |
| 32 | enumType = _enumType; |
| 33 | szEnumName = _szEnumName; |
| 34 | cEnumName = _cEnumName; |
| 35 | } |
| 36 | |
| 37 | CorSerializationType tag; |
| 38 | CorSerializationType arrayType; |
| 39 | CorSerializationType enumType; |
| 40 | LPCSTR szEnumName; |
| 41 | ULONG cEnumName; |
| 42 | }; |
| 43 | |
| 44 | struct CaTypeCtor : public CaType |
| 45 | { |
| 46 | CaTypeCtor(CorSerializationType _type) |
| 47 | { |
| 48 | Init(_type); |
| 49 | } |
| 50 | |
| 51 | CaTypeCtor(CorSerializationType _type, CorSerializationType _arrayType, CorSerializationType _enumType, LPCSTR _szEnumName, ULONG _cEnumName) |
| 52 | { |
| 53 | Init(_type, _arrayType, _enumType, _szEnumName, _cEnumName); |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | typedef struct CaValue |
| 58 | { |
| 59 | union |
| 60 | { |
| 61 | unsigned __int8 boolean; |
| 62 | signed __int8 i1; |
| 63 | unsigned __int8 u1; |
| 64 | signed __int16 i2; |
| 65 | unsigned __int16 u2; |
| 66 | signed __int32 i4; |
| 67 | unsigned __int32 u4; |
| 68 | signed __int64 i8; |
| 69 | unsigned __int64 u8; |
| 70 | float r4; |
| 71 | double r8; |
| 72 | |
| 73 | struct |
| 74 | { |
| 75 | CorSerializationType tag; |
| 76 | SArray<CaValue>* pSArray; |
| 77 | ULONG length; |
| 78 | inline CaValue &operator[](int index) { return (*pSArray)[index]; } |
| 79 | } arr; |
| 80 | |
| 81 | struct |
| 82 | { |
| 83 | LPCUTF8 pStr; |
| 84 | ULONG cbStr; |
| 85 | } str; |
| 86 | }; |
| 87 | |
| 88 | CaType type; |
| 89 | |
| 90 | } CaValue; |
| 91 | |
| 92 | |
| 93 | |
| 94 | #endif // __CAHLPR_H__ |
| 95 | |