} CompartmentValue;
typedef struct tagCompartmentMgr {
- const ITfCompartmentMgrVtbl *CompartmentMgrVtbl;
+ ITfCompartmentMgr ITfCompartmentMgr_iface;
LONG refCount;
IUnknown *pUnkOuter;
} CompartmentMgr;
typedef struct tagCompartmentEnumGuid {
- const IEnumGUIDVtbl *Vtbl;
+ IEnumGUID IEnumGUID_iface;
LONG refCount;
struct list *values;
} CompartmentSink;
typedef struct tagCompartment {
- const ITfCompartmentVtbl *Vtbl;
- const ITfSourceVtbl *SourceVtbl;
+ ITfCompartment ITfCompartment_iface;
+ ITfSource ITfSource_iface;
LONG refCount;
/* Only VT_I4, VT_UNKNOWN and VT_BSTR data types are allowed */
static HRESULT CompartmentEnumGuid_Constructor(struct list* values, IEnumGUID **ppOut);
static HRESULT Compartment_Constructor(CompartmentValue *value, ITfCompartment **ppOut);
-static inline Compartment *impl_from_ITfSourceVtbl(ITfSource *iface)
+static inline CompartmentMgr *impl_from_ITfCompartmentMgr(ITfCompartmentMgr *iface)
{
- return (Compartment *)((char *)iface - FIELD_OFFSET(Compartment,SourceVtbl));
+ return CONTAINING_RECORD(iface, CompartmentMgr, ITfCompartmentMgr_iface);
+}
+
+static inline Compartment *impl_from_ITfCompartment(ITfCompartment *iface)
+{
+ return CONTAINING_RECORD(iface, Compartment, ITfCompartment_iface);
+}
+
+static inline Compartment *impl_from_ITfSource(ITfSource *iface)
+{
+ return CONTAINING_RECORD(iface, Compartment, ITfSource_iface);
+}
+
+static inline CompartmentEnumGuid *impl_from_IEnumGUID(IEnumGUID *iface)
+{
+ return CONTAINING_RECORD(iface, CompartmentEnumGuid, IEnumGUID_iface);
}
HRESULT CompartmentMgr_Destructor(ITfCompartmentMgr *iface)
{
- CompartmentMgr *This = (CompartmentMgr *)iface;
+ CompartmentMgr *This = impl_from_ITfCompartmentMgr(iface);
struct list *cursor, *cursor2;
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->values)
*****************************************************/
static HRESULT WINAPI CompartmentMgr_QueryInterface(ITfCompartmentMgr *iface, REFIID iid, LPVOID *ppvOut)
{
- CompartmentMgr *This = (CompartmentMgr *)iface;
+ CompartmentMgr *This = impl_from_ITfCompartmentMgr(iface);
if (This->pUnkOuter)
- return IUnknown_QueryInterface(This->pUnkOuter, iid, *ppvOut);
+ return IUnknown_QueryInterface(This->pUnkOuter, iid, ppvOut);
else
{
*ppvOut = NULL;
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfCompartmentMgr))
{
- *ppvOut = This;
+ *ppvOut = &This->ITfCompartmentMgr_iface;
}
if (*ppvOut)
static ULONG WINAPI CompartmentMgr_AddRef(ITfCompartmentMgr *iface)
{
- CompartmentMgr *This = (CompartmentMgr *)iface;
+ CompartmentMgr *This = impl_from_ITfCompartmentMgr(iface);
if (This->pUnkOuter)
return IUnknown_AddRef(This->pUnkOuter);
else
static ULONG WINAPI CompartmentMgr_Release(ITfCompartmentMgr *iface)
{
- CompartmentMgr *This = (CompartmentMgr *)iface;
+ CompartmentMgr *This = impl_from_ITfCompartmentMgr(iface);
if (This->pUnkOuter)
return IUnknown_Release(This->pUnkOuter);
else
static HRESULT WINAPI CompartmentMgr_GetCompartment(ITfCompartmentMgr *iface,
REFGUID rguid, ITfCompartment **ppcomp)
{
- CompartmentMgr *This = (CompartmentMgr *)iface;
+ CompartmentMgr *This = impl_from_ITfCompartmentMgr(iface);
CompartmentValue* value;
struct list *cursor;
HRESULT hr;
static HRESULT WINAPI CompartmentMgr_ClearCompartment(ITfCompartmentMgr *iface,
TfClientId tid, REFGUID rguid)
{
+ CompartmentMgr *This = impl_from_ITfCompartmentMgr(iface);
struct list *cursor;
- CompartmentMgr *This = (CompartmentMgr *)iface;
+
TRACE("(%p) %i %s\n",This,tid,debugstr_guid(rguid));
LIST_FOR_EACH(cursor, &This->values)
static HRESULT WINAPI CompartmentMgr_EnumCompartments(ITfCompartmentMgr *iface,
IEnumGUID **ppEnum)
{
- CompartmentMgr *This = (CompartmentMgr *)iface;
+ CompartmentMgr *This = impl_from_ITfCompartmentMgr(iface);
+
TRACE("(%p) %p\n",This,ppEnum);
if (!ppEnum)
return E_INVALIDARG;
return CompartmentEnumGuid_Constructor(&This->values, ppEnum);
}
-static const ITfCompartmentMgrVtbl CompartmentMgr_CompartmentMgrVtbl =
+static const ITfCompartmentMgrVtbl CompartmentMgrVtbl =
{
CompartmentMgr_QueryInterface,
CompartmentMgr_AddRef,
CompartmentMgr_Release,
-
CompartmentMgr_GetCompartment,
CompartmentMgr_ClearCompartment,
CompartmentMgr_EnumCompartments
if (This == NULL)
return E_OUTOFMEMORY;
- This->CompartmentMgrVtbl = &CompartmentMgr_CompartmentMgrVtbl;
+ This->ITfCompartmentMgr_iface.lpVtbl = &CompartmentMgrVtbl;
This->pUnkOuter = pUnkOuter;
list_init(&This->values);
if (pUnkOuter)
{
- TRACE("returning %p\n", This);
- *ppOut = (IUnknown*)This;
+ *ppOut = (IUnknown*)&This->ITfCompartmentMgr_iface;
+ TRACE("returning %p\n", *ppOut);
return S_OK;
}
else
{
HRESULT hr;
- hr = IUnknown_QueryInterface((IUnknown*)This, riid, (LPVOID*)ppOut);
+ hr = ITfCompartmentMgr_QueryInterface(&This->ITfCompartmentMgr_iface, riid, (void**)ppOut);
if (FAILED(hr))
HeapFree(GetProcessHeap(),0,This);
return hr;
static HRESULT WINAPI CompartmentEnumGuid_QueryInterface(IEnumGUID *iface, REFIID iid, LPVOID *ppvOut)
{
- CompartmentEnumGuid *This = (CompartmentEnumGuid *)iface;
+ CompartmentEnumGuid *This = impl_from_IEnumGUID(iface);
*ppvOut = NULL;
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IEnumGUID))
{
- *ppvOut = This;
+ *ppvOut = &This->IEnumGUID_iface;
}
if (*ppvOut)
static ULONG WINAPI CompartmentEnumGuid_AddRef(IEnumGUID *iface)
{
- CompartmentEnumGuid *This = (CompartmentEnumGuid*)iface;
+ CompartmentEnumGuid *This = impl_from_IEnumGUID(iface);
return InterlockedIncrement(&This->refCount);
}
static ULONG WINAPI CompartmentEnumGuid_Release(IEnumGUID *iface)
{
- CompartmentEnumGuid *This = (CompartmentEnumGuid *)iface;
+ CompartmentEnumGuid *This = impl_from_IEnumGUID(iface);
ULONG ret;
ret = InterlockedDecrement(&This->refCount);
/*****************************************************
* IEnumGuid functions
*****************************************************/
-static HRESULT WINAPI CompartmentEnumGuid_Next( LPENUMGUID iface,
+static HRESULT WINAPI CompartmentEnumGuid_Next(IEnumGUID *iface,
ULONG celt, GUID *rgelt, ULONG *pceltFetched)
{
- CompartmentEnumGuid *This = (CompartmentEnumGuid *)iface;
+ CompartmentEnumGuid *This = impl_from_IEnumGUID(iface);
ULONG fetched = 0;
TRACE("(%p)\n",This);
return fetched == celt ? S_OK : S_FALSE;
}
-static HRESULT WINAPI CompartmentEnumGuid_Skip( LPENUMGUID iface, ULONG celt)
+static HRESULT WINAPI CompartmentEnumGuid_Skip(IEnumGUID *iface, ULONG celt)
{
- CompartmentEnumGuid *This = (CompartmentEnumGuid *)iface;
+ CompartmentEnumGuid *This = impl_from_IEnumGUID(iface);
TRACE("(%p)\n",This);
This->cursor = list_next(This->values,This->cursor);
return S_OK;
}
-static HRESULT WINAPI CompartmentEnumGuid_Reset( LPENUMGUID iface)
+static HRESULT WINAPI CompartmentEnumGuid_Reset(IEnumGUID *iface)
{
- CompartmentEnumGuid *This = (CompartmentEnumGuid *)iface;
+ CompartmentEnumGuid *This = impl_from_IEnumGUID(iface);
TRACE("(%p)\n",This);
This->cursor = list_head(This->values);
return S_OK;
}
-static HRESULT WINAPI CompartmentEnumGuid_Clone( LPENUMGUID iface,
+static HRESULT WINAPI CompartmentEnumGuid_Clone(IEnumGUID *iface,
IEnumGUID **ppenum)
{
- CompartmentEnumGuid *This = (CompartmentEnumGuid *)iface;
+ CompartmentEnumGuid *This = impl_from_IEnumGUID(iface);
HRESULT res;
TRACE("(%p)\n",This);
res = CompartmentEnumGuid_Constructor(This->values, ppenum);
if (SUCCEEDED(res))
{
- CompartmentEnumGuid *new_This = (CompartmentEnumGuid *)*ppenum;
+ CompartmentEnumGuid *new_This = impl_from_IEnumGUID(*ppenum);
new_This->cursor = This->cursor;
}
return res;
}
-static const IEnumGUIDVtbl IEnumGUID_Vtbl ={
+static const IEnumGUIDVtbl EnumGUIDVtbl =
+{
CompartmentEnumGuid_QueryInterface,
CompartmentEnumGuid_AddRef,
CompartmentEnumGuid_Release,
-
CompartmentEnumGuid_Next,
CompartmentEnumGuid_Skip,
CompartmentEnumGuid_Reset,
if (This == NULL)
return E_OUTOFMEMORY;
- This->Vtbl= &IEnumGUID_Vtbl;
+ This->IEnumGUID_iface.lpVtbl= &EnumGUIDVtbl;
This->refCount = 1;
This->values = values;
This->cursor = list_head(values);
- TRACE("returning %p\n", This);
- *ppOut = (IEnumGUID*)This;
+ *ppOut = &This->IEnumGUID_iface;
+ TRACE("returning %p\n", *ppOut);
return S_OK;
}
static HRESULT WINAPI Compartment_QueryInterface(ITfCompartment *iface, REFIID iid, LPVOID *ppvOut)
{
- Compartment *This = (Compartment *)iface;
+ Compartment *This = impl_from_ITfCompartment(iface);
+
*ppvOut = NULL;
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfCompartment))
{
- *ppvOut = This;
+ *ppvOut = &This->ITfCompartment_iface;
}
else if (IsEqualIID(iid, &IID_ITfSource))
{
- *ppvOut = &This->SourceVtbl;
+ *ppvOut = &This->ITfSource_iface;
}
if (*ppvOut)
static ULONG WINAPI Compartment_AddRef(ITfCompartment *iface)
{
- Compartment *This = (Compartment*)iface;
+ Compartment *This = impl_from_ITfCompartment(iface);
return InterlockedIncrement(&This->refCount);
}
static ULONG WINAPI Compartment_Release(ITfCompartment *iface)
{
- Compartment *This = (Compartment *)iface;
+ Compartment *This = impl_from_ITfCompartment(iface);
ULONG ret;
ret = InterlockedDecrement(&This->refCount);
static HRESULT WINAPI Compartment_SetValue(ITfCompartment *iface,
TfClientId tid, const VARIANT *pvarValue)
{
- Compartment *This = (Compartment *)iface;
+ Compartment *This = impl_from_ITfCompartment(iface);
struct list *cursor;
TRACE("(%p) %i %p\n",This,tid,pvarValue);
static HRESULT WINAPI Compartment_GetValue(ITfCompartment *iface,
VARIANT *pvarValue)
{
- Compartment *This = (Compartment *)iface;
+ Compartment *This = impl_from_ITfCompartment(iface);
TRACE("(%p) %p\n",This, pvarValue);
if (!pvarValue)
return VariantCopy(pvarValue,&This->variant);
}
-static const ITfCompartmentVtbl ITfCompartment_Vtbl ={
+static const ITfCompartmentVtbl CompartmentVtbl =
+{
Compartment_QueryInterface,
Compartment_AddRef,
Compartment_Release,
-
Compartment_SetValue,
Compartment_GetValue
};
* ITfSource functions
*****************************************************/
-static HRESULT WINAPI Source_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
+static HRESULT WINAPI CompartmentSource_QueryInterface(ITfSource *iface, REFIID iid, LPVOID *ppvOut)
{
- Compartment *This = impl_from_ITfSourceVtbl(iface);
- return Compartment_QueryInterface((ITfCompartment *)This, iid, *ppvOut);
+ Compartment *This = impl_from_ITfSource(iface);
+ return ITfCompartment_QueryInterface(&This->ITfCompartment_iface, iid, ppvOut);
}
-static ULONG WINAPI Source_AddRef(ITfSource *iface)
+static ULONG WINAPI CompartmentSource_AddRef(ITfSource *iface)
{
- Compartment *This = impl_from_ITfSourceVtbl(iface);
- return Compartment_AddRef((ITfCompartment*)This);
+ Compartment *This = impl_from_ITfSource(iface);
+ return ITfCompartment_AddRef(&This->ITfCompartment_iface);
}
-static ULONG WINAPI Source_Release(ITfSource *iface)
+static ULONG WINAPI CompartmentSource_Release(ITfSource *iface)
{
- Compartment *This = impl_from_ITfSourceVtbl(iface);
- return Compartment_Release((ITfCompartment *)This);
+ Compartment *This = impl_from_ITfSource(iface);
+ return ITfCompartment_Release(&This->ITfCompartment_iface);
}
static HRESULT WINAPI CompartmentSource_AdviseSink(ITfSource *iface,
REFIID riid, IUnknown *punk, DWORD *pdwCookie)
{
+ Compartment *This = impl_from_ITfSource(iface);
CompartmentSink *cs;
- Compartment *This = impl_from_ITfSourceVtbl(iface);
TRACE("(%p) %s %p %p\n",This,debugstr_guid(riid),punk,pdwCookie);
static HRESULT WINAPI CompartmentSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
{
+ Compartment *This = impl_from_ITfSource(iface);
CompartmentSink *sink;
- Compartment *This = impl_from_ITfSourceVtbl(iface);
TRACE("(%p) %x\n",This,pdwCookie);
return S_OK;
}
-static const ITfSourceVtbl Compartment_SourceVtbl =
+static const ITfSourceVtbl CompartmentSourceVtbl =
{
- Source_QueryInterface,
- Source_AddRef,
- Source_Release,
-
+ CompartmentSource_QueryInterface,
+ CompartmentSource_AddRef,
+ CompartmentSource_Release,
CompartmentSource_AdviseSink,
CompartmentSource_UnadviseSink,
};
if (This == NULL)
return E_OUTOFMEMORY;
- This->Vtbl= &ITfCompartment_Vtbl;
- This->SourceVtbl = &Compartment_SourceVtbl;
+ This->ITfCompartment_iface.lpVtbl= &CompartmentVtbl;
+ This->ITfSource_iface.lpVtbl = &CompartmentSourceVtbl;
This->refCount = 1;
This->valueData = valueData;
list_init(&This->CompartmentEventSink);
- TRACE("returning %p\n", This);
- *ppOut = (ITfCompartment*)This;
+ *ppOut = &This->ITfCompartment_iface;
+ TRACE("returning %p\n", *ppOut);
return S_OK;
}