jscript: Added IActiveScriptParse::InitNew implementation.

This commit is contained in:
Jacek Caban 2008-09-01 01:23:16 +02:00 committed by Alexandre Julliard
parent 9e6784c2a7
commit d19cdef8f8
4 changed files with 48 additions and 5 deletions

View File

@ -17,7 +17,6 @@
*/
#include "jscript.h"
#include "activscp.h"
#include "objsafe.h"
#include "wine/debug.h"
@ -34,6 +33,7 @@ typedef struct {
LONG ref;
DWORD safeopt;
script_ctx_t *ctx;
} JScript;
#define ACTSCRIPT(x) ((IActiveScript*) &(x)->lpIActiveScriptVtbl)
@ -42,6 +42,14 @@ typedef struct {
#define ACTSCPPROP(x) ((IActiveScriptProperty*) &(x)->lpIActiveScriptPropertyVtbl)
#define OBJSAFETY(x) ((IObjectSafety*) &(x)->lpIObjectSafetyVtbl)
void script_release(script_ctx_t *ctx)
{
if(--ctx->ref)
return;
heap_free(ctx);
}
#define ACTSCRIPT_THIS(iface) DEFINE_THIS(JScript, IActiveScript, iface)
static HRESULT WINAPI JScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
@ -100,6 +108,8 @@ static ULONG WINAPI JScript_Release(IActiveScript *iface)
TRACE("(%p) ref=%d\n", iface, ref);
if(!ref) {
if(This->ctx)
script_release(This->ctx);
heap_free(This);
unlock_module();
}
@ -251,8 +261,27 @@ static ULONG WINAPI JScriptParse_Release(IActiveScriptParse *iface)
static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
{
JScript *This = ASPARSE_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
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;
ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL);
if(ctx) {
script_release(ctx);
return E_UNEXPECTED;
}
return S_OK;
}
static HRESULT WINAPI JScriptParse_AddScriptlet(IActiveScriptParse *iface,
@ -449,7 +478,7 @@ HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pUn
lock_module();
ret = heap_alloc(sizeof(*ret));
ret = heap_alloc_zero(sizeof(*ret));
ret->lpIActiveScriptVtbl = &JScriptVtbl;
ret->lpIActiveScriptParseVtbl = &JScriptParseVtbl;

View File

@ -25,6 +25,15 @@
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "activscp.h"
typedef struct _script_ctx_t script_ctx_t;
struct _script_ctx_t {
LONG ref;
SCRIPTSTATE state;
};
HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**);

View File

@ -22,7 +22,6 @@
#include "winreg.h"
#include "advpub.h"
#include "activscp.h"
#include "activaut.h"
#include "objsafe.h"

View File

@ -110,6 +110,12 @@ static void test_jscript(void)
test_safety(unk);
hres = IActiveScriptParse_InitNew(parse);
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
hres = IActiveScriptParse_InitNew(parse);
ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres);
IActiveScriptParse_Release(parse);
IActiveScript_Release(script);
IUnknown_Release(unk);