VirtualBox

Changeset 85306 in vbox


Ignore:
Timestamp:
Jul 13, 2020 12:10:02 PM (4 years ago)
Author:
vboxsync
Message:

Main/comimpl.xsl,++: Make it possible to pass Utf8Str rather that IN_BSTR to the event creation/fire/reinit functions. bugref:9790

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/string.cpp

    r85288 r85306  
    185185    throw std::bad_alloc();
    186186}
     187
     188HRESULT Bstr::cleanupAndCopyFromNoThrow(const char *a_pszSrc, size_t a_cchMax) RT_NOEXCEPT
     189{
     190    /*
     191     * Check for empty input (m_bstr == NULL means empty, there are no NULL strings).
     192     */
     193    cleanup();
     194    if (!a_cchMax || !a_pszSrc || !*a_pszSrc)
     195        return S_OK;
     196
     197    /*
     198     * Calculate the length and allocate a BSTR string buffer of the right
     199     * size, i.e. optimize heap usage.
     200     */
     201    HRESULT hrc;
     202    size_t cwc;
     203    int vrc = ::RTStrCalcUtf16LenEx(a_pszSrc, a_cchMax, &cwc);
     204    if (RT_SUCCESS(vrc))
     205    {
     206        m_bstr = ::SysAllocStringByteLen(NULL, (unsigned)(cwc * sizeof(OLECHAR)));
     207        if (RT_LIKELY(m_bstr))
     208        {
     209            PRTUTF16 pwsz = (PRTUTF16)m_bstr;
     210            vrc = ::RTStrToUtf16Ex(a_pszSrc, a_cchMax, &pwsz, cwc + 1, NULL);
     211            if (RT_SUCCESS(vrc))
     212                return S_OK;
     213
     214            /* This should not happen! */
     215            AssertRC(vrc);
     216            cleanup();
     217            hrc = E_UNEXPECTED;
     218        }
     219        else
     220            hrc = E_OUTOFMEMORY;
     221    }
     222    else
     223    {
     224        /* Unexpected: Invalid UTF-8 input. */
     225        AssertLogRelMsgFailed(("%Rrc %.*Rhxs\n", vrc, RTStrNLen(a_pszSrc, a_cchMax), a_pszSrc));
     226        hrc = E_UNEXPECTED;
     227    }
     228    return hrc;
     229}
     230
    187231
    188232int Bstr::compareUtf8(const char *a_pszRight, CaseSensitivity a_enmCase /*= CaseSensitive*/) const
  • trunk/src/VBox/Main/idl/comimpl.xsl

    r85305 r85306  
    3535<!-- $G_kind contains what kind of COM class implementation we generate -->
    3636<xsl:variable name="G_xsltFilename" select="'autogen.xsl'" />
     37<xsl:variable name="G_generateBstrVariants" select="'yes'" />
    3738
    3839
     
    102103  <xsl:param name="dir" />
    103104  <xsl:param name="mod" />
     105  <xsl:param name="utf8str" select="'no'" />
    104106
    105107  <xsl:choose>
     
    110112          <xsl:with-param name="safearray" select="''" />
    111113          <xsl:with-param name="dir" select="'in'" />
     114          <xsl:with-param name="utf8str" select="$utf8str" />
    112115        </xsl:call-template>
    113116      </xsl:variable>
     
    131134        <xsl:when test="(($type='wstring') or ($type='uuid'))">
    132135          <xsl:choose>
    133             <xsl:when test="$param and ($dir='in')">
     136            <xsl:when test="$param and ($dir='in') and ($utf8str!='yes')">
    134137              <xsl:value-of select="'CBSTR'"/>
     138            </xsl:when>
     139            <xsl:when test="$param and ($dir='in') and ($utf8str='yes')">
     140              <xsl:value-of select="'const Utf8Str &amp;'"/>
    135141            </xsl:when>
    136142            <xsl:when test="$param and ($dir='out')">
    137143              <xsl:value-of select="'BSTR'"/>
     144            </xsl:when>
     145            <xsl:when test="$param and ($dir='out') and ($utf8str='yes')">
     146              <xsl:value-of select="'Utf8Str &amp;'"/>
    138147            </xsl:when>
    139148            <xsl:otherwise>
     
    194203  </xsl:choose>
    195204
     205</xsl:template>
     206
     207<!-- Checks if interface $name has any string attributes, producing '1' for each string attrib.
     208     No output if no string attributes -->
     209<xsl:template name="hasStringAttributes">
     210  <xsl:param name="name" />
     211
     212  <!-- Recurse into parent interfaces: -->
     213  <xsl:variable name="extends">
     214    <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
     215  </xsl:variable>
     216  <xsl:choose>
     217    <xsl:when test="$extends='IEvent'">
     218    </xsl:when>
     219    <xsl:when test="$extends='IReusableEvent'">
     220    </xsl:when>
     221    <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
     222      <xsl:call-template name="hasStringAttributes">
     223        <xsl:with-param name="name" select="$extends" />
     224      </xsl:call-template>
     225    </xsl:when>
     226    <xsl:otherwise>
     227      <xsl:call-template name="fatalError">
     228        <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
     229      </xsl:call-template>
     230    </xsl:otherwise>
     231  </xsl:choose>
     232
     233  <!-- Find immediate string and uuid attributes and output '1' for each one: -->
     234  <xsl:for-each select="key('G_keyInterfacesByName', $name)/attribute[(@type = 'wstring' or @type = 'uuid') and (@name != 'midlDoesNotLikeEmptyInterfaces')]">
     235    <xsl:text>1</xsl:text>
     236  </xsl:for-each>
    196237</xsl:template>
    197238
     
    264305<xsl:template name="genFormalParams">
    265306  <xsl:param name="name" />
     307  <xsl:param name="utf8str" />
    266308  <xsl:variable name="extends">
    267309    <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
     
    276318      <xsl:call-template name="genFormalParams">
    277319        <xsl:with-param name="name" select="$extends" />
     320        <xsl:with-param name="utf8str" select="$utf8str" />
    278321      </xsl:call-template>
    279322    </xsl:when>
     
    294337        <xsl:with-param name="dir" select="'in'" />
    295338        <xsl:with-param name="mod" select="@mod" />
     339        <xsl:with-param name="utf8str" select="$utf8str" />
    296340      </xsl:call-template>
    297341    </xsl:variable>
     
    534578    </xsl:call-template>
    535579    <xsl:value-of select="       '    }&#10;'" />
     580
     581    <xsl:if test="(@type='wstring') or (@type = 'uuid')">
     582      <xsl:text>    inline HRESULT set_</xsl:text><xsl:value-of select="@name"/><xsl:text>(const Utf8Str &amp;a_rString)&#10;</xsl:text>
     583      <xsl:text>    {&#10;</xsl:text>
     584      <xsl:text>        return </xsl:text><xsl:value-of select="$mName"/><xsl:text>.assignEx(a_rString);&#10;</xsl:text>
     585      <xsl:text>    }&#10;</xsl:text>
     586    </xsl:if>
     587
    536588  </xsl:for-each>
    537589
     
    559611    </xsl:otherwise>
    560612  </xsl:choose>
     613</xsl:template>
     614
     615<xsl:template name="genReinitFunction">
     616  <xsl:param name="name"/>
     617  <xsl:param name="evname"/>
     618  <xsl:param name="ifname"/>
     619  <xsl:param name="implName"/>
     620  <xsl:param name="utf8str"/>
     621
     622  <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/>
     623  <xsl:call-template name="genFormalParams">
     624    <xsl:with-param name="name" select="$ifname" />
     625    <xsl:with-param name="utf8str" select="'no'" />
     626  </xsl:call-template>
     627  <xsl:text>)&#10;</xsl:text>
     628  <xsl:text>{&#10;</xsl:text>
     629  <xsl:text>    </xsl:text><xsl:value-of select="$implName"/><xsl:text> *pEvtImpl = dynamic_cast&lt;</xsl:text>
     630  <xsl:value-of select="$implName"/><xsl:text> *&gt;(aEvent);&#10;</xsl:text>
     631  <xsl:text>    if (pEvtImpl)&#10;</xsl:text>
     632  <xsl:text>    {&#10;</xsl:text>
     633  <xsl:text>        pEvtImpl->Reuse();&#10;</xsl:text>
     634  <xsl:text>        HRESULT hrc = S_OK;&#10;</xsl:text>
     635  <xsl:call-template name="genAttrInitCode">
     636    <xsl:with-param name="name" select="$name" />
     637    <xsl:with-param name="obj" select="'pEvtImpl'" />
     638  </xsl:call-template>
     639  <xsl:text>        return hrc;&#10;</xsl:text>
     640  <xsl:text>    }&#10;</xsl:text>
     641  <xsl:text>    return E_INVALIDARG;&#10;</xsl:text>
     642  <xsl:text>}&#10;</xsl:text>
     643  <xsl:text>&#10;</xsl:text>
     644</xsl:template>
     645
     646<xsl:template name="genCreateFunction">
     647  <xsl:param name="name"/>
     648  <xsl:param name="evname"/>
     649  <xsl:param name="ifname"/>
     650  <xsl:param name="implName"/>
     651  <xsl:param name="waitable"/>
     652  <xsl:param name="evid"/>
     653  <xsl:param name="utf8str"/>
     654
     655  <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/>
     656  <xsl:call-template name="genFormalParams">
     657    <xsl:with-param name="name" select="$ifname" />
     658    <xsl:with-param name="utf8str" select="$utf8str" />
     659  </xsl:call-template>
     660  <xsl:text>)&#10;</xsl:text>
     661  <xsl:text>{&#10;</xsl:text>
     662  <xsl:text>    ComObjPtr&lt;</xsl:text><xsl:value-of select="$implName"/><xsl:text>&gt; EvtObj;&#10;</xsl:text>
     663  <xsl:text>    HRESULT hrc = EvtObj.createObject();&#10;</xsl:text>
     664  <xsl:text>    if (SUCCEEDED(hrc))&#10;</xsl:text>
     665  <xsl:text>    {&#10;</xsl:text>
     666  <xsl:text>        hrc = EvtObj-&gt;init(aSource, VBoxEventType_</xsl:text><xsl:value-of select="$evid"/>
     667  <xsl:text>, </xsl:text><xsl:value-of select="$waitable" /><xsl:text> /*waitable*/);&#10;</xsl:text>
     668  <xsl:call-template name="genAttrInitCode">
     669    <xsl:with-param name="name" select="$name" />
     670    <xsl:with-param name="obj" select="'EvtObj'" />
     671  </xsl:call-template>
     672  <xsl:text>        if (SUCCEEDED(hrc))&#10;</xsl:text>
     673  <xsl:text>        {&#10;</xsl:text>
     674  <xsl:text>            hrc = EvtObj.queryInterfaceTo(aEvent);&#10;</xsl:text>
     675  <xsl:text>            if (SUCCEEDED(hrc))&#10;</xsl:text>
     676  <xsl:text>                return hrc;&#10;</xsl:text>
     677  <xsl:text>        }&#10;</xsl:text>
     678  <xsl:text>    }&#10;</xsl:text>
     679  <xsl:text>    *aEvent = NULL;&#10;</xsl:text>
     680  <xsl:text>    return hrc;&#10;</xsl:text>
     681  <xsl:text>}&#10;</xsl:text>
     682  <xsl:text>&#10;</xsl:text>
     683</xsl:template>
     684
     685<xsl:template name="genFireFunction">
     686  <xsl:param name="evname"/>
     687  <xsl:param name="ifname"/>
     688  <xsl:param name="utf8str"/>
     689
     690  <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Fire', $evname, '(IEventSource *aSource')"/>
     691  <xsl:call-template name="genFormalParams">
     692    <xsl:with-param name="name" select="$ifname" />
     693    <xsl:with-param name="utf8str" select="$utf8str" />
     694  </xsl:call-template>
     695  <xsl:text>)&#10;</xsl:text>
     696  <xsl:text>{&#10;</xsl:text>
     697  <xsl:text>    AssertReturn(aSource, E_INVALIDARG);&#10;</xsl:text>
     698  <xsl:text>    ComPtr&lt;IEvent&gt; ptrEvent;&#10;</xsl:text>
     699  <xsl:text>    HRESULT hrc = </xsl:text>
     700  <xsl:value-of select="concat('Create', $evname, '(ptrEvent.asOutParam(), aSource')"/>
     701  <xsl:call-template name="genCallParams">
     702    <xsl:with-param name="name" select="$ifname" />
     703  </xsl:call-template>
     704  <xsl:text>);&#10;</xsl:text>
     705  <xsl:text>    if (SUCCEEDED(hrc))&#10;</xsl:text>
     706  <xsl:text>    {&#10;</xsl:text>
     707  <xsl:text>        BOOL fDeliveredIgnored = FALSE;&#10;</xsl:text>
     708  <xsl:text>        hrc = aSource-&gt;FireEvent(ptrEvent, /* do not wait for delivery */ 0, &amp;fDeliveredIgnored);&#10;</xsl:text>
     709  <xsl:text>        AssertComRC(hrc);&#10;</xsl:text>
     710  <xsl:text>    }&#10;</xsl:text>
     711  <xsl:text>    return hrc;&#10;</xsl:text>
     712  <xsl:text>}&#10;</xsl:text>
     713  <xsl:text>&#10;</xsl:text>
    561714</xsl:template>
    562715
     
    716869  </xsl:call-template>
    717870
    718   <!-- Split off the remainer into separate template? -->
     871  <!-- Associate public functions. -->
    719872  <xsl:variable name="evname">
    720873    <xsl:value-of select="substring(@name, 2)" />
     
    736889    </xsl:choose>
    737890  </xsl:variable>
     891  <xsl:variable name="hasStringAttribs">
     892    <xsl:call-template name="hasStringAttributes">
     893      <xsl:with-param name="name" select="@name"/>
     894    </xsl:call-template>
     895  </xsl:variable>
    738896
    739897  <!-- Generate ReinitXxxxEvent functions if reusable. -->
    740898  <xsl:if test="$isReusable='yes'">
    741     <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/>
    742     <xsl:call-template name="genFormalParams">
    743       <xsl:with-param name="name" select="$ifname" />
     899    <xsl:call-template name="genReinitFunction">
     900      <xsl:with-param name="name" select="@name"/>
     901      <xsl:with-param name="evname" select="$evname"/>
     902      <xsl:with-param name="ifname" select="$ifname"/>
     903      <xsl:with-param name="implName" select="$implName"/>
     904      <xsl:with-param name="utf8str" select="'yes'"/>
    744905    </xsl:call-template>
    745     <xsl:text>)&#10;</xsl:text>
    746     <xsl:text>{&#10;</xsl:text>
    747     <xsl:text>    </xsl:text><xsl:value-of select="$implName"/><xsl:text> *pEvtImpl = dynamic_cast&lt;</xsl:text>
    748     <xsl:value-of select="$implName"/><xsl:text> *&gt;(aEvent);&#10;</xsl:text>
    749     <xsl:text>    if (pEvtImpl)&#10;</xsl:text>
    750     <xsl:text>    {&#10;</xsl:text>
    751     <xsl:text>        pEvtImpl->Reuse();&#10;</xsl:text>
    752     <xsl:text>        HRESULT hrc = S_OK;&#10;</xsl:text>
    753     <xsl:call-template name="genAttrInitCode">
    754       <xsl:with-param name="name" select="@name" />
    755       <xsl:with-param name="obj" select="'pEvtImpl'" />
     906
     907    <xsl:if test="($hasStringAttribs != '') and ($G_generateBstrVariants = 'yes')">
     908      <xsl:call-template name="genReinitFunction">
     909        <xsl:with-param name="name" select="@name"/>
     910        <xsl:with-param name="evname" select="$evname"/>
     911        <xsl:with-param name="ifname" select="$ifname"/>
     912        <xsl:with-param name="implName" select="$implName"/>
     913        <xsl:with-param name="utf8str" select="'no'"/>
     914      </xsl:call-template>
     915    </xsl:if>
     916  </xsl:if>
     917
     918  <!-- Generate the CreateXxxxEvent function. -->
     919  <xsl:call-template name="genCreateFunction">
     920    <xsl:with-param name="name" select="@name"/>
     921    <xsl:with-param name="evname" select="$evname"/>
     922    <xsl:with-param name="ifname" select="$ifname"/>
     923    <xsl:with-param name="implName" select="$implName"/>
     924    <xsl:with-param name="waitable" select="$waitable"/>
     925    <xsl:with-param name="evid" select="$evid"/>
     926    <xsl:with-param name="utf8str" select="'yes'"/>
     927  </xsl:call-template>
     928
     929  <xsl:if test="($hasStringAttribs != '') and ($G_generateBstrVariants = 'yes')">
     930    <xsl:call-template name="genCreateFunction">
     931      <xsl:with-param name="name" select="@name"/>
     932      <xsl:with-param name="evname" select="$evname"/>
     933      <xsl:with-param name="ifname" select="$ifname"/>
     934      <xsl:with-param name="implName" select="$implName"/>
     935      <xsl:with-param name="waitable" select="$waitable"/>
     936      <xsl:with-param name="evid" select="$evid"/>
     937      <xsl:with-param name="utf8str" select="'no'"/>
    756938    </xsl:call-template>
    757     <xsl:text>        return hrc;&#10;</xsl:text>
    758     <xsl:text>    }&#10;</xsl:text>
    759     <xsl:text>    return E_INVALIDARG;&#10;</xsl:text>
    760     <xsl:text>}&#10;</xsl:text>
    761     <xsl:text>&#10;</xsl:text>
    762939  </xsl:if>
    763940
    764   <!-- Generate the CreateXxxxEvent function. -->
    765   <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/>
    766   <xsl:call-template name="genFormalParams">
    767     <xsl:with-param name="name" select="$ifname" />
    768   </xsl:call-template>
    769   <xsl:text>)&#10;</xsl:text>
    770   <xsl:text>{&#10;</xsl:text>
    771   <xsl:text>    ComObjPtr&lt;</xsl:text><xsl:value-of select="$implName"/><xsl:text>&gt; EvtObj;&#10;</xsl:text>
    772   <xsl:text>    HRESULT hrc = EvtObj.createObject();&#10;</xsl:text>
    773   <xsl:text>    if (SUCCEEDED(hrc))&#10;</xsl:text>
    774   <xsl:text>    {&#10;</xsl:text>
    775   <xsl:text>        hrc = EvtObj-&gt;init(aSource, VBoxEventType_</xsl:text><xsl:value-of select="$evid"/>
    776   <xsl:text>, </xsl:text><xsl:value-of select="$waitable" /><xsl:text> /*waitable*/);&#10;</xsl:text>
    777   <xsl:call-template name="genAttrInitCode">
    778     <xsl:with-param name="name" select="@name" />
    779     <xsl:with-param name="obj" select="'EvtObj'" />
    780   </xsl:call-template>
    781   <xsl:text>        if (SUCCEEDED(hrc))&#10;</xsl:text>
    782   <xsl:text>        {&#10;</xsl:text>
    783   <xsl:text>            hrc = EvtObj.queryInterfaceTo(aEvent);&#10;</xsl:text>
    784   <xsl:text>            if (SUCCEEDED(hrc))&#10;</xsl:text>
    785   <xsl:text>                return hrc;&#10;</xsl:text>
    786   <xsl:text>        }&#10;</xsl:text>
    787   <xsl:text>    }&#10;</xsl:text>
    788   <xsl:text>    *aEvent = NULL;&#10;</xsl:text>
    789   <xsl:text>    return hrc;&#10;</xsl:text>
    790   <xsl:text>}&#10;</xsl:text>
    791   <xsl:text>&#10;</xsl:text>
    792 
    793941  <!-- Generate the FireXxxxEvent function. -->
    794   <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Fire', $evname, '(IEventSource *aSource')"/>
    795   <xsl:call-template name="genFormalParams">
    796     <xsl:with-param name="name" select="$ifname" />
    797   </xsl:call-template>
    798   <xsl:text>)&#10;</xsl:text>
    799   <xsl:text>{&#10;</xsl:text>
    800   <xsl:text>    AssertReturn(aSource, E_INVALIDARG);&#10;</xsl:text>
    801   <xsl:text>    ComPtr&lt;IEvent&gt; ptrEvent;&#10;</xsl:text>
    802   <xsl:text>    HRESULT hrc = </xsl:text>
    803   <xsl:value-of select="concat('Create', $evname, '(ptrEvent.asOutParam(), aSource')"/>
    804   <xsl:call-template name="genCallParams">
    805     <xsl:with-param name="name" select="$ifname" />
    806   </xsl:call-template>
    807   <xsl:text>);&#10;</xsl:text>
    808   <xsl:text>    if (SUCCEEDED(hrc))&#10;</xsl:text>
    809   <xsl:text>    {&#10;</xsl:text>
    810   <xsl:text>        BOOL fDeliveredIgnored = FALSE;&#10;</xsl:text>
    811   <xsl:text>        hrc = aSource-&gt;FireEvent(ptrEvent, /* do not wait for delivery */ 0, &amp;fDeliveredIgnored);&#10;</xsl:text>
    812   <xsl:text>        AssertComRC(hrc);&#10;</xsl:text>
    813   <xsl:text>    }&#10;</xsl:text>
    814   <xsl:text>    return hrc;&#10;</xsl:text>
    815   <xsl:text>}&#10;</xsl:text>
    816   <xsl:text>&#10;</xsl:text>
     942  <xsl:call-template name="genFireFunction">
     943    <xsl:with-param name="evname" select="$evname"/>
     944    <xsl:with-param name="ifname" select="$ifname"/>
     945    <xsl:with-param name="utf8str" select="'yes'"/>
     946  </xsl:call-template>
     947
     948  <xsl:if test="($hasStringAttribs != '') and ($G_generateBstrVariants = 'yes')">
     949    <xsl:call-template name="genFireFunction">
     950      <xsl:with-param name="evname" select="$evname"/>
     951      <xsl:with-param name="ifname" select="$ifname"/>
     952      <xsl:with-param name="utf8str" select="'no'"/>
     953    </xsl:call-template>
     954  </xsl:if>
    817955
    818956</xsl:template>
     
    8921030      <xsl:value-of select="@name" />
    8931031    </xsl:variable>
     1032    <xsl:variable name="hasStringAttribs">
     1033      <xsl:call-template name="hasStringAttributes">
     1034        <xsl:with-param name="name" select="@name"/>
     1035      </xsl:call-template>
     1036    </xsl:variable>
    8941037
    8951038    <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Fire', $evname, '(IEventSource *aSource')"/>
    8961039    <xsl:call-template name="genFormalParams">
    8971040      <xsl:with-param name="name" select="$ifname" />
     1041      <xsl:with-param name="utf8str" select="'yes'" />
    8981042    </xsl:call-template>
    8991043    <xsl:text>);&#10;</xsl:text>
     1044
     1045    <xsl:if test="($hasStringAttribs != '') and ($G_generateBstrVariants = 'yes')">
     1046      <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Fire', $evname, '(IEventSource *aSource')"/>
     1047      <xsl:call-template name="genFormalParams">
     1048        <xsl:with-param name="name" select="$ifname" />
     1049        <xsl:with-param name="utf8str" select="'no'" />
     1050      </xsl:call-template>
     1051      <xsl:text>);&#10;</xsl:text>
     1052    </xsl:if>
    9001053  </xsl:for-each>
    9011054  <xsl:text>/** @} */&#10;&#10;</xsl:text>
     
    9121065      <xsl:value-of select="@name" />
    9131066    </xsl:variable>
     1067    <xsl:variable name="hasStringAttribs">
     1068      <xsl:call-template name="hasStringAttributes">
     1069        <xsl:with-param name="name" select="@name"/>
     1070      </xsl:call-template>
     1071    </xsl:variable>
    9141072
    9151073    <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/>
    9161074    <xsl:call-template name="genFormalParams">
    9171075      <xsl:with-param name="name" select="$ifname" />
     1076      <xsl:with-param name="utf8str" select="'yes'" />
    9181077    </xsl:call-template>
    9191078    <xsl:text>);&#10;</xsl:text>
     1079
     1080    <xsl:if test="($hasStringAttribs != '') and ($G_generateBstrVariants = 'yes')">
     1081      <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/>
     1082      <xsl:call-template name="genFormalParams">
     1083        <xsl:with-param name="name" select="$ifname" />
     1084        <xsl:with-param name="utf8str" select="'no'" />
     1085      </xsl:call-template>
     1086      <xsl:text>);&#10;</xsl:text>
     1087    </xsl:if>
    9201088  </xsl:for-each>
    9211089  <xsl:text>/** @} */&#10;</xsl:text>
     
    9341102        <xsl:value-of select="@name" />
    9351103      </xsl:variable>
     1104      <xsl:variable name="hasStringAttribs">
     1105        <xsl:call-template name="hasStringAttributes">
     1106          <xsl:with-param name="name" select="@name"/>
     1107        </xsl:call-template>
     1108      </xsl:variable>
    9361109
    9371110      <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/>
    9381111      <xsl:call-template name="genFormalParams">
    9391112        <xsl:with-param name="name" select="$ifname" />
     1113        <xsl:with-param name="utf8str" select="'yes'" />
    9401114      </xsl:call-template>
    9411115      <xsl:text>);&#10;</xsl:text>
     1116
     1117      <xsl:if test="($hasStringAttribs != '') and ($G_generateBstrVariants = 'yes')">
     1118        <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/>
     1119        <xsl:call-template name="genFormalParams">
     1120          <xsl:with-param name="name" select="$ifname" />
     1121          <xsl:with-param name="utf8str" select="'no'" />
     1122        </xsl:call-template>
     1123        <xsl:text>);&#10;</xsl:text>
     1124      </xsl:if>
    9421125    </xsl:if>
    9431126  </xsl:for-each>
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r85304 r85306  
    169169    void i_onMachineStateChanged(const Guid &aId, MachineState_T aState);
    170170    void i_onMachineDataChanged(const Guid &aId, BOOL aTemporary = FALSE);
    171     BOOL i_onExtraDataCanChange(const Guid &aId, IN_BSTR aKey, IN_BSTR aValue,
    172                                 Bstr &aError);
    173     void i_onExtraDataChanged(const Guid &aId, IN_BSTR aKey, IN_BSTR aValue);
     171    BOOL i_onExtraDataCanChange(const Guid &aId, const Utf8Str &aKey, const Utf8Str &aValue, Bstr &aError);
     172    void i_onExtraDataChanged(const Guid &aId, const Utf8Str &aKey, const Utf8Str &aValue);
    174173    void i_onMachineRegistered(const Guid &aId, BOOL aRegistered);
    175174    void i_onSessionStateChanged(const Guid &aId, SessionState_T aState);
     
    192191#endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
    193192
    194     void i_onGuestPropertyChanged(const Guid &aMachineId, IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags);
     193    void i_onGuestPropertyChanged(const Guid &aMachineId, const Utf8Str &aName, const Utf8Str &aValue, const Utf8Str &aFlags);
    195194    void i_onNatRedirectChanged(const Guid &aMachineId, ULONG ulSlot, bool fRemove, IN_BSTR aName,
    196195                                NATProtocol_T aProto, IN_BSTR aHostIp, uint16_t aHostPort,
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r85304 r85306  
    46984698        // i_onExtraDataCanChange() only briefly requests the VirtualBox
    46994699        // lock to copy the list of callbacks to invoke
    4700         Bstr error;
    4701         Bstr bstrValue(aValue);
    4702 
    4703         if (!mParent->i_onExtraDataCanChange(mData->mUuid, Bstr(aKey).raw(), bstrValue.raw(), error))
    4704         {
    4705             const char *sep = error.isEmpty() ? "" : ": ";
    4706             Log1WarningFunc(("Someone vetoed! Change refused%s%ls\n", sep, error.raw()));
     4700        Bstr bstrError;
     4701        if (!mParent->i_onExtraDataCanChange(mData->mUuid, aKey, aValue, bstrError))
     4702        {
     4703            const char *sep = bstrError.isEmpty() ? "" : ": ";
     4704            Log1WarningFunc(("Someone vetoed! Change refused%s%ls\n", sep, bstrError.raw()));
    47074705            return setError(E_ACCESSDENIED,
    47084706                            tr("Could not set extra data because someone refused the requested change of '%s' to '%s'%s%ls"),
     
    47104708                            aValue.c_str(),
    47114709                            sep,
    4712                             error.raw());
     4710                            bstrError.raw());
    47134711        }
    47144712
     
    47394737    // fire notification outside the lock
    47404738    if (fChanged)
    4741         mParent->i_onExtraDataChanged(mData->mUuid, Bstr(aKey).raw(), Bstr(aValue).raw());
     4739        mParent->i_onExtraDataChanged(mData->mUuid, aKey, aValue);
    47424740
    47434741    return S_OK;
     
    55235521            alock.release();
    55245522
    5525             mParent->i_onGuestPropertyChanged(mData->mUuid, Bstr(aName).raw(), Bstr(aValue).raw(), Bstr(aFlags).raw());
     5523            mParent->i_onGuestPropertyChanged(mData->mUuid, aName, aValue, aFlags);
    55265524        }
    55275525    }
     
    1353613534        alock.release();
    1353713535
    13538         mParent->i_onGuestPropertyChanged(mData->mUuid, Bstr(aName).raw(), Bstr(aValue).raw(), Bstr(aFlags).raw());
     13536        mParent->i_onGuestPropertyChanged(mData->mUuid, aName, aValue, aFlags);
    1353913537    }
    1354013538    catch (...)
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r85304 r85306  
    32463246    ComPtr<IEvent> ptrEvent;
    32473247    HRESULT hrc = ::CreateMediumRegisteredEvent(ptrEvent.asOutParam(), m->pEventSource,
    3248                                                 aMediumId.toUtf16().raw(), aDevType, aRegistered);
     3248                                                aMediumId.toString(), aDevType, aRegistered);
    32493249    AssertComRCReturnVoid(hrc);
    32503250    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    32743274    ComPtr<IEvent> ptrEvent;
    32753275    HRESULT hrc = ::CreateStorageControllerChangedEvent(ptrEvent.asOutParam(), m->pEventSource,
    3276                                                         aMachineId.toUtf16().raw(), Bstr(aControllerName).raw());
     3276                                                        aMachineId.toString(), aControllerName);
    32773277    AssertComRCReturnVoid(hrc);
    32783278    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    32933293{
    32943294    ComPtr<IEvent> ptrEvent;
    3295     HRESULT hrc = ::CreateMachineStateChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aState);
     3295    HRESULT hrc = ::CreateMachineStateChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toString(), aState);
    32963296    AssertComRCReturnVoid(hrc);
    32973297    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    33043304{
    33053305    ComPtr<IEvent> ptrEvent;
    3306     HRESULT hrc = ::CreateMachineDataChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aTemporary);
     3306    HRESULT hrc = ::CreateMachineDataChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toString(), aTemporary);
    33073307    AssertComRCReturnVoid(hrc);
    33083308    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    33123312 *  @note Locks this object for reading.
    33133313 */
    3314 BOOL VirtualBox::i_onExtraDataCanChange(const Guid &aId, IN_BSTR aKey, IN_BSTR aValue,
    3315                                         Bstr &aError)
    3316 {
    3317     LogFlowThisFunc(("machine={%RTuuid} aKey={%ls} aValue={%ls}\n", aId.raw(), aKey, aValue));
     3314BOOL VirtualBox::i_onExtraDataCanChange(const Guid &aId, const Utf8Str &aKey, const Utf8Str &aValue, Bstr &aError)
     3315{
     3316    LogFlowThisFunc(("machine={%RTuuid} aKey={%s} aValue={%s}\n", aId.raw(), aKey.c_str(), aValue.c_str()));
    33183317
    33193318    AutoCaller autoCaller(this);
     
    33213320
    33223321    ComPtr<IEvent> ptrEvent;
    3323     HRESULT hrc = ::CreateExtraDataCanChangeEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aKey, aValue);
     3322    HRESULT hrc = ::CreateExtraDataCanChangeEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toString(), aKey, aValue);
    33243323    AssertComRCReturn(hrc, TRUE);
    33253324
     
    33533352 *  @note Doesn't lock any object.
    33543353 */
    3355 void VirtualBox::i_onExtraDataChanged(const Guid &aId, IN_BSTR aKey, IN_BSTR aValue)
     3354void VirtualBox::i_onExtraDataChanged(const Guid &aId, const Utf8Str &aKey, const Utf8Str &aValue)
    33563355{
    33573356    ComPtr<IEvent> ptrEvent;
    3358     HRESULT hrc = ::CreateExtraDataChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aKey, aValue);
     3357    HRESULT hrc = ::CreateExtraDataChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toString(), aKey, aValue);
    33593358    AssertComRCReturnVoid(hrc);
    33603359    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    33673366{
    33683367    ComPtr<IEvent> ptrEvent;
    3369     HRESULT hrc = ::CreateMachineRegisteredEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aRegistered);
     3368    HRESULT hrc = ::CreateMachineRegisteredEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toString(), aRegistered);
    33703369    AssertComRCReturnVoid(hrc);
    33713370    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    33783377{
    33793378    ComPtr<IEvent> ptrEvent;
    3380     HRESULT hrc = ::CreateSessionStateChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aState);
     3379    HRESULT hrc = ::CreateSessionStateChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toString(), aState);
    33813380    AssertComRCReturnVoid(hrc);
    33823381    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    33903389    ComPtr<IEvent> ptrEvent;
    33913390    HRESULT hrc = ::CreateSnapshotTakenEvent(ptrEvent.asOutParam(), m->pEventSource,
    3392                                              aMachineId.toUtf16().raw(), aSnapshotId.toUtf16().raw());
     3391                                             aMachineId.toString(), aSnapshotId.toString());
    33933392    AssertComRCReturnVoid(hrc);
    33943393    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    34023401    ComPtr<IEvent> ptrEvent;
    34033402    HRESULT hrc = ::CreateSnapshotDeletedEvent(ptrEvent.asOutParam(), m->pEventSource,
    3404                                                aMachineId.toUtf16().raw(), aSnapshotId.toUtf16().raw());
     3403                                               aMachineId.toString(), aSnapshotId.toString());
    34053404    AssertComRCReturnVoid(hrc);
    34063405    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    34143413    ComPtr<IEvent> ptrEvent;
    34153414    HRESULT hrc = ::CreateSnapshotRestoredEvent(ptrEvent.asOutParam(), m->pEventSource,
    3416                                                 aMachineId.toUtf16().raw(), aSnapshotId.toUtf16().raw());
     3415                                                aMachineId.toString(), aSnapshotId.toString());
    34173416    AssertComRCReturnVoid(hrc);
    34183417    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    34263425    ComPtr<IEvent> ptrEvent;
    34273426    HRESULT hrc = ::CreateSnapshotChangedEvent(ptrEvent.asOutParam(), m->pEventSource,
    3428                                                aMachineId.toUtf16().raw(), aSnapshotId.toUtf16().raw());
     3427                                               aMachineId.toString(), aSnapshotId.toString());
    34293428    AssertComRCReturnVoid(hrc);
    34303429    i_postEvent(new AsyncEvent(this, ptrEvent));
     
    37113710 *  @note Doesn't lock any object.
    37123711 */
    3713 void VirtualBox::i_onGuestPropertyChanged(const Guid &aMachineId, IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags)
     3712void VirtualBox::i_onGuestPropertyChanged(const Guid &aMachineId, const Utf8Str &aName, const Utf8Str &aValue,
     3713                                          const Utf8Str &aFlags)
    37143714{
    37153715    ComPtr<IEvent> ptrEvent;
    37163716    HRESULT hrc = ::CreateGuestPropertyChangedEvent(ptrEvent.asOutParam(), m->pEventSource,
    3717                                                     aMachineId.toUtf16().raw(), aName, aValue, aFlags);
     3717                                                    aMachineId.toString(), aName, aValue, aFlags);
    37183718    AssertComRCReturnVoid(hrc);
    37193719    i_postEvent(new AsyncEvent(this, ptrEvent));
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette