oledb32: Implement DataConvert DBTYPE_VARIANT->DBTYPE_BYTES.
This commit is contained in:
parent
40fcf66752
commit
471bdafa3b
|
@ -995,6 +995,49 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
|
|||
memcpy(d, src, min(src_len, dst_max_len));
|
||||
|
||||
return S_OK;
|
||||
case DBTYPE_VARIANT:
|
||||
{
|
||||
if(V_VT((VARIANT*)src) == VT_NULL)
|
||||
{
|
||||
*dst_status = DBSTATUS_S_ISNULL;
|
||||
*dst_len = 0;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(V_VT((VARIANT*)src))
|
||||
{
|
||||
case VT_UI1 | VT_ARRAY:
|
||||
{
|
||||
LONG l;
|
||||
BYTE *data = NULL;
|
||||
|
||||
hr = SafeArrayGetUBound(V_ARRAY((VARIANT*)src), 1, &l);
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
|
||||
hr = SafeArrayAccessData(V_ARRAY((VARIANT*)src), (VOID**)&data);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
ERR("SafeArrayAccessData Failed = 0x%08x\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
*dst_len = l+1;
|
||||
*dst_status = DBSTATUS_S_OK;
|
||||
memcpy(d, data, *dst_len);
|
||||
|
||||
SafeArrayUnaccessData(V_ARRAY((VARIANT*)src));
|
||||
return S_OK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FIXME("Unimplemented variant type %d -> BYTES\n", V_VT((VARIANT*)src));
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: FIXME("Unimplemented conversion %04x -> DBTYPE_BYTES\n", src_type); return E_NOTIMPL;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -2500,8 +2500,12 @@ static void test_converttobytes(void)
|
|||
DBLENGTH dst_len;
|
||||
HRESULT hr;
|
||||
BYTE byte_src[] = {0, 1, 2, 4, 5};
|
||||
BYTE byte_dst[] = {0, 0, 0, 0, 0};
|
||||
BYTE dst[10] = {0};
|
||||
DBSTATUS dst_status;
|
||||
VARIANT v;
|
||||
SAFEARRAY *psa = NULL;
|
||||
SAFEARRAYBOUND rgsabound[1];
|
||||
|
||||
dst_len = 0;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_BYTES, DBTYPE_BYTES, sizeof(byte_src), &dst_len, byte_src, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
|
||||
|
@ -2516,6 +2520,27 @@ static void test_converttobytes(void)
|
|||
ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
|
||||
ok(dst_len == sizeof(byte_src), "got %ld\n", dst_len);
|
||||
ok(!memcmp(byte_src, dst, 2 ), "bytes differ\n");
|
||||
|
||||
V_VT(&v) = VT_NULL;
|
||||
dst_len = 0;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BYTES, sizeof(v), &dst_len, &v, &dst, 2, 0, &dst_status, 0, 0, 0);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
|
||||
ok(dst_len == 0, "got %ld\n", dst_len);
|
||||
|
||||
dst_len = 0;
|
||||
rgsabound[0].lLbound = 0;
|
||||
rgsabound[0].cElements = 4;
|
||||
psa = SafeArrayCreate(VT_UI1,1,rgsabound);
|
||||
|
||||
V_VT(&v) = VT_ARRAY|VT_UI1;
|
||||
V_ARRAY(&v) = psa;
|
||||
hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BYTES, sizeof(v), &dst_len, &v, &dst, 10, 0, &dst_status, 0, 0, 0);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(dst_len == 4, "%ld\n", dst_len);
|
||||
ok(!memcmp(byte_dst, dst, dst_len), "bytes differ\n");
|
||||
VariantClear(&v);
|
||||
|
||||
}
|
||||
|
||||
static void test_converttobytesbyref(void)
|
||||
|
|
Loading…
Reference in New Issue