gboolean is_open;
int i;
int size = MONO_SIZEOF_GENERIC_INST + type_argc * sizeof (MonoType *);
- CollectData data;
- MonoImageSet *set;
for (i = 0; i < type_argc; ++i)
if (mono_class_is_open_constructed_type (type_argv [i]))
ginst->type_argc = type_argc;
memcpy (ginst->type_argv, type_argv, type_argc * sizeof (MonoType *));
+ return mono_metadata_get_canonical_generic_inst (ginst);
+}
+
+
+/**
+ * mono_metadata_get_canonical_generic_inst:
+ * @candidate: an arbitrary generic instantiation
+ *
+ * Returns the canonical generic instantiation that represents the given
+ * candidate by identifying the image set for the candidate instantiation and
+ * finding the instance in the image set or adding a copy of the given instance
+ * to the image set.
+ *
+ * The returned MonoGenericInst has its own copy of the list of types. The list
+ * passed in the argument can be freed, modified or disposed of.
+ *
+ */
+MonoGenericInst *
+mono_metadata_get_canonical_generic_inst (MonoGenericInst *candidate)
+{
+ CollectData data;
+ int type_argc = candidate->type_argc;
+ gboolean is_open = candidate->is_open;
+ MonoImageSet *set;
+
collect_data_init (&data);
- collect_ginst_images (ginst, &data);
+ collect_ginst_images (candidate, &data);
set = get_image_set (data.images, data.nimages);
mono_image_set_lock (set);
- ginst = (MonoGenericInst *)g_hash_table_lookup (set->ginst_cache, ginst);
+ MonoGenericInst *ginst = (MonoGenericInst *)g_hash_table_lookup (set->ginst_cache, candidate);
if (!ginst) {
+ int size = MONO_SIZEOF_GENERIC_INST + type_argc * sizeof (MonoType *);
ginst = (MonoGenericInst *)mono_image_set_alloc0 (set, size);
#ifndef MONO_SMALL_CONFIG
ginst->id = ++next_generic_inst_id;
ginst->is_open = is_open;
ginst->type_argc = type_argc;
- for (i = 0; i < type_argc; ++i)
- ginst->type_argv [i] = mono_metadata_type_dup (NULL, type_argv [i]);
+ for (int i = 0; i < type_argc; ++i)
+ ginst->type_argv [i] = mono_metadata_type_dup (NULL, candidate->type_argv [i]);
g_hash_table_insert (set->ginst_cache, ginst, ginst);
}
*conv = MONO_MARSHAL_CONV_STR_TBSTR;
return MONO_NATIVE_TBSTR;
case MONO_NATIVE_UTF8STR:
- *conv = MONO_MARSHAL_CONV_STR_LPTSTR;
+ *conv = MONO_MARSHAL_CONV_STR_UTF8STR;
return MONO_NATIVE_UTF8STR;
case MONO_NATIVE_BYVALTSTR:
if (unicode)
return event;
gtd = mono_class_get_generic_class (event->parent)->container_class;
- offset = event - event->parent->ext->events;
- return gtd->ext->events + offset;
+ offset = event - mono_class_get_event_info (event->parent)->events;
+ return mono_class_get_event_info (gtd)->events + offset;
}
/*
MonoProperty*
mono_metadata_get_corresponding_property_from_generic_type_definition (MonoProperty *property)
{
+ MonoClassPropertyInfo *info;
MonoClass *gtd;
int offset;
if (!mono_class_is_ginst (property->parent))
return property;
+ info = mono_class_get_property_info (property->parent);
gtd = mono_class_get_generic_class (property->parent)->container_class;
- offset = property - property->parent->ext->properties;
- return gtd->ext->properties + offset;
+ offset = property - info->properties;
+ return mono_class_get_property_info (gtd)->properties + offset;
}
MonoWrapperCaches*