2 #ifndef __MONO_METADATA_H__
3 #define __MONO_METADATA_H__
7 #include <mono/metadata/blob.h>
8 #include <mono/metadata/row-indexes.h>
11 #define MONO_ZERO_LEN_ARRAY 0
13 #define MONO_ZERO_LEN_ARRAY 1
26 MONO_TABLE_INTERFACEIMPL,
29 MONO_TABLE_CUSTOMATTRIBUTE,
30 MONO_TABLE_FIELDMARSHAL,
31 MONO_TABLE_DECLSECURITY,
32 MONO_TABLE_CLASSLAYOUT,
33 MONO_TABLE_FIELDLAYOUT,
34 MONO_TABLE_STANDALONESIG,
38 MONO_TABLE_PROPERTYMAP,
41 MONO_TABLE_METHODSEMANTICS,
42 MONO_TABLE_METHODIMPL,
50 MONO_TABLE_ASSEMBLYPROCESSOR,
51 MONO_TABLE_ASSEMBLYOS,
52 MONO_TABLE_ASSEMBLYREF,
53 MONO_TABLE_ASSEMBLYREFPROCESSOR,
54 MONO_TABLE_ASSEMBLYREFOS,
56 MONO_TABLE_EXPORTEDTYPE,
57 MONO_TABLE_MANIFESTRESOURCE,
58 MONO_TABLE_NESTEDCLASS,
60 #define MONO_TABLE_LAST MONO_TABLE_NESTEDCLASS
64 MONO_EXCEPTION_CLAUSE_NONE,
65 MONO_EXCEPTION_CLAUSE_FILTER,
66 MONO_EXCEPTION_CLAUSE_FINALLY,
67 MONO_EXCEPTION_CLAUSE_FAULT = 4
85 guint32 rows, row_size;
89 * Tables contain up to 9 rows and the possible sizes of the
90 * fields in the documentation are 1, 2 and 4 bytes. So we
91 * can encode in 2 bits the size.
93 * A 32 bit value can encode the resulting size
95 * The top eight bits encode the number of columns in the table.
96 * we only need 4, but 8 is aligned no shift required.
98 guint32 size_bitfield;
101 void mono_metadata_decode_row (MonoTableInfo *t,
107 * This macro is used to extract the size of the table encoded in
108 * the size_bitfield of MonoTableInfo.
110 #define mono_metadata_table_size(bitfield,table) ((((bitfield) >> ((table)*2)) & 0x3) + 1)
111 #define mono_metadata_table_count(bitfield) ((bitfield) >> 24)
116 gboolean idx_string_wide, idx_guid_wide, idx_blob_wide;
118 MonoStreamHeader heap_strings;
119 MonoStreamHeader heap_us;
120 MonoStreamHeader heap_blob;
121 MonoStreamHeader heap_guid;
122 MonoStreamHeader heap_tables;
126 MonoTableInfo tables [64];
132 char *mono_metadata_locate (MonoMetadata *meta, int table, int idx);
133 char *mono_metadata_locate_token (MonoMetadata *meta, guint32 token);
135 const char *mono_metadata_string_heap (MonoMetadata *meta, guint32 index);
136 const char *mono_metadata_blob_heap (MonoMetadata *meta, guint32 index);
137 const char *mono_metadata_user_string (MonoMetadata *meta, guint32 index);
139 guint32 mono_metadata_typedef_from_field (MonoMetadata *meta, guint32 index);
140 guint32 mono_metadata_typedef_from_method (MonoMetadata *meta, guint32 index);
143 * Functions to extract information from the Blobs
145 guint32 mono_metadata_decode_value (const char *ptr,
147 guint32 mono_metadata_decode_blob_size (const char *ptr,
154 guint32 handler_offset;
156 guint32 token_or_filter;
157 } MonoExceptionClause;
159 typedef struct _MonoType MonoType;
160 typedef struct _MonoArray MonoArray;
161 typedef struct _MonoMethodSignature MonoMethodSignature;
171 MonoCustomMod modifiers[MONO_ZERO_LEN_ARRAY]; /* this may grow */
184 guchar type; /* ElementTypeEnum */
185 guchar custom_mod; /* for PTR and SZARRAY: use data.mtype instead of data.type */
186 guchar byref; /* when included in a MonoRetType */
187 guchar constraint; /* valid when included in a local var signature */
189 guint32 token; /* for VALUETYPE and CLASS */
191 MonoModifiedType *mtype;
192 MonoArray *array; /* for ARRAY */
193 MonoMethodSignature *method;
198 /* maybe use a union here: saves 4 bytes */
199 MonoType *type; /* NULL for VOID */
200 short param_attrs; /* 22.1.11 */
203 MonoCustomMod modifiers[MONO_ZERO_LEN_ARRAY]; /* this may grow */
206 /* MonoRetType is used also for params and fields */
207 typedef MonoRetType MonoParam;
208 typedef MonoRetType MonoFieldType;
210 struct _MonoMethodSignature {
213 char call_convention;
224 unsigned int num_clauses : 15;
225 /* if num_locals != 0, then the following apply: */
226 unsigned int init_locals : 1;
230 MonoExceptionClause *clauses;
233 guint32 mono_metadata_parse_typedef_or_ref (MonoMetadata *m,
236 int mono_metadata_parse_custom_mod (MonoMetadata *m,
240 MonoArray *mono_metadata_parse_array (MonoMetadata *m,
243 void mono_metadata_free_array (MonoArray *array);
244 MonoParam *mono_metadata_parse_param (MonoMetadata *m,
248 void mono_metadata_free_param (MonoParam *param);
249 MonoType *mono_metadata_parse_type (MonoMetadata *m,
252 void mono_metadata_free_type (MonoType *type);
254 MonoFieldType *mono_metadata_parse_field_type (MonoMetadata *m,
259 MonoMethodSignature *mono_metadata_parse_method_signature (MonoMetadata *m,
263 void mono_metadata_free_method_signature (MonoMethodSignature *method);
265 MonoMethodHeader *mono_metadata_parse_mh (MonoMetadata *m, const char *ptr);
266 void mono_metadata_free_mh (MonoMethodHeader *mh);
269 * Makes a token based on a table and an index
271 #define mono_metadata_make_token(table,idx) (((table) << 24)| idx)
274 * Returns the table index that this token encodes.
276 #define mono_metadata_token_table(token) ((token) >> 24)
279 * Returns the index that a token refers to
281 #define mono_metadata_token_index(token) ((token & 0xffffff))
284 #define mono_metadata_token_code(token) ((token & 0xff000000))
286 guint32 mono_metadata_token_from_dor (guint32 dor_index);
288 #endif /* __MONO_METADATA_H__ */