[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: [PATCH] vbscript: Fixed CBool
From:       Shuai Meng <mengshuaicalendr () gmail ! com>
Date:       2014-04-30 14:21:24
Message-ID: CAOhhAYMp-VxJKsCrvG6miPKh7uj4ffShxDhmN01E+F3q4Ko8yA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thank you, I got it. And I'll correct it.


2014-04-30 16:05 GMT+08:00 Jacek Caban <jacek@codeweavers.com>:

>  On 04/30/14 02:42, Shuai Meng wrote:
>
> Thank you.
>
>
> 2014-04-30 1:13 GMT+08:00 Piotr Caban <piotr.caban@gmail.com>:
>
>> On 04/29/14 17:25, Shuai Meng wrote:
>>
>>>  2014-04-29 22:25 GMT+08:00 Piotr Caban <piotr.caban@gmail.com
>>>  <mailto:piotr.caban@gmail.com>>:
>>>
>>>     No, I mean that you should do something like this:
>>>     VARIANT v;
>>>     ...
>>>     V_VT(&v) = VT_EMPTY;
>>>     hr = VariantChangeType(..., &v);
>>>     if(FAILED(hr))
>>>          return hr;
>>>     ...
>>>
>>>     if(res)
>>>          *res = v;
>>>     else
>>>          VariantClear(&v);
>>>
>>>   what will be returned after  *res =  v; or VariantClear(&v); ?
>>>
>> S_OK, because the function has succeeded.
>>
>>
> Then I think this the same as return  VariantChangeType directly. How
> about writing like this:
>
>  if(res)
> {
>     V_VT(res) = VT_EMPTY;
>     return VariantChangeType(res, arg, 0, VT_BOOL);
> }
> return S_OK;
>
>  Because whether the change succeed or not, VariantChangeType will return
> a value indicating the situation.
>
>
> Even if res is NULL (meaning that the return value is not used by the
> script), the semantic of the code needs to be the same as if it was used.
> It's just an optimization and optimizations can't change semantics. For
> example:
>
> call CBool("blah")
>
> needs to return an error and you need to perform the conversion to
> recognize the error. An other example why this is wrong is if you try to
> convert an object. In such case, default value getter needs to be called
> (and it's called by VariantChangeType in this case).
>
> Jacek
>

[Attachment #5 (text/html)]

<div dir="ltr">Thank you, I got it. And I&#39;ll correct it.</div><div \
class="gmail_extra"><br><br><div class="gmail_quote">2014-04-30 16:05 GMT+08:00 Jacek \
Caban <span dir="ltr">&lt;<a href="mailto:jacek@codeweavers.com" \
target="_blank">jacek@codeweavers.com</a>&gt;</span>:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
    <div>On 04/30/14 02:42, Shuai Meng wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Thank you.<br>
        <div class="gmail_extra"><br>
          <br>
          <div class="gmail_quote">2014-04-30 1:13 GMT+08:00 Piotr Caban
            <span dir="ltr">&lt;<a href="mailto:piotr.caban@gmail.com" \
target="_blank">piotr.caban@gmail.com</a>&gt;</span>:<br>  <blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  <div>On 04/29/14 17:25, Shuai Meng wrote:<br>
              </div>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  <div>
                  2014-04-29 22:25 GMT+08:00 Piotr Caban &lt;<a \
href="mailto:piotr.caban@gmail.com" target="_blank">piotr.caban@gmail.com</a><br>  \
                </div>
                &lt;mailto:<a href="mailto:piotr.caban@gmail.com" \
target="_blank">piotr.caban@gmail.com</a>&gt;&gt;:  <div><br>
                        No, I mean that you should do something like this:<br>
                        VARIANT v;<br>
                        ...<br>
                        V_VT(&amp;v) = VT_EMPTY;<br>
                        hr = VariantChangeType(..., &amp;v);<br>
                        if(FAILED(hr))<br>
                                return hr;<br>
                        ...<br>
                  <br>
                        if(res)<br>
                                *res = v;<br>
                        else<br>
                                VariantClear(&amp;v);<br>
                  <br>
                     what will be returned after   *res =   v; or
                  VariantClear(&amp;v); ?<br>
                </div>
              </blockquote>
              S_OK, because the function has succeeded.
              <div><br>
              </div>
            </blockquote>
            <div>  </div>
            <div>Then I think this the same as return   VariantChangeType
              directly. How about writing like this:</div>
            <div><br>
            </div>
            <div>if(res)</div>
            <div>{</div>
            <div>       V_VT(res) = VT_EMPTY;</div>
            <div>      return VariantChangeType(res, arg, 0, VT_BOOL);</div>
            <div>}</div>
            <div>return S_OK;</div>
            <div><br>
            </div>
            <div>Because whether the change succeed or not,
              VariantChangeType will return a value indicating the
              situation.</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br></div></div>
    Even if res is NULL (meaning that the return value is not used by
    the script), the semantic of the code needs to be the same as if it
    was used. It&#39;s just an optimization and optimizations can&#39;t change
    semantics. For example:<br>
    <br>
    call CBool(&quot;blah&quot;)<br>
    <br>
    needs to return an error and you need to perform the conversion to
    recognize the error. An other example why this is wrong is if you
    try to convert an object. In such case, default value getter needs
    to be called (and it&#39;s called by VariantChangeType in this case).<span \
class="HOEnZb"><font color="#888888"><br>  <br>
    Jacek<br>
  </font></span></div>

</blockquote></div><br></div>





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic