- Change remaining blocks of code with 2-space indentation to 4-space

indentation.
- Make vtables const.
- Remove an unnecessary memcpy and let the compiler do the work.
This commit is contained in:
Robert Shearman 2005-05-19 12:04:58 +00:00 committed by Alexandre Julliard
parent 447ab61288
commit a890293f33
1 changed files with 175 additions and 169 deletions

View File

@ -63,26 +63,25 @@ static HRESULT unmarshal_object(const STDOBJREF *stdobjref, APARTMENT *apt, REFI
*
* So basically we need a set of values that make it unique.
*
* Process Identifier, Object IUnknown ptr, IID
*
* Note that the IUnknown_QI(ob,xiid,&ppv) always returns the SAME ppv value!
*
* In Windows, a different triple is used: OXID (apt id), OID (stub
* manager id), IPID (interface ptr/stub id).
* A triple is used: OXID (apt id), OID (stub manager id),
* IPID (interface ptr/stub id).
*
* OXIDs identify an apartment and are network scoped
* OIDs identify a stub manager and are apartment scoped
* IPIDs identify an interface stub and are apartment scoped
*/
inline static HRESULT
get_facbuf_for_iid(REFIID riid,IPSFactoryBuffer **facbuf) {
HRESULT hres;
CLSID pxclsid;
inline static HRESULT get_facbuf_for_iid(REFIID riid, IPSFactoryBuffer **facbuf)
{
HRESULT hr;
CLSID clsid;
if ((hres = CoGetPSClsid(riid,&pxclsid)))
return hres;
return CoGetClassObject(&pxclsid,CLSCTX_INPROC_SERVER,NULL,&IID_IPSFactoryBuffer,(LPVOID*)facbuf);
if ((hr = CoGetPSClsid(riid, &clsid)))
return hr;
return CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL,
&IID_IPSFactoryBuffer, (LPVOID*)facbuf);
}
/* creates a new stub manager */
@ -747,8 +746,9 @@ HRESULT apartment_disconnectproxies(struct apartment *apt)
}
/********************** StdMarshal implementation ****************************/
typedef struct _StdMarshalImpl {
IMarshalVtbl *lpvtbl;
typedef struct _StdMarshalImpl
{
const IMarshalVtbl *lpvtbl;
DWORD ref;
IID iid;
@ -758,9 +758,11 @@ typedef struct _StdMarshalImpl {
} StdMarshalImpl;
static HRESULT WINAPI
StdMarshalImpl_QueryInterface(LPMARSHAL iface,REFIID riid,LPVOID *ppv) {
StdMarshalImpl_QueryInterface(LPMARSHAL iface, REFIID riid, LPVOID *ppv)
{
*ppv = NULL;
if (IsEqualIID(&IID_IUnknown,riid) || IsEqualIID(&IID_IMarshal,riid)) {
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IMarshal, riid))
{
*ppv = iface;
IUnknown_AddRef(iface);
return S_OK;
@ -770,13 +772,15 @@ StdMarshalImpl_QueryInterface(LPMARSHAL iface,REFIID riid,LPVOID *ppv) {
}
static ULONG WINAPI
StdMarshalImpl_AddRef(LPMARSHAL iface) {
StdMarshalImpl_AddRef(LPMARSHAL iface)
{
StdMarshalImpl *This = (StdMarshalImpl *)iface;
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI
StdMarshalImpl_Release(LPMARSHAL iface) {
StdMarshalImpl_Release(LPMARSHAL iface)
{
StdMarshalImpl *This = (StdMarshalImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
@ -787,9 +791,9 @@ StdMarshalImpl_Release(LPMARSHAL iface) {
static HRESULT WINAPI
StdMarshalImpl_GetUnmarshalClass(
LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags, CLSID* pCid
) {
memcpy(pCid,&CLSID_DfMarshal,sizeof(CLSID_DfMarshal));
void* pvDestContext, DWORD mshlflags, CLSID* pCid)
{
*pCid = CLSID_DfMarshal;
return S_OK;
}
@ -805,8 +809,8 @@ StdMarshalImpl_GetMarshalSizeMax(
static HRESULT WINAPI
StdMarshalImpl_MarshalInterface(
LPMARSHAL iface, IStream *pStm,REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags
) {
void* pvDestContext, DWORD mshlflags)
{
STDOBJREF stdobjref;
IUnknown *pUnk;
ULONG res;
@ -838,7 +842,7 @@ StdMarshalImpl_MarshalInterface(
if (hres)
{
FIXME("Failed to create ifstub, hres=0x%lx\n", hres);
ERR("Failed to create ifstub, hres=0x%lx\n", hres);
return hres;
}
@ -985,7 +989,8 @@ StdMarshalImpl_UnmarshalInterface(LPMARSHAL iface, IStream *pStm, REFIID riid, v
}
static HRESULT WINAPI
StdMarshalImpl_ReleaseMarshalData(LPMARSHAL iface, IStream *pStm) {
StdMarshalImpl_ReleaseMarshalData(LPMARSHAL iface, IStream *pStm)
{
STDOBJREF stdobjref;
ULONG res;
HRESULT hres;
@ -1020,12 +1025,14 @@ StdMarshalImpl_ReleaseMarshalData(LPMARSHAL iface, IStream *pStm) {
}
static HRESULT WINAPI
StdMarshalImpl_DisconnectObject(LPMARSHAL iface, DWORD dwReserved) {
StdMarshalImpl_DisconnectObject(LPMARSHAL iface, DWORD dwReserved)
{
FIXME("(), stub!\n");
return S_OK;
}
IMarshalVtbl stdmvtbl = {
static const IMarshalVtbl VT_StdMarshal =
{
StdMarshalImpl_QueryInterface,
StdMarshalImpl_AddRef,
StdMarshalImpl_Release,
@ -1043,7 +1050,7 @@ static HRESULT StdMarshalImpl_Construct(REFIID riid, void** ppvObject)
HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(StdMarshalImpl));
if (!pStdMarshal)
return E_OUTOFMEMORY;
pStdMarshal->lpvtbl = &stdmvtbl;
pStdMarshal->lpvtbl = &VT_StdMarshal;
pStdMarshal->ref = 0;
return IMarshal_QueryInterface((IMarshal*)pStdMarshal, riid, ppvObject);
}
@ -1077,22 +1084,21 @@ HRESULT WINAPI CoGetStandardMarshal(REFIID riid, IUnknown *pUnk,
{
StdMarshalImpl *dm;
if (pUnk == NULL) {
if (pUnk == NULL)
{
FIXME("(%s,NULL,%lx,%p,%lx,%p), unimplemented yet.\n",
debugstr_guid(riid),dwDestContext,pvDestContext,mshlflags,ppMarshal
);
return E_FAIL;
debugstr_guid(riid),dwDestContext,pvDestContext,mshlflags,ppMarshal);
return E_NOTIMPL;
}
TRACE("(%s,%p,%lx,%p,%lx,%p)\n",
debugstr_guid(riid),pUnk,dwDestContext,pvDestContext,mshlflags,ppMarshal
);
debugstr_guid(riid),pUnk,dwDestContext,pvDestContext,mshlflags,ppMarshal);
*ppMarshal = HeapAlloc(GetProcessHeap(),0,sizeof(StdMarshalImpl));
dm = (StdMarshalImpl*) *ppMarshal;
if (!dm) return E_FAIL;
dm->lpvtbl = &stdmvtbl;
dm->lpvtbl = &VT_StdMarshal;
dm->ref = 1;
memcpy(&dm->iid,riid,sizeof(dm->iid));
dm->iid = *riid;
dm->dwDestContext = dwDestContext;
dm->pvDestContext = pvDestContext;
dm->mshlflags = mshlflags;
@ -1602,7 +1608,7 @@ static ULONG WINAPI StdMarshalCF_Release(LPCLASSFACTORY iface)
static HRESULT WINAPI StdMarshalCF_CreateInstance(LPCLASSFACTORY iface,
LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
{
if (IsEqualIID(riid,&IID_IMarshal))
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IMarshal))
return StdMarshalImpl_Construct(riid, ppv);
FIXME("(%s), not supported.\n",debugstr_guid(riid));
@ -1615,7 +1621,7 @@ static HRESULT WINAPI StdMarshalCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
return S_OK;
}
static IClassFactoryVtbl StdMarshalCFVtbl =
static const IClassFactoryVtbl StdMarshalCFVtbl =
{
StdMarshalCF_QueryInterface,
StdMarshalCF_AddRef,
@ -1623,7 +1629,7 @@ static IClassFactoryVtbl StdMarshalCFVtbl =
StdMarshalCF_CreateInstance,
StdMarshalCF_LockServer
};
static IClassFactoryVtbl *StdMarshalCF = &StdMarshalCFVtbl;
static const IClassFactoryVtbl *StdMarshalCF = &StdMarshalCFVtbl;
HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv)
{