VirtualBox

Changeset 34393 in vbox for trunk/src/VBox/Main/idl


Ignore:
Timestamp:
Nov 26, 2010 2:13:35 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
68162
Message:

Main: better type checks when firing events

Location:
trunk/src/VBox/Main/idl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r34331 r34393  
    1438714387  <enum
    1438814388     name="VBoxEventType"
    14389      uuid="FA0D4183-CDCA-428E-A078-BBF5B69CA158">
     14389     uuid="BA0F90B2-3F41-4222-840D-EDD5055476A8">
    1439014390
    1439114391    <desc>
     
    1460414604      </desc>
    1460514605    </const>
    14606     <const name="OnGuestKeyboardEvent" value="64">
     14606    <const name="OnGuestKeyboard" value="64">
    1460714607      <desc>
    1460814608        See <link to="IGuestKeyboardEvent">IGuestKeyboardEvent</link>.
    1460914609      </desc>
    1461014610    </const>
    14611     <const name="OnGuestMouseEvent" value="65">
     14611    <const name="OnGuestMouse" value="65">
    1461214612      <desc>
    1461314613        See <link to="IGuestMouseEvent">IGuestMouseEvent</link>.
    1461414614      </desc>
    1461514615    </const>
    14616     <const name="OnNATRedirectEvent" value="66">
     14616    <const name="OnNATRedirect" value="66">
    1461714617      <desc>
    1461814618        See <link to="INATRedirectEvent">INATRedirectEvent</link>.
    1461914619      </desc>
    1462014620    </const>
    14621     <const name="OnHostPciDevicePlugEvent" value="67">
     14621    <const name="OnHostPciDevicePlug" value="67">
    1462214622      <desc>
    1462314623        See <link to="IHostPciDevicePlugEvent">IHostPciDevicePlugEvent</link>.
     
    1539415394    name="IGuestKeyboardEvent" extends="IEvent"
    1539515395    uuid="88394258-7006-40d4-b339-472ee3801844"
    15396     wsmap="managed" autogen="VBoxEvent" id="OnGuestKeyboardEvent"
     15396    wsmap="managed" autogen="VBoxEvent" id="OnGuestKeyboard"
    1539715397    >
    1539815398   <desc>
     
    1540915409    name="IGuestMouseEvent" extends="IReusableEvent"
    1541015410    uuid="1f85d35c-c524-40ff-8e98-307000df0992"
    15411     wsmap="managed" autogen="VBoxEvent" id="OnGuestMouseEvent"
     15411    wsmap="managed" autogen="VBoxEvent" id="OnGuestMouse"
    1541215412    >
    1541315413   <desc>
     
    1581615816    name="INATRedirectEvent" extends="IMachineEvent"
    1581715817    uuid="57DE97D7-3CBB-42A0-888F-610D5832D16B"
    15818     wsmap="managed" autogen="VBoxEvent" id="OnNATRedirectEvent"
     15818    wsmap="managed" autogen="VBoxEvent" id="OnNATRedirect"
    1581915819    >
    1582015820   <desc>
     
    1586715867      waitable="yes"
    1586815868      uuid="EDD4782B-DB74-43A0-B724-2BAA36F039CC"
    15869       wsmap="managed" autogen="VBoxEvent" id="OnHostPciDevicePlugEvent"
     15869      wsmap="managed" autogen="VBoxEvent" id="OnHostPciDevicePlug"
    1587015870    >
    1587115871   <desc>
  • trunk/src/VBox/Main/idl/comimpl.xsl

    r33063 r34393  
    118118          <xsl:value-of select="'BYTE*'" />
    119119        </xsl:when>
    120         <xsl:when test="(($type='wstring') or ($type='uuid')) and $param">
    121           <xsl:value-of select="'BSTR'" />
    122         </xsl:when>
    123         <xsl:when test="(($type='wstring') or ($type='uuid')) and not($param)">
    124           <xsl:value-of select="'Bstr'" />
     120        <xsl:when test="(($type='wstring') or ($type='uuid'))">
     121          <xsl:choose>
     122            <xsl:when test="$param and ($dir='in')">
     123              <xsl:value-of select="'CBSTR'"/>
     124            </xsl:when>
     125            <xsl:when test="$param and ($dir='out')">
     126              <xsl:value-of select="'BSTR'"/>
     127            </xsl:when>
     128            <xsl:otherwise>
     129              <xsl:value-of select="'Bstr'"/>
     130            </xsl:otherwise>
     131          </xsl:choose>
    125132        </xsl:when>
    126133        <xsl:when test="//enum[@name=$type]">
     
    624631
    625632<xsl:template name="genCommonEventCode">
    626   <xsl:text><![CDATA[
    627 HRESULT VBoxEventDesc::init(IEventSource* aSource, VBoxEventType_T aType, ...)
    628 {
    629     va_list args;
    630 
    631     mEventSource = aSource;
    632     va_start(args, aType);
    633     switch (aType)
    634     {
    635 ]]></xsl:text>
    636 
    637   <xsl:for-each select="//interface[@autogen=$G_kind]">
    638     <xsl:variable name="implName">
    639       <xsl:value-of select="substring(@name, 2)" />
    640     </xsl:variable>
    641     <xsl:call-template name="genSwitchCase">
    642       <xsl:with-param name="ifaceName" select="@name" />
    643       <xsl:with-param name="implName" select="$implName" />
    644       <xsl:with-param name="reinit" select="'no'" />
    645     </xsl:call-template>
    646   </xsl:for-each>
    647 
    648   <xsl:text><![CDATA[
    649          default:
    650             AssertFailed();
    651     }
    652     va_end(args);
    653 
    654     return S_OK;
    655 }
    656 ]]></xsl:text>
    657 
    658  <xsl:text><![CDATA[
    659 HRESULT VBoxEventDesc::reinit(VBoxEventType_T aType, ...)
    660 {
    661     va_list args;
    662 
    663     va_start(args, aType);
    664     switch (aType)
    665     {
    666 ]]></xsl:text>
    667 
    668   <xsl:for-each select="//interface[@autogen=$G_kind and @extends='IReusableEvent']">
    669     <xsl:variable name="implName">
    670       <xsl:value-of select="substring(@name, 2)" />
    671     </xsl:variable>
    672     <xsl:call-template name="genSwitchCase">
    673       <xsl:with-param name="ifaceName" select="@name" />
    674       <xsl:with-param name="implName" select="$implName" />
    675       <xsl:with-param name="reinit" select="'yes'" />
    676     </xsl:call-template>
    677   </xsl:for-each>
    678 
    679   <xsl:text><![CDATA[
    680          default:
    681             AssertFailed();
    682     }
    683     va_end(args);
    684 
    685     return S_OK;
    686 }
    687 ]]></xsl:text>
    688 
    689 </xsl:template>
    690 
    691 
    692 <xsl:template match="/">
    693633  <xsl:call-template name="fileheader">
    694634    <xsl:with-param name="name" select="'VBoxEvents.cpp'" />
     
    700640#include "EventImpl.h"
    701641]]></xsl:text>
    702 
    703642
    704643  <!-- Interfaces -->
     
    730669  </xsl:for-each>
    731670
     671  <xsl:text><![CDATA[
     672HRESULT VBoxEventDesc::init(IEventSource* aSource, VBoxEventType_T aType, ...)
     673{
     674    va_list args;
     675
     676    mEventSource = aSource;
     677    va_start(args, aType);
     678    switch (aType)
     679    {
     680]]></xsl:text>
     681
     682  <xsl:for-each select="//interface[@autogen=$G_kind]">
     683    <xsl:variable name="implName">
     684      <xsl:value-of select="substring(@name, 2)" />
     685    </xsl:variable>
     686    <xsl:call-template name="genSwitchCase">
     687      <xsl:with-param name="ifaceName" select="@name" />
     688      <xsl:with-param name="implName" select="$implName" />
     689      <xsl:with-param name="reinit" select="'no'" />
     690    </xsl:call-template>
     691  </xsl:for-each>
     692
     693  <xsl:text><![CDATA[
     694         default:
     695            AssertFailed();
     696    }
     697    va_end(args);
     698
     699    return S_OK;
     700}
     701]]></xsl:text>
     702
     703 <xsl:text><![CDATA[
     704HRESULT VBoxEventDesc::reinit(VBoxEventType_T aType, ...)
     705{
     706    va_list args;
     707
     708    va_start(args, aType);
     709    switch (aType)
     710    {
     711]]></xsl:text>
     712
     713  <xsl:for-each select="//interface[@autogen=$G_kind and @extends='IReusableEvent']">
     714    <xsl:variable name="implName">
     715      <xsl:value-of select="substring(@name, 2)" />
     716    </xsl:variable>
     717    <xsl:call-template name="genSwitchCase">
     718      <xsl:with-param name="ifaceName" select="@name" />
     719      <xsl:with-param name="implName" select="$implName" />
     720      <xsl:with-param name="reinit" select="'yes'" />
     721    </xsl:call-template>
     722  </xsl:for-each>
     723
     724  <xsl:text><![CDATA[
     725         default:
     726            AssertFailed();
     727    }
     728    va_end(args);
     729
     730    return S_OK;
     731}
     732]]></xsl:text>
     733
     734</xsl:template>
     735
     736<xsl:template name="genFormalParams">
     737  <xsl:param name="name" />
     738  <xsl:variable name="extends">
     739    <xsl:value-of select="//interface[@name=$name]/@extends" />
     740  </xsl:variable>
     741 
     742  <xsl:choose>
     743    <xsl:when test="$extends='IEvent'">
     744    </xsl:when>
     745    <xsl:when test="$extends='IReusableEvent'">
     746    </xsl:when>
     747    <xsl:when test="//interface[@name=$extends]">
     748      <xsl:call-template name="genFormalParams">
     749        <xsl:with-param name="name" select="$extends" />
     750      </xsl:call-template>
     751    </xsl:when>
     752    <xsl:otherwise>
     753      <xsl:call-template name="fatalError">
     754        <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
     755      </xsl:call-template>
     756    </xsl:otherwise>
     757  </xsl:choose>
     758
     759  <xsl:for-each select="//interface[@name=$name]/attribute">
     760    <xsl:variable name="aName" select="concat('a_',@name)"/>
     761    <xsl:variable name="aTypeName">
     762      <xsl:call-template name="typeIdl2Back">
     763        <xsl:with-param name="type" select="@type" />
     764        <xsl:with-param name="safearray" select="@safearray" />
     765        <xsl:with-param name="param" select="$aName" />
     766        <xsl:with-param name="dir" select="'in'" />
     767        <xsl:with-param name="mod" select="@mod" />
     768      </xsl:call-template>
     769    </xsl:variable>     
     770    <xsl:value-of select="concat(', ',$aTypeName)"/>
     771  </xsl:for-each>
     772</xsl:template>
     773
     774<xsl:template name="genFactParams">
     775  <xsl:param name="name" />
     776  <xsl:variable name="extends">
     777    <xsl:value-of select="//interface[@name=$name]/@extends" />
     778  </xsl:variable>
     779
     780  <xsl:choose>
     781    <xsl:when test="$extends='IEvent'">
     782    </xsl:when>
     783    <xsl:when test="$extends='IReusableEvent'">
     784    </xsl:when>
     785    <xsl:when test="//interface[@name=$extends]">
     786      <xsl:call-template name="genFactParams">
     787        <xsl:with-param name="name" select="$extends" />
     788      </xsl:call-template>
     789    </xsl:when>
     790    <xsl:otherwise>
     791      <xsl:call-template name="fatalError">
     792        <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
     793      </xsl:call-template>
     794    </xsl:otherwise>
     795  </xsl:choose>
     796
     797  <xsl:for-each select="//interface[@name=$name]/attribute">
     798    <xsl:variable name="aName" select="concat('a_',@name)"/>
     799    <xsl:choose>
     800      <xsl:when test="@safearray='yes'">
     801        <xsl:value-of select="concat(', ComSafeArrayInArg(',$aName,')')"/>
     802      </xsl:when>
     803      <xsl:otherwise>
     804        <xsl:value-of select="concat(', ',$aName)"/>
     805      </xsl:otherwise>
     806    </xsl:choose>
     807  </xsl:for-each>
     808</xsl:template>
     809
     810<xsl:template name="genCommonEventHeader">
     811  <xsl:call-template name="fileheader">
     812    <xsl:with-param name="name" select="'VBoxEvents.h'" />
     813  </xsl:call-template>
     814
     815<xsl:text><![CDATA[
     816#include "EventImpl.h"
     817]]></xsl:text>
     818
     819  <!-- Interfaces -->
     820  <xsl:for-each select="//interface[@autogen='VBoxEvent']">
     821    <xsl:value-of select="concat('// ', @name,  ' generation routine &#10;')" />
     822    <xsl:variable name="evname">
     823      <xsl:value-of select="substring(@name, 2)" />
     824    </xsl:variable>
     825    <xsl:variable name="evid">
     826      <xsl:value-of select="concat('On', substring(@name, 2, string-length(@name)-6))" />
     827    </xsl:variable>
     828
     829    <xsl:variable name="ifname">
     830      <xsl:value-of select="@name" />
     831    </xsl:variable>
     832
     833    <xsl:value-of select="concat('DECLINLINE(void) fire', $evname, '(IEventSource* aSource')"/>
     834    <xsl:call-template name="genFormalParams">
     835      <xsl:with-param name="name" select="$ifname" />
     836    </xsl:call-template>
     837    <xsl:value-of select="       ')&#10;{&#10;'"/>
     838
     839    <xsl:value-of select="       '   VBoxEventDesc evDesc;&#10;'"/>
     840    <xsl:value-of select="concat('   evDesc.init(aSource, VBoxEventType_',$evid)"/>
     841    <xsl:call-template name="genFactParams">
     842      <xsl:with-param name="name" select="$ifname" />
     843    </xsl:call-template>
     844    <xsl:value-of select="');&#10;'"/>
     845    <xsl:value-of select="       '   evDesc.fire(/* do not wait for delivery */ 0);&#10;'"/>
     846    <xsl:value-of select="       '}&#10;'"/>
     847  </xsl:for-each>
     848</xsl:template>
     849
     850<xsl:template match="/">
    732851  <!-- Global code -->
    733852   <xsl:choose>
     
    736855        </xsl:call-template>
    737856      </xsl:when>
     857      <xsl:when test="$G_kind='VBoxEventHeader'">
     858        <xsl:call-template name="genCommonEventHeader">
     859        </xsl:call-template>
     860      </xsl:when>
     861      <xsl:otherwise>
     862        <xsl:call-template name="fatalError">
     863          <xsl:with-param name="msg" select="concat('Request unsupported: ', $G_kind)" />
     864        </xsl:call-template>
     865      </xsl:otherwise>
    738866   </xsl:choose>
    739867</xsl:template>
Note: See TracChangeset for help on using the changeset viewer.

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