| 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 "ole.h" | 
|---|
| 32 | #include "oleauto.h" | 
|---|
| 33 | #include "winerror.h" | 
|---|
| 34 | #include "winreg.h"         /* for HKEY_LOCAL_MACHINE */ | 
|---|
| 35 | #include "winnls.h"         /* for PRIMARYLANGID */ | 
|---|
| 36 |  | 
|---|
| 37 | #include "wine/obj_oleaut.h" | 
|---|
| 38 |  | 
|---|
| 39 | #include "wine/debug.h" | 
|---|
| 40 |  | 
|---|
| 41 | WINE_DEFAULT_DEBUG_CHANNEL(ole); | 
|---|
| 42 | WINE_DECLARE_DEBUG_CHANNEL(typelib); | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 | /****************************************************************************** | 
|---|
| 46 | *              DispInvoke (OLEAUT32.30) | 
|---|
| 47 | * | 
|---|
| 48 | * | 
|---|
| 49 | * Calls method of an object through its IDispatch interface. | 
|---|
| 50 | * | 
|---|
| 51 | * NOTES | 
|---|
| 52 | *              - Defer method invocation to ITypeInfo::Invoke() | 
|---|
| 53 | * | 
|---|
| 54 | * RETURNS | 
|---|
| 55 | * | 
|---|
| 56 | *              S_OK on success. | 
|---|
| 57 | */ | 
|---|
| 58 | HRESULT WINAPI DispInvoke( | 
|---|
| 59 | VOID       *_this,        /* [in] object instance */ | 
|---|
| 60 | ITypeInfo  *ptinfo,       /* [in] object's type info */ | 
|---|
| 61 | DISPID      dispidMember, /* [in] member id */ | 
|---|
| 62 | USHORT      wFlags,       /* [in] kind of method call */ | 
|---|
| 63 | DISPPARAMS *pparams,      /* [in] array of arguments */ | 
|---|
| 64 | VARIANT    *pvarResult,   /* [out] result of method call */ | 
|---|
| 65 | EXCEPINFO  *pexcepinfo,   /* [out] information about exception */ | 
|---|
| 66 | UINT       *puArgErr)     /* [out] index of bad argument(if any) */ | 
|---|
| 67 | { | 
|---|
| 68 | HRESULT hr = E_FAIL; | 
|---|
| 69 |  | 
|---|
| 70 | /** | 
|---|
| 71 | * TODO: | 
|---|
| 72 | * For each param, call DispGetParam to perform type coercion | 
|---|
| 73 | */ | 
|---|
| 74 | FIXME("Coercion of arguments not implemented\n"); | 
|---|
| 75 |  | 
|---|
| 76 | hr = ICOM_CALL7(Invoke, | 
|---|
| 77 | ptinfo, | 
|---|
| 78 | _this, | 
|---|
| 79 | dispidMember, | 
|---|
| 80 | wFlags, | 
|---|
| 81 | pparams, pvarResult, pexcepinfo, puArgErr); | 
|---|
| 82 |  | 
|---|
| 83 | return (hr); | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 |  | 
|---|
| 87 | /****************************************************************************** | 
|---|
| 88 | *              DispGetIDsOfNames (OLEAUT32.29) | 
|---|
| 89 | * | 
|---|
| 90 | * Convert a set of names to dispids, based on information | 
|---|
| 91 | * contained in object's type library. | 
|---|
| 92 | * | 
|---|
| 93 | * NOTES | 
|---|
| 94 | *              - Defers to ITypeInfo::GetIDsOfNames() | 
|---|
| 95 | * | 
|---|
| 96 | * RETURNS | 
|---|
| 97 | * | 
|---|
| 98 | *              S_OK on success. | 
|---|
| 99 | */ | 
|---|
| 100 | HRESULT WINAPI DispGetIDsOfNames( | 
|---|
| 101 | ITypeInfo  *ptinfo,    /* [in] */ | 
|---|
| 102 | OLECHAR   **rgszNames, /* [in] */ | 
|---|
| 103 | UINT        cNames,    /* [in] */ | 
|---|
| 104 | DISPID     *rgdispid)  /* [out] */ | 
|---|
| 105 | { | 
|---|
| 106 | HRESULT hr = E_FAIL; | 
|---|
| 107 |  | 
|---|
| 108 | hr = ICOM_CALL3(GetIDsOfNames, | 
|---|
| 109 | ptinfo, | 
|---|
| 110 | rgszNames, | 
|---|
| 111 | cNames, | 
|---|
| 112 | rgdispid); | 
|---|
| 113 | return (hr); | 
|---|
| 114 | } | 
|---|
| 115 |  | 
|---|
| 116 | /****************************************************************************** | 
|---|
| 117 | *              DispGetParam (OLEAUT32.28) | 
|---|
| 118 | * | 
|---|
| 119 | * Retrive a parameter from a DISPPARAMS structures and coerce it to | 
|---|
| 120 | * specified variant type | 
|---|
| 121 | * | 
|---|
| 122 | * NOTES | 
|---|
| 123 | *              Coercion is done using system (0) locale. | 
|---|
| 124 | * | 
|---|
| 125 | * RETURNS | 
|---|
| 126 | * | 
|---|
| 127 | *              S_OK on success. | 
|---|
| 128 | */ | 
|---|
| 129 | HRESULT WINAPI DispGetParam( | 
|---|
| 130 | DISPPARAMS *pdispparams, /* [in] */ | 
|---|
| 131 | UINT        position,    /* [in] */ | 
|---|
| 132 | VARTYPE     vtTarg,      /* [in] */ | 
|---|
| 133 | VARIANT    *pvarResult,  /* [out] */ | 
|---|
| 134 | UINT       *puArgErr)    /* [out] */ | 
|---|
| 135 | { | 
|---|
| 136 | /* position is counted backwards */ | 
|---|
| 137 | UINT pos; | 
|---|
| 138 | HRESULT hr; | 
|---|
| 139 |  | 
|---|
| 140 | TRACE("position=%d, cArgs=%d, cNamedArgs=%d\n", | 
|---|
| 141 | position, pdispparams->cArgs, pdispparams->cNamedArgs); | 
|---|
| 142 | if (position < pdispparams->cArgs) { | 
|---|
| 143 | /* positional arg? */ | 
|---|
| 144 | pos = pdispparams->cArgs - position - 1; | 
|---|
| 145 | } else { | 
|---|
| 146 | /* FIXME: is this how to handle named args? */ | 
|---|
| 147 | for (pos=0; pos<pdispparams->cNamedArgs; pos++) | 
|---|
| 148 | if (pdispparams->rgdispidNamedArgs[pos] == position) break; | 
|---|
| 149 |  | 
|---|
| 150 | if (pos==pdispparams->cNamedArgs) | 
|---|
| 151 | return DISP_E_PARAMNOTFOUND; | 
|---|
| 152 | } | 
|---|
| 153 | hr = VariantChangeType(pvarResult, | 
|---|
| 154 | &pdispparams->rgvarg[pos], | 
|---|
| 155 | 0, vtTarg); | 
|---|
| 156 | if (hr == DISP_E_TYPEMISMATCH) *puArgErr = pos; | 
|---|
| 157 | return hr; | 
|---|
| 158 | } | 
|---|