#include <mono/metadata/assembly.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/metadata.h>
+#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/tokentype.h>
-#include <mono/metadata/class.h>
+#include <mono/metadata/class-internals.h>
#include <mono/metadata/object.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/mono-endian.h>
static MonoClass * mono_class_create_from_typedef (MonoImage *image, guint32 type_token);
+void (*mono_debugger_start_class_init_func) (MonoClass *klass) = NULL;
void (*mono_debugger_class_init_func) (MonoClass *klass) = NULL;
MonoClass *
name = mono_metadata_string_heap (image, cols [MONO_TYPEREF_NAME]);
nspace = mono_metadata_string_heap (image, cols [MONO_TYPEREF_NAMESPACE]);
- idx = cols [MONO_TYPEREF_SCOPE] >> RESOLTION_SCOPE_BITS;
- switch (cols [MONO_TYPEREF_SCOPE] & RESOLTION_SCOPE_MASK) {
- case RESOLTION_SCOPE_MODULE:
+ idx = cols [MONO_TYPEREF_SCOPE] >> MONO_RESOLTION_SCOPE_BITS;
+ switch (cols [MONO_TYPEREF_SCOPE] & MONO_RESOLTION_SCOPE_MASK) {
+ case MONO_RESOLTION_SCOPE_MODULE:
if (!idx)
g_error ("null ResolutionScope not yet handled");
/* a typedef in disguise */
return mono_class_from_name (image, nspace, name);
- case RESOLTION_SCOPE_MODULEREF:
+ case MONO_RESOLTION_SCOPE_MODULEREF:
return mono_class_from_name (image->modules [idx - 1], nspace, name);
- case RESOLTION_SCOPE_TYPEREF: {
+ case MONO_RESOLTION_SCOPE_TYPEREF: {
MonoClass *enclosing = mono_class_from_typeref (image, MONO_TOKEN_TYPE_REF | idx);
GList *tmp;
mono_class_init (enclosing);
g_warning ("TypeRef ResolutionScope not yet handled (%d)", idx);
return NULL;
}
- case RESOLTION_SCOPE_ASSEMBLYREF:
+ case MONO_RESOLTION_SCOPE_ASSEMBLYREF:
break;
}
/*
* detected a reference to mscorlib, we simply return a reference to a dummy
* until we have a better solution.
+ *
+ * once a better solution is in place, the System.MonoDummy
+ * class should be removed from CVS.
*/
fprintf(stderr, "Sending dummy where %s.%s expected\n", mono_metadata_string_heap (image, cols [MONO_TYPEREF_NAMESPACE]), mono_metadata_string_heap (image, cols [MONO_TYPEREF_NAME]));
}
static void
-mono_type_get_name_recurse (MonoType *type, GString *str)
+mono_type_get_name_recurse (MonoType *type, GString *str, gboolean is_recursed)
{
MonoClass *klass;
case MONO_TYPE_ARRAY: {
int i, rank = type->data.array->rank;
- mono_type_get_name_recurse (&type->data.array->eklass->byval_arg, str);
+ mono_type_get_name_recurse (&type->data.array->eklass->byval_arg, str, FALSE);
g_string_append_c (str, '[');
for (i = 1; i < rank; i++)
g_string_append_c (str, ',');
break;
}
case MONO_TYPE_SZARRAY:
- mono_type_get_name_recurse (&type->data.klass->byval_arg, str);
+ mono_type_get_name_recurse (&type->data.klass->byval_arg, str, FALSE);
g_string_append (str, "[]");
break;
case MONO_TYPE_PTR:
- mono_type_get_name_recurse (type->data.type, str);
+ mono_type_get_name_recurse (type->data.type, str, FALSE);
g_string_append_c (str, '*');
break;
default:
klass = mono_class_from_mono_type (type);
if (klass->nested_in) {
- mono_type_get_name_recurse (&klass->nested_in->byval_arg, str);
+ mono_type_get_name_recurse (&klass->nested_in->byval_arg, str, TRUE);
g_string_append_c (str, '+');
}
if (*klass->name_space) {
g_string_append_c (str, '.');
}
g_string_append (str, klass->name);
+ if (is_recursed)
+ break;
+ if (klass->generic_inst) {
+ MonoGenericInst *ginst = klass->generic_inst;
+ int i;
+
+ g_string_append_c (str, '[');
+ for (i = 0; i < ginst->type_argc; i++) {
+ if (i)
+ g_string_append_c (str, ',');
+ mono_type_get_name_recurse (ginst->type_argv [i], str, FALSE);
+ }
+ g_string_append_c (str, ']');
+ } else if (klass->gen_params) {
+ int i;
+
+ g_string_append_c (str, '[');
+ for (i = 0; i < klass->num_gen_params; i++) {
+ if (i)
+ g_string_append_c (str, ',');
+ g_string_append (str, klass->gen_params [i].name);
+ }
+ g_string_append_c (str, ']');
+ }
break;
}
}
mono_type_get_name (MonoType *type)
{
GString* result = g_string_new ("");
- mono_type_get_name_recurse (type, result);
+ mono_type_get_name_recurse (type, result, FALSE);
if (type->byref)
g_string_append_c (result, '&');
return NULL;
case MONO_TYPE_SZARRAY: {
MonoClass *eclass = type->data.klass;
- MonoClass *nclass;
- MonoType *nt;
- if ((eclass->byval_arg.type == MONO_TYPE_MVAR) &&
- context->gmethod && context->gmethod->mtype_argv) {
- nclass = mono_class_from_mono_type (context->gmethod->mtype_argv [eclass->byval_arg.data.generic_param->num]);
- } else if ((eclass->byval_arg.type == MONO_TYPE_VAR) && context->ginst) {
- nclass = mono_class_from_mono_type (context->ginst->type_argv [eclass->byval_arg.data.generic_param->num]);
- } else
+ MonoType *nt, *inflated = inflate_generic_type (&eclass->byval_arg, context);
+ if (!inflated)
return NULL;
nt = dup_type (type, type);
- nt->data.klass = nclass;
+ nt->data.klass = mono_class_from_mono_type (inflated);
return nt;
}
case MONO_TYPE_GENERICINST: {
class_compute_field_layout (class->parent);
class->instance_size += class->parent->instance_size;
class->min_align = class->parent->min_align;
- blittable = class->blittable;
+ blittable = class->parent->blittable;
} else {
class->instance_size = sizeof (MonoObject);
class->min_align = 1;
field->parent = class;
- if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
+ /* Only do these checks if we still think this type is blittable */
+ if (blittable && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
if (field->type->byref) {
blittable = FALSE;
} else {
blittable = FALSE;
}
}
+
if (layout == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) {
mono_metadata_field_info (m, idx, &field->offset, NULL, NULL);
- if (field->offset == (guint32)-1)
+ if (field->offset == (guint32)-1 && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
g_warning ("%s not initialized correctly (missing field layout info for %s)", class->name, field->name);
}
* performance.
* Requires that all classes whose layout is known to native code be annotated
* with [StructLayout (LayoutKind.Sequential)]
+ * Value types have gc_aware_layout disabled by default, as per
+ * what the default is for other runtimes.
*/
/* corlib is missing [StructLayout] directives in many places */
if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT) {
- if (class->image != mono_defaults.corlib)
+ if (class->image != mono_defaults.corlib &&
+ class->byval_arg.type != MONO_TYPE_VALUETYPE)
gc_aware_layout = TRUE;
}
int size, align;
field = &class->fields [i];
- if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
+ if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC) || field->type->attrs & FIELD_ATTRIBUTE_LITERAL)
continue;
if (mono_field_is_deleted (field))
continue;
char *str;
gpointer value;
- g_assert (class->flags & TYPE_ATTRIBUTE_INTERFACE);
+ g_assert (MONO_CLASS_IS_INTERFACE (class));
mono_loader_lock ();
}
}
- if (class->flags & TYPE_ATTRIBUTE_INTERFACE) {
+ if (MONO_CLASS_IS_INTERFACE (class)) {
if (max_iid < class->interface_id)
max_iid = class->interface_id;
}
}
}
- if (class->flags & TYPE_ATTRIBUTE_INTERFACE)
+ if (MONO_CLASS_IS_INTERFACE (class))
class->interface_offsets [class->interface_id] = cur_slot;
return cur_slot;
/* override interface methods */
for (i = 0; i < onum; i++) {
MonoMethod *decl = overrides [i*2];
- if (decl->klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
+ if (MONO_CLASS_IS_INTERFACE (decl->klass)) {
int dslot;
g_assert (decl->slot != -1);
dslot = decl->slot + class->interface_offsets [decl->klass->interface_id];
/* override non interface methods */
for (i = 0; i < onum; i++) {
MonoMethod *decl = overrides [i*2];
- if (!(decl->klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
+ if (!MONO_CLASS_IS_INTERFACE (decl->klass)) {
g_assert (decl->slot != -1);
vtable [decl->slot] = overrides [i*2 + 1];
overrides [i * 2 + 1]->slot = decl->slot;
class->init_pending = 1;
+ if (mono_debugger_start_class_init_func)
+ mono_debugger_start_class_init_func (class);
+
mono_stats.initialized_class_count++;
if (class->generic_inst && !class->generic_inst->is_dynamic) {
MonoGenericInst *ginst = class->generic_inst;
MonoClass *gklass;
+ GList *list;
gklass = mono_class_from_mono_type (ginst->generic_type);
mono_class_init (gklass);
mono_class_setup_parent (class, class->parent);
- if (class->flags & TYPE_ATTRIBUTE_INTERFACE)
+ if (MONO_CLASS_IS_INTERFACE (class))
class->interface_id = mono_get_unique_iid (class);
class->method = gklass->method;
class->fields = g_new0 (MonoClassField, class->field.count);
for (i = 0; i < class->field.count; i++) {
+ MonoInflatedField *ifield = g_new0 (MonoInflatedField, 1);
+ ifield->generic_type = gklass->fields [i].type;
+
class->fields [i] = gklass->fields [i];
- class->fields [i].generic_type = gklass->fields [i].type;
+ class->fields [i].generic_info = ifield;
class->fields [i].parent = class;
class->fields [i].type = mono_class_inflate_generic_type (
class->fields [i].type, ginst->context);
class->interfaces [i] = mono_class_from_mono_type (inflated);
mono_class_init (class->interfaces [i]);
}
+
+ for (list = gklass->nested_classes; list; list = list->next)
+ class->nested_classes = g_list_append (
+ class->nested_classes, list->data);
}
if (class->parent && !class->parent->inited)
if (!class->generic_inst) {
init_properties (class);
init_events (class);
- }
- i = mono_metadata_nesting_typedef (class->image, class->type_token, 1);
- while (i) {
- MonoClass* nclass;
- guint32 cols [MONO_NESTED_CLASS_SIZE];
- mono_metadata_decode_row (&class->image->tables [MONO_TABLE_NESTEDCLASS], i - 1, cols, MONO_NESTED_CLASS_SIZE);
- nclass = mono_class_create_from_typedef (class->image, MONO_TOKEN_TYPE_DEF | cols [MONO_NESTED_CLASS_NESTED]);
- class->nested_classes = g_list_prepend (class->nested_classes, nclass);
+ i = mono_metadata_nesting_typedef (class->image, class->type_token, 1);
+ while (i) {
+ MonoClass* nclass;
+ guint32 cols [MONO_NESTED_CLASS_SIZE];
+ mono_metadata_decode_row (&class->image->tables [MONO_TABLE_NESTEDCLASS], i - 1, cols, MONO_NESTED_CLASS_SIZE);
+ nclass = mono_class_create_from_typedef (class->image, MONO_TOKEN_TYPE_DEF | cols [MONO_NESTED_CLASS_NESTED]);
+ class->nested_classes = g_list_prepend (class->nested_classes, nclass);
- i = mono_metadata_nesting_typedef (class->image, class->type_token, i + 1);
+ i = mono_metadata_nesting_typedef (class->image, class->type_token, i + 1);
+ }
}
mono_class_setup_supertypes (class);
- if (class->flags & TYPE_ATTRIBUTE_INTERFACE) {
+ if (MONO_CLASS_IS_INTERFACE (class)) {
for (i = 0; i < class->method.count; ++i)
class->methods [i]->slot = i;
class->init_pending = 0;
*/
setup_interface_offsets (class, 0);
mono_loader_unlock ();
+
+ if (mono_debugger_class_init_func)
+ mono_debugger_class_init_func (class);
+
return;
}
mono_debugger_class_init_func (class);
}
-
void
mono_class_setup_mono_type (MonoClass *class)
{
const char *name = class->name;
const char *nspace = class->name_space;
- if (class->flags & TYPE_ATTRIBUTE_INTERFACE)
+ if (MONO_CLASS_IS_INTERFACE (class))
class->interface_id = mono_get_unique_iid (class);
class->this_arg.byref = 1;
* do not set the valuetype bit for System.ValueType.
* class->valuetype = 1;
*/
+ class->blittable = TRUE;
} else if (!strcmp (name, "Enum")) {
/*
* do not set the valuetype bit for System.Enum.
return;
}
- if (!(class->flags & TYPE_ATTRIBUTE_INTERFACE)) {
+ if (!MONO_CLASS_IS_INTERFACE (class)) {
class->parent = parent;
if (!parent)
}
g_assert (mono_metadata_token_table (type_token) == MONO_TABLE_TYPEDEF);
-
+
mono_metadata_decode_row (tt, tidx - 1, cols, MONO_TYPEDEF_SIZE);
name = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAME]);
nspace = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAMESPACE]);
- if (cols [MONO_TYPEDEF_EXTENDS])
- parent = mono_class_get (image, mono_metadata_token_from_dor (cols [MONO_TYPEDEF_EXTENDS]));
- interfaces = mono_metadata_interfaces_from_typedef (image, type_token, &icount);
-
class = g_malloc0 (sizeof (MonoClass));
-
- g_hash_table_insert (image->class_cache, GUINT_TO_POINTER (type_token), class);
-
- class->interfaces = interfaces;
- class->interface_count = icount;
class->name = name;
class->name_space = nspace;
class->type_token = type_token;
class->flags = cols [MONO_TYPEDEF_FLAGS];
+ g_hash_table_insert (image->class_cache, GUINT_TO_POINTER (type_token), class);
+
+ if (cols [MONO_TYPEDEF_EXTENDS])
+ parent = mono_class_get (image, mono_metadata_token_from_dor (cols [MONO_TYPEDEF_EXTENDS]));
+ interfaces = mono_metadata_interfaces_from_typedef (image, type_token, &icount);
+
+ class->interfaces = interfaces;
+ class->interface_count = icount;
+
if ((class->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_UNICODE_CLASS)
class->unicode = 1;
/* fixme: maybe we must set this on windows
return class;
}
-char*
-_mono_class_get_instantiation_name (const char *name, MonoGenericInst *ginst, int offset)
-{
- GString *res = g_string_new (name);
- const char *p;
- int count, i;
- MonoClass *argclass;
-
- p = strchr (name, '<');
- count = ginst->type_argc - offset;
- if (p) {
- g_string_truncate (res, (p - name) + 1);
- } else if (count) {
- g_string_append_c (res, '<');
- }
- for (i = offset; i < ginst->type_argc; ++i) {
- if (i > offset)
- g_string_append_c (res, ',');
- argclass = mono_class_from_mono_type (ginst->type_argv [i]);
- g_string_append (res, argclass->name);
- }
- if (count)
- g_string_append_c (res, '>');
- return g_string_free (res, FALSE);
-}
-
MonoClass*
mono_class_create_generic (MonoGenericInst *ginst)
{
gklass = mono_class_from_mono_type (ginst->generic_type);
- if (ginst->nested_in) {
- MonoGenericInst *nginst = ginst->nested_in->data.generic_inst;
- int offset = nginst->type_argc;
+ klass->nested_in = gklass->nested_in;
- klass->nested_in = nginst->klass;
- klass->name = _mono_class_get_instantiation_name (gklass->name, ginst, nginst->type_argc);
- } else if (!ginst->init_pending)
- klass->name = _mono_class_get_instantiation_name (gklass->name, ginst, 0);
- else
- klass->name = gklass->name;
+ klass->name = gklass->name;
klass->name_space = gklass->name_space;
klass->image = gklass->image;
klass->flags = gklass->flags;
;
pos = 0;
- if ((count > 0) && !(param->constraints [0]->flags & TYPE_ATTRIBUTE_INTERFACE)) {
+ if ((count > 0) && !MONO_CLASS_IS_INTERFACE (param->constraints [0])) {
klass->parent = param->constraints [0];
pos++;
- } else
- klass->parent = mono_defaults.object_class;
+ }
if (count - pos > 0) {
klass->interface_count = count - pos;
klass->image = image;
klass->cast_class = klass->element_class = klass;
klass->enum_basetype = &klass->element_class->byval_arg;
- klass->flags = TYPE_ATTRIBUTE_INTERFACE | TYPE_ATTRIBUTE_PUBLIC;
+ klass->flags = TYPE_ATTRIBUTE_PUBLIC;
klass->this_arg.type = klass->byval_arg.type = is_mvar ? MONO_TYPE_MVAR : MONO_TYPE_VAR;
klass->this_arg.data.generic_param = klass->byval_arg.data.generic_param = param;
klass->image = mono_defaults.corlib;
klass->cast_class = klass->element_class = klass;
klass->enum_basetype = &klass->element_class->byval_arg;
- klass->flags = TYPE_ATTRIBUTE_INTERFACE | TYPE_ATTRIBUTE_PUBLIC;
+ klass->flags = TYPE_ATTRIBUTE_PUBLIC;
klass->this_arg.type = klass->byval_arg.type = is_mvar ? MONO_TYPE_MVAR : MONO_TYPE_VAR;
klass->this_arg.data.generic_param = klass->byval_arg.data.generic_param = param;
result->instance_size = sizeof (gpointer);
result->cast_class = result->element_class = el_class;
result->enum_basetype = &result->element_class->byval_arg;
+ result->blittable = TRUE;
result->this_arg.type = result->byval_arg.type = MONO_TYPE_PTR;
result->this_arg.data.type = result->byval_arg.data.type = result->enum_basetype;
result->name_space = "MonoFNPtrFakeClass";
result->image = NULL; /* need to fix... */
result->inited = TRUE;
- result->flags = TYPE_ATTRIBUTE_CLASS; // | (el_class->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK);
+ result->flags = TYPE_ATTRIBUTE_CLASS; /* | (el_class->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK); */
/* Can pointers get boxed? */
result->instance_size = sizeof (gpointer);
result->cast_class = result->element_class = result;
+ result->blittable = TRUE;
result->this_arg.type = result->byval_arg.type = MONO_TYPE_FNPTR;
result->this_arg.data.method = result->byval_arg.data.method = sig;
result->this_arg.byref = TRUE;
result->enum_basetype = &result->element_class->byval_arg;
+ result->blittable = TRUE;
mono_class_setup_supertypes (result);
class = mono_array_class_get (type->data.klass, 1);
break;
case MONO_TYPE_PTR:
- class = mono_class_from_mono_type (type->data.type);
+ class = mono_ptr_class_get (type->data.type);
break;
case MONO_TYPE_GENERICINST:
g_assert (type->data.generic_inst->klass);
return NULL;
}
+void *
+mono_vtable_get_static_field_data (MonoVTable *vt)
+{
+ return vt->data;
+}
+
MonoProperty*
mono_class_get_property_from_name (MonoClass *klass, const char *name)
{
return mono_class_from_mono_type (inflated);
}
+/**
+ * mono_class_from_name_case:
+ * @image: The MonoImage where the type is looked up in, or NULL for looking up in all loaded assemblies
+ * @name_space: the type namespace
+ * @name: the type short name.
+ *
+ * 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)
{
return NULL;
}
+
+/**
+ * mono_class_from_name_case:
+ * @image: The MonoImage where the type is looked up in, or NULL for looking up in all loaded assemblies
+ * @name_space: the type namespace
+ * @name: the type short name.
+ *
+ * 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)
{
mono_metadata_decode_row (t, idx - 1, cols, MONO_EXP_TYPE_SIZE);
impl = cols [MONO_EXP_TYPE_IMPLEMENTATION];
- if ((impl & IMPLEMENTATION_MASK) == IMPLEMENTATION_FILE) {
- loaded_image = mono_assembly_load_module (image->assembly, impl >> IMPLEMENTATION_BITS);
+ if ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_FILE) {
+ loaded_image = mono_assembly_load_module (image->assembly, impl >> MONO_IMPLEMENTATION_BITS);
if (!loaded_image)
return NULL;
class = mono_class_from_name (loaded_image, name_space, name);
gboolean check_interfaces)
{
again:
- if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && !(klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
+ if (check_interfaces && MONO_CLASS_IS_INTERFACE (klassc) && !MONO_CLASS_IS_INTERFACE (klass)) {
if ((klassc->interface_id <= klass->max_interface_id) &&
(klass->interface_offsets [klassc->interface_id] >= 0))
return TRUE;
- } else if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && (klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
+ } else if (check_interfaces && MONO_CLASS_IS_INTERFACE (klassc) && MONO_CLASS_IS_INTERFACE (klass)) {
int i;
for (i = 0; i < klass->interface_count; i ++) {
return TRUE;
}
} else {
- if (!(klass->flags & TYPE_ATTRIBUTE_INTERFACE) && mono_class_has_parent (klass, klassc))
+ if (!MONO_CLASS_IS_INTERFACE (klass) && mono_class_has_parent (klass, klassc))
return TRUE;
if (klass->generic_inst) {
MonoType *parent = klass->generic_inst->parent;
if (!oklass->inited)
mono_class_init (oklass);
- if (klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
+ if (MONO_CLASS_IS_INTERFACE (klass)) {
if ((klass->interface_id <= oklass->max_interface_id) &&
(oklass->interface_offsets [klass->interface_id] != -1))
return TRUE;
return lookup_dynamic (image, token);
}
+MonoImage*
+mono_class_get_image (MonoClass *klass)
+{
+ return klass->image;
+}
+
+/**
+ * mono_class_get_element_class:
+ * @klass: the MonoClass to act on
+ *
+ * Returns the element class of an array or an enumeration.
+ */
+MonoClass*
+mono_class_get_element_class (MonoClass *klass)
+{
+ return klass->element_class;
+}
+
+/**
+ * mono_class_is_valuetype:
+ * @klass: the MonoClass to act on
+ *
+ * Returns true if the MonoClass represents a ValueType.
+ */
+gboolean
+mono_class_is_valuetype (MonoClass *klass)
+{
+ return klass->valuetype;
+}
+
+/**
+ * mono_class_is_enum:
+ * @klass: the MonoClass to act on
+ *
+ * Returns true if the MonoClass represents an enumeration.
+ */
+gboolean
+mono_class_is_enum (MonoClass *klass)
+{
+ return klass->enumtype;
+}
+
+/**
+ * mono_class_enum_basetype:
+ * @klass: the MonoClass to act on
+ *
+ * Returns the underlying type representation for an enumeration.
+ */
+MonoType*
+mono_class_enum_basetype (MonoClass *klass)
+{
+ return klass->enum_basetype;
+}
+
+/**
+ * mono_class_get_parent
+ * @klass: the MonoClass to act on
+ *
+ * Returns the parent class for this class.
+ */
+MonoClass*
+mono_class_get_parent (MonoClass *klass)
+{
+ return klass->parent;
+}
+/**
+ * mono_class_get_nesting_type;
+ * @klass: the MonoClass to act on
+ *
+ * Returns the container type where this type is nested or NULL if this type is not a nested type.
+ */
+MonoClass*
+mono_class_get_nesting_type (MonoClass *klass)
+{
+ return klass->nested_in;
+}
+
+/**
+ * mono_class_get_rank:
+ * @klass: the MonoClass to act on
+ *
+ * Returns the rank for the array (the number of dimensions).
+ */
+int
+mono_class_get_rank (MonoClass *klass)
+{
+ return klass->rank;
+}
+
+/**
+ * mono_class_get_flags:
+ * @klass: the MonoClass to act on
+ *
+ * The type flags from the TypeDef table from the metadata.
+ * see the TYPE_ATTRIBUTE_* definitions on tabledefs.h for the
+ * different values.
+ *
+ * Returns the flags from the TypeDef table.
+ */
+guint32
+mono_class_get_flags (MonoClass *klass)
+{
+ return klass->flags;
+}
+
+/**
+ * mono_class_get_name
+ * @klass: the MonoClass to act on
+ *
+ * Returns the name of the class.
+ */
+const char*
+mono_class_get_name (MonoClass *klass)
+{
+ return klass->name;
+}
+
+/**
+ * mono_class_get_namespace:
+ * @klass: the MonoClass to act on
+ *
+ * Returns the namespace of the class.
+ */
+const char*
+mono_class_get_namespace (MonoClass *klass)
+{
+ return klass->name_space;
+}
+
+/**
+ * mono_class_get_type:
+ * @klass: the MonoClass to act on
+ *
+ * This method returns the internal Type representation for the class.
+ *
+ * Returns the MonoType from the class.
+ */
+MonoType*
+mono_class_get_type (MonoClass *klass)
+{
+ return &klass->byval_arg;
+}
+
+/**
+ * mono_class_get_byref_type:
+ * @klass: the MonoClass to act on
+ *
+ *
+ */
+MonoType*
+mono_class_get_byref_type (MonoClass *klass)
+{
+ return &klass->this_arg;
+}
+
+/**
+ * mono_class_num_fields:
+ * @klass: the MonoClass to act on
+ *
+ * Returns the number of static and instance fields in the class.
+ */
+int
+mono_class_num_fields (MonoClass *klass)
+{
+ return klass->field.count;
+}
+
+/**
+ * mono_class_num_methods:
+ * @klass: the MonoClass to act on
+ *
+ * Returns the number of methods in the class.
+ */
+int
+mono_class_num_methods (MonoClass *klass)
+{
+ return klass->method.count;
+}
+
+/**
+ * mono_class_num_properties
+ * @klass: the MonoClass to act on
+ *
+ * Returns the number of properties in the class.
+ */
+int
+mono_class_num_properties (MonoClass *klass)
+{
+ return klass->property.count;
+}
+
+/**
+ * mono_class_num_events:
+ * @klass: the MonoClass to act on
+ *
+ * Returns the number of events in the class.
+ */
+int
+mono_class_num_events (MonoClass *klass)
+{
+ return klass->event.count;
+}
+
+/**
+ * mono_class_get_fields:
+ * @klass: the MonoClass to act on
+ *
+ * This routine is an iterator routine for retrieving the fields in a class.
+ *
+ * You must pass a gpointer that points to zero and is treated as an opaque handle to
+ * iterate over all of the elements. When no more values are
+ * available, the return value is NULL.
+ *
+ * Returns a `MonoClassField *' on each iteration, or NULL when no more fields are available.
+ */
+MonoClassField*
+mono_class_get_fields (MonoClass* klass, gpointer *iter)
+{
+ MonoClassField* field;
+ if (!iter)
+ return NULL;
+ if (!klass->inited)
+ mono_class_init (klass);
+ if (!*iter) {
+ /* start from the first */
+ if (klass->field.count) {
+ return *iter = &klass->fields [0];
+ } else {
+ /* no fields */
+ return NULL;
+ }
+ }
+ field = *iter;
+ field++;
+ if (field < &klass->fields [klass->field.count]) {
+ return *iter = field;
+ }
+ return NULL;
+}
+
+/**
+ * mono_class_get_methods
+ * @klass: the MonoClass to act on
+ *
+ * This routine is an iterator routine for retrieving the fields in a class.
+ *
+ * You must pass a gpointer that points to zero and is treated as an opaque handle to
+ * iterate over all of the elements. When no more values are
+ * available, the return value is NULL.
+ *
+ * Returns a MonoMethod on each iteration or NULL when no more methods are available.
+ */
+MonoMethod*
+mono_class_get_methods (MonoClass* klass, gpointer *iter)
+{
+ MonoMethod** method;
+ if (!iter)
+ return NULL;
+ if (!klass->inited)
+ mono_class_init (klass);
+ if (!*iter) {
+ /* start from the first */
+ if (klass->method.count) {
+ *iter = &klass->methods [0];
+ return klass->methods [0];
+ } else {
+ /* no method */
+ return NULL;
+ }
+ }
+ method = *iter;
+ method++;
+ if (method < &klass->methods [klass->method.count]) {
+ *iter = method;
+ return *method;
+ }
+ return NULL;
+}
+
+/**
+ * mono_class_get_properties:
+ * @klass: the MonoClass to act on
+ *
+ * This routine is an iterator routine for retrieving the properties in a class.
+ *
+ * You must pass a gpointer that points to zero and is treated as an opaque handle to
+ * iterate over all of the elements. When no more values are
+ * available, the return value is NULL.
+ *
+ * Returns a `MonoProperty *' on each invocation, or NULL when no more are available.
+ */
+MonoProperty*
+mono_class_get_properties (MonoClass* klass, gpointer *iter)
+{
+ MonoProperty* property;
+ if (!iter)
+ return NULL;
+ if (!klass->inited)
+ mono_class_init (klass);
+ if (!*iter) {
+ /* start from the first */
+ if (klass->property.count) {
+ return *iter = &klass->properties [0];
+ } else {
+ /* no fields */
+ return NULL;
+ }
+ }
+ property = *iter;
+ property++;
+ if (property < &klass->properties [klass->property.count]) {
+ return *iter = property;
+ }
+ return NULL;
+}
+
+/**
+ * mono_class_get_events:
+ * @klass: the MonoClass to act on
+ *
+ * This routine is an iterator routine for retrieving the properties in a class.
+ *
+ * You must pass a gpointer that points to zero and is treated as an opaque handle to
+ * iterate over all of the elements. When no more values are
+ * available, the return value is NULL.
+ *
+ * Returns a `MonoEvent *' on each invocation, or NULL when no more are available.
+ */
+MonoEvent*
+mono_class_get_events (MonoClass* klass, gpointer *iter)
+{
+ MonoEvent* event;
+ if (!iter)
+ return NULL;
+ if (!klass->inited)
+ mono_class_init (klass);
+ if (!*iter) {
+ /* start from the first */
+ if (klass->event.count) {
+ return *iter = &klass->events [0];
+ } else {
+ /* no fields */
+ return NULL;
+ }
+ }
+ event = *iter;
+ event++;
+ if (event < &klass->events [klass->event.count]) {
+ return *iter = event;
+ }
+ return NULL;
+}
+
+/**
+ * mono_class_get_interfaaces
+ * @klass: the MonoClass to act on
+ *
+ * This routine is an iterator routine for retrieving the interfaces implemented by this class.
+ *
+ * You must pass a gpointer that points to zero and is treated as an opaque handle to
+ * iterate over all of the elements. When no more values are
+ * available, the return value is NULL.
+ *
+ * Returns a `Monoclass *' on each invocation, or NULL when no more are available.
+ */
+MonoClass*
+mono_class_get_interfaces (MonoClass* klass, gpointer *iter)
+{
+ MonoClass** iface;
+ if (!iter)
+ return NULL;
+ if (!klass->inited)
+ mono_class_init (klass);
+ if (!*iter) {
+ /* start from the first */
+ if (klass->interface_count) {
+ *iter = &klass->interfaces [0];
+ return klass->interfaces [0];
+ } else {
+ /* no interface */
+ return NULL;
+ }
+ }
+ iface = *iter;
+ iface++;
+ if (iface < &klass->interfaces [klass->interface_count]) {
+ *iter = iface;
+ return *iface;
+ }
+ return NULL;
+}
+
+/**
+ * mono_class_get_interfaaces
+ * @klass: the MonoClass to act on
+ *
+ * This routine is an iterator routine for retrieving the nested types of a class.
+ *
+ * You must pass a gpointer that points to zero and is treated as an opaque handle to
+ * iterate over all of the elements. When no more values are
+ * available, the return value is NULL.
+ *
+ * Returns a `Monoclass *' on each invocation, or NULL when no more are available.
+ */
+MonoClass*
+mono_class_get_nested_types (MonoClass* klass, gpointer *iter)
+{
+ GList *item;
+ if (!iter)
+ return NULL;
+ if (!klass->inited)
+ mono_class_init (klass);
+ if (!*iter) {
+ /* start from the first */
+ if (klass->nested_classes) {
+ *iter = klass->nested_classes;
+ return klass->nested_classes->data;
+ } else {
+ /* no nested types */
+ return NULL;
+ }
+ }
+ item = *iter;
+ item = item->next;
+ if (item) {
+ *iter = item;
+ return item->data;
+ }
+ return NULL;
+}
+
+/**
+ * mono_field_get_name:
+ * @field: the MonoClassField to act on
+ *
+ * Returns the name of the field.
+ */
+const char*
+mono_field_get_name (MonoClassField *field)
+{
+ return field->name;
+}
+
+/**
+ * mono_field_get_type:
+ * @field: the MonoClassField to act on
+ *
+ * Returns MonoType of the field.
+ */
+MonoType*
+mono_field_get_type (MonoClassField *field)
+{
+ return field->type;
+}
+
+/**
+ * mono_field_get_type:
+ * @field: the MonoClassField to act on
+ *
+ * Returns MonoClass where the field was defined.
+ */
+MonoClass*
+mono_field_get_parent (MonoClassField *field)
+{
+ return field->parent;
+}
+
+/**
+ * mono_field_get_flags;
+ * @field: the MonoClassField to act on
+ *
+ * The metadata flags for a field are encoded using the
+ * FIELD_ATTRIBUTE_* constants. See the tabledefs.h file for details.
+ *
+ * Returns the flags for the field.
+ */
+guint32
+mono_field_get_flags (MonoClassField *field)
+{
+ return field->type->attrs;
+}
+
+/**
+ * mono_property_get_name:
+ * @prop: the MonoProperty to act on
+ *
+ * Returns the name of the property
+ */
+const char*
+mono_property_get_name (MonoProperty *prop)
+{
+ return prop->name;
+}
+
+/**
+ * mono_property_get_set_method
+ * @prop: the MonoProperty to act on.
+ *
+ * Returns the setter method of the property (A MonoMethod)
+ */
+MonoMethod*
+mono_property_get_set_method (MonoProperty *prop)
+{
+ return prop->set;
+}
+
+/**
+ * mono_property_get_get_method
+ * @prop: the MonoProperty to act on.
+ *
+ * Returns the setter method of the property (A MonoMethod)
+ */
+MonoMethod*
+mono_property_get_get_method (MonoProperty *prop)
+{
+ return prop->get;
+}
+
+/**
+ * mono_property_get_parent:
+ * @prop: the MonoProperty to act on.
+ *
+ * Returns the MonoClass where the property was defined.
+ */
+MonoClass*
+mono_property_get_parent (MonoProperty *prop)
+{
+ return prop->parent;
+}
+
+/**
+ * mono_property_get_flags:
+ * @prop: the MonoProperty to act on.
+ *
+ * The metadata flags for a property are encoded using the
+ * PROPERTY_ATTRIBUTE_* constants. See the tabledefs.h file for details.
+ *
+ * Returns the flags for the property.
+ */
+guint32
+mono_property_get_flags (MonoProperty *prop)
+{
+ return prop->attrs;
+}
+
+/**
+ * mono_event_get_name:
+ * @event: the MonoEvent to act on
+ *
+ * Returns the name of the event.
+ */
+const char*
+mono_event_get_name (MonoEvent *event)
+{
+ return event->name;
+}
+
+/**
+ * mono_event_get_add_method:
+ * @event: The MonoEvent to act on.
+ *
+ * Returns the `add' method for the event (a MonoMethod).
+ */
+MonoMethod*
+mono_event_get_add_method (MonoEvent *event)
+{
+ return event->add;
+}
+
+/**
+ * mono_event_get_remove_method:
+ * @event: The MonoEvent to act on.
+ *
+ * Returns the `remove' method for the event (a MonoMethod).
+ */
+MonoMethod*
+mono_event_get_remove_method (MonoEvent *event)
+{
+ return event->remove;
+}
+
+/**
+ * mono_event_get_raise_method:
+ * @event: The MonoEvent to act on.
+ *
+ * Returns the `raise' method for the event (a MonoMethod).
+ */
+MonoMethod*
+mono_event_get_raise_method (MonoEvent *event)
+{
+ return event->raise;
+}
+
+/**
+ * mono_event_get_parent:
+ * @event: the MonoEvent to act on.
+ *
+ * Returns the MonoClass where the event is defined.
+ */
+MonoClass*
+mono_event_get_parent (MonoEvent *event)
+{
+ return event->parent;
+}
+
+/**
+ * mono_event_get_flags
+ * @event: the MonoEvent to act on.
+ *
+ * The metadata flags for an event are encoded using the
+ * EVENT_* constants. See the tabledefs.h file for details.
+ *
+ * Returns the flags for the event.
+ */
+guint32
+mono_event_get_flags (MonoEvent *event)
+{
+ return event->attrs;
+}