Author: lupus
Date: 2007-11-08 09:10:43 -0500 (Thu, 08 Nov 2007)
New Revision: 89185

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/reflection.c
   trunk/mono/mono/metadata/reflection.h
Log:


Thu Nov 8 15:31:21 CET 2007 Paolo Molaro <[EMAIL PROTECTED]>

        * reflection.h, reflection.c: don't export random functions
        and lazy load dbnull and missing objects.



Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-11-08 14:02:11 UTC (rev 89184)
+++ trunk/mono/mono/metadata/ChangeLog  2007-11-08 14:10:43 UTC (rev 89185)
@@ -1,3 +1,9 @@
+
+Thu Nov 8 15:31:21 CET 2007 Paolo Molaro <[EMAIL PROTECTED]>
+
+       * reflection.h, reflection.c: don't export random functions
+       and lazy load dbnull and missing objects.
+
 2007-11-07  Jonathan Chambers <[EMAIL PROTECTED]>
 
        * class.c: Initialize COM types if COM interfaces

Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c       2007-11-08 14:02:11 UTC (rev 
89184)
+++ trunk/mono/mono/metadata/reflection.c       2007-11-08 14:10:43 UTC (rev 
89185)
@@ -5702,6 +5702,50 @@
        CACHE_OBJECT (MonoReflectionEvent *, event, res, klass);
 }
 
+/**
+ * mono_get_reflection_missing_object:
+ * @domain: Domain where the object lives
+ *
+ * Returns the System.Reflection.Missing.Value singleton object
+ * (of type System.Reflection.Missing).
+ *
+ * Used as the value for ParameterInfo.DefaultValue when Optional
+ * is present
+ */
+static MonoObject *
+mono_get_reflection_missing_object (MonoDomain *domain)
+{
+       MonoObject *obj;
+       static MonoClassField *missing_value_field = NULL;
+       
+       if (!missing_value_field) {
+               MonoClass *missing_klass;
+               missing_klass = mono_class_from_name (mono_defaults.corlib, 
"System.Reflection", "Missing");
+               mono_class_init (missing_klass);
+               missing_value_field = mono_class_get_field_from_name 
(missing_klass, "Value");
+               g_assert (missing_value_field);
+       }
+       obj = mono_field_get_value_object (domain, missing_value_field, NULL); 
+       g_assert (obj);
+       return obj;
+}
+
+static MonoObject*
+get_dbnull (MonoDomain *domain, MonoObject **dbnull)
+{
+       if (!*dbnull)
+               *dbnull = mono_get_dbnull_object (domain);
+       return *dbnull;
+}
+
+static MonoObject*
+get_reflection_missing (MonoDomain *domain, MonoObject **reflection_missing)
+{
+       if (!*reflection_missing)
+               *reflection_missing = mono_get_reflection_missing_object 
(domain);
+       return *reflection_missing;
+}
+
 /*
  * mono_param_get_objects:
  * @domain: an app domain
@@ -5720,8 +5764,8 @@
        char **names, **blobs = NULL;
        guint32 *types = NULL;
        MonoType *type = NULL;
-       MonoObject *dbnull = mono_get_dbnull_object (domain);
-       MonoObject *missing = mono_get_reflection_missing_object (domain);
+       MonoObject *dbnull = NULL;
+       MonoObject *missing = NULL;
        MonoMarshalSpec **mspecs;
        MonoMethodSignature *sig;
        int i;
@@ -5757,9 +5801,9 @@
 
                if (!(param->AttrsImpl & PARAM_ATTRIBUTE_HAS_DEFAULT)) {
                        if (param->AttrsImpl & PARAM_ATTRIBUTE_OPTIONAL)
-                               MONO_OBJECT_SETREF (param, DefaultValueImpl, 
missing);
+                               MONO_OBJECT_SETREF (param, DefaultValueImpl, 
get_reflection_missing (domain, &missing));
                        else
-                               MONO_OBJECT_SETREF (param, DefaultValueImpl, 
dbnull);
+                               MONO_OBJECT_SETREF (param, DefaultValueImpl, 
get_dbnull (domain, &dbnull));
                } else {
 
                        if (!blobs) {
@@ -5788,9 +5832,9 @@
                        /* Type in the Constant table is MONO_TYPE_CLASS for 
nulls */
                        if (types [i] != MONO_TYPE_CLASS && 
!param->DefaultValueImpl) {
                                if (param->AttrsImpl & PARAM_ATTRIBUTE_OPTIONAL)
-                                       MONO_OBJECT_SETREF (param, 
DefaultValueImpl, missing);
+                                       MONO_OBJECT_SETREF (param, 
DefaultValueImpl, get_reflection_missing (domain, &missing));
                                else
-                                       MONO_OBJECT_SETREF (param, 
DefaultValueImpl, dbnull);
+                                       MONO_OBJECT_SETREF (param, 
DefaultValueImpl, get_dbnull (domain, &dbnull));
                        }
                        
                }
@@ -5938,35 +5982,6 @@
        return obj;
 }
 
-/**
- * mono_get_reflection_missing_object:
- * @domain: Domain where the object lives
- *
- * Returns the System.Reflection.Missing.Value singleton object
- * (of type System.Reflection.Missing).
- *
- * Used as the value for ParameterInfo.DefaultValue when Optional
- * is present
- */
-MonoObject *
-mono_get_reflection_missing_object (MonoDomain *domain)
-{
-       MonoObject *obj;
-       static MonoClassField *missing_value_field = NULL;
-       
-       if (!missing_value_field) {
-               MonoClass *missing_klass;
-               missing_klass = mono_class_from_name (mono_defaults.corlib, 
"System.Reflection", "Missing");
-               mono_class_init (missing_klass);
-               missing_value_field = mono_class_get_field_from_name 
(missing_klass, "Value");
-               g_assert (missing_value_field);
-       }
-       obj = mono_field_get_value_object (domain, missing_value_field, NULL); 
-       g_assert (obj);
-       return obj;
-}
-
-
 static void
 get_default_param_value_blobs (MonoMethod *method, char **blobs, guint32 
*types)
 {

Modified: trunk/mono/mono/metadata/reflection.h
===================================================================
--- trunk/mono/mono/metadata/reflection.h       2007-11-08 14:02:11 UTC (rev 
89184)
+++ trunk/mono/mono/metadata/reflection.h       2007-11-08 14:10:43 UTC (rev 
89185)
@@ -67,7 +67,6 @@
 MonoReflectionMethodBody* mono_method_body_get_object (MonoDomain *domain, 
MonoMethod *method);
 
 MonoObject *mono_get_dbnull_object (MonoDomain *domain);
-MonoObject *mono_get_reflection_missing_object (MonoDomain *domain);
 
 MonoArray*  mono_reflection_get_custom_attrs_by_type (MonoObject *obj, 
MonoClass *attr_klass);
 MonoArray*  mono_reflection_get_custom_attrs (MonoObject *obj);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to