diff --git a/programs/wscript/Makefile.in b/programs/wscript/Makefile.in index 65fe3a43a73..49836b92750 100644 --- a/programs/wscript/Makefile.in +++ b/programs/wscript/Makefile.in @@ -7,6 +7,7 @@ RC_SRCS = \ rsrc.rc C_SRCS = \ + arguments.c \ host.c \ main.c diff --git a/programs/wscript/arguments.c b/programs/wscript/arguments.c new file mode 100644 index 00000000000..4b10d2fabdb --- /dev/null +++ b/programs/wscript/arguments.c @@ -0,0 +1,127 @@ +/* + * Copyright 2011 Michal Zietek + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#define COBJMACROS +#define CONST_VTABLE + +#include +#include +#include + +#include "wscript.h" + +#include + +WINE_DEFAULT_DEBUG_CHANNEL(wscript); + +static HRESULT WINAPI Arguments2_QueryInterface(IArguments2 *iface, REFIID riid, void **ppv) +{ + WINE_TRACE("(%s %p)\n", wine_dbgstr_guid(riid), ppv); + + if(IsEqualGUID(&IID_IUnknown, riid) + || IsEqualGUID(&IID_IDispatch, riid) + || IsEqualGUID(&IID_IArguments2, riid)) { + *ppv = iface; + return S_OK; + } + + *ppv = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI Arguments2_AddRef(IArguments2 *iface) +{ + return 2; +} + +static ULONG WINAPI Arguments2_Release(IArguments2 *iface) +{ + return 1; +} + +static HRESULT WINAPI Arguments2_GetTypeInfoCount(IArguments2 *iface, UINT *pctinfo) +{ + WINE_TRACE("(%p)\n", pctinfo); + + *pctinfo = 1; + return S_OK; +} + +static HRESULT WINAPI Arguments2_GetTypeInfo(IArguments2 *iface, UINT iTInfo, LCID lcid, + ITypeInfo **ppTInfo) +{ + WINE_TRACE("(%x %x %p\n", iTInfo, lcid, ppTInfo); + + ITypeInfo_AddRef(arguments_ti); + *ppTInfo = arguments_ti; + return S_OK; +} + +static HRESULT WINAPI Arguments2_GetIDsOfNames(IArguments2 *iface, REFIID riid, LPOLESTR *rgszNames, + UINT cNames, LCID lcid, DISPID *rgDispId) +{ + WINE_TRACE("(%s %p %d %x %p)\n", wine_dbgstr_guid(riid), rgszNames, + cNames, lcid, rgDispId); + + return ITypeInfo_GetIDsOfNames(arguments_ti, rgszNames, cNames, rgDispId); +} + +static HRESULT WINAPI Arguments2_Invoke(IArguments2 *iface, DISPID dispIdMember, REFIID riid, + LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + WINE_TRACE("(%d %p %p)\n", dispIdMember, pDispParams, pVarResult); + + return ITypeInfo_Invoke(arguments_ti, iface, dispIdMember, wFlags, pDispParams, + pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI Arguments2_Item(IArguments2 *iface, LONG index, BSTR *out_Value) +{ + WINE_FIXME("(%d %p)\n", index, out_Value); + return E_NOTIMPL; +} + +static HRESULT WINAPI Arguments2_Count(IArguments2 *iface, LONG *out_Count) +{ + WINE_FIXME("(%p)\n", out_Count); + return E_NOTIMPL; +} + +static HRESULT WINAPI Arguments2_get_length(IArguments2 *iface, LONG *out_Count) +{ + WINE_FIXME("(%p)\n", out_Count); + return E_NOTIMPL; +} + +static const IArguments2Vtbl Arguments2Vtbl = { + Arguments2_QueryInterface, + Arguments2_AddRef, + Arguments2_Release, + Arguments2_GetTypeInfoCount, + Arguments2_GetTypeInfo, + Arguments2_GetIDsOfNames, + Arguments2_Invoke, + Arguments2_Item, + Arguments2_Count, + Arguments2_get_length +}; + +IArguments2 arguments_obj = { &Arguments2Vtbl }; diff --git a/programs/wscript/host.c b/programs/wscript/host.c index d17e4b491f1..02a9291d613 100644 --- a/programs/wscript/host.c +++ b/programs/wscript/host.c @@ -185,8 +185,10 @@ static HRESULT WINAPI Host_get_ScriptFullName(IHost *iface, BSTR *out_ScriptFull static HRESULT WINAPI Host_get_Arguments(IHost *iface, IArguments2 **out_Arguments) { - WINE_FIXME("(%p)\n", out_Arguments); - return E_NOTIMPL; + WINE_TRACE("(%p)\n", out_Arguments); + + *out_Arguments = &arguments_obj; + return S_OK; } static HRESULT WINAPI Host_get_Version(IHost *iface, BSTR *out_Version) diff --git a/programs/wscript/main.c b/programs/wscript/main.c index 8bf071260ae..2f9b15c029e 100644 --- a/programs/wscript/main.c +++ b/programs/wscript/main.c @@ -39,6 +39,7 @@ static const WCHAR wshW[] = {'W','S','H',0}; WCHAR scriptFullName[MAX_PATH]; ITypeInfo *host_ti; +ITypeInfo *arguments_ti; static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv) @@ -166,6 +167,8 @@ static BOOL load_typelib(void) return FALSE; hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IHost, &host_ti); + if(SUCCEEDED(hres)) + hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IArguments2, &arguments_ti); ITypeLib_Release(typelib); return SUCCEEDED(hres); diff --git a/programs/wscript/tests/run.js b/programs/wscript/tests/run.js index 5e61d69bc44..e1c9da8aeb0 100644 --- a/programs/wscript/tests/run.js +++ b/programs/wscript/tests/run.js @@ -32,5 +32,6 @@ ok(WScript.FullName === winetest.wscriptFullName, "WScript.FullName = ", WScript ok(WScript.Path === winetest.wscriptPath, "WScript.Path = ", WScript.Path); ok(WScript.ScriptName === winetest.wscriptScriptName, "WScript.ScriptName = " + WScript.ScriptName); ok(WScript.ScriptFullName === winetest.wscriptScriptFullName, "WScript.ScriptFullName = " + WScript.ScriptFullName); +ok(typeof(WScript.Arguments) === "object", "typeof(WScript.Arguments) = " + typeof(WScript.Arguments)); winetest.reportSuccess(); diff --git a/programs/wscript/wscript.h b/programs/wscript/wscript.h index 642784ed803..c4b2eb2f854 100644 --- a/programs/wscript/wscript.h +++ b/programs/wscript/wscript.h @@ -20,6 +20,10 @@ extern IHost host_obj; +extern IArguments2 arguments_obj; + extern ITypeInfo *host_ti; +extern ITypeInfo *arguments_ti; + extern WCHAR scriptFullName[];