Commit 75be5eee authored by Zhan Jianyu's avatar Zhan Jianyu Committed by Alexandre Julliard

vbscript: Implemented builtin function CBool.

parent c6ce31ce
......@@ -114,6 +114,16 @@ static HRESULT return_int(VARIANT *res, int val)
return S_OK;
}
static HRESULT return_bool(VARIANT *res, int val)
{
if(res) {
V_VT(res) = VT_BOOL;
V_BOOL(res) = val != 0 ? VARIANT_TRUE : VARIANT_FALSE;
}
return S_OK;
}
static inline HRESULT return_double(VARIANT *res, double val)
{
if(res) {
......@@ -400,8 +410,30 @@ static HRESULT Global_CLng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
static HRESULT Global_CBool(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{
FIXME("\n");
return E_NOTIMPL;
int val;
TRACE("%s\n", debugstr_variant(arg));
assert(args_cnt == 1);
switch(V_VT(arg)) {
case VT_I2:
val = V_I2(arg);
break;
case VT_I4:
val = V_I4(arg);
break;
case VT_R4:
val = V_R4(arg) > 0.0 || V_R4(arg) < 0.0;
break;
case VT_R8:
val = V_R8(arg) > 0.0 || V_R8(arg) < 0.0;
break;
default:
ERR("Not a numeric vaule: %s\n", debugstr_variant(arg));
return E_FAIL;
}
return return_bool(res, val);
}
static HRESULT Global_CByte(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
......
......@@ -456,4 +456,12 @@ Call ok(getVT(CInt(36.50)) = "VT_I2", "getVT(CInt(36.50)) = " & getVT(CInt(36.50
Call ok(CInt(36.75) = 37, "CInt(36.75) = " & CInt(36.75))
Call ok(getVT(CInt(36.75)) = "VT_I2", "getVT(CInt(36.75)) = " & getVT(CInt(36.75)))
Call ok(CBool(5) = true, "CBool(5) = " & CBool(5))
Call ok(getVT(CBool(5)) = "VT_BOOL", "getVT(CBool(5)) = " & getVT(CBool(5)))
Call ok(CBool(0) = false, "CBool(0) = " & CBool(0))
Call ok(getVT(CBool(0)) = "VT_BOOL", "getVT(CBool(0)) = " & getVT(CBool(0)))
Call ok(CBool(-5) = true, "CBool(-5) = " & CBool(-5))
Call ok(getVT(CBool(-5)) = "VT_BOOL", "getVT(CBool(-5)) = " & getVT(CBool(-5)))
Call reportSuccess()
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