Module: wine Branch: master Commit: d6fd86e8ec1f764c59306ed3bb3b7270a66487f7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d6fd86e8ec1f764c59306ed3bb...
Author: Michał Ziętek smierc.w.wenecji@gmail.com Date: Wed Jul 20 21:47:18 2011 +0200
wscript: Implemented Host_get_FullName.
---
programs/wscript/host.c | 11 +++++++++-- programs/wscript/tests/Makefile.in | 2 +- programs/wscript/tests/run.c | 26 +++++++++++++++++++++++--- programs/wscript/tests/run.js | 1 + 4 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/programs/wscript/host.c b/programs/wscript/host.c index c0d73a5..8277cdf 100644 --- a/programs/wscript/host.c +++ b/programs/wscript/host.c @@ -114,8 +114,15 @@ static HRESULT WINAPI Host_get_Application(IHost *iface, IDispatch **out_Dispatc
static HRESULT WINAPI Host_get_FullName(IHost *iface, BSTR *out_Path) { - WINE_FIXME("(%p)\n", out_Path); - return E_NOTIMPL; + WCHAR fullPath[MAX_PATH]; + + WINE_TRACE("(%p)\n", out_Path); + + if(GetModuleFileNameW(NULL, fullPath, sizeof(fullPath)/sizeof(WCHAR)) == 0) + return E_FAIL; + if(!(*out_Path = SysAllocString(fullPath))) + return E_OUTOFMEMORY; + return S_OK; }
static HRESULT WINAPI Host_get_Path(IHost *iface, BSTR *out_Path) diff --git a/programs/wscript/tests/Makefile.in b/programs/wscript/tests/Makefile.in index 8eb0535..78f0cc4 100644 --- a/programs/wscript/tests/Makefile.in +++ b/programs/wscript/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = wscript.exe -IMPORTS = ole32 advapi32 +IMPORTS = ole32 oleaut32 advapi32
C_SRCS = \ run.c diff --git a/programs/wscript/tests/run.c b/programs/wscript/tests/run.c index 2c2a15a..30230b6 100644 --- a/programs/wscript/tests/run.c +++ b/programs/wscript/tests/run.c @@ -56,9 +56,10 @@
DEFINE_EXPECT(reportSuccess);
-#define DISPID_TESTOBJ_OK 10000 -#define DISPID_TESTOBJ_TRACE 10001 -#define DISPID_TESTOBJ_REPORTSUCCESS 10002 +#define DISPID_TESTOBJ_OK 10000 +#define DISPID_TESTOBJ_TRACE 10001 +#define DISPID_TESTOBJ_REPORTSUCCESS 10002 +#define DISPID_TESTOBJ_WSCRIPTFULLNAME 10003
#define TESTOBJ_CLSID "{178fc166-f585-4e24-9c13-4bb7faf80646}"
@@ -120,6 +121,8 @@ static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, rgDispId[i] = DISPID_TESTOBJ_TRACE; }else if(!strcmp_wa(rgszNames[i], "reportSuccess")) { rgDispId[i] = DISPID_TESTOBJ_REPORTSUCCESS; + }else if(!strcmp_wa(rgszNames[i], "wscriptFullName")) { + rgDispId[i] = DISPID_TESTOBJ_WSCRIPTFULLNAME; }else { ok(0, "unexpected name %s\n", wine_dbgstr_w(rgszNames[i])); return DISP_E_UNKNOWNNAME; @@ -161,6 +164,23 @@ static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REF if(pVarResult) V_VT(pVarResult) = VT_EMPTY; break; + case DISPID_TESTOBJ_WSCRIPTFULLNAME: + { + WCHAR fullName[MAX_PATH]; + const WCHAR wscriptexe[] = {'w','s','c','r','i','p','t','.','e','x','e',0}; + DWORD res; + + ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags); + ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs); + ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs); + V_VT(pVarResult) = VT_BSTR; + res = SearchPathW(NULL, wscriptexe, NULL, sizeof(fullName)/sizeof(WCHAR), fullName, NULL); + if(res == 0) + return E_FAIL; + if(!(V_BSTR(pVarResult) = SysAllocString(fullName))) + return E_OUTOFMEMORY; + break; + } default: ok(0, "unexpected dispIdMember %d\n", dispIdMember); return E_NOTIMPL; diff --git a/programs/wscript/tests/run.js b/programs/wscript/tests/run.js index fda62f6..1156e13 100644 --- a/programs/wscript/tests/run.js +++ b/programs/wscript/tests/run.js @@ -28,5 +28,6 @@ ok(WScript === WSH, "WScript !== WSH"); ok(WScript.Name === "Windows Script Host", "WScript.Name = " + WScript.Name); ok(typeof(WScript.Version) === "string", "typeof(WScript.Version) = " + typeof(WScript.Version)); ok(typeof(WScript.BuildVersion) === "number", "typeof(WScript.BuldVersion) = " + typeof(WScript.BuldVersion)); +ok(WScript.FullName === winetest.wscriptFullName, "WScript.FullName = ", WScript.FullName);
winetest.reportSuccess();