2008-10-24 Mark Probst <mark.probst@gmail.com>
[mono.git] / mono / metadata / metadata.h
index 1149c4082b13b33006c73672c300c43cc654555c..1238b52ef4085b7b5e5fe8e6b9824e2f7648cfa8 100644 (file)
@@ -16,7 +16,10 @@ G_BEGIN_DECLS
 #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) || (((t)->type == MONO_TYPE_GENERICINST) && mono_metadata_generic_class_is_valuetype ((t)->data.generic_class))))
+#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) && !(t)->data.generic_class->container_class->enumtype)))
+
 #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)))
 
@@ -31,6 +34,8 @@ G_BEGIN_DECLS
 
 #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 struct _MonoMethod MonoMethod;
@@ -171,7 +176,9 @@ typedef enum {
        MONO_MARSHAL_CONV_DEL_FTN,
        MONO_MARSHAL_CONV_FTN_DEL,
        MONO_MARSHAL_FREE_ARRAY,
-       MONO_MARSHAL_CONV_BSTR_STR
+       MONO_MARSHAL_CONV_BSTR_STR,
+       MONO_MARSHAL_CONV_SAFEHANDLE,
+       MONO_MARSHAL_CONV_HANDLEREF
 } MonoMarshalConv;
 
 typedef struct {
@@ -272,6 +279,8 @@ void mono_metadata_encode_value (guint32 value, char *bug, char **endbuf);
        ((clause)->try_offset <= (offset) && (offset) < ((clause)->try_offset + (clause)->try_len))
 #define MONO_OFFSET_IN_HANDLER(clause,offset) \
        ((clause)->handler_offset <= (offset) && (offset) < ((clause)->handler_offset + (clause)->handler_len))
+#define MONO_OFFSET_IN_FILTER(clause,offset) \
+       ((clause)->flags == MONO_EXCEPTION_CLAUSE_FILTER && (clause)->data.filter_offset <= (offset) && (offset) < ((clause)->handler_offset))
 
 typedef struct {
        guint32 flags;
@@ -288,15 +297,16 @@ typedef struct {
 typedef struct _MonoType MonoType;
 typedef struct _MonoGenericInst MonoGenericInst;
 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;
 
+/* FIXME: Keeping this name alive for now, since it is part of the exposed API, even though no entrypoint uses it.  */
+typedef struct invalid_name MonoGenericMethod;
+
 typedef struct {
        unsigned int required : 1;
        unsigned int token    : 31;
@@ -324,7 +334,7 @@ struct _MonoType {
                MonoGenericClass *generic_class; /* for GENERICINST */
        } data;
        unsigned int attrs    : 16; /* param attributes or field flags */
-       unsigned int type     : 8;  /* ElementTypeEnum */
+       MonoTypeEnum type     : 8;
        unsigned int num_mods : 6;  /* max 64 modifiers follow at the end */
        unsigned int byref    : 1;
        unsigned int pinned   : 1;  /* valid when included in a local var signature */
@@ -378,6 +388,10 @@ mono_type_get_class      (MonoType *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);
 
@@ -506,6 +520,17 @@ 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__ */