On Mon, Sep 21, 2009 at 01:50:51PM +0100, Huw Davies wrote:
--- dlls/oledb32/convert.c | 231 +++++++++++++++++++++++++++++++++++++++++- dlls/oledb32/tests/convert.c | 10 -- 2 files changed, 228 insertions(+), 13 deletions(-) diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c index 458abb5..a2385f0 100644 --- a/dlls/oledb32/convert.c +++ b/dlls/oledb32/convert.c @@ -126,13 +126,238 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, return E_NOTIMPL; }
+static inline WORD get_dbtype_class(DBTYPE type) +{ + switch(type) + { + case DBTYPE_I2: + case DBTYPE_R4: + case DBTYPE_R8: + case DBTYPE_I1: + case DBTYPE_UI1: + case DBTYPE_UI2: + return DBTYPE_I2; + + case DBTYPE_I4: + case DBTYPE_UI4: + return DBTYPE_I4; + + case DBTYPE_I8: + case DBTYPE_UI8: + return DBTYPE_I8; + + case DBTYPE_BSTR: + case DBTYPE_STR: + case DBTYPE_WSTR: + return DBTYPE_BSTR; + + case DBTYPE_DBDATE: + case DBTYPE_DBTIME: + case DBTYPE_DBTIMESTAMP: + return DBTYPE_DBDATE; + } + return type; +} + +/* Many src types will convert to this group of dst types */ +static inline BOOL common_class(WORD dst_class) +{ + switch(dst_class) + { + case DBTYPE_EMPTY: + case DBTYPE_NULL: + case DBTYPE_I2: + case DBTYPE_I4: + case DBTYPE_BSTR: + case DBTYPE_BOOL: + case DBTYPE_VARIANT: + case DBTYPE_I8: + case DBTYPE_CY: + case DBTYPE_DECIMAL: + case DBTYPE_NUMERIC: + return TRUE; + } + return FALSE; +} + +static inline BOOL array_type(DBTYPE type) +{ + return (type >= DBTYPE_I2 && type <= DBTYPE_UI4); +} + static HRESULT WINAPI convert_CanConvert(IDataConvert* iface, - DBTYPE wSrcType, DBTYPE wDstType) + DBTYPE src_type, DBTYPE dst_type) { convert *This = impl_from_IDataConvert(iface); - FIXME("(%p)->(%d, %d): stub\n", This, wSrcType, wDstType); + DBTYPE src_base_type = src_type & 0x1ff; + DBTYPE dst_base_type = dst_type & 0x1ff; + WORD dst_class = get_dbtype_class(dst_base_type);
- return E_NOTIMPL; + TRACE("(%p)->(%d, %d)\n", This, src_type, dst_type); + + if(src_type & DBTYPE_VECTOR || dst_type & DBTYPE_VECTOR) return S_FALSE;
I think this needs brackets... Ciao, Marcus
On Mon, Sep 21, 2009 at 03:36:21PM +0200, Marcus Meissner wrote:
On Mon, Sep 21, 2009 at 01:50:51PM +0100, Huw Davies wrote:
+ if(src_type & DBTYPE_VECTOR || dst_type & DBTYPE_VECTOR) return S_FALSE;
I think this needs brackets...
Why? It's equivalent to: if((src_type & DBTYPE_VECTOR) || (dst_type & DBTYPE_VECTOR)) return S_FALSE; which is what I want. Huw.
On Mon, Sep 21, 2009 at 02:46:25PM +0100, Huw Davies wrote:
On Mon, Sep 21, 2009 at 03:36:21PM +0200, Marcus Meissner wrote:
On Mon, Sep 21, 2009 at 01:50:51PM +0100, Huw Davies wrote:
+ if(src_type & DBTYPE_VECTOR || dst_type & DBTYPE_VECTOR) return S_FALSE;
I think this needs brackets...
Why? It's equivalent to: if((src_type & DBTYPE_VECTOR) || (dst_type & DBTYPE_VECTOR)) return S_FALSE;
which is what I want.
I am always confusing precedence there, sorry ;) Ciao, Marcus
On Monday 21 September 2009 16:46:25 Huw Davies wrote:
On Mon, Sep 21, 2009 at 03:36:21PM +0200, Marcus Meissner wrote:
On Mon, Sep 21, 2009 at 01:50:51PM +0100, Huw Davies wrote:
+ if(src_type & DBTYPE_VECTOR || dst_type & DBTYPE_VECTOR) return S_FALSE;
I think this needs brackets...
Why? It's equivalent to: if((src_type & DBTYPE_VECTOR) || (dst_type & DBTYPE_VECTOR)) return S_FALSE;
which is what I want.
Huw.
((src_type | dst_type) & DBTYPE_VECTOR) does the same but looks even more suspect to the casual programmer. Better go for clarity.
participants (3)
-
Huw Davies -
Marcus Meissner -
Paul Chitescu