mono_mb_emit_byte (mb, CEE_LDIND_REF);
if (conv == MONO_MARSHAL_CONV_OBJECT_INTERFACE) {
- mono_mb_emit_ptr (mb, mono_type_get_class (type));
+ mono_mb_emit_ptr (mb, mono_type_get_class_internal (type));
mono_mb_emit_icall (mb, cominterop_get_interface);
}
mono_mb_emit_byte (mb, CEE_LDIND_REF);
if (conv == MONO_MARSHAL_CONV_OBJECT_INTERFACE)
- mono_mb_emit_ptr (mb, mono_type_get_class (type));
+ mono_mb_emit_ptr (mb, mono_type_get_class_internal (type));
else if (conv == MONO_MARSHAL_CONV_OBJECT_IUNKNOWN)
mono_mb_emit_ptr (mb, mono_class_get_iunknown_class ());
else if (conv == MONO_MARSHAL_CONV_OBJECT_IDISPATCH)
g_assert (!MONO_HANDLE_IS_NULL (ref_type));
MonoType * const type = MONO_HANDLE_GETVAL (ref_type, type);
g_assert (type);
- MonoClass * klass = mono_type_get_class (type);
+ MonoClass * klass = mono_type_get_class_internal (type);
g_assert (klass);
if (!mono_class_init_checked (klass, error))
return NULL;
if (attr) {
MonoType *def_itf = attr->type->type;
if (def_itf->type == MONO_TYPE_CLASS)
- klass = mono_type_get_class (def_itf);
+ klass = mono_type_get_class_internal (def_itf);
}
if (!cinfo->cached)
mono_custom_attrs_free (cinfo);
}
if (type->type == MONO_TYPE_CLASS) {
- MonoClass *klass = mono_type_get_class (type);
+ MonoClass *klass = mono_type_get_class_internal (type);
/* need to report exceptions ? */
if (throwOnError && mono_class_has_failure (klass)) {
MONO_HANDLE_ARRAY_GETREF (t, res, i);
if (!MONO_HANDLE_IS_NULL (t)) {
- MonoClass *klass = mono_type_get_class (MONO_HANDLE_GETVAL (t, type));
+ MonoClass *klass = mono_type_get_class_internal (MONO_HANDLE_GETVAL (t, type));
if ((klass != NULL) && mono_class_has_failure (klass)) {
/* keep the class in the list */
list = g_list_append (list, klass);
* like string& since the C code for the icall has to work uniformly
* for both valuetypes and reference types.
*/
- if (generic_sig && mono_type_is_byref (generic_sig->params [param]) &&
+ if (generic_sig && mono_type_is_byref_internal (generic_sig->params [param]) &&
(generic_sig->params [param]->type == MONO_TYPE_VAR || generic_sig->params [param]->type == MONO_TYPE_MVAR))
return ICALL_HANDLES_WRAP_VALUETYPE_REF;
if (MONO_TYPE_IS_REFERENCE (sig->params [param])) {
if (mono_signature_param_is_out (sig, param))
return ICALL_HANDLES_WRAP_OBJ_OUT;
- else if (mono_type_is_byref (sig->params [param]))
+ else if (mono_type_is_byref_internal (sig->params [param]))
return ICALL_HANDLES_WRAP_OBJ_INOUT;
else
return ICALL_HANDLES_WRAP_OBJ;
- } else if (mono_type_is_byref (sig->params [param]))
+ } else if (mono_type_is_byref_internal (sig->params [param]))
return ICALL_HANDLES_WRAP_VALUETYPE_REF;
else
return ICALL_HANDLES_WRAP_NONE;
MonoDelegateHandle
ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal (void *ftn, MonoReflectionTypeHandle type, MonoError *error)
{
- MonoClass *klass = mono_type_get_class (MONO_HANDLE_GETVAL (type, type));
+ MonoClass *klass = mono_type_get_class_internal (MONO_HANDLE_GETVAL (type, type));
if (!mono_class_init_checked (klass, error))
return MONO_HANDLE_CAST (MonoDelegate, NULL_HANDLE);
int
ves_icall_System_Runtime_InteropServices_Marshal_GetArrayElementSize (MonoReflectionTypeHandle type_h, MonoError *error)
{
- MonoClass *eklass = mono_type_get_class (MONO_HANDLE_GETVAL (type_h, type));
+ MonoClass *eklass = mono_type_get_class_internal (MONO_HANDLE_GETVAL (type_h, type));
mono_class_init_internal (eklass);
return mono_image_get_alc (assm->image);
}
+/**
+ * mono_type_get_type_internal:
+ * \param type the \c MonoType operated on
+ * \returns the IL type value for \p type. This is one of the \c MonoTypeEnum
+ * enum members like \c MONO_TYPE_I4 or \c MONO_TYPE_STRING.
+ */
+static inline int
+mono_type_get_type_internal (MonoType *type)
+{
+ return type->type;
+}
+
+/**
+ * mono_type_get_signature:
+ * \param type the \c MonoType operated on
+ * It is only valid to call this function if \p type is a \c MONO_TYPE_FNPTR .
+ * \returns the \c MonoMethodSignature pointer that describes the signature
+ * of the function pointer \p type represents.
+ */
+static inline MonoMethodSignature*
+mono_type_get_signature_internal (MonoType *type)
+{
+ g_assert (type->type == MONO_TYPE_FNPTR);
+ return type->data.method;
+}
+
+/**
+ * mono_type_is_byref_internal:
+ * \param type the \c MonoType operated on
+ * \returns TRUE if \p type represents a type passed by reference,
+ * FALSE otherwise.
+ */
+static inline mono_bool
+mono_type_is_byref_internal (MonoType *type)
+{
+ return type->byref;
+}
+
+/**
+ * mono_type_get_class_internal:
+ * \param type the \c MonoType operated on
+ * It is only valid to call this function if \p type is a \c MONO_TYPE_CLASS or a
+ * \c MONO_TYPE_VALUETYPE . For more general functionality, use \c mono_class_from_mono_type_internal,
+ * instead.
+ * \returns the \c MonoClass pointer that describes the class that \p type represents.
+ */
+static inline MonoClass*
+mono_type_get_class_internal (MonoType *type)
+{
+ /* FIXME: review the runtime users before adding the assert here */
+ return type->data.klass;
+}
+
+/**
+ * mono_type_get_array_type_internal:
+ * \param type the \c MonoType operated on
+ * It is only valid to call this function if \p type is a \c MONO_TYPE_ARRAY .
+ * \returns a \c MonoArrayType struct describing the array type that \p type
+ * represents. The info includes details such as rank, array element type
+ * and the sizes and bounds of multidimensional arrays.
+ */
+static inline MonoArrayType*
+mono_type_get_array_type_internal (MonoType *type)
+{
+ return type->data.array;
+}
+
#endif /* __MONO_METADATA_INTERNALS_H__ */
mono_type_is_byref (MonoType *type)
{
mono_bool result;
- MONO_ENTER_GC_UNSAFE;
- result = type->byref;
+ MONO_ENTER_GC_UNSAFE; // FIXME slow
+ result = mono_type_is_byref_internal (type);
MONO_EXIT_GC_UNSAFE;
return result;
}
int
mono_type_get_type (MonoType *type)
{
- return type->type;
+ return mono_type_get_type_internal (type);
}
/**
MonoMethodSignature*
mono_type_get_signature (MonoType *type)
{
- g_assert (type->type == MONO_TYPE_FNPTR);
- return type->data.method;
+ return mono_type_get_signature_internal (type);
}
/**
mono_type_get_class (MonoType *type)
{
/* FIXME: review the runtime users before adding the assert here */
- return type->data.klass;
+ return mono_type_get_class_internal (type);
}
/**
MonoArrayType*
mono_type_get_array_type (MonoType *type)
{
- return type->data.array;
+ return mono_type_get_array_type_internal (type);
}
/**
MONO_PARSE_FIELD
} MonoParseTypeMode;
-MONO_API mono_bool
+MONO_API MONO_RT_EXTERNAL_ONLY mono_bool
mono_type_is_byref (MonoType *type);
-MONO_API int
+MONO_API MONO_RT_EXTERNAL_ONLY int
mono_type_get_type (MonoType *type);
/* For MONO_TYPE_FNPTR */
-MONO_API MonoMethodSignature*
+MONO_API MONO_RT_EXTERNAL_ONLY MonoMethodSignature*
mono_type_get_signature (MonoType *type);
/* For MONO_TYPE_CLASS, VALUETYPE */
-MONO_API MonoClass*
+MONO_API MONO_RT_EXTERNAL_ONLY MonoClass*
mono_type_get_class (MonoType *type);
MONO_API MonoArrayType*
if (candidate->type != MONO_TYPE_FNPTR)
return FALSE;
- left = mono_type_get_signature (target);
- right = mono_type_get_signature (candidate);
+ left = mono_type_get_signature_internal (target);
+ right = mono_type_get_signature_internal (candidate);
return mono_metadata_signature_equal (left, right) && left->call_convention == right->call_convention;
}
case MONO_TYPE_FNPTR:
if (candidate->type != MONO_TYPE_FNPTR)
return FALSE;
- return mono_delegate_signature_equal (mono_type_get_signature (target), mono_type_get_signature (candidate), FALSE);
+ return mono_delegate_signature_equal (mono_type_get_signature_internal (target), mono_type_get_signature_internal (candidate), FALSE);
case MONO_TYPE_GENERICINST: {
MonoClass *target_klass;
t = mono_reflection_get_type_checked (ass->image, ass->image, ud->info, ud->ignore_case, TRUE, &type_resolve, probe_type_error);
mono_error_cleanup (probe_type_error);
if (t) {
- g_ptr_array_add (ud->res_classes, mono_type_get_class (t));
+ g_ptr_array_add (ud->res_classes, mono_type_get_class_internal (t));
g_ptr_array_add (ud->res_domains, domain);
}
}
static int
type_check_context_used (MonoType *type, gboolean recursive)
{
- switch (mono_type_get_type (type)) {
+ switch (mono_type_get_type_internal (type)) {
case MONO_TYPE_VAR:
return MONO_GENERIC_CONTEXT_USED_CLASS;
case MONO_TYPE_MVAR:
return MONO_GENERIC_CONTEXT_USED_METHOD;
case MONO_TYPE_SZARRAY:
- return mono_class_check_context_used (mono_type_get_class (type));
+ return mono_class_check_context_used (mono_type_get_class_internal (type));
case MONO_TYPE_ARRAY:
return mono_class_check_context_used (mono_type_get_array_type (type)->eklass);
case MONO_TYPE_CLASS:
if (recursive)
- return mono_class_check_context_used (mono_type_get_class (type));
+ return mono_class_check_context_used (mono_type_get_class_internal (type));
else
return 0;
case MONO_TYPE_GENERICINST: