2014-06-17 17:40 GMT+08:00 Jacek Caban <jacek@codeweavers.com>:
On 06/17/14 07:59, Shuai Meng wrote:
> diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
> index 5357df8..c2b2edd 100644
> --- a/dlls/vbscript/global.c
> +++ b/dlls/vbscript/global.c
> @@ -602,8 +602,52 @@ static HRESULT Global_Oct(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIA
>
>  static HRESULT Global_VarType(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
>  {
> -    FIXME("\n");
> -    return E_NOTIMPL;
> +    TRACE("(%s)\n", debugstr_variant(arg));
> +
> +    assert(args_cnt == 1);
> +
> +    if(res) {
> +        V_VT(res) = VT_I2;
> +        switch(V_VT(arg)) {
> +            case VT_EMPTY:
> +                V_I2(res) = VT_EMPTY;
> +                break;
> +            case VT_NULL:
> +                V_I2(res) = VT_NULL;
> +                break;
> +            case VT_I2:
> +                V_I2(res) = VT_I2;
> +                break;
(...)

This all could be just:

V_I2(res) = V_VT(arg);

To handle unsupported types, you could use something like:

if(V_VT(arg) & ~VT_TYPEMASK) {
    FIXME("...");
    return E_NOTIMPL;
}

I think over these codes again,  ~VT_TYPEMASK is equal to 0, V_VT(arg) & ~VT_TYPEMASK will always be equal to 0, and then the codes belong to this if branch will never be executed, so why we write them?
if(res) {
    V_VT(res) = VT_I2;
    V_I2(res) = V_VT(arg);
}

Jacek