Commit 7edaff43 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added IActiveScript::InitNew implementation.

parent c35745d4
...@@ -50,11 +50,41 @@ struct VBScript { ...@@ -50,11 +50,41 @@ struct VBScript {
LONG ref; LONG ref;
SCRIPTSTATE state;
IActiveScriptSite *site; IActiveScriptSite *site;
script_ctx_t *ctx;
LONG thread_id; LONG thread_id;
LCID lcid; LCID lcid;
}; };
static void change_state(VBScript *This, SCRIPTSTATE state)
{
if(This->state == state)
return;
This->state = state;
if(This->site)
IActiveScriptSite_OnStateChange(This->site, state);
}
static HRESULT set_ctx_site(VBScript *This)
{
This->ctx->lcid = This->lcid;
IActiveScriptSite_AddRef(This->site);
This->ctx->site = This->site;
change_state(This, SCRIPTSTATE_INITIALIZED);
return S_OK;
}
static void destroy_script(script_ctx_t *ctx)
{
if(ctx->site)
IActiveScriptSite_Release(ctx->site);
heap_free(ctx);
}
static inline VBScript *impl_from_IActiveScript(IActiveScript *iface) static inline VBScript *impl_from_IActiveScript(IActiveScript *iface)
{ {
return CONTAINING_RECORD(iface, VBScript, IActiveScript_iface); return CONTAINING_RECORD(iface, VBScript, IActiveScript_iface);
...@@ -133,7 +163,7 @@ static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScript ...@@ -133,7 +163,7 @@ static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScript
if(hres == S_OK) if(hres == S_OK)
This->lcid = lcid; This->lcid = lcid;
return S_OK; return This->ctx ? set_ctx_site(This) : S_OK;
} }
static HRESULT WINAPI VBScript_GetScriptSite(IActiveScript *iface, REFIID riid, static HRESULT WINAPI VBScript_GetScriptSite(IActiveScript *iface, REFIID riid,
...@@ -271,8 +301,24 @@ static ULONG WINAPI VBScriptParse_Release(IActiveScriptParse *iface) ...@@ -271,8 +301,24 @@ static ULONG WINAPI VBScriptParse_Release(IActiveScriptParse *iface)
static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface) static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface)
{ {
VBScript *This = impl_from_IActiveScriptParse(iface); VBScript *This = impl_from_IActiveScriptParse(iface);
FIXME("(%p)\n", This); script_ctx_t *ctx;
return S_OK;
TRACE("(%p)\n", This);
if(This->ctx)
return E_UNEXPECTED;
ctx = heap_alloc_zero(sizeof(script_ctx_t));
if(!ctx)
return E_OUTOFMEMORY;
ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL);
if(ctx) {
destroy_script(ctx);
return E_UNEXPECTED;
}
return This->site ? set_ctx_site(This) : S_OK;
} }
static HRESULT WINAPI VBScriptParse_AddScriptlet(IActiveScriptParse *iface, static HRESULT WINAPI VBScriptParse_AddScriptlet(IActiveScriptParse *iface,
...@@ -325,6 +371,7 @@ HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pU ...@@ -325,6 +371,7 @@ HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pU
ret->IActiveScriptParse_iface.lpVtbl = &VBScriptParseVtbl; ret->IActiveScriptParse_iface.lpVtbl = &VBScriptParseVtbl;
ret->ref = 1; ret->ref = 1;
ret->state = SCRIPTSTATE_UNINITIALIZED;
hres = IActiveScript_QueryInterface(&ret->IActiveScript_iface, riid, ppv); hres = IActiveScript_QueryInterface(&ret->IActiveScript_iface, riid, ppv);
IActiveScript_Release(&ret->IActiveScript_iface); IActiveScript_Release(&ret->IActiveScript_iface);
......
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
#include "activscp.h" #include "activscp.h"
#include "vbscript_classes.h" #include "vbscript_classes.h"
typedef struct {
IActiveScriptSite *site;
LCID lcid;
} script_ctx_t;
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**); HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**);
static inline void *heap_alloc(size_t len) static inline void *heap_alloc(size_t len)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment