[reflection] Use MonoError for mono_custom_attrs_from_event
authorAleksey Kliger <aleksey@xamarin.com>
Thu, 25 Feb 2016 21:46:29 +0000 (16:46 -0500)
committerAleksey Kliger <aleksey@xamarin.com>
Mon, 29 Feb 2016 16:15:27 +0000 (11:15 -0500)
Mark it external only.  Runtime should use mono_custom_attrs_from_event_checked.

mono/metadata/reflection-internals.h
mono/metadata/reflection.c
mono/metadata/reflection.h

index 33658ba39187b3531fd65eb9fc7b91b96aeaa55e..fdb51276890b919eceb9756e368ddf0671e9cbd0 100644 (file)
@@ -27,6 +27,8 @@ MonoCustomAttrInfo*
 mono_custom_attrs_from_assembly_checked        (MonoAssembly *assembly, MonoError *error);
 MonoCustomAttrInfo*
 mono_custom_attrs_from_property_checked        (MonoClass *klass, MonoProperty *property, MonoError *error);
+MonoCustomAttrInfo*
+mono_custom_attrs_from_event_checked   (MonoClass *klass, MonoEvent *event, MonoError *error);
 
 
 char*
index e812f7cd26dd3ca180140c5c2668bf24e402ebc7..eba4885f60abdebbf26fd7a845861508d5a674f7 100644 (file)
@@ -9715,6 +9715,14 @@ MonoCustomAttrInfo*
 mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event)
 {
        MonoError error;
+       MonoCustomAttrInfo * result = mono_custom_attrs_from_event_checked (klass, event, &error);
+       mono_error_cleanup (&error); /* FIXME want a better API that doesn't swallow the error */
+       return result;
+}
+
+MonoCustomAttrInfo*
+mono_custom_attrs_from_event_checked (MonoClass *klass, MonoEvent *event, MonoError *error)
+{
        guint32 idx;
        
        if (image_is_dynamic (klass->image)) {
@@ -9724,12 +9732,7 @@ mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event)
        idx = find_event_index (klass, event);
        idx <<= MONO_CUSTOM_ATTR_BITS;
        idx |= MONO_CUSTOM_ATTR_EVENT;
-       MonoCustomAttrInfo * result = mono_custom_attrs_from_index_checked (klass->image, idx, &error);
-       if (!is_ok (&error)) {
-               mono_loader_set_error_from_mono_error (&error); /* FIXME don't set loader error here */
-               return NULL;
-       }
-       return result;
+       return mono_custom_attrs_from_index_checked (klass->image, idx, error);
 }
 
 MonoCustomAttrInfo*
@@ -9940,7 +9943,8 @@ mono_reflection_get_custom_attrs_info_checked (MonoObject *obj, MonoError *error
                return_val_if_nok (error, NULL);
        } else if (strcmp ("MonoEvent", klass->name) == 0) {
                MonoReflectionMonoEvent *revent = (MonoReflectionMonoEvent*)obj;
-               cinfo = mono_custom_attrs_from_event (revent->event->parent, revent->event);
+               cinfo = mono_custom_attrs_from_event_checked (revent->event->parent, revent->event, error);
+               return_val_if_nok (error, NULL);
        } else if (strcmp ("MonoField", klass->name) == 0) {
                MonoReflectionField *rfield = (MonoReflectionField*)obj;
                cinfo = mono_custom_attrs_from_field (rfield->field->parent, rfield->field);
index eee44ebe2cd2df604b319c1f046e2dcb7c3e4027..4e8ffae7758fefa782acf27cc2d5ea726f05377e 100644 (file)
@@ -88,6 +88,7 @@ MONO_RT_EXTERNAL_ONLY
 MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
 MONO_RT_EXTERNAL_ONLY
 MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
+MONO_RT_EXTERNAL_ONLY
 MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_event    (MonoClass *klass, MonoEvent *event);
 MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_field    (MonoClass *klass, MonoClassField *field);
 MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_param    (MonoMethod *method, uint32_t param);