ReactOS  0.4.11-dev-946-g431643b
arguments.c
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Michal Zietek
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include <stdarg.h>
20 
21 #define COBJMACROS
22 #define CONST_VTABLE
23 
24 #include <windef.h>
25 #include <winbase.h>
26 #include <ole2.h>
27 
28 #include "wscript.h"
29 
30 #include <wine/debug.h>
31 
33 
36 
37 static HRESULT WINAPI Arguments2_QueryInterface(IArguments2 *iface, REFIID riid, void **ppv)
38 {
39  WINE_TRACE("(%s %p)\n", wine_dbgstr_guid(riid), ppv);
40 
41  if(IsEqualGUID(&IID_IUnknown, riid)
42  || IsEqualGUID(&IID_IDispatch, riid)
43  || IsEqualGUID(&IID_IArguments2, riid)) {
44  *ppv = iface;
45  return S_OK;
46  }
47 
48  *ppv = NULL;
49  return E_NOINTERFACE;
50 }
51 
52 static ULONG WINAPI Arguments2_AddRef(IArguments2 *iface)
53 {
54  return 2;
55 }
56 
57 static ULONG WINAPI Arguments2_Release(IArguments2 *iface)
58 {
59  return 1;
60 }
61 
62 static HRESULT WINAPI Arguments2_GetTypeInfoCount(IArguments2 *iface, UINT *pctinfo)
63 {
64  WINE_TRACE("(%p)\n", pctinfo);
65 
66  *pctinfo = 1;
67  return S_OK;
68 }
69 
70 static HRESULT WINAPI Arguments2_GetTypeInfo(IArguments2 *iface, UINT iTInfo, LCID lcid,
71  ITypeInfo **ppTInfo)
72 {
73  WINE_TRACE("(%x %x %p\n", iTInfo, lcid, ppTInfo);
74 
75  ITypeInfo_AddRef(arguments_ti);
76  *ppTInfo = arguments_ti;
77  return S_OK;
78 }
79 
80 static HRESULT WINAPI Arguments2_GetIDsOfNames(IArguments2 *iface, REFIID riid, LPOLESTR *rgszNames,
81  UINT cNames, LCID lcid, DISPID *rgDispId)
82 {
83  WINE_TRACE("(%s %p %d %x %p)\n", wine_dbgstr_guid(riid), rgszNames,
84  cNames, lcid, rgDispId);
85 
86  return ITypeInfo_GetIDsOfNames(arguments_ti, rgszNames, cNames, rgDispId);
87 }
88 
89 static HRESULT WINAPI Arguments2_Invoke(IArguments2 *iface, DISPID dispIdMember, REFIID riid,
90  LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
91  EXCEPINFO *pExcepInfo, UINT *puArgErr)
92 {
93  WINE_TRACE("(%d %p %p)\n", dispIdMember, pDispParams, pVarResult);
94 
95  return ITypeInfo_Invoke(arguments_ti, iface, dispIdMember, wFlags, pDispParams,
96  pVarResult, pExcepInfo, puArgErr);
97 }
98 
99 static HRESULT WINAPI Arguments2_Item(IArguments2 *iface, LONG index, BSTR *out_Value)
100 {
101  WINE_TRACE("(%d %p)\n", index, out_Value);
102 
104  return E_INVALIDARG;
105  if(!(*out_Value = SysAllocString(argums[index])))
106  return E_OUTOFMEMORY;
107 
108  return S_OK;
109 }
110 
111 static HRESULT WINAPI Arguments2_Count(IArguments2 *iface, LONG *out_Count)
112 {
113  WINE_TRACE("(%p)\n", out_Count);
114 
115  *out_Count = numOfArgs;
116  return S_OK;
117 }
118 
119 static HRESULT WINAPI Arguments2_get_length(IArguments2 *iface, LONG *out_Count)
120 {
121  WINE_TRACE("(%p)\n", out_Count);
122 
123  *out_Count = numOfArgs;
124  return S_OK;
125 }
126 
127 static const IArguments2Vtbl Arguments2Vtbl = {
138 };
139 
140 IArguments2 arguments_obj = { &Arguments2Vtbl };
static const IArguments2Vtbl Arguments2Vtbl
Definition: arguments.c:127
IArguments2 arguments_obj
Definition: arguments.c:140
#define REFIID
Definition: guiddef.h:113
#define E_NOINTERFACE
Definition: winerror.h:2364
static HRESULT WINAPI Arguments2_GetTypeInfo(IArguments2 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: arguments.c:70
static ULONG WINAPI Arguments2_Release(IArguments2 *iface)
Definition: arguments.c:57
__wchar_t WCHAR
Definition: xmlstorage.h:180
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
static HRESULT WINAPI Arguments2_Item(IArguments2 *iface, LONG index, BSTR *out_Value)
Definition: arguments.c:99
const char * wine_dbgstr_guid(const GUID *guid)
#define WINE_TRACE
Definition: debug.h:358
WCHAR ** argums
Definition: arguments.c:34
DWORD LCID
Definition: nls.h:13
OLECHAR * BSTR
Definition: compat.h:1927
ITypeInfo * arguments_ti
Definition: main.c:60
static LPOLESTR
Definition: stg_prop.c:33
WINE_DEFAULT_DEBUG_CHANNEL(wscript)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:242
GLuint index
Definition: glext.h:6031
static HRESULT WINAPI Arguments2_Invoke(IArguments2 *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: arguments.c:89
static HRESULT WINAPI Arguments2_QueryInterface(IArguments2 *iface, REFIID riid, void **ppv)
Definition: arguments.c:37
LONG HRESULT
Definition: typedefs.h:77
static HRESULT WINAPI Arguments2_Count(IArguments2 *iface, LONG *out_Count)
Definition: arguments.c:111
const GUID IID_IUnknown
int numOfArgs
Definition: arguments.c:35
unsigned int UINT
Definition: ndis.h:50
unsigned short WORD
Definition: ntddk_ex.h:93
static ULONG WINAPI Arguments2_AddRef(IArguments2 *iface)
Definition: arguments.c:52
const GUID IID_IDispatch
static HRESULT WINAPI Arguments2_GetIDsOfNames(IArguments2 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: arguments.c:80
#define WINAPI
Definition: msvc.h:20
static HRESULT WINAPI Arguments2_GetTypeInfoCount(IArguments2 *iface, UINT *pctinfo)
Definition: arguments.c:62
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
struct stdole::EXCEPINFO EXCEPINFO
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4024
struct stdole::DISPPARAMS DISPPARAMS
unsigned int ULONG
Definition: retypes.h:1
static HRESULT WINAPI Arguments2_get_length(IArguments2 *iface, LONG *out_Count)
Definition: arguments.c:119