2 * Copyright 2008 Jacek Caban for CodeWeavers
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.
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.
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
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
28 const IActiveScriptVtbl *lpIActiveScriptVtbl;
29 const IActiveScriptParseVtbl *lpIActiveScriptParseVtbl;
30 const IActiveScriptParseProcedure2Vtbl *lpIActiveScriptParseProcedure2Vtbl;
31 const IActiveScriptPropertyVtbl *lpIActiveScriptPropertyVtbl;
32 const IObjectSafetyVtbl *lpIObjectSafetyVtbl;
39 #define ACTSCRIPT(x) ((IActiveScript*) &(x)->lpIActiveScriptVtbl)
40 #define ASPARSE(x) ((IActiveScriptParse*) &(x)->lpIActiveScriptParseVtbl)
41 #define ASPARSEPROC(x) ((IActiveScriptParseProcedure2*) &(x)->lpIActiveScriptParseProcedure2Vtbl)
42 #define ACTSCPPROP(x) ((IActiveScriptProperty*) &(x)->lpIActiveScriptPropertyVtbl)
43 #define OBJSAFETY(x) ((IObjectSafety*) &(x)->lpIObjectSafetyVtbl)
45 #define ACTSCRIPT_THIS(iface) DEFINE_THIS(JScript, IActiveScript, iface)
47 static HRESULT WINAPI JScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
49 JScript *This = ACTSCRIPT_THIS(iface);
53 if(IsEqualGUID(riid, &IID_IUnknown)) {
54 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
55 *ppv = ACTSCRIPT(This);
56 }else if(IsEqualGUID(riid, &IID_IActiveScript)) {
57 TRACE("(%p)->(IID_IActiveScript %p)\n", This, ppv);
58 *ppv = ACTSCRIPT(This);
59 }else if(IsEqualGUID(riid, &IID_IActiveScriptParse)) {
60 TRACE("(%p)->(IID_IActiveScriptParse %p)\n", This, ppv);
62 }else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure)) {
63 TRACE("(%p)->(IID_IActiveScriptParseProcedure %p)\n", This, ppv);
64 *ppv = ASPARSEPROC(This);
65 }else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure2)) {
66 TRACE("(%p)->(IID_IActiveScriptParseProcedure2 %p)\n", This, ppv);
67 *ppv = ASPARSEPROC(This);
68 }else if(IsEqualGUID(riid, &IID_IActiveScriptProperty)) {
69 TRACE("(%p)->(IID_IActiveScriptProperty %p)\n", This, ppv);
70 *ppv = ACTSCPPROP(This);
71 }else if(IsEqualGUID(riid, &IID_IObjectSafety)) {
72 TRACE("(%p)->(IID_IObjectSafety %p)\n", This, ppv);
73 *ppv = OBJSAFETY(This);
77 IUnknown_AddRef((IUnknown*)*ppv);
81 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
85 static ULONG WINAPI JScript_AddRef(IActiveScript *iface)
87 JScript *This = ACTSCRIPT_THIS(iface);
88 LONG ref = InterlockedIncrement(&This->ref);
90 TRACE("(%p) ref=%d\n", This, ref);
95 static ULONG WINAPI JScript_Release(IActiveScript *iface)
97 JScript *This = ACTSCRIPT_THIS(iface);
98 LONG ref = InterlockedDecrement(&This->ref);
100 TRACE("(%p) ref=%d\n", iface, ref);
110 static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface,
111 IActiveScriptSite *pass)
113 JScript *This = ACTSCRIPT_THIS(iface);
114 FIXME("(%p)->(%p)\n", This, pass);
118 static HRESULT WINAPI JScript_GetScriptSite(IActiveScript *iface, REFIID riid,
121 JScript *This = ACTSCRIPT_THIS(iface);
122 FIXME("(%p)->()\n", This);
126 static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss)
128 JScript *This = ACTSCRIPT_THIS(iface);
129 FIXME("(%p)->(%d)\n", This, ss);
133 static HRESULT WINAPI JScript_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState)
135 JScript *This = ACTSCRIPT_THIS(iface);
136 FIXME("(%p)->(%p)\n", This, pssState);
140 static HRESULT WINAPI JScript_Close(IActiveScript *iface)
142 JScript *This = ACTSCRIPT_THIS(iface);
143 FIXME("(%p)->()\n", This);
147 static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface,
148 LPCOLESTR pstrName, DWORD dwFlags)
150 JScript *This = ACTSCRIPT_THIS(iface);
151 FIXME("(%p)->(%s %x)\n", This, debugstr_w(pstrName), dwFlags);
155 static HRESULT WINAPI JScript_AddTypeLib(IActiveScript *iface, REFGUID rguidTypeLib,
156 DWORD dwMajor, DWORD dwMinor, DWORD dwFlags)
158 JScript *This = ACTSCRIPT_THIS(iface);
159 FIXME("(%p)->()\n", This);
163 static HRESULT WINAPI JScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR pstrItemName,
166 JScript *This = ACTSCRIPT_THIS(iface);
167 FIXME("(%p)->()\n", This);
171 static HRESULT WINAPI JScript_GetCurrentScriptThreadID(IActiveScript *iface,
172 SCRIPTTHREADID *pstridThread)
174 JScript *This = ACTSCRIPT_THIS(iface);
175 FIXME("(%p)->()\n", This);
179 static HRESULT WINAPI JScript_GetScriptThreadID(IActiveScript *iface,
180 DWORD dwWin32ThreadId, SCRIPTTHREADID *pstidThread)
182 JScript *This = ACTSCRIPT_THIS(iface);
183 FIXME("(%p)->()\n", This);
187 static HRESULT WINAPI JScript_GetScriptThreadState(IActiveScript *iface,
188 SCRIPTTHREADID stidThread, SCRIPTTHREADSTATE *pstsState)
190 JScript *This = ACTSCRIPT_THIS(iface);
191 FIXME("(%p)->()\n", This);
195 static HRESULT WINAPI JScript_InterruptScriptThread(IActiveScript *iface,
196 SCRIPTTHREADID stidThread, const EXCEPINFO *pexcepinfo, DWORD dwFlags)
198 JScript *This = ACTSCRIPT_THIS(iface);
199 FIXME("(%p)->()\n", This);
203 static HRESULT WINAPI JScript_Clone(IActiveScript *iface, IActiveScript **ppscript)
205 JScript *This = ACTSCRIPT_THIS(iface);
206 FIXME("(%p)->()\n", This);
210 #undef ACTSCRIPT_THIS
212 static const IActiveScriptVtbl JScriptVtbl = {
213 JScript_QueryInterface,
216 JScript_SetScriptSite,
217 JScript_GetScriptSite,
218 JScript_SetScriptState,
219 JScript_GetScriptState,
221 JScript_AddNamedItem,
223 JScript_GetScriptDispatch,
224 JScript_GetCurrentScriptThreadID,
225 JScript_GetScriptThreadID,
226 JScript_GetScriptThreadState,
227 JScript_InterruptScriptThread,
231 #define ASPARSE_THIS(iface) DEFINE_THIS(JScript, IActiveScriptParse, iface)
233 static HRESULT WINAPI JScriptParse_QueryInterface(IActiveScriptParse *iface, REFIID riid, void **ppv)
235 JScript *This = ASPARSE_THIS(iface);
236 return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
239 static ULONG WINAPI JScriptParse_AddRef(IActiveScriptParse *iface)
241 JScript *This = ASPARSE_THIS(iface);
242 return IActiveScript_AddRef(ACTSCRIPT(This));
245 static ULONG WINAPI JScriptParse_Release(IActiveScriptParse *iface)
247 JScript *This = ASPARSE_THIS(iface);
248 return IActiveScript_Release(ACTSCRIPT(This));
251 static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
253 JScript *This = ASPARSE_THIS(iface);
254 FIXME("(%p)\n", This);
258 static HRESULT WINAPI JScriptParse_AddScriptlet(IActiveScriptParse *iface,
259 LPCOLESTR pstrDefaultName, LPCOLESTR pstrCode, LPCOLESTR pstrItemName,
260 LPCOLESTR pstrSubItemName, LPCOLESTR pstrEventName, LPCOLESTR pstrDelimiter,
261 DWORD dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags,
262 BSTR *pbstrName, EXCEPINFO *pexcepinfo)
264 JScript *This = ASPARSE_THIS(iface);
265 FIXME("(%p)->(%s %s %s %s %s %s %x %u %x %p %p)\n", This, debugstr_w(pstrDefaultName),
266 debugstr_w(pstrCode), debugstr_w(pstrItemName), debugstr_w(pstrSubItemName),
267 debugstr_w(pstrEventName), debugstr_w(pstrDelimiter), dwSourceContextCookie,
268 ulStartingLineNumber, dwFlags, pbstrName, pexcepinfo);
272 static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
273 LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
274 LPCOLESTR pstrDelimiter, DWORD dwSourceContextCookie, ULONG ulStartingLine,
275 DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
277 JScript *This = ASPARSE_THIS(iface);
278 FIXME("(%p)->(%s %s %p %s %x %u %x %p %p)\n", This, debugstr_w(pstrCode),
279 debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
280 dwSourceContextCookie, ulStartingLine, dwFlags, pvarResult, pexcepinfo);
286 static const IActiveScriptParseVtbl JScriptParseVtbl = {
287 JScriptParse_QueryInterface,
289 JScriptParse_Release,
290 JScriptParse_InitNew,
291 JScriptParse_AddScriptlet,
292 JScriptParse_ParseScriptText
295 #define ASPARSEPROC_THIS(iface) DEFINE_THIS(JScript, IActiveScriptParse, iface)
297 static HRESULT WINAPI JScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2 *iface, REFIID riid, void **ppv)
299 JScript *This = ASPARSEPROC_THIS(iface);
300 return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
303 static ULONG WINAPI JScriptParseProcedure_AddRef(IActiveScriptParseProcedure2 *iface)
305 JScript *This = ASPARSEPROC_THIS(iface);
306 return IActiveScript_AddRef(ACTSCRIPT(This));
309 static ULONG WINAPI JScriptParseProcedure_Release(IActiveScriptParseProcedure2 *iface)
311 JScript *This = ASPARSEPROC_THIS(iface);
312 return IActiveScript_Release(ACTSCRIPT(This));
315 static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2 *iface,
316 LPCOLESTR pstrCode, LPCOLESTR pstrFormalParams, LPCOLESTR pstrProcedureName,
317 LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter,
318 DWORD dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, IDispatch **ppdisp)
320 JScript *This = ASPARSEPROC_THIS(iface);
321 FIXME("(%p)->()\n", This);
325 #undef ASPARSEPROC_THIS
327 static const IActiveScriptParseProcedure2Vtbl JScriptParseProcedureVtbl = {
328 JScriptParseProcedure_QueryInterface,
329 JScriptParseProcedure_AddRef,
330 JScriptParseProcedure_Release,
331 JScriptParseProcedure_ParseProcedureText,
334 #define ACTSCPPROP_THIS(iface) DEFINE_THIS(JScript, IActiveScriptProperty, iface)
336 static HRESULT WINAPI JScriptProperty_QueryInterface(IActiveScriptProperty *iface, REFIID riid, void **ppv)
338 JScript *This = ACTSCPPROP_THIS(iface);
339 return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
342 static ULONG WINAPI JScriptProperty_AddRef(IActiveScriptProperty *iface)
344 JScript *This = ACTSCPPROP_THIS(iface);
345 return IActiveScript_AddRef(ACTSCRIPT(This));
348 static ULONG WINAPI JScriptProperty_Release(IActiveScriptProperty *iface)
350 JScript *This = ACTSCPPROP_THIS(iface);
351 return IActiveScript_Release(ACTSCRIPT(This));
354 static HRESULT WINAPI JScriptProperty_GetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
355 VARIANT *pvarIndex, VARIANT *pvarValue)
357 JScript *This = ACTSCPPROP_THIS(iface);
358 FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue);
362 static HRESULT WINAPI JScriptProperty_SetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
363 VARIANT *pvarIndex, VARIANT *pvarValue)
365 JScript *This = ACTSCPPROP_THIS(iface);
366 FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue);
370 #undef ACTSCPPROP_THIS
372 static const IActiveScriptPropertyVtbl JScriptPropertyVtbl = {
373 JScriptProperty_QueryInterface,
374 JScriptProperty_AddRef,
375 JScriptProperty_Release,
376 JScriptProperty_GetProperty,
377 JScriptProperty_SetProperty
380 #define OBJSAFETY_THIS(iface) DEFINE_THIS(JScript, IObjectSafety, iface)
382 static HRESULT WINAPI JScriptSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
384 JScript *This = OBJSAFETY_THIS(iface);
385 return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
388 static ULONG WINAPI JScriptSafety_AddRef(IObjectSafety *iface)
390 JScript *This = OBJSAFETY_THIS(iface);
391 return IActiveScript_AddRef(ACTSCRIPT(This));
394 static ULONG WINAPI JScriptSafety_Release(IObjectSafety *iface)
396 JScript *This = OBJSAFETY_THIS(iface);
397 return IActiveScript_Release(ACTSCRIPT(This));
400 #define SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER)
402 static HRESULT WINAPI JScriptSafety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
403 DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
405 JScript *This = OBJSAFETY_THIS(iface);
407 TRACE("(%p)->(%s %p %p)\n", This, debugstr_guid(riid), pdwSupportedOptions, pdwEnabledOptions);
409 if(!pdwSupportedOptions || !pdwEnabledOptions)
412 *pdwSupportedOptions = SUPPORTED_OPTIONS;
413 *pdwEnabledOptions = This->safeopt;
418 static HRESULT WINAPI JScriptSafety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
419 DWORD dwOptionSetMask, DWORD dwEnabledOptions)
421 JScript *This = OBJSAFETY_THIS(iface);
423 TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions);
425 if(dwOptionSetMask & ~SUPPORTED_OPTIONS)
428 This->safeopt = dwEnabledOptions & dwEnabledOptions;
432 #undef OBJSAFETY_THIS
434 static const IObjectSafetyVtbl JScriptSafetyVtbl = {
435 JScriptSafety_QueryInterface,
436 JScriptSafety_AddRef,
437 JScriptSafety_Release,
438 JScriptSafety_GetInterfaceSafetyOptions,
439 JScriptSafety_SetInterfaceSafetyOptions
442 HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
443 REFIID riid, void **ppv)
448 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
452 ret = heap_alloc(sizeof(*ret));
454 ret->lpIActiveScriptVtbl = &JScriptVtbl;
455 ret->lpIActiveScriptParseVtbl = &JScriptParseVtbl;
456 ret->lpIActiveScriptParseProcedure2Vtbl = &JScriptParseProcedureVtbl;
457 ret->lpIActiveScriptPropertyVtbl = &JScriptPropertyVtbl;
458 ret->lpIObjectSafetyVtbl = &JScriptSafetyVtbl;
460 ret->safeopt = INTERFACE_USES_DISPEX;
462 hres = IActiveScript_QueryInterface(ACTSCRIPT(ret), riid, ppv);
463 IActiveScript_Release(ACTSCRIPT(ret));