Module: wine Branch: master Commit: 658209b57164da96919500468114a6a7eb0bf7b5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=658209b57164da969195004681...
Author: Andrey Turkin andrey.turkin@gmail.com Date: Sun May 9 23:33:24 2010 +0400
oleaut32: Implement ICreateTypeInfo2::SetCustData method.
---
dlls/oleaut32/tests/typelib.c | 77 +++++++++++++++++++++++++++++++++++++++++ dlls/oleaut32/typelib2.c | 12 +++++-- 2 files changed, 86 insertions(+), 3 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index cf8c8cb..f0f577a 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -975,6 +975,7 @@ static void test_CreateTypeLib(void) { static OLECHAR typelibW[] = {'t','y','p','e','l','i','b',0}; static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',0}; static OLECHAR interface2W[] = {'i','n','t','e','r','f','a','c','e','2',0}; + static OLECHAR interface3W[] = {'i','n','t','e','r','f','a','c','e','3',0}; static OLECHAR dualW[] = {'d','u','a','l',0}; static OLECHAR coclassW[] = {'c','o','c','l','a','s','s',0}; static WCHAR defaultW[] = {'d','e','f','a','u','l','t',0x3213,0}; @@ -984,13 +985,16 @@ static void test_CreateTypeLib(void) { static OLECHAR param2W[] = {'p','a','r','a','m','2',0}; static OLECHAR *names1[] = {func1W, param1W, param2W}; static OLECHAR *names2[] = {func2W, param1W, param2W}; + static const GUID custguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x70}};
char filename[MAX_PATH]; WCHAR filenameW[MAX_PATH]; ICreateTypeLib2 *createtl; ICreateTypeInfo *createti; + ICreateTypeInfo2 *createti2; ITypeLib *tl, *stdole; ITypeInfo *interface1, *interface2, *dual, *unknown, *dispatch, *ti; + ITypeInfo2 *ti2; FUNCDESC funcdesc; ELEMDESC elemdesc[5]; PARAMDESCEX paramdescex; @@ -1001,6 +1005,7 @@ static void test_CreateTypeLib(void) { BSTR name, docstring, helpfile; DWORD helpcontext; int impltypeflags; + VARIANT cust_data; HRESULT hres;
trace("CreateTypeLib tests\n"); @@ -1281,6 +1286,78 @@ static void test_CreateTypeLib(void) {
ICreateTypeInfo_Release(createti);
+ VariantInit(&cust_data); + + hres = ICreateTypeLib_CreateTypeInfo(createtl, interface3W, TKIND_INTERFACE, &createti); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_QueryInterface(createti, &IID_ICreateTypeInfo2, (void**)&createti2); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo2_QueryInterface(createti2, &IID_ITypeInfo2, (void**)&ti2); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ITypeInfo2_GetCustData(ti2, NULL, NULL); + todo_wine + ok(hres == E_INVALIDARG, "got %08x\n", hres); + + hres = ITypeInfo2_GetCustData(ti2, &custguid, NULL); + todo_wine + ok(hres == E_INVALIDARG, "got %08x\n", hres); + + hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data); + todo_wine + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo2_SetCustData(createti2, NULL, NULL); + ok(hres == E_INVALIDARG, "got %08x\n", hres); + + hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, NULL); + ok(hres == E_INVALIDARG, "got %08x\n", hres); + + hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data); + ok(hres == DISP_E_BADVARTYPE, "got %08x\n", hres); + + V_VT(&cust_data) = VT_UI4; + V_I4(&cust_data) = 0xdeadbeef; + + hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data); + ok(hres == S_OK, "got %08x\n", hres); + + V_I4(&cust_data) = 0; + V_VT(&cust_data) = VT_EMPTY; + + hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data); + todo_wine + ok(hres == S_OK, "got %08x\n", hres); + + todo_wine + ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data)); + todo_wine + ok(V_I4(&cust_data) == 0xdeadbeef, "got 0x%08x\n", V_I4(&cust_data)); + + V_VT(&cust_data) = VT_UI4; + V_I4(&cust_data) = 12345678; + + hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data); + ok(hres == S_OK, "got %08x\n", hres); + + V_I4(&cust_data) = 0; + V_VT(&cust_data) = VT_EMPTY; + + hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data); + todo_wine + ok(hres == S_OK, "got %08x\n", hres); + + todo_wine + ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data)); + todo_wine + ok(V_I4(&cust_data) == 12345678, "got 0x%08x\n", V_I4(&cust_data)); + + ITypeInfo2_Release(ti2); + ICreateTypeInfo2_Release(createti2); + ICreateTypeInfo_Release(createti); + hres = ICreateTypeLib_CreateTypeInfo(createtl, coclassW, TKIND_COCLASS, &createti); ok(hres == S_OK, "got %08x\n", hres);
diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index f798979..22a3a23 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -890,7 +890,7 @@ static HRESULT ctl2_set_custdata( if (guidoffset == -1) return E_OUTOFMEMORY; dataoffset = ctl2_alloc_custdata(This, pVarVal); if (dataoffset == -1) return E_OUTOFMEMORY; - if (dataoffset == -2) return E_INVALIDARG; + if (dataoffset == -2) return DISP_E_BADVARTYPE;
custoffset = ctl2_alloc_segment(This, MSFT_SEG_CUSTDATAGUID, 12, 0); if (custoffset == -1) return E_OUTOFMEMORY; @@ -2709,8 +2709,14 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetCustData( REFGUID guid, /* [I] The GUID used as a key to retrieve the custom data. */ VARIANT* pVarVal) /* [I] The custom data. */ { - FIXME("(%p,%s,%p), stub!\n", iface, debugstr_guid(guid), pVarVal); - return E_OUTOFMEMORY; + ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface; + + TRACE("(%p,%s,%p)!\n", iface, debugstr_guid(guid), pVarVal); + + if (!pVarVal) + return E_INVALIDARG; + + return ctl2_set_custdata(This->typelib, guid, pVarVal, &This->typeinfo->oCustData); }
/******************************************************************************