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,
106 guint32 mono_metadata_decode_row_col (MonoTableInfo *t,
111 * This macro is used to extract the size of the table encoded in
112 * the size_bitfield of MonoTableInfo.
114 #define mono_metadata_table_size(bitfield,table) ((((bitfield) >> ((table)*2)) & 0x3) + 1)
115 #define mono_metadata_table_count(bitfield) ((bitfield) >> 24)
120 gboolean idx_string_wide, idx_guid_wide, idx_blob_wide;
122 MonoStreamHeader heap_strings;
123 MonoStreamHeader heap_us;
124 MonoStreamHeader heap_blob;
125 MonoStreamHeader heap_guid;
126 MonoStreamHeader heap_tables;
130 MonoTableInfo tables [64];
136 char *mono_metadata_locate (MonoMetadata *meta, int table, int idx);
137 char *mono_metadata_locate_token (MonoMetadata *meta, guint32 token);
139 const char *mono_metadata_string_heap (MonoMetadata *meta, guint32 index);
140 const char *mono_metadata_blob_heap (MonoMetadata *meta, guint32 index);
141 const char *mono_metadata_user_string (MonoMetadata *meta, guint32 index);
143 guint32 mono_metadata_typedef_from_field (MonoMetadata *meta, guint32 index);
144 guint32 mono_metadata_typedef_from_method (MonoMetadata *meta, guint32 index);
147 * Functions to extract information from the Blobs
149 guint32 mono_metadata_decode_value (const char *ptr,
151 guint32 mono_metadata_decode_blob_size (const char *ptr,
158 guint32 handler_offset;
160 guint32 token_or_filter;
161 } MonoExceptionClause;
163 typedef struct _MonoType MonoType;
164 typedef struct _MonoArray MonoArray;
165 typedef struct _MonoMethodSignature MonoMethodSignature;
175 MonoCustomMod modifiers [MONO_ZERO_LEN_ARRAY]; /* this may grow */
188 guchar type; /* ElementTypeEnum */
189 guchar custom_mod; /* for PTR and SZARRAY: use data.mtype instead of data.type */
190 guchar byref; /* when included in a MonoRetType */
191 guchar constraint; /* valid when included in a local var signature */
193 guint32 token; /* for VALUETYPE and CLASS */
195 MonoModifiedType *mtype;
196 MonoArray *array; /* for ARRAY */
197 MonoMethodSignature *method;
202 /* maybe use a union here: saves 4 bytes */
203 MonoType *type; /* NULL for VOID */
204 short param_attrs; /* 22.1.11 */
207 MonoCustomMod modifiers [MONO_ZERO_LEN_ARRAY]; /* this may grow */
210 /* MonoRetType is used also for params and fields */
211 typedef MonoRetType MonoParam;
212 typedef MonoRetType MonoFieldType;
214 struct _MonoMethodSignature {
217 char call_convention;
222 guint32 *param_offsets;
229 unsigned int num_clauses : 15;
230 /* if num_locals != 0, then the following apply: */
231 unsigned int init_locals : 1;
234 guint32 *locals_offsets;
235 MonoExceptionClause *clauses;
238 guint32 mono_metadata_parse_typedef_or_ref (MonoMetadata *m,
241 int mono_metadata_parse_custom_mod (MonoMetadata *m,
245 MonoArray *mono_metadata_parse_array (MonoMetadata *m,
248 void mono_metadata_free_array (MonoArray *array);
249 MonoParam *mono_metadata_parse_param (MonoMetadata *m,
253 void mono_metadata_free_param (MonoParam *param);
254 MonoType *mono_metadata_parse_type (MonoMetadata *m,
257 void mono_metadata_free_type (MonoType *type);
258 int mono_type_size (MonoType *type,
261 MonoFieldType *mono_metadata_parse_field_type (MonoMetadata *m,
266 MonoMethodSignature *mono_metadata_parse_method_signature (MonoMetadata *m,
270 void mono_metadata_free_method_signature (MonoMethodSignature *method);
272 MonoMethodHeader *mono_metadata_parse_mh (MonoMetadata *m, const char *ptr);
273 void mono_metadata_free_mh (MonoMethodHeader *mh);
276 * Makes a token based on a table and an index
278 #define mono_metadata_make_token(table,idx) (((table) << 24)| idx)
281 * Returns the table index that this token encodes.
283 #define mono_metadata_token_table(token) ((token) >> 24)
286 * Returns the index that a token refers to
288 #define mono_metadata_token_index(token) ((token & 0xffffff))
291 #define mono_metadata_token_code(token) ((token & 0xff000000))
293 guint32 mono_metadata_token_from_dor (guint32 dor_index);
295 #endif /* __MONO_METADATA_H__ */