- 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

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