wined3d: Fix uploading higher transform matrices.
[wine] / dlls / jscript / dispex.c
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
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 "jscript.h"
20
21 #include "wine/unicode.h"
22 #include "wine/debug.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
25
26 #define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface)
27
28 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
29 {
30     DispatchEx *This = DISPATCHEX_THIS(iface);
31
32     if(IsEqualGUID(&IID_IUnknown, riid)) {
33         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
34         *ppv = _IDispatchEx_(This);
35     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
36         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
37         *ppv = _IDispatchEx_(This);
38     }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
39         TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
40         *ppv = _IDispatchEx_(This);
41     }else {
42         WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
43         *ppv = NULL;
44         return E_NOINTERFACE;
45     }
46
47     IUnknown_AddRef((IUnknown*)*ppv);
48     return S_OK;
49 }
50
51 static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
52 {
53     DispatchEx *This = DISPATCHEX_THIS(iface);
54     LONG ref = InterlockedIncrement(&This->ref);
55
56     TRACE("(%p) ref=%d\n", This, ref);
57
58     return ref;
59 }
60
61 static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
62 {
63     DispatchEx *This = DISPATCHEX_THIS(iface);
64     LONG ref = InterlockedDecrement(&This->ref);
65
66     TRACE("(%p) ref=%d\n", This, ref);
67
68     if(!ref) {
69         script_release(This->ctx);
70         heap_free(This);
71     }
72
73     return ref;
74 }
75
76 static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
77 {
78     DispatchEx *This = DISPATCHEX_THIS(iface);
79
80     TRACE("(%p)->(%p)\n", This, pctinfo);
81
82     *pctinfo = 1;
83     return S_OK;
84 }
85
86 static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
87                                               LCID lcid, ITypeInfo **ppTInfo)
88 {
89     DispatchEx *This = DISPATCHEX_THIS(iface);
90     FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
91     return E_NOTIMPL;
92 }
93
94 static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
95                                                 LPOLESTR *rgszNames, UINT cNames,
96                                                 LCID lcid, DISPID *rgDispId)
97 {
98     DispatchEx *This = DISPATCHEX_THIS(iface);
99     UINT i;
100     HRESULT hres;
101
102     TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
103           lcid, rgDispId);
104
105     for(i=0; i < cNames; i++) {
106         hres = IDispatchEx_GetDispID(_IDispatchEx_(This), rgszNames[i], 0, rgDispId+i);
107         if(FAILED(hres))
108             return hres;
109     }
110
111     return S_OK;
112 }
113
114 static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
115                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
116                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
117 {
118     DispatchEx *This = DISPATCHEX_THIS(iface);
119
120     TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
121           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
122
123     return IDispatchEx_InvokeEx(_IDispatchEx_(This), dispIdMember, lcid, wFlags,
124             pDispParams, pVarResult, pExcepInfo, NULL);
125 }
126
127 static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
128 {
129     DispatchEx *This = DISPATCHEX_THIS(iface);
130     FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
131     return E_NOTIMPL;
132 }
133
134 static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
135         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
136 {
137     DispatchEx *This = DISPATCHEX_THIS(iface);
138     FIXME("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
139     return E_NOTIMPL;
140 }
141
142 static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
143 {
144     DispatchEx *This = DISPATCHEX_THIS(iface);
145     FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
146     return E_NOTIMPL;
147 }
148
149 static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
150 {
151     DispatchEx *This = DISPATCHEX_THIS(iface);
152     FIXME("(%p)->(%x)\n", This, id);
153     return E_NOTIMPL;
154 }
155
156 static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
157 {
158     DispatchEx *This = DISPATCHEX_THIS(iface);
159     FIXME("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
160     return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
164 {
165     DispatchEx *This = DISPATCHEX_THIS(iface);
166     FIXME("(%p)->(%x %p)\n", This, id, pbstrName);
167     return E_NOTIMPL;
168 }
169
170 static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
171 {
172     DispatchEx *This = DISPATCHEX_THIS(iface);
173     FIXME("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
174     return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
178 {
179     DispatchEx *This = DISPATCHEX_THIS(iface);
180     FIXME("(%p)->(%p)\n", This, ppunk);
181     return E_NOTIMPL;
182 }
183
184 #undef DISPATCHEX_THIS
185
186 static IDispatchExVtbl DispatchExVtbl = {
187     DispatchEx_QueryInterface,
188     DispatchEx_AddRef,
189     DispatchEx_Release,
190     DispatchEx_GetTypeInfoCount,
191     DispatchEx_GetTypeInfo,
192     DispatchEx_GetIDsOfNames,
193     DispatchEx_Invoke,
194     DispatchEx_GetDispID,
195     DispatchEx_InvokeEx,
196     DispatchEx_DeleteMemberByName,
197     DispatchEx_DeleteMemberByDispID,
198     DispatchEx_GetMemberProperties,
199     DispatchEx_GetMemberName,
200     DispatchEx_GetNextDispID,
201     DispatchEx_GetNameSpaceParent
202 };
203
204 static HRESULT init_dispex(DispatchEx *dispex, script_ctx_t *ctx)
205 {
206     dispex->lpIDispatchExVtbl = &DispatchExVtbl;
207     dispex->ref = 1;
208
209     script_addref(ctx);
210     dispex->ctx = ctx;
211
212     return S_OK;
213 }
214
215 HRESULT create_dispex(script_ctx_t *ctx, DispatchEx **dispex)
216 {
217     DispatchEx *ret;
218     HRESULT hres;
219
220     ret = heap_alloc_zero(sizeof(DispatchEx));
221     if(!ret)
222         return E_OUTOFMEMORY;
223
224     hres = init_dispex(ret, ctx);
225     if(FAILED(hres))
226         return hres;
227
228     *dispex = ret;
229     return S_OK;
230 }