ReactOS 0.4.16-dev-88-ga65b6ae
dispatch.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "oleauto.h"
#include "winerror.h"
#include "wine/debug.h"
Include dependency graph for dispatch.c:

Go to the source code of this file.

Classes

struct  StdDispatch
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
HRESULT WINAPI DispInvoke (VOID *_this, ITypeInfo *ptinfo, DISPID dispidMember, USHORT wFlags, DISPPARAMS *pparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr)
 
HRESULT WINAPI DispGetIDsOfNames (ITypeInfo *ptinfo, OLECHAR **rgszNames, UINT cNames, DISPID *rgdispid)
 
HRESULT WINAPI DispGetParam (DISPPARAMS *pdispparams, UINT position, VARTYPE vtTarg, VARIANT *pvarResult, UINT *puArgErr)
 
static StdDispatchimpl_from_IDispatch (IDispatch *iface)
 
static HRESULT WINAPI StdDispatch_QueryInterface (LPDISPATCH iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI StdDispatch_AddRef (LPDISPATCH iface)
 
static ULONG WINAPI StdDispatch_Release (LPDISPATCH iface)
 
static HRESULT WINAPI StdDispatch_GetTypeInfoCount (LPDISPATCH iface, UINT *pctinfo)
 
static HRESULT WINAPI StdDispatch_GetTypeInfo (LPDISPATCH iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI StdDispatch_GetIDsOfNames (LPDISPATCH iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI StdDispatch_Invoke (LPDISPATCH iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
HRESULT WINAPI CreateStdDispatch (IUnknown *punkOuter, void *pvThis, ITypeInfo *ptinfo, IUnknown **stddisp)
 

Variables

static const IDispatchVtbl StdDispatch_VTable
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Dispatch API functions

Copyright 2000 Francois Jacques, Macadamian Technologies Inc.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA

Definition at line 28 of file dispatch.c.

Function Documentation

◆ CreateStdDispatch()

HRESULT WINAPI CreateStdDispatch ( IUnknown punkOuter,
void pvThis,
ITypeInfo ptinfo,
IUnknown **  stddisp 
)

Definition at line 434 of file dispatch.c.

439{
440 StdDispatch *pStdDispatch;
441
442 TRACE("(%p, %p, %p, %p)\n", punkOuter, pvThis, ptinfo, stddisp);
443
444 if (!pvThis || !ptinfo || !stddisp)
445 return E_INVALIDARG;
446
447 pStdDispatch = CoTaskMemAlloc(sizeof(StdDispatch));
448 if (!pStdDispatch)
449 return E_OUTOFMEMORY;
450
451 pStdDispatch->IDispatch_iface.lpVtbl = &StdDispatch_VTable;
452 pStdDispatch->pvThis = pvThis;
453 pStdDispatch->pTypeInfo = ptinfo;
454 pStdDispatch->ref = 1;
455
456 /* we keep a reference to the type info so prevent it from
457 * being destroyed until we are done with it */
458 ITypeInfo_AddRef(ptinfo);
459 *stddisp = (IUnknown*)&pStdDispatch->IDispatch_iface;
460
461 return S_OK;
462}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
static const IDispatchVtbl StdDispatch_VTable
Definition: dispatch.c:411
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define S_OK
Definition: intsafe.h:52
#define TRACE(s)
Definition: solgame.cpp:4
LONG ref
Definition: dispatch.c:208
IDispatch IDispatch_iface
Definition: dispatch.c:205
void * pvThis
Definition: dispatch.c:206
ITypeInfo * pTypeInfo
Definition: dispatch.c:207

Referenced by test_CreateStdDispatch(), and Widget_Create().

◆ DispGetIDsOfNames()

HRESULT WINAPI DispGetIDsOfNames ( ITypeInfo ptinfo,
OLECHAR **  rgszNames,
UINT  cNames,
DISPID rgdispid 
)

Definition at line 92 of file dispatch.c.

97{
98 return ITypeInfo_GetIDsOfNames(ptinfo, rgszNames, cNames, rgdispid);
99}

Referenced by OLEFontImpl_GetIDsOfNames(), OLEPictureImpl_GetIDsOfNames(), and StdDispatch_GetIDsOfNames().

◆ DispGetParam()

HRESULT WINAPI DispGetParam ( DISPPARAMS *  pdispparams,
UINT  position,
VARTYPE  vtTarg,
VARIANT pvarResult,
UINT puArgErr 
)

Definition at line 116 of file dispatch.c.

122{
123 /* position is counted backwards */
124 UINT pos;
125 HRESULT hr;
126
127 TRACE("position=%d, cArgs=%d, cNamedArgs=%d\n",
128 position, pdispparams->cArgs, pdispparams->cNamedArgs);
129
130 if (position < pdispparams->cArgs)
131 {
132 /* positional arg? */
133 pos = pdispparams->cArgs - position - 1;
134 }
135 else
136 {
137 /* FIXME: is this how to handle named args? */
138 for (pos=0; pos<pdispparams->cNamedArgs; pos++)
139 if (pdispparams->rgdispidNamedArgs[pos] == position) break;
140
141 if (pos==pdispparams->cNamedArgs)
143 }
144
145 if (pdispparams->cArgs > 0 && !pdispparams->rgvarg)
146 {
148 goto done;
149 }
150
151 if (!pvarResult)
152 {
154 goto done;
155 }
156
157 hr = VariantChangeType(pvarResult,
158 &pdispparams->rgvarg[pos],
159 0, vtTarg);
160
161done:
162 if (FAILED(hr))
163 *puArgErr = pos;
164
165 return hr;
166}
#define FAILED(hr)
Definition: intsafe.h:51
unsigned int UINT
Definition: ndis.h:50
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:962
#define DISP_E_PARAMNOTFOUND
Definition: winerror.h:2513

Referenced by database_invoke(), InstallerImpl_CreateRecord(), InstallerImpl_InstallProduct(), InstallerImpl_OpenDatabase(), InstallerImpl_OpenPackage(), InstallerImpl_OpenProduct(), InstallerImpl_ProductInfo(), InstallerImpl_ProductState(), InstallerImpl_RegistryValue(), InstallerImpl_RelatedProducts(), InstallerImpl_SummaryInformation(), InstallerImpl_UILevel(), list_invoke(), record_invoke(), session_invoke(), summaryinfo_invoke(), test_DispGetParam(), view_invoke(), and winhttp_request_Invoke().

◆ DispInvoke()

HRESULT WINAPI DispInvoke ( VOID _this,
ITypeInfo ptinfo,
DISPID  dispidMember,
USHORT  wFlags,
DISPPARAMS *  pparams,
VARIANT pvarResult,
EXCEPINFO *  pexcepinfo,
UINT puArgErr 
)

Definition at line 63 of file dispatch.c.

72{
73 TRACE("\n");
74
75 return ITypeInfo_Invoke(ptinfo, _this, dispidMember, wFlags,
76 pparams, pvarResult, pexcepinfo, puArgErr);
77}
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

Referenced by StdDispatch_Invoke().

◆ impl_from_IDispatch()

static StdDispatch * impl_from_IDispatch ( IDispatch iface)
inlinestatic

Definition at line 211 of file dispatch.c.

212{
213 return CONTAINING_RECORD(iface, StdDispatch, IDispatch_iface);
214}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by StdDispatch_AddRef(), StdDispatch_GetIDsOfNames(), StdDispatch_GetTypeInfo(), StdDispatch_Invoke(), StdDispatch_QueryInterface(), and StdDispatch_Release().

◆ StdDispatch_AddRef()

static ULONG WINAPI StdDispatch_AddRef ( LPDISPATCH  iface)
static

Definition at line 246 of file dispatch.c.

247{
249 ULONG refCount = InterlockedIncrement(&This->ref);
250
251 TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
252
253 return refCount;
254}
#define InterlockedIncrement
Definition: armddk.h:53
static StdDispatch * impl_from_IDispatch(IDispatch *iface)
Definition: dispatch.c:211
uint32_t ULONG
Definition: typedefs.h:59

◆ StdDispatch_GetIDsOfNames()

static HRESULT WINAPI StdDispatch_GetIDsOfNames ( LPDISPATCH  iface,
REFIID  riid,
LPOLESTR rgszNames,
UINT  cNames,
LCID  lcid,
DISPID rgDispId 
)
static

Definition at line 360 of file dispatch.c.

361{
363 TRACE("(%s, %p, %d, 0x%x, %p)\n", debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
364
365 if (!IsEqualGUID(riid, &IID_NULL))
366 {
367 FIXME(" expected riid == IID_NULL\n");
368 return E_INVALIDARG;
369 }
370 return DispGetIDsOfNames(This->pTypeInfo, rgszNames, cNames, rgDispId);
371}
#define FIXME(fmt,...)
Definition: precomp.h:53
HRESULT WINAPI DispGetIDsOfNames(ITypeInfo *ptinfo, OLECHAR **rgszNames, UINT cNames, DISPID *rgdispid)
Definition: dispatch.c:92
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IID_NULL
Definition: guiddef.h:98

◆ StdDispatch_GetTypeInfo()

static HRESULT WINAPI StdDispatch_GetTypeInfo ( LPDISPATCH  iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 319 of file dispatch.c.

320{
322 TRACE("(%d, %x, %p)\n", iTInfo, lcid, ppTInfo);
323
324 *ppTInfo = NULL;
325 if (iTInfo != 0)
326 return DISP_E_BADINDEX;
327
328 *ppTInfo = This->pTypeInfo;
329 ITypeInfo_AddRef(*ppTInfo);
330
331 return S_OK;
332}
#define NULL
Definition: types.h:112
#define DISP_E_BADINDEX
Definition: winerror.h:2520

◆ StdDispatch_GetTypeInfoCount()

static HRESULT WINAPI StdDispatch_GetTypeInfoCount ( LPDISPATCH  iface,
UINT pctinfo 
)
static

Definition at line 294 of file dispatch.c.

295{
296 TRACE("(%p)\n", pctinfo);
297 *pctinfo = 1;
298 return S_OK;
299}

◆ StdDispatch_Invoke()

static HRESULT WINAPI StdDispatch_Invoke ( LPDISPATCH  iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT pVarResult,
EXCEPINFO *  pExcepInfo,
UINT puArgErr 
)
static

Definition at line 396 of file dispatch.c.

399{
401 TRACE("(%d, %s, 0x%x, 0x%x, %p, %p, %p, %p)\n", dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
402
403 if (!IsEqualGUID(riid, &IID_NULL))
404 {
405 FIXME(" expected riid == IID_NULL\n");
406 return E_INVALIDARG;
407 }
408 return DispInvoke(This->pvThis, This->pTypeInfo, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
409}
HRESULT WINAPI DispInvoke(VOID *_this, ITypeInfo *ptinfo, DISPID dispidMember, USHORT wFlags, DISPPARAMS *pparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr)
Definition: dispatch.c:63

◆ StdDispatch_QueryInterface()

static HRESULT WINAPI StdDispatch_QueryInterface ( LPDISPATCH  iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 221 of file dispatch.c.

225{
227 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject);
228
229 *ppvObject = NULL;
230
233 {
234 *ppvObject = iface;
235 IDispatch_AddRef(iface);
236 return S_OK;
237 }
238 return E_NOINTERFACE;
239}
const GUID IID_IUnknown
const GUID IID_IDispatch
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ StdDispatch_Release()

static ULONG WINAPI StdDispatch_Release ( LPDISPATCH  iface)
static

Definition at line 261 of file dispatch.c.

262{
264 ULONG refCount = InterlockedDecrement(&This->ref);
265
266 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
267
268 if (!refCount)
269 {
270 ITypeInfo_Release(This->pTypeInfo);
272 }
273
274 return refCount;
275}
#define InterlockedDecrement
Definition: armddk.h:52
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ StdDispatch_VTable

const IDispatchVtbl StdDispatch_VTable
static
Initial value:
=
{
}
static HRESULT WINAPI StdDispatch_GetTypeInfoCount(LPDISPATCH iface, UINT *pctinfo)
Definition: dispatch.c:294
static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface)
Definition: dispatch.c:246
static HRESULT WINAPI StdDispatch_Invoke(LPDISPATCH iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: dispatch.c:396
static HRESULT WINAPI StdDispatch_QueryInterface(LPDISPATCH iface, REFIID riid, void **ppvObject)
Definition: dispatch.c:221
static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface)
Definition: dispatch.c:261
static HRESULT WINAPI StdDispatch_GetIDsOfNames(LPDISPATCH iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: dispatch.c:360
static HRESULT WINAPI StdDispatch_GetTypeInfo(LPDISPATCH iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: dispatch.c:319

Definition at line 411 of file dispatch.c.

Referenced by CreateStdDispatch().