Fri Oct 6 16:57:26 CEST 2006 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / metadata / class.c
index 2ad8bd06da9fbad8992048e8a8d1cbaf6315309d..4cdd90efbc65b23268ce3a76736e17c9a89a7729 100644 (file)
@@ -744,7 +744,6 @@ mono_class_find_enum_basetype (MonoClass *class)
 {
        MonoImage *m = class->image; 
        const int top = class->field.count;
-       MonoTableInfo *t = &m->tables [MONO_TABLE_FIELD];
        int i;
 
        g_assert (class->enumtype);
@@ -759,7 +758,7 @@ mono_class_find_enum_basetype (MonoClass *class)
                MonoGenericContainer *container = NULL;
                MonoType *ftype;
 
-               mono_metadata_decode_row (t, idx, cols, MONO_FIELD_SIZE);
+               mono_metadata_decode_table_row (m, MONO_TABLE_FIELD, idx, cols, MONO_FIELD_SIZE);
                sig = mono_metadata_blob_heap (m, cols [MONO_FIELD_SIGNATURE]);
                mono_metadata_decode_value (sig, &sig);
                /* FIELD signature == 0x06 */
@@ -800,7 +799,6 @@ mono_class_setup_fields (MonoClass *class)
        MonoImage *m = class->image; 
        int top = class->field.count;
        guint32 layout = class->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
-       MonoTableInfo *t = &m->tables [MONO_TABLE_FIELD];
        int i, blittable = TRUE;
        guint32 real_size = 0;
        guint32 packing_size = 0;
@@ -900,7 +898,7 @@ mono_class_setup_fields (MonoClass *class)
                        const char *sig;
                        guint32 cols [MONO_FIELD_SIZE];
 
-                       mono_metadata_decode_row (t, idx, cols, MONO_FIELD_SIZE);
+                       mono_metadata_decode_table_row (m, MONO_TABLE_FIELD, idx, cols, MONO_FIELD_SIZE);
                        /* The name is needed for fieldrefs */
                        field->name = mono_metadata_string_heap (m, cols [MONO_FIELD_NAME]);
                        sig = mono_metadata_blob_heap (m, cols [MONO_FIELD_SIGNATURE]);
@@ -1291,7 +1289,6 @@ mono_class_setup_properties (MonoClass *class)
 {
        guint startm, endm, i, j;
        guint32 cols [MONO_PROPERTY_SIZE];
-       MonoTableInfo *pt = &class->image->tables [MONO_TABLE_PROPERTY];
        MonoTableInfo *msemt = &class->image->tables [MONO_TABLE_METHODSEMANTICS];
        MonoProperty *properties;
        guint32 last;
@@ -1314,7 +1311,7 @@ mono_class_setup_properties (MonoClass *class)
 
        properties = mono_mempool_alloc0 (class->image->mempool, sizeof (MonoProperty) * class->property.count);
        for (i = class->property.first; i < last; ++i) {
-               mono_metadata_decode_row (pt, i, cols, MONO_PROPERTY_SIZE);
+               mono_metadata_decode_table_row (class->image, MONO_TABLE_PROPERTY, i, cols, MONO_PROPERTY_SIZE);
                properties [i - class->property.first].parent = class;
                properties [i - class->property.first].attrs = cols [MONO_PROPERTY_FLAGS];
                properties [i - class->property.first].name = mono_metadata_string_heap (class->image, cols [MONO_PROPERTY_NAME]);
@@ -1395,7 +1392,6 @@ mono_class_setup_events (MonoClass *class)
 {
        guint startm, endm, i, j;
        guint32 cols [MONO_EVENT_SIZE];
-       MonoTableInfo *pt = &class->image->tables [MONO_TABLE_EVENT];
        MonoTableInfo *msemt = &class->image->tables [MONO_TABLE_METHODSEMANTICS];
        guint32 last;
        MonoEvent *events;
@@ -1440,8 +1436,8 @@ mono_class_setup_events (MonoClass *class)
        events = mono_mempool_alloc0 (class->image->mempool, sizeof (MonoEvent) * class->event.count);
        for (i = class->event.first; i < last; ++i) {
                MonoEvent *event = &events [i - class->event.first];
-                       
-               mono_metadata_decode_row (pt, i, cols, MONO_EVENT_SIZE);
+
+               mono_metadata_decode_table_row (class->image, MONO_TABLE_EVENT, i, cols, MONO_EVENT_SIZE);
                event->parent = class;
                event->attrs = cols [MONO_EVENT_FLAGS];
                event->name = mono_metadata_string_heap (class->image, cols [MONO_EVENT_NAME]);
@@ -4076,12 +4072,6 @@ find_nocase (gpointer key, gpointer value, gpointer user_data)
  * Obtains a MonoClass with a given namespace and a given name which
  * is located in the given MonoImage.   The namespace and name
  * lookups are case insensitive.
- *
- * You can also pass @NULL to the image, and that will lookup for
- * a type with the given namespace and name in all of the loaded
- * assemblies: notice that since there might be a name clash in this
- * case, passing @NULL is not encouraged if you need a precise type.
- *
  */
 MonoClass *
 mono_class_from_name_case (MonoImage *image, const char* name_space, const char *name)
@@ -4171,12 +4161,6 @@ return_nested_in (MonoClass *class, char *nested) {
  *
  * Obtains a MonoClass with a given namespace and a given name which
  * is located in the given MonoImage.   
- *
- * You can also pass `NULL' to the image, and that will lookup for
- * a type with the given namespace and name in all of the loaded
- * assemblies: notice that since there might be a name clash in this
- * case, passing NULL is not encouraged if you need a precise type.
- *
  */
 MonoClass *
 mono_class_from_name (MonoImage *image, const char* name_space, const char *name)
@@ -4483,7 +4467,6 @@ gint32
 mono_array_element_size (MonoClass *ac)
 {
        g_assert (ac->rank);
-       g_assert (ac->sizes.element_size);
        return ac->sizes.element_size;
 }
 
@@ -4758,6 +4741,20 @@ mono_class_get_type (MonoClass *klass)
        return &klass->byval_arg;
 }
 
+/**
+ * mono_class_get_type_token
+ * @klass: the MonoClass to act on
+ *
+ * This method returns type token for the class.
+ *
+ * Returns: the type token for the class.
+ */
+guint32
+mono_class_get_type_token (MonoClass *klass)
+{
+  return klass->type_token;
+}
+
 /**
  * mono_class_get_byref_type:
  * @klass: the MonoClass to act on
@@ -5103,6 +5100,19 @@ mono_field_get_flags (MonoClassField *field)
        return field->type->attrs;
 }
 
+/**
+ * mono_field_get_data;
+ * @field: the MonoClassField to act on
+ *
+ * Returns: pointer to the metadata constant value or to the field
+ * data if it has an RVA flag.
+ */
+const char *
+mono_field_get_data  (MonoClassField *field)
+{
+  return field->data;
+}
+
 /**
  * mono_property_get_name: 
  * @prop: the MonoProperty to act on