Changeset 71791 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 9, 2018 4:52:12 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r71784 r71791 280 280 $(VBOX_GUI_INC_DIRS) \ 281 281 $(VirtualBox_0_OUTDIR)/include \ 282 $(VBoxGlobal_0_OUTDIR)/include \ 282 283 $(VBOX_GRAPHICS_INCS) 283 284 … … 288 289 VBoxGlobal_INCS = \ 289 290 $(VBOX_GUI_INC_DIRS) \ 290 $(V irtualBox_0_OUTDIR)/include291 $(VBoxGlobal_0_OUTDIR)/include 291 292 292 293 … … 1429 1430 1430 1431 # 1431 # Generate the COM wrappers.1432 #1433 includedep $(PATH_TARGET)/VirtualBoxComWrapperFiles.dep1434 VirtualBox_BLDDIRS += $(VirtualBox_0_OUTDIR)/include1435 VirtualBox_INTERMEDIATES += $(VirtualBox_0_OUTDIR)/include/COMWrappers1436 VirtualBox_CLEAN += $(wildcard $(VirtualBox_0_OUTDIR)/include/*) $(PATH_TARGET)/VirtualBoxComWrapperFiles.dep1437 1438 #1439 # VirtualBox - GUI Application.1440 1432 # Build generated COM wrappers as part of app. 1441 1433 # 1442 VirtualBox_SOURCES += $(VirtualBox_0_OUTDIR)/include/COMWrappers.cpp 1443 1444 # 1445 # VirtualBox - GUI Global Shared Library. 1446 # Build generated COM wrappers as part of app. 1447 # 1448 VBoxGlobal_SOURCES += $(VirtualBox_0_OUTDIR)/include/COMWrappers.cpp 1449 1450 ## @todo kmk doesn't remake optional outputs when they are missing... 1451 $$(VirtualBox_0_OUTDIR)/include/COMWrappers \ 1452 + $(PATH_TARGET)/VirtualBoxComWrapperFiles.dep \ 1453 +| $(if-expr defined(VirtualBox_VBOX_COMWRAPPERS) \ 1454 , $(VirtualBox_VBOX_COMWRAPPERS) \ 1455 , $$(VirtualBox_0_OUTDIR)/include/COMEnums.h \ 1456 $$(VirtualBox_0_OUTDIR)/include/COMWrappers.cpp \ 1457 ): \ 1434 ifndef VBOX_GUI_WITH_SHARED_LIBRARY 1435 1436 # 1437 # VirtualBox - GUI Application. 1438 # 1439 includedep $(PATH_TARGET)/VirtualBoxComWrapperFiles.dep 1440 VirtualBox_BLDDIRS += $(VirtualBox_0_OUTDIR)/include 1441 VirtualBox_INTERMEDIATES += $(VirtualBox_0_OUTDIR)/include/COMWrappers 1442 VirtualBox_SOURCES += $(VirtualBox_0_OUTDIR)/include/COMWrappers.cpp 1443 VirtualBox_CLEAN += $(wildcard $(VirtualBox_0_OUTDIR)/include/*) $(PATH_TARGET)/VirtualBoxComWrapperFiles.dep 1444 1445 ## @todo kmk doesn't remake optional outputs when they are missing... 1446 $$(VirtualBox_0_OUTDIR)/include/COMWrappers \ 1447 + $(PATH_TARGET)/VirtualBoxComWrapperFiles.dep \ 1448 +| $(if-expr defined(VirtualBox_VBOX_COMWRAPPERS) \ 1449 , $(VirtualBox_VBOX_COMWRAPPERS) \ 1450 , $$(VirtualBox_0_OUTDIR)/include/COMEnums.h \ 1451 $$(VirtualBox_0_OUTDIR)/include/COMWrappers.cpp \ 1452 ): \ 1458 1453 $(VBOX_XIDL_FILE) \ 1459 1454 $(VBOX_VIRTUALBOX_SRC)/src/globals/COMWrappers.xsl \ … … 1468 1463 $(APPEND) "$@" 1469 1464 1470 # alias for generating the COM Wrappers file. 1471 testwrappers:: $$(VirtualBox_0_OUTDIR)/include/COMWrappers 1465 # alias for generating the COM Wrappers file. 1466 testwrappers:: $$(VirtualBox_0_OUTDIR)/include/COMWrappers 1467 1468 else 1469 1470 # 1471 # VirtualBox - GUI Global Shared Library. 1472 # 1473 includedep $(PATH_TARGET)/VboxGlobalComWrapperFiles.dep 1474 VBoxGlobal_BLDDIRS += $(VBoxGlobal_0_OUTDIR)/include 1475 VBoxGlobal_INTERMEDIATES += $(VBoxGlobal_0_OUTDIR)/include/COMWrappers 1476 VBoxGlobal_SOURCES += $(VBoxGlobal_0_OUTDIR)/include/COMWrappers.cpp 1477 VBoxGlobal_CLEAN += $(wildcard $(VBoxGlobal_0_OUTDIR)/include/*) $(PATH_TARGET)/VboxGlobalComWrapperFiles.dep 1478 1479 ## @todo kmk doesn't remake optional outputs when they are missing... 1480 $$(VBoxGlobal_0_OUTDIR)/include/COMWrappers \ 1481 + $(PATH_TARGET)/VBoxGlobalComWrapperFiles.dep \ 1482 +| $(if-expr defined(VBoxGlobal_VBOX_COMWRAPPERS) \ 1483 , $(VBoxGlobal_VBOX_COMWRAPPERS) \ 1484 , $$(VBoxGlobal_0_OUTDIR)/include/COMEnums.h \ 1485 $$(VBoxGlobal_0_OUTDIR)/include/COMWrappers.cpp \ 1486 ): \ 1487 $(VBOX_XIDL_FILE) \ 1488 $(VBOX_VIRTUALBOX_SRC)/src/globals/COMWrappers.xsl \ 1489 $(VBOX_FILESPLIT) \ 1490 | $$(dir $$@) 1491 $(call MSG_GENERATE,VBoxGlobal,$<,$@) 1492 $(QUIET)$(RM) -f -- "$@" "$(PATH_TARGET)/VBoxGlobalComWrapperFiles.dep" 1493 $(QUIET)$(VBOX_XSLTPROC) -o $@ \ 1494 $(VBOX_VIRTUALBOX_SRC)/src/globals/COMWrappers.xsl $< 1495 $(QUIET)$(VBOX_FILESPLIT) $@ $(VBoxGlobal_0_OUTDIR)/include \ 1496 $(PATH_TARGET)/VBoxGlobalComWrapperFiles.dep VBoxGlobal_VBOX_COMWRAPPERS 1497 $(APPEND) "$@" 1498 1499 # alias for generating the COM Wrappers file. 1500 testwrappers:: $$(VBoxGlobal_0_OUTDIR)/include/COMWrappers 1501 1502 endif 1472 1503 1473 1504 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h
r71630 r71791 810 810 }; 811 811 812 /** 813 * Partial specialization for CInterface template class above for a case when B == COMBase. 814 * 815 * We had to add it because on exporting template to a library at least on Windows there is 816 * an implicit instantiation of the createInstance() member (even if it's not used) which 817 * in case of base template uses API present in COMBaseWithEI class only, not in COMBase. 818 * 819 * @param I Brings the interface class (i.e. derived from IUnknown/nsISupports). 820 */ 821 template <class I> 822 class CInterface<I, COMBase> : public COMBase 823 { 824 public: 825 826 typedef COMBase Base; 827 typedef I Iface; 828 829 // constructors & destructor 830 831 CInterface() 832 { 833 clear(); 834 } 835 836 CInterface(const CInterface &that) : COMBase(that) 837 { 838 clear(); 839 mIface = that.mIface; 840 this->addref((IUnknown*)ptr()); 841 } 842 843 CInterface(I *pIface) 844 { 845 clear(); 846 setPtr(pIface); 847 this->addref((IUnknown*)pIface); 848 } 849 850 virtual ~CInterface() 851 { 852 detach(); 853 #ifdef RT_STRICT 854 mDead = true; 855 #endif 856 } 857 858 // utility methods 859 860 void createInstance(const CLSID &clsId) 861 { 862 AssertMsg(ptr() == NULL, ("Instance is already non-NULL\n")); 863 if (ptr() == NULL) 864 { 865 I* pObj = NULL; 866 #if !defined(VBOX_WITH_XPCOM) 867 COMBase::mRC = CoCreateInstance(clsId, NULL, CLSCTX_ALL, 868 COM_IIDOF(I), (void **)&pObj); 869 #else 870 nsCOMPtr<nsIComponentManager> manager; 871 COMBase::mRC = NS_GetComponentManager(getter_AddRefs(manager)); 872 if (SUCCEEDED(COMBase::mRC)) 873 COMBase::mRC = manager->CreateInstance(clsId, nsnull, NS_GET_IID(I), 874 (void **)&pObj); 875 #endif 876 877 if (SUCCEEDED(COMBase::mRC)) 878 setPtr(pObj); 879 else 880 setPtr(NULL); 881 } 882 } 883 884 /** 885 * Attaches to the given foreign interface pointer by querying the own 886 * interface on it. The operation may fail. 887 */ 888 template <class OI> 889 void attach(OI *pIface) 890 { 891 Assert(!mDead); 892 /* Be aware of self assignment: */ 893 I *pmIface = ptr(); 894 this->addref((IUnknown*)pIface); 895 this->release((IUnknown*)pmIface); 896 if (pIface) 897 { 898 pmIface = NULL; 899 COMBase::mRC = pIface->QueryInterface(COM_IIDOF(I), (void **)&pmIface); 900 this->release((IUnknown*)pIface); 901 setPtr(pmIface); 902 } 903 else 904 { 905 setPtr(NULL); 906 COMBase::mRC = S_OK; 907 } 908 }; 909 910 /** Specialization of attach() for our own interface I. Never fails. */ 911 void attach(I *pIface) 912 { 913 Assert(!mDead); 914 /* Be aware of self assignment: */ 915 this->addref((IUnknown*)pIface); 916 this->release((IUnknown*)ptr()); 917 setPtr(pIface); 918 COMBase::mRC = S_OK; 919 }; 920 921 /** Detaches from the underlying interface pointer. */ 922 void detach() 923 { 924 Assert(!mDead); 925 this->release((IUnknown*)ptr()); 926 setPtr(NULL); 927 } 928 929 /** Returns @c true if not attached to any interface pointer. */ 930 bool isNull() const 931 { 932 Assert(!mDead); 933 return mIface == NULL; 934 } 935 936 /** Returns @c true if attached to an interface pointer. */ 937 bool isNotNull() const 938 { 939 Assert(!mDead); 940 return mIface != NULL; 941 } 942 943 /** Returns @c true if the result code represents success (with or without warnings). */ 944 bool isOk() const { return !isNull() && SUCCEEDED(COMBase::mRC); } 945 946 /** Returns @c true if the result code represents success with one or more warnings. */ 947 bool isWarning() const { return !isNull() && SUCCEEDED_WARNING(COMBase::mRC); } 948 949 /** Returns @c true if the result code represents success with no warnings. */ 950 bool isReallyOk() const { return !isNull() && COMBase::mRC == S_OK; } 951 952 // utility operators 953 954 CInterface &operator=(const CInterface &that) 955 { 956 attach(that.ptr()); 957 COMBase::operator=(that); 958 return *this; 959 } 960 961 CInterface &operator=(I *pIface) 962 { 963 attach(pIface); 964 return *this; 965 } 966 967 /** 968 * Returns the raw interface pointer. Not intended to be used for anything 969 * else but in generated wrappers and for debugging. You've been warned. 970 */ 971 I *raw() const 972 { 973 return ptr(); 974 } 975 976 bool operator==(const CInterface &that) const { return ptr() == that.ptr(); } 977 bool operator!=(const CInterface &that) const { return ptr() != that.ptr(); } 978 979 I *ptr() const 980 { 981 Assert(!mDead); 982 return mIface; 983 } 984 985 void setPtr(I* aObj) const 986 { 987 Assert(!mDead); 988 mIface = aObj; 989 } 990 991 private: 992 993 #ifdef RT_STRICT 994 bool mDead; 995 #endif 996 mutable I *mIface; 997 998 void clear() 999 { 1000 mIface = NULL; 1001 #ifdef RT_STRICT 1002 mDead = false; 1003 #endif 1004 } 1005 }; 1006 812 1007 ///////////////////////////////////////////////////////////////////////////// 813 1008 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMWrappers.xsl
r66274 r71791 256 256 <xsl:text> * Generator : src/VBox/Frontends/VirtualBox/src/globals/COMWrappers.xsl
</xsl:text> 257 257 <xsl:text> */

</xsl:text> 258 <xsl:text>/* VirtualBox interface declarations: */
</xsl:text>259 <xsl:text>#ifndef VBOX_WITH_XPCOM
</xsl:text>260 <xsl:text># include "VirtualBox.h"
</xsl:text>261 <xsl:text>#else /* !VBOX_WITH_XPCOM */
</xsl:text>262 <xsl:text># include "VirtualBox_XPCOM.h"
</xsl:text>263 <xsl:text>#endif /* VBOX_WITH_XPCOM */

</xsl:text>264 258 <xsl:text>/* COM includes: */
</xsl:text> 265 259 <xsl:text>#include "COMEnums.h"
</xsl:text> … … 303 297 <xsl:text>_h__

</xsl:text> 304 298 <xsl:text>/* GUI includes: */
</xsl:text> 305 <xsl:text>#include "COMDefs.h"

</xsl:text> 299 <xsl:text>#include "COMDefs.h"
</xsl:text> 300 <xsl:text>#include "UILibraryDefs.h"

</xsl:text> 301 <xsl:text>/* VirtualBox interface declarations: */
</xsl:text> 302 <xsl:text>#ifndef VBOX_WITH_XPCOM
</xsl:text> 303 <xsl:text># include "VirtualBox.h"
</xsl:text> 304 <xsl:text>#else /* !VBOX_WITH_XPCOM */
</xsl:text> 305 <xsl:text># include "VirtualBox_XPCOM.h"
</xsl:text> 306 <xsl:text>#endif /* VBOX_WITH_XPCOM */

</xsl:text> 306 307 307 308 <!-- Forward declarations: --> … … 322 323 <!-- Interface wrapper declaration: --> 323 324 <xsl:text>/* Interface wrapper declaration: */
</xsl:text> 324 <xsl:text>class C</xsl:text>325 <xsl:text>class SHARED_LIBRARY_STUFF C</xsl:text> 325 326 <xsl:value-of select="substring(@name,2)"/> 326 327 <xsl:text> : public CInterface<</xsl:text>
Note:
See TracChangeset
for help on using the changeset viewer.