| [4837] | 1 | /**
 | 
|---|
 | 2 |  * Dispatch API functions
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  * Copyright 2000  Francois Jacques, Macadamian Technologies Inc.
 | 
|---|
 | 5 |  *
 | 
|---|
| [8450] | 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.
 | 
|---|
| [4837] | 10 |  *
 | 
|---|
| [8450] | 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 |  *
 | 
|---|
| [4837] | 20 |  * TODO: Type coercion is implemented in variant.c but not called yet.
 | 
|---|
 | 21 |  */
 | 
|---|
 | 22 | 
 | 
|---|
| [6944] | 23 | #include "config.h"
 | 
|---|
 | 24 | 
 | 
|---|
| [4837] | 25 | #include <stdlib.h>
 | 
|---|
 | 26 | #include <string.h>
 | 
|---|
 | 27 | #include <stdio.h>
 | 
|---|
 | 28 | #include <ctype.h>
 | 
|---|
| [6944] | 29 | 
 | 
|---|
 | 30 | #include "windef.h"
 | 
|---|
 | 31 | #include "oleauto.h"
 | 
|---|
| [4837] | 32 | #include "winerror.h"
 | 
|---|
 | 33 | #include "winreg.h"         /* for HKEY_LOCAL_MACHINE */
 | 
|---|
 | 34 | #include "winnls.h"         /* for PRIMARYLANGID */
 | 
|---|
| [6944] | 35 | 
 | 
|---|
| [4837] | 36 | #include "wine/obj_oleaut.h"
 | 
|---|
| [6944] | 37 | 
 | 
|---|
| [8450] | 38 | #include "wine/debug.h"
 | 
|---|
| [4837] | 39 | 
 | 
|---|
| [8450] | 40 | WINE_DEFAULT_DEBUG_CHANNEL(ole);
 | 
|---|
 | 41 | WINE_DECLARE_DEBUG_CHANNEL(typelib);
 | 
|---|
| [4837] | 42 | 
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | /******************************************************************************
 | 
|---|
| [6944] | 45 |  *              DispInvoke (OLEAUT32.30)
 | 
|---|
| [4837] | 46 |  *
 | 
|---|
 | 47 |  *
 | 
|---|
 | 48 |  * Calls method of an object through its IDispatch interface.
 | 
|---|
 | 49 |  *
 | 
|---|
 | 50 |  * NOTES
 | 
|---|
| [6711] | 51 |  *              - Defer method invocation to ITypeInfo::Invoke()
 | 
|---|
| [4837] | 52 |  *
 | 
|---|
 | 53 |  * RETURNS
 | 
|---|
 | 54 |  *
 | 
|---|
| [6711] | 55 |  *              S_OK on success.
 | 
|---|
| [4837] | 56 |  */
 | 
|---|
| [6944] | 57 | HRESULT 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) */
 | 
|---|
| [4837] | 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 | /******************************************************************************
 | 
|---|
| [6944] | 87 |  *              DispGetIDsOfNames (OLEAUT32.29)
 | 
|---|
| [4837] | 88 |  *
 | 
|---|
| [6711] | 89 |  * Convert a set of names to dispids, based on information 
 | 
|---|
| [4837] | 90 |  * contained in object's type library.
 | 
|---|
| [6711] | 91 |  * 
 | 
|---|
| [4837] | 92 |  * NOTES
 | 
|---|
| [6711] | 93 |  *              - Defers to ITypeInfo::GetIDsOfNames()
 | 
|---|
| [4837] | 94 |  *
 | 
|---|
 | 95 |  * RETURNS
 | 
|---|
 | 96 |  *
 | 
|---|
| [6711] | 97 |  *              S_OK on success.
 | 
|---|
| [4837] | 98 |  */
 | 
|---|
| [6944] | 99 | HRESULT WINAPI DispGetIDsOfNames(
 | 
|---|
 | 100 |         ITypeInfo  *ptinfo,    /* [in] */
 | 
|---|
 | 101 |         OLECHAR   **rgszNames, /* [in] */
 | 
|---|
 | 102 |         UINT        cNames,    /* [in] */
 | 
|---|
 | 103 |         DISPID     *rgdispid)  /* [out] */
 | 
|---|
| [4837] | 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 | /******************************************************************************
 | 
|---|
| [6944] | 116 |  *              DispGetParam (OLEAUT32.28)
 | 
|---|
| [4837] | 117 |  *
 | 
|---|
 | 118 |  * Retrive a parameter from a DISPPARAMS structures and coerce it to
 | 
|---|
 | 119 |  * specified variant type
 | 
|---|
 | 120 |  *
 | 
|---|
 | 121 |  * NOTES
 | 
|---|
| [6711] | 122 |  *              Coercion is done using system (0) locale.
 | 
|---|
| [4837] | 123 |  *
 | 
|---|
 | 124 |  * RETURNS
 | 
|---|
 | 125 |  *
 | 
|---|
| [6711] | 126 |  *              S_OK on success.
 | 
|---|
| [4837] | 127 |  */
 | 
|---|
| [6944] | 128 | HRESULT WINAPI DispGetParam(
 | 
|---|
 | 129 |         DISPPARAMS *pdispparams, /* [in] */
 | 
|---|
 | 130 |         UINT        position,    /* [in] */
 | 
|---|
 | 131 |         VARTYPE     vtTarg,      /* [in] */
 | 
|---|
 | 132 |         VARIANT    *pvarResult,  /* [out] */
 | 
|---|
 | 133 |         UINT       *puArgErr)    /* [out] */
 | 
|---|
| [4837] | 134 | {
 | 
|---|
| [6944] | 135 |     /* position is counted backwards */
 | 
|---|
 | 136 |     UINT pos;
 | 
|---|
 | 137 |     HRESULT hr;
 | 
|---|
| [4837] | 138 | 
 | 
|---|
| [6944] | 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;
 | 
|---|
| [4837] | 148 | 
 | 
|---|
| [6944] | 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;
 | 
|---|
| [4837] | 157 | }
 | 
|---|