Changeset 85306 in vbox for trunk/src/VBox/Main/idl
- Timestamp:
- Jul 13, 2020 12:10:02 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139284
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/comimpl.xsl
r85305 r85306 35 35 <!-- $G_kind contains what kind of COM class implementation we generate --> 36 36 <xsl:variable name="G_xsltFilename" select="'autogen.xsl'" /> 37 <xsl:variable name="G_generateBstrVariants" select="'yes'" /> 37 38 38 39 … … 102 103 <xsl:param name="dir" /> 103 104 <xsl:param name="mod" /> 105 <xsl:param name="utf8str" select="'no'" /> 104 106 105 107 <xsl:choose> … … 110 112 <xsl:with-param name="safearray" select="''" /> 111 113 <xsl:with-param name="dir" select="'in'" /> 114 <xsl:with-param name="utf8str" select="$utf8str" /> 112 115 </xsl:call-template> 113 116 </xsl:variable> … … 131 134 <xsl:when test="(($type='wstring') or ($type='uuid'))"> 132 135 <xsl:choose> 133 <xsl:when test="$param and ($dir='in') ">136 <xsl:when test="$param and ($dir='in') and ($utf8str!='yes')"> 134 137 <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 &'"/> 135 141 </xsl:when> 136 142 <xsl:when test="$param and ($dir='out')"> 137 143 <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 &'"/> 138 147 </xsl:when> 139 148 <xsl:otherwise> … … 194 203 </xsl:choose> 195 204 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> 196 237 </xsl:template> 197 238 … … 264 305 <xsl:template name="genFormalParams"> 265 306 <xsl:param name="name" /> 307 <xsl:param name="utf8str" /> 266 308 <xsl:variable name="extends"> 267 309 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" /> … … 276 318 <xsl:call-template name="genFormalParams"> 277 319 <xsl:with-param name="name" select="$extends" /> 320 <xsl:with-param name="utf8str" select="$utf8str" /> 278 321 </xsl:call-template> 279 322 </xsl:when> … … 294 337 <xsl:with-param name="dir" select="'in'" /> 295 338 <xsl:with-param name="mod" select="@mod" /> 339 <xsl:with-param name="utf8str" select="$utf8str" /> 296 340 </xsl:call-template> 297 341 </xsl:variable> … … 534 578 </xsl:call-template> 535 579 <xsl:value-of select=" ' } '" /> 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 &a_rString) </xsl:text> 583 <xsl:text> { </xsl:text> 584 <xsl:text> return </xsl:text><xsl:value-of select="$mName"/><xsl:text>.assignEx(a_rString); </xsl:text> 585 <xsl:text> } </xsl:text> 586 </xsl:if> 587 536 588 </xsl:for-each> 537 589 … … 559 611 </xsl:otherwise> 560 612 </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>) </xsl:text> 628 <xsl:text>{ </xsl:text> 629 <xsl:text> </xsl:text><xsl:value-of select="$implName"/><xsl:text> *pEvtImpl = dynamic_cast<</xsl:text> 630 <xsl:value-of select="$implName"/><xsl:text> *>(aEvent); </xsl:text> 631 <xsl:text> if (pEvtImpl) </xsl:text> 632 <xsl:text> { </xsl:text> 633 <xsl:text> pEvtImpl->Reuse(); </xsl:text> 634 <xsl:text> HRESULT hrc = S_OK; </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; </xsl:text> 640 <xsl:text> } </xsl:text> 641 <xsl:text> return E_INVALIDARG; </xsl:text> 642 <xsl:text>} </xsl:text> 643 <xsl:text> </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>) </xsl:text> 661 <xsl:text>{ </xsl:text> 662 <xsl:text> ComObjPtr<</xsl:text><xsl:value-of select="$implName"/><xsl:text>> EvtObj; </xsl:text> 663 <xsl:text> HRESULT hrc = EvtObj.createObject(); </xsl:text> 664 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text> 665 <xsl:text> { </xsl:text> 666 <xsl:text> hrc = EvtObj->init(aSource, VBoxEventType_</xsl:text><xsl:value-of select="$evid"/> 667 <xsl:text>, </xsl:text><xsl:value-of select="$waitable" /><xsl:text> /*waitable*/); </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)) </xsl:text> 673 <xsl:text> { </xsl:text> 674 <xsl:text> hrc = EvtObj.queryInterfaceTo(aEvent); </xsl:text> 675 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text> 676 <xsl:text> return hrc; </xsl:text> 677 <xsl:text> } </xsl:text> 678 <xsl:text> } </xsl:text> 679 <xsl:text> *aEvent = NULL; </xsl:text> 680 <xsl:text> return hrc; </xsl:text> 681 <xsl:text>} </xsl:text> 682 <xsl:text> </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>) </xsl:text> 696 <xsl:text>{ </xsl:text> 697 <xsl:text> AssertReturn(aSource, E_INVALIDARG); </xsl:text> 698 <xsl:text> ComPtr<IEvent> ptrEvent; </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>); </xsl:text> 705 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text> 706 <xsl:text> { </xsl:text> 707 <xsl:text> BOOL fDeliveredIgnored = FALSE; </xsl:text> 708 <xsl:text> hrc = aSource->FireEvent(ptrEvent, /* do not wait for delivery */ 0, &fDeliveredIgnored); </xsl:text> 709 <xsl:text> AssertComRC(hrc); </xsl:text> 710 <xsl:text> } </xsl:text> 711 <xsl:text> return hrc; </xsl:text> 712 <xsl:text>} </xsl:text> 713 <xsl:text> </xsl:text> 561 714 </xsl:template> 562 715 … … 716 869 </xsl:call-template> 717 870 718 <!-- Split off the remainer into separate template?-->871 <!-- Associate public functions. --> 719 872 <xsl:variable name="evname"> 720 873 <xsl:value-of select="substring(@name, 2)" /> … … 736 889 </xsl:choose> 737 890 </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> 738 896 739 897 <!-- Generate ReinitXxxxEvent functions if reusable. --> 740 898 <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'"/> 744 905 </xsl:call-template> 745 <xsl:text>) </xsl:text> 746 <xsl:text>{ </xsl:text> 747 <xsl:text> </xsl:text><xsl:value-of select="$implName"/><xsl:text> *pEvtImpl = dynamic_cast<</xsl:text> 748 <xsl:value-of select="$implName"/><xsl:text> *>(aEvent); </xsl:text> 749 <xsl:text> if (pEvtImpl) </xsl:text> 750 <xsl:text> { </xsl:text> 751 <xsl:text> pEvtImpl->Reuse(); </xsl:text> 752 <xsl:text> HRESULT hrc = S_OK; </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'"/> 756 938 </xsl:call-template> 757 <xsl:text> return hrc; </xsl:text>758 <xsl:text> } </xsl:text>759 <xsl:text> return E_INVALIDARG; </xsl:text>760 <xsl:text>} </xsl:text>761 <xsl:text> </xsl:text>762 939 </xsl:if> 763 940 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>) </xsl:text>770 <xsl:text>{ </xsl:text>771 <xsl:text> ComObjPtr<</xsl:text><xsl:value-of select="$implName"/><xsl:text>> EvtObj; </xsl:text>772 <xsl:text> HRESULT hrc = EvtObj.createObject(); </xsl:text>773 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text>774 <xsl:text> { </xsl:text>775 <xsl:text> hrc = EvtObj->init(aSource, VBoxEventType_</xsl:text><xsl:value-of select="$evid"/>776 <xsl:text>, </xsl:text><xsl:value-of select="$waitable" /><xsl:text> /*waitable*/); </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)) </xsl:text>782 <xsl:text> { </xsl:text>783 <xsl:text> hrc = EvtObj.queryInterfaceTo(aEvent); </xsl:text>784 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text>785 <xsl:text> return hrc; </xsl:text>786 <xsl:text> } </xsl:text>787 <xsl:text> } </xsl:text>788 <xsl:text> *aEvent = NULL; </xsl:text>789 <xsl:text> return hrc; </xsl:text>790 <xsl:text>} </xsl:text>791 <xsl:text> </xsl:text>792 793 941 <!-- 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>) </xsl:text> 799 <xsl:text>{ </xsl:text> 800 <xsl:text> AssertReturn(aSource, E_INVALIDARG); </xsl:text> 801 <xsl:text> ComPtr<IEvent> ptrEvent; </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>); </xsl:text> 808 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text> 809 <xsl:text> { </xsl:text> 810 <xsl:text> BOOL fDeliveredIgnored = FALSE; </xsl:text> 811 <xsl:text> hrc = aSource->FireEvent(ptrEvent, /* do not wait for delivery */ 0, &fDeliveredIgnored); </xsl:text> 812 <xsl:text> AssertComRC(hrc); </xsl:text> 813 <xsl:text> } </xsl:text> 814 <xsl:text> return hrc; </xsl:text> 815 <xsl:text>} </xsl:text> 816 <xsl:text> </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> 817 955 818 956 </xsl:template> … … 892 1030 <xsl:value-of select="@name" /> 893 1031 </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> 894 1037 895 1038 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Fire', $evname, '(IEventSource *aSource')"/> 896 1039 <xsl:call-template name="genFormalParams"> 897 1040 <xsl:with-param name="name" select="$ifname" /> 1041 <xsl:with-param name="utf8str" select="'yes'" /> 898 1042 </xsl:call-template> 899 1043 <xsl:text>); </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>); </xsl:text> 1052 </xsl:if> 900 1053 </xsl:for-each> 901 1054 <xsl:text>/** @} */ </xsl:text> … … 912 1065 <xsl:value-of select="@name" /> 913 1066 </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> 914 1072 915 1073 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/> 916 1074 <xsl:call-template name="genFormalParams"> 917 1075 <xsl:with-param name="name" select="$ifname" /> 1076 <xsl:with-param name="utf8str" select="'yes'" /> 918 1077 </xsl:call-template> 919 1078 <xsl:text>); </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>); </xsl:text> 1087 </xsl:if> 920 1088 </xsl:for-each> 921 1089 <xsl:text>/** @} */ </xsl:text> … … 934 1102 <xsl:value-of select="@name" /> 935 1103 </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> 936 1109 937 1110 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/> 938 1111 <xsl:call-template name="genFormalParams"> 939 1112 <xsl:with-param name="name" select="$ifname" /> 1113 <xsl:with-param name="utf8str" select="'yes'" /> 940 1114 </xsl:call-template> 941 1115 <xsl:text>); </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>); </xsl:text> 1124 </xsl:if> 942 1125 </xsl:if> 943 1126 </xsl:for-each>
Note:
See TracChangeset
for help on using the changeset viewer.