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

jscript: Added global object implementation.

parent 2bbd9d41
...@@ -10,6 +10,7 @@ RC_SRCS = rsrc.rc ...@@ -10,6 +10,7 @@ RC_SRCS = rsrc.rc
C_SRCS = \ C_SRCS = \
dispex.c \ dispex.c \
engine.c \ engine.c \
global.c \
jscript.c \ jscript.c \
jscript_main.c \ jscript_main.c \
jsutils.c \ jsutils.c \
......
...@@ -203,7 +203,12 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, ex ...@@ -203,7 +203,12 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, ex
TRACE("%s\n", debugstr_w(identifier)); TRACE("%s\n", debugstr_w(identifier));
/* FIXME: scope chain */ /* FIXME: scope chain */
/* FIXME: global */
hres = dispex_get_id(_IDispatchEx_(ctx->parser->script->global), identifier, 0, &id);
if(SUCCEEDED(hres)) {
exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->global), id);
return S_OK;
}
for(item = ctx->parser->script->named_items; item; item = item->next) { for(item = ctx->parser->script->named_items; item; item = item->next) {
hres = disp_get_id(item->disp, identifier, 0, &id); hres = disp_get_id(item->disp, identifier, 0, &id);
......
...@@ -216,9 +216,15 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface, ...@@ -216,9 +216,15 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface,
return hres; return hres;
} }
if(!This->ctx->script_disp) {
hres = create_dispex(This->ctx, NULL, NULL, &This->ctx->script_disp); hres = create_dispex(This->ctx, NULL, NULL, &This->ctx->script_disp);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}
hres = init_global(This->ctx);
if(FAILED(hres))
return hres;
if(InterlockedCompareExchange(&This->thread_id, GetCurrentThreadId(), 0)) if(InterlockedCompareExchange(&This->thread_id, GetCurrentThreadId(), 0))
return E_UNEXPECTED; return E_UNEXPECTED;
...@@ -306,6 +312,11 @@ static HRESULT WINAPI JScript_Close(IActiveScript *iface) ...@@ -306,6 +312,11 @@ static HRESULT WINAPI JScript_Close(IActiveScript *iface)
IDispatchEx_Release(_IDispatchEx_(This->ctx->script_disp)); IDispatchEx_Release(_IDispatchEx_(This->ctx->script_disp));
This->ctx->script_disp = NULL; This->ctx->script_disp = NULL;
} }
if(This->ctx->global) {
IDispatchEx_Release(_IDispatchEx_(This->ctx->global));
This->ctx->global = NULL;
}
} }
if(This->site) { if(This->site) {
......
...@@ -48,7 +48,8 @@ typedef struct DispatchEx DispatchEx; ...@@ -48,7 +48,8 @@ typedef struct DispatchEx DispatchEx;
#define PROPF_CONSTR 0x0400 #define PROPF_CONSTR 0x0400
typedef enum { typedef enum {
JSCLASS_NONE JSCLASS_NONE,
JSCLASS_GLOBAL
} jsclass_t; } jsclass_t;
typedef HRESULT (*builtin_invoke_t)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*); typedef HRESULT (*builtin_invoke_t)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
...@@ -105,6 +106,7 @@ struct _script_ctx_t { ...@@ -105,6 +106,7 @@ struct _script_ctx_t {
LCID lcid; LCID lcid;
DispatchEx *script_disp; DispatchEx *script_disp;
DispatchEx *global;
}; };
void script_release(script_ctx_t*); void script_release(script_ctx_t*);
...@@ -114,6 +116,8 @@ static inline void script_addref(script_ctx_t *ctx) ...@@ -114,6 +116,8 @@ static inline void script_addref(script_ctx_t *ctx)
ctx->ref++; ctx->ref++;
} }
HRESULT init_global(script_ctx_t*);
const char *debugstr_variant(const VARIANT*); const char *debugstr_variant(const VARIANT*);
HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**); HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**);
......
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