source: trunk/src/oleaut32/dispatch.c@ 21494

Last change on this file since 21494 was 21494, checked in by dmik, 15 years ago

Fixed broken build after r21492 by sorting out a huuuuge wagon of duplicates, wrong include order and other dirty mess.

File size: 4.4 KB
Line 
1/**
2 * Dispatch API functions
3 *
4 * Copyright 2000 Francois Jacques, Macadamian Technologies Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * TODO: Type coercion is implemented in variant.c but not called yet.
21 */
22
23#include "config.h"
24
25#include <stdlib.h>
26#include <string.h>
27#include <stdio.h>
28#include <ctype.h>
29
30#include "windef.h"
31#include "oleauto.h"
32#include "winerror.h"
33#include "winreg.h" /* for HKEY_LOCAL_MACHINE */
34#include "winnls.h" /* for PRIMARYLANGID */
35
36#include "wine/obj_oleaut.h"
37
38#include "wine/debug.h"
39
40WINE_DEFAULT_DEBUG_CHANNEL(ole);
41WINE_DECLARE_DEBUG_CHANNEL(typelib);
42
43
44/******************************************************************************
45 * DispInvoke (OLEAUT32.30)
46 *
47 *
48 * Calls method of an object through its IDispatch interface.
49 *
50 * NOTES
51 * - Defer method invocation to ITypeInfo::Invoke()
52 *
53 * RETURNS
54 *
55 * S_OK on success.
56 */
57HRESULT WINAPI DispInvoke(
58 VOID *_this, /* [in] object instance */
59 ITypeInfo *ptinfo, /* [in] object's type info */
60 DISPID dispidMember, /* [in] member id */
61 USHORT wFlags, /* [in] kind of method call */
62 DISPPARAMS *pparams, /* [in] array of arguments */
63 VARIANT *pvarResult, /* [out] result of method call */
64 EXCEPINFO *pexcepinfo, /* [out] information about exception */
65 UINT *puArgErr) /* [out] index of bad argument(if any) */
66{
67 HRESULT hr = E_FAIL;
68
69 /**
70 * TODO:
71 * For each param, call DispGetParam to perform type coercion
72 */
73 FIXME("Coercion of arguments not implemented\n");
74
75 hr = ICOM_CALL7(Invoke,
76 ptinfo,
77 _this,
78 dispidMember,
79 wFlags,
80 pparams, pvarResult, pexcepinfo, puArgErr);
81
82 return (hr);
83}
84
85
86/******************************************************************************
87 * DispGetIDsOfNames (OLEAUT32.29)
88 *
89 * Convert a set of names to dispids, based on information
90 * contained in object's type library.
91 *
92 * NOTES
93 * - Defers to ITypeInfo::GetIDsOfNames()
94 *
95 * RETURNS
96 *
97 * S_OK on success.
98 */
99HRESULT WINAPI DispGetIDsOfNames(
100 ITypeInfo *ptinfo, /* [in] */
101 OLECHAR **rgszNames, /* [in] */
102 UINT cNames, /* [in] */
103 DISPID *rgdispid) /* [out] */
104{
105 HRESULT hr = E_FAIL;
106
107 hr = ICOM_CALL3(GetIDsOfNames,
108 ptinfo,
109 rgszNames,
110 cNames,
111 rgdispid);
112 return (hr);
113}
114
115/******************************************************************************
116 * DispGetParam (OLEAUT32.28)
117 *
118 * Retrive a parameter from a DISPPARAMS structures and coerce it to
119 * specified variant type
120 *
121 * NOTES
122 * Coercion is done using system (0) locale.
123 *
124 * RETURNS
125 *
126 * S_OK on success.
127 */
128HRESULT WINAPI DispGetParam(
129 DISPPARAMS *pdispparams, /* [in] */
130 UINT position, /* [in] */
131 VARTYPE vtTarg, /* [in] */
132 VARIANT *pvarResult, /* [out] */
133 UINT *puArgErr) /* [out] */
134{
135 /* position is counted backwards */
136 UINT pos;
137 HRESULT hr;
138
139 TRACE("position=%d, cArgs=%d, cNamedArgs=%d\n",
140 position, pdispparams->cArgs, pdispparams->cNamedArgs);
141 if (position < pdispparams->cArgs) {
142 /* positional arg? */
143 pos = pdispparams->cArgs - position - 1;
144 } else {
145 /* FIXME: is this how to handle named args? */
146 for (pos=0; pos<pdispparams->cNamedArgs; pos++)
147 if (pdispparams->rgdispidNamedArgs[pos] == position) break;
148
149 if (pos==pdispparams->cNamedArgs)
150 return DISP_E_PARAMNOTFOUND;
151 }
152 hr = VariantChangeType(pvarResult,
153 &pdispparams->rgvarg[pos],
154 0, vtTarg);
155 if (hr == DISP_E_TYPEMISMATCH) *puArgErr = pos;
156 return hr;
157}
Note: See TracBrowser for help on using the repository browser.