Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 32 +++++++++++++++++++++++++++++--- dlls/jscript/function.c | 8 ++++++++ dlls/jscript/jscript.h | 1 + 3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 8c1fc45..e58b285 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -719,10 +719,34 @@ static HRESULT WINAPI ScriptTypeInfo_GetTypeComp(ITypeInfo *iface, ITypeComp **p static HRESULT WINAPI ScriptTypeInfo_GetFuncDesc(ITypeInfo *iface, UINT index, FUNCDESC **ppFuncDesc) { ScriptTypeInfo *This = ScriptTypeInfo_from_ITypeInfo(iface); + struct typeinfo_func *func; + unsigned num_args, i; + FUNCDESC *desc;
- FIXME("(%p)->(%u %p)\n", This, index, ppFuncDesc); + TRACE("(%p)->(%u %p)\n", This, index, ppFuncDesc);
- return E_NOTIMPL; + if (!ppFuncDesc) return E_INVALIDARG; + if (index >= This->num_funcs) return TYPE_E_ELEMENTNOTFOUND; + func = &This->funcs[index]; + get_source_function_params(func->disp, &num_args); + + /* Store the parameter array after the FUNCDESC structure */ + desc = heap_alloc_zero(sizeof(*desc) + sizeof(ELEMDESC) * num_args); + if (!desc) return E_OUTOFMEMORY; + + desc->memid = prop_to_id(This->jsdisp, func->prop); + desc->funckind = FUNC_DISPATCH; + desc->invkind = INVOKE_FUNC; + desc->callconv = CC_STDCALL; + desc->cParams = num_args; + desc->elemdescFunc.tdesc.vt = VT_VARIANT; + + if (num_args) desc->lprgelemdescParam = (ELEMDESC*)(desc + 1); + for (i = 0; i < num_args; i++) + desc->lprgelemdescParam[i].tdesc.vt = VT_VARIANT; + + *ppFuncDesc = desc; + return S_OK; }
static HRESULT WINAPI ScriptTypeInfo_GetVarDesc(ITypeInfo *iface, UINT index, VARDESC **ppVarDesc) @@ -861,7 +885,9 @@ static void WINAPI ScriptTypeInfo_ReleaseFuncDesc(ITypeInfo *iface, FUNCDESC *pF { ScriptTypeInfo *This = ScriptTypeInfo_from_ITypeInfo(iface);
- FIXME("(%p)->(%p)\n", This, pFuncDesc); + TRACE("(%p)->(%p)\n", This, pFuncDesc); + + heap_free(pFuncDesc); }
static void WINAPI ScriptTypeInfo_ReleaseVarDesc(ITypeInfo *iface, VARDESC *pVarDesc) diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 98d1259..c2d058b 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -808,6 +808,14 @@ BOOL is_source_function(jsdisp_t *jsdisp) return function_from_jsdisp(jsdisp)->vtbl == &InterpretedFunctionVtbl; }
+BSTR *get_source_function_params(jsdisp_t *jsdisp, unsigned *param_cnt) +{ + InterpretedFunction *func = (InterpretedFunction*)function_from_jsdisp(jsdisp); + + *param_cnt = func->func_code->param_cnt; + return func->func_code->params; +} + static HRESULT BindFunction_call(script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_obj, unsigned flags, unsigned argc, jsval_t *argv, jsval_t *r) { diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 91923f8..09ecfb4 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -304,6 +304,7 @@ HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,cons HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD, jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; BOOL is_source_function(jsdisp_t*) DECLSPEC_HIDDEN; +BSTR *get_source_function_params(jsdisp_t*,unsigned*) DECLSPEC_HIDDEN; HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;