From: Vibhav Pant vibhavp@gmail.com
--- dlls/rometadata/mdtables.c | 33 ++++++++++++++++++++++++++++-- dlls/rometadata/tests/rometadata.c | 16 +++++++-------- 2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/dlls/rometadata/mdtables.c b/dlls/rometadata/mdtables.c index 0c3ee5eb1d7..ca86124d065 100644 --- a/dlls/rometadata/mdtables.c +++ b/dlls/rometadata/mdtables.c @@ -1000,8 +1000,37 @@ static HRESULT WINAPI import_FindMember(IMetaDataImport *iface, mdTypeDef type_d static HRESULT WINAPI import_FindMethod(IMetaDataImport *iface, mdTypeDef type_def, const WCHAR *name, const COR_SIGNATURE *sig_blob, ULONG len, mdMethodDef *method_def) { - FIXME("(%p, %#x, %s, %p, %lu, %p): stub!\n", iface, type_def, debugstr_w(name), sig_blob, len, method_def); - return E_NOTIMPL; + mdMethodDef cur_method; + HCORENUM henum = NULL; + BOOL found = FALSE; + HRESULT hr; + + TRACE("(%p, %s, %s, %p, %lu, %p):\n", iface, debugstr_mdToken(type_def), debugstr_w(name), sig_blob, len, + method_def); + + if (!name) return E_INVALIDARG; + if (IsNilToken(type_def) || TypeFromToken(type_def) != mdtTypeDef) return CLDB_E_RECORD_NOTFOUND; + + if (FAILED((hr = IMetaDataImport_EnumMethodsWithName(iface, &henum, type_def, name, &cur_method, 1, NULL)))) return hr; + while (hr == S_OK) + { + const COR_SIGNATURE *cur_sig; + ULONG cur_sig_len; + + hr = IMetaDataImport_GetMethodProps(iface, cur_method, NULL, NULL, 0, NULL, NULL, &cur_sig, &cur_sig_len, NULL, + NULL); + if (FAILED(hr)) break; + if (!(len && sig_blob) || (len == cur_sig_len && !memcmp(cur_sig, sig_blob, len))) + { + found = TRUE; + break; + } + hr = IMetaDataImport_EnumMethodsWithName(iface, &henum, type_def, name, &cur_method, 1, NULL); + } + IMetaDataImport_CloseEnum(iface, henum); + + *method_def = found ? cur_method : mdMethodDefNil; + return FAILED(hr) ? hr : (found ? S_OK : CLDB_E_RECORD_NOTFOUND); }
static HRESULT WINAPI import_FindField(IMetaDataImport *iface, mdTypeDef type_def, const WCHAR *name, diff --git a/dlls/rometadata/tests/rometadata.c b/dlls/rometadata/tests/rometadata.c index 3bab03a4252..6bcaa8fedbc 100644 --- a/dlls/rometadata/tests/rometadata.c +++ b/dlls/rometadata/tests/rometadata.c @@ -1176,14 +1176,14 @@ static void test_IMetaDataImport(void)
methoddef = mdMethodDefNil; hr = IMetaDataImport_FindMethod(md_import, typedef2, name, sig_blob, sig_len, &methoddef); - todo_wine ok(hr == S_OK, "got hr %#lx\n", hr); - todo_wine ok(methoddef == methoddef_tokens[i], "got methoddef %s != %s\n", debugstr_mdToken(methoddef), - debugstr_mdToken(methoddef_tokens[i])); + ok(hr == S_OK, "got hr %#lx\n", hr); + ok(methoddef == methoddef_tokens[i], "got methoddef %s != %s\n", debugstr_mdToken(methoddef), + debugstr_mdToken(methoddef_tokens[i])); methoddef = mdMethodDefNil; hr = IMetaDataImport_FindMethod(md_import, typedef2, name, NULL, 0, &methoddef); - todo_wine ok(hr == S_OK, "got hr %#lx\n", hr); - todo_wine ok(methoddef == methoddef_tokens[i], "got methoddef %s != %s\n", debugstr_mdToken(methoddef), - debugstr_mdToken(methoddef_tokens[i])); + ok(hr == S_OK, "got hr %#lx\n", hr); + ok(methoddef == methoddef_tokens[i], "got methoddef %s != %s\n", debugstr_mdToken(methoddef), + debugstr_mdToken(methoddef_tokens[i]));
henum2 = NULL; methoddef = mdMethodDefNil; @@ -1216,9 +1216,9 @@ static void test_IMetaDataImport(void) winetest_pop_context(); } hr = IMetaDataImport_FindMethod(md_import, typedef2, NULL, NULL, 0, &methoddef); - todo_wine ok(hr == E_INVALIDARG, "got hr %#lx\n", hr); + ok(hr == E_INVALIDARG, "got hr %#lx\n", hr); hr = IMetaDataImport_FindMethod(md_import, typedef2, L"foo", NULL, 0, &methoddef); - todo_wine ok(hr == CLDB_E_RECORD_NOTFOUND, "got hr %#lx\n", hr); + ok(hr == CLDB_E_RECORD_NOTFOUND, "got hr %#lx\n", hr); free(methoddef_tokens); IMetaDataImport_CloseEnum(md_import, henum);