Module: wine Branch: master Commit: 2d2a91fd0183c7d2b751cee2251d0e9b67c85161 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2d2a91fd0183c7d2b751cee225...
Author: Michał Ziętek smierc.w.wenecji@gmail.com Date: Tue Aug 23 15:15:48 2011 +0200
wscript: Implemented Host_get_Arguments.
---
programs/wscript/Makefile.in | 1 + programs/wscript/arguments.c | 127 +++++++++++++++++++++++++++++++++++++++++ programs/wscript/host.c | 6 +- programs/wscript/main.c | 3 + programs/wscript/tests/run.js | 1 + programs/wscript/wscript.h | 4 + 6 files changed, 140 insertions(+), 2 deletions(-)
diff --git a/programs/wscript/Makefile.in b/programs/wscript/Makefile.in index 65fe3a4..49836b9 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 0000000..4b10d2f --- /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 <stdarg.h> + +#define COBJMACROS +#define CONST_VTABLE + +#include <windef.h> +#include <winbase.h> +#include <ole2.h> + +#include "wscript.h" + +#include <wine/debug.h> + +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 d17e4b4..02a9291 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 8bf0712..2f9b15c 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 5e61d69..e1c9da8 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 642784e..c4b2eb2 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[];