[PATCH 3/4] vbscript: Implemented Sgn(try 2)
Jacek Caban
jacek at codeweavers.com
Tue Jun 24 11:50:43 CDT 2014
On 06/24/14 15:59, Shuai Meng wrote:
>
>
>
> 2014-06-19 8:30 GMT+08:00 Shuai Meng <mengshuaicalendr at gmail.com
> <mailto:mengshuaicalendr at gmail.com>>:
>
>
>
>
> 2014-06-17 17:43 GMT+08:00 Jacek Caban <jacek at codeweavers.com
> <mailto:jacek at codeweavers.com>>:
>
> On 06/17/14 07:59, Shuai Meng wrote:
> > diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
> > index c2b2edd..d21784d 100644
> > --- a/dlls/vbscript/global.c
> > +++ b/dlls/vbscript/global.c
> > @@ -1320,8 +1320,24 @@ static HRESULT Global_Int(vbdisp_t
> *This, VARIANT *arg, unsigned args_cnt, VARIA
> >
> > static HRESULT Global_Sgn(vbdisp_t *This, VARIANT *arg,
> unsigned args_cnt, VARIANT *res)
> > {
> > - FIXME("\n");
> > - return E_NOTIMPL;
> > + VARIANT v;
> > + HRESULT hres;
> > +
> > + TRACE("(%s)\n", debugstr_variant(arg));
> > +
> > + assert(args_cnt == 1);
> > +
> > + V_VT(&v) = VT_EMPTY;
> > + hres = VariantChangeType(&v, arg, VARIANT_LOCALBOOL,
> VT_R8);
> > + if (FAILED(hres))
> > + return S_OK;
>
> Please use to_double() instead. to_double may need some fixes
> (it may
> require similar changes as you did for to_string first).
>
> Yes, to_double is better and simpler.
>
> Jacek
>
>
>
> I have tried to_double, but I don't think it is as convenient as
> VariantChangeType.
Not if you fix to_double first. Just call VariantChangeType inside
to_double, like you did in to_string:
http://source.winehq.org/git/wine.git/commitdiff/6bef4da592c8be4857dc0fa179a3139835266d3c
> I have to add more types such as VT_CY and VT_EMPTY, and they don't
> work. For example, if
> 185 switch(V_VT(v)) {
> 186 case VT_EMPTY:
> 187 *ret = VT_EMPTY(v);
>
> but there is no VT_EMPTY(), how can I give ret whose type is double a
> "EMPTY" value?
Well... of course there is no. As the name suggests, the type "empty" is
empty and has no values ;) What will be result of converting empty to
double is a matter of language semantic and vbscript happens to have the
same semantic as VT_EMPTY->VT_R8 conversion in VariantChangeType.
> Why must we pick up to_double and give up VariantChangeType?
I'm not saying about giving up VariantChangeType, I just want to use it
right.
Jacek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140624/834fb7ad/attachment-0001.html>
More information about the wine-devel
mailing list