Commit 6deee88a authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Implement SID_GetCaller for QueryService.

parent a9a3c65c
...@@ -1900,6 +1900,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -1900,6 +1900,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
{ {
jsdisp_t *This = impl_from_IDispatchEx(iface); jsdisp_t *This = impl_from_IDispatchEx(iface);
IServiceProvider *prev_caller;
dispex_prop_t *prop; dispex_prop_t *prop;
jsexcept_t ei; jsexcept_t ei;
HRESULT hres; HRESULT hres;
...@@ -1917,6 +1918,11 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -1917,6 +1918,11 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
enter_script(This->ctx, &ei); enter_script(This->ctx, &ei);
prev_caller = This->ctx->jscaller->caller;
This->ctx->jscaller->caller = pspCaller;
if(pspCaller)
IServiceProvider_AddRef(pspCaller);
switch(wFlags) { switch(wFlags) {
case DISPATCH_METHOD|DISPATCH_PROPERTYGET: case DISPATCH_METHOD|DISPATCH_PROPERTYGET:
wFlags = DISPATCH_METHOD; wFlags = DISPATCH_METHOD;
...@@ -2000,6 +2006,9 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -2000,6 +2006,9 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
break; break;
} }
This->ctx->jscaller->caller = prev_caller;
if(pspCaller)
IServiceProvider_Release(pspCaller);
return leave_script(This->ctx, hres); return leave_script(This->ctx, hres);
} }
......
...@@ -428,6 +428,17 @@ static void release_named_item_list(JScript *This) ...@@ -428,6 +428,17 @@ static void release_named_item_list(JScript *This)
} }
} }
static HRESULT exec_global_code(script_ctx_t *ctx, bytecode_t *code, jsval_t *r)
{
IServiceProvider *prev_caller = ctx->jscaller->caller;
HRESULT hres;
ctx->jscaller->caller = SP_CALLER_UNINITIALIZED;
hres = exec_source(ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, 0, NULL, r);
ctx->jscaller->caller = prev_caller;
return hres;
}
static void exec_queued_code(JScript *This) static void exec_queued_code(JScript *This)
{ {
bytecode_t *iter; bytecode_t *iter;
...@@ -436,7 +447,7 @@ static void exec_queued_code(JScript *This) ...@@ -436,7 +447,7 @@ static void exec_queued_code(JScript *This)
LIST_FOR_EACH_ENTRY(iter, &This->queued_code, bytecode_t, entry) { LIST_FOR_EACH_ENTRY(iter, &This->queued_code, bytecode_t, entry) {
enter_script(This->ctx, &ei); enter_script(This->ctx, &ei);
hres = exec_source(This->ctx, EXEC_GLOBAL, iter, &iter->global_code, NULL, NULL, NULL, 0, NULL, NULL); hres = exec_global_code(This->ctx, iter, NULL);
leave_script(This->ctx, hres); leave_script(This->ctx, hres);
if(FAILED(hres)) if(FAILED(hres))
break; break;
...@@ -1103,7 +1114,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface, ...@@ -1103,7 +1114,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
if(dwFlags & SCRIPTTEXT_ISEXPRESSION) { if(dwFlags & SCRIPTTEXT_ISEXPRESSION) {
jsval_t r; jsval_t r;
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, 0, NULL, &r); hres = exec_global_code(This->ctx, code, &r);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
if(pvarResult) if(pvarResult)
hres = jsval_to_variant(r, pvarResult); hres = jsval_to_variant(r, pvarResult);
...@@ -1122,7 +1133,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface, ...@@ -1122,7 +1133,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
if(!pvarResult && !is_started(This->ctx)) { if(!pvarResult && !is_started(This->ctx)) {
list_add_tail(&This->queued_code, &code->entry); list_add_tail(&This->queued_code, &code->entry);
}else { }else {
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, 0, NULL, NULL); hres = exec_global_code(This->ctx, code, NULL);
if(code->is_persistent) if(code->is_persistent)
list_add_tail(&This->persistent_code, &code->entry); list_add_tail(&This->persistent_code, &code->entry);
else else
......
...@@ -331,12 +331,15 @@ typedef struct { ...@@ -331,12 +331,15 @@ typedef struct {
void release_cc(cc_ctx_t*) DECLSPEC_HIDDEN; void release_cc(cc_ctx_t*) DECLSPEC_HIDDEN;
#define SP_CALLER_UNINITIALIZED ((IServiceProvider*)IntToPtr(-1))
typedef struct { typedef struct {
IServiceProvider IServiceProvider_iface; IServiceProvider IServiceProvider_iface;
LONG ref; LONG ref;
script_ctx_t *ctx; script_ctx_t *ctx;
IServiceProvider *caller;
} JSCaller; } JSCaller;
#include "jsval.h" #include "jsval.h"
......
...@@ -1034,6 +1034,14 @@ static HRESULT WINAPI JSCaller_QueryService(IServiceProvider *iface, REFGUID gui ...@@ -1034,6 +1034,14 @@ static HRESULT WINAPI JSCaller_QueryService(IServiceProvider *iface, REFGUID gui
{ {
JSCaller *This = impl_from_IServiceProvider(iface); JSCaller *This = impl_from_IServiceProvider(iface);
if(IsEqualGUID(guidService, &SID_GetCaller)) {
TRACE("(%p)->(SID_GetCaller)\n", This);
*ppv = NULL;
if(!This->caller)
return S_OK;
return (This->caller == SP_CALLER_UNINITIALIZED) ? E_NOINTERFACE : IServiceProvider_QueryInterface(This->caller, riid, ppv);
}
if(IsEqualGUID(guidService, &SID_VariantConversion) && This->ctx && This->ctx->active_script) { if(IsEqualGUID(guidService, &SID_VariantConversion) && This->ctx && This->ctx->active_script) {
TRACE("(%p)->(SID_VariantConversion)\n", This); TRACE("(%p)->(SID_VariantConversion)\n", This);
return IActiveScript_QueryInterface(This->ctx->active_script, riid, ppv); return IActiveScript_QueryInterface(This->ctx->active_script, riid, ppv);
...@@ -1063,6 +1071,7 @@ HRESULT create_jscaller(script_ctx_t *ctx) ...@@ -1063,6 +1071,7 @@ HRESULT create_jscaller(script_ctx_t *ctx)
ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl; ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
ret->ref = 1; ret->ref = 1;
ret->ctx = ctx; ret->ctx = ctx;
ret->caller = SP_CALLER_UNINITIALIZED;
ctx->jscaller = ret; ctx->jscaller = ret;
return S_OK; return S_OK;
......
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