load_cattr_value (MonoImage *image, MonoType *t, const char *p, const char **end)
{
int slen, type = t->type;
+ MonoClass *tklass = t->data.klass;
+
handle_enum:
switch (type) {
case MONO_TYPE_U1:
} else if (subt == 0x0E) {
type = MONO_TYPE_STRING;
goto handle_enum;
+ } else if (subt == 0x1D) {
+ MonoType simple_type = {{0}};
+ int etype = *p;
+ p ++;
+
+ type = MONO_TYPE_SZARRAY;
+ simple_type.type = etype;
+ tklass = mono_class_from_mono_type (&simple_type);
+ goto handle_enum;
} else if (subt == 0x55) {
char *n;
MonoType *t;
*end = p;
return NULL;
}
- arr = mono_array_new (mono_domain_get(), t->data.klass, alen);
- basetype = t->data.klass->byval_arg.type;
+ arr = mono_array_new (mono_domain_get(), tklass, alen);
+ basetype = tklass->byval_arg.type;
switch (basetype)
{
case MONO_TYPE_U1:
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
for (i = 0; i < alen; i++) {
- MonoObject *item = load_cattr_value (image, &t->data.klass->byval_arg, p, &p);
+ MonoObject *item = load_cattr_value (image, &tklass->byval_arg, p, &p);
mono_array_setref (arr, i, item);
}
break;
return result;
}
-MonoArray*
+static MonoArray*
mono_custom_attrs_construct_by_type (MonoCustomAttrInfo *cinfo, MonoClass *attr_klass)
{
MonoArray *result;
return result;
}
-MonoArray*
+static MonoArray*
mono_custom_attrs_data_construct (MonoCustomAttrInfo *cinfo)
{
MonoArray *result;
*retbuffer = buffer;
eclass = type->data.klass;
arg_eclass = mono_object_class (arg)->element_class;
- if (eclass->valuetype && arg_eclass->valuetype) {
+ if (eclass == mono_defaults.object_class && arg_eclass->valuetype) {
+ /* Happens when we are called from the MONO_TYPE_OBJECT case below */
+ char *elptr = mono_array_addr ((MonoArray*)arg, char, 0);
+ int elsize = mono_class_array_element_size (arg_eclass);
+ for (i = 0; i < len; ++i) {
+ encode_cattr_value (assembly, buffer, p, &buffer, &p, buflen, &arg_eclass->byval_arg, NULL, elptr);
+ elptr += elsize;
+ }
+ } else if (eclass->valuetype && arg_eclass->valuetype) {
char *elptr = mono_array_addr ((MonoArray*)arg, char, 0);
int elsize = mono_class_array_element_size (eclass);
for (i = 0; i < len; ++i) {
}
break;
}
- /* it may be a boxed value or a Type */
case MONO_TYPE_OBJECT: {
MonoClass *klass;
char *str;
guint32 slen;
+ /*
+ * The parameter type is 'object' but the type of the actual
+ * argument is not. So we have to add type information to the blob
+ * too. This is completely undocumented in the spec.
+ */
+
if (arg == NULL) {
*p++ = MONO_TYPE_STRING; // It's same hack as MS uses
*p++ = 0xFF;
simple_type = MONO_TYPE_STRING;
*p++ = 0x0E;
goto handle_enum;
+ } else if (klass->rank == 1) {
+ simple_type = MONO_TYPE_SZARRAY;
+ *p++ = 0x1D;
+ *p++ = klass->element_class->byval_arg.type;
+ goto handle_enum;
} else if (klass->byval_arg.type >= MONO_TYPE_BOOLEAN && klass->byval_arg.type <= MONO_TYPE_R8) {
*p++ = simple_type = klass->byval_arg.type;
goto handle_enum;
}
}
- if (klass->flags & TYPE_ATTRIBUTE_INTERFACE)
+ if (klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
for (i = 0; i < klass->method.count; ++i)
klass->methods [i]->slot = i;
+
+ mono_class_setup_interface_offsets (klass);
+ }
/*
* The generic vtable is needed even if image->run is not set since some