From f42a73d01fe8226b8188997679cc23e1d9a89458 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 22 Feb 2010 23:12:45 +0100 Subject: [PATCH] oleaut32: Added more arguments with default values handling. --- dlls/oleaut32/tests/typelib.c | 8 ++++++++ dlls/oleaut32/typelib2.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index b9bb396f5e0..9e5d91d0bcc 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -1067,6 +1067,14 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc); ok(hres == S_OK, "got %08x\n", hres); + elemdesc[0].paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT; + elemdesc[0].paramdesc.pparamdescex = ¶mdescex; + elemdesc[1].tdesc.vt = VT_INT; + V_VT(¶mdescex.varDefaultValue) = VT_INT; + V_INT(¶mdescex.varDefaultValue) = 0xffffffff; + hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc); + ok(hres == S_OK, "got %08x\n", hres); + ICreateTypeInfo_Release(createti); hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti); diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 41b789138fe..0a4a8bba327 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -1163,8 +1163,37 @@ static HRESULT ctl2_add_default_value( return S_OK; } - FIXME("default values not implemented\n"); - return S_OK; + switch(arg_type) { + case VT_I4: + case VT_R4: + case VT_UI4: + case VT_INT: + case VT_UINT: + case VT_HRESULT: + case VT_PTR: { + /* Construct the data to be allocated */ + int data[2]; + data[0] = arg_type + (V_UI4(&v)<<16); + data[1] = (V_UI4(&v)>>16) + 0x57570000; + + /* Check if the data was already allocated */ + /* Currently the structures doesn't allow to do it in a nice way */ + for(*encoded_value=0; *encoded_value<=This->typelib_segdir[MSFT_SEG_CUSTDATA].length-8; *encoded_value+=4) + if(!memcmp(&This->typelib_segment_data[MSFT_SEG_CUSTDATA][*encoded_value], data, 8)) + return S_OK; + + /* Allocate the data */ + *encoded_value = ctl2_alloc_segment(This, MSFT_SEG_CUSTDATA, 8, 0); + if(*encoded_value == -1) + return E_OUTOFMEMORY; + + memcpy(&This->typelib_segment_data[MSFT_SEG_CUSTDATA][*encoded_value], data, 8); + return S_OK; + } + default: + FIXME("Argument type not yet handled\n"); + return E_NOTIMPL; + } } /*================== ICreateTypeInfo2 Implementation ===================================*/ -- 2.11.4.GIT