Commit 61d49a8a authored by Shuai Meng's avatar Shuai Meng Committed by Alexandre Julliard

vbscript: Implemented TypeName.

parent 342eec7f
......@@ -1502,8 +1502,52 @@ static HRESULT Global_DatePart(vbdisp_t *This, VARIANT *arg, unsigned args_cnt,
static HRESULT Global_TypeName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{
FIXME("\n");
return E_NOTIMPL;
static const WCHAR ByteW[] = {'B', 'y', 't', 'e', 0};
static const WCHAR IntegerW[] = {'I', 'n', 't', 'e', 'g', 'e', 'r', 0};
static const WCHAR LongW[] = {'L', 'o', 'n', 'g', 0};
static const WCHAR SingleW[] = {'S', 'i', 'n', 'g', 'l', 'e', 0};
static const WCHAR DoubleW[] = {'D', 'o', 'u', 'b', 'l', 'e', 0};
static const WCHAR CurrencyW[] = {'C', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 0};
static const WCHAR DecimalW[] = {'D', 'e', 'c', 'i', 'm', 'a', 'l', 0};
static const WCHAR DateW[] = {'D', 'a', 't', 'e', 0};
static const WCHAR StringW[] = {'S', 't', 'r', 'i', 'n', 'g', 0};
static const WCHAR BooleanW[] = {'B', 'o', 'o', 'l', 'e', 'a', 'n', 0};
static const WCHAR EmptyW[] = {'E', 'm', 'p', 't', 'y', 0};
static const WCHAR NullW[] = {'N', 'u', 'l', 'l', 0};
TRACE("(%s)\n", debugstr_variant(arg));
assert(args_cnt == 1);
switch(V_VT(arg)) {
case VT_UI1:
return return_string(res, ByteW);
case VT_I2:
return return_string(res, IntegerW);
case VT_I4:
return return_string(res, LongW);
case VT_R4:
return return_string(res, SingleW);
case VT_R8:
return return_string(res, DoubleW);
case VT_CY:
return return_string(res, CurrencyW);
case VT_DECIMAL:
return return_string(res, DecimalW);
case VT_DATE:
return return_string(res, DateW);
case VT_BSTR:
return return_string(res, StringW);
case VT_BOOL:
return return_string(res, BooleanW);
case VT_EMPTY:
return return_string(res, EmptyW);
case VT_NULL:
return return_string(res, NullW);
default:
FIXME("arg %s not supported\n", debugstr_variant(arg));
return E_NOTIMPL;
}
}
static HRESULT Global_Array(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
......
......@@ -845,4 +845,16 @@ MyObject.myval = 0
Call ok(CSng(MyObject) = 0, "CSng(MyObject) = " & CSng(MyObject))
Call ok(getVT(CSng(MyObject)) = "VT_R4", "getVT(CSng(MyObject)) = " & getVT(CSng(MyObject)))
Dim MyEmpty
Call ok(TypeName(CByte(255)) = "Byte", "TypeName(CByte(255)) = " & TypeName(CByte(255)))
Call ok(TypeName(255) = "Integer", "TypeName(255) = " & TypeName(255))
Call ok(TypeName(32768) = "Long", "TypeName(32768) = " & TypeName(32768))
Call ok(TypeName(CSng(0.5)) = "Single", "TypeName(CSng(0.5)) = " & TypeName(CSng(0.5)))
Call ok(TypeName(-0.5) = "Double", "TypeName(-0.5) = " & TypeName(-0.5))
Call ok(TypeName(CCur(0.5)) = "Currency", "TypeName(CCur(0.5)) = " & TypeName(CCur(0.5)))
Call ok(TypeName(CStr(0.5)) = "String", "TypeName(CStr(0.5)) = " & TypeName(CStr(0.5)))
Call ok(TypeName(True) = "Boolean", "TypeName(True) = " & TypeName(True))
Call ok(TypeName(MyEmpty) = "Empty", "TypeName(MyEmpty) = " & TypeName(Empty))
Call ok(TypeName(Null) = "Null", "TypeName(Null) = " & TypeName(Null))
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