#include "mono/metadata/gc-internals.h"
#include "mono/metadata/mono-endian.h"
#include "mono/metadata/object-internals.h"
-#include "mono/metadata/reflection-cache.h"
#include "mono/metadata/custom-attrs-internals.h"
#include "mono/metadata/sre-internals.h"
#include "mono/metadata/reflection-internals.h"
static gboolean type_is_reference (MonoType *type);
-static GENERATE_GET_CLASS_WITH_CACHE (custom_attribute_typed_argument, System.Reflection, CustomAttributeTypedArgument);
-static GENERATE_GET_CLASS_WITH_CACHE (custom_attribute_named_argument, System.Reflection, CustomAttributeNamedArgument);
+static GENERATE_GET_CLASS_WITH_CACHE (custom_attribute_typed_argument, "System.Reflection", "CustomAttributeTypedArgument");
+static GENERATE_GET_CLASS_WITH_CACHE (custom_attribute_named_argument, "System.Reflection", "CustomAttributeNamedArgument");
/*
* LOCKING: Acquires the loader lock.
find_field_index (MonoClass *klass, MonoClassField *field) {
int i;
- for (i = 0; i < klass->field.count; ++i) {
+ int fcount = mono_class_get_field_count (klass);
+ for (i = 0; i < fcount; ++i) {
if (field == &klass->fields [i])
- return klass->field.first + 1 + i;
+ return mono_class_get_first_field_idx (klass) + 1 + i;
}
return 0;
}
* Find the property index in the metadata Property table.
*/
static guint32
-find_property_index (MonoClass *klass, MonoProperty *property) {
+find_property_index (MonoClass *klass, MonoProperty *property)
+{
int i;
+ MonoClassPropertyInfo *info = mono_class_get_property_info (klass);
- for (i = 0; i < klass->ext->property.count; ++i) {
- if (property == &klass->ext->properties [i])
- return klass->ext->property.first + 1 + i;
+ for (i = 0; i < info->count; ++i) {
+ if (property == &info->properties [i])
+ return info->first + 1 + i;
}
return 0;
}
* Find the event index in the metadata Event table.
*/
static guint32
-find_event_index (MonoClass *klass, MonoEvent *event) {
+find_event_index (MonoClass *klass, MonoEvent *event)
+{
int i;
+ MonoClassEventInfo *info = mono_class_get_event_info (klass);
- for (i = 0; i < klass->ext->event.count; ++i) {
- if (event == &klass->ext->events [i])
- return klass->ext->event.first + 1 + i;
+ for (i = 0; i < info->count; ++i) {
+ if (event == &info->events [i])
+ return info->first + 1 + i;
}
return 0;
}
MonoType *t;
int slen = mono_metadata_decode_value (p, &p);
- mono_error_init (error);
+ error_init (error);
n = (char *)g_memdup (p, slen + 1);
n [slen] = 0;
int slen, type = t->type;
MonoClass *tklass = t->data.klass;
- mono_error_init (error);
+ error_init (error);
handle_enum:
switch (type) {
static MonoObject*
load_cattr_value_boxed (MonoDomain *domain, MonoImage *image, MonoType *t, const char* p, const char** end, MonoError *error)
{
- mono_error_init (error);
+ error_init (error);
gboolean is_ref = type_is_reference (t);
MonoObject *retval;
void *params [2], *unboxed;
- mono_error_init (error);
+ error_init (error);
if (!ctor)
ctor = mono_class_get_method_from_name (mono_class_get_custom_attribute_typed_argument_class (), ".ctor", 2);
MonoObject *retval;
void *unboxed, *params [2];
- mono_error_init (error);
+ error_init (error);
if (!ctor)
ctor = mono_class_get_method_from_name (mono_class_get_custom_attribute_named_argument_class (), ".ctor", 2);
void **params = NULL;
MonoMethodSignature *sig;
- mono_error_init (error);
+ error_init (error);
mono_class_init (method->klass);
*named_args = NULL;
*named_arg_info = NULL;
- mono_error_init (error);
+ error_init (error);
if (!mono_verifier_verify_cattr_content (image, method, data, len, NULL)) {
mono_error_set_generic_error (error, "System.Reflection", "CustomAttributeFormatException", "Binary format of the specified custom attribute was invalid.");
CattrNamedArg *arginfo = NULL;
int i;
- mono_error_init (error);
+ error_init (error);
*ctor_args = NULL;
*named_args = NULL;
mono_error_set_pending_exception (&error);
}
-static MonoObject*
-create_custom_attr_data (MonoImage *image, MonoCustomAttrEntry *cattr, MonoError *error)
+static MonoObjectHandle
+create_custom_attr_data_handle (MonoImage *image, MonoCustomAttrEntry *cattr, MonoError *error)
{
static MonoMethod *ctor;
MonoDomain *domain;
- MonoObject *attr;
void *params [4];
- mono_error_init (error);
+ error_init (error);
g_assert (image->assembly);
ctor = mono_class_get_method_from_name (mono_defaults.customattribute_data_class, ".ctor", 4);
domain = mono_domain_get ();
- attr = mono_object_new_checked (domain, mono_defaults.customattribute_data_class, error);
- return_val_if_nok (error, NULL);
- params [0] = mono_method_get_object_checked (domain, cattr->ctor, NULL, error);
- return_val_if_nok (error, NULL);
- params [1] = mono_assembly_get_object_checked (domain, image->assembly, error);
- return_val_if_nok (error, NULL);
+
+ MonoObjectHandle attr = MONO_HANDLE_NEW (MonoObject, mono_object_new_checked (domain, mono_defaults.customattribute_data_class, error));
+ if (!is_ok (error))
+ goto fail;
+
+ MonoReflectionMethod *ctor_obj = mono_method_get_object_checked (domain, cattr->ctor, NULL, error);
+ if (!is_ok (error))
+ goto fail;
+ MonoReflectionAssemblyHandle assm = mono_assembly_get_object_handle (domain, image->assembly, error);
+ if (!is_ok (error))
+ goto fail;
+ params [0] = ctor_obj;
+ params [1] = MONO_HANDLE_RAW (assm);
params [2] = (gpointer)&cattr->data;
params [3] = &cattr->data_size;
- mono_runtime_invoke_checked (ctor, attr, params, error);
- return_val_if_nok (error, NULL);
+ mono_runtime_invoke_checked (ctor, MONO_HANDLE_RAW (attr), params, error);
return attr;
+fail:
+ return MONO_HANDLE_NEW (MonoObject, NULL);
+}
+
+static MonoObject *
+create_custom_attr_data (MonoImage *image, MonoCustomAttrEntry *cattr, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ MonoObjectHandle obj = create_custom_attr_data_handle (image, cattr, error);
+ HANDLE_FUNCTION_RETURN_OBJ (obj);
}
static MonoArray*
MonoObject *attr;
int i, n;
- mono_error_init (error);
+ error_init (error);
for (i = 0; i < cinfo->num_attrs; ++i) {
MonoCustomAttrEntry *centry = &cinfo->attrs[i];
MonoObject *attr;
int i;
- mono_error_init (error);
+ error_init (error);
result = mono_array_new_checked (mono_domain_get (), mono_defaults.customattribute_data_class, cinfo->num_attrs, error);
return_val_if_nok (error, NULL);
for (i = 0; i < cinfo->num_attrs; ++i) {
const char *data;
MonoCustomAttrEntry* attr;
- mono_error_init (error);
+ error_init (error);
ca = &image->tables [MONO_TABLE_CUSTOMATTRIBUTE];
g_warning ("Can't find custom attr constructor image: %s mtoken: 0x%08x due to: %s", image->name, mtoken, mono_error_get_message (error));
if (ignore_missing) {
mono_error_cleanup (error);
- mono_error_init (error);
+ error_init (error);
} else {
g_list_free (list);
g_free (ainfo);
{
guint32 idx;
- mono_error_init (error);
+ error_init (error);
/*
* An instantiated method has the same cattrs as the generic method definition.
{
guint32 idx;
- mono_error_init (error);
+ error_init (error);
if (mono_class_is_ginst (klass))
klass = mono_class_get_generic_class (klass)->container_class;
{
guint32 idx;
- mono_error_init (error);
+ error_init (error);
if (image_is_dynamic (assembly->image))
return lookup_custom_attr (assembly->image, assembly);
mono_custom_attrs_from_field_checked (MonoClass *klass, MonoClassField *field, MonoError *error)
{
guint32 idx;
- mono_error_init (error);
+ error_init (error);
if (image_is_dynamic (klass->image)) {
field = mono_metadata_get_corresponding_field_from_generic_type_definition (field);
MonoImage *image;
MonoReflectionMethodAux *aux;
- mono_error_init (error);
+ error_init (error);
/*
* An instantiated method has the same cattrs as the generic method definition.
g_assert (attr_klass != NULL);
- mono_error_init (error);
+ error_init (error);
for (i = 0; i < ainfo->num_attrs; ++i) {
centry = &ainfo->attrs[i];
MonoClass *klass;
MonoCustomAttrInfo *cinfo = NULL;
- mono_error_init (error);
+ error_init (error);
klass = obj->vtable->klass;
if (klass == mono_defaults.runtimetype_class) {
MonoArray *result;
MonoCustomAttrInfo *cinfo;
- mono_error_init (error);
+ error_init (error);
cinfo = mono_reflection_get_custom_attrs_info_checked (obj, error);
return_val_if_nok (error, NULL);
MonoArray *result;
MonoCustomAttrInfo *cinfo;
- mono_error_init (error);
+ error_init (error);
cinfo = mono_reflection_get_custom_attrs_info_checked (obj, error);
return_val_if_nok (error, NULL);