Author: raja
Date: 2005-04-08 07:00:31 -0400 (Fri, 08 Apr 2005)
New Revision: 42685
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/reflection.c
Log:
2005-04-08 Ankit Jain <[EMAIL PROTECTED]>
* reflection.c (get_default_param_value_blobs): Add 'types'
parameter to get the types encoded in the constant table.
(mono_param_get_objects): Use the type from the constant table,
not the type of the parameter, when creating default values.
Handle null default values correctly.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2005-04-08 10:43:02 UTC (rev 42684)
+++ trunk/mono/mono/metadata/ChangeLog 2005-04-08 11:00:31 UTC (rev 42685)
@@ -1,3 +1,11 @@
+2005-04-08 Ankit Jain <[EMAIL PROTECTED]>
+
+ * reflection.c (get_default_param_value_blobs): Add 'types'
+ parameter to get the types encoded in the constant table.
+ (mono_param_get_objects): Use the type from the constant table,
+ not the type of the parameter, when creating default values.
+ Handle null default values correctly.
+
2005-04-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* file-io.c:
Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c 2005-04-08 10:43:02 UTC (rev
42684)
+++ trunk/mono/mono/metadata/reflection.c 2005-04-08 11:00:31 UTC (rev
42685)
@@ -137,7 +137,7 @@
static gpointer resolve_object (MonoImage *image, MonoObject *obj, MonoClass
**handle_class);
static void encode_type (MonoDynamicImage *assembly, MonoType *type, char
*p, char **endbuf);
static guint32 type_get_signature_size (MonoType *type);
-static void get_default_param_value_blobs (MonoMethod *method, char **blobs);
+static void get_default_param_value_blobs (MonoMethod *method, char **blobs,
guint32 *types);
static MonoObject *mono_get_object_from_blob (MonoDomain *domain, MonoType
*type, const char *blob);
@@ -5532,6 +5532,8 @@
MonoReflectionMethod *member = NULL;
MonoReflectionParameter *param = NULL;
char **names, **blobs = NULL;
+ guint32 *types = NULL;
+ MonoType *type = NULL;
MonoObject *dbnull = mono_get_dbnull_object (domain);
MonoMarshalSpec **mspecs;
int i;
@@ -5567,18 +5569,29 @@
if (!(param->AttrsImpl & PARAM_ATTRIBUTE_HAS_DEFAULT)) {
param->DefaultValueImpl = dbnull;
} else {
- MonoType *type = param->ClassImpl->type;
if (!blobs) {
blobs = g_new0 (char *, mono_method_signature
(method)->param_count);
- get_default_param_value_blobs (method, blobs);
+ types = g_new0 (guint32, mono_method_signature
(method)->param_count);
+ get_default_param_value_blobs (method, blobs,
types);
}
+ /* Build MonoType for the type from the Constant Table
*/
+ if (!type)
+ type = g_new0 (MonoType, 1);
+ type->type = types [i];
+ type->data.klass = NULL;
+ if (types [i] == MONO_TYPE_CLASS)
+ type->data.klass = mono_defaults.object_class;
+ else
+ type->data.klass = mono_class_from_mono_type
(type);
+
param->DefaultValueImpl = mono_get_object_from_blob
(domain, type, blobs [i]);
- if (!param->DefaultValueImpl) {
+ /* Type in the Constant table is MONO_TYPE_CLASS for
nulls */
+ if (types [i] != MONO_TYPE_CLASS &&
!param->DefaultValueImpl)
param->DefaultValueImpl = dbnull;
- }
+
}
if (mspecs [i + 1])
@@ -5588,6 +5601,8 @@
}
g_free (names);
g_free (blobs);
+ g_free (types);
+ g_free (type);
for (i = mono_method_signature (method)->param_count; i >= 0; i--)
if (mspecs [i])
@@ -5717,7 +5732,7 @@
static void
-get_default_param_value_blobs (MonoMethod *method, char **blobs)
+get_default_param_value_blobs (MonoMethod *method, char **blobs, guint32
*types)
{
guint32 param_index, i, lastp, crow = 0;
guint32 param_cols [MONO_PARAM_SIZE], const_cols [MONO_CONSTANT_SIZE];
@@ -5776,6 +5791,7 @@
mono_metadata_decode_row (constt, crow - 1, const_cols,
MONO_CONSTANT_SIZE);
blobs [paramseq - 1] = (gpointer) mono_metadata_blob_heap
(image, const_cols [MONO_CONSTANT_VALUE]);
+ types [paramseq - 1] = const_cols [MONO_CONSTANT_TYPE];
}
return;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches