2008-03-16 21:10:13 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "jscript.h"
|
2008-09-03 00:25:21 +02:00
|
|
|
#include "engine.h"
|
2008-03-21 13:03:07 +01:00
|
|
|
#include "objsafe.h"
|
2008-03-16 21:10:13 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
|
|
|
|
|
2009-02-02 15:27:24 +01:00
|
|
|
#ifdef _WIN64
|
|
|
|
|
|
|
|
#define CTXARG_T DWORDLONG
|
|
|
|
#define IActiveScriptParseVtbl IActiveScriptParse64Vtbl
|
2009-02-09 21:11:36 +01:00
|
|
|
#define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_64Vtbl
|
2009-02-02 15:27:24 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define CTXARG_T DWORD
|
|
|
|
#define IActiveScriptParseVtbl IActiveScriptParse32Vtbl
|
2009-02-09 21:11:36 +01:00
|
|
|
#define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_32Vtbl
|
2009-02-02 15:27:24 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-03-16 21:10:13 +01:00
|
|
|
typedef struct {
|
2008-03-21 13:02:46 +01:00
|
|
|
const IActiveScriptVtbl *lpIActiveScriptVtbl;
|
|
|
|
const IActiveScriptParseVtbl *lpIActiveScriptParseVtbl;
|
|
|
|
const IActiveScriptParseProcedure2Vtbl *lpIActiveScriptParseProcedure2Vtbl;
|
|
|
|
const IActiveScriptPropertyVtbl *lpIActiveScriptPropertyVtbl;
|
2008-03-21 13:03:07 +01:00
|
|
|
const IObjectSafetyVtbl *lpIObjectSafetyVtbl;
|
2008-03-16 21:10:13 +01:00
|
|
|
|
|
|
|
LONG ref;
|
2008-04-07 12:35:41 +02:00
|
|
|
|
|
|
|
DWORD safeopt;
|
2008-09-01 01:23:16 +02:00
|
|
|
script_ctx_t *ctx;
|
2008-09-01 01:17:14 +02:00
|
|
|
LONG thread_id;
|
2008-11-05 01:03:03 +01:00
|
|
|
LCID lcid;
|
2009-10-19 20:39:24 +02:00
|
|
|
DWORD version;
|
2008-09-01 01:17:14 +02:00
|
|
|
|
|
|
|
IActiveScriptSite *site;
|
2008-09-05 02:37:59 +02:00
|
|
|
|
|
|
|
parser_ctx_t *queue_head;
|
|
|
|
parser_ctx_t *queue_tail;
|
2008-03-16 21:10:13 +01:00
|
|
|
} JScript;
|
|
|
|
|
2009-02-02 11:01:02 +01:00
|
|
|
#define ACTSCRIPT(x) ((IActiveScript*) &(x)->lpIActiveScriptVtbl)
|
|
|
|
#define ASPARSE(x) (&(x)->lpIActiveScriptParseVtbl)
|
|
|
|
#define ASPARSEPROC(x) (&(x)->lpIActiveScriptParseProcedure2Vtbl)
|
|
|
|
#define ACTSCPPROP(x) (&(x)->lpIActiveScriptPropertyVtbl)
|
|
|
|
#define OBJSAFETY(x) (&(x)->lpIObjectSafetyVtbl)
|
2008-03-16 21:10:13 +01:00
|
|
|
|
2008-09-01 01:23:16 +02:00
|
|
|
void script_release(script_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
if(--ctx->ref)
|
|
|
|
return;
|
|
|
|
|
2008-09-15 20:38:46 +02:00
|
|
|
jsheap_free(&ctx->tmp_heap);
|
2010-05-26 19:18:18 +02:00
|
|
|
SysFreeString(ctx->last_match);
|
2008-09-01 01:23:16 +02:00
|
|
|
heap_free(ctx);
|
|
|
|
}
|
|
|
|
|
2008-09-01 01:17:14 +02:00
|
|
|
static void change_state(JScript *This, SCRIPTSTATE state)
|
|
|
|
{
|
|
|
|
if(This->ctx->state == state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
This->ctx->state = state;
|
|
|
|
IActiveScriptSite_OnStateChange(This->site, state);
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:37:59 +02:00
|
|
|
static inline BOOL is_started(script_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
return ctx->state == SCRIPTSTATE_STARTED
|
|
|
|
|| ctx->state == SCRIPTSTATE_CONNECTED
|
|
|
|
|| ctx->state == SCRIPTSTATE_DISCONNECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx)
|
|
|
|
{
|
|
|
|
exec_ctx_t *exec_ctx;
|
|
|
|
jsexcept_t jsexcept;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, &exec_ctx);
|
2008-09-05 02:37:59 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
IActiveScriptSite_OnEnterScript(This->site);
|
|
|
|
|
|
|
|
memset(&jsexcept, 0, sizeof(jsexcept));
|
2009-12-01 14:52:43 +01:00
|
|
|
hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, EXECT_PROGRAM, &jsexcept, NULL);
|
2008-09-05 02:37:59 +02:00
|
|
|
VariantClear(&jsexcept.var);
|
|
|
|
exec_release(exec_ctx);
|
|
|
|
|
|
|
|
IActiveScriptSite_OnLeaveScript(This->site);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clear_script_queue(JScript *This)
|
|
|
|
{
|
|
|
|
parser_ctx_t *iter, *iter2;
|
|
|
|
|
|
|
|
if(!This->queue_head)
|
|
|
|
return;
|
|
|
|
|
|
|
|
iter = This->queue_head;
|
|
|
|
while(iter) {
|
|
|
|
iter2 = iter->next;
|
|
|
|
iter->next = NULL;
|
|
|
|
parser_release(iter);
|
|
|
|
iter = iter2;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->queue_head = This->queue_tail = NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:38:17 +02:00
|
|
|
static void exec_queued_code(JScript *This)
|
|
|
|
{
|
|
|
|
parser_ctx_t *iter;
|
|
|
|
|
|
|
|
for(iter = This->queue_head; iter; iter = iter->next)
|
|
|
|
exec_global_code(This, iter);
|
|
|
|
|
|
|
|
clear_script_queue(This);
|
|
|
|
}
|
|
|
|
|
2008-11-05 01:03:03 +01:00
|
|
|
static HRESULT set_ctx_site(JScript *This)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
This->ctx->lcid = This->lcid;
|
|
|
|
|
|
|
|
hres = init_global(This->ctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2008-12-15 22:24:33 +01:00
|
|
|
IActiveScriptSite_AddRef(This->site);
|
|
|
|
This->ctx->site = This->site;
|
|
|
|
|
2008-11-05 01:03:03 +01:00
|
|
|
change_state(This, SCRIPTSTATE_INITIALIZED);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-06 21:23:14 +02:00
|
|
|
typedef struct {
|
|
|
|
const IServiceProviderVtbl *lpIServiceProviderVtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IServiceProvider *sp;
|
|
|
|
} AXSite;
|
|
|
|
|
|
|
|
#define SERVPROV(x) ((IServiceProvider*) &(x)->lpIServiceProviderVtbl)
|
|
|
|
|
|
|
|
#define SERVPROV_THIS(iface) DEFINE_THIS(AXSite, IServiceProvider, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI AXSite_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AXSite *This = SERVPROV_THIS(iface);
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = SERVPROV(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
|
|
|
|
*ppv = SERVPROV(This);
|
|
|
|
}else {
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AXSite_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
AXSite *This = SERVPROV_THIS(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AXSite_Release(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
AXSite *This = SERVPROV_THIS(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref)
|
|
|
|
heap_free(This);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AXSite_QueryService(IServiceProvider *iface,
|
|
|
|
REFGUID guidService, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AXSite *This = SERVPROV_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
return IServiceProvider_QueryService(This->sp, guidService, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef SERVPROV_THIS
|
|
|
|
|
|
|
|
static IServiceProviderVtbl AXSiteVtbl = {
|
|
|
|
AXSite_QueryInterface,
|
|
|
|
AXSite_AddRef,
|
|
|
|
AXSite_Release,
|
|
|
|
AXSite_QueryService
|
|
|
|
};
|
|
|
|
|
|
|
|
IUnknown *create_ax_site(script_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
IServiceProvider *sp;
|
|
|
|
AXSite *ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("Could not get IServiceProvider iface: %08x\n", hres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = heap_alloc(sizeof(AXSite));
|
|
|
|
if(!ret) {
|
|
|
|
IServiceProvider_Release(sp);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->lpIServiceProviderVtbl = &AXSiteVtbl;
|
|
|
|
ret->ref = 1;
|
|
|
|
ret->sp = sp;
|
|
|
|
|
|
|
|
return (IUnknown*)SERVPROV(ret);
|
|
|
|
}
|
|
|
|
|
2008-03-16 21:10:13 +01:00
|
|
|
#define ACTSCRIPT_THIS(iface) DEFINE_THIS(JScript, IActiveScript, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = ACTSCRIPT(This);
|
|
|
|
}else if(IsEqualGUID(riid, &IID_IActiveScript)) {
|
|
|
|
TRACE("(%p)->(IID_IActiveScript %p)\n", This, ppv);
|
|
|
|
*ppv = ACTSCRIPT(This);
|
2008-03-19 11:31:36 +01:00
|
|
|
}else if(IsEqualGUID(riid, &IID_IActiveScriptParse)) {
|
|
|
|
TRACE("(%p)->(IID_IActiveScriptParse %p)\n", This, ppv);
|
|
|
|
*ppv = ASPARSE(This);
|
2008-03-21 13:02:46 +01:00
|
|
|
}else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure)) {
|
|
|
|
TRACE("(%p)->(IID_IActiveScriptParseProcedure %p)\n", This, ppv);
|
|
|
|
*ppv = ASPARSEPROC(This);
|
|
|
|
}else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure2)) {
|
|
|
|
TRACE("(%p)->(IID_IActiveScriptParseProcedure2 %p)\n", This, ppv);
|
|
|
|
*ppv = ASPARSEPROC(This);
|
2008-03-19 11:31:54 +01:00
|
|
|
}else if(IsEqualGUID(riid, &IID_IActiveScriptProperty)) {
|
|
|
|
TRACE("(%p)->(IID_IActiveScriptProperty %p)\n", This, ppv);
|
|
|
|
*ppv = ACTSCPPROP(This);
|
2008-03-21 13:03:07 +01:00
|
|
|
}else if(IsEqualGUID(riid, &IID_IObjectSafety)) {
|
|
|
|
TRACE("(%p)->(IID_IObjectSafety %p)\n", This, ppv);
|
|
|
|
*ppv = OBJSAFETY(This);
|
2008-03-16 21:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScript_AddRef(IActiveScript *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScript_Release(IActiveScript *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", iface, ref);
|
|
|
|
|
2008-03-24 21:53:34 +01:00
|
|
|
if(!ref) {
|
2008-09-01 01:17:53 +02:00
|
|
|
if(This->ctx && This->ctx->state != SCRIPTSTATE_CLOSED)
|
|
|
|
IActiveScript_Close(ACTSCRIPT(This));
|
2008-09-01 01:23:16 +02:00
|
|
|
if(This->ctx)
|
|
|
|
script_release(This->ctx);
|
2008-03-16 21:10:13 +01:00
|
|
|
heap_free(This);
|
2008-03-24 21:53:34 +01:00
|
|
|
unlock_module();
|
|
|
|
}
|
2008-03-16 21:10:13 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface,
|
|
|
|
IActiveScriptSite *pass)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
2008-09-01 01:17:14 +02:00
|
|
|
LCID lcid;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pass);
|
|
|
|
|
|
|
|
if(!pass)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if(This->site)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
if(InterlockedCompareExchange(&This->thread_id, GetCurrentThreadId(), 0))
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
This->site = pass;
|
|
|
|
IActiveScriptSite_AddRef(This->site);
|
|
|
|
|
|
|
|
hres = IActiveScriptSite_GetLCID(This->site, &lcid);
|
|
|
|
if(hres == S_OK)
|
2008-11-21 19:33:03 +01:00
|
|
|
This->lcid = lcid;
|
2008-09-01 01:17:14 +02:00
|
|
|
|
2008-11-05 01:03:03 +01:00
|
|
|
return This->ctx ? set_ctx_site(This) : S_OK;
|
2008-03-16 21:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_GetScriptSite(IActiveScript *iface, REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
2008-09-05 02:38:17 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ss);
|
|
|
|
|
|
|
|
if(!This->ctx || GetCurrentThreadId() != This->thread_id)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
switch(ss) {
|
|
|
|
case SCRIPTSTATE_STARTED:
|
2008-11-05 01:03:19 +01:00
|
|
|
case SCRIPTSTATE_CONNECTED: /* FIXME */
|
2008-09-05 02:38:17 +02:00
|
|
|
if(This->ctx->state == SCRIPTSTATE_CLOSED)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
exec_queued_code(This);
|
|
|
|
break;
|
2010-07-27 15:51:29 +02:00
|
|
|
case SCRIPTSTATE_INITIALIZED:
|
|
|
|
FIXME("unimplemented SCRIPTSTATE_INITIALIZED\n");
|
|
|
|
return S_OK;
|
2008-09-05 02:38:17 +02:00
|
|
|
default:
|
|
|
|
FIXME("unimplemented state %d\n", ss);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
change_state(This, ss);
|
|
|
|
return S_OK;
|
2008-03-16 21:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
2008-09-01 01:25:29 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pssState);
|
|
|
|
|
|
|
|
if(!pssState)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if(!This->thread_id) {
|
|
|
|
*pssState = SCRIPTSTATE_UNINITIALIZED;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->thread_id != GetCurrentThreadId())
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
*pssState = This->ctx ? This->ctx->state : SCRIPTSTATE_UNINITIALIZED;
|
|
|
|
return S_OK;
|
2008-03-16 21:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_Close(IActiveScript *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
2008-09-01 01:17:53 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
|
|
|
if(This->thread_id != GetCurrentThreadId())
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
2008-10-14 09:59:33 +02:00
|
|
|
if(This->ctx) {
|
2008-11-05 01:03:19 +01:00
|
|
|
if(This->ctx->state == SCRIPTSTATE_CONNECTED)
|
|
|
|
change_state(This, SCRIPTSTATE_DISCONNECTED);
|
|
|
|
|
|
|
|
clear_script_queue(This);
|
|
|
|
|
|
|
|
if(This->ctx->state == SCRIPTSTATE_DISCONNECTED)
|
|
|
|
change_state(This, SCRIPTSTATE_INITIALIZED);
|
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
if(This->ctx->host_global) {
|
|
|
|
IDispatch_Release(This->ctx->host_global);
|
|
|
|
This->ctx->host_global = NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-14 09:59:33 +02:00
|
|
|
if(This->ctx->named_items) {
|
|
|
|
named_item_t *iter, *iter2;
|
2008-09-10 21:09:29 +02:00
|
|
|
|
2008-10-14 09:59:33 +02:00
|
|
|
iter = This->ctx->named_items;
|
|
|
|
while(iter) {
|
|
|
|
iter2 = iter->next;
|
2008-09-10 21:09:29 +02:00
|
|
|
|
2008-12-15 22:24:33 +01:00
|
|
|
if(iter->disp)
|
|
|
|
IDispatch_Release(iter->disp);
|
2008-11-05 01:03:38 +01:00
|
|
|
heap_free(iter->name);
|
2008-10-14 09:59:33 +02:00
|
|
|
heap_free(iter);
|
|
|
|
iter = iter2;
|
|
|
|
}
|
2008-09-10 21:09:29 +02:00
|
|
|
|
2008-10-14 09:59:33 +02:00
|
|
|
This->ctx->named_items = NULL;
|
|
|
|
}
|
2008-09-10 21:09:29 +02:00
|
|
|
|
2009-09-30 14:34:47 +02:00
|
|
|
if(This->ctx->secmgr) {
|
|
|
|
IInternetHostSecurityManager_Release(This->ctx->secmgr);
|
|
|
|
This->ctx->secmgr = NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-15 22:24:33 +01:00
|
|
|
if(This->ctx->site) {
|
|
|
|
IActiveScriptSite_Release(This->ctx->site);
|
|
|
|
This->ctx->site = NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-14 09:59:33 +02:00
|
|
|
if (This->site)
|
|
|
|
change_state(This, SCRIPTSTATE_CLOSED);
|
2008-09-01 01:17:53 +02:00
|
|
|
|
2008-09-09 01:22:54 +02:00
|
|
|
if(This->ctx->global) {
|
2009-09-01 13:26:08 +02:00
|
|
|
jsdisp_release(This->ctx->global);
|
2008-09-09 01:22:54 +02:00
|
|
|
This->ctx->global = NULL;
|
|
|
|
}
|
2008-09-01 01:23:38 +02:00
|
|
|
}
|
|
|
|
|
2008-09-01 01:17:53 +02:00
|
|
|
if(This->site) {
|
|
|
|
IActiveScriptSite_Release(This->site);
|
|
|
|
This->site = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2008-03-16 21:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface,
|
|
|
|
LPCOLESTR pstrName, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
2008-09-09 01:22:31 +02:00
|
|
|
named_item_t *item;
|
2008-12-15 22:24:33 +01:00
|
|
|
IDispatch *disp = NULL;
|
2008-09-09 01:22:31 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %x)\n", This, debugstr_w(pstrName), dwFlags);
|
|
|
|
|
|
|
|
if(This->thread_id != GetCurrentThreadId() || !This->ctx || This->ctx->state == SCRIPTSTATE_CLOSED)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
2008-12-15 22:24:33 +01:00
|
|
|
if(dwFlags & SCRIPTITEM_GLOBALMEMBERS) {
|
|
|
|
IUnknown *unk;
|
2008-09-09 01:22:31 +02:00
|
|
|
|
2008-12-15 22:24:33 +01:00
|
|
|
hres = IActiveScriptSite_GetItemInfo(This->site, pstrName, SCRIPTINFO_IUNKNOWN, &unk, NULL);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("GetItemInfo failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&disp);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("object does not implement IDispatch\n");
|
|
|
|
return hres;
|
|
|
|
}
|
2009-09-27 20:59:28 +02:00
|
|
|
|
|
|
|
if(This->ctx->host_global)
|
|
|
|
IDispatch_Release(This->ctx->host_global);
|
|
|
|
IDispatch_AddRef(disp);
|
|
|
|
This->ctx->host_global = disp;
|
2008-09-09 01:22:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
item = heap_alloc(sizeof(*item));
|
|
|
|
if(!item) {
|
2008-12-15 22:24:33 +01:00
|
|
|
if(disp)
|
|
|
|
IDispatch_Release(disp);
|
2008-09-09 01:22:31 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->disp = disp;
|
|
|
|
item->flags = dwFlags;
|
2008-11-05 01:03:38 +01:00
|
|
|
item->name = heap_strdupW(pstrName);
|
|
|
|
if(!item->name) {
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
heap_free(item);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2008-09-09 01:22:31 +02:00
|
|
|
item->next = This->ctx->named_items;
|
|
|
|
This->ctx->named_items = item;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-03-16 21:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_AddTypeLib(IActiveScript *iface, REFGUID rguidTypeLib,
|
|
|
|
DWORD dwMajor, DWORD dwMinor, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR pstrItemName,
|
|
|
|
IDispatch **ppdisp)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
2008-09-01 01:23:38 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppdisp);
|
|
|
|
|
|
|
|
if(!ppdisp)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
if(This->thread_id != GetCurrentThreadId() || !This->ctx->global) {
|
2008-09-01 01:23:38 +02:00
|
|
|
*ppdisp = NULL;
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2009-09-27 20:59:28 +02:00
|
|
|
*ppdisp = (IDispatch*)_IDispatchEx_(This->ctx->global);
|
2008-09-01 01:23:38 +02:00
|
|
|
IDispatch_AddRef(*ppdisp);
|
|
|
|
return S_OK;
|
2008-03-16 21:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_GetCurrentScriptThreadID(IActiveScript *iface,
|
|
|
|
SCRIPTTHREADID *pstridThread)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_GetScriptThreadID(IActiveScript *iface,
|
|
|
|
DWORD dwWin32ThreadId, SCRIPTTHREADID *pstidThread)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_GetScriptThreadState(IActiveScript *iface,
|
|
|
|
SCRIPTTHREADID stidThread, SCRIPTTHREADSTATE *pstsState)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_InterruptScriptThread(IActiveScript *iface,
|
|
|
|
SCRIPTTHREADID stidThread, const EXCEPINFO *pexcepinfo, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScript_Clone(IActiveScript *iface, IActiveScript **ppscript)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCRIPT_THIS(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef ACTSCRIPT_THIS
|
|
|
|
|
|
|
|
static const IActiveScriptVtbl JScriptVtbl = {
|
|
|
|
JScript_QueryInterface,
|
|
|
|
JScript_AddRef,
|
|
|
|
JScript_Release,
|
|
|
|
JScript_SetScriptSite,
|
|
|
|
JScript_GetScriptSite,
|
|
|
|
JScript_SetScriptState,
|
|
|
|
JScript_GetScriptState,
|
|
|
|
JScript_Close,
|
|
|
|
JScript_AddNamedItem,
|
|
|
|
JScript_AddTypeLib,
|
|
|
|
JScript_GetScriptDispatch,
|
|
|
|
JScript_GetCurrentScriptThreadID,
|
|
|
|
JScript_GetScriptThreadID,
|
|
|
|
JScript_GetScriptThreadState,
|
|
|
|
JScript_InterruptScriptThread,
|
|
|
|
JScript_Clone
|
|
|
|
};
|
|
|
|
|
2008-03-19 11:31:36 +01:00
|
|
|
#define ASPARSE_THIS(iface) DEFINE_THIS(JScript, IActiveScriptParse, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptParse_QueryInterface(IActiveScriptParse *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSE_THIS(iface);
|
|
|
|
return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScriptParse_AddRef(IActiveScriptParse *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSE_THIS(iface);
|
|
|
|
return IActiveScript_AddRef(ACTSCRIPT(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScriptParse_Release(IActiveScriptParse *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSE_THIS(iface);
|
|
|
|
return IActiveScript_Release(ACTSCRIPT(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSE_THIS(iface);
|
2008-09-01 01:23:16 +02:00
|
|
|
script_ctx_t *ctx;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if(This->ctx)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
ctx = heap_alloc_zero(sizeof(script_ctx_t));
|
|
|
|
if(!ctx)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ctx->ref = 1;
|
|
|
|
ctx->state = SCRIPTSTATE_UNINITIALIZED;
|
2009-09-30 14:34:47 +02:00
|
|
|
ctx->safeopt = This->safeopt;
|
2009-10-19 20:39:24 +02:00
|
|
|
ctx->version = This->version;
|
2008-09-15 20:38:46 +02:00
|
|
|
jsheap_init(&ctx->tmp_heap);
|
2008-09-01 01:23:16 +02:00
|
|
|
|
|
|
|
ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL);
|
|
|
|
if(ctx) {
|
|
|
|
script_release(ctx);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2008-11-05 01:03:03 +01:00
|
|
|
return This->site ? set_ctx_site(This) : S_OK;
|
2008-03-19 11:31:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptParse_AddScriptlet(IActiveScriptParse *iface,
|
|
|
|
LPCOLESTR pstrDefaultName, LPCOLESTR pstrCode, LPCOLESTR pstrItemName,
|
|
|
|
LPCOLESTR pstrSubItemName, LPCOLESTR pstrEventName, LPCOLESTR pstrDelimiter,
|
2009-02-02 15:27:24 +01:00
|
|
|
CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags,
|
2008-03-19 11:31:36 +01:00
|
|
|
BSTR *pbstrName, EXCEPINFO *pexcepinfo)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSE_THIS(iface);
|
2009-02-02 15:27:24 +01:00
|
|
|
FIXME("(%p)->(%s %s %s %s %s %s %s %u %x %p %p)\n", This, debugstr_w(pstrDefaultName),
|
2008-03-19 11:31:36 +01:00
|
|
|
debugstr_w(pstrCode), debugstr_w(pstrItemName), debugstr_w(pstrSubItemName),
|
2009-02-02 15:27:24 +01:00
|
|
|
debugstr_w(pstrEventName), debugstr_w(pstrDelimiter), wine_dbgstr_longlong(dwSourceContextCookie),
|
2008-03-19 11:31:36 +01:00
|
|
|
ulStartingLineNumber, dwFlags, pbstrName, pexcepinfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
|
|
|
LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
|
2009-02-02 15:27:24 +01:00
|
|
|
LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine,
|
2008-03-19 11:31:36 +01:00
|
|
|
DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSE_THIS(iface);
|
2008-09-03 00:25:21 +02:00
|
|
|
parser_ctx_t *parser_ctx;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2009-02-02 15:27:24 +01:00
|
|
|
TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode),
|
2008-03-19 11:31:36 +01:00
|
|
|
debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
|
2009-02-02 15:27:24 +01:00
|
|
|
wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo);
|
2008-09-03 00:25:21 +02:00
|
|
|
|
2008-09-05 02:37:59 +02:00
|
|
|
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
2009-04-09 23:34:26 +02:00
|
|
|
hres = script_parse(This->ctx, pstrCode, pstrDelimiter, &parser_ctx);
|
2008-09-03 00:25:21 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2008-09-05 02:37:59 +02:00
|
|
|
if(!is_started(This->ctx)) {
|
|
|
|
if(This->queue_tail)
|
|
|
|
This->queue_tail = This->queue_tail->next = parser_ctx;
|
|
|
|
else
|
|
|
|
This->queue_head = This->queue_tail = parser_ctx;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = exec_global_code(This, parser_ctx);
|
2008-09-03 00:25:21 +02:00
|
|
|
parser_release(parser_ctx);
|
2008-09-05 02:37:59 +02:00
|
|
|
|
|
|
|
return hres;
|
2008-03-19 11:31:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef ASPARSE_THIS
|
|
|
|
|
|
|
|
static const IActiveScriptParseVtbl JScriptParseVtbl = {
|
|
|
|
JScriptParse_QueryInterface,
|
|
|
|
JScriptParse_AddRef,
|
|
|
|
JScriptParse_Release,
|
|
|
|
JScriptParse_InitNew,
|
|
|
|
JScriptParse_AddScriptlet,
|
|
|
|
JScriptParse_ParseScriptText
|
|
|
|
};
|
|
|
|
|
2008-09-10 21:09:48 +02:00
|
|
|
#define ASPARSEPROC_THIS(iface) DEFINE_THIS(JScript, IActiveScriptParseProcedure2, iface)
|
2008-03-21 13:02:46 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2 *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSEPROC_THIS(iface);
|
|
|
|
return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScriptParseProcedure_AddRef(IActiveScriptParseProcedure2 *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSEPROC_THIS(iface);
|
|
|
|
return IActiveScript_AddRef(ACTSCRIPT(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScriptParseProcedure_Release(IActiveScriptParseProcedure2 *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ASPARSEPROC_THIS(iface);
|
|
|
|
return IActiveScript_Release(ACTSCRIPT(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2 *iface,
|
|
|
|
LPCOLESTR pstrCode, LPCOLESTR pstrFormalParams, LPCOLESTR pstrProcedureName,
|
|
|
|
LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter,
|
2009-02-09 21:11:36 +01:00
|
|
|
CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, IDispatch **ppdisp)
|
2008-03-21 13:02:46 +01:00
|
|
|
{
|
|
|
|
JScript *This = ASPARSEPROC_THIS(iface);
|
2008-09-10 21:09:48 +02:00
|
|
|
parser_ctx_t *parser_ctx;
|
|
|
|
DispatchEx *dispex;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2009-02-09 21:11:36 +01:00
|
|
|
TRACE("(%p)->(%s %s %s %s %p %s %s %u %x %p)\n", This, debugstr_w(pstrCode), debugstr_w(pstrFormalParams),
|
2008-09-10 21:09:48 +02:00
|
|
|
debugstr_w(pstrProcedureName), debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
|
2009-02-09 21:11:36 +01:00
|
|
|
wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLineNumber, dwFlags, ppdisp);
|
2008-09-10 21:09:48 +02:00
|
|
|
|
|
|
|
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
2009-04-09 23:34:26 +02:00
|
|
|
hres = script_parse(This->ctx, pstrCode, pstrDelimiter, &parser_ctx);
|
2008-09-10 21:09:48 +02:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("Parse failed %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2008-09-21 15:47:47 +02:00
|
|
|
hres = create_source_function(parser_ctx, NULL, parser_ctx->source, NULL, NULL, 0, &dispex);
|
2008-09-10 21:09:48 +02:00
|
|
|
parser_release(parser_ctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*ppdisp = (IDispatch*)_IDispatchEx_(dispex);
|
|
|
|
return S_OK;
|
2008-03-21 13:02:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef ASPARSEPROC_THIS
|
|
|
|
|
|
|
|
static const IActiveScriptParseProcedure2Vtbl JScriptParseProcedureVtbl = {
|
|
|
|
JScriptParseProcedure_QueryInterface,
|
|
|
|
JScriptParseProcedure_AddRef,
|
|
|
|
JScriptParseProcedure_Release,
|
|
|
|
JScriptParseProcedure_ParseProcedureText,
|
|
|
|
};
|
|
|
|
|
2008-03-19 11:31:54 +01:00
|
|
|
#define ACTSCPPROP_THIS(iface) DEFINE_THIS(JScript, IActiveScriptProperty, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptProperty_QueryInterface(IActiveScriptProperty *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCPPROP_THIS(iface);
|
|
|
|
return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScriptProperty_AddRef(IActiveScriptProperty *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCPPROP_THIS(iface);
|
|
|
|
return IActiveScript_AddRef(ACTSCRIPT(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScriptProperty_Release(IActiveScriptProperty *iface)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCPPROP_THIS(iface);
|
|
|
|
return IActiveScript_Release(ACTSCRIPT(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptProperty_GetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
|
|
|
|
VARIANT *pvarIndex, VARIANT *pvarValue)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCPPROP_THIS(iface);
|
|
|
|
FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptProperty_SetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
|
|
|
|
VARIANT *pvarIndex, VARIANT *pvarValue)
|
|
|
|
{
|
|
|
|
JScript *This = ACTSCPPROP_THIS(iface);
|
2009-10-19 20:39:24 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x %s %s)\n", This, dwProperty, debugstr_variant(pvarIndex), debugstr_variant(pvarValue));
|
|
|
|
|
|
|
|
if(pvarIndex)
|
|
|
|
FIXME("unsupported pvarIndex\n");
|
|
|
|
|
|
|
|
switch(dwProperty) {
|
|
|
|
case SCRIPTPROP_INVOKEVERSIONING:
|
|
|
|
if(V_VT(pvarValue) != VT_I4 || V_I4(pvarValue) < 0 || V_I4(pvarValue) > 15) {
|
|
|
|
WARN("invalid value %s\n", debugstr_variant(pvarValue));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->version = V_I4(pvarValue);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unimplemented property %x\n", dwProperty);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2008-03-19 11:31:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef ACTSCPPROP_THIS
|
|
|
|
|
|
|
|
static const IActiveScriptPropertyVtbl JScriptPropertyVtbl = {
|
|
|
|
JScriptProperty_QueryInterface,
|
|
|
|
JScriptProperty_AddRef,
|
|
|
|
JScriptProperty_Release,
|
|
|
|
JScriptProperty_GetProperty,
|
|
|
|
JScriptProperty_SetProperty
|
|
|
|
};
|
|
|
|
|
2008-03-21 13:03:07 +01:00
|
|
|
#define OBJSAFETY_THIS(iface) DEFINE_THIS(JScript, IObjectSafety, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
JScript *This = OBJSAFETY_THIS(iface);
|
|
|
|
return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScriptSafety_AddRef(IObjectSafety *iface)
|
|
|
|
{
|
|
|
|
JScript *This = OBJSAFETY_THIS(iface);
|
|
|
|
return IActiveScript_AddRef(ACTSCRIPT(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI JScriptSafety_Release(IObjectSafety *iface)
|
|
|
|
{
|
|
|
|
JScript *This = OBJSAFETY_THIS(iface);
|
|
|
|
return IActiveScript_Release(ACTSCRIPT(This));
|
|
|
|
}
|
|
|
|
|
2008-04-07 12:35:41 +02:00
|
|
|
#define SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER)
|
|
|
|
|
2008-03-21 13:03:07 +01:00
|
|
|
static HRESULT WINAPI JScriptSafety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
|
|
|
|
DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
|
|
|
|
{
|
|
|
|
JScript *This = OBJSAFETY_THIS(iface);
|
2008-04-07 12:35:41 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %p)\n", This, debugstr_guid(riid), pdwSupportedOptions, pdwEnabledOptions);
|
|
|
|
|
|
|
|
if(!pdwSupportedOptions || !pdwEnabledOptions)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pdwSupportedOptions = SUPPORTED_OPTIONS;
|
|
|
|
*pdwEnabledOptions = This->safeopt;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-03-21 13:03:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JScriptSafety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
|
|
|
|
DWORD dwOptionSetMask, DWORD dwEnabledOptions)
|
|
|
|
{
|
|
|
|
JScript *This = OBJSAFETY_THIS(iface);
|
2008-04-07 12:35:41 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions);
|
|
|
|
|
|
|
|
if(dwOptionSetMask & ~SUPPORTED_OPTIONS)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
This->safeopt = dwEnabledOptions & dwEnabledOptions;
|
2008-03-21 13:03:07 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef OBJSAFETY_THIS
|
|
|
|
|
|
|
|
static const IObjectSafetyVtbl JScriptSafetyVtbl = {
|
|
|
|
JScriptSafety_QueryInterface,
|
|
|
|
JScriptSafety_AddRef,
|
|
|
|
JScriptSafety_Release,
|
|
|
|
JScriptSafety_GetInterfaceSafetyOptions,
|
|
|
|
JScriptSafety_SetInterfaceSafetyOptions
|
|
|
|
};
|
|
|
|
|
2008-03-16 21:10:13 +01:00
|
|
|
HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
JScript *ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
|
|
|
|
|
2008-03-24 21:53:34 +01:00
|
|
|
lock_module();
|
|
|
|
|
2008-09-01 01:23:16 +02:00
|
|
|
ret = heap_alloc_zero(sizeof(*ret));
|
2008-10-06 16:57:20 +02:00
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
2008-03-16 21:10:13 +01:00
|
|
|
|
2008-03-21 13:02:46 +01:00
|
|
|
ret->lpIActiveScriptVtbl = &JScriptVtbl;
|
|
|
|
ret->lpIActiveScriptParseVtbl = &JScriptParseVtbl;
|
|
|
|
ret->lpIActiveScriptParseProcedure2Vtbl = &JScriptParseProcedureVtbl;
|
|
|
|
ret->lpIActiveScriptPropertyVtbl = &JScriptPropertyVtbl;
|
2008-03-21 13:03:07 +01:00
|
|
|
ret->lpIObjectSafetyVtbl = &JScriptSafetyVtbl;
|
2008-03-16 21:10:13 +01:00
|
|
|
ret->ref = 1;
|
2008-04-07 12:35:41 +02:00
|
|
|
ret->safeopt = INTERFACE_USES_DISPEX;
|
2008-03-16 21:10:13 +01:00
|
|
|
|
|
|
|
hres = IActiveScript_QueryInterface(ACTSCRIPT(ret), riid, ppv);
|
|
|
|
IActiveScript_Release(ACTSCRIPT(ret));
|
|
|
|
return hres;
|
|
|
|
}
|