Commit d19cdef8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added IActiveScriptParse::InitNew implementation.

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