jscript: Make Function object invocation a special case in IDispatchEx implementation.

This commit is contained in:
Jacek Caban 2012-06-21 10:47:36 +02:00 committed by Alexandre Julliard
parent 4a335142f9
commit 17ff7829d3
3 changed files with 32 additions and 4 deletions

View File

@ -391,7 +391,6 @@ static HRESULT invoke_prop_func(jsdisp_t *This, jsdisp_t *jsthis, dispex_prop_t
case PROP_BUILTIN: {
DISPPARAMS params;
VARIANT buf[6];
vdisp_t vthis;
if(flags == DISPATCH_CONSTRUCT && (prop->flags & PROPF_METHOD)) {
WARN("%s is not a constructor\n", debugstr_w(prop->name));
@ -402,9 +401,16 @@ static HRESULT invoke_prop_func(jsdisp_t *This, jsdisp_t *jsthis, dispex_prop_t
if(FAILED(hres))
return hres;
if(prop->name || jsthis->builtin_info->class != JSCLASS_FUNCTION) {
vdisp_t vthis;
set_jsdisp(&vthis, jsthis);
hres = prop->u.p->invoke(This->ctx, &vthis, flags, &params, retv, ei);
vdisp_release(&vthis);
}else {
/* Function object calls are special case */
hres = Function_invoke(This, flags, &params, retv, ei);
}
if(params.rgvarg != buf && params.rgvarg != dp->rgvarg)
heap_free(params.rgvarg);
return hres;

View File

@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <assert.h>
#include "jscript.h"
#include "engine.h"
@ -305,6 +307,25 @@ static HRESULT function_to_string(FunctionInstance *function, BSTR *ret)
return S_OK;
}
HRESULT Function_invoke(jsdisp_t *func_this, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei)
{
FunctionInstance *function;
TRACE("\n");
assert(is_class(func_this, JSCLASS_FUNCTION));
function = (FunctionInstance*)func_this;
if(function->value_proc)
return invoke_value_proc(function->dispex.ctx, function, get_this(dp), flags, dp, retv, ei);
if(flags == DISPATCH_CONSTRUCT)
return invoke_constructor(function->dispex.ctx, function, dp, retv, ei);
assert(flags == DISPATCH_METHOD);
return invoke_source(function->dispex.ctx, function, get_this(dp), dp, retv, ei);
}
static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei)
{

View File

@ -225,6 +225,7 @@ VARIANT_BOOL jsdisp_is_own_prop(jsdisp_t *obj, BSTR name) DECLSPEC_HIDDEN;
HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT Function_invoke(jsdisp_t*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*);
HRESULT throw_eval_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT throw_generic_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;