Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 9 +++++++-- dlls/msscript.ocx/tests/msscript.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 173e04a..a510db7 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -97,6 +97,7 @@ typedef struct { struct list entry;
BSTR name; + USHORT num_args; } ScriptProcedure;
struct ScriptProcedureCollection { @@ -888,9 +889,12 @@ static HRESULT WINAPI ScriptProcedure_get_NumArgs(IScriptProcedure *iface, LONG { ScriptProcedure *This = impl_from_IScriptProcedure(iface);
- FIXME("(%p)->(%p)\n", This, pcArgs); + TRACE("(%p)->(%p)\n", This, pcArgs);
- return E_NOTIMPL; + if (!pcArgs) return E_POINTER; + + *pcArgs = This->num_args; + return S_OK; }
static HRESULT WINAPI ScriptProcedure_get_HasReturnValue(IScriptProcedure *iface, VARIANT_BOOL *pfHasReturnValue) @@ -957,6 +961,7 @@ static HRESULT get_script_procedure(ScriptProcedureCollection *procedures, IType proc->ref = 1; proc->hash = hash; proc->name = str; + proc->num_args = desc->cParams + desc->cParamsOpt; list_add_tail(proc_list, &proc->entry);
*procedure = &proc->IScriptProcedure_iface; diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index d08f30c..ad7e48f 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3358,6 +3358,11 @@ static void test_IScriptControl_get_Procedures(void) ok(hr == S_OK, "IScriptProcedure_get_Name failed: 0x%08x.\n", hr); ok(!lstrcmpW(str, L"add"), "Wrong name, got %s.\n", wine_dbgstr_w(str)); SysFreeString(str); + hr = IScriptProcedure_get_NumArgs(proc, NULL); + ok(hr == E_POINTER, "IScriptProcedure_get_NumArgs returned: 0x%08x.\n", hr); + hr = IScriptProcedure_get_NumArgs(proc, &count); + ok(hr == S_OK, "IScriptProcedure_get_NumArgs failed: 0x%08x.\n", hr); + ok(count == 2, "Wrong NumArgs, got %d.\n", count); IScriptProcedure_Release(proc);
V_VT(&var) = VT_BSTR; @@ -3370,6 +3375,9 @@ static void test_IScriptControl_get_Procedures(void) ok(hr == S_OK, "IScriptProcedure_get_Name failed: 0x%08x.\n", hr); ok(!lstrcmpW(str, L"nop"), "Wrong name, got %s.\n", wine_dbgstr_w(str)); SysFreeString(str); + hr = IScriptProcedure_get_NumArgs(proc, &count); + ok(hr == S_OK, "IScriptProcedure_get_NumArgs failed: 0x%08x.\n", hr); + ok(count == 1, "Wrong NumArgs, got %d.\n", count); IScriptProcedure_Release(proc);
V_VT(&var) = VT_R8; @@ -3380,6 +3388,9 @@ static void test_IScriptControl_get_Procedures(void) ok(hr == S_OK, "IScriptProcedure_get_Name failed: 0x%08x.\n", hr); ok(!lstrcmpW(str, L"muladd"), "Wrong name, got %s.\n", wine_dbgstr_w(str)); SysFreeString(str); + hr = IScriptProcedure_get_NumArgs(proc, &count); + ok(hr == S_OK, "IScriptProcedure_get_NumArgs failed: 0x%08x.\n", hr); + ok(count == 3, "Wrong NumArgs, got %d.\n", count); IScriptProcedure_Release(proc);
IScriptProcedureCollection_Release(procs); @@ -3569,6 +3580,10 @@ static void test_IScriptControl_get_Procedures(void) ok(!lstrcmpW(str, custom_engine_funcs[i].name), "Name is not %s, got %s.\n", wine_dbgstr_w(custom_engine_funcs[i].name), wine_dbgstr_w(str)); SysFreeString(str); + hr = IScriptProcedure_get_NumArgs(proc, &count); + ok(hr == S_OK, "get_NumArgs for %s failed: 0x%08x.\n", wine_dbgstr_w(custom_engine_funcs[i].name), hr); + ok(count == custom_engine_funcs[i].num_args + custom_engine_funcs[i].num_opt_args, + "NumArgs is not %d, got %d.\n", custom_engine_funcs[i].num_args + custom_engine_funcs[i].num_opt_args, count);
IScriptProcedure_Release(proc); }