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);
29 #define CTXARG_T DWORDLONG
30 #define IActiveScriptParseVtbl IActiveScriptParse64Vtbl
31 #define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_64Vtbl
35 #define CTXARG_T DWORD
36 #define IActiveScriptParseVtbl IActiveScriptParse32Vtbl
37 #define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_32Vtbl
42 const IActiveScriptVtbl *lpIActiveScriptVtbl;
43 const IActiveScriptParseVtbl *lpIActiveScriptParseVtbl;
44 const IActiveScriptParseProcedure2Vtbl *lpIActiveScriptParseProcedure2Vtbl;
45 const IActiveScriptPropertyVtbl *lpIActiveScriptPropertyVtbl;
46 const IObjectSafetyVtbl *lpIObjectSafetyVtbl;
55 IActiveScriptSite *site;
57 parser_ctx_t *queue_head;
58 parser_ctx_t *queue_tail;
61 #define ACTSCRIPT(x) ((IActiveScript*) &(x)->lpIActiveScriptVtbl)
62 #define ASPARSE(x) (&(x)->lpIActiveScriptParseVtbl)
63 #define ASPARSEPROC(x) (&(x)->lpIActiveScriptParseProcedure2Vtbl)
64 #define ACTSCPPROP(x) (&(x)->lpIActiveScriptPropertyVtbl)
65 #define OBJSAFETY(x) (&(x)->lpIObjectSafetyVtbl)
67 void script_release(script_ctx_t *ctx)
72 jsheap_free(&ctx->tmp_heap);
76 static void change_state(JScript *This, SCRIPTSTATE state)
78 if(This->ctx->state == state)
81 This->ctx->state = state;
82 IActiveScriptSite_OnStateChange(This->site, state);
85 static inline BOOL is_started(script_ctx_t *ctx)
87 return ctx->state == SCRIPTSTATE_STARTED
88 || ctx->state == SCRIPTSTATE_CONNECTED
89 || ctx->state == SCRIPTSTATE_DISCONNECTED;
92 static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx)
99 hres = create_exec_ctx((IDispatch*)_IDispatchEx_(This->ctx->script_disp), This->ctx->script_disp, NULL, &exec_ctx);
103 IActiveScriptSite_OnEnterScript(This->site);
105 memset(&jsexcept, 0, sizeof(jsexcept));
106 hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, &jsexcept, &var);
107 VariantClear(&jsexcept.var);
108 exec_release(exec_ctx);
112 IActiveScriptSite_OnLeaveScript(This->site);
117 static void clear_script_queue(JScript *This)
119 parser_ctx_t *iter, *iter2;
121 if(!This->queue_head)
124 iter = This->queue_head;
128 parser_release(iter);
132 This->queue_head = This->queue_tail = NULL;
135 static void exec_queued_code(JScript *This)
139 for(iter = This->queue_head; iter; iter = iter->next)
140 exec_global_code(This, iter);
142 clear_script_queue(This);
145 static HRESULT set_ctx_site(JScript *This)
149 This->ctx->lcid = This->lcid;
151 if(!This->ctx->script_disp) {
152 hres = create_dispex(This->ctx, NULL, NULL, &This->ctx->script_disp);
157 hres = init_global(This->ctx);
161 IActiveScriptSite_AddRef(This->site);
162 This->ctx->site = This->site;
164 change_state(This, SCRIPTSTATE_INITIALIZED);
168 #define ACTSCRIPT_THIS(iface) DEFINE_THIS(JScript, IActiveScript, iface)
170 static HRESULT WINAPI JScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
172 JScript *This = ACTSCRIPT_THIS(iface);
176 if(IsEqualGUID(riid, &IID_IUnknown)) {
177 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
178 *ppv = ACTSCRIPT(This);
179 }else if(IsEqualGUID(riid, &IID_IActiveScript)) {
180 TRACE("(%p)->(IID_IActiveScript %p)\n", This, ppv);
181 *ppv = ACTSCRIPT(This);
182 }else if(IsEqualGUID(riid, &IID_IActiveScriptParse)) {
183 TRACE("(%p)->(IID_IActiveScriptParse %p)\n", This, ppv);
184 *ppv = ASPARSE(This);
185 }else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure)) {
186 TRACE("(%p)->(IID_IActiveScriptParseProcedure %p)\n", This, ppv);
187 *ppv = ASPARSEPROC(This);
188 }else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure2)) {
189 TRACE("(%p)->(IID_IActiveScriptParseProcedure2 %p)\n", This, ppv);
190 *ppv = ASPARSEPROC(This);
191 }else if(IsEqualGUID(riid, &IID_IActiveScriptProperty)) {
192 TRACE("(%p)->(IID_IActiveScriptProperty %p)\n", This, ppv);
193 *ppv = ACTSCPPROP(This);
194 }else if(IsEqualGUID(riid, &IID_IObjectSafety)) {
195 TRACE("(%p)->(IID_IObjectSafety %p)\n", This, ppv);
196 *ppv = OBJSAFETY(This);
200 IUnknown_AddRef((IUnknown*)*ppv);
204 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
205 return E_NOINTERFACE;
208 static ULONG WINAPI JScript_AddRef(IActiveScript *iface)
210 JScript *This = ACTSCRIPT_THIS(iface);
211 LONG ref = InterlockedIncrement(&This->ref);
213 TRACE("(%p) ref=%d\n", This, ref);
218 static ULONG WINAPI JScript_Release(IActiveScript *iface)
220 JScript *This = ACTSCRIPT_THIS(iface);
221 LONG ref = InterlockedDecrement(&This->ref);
223 TRACE("(%p) ref=%d\n", iface, ref);
226 if(This->ctx && This->ctx->state != SCRIPTSTATE_CLOSED)
227 IActiveScript_Close(ACTSCRIPT(This));
229 script_release(This->ctx);
237 static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface,
238 IActiveScriptSite *pass)
240 JScript *This = ACTSCRIPT_THIS(iface);
244 TRACE("(%p)->(%p)\n", This, pass);
252 if(InterlockedCompareExchange(&This->thread_id, GetCurrentThreadId(), 0))
256 IActiveScriptSite_AddRef(This->site);
258 hres = IActiveScriptSite_GetLCID(This->site, &lcid);
262 return This->ctx ? set_ctx_site(This) : S_OK;
265 static HRESULT WINAPI JScript_GetScriptSite(IActiveScript *iface, REFIID riid,
268 JScript *This = ACTSCRIPT_THIS(iface);
269 FIXME("(%p)->()\n", This);
273 static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss)
275 JScript *This = ACTSCRIPT_THIS(iface);
277 TRACE("(%p)->(%d)\n", This, ss);
279 if(!This->ctx || GetCurrentThreadId() != This->thread_id)
283 case SCRIPTSTATE_STARTED:
284 case SCRIPTSTATE_CONNECTED: /* FIXME */
285 if(This->ctx->state == SCRIPTSTATE_CLOSED)
288 exec_queued_code(This);
291 FIXME("unimplemented state %d\n", ss);
295 change_state(This, ss);
299 static HRESULT WINAPI JScript_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState)
301 JScript *This = ACTSCRIPT_THIS(iface);
303 TRACE("(%p)->(%p)\n", This, pssState);
308 if(!This->thread_id) {
309 *pssState = SCRIPTSTATE_UNINITIALIZED;
313 if(This->thread_id != GetCurrentThreadId())
316 *pssState = This->ctx ? This->ctx->state : SCRIPTSTATE_UNINITIALIZED;
320 static HRESULT WINAPI JScript_Close(IActiveScript *iface)
322 JScript *This = ACTSCRIPT_THIS(iface);
324 TRACE("(%p)->()\n", This);
326 if(This->thread_id != GetCurrentThreadId())
330 if(This->ctx->state == SCRIPTSTATE_CONNECTED)
331 change_state(This, SCRIPTSTATE_DISCONNECTED);
333 clear_script_queue(This);
335 if(This->ctx->state == SCRIPTSTATE_DISCONNECTED)
336 change_state(This, SCRIPTSTATE_INITIALIZED);
338 if(This->ctx->named_items) {
339 named_item_t *iter, *iter2;
341 iter = This->ctx->named_items;
346 IDispatch_Release(iter->disp);
347 heap_free(iter->name);
352 This->ctx->named_items = NULL;
355 if(This->ctx->site) {
356 IActiveScriptSite_Release(This->ctx->site);
357 This->ctx->site = NULL;
361 change_state(This, SCRIPTSTATE_CLOSED);
363 if(This->ctx->script_disp) {
364 IDispatchEx_Release(_IDispatchEx_(This->ctx->script_disp));
365 This->ctx->script_disp = NULL;
368 if(This->ctx->global) {
369 IDispatchEx_Release(_IDispatchEx_(This->ctx->global));
370 This->ctx->global = NULL;
375 IActiveScriptSite_Release(This->site);
382 static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface,
383 LPCOLESTR pstrName, DWORD dwFlags)
385 JScript *This = ACTSCRIPT_THIS(iface);
387 IDispatch *disp = NULL;
390 TRACE("(%p)->(%s %x)\n", This, debugstr_w(pstrName), dwFlags);
392 if(This->thread_id != GetCurrentThreadId() || !This->ctx || This->ctx->state == SCRIPTSTATE_CLOSED)
395 if(dwFlags & SCRIPTITEM_GLOBALMEMBERS) {
398 hres = IActiveScriptSite_GetItemInfo(This->site, pstrName, SCRIPTINFO_IUNKNOWN, &unk, NULL);
400 WARN("GetItemInfo failed: %08x\n", hres);
404 hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&disp);
405 IUnknown_Release(unk);
407 WARN("object does not implement IDispatch\n");
412 item = heap_alloc(sizeof(*item));
415 IDispatch_Release(disp);
416 return E_OUTOFMEMORY;
420 item->flags = dwFlags;
421 item->name = heap_strdupW(pstrName);
423 IDispatch_Release(disp);
425 return E_OUTOFMEMORY;
428 item->next = This->ctx->named_items;
429 This->ctx->named_items = item;
434 static HRESULT WINAPI JScript_AddTypeLib(IActiveScript *iface, REFGUID rguidTypeLib,
435 DWORD dwMajor, DWORD dwMinor, DWORD dwFlags)
437 JScript *This = ACTSCRIPT_THIS(iface);
438 FIXME("(%p)->()\n", This);
442 static HRESULT WINAPI JScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR pstrItemName,
445 JScript *This = ACTSCRIPT_THIS(iface);
447 TRACE("(%p)->(%p)\n", This, ppdisp);
452 if(This->thread_id != GetCurrentThreadId() || !This->ctx->script_disp) {
457 *ppdisp = (IDispatch*)_IDispatchEx_(This->ctx->script_disp);
458 IDispatch_AddRef(*ppdisp);
462 static HRESULT WINAPI JScript_GetCurrentScriptThreadID(IActiveScript *iface,
463 SCRIPTTHREADID *pstridThread)
465 JScript *This = ACTSCRIPT_THIS(iface);
466 FIXME("(%p)->()\n", This);
470 static HRESULT WINAPI JScript_GetScriptThreadID(IActiveScript *iface,
471 DWORD dwWin32ThreadId, SCRIPTTHREADID *pstidThread)
473 JScript *This = ACTSCRIPT_THIS(iface);
474 FIXME("(%p)->()\n", This);
478 static HRESULT WINAPI JScript_GetScriptThreadState(IActiveScript *iface,
479 SCRIPTTHREADID stidThread, SCRIPTTHREADSTATE *pstsState)
481 JScript *This = ACTSCRIPT_THIS(iface);
482 FIXME("(%p)->()\n", This);
486 static HRESULT WINAPI JScript_InterruptScriptThread(IActiveScript *iface,
487 SCRIPTTHREADID stidThread, const EXCEPINFO *pexcepinfo, DWORD dwFlags)
489 JScript *This = ACTSCRIPT_THIS(iface);
490 FIXME("(%p)->()\n", This);
494 static HRESULT WINAPI JScript_Clone(IActiveScript *iface, IActiveScript **ppscript)
496 JScript *This = ACTSCRIPT_THIS(iface);
497 FIXME("(%p)->()\n", This);
501 #undef ACTSCRIPT_THIS
503 static const IActiveScriptVtbl JScriptVtbl = {
504 JScript_QueryInterface,
507 JScript_SetScriptSite,
508 JScript_GetScriptSite,
509 JScript_SetScriptState,
510 JScript_GetScriptState,
512 JScript_AddNamedItem,
514 JScript_GetScriptDispatch,
515 JScript_GetCurrentScriptThreadID,
516 JScript_GetScriptThreadID,
517 JScript_GetScriptThreadState,
518 JScript_InterruptScriptThread,
522 #define ASPARSE_THIS(iface) DEFINE_THIS(JScript, IActiveScriptParse, iface)
524 static HRESULT WINAPI JScriptParse_QueryInterface(IActiveScriptParse *iface, REFIID riid, void **ppv)
526 JScript *This = ASPARSE_THIS(iface);
527 return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
530 static ULONG WINAPI JScriptParse_AddRef(IActiveScriptParse *iface)
532 JScript *This = ASPARSE_THIS(iface);
533 return IActiveScript_AddRef(ACTSCRIPT(This));
536 static ULONG WINAPI JScriptParse_Release(IActiveScriptParse *iface)
538 JScript *This = ASPARSE_THIS(iface);
539 return IActiveScript_Release(ACTSCRIPT(This));
542 static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
544 JScript *This = ASPARSE_THIS(iface);
547 TRACE("(%p)\n", This);
552 ctx = heap_alloc_zero(sizeof(script_ctx_t));
554 return E_OUTOFMEMORY;
557 ctx->state = SCRIPTSTATE_UNINITIALIZED;
558 jsheap_init(&ctx->tmp_heap);
560 ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL);
566 return This->site ? set_ctx_site(This) : S_OK;
569 static HRESULT WINAPI JScriptParse_AddScriptlet(IActiveScriptParse *iface,
570 LPCOLESTR pstrDefaultName, LPCOLESTR pstrCode, LPCOLESTR pstrItemName,
571 LPCOLESTR pstrSubItemName, LPCOLESTR pstrEventName, LPCOLESTR pstrDelimiter,
572 CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags,
573 BSTR *pbstrName, EXCEPINFO *pexcepinfo)
575 JScript *This = ASPARSE_THIS(iface);
576 FIXME("(%p)->(%s %s %s %s %s %s %s %u %x %p %p)\n", This, debugstr_w(pstrDefaultName),
577 debugstr_w(pstrCode), debugstr_w(pstrItemName), debugstr_w(pstrSubItemName),
578 debugstr_w(pstrEventName), debugstr_w(pstrDelimiter), wine_dbgstr_longlong(dwSourceContextCookie),
579 ulStartingLineNumber, dwFlags, pbstrName, pexcepinfo);
583 static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
584 LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
585 LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine,
586 DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
588 JScript *This = ASPARSE_THIS(iface);
589 parser_ctx_t *parser_ctx;
592 TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode),
593 debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
594 wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo);
596 if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
599 hres = script_parse(This->ctx, pstrCode, &parser_ctx);
603 if(!is_started(This->ctx)) {
605 This->queue_tail = This->queue_tail->next = parser_ctx;
607 This->queue_head = This->queue_tail = parser_ctx;
611 hres = exec_global_code(This, parser_ctx);
612 parser_release(parser_ctx);
619 static const IActiveScriptParseVtbl JScriptParseVtbl = {
620 JScriptParse_QueryInterface,
622 JScriptParse_Release,
623 JScriptParse_InitNew,
624 JScriptParse_AddScriptlet,
625 JScriptParse_ParseScriptText
628 #define ASPARSEPROC_THIS(iface) DEFINE_THIS(JScript, IActiveScriptParseProcedure2, iface)
630 static HRESULT WINAPI JScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2 *iface, REFIID riid, void **ppv)
632 JScript *This = ASPARSEPROC_THIS(iface);
633 return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
636 static ULONG WINAPI JScriptParseProcedure_AddRef(IActiveScriptParseProcedure2 *iface)
638 JScript *This = ASPARSEPROC_THIS(iface);
639 return IActiveScript_AddRef(ACTSCRIPT(This));
642 static ULONG WINAPI JScriptParseProcedure_Release(IActiveScriptParseProcedure2 *iface)
644 JScript *This = ASPARSEPROC_THIS(iface);
645 return IActiveScript_Release(ACTSCRIPT(This));
648 static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2 *iface,
649 LPCOLESTR pstrCode, LPCOLESTR pstrFormalParams, LPCOLESTR pstrProcedureName,
650 LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter,
651 CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, IDispatch **ppdisp)
653 JScript *This = ASPARSEPROC_THIS(iface);
654 parser_ctx_t *parser_ctx;
658 TRACE("(%p)->(%s %s %s %s %p %s %s %u %x %p)\n", This, debugstr_w(pstrCode), debugstr_w(pstrFormalParams),
659 debugstr_w(pstrProcedureName), debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
660 wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLineNumber, dwFlags, ppdisp);
662 if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
665 hres = script_parse(This->ctx, pstrCode, &parser_ctx);
667 WARN("Parse failed %08x\n", hres);
671 hres = create_source_function(parser_ctx, NULL, parser_ctx->source, NULL, NULL, 0, &dispex);
672 parser_release(parser_ctx);
676 *ppdisp = (IDispatch*)_IDispatchEx_(dispex);
680 #undef ASPARSEPROC_THIS
682 static const IActiveScriptParseProcedure2Vtbl JScriptParseProcedureVtbl = {
683 JScriptParseProcedure_QueryInterface,
684 JScriptParseProcedure_AddRef,
685 JScriptParseProcedure_Release,
686 JScriptParseProcedure_ParseProcedureText,
689 #define ACTSCPPROP_THIS(iface) DEFINE_THIS(JScript, IActiveScriptProperty, iface)
691 static HRESULT WINAPI JScriptProperty_QueryInterface(IActiveScriptProperty *iface, REFIID riid, void **ppv)
693 JScript *This = ACTSCPPROP_THIS(iface);
694 return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
697 static ULONG WINAPI JScriptProperty_AddRef(IActiveScriptProperty *iface)
699 JScript *This = ACTSCPPROP_THIS(iface);
700 return IActiveScript_AddRef(ACTSCRIPT(This));
703 static ULONG WINAPI JScriptProperty_Release(IActiveScriptProperty *iface)
705 JScript *This = ACTSCPPROP_THIS(iface);
706 return IActiveScript_Release(ACTSCRIPT(This));
709 static HRESULT WINAPI JScriptProperty_GetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
710 VARIANT *pvarIndex, VARIANT *pvarValue)
712 JScript *This = ACTSCPPROP_THIS(iface);
713 FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue);
717 static HRESULT WINAPI JScriptProperty_SetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
718 VARIANT *pvarIndex, VARIANT *pvarValue)
720 JScript *This = ACTSCPPROP_THIS(iface);
721 FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue);
725 #undef ACTSCPPROP_THIS
727 static const IActiveScriptPropertyVtbl JScriptPropertyVtbl = {
728 JScriptProperty_QueryInterface,
729 JScriptProperty_AddRef,
730 JScriptProperty_Release,
731 JScriptProperty_GetProperty,
732 JScriptProperty_SetProperty
735 #define OBJSAFETY_THIS(iface) DEFINE_THIS(JScript, IObjectSafety, iface)
737 static HRESULT WINAPI JScriptSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
739 JScript *This = OBJSAFETY_THIS(iface);
740 return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
743 static ULONG WINAPI JScriptSafety_AddRef(IObjectSafety *iface)
745 JScript *This = OBJSAFETY_THIS(iface);
746 return IActiveScript_AddRef(ACTSCRIPT(This));
749 static ULONG WINAPI JScriptSafety_Release(IObjectSafety *iface)
751 JScript *This = OBJSAFETY_THIS(iface);
752 return IActiveScript_Release(ACTSCRIPT(This));
755 #define SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER)
757 static HRESULT WINAPI JScriptSafety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
758 DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
760 JScript *This = OBJSAFETY_THIS(iface);
762 TRACE("(%p)->(%s %p %p)\n", This, debugstr_guid(riid), pdwSupportedOptions, pdwEnabledOptions);
764 if(!pdwSupportedOptions || !pdwEnabledOptions)
767 *pdwSupportedOptions = SUPPORTED_OPTIONS;
768 *pdwEnabledOptions = This->safeopt;
773 static HRESULT WINAPI JScriptSafety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
774 DWORD dwOptionSetMask, DWORD dwEnabledOptions)
776 JScript *This = OBJSAFETY_THIS(iface);
778 TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions);
780 if(dwOptionSetMask & ~SUPPORTED_OPTIONS)
783 This->safeopt = dwEnabledOptions & dwEnabledOptions;
787 #undef OBJSAFETY_THIS
789 static const IObjectSafetyVtbl JScriptSafetyVtbl = {
790 JScriptSafety_QueryInterface,
791 JScriptSafety_AddRef,
792 JScriptSafety_Release,
793 JScriptSafety_GetInterfaceSafetyOptions,
794 JScriptSafety_SetInterfaceSafetyOptions
797 HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
798 REFIID riid, void **ppv)
803 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
807 ret = heap_alloc_zero(sizeof(*ret));
809 return E_OUTOFMEMORY;
811 ret->lpIActiveScriptVtbl = &JScriptVtbl;
812 ret->lpIActiveScriptParseVtbl = &JScriptParseVtbl;
813 ret->lpIActiveScriptParseProcedure2Vtbl = &JScriptParseProcedureVtbl;
814 ret->lpIActiveScriptPropertyVtbl = &JScriptPropertyVtbl;
815 ret->lpIObjectSafetyVtbl = &JScriptSafetyVtbl;
817 ret->safeopt = INTERFACE_USES_DISPEX;
819 hres = IActiveScript_QueryInterface(ACTSCRIPT(ret), riid, ppv);
820 IActiveScript_Release(ACTSCRIPT(ret));