/* FIXME: !mono_class_is_ginst (from_class) condition causes test failures. */
if (klass->type_token && !image_is_dynamic (klass->image) && !klass->methods && !klass->rank && klass == from_class && !mono_class_is_ginst (from_class)) {
- for (i = 0; i < klass->method.count; ++i) {
+ int first_idx = mono_class_get_first_method_idx (klass);
+ int mcount = mono_class_get_method_count (klass);
+ for (i = 0; i < mcount; ++i) {
guint32 cols [MONO_METHOD_SIZE];
MonoMethod *method;
const char *m_name;
MonoMethodSignature *other_sig;
- mono_metadata_decode_table_row (klass->image, MONO_TABLE_METHOD, klass->method.first + i, cols, MONO_METHOD_SIZE);
+ mono_metadata_decode_table_row (klass->image, MONO_TABLE_METHOD, first_idx + i, cols, MONO_METHOD_SIZE);
m_name = mono_metadata_string_heap (klass->image, cols [MONO_METHOD_NAME]);
(name && !strcmp (m_name, name))))
continue;
- method = mono_get_method_checked (klass->image, MONO_TOKEN_METHOD_DEF | (klass->method.first + i + 1), klass, NULL, error);
+ method = mono_get_method_checked (klass->image, MONO_TOKEN_METHOD_DEF | (first_idx + i + 1), klass, NULL, error);
if (!mono_error_ok (error)) //bail out if we hit a loader error
return NULL;
if (method) {
return NULL;
}
- for (i = 0; i < klass->method.count; ++i) {
+ int mcount = mono_class_get_method_count (klass);
+ for (i = 0; i < mcount; ++i) {
MonoMethod *m = klass->methods [i];
MonoMethodSignature *msig;
}
}
- if (i < klass->method.count)
+ if (i < mcount)
return mono_class_get_method_by_index (from_class, i);
return NULL;
}
mono_class_setup_methods (klass);
g_assert (!mono_class_has_failure (klass)); /*FIXME this should not fail, right?*/
- for (i = 0; i < klass->method.count; ++i) {
+ int mcount = mono_class_get_method_count (klass);
+ for (i = 0; i < mcount; ++i) {
MonoMethod *method = klass->methods [i];
if (strcmp (method->name, name) == 0 && sig->param_count == method->signature->param_count)
return method;
mono_error_set_method_load (error, m->klass, m->name, "generic_params table claims method has generic parameters, but signature says it doesn't for method 0x%08x from image %s", idx, img->name);
return NULL;
}
- if (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)
+ if (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
signature->pinvoke = 1;
- else if (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
+#ifdef HOST_WIN32
+ /*
+ * On Windows the default pinvoke calling convention is STDCALL but
+ * we need CDECL since this is actually an icall.
+ */
+ signature->call_convention = MONO_CALL_C;
+#endif
+ } else if (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
MonoCallConvention conv = (MonoCallConvention)0;
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)m;
signature->pinvoke = 1;
mono_class_setup_methods (klass);
if (mono_class_has_failure (klass))
return 0;
- for (i = 0; i < klass->method.count; ++i) {
+ int first_idx = mono_class_get_first_method_idx (klass);
+ int mcount = mono_class_get_method_count (klass);
+ for (i = 0; i < mcount; ++i) {
if (method == klass->methods [i]) {
if (klass->image->uncompressed_metadata)
- return mono_metadata_translate_token_index (klass->image, MONO_TABLE_METHOD, klass->method.first + i + 1);
+ return mono_metadata_translate_token_index (klass->image, MONO_TABLE_METHOD, first_idx + i + 1);
else
- return klass->method.first + i + 1;
+ return first_idx + i + 1;
}
}
return 0;