Michał Ziętek : wscript: Implemented Arguments2_Item.
Alexandre Julliard
julliard at winehq.org
Thu Aug 25 13:00:14 CDT 2011
Module: wine
Branch: master
Commit: 1c293750313d9f6a173de8c21a02e6045d61ef57
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1c293750313d9f6a173de8c21a02e6045d61ef57
Author: Michał Ziętek <smierc.w.wenecji at gmail.com>
Date: Tue Aug 23 15:15:54 2011 +0200
wscript: Implemented Arguments2_Item.
---
programs/wscript/arguments.c | 13 +++++++++++--
programs/wscript/main.c | 2 ++
programs/wscript/tests/run.c | 2 +-
programs/wscript/tests/run.js | 7 +++++++
programs/wscript/wscript.h | 4 ++++
5 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/programs/wscript/arguments.c b/programs/wscript/arguments.c
index 4b10d2f..62d6ad0 100644
--- a/programs/wscript/arguments.c
+++ b/programs/wscript/arguments.c
@@ -31,6 +31,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(wscript);
+WCHAR **argums;
+int numOfArgs;
+
static HRESULT WINAPI Arguments2_QueryInterface(IArguments2 *iface, REFIID riid, void **ppv)
{
WINE_TRACE("(%s %p)\n", wine_dbgstr_guid(riid), ppv);
@@ -95,8 +98,14 @@ static HRESULT WINAPI Arguments2_Invoke(IArguments2 *iface, DISPID dispIdMember,
static HRESULT WINAPI Arguments2_Item(IArguments2 *iface, LONG index, BSTR *out_Value)
{
- WINE_FIXME("(%d %p)\n", index, out_Value);
- return E_NOTIMPL;
+ WINE_TRACE("(%d %p)\n", index, out_Value);
+
+ if(index<0 || index >= numOfArgs)
+ return E_INVALIDARG;
+ if(!(*out_Value = SysAllocString(argums[index])))
+ return E_OUTOFMEMORY;
+
+ return S_OK;
}
static HRESULT WINAPI Arguments2_Count(IArguments2 *iface, LONG *out_Count)
diff --git a/programs/wscript/main.c b/programs/wscript/main.c
index 2f9b15c..3073445 100644
--- a/programs/wscript/main.c
+++ b/programs/wscript/main.c
@@ -343,6 +343,8 @@ int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cm
WINE_FIXME("Unsupported argument %s\n", wine_dbgstr_w(argv[i]));
}else {
filename = argv[i];
+ argums = argv+i+1;
+ numOfArgs = argc-i-1;
break;
}
}
diff --git a/programs/wscript/tests/run.c b/programs/wscript/tests/run.c
index 7d43d66..b7d3c3c 100644
--- a/programs/wscript/tests/run.c
+++ b/programs/wscript/tests/run.c
@@ -336,7 +336,7 @@ static void run_test(const char *file_name)
BOOL bres;
script_name = file_name;
- sprintf(command, "wscript.exe %s", file_name);
+ sprintf(command, "wscript.exe %s arg1 2 ar3", file_name);
SET_EXPECT(reportSuccess);
diff --git a/programs/wscript/tests/run.js b/programs/wscript/tests/run.js
index e1c9da8..4b6014e 100644
--- a/programs/wscript/tests/run.js
+++ b/programs/wscript/tests/run.js
@@ -33,5 +33,12 @@ 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));
+ok(WScript.Arguments.Item(0) === "arg1", "WScript.Arguments.Item(0) = " + WScript.Arguments.Item(0));
+ok(WScript.Arguments.Item(1) === "2", "WScript.Arguments.Item(1) = " + WScript.Arguments.Item(1));
+ok(WScript.Arguments.Item(2) === "ar3", "WScript.Arguments.Item(2) = " + WScript.Arguments.Item(2));
+try {
+ WScript.Arguments.Item(3);
+ ok(false, "expected exception");
+}catch(e) {}
winetest.reportSuccess();
diff --git a/programs/wscript/wscript.h b/programs/wscript/wscript.h
index c4b2eb2..3c9191f 100644
--- a/programs/wscript/wscript.h
+++ b/programs/wscript/wscript.h
@@ -27,3 +27,7 @@ extern ITypeInfo *host_ti;
extern ITypeInfo *arguments_ti;
extern WCHAR scriptFullName[];
+
+extern WCHAR **argums;
+
+extern int numOfArgs;
More information about the wine-cvs
mailing list