Thu Feb 25 11:37:50 CET 2010 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Thu, 25 Feb 2010 10:38:58 +0000 (10:38 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Thu, 25 Feb 2010 10:38:58 +0000 (10:38 -0000)
* metadata.c, metadata.h: make MONO_TYPE_IS* functional without
direct access to the MonoType fields.

svn path=/trunk/mono/; revision=152442

mono/metadata/ChangeLog
mono/metadata/metadata.c
mono/metadata/metadata.h

index 9dc3a1c7fea6393ec55d028355ef3bed7154ddb6..ea3cbad78d5f490611986a0962130885f4ebaea5 100644 (file)
@@ -1,3 +1,9 @@
+
+Thu Feb 25 11:37:50 CET 2010 Paolo Molaro <lupus@ximian.com>
+
+       * metadata.c, metadata.h: make MONO_TYPE_IS* functional without
+       direct access to the MonoType fields.
+
 2010-02-25  Zoltan Varga  <vargaz@gmail.com>
 
        * threads.h: Move some internal functions which were added to this header by
index caebbd361cfe3d357390bb6ee2fc0eee3ae91101..90410dd1897a5f68f7acb8f7b7120045681a2cb4 100644 (file)
@@ -5937,6 +5937,38 @@ mono_type_get_modifiers (MonoType *type, gboolean *is_required, gpointer *iter)
        return NULL;
 }
 
+mono_bool
+mono_type_is_struct (MonoType *type)
+{
+       return (!type->byref && ((type->type == MONO_TYPE_VALUETYPE &&
+               !type->data.klass->enumtype) || (type->type == MONO_TYPE_TYPEDBYREF) ||
+               ((type->type == MONO_TYPE_GENERICINST) && 
+               mono_metadata_generic_class_is_valuetype (type->data.generic_class) &&
+               !type->data.generic_class->container_class->enumtype)));
+}
+
+mono_bool
+mono_type_is_void (MonoType *type)
+{
+       return (type && (type->type == MONO_TYPE_VOID) && !type->byref);
+}
+
+mono_bool
+mono_type_is_pointer (MonoType *type)
+{
+       return (type && ((type->byref || (type->type == MONO_TYPE_I) || type->type == MONO_TYPE_STRING) || (type->type == MONO_TYPE_SZARRAY) || (type->type == MONO_TYPE_CLASS) || (type->type == MONO_TYPE_CLASS) || (type->type == MONO_TYPE_OBJECT) || (type->type == MONO_TYPE_ARRAY) || (type->type == MONO_TYPE_PTR)));
+}
+
+mono_bool
+mono_type_is_reference (MonoType *type)
+{
+       return (type && (((type->type == MONO_TYPE_STRING) ||
+               (type->type == MONO_TYPE_SZARRAY) || (type->type == MONO_TYPE_CLASS) ||
+               (type->type == MONO_TYPE_OBJECT) || (type->type == MONO_TYPE_ARRAY)) ||
+               ((type->type == MONO_TYPE_GENERICINST) &&
+               !mono_metadata_generic_class_is_valuetype (type->data.generic_class))));
+}
+
 MonoType*
 mono_signature_get_return_type (MonoMethodSignature *sig)
 {
index 2237da24aa82e961f2dfea8acb3a6591524e31e1..4d83adf9ead5bdccd00e61744694780317bfc095 100644 (file)
@@ -23,21 +23,10 @@ MONO_BEGIN_DECLS
 #endif
 #endif
 
-#define MONO_TYPE_ISSTRUCT(t) (!(t)->byref && (((t)->type == MONO_TYPE_VALUETYPE && \
-       !(t)->data.klass->enumtype) || ((t)->type == MONO_TYPE_TYPEDBYREF) || \
-       (((t)->type == MONO_TYPE_GENERICINST) && mono_metadata_generic_class_is_valuetype ((t)->data.generic_class) && !(t)->data.generic_class->container_class->enumtype)))
-
-#define MONO_TYPE_IS_VOID(t) ((t) && ((t)->type == MONO_TYPE_VOID) && !(t)->byref)
-#define MONO_TYPE_IS_POINTER(t) ((t) && (((t)->byref || ((t)->type == MONO_TYPE_I) || (t)->type == MONO_TYPE_STRING) || ((t)->type == MONO_TYPE_SZARRAY) || ((t)->type == MONO_TYPE_CLASS) || ((t)->type == MONO_TYPE_CLASS) || ((t)->type == MONO_TYPE_OBJECT) || ((t)->type == MONO_TYPE_ARRAY) || ((t)->type == MONO_TYPE_PTR)))
-
-#define MONO_TYPE_IS_REFERENCE(t) ((t) &&                                      \
-                                  ((((t)->type == MONO_TYPE_STRING) ||         \
-                                    ((t)->type == MONO_TYPE_SZARRAY) ||        \
-                                    ((t)->type == MONO_TYPE_CLASS) ||          \
-                                    ((t)->type == MONO_TYPE_OBJECT) ||         \
-                                    ((t)->type == MONO_TYPE_ARRAY)) ||         \
-                                   (((t)->type == MONO_TYPE_GENERICINST) &&    \
-                                    !mono_metadata_generic_class_is_valuetype ((t)->data.generic_class))))
+#define MONO_TYPE_ISSTRUCT(t) mono_type_is_struct (t)
+#define MONO_TYPE_IS_VOID(t) mono_type_is_void (t)
+#define MONO_TYPE_IS_POINTER(t) mono_type_is_pointer (t)
+#define MONO_TYPE_IS_REFERENCE(t) mono_type_is_reference (t)
 
 #define MONO_CLASS_IS_INTERFACE(c) ((c->flags & TYPE_ATTRIBUTE_INTERFACE) || (c->byval_arg.type == MONO_TYPE_VAR) || (c->byval_arg.type == MONO_TYPE_MVAR))
 
@@ -364,6 +353,11 @@ mono_type_get_ptr_type (MonoType *type);
 MonoClass*
 mono_type_get_modifiers  (MonoType *type, mono_bool *is_required, void **iter);
 
+mono_bool mono_type_is_struct    (MonoType *type);
+mono_bool mono_type_is_void      (MonoType *type);
+mono_bool mono_type_is_pointer   (MonoType *type);
+mono_bool mono_type_is_reference (MonoType *type);
+
 MonoType*
 mono_signature_get_return_type (MonoMethodSignature *sig);