Permalink
Browse files

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.


svn path=/trunk/mono/; revision=152442
  • Loading branch information...
1 parent 42bf900 commit 22c072ac46c9c6afe158bbb08f13ea7236c38c74 @illupus illupus committed Feb 25, 2010
Showing with 47 additions and 15 deletions.
  1. +6 −0 mono/metadata/ChangeLog
  2. +32 −0 mono/metadata/metadata.c
  3. +9 −15 mono/metadata/metadata.h
@@ -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
@@ -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)
{
@@ -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);

0 comments on commit 22c072a

Please sign in to comment.