#include <mono/metadata/row-indexes.h>
#include <mono/metadata/image.h>
+G_BEGIN_DECLS
+
#ifdef __GNUC__
#define MONO_ZERO_LEN_ARRAY 0
#else
#define MONO_ZERO_LEN_ARRAY 1
#endif
-#define MONO_TYPE_ISSTRUCT(t) (!(t)->byref && (((t)->type == MONO_TYPE_VALUETYPE && !(t)->data.klass->enumtype) || ((t)->type == MONO_TYPE_TYPEDBYREF)))
+#define MONO_TYPE_ISSTRUCT(t) (!(t)->byref && (((t)->type == MONO_TYPE_VALUETYPE && !(t)->data.klass->enumtype) || ((t)->type == MONO_TYPE_TYPEDBYREF) || (((t)->type == MONO_TYPE_GENERICINST) && mono_metadata_generic_class_is_valuetype ((t)->data.generic_class))))
#define MONO_TYPE_IS_VOID(t) ((t) && ((t)->type == MONO_TYPE_VOID) && !(t)->byref)
#define MONO_TYPE_IS_POINTER(t) ((t) && (((t)->byref || ((t)->type == MONO_TYPE_I) || (t)->type == MONO_TYPE_STRING) || ((t)->type == MONO_TYPE_SZARRAY) || ((t)->type == MONO_TYPE_CLASS) || ((t)->type == MONO_TYPE_CLASS) || ((t)->type == MONO_TYPE_OBJECT) || ((t)->type == MONO_TYPE_ARRAY) || ((t)->type == MONO_TYPE_PTR)))
-#define MONO_TYPE_IS_REFERENCE(t) ((t) && (((t)->type == MONO_TYPE_STRING) || ((t)->type == MONO_TYPE_SZARRAY) || ((t)->type == MONO_TYPE_CLASS) || ((t)->type == MONO_TYPE_OBJECT) || ((t)->type == MONO_TYPE_ARRAY)))
+
+#define MONO_TYPE_IS_REFERENCE(t) ((t) && \
+ ((((t)->type == MONO_TYPE_STRING) || \
+ ((t)->type == MONO_TYPE_SZARRAY) || \
+ ((t)->type == MONO_TYPE_CLASS) || \
+ ((t)->type == MONO_TYPE_OBJECT) || \
+ ((t)->type == MONO_TYPE_ARRAY)) || \
+ (((t)->type == MONO_TYPE_GENERICINST) && \
+ !mono_metadata_generic_class_is_valuetype ((t)->data.generic_class))))
+
#define MONO_CLASS_IS_INTERFACE(c) ((c->flags & TYPE_ATTRIBUTE_INTERFACE) || (c->byval_arg.type == MONO_TYPE_VAR) || (c->byval_arg.type == MONO_TYPE_MVAR))
+#define MONO_CLASS_IS_IMPORT(c) ((c->flags & TYPE_ATTRIBUTE_IMPORT))
+
typedef struct _MonoClass MonoClass;
typedef struct _MonoDomain MonoDomain;
-
-typedef enum {
- MONO_TABLE_MODULE,
- MONO_TABLE_TYPEREF,
- MONO_TABLE_TYPEDEF,
- MONO_TABLE_FIELD_POINTER,
- MONO_TABLE_FIELD,
- MONO_TABLE_METHOD_POINTER,
- MONO_TABLE_METHOD,
- MONO_TABLE_PARAM_POINTER,
- MONO_TABLE_PARAM,
- MONO_TABLE_INTERFACEIMPL,
- MONO_TABLE_MEMBERREF, /* 0xa */
- MONO_TABLE_CONSTANT,
- MONO_TABLE_CUSTOMATTRIBUTE,
- MONO_TABLE_FIELDMARSHAL,
- MONO_TABLE_DECLSECURITY,
- MONO_TABLE_CLASSLAYOUT,
- MONO_TABLE_FIELDLAYOUT, /* 0x10 */
- MONO_TABLE_STANDALONESIG,
- MONO_TABLE_EVENTMAP,
- MONO_TABLE_EVENT_POINTER,
- MONO_TABLE_EVENT,
- MONO_TABLE_PROPERTYMAP,
- MONO_TABLE_UNUSED5,
- MONO_TABLE_PROPERTY,
- MONO_TABLE_METHODSEMANTICS,
- MONO_TABLE_METHODIMPL,
- MONO_TABLE_MODULEREF, /* 0x1a */
- MONO_TABLE_TYPESPEC,
- MONO_TABLE_IMPLMAP,
- MONO_TABLE_FIELDRVA,
- MONO_TABLE_UNUSED6,
- MONO_TABLE_UNUSED7,
- MONO_TABLE_ASSEMBLY, /* 0x20 */
- MONO_TABLE_ASSEMBLYPROCESSOR,
- MONO_TABLE_ASSEMBLYOS,
- MONO_TABLE_ASSEMBLYREF,
- MONO_TABLE_ASSEMBLYREFPROCESSOR,
- MONO_TABLE_ASSEMBLYREFOS,
- MONO_TABLE_FILE,
- MONO_TABLE_EXPORTEDTYPE,
- MONO_TABLE_MANIFESTRESOURCE,
- MONO_TABLE_NESTEDCLASS,
- MONO_TABLE_GENERICPARAM, /* 0x2a */
- MONO_TABLE_METHODSPEC,
- MONO_TABLE_GENERICPARAMCONSTRAINT
-
-#define MONO_TABLE_LAST MONO_TABLE_GENERICPARAMCONSTRAINT
-} MonoMetaTableEnum;
+typedef struct _MonoMethod MonoMethod;
typedef enum {
MONO_EXCEPTION_CLAUSE_NONE,
MONO_NATIVE_MAX = 0x50 /* no info */
} MonoMarshalNative;
+/* Used only in context of SafeArray */
+typedef enum {
+ MONO_VARIANT_EMPTY = 0x00,
+ MONO_VARIANT_NULL = 0x01,
+ MONO_VARIANT_I2 = 0x02,
+ MONO_VARIANT_I4 = 0x03,
+ MONO_VARIANT_R4 = 0x04,
+ MONO_VARIANT_R8 = 0x05,
+ MONO_VARIANT_CY = 0x06,
+ MONO_VARIANT_DATE = 0x07,
+ MONO_VARIANT_BSTR = 0x08,
+ MONO_VARIANT_DISPATCH = 0x09,
+ MONO_VARIANT_ERROR = 0x0a,
+ MONO_VARIANT_BOOL = 0x0b,
+ MONO_VARIANT_VARIANT = 0x0c,
+ MONO_VARIANT_UNKNOWN = 0x0d,
+ MONO_VARIANT_DECIMAL = 0x0e,
+ MONO_VARIANT_I1 = 0x10,
+ MONO_VARIANT_UI1 = 0x11,
+ MONO_VARIANT_UI2 = 0x12,
+ MONO_VARIANT_UI4 = 0x13,
+ MONO_VARIANT_I8 = 0x14,
+ MONO_VARIANT_UI8 = 0x15,
+ MONO_VARIANT_INT = 0x16,
+ MONO_VARIANT_UINT = 0x17,
+ MONO_VARIANT_VOID = 0x18,
+ MONO_VARIANT_HRESULT = 0x19,
+ MONO_VARIANT_PTR = 0x1a,
+ MONO_VARIANT_SAFEARRAY = 0x1b,
+ MONO_VARIANT_CARRAY = 0x1c,
+ MONO_VARIANT_USERDEFINED = 0x1d,
+ MONO_VARIANT_LPSTR = 0x1e,
+ MONO_VARIANT_LPWSTR = 0x1f,
+ MONO_VARIANT_RECORD = 0x24,
+ MONO_VARIANT_FILETIME = 0x40,
+ MONO_VARIANT_BLOB = 0x41,
+ MONO_VARIANT_STREAM = 0x42,
+ MONO_VARIANT_STORAGE = 0x43,
+ MONO_VARIANT_STREAMED_OBJECT = 0x44,
+ MONO_VARIANT_STORED_OBJECT = 0x45,
+ MONO_VARIANT_BLOB_OBJECT = 0x46,
+ MONO_VARIANT_CF = 0x47,
+ MONO_VARIANT_CLSID = 0x48,
+ MONO_VARIANT_VECTOR = 0x1000,
+ MONO_VARIANT_ARRAY = 0x2000,
+ MONO_VARIANT_BYREF = 0x4000
+} MonoMarshalVariant;
+
typedef enum {
MONO_MARSHAL_CONV_NONE,
MONO_MARSHAL_CONV_BOOL_VARIANTBOOL,
MONO_MARSHAL_CONV_STR_BSTR,
MONO_MARSHAL_CONV_STR_LPSTR,
MONO_MARSHAL_CONV_LPSTR_STR,
+ MONO_MARSHAL_CONV_LPTSTR_STR,
MONO_MARSHAL_CONV_STR_LPWSTR,
MONO_MARSHAL_CONV_LPWSTR_STR,
MONO_MARSHAL_CONV_STR_LPTSTR,
MONO_MARSHAL_CONV_LPTSTR_SB,
MONO_MARSHAL_CONV_LPWSTR_SB,
MONO_MARSHAL_CONV_ARRAY_BYVALARRAY,
+ MONO_MARSHAL_CONV_ARRAY_BYVALCHARARRAY,
MONO_MARSHAL_CONV_ARRAY_SAVEARRAY,
MONO_MARSHAL_CONV_ARRAY_LPARRAY,
MONO_MARSHAL_CONV_OBJECT_INTERFACE,
MONO_MARSHAL_CONV_OBJECT_STRUCT,
MONO_MARSHAL_CONV_DEL_FTN,
MONO_MARSHAL_CONV_FTN_DEL,
- MONO_MARSHAL_CONV_STRARRAY_STRLPARRAY,
- MONO_MARSHAL_CONV_STRARRAY_STRWLPARRAY,
- MONO_MARSHAL_CONV_ASANY,
MONO_MARSHAL_FREE_ARRAY,
- MONO_MARSHAL_FREE_ASANY
+ MONO_MARSHAL_CONV_BSTR_STR
} MonoMarshalConv;
typedef struct {
union {
struct {
MonoMarshalNative elem_type;
- gint32 param_num;
- gint32 num_elem;
+ gint32 num_elem; /* -1 if not set */
+ gint16 param_num; /* -1 if not set */
+ gint16 elem_mult; /* -1 if not set */
} array_data;
struct {
char *custom_name;
char *cookie;
} custom_data;
+ struct {
+ MonoMarshalVariant elem_type;
+ gint32 num_elem;
+ } safearray_data;
} data;
} MonoMarshalSpec;
void mono_metadata_init (void);
-void mono_metadata_decode_row (MonoTableInfo *t,
+void mono_metadata_decode_row (const MonoTableInfo *t,
int idx,
guint32 *res,
int res_size);
-guint32 mono_metadata_decode_row_col (MonoTableInfo *t,
+guint32 mono_metadata_decode_row_col (const MonoTableInfo *t,
int idx,
guint col);
MonoMarshalSpec *mono_metadata_parse_marshal_spec (MonoImage *image, const char *ptr);
+void mono_metadata_free_marshal_spec (MonoMarshalSpec *spec);
+
guint32 mono_metadata_implmap_from_method (MonoImage *meta, guint32 method_idx);
void mono_metadata_field_info (MonoImage *meta,
*/
guint32 mono_metadata_decode_value (const char *ptr,
const char **rptr);
+gint32 mono_metadata_decode_signed_value (const char *ptr, const char **rptr);
+
guint32 mono_metadata_decode_blob_size (const char *ptr,
const char **rptr);
guint32 try_len;
guint32 handler_offset;
guint32 handler_len;
- guint32 token_or_filter;
+ union {
+ guint32 filter_offset;
+ MonoClass *catch_class;
+ } data;
} MonoExceptionClause;
typedef struct _MonoType MonoType;
typedef struct _MonoGenericInst MonoGenericInst;
-typedef struct _MonoDynamicGenericInst MonoDynamicGenericInst;
+typedef struct _MonoGenericClass MonoGenericClass;
+typedef struct _MonoInflatedGenericClass MonoInflatedGenericClass;
+typedef struct _MonoDynamicGenericClass MonoDynamicGenericClass;
typedef struct _MonoGenericMethod MonoGenericMethod;
typedef struct _MonoGenericContext MonoGenericContext;
+typedef struct _MonoGenericContainer MonoGenericContainer;
typedef struct _MonoGenericParam MonoGenericParam;
typedef struct _MonoArrayType MonoArrayType;
typedef struct _MonoMethodSignature MonoMethodSignature;
int *lobounds;
};
+/* This structure is internal to the runtime: use the mono_type*
+ * accessors below, because it will soon ago away from the public header file.
+ */
struct _MonoType {
union {
MonoClass *klass; /* for VALUETYPE and CLASS */
MonoArrayType *array; /* for ARRAY */
MonoMethodSignature *method;
MonoGenericParam *generic_param; /* for VAR and MVAR */
- MonoGenericInst *generic_inst; /* for GENERICINST */
+ MonoGenericClass *generic_class; /* for GENERICINST */
} data;
unsigned int attrs : 16; /* param attributes or field flags */
unsigned int type : 8; /* ElementTypeEnum */
MonoCustomMod modifiers [MONO_ZERO_LEN_ARRAY]; /* this may grow */
};
+/*
+ * This structure is an internal runtime detail: use the mono_signature_*
+ * accessors below, because it will go away from the public header.
+ */
struct _MonoMethodSignature {
unsigned int hasthis : 1;
unsigned int explicit_this : 1;
MonoType *params [MONO_ZERO_LEN_ARRAY];
};
-typedef struct {
- guint32 code_size;
- const unsigned char *code;
- guint16 max_stack;
- unsigned int num_clauses : 15;
- /* if num_locals != 0, then the following apply: */
- unsigned int init_locals : 1;
- guint16 num_locals;
- MonoExceptionClause *clauses;
- MonoGenericParam *gen_params;
- MonoType *locals [MONO_ZERO_LEN_ARRAY];
-} MonoMethodHeader;
+typedef struct _MonoMethodHeader MonoMethodHeader;
typedef enum {
MONO_PARSE_TYPE,
MonoArrayType*
mono_type_get_array_type (MonoType *type);
+/* For MONO_TYPE_PTR */
+MonoType*
+mono_type_get_ptr_type (MonoType *type);
+
MonoClass*
mono_type_get_modifiers (MonoType *type, gboolean *is_required, gpointer *iter);
int mono_type_stack_size (MonoType *type,
int *alignment);
-guint mono_metadata_generic_inst_hash (MonoGenericInst *ginst);
-gboolean mono_metadata_generic_inst_equal (MonoGenericInst *g1, MonoGenericInst *g2);
+gboolean mono_type_generic_inst_is_valuetype (MonoType *type);
+gboolean mono_metadata_generic_class_is_valuetype (MonoGenericClass *gclass);
+guint mono_metadata_generic_class_hash (MonoGenericClass *gclass);
+gboolean mono_metadata_generic_class_equal (MonoGenericClass *g1, MonoGenericClass *g2);
guint mono_metadata_type_hash (MonoType *t1);
gboolean mono_metadata_type_equal (MonoType *t1, MonoType *t2);
MonoMethodHeader *mono_metadata_parse_mh (MonoImage *m, const char *ptr);
void mono_metadata_free_mh (MonoMethodHeader *mh);
+/* MonoMethodHeader acccessors */
+const unsigned char*
+mono_method_header_get_code (MonoMethodHeader *header, guint32* code_size, guint32* max_stack);
+
+MonoType**
+mono_method_header_get_locals (MonoMethodHeader *header, guint32* num_locals, gboolean *init_locals);
+
+int
+mono_method_header_get_num_clauses (MonoMethodHeader *header);
+
+int
+mono_method_header_get_clauses (MonoMethodHeader *header, MonoMethod *method, gpointer *iter, MonoExceptionClause *clause);
+
guint32
mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec,
gboolean as_field, gboolean unicode, MonoMarshalConv *conv);
char *mono_guid_to_string (const guint8 *guid);
+guint32 mono_metadata_declsec_from_index (MonoImage *meta, guint32 idx);
+
+guint32 mono_metadata_translate_token_index (MonoImage *image, int table, guint32 idx);
+
+void mono_metadata_decode_table_row (MonoImage *image, int table,
+ int idx,
+ guint32 *res,
+ int res_size);
+
+guint32 mono_metadata_decode_table_row_col (MonoImage *image, int table,
+ int idx,
+ guint col);
+
+G_END_DECLS
+
#endif /* __MONO_METADATA_H__ */