Commit a42f3cb4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added WeekDayName implementation.

parent 5f5f20d6
...@@ -63,7 +63,7 @@ static IInternetHostSecurityManager *get_sec_mgr(script_ctx_t *ctx) ...@@ -63,7 +63,7 @@ static IInternetHostSecurityManager *get_sec_mgr(script_ctx_t *ctx)
return ctx->secmgr = secmgr; return ctx->secmgr = secmgr;
} }
static HRESULT return_bstr(VARIANT *res, const WCHAR *str) static HRESULT return_string(VARIANT *res, const WCHAR *str)
{ {
BSTR ret; BSTR ret;
...@@ -79,6 +79,17 @@ static HRESULT return_bstr(VARIANT *res, const WCHAR *str) ...@@ -79,6 +79,17 @@ static HRESULT return_bstr(VARIANT *res, const WCHAR *str)
return S_OK; return S_OK;
} }
static HRESULT return_bstr(VARIANT *res, BSTR str)
{
if(res) {
V_VT(res) = VT_BSTR;
V_BSTR(res) = str;
}else {
SysFreeString(str);
}
return S_OK;
}
static HRESULT return_short(VARIANT *res, short val) static HRESULT return_short(VARIANT *res, short val)
{ {
if(res) { if(res) {
...@@ -137,6 +148,9 @@ static HRESULT to_int(VARIANT *v, int *ret) ...@@ -137,6 +148,9 @@ static HRESULT to_int(VARIANT *v, int *ret)
*ret = n; *ret = n;
break; break;
} }
case VT_BOOL:
*ret = V_BOOL(v) ? -1 : 0;
break;
default: default:
FIXME("not supported %s\n", debugstr_variant(v)); FIXME("not supported %s\n", debugstr_variant(v));
return E_NOTIMPL; return E_NOTIMPL;
...@@ -427,7 +441,7 @@ static HRESULT Global_Hex(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIA ...@@ -427,7 +441,7 @@ static HRESULT Global_Hex(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIA
*ptr = '0'; *ptr = '0';
} }
return return_bstr(res, ptr); return return_string(res, ptr);
} }
static HRESULT Global_Oct(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) static HRESULT Global_Oct(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
...@@ -1224,8 +1238,35 @@ static HRESULT Global_FormatDateTime(vbdisp_t *This, VARIANT *arg, unsigned args ...@@ -1224,8 +1238,35 @@ static HRESULT Global_FormatDateTime(vbdisp_t *This, VARIANT *arg, unsigned args
static HRESULT Global_WeekdayName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) static HRESULT Global_WeekdayName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{ {
FIXME("\n"); int weekday, first_day = 0, abbrev = 0;
return E_NOTIMPL; BSTR ret;
HRESULT hres;
TRACE("\n");
assert(1 <= args_cnt && args_cnt <= 3);
hres = to_int(arg+args_cnt-1, &weekday);
if(FAILED(hres))
return hres;
if(args_cnt > 1) {
hres = to_int(arg+args_cnt-2, &abbrev);
if(FAILED(hres))
return hres;
if(args_cnt == 3) {
hres = to_int(arg, &first_day);
if(FAILED(hres))
return hres;
}
}
hres = VarWeekdayName(weekday, abbrev, first_day, 0, &ret);
if(FAILED(hres))
return hres;
return return_bstr(res, ret);
} }
static HRESULT Global_MonthName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) static HRESULT Global_MonthName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
...@@ -1988,7 +2029,7 @@ static const builtin_prop_t global_props[] = { ...@@ -1988,7 +2029,7 @@ static const builtin_prop_t global_props[] = {
{DISPID_GLOBAL_FORMATCURRENCY, Global_FormatCurrency, 0, 1, 5}, {DISPID_GLOBAL_FORMATCURRENCY, Global_FormatCurrency, 0, 1, 5},
{DISPID_GLOBAL_FORMATPERCENT, Global_FormatPercent, 0, 1, 5}, {DISPID_GLOBAL_FORMATPERCENT, Global_FormatPercent, 0, 1, 5},
{DISPID_GLOBAL_FORMATDATETIME, Global_FormatDateTime, 0, 1, 2}, {DISPID_GLOBAL_FORMATDATETIME, Global_FormatDateTime, 0, 1, 2},
{DISPID_GLOBAL_WEEKDAYNAME, Global_WeekdayName, 0, 3}, {DISPID_GLOBAL_WEEKDAYNAME, Global_WeekdayName, 0, 1, 3},
{DISPID_GLOBAL_MONTHNAME, Global_MonthName, 0, 1, 2}, {DISPID_GLOBAL_MONTHNAME, Global_MonthName, 0, 1, 2},
{DISPID_GLOBAL_ROUND, Global_Round, 0, 1, 2}, {DISPID_GLOBAL_ROUND, Global_Round, 0, 1, 2},
{DISPID_GLOBAL_ESCAPE, Global_Escape, 0, 1}, {DISPID_GLOBAL_ESCAPE, Global_Escape, 0, 1},
......
...@@ -190,6 +190,7 @@ Call ok(Len(empty) = 0, "Len(empty) = " & Len(empty)) ...@@ -190,6 +190,7 @@ Call ok(Len(empty) = 0, "Len(empty) = " & Len(empty))
Call ok(Space(1) = " ", "Space(1) = " & Space(1) & """") Call ok(Space(1) = " ", "Space(1) = " & Space(1) & """")
Call ok(Space(0) = "", "Space(0) = " & Space(0) & """") Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
Call ok(Space(false) = "", "Space(false) = " & Space(false) & """")
Call ok(Space(5) = " ", "Space(5) = " & Space(5) & """") Call ok(Space(5) = " ", "Space(5) = " & Space(5) & """")
Call ok(Space(5.2) = " ", "Space(5.2) = " & Space(5.2) & """") Call ok(Space(5.2) = " ", "Space(5.2) = " & Space(5.2) & """")
Call ok(Space(5.8) = " ", "Space(5.8) = " & Space(5.8) & """") Call ok(Space(5.8) = " ", "Space(5.8) = " & Space(5.8) & """")
...@@ -210,4 +211,18 @@ TestRound "2", 2, "VT_R8" ...@@ -210,4 +211,18 @@ TestRound "2", 2, "VT_R8"
TestRound true, true, "VT_BOOL" TestRound true, true, "VT_BOOL"
TestRound false, false, "VT_BOOL" TestRound false, false, "VT_BOOL"
if isEnglishLang then
Call ok(WeekDayName(1) = "Sunday", "WeekDayName(1) = " & WeekDayName(1))
Call ok(WeekDayName(3) = "Tuesday", "WeekDayName(3) = " & WeekDayName(3))
Call ok(WeekDayName(7) = "Saturday", "WeekDayName(7) = " & WeekDayName(7))
Call ok(WeekDayName(1.1) = "Sunday", "WeekDayName(1.1) = " & WeekDayName(1.1))
Call ok(WeekDayName(1, false) = "Sunday", "WeekDayName(1, false) = " & WeekDayName(1, false))
Call ok(WeekDayName(1, true) = "Sun", "WeekDayName(1, true) = " & WeekDayName(1, true))
Call ok(WeekDayName(1, 10) = "Sun", "WeekDayName(1, 10) = " & WeekDayName(1, 10))
Call ok(WeekDayName(1, true, 0) = "Sun", "WeekDayName(1, true, 0) = " & WeekDayName(1, true, 0))
Call ok(WeekDayName(1, true, 2) = "Mon", "WeekDayName(1, true, 2) = " & WeekDayName(1, true, 2))
Call ok(WeekDayName(1, true, 7) = "Sat", "WeekDayName(1, true, 7) = " & WeekDayName(1, true, 7))
Call ok(WeekDayName(1, true, 7.1) = "Sat", "WeekDayName(1, true, 7.1) = " & WeekDayName(1, true, 7.1))
end if
Call reportSuccess() Call reportSuccess()
...@@ -202,10 +202,10 @@ static BOOL is_lang_english(void) ...@@ -202,10 +202,10 @@ static BOOL is_lang_english(void)
pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage"); pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage"); pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
} }
if (pGetThreadUILanguage) if (pGetThreadUILanguage && PRIMARYLANGID(pGetThreadUILanguage()) != LANG_ENGLISH)
return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH; return FALSE;
if (pGetUserDefaultUILanguage) if (pGetUserDefaultUILanguage && PRIMARYLANGID(pGetUserDefaultUILanguage()) != LANG_ENGLISH)
return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH; return FALSE;
return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH; return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
} }
...@@ -1906,7 +1906,7 @@ START_TEST(run) ...@@ -1906,7 +1906,7 @@ START_TEST(run)
is_english = is_lang_english(); is_english = is_lang_english();
if(!is_english) if(!is_english)
skip("Skipping some tests in non-English UIs\n"); skip("Skipping some tests in non-English locale\n");
argc = winetest_get_mainargs(&argv); argc = winetest_get_mainargs(&argv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment