gboolean mono_class_is_magic_float (MonoClass *klass) { static MonoClass *magic_nfloat_class; if (klass == magic_nfloat_class) return TRUE; if (magic_nfloat_class) return FALSE; if (!mono_class_is_magic_assembly (klass)) return FALSE; if (strcmp ("System", m_class_get_name_space (klass)) != 0) return FALSE; if (strcmp ("nfloat", m_class_get_name (klass)) == 0) { magic_nfloat_class = klass; /* Assert that we are using the matching assembly */ MonoClassField *value_field = mono_class_get_field_from_name_full (klass, "v", NULL); g_assert (value_field); MonoType *t = mono_field_get_type (value_field); MonoType *native = mini_native_type_replace_type (m_class_get_byval_arg (klass)); if (t->type != native->type) g_error ("Assembly used for native types '%s' doesn't match this runtime, %s is mapped to %s, expecting %s.\n", m_class_get_image (klass)->name, m_class_get_name (klass), mono_type_full_name (t), mono_type_full_name (native)); return TRUE; } return FALSE; }
static MonoToggleRefStatus test_toggleref_callback (MonoObject *obj) { static MonoClassField *mono_toggleref_test_field; MonoToggleRefStatus status = MONO_TOGGLE_REF_DROP; if (!mono_toggleref_test_field) { mono_toggleref_test_field = mono_class_get_field_from_name_full (mono_object_get_class (obj), "__test", NULL); g_assert (mono_toggleref_test_field); } /* In coop mode, important to not call a helper that will pin obj! */ mono_field_get_value_internal (obj, mono_toggleref_test_field, &status); printf ("toggleref-cb obj %d\n", status); return status; }