- Timestamp:
- Jan 23, 2014 3:58:21 PM (11 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 8 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/win/VirtualBox.wxs
r49537 r50183 660 660 <?endif?> 661 661 662 <!-- C API (glue) binding --> 663 <Component Id="cp_VBoxCAPI" Guid="097F7F53-7111-467F-8E0C-257D9926FDA0"> 664 <File Id="file_VBoxCAPI.dll" Name="VBoxCAPI.dll" 665 Source="$(env.PATH_OUT)\bin\VBoxCAPI.dll" /> 666 </Component> 667 662 668 <?if $(env.VBOX_WITH_PYTHON) = "yes" ?> 663 669 <Component Id="cp_VBoxPythonBinding" Guid="293D7E11-78DA-4C31-AEED-AE2FE42F6881"> -
trunk/src/VBox/Main/cbinding/Makefile.kmk
r49539 r50183 5 5 6 6 # 7 # Copyright (C) 2009-201 3Oracle Corporation7 # Copyright (C) 2009-2014 Oracle Corporation 8 8 # 9 9 # This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 21 21 22 if defined(VBOX_WITH_XPCOM) || defined(VBOX_ONLY_SDK)23 22 # 24 23 # The samples 25 24 # 26 INSTALLS += XpComCSamples27 XpComCSamples_MODE = a+r,u+rw28 XpComCSamples_INST = \29 $(INST_SDK)bindings/ xpcom/cbinding/samples/30 XpComCSamples_SOURCES = \31 tst XPCOMCGlue.c \32 makefile.tst XPCOMCGlue=>Makefile25 INSTALLS += CAPISamples 26 CAPISamples_MODE = a+r,u+rw 27 CAPISamples_INST = \ 28 $(INST_SDK)bindings/c/samples/ 29 CAPISamples_SOURCES = \ 30 tstCAPIGlue.c \ 31 makefile.tstCAPIGlue=>Makefile 33 32 34 INSTALLS += XpComCGlue35 XpComCGlue_MODE = a+r,u+rw36 XpComCGlue_INST = \37 $(INST_SDK)bindings/ xpcom/cbinding/38 XpComCGlue_SOURCES = \39 VBox XPCOMCGlue.c \40 $( XpComCHeaders_0_OUTDIR)/VBoxXPCOMCGlue.h33 INSTALLS += CAPIGlue 34 CAPIGlue_MODE = a+r,u+rw 35 CAPIGlue_INST = \ 36 $(INST_SDK)bindings/c/glue/ 37 CAPIGlue_SOURCES = \ 38 VBoxCAPIGlue.c \ 39 $(CAPIHeaders_0_OUTDIR)/VBoxCAPIGlue.h 41 40 42 INSTALLS += XpComCHeaders43 XpComCHeaders_MODE = a+r,u+rw44 XpComCHeaders_INST = $(INST_SDK)bindings/xpcom/include/45 XpComCHeaders_SOURCES = \41 INSTALLS += CAPIHeaders 42 CAPIHeaders_MODE = a+r,u+rw 43 CAPIHeaders_INST = $(INST_SDK)bindings/c/include/ 44 CAPIHeaders_SOURCES = \ 46 45 VBoxCAPI_v2_2.h \ 47 46 VBoxCAPI_v3_0.h \ … … 51 50 VBoxCAPI_v4_1.h \ 52 51 VBoxCAPI_v4_2.h \ 53 $( XpComCHeaders_0_OUTDIR)/VBoxCAPI.h=>VBoxCAPI_v$(VBOX_API_VERSION).h52 $(CAPIHeaders_0_OUTDIR)/VBoxCAPI.h=>VBoxCAPI_v$(VBOX_API_VERSION).h 54 53 55 $$( XpComCHeaders_0_OUTDIR)/VBoxXPCOMCGlue.h: \56 $(PATH_SUB_CURRENT)/VBox XPCOMCGlue.h.in \54 $$(CAPIHeaders_0_OUTDIR)/VBoxCAPIGlue.h: \ 55 $(PATH_SUB_CURRENT)/VBoxCAPIGlue.h.in \ 57 56 $(MAKEFILE_CURRENT) \ 58 57 | $$(dir $$@) … … 62 61 < $< > $@ 63 62 64 $$( XpComCHeaders_0_OUTDIR)/VBoxCAPI.h: \65 $(PATH_SUB_CURRENT)/ xpcidl.xsl \63 $$(CAPIHeaders_0_OUTDIR)/VBoxCAPI.h: \ 64 $(PATH_SUB_CURRENT)/capiidl.xsl \ 66 65 $(VBOX_XIDL_FILE) \ 67 66 | $$(dir $$@) 68 $(call MSG_TOOL,xsltproc, XpComCHeaders,$<,$@)67 $(call MSG_TOOL,xsltproc,CAPIHeaders,$<,$@) 69 68 $(QUIET)$(VBOX_XSLTPROC) -o $@ $^ 70 69 71 endif # VBOX_WITH_XPCOM || SDK 72 if !defined(VBOX_ONLY_SDK) && defined(VBOX_WITH_XPCOM) 70 if !defined(VBOX_ONLY_SDK) 73 71 74 72 # 75 # The C utility DLL73 # The C API binding utility DLL 76 74 # 75 DLLS += VBoxCAPI 76 VBoxCAPI_TEMPLATE = VBOXMAINCLIENTDLL 77 77 ifdef VBOX_WITH_XPCOM 78 DLLS += VBoxXPCOMC 79 VBoxXPCOMC_TEMPLATE = VBOXMAINDLL 80 VBoxXPCOMC_DEFS = IN_VBOXXPCOMC 81 VBoxXPCOMC_SOURCES = \ 82 VBoxXPCOMC.cpp 83 VBoxXPCOMC_INCS = \ 84 $(XpComCHeaders_0_OUTDIR) 85 VBoxXPCOMC_INTERMEDIATES = \ 86 $(XpComCHeaders_0_OUTDIR)/VBoxCAPI.h 78 # Keep old name on XPCOM so that legacy code is happy. 79 VBoxCAPI_INST = $(INST_BIN)VBoxXPCOMC$(VBOX_SUFF_DLL) 87 80 endif 81 VBoxCAPI_DEFS = IN_VBOXCAPI 82 VBoxCAPI_SOURCES = \ 83 VBoxCAPI.cpp 84 VBoxCAPI_INCS = \ 85 $(CAPIHeaders_0_OUTDIR) 86 VBoxCAPI_INTERMEDIATES = \ 87 $(CAPIHeaders_0_OUTDIR)/VBoxCAPI.h 88 88 89 89 # 90 90 # The C glue library. 91 91 # 92 LIBRARIES += VBoxXPCOMCGlue 93 VBoxXPCOMCGlue_TEMPLATE = VBOXMAINEXE 94 VBoxXPCOMCGlue_DEFS = IN_VBOXXPCOMC 95 VBoxXPCOMCGlue_SOURCES = \ 96 VBoxXPCOMCGlue.c 97 VBoxXPCOMCGlue_INCS = \ 98 $(VBOX_PATH_SDK)/bindings/xpcom/cbinding 99 VBoxXPCOMCGlue_INTERMEDIATES = \ 100 $(VBOX_PATH_SDK)/bindings/xpcom/cbinding/VBoxXPCOMCGlue.h \ 101 $(VBOX_PATH_SDK)/bindings/xpcom/include/VBoxCAPI_v$(VBOX_API_VERSION).h 92 LIBRARIES += VBoxCAPIGlue 93 VBoxCAPIGlue_TEMPLATE = VBOXMAINEXE 94 VBoxCAPIGlue_DEFS = IN_VBOXCAPI 95 VBoxCAPIGlue_SOURCES = \ 96 VBoxCAPIGlue.c 97 ifdef VBOX_WITH_XPCOM 98 VBoxCAPIGlue_SOURCES += \ 99 $(VBOX_PATH_SDK)/bindings/xpcom/lib/VirtualBox_i.c 100 else 101 VBoxCAPIGlue_SOURCES += \ 102 $(VBOX_PATH_SDK)/bindings/mscom/lib/VirtualBox_i.c 103 endif 104 VBoxCAPIGlue_INCS = \ 105 $(VBOX_PATH_SDK)/bindings/c/include \ 106 $(VBOX_PATH_SDK)/bindings/c/glue 107 VBoxCAPIGlue_INTERMEDIATES = \ 108 $(VBOX_PATH_SDK)/bindings/c/glue/VBoxCAPIGlue.h \ 109 $(VBOX_PATH_SDK)/bindings/c/include/VBoxCAPI_v$(VBOX_API_VERSION).h 102 110 103 111 if defined(VBOX_WITH_TESTCASES) && "$(KBUILD_TARGET)" != "darwin" … … 106 114 # C testcase using the dynamic glue. 107 115 # 108 PROGRAMS += tstXPCOMCGlue 109 tstXPCOMCGlue_TEMPLATE = VBOXR3TSTEXE 110 tstXPCOMCGlue_INCS = \ 111 $(VBOX_PATH_SDK)/bindings/xpcom/include \ 112 $(VBOX_PATH_SDK)/bindings/xpcom/cbinding 113 tstXPCOMCGlue_INTERMEDIATES = \ 114 $(VBOX_PATH_SDK)/bindings/xpcom/cbinding/VBoxXPCOMCGlue.h \ 115 $(VBOX_PATH_SDK)/bindings/xpcom/include/VBoxCAPI_v$(VBOX_API_VERSION).h 116 tstXPCOMCGlue_SOURCES = \ 117 tstXPCOMCGlue.c 118 tstXPCOMCGlue_LIBS = \ 119 $(VBoxXPCOMCGlue_1_TARGET) 116 PROGRAMS += tstCAPIGlue 117 tstCAPIGlue_TEMPLATE = VBOXR3TSTEXE 118 tstCAPIGlue_INCS = \ 119 $(VBOX_PATH_SDK)/bindings/c/include \ 120 $(VBOX_PATH_SDK)/bindings/c/glue 121 ifdef VBOX_WITH_XPCOM 122 tstCAPIGlue_INCS += \ 123 $(VBOX_PATH_SDK)/bindings/xpcom/include 124 else 125 tstCAPIGlue_INCS += \ 126 $(VBOX_PATH_SDK)/bindings/mscom/include 127 endif 128 tstCAPIGlue_INTERMEDIATES = \ 129 $(VBOX_PATH_SDK)/bindings/c/glue/VBoxCAPIGlue.h \ 130 $(VBOX_PATH_SDK)/bindings/c/include/VBoxCAPI_v$(VBOX_API_VERSION).h 131 tstCAPIGlue_SOURCES = \ 132 tstCAPIGlue.c 133 tstCAPIGlue_LIBS = \ 134 $(VBoxCAPIGlue_1_TARGET) 120 135 endif 121 136 -
trunk/src/VBox/Main/cbinding/VBoxCAPI.cpp
r49984 r50183 1 1 /* $Id$ */ 2 /** @file VBox XPCOMC.cpp3 * Utility functions to use with the C binding for XPCOM.2 /** @file VBoxCAPI.cpp 3 * Utility functions to use with the C API binding. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 3Oracle Corporation7 * Copyright (C) 2009-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 #define LOG_GROUP LOG_GROUP_MAIN 19 #include <nsMemory.h> 20 #include <nsIServiceManager.h> 21 #include <nsEventQueueUtils.h> 22 #include <nsIExceptionService.h> 23 19 20 #include "VBoxCAPI.h" 21 22 #ifdef VBOX_WITH_XPCOM 23 # include <nsMemory.h> 24 # include <nsIServiceManager.h> 25 # include <nsEventQueueUtils.h> 26 # include <nsIExceptionService.h> 27 # include <stdlib.h> 28 #endif /* VBOX_WITH_XPCOM */ 29 30 #include <iprt/initterm.h> 24 31 #include <iprt/string.h> 32 #include <iprt/uuid.h> 25 33 #include <iprt/env.h> 34 #include <iprt/mem.h> 26 35 #include <VBox/log.h> 27 28 #include "VBoxCAPI.h" 36 #include <VBox/version.h> 37 29 38 #include "VBox/com/com.h" 30 #include "VBox/ version.h"39 #include "VBox/com/NativeEventQueue.h" 31 40 32 41 using namespace std; 33 42 34 /* The following 3object references should be eliminated once the legacy35 * way to initialize the XPCOM C bindings is removed. */43 /* The following 2 object references should be eliminated once the legacy 44 * way to initialize the COM/XPCOM C bindings is removed. */ 36 45 static ISession *g_Session = NULL; 37 46 static IVirtualBox *g_VirtualBox = NULL; 38 static nsIComponentManager *g_Manager = NULL; 39 47 48 #ifdef VBOX_WITH_XPCOM 49 /* This object reference should be eliminated once the legacy way of handling 50 * the event queue (XPCOM specific) is removed. */ 40 51 static nsIEventQueue *g_EventQueue = NULL; 52 #endif /* VBOX_WITH_XPCOM */ 41 53 42 54 static void VBoxComUninitialize(void); … … 44 56 45 57 static int 46 VBoxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString) 47 { 58 VBoxUtf16ToUtf8(CBSTR pwszString, char **ppszString) 59 { 60 if (!pwszString) 61 { 62 *ppszString = NULL; 63 return VINF_SUCCESS; 64 } 48 65 return RTUtf16ToUtf8(pwszString, ppszString); 49 66 } 50 67 51 68 static int 52 VBoxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString) 53 { 69 VBoxUtf8ToUtf16(const char *pszString, BSTR *ppwszString) 70 { 71 if (!pszString) 72 { 73 *ppwszString = NULL; 74 return VINF_SUCCESS; 75 } 76 #ifdef VBOX_WITH_XPCOM 54 77 return RTStrToUtf16(pszString, ppwszString); 78 #else /* !VBOX_WITH_XPCOM */ 79 PRTUTF16 pwsz; 80 int vrc = RTStrToUtf16(pszString, &pwsz); 81 *ppwszString = ::SysAllocString(pwsz); 82 RTUtf16Free(pwsz); 83 return vrc; 84 #endif /* !VBOX_WITH_XPCOM */ 55 85 } 56 86 57 87 static void 58 VBoxUtf16Free(PRUnichar *pwszString) 59 { 88 VBoxUtf16Free(BSTR pwszString) 89 { 90 #ifdef VBOX_WITH_XPCOM 60 91 RTUtf16Free(pwszString); 92 #else /* !VBOX_WITH_XPCOM */ 93 ::SysFreeString(pwszString); 94 #endif /* !VBOX_WITH_XPCOM */ 61 95 } 62 96 … … 68 102 69 103 static void 70 VBoxComUnallocMem(void *ptr) 71 { 72 if (ptr) 73 nsMemory::Free(ptr); 104 VBoxComUnallocString(BSTR pwsz) 105 { 106 if (pwsz) 107 { 108 #ifdef VBOX_WITH_XPCOM 109 nsMemory::Free(pwsz); 110 #else /* !VBOX_WITH_XPCOM */ 111 ::SysFreeString(pwsz); 112 #endif /* !VBOX_WITH_XPCOM */ 113 } 114 } 115 116 static void 117 VBoxComUnallocMem(void *pv) 118 { 119 VBoxComUnallocString((BSTR)pv); 120 } 121 122 static ULONG 123 VBoxVTElemSize(VARTYPE vt) 124 { 125 switch (vt) 126 { 127 case VT_BOOL: 128 case VT_I1: 129 case VT_UI1: 130 return 1; 131 case VT_I2: 132 case VT_UI2: 133 return 2; 134 case VT_I4: 135 case VT_UI4: 136 case VT_HRESULT: 137 return 4; 138 case VT_I8: 139 case VT_UI8: 140 return 8; 141 case VT_BSTR: 142 case VT_DISPATCH: 143 case VT_UNKNOWN: 144 return sizeof(void *); 145 default: 146 return 0; 147 } 148 } 149 150 static SAFEARRAY * 151 VBoxSafeArrayCreateVector(VARTYPE vt, LONG lLbound, ULONG cElements) 152 { 153 #ifdef VBOX_WITH_XPCOM 154 NOREF(lLbound); 155 ULONG cbElement = VBoxVTElemSize(vt); 156 if (!cbElement) 157 return NULL; 158 SAFEARRAY *psa = (SAFEARRAY *)RTMemAllocZ(sizeof(SAFEARRAY)); 159 if (!psa) 160 return psa; 161 if (cElements) 162 { 163 void *pv = nsMemory::Alloc(cElements * cbElement); 164 if (!pv) 165 { 166 RTMemFree(psa); 167 return NULL; 168 } 169 psa->pv = pv; 170 psa->c = cElements; 171 } 172 return psa; 173 #else /* !VBOX_WITH_XPCOM */ 174 return SafeArrayCreateVector(vt, lLbound, cElements); 175 #endif /* !VBOX_WITH_XPCOM */ 176 } 177 178 static SAFEARRAY * 179 VBoxSafeArrayOutParamAlloc(void) 180 { 181 #ifdef VBOX_WITH_XPCOM 182 return (SAFEARRAY *)RTMemAllocZ(sizeof(SAFEARRAY)); 183 #else /* !VBOX_WITH_XPCOM */ 184 return NULL; 185 #endif /* !VBOX_WITH_XPCOM */ 186 } 187 188 static HRESULT 189 VBoxSafeArrayDestroy(SAFEARRAY *psa) 190 { 191 #ifdef VBOX_WITH_XPCOM 192 if (psa) 193 { 194 if (psa->pv) 195 nsMemory::Free(psa->pv); 196 RTMemFree(psa); 197 } 198 return S_OK; 199 #else /* !VBOX_WITH_XPCOM */ 200 return SafeArrayDestroy(psa); 201 #endif /* !VBOX_WITH_XPCOM */ 202 } 203 204 static HRESULT 205 VBoxSafeArrayCopyInParamHelper(SAFEARRAY *psa, const void *pv, ULONG cb) 206 { 207 if (!pv || !psa) 208 return E_POINTER; 209 if (!cb) 210 return S_OK; 211 212 void *pData; 213 #ifdef VBOX_WITH_XPCOM 214 pData = psa->pv; 215 #else /* !VBOX_WITH_XPCOM */ 216 HRESULT rc = SafeArrayAccessData(psa, &pData); 217 if (FAILED(rc)) 218 return rc; 219 #endif /* !VBOX_WITH_XPCOM */ 220 memcpy(pData, pv, cb); 221 #ifndef VBOX_WITH_XPCOM 222 SafeArrayUnaccessData(psa); 223 #endif /* !VBOX_WITH_XPCOM */ 224 return S_OK; 225 } 226 227 static HRESULT 228 VBoxSafeArrayCopyOutParamHelper(void **ppv, ULONG *pcb, VARTYPE vt, SAFEARRAY *psa) 229 { 230 if (!ppv) 231 return E_POINTER; 232 ULONG cbElement = VBoxVTElemSize(vt); 233 if (!cbElement) 234 return E_INVALIDARG; 235 #ifndef VBOX_WITH_XPCOM 236 if (psa->cDims != 1) 237 return E_INVALIDARG; 238 Assert(cbElement = psa->cbElements); 239 #endif /* !VBOX_WITH_XPCOM */ 240 void *pData; 241 ULONG cElements; 242 #ifdef VBOX_WITH_XPCOM 243 pData = psa->pv; 244 cElements = psa->c; 245 #else /* !VBOX_WITH_XPCOM */ 246 HRESULT rc = SafeArrayAccessData(psa, &pData); 247 if (FAILED(rc)) 248 return rc; 249 cElements = psa->rgsabound[0].cElements; 250 #endif /* !VBOX_WITH_XPCOM */ 251 size_t cbTotal = cbElement * cElements; 252 void *pv = malloc(cbTotal); 253 if (pv) 254 { 255 memcpy(pv, pData, cbTotal); 256 *ppv = pv; 257 if (pcb) 258 *pcb = (ULONG)cbTotal; 259 } 260 #ifndef VBOX_WITH_XPCOM 261 SafeArrayUnaccessData(psa); 262 #endif /* !VBOX_WITH_XPCOM */ 263 return S_OK; 264 } 265 266 static HRESULT 267 VBoxSafeArrayCopyOutIfaceParamHelper(IUnknown ***ppaObj, ULONG *pcObj, SAFEARRAY *psa) 268 { 269 ULONG mypcb; 270 HRESULT rc = VBoxSafeArrayCopyOutParamHelper((void **)ppaObj, &mypcb, VT_UNKNOWN, psa); 271 if (FAILED(rc)) 272 return rc; 273 ULONG cElements = mypcb / sizeof(void *); 274 if (pcObj) 275 *pcObj = cElements; 276 #ifndef VBOX_WITH_XPCOM 277 /* Do this only for COM, as there the SAFEARRAY destruction will release 278 * the contained references automatically. XPCOM doesn't do that, which 279 * means that copying implicitly transfers ownership. */ 280 IUnknown **paObj = *ppaObj; 281 for (ULONG i = 0; i < cElements; i++) 282 { 283 IUnknown *pObj = paObj[i]; 284 if (pObj) 285 pObj->AddRef(); 286 } 287 #endif /* VBOX_WITH_XPCOM */ 288 return S_OK; 74 289 } 75 290 … … 78 293 const char *pszSessionIID, ISession **ppSession) 79 294 { 80 nsresultrc;81 nsID virtualBoxIID;82 nsID sessionIID;295 int vrc; 296 IID virtualBoxIID; 297 IID sessionIID; 83 298 84 299 *ppSession = NULL; 85 300 *ppVirtualBox = NULL; 86 301 87 /* convert the string representation of UUID to nsIID type */ 88 if (!(virtualBoxIID.Parse(pszVirtualBoxIID) && sessionIID.Parse(pszSessionIID))) 89 return; 90 91 rc = com::Initialize(); 92 if (NS_FAILED(rc)) 93 { 94 Log(("Cbinding: XPCOM could not be initialized! rc=%Rhrc\n", rc)); 302 /* convert the string representation of the UUIDs (if provided) to IID */ 303 if (pszVirtualBoxIID && *pszVirtualBoxIID) 304 { 305 vrc = ::RTUuidFromStr((RTUUID *)&virtualBoxIID, pszVirtualBoxIID); 306 if (RT_FAILURE(vrc)) 307 return; 308 } 309 else 310 virtualBoxIID = IID_IVirtualBox; 311 if (pszSessionIID && *pszSessionIID) 312 { 313 vrc = ::RTUuidFromStr((RTUUID *)&sessionIID, pszSessionIID); 314 if (RT_FAILURE(vrc)) 315 return; 316 } 317 else 318 sessionIID = IID_ISession; 319 320 HRESULT rc = com::Initialize(); 321 if (FAILED(rc)) 322 { 323 Log(("Cbinding: COM/XPCOM could not be initialized! rc=%Rhrc\n", rc)); 95 324 VBoxComUninitialize(); 96 325 return; 97 326 } 98 327 99 rc = NS_GetComponentManager(&g_Manager); 100 if (NS_FAILED(rc)) 328 #ifdef VBOX_WITH_XPCOM 329 rc = NS_GetMainEventQ(&g_EventQueue); 330 if (FAILED(rc)) 331 { 332 Log(("Cbinding: Could not get XPCOM event queue! rc=%Rhrc\n", rc)); 333 VBoxComUninitialize(); 334 return; 335 } 336 #endif /* VBOX_WITH_XPCOM */ 337 338 #ifdef VBOX_WITH_XPCOM 339 nsIComponentManager *pManager; 340 rc = NS_GetComponentManager(&pManager); 341 if (FAILED(rc)) 101 342 { 102 343 Log(("Cbinding: Could not get component manager! rc=%Rhrc\n", rc)); … … 105 346 } 106 347 348 rc = pManager->CreateInstanceByContractID(NS_VIRTUALBOX_CONTRACTID, 349 nsnull, 350 virtualBoxIID, 351 (void **)&g_VirtualBox); 352 #else /* !VBOX_WITH_XPCOM */ 353 rc = CoCreateInstance(CLSID_VirtualBox, NULL, CLSCTX_LOCAL_SERVER, virtualBoxIID, (void **)&g_VirtualBox); 354 #endif /* !VBOX_WITH_XPCOM */ 355 if (FAILED(rc)) 356 { 357 Log(("Cbinding: Could not instantiate VirtualBox object! rc=%Rhrc\n",rc)); 358 #ifdef VBOX_WITH_XPCOM 359 pManager->Release(); 360 pManager = NULL; 361 #endif /* VBOX_WITH_XPCOM */ 362 VBoxComUninitialize(); 363 return; 364 } 365 366 Log(("Cbinding: IVirtualBox object created.\n")); 367 368 #ifdef VBOX_WITH_XPCOM 369 rc = pManager->CreateInstanceByContractID(NS_SESSION_CONTRACTID, 370 nsnull, 371 sessionIID, 372 (void **)&g_Session); 373 #else /* !VBOX_WITH_XPCOM */ 374 rc = CoCreateInstance(CLSID_Session, NULL, CLSCTX_INPROC_SERVER, sessionIID, (void **)&g_Session); 375 #endif /* !VBOX_WITH_XPCOM */ 376 if (FAILED(rc)) 377 { 378 Log(("Cbinding: Could not instantiate Session object! rc=%Rhrc\n",rc)); 379 #ifdef VBOX_WITH_XPCOM 380 pManager->Release(); 381 pManager = NULL; 382 #endif /* VBOX_WITH_XPCOM */ 383 VBoxComUninitialize(); 384 return; 385 } 386 387 Log(("Cbinding: ISession object created.\n")); 388 389 #ifdef VBOX_WITH_XPCOM 390 pManager->Release(); 391 pManager = NULL; 392 #endif /* VBOX_WITH_XPCOM */ 393 394 *ppSession = g_Session; 395 *ppVirtualBox = g_VirtualBox; 396 } 397 398 static void 399 VBoxComInitializeV1(IVirtualBox **ppVirtualBox, ISession **ppSession) 400 { 401 VBoxComInitialize(NULL, ppVirtualBox, NULL, ppSession); 402 } 403 404 static void 405 VBoxComUninitialize(void) 406 { 407 if (g_Session) 408 { 409 g_Session->Release(); 410 g_Session = NULL; 411 } 412 if (g_VirtualBox) 413 { 414 g_VirtualBox->Release(); 415 g_VirtualBox = NULL; 416 } 417 #ifdef VBOX_WITH_XPCOM 418 if (g_EventQueue) 419 { 420 g_EventQueue->Release(); 421 g_EventQueue = NULL; 422 } 423 #endif /* VBOX_WITH_XPCOM */ 424 com::Shutdown(); 425 Log(("Cbinding: Cleaned up the created objects.\n")); 426 } 427 428 #ifdef VBOX_WITH_XPCOM 429 static void 430 VBoxGetEventQueue(nsIEventQueue **ppEventQueue) 431 { 432 *ppEventQueue = g_EventQueue; 433 } 434 #endif /* VBOX_WITH_XPCOM */ 435 436 static int 437 VBoxProcessEventQueue(LONG64 iTimeoutMS) 438 { 439 RTMSINTERVAL iTimeout; 440 if (iTimeoutMS < 0 || iTimeoutMS > UINT32_MAX) 441 iTimeout = RT_INDEFINITE_WAIT; 442 else 443 iTimeout = (RTMSINTERVAL)iTimeoutMS; 444 int vrc = com::NativeEventQueue::getMainEventQueue()->processEventQueue(iTimeout); 445 switch (vrc) 446 { 447 case VINF_SUCCESS: 448 return 0; 449 case VINF_INTERRUPTED: 450 return 1; 451 case VERR_INTERRUPTED: 452 return 2; 453 case VERR_TIMEOUT: 454 return 3; 455 case VERR_INVALID_CONTEXT: 456 return 4; 457 default: 458 return 5; 459 } 460 } 461 462 static int 463 VBoxInterruptEventQueueProcessing(void) 464 { 465 com::NativeEventQueue::getMainEventQueue()->interruptEventQueueProcessing(); 466 return 0; 467 } 468 469 static HRESULT 470 VBoxGetException(IErrorInfo **ppException) 471 { 472 HRESULT rc; 473 474 *ppException = NULL; 475 476 #ifdef VBOX_WITH_XPCOM 477 nsIServiceManager *mgr = NULL; 478 rc = NS_GetServiceManager(&mgr); 479 if (FAILED(rc) || !mgr) 480 return rc; 481 482 IID esid = NS_IEXCEPTIONSERVICE_IID; 483 nsIExceptionService *es = NULL; 484 rc = mgr->GetServiceByContractID(NS_EXCEPTIONSERVICE_CONTRACTID, esid, (void **)&es); 485 if (FAILED(rc) || !es) 486 { 487 mgr->Release(); 488 return rc; 489 } 490 491 nsIExceptionManager *em; 492 rc = es->GetCurrentExceptionManager(&em); 493 if (FAILED(rc) || !em) 494 { 495 es->Release(); 496 mgr->Release(); 497 return rc; 498 } 499 500 nsIException *ex; 501 rc = em->GetCurrentException(&ex); 502 if (FAILED(rc)) 503 { 504 em->Release(); 505 es->Release(); 506 mgr->Release(); 507 return rc; 508 } 509 510 *ppException = ex; 511 em->Release(); 512 es->Release(); 513 mgr->Release(); 514 #else /* !VBOX_WITH_XPCOM */ 515 IErrorInfo *ex; 516 rc = ::GetErrorInfo(0, &ex); 517 if (FAILED(rc)) 518 return rc; 519 520 *ppException = ex; 521 #endif /* !VBOX_WITH_XPCOM */ 522 523 return rc; 524 } 525 526 static HRESULT 527 VBoxClearException(void) 528 { 529 HRESULT rc; 530 531 #ifdef VBOX_WITH_XPCOM 532 nsIServiceManager *mgr = NULL; 533 rc = NS_GetServiceManager(&mgr); 534 if (FAILED(rc) || !mgr) 535 return rc; 536 537 IID esid = NS_IEXCEPTIONSERVICE_IID; 538 nsIExceptionService *es = NULL; 539 rc = mgr->GetServiceByContractID(NS_EXCEPTIONSERVICE_CONTRACTID, esid, (void **)&es); 540 if (FAILED(rc) || !es) 541 { 542 mgr->Release(); 543 return rc; 544 } 545 546 nsIExceptionManager *em; 547 rc = es->GetCurrentExceptionManager(&em); 548 if (FAILED(rc) || !em) 549 { 550 es->Release(); 551 mgr->Release(); 552 return rc; 553 } 554 555 rc = em->SetCurrentException(NULL); 556 em->Release(); 557 es->Release(); 558 mgr->Release(); 559 #else /* !VBOX_WITH_XPCOM */ 560 rc = ::SetErrorInfo(0, NULL); 561 #endif /* !VBOX_WITH_XPCOM */ 562 563 return rc; 564 } 565 566 static HRESULT 567 VBoxClientInitialize(const char *pszVirtualBoxClientIID, IVirtualBoxClient **ppVirtualBoxClient) 568 { 569 IID virtualBoxClientIID; 570 571 *ppVirtualBoxClient = NULL; 572 573 /* convert the string representation of UUID to IID type */ 574 if (pszVirtualBoxClientIID && *pszVirtualBoxClientIID) 575 { 576 int vrc = ::RTUuidFromStr((RTUUID *)&virtualBoxClientIID, pszVirtualBoxClientIID); 577 if (RT_FAILURE(vrc)) 578 return E_INVALIDARG; 579 } 580 else 581 virtualBoxClientIID = IID_IVirtualBoxClient; 582 583 HRESULT rc = com::Initialize(); 584 if (FAILED(rc)) 585 { 586 Log(("Cbinding: COM/XPCOM could not be initialized! rc=%Rhrc\n", rc)); 587 VBoxClientUninitialize(); 588 return rc; 589 } 590 591 #ifdef VBOX_WITH_XPCOM 107 592 rc = NS_GetMainEventQ(&g_EventQueue); 108 593 if (NS_FAILED(rc)) 109 594 { 110 Log(("Cbinding: Could not get xpcom event queue! rc=%Rhrc\n", rc)); 111 VBoxComUninitialize(); 112 return; 113 } 114 115 rc = g_Manager->CreateInstanceByContractID(NS_VIRTUALBOX_CONTRACTID, 116 nsnull, 117 virtualBoxIID, 118 (void **)&g_VirtualBox); 119 if (NS_FAILED(rc)) 120 { 121 Log(("Cbinding: Could not instantiate VirtualBox object! rc=%Rhrc\n",rc)); 122 VBoxComUninitialize(); 123 return; 124 } 125 126 Log(("Cbinding: IVirtualBox object created.\n")); 127 128 rc = g_Manager->CreateInstanceByContractID(NS_SESSION_CONTRACTID, 129 nsnull, 130 sessionIID, 131 (void **)&g_Session); 132 if (NS_FAILED(rc)) 133 { 134 Log(("Cbinding: Could not instantiate Session object! rc=%Rhrc\n",rc)); 135 VBoxComUninitialize(); 136 return; 137 } 138 139 Log(("Cbinding: ISession object created.\n")); 140 141 *ppSession = g_Session; 142 *ppVirtualBox = g_VirtualBox; 143 } 144 145 static void 146 VBoxComInitializeV1(IVirtualBox **ppVirtualBox, ISession **ppSession) 147 { 148 VBoxComInitialize(IVIRTUALBOX_IID_STR, ppVirtualBox, 149 ISESSION_IID_STR, ppSession); 150 } 151 152 static void 153 VBoxComUninitialize(void) 154 { 155 if (g_Session) 156 { 157 NS_RELEASE(g_Session); 158 g_Session = NULL; 159 } 160 if (g_VirtualBox) 161 { 162 NS_RELEASE(g_VirtualBox); 163 g_VirtualBox = NULL; 164 } 165 if (g_EventQueue) 166 { 167 NS_RELEASE(g_EventQueue); 168 g_EventQueue = NULL; 169 } 170 if (g_Manager) 171 { 172 NS_RELEASE(g_Manager); 173 g_Manager = NULL; 174 } 175 com::Shutdown(); 176 Log(("Cbinding: Cleaned up the created objects.\n")); 177 } 178 179 static void 180 VBoxGetEventQueue(nsIEventQueue **ppEventQueue) 181 { 182 *ppEventQueue = g_EventQueue; 183 } 184 185 static nsresult 186 VBoxGetException(nsIException **ppException) 187 { 188 nsresult rc; 189 190 *ppException = NULL; 191 nsIServiceManager *mgr = NULL; 192 rc = NS_GetServiceManager(&mgr); 193 if (NS_FAILED(rc) || !mgr) 194 return rc; 195 196 nsIID esid = NS_IEXCEPTIONSERVICE_IID; 197 nsIExceptionService *es = NULL; 198 rc = mgr->GetServiceByContractID(NS_EXCEPTIONSERVICE_CONTRACTID, esid, (void **)&es); 199 if (NS_FAILED(rc) || !es) 200 { 201 NS_RELEASE(mgr); 202 return rc; 203 } 204 205 nsIExceptionManager *em; 206 rc = es->GetCurrentExceptionManager(&em); 207 if (NS_FAILED(rc) || !em) 208 { 209 NS_RELEASE(es); 210 NS_RELEASE(mgr); 211 return rc; 212 } 213 214 nsIException *ex; 215 rc = em->GetCurrentException(&ex); 216 if (NS_FAILED(rc)) 217 { 218 NS_RELEASE(em); 219 NS_RELEASE(es); 220 NS_RELEASE(mgr); 221 return rc; 222 } 223 224 *ppException = ex; 225 NS_RELEASE(em); 226 NS_RELEASE(es); 227 NS_RELEASE(mgr); 228 return rc; 229 } 230 231 static nsresult 232 VBoxClearException(void) 233 { 234 nsresult rc; 235 236 nsIServiceManager *mgr = NULL; 237 rc = NS_GetServiceManager(&mgr); 238 if (NS_FAILED(rc) || !mgr) 239 return rc; 240 241 nsIID esid = NS_IEXCEPTIONSERVICE_IID; 242 nsIExceptionService *es = NULL; 243 rc = mgr->GetServiceByContractID(NS_EXCEPTIONSERVICE_CONTRACTID, esid, (void **)&es); 244 if (NS_FAILED(rc) || !es) 245 { 246 NS_RELEASE(mgr); 247 return rc; 248 } 249 250 nsIExceptionManager *em; 251 rc = es->GetCurrentExceptionManager(&em); 252 if (NS_FAILED(rc) || !em) 253 { 254 NS_RELEASE(es); 255 NS_RELEASE(mgr); 256 return rc; 257 } 258 259 rc = em->SetCurrentException(NULL); 260 NS_RELEASE(em); 261 NS_RELEASE(es); 262 NS_RELEASE(mgr); 263 return rc; 264 } 265 266 static nsresult 267 VBoxClientInitialize(const char *pszVirtualBoxClientIID, IVirtualBoxClient **ppVirtualBoxClient) 268 { 269 nsresult rc; 270 nsID virtualBoxClientIID; 271 nsID sessionIID; 272 273 *ppVirtualBoxClient = NULL; 274 275 /* convert the string representation of UUID to nsIID type */ 276 if (!virtualBoxClientIID.Parse(pszVirtualBoxClientIID)) 277 return NS_ERROR_INVALID_ARG; 278 279 rc = com::Initialize(); 280 if (NS_FAILED(rc)) 281 { 282 Log(("Cbinding: XPCOM could not be initialized! rc=%Rhrc\n", rc)); 595 Log(("Cbinding: Could not get XPCOM event queue! rc=%Rhrc\n", rc)); 283 596 VBoxClientUninitialize(); 284 597 return rc; 285 598 } 286 599 #endif /* VBOX_WITH_XPCOM */ 600 601 #ifdef VBOX_WITH_XPCOM 287 602 nsIComponentManager *pManager; 288 603 rc = NS_GetComponentManager(&pManager); 289 if ( NS_FAILED(rc))604 if (FAILED(rc)) 290 605 { 291 606 Log(("Cbinding: Could not get component manager! rc=%Rhrc\n", rc)); 292 VBoxClientUninitialize();293 return rc;294 }295 296 rc = NS_GetMainEventQ(&g_EventQueue);297 if (NS_FAILED(rc))298 {299 Log(("Cbinding: Could not get xpcom event queue! rc=%Rhrc\n", rc));300 607 VBoxClientUninitialize(); 301 608 return rc; … … 306 613 virtualBoxClientIID, 307 614 (void **)ppVirtualBoxClient); 308 if (NS_FAILED(rc)) 615 #else /* !VBOX_WITH_XPCOM */ 616 rc = CoCreateInstance(CLSID_VirtualBoxClient, NULL, CLSCTX_INPROC_SERVER, virtualBoxClientIID, (void **)ppVirtualBoxClient); 617 #endif /* !VBOX_WITH_XPCOM */ 618 if (FAILED(rc)) 309 619 { 310 620 Log(("Cbinding: Could not instantiate VirtualBoxClient object! rc=%Rhrc\n",rc)); 621 #ifdef VBOX_WITH_XPCOM 622 pManager->Release(); 623 pManager = NULL; 624 #endif /* VBOX_WITH_XPCOM */ 311 625 VBoxClientUninitialize(); 312 626 return rc; 313 627 } 314 628 315 NS_RELEASE(pManager); 629 #ifdef VBOX_WITH_XPCOM 630 pManager->Release(); 316 631 pManager = NULL; 632 #endif /* VBOX_WITH_XPCOM */ 317 633 318 634 Log(("Cbinding: IVirtualBoxClient object created.\n")); 319 635 320 return NS_OK; 636 return S_OK; 637 } 638 639 static HRESULT 640 VBoxClientThreadInitialize(void) 641 { 642 return com::Initialize(); 643 } 644 645 static HRESULT 646 VBoxClientThreadUninitialize(void) 647 { 648 return com::Shutdown(); 321 649 } 322 650 … … 324 652 VBoxClientUninitialize(void) 325 653 { 654 #ifdef VBOX_WITH_XPCOM 326 655 if (g_EventQueue) 327 656 { … … 329 658 g_EventQueue = NULL; 330 659 } 660 #endif /* VBOX_WITH_XPCOM */ 331 661 com::Shutdown(); 332 662 Log(("Cbinding: Cleaned up the created objects.\n")); … … 345 675 } 346 676 347 VBOXXPCOMC_DECL(PCVBOXXPCOM) 348 VBoxGetXPCOMCFunctions(unsigned uVersion) 349 { 677 VBOXCAPI_DECL(PCVBOXCAPI) 678 VBoxGetCAPIFunctions(unsigned uVersion) 679 { 680 /* This is the first piece of code which knows that IPRT exists, so 681 * initialize it properly. The limited initialization in VBoxC is not 682 * sufficient, and causes trouble with com::Initialize() misbehaving. */ 683 RTR3InitDll(0); 684 350 685 /* 351 686 * The current interface version. 352 687 */ 353 static const VBOX XPCOMCs_Functions =354 { 355 sizeof(VBOX XPCOMC),356 VBOX_ XPCOMC_VERSION,688 static const VBOXCAPI s_Functions = 689 { 690 sizeof(VBOXCAPI), 691 VBOX_CAPI_VERSION, 357 692 358 693 VBoxVersion, … … 360 695 361 696 VBoxClientInitialize, 697 VBoxClientThreadInitialize, 698 VBoxClientThreadUninitialize, 362 699 VBoxClientUninitialize, 363 700 … … 365 702 VBoxComUninitialize, 366 703 367 VBoxComUnalloc Mem,704 VBoxComUnallocString, 368 705 369 706 VBoxUtf16ToUtf8, … … 372 709 VBoxUtf16Free, 373 710 711 VBoxSafeArrayCreateVector, 712 VBoxSafeArrayOutParamAlloc, 713 VBoxSafeArrayCopyInParamHelper, 714 VBoxSafeArrayCopyOutParamHelper, 715 VBoxSafeArrayCopyOutIfaceParamHelper, 716 VBoxSafeArrayDestroy, 717 718 #ifdef VBOX_WITH_XPCOM 374 719 VBoxGetEventQueue, 720 #endif /* VBOX_WITH_XPCOM */ 375 721 VBoxGetException, 376 722 VBoxClearException, 377 378 VBOX_XPCOMC_VERSION 723 VBoxProcessEventQueue, 724 VBoxInterruptEventQueueProcessing, 725 726 VBOX_CAPI_VERSION 379 727 }; 380 728 381 if ((uVersion & 0xffff0000U) == (VBOX_ XPCOMC_VERSION & 0xffff0000U))729 if ((uVersion & 0xffff0000U) == (VBOX_CAPI_VERSION & 0xffff0000U)) 382 730 return &s_Functions; 383 731 384 732 /* 385 * Legacy interface version 2.0.733 * Legacy interface version 3.0. 386 734 */ 387 static const struct VBOX XPCOMCV2735 static const struct VBOXCAPIV3 388 736 { 389 737 /** The size of the structure. */ … … 394 742 unsigned int (*pfnGetVersion)(void); 395 743 744 unsigned int (*pfnGetAPIVersion)(void); 745 746 HRESULT (*pfnClientInitialize)(const char *pszVirtualBoxClientIID, 747 IVirtualBoxClient **ppVirtualBoxClient); 748 void (*pfnClientUninitialize)(void); 749 396 750 void (*pfnComInitialize)(const char *pszVirtualBoxIID, 397 751 IVirtualBox **ppVirtualBox, … … 402 756 403 757 void (*pfnComUnallocMem)(void *pv); 404 void (*pfnUtf16Free)(PRUnichar *pwszString); 758 759 int (*pfnUtf16ToUtf8)(CBSTR pwszString, char **ppszString); 760 int (*pfnUtf8ToUtf16)(const char *pszString, BSTR *ppwszString); 405 761 void (*pfnUtf8Free)(char *pszString); 406 407 int (*pfnUtf16ToUtf8)(const PRUnichar *pwszString, char **ppszString); 408 int (*pfnUtf8ToUtf16)(const char *pszString, PRUnichar **ppwszString); 409 762 void (*pfnUtf16Free)(BSTR pwszString); 763 764 #ifdef VBOX_WITH_XPCOM 410 765 void (*pfnGetEventQueue)(nsIEventQueue **ppEventQueue); 766 #endif /* VBOX_WITH_XPCOM */ 767 HRESULT (*pfnGetException)(IErrorInfo **ppException); 768 HRESULT (*pfnClearException)(void); 411 769 412 770 /** Tail version, same as uVersion. */ 413 771 unsigned uEndVersion; 414 } s_Functions_v 2_0 =415 { 416 sizeof(s_Functions_v 2_0),417 0x000 20000U,772 } s_Functions_v3_0 = 773 { 774 sizeof(s_Functions_v3_0), 775 0x00030000U, 418 776 419 777 VBoxVersion, 778 VBoxAPIVersion, 779 780 VBoxClientInitialize, 781 VBoxClientUninitialize, 420 782 421 783 VBoxComInitialize, … … 423 785 424 786 VBoxComUnallocMem, 425 VBoxUtf16Free,426 VBoxUtf8Free,427 787 428 788 VBoxUtf16ToUtf8, 429 789 VBoxUtf8ToUtf16, 430 790 VBoxUtf8Free, 791 VBoxUtf16Free, 792 793 #ifdef VBOX_WITH_XPCOM 431 794 VBoxGetEventQueue, 432 433 0x00020000U 795 #endif /* VBOX_WITH_XPCOM */ 796 VBoxGetException, 797 VBoxClearException, 798 799 0x00030000U 434 800 }; 435 801 436 if ((uVersion & 0xffff0000U) == 0x000 20000U)437 return (PCVBOX XPCOM)&s_Functions_v2_0;802 if ((uVersion & 0xffff0000U) == 0x00030000U) 803 return (PCVBOXCAPI)&s_Functions_v3_0; 438 804 439 805 /* 440 * Legacy interface version 1.0.806 * Legacy interface version 2.0. 441 807 */ 442 static const struct VBOX XPCOMCV1808 static const struct VBOXCAPIV2 443 809 { 444 810 /** The size of the structure. */ … … 449 815 unsigned int (*pfnGetVersion)(void); 450 816 817 void (*pfnComInitialize)(const char *pszVirtualBoxIID, 818 IVirtualBox **ppVirtualBox, 819 const char *pszSessionIID, 820 ISession **ppSession); 821 822 void (*pfnComUninitialize)(void); 823 824 void (*pfnComUnallocMem)(void *pv); 825 void (*pfnUtf16Free)(BSTR pwszString); 826 void (*pfnUtf8Free)(char *pszString); 827 828 int (*pfnUtf16ToUtf8)(CBSTR pwszString, char **ppszString); 829 int (*pfnUtf8ToUtf16)(const char *pszString, BSTR *ppwszString); 830 831 #ifdef VBOX_WITH_XPCOM 832 void (*pfnGetEventQueue)(nsIEventQueue **ppEventQueue); 833 #endif /* VBOX_WITH_XPCOM */ 834 835 /** Tail version, same as uVersion. */ 836 unsigned uEndVersion; 837 } s_Functions_v2_0 = 838 { 839 sizeof(s_Functions_v2_0), 840 0x00020000U, 841 842 VBoxVersion, 843 844 VBoxComInitialize, 845 VBoxComUninitialize, 846 847 VBoxComUnallocMem, 848 VBoxUtf16Free, 849 VBoxUtf8Free, 850 851 VBoxUtf16ToUtf8, 852 VBoxUtf8ToUtf16, 853 854 #ifdef VBOX_WITH_XPCOM 855 VBoxGetEventQueue, 856 #endif /* VBOX_WITH_XPCOM */ 857 858 0x00020000U 859 }; 860 861 if ((uVersion & 0xffff0000U) == 0x00020000U) 862 return (PCVBOXCAPI)&s_Functions_v2_0; 863 864 /* 865 * Legacy interface version 1.0. 866 */ 867 static const struct VBOXCAPIV1 868 { 869 /** The size of the structure. */ 870 unsigned cb; 871 /** The structure version. */ 872 unsigned uVersion; 873 874 unsigned int (*pfnGetVersion)(void); 875 451 876 void (*pfnComInitialize)(IVirtualBox **virtualBox, ISession **session); 452 877 void (*pfnComUninitialize)(void); 453 878 454 879 void (*pfnComUnallocMem)(void *pv); 455 void (*pfnUtf16Free)( PRUnichar *pwszString);880 void (*pfnUtf16Free)(BSTR pwszString); 456 881 void (*pfnUtf8Free)(char *pszString); 457 882 458 int (*pfnUtf16ToUtf8)( const PRUnichar *pwszString, char **ppszString);459 int (*pfnUtf8ToUtf16)(const char *pszString, PRUnichar **ppwszString);883 int (*pfnUtf16ToUtf8)(CBSTR pwszString, char **ppszString); 884 int (*pfnUtf8ToUtf16)(const char *pszString, BSTR *ppwszString); 460 885 461 886 /** Tail version, same as uVersion. */ … … 482 907 483 908 if ((uVersion & 0xffff0000U) == 0x00010000U) 484 return (PCVBOX XPCOM)&s_Functions_v1_0;909 return (PCVBOXCAPI)&s_Functions_v1_0; 485 910 486 911 /* … … 490 915 } 491 916 917 #ifdef VBOX_WITH_XPCOM 918 VBOXCAPI_DECL(PCVBOXCAPI) 919 VBoxGetXPCOMCFunctions(unsigned uVersion) 920 { 921 return VBoxGetCAPIFunctions(uVersion); 922 } 923 #endif /* VBOX_WITH_XPCOM */ 492 924 /* vim: set ts=4 sw=4 et: */ -
trunk/src/VBox/Main/cbinding/VBoxCAPIGlue.c
r49984 r50183 1 1 /* $Revision$ */ 2 2 /** @file 3 * Glue code for dynamically linking to VBox XPCOMC.3 * Glue code for dynamically linking to VBoxCAPI. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2008-201 3Oracle Corporation7 * Copyright (C) 2008-2014 Oracle Corporation 8 8 * 9 9 * Permission is hereby granted, free of charge, to any person … … 32 32 * Header Files * 33 33 *******************************************************************************/ 34 #include "VBoxCAPIGlue.h" 35 34 36 #include <stdio.h> 35 37 #include <string.h> … … 37 39 #include <stdarg.h> 38 40 #include <stdint.h> 39 #include <dlfcn.h> 40 #include <pthread.h> 41 42 #include "VBoxXPCOMCGlue.h" 41 #ifndef WIN32 42 # include <dlfcn.h> 43 # include <pthread.h> 44 #else /* WIN32 */ 45 # include <Windows.h> 46 #endif /* WIN32 */ 43 47 44 48 … … 47 51 *******************************************************************************/ 48 52 #if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || defined(__FreeBSD__) 49 # define DYNLIB_NAME "VBoxXPCOMC.so"53 # define DYNLIB_NAME "VBoxXPCOMC.so" 50 54 #elif defined(__APPLE__) 51 # define DYNLIB_NAME "VBoxXPCOMC.dylib" 52 #elif defined(_MSC_VER) || defined(__OS2__) 53 # define DYNLIB_NAME "VBoxXPCOMC.dll" 55 # define DYNLIB_NAME "VBoxXPCOMC.dylib" 56 #elif defined(__OS2__) 57 # define DYNLIB_NAME "VBoxXPCOMC.dll" 58 #elif defined(WIN32) 59 # define DYNLIB_NAME "VBoxCAPI.dll" 60 # undef DYNLIB_LEGACY_NAME 54 61 #else 55 62 # error "Port me" … … 60 67 * Global Variables * 61 68 *******************************************************************************/ 62 /** The dlopen handle for VBoxXPCOMC. */ 63 void *g_hVBoxXPCOMC = NULL; 69 /** The so/dynsym/dll handle for VBoxCAPI. */ 70 #ifndef WIN32 71 void *g_hVBoxCAPI = NULL; 72 #else /* WIN32 */ 73 HMODULE g_hVBoxCAPI = NULL; 74 #endif /* WIN32 */ 64 75 /** The last load error. */ 65 char g_szVBoxErrMsg[256] ;66 /** Pointer to the VB oxXPCOMCfunction table. */67 PCVBOX XPCOMg_pVBoxFuncs = NULL;68 /** Pointer to VBoxGet XPCOMCFunctions for the loaded VBoxXPCOMCso/dylib/dll. */69 PFNVBOXGET XPCOMCFUNCTIONS g_pfnGetFunctions = NULL;76 char g_szVBoxErrMsg[256] = ""; 77 /** Pointer to the VBOXCAPI function table. */ 78 PCVBOXCAPI g_pVBoxFuncs = NULL; 79 /** Pointer to VBoxGetCAPIFunctions for the loaded VBoxCAPI so/dylib/dll. */ 80 PFNVBOXGETCAPIFUNCTIONS g_pfnGetFunctions = NULL; 70 81 71 82 typedef void FNDUMMY(void); 72 83 typedef FNDUMMY *PFNDUMMY; 73 84 /** Just a dummy global structure containing a bunch of 74 * function pointers to code which is wanted in the link. 75 * In this case this is for helping gdb as it gets hideously 76 * confused if the application doesn't drag in pthreads. 77 */ 78 PFNDUMMY g_apfnVBoxXPCOMCGlue[] = 79 { 80 (PFNDUMMY)pthread_create 85 * function pointers to code which is wanted in the link. */ 86 PFNDUMMY g_apfnVBoxCAPIGlue[] = 87 { 88 #ifndef WIN32 89 /* The following link dependency is for helping gdb as it gets hideously 90 * confused if the application doesn't drag in pthreads, but uses it. */ 91 (PFNDUMMY)pthread_create, 92 #endif /* !WIN32 */ 93 NULL 81 94 }; 82 95 … … 103 116 104 117 /** 105 * Try load VBoxXPCOMC.so/dylib/dll from the specified location and resolve all106 * the symbols we need. 118 * Try load C API .so/dylib/dll from the specified location and resolve all 119 * the symbols we need. Tries both the new style and legacy name. 107 120 * 108 121 * @returns 0 on success, -1 on failure. 109 * @param pszHome The director where to try load VBoxXPCOMC from. Can110 * be NULL.122 * @param pszHome The directory where to try load VBoxCAPI/VBoxXPCOMC 123 * from. Can be NULL. 111 124 * @param fSetAppHome Whether to set the VBOX_APP_HOME env.var. or not 112 125 * (boolean). 113 126 */ 114 static int tryLoad One(const char *pszHome, int fSetAppHome)127 static int tryLoadLibrary(const char *pszHome, int fSetAppHome) 115 128 { 116 129 size_t cchHome = pszHome ? strlen(pszHome) : 0; 117 130 size_t cbBufNeeded; 118 131 char szName[4096]; 119 int rc = -1;120 132 121 133 /* … … 143 155 if (fSetAppHome) 144 156 { 157 #ifndef WIN32 145 158 if (pszHome) 146 159 setenv("VBOX_APP_HOME", pszHome, 1 /* always override */); 147 160 else 148 161 unsetenv("VBOX_APP_HOME"); 149 } 150 g_hVBoxXPCOMC = dlopen(szName, RTLD_NOW | RTLD_LOCAL); 151 if (g_hVBoxXPCOMC) 152 { 153 PFNVBOXGETXPCOMCFUNCTIONS pfnGetFunctions; 154 pfnGetFunctions = (PFNVBOXGETXPCOMCFUNCTIONS)(uintptr_t) 155 dlsym(g_hVBoxXPCOMC, VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME); 162 #endif /* !WIN32 */ 163 } 164 165 #ifndef WIN32 166 g_hVBoxCAPI = dlopen(szName, RTLD_NOW | RTLD_LOCAL); 167 if (g_hVBoxCAPI) 168 { 169 PFNVBOXGETCAPIFUNCTIONS pfnGetFunctions; 170 pfnGetFunctions = (PFNVBOXGETCAPIFUNCTIONS)(uintptr_t) 171 dlsym(g_hVBoxCAPI, VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME); 172 #ifdef VBOX_GET_XPCOM_FUNCTIONS_SYMBOL_NAME 173 if (!pfnGetFunctions) 174 pfnGetFunctions = (PFNVBOXGETCAPIFUNCTIONS)(uintptr_t) 175 dlsym(g_hVBoxCAPI, VBOX_GET_XPCOM_FUNCTIONS_SYMBOL_NAME); 176 #endif /* VBOX_GET_XPCOM_FUNCTIONS_SYMBOL_NAME */ 156 177 if (pfnGetFunctions) 157 178 { 158 g_pVBoxFuncs = pfnGetFunctions(VBOX_ XPCOMC_VERSION);179 g_pVBoxFuncs = pfnGetFunctions(VBOX_CAPI_VERSION); 159 180 if (g_pVBoxFuncs) 160 181 { … … 165 186 /* bail out */ 166 187 setErrMsg(1, "%.80s: pfnGetFunctions(%#x) failed", 167 szName, VBOX_ XPCOMC_VERSION);188 szName, VBOX_CAPI_VERSION); 168 189 } 169 190 else 170 191 setErrMsg(1, "dlsym(%.80s/%.32s): %.128s", 171 szName, VBOX_GET_ XPCOMC_FUNCTIONS_SYMBOL_NAME, dlerror());172 dlclose(g_hVBox XPCOMC);173 g_hVBox XPCOMC= NULL;192 szName, VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME, dlerror()); 193 dlclose(g_hVBoxCAPI); 194 g_hVBoxCAPI = NULL; 174 195 } 175 196 else 176 197 setErrMsg(0, "dlopen(%.80s): %.160s", szName, dlerror()); 177 return rc; 198 #else /* !WIN32 */ 199 g_hVBoxCAPI = LoadLibraryExA(szName, NULL /* hFile */, 0 /* dwFlags */); 200 if (g_hVBoxCAPI) 201 { 202 PFNVBOXGETCAPIFUNCTIONS pfnGetFunctions; 203 pfnGetFunctions = (PFNVBOXGETCAPIFUNCTIONS) 204 GetProcAddress(g_hVBoxCAPI, VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME); 205 if (pfnGetFunctions) 206 { 207 g_pVBoxFuncs = pfnGetFunctions(VBOX_CAPI_VERSION); 208 if (g_pVBoxFuncs) 209 { 210 g_pfnGetFunctions = pfnGetFunctions; 211 return 0; 212 } 213 214 /* bail out */ 215 setErrMsg(1, "%.80s: pfnGetFunctions(%#x) failed", 216 szName, VBOX_CAPI_VERSION); 217 } 218 else 219 setErrMsg(1, "GetProcAddress(%.80s/%.32s): %d", 220 szName, VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME, GetLastError()); 221 FreeLibrary(g_hVBoxCAPI); 222 g_hVBoxCAPI = NULL; 223 } 224 else 225 setErrMsg(0, "LoadLibraryEx(%.80s): %d", szName, GetLastError()); 226 #endif /* !WIN32 */ 227 228 return -1; 178 229 } 179 230 180 231 181 232 /** 182 * Tries to locate and load VBox XPCOMC.so/dylib/dll, resolving all the related233 * Tries to locate and load VBoxCAPI.so/dylib/dll, resolving all the related 183 234 * function pointers. 184 235 * … … 186 237 * 187 238 * @remark This should be considered moved into a separate glue library since 188 * its its going to be pretty much the same for any user of VBox XPCOMC239 * its its going to be pretty much the same for any user of VBoxCAPI 189 240 * and it will just cause trouble to have duplicate versions of this 190 241 * source code all around the place. … … 192 243 int VBoxCGlueInit(void) 193 244 { 245 const char *pszHome; 246 247 memset(g_szVBoxErrMsg, 0, sizeof(g_szVBoxErrMsg)); 248 194 249 /* 195 250 * If the user specifies the location, try only that. 196 251 */ 197 const char *pszHome = getenv("VBOX_APP_HOME");252 pszHome = getenv("VBOX_APP_HOME"); 198 253 if (pszHome) 199 return tryLoad One(pszHome, 0);254 return tryLoadLibrary(pszHome, 0); 200 255 201 256 /* 202 257 * Try the known standard locations. 203 258 */ 204 g_szVBoxErrMsg[0] = '\0';205 259 #if defined(__gnu__linux__) || defined(__linux__) 206 if (tryLoad One("/opt/VirtualBox", 1) == 0)207 return 0; 208 if (tryLoad One("/usr/lib/virtualbox", 1) == 0)260 if (tryLoadLibrary("/opt/VirtualBox", 1) == 0) 261 return 0; 262 if (tryLoadLibrary("/usr/lib/virtualbox", 1) == 0) 209 263 return 0; 210 264 #elif defined(__sun__) 211 if (tryLoad One("/opt/VirtualBox/amd64", 1) == 0)212 return 0; 213 if (tryLoad One("/opt/VirtualBox/i386", 1) == 0)265 if (tryLoadLibrary("/opt/VirtualBox/amd64", 1) == 0) 266 return 0; 267 if (tryLoadLibrary("/opt/VirtualBox/i386", 1) == 0) 214 268 return 0; 215 269 #elif defined(__APPLE__) 216 if (tryLoad One("/Application/VirtualBox.app/Contents/MacOS", 1) == 0)270 if (tryLoadLibrary("/Application/VirtualBox.app/Contents/MacOS", 1) == 0) 217 271 return 0; 218 272 #elif defined(__FreeBSD__) 219 if (tryLoad One("/usr/local/lib/virtualbox", 1) == 0)273 if (tryLoadLibrary("/usr/local/lib/virtualbox", 1) == 0) 220 274 return 0; 221 275 #elif defined(__OS2__) 222 if (tryLoadOne("C:/Apps/VirtualBox", 1) == 0) 276 if (tryLoadLibrary("C:/Apps/VirtualBox", 1) == 0) 277 return 0; 278 #elif defined(WIN32) 279 pszHome = getenv("ProgramFiles"); 280 if (pszHome) 281 { 282 char szPath[4096]; 283 size_t cb = sizeof(szPath); 284 char *tmp = szPath; 285 strncpy(tmp, pszHome, cb); 286 tmp[cb - 1] = '\0'; 287 cb -= strlen(tmp); 288 tmp += strlen(tmp); 289 strncpy(tmp, "/Oracle/VirtualBox", cb); 290 tmp[cb - 1] = '\0'; 291 if (tryLoadLibrary(szPath, 1) == 0) 292 return 0; 293 } 294 if (tryLoadLibrary("C:/Program Files/Oracle/VirtualBox", 1) == 0) 223 295 return 0; 224 296 #else … … 229 301 * Finally try the dynamic linker search path. 230 302 */ 231 if (tryLoad One(NULL, 1) == 0)303 if (tryLoadLibrary(NULL, 1) == 0) 232 304 return 0; 233 305 … … 242 314 void VBoxCGlueTerm(void) 243 315 { 244 if (g_hVBox XPCOMC)316 if (g_hVBoxCAPI) 245 317 { 246 318 #if 0 /* VBoxRT.so doesn't like being reloaded. See @bugref{3725}. */ 247 dlclose(g_hVBoxXPCOMC); 319 #ifndef WIN32 320 dlclose(g_hVBoxCAPI); 321 #else 322 FreeLibrary(g_hVBoxCAPI); 248 323 #endif 249 g_hVBoxXPCOMC = NULL; 324 #endif 325 g_hVBoxCAPI = NULL; 250 326 } 251 327 g_pVBoxFuncs = NULL; -
trunk/src/VBox/Main/cbinding/VBoxCAPIGlue.h.in
r49984 r50183 1 1 /* $Revision$ */ 2 /** @file VBox XPCOMCGlue.h3 * Glue for dynamically linking with VBox XPCOMC.2 /** @file VBoxCAPIGlue.h 3 * Glue for dynamically linking with VBoxCAPI. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2008-201 2Oracle Corporation7 * Copyright (C) 2008-2014 Oracle Corporation 8 8 * 9 9 * Permission is hereby granted, free of charge, to any person … … 29 29 */ 30 30 31 #ifndef ___VBox XPCOMC_cglue_h32 #define ___VBox XPCOMC_cglue_h31 #ifndef ___VBoxCAPIGlue_h 32 #define ___VBoxCAPIGlue_h 33 33 34 #undef VBOX_WITH_GLUE 35 #define VBOX_WITH_GLUE 34 36 #include "VBoxCAPI_v@[email protected]" 35 37 … … 38 40 #endif 39 41 40 /** The dlopen handle for VBoxXPCOMC. */ 41 extern void *g_hVBoxXPCOMC; 42 /** The so/dynsym/dll handle for VBoxCAPI. */ 43 #ifndef WIN32 44 extern void *g_hVBoxCAPI; 45 #else 46 extern HMODULE g_hVBoxCAPI; 47 #endif 42 48 /** The last load error. */ 43 49 extern char g_szVBoxErrMsg[256]; 44 /** Pointer to the VB oxXPCOMCfunction table. */45 extern PCVBOX XPCOMg_pVBoxFuncs;46 /** Pointer to VBoxGet XPCOMCFunctions for the loaded VBoxXPCOMCso/dylib/dll. */47 extern PFNVBOXGET XPCOMCFUNCTIONS g_pfnGetFunctions;50 /** Pointer to the VBOXCAPI function table. */ 51 extern PCVBOXCAPI g_pVBoxFuncs; 52 /** Pointer to VBoxGetCAPIFunctions for the loaded VBoxCAPI so/dylib/dll. */ 53 extern PFNVBOXGETCAPIFUNCTIONS g_pfnGetFunctions; 48 54 49 55 -
trunk/src/VBox/Main/cbinding/capiidl.xsl
r49984 r50183 3 3 4 4 <!-- 5 * A template to generate a XPCOM IDL compatible interface definition file 6 * from the generic interface definition expressed in XML. 7 8 Copyright (C) 2008-2013 Oracle Corporation 5 * A template to generate a C header file for all relevant XPCOM interfaces 6 * provided or needed for calling the VirtualBox API. The header file also 7 * works on Windows, by using the C bindings header created by the MS COM IDL 8 * compiler (which simultaneously supports C and C++, unlike XPCOM). 9 10 Copyright (C) 2008-2014 Oracle Corporation 9 11 10 12 This file is part of VirtualBox Open Source Edition (OSE), as … … 100 102 --> 101 103 <xsl:template match="/idl"> 102 <xsl:text> 103 /* 104 <xsl:text>/* 104 105 * DO NOT EDIT! This is a generated file. 105 106 * 106 * XPCOM IDL (XPIDL) definition for VirtualBox Main API (COM interfaces) 107 * generated from XIDL (XML interface definition). 107 * Header file which provides C declarations for VirtualBox Main API 108 * (COM interfaces), generated from XIDL (XML interface definition). 109 * On Windows (which uses COM instead of XPCOM) the native C support 110 * is used, and most of this file is not used. 108 111 * 109 112 * Source : src/VBox/Main/idl/VirtualBox.xidl 110 * Generator : src/VBox/Main/ idl/xpcidl.xsl113 * Generator : src/VBox/Main/cbinding/capiidl.xsl 111 114 * 112 115 * This file contains portions from the following Mozilla XPCOM files: … … 121 124 122 125 /* 123 * Copyright (C) 2008-201 2Oracle Corporation126 * Copyright (C) 2008-2014 Oracle Corporation 124 127 * 125 128 * This file is part of a free software library; you can redistribute … … 140 143 */ 141 144 142 #ifndef ___VirtualBox_CXPCOM_h 143 #define ___VirtualBox_CXPCOM_h 145 #ifndef ___VirtualBox_CAPI_h 146 #define ___VirtualBox_CAPI_h 147 148 #ifdef _WIN32 149 # undef COBJMACROS 150 # define COBJMACROS 151 # include "Windows.h" 152 #endif /* _WIN32 */ 153 154 #ifdef WIN32 155 # ifdef IN_VBOXCAPI 156 # define VBOXCAPI_DECL(type) extern __declspec(dllexport) type 157 # else /* !IN_VBOXCAPI */ 158 # define VBOXCAPI_DECL(type) __declspec(dllimport) type 159 # endif /* !IN_VBOXCAPI */ 160 #endif /* WIN32 */ 144 161 145 162 #ifdef __cplusplus 146 # include "VirtualBox_XPCOM.h" 147 #else /* !__cplusplus */ 163 /* The C++ treatment in this file is not meant for SDK users, it only exists 164 * so that this file can be used to produce the VBoxCAPI shared library which 165 * has to use C++ as it does all the conversion magic. */ 166 # ifdef IN_VBOXCAPI 167 # include "VBox/com/VirtualBox.h" 168 # ifndef WIN32 169 # include "nsIEventQueue.h" 170 # endif /* !WIN32 */ 171 # else /* !IN_VBOXCAPI */ 172 # error Do not include this header file from C++ code 173 # endif /* !IN_VBOXCAPI */ 174 #endif /* __cplusplus */ 175 176 #ifdef __GNUC__ 177 # define VBOX_EXTERN_CONST(type, name) extern const type name __attribute__((nocommon)) 178 #else /* !__GNUC__ */ 179 # define VBOX_EXTERN_CONST(type, name) extern const type name 180 #endif /* !__GNUC__ */ 181 182 /* Treat WIN32 completely separately, as on Windows VirtualBox uses COM, not 183 * XPCOM like on all other platforms. While the code below would also compile 184 * on Windows, we need to switch to the native C support provided by the header 185 * files produced by the COM IDL compiler. */ 186 #ifdef WIN32 187 # include "ObjBase.h" 188 # include "oaidl.h" 189 # include "VirtualBox.h" 190 191 typedef const BSTR CBSTR; 192 193 #define ComSafeArrayAsInParam(f) (f) 194 #define ComSafeArrayAsOutParam(f) (&(f)) 195 #define ComSafeArrayAsOutIfaceParam(f) (&(f)) 196 197 #else /* !WIN32 */ 148 198 149 199 #include <stddef.h> 150 200 #include "wchar.h" 201 202 #ifdef IN_VBOXCAPI 203 # define VBOXCAPI_DECL(type) PR_EXPORT(type) 204 #else /* !IN_VBOXCAPI */ 205 # define VBOXCAPI_DECL(type) PR_IMPORT(type) 206 #endif /* !IN_VBOXCAPI */ 207 208 #ifndef __cplusplus 151 209 152 210 #if defined(WIN32) … … 361 419 typedef PRUint16 PRUnichar; 362 420 #endif 421 typedef PRUnichar *BSTR; 422 typedef const PRUnichar *CBSTR; 363 423 #endif 364 424 … … 721 781 #define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100) 722 782 723 724 783 /** 725 784 * An "interface id" which can be used to uniquely identify a given … … 729 788 730 789 struct nsID { 731 PRUint32 m0;732 PRUint16 m1;733 PRUint16 m2;734 PRUint8 m3[8];790 PRUint32 m0; 791 PRUint16 m1; 792 PRUint16 m2; 793 PRUint8 m3[8]; 735 794 }; 736 795 737 796 typedef struct nsID nsID; 738 797 typedef nsID nsIID; 798 typedef nsID nsCID; 799 800 #endif /* __cplusplus */ 801 802 803 /* Various COM types defined by their XPCOM equivalent */ 804 typedef PRInt64 LONG64; 805 typedef PRInt32 LONG; 806 typedef PRInt32 DWORD; 807 typedef PRInt16 SHORT; 808 typedef PRUint64 ULONG64; 809 typedef PRUint32 ULONG; 810 typedef PRUint16 USHORT; 811 812 typedef PRBool BOOL; 813 814 #ifndef FALSE 815 #define FALSE 0 816 #define TRUE 1 817 #endif 818 819 #define HRESULT nsresult 820 #define SUCCEEDED NS_SUCCEEDED 821 #define FAILED NS_FAILED 822 823 /* OLE error codes */ 824 #define S_OK ((nsresult)NS_OK) 825 #define E_UNEXPECTED NS_ERROR_UNEXPECTED 826 #define E_NOTIMPL NS_ERROR_NOT_IMPLEMENTED 827 #define E_OUTOFMEMORY NS_ERROR_OUT_OF_MEMORY 828 #define E_INVALIDARG NS_ERROR_INVALID_ARG 829 #define E_NOINTERFACE NS_ERROR_NO_INTERFACE 830 #define E_POINTER NS_ERROR_NULL_POINTER 831 #define E_ABORT NS_ERROR_ABORT 832 #define E_FAIL NS_ERROR_FAILURE 833 /* Note: a better analog for E_ACCESSDENIED would probably be 834 * NS_ERROR_NOT_AVAILABLE, but we want binary compatibility for now. */ 835 #define E_ACCESSDENIED ((nsresult)0x80070005L) 836 837 /* Basic vartype for COM compatibility. */ 838 typedef enum VARTYPE 839 { 840 VT_I2 = 2, 841 VT_I4 = 3, 842 VT_BSTR = 8, 843 VT_DISPATCH = 9, 844 VT_BOOL = 11, 845 VT_UNKNOWN = 13, 846 VT_I1 = 16, 847 VT_UI1 = 17, 848 VT_UI2 = 18, 849 VT_UI4 = 19, 850 VT_I8 = 20, 851 VT_UI8 = 21, 852 VT_HRESULT = 25 853 } VARTYPE; 854 855 /* Basic safearray type for COM compatibility. */ 856 typedef struct SAFEARRAY 857 { 858 void *pv; 859 ULONG c; 860 } SAFEARRAY; 861 862 #define ComSafeArrayAsInParam(f) ((f)->c), ((f)->pv) 863 #define ComSafeArrayAsOutParam(f) (&((f)->c)), (&((f)->pv)) 864 #define ComSafeArrayAsOutIfaceParam(f,t) (&((f)->c)), (t**)(&((f)->pv)) 865 866 /* Glossing over differences between COM and XPCOM */ 867 #define IErrorInfo nsIException 868 #define IUnknown nsISupports 869 #define IDispatch nsISupports 870 871 #ifndef __cplusplus 739 872 740 873 struct nsISupports; /* forward declaration */ … … 745 878 typedef struct nsIException nsIException; /* forward declaration */ 746 879 747 /** 748 * IID for the nsISupports interface 749 * {00000000-0000-0000-c000-000000000046} 750 * 751 * To maintain binary compatibility with COM's IUnknown, we define the IID 752 * of nsISupports to be the same as that of COM's IUnknown. 753 */ 754 #define NS_ISUPPORTS_IID \ 755 { 0x00000000, 0x0000, 0x0000, \ 756 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} } 880 /* starting interface: nsISupports */ 881 #define NS_ISUPPORTS_IID_STR "00000000-0000-0000-c000-000000000046" 882 883 #define NS_ISUPPORTS_IID \ 884 { 0x00000000, 0x0000, 0x0000, \ 885 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} } 757 886 758 887 /** … … 764 893 * IUnknown. 765 894 */ 895 #if defined(XP_WIN) && PR_BYTES_PER_LONG == 4 896 typedef unsigned long nsrefcnt; 897 #else 898 typedef PRUint32 nsrefcnt; 899 #endif 766 900 767 901 /** … … 771 905 * modelled after the win32 IUnknown API. 772 906 */ 773 struct nsISupports_vtbl { 774 775 /** 776 * @name Methods 777 */ 778 779 /** 780 * A run time mechanism for interface discovery. 781 * @param aIID [in] A requested interface IID 782 * @param aInstancePtr [out] A pointer to an interface pointer to 783 * receive the result. 784 * @return NS_OK if the interface is supported by the associated 785 * instance, NS_NOINTERFACE if it is not. 786 * NS_ERROR_INVALID_POINTER if aInstancePtr is NULL. 787 */ 788 nsresult (*QueryInterface)(nsISupports *pThis, const nsID *iid, void **resultp); 789 /** 790 * Increases the reference count for this interface. 791 * The associated instance will not be deleted unless 792 * the reference count is returned to zero. 793 * 794 * @return The resulting reference count. 795 */ 796 nsresult (*AddRef)(nsISupports *pThis); 797 798 /** 799 * Decreases the reference count for this interface. 800 * Generally, if the reference count returns to zero, 801 * the associated instance is deleted. 802 * 803 * @return The resulting reference count. 804 */ 805 nsresult (*Release)(nsISupports *pThis); 806 907 #ifndef VBOX_WITH_GLUE 908 struct nsISupports_vtbl 909 { 910 nsresult (*QueryInterface)(nsISupports *pThis, const nsID *iid, void **resultp); 911 nsrefcnt (*AddRef)(nsISupports *pThis); 912 nsrefcnt (*Release)(nsISupports *pThis); 807 913 }; 808 809 struct nsISupports { 914 #else /* !VBOX_WITH_GLUE */ 915 struct nsISupportsVtbl 916 { 917 nsresult (*QueryInterface)(nsISupports *pThis, const nsID *iid, void **resultp); 918 nsrefcnt (*AddRef)(nsISupports *pThis); 919 nsrefcnt (*Release)(nsISupports *pThis); 920 }; 921 #define nsISupports_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp)) 922 #define nsISupports_AddRef(p) ((p)->lpVtbl->AddRef(p)) 923 #define nsISupports_Release(p) ((p)->lpVtbl->Release(p)) 924 #define IUnknown_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp)) 925 #define IUnknown_AddRef(p) ((p)->lpVtbl->AddRef(p)) 926 #define IUnknown_Release(p) ((p)->lpVtbl->Release(p)) 927 #define IDispatch_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp)) 928 #define IDispatch_AddRef(p) ((p)->lpVtbl->AddRef(p)) 929 #define IDispatch_Release(p) ((p)->lpVtbl->Release(p)) 930 #endif /* !VBOX_WITH_GLUE */ 931 932 struct nsISupports 933 { 934 #ifndef VBOX_WITH_GLUE 810 935 struct nsISupports_vtbl *vtbl; 936 #else /* !VBOX_WITH_GLUE */ 937 struct nsISupportsVtbl *lpVtbl; 938 #endif /* !VBOX_WITH_GLUE */ 811 939 }; 812 940 … … 815 943 816 944 #define NS_IEXCEPTION_IID \ 817 {0xf3a8d3b4, 0xc424, 0x4edc, \ 818 { 0x8b, 0xf6, 0x89, 0x74, 0xc9, 0x83, 0xba, 0x78 }} 819 820 struct nsIException_vtbl { 821 822 /* Methods from the Class nsISupports */ 823 struct nsISupports_vtbl nsisupports; 824 825 /* readonly attribute string message; */ 826 nsresult (*GetMessage)(nsIException *pThis, PRUnichar * *aMessage); 827 828 /* readonly attribute nsresult (*result; */ 829 nsresult (*GetResult)(nsIException *pThis, nsresult *aResult); 830 831 /* readonly attribute string name; */ 832 nsresult (*GetName)(nsIException *pThis, PRUnichar * *aName); 833 834 /* readonly attribute string filename; */ 835 nsresult (*GetFilename)(nsIException *pThis, PRUnichar * *aFilename); 836 837 /* readonly attribute PRUint32 lineNumber; */ 838 nsresult (*GetLineNumber)(nsIException *pThis, PRUint32 *aLineNumber); 839 840 /* readonly attribute PRUint32 columnNumber; */ 841 nsresult (*GetColumnNumber)(nsIException *pThis, PRUint32 *aColumnNumber); 842 843 /* readonly attribute nsIStackFrame location; */ 844 nsresult (*GetLocation)(nsIException *pThis, nsIStackFrame * *aLocation); 845 846 /* readonly attribute nsIException inner; */ 847 nsresult (*GetInner)(nsIException *pThis, nsIException * *aInner); 848 849 /* readonly attribute nsISupports data; */ 850 nsresult (*GetData)(nsIException *pThis, nsISupports * *aData); 851 852 /* string toString (); */ 853 nsresult (*ToString)(nsIException *pThis, PRUnichar **_retval); 945 {0xf3a8d3b4, 0xc424, 0x4edc, \ 946 { 0x8b, 0xf6, 0x89, 0x74, 0xc9, 0x83, 0xba, 0x78 }} 947 948 #ifndef VBOX_WITH_GLUE 949 struct nsIException_vtbl 950 { 951 /* Methods from the interface nsISupports */ 952 struct nsISupports_vtbl nsisupports; 953 954 nsresult (*GetMessage)(nsIException *pThis, PRUnichar * *aMessage); 955 nsresult (*GetResult)(nsIException *pThis, nsresult *aResult); 956 nsresult (*GetName)(nsIException *pThis, PRUnichar * *aName); 957 nsresult (*GetFilename)(nsIException *pThis, PRUnichar * *aFilename); 958 nsresult (*GetLineNumber)(nsIException *pThis, PRUint32 *aLineNumber); 959 nsresult (*GetColumnNumber)(nsIException *pThis, PRUint32 *aColumnNumber); 960 nsresult (*GetLocation)(nsIException *pThis, nsIStackFrame * *aLocation); 961 nsresult (*GetInner)(nsIException *pThis, nsIException * *aInner); 962 nsresult (*GetData)(nsIException *pThis, nsISupports * *aData); 963 nsresult (*ToString)(nsIException *pThis, PRUnichar **_retval); 854 964 }; 855 856 struct nsIException { 965 #else /* !VBOX_WITH_GLUE */ 966 struct nsIExceptionVtbl 967 { 968 nsresult (*QueryInterface)(nsIException *pThis, const nsID *iid, void **resultp); 969 nsrefcnt (*AddRef)(nsIException *pThis); 970 nsrefcnt (*Release)(nsIException *pThis); 971 972 nsresult (*GetMessage)(nsIException *pThis, PRUnichar * *aMessage); 973 nsresult (*GetResult)(nsIException *pThis, nsresult *aResult); 974 nsresult (*GetName)(nsIException *pThis, PRUnichar * *aName); 975 nsresult (*GetFilename)(nsIException *pThis, PRUnichar * *aFilename); 976 nsresult (*GetLineNumber)(nsIException *pThis, PRUint32 *aLineNumber); 977 nsresult (*GetColumnNumber)(nsIException *pThis, PRUint32 *aColumnNumber); 978 nsresult (*GetLocation)(nsIException *pThis, nsIStackFrame * *aLocation); 979 nsresult (*GetInner)(nsIException *pThis, nsIException * *aInner); 980 nsresult (*GetData)(nsIException *pThis, nsISupports * *aData); 981 nsresult (*ToString)(nsIException *pThis, PRUnichar **_retval); 982 }; 983 #define nsIException_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp)) 984 #define nsIException_AddRef(p) ((p)->lpVtbl->AddRef(p)) 985 #define nsIException_Release(p) ((p)->lpVtbl->Release(p)) 986 #define nsIException_get_Message(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage)) 987 #define nsIException_GetMessage(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage)) 988 #define nsIException_get_Result(p, aResult) ((p)->lpVtbl->GetResult(p, aResult)) 989 #define nsIException_GetResult(p, aResult) ((p)->lpVtbl->GetResult(p, aResult)) 990 #define nsIException_get_Name(p, aName) ((p)->lpVtbl->GetName(p, aName)) 991 #define nsIException_GetName(p, aName) ((p)->lpVtbl->GetName(p, aName)) 992 #define nsIException_get_Filename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename)) 993 #define nsIException_GetFilename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename)) 994 #define nsIException_get_LineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber)) 995 #define nsIException_GetLineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber)) 996 #define nsIException_get_ColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber)) 997 #define nsIException_GetColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber)) 998 #define nsIException_get_Inner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner)) 999 #define nsIException_GetInner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner)) 1000 #define nsIException_get_Data(p, aData) ((p)->lpVtbl->GetData(p, aData)) 1001 #define nsIException_GetData(p, aData) ((p)->lpVtbl->GetData(p, aData)) 1002 #define nsIException_ToString(p, retval) ((p)->lpVtbl->ToString(p, retval)) 1003 #define IErrorInfo_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp)) 1004 #define IErrorInfo_AddRef(p) ((p)->lpVtbl->AddRef(p)) 1005 #define IErrorInfo_Release(p) ((p)->lpVtbl->Release(p)) 1006 #define IErrorInfo_get_Message(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage)) 1007 #define IErrorInfo_GetMessage(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage)) 1008 #define IErrorInfo_get_Result(p, aResult) ((p)->lpVtbl->GetResult(p, aResult)) 1009 #define IErrorInfo_GetResult(p, aResult) ((p)->lpVtbl->GetResult(p, aResult)) 1010 #define IErrorInfo_get_Name(p, aName) ((p)->lpVtbl->GetName(p, aName)) 1011 #define IErrorInfo_GetName(p, aName) ((p)->lpVtbl->GetName(p, aName)) 1012 #define IErrorInfo_get_Filename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename)) 1013 #define IErrorInfo_GetFilename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename)) 1014 #define IErrorInfo_get_LineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber)) 1015 #define IErrorInfo_GetLineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber)) 1016 #define IErrorInfo_get_ColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber)) 1017 #define IErrorInfo_GetColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber)) 1018 #define IErrorInfo_get_Inner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner)) 1019 #define IErrorInfo_GetInner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner)) 1020 #define IErrorInfo_get_Data(p, aData) ((p)->lpVtbl->GetData(p, aData)) 1021 #define IErrorInfo_GetData(p, aData) ((p)->lpVtbl->GetData(p, aData)) 1022 #define IErrorInfo_ToString(p, retval) ((p)->lpVtbl->ToString(p, retval)) 1023 #endif /* !VBOX_WITH_GLUE */ 1024 1025 struct nsIException 1026 { 1027 #ifndef VBOX_WITH_GLUE 857 1028 struct nsIException_vtbl *vtbl; 1029 #else /* !VBOX_WITH_GLUE */ 1030 struct nsIExceptionVtbl *lpVtbl; 1031 #endif /* !VBOX_WITH_GLUE */ 858 1032 }; 859 1033 … … 862 1036 863 1037 #define NS_ISTACKFRAME_IID \ 864 {0x91d82105, 0x7c62, 0x4f8b, \ 865 { 0x97, 0x79, 0x15, 0x42, 0x77, 0xc0, 0xee, 0x90 }} 866 867 struct nsIStackFrame_vtbl { 868 869 /* Methods from the Class nsISupports */ 870 struct nsISupports_vtbl nsisupports; 871 872 /* readonly attribute PRUint32 language; */ 873 nsresult (*GetLanguage)(nsIStackFrame *pThis, PRUint32 *aLanguage); 874 875 /* readonly attribute string languageName; */ 876 nsresult (*GetLanguageName)(nsIStackFrame *pThis, PRUnichar * *aLanguageName); 877 878 /* readonly attribute string filename; */ 879 nsresult (*GetFilename)(nsIStackFrame *pThis, PRUnichar * *aFilename); 880 881 /* readonly attribute string name; */ 882 nsresult (*GetName)(nsIStackFrame *pThis, PRUnichar * *aName); 883 884 /* readonly attribute PRInt32 lineNumber; */ 885 nsresult (*GetLineNumber)(nsIStackFrame *pThis, PRInt32 *aLineNumber); 886 887 /* readonly attribute string sourceLine; */ 888 nsresult (*GetSourceLine)(nsIStackFrame *pThis, PRUnichar * *aSourceLine); 889 890 /* readonly attribute nsIStackFrame caller; */ 891 nsresult (*GetCaller)(nsIStackFrame *pThis, nsIStackFrame * *aCaller); 892 893 /* string toString (); */ 894 nsresult (*ToString)(nsIStackFrame *pThis, PRUnichar **_retval); 1038 {0x91d82105, 0x7c62, 0x4f8b, \ 1039 { 0x97, 0x79, 0x15, 0x42, 0x77, 0xc0, 0xee, 0x90 }} 1040 1041 #ifndef VBOX_WITH_GLUE 1042 struct nsIStackFrame_vtbl 1043 { 1044 /* Methods from the interface nsISupports */ 1045 struct nsISupports_vtbl nsisupports; 1046 1047 nsresult (*GetLanguage)(nsIStackFrame *pThis, PRUint32 *aLanguage); 1048 nsresult (*GetLanguageName)(nsIStackFrame *pThis, PRUnichar * *aLanguageName); 1049 nsresult (*GetFilename)(nsIStackFrame *pThis, PRUnichar * *aFilename); 1050 nsresult (*GetName)(nsIStackFrame *pThis, PRUnichar * *aName); 1051 nsresult (*GetLineNumber)(nsIStackFrame *pThis, PRInt32 *aLineNumber); 1052 nsresult (*GetSourceLine)(nsIStackFrame *pThis, PRUnichar * *aSourceLine); 1053 nsresult (*GetCaller)(nsIStackFrame *pThis, nsIStackFrame * *aCaller); 1054 nsresult (*ToString)(nsIStackFrame *pThis, PRUnichar **_retval); 895 1055 }; 896 897 struct nsIStackFrame { 1056 #else /* !VBOX_WITH_GLUE */ 1057 struct nsIStackFrameVtbl 1058 { 1059 nsresult (*QueryInterface)(nsIStackFrame *pThis, const nsID *iid, void **resultp); 1060 nsrefcnt (*AddRef)(nsIStackFrame *pThis); 1061 nsrefcnt (*Release)(nsIStackFrame *pThis); 1062 1063 nsresult (*GetLanguage)(nsIStackFrame *pThis, PRUint32 *aLanguage); 1064 nsresult (*GetLanguageName)(nsIStackFrame *pThis, PRUnichar * *aLanguageName); 1065 nsresult (*GetFilename)(nsIStackFrame *pThis, PRUnichar * *aFilename); 1066 nsresult (*GetName)(nsIStackFrame *pThis, PRUnichar * *aName); 1067 nsresult (*GetLineNumber)(nsIStackFrame *pThis, PRInt32 *aLineNumber); 1068 nsresult (*GetSourceLine)(nsIStackFrame *pThis, PRUnichar * *aSourceLine); 1069 nsresult (*GetCaller)(nsIStackFrame *pThis, nsIStackFrame * *aCaller); 1070 nsresult (*ToString)(nsIStackFrame *pThis, PRUnichar **_retval); 1071 }; 1072 #define nsIStackFrame_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp)) 1073 #define nsIStackFrame_AddRef(p) ((p)->lpVtbl->AddRef(p)) 1074 #define nsIStackFrame_Release(p) ((p)->lpVtbl->Release(p)) 1075 #define nsIStackFrame_get_Language(p, aLanguage) ((p)->lpVtbl->GetLanguge(p, aLanguage)) 1076 #define nsIStackFrame_GetLanguage(p, aLanguage) ((p)->lpVtbl->GetLanguge(p, aLanguage)) 1077 #define nsIStackFrame_get_LanguageName(p, aLanguageName) ((p)->lpVtbl->GetLanguageName(p, aLanguageName)) 1078 #define nsIStackFrame_GetLanguageName(p, aLanguageName) ((p)->lpVtbl->GetLanguageName(p, aLanguageName)) 1079 #define nsIStackFrame_get_Filename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename)) 1080 #define nsIStackFrame_GetFilename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename)) 1081 #define nsIStackFrame_get_Name(p, aName) ((p)->lpVtbl->GetName(p, aName)) 1082 #define nsIStackFrame_GetName(p, aName) ((p)->lpVtbl->GetName(p, aName)) 1083 #define nsIStackFrame_get_LineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber)) 1084 #define nsIStackFrame_GetLineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber)) 1085 #define nsIStackFrame_get_SourceLine(p, aSourceLine) ((p)->lpVtbl->GetSourceLine(p, aSourceLine)) 1086 #define nsIStackFrame_GetSourceLine(p, aSourceLine) ((p)->lpVtbl->GetSourceLine(p, aSourceLine)) 1087 #define nsIStackFrame_get_Caller(p, aCaller) ((p)->lpVtbl->GetCaller(p, aCaller)) 1088 #define nsIStackFrame_GetCaller(p, aCaller) ((p)->lpVtbl->GetCaller(p, aCaller)) 1089 #define nsIStackFrame_ToString(p, retval) ((p)->lpVtbl->ToString(p, retval)) 1090 #endif /* !VBOX_WITH_GLUE */ 1091 1092 struct nsIStackFrame 1093 { 1094 #ifndef VBOX_WITH_GLUE 898 1095 struct nsIStackFrame_vtbl *vtbl; 1096 #else /* !VBOX_WITH_GLUE */ 1097 struct nsIStackFrameVtbl *lpVtbl; 1098 #endif /* !VBOX_WITH_GLUE */ 899 1099 }; 900 1100 … … 903 1103 904 1104 #define NS_IEVENTTARGET_IID \ 905 {0xea99ad5b, 0xcc67, 0x4efb, \906 { 0x97, 0xc9, 0x2e, 0xf6, 0x20, 0xa5, 0x9f, 0x2a }}1105 {0xea99ad5b, 0xcc67, 0x4efb, \ 1106 { 0x97, 0xc9, 0x2e, 0xf6, 0x20, 0xa5, 0x9f, 0x2a }} 907 1107 908 1108 struct nsIEventTarget; 909 1109 typedef struct nsIEventTarget nsIEventTarget; 910 1110 911 struct nsIEventTarget_vtbl { 912 1111 #ifndef VBOX_WITH_GLUE 1112 struct nsIEventTarget_vtbl 1113 { 913 1114 struct nsISupports_vtbl nsisupports; 914 1115 915 1116 nsresult (*PostEvent)(nsIEventTarget *pThis, PLEvent * aEvent); 916 917 1117 nsresult (*IsOnCurrentThread)(nsIEventTarget *pThis, PRBool *_retval); 918 919 1118 }; 920 921 struct nsIEventTarget { 1119 #else /* !VBOX_WITH_GLUE */ 1120 struct nsIEventTargetVtbl 1121 { 1122 nsresult (*QueryInterface)(nsIEventTarget *pThis, const nsID *iid, void **resultp); 1123 nsrefcnt (*AddRef)(nsIEventTarget *pThis); 1124 nsrefcnt (*Release)(nsIEventTarget *pThis); 1125 1126 nsresult (*PostEvent)(nsIEventTarget *pThis, PLEvent * aEvent); 1127 nsresult (*IsOnCurrentThread)(nsIEventTarget *pThis, PRBool *_retval); 1128 }; 1129 #define nsIEventTarget_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp)) 1130 #define nsIEventTarget_AddRef(p) ((p)->lpVtbl->AddRef(p)) 1131 #define nsIEventTarget_Release(p) ((p)->lpVtbl->Release(p)) 1132 #define nsIEventTarget_PostEvent(p, aEvent) ((p)->lpVtbl->PostEvent(p, aEvent)) 1133 #define nsIEventTarget_IsOnCurrentThread(p, retval) ((p)->lpVtbl->IsOnCurrentThread(p, retval)) 1134 #endif /* !VBOX_WITH_GLUE */ 1135 1136 struct nsIEventTarget 1137 { 1138 #ifndef VBOX_WITH_GLUE 922 1139 struct nsIEventTarget_vtbl *vtbl; 1140 #else /* !VBOX_WITH_GLUE */ 1141 struct nsIEventTargetVtbl *lpVtbl; 1142 #endif /* !VBOX_WITH_GLUE */ 923 1143 }; 924 1144 … … 933 1153 typedef struct nsIEventQueue nsIEventQueue; 934 1154 935 struct nsIEventQueue_vtbl { 936 1155 #ifndef VBOX_WITH_GLUE 1156 struct nsIEventQueue_vtbl 1157 { 937 1158 struct nsIEventTarget_vtbl nsieventtarget; 938 1159 939 1160 nsresult (*InitEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * owner, PLHandleEventProc handler, PLDestroyEventProc destructor); 940 941 1161 nsresult (*PostSynchronousEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * *aResult); 942 943 1162 nsresult (*PendingEvents)(nsIEventQueue *pThis, PRBool *_retval); 944 945 1163 nsresult (*ProcessPendingEvents)(nsIEventQueue *pThis); 946 947 1164 nsresult (*EventLoop)(nsIEventQueue *pThis); 948 949 1165 nsresult (*EventAvailable)(nsIEventQueue *pThis, PRBool *aResult); 950 951 1166 nsresult (*GetEvent)(nsIEventQueue *pThis, PLEvent * *_retval); 952 953 1167 nsresult (*HandleEvent)(nsIEventQueue *pThis, PLEvent * aEvent); 954 955 1168 nsresult (*WaitForEvent)(nsIEventQueue *pThis, PLEvent * *_retval); 956 957 1169 PRInt32 (*GetEventQueueSelectFD)(nsIEventQueue *pThis); 958 959 1170 nsresult (*Init)(nsIEventQueue *pThis, PRBool aNative); 960 961 1171 nsresult (*InitFromPRThread)(nsIEventQueue *pThis, PRThread * thread, PRBool aNative); 962 963 1172 nsresult (*InitFromPLQueue)(nsIEventQueue *pThis, PLEventQueue * aQueue); 964 965 1173 nsresult (*EnterMonitor)(nsIEventQueue *pThis); 966 967 1174 nsresult (*ExitMonitor)(nsIEventQueue *pThis); 968 969 1175 nsresult (*RevokeEvents)(nsIEventQueue *pThis, void * owner); 970 971 1176 nsresult (*GetPLEventQueue)(nsIEventQueue *pThis, PLEventQueue * *_retval); 972 973 1177 nsresult (*IsQueueNative)(nsIEventQueue *pThis, PRBool *_retval); 974 975 1178 nsresult (*StopAcceptingEvents)(nsIEventQueue *pThis); 976 977 1179 }; 978 979 struct nsIEventQueue { 1180 #else /* !VBOX_WITH_GLUE */ 1181 struct nsIEventQueueVtbl 1182 { 1183 nsresult (*QueryInterface)(nsIEventQueue *pThis, const nsID *iid, void **resultp); 1184 nsrefcnt (*AddRef)(nsIEventQueue *pThis); 1185 nsrefcnt (*Release)(nsIEventQueue *pThis); 1186 1187 nsresult (*PostEvent)(nsIEventQueue *pThis, PLEvent * aEvent); 1188 nsresult (*IsOnCurrentThread)(nsIEventQueue *pThis, PRBool *_retval); 1189 1190 nsresult (*InitEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * owner, PLHandleEventProc handler, PLDestroyEventProc destructor); 1191 nsresult (*PostSynchronousEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * *aResult); 1192 nsresult (*PendingEvents)(nsIEventQueue *pThis, PRBool *_retval); 1193 nsresult (*ProcessPendingEvents)(nsIEventQueue *pThis); 1194 nsresult (*EventLoop)(nsIEventQueue *pThis); 1195 nsresult (*EventAvailable)(nsIEventQueue *pThis, PRBool *aResult); 1196 nsresult (*GetEvent)(nsIEventQueue *pThis, PLEvent * *_retval); 1197 nsresult (*HandleEvent)(nsIEventQueue *pThis, PLEvent * aEvent); 1198 nsresult (*WaitForEvent)(nsIEventQueue *pThis, PLEvent * *_retval); 1199 PRInt32 (*GetEventQueueSelectFD)(nsIEventQueue *pThis); 1200 nsresult (*Init)(nsIEventQueue *pThis, PRBool aNative); 1201 nsresult (*InitFromPRThread)(nsIEventQueue *pThis, PRThread * thread, PRBool aNative); 1202 nsresult (*InitFromPLQueue)(nsIEventQueue *pThis, PLEventQueue * aQueue); 1203 nsresult (*EnterMonitor)(nsIEventQueue *pThis); 1204 nsresult (*ExitMonitor)(nsIEventQueue *pThis); 1205 nsresult (*RevokeEvents)(nsIEventQueue *pThis, void * owner); 1206 nsresult (*GetPLEventQueue)(nsIEventQueue *pThis, PLEventQueue * *_retval); 1207 nsresult (*IsQueueNative)(nsIEventQueue *pThis, PRBool *_retval); 1208 nsresult (*StopAcceptingEvents)(nsIEventQueue *pThis); 1209 }; 1210 #define nsIEventQueue_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp)) 1211 #define nsIEventQueue_AddRef(p) ((p)->lpVtbl->AddRef(p)) 1212 #define nsIEventQueue_Release(p) ((p)->lpVtbl->Release(p)) 1213 #define nsIEventQueue_PostEvent(p, aEvent) ((p)->lpVtbl->PostEvent(p, aEvent)) 1214 #define nsIEventQueue_IsOnCurrentThread(p, retval) ((p)->lpVtbl->IsOnCurrentThread(p, retval)) 1215 #define nsIEventQueue_InitEvent(p, aEvent, owner, handler, destructor) ((p)->lpVtbl->InitEvent(p, aEvent, owner, handler, destructor)) 1216 #define nsIEventQueue_PostSynchronousEvent(p, aEvent, aResult) ((p)->lpVtbl->PostSynchronousEvent(p, aEvent, aResult)) 1217 #define nsIEventQueue_ProcessPendingEvents(p) ((p)->lpVtbl->ProcessPendingEvents(p)) 1218 #define nsIEventQueue_EventLoop(p) ((p)->lpVtbl->EventLoop(p)) 1219 #define nsIEventQueue_EventAvailable(p, aResult) ((p)->lpVtbl->EventAvailable(p, aResult)) 1220 #define nsIEventQueue_get_Event(p, aEvent) ((p)->lpVtbl->GetEvent(p, aEvent)) 1221 #define nsIEventQueue_GetEvent(p, aEvent) ((p)->lpVtbl->GetEvent(p, aEvent)) 1222 #define nsIEventQueue_HandleEvent(p, aEvent) ((p)->lpVtbl->HandleEvent(p, aEvent)) 1223 #define nsIEventQueue_WaitForEvent(p, aEvent) ((p)->lpVtbl->WaitForEvent(p, aEvent)) 1224 #define nsIEventQueue_GetEventQueueSelectFD(p) ((p)->lpVtbl->GetEventQueueSelectFD(p)) 1225 #define nsIEventQueue_Init(p, aNative) ((p)->lpVtbl->Init(p, aNative)) 1226 #define nsIEventQueue_InitFromPLQueue(p, aQueue) ((p)->lpVtbl->InitFromPLQueue(p, aQueue)) 1227 #define nsIEventQueue_EnterMonitor(p) ((p)->lpVtbl->EnterMonitor(p)) 1228 #define nsIEventQueue_ExitMonitor(p) ((p)->lpVtbl->ExitMonitor(p)) 1229 #define nsIEventQueue_RevokeEvents(p, owner) ((p)->lpVtbl->RevokeEvents(p, owner)) 1230 #define nsIEventQueue_GetPLEventQueue(p, retval) ((p)->lpVtbl->GetPLEventQueue(p, retval)) 1231 #define nsIEventQueue_IsQueueNative(p, retval) ((p)->lpVtbl->IsQueueNative(p, retval)) 1232 #define nsIEventQueue_StopAcceptingEvents(p) ((p)->lpVtbl->StopAcceptingEvents(p)) 1233 #endif /* !VBOX_WITH_GLUE */ 1234 1235 struct nsIEventQueue 1236 { 1237 #ifndef VBOX_WITH_GLUE 980 1238 struct nsIEventQueue_vtbl *vtbl; 1239 #else /* !VBOX_WITH_GLUE */ 1240 struct nsIEventQueueVtbl *lpVtbl; 1241 #endif /* !VBOX_WITH_GLUE */ 981 1242 }; 982 1243 983 1244 </xsl:text> 984 1245 <xsl:apply-templates/> 985 <xsl:text> 986 #endif /* !__cplusplus */ 987 988 #ifdef IN_VBOXXPCOMC 989 # define VBOXXPCOMC_DECL(type) PR_EXPORT(type) 990 #else 991 # define VBOXXPCOMC_DECL(type) PR_IMPORT(type) 992 #endif 1246 <xsl:text> 1247 1248 #endif /* __cplusplus */ 1249 1250 #endif /* !WIN32 */ 993 1251 994 1252 #ifdef __cplusplus 995 extern "C" { 996 #endif 1253 extern "C" 1254 { 1255 #endif /* __cplusplus */ 997 1256 998 1257 999 1258 /** 1000 1259 * Function table for dynamic linking. 1001 * Use VBoxGet Functions() to obtain the pointer to it.1260 * Use VBoxGetCAPIFunctions() to obtain the pointer to it. 1002 1261 */ 1003 typedef struct VBOX XPCOMC1262 typedef struct VBOXCAPI 1004 1263 { 1005 1264 /** The size of the structure. */ … … 1032 1291 * @param pszVirtualBoxClientIID pass IVIRTUALBOXCLIENT_IID_STR 1033 1292 * @param ppVirtualBoxClient output parameter for VirtualBoxClient 1034 * reference, handled as usual with XPCOM.1035 * @returns XPCOM error code1293 * reference, handled as usual with COM/XPCOM. 1294 * @returns COM/XPCOM error code 1036 1295 */ 1037 nsresult (*pfnClientInitialize)(const char *pszVirtualBoxClientIID, 1038 IVirtualBoxClient **ppVirtualBoxClient); 1296 HRESULT (*pfnClientInitialize)(const char *pszVirtualBoxClientIID, 1297 IVirtualBoxClient **ppVirtualBoxClient); 1298 /** 1299 * Initialize the use of the C bindings in a non-primary thread. 1300 * 1301 * Must be called on any newly created thread which wants to use the 1302 * VirtualBox API. 1303 * 1304 * @returns COM/XPCOM error code 1305 */ 1306 HRESULT (*pfnClientThreadInitialize)(void); 1307 /** 1308 * Uninitialize the use of the C bindings in a non-primary thread. 1309 * 1310 * Should be called before terminating the thread which initialized the 1311 * C bindings using pfnClientThreadInitialize. 1312 * 1313 * @returns COM/XPCOM error code 1314 */ 1315 HRESULT (*pfnClientThreadUninitialize)(void); 1039 1316 /** 1040 1317 * Uninitialize the C bindings for an API client. … … 1077 1354 1078 1355 /** 1079 * Free memory managed byXPCOM.1080 * 1081 * @param p v pointer to memory blockto be freed1356 * Free string managed by COM/XPCOM. 1357 * 1358 * @param pwsz pointer to string to be freed 1082 1359 */ 1083 void (*pfnComUnallocMem)(void *pv); 1360 void (*pfnComUnallocString)(BSTR pwsz); 1361 #ifndef WIN32 1362 /** Legacy function, was always for freeing strings only. */ 1363 #define pfnComUnallocMem(pv) pfnComUnallocString((BSTR)(pv)) 1364 #endif /* !WIN32 */ 1084 1365 1085 1366 /** … … 1090 1371 * @returns IPRT status code 1091 1372 */ 1092 int (*pfnUtf16ToUtf8)( const PRUnichar *pwszString, char **ppszString);1373 int (*pfnUtf16ToUtf8)(CBSTR pwszString, char **ppszString); 1093 1374 /** 1094 1375 * Convert string from UTF-8 encoding to UTF-16 encoding. … … 1098 1379 * @returns IPRT status code 1099 1380 */ 1100 int (*pfnUtf8ToUtf16)(const char *pszString, PRUnichar **ppwszString);1381 int (*pfnUtf8ToUtf16)(const char *pszString, BSTR *ppwszString); 1101 1382 /** 1102 1383 * Free memory returned by pfnUtf16ToUtf8. Do not use for anything else. … … 1110 1391 * @param pwszString string to be freed. 1111 1392 */ 1112 void (*pfnUtf16Free)( PRUnichar *pwszString);1393 void (*pfnUtf16Free)(BSTR pwszString); 1113 1394 1114 1395 /** 1115 * Get main XPCOM event queue. 1396 * Create a safearray (used for passing arrays to COM/XPCOM) 1397 * 1398 * Must be freed by pfnSafeArrayDestroy. 1399 * 1400 * @param vt variant type, defines the size of the elements 1401 * @param lLbound lower bound of the index, should be 0 1402 * @param cElements number of elements 1403 * @returns pointer to safearray 1404 */ 1405 SAFEARRAY *(*pfnSafeArrayCreateVector)(VARTYPE vt, LONG lLbound, ULONG cElements); 1406 /** 1407 * Pre-allocate a safearray to be used by an out safearray parameter 1408 * 1409 * Must be freed by pfnSafeArrayDestroy. 1410 * 1411 * @returns pointer to safearray (system dependent, may be NULL if 1412 * there is no need to pre-allocate a safearray) 1413 */ 1414 SAFEARRAY *(*pfnSafeArrayOutParamAlloc)(void); 1415 /** 1416 * Copy a C array into a safearray (for passing as an input parameter) 1417 * 1418 * @param psa pointer to already created safearray. 1419 * @param pv pointer to memory block to copy into safearray. 1420 * @param cb number of bytes to copy. 1421 * @returns COM/XPCOM error code 1422 */ 1423 HRESULT (*pfnSafeArrayCopyInParamHelper)(SAFEARRAY *psa, const void *pv, ULONG cb); 1424 /** 1425 * Copy a safearray into a C array (for getting an output parameter) 1426 * 1427 * @param ppv output pointer to newly created array, which has to 1428 * be freed with free(). 1429 * @param pcb number of bytes in the output buffer. 1430 * @param vt variant type, defines the size of the elements 1431 * @param psa pointer to safearray for getting the data 1432 * @returns COM/XPCOM error code 1433 */ 1434 HRESULT (*pfnSafeArrayCopyOutParamHelper)(void **ppv, ULONG *pcb, VARTYPE vt, SAFEARRAY *psa); 1435 /** 1436 * Copy a safearray into a C array (special variant for interface pointers) 1437 * 1438 * @param ppaObj output pointer to newly created array, which has 1439 * to be freed with free(). Note that it's the caller's 1440 * responsibility to call Release() on each non-NULL interface 1441 * pointer before freeing. 1442 * @param pcObj number of pointers in the output buffer. 1443 * @param psa pointer to safearray for getting the data 1444 * @returns COM/XPCOM error code 1445 */ 1446 HRESULT (*pfnSafeArrayCopyOutIfaceParamHelper)(IUnknown ***ppaObj, ULONG *pcObj, SAFEARRAY *psa); 1447 /** 1448 * Free a safearray 1449 * 1450 * @param psa pointer to safearray for getting the data 1451 * @returns COM/XPCOM error code 1452 */ 1453 HRESULT (*pfnSafeArrayDestroy)(SAFEARRAY *psa); 1454 1455 #ifndef WIN32 1456 /** 1457 * Get XPCOM event queue. Deprecated! 1116 1458 * 1117 1459 * @param ppEventQueue output parameter for nsIEventQueue reference, … … 1119 1461 */ 1120 1462 void (*pfnGetEventQueue)(nsIEventQueue **ppEventQueue); 1463 #endif /* !WIN32 */ 1121 1464 1122 1465 /** 1123 * Get current XPCOM exception.1124 * 1125 * @param ppException output parameter for nsIExceptionreference,1466 * Get current COM/XPCOM exception. 1467 * 1468 * @param ppException output parameter for exception info reference, 1126 1469 * may be @c NULL if no exception object has been created by 1127 * a previous XPCOM call.1128 * @returns XPCOM error code1470 * a previous COM/XPCOM call. 1471 * @returns COM/XPCOM error code 1129 1472 */ 1130 nsresult (*pfnGetException)(nsIException**ppException);1473 HRESULT (*pfnGetException)(IErrorInfo **ppException); 1131 1474 /** 1132 * Clears current XPCOM exception.1133 * 1134 * @returns XPCOM error code1475 * Clears current COM/XPCOM exception. 1476 * 1477 * @returns COM/XPCOM error code 1135 1478 */ 1136 nsresult (*pfnClearException)(void); 1479 HRESULT (*pfnClearException)(void); 1480 1481 /** 1482 * Process the event queue for a given amount of time. 1483 * 1484 * Must be called on the primary thread. Typical timeouts are from 200 to 1485 * 5000 msecs, to allow for checking a volatile variable if the event queue 1486 * processing should be terminated (, 1487 * or 0 if only the pending events should be processed, without waiting. 1488 * 1489 * @param iTimeoutMS how long to process the event queue, -1 means 1490 * infinitely long 1491 * @returns status code 1492 * @retval 0 if at least one event has been processed 1493 * @retval 1 if any signal interrupted the native system call (or returned 1494 * otherwise) 1495 * @retval 2 if the event queue was explicitly interrupted 1496 * @retval 3 if the timeout expired 1497 * @retval 4 if the function was called from the wrong thread 1498 * @retval 5 for all other (unexpected) errors 1499 */ 1500 int (*pfnProcessEventQueue)(LONG64 iTimeoutMS); 1501 /** 1502 * Interrupt event queue processing. 1503 * 1504 * Can be called on any thread. Note that this function is not async-signal 1505 * safe, so never use it in such a context, instead use a volatile global 1506 * variable and a sensible timeout. 1507 * @returns 0 if successful, 1 otherwise. 1508 */ 1509 int (*pfnInterruptEventQueueProcessing)(void); 1137 1510 1138 1511 /** Tail version, same as uVersion. */ 1139 1512 unsigned uEndVersion; 1140 } VBOXXPCOMC; 1141 /** Pointer to a const VBoxXPCOMC function table. */ 1142 typedef VBOXXPCOMC const *PCVBOXXPCOM; 1513 } VBOXCAPI; 1514 /** Pointer to a const VBOXCAPI function table. */ 1515 typedef VBOXCAPI const *PCVBOXCAPI; 1516 #ifndef WIN32 1517 /** Backwards compatibility: Pointer to a const VBOXCAPI function table. 1518 * Use PCVBOXCAPI instead. */ 1519 typedef VBOXCAPI const *PCVBOXXPCOM; 1520 #endif /* !WIN32 */ 1521 1522 #ifndef WIN32 1523 /** Backwards compatibility: make sure old code using VBOXXPCOMC still compiles. 1524 * Use VBOXCAPI instead. */ 1525 #define VBOXXPCOMC VBOXCAPI 1526 #endif /* !WIN32 */ 1143 1527 1144 1528 /** The current interface version. 1145 * For use with VBoxGetXPCOMCFunctions and to be found in 1146 * VBOXXPCOMC::uVersion. */ 1147 #define VBOX_XPCOMC_VERSION 0x00030000U 1148 1149 VBOXXPCOMC_DECL(PCVBOXXPCOM) VBoxGetXPCOMCFunctions(unsigned uVersion); 1150 /** Typedef for VBoxGetXPCOMCFunctions. */ 1151 typedef PCVBOXXPCOM (*PFNVBOXGETXPCOMCFUNCTIONS)(unsigned uVersion); 1152 1153 /** The symbol name of VBoxGetXPCOMCFunctions. */ 1154 #if defined(__OS2__) 1155 # define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions" 1156 #else 1157 # define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions" 1158 #endif 1529 * For use with VBoxGetCAPIFunctions and to be found in VBOXCAPI::uVersion. */ 1530 #define VBOX_CAPI_VERSION 0x00040000U 1531 1532 #ifndef WIN32 1533 /** Backwards compatibility: The current interface version. 1534 * Use VBOX_CAPI_VERSION instead. */ 1535 #define VBOX_XPCOMC_VERSION VBOX_CAPI_VERSION 1536 #endif /* !WIN32 */ 1537 1538 /** VBoxGetCAPIFunctions. */ 1539 VBOXCAPI_DECL(PCVBOXCAPI) VBoxGetCAPIFunctions(unsigned uVersion); 1540 #ifndef WIN32 1541 /** Backwards compatibility: VBoxGetXPCOMCFunctions. 1542 * Use VBoxGetCAPIFunctions instead. */ 1543 VBOXCAPI_DECL(PCVBOXCAPI) VBoxGetXPCOMCFunctions(unsigned uVersion); 1544 #endif /* !WIN32 */ 1545 1546 /** Typedef for VBoxGetCAPIFunctions. */ 1547 typedef PCVBOXCAPI (*PFNVBOXGETCAPIFUNCTIONS)(unsigned uVersion); 1548 #ifndef WIN32 1549 /** Backwards compatibility: Typedef for VBoxGetXPCOMCFunctions. 1550 * Use PFNVBOXGETCAPIFUNCTIONS instead. */ 1551 typedef PCVBOXCAPI (*PFNVBOXGETXPCOMCFUNCTIONS)(unsigned uVersion); 1552 #endif /* !WIN32 */ 1553 1554 /** The symbol name of VBoxGetCAPIFunctions. */ 1555 #ifdef __OS2__ 1556 # define VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME "_VBoxGetCAPIFunctions" 1557 #else /* !__OS2__ */ 1558 # define VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME "VBoxGetCAPIFunctions" 1559 #endif /* !__OS2__ */ 1560 #ifndef WIN32 1561 /** Backwards compatibility: The symbol name of VBoxGetXPCOMCFunctions. 1562 * Use VBOX_GET_CAPI_FUNCTIONS_SYMBOL_NAME instead. */ 1563 # ifdef __OS2__ 1564 # define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions" 1565 # else /* !__OS2__ */ 1566 # define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions" 1567 # endif /* !__OS2__ */ 1568 #endif /* !WIN32 */ 1159 1569 1160 1570 1161 1571 #ifdef __cplusplus 1162 1572 } 1163 #endif 1164 1165 #endif /* !___VirtualBox_C XPCOM_h */1573 #endif /* __cplusplus */ 1574 1575 #endif /* !___VirtualBox_CAPI_h */ 1166 1576 </xsl:text> 1167 1577 </xsl:template> … … 1169 1579 <!-- 1170 1580 * ignore all |if|s except those for XPIDL target 1581 --> 1171 1582 <xsl:template match="if"> 1172 1583 <xsl:if test="@target='xpidl'"> … … 1185 1596 </xsl:template> 1186 1597 1187 -->1188 1189 <!--1190 * cpp_quote1191 <xsl:template match="cpp">1192 <xsl:if test="text()">1193 <xsl:text>%{C++</xsl:text>1194 <xsl:value-of select="text()"/>1195 <xsl:text>
%}

</xsl:text>1196 </xsl:if>1197 <xsl:if test="not(text()) and @line">1198 <xsl:text>%{C++
</xsl:text>1199 <xsl:value-of select="@line"/>1200 <xsl:text>
%}

</xsl:text>1201 </xsl:if>1202 </xsl:template>1203 -->1204 1205 1206 <!--1207 * #if statement (@if attribute)1208 * @note1209 * xpidl doesn't support any preprocessor defines other than #include1210 * (it just ignores them), so the generated IDL will most likely be1211 * invalid. So for now we forbid using @if attributes1212 -->1213 <xsl:template match="@if" mode="begin">1214 <xsl:message terminate="yes">1215 @if attributes are not currently allowed because xpidl lacks1216 support for #ifdef and stuff.1217 </xsl:message>1218 <xsl:text>#if </xsl:text>1219 <xsl:value-of select="."/>1220 <xsl:text>
</xsl:text>1221 </xsl:template>1222 <xsl:template match="@if" mode="end">1223 <xsl:text>#endif
</xsl:text>1224 </xsl:template>1225 1226 1598 1227 1599 <!-- … … 1236 1608 <xsl:text>

</xsl:text> 1237 1609 <!-- forward declarations --> 1238 <xsl:apply-templates select="i f |interface" mode="forward"/>1610 <xsl:apply-templates select="interface | if/interface" mode="forward"/> 1239 1611 <xsl:text>
</xsl:text> 1240 1612 <!-- typedef'ing the struct declarations --> 1241 <xsl:apply-templates select="i f |interface" mode="typedef"/>1613 <xsl:apply-templates select="interface | if/interface" mode="typedef"/> 1242 1614 <xsl:text>
</xsl:text> 1243 1615 <!-- all enums go first --> … … 1263 1635 --> 1264 1636 <xsl:template match="interface" mode="forward"> 1265 <xsl:text>struct </xsl:text> 1266 <xsl:value-of select="@name"/> 1267 <xsl:text>;
</xsl:text> 1637 <xsl:if test="not(@internal='yes')"> 1638 <xsl:text>struct </xsl:text> 1639 <xsl:value-of select="@name"/> 1640 <xsl:text>;
</xsl:text> 1641 </xsl:if> 1268 1642 </xsl:template> 1269 1643 … … 1273 1647 --> 1274 1648 <xsl:template match="interface" mode="typedef"> 1275 <xsl:text>typedef struct </xsl:text> 1276 <xsl:value-of select="@name"/> 1277 <xsl:text> </xsl:text> 1278 <xsl:value-of select="@name"/> 1279 <xsl:text>;
</xsl:text> 1649 <xsl:if test="not(@internal='yes')"> 1650 <xsl:text>typedef struct </xsl:text> 1651 <xsl:value-of select="@name"/> 1652 <xsl:text> </xsl:text> 1653 <xsl:value-of select="@name"/> 1654 <xsl:text>;
</xsl:text> 1655 </xsl:if> 1656 </xsl:template> 1657 1658 1659 <!-- 1660 * COBJMACRO style convenience macros for calling methods 1661 --> 1662 <xsl:template match="interface" mode="cobjmacro"> 1663 <xsl:param name="iface"/> 1664 1665 <xsl:variable name="extends" select="@extends"/> 1666 <xsl:choose> 1667 <xsl:when test="$extends='$unknown'"> 1668 <xsl:text>#define </xsl:text> 1669 <xsl:value-of select="$iface"/> 1670 <xsl:text>_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
</xsl:text> 1671 <xsl:text>#define </xsl:text> 1672 <xsl:value-of select="$iface"/> 1673 <xsl:text>_AddRef(p) ((p)->lpVtbl->AddRef(p))
</xsl:text> 1674 <xsl:text>#define </xsl:text> 1675 <xsl:value-of select="$iface"/> 1676 <xsl:text>_Release(p) ((p)->lpVtbl->Release(p))
</xsl:text> 1677 </xsl:when> 1678 <xsl:when test="$extends='$errorinfo'"> 1679 <xsl:text>#define </xsl:text> 1680 <xsl:value-of select="$iface"/> 1681 <xsl:text>_QueryInterface(p, iid, resultp) ((p)->lpVtbl->QueryInterface(p, iid, resultp))
</xsl:text> 1682 <xsl:text>#define </xsl:text> 1683 <xsl:value-of select="$iface"/> 1684 <xsl:text>_AddRef(p) ((p)->lpVtbl->AddRef(p))
</xsl:text> 1685 <xsl:text>#define </xsl:text> 1686 <xsl:value-of select="$iface"/> 1687 <xsl:text>_Release(p) ((p)->lpVtbl->Release(p))
</xsl:text> 1688 <xsl:text>#define </xsl:text> 1689 <xsl:value-of select="$iface"/> 1690 <xsl:text>_get_Message(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage))
</xsl:text> 1691 <xsl:text>#define </xsl:text> 1692 <xsl:value-of select="$iface"/> 1693 <xsl:text>_GetMessage(p, aMessage) ((p)->lpVtbl->GetMessage(p, aMessage))
</xsl:text> 1694 <xsl:text>#define </xsl:text> 1695 <xsl:value-of select="$iface"/> 1696 <xsl:text>_get_Result(p, aResult) ((p)->lpVtbl->GetResult(p, aResult))
</xsl:text> 1697 <xsl:text>#define </xsl:text> 1698 <xsl:value-of select="$iface"/> 1699 <xsl:text>_GetResult(p, aResult) ((p)->lpVtbl->GetResult(p, aResult))
</xsl:text> 1700 <xsl:text>#define </xsl:text> 1701 <xsl:value-of select="$iface"/> 1702 <xsl:text>_get_Name(p, aName) ((p)->lpVtbl->GetName(p, aName))
</xsl:text> 1703 <xsl:text>#define </xsl:text> 1704 <xsl:value-of select="$iface"/> 1705 <xsl:text>_GetName(p, aName) ((p)->lpVtbl->GetName(p, aName))
</xsl:text> 1706 <xsl:text>#define </xsl:text> 1707 <xsl:value-of select="$iface"/> 1708 <xsl:text>_get_Filename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))
</xsl:text> 1709 <xsl:text>#define </xsl:text> 1710 <xsl:value-of select="$iface"/> 1711 <xsl:text>_GetFilename(p, aFilename) ((p)->lpVtbl->GetFilename(p, aFilename))
</xsl:text> 1712 <xsl:text>#define </xsl:text> 1713 <xsl:value-of select="$iface"/> 1714 <xsl:text>_get_LineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))
</xsl:text> 1715 <xsl:text>#define </xsl:text> 1716 <xsl:value-of select="$iface"/> 1717 <xsl:text>_GetLineNumber(p, aLineNumber) ((p)->lpVtbl->GetLineNumber(p, aLineNumber))
</xsl:text> 1718 <xsl:text>#define </xsl:text> 1719 <xsl:value-of select="$iface"/> 1720 <xsl:text>_get_ColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber))
</xsl:text> 1721 <xsl:text>#define </xsl:text> 1722 <xsl:value-of select="$iface"/> 1723 <xsl:text>_GetColumnNumber(p, aColumnNumber) ((p)->lpVtbl->GetColumnNumber(p, aColumnNumber))
</xsl:text> 1724 <xsl:text>#define </xsl:text> 1725 <xsl:value-of select="$iface"/> 1726 <xsl:text>_get_Location(p, aLocation) ((p)->lpVtbl->GetLocation(p, aLocation))
</xsl:text> 1727 <xsl:text>#define </xsl:text> 1728 <xsl:value-of select="$iface"/> 1729 <xsl:text>_GetLocation(p, aLocation) ((p)->lpVtbl->GetLocation(p, aLocation))
</xsl:text> 1730 <xsl:text>#define </xsl:text> 1731 <xsl:value-of select="$iface"/> 1732 <xsl:text>_get_Inner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner))
</xsl:text> 1733 <xsl:text>#define </xsl:text> 1734 <xsl:value-of select="$iface"/> 1735 <xsl:text>_GetInner(p, aInner) ((p)->lpVtbl->GetInner(p, aInner))
</xsl:text> 1736 <xsl:text>#define </xsl:text> 1737 <xsl:value-of select="$iface"/> 1738 <xsl:text>_get_Data(p, aData) ((p)->lpVtbl->GetData(p, aData))
</xsl:text> 1739 <xsl:text>#define </xsl:text> 1740 <xsl:value-of select="$iface"/> 1741 <xsl:text>_GetData(p, aData) ((p)->lpVtbl->GetData(p, aData))
</xsl:text> 1742 <xsl:text>#define </xsl:text> 1743 <xsl:value-of select="$iface"/> 1744 <xsl:text>_ToString(p, retval) ((p)->lpVtbl->ToString(p, retval))
</xsl:text> 1745 </xsl:when> 1746 <xsl:otherwise> 1747 <xsl:apply-templates select="//interface[@name=$extends]" mode="cobjmacro"> 1748 <xsl:with-param name="iface" select="$iface"/> 1749 </xsl:apply-templates> 1750 </xsl:otherwise> 1751 </xsl:choose> 1752 <!-- attributes (properties) --> 1753 <xsl:apply-templates select="attribute | if/attribute" mode="cobjmacro"> 1754 <xsl:with-param name="iface" select="$iface"/> 1755 </xsl:apply-templates> 1756 <!-- methods --> 1757 <xsl:apply-templates select="method | if/method" mode="cobjmacro"> 1758 <xsl:with-param name="iface" select="$iface"/> 1759 </xsl:apply-templates> 1760 </xsl:template> 1761 1762 1763 <!-- 1764 * emit flat vtable, compatible with COM 1765 --> 1766 <xsl:template match="interface" mode="vtab_flat"> 1767 <xsl:param name="iface"/> 1768 1769 <xsl:variable name="extends" select="@extends"/> 1770 <xsl:choose> 1771 <xsl:when test="$extends='$unknown'"> 1772 <xsl:text> nsresult (*QueryInterface)(</xsl:text> 1773 <xsl:value-of select="$iface"/> 1774 <xsl:text> *pThis, const nsID *iid, void **resultp);
</xsl:text> 1775 <xsl:text> nsrefcnt (*AddRef)(</xsl:text> 1776 <xsl:value-of select="$iface"/> 1777 <xsl:text> *pThis);
</xsl:text> 1778 <xsl:text> nsrefcnt (*Release)(</xsl:text> 1779 <xsl:value-of select="$iface"/> 1780 <xsl:text> *pThis);
</xsl:text> 1781 </xsl:when> 1782 <xsl:when test="$extends='$errorinfo'"> 1783 <xsl:text> nsresult (*QueryInterface)(</xsl:text> 1784 <xsl:value-of select="$iface"/> 1785 <xsl:text> *pThis, const nsID *iid, void **resultp);
</xsl:text> 1786 <xsl:text> nsrefcnt (*AddRef)(</xsl:text> 1787 <xsl:value-of select="$iface"/> 1788 <xsl:text> *pThis);
</xsl:text> 1789 <xsl:text> nsrefcnt (*Release)(</xsl:text> 1790 <xsl:value-of select="$iface"/> 1791 <xsl:text> *pThis);
</xsl:text> 1792 <xsl:text> nsresult (*GetMessage)(</xsl:text> 1793 <xsl:value-of select="$iface"/> 1794 <xsl:text> *pThis, PRUnichar * *aMessage);
</xsl:text> 1795 <xsl:text> nsresult (*GetResult)(</xsl:text> 1796 <xsl:value-of select="$iface"/> 1797 <xsl:text> *pThis, nsresult *aResult);
</xsl:text> 1798 <xsl:text> nsresult (*GetName)(</xsl:text> 1799 <xsl:value-of select="$iface"/> 1800 <xsl:text>*pThis, PRUnichar * *aName);
</xsl:text> 1801 <xsl:text> nsresult (*GetFilename)(</xsl:text> 1802 <xsl:value-of select="$iface"/> 1803 <xsl:text> *pThis, PRUnichar * *aFilename);
</xsl:text> 1804 <xsl:text> nsresult (*GetLineNumber)(</xsl:text> 1805 <xsl:value-of select="$iface"/> 1806 <xsl:text> *pThis, PRUint32 *aLineNumber);
</xsl:text> 1807 <xsl:text> nsresult (*GetColumnNumber)(</xsl:text> 1808 <xsl:value-of select="$iface"/> 1809 <xsl:text> *pThis, PRUint32 *aColumnNumber);
</xsl:text> 1810 <xsl:text> nsresult (*GetLocation)(</xsl:text> 1811 <xsl:value-of select="$iface"/> 1812 <xsl:text> *pThis, nsIStackFrame * *aLocation);
</xsl:text> 1813 <xsl:text> nsresult (*GetInner)(</xsl:text> 1814 <xsl:value-of select="$iface"/> 1815 <xsl:text> *pThis, nsIException * *aInner);
</xsl:text> 1816 <xsl:text> nsresult (*GetData)(</xsl:text> 1817 <xsl:value-of select="$iface"/> 1818 <xsl:text> *pThis, nsISupports * *aData);
</xsl:text> 1819 <xsl:text> nsresult (*ToString)(</xsl:text> 1820 <xsl:value-of select="$iface"/> 1821 <xsl:text> *pThis, PRUnichar **_retval);
</xsl:text> 1822 </xsl:when> 1823 <xsl:otherwise> 1824 <xsl:apply-templates select="//interface[@name=$extends]" mode="vtab_flat"> 1825 <xsl:with-param name="iface" select="$iface"/> 1826 </xsl:apply-templates> 1827 </xsl:otherwise> 1828 </xsl:choose> 1829 <!-- attributes (properties) --> 1830 <xsl:apply-templates select="attribute | if/attribute"> 1831 <xsl:with-param name="iface" select="$iface"/> 1832 </xsl:apply-templates> 1833 <!-- methods --> 1834 <xsl:apply-templates select="method | if/method"> 1835 <xsl:with-param name="iface" select="$iface"/> 1836 </xsl:apply-templates> 1280 1837 </xsl:template> 1281 1838 … … 1285 1842 --> 1286 1843 <xsl:template match="interface"> 1287 <xsl:text>/* Start of struct </xsl:text> 1288 <xsl:value-of select="@name"/> 1289 <xsl:text> Declaration */
</xsl:text> 1290 <xsl:text>#define </xsl:text> 1291 <xsl:call-template name="uppercase"> 1292 <xsl:with-param name="str" select="@name"/> 1293 </xsl:call-template> 1294 <xsl:value-of select="concat('_IID_STR "',@uuid,'"')"/> 1295 <xsl:text>
</xsl:text> 1296 <xsl:text>#define </xsl:text> 1297 <xsl:call-template name="uppercase"> 1298 <xsl:with-param name="str" select="@name"/> 1299 </xsl:call-template> 1300 <xsl:text>_IID { \
</xsl:text> 1301 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/> 1302 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/> 1303 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/> 1304 <xsl:text>, \
 </xsl:text> 1305 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/> 1306 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/> 1307 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/> 1308 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/> 1309 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/> 1310 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/> 1311 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/> 1312 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/> 1313 <xsl:text> } \
}
</xsl:text> 1314 <xsl:text>struct </xsl:text> 1315 <xsl:value-of select="@name"/> 1316 <xsl:text>_vtbl
{
</xsl:text> 1317 <xsl:text> </xsl:text> 1318 <xsl:choose> 1319 <xsl:when test="@extends='$unknown'">struct nsISupports_vtbl nsisupports;</xsl:when> 1320 <xsl:when test="@extends='$dispatched'">struct nsISupports_vtbl nsisupports;</xsl:when> 1321 <xsl:when test="@extends='$errorinfo'">struct nsIException_vtbl nsiexception;</xsl:when> 1322 <xsl:otherwise> 1323 <xsl:text>struct </xsl:text> 1324 <xsl:value-of select="@extends"/> 1325 <xsl:text>_vtbl </xsl:text> 1326 <xsl:call-template name="lowercase"> 1327 <xsl:with-param name="str" select="@extends"/> 1328 </xsl:call-template> 1329 <xsl:text>;</xsl:text> 1330 </xsl:otherwise> 1331 </xsl:choose> 1332 <xsl:text>

</xsl:text> 1333 <!-- attributes (properties) --> 1334 <xsl:apply-templates select="attribute"/> 1335 <!-- methods --> 1336 <xsl:apply-templates select="method"/> 1337 <!-- 'if' enclosed elements, unsorted --> 1338 <xsl:apply-templates select="if"/> 1339 <!-- --> 1340 <xsl:text>};</xsl:text> 1341 <xsl:text>

</xsl:text> 1342 <xsl:text>struct </xsl:text> 1343 <xsl:value-of select="@name"/> 1344 <xsl:text>
{
 struct </xsl:text> 1345 <xsl:value-of select="@name"/> 1346 <xsl:text>_vtbl *vtbl;
};
</xsl:text> 1347 <xsl:text>/* End of struct </xsl:text> 1348 <xsl:value-of select="@name"/> 1349 <xsl:text> Declaration */


</xsl:text> 1844 <xsl:if test="not(@internal='yes')"> 1845 <xsl:text>/* Start of struct </xsl:text> 1846 <xsl:value-of select="@name"/> 1847 <xsl:text> declaration */
</xsl:text> 1848 <xsl:text>#define </xsl:text> 1849 <xsl:call-template name="uppercase"> 1850 <xsl:with-param name="str" select="@name"/> 1851 </xsl:call-template> 1852 <xsl:value-of select="concat('_IID_STR "',@uuid,'"')"/> 1853 <xsl:text>
</xsl:text> 1854 <xsl:text>#define </xsl:text> 1855 <xsl:call-template name="uppercase"> 1856 <xsl:with-param name="str" select="@name"/> 1857 </xsl:call-template> 1858 <xsl:text>_IID { \
</xsl:text> 1859 <xsl:text> 0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/> 1860 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/> 1861 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/> 1862 <xsl:text>, \
 </xsl:text> 1863 <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/> 1864 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/> 1865 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/> 1866 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/> 1867 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/> 1868 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/> 1869 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/> 1870 <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/> 1871 <xsl:text> } \
}
</xsl:text> 1872 <xsl:text>/* COM compatibility */
</xsl:text> 1873 <xsl:text>VBOX_EXTERN_CONST(nsIID, IID_</xsl:text> 1874 <xsl:value-of select="@name"/> 1875 <xsl:text>);
</xsl:text> 1876 <xsl:text>#ifndef VBOX_WITH_GLUE
</xsl:text> 1877 <xsl:text>struct </xsl:text> 1878 <xsl:value-of select="@name"/> 1879 <xsl:text>_vtbl
{
</xsl:text> 1880 <xsl:text> </xsl:text> 1881 <xsl:choose> 1882 <xsl:when test="@extends='$unknown'">struct nsISupports_vtbl nsisupports;</xsl:when> 1883 <xsl:when test="@extends='$errorinfo'">struct nsIException_vtbl nsiexception;</xsl:when> 1884 <xsl:otherwise> 1885 <xsl:text>struct </xsl:text> 1886 <xsl:value-of select="@extends"/> 1887 <xsl:text>_vtbl </xsl:text> 1888 <xsl:call-template name="lowercase"> 1889 <xsl:with-param name="str" select="@extends"/> 1890 </xsl:call-template> 1891 <xsl:text>;</xsl:text> 1892 </xsl:otherwise> 1893 </xsl:choose> 1894 <xsl:text>

</xsl:text> 1895 <!-- attributes (properties) --> 1896 <xsl:apply-templates select="attribute | if/attribute"/> 1897 <!-- methods --> 1898 <xsl:apply-templates select="method | if/method"/> 1899 <!-- --> 1900 <xsl:text>};
</xsl:text> 1901 <xsl:text>#else /* VBOX_WITH_GLUE */
</xsl:text> 1902 <xsl:text>struct </xsl:text> 1903 <xsl:value-of select="@name"/> 1904 <xsl:text>Vtbl
{
</xsl:text> 1905 <xsl:apply-templates select="." mode="vtab_flat"> 1906 <xsl:with-param name="iface" select="@name"/> 1907 </xsl:apply-templates> 1908 <xsl:text>};
</xsl:text> 1909 <xsl:apply-templates select="." mode="cobjmacro"> 1910 <xsl:with-param name="iface" select="@name"/> 1911 </xsl:apply-templates> 1912 <!-- --> 1913 <xsl:text>#endif /* VBOX_WITH_GLUE */
</xsl:text> 1914 <xsl:text>
</xsl:text> 1915 <xsl:text>struct </xsl:text> 1916 <xsl:value-of select="@name"/> 1917 <xsl:text>
{
</xsl:text> 1918 <xsl:text>#ifndef VBOX_WITH_GLUE
</xsl:text> 1919 <xsl:text> struct </xsl:text> 1920 <xsl:value-of select="@name"/> 1921 <xsl:text>_vtbl *vtbl;
</xsl:text> 1922 <xsl:text>#else /* VBOX_WITH_GLUE */
</xsl:text> 1923 <xsl:text> struct </xsl:text> 1924 <xsl:value-of select="@name"/> 1925 <xsl:text>Vtbl *lpVtbl;
</xsl:text> 1926 <xsl:text>#endif /* VBOX_WITH_GLUE */
</xsl:text> 1927 <xsl:text>};
</xsl:text> 1928 <xsl:text>/* End of struct </xsl:text> 1929 <xsl:value-of select="@name"/> 1930 <xsl:text> declaration */


</xsl:text> 1931 </xsl:if> 1350 1932 </xsl:template> 1351 1933 … … 1354 1936 * attributes 1355 1937 --> 1356 <xsl:template match="interface//attribute"> 1357 <xsl:apply-templates select="@if" mode="begin"/> 1358 <xsl:if test="@mod='ptr'"> 1359 <!-- attributes using native types must be non-scriptable 1360 <xsl:text> [noscript]
</xsl:text>--> 1361 </xsl:if> 1938 <xsl:template match="attribute"> 1939 <xsl:param name="iface" select="ancestor::interface/@name"/> 1940 1362 1941 <xsl:choose> 1363 1942 <!-- safearray pseudo attribute --> … … 1369 1948 </xsl:call-template> 1370 1949 <xsl:text>)(</xsl:text> 1371 <xsl:value-of select=" ../@name" />1950 <xsl:value-of select="$iface" /> 1372 1951 <xsl:text> *pThis, </xsl:text> 1373 1952 <!-- array size --> … … 1387 1966 </xsl:call-template> 1388 1967 <xsl:text>)(</xsl:text> 1389 <xsl:value-of select=" ../@name" />1968 <xsl:value-of select="$iface" /> 1390 1969 <xsl:text> *pThis, </xsl:text> 1391 1970 <!-- array size --> … … 1409 1988 </xsl:call-template> 1410 1989 <xsl:text>)(</xsl:text> 1411 <xsl:value-of select=" ../@name" />1990 <xsl:value-of select="$iface" /> 1412 1991 <xsl:text> *pThis, </xsl:text> 1413 1992 <xsl:apply-templates select="@type" mode="forwarder"/> … … 1425 2004 </xsl:call-template> 1426 2005 <xsl:text>)(</xsl:text> 1427 <xsl:value-of select=" ../@name" />2006 <xsl:value-of select="$iface" /> 1428 2007 <xsl:text> *pThis, </xsl:text> 1429 2008 <xsl:apply-templates select="@type" mode="forwarder"/> … … 1436 2015 </xsl:call-template> 1437 2016 <xsl:text>)(</xsl:text> 1438 <xsl:value-of select=" ../@name" />2017 <xsl:value-of select="$iface" /> 1439 2018 <xsl:text> *pThis, </xsl:text> 1440 2019 <xsl:apply-templates select="@type" mode="forwarder"/> … … 1446 2025 </xsl:otherwise> 1447 2026 </xsl:choose> 1448 <xsl:apply-templates select="@if" mode="end"/>1449 2027 <xsl:text>
</xsl:text> 1450 2028 </xsl:template> 1451 2029 1452 <xsl:template match="interface//attribute" mode="forwarder"> 1453 1454 <xsl:variable name="parent" select="ancestor::interface"/> 1455 1456 <xsl:apply-templates select="@if" mode="begin"/> 1457 1458 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO(smth) --> 1459 <xsl:text>#define COM_FORWARD_</xsl:text> 1460 <xsl:value-of select="$parent/@name"/> 1461 <xsl:text>_GETTER_</xsl:text> 2030 <xsl:template match="attribute" mode="cobjmacro"> 2031 <xsl:param name="iface"/> 2032 2033 <!-- getter (COM compatible) --> 2034 <xsl:text>#define </xsl:text> 2035 <xsl:value-of select="concat($iface, '_get_')"/> 1462 2036 <xsl:call-template name="capitalize"> 1463 2037 <xsl:with-param name="str" select="@name"/> 1464 2038 </xsl:call-template> 1465 <xsl:text> _TO(smth) NS_IMETHOD Get</xsl:text>2039 <xsl:text>(p, a</xsl:text> 1466 2040 <xsl:call-template name="capitalize"> 1467 2041 <xsl:with-param name="str" select="@name"/> 1468 2042 </xsl:call-template> 1469 <xsl:text> (</xsl:text> 1470 <xsl:if test="@safearray='yes'"> 1471 <xsl:text>PRUint32 * a</xsl:text> 2043 <xsl:text>) ((p)->lpVtbl->Get</xsl:text> 2044 <xsl:call-template name="capitalize"> 2045 <xsl:with-param name="str" select="@name"/> 2046 </xsl:call-template> 2047 <xsl:text>(p, a</xsl:text> 2048 <xsl:call-template name="capitalize"> 2049 <xsl:with-param name="str" select="@name"/> 2050 </xsl:call-template> 2051 <xsl:text>))
</xsl:text> 2052 2053 <!-- getter (XPCOM compatible) --> 2054 <xsl:text>#define </xsl:text> 2055 <xsl:value-of select="concat($iface, '_Get')"/> 2056 <xsl:call-template name="capitalize"> 2057 <xsl:with-param name="str" select="@name"/> 2058 </xsl:call-template> 2059 <xsl:text>(p, a</xsl:text> 2060 <xsl:call-template name="capitalize"> 2061 <xsl:with-param name="str" select="@name"/> 2062 </xsl:call-template> 2063 <xsl:text>) ((p)->lpVtbl->Get</xsl:text> 2064 <xsl:call-template name="capitalize"> 2065 <xsl:with-param name="str" select="@name"/> 2066 </xsl:call-template> 2067 <xsl:text>(p, a</xsl:text> 2068 <xsl:call-template name="capitalize"> 2069 <xsl:with-param name="str" select="@name"/> 2070 </xsl:call-template> 2071 <xsl:text>))
</xsl:text> 2072 2073 <xsl:if test="not(@readonly='yes')"> 2074 <!-- setter (COM compatible) --> 2075 <xsl:text>#define </xsl:text> 2076 <xsl:value-of select="concat($iface, '_set_')"/> 1472 2077 <xsl:call-template name="capitalize"> 1473 2078 <xsl:with-param name="str" select="@name"/> 1474 2079 </xsl:call-template> 1475 <xsl:text>Size, </xsl:text> 1476 </xsl:if> 1477 <xsl:apply-templates select="@type" mode="forwarder"/> 1478 <xsl:if test="@safearray='yes'"> 1479 <xsl:text> *</xsl:text> 1480 </xsl:if> 1481 <xsl:text> * a</xsl:text> 1482 <xsl:call-template name="capitalize"> 1483 <xsl:with-param name="str" select="@name"/> 1484 </xsl:call-template> 1485 <xsl:text>) { return smth Get</xsl:text> 1486 <xsl:call-template name="capitalize"> 1487 <xsl:with-param name="str" select="@name"/> 1488 </xsl:call-template> 1489 <xsl:text> (</xsl:text> 1490 <xsl:if test="@safearray='yes'"> 1491 <xsl:text>a</xsl:text> 2080 <xsl:text>(p, a</xsl:text> 1492 2081 <xsl:call-template name="capitalize"> 1493 2082 <xsl:with-param name="str" select="@name"/> 1494 2083 </xsl:call-template> 1495 <xsl:text>Size, </xsl:text> 1496 </xsl:if> 1497 <xsl:text>a</xsl:text> 1498 <xsl:call-template name="capitalize"> 1499 <xsl:with-param name="str" select="@name"/> 1500 </xsl:call-template> 1501 <xsl:text>); }
</xsl:text> 1502 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_OBJ(obj) --> 1503 <xsl:text>#define COM_FORWARD_</xsl:text> 1504 <xsl:value-of select="$parent/@name"/> 1505 <xsl:text>_GETTER_</xsl:text> 1506 <xsl:call-template name="capitalize"> 1507 <xsl:with-param name="str" select="@name"/> 1508 </xsl:call-template> 1509 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text> 1510 <xsl:value-of select="$parent/@name"/> 1511 <xsl:text>_GETTER_</xsl:text> 1512 <xsl:call-template name="capitalize"> 1513 <xsl:with-param name="str" select="@name"/> 1514 </xsl:call-template> 1515 <xsl:text>_TO ((obj)->)
</xsl:text> 1516 <!-- getter: COM_FORWARD_Interface_GETTER_Name_TO_BASE(base) --> 1517 <xsl:text>#define COM_FORWARD_</xsl:text> 1518 <xsl:value-of select="$parent/@name"/> 1519 <xsl:text>_GETTER_</xsl:text> 1520 <xsl:call-template name="capitalize"> 1521 <xsl:with-param name="str" select="@name"/> 1522 </xsl:call-template> 1523 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text> 1524 <xsl:value-of select="$parent/@name"/> 1525 <xsl:text>_GETTER_</xsl:text> 1526 <xsl:call-template name="capitalize"> 1527 <xsl:with-param name="str" select="@name"/> 1528 </xsl:call-template> 1529 <xsl:text>_TO (base::)
</xsl:text> 1530 <!-- --> 1531 <xsl:if test="not(@readonly='yes')"> 1532 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO(smth) --> 1533 <xsl:text>#define COM_FORWARD_</xsl:text> 1534 <xsl:value-of select="$parent/@name"/> 1535 <xsl:text>_SETTER_</xsl:text> 2084 <xsl:text>) ((p)->lpVtbl->Set</xsl:text> 1536 2085 <xsl:call-template name="capitalize"> 1537 2086 <xsl:with-param name="str" select="@name"/> 1538 2087 </xsl:call-template> 1539 <xsl:text> _TO(smth) NS_IMETHOD Set</xsl:text>2088 <xsl:text>(p, a</xsl:text> 1540 2089 <xsl:call-template name="capitalize"> 1541 2090 <xsl:with-param name="str" select="@name"/> 1542 2091 </xsl:call-template> 1543 <xsl:text> (</xsl:text> 1544 <xsl:if test="@safearray='yes'"> 1545 <xsl:text>PRUint32 a</xsl:text> 1546 <xsl:call-template name="capitalize"> 1547 <xsl:with-param name="str" select="@name"/> 1548 </xsl:call-template> 1549 <xsl:text>Size, </xsl:text> 1550 </xsl:if> 1551 <xsl:if test="not(@safearray='yes') and (@type='string' or @type='wstring')"> 1552 <xsl:text>const </xsl:text> 1553 </xsl:if> 1554 <xsl:apply-templates select="@type" mode="forwarder"/> 1555 <xsl:if test="@safearray='yes'"> 1556 <xsl:text> *</xsl:text> 1557 </xsl:if> 1558 <xsl:text> a</xsl:text> 2092 <xsl:text>))
</xsl:text> 2093 2094 <!-- setter (XPCOM compatible) --> 2095 <xsl:text>#define </xsl:text> 2096 <xsl:value-of select="concat($iface, '_Set')"/> 1559 2097 <xsl:call-template name="capitalize"> 1560 2098 <xsl:with-param name="str" select="@name"/> 1561 2099 </xsl:call-template> 1562 <xsl:text> ) { return smth Set</xsl:text>2100 <xsl:text>(p, a</xsl:text> 1563 2101 <xsl:call-template name="capitalize"> 1564 2102 <xsl:with-param name="str" select="@name"/> 1565 2103 </xsl:call-template> 1566 <xsl:text> (a</xsl:text>2104 <xsl:text>) ((p)->lpVtbl->Set</xsl:text> 1567 2105 <xsl:call-template name="capitalize"> 1568 2106 <xsl:with-param name="str" select="@name"/> 1569 2107 </xsl:call-template> 1570 <xsl:text>); }
</xsl:text> 1571 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_OBJ(obj) --> 1572 <xsl:text>#define COM_FORWARD_</xsl:text> 1573 <xsl:value-of select="$parent/@name"/> 1574 <xsl:text>_SETTER_</xsl:text> 2108 <xsl:text>(p, a</xsl:text> 1575 2109 <xsl:call-template name="capitalize"> 1576 2110 <xsl:with-param name="str" select="@name"/> 1577 2111 </xsl:call-template> 1578 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text> 1579 <xsl:value-of select="$parent/@name"/> 1580 <xsl:text>_SETTER_</xsl:text> 1581 <xsl:call-template name="capitalize"> 1582 <xsl:with-param name="str" select="@name"/> 1583 </xsl:call-template> 1584 <xsl:text>_TO ((obj)->)
</xsl:text> 1585 <!-- setter: COM_FORWARD_Interface_SETTER_Name_TO_BASE(base) --> 1586 <xsl:text>#define COM_FORWARD_</xsl:text> 1587 <xsl:value-of select="$parent/@name"/> 1588 <xsl:text>_SETTER_</xsl:text> 1589 <xsl:call-template name="capitalize"> 1590 <xsl:with-param name="str" select="@name"/> 1591 </xsl:call-template> 1592 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text> 1593 <xsl:value-of select="$parent/@name"/> 1594 <xsl:text>_SETTER_</xsl:text> 1595 <xsl:call-template name="capitalize"> 1596 <xsl:with-param name="str" select="@name"/> 1597 </xsl:call-template> 1598 <xsl:text>_TO (base::)
</xsl:text> 2112 <xsl:text>))
</xsl:text> 2113 1599 2114 </xsl:if> 1600 1601 <xsl:apply-templates select="@if" mode="end"/>1602 1603 2115 </xsl:template> 1604 1605 2116 1606 2117 <!-- 1607 2118 * methods 1608 2119 --> 1609 <xsl:template match="interface//method"> 1610 <xsl:apply-templates select="@if" mode="begin"/> 2120 <xsl:template match="method"> 2121 <xsl:param name="iface" select="ancestor::interface/@name"/> 2122 1611 2123 <xsl:if test="param/@mod='ptr'"> 1612 2124 <!-- methods using native types must be non-scriptable … … 1620 2132 <xsl:text>)(
</xsl:text> 1621 2133 <xsl:text> </xsl:text> 1622 <xsl:value-of select=" ../@name" />2134 <xsl:value-of select="$iface" /> 1623 2135 <xsl:text> *pThis,
</xsl:text> 1624 2136 <xsl:for-each select="param [position() != last()]"> … … 1633 2145 <xsl:if test="not(param)"> 1634 2146 <xsl:text>)(</xsl:text> 1635 <xsl:value-of select=" ../@name" />2147 <xsl:value-of select="$iface" /> 1636 2148 <xsl:text> *pThis );
</xsl:text> 1637 2149 </xsl:if> 1638 <xsl:apply-templates select="@if" mode="end"/>1639 2150 <xsl:text>
</xsl:text> 1640 2151 </xsl:template> 1641 2152 1642 <xsl:template match="interface//method" mode="forwarder"> 1643 1644 <xsl:variable name="parent" select="ancestor::interface"/> 1645 1646 <xsl:apply-templates select="@if" mode="begin"/> 1647 1648 <xsl:text>#define COM_FORWARD_</xsl:text> 1649 <xsl:value-of select="$parent/@name"/> 1650 <xsl:text>_</xsl:text> 2153 <xsl:template match="method" mode="cobjmacro"> 2154 <xsl:param name="iface"/> 2155 2156 <xsl:text>#define </xsl:text> 2157 <xsl:value-of select="concat($iface, '_')"/> 1651 2158 <xsl:call-template name="capitalize"> 1652 2159 <xsl:with-param name="str" select="@name"/> 1653 2160 </xsl:call-template> 1654 <xsl:text>_TO(smth) NS_IMETHOD </xsl:text> 2161 <xsl:text>(p</xsl:text> 2162 <xsl:for-each select="param"> 2163 <xsl:text>, a</xsl:text> 2164 <xsl:call-template name="capitalize"> 2165 <xsl:with-param name="str" select="@name"/> 2166 </xsl:call-template> 2167 </xsl:for-each> 2168 <xsl:text>) ((p)->lpVtbl-></xsl:text> 1655 2169 <xsl:call-template name="capitalize"> 1656 2170 <xsl:with-param name="str" select="@name"/> 1657 2171 </xsl:call-template> 1658 <xsl:choose> 1659 <xsl:when test="param"> 1660 <xsl:text> (</xsl:text> 1661 <xsl:for-each select="param [position() != last()]"> 1662 <xsl:apply-templates select="." mode="forwarder"/> 1663 <xsl:text>, </xsl:text> 1664 </xsl:for-each> 1665 <xsl:apply-templates select="param [last()]" mode="forwarder"/> 1666 <xsl:text>) { return smth </xsl:text> 1667 <xsl:call-template name="capitalize"> 1668 <xsl:with-param name="str" select="@name"/> 1669 </xsl:call-template> 1670 <xsl:text> (</xsl:text> 1671 <xsl:for-each select="param [position() != last()]"> 1672 <xsl:if test="@safearray='yes'"> 1673 <xsl:text>a</xsl:text> 1674 <xsl:call-template name="capitalize"> 1675 <xsl:with-param name="str" select="@name"/> 1676 </xsl:call-template> 1677 <xsl:text>Size+++, </xsl:text> 1678 </xsl:if> 1679 <xsl:text>a</xsl:text> 1680 <xsl:call-template name="capitalize"> 1681 <xsl:with-param name="str" select="@name"/> 1682 </xsl:call-template> 1683 <xsl:text>, </xsl:text> 1684 </xsl:for-each> 1685 <xsl:if test="param [last()]/@safearray='yes'"> 1686 <xsl:text>a</xsl:text> 1687 <xsl:call-template name="capitalize"> 1688 <xsl:with-param name="str" select="param [last()]/@name"/> 1689 </xsl:call-template> 1690 <xsl:text>Size, </xsl:text> 1691 </xsl:if> 1692 <xsl:text>a</xsl:text> 1693 <xsl:call-template name="capitalize"> 1694 <xsl:with-param name="str" select="param [last()]/@name"/> 1695 </xsl:call-template> 1696 <xsl:text>); }</xsl:text> 1697 </xsl:when> 1698 <xsl:otherwise test="not(param)"> 1699 <xsl:text>() { return smth </xsl:text> 1700 <xsl:call-template name="capitalize"> 1701 <xsl:with-param name="str" select="@name"/> 1702 </xsl:call-template> 1703 <xsl:text>(); }</xsl:text> 1704 </xsl:otherwise> 1705 </xsl:choose> 1706 <xsl:text>
</xsl:text> 1707 <!-- COM_FORWARD_Interface_Method_TO_OBJ(obj) --> 1708 <xsl:text>#define COM_FORWARD_</xsl:text> 1709 <xsl:value-of select="$parent/@name"/> 1710 <xsl:text>_</xsl:text> 1711 <xsl:call-template name="capitalize"> 1712 <xsl:with-param name="str" select="@name"/> 1713 </xsl:call-template> 1714 <xsl:text>_TO_OBJ(obj) COM_FORWARD_</xsl:text> 1715 <xsl:value-of select="$parent/@name"/> 1716 <xsl:text>_</xsl:text> 1717 <xsl:call-template name="capitalize"> 1718 <xsl:with-param name="str" select="@name"/> 1719 </xsl:call-template> 1720 <xsl:text>_TO ((obj)->)
</xsl:text> 1721 <!-- COM_FORWARD_Interface_Method_TO_BASE(base) --> 1722 <xsl:text>#define COM_FORWARD_</xsl:text> 1723 <xsl:value-of select="$parent/@name"/> 1724 <xsl:text>_</xsl:text> 1725 <xsl:call-template name="capitalize"> 1726 <xsl:with-param name="str" select="@name"/> 1727 </xsl:call-template> 1728 <xsl:text>_TO_BASE(base) COM_FORWARD_</xsl:text> 1729 <xsl:value-of select="$parent/@name"/> 1730 <xsl:text>_</xsl:text> 1731 <xsl:call-template name="capitalize"> 1732 <xsl:with-param name="str" select="@name"/> 1733 </xsl:call-template> 1734 <xsl:text>_TO (base::)
</xsl:text> 1735 1736 <xsl:apply-templates select="@if" mode="end"/> 1737 2172 <xsl:text>(p</xsl:text> 2173 <xsl:for-each select="param"> 2174 <xsl:text>, a</xsl:text> 2175 <xsl:call-template name="capitalize"> 2176 <xsl:with-param name="str" select="@name"/> 2177 </xsl:call-template> 2178 </xsl:for-each> 2179 <xsl:text>))
</xsl:text> 1738 2180 </xsl:template> 1739 2181 … … 1782 2224 <xsl:text>;1"
</xsl:text> 1783 2225 <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 --> 1784 <xsl:text>/* for compatibility with Win32*/
</xsl:text>1785 <xsl:text> #defineCLSID_</xsl:text>2226 <xsl:text>/* COM compatibility */
</xsl:text> 2227 <xsl:text>VBOX_EXTERN_CONST(nsCID, CLSID_</xsl:text> 1786 2228 <xsl:value-of select="@name"/> 1787 <xsl:text> (nsCID) NS_</xsl:text> 1788 <xsl:call-template name="uppercase"> 1789 <xsl:with-param name="str" select="@name"/> 1790 </xsl:call-template> 1791 <xsl:text>_CID
</xsl:text> 2229 <xsl:text>);
</xsl:text> 1792 2230 <xsl:text>

</xsl:text> 1793 2231 </xsl:template> … … 1800 2238 <xsl:text>/* Start of enum </xsl:text> 1801 2239 <xsl:value-of select="@name"/> 1802 <xsl:text> Declaration */
</xsl:text>2240 <xsl:text> declaration */
</xsl:text> 1803 2241 <xsl:text>#define </xsl:text> 1804 2242 <xsl:call-template name="uppercase"> … … 1842 2280 <xsl:text>/* End of enum </xsl:text> 1843 2281 <xsl:value-of select="@name"/> 1844 <xsl:text> Declaration */


</xsl:text> 2282 <xsl:text> declaration */ 2283 #define </xsl:text> 2284 <xsl:value-of select="concat(@name, '_T PRUint32


')"/> 1845 2285 </xsl:template> 1846 2286 -
trunk/src/VBox/Main/cbinding/makefile.tstCAPIGlue
r49984 r50183 1 1 # $Revision$ 2 ## @file makefile.tst XPCOMCGlue3 # Makefile for sample program illustrating use of C binding for XPCOM.2 ## @file makefile.tstCAPIGlue 3 # Makefile for sample program illustrating use of C binding for COM/XPCOM. 4 4 # 5 5 6 6 # 7 # Copyright (C) 2009-201 3Oracle Corporation7 # Copyright (C) 2009-2014 Oracle Corporation 8 8 # 9 9 # This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 # 17 17 18 INCS_XPCOM = -I../../include 19 GLUE_DIR = .. 20 GLUE_INC = -I.. 18 PATH_SDK = ../../.. 19 CAPI_INC = -I$(PATH_SDK)/bindings/c/include 20 ifeq ($(BUILD_PLATFORM),win) 21 PLATFORM_INC = -I$(PATH_SDK)/bindings/mscom/include 22 PLATFORM_LIB = $(PATH_SDK)/bindings/mscom/lib 23 else 24 PLATFORM_INC = -I$(PATH_SDK)/bindings/xpcom/include 25 PLATFORM_LIB = $(PATH_SDK)/bindings/xpcom/lib 26 endif 27 GLUE_DIR = $(PATH_SDK)/bindings/c/glue 28 GLUE_INC = -I$(GLUE_DIR) 21 29 22 30 CC = gcc … … 24 32 25 33 .PHONY: all 26 all: tst XPCOMCGlue34 all: tstCAPIGlue 27 35 28 36 .PHONY: clean 29 37 clean: 30 rm -f tst XPCOMCGlue.o tstXPCOMCGlue VBoxXPCOMCGlue.o38 rm -f tstCAPIGlue.o VBoxCAPIGlue.o VirtualBox_i.o tstCAPIGlue 31 39 32 tst XPCOMCGlue: tstXPCOMCGlue.o VBoxXPCOMCGlue.o40 tstCAPIGlue: tstCAPIGlue.o VBoxCAPIGlue.o VirtualBox_i.o 33 41 $(CC) -o $@ $^ -ldl -lpthread 34 42 35 tst XPCOMCGlue.o: tstXPCOMCGlue.c36 $(CC) $(CFLAGS) $( INCS_XPCOM) $(GLUE_INC) -o $@ -c $<43 tstCAPIGlue.o: tstCAPIGlue.c 44 $(CC) $(CFLAGS) $(CAPI_INC) $(PLATFORM_INC) $(GLUE_INC) -o $@ -c $< 37 45 38 VBoxXPCOMCGlue.o: $(GLUE_DIR)/VBoxXPCOMCGlue.c 39 $(CC) $(CFLAGS) $(INCS_XPCOM) $(GLUE_INC) -o $@ -c $< 46 VBoxCAPIGlue.o: $(GLUE_DIR)/VBoxCAPIGlue.c 47 $(CC) $(CFLAGS) $(CAPI_INC) $(PLATFORM_INC) $(GLUE_INC) -o $@ -c $< 48 49 VirtualBox_i.o: $(PLATFORM_LIB)/VirtualBox_i.c 50 $(CC) $(CFLAGS) $(CAPI_INC) $(PLATFORM_INC) $(GLUE_INC) -o $@ -c $< -
trunk/src/VBox/Main/cbinding/tstCAPIGlue.c
r49984 r50183 1 1 /* $Revision$ */ 2 /** @file tstXPCOMCGlue.c 3 * Demonstrator program to illustrate use of C bindings of Main API, including 4 * how to retrieve all available error information. 2 /** @file tstCAPIGlue.c 3 * Demonstrator program to illustrate use of C bindings of Main API. 5 4 * 6 * This includes code which shows how to handle active event listeners 7 * (event delivery through callbacks), which is not so frequently seen in 8 * other samples which mostly use passive event listeners. 9 * 10 * Linux only at the moment due to shared library magic in the Makefile. 5 * It has sample code showing how to retrieve all available error information, 6 * and how to handle active (event delivery through callbacks) or passive 7 * (event delivery through a polling mechanism) event listeners. 11 8 */ 12 9 13 10 /* 14 * Copyright (C) 2009-201 3Oracle Corporation11 * Copyright (C) 2009-2014 Oracle Corporation 15 12 * 16 13 * This file is part of VirtualBox Open Source Edition (OSE), as … … 26 23 * Header Files * 27 24 *******************************************************************************/ 28 #include "VBox XPCOMCGlue.h"25 #include "VBoxCAPIGlue.h" 29 26 #include <stdio.h> 30 27 #include <string.h> 31 28 #include <stdlib.h> 32 #include <unistd.h> 33 #include <signal.h> 34 #include <sys/poll.h> 29 #ifndef WIN32 30 # include <signal.h> 31 # include <unistd.h> 32 # include <sys/poll.h> 33 #endif 34 35 /** 36 * Select between active event listener (defined) and passive event listener 37 * (undefined). The active event listener case needs much more code, and 38 * additionally requires a lot more platform dependent code. 39 */ 40 #undef USE_ACTIVE_EVENT_LISTENER 41 35 42 36 43 /******************************************************************************* 37 44 * Global Variables * 38 45 *******************************************************************************/ 39 /** Set by signalhandler. */46 /** Set by Ctrl+C handler. */ 40 47 static volatile int g_fStop = 0; 41 48 42 static const char *GetStateName(PRUint32 machineState) 49 #ifdef USE_ACTIVE_EVENT_LISTENER 50 # ifdef WIN32 51 /** The COM type information for IEventListener, for implementing IDispatch. */ 52 static ITypeInfo *g_pTInfoIEventListener = NULL; 53 # endif /* WIN32 */ 54 #endif /* USE_ACTIVE_EVENT_LISTENER */ 55 56 static const char *GetStateName(MachineState_T machineState) 43 57 { 44 58 switch (machineState) … … 70 84 } 71 85 72 struct IEventListenerDemo_vtbl73 {74 struct IEventListener_vtbl ieventlistener;75 };76 77 typedef struct IEventListenerDemo78 {79 struct IEventListenerDemo_vtbl *vtbl;80 81 int refcount;82 } IEventListenerDemo;83 84 86 /** 85 * Event handler function 87 * Ctrl+C handler, terminate event listener. 88 * 89 * Remember that most function calls are not allowed in this context (including 90 * printf!), so make sure that this does as little as possible. 91 * 92 * @param iInfo Platform dependent detail info (ignored). 86 93 */ 87 static nsresult IEventListenerDemo_HandleEvent(IEventListener *pThis, IEvent *event) 88 { 89 enum VBoxEventType evType; 90 nsresult rc; 94 static BOOL ctrlCHandler(DWORD iInfo) 95 { 96 (void)iInfo; 97 g_fStop = 1; 98 return TRUE; 99 } 100 101 /** 102 * Sample event processing function, dumping some event information. 103 * Shared between active and passive event demo, to highlight that this part 104 * is identical between the two. 105 */ 106 static HRESULT EventListenerDemoProcessEvent(IEvent *event) 107 { 108 VBoxEventType_T evType; 109 HRESULT rc; 91 110 92 111 if (!event) 93 112 { 94 113 printf("event null\n"); 95 return NS_OK;114 return S_OK; 96 115 } 97 116 98 117 evType = VBoxEventType_Invalid; 99 rc = event->vtbl->GetType(event, &evType);100 if ( NS_FAILED(rc))118 rc = IEvent_get_Type(event, &evType); 119 if (FAILED(rc)) 101 120 { 102 121 printf("cannot get event type, rc=%#x\n", rc); 103 return NS_OK;122 return S_OK; 104 123 } 105 124 … … 120 139 case VBoxEventType_OnStateChanged: 121 140 { 122 static const nsID istateChangedEventUUID = ISTATECHANGEDEVENT_IID;123 141 IStateChangedEvent *ev = NULL; 124 142 enum MachineState state; 125 rc = event->vtbl->nsisupports.QueryInterface((nsISupports *)event, &istateChangedEventUUID, (void **)&ev);126 if ( NS_FAILED(rc))143 rc = IEvent_QueryInterface(event, &IID_IStateChangedEvent, (void **)&ev); 144 if (FAILED(rc)) 127 145 { 128 146 printf("cannot get StateChangedEvent interface, rc=%#x\n", rc); 129 return NS_OK;147 return S_OK; 130 148 } 131 149 if (!ev) 132 150 { 133 151 printf("StateChangedEvent reference null\n"); 134 return NS_OK;152 return S_OK; 135 153 } 136 rc = ev->vtbl->GetState(ev, &state);137 if ( NS_FAILED(rc))154 rc = IStateChangedEvent_get_State(ev, &state); 155 if (FAILED(rc)) 138 156 printf("warning: cannot get state, rc=%#x\n", rc); 139 ev->vtbl->ievent.nsisupports.Release((nsISupports *)ev);157 IStateChangedEvent_Release(ev); 140 158 printf("OnStateChanged: %s\n", GetStateName(state)); 141 159 … … 205 223 } 206 224 207 return NS_OK; 208 } 209 210 static nsresult IEventListenerDemo_QueryInterface(nsISupports *pThis, const nsID *iid, void **resultp) 211 { 212 static const nsID ieventListenerUUID = IEVENTLISTENER_IID; 213 static const nsID isupportIID = NS_ISUPPORTS_IID; 214 225 return S_OK; 226 } 227 228 #ifdef USE_ACTIVE_EVENT_LISTENER 229 230 struct IEventListenerDemo; 231 typedef struct IEventListenerDemo IEventListenerDemo; 232 233 typedef struct IEventListenerDemoVtbl 234 { 235 HRESULT (*QueryInterface)(IEventListenerDemo *pThis, REFIID riid, void **ppvObject); 236 ULONG (*AddRef)(IEventListenerDemo *pThis); 237 ULONG (*Release)(IEventListenerDemo *pThis); 238 #ifdef WIN32 239 HRESULT (*GetTypeInfoCount)(IEventListenerDemo *pThis, UINT *pctinfo); 240 HRESULT (*GetTypeInfo)(IEventListenerDemo *pThis, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); 241 HRESULT (*GetIDsOfNames)(IEventListenerDemo *pThis, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); 242 HRESULT (*Invoke)(IEventListenerDemo *pThis, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); 243 #endif 244 HRESULT (*HandleEvent)(IEventListenerDemo *pThis, IEvent *aEvent); 245 } IEventListenerDemoVtbl; 246 247 typedef struct IEventListenerDemo 248 { 249 struct IEventListenerDemoVtbl *lpVtbl; 250 251 int cRef; 252 253 #ifdef WIN32 254 /* Active event delivery needs a free threaded marshaler, as the default 255 * proxy marshaling cannot deal correctly with this case. */ 256 IUnknown *pUnkMarshaler; 257 #endif 258 } IEventListenerDemo; 259 260 /* Defines for easily calling IEventListenerDemo functions. */ 261 262 /* IUnknown functions. */ 263 #define IEventListenerDemo_QueryInterface(This,riid,ppvObject) \ 264 ( (This)->lpVtbl->QueryInterface(This,riid,ppvObject) ) 265 266 #define IEventListenerDemo_AddRef(This) \ 267 ( (This)->lpVtbl->AddRef(This) ) 268 269 #define IEventListenerDemo_Release(This) \ 270 ( (This)->lpVtbl->Release(This) ) 271 272 #ifdef WIN32 273 /* IDispatch functions. */ 274 #define IEventListenerDemo_GetTypeInfoCount(This,pctinfo) \ 275 ( (This)->lpVtbl->GetTypeInfoCount(This,pctinfo) ) 276 277 #define IEventListenerDemo_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ 278 ( (This)->lpVtbl->GetTypeInfo(This,iTInfo,lcid,ppTInfo) ) 279 280 #define IEventListenerDemo_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ 281 ( (This)->lpVtbl->GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) ) 282 283 #define IEventListenerDemo_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ 284 ( (This)->lpVtbl->Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) ) 285 #endif 286 287 /* IEventListener functions. */ 288 #define IEventListenerDemo_HandleEvent(This,aEvent) \ 289 ( (This)->lpVtbl->HandleEvent(This,aEvent) ) 290 291 292 /** 293 * Event handler function, for active event processing. 294 */ 295 static HRESULT IEventListenerDemoImpl_HandleEvent(IEventListenerDemo *pThis, IEvent *event) 296 { 297 return EventListenerDemoProcessEvent(event); 298 } 299 300 static HRESULT IEventListenerDemoImpl_QueryInterface(IEventListenerDemo *pThis, const IID *iid, void **resultp) 301 { 215 302 /* match iid */ 216 if ( memcmp(iid, &ieventListenerUUID, sizeof(nsID)) == 0 217 || memcmp(iid, &isupportIID, sizeof(nsID)) == 0) 218 { 219 pThis->vtbl->AddRef(pThis); 303 if ( !memcmp(iid, &IID_IEventListener, sizeof(IID)) 304 || !memcmp(iid, &IID_IDispatch, sizeof(IID)) 305 || !memcmp(iid, &IID_IUnknown, sizeof(IID))) 306 { 307 IEventListenerDemo_AddRef(pThis); 220 308 *resultp = pThis; 221 return NS_OK; 222 } 223 224 return NS_NOINTERFACE; 225 } 226 227 static nsresult IEventListenerDemo_AddRef(nsISupports *pThis) 228 { 229 return ++(((IEventListenerDemo *)pThis)->refcount); 230 } 231 232 static nsresult IEventListenerDemo_Release(nsISupports *pThis) 233 { 234 nsresult c; 235 236 c = --(((IEventListenerDemo *)pThis)->refcount); 237 if (c == 0) 309 return S_OK; 310 } 311 #ifdef WIN32 312 if (!memcmp(iid, &IID_IMarshal, sizeof(IID))) 313 return IUnknown_QueryInterface(pThis->pUnkMarshaler, iid, resultp); 314 #endif 315 316 return E_NOINTERFACE; 317 } 318 319 static HRESULT IEventListenerDemoImpl_AddRef(IEventListenerDemo *pThis) 320 { 321 return ++(pThis->cRef); 322 } 323 324 static HRESULT IEventListenerDemoImpl_Release(IEventListenerDemo *pThis) 325 { 326 HRESULT c; 327 328 c = --(pThis->cRef); 329 if (!c) 238 330 free(pThis); 239 331 return c; 240 332 } 241 333 242 struct IEventListenerDemo_vtbl_int_gcc 334 #ifdef WIN32 335 static HRESULT IEventListenerDemoImpl_GetTypeInfoCount(IEventListenerDemo *pThis, UINT *pctinfo) 336 { 337 if (!pctinfo) 338 return E_POINTER; 339 *pctinfo = 1; 340 return S_OK; 341 } 342 343 static HRESULT IEventListenerDemoImpl_GetTypeInfo(IEventListenerDemo *pThis, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) 344 { 345 if (!ppTInfo) 346 return E_POINTER; 347 ITypeInfo_AddRef(g_pTInfoIEventListener); 348 *ppTInfo = g_pTInfoIEventListener; 349 return S_OK; 350 } 351 352 static HRESULT IEventListenerDemoImpl_GetIDsOfNames(IEventListenerDemo *pThis, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) 353 { 354 return ITypeInfo_GetIDsOfNames(g_pTInfoIEventListener, rgszNames, cNames, rgDispId); 355 } 356 357 static HRESULT IEventListenerDemoImpl_Invoke(IEventListenerDemo *pThis, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 358 { 359 return ITypeInfo_Invoke(g_pTInfoIEventListener, (IDispatch *)pThis, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); 360 } 361 362 static HRESULT LoadTypeInfo(REFIID riid, ITypeInfo **pTInfo) 363 { 364 HRESULT rc; 365 ITypeLib *pTypeLib; 366 rc = LoadRegTypeLib(&LIBID_VirtualBox, 1 /* major */, 0 /* minor */, 0 /* lcid */, &pTypeLib); 367 if (FAILED(rc)) 368 return rc; 369 rc = ITypeLib_GetTypeInfoOfGuid(pTypeLib, riid, pTInfo); 370 371 /* No longer need access to the type lib, release it. */ 372 ITypeLib_Release(pTypeLib); 373 374 return rc; 375 } 376 #endif 377 378 #ifdef __GNUC__ 379 typedef struct IEventListenerDemoVtblInt 243 380 { 244 381 ptrdiff_t offset_to_top; 245 382 void *typeinfo; 246 struct IEventListenerDemo_vtbl vtbl;247 } ;248 249 static struct IEventListenerDemo_vtbl_int_gcc g_IEventListenerDemo_vtbl_int_gcc=383 IEventListenerDemoVtbl lpVtbl; 384 } IEventListenerDemoVtblInt; 385 386 static IEventListenerDemoVtblInt g_IEventListenerDemoVtblInt = 250 387 { 251 388 0, /* offset_to_top */ 252 389 NULL, /* typeinfo, not vital */ 253 390 { 254 { 255 { 256 IEventListenerDemo_QueryInterface, 257 IEventListenerDemo_AddRef, 258 IEventListenerDemo_Release 259 }, 260 IEventListenerDemo_HandleEvent 261 } 391 IEventListenerDemoImpl_QueryInterface, 392 IEventListenerDemoImpl_AddRef, 393 IEventListenerDemoImpl_Release, 394 #ifdef WIN32 395 IEventListenerDemoImpl_GetTypeInfoCount, 396 IEventListenerDemoImpl_GetTypeInfo, 397 IEventListenerDemoImpl_GetIDsOfNames, 398 IEventListenerDemoImpl_Invoke, 399 #endif 400 IEventListenerDemoImpl_HandleEvent 262 401 } 263 402 }; 403 #elif defined(_MSC_VER) 404 typedef struct IEventListenerDemoVtblInt 405 { 406 IEventListenerDemoVtbl lpVtbl; 407 } IEventListenerDemoVtblInt; 408 409 static IEventListenerDemoVtblInt g_IEventListenerDemoVtblInt = 410 { 411 { 412 IEventListenerDemoImpl_QueryInterface, 413 IEventListenerDemoImpl_AddRef, 414 IEventListenerDemoImpl_Release, 415 #ifdef WIN32 416 IEventListenerDemoImpl_GetTypeInfoCount, 417 IEventListenerDemoImpl_GetTypeInfo, 418 IEventListenerDemoImpl_GetIDsOfNames, 419 IEventListenerDemoImpl_Invoke, 420 #endif 421 IEventListenerDemoImpl_HandleEvent 422 } 423 }; 424 #else 425 # error Port me! 426 #endif 264 427 265 428 /** 266 * Signal handler, terminate event listener. 267 * 268 * @param iSig The signal number (ignored). 269 */ 270 static void sigIntHandler(int iSig) 271 { 272 (void)iSig; 273 g_fStop = 1; 274 } 275 276 /** 277 * Register event listener for the selected VM. 429 * Register active event listener for the selected VM. 278 430 * 279 431 * @param virtualBox ptr to IVirtualBox object 280 432 * @param session ptr to ISession object 281 433 * @param id identifies the machine to start 282 * @param queue handle to the event queue283 434 */ 284 static void register EventListener(IVirtualBox *virtualBox, ISession *session, PRUnichar *machineId, nsIEventQueue *queue)435 static void registerActiveEventListener(IVirtualBox *virtualBox, ISession *session, BSTR machineId) 285 436 { 286 437 IConsole *console = NULL; 287 nsresultrc;288 289 rc = session->vtbl->GetConsole(session, &console);290 if (( NS_SUCCEEDED(rc)) && console)438 HRESULT rc; 439 440 rc = ISession_get_Console(session, &console); 441 if ((SUCCEEDED(rc)) && console) 291 442 { 292 443 IEventSource *es = NULL; 293 rc = console->vtbl->GetEventSource(console, &es);294 if ( NS_SUCCEEDED(rc) && es)295 { 296 PRUint32interestingEvents[] =444 rc = IConsole_get_EventSource(console, &es); 445 if (SUCCEEDED(rc) && es) 446 { 447 static const ULONG interestingEvents[] = 297 448 { 298 449 VBoxEventType_OnMousePointerShapeChanged, … … 314 465 VBoxEventType_OnShowWindow 315 466 }; 467 SAFEARRAY *interestingEventsSA = NULL; 316 468 IEventListenerDemo *consoleListener = NULL; 469 470 /* The VirtualBox API expects enum values as VT_I4, which in the 471 * future can be hopefully relaxed. */ 472 interestingEventsSA = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_I4, 0, sizeof(interestingEvents) / sizeof(interestingEvents[0])); 473 g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(interestingEventsSA, &interestingEvents, sizeof(interestingEvents)); 474 317 475 consoleListener = calloc(1, sizeof(IEventListenerDemo)); 318 476 if (consoleListener) 319 477 { 320 consoleListener->vtbl = &(g_IEventListenerDemo_vtbl_int_gcc.vtbl); 321 consoleListener->vtbl->ieventlistener.nsisupports.AddRef((nsISupports *)consoleListener); 322 323 rc = es->vtbl->RegisterListener(es, (IEventListener *)consoleListener, 324 sizeof(interestingEvents) / sizeof(interestingEvents[0]), 325 interestingEvents, 1 /* active */); 326 if (NS_SUCCEEDED(rc)) 478 consoleListener->lpVtbl = &(g_IEventListenerDemoVtblInt.lpVtbl); 479 #ifdef WIN32 480 CoCreateFreeThreadedMarshaler((IUnknown *)consoleListener, &consoleListener->pUnkMarshaler); 481 #endif 482 IEventListenerDemo_AddRef(consoleListener); 483 484 rc = IEventSource_RegisterListener(es, (IEventListener *)consoleListener, 485 ComSafeArrayAsInParam(interestingEventsSA), 486 1 /* active */); 487 if (SUCCEEDED(rc)) 327 488 { 328 489 /* Just wait here for events, no easy way to do this better 329 490 * as there's not much to do after this completes. */ 330 PRInt32 fd;331 int ret;332 491 printf("Entering event loop, PowerOff the machine to exit or press Ctrl-C to terminate\n"); 333 492 fflush(stdout); 334 signal(SIGINT, sigIntHandler); 335 336 fd = queue->vtbl->GetEventQueueSelectFD(queue); 337 if (fd >= 0) 493 #ifdef WIN32 494 SetConsoleCtrlHandler(ctrlCHandler, TRUE); 495 #else 496 signal(SIGINT, (void (*)(int))ctrlCHandler); 497 #endif 498 499 while (!g_fStop) 338 500 { 339 while (!g_fStop) 340 { 341 struct pollfd pfd; 342 343 pfd.fd = fd; 344 pfd.events = POLLIN | POLLERR | POLLHUP; 345 pfd.revents = 0; 346 347 ret = poll(&pfd, 1, 250); 348 349 if (ret <= 0) 350 continue; 351 352 if (pfd.revents & POLLHUP) 353 g_fStop = 1; 354 355 queue->vtbl->ProcessPendingEvents(queue); 356 } 501 g_pVBoxFuncs->pfnProcessEventQueue(250); 357 502 } 358 else 359 { 360 while (!g_fStop) 361 { 362 PLEvent *pEvent = NULL; 363 rc = queue->vtbl->WaitForEvent(queue, &pEvent); 364 if (NS_SUCCEEDED(rc)) 365 queue->vtbl->HandleEvent(queue, pEvent); 366 } 367 } 503 504 #ifdef WIN32 505 SetConsoleCtrlHandler(ctrlCHandler, FALSE); 506 #else 368 507 signal(SIGINT, SIG_DFL); 508 #endif 369 509 } 370 es->vtbl->UnregisterListener(es, (IEventListener *)consoleListener); 371 consoleListener->vtbl->ieventlistener.nsisupports.Release((nsISupports *)consoleListener); 510 else 511 { 512 printf("Failed to register event listener.\n"); 513 } 514 IEventSource_UnregisterListener(es, (IEventListener *)consoleListener); 515 #ifdef WIN32 516 if (consoleListener->pUnkMarshaler) 517 IUnknown_Release(consoleListener->pUnkMarshaler); 518 #endif 519 IEventListenerDemo_Release(consoleListener); 372 520 } 373 521 else … … 375 523 printf("Failed while allocating memory for console event listener.\n"); 376 524 } 377 es->vtbl->nsisupports.Release((nsISupports *)es); 378 } 379 console->vtbl->nsisupports.Release((nsISupports *)console); 380 } 381 } 525 g_pVBoxFuncs->pfnSafeArrayDestroy(interestingEventsSA); 526 IEventSource_Release(es); 527 } 528 else 529 { 530 printf("Failed to get the event source instance.\n"); 531 } 532 IConsole_Release(console); 533 } 534 } 535 536 #else /* !USE_ACTIVE_EVENT_LISTENER */ 537 538 /** 539 * Register passive event listener for the selected VM. 540 * 541 * @param virtualBox ptr to IVirtualBox object 542 * @param session ptr to ISession object 543 * @param id identifies the machine to start 544 */ 545 static void registerPassiveEventListener(IVirtualBox *virtualBox, ISession *session, BSTR machineId) 546 { 547 IConsole *console = NULL; 548 HRESULT rc; 549 550 rc = ISession_get_Console(session, &console); 551 if ((SUCCEEDED(rc)) && console) 552 { 553 IEventSource *es = NULL; 554 rc = IConsole_get_EventSource(console, &es); 555 if (SUCCEEDED(rc) && es) 556 { 557 static const ULONG interestingEvents[] = 558 { 559 VBoxEventType_OnMousePointerShapeChanged, 560 VBoxEventType_OnMouseCapabilityChanged, 561 VBoxEventType_OnKeyboardLedsChanged, 562 VBoxEventType_OnStateChanged, 563 VBoxEventType_OnAdditionsStateChanged, 564 VBoxEventType_OnNetworkAdapterChanged, 565 VBoxEventType_OnSerialPortChanged, 566 VBoxEventType_OnParallelPortChanged, 567 VBoxEventType_OnStorageControllerChanged, 568 VBoxEventType_OnMediumChanged, 569 VBoxEventType_OnVRDEServerChanged, 570 VBoxEventType_OnUSBControllerChanged, 571 VBoxEventType_OnUSBDeviceStateChanged, 572 VBoxEventType_OnSharedFolderChanged, 573 VBoxEventType_OnRuntimeError, 574 VBoxEventType_OnCanShowWindow, 575 VBoxEventType_OnShowWindow 576 }; 577 SAFEARRAY *interestingEventsSA = NULL; 578 IEventListener *consoleListener = NULL; 579 580 /* The VirtualBox API expects enum values as VT_I4, which in the 581 * future can be hopefully relaxed. */ 582 interestingEventsSA = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_I4, 0, sizeof(interestingEvents) / sizeof(interestingEvents[0])); 583 g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(interestingEventsSA, &interestingEvents, sizeof(interestingEvents)); 584 585 rc = IEventSource_CreateListener(es, &consoleListener); 586 if (SUCCEEDED(rc) && consoleListener) 587 { 588 rc = IEventSource_RegisterListener(es, consoleListener, 589 ComSafeArrayAsInParam(interestingEventsSA), 590 0 /* passive */); 591 if (SUCCEEDED(rc)) 592 { 593 /* Just wait here for events, no easy way to do this better 594 * as there's not much to do after this completes. */ 595 printf("Entering event loop, PowerOff the machine to exit or press Ctrl-C to terminate\n"); 596 fflush(stdout); 597 #ifdef WIN32 598 SetConsoleCtrlHandler(ctrlCHandler, TRUE); 599 #else 600 signal(SIGINT, (void (*)(int))ctrlCHandler); 601 #endif 602 603 while (!g_fStop) 604 { 605 IEvent *ev = NULL; 606 rc = IEventSource_GetEvent(es, consoleListener, 250, &ev); 607 if (FAILED(rc)) 608 { 609 printf("Failed getting event: %#x\n", rc); 610 g_fStop = 1; 611 continue; 612 } 613 /* handle timeouts, resulting in NULL events */ 614 if (!ev) 615 continue; 616 rc = EventListenerDemoProcessEvent(ev); 617 if (FAILED(rc)) 618 { 619 printf("Failed processing event: %#x\n", rc); 620 g_fStop = 1; 621 /* finish processing the event */ 622 } 623 rc = IEventSource_EventProcessed(es, consoleListener, ev); 624 if (FAILED(rc)) 625 { 626 printf("Failed to mark event as processed: %#x\n", rc); 627 g_fStop = 1; 628 /* continue with event release */ 629 } 630 if (ev) 631 { 632 IEvent_Release(ev); 633 ev = NULL; 634 } 635 } 636 637 #ifdef WIN32 638 SetConsoleCtrlHandler(ctrlCHandler, FALSE); 639 #else 640 signal(SIGINT, SIG_DFL); 641 #endif 642 } 643 else 644 { 645 printf("Failed to register event listener.\n"); 646 } 647 IEventSource_UnregisterListener(es, (IEventListener *)consoleListener); 648 IEventListener_Release(consoleListener); 649 } 650 else 651 { 652 printf("Failed to create an event listener instance.\n"); 653 } 654 g_pVBoxFuncs->pfnSafeArrayDestroy(interestingEventsSA); 655 IEventSource_Release(es); 656 } 657 else 658 { 659 printf("Failed to get the event source instance.\n"); 660 } 661 IConsole_Release(console); 662 } 663 } 664 665 #endif /* !USE_ACTIVE_EVENT_LISTENER */ 382 666 383 667 /** … … 385 669 * @param pszExecutable string with the executable name 386 670 * @param pszErrorMsg string containing the code location specific error message 387 * @param rc XPCOM result code671 * @param rc COM/XPCOM result code 388 672 */ 389 static void PrintErrorInfo(const char *pszExecutable, const char *pszErrorMsg, nsresultrc)390 { 391 nsIException*ex;392 nsresult rc2 = NS_OK;673 static void PrintErrorInfo(const char *pszExecutable, const char *pszErrorMsg, HRESULT rc) 674 { 675 IErrorInfo *ex; 676 HRESULT rc2 = S_OK; 393 677 fprintf(stderr, "%s: %s (rc=%#010x)\n", pszExecutable, pszErrorMsg, (unsigned)rc); 394 678 rc2 = g_pVBoxFuncs->pfnGetException(&ex); 395 if (NS_SUCCEEDED(rc2)) 396 { 397 static const nsID vbei = IVIRTUALBOXERRORINFO_IID; 679 if (SUCCEEDED(rc2)) 680 { 398 681 IVirtualBoxErrorInfo *ei; 399 rc2 = ex->vtbl->nsisupports.QueryInterface((nsISupports *)ex, &vbei, (void **)&ei);400 if ( NS_FAILED(rc2))682 rc2 = IErrorInfo_QueryInterface(ex, &IID_IVirtualBoxErrorInfo, (void **)&ei); 683 if (FAILED(rc2)) 401 684 ei = NULL; 402 685 if (ei) … … 405 688 do 406 689 { 407 PRInt32 resultCode = NS_OK;408 PRUnichar *componentUtf16 = NULL;690 LONG resultCode = S_OK; 691 BSTR componentUtf16 = NULL; 409 692 char *component = NULL; 410 PRUnichar *textUtf16 = NULL;693 BSTR textUtf16 = NULL; 411 694 char *text = NULL; 412 695 IVirtualBoxErrorInfo *ei_next = NULL; 413 696 fprintf(stderr, "Extended error info (IVirtualBoxErrorInfo):\n"); 414 697 415 ei->vtbl->GetResultCode(ei, &resultCode);698 IVirtualBoxErrorInfo_get_ResultCode(ei, &resultCode); 416 699 fprintf(stderr, " resultCode=%#010x\n", (unsigned)resultCode); 417 700 418 ei->vtbl->GetComponent(ei, &componentUtf16);701 IVirtualBoxErrorInfo_get_Component(ei, &componentUtf16); 419 702 g_pVBoxFuncs->pfnUtf16ToUtf8(componentUtf16, &component); 420 g_pVBoxFuncs->pfnComUnalloc Mem(componentUtf16);703 g_pVBoxFuncs->pfnComUnallocString(componentUtf16); 421 704 fprintf(stderr, " component=%s\n", component); 422 705 g_pVBoxFuncs->pfnUtf8Free(component); 423 706 424 ei->vtbl->GetText(ei, &textUtf16);707 IVirtualBoxErrorInfo_get_Text(ei, &textUtf16); 425 708 g_pVBoxFuncs->pfnUtf16ToUtf8(textUtf16, &text); 426 g_pVBoxFuncs->pfnComUnalloc Mem(textUtf16);709 g_pVBoxFuncs->pfnComUnallocString(textUtf16); 427 710 fprintf(stderr, " text=%s\n", text); 428 711 g_pVBoxFuncs->pfnUtf8Free(text); 429 712 430 rc2 = ei->vtbl->GetNext(ei, &ei_next);431 if ( NS_FAILED(rc2))713 rc2 = IVirtualBoxErrorInfo_get_Next(ei, &ei_next); 714 if (FAILED(rc2)) 432 715 ei_next = NULL; 433 ei->vtbl->nsiexception.nsisupports.Release((nsISupports *)ei);716 IVirtualBoxErrorInfo_Release(ei); 434 717 ei = ei_next; 435 718 } 436 719 while (ei); 437 720 } 438 else 439 { 440 /* got basic error info */ 441 nsresult resultCode = NS_OK; 442 PRUnichar *messageUtf16 = NULL; 443 char *message = NULL; 444 fprintf(stderr, "Basic error info (nsIException):\n"); 445 446 ex->vtbl->GetResult(ex, &resultCode); 447 fprintf(stderr, " resultCode=%#010x\n", resultCode); 448 449 ex->vtbl->GetMessage(ex, &messageUtf16); 450 g_pVBoxFuncs->pfnUtf16ToUtf8(messageUtf16, &message); 451 g_pVBoxFuncs->pfnComUnallocMem(messageUtf16); 452 fprintf(stderr, " message=%s\n", message); 453 g_pVBoxFuncs->pfnUtf8Free(message); 454 } 455 456 ex->vtbl->nsisupports.Release((nsISupports *)ex); 721 722 IErrorInfo_Release(ex); 457 723 g_pVBoxFuncs->pfnClearException(); 458 724 } … … 466 732 * @param session ptr to ISession object 467 733 * @param id identifies the machine to start 468 * @param queue ptr to event queue469 734 */ 470 static void startVM(const char *argv0, IVirtualBox *virtualBox, ISession *session, PRUnichar *id, nsIEventQueue *queue)471 { 472 nsresultrc;735 static void startVM(const char *argv0, IVirtualBox *virtualBox, ISession *session, BSTR id) 736 { 737 HRESULT rc; 473 738 IMachine *machine = NULL; 474 739 IProgress *progress = NULL; 475 PRUnichar *env= NULL;476 PRUnichar *sessionType;477 478 rc = virtualBox->vtbl->FindMachine(virtualBox, id, &machine);479 if ( NS_FAILED(rc) || !machine)740 BSTR env = NULL; 741 BSTR sessionType; 742 743 rc = IVirtualBox_FindMachine(virtualBox, id, &machine); 744 if (FAILED(rc) || !machine) 480 745 { 481 746 PrintErrorInfo(argv0, "Error: Couldn't get the Machine reference", rc); … … 484 749 485 750 g_pVBoxFuncs->pfnUtf8ToUtf16("gui", &sessionType); 486 rc = machine->vtbl->LaunchVMProcess(machine, 487 session, 488 sessionType, 489 env, 490 &progress 491 ); 751 rc = IMachine_LaunchVMProcess(machine, session, sessionType, env, &progress); 492 752 g_pVBoxFuncs->pfnUtf16Free(sessionType); 493 if ( NS_SUCCEEDED(rc))494 { 495 PRBoolcompleted;496 PRInt32resultCode;753 if (SUCCEEDED(rc)) 754 { 755 BOOL completed; 756 LONG resultCode; 497 757 498 758 printf("Waiting for the remote session to open...\n"); 499 progress->vtbl->WaitForCompletion(progress, -1);500 501 rc = progress->vtbl->GetCompleted(progress, &completed);502 if ( NS_FAILED(rc))759 IProgress_WaitForCompletion(progress, -1); 760 761 rc = IProgress_get_Completed(progress, &completed); 762 if (FAILED(rc)) 503 763 fprintf(stderr, "Error: GetCompleted status failed\n"); 504 764 505 progress->vtbl->GetResultCode(progress, &resultCode);506 if ( NS_FAILED(resultCode))765 IProgress_get_ResultCode(progress, &resultCode); 766 if (FAILED(resultCode)) 507 767 { 508 768 IVirtualBoxErrorInfo *errorInfo; 509 PRUnichar *textUtf16;769 BSTR textUtf16; 510 770 char *text; 511 771 512 progress->vtbl->GetErrorInfo(progress, &errorInfo);513 errorInfo->vtbl->GetText(errorInfo, &textUtf16);772 IProgress_get_ErrorInfo(progress, &errorInfo); 773 IVirtualBoxErrorInfo_get_Text(errorInfo, &textUtf16); 514 774 g_pVBoxFuncs->pfnUtf16ToUtf8(textUtf16, &text); 515 775 printf("Error: %s\n", text); 516 776 517 g_pVBoxFuncs->pfnComUnalloc Mem(textUtf16);777 g_pVBoxFuncs->pfnComUnallocString(textUtf16); 518 778 g_pVBoxFuncs->pfnUtf8Free(text); 779 IVirtualBoxErrorInfo_Release(errorInfo); 519 780 } 520 781 else … … 524 785 /* Kick off the event listener demo part, which is quite separate. 525 786 * Ignore it if you need a more basic sample. */ 526 registerEventListener(virtualBox, session, id, queue); 527 } 528 progress->vtbl->nsisupports.Release((nsISupports *)progress); 787 #ifdef USE_ACTIVE_EVENT_LISTENER 788 registerActiveEventListener(virtualBox, session, id); 789 #else /* !USE_ACTIVE_EVENT_LISTENER */ 790 registerPassiveEventListener(virtualBox, session, id); 791 #endif /* !USE_ACTIVE_EVENT_LISTENER */ 792 } 793 IProgress_Release(progress); 529 794 } 530 795 else … … 532 797 533 798 /* It's important to always release resources. */ 534 machine->vtbl->nsisupports.Release((nsISupports *)machine);799 IMachine_Release(machine); 535 800 } 536 801 … … 541 806 * @param virtualBox ptr to IVirtualBox object 542 807 * @param session ptr to ISession object 543 * @param queue ptr to event queue544 808 */ 545 static void listVMs(const char *argv0, IVirtualBox *virtualBox, ISession *session, nsIEventQueue *queue) 546 { 547 nsresult rc; 809 static void listVMs(const char *argv0, IVirtualBox *virtualBox, ISession *session) 810 { 811 HRESULT rc; 812 SAFEARRAY *machinesSA = g_pVBoxFuncs->pfnSafeArrayOutParamAlloc(); 548 813 IMachine **machines = NULL; 549 PRUint32machineCnt = 0;550 PRUint32i;814 ULONG machineCnt = 0; 815 ULONG i; 551 816 unsigned start_id; 552 817 … … 554 819 * Get the list of all registered VMs. 555 820 */ 556 557 rc = virtualBox->vtbl->GetMachines(virtualBox, &machineCnt, &machines); 558 if (NS_FAILED(rc)) 821 rc = IVirtualBox_get_Machines(virtualBox, ComSafeArrayAsOutIfaceParam(machinesSA, IMachine *)); 822 if (FAILED(rc)) 559 823 { 560 824 PrintErrorInfo(argv0, "could not get list of machines", rc); … … 562 826 } 563 827 564 if (machineCnt == 0) 828 /* 829 * Extract interface pointers from machinesSA, and update the reference 830 * counter of each object, as destroying machinesSA would call Release. 831 */ 832 g_pVBoxFuncs->pfnSafeArrayCopyOutIfaceParamHelper((IUnknown ***)&machines, &machineCnt, machinesSA); 833 g_pVBoxFuncs->pfnSafeArrayDestroy(machinesSA); 834 835 if (!machineCnt) 565 836 { 566 837 printf("\tNo VMs\n"); … … 577 848 { 578 849 IMachine *machine = machines[i]; 579 PRBool isAccessible = PR_FALSE;850 BOOL isAccessible = FALSE; 580 851 581 852 printf("\tMachine #%u\n", (unsigned)i); … … 587 858 } 588 859 589 machine->vtbl->GetAccessible(machine, &isAccessible);860 IMachine_get_Accessible(machine, &isAccessible); 590 861 591 862 if (isAccessible) 592 863 { 593 PRUnichar *machineNameUtf16;864 BSTR machineNameUtf16; 594 865 char *machineName; 595 866 596 machine->vtbl->GetName(machine, &machineNameUtf16);867 IMachine_get_Name(machine, &machineNameUtf16); 597 868 g_pVBoxFuncs->pfnUtf16ToUtf8(machineNameUtf16,&machineName); 598 g_pVBoxFuncs->pfnComUnalloc Mem(machineNameUtf16);869 g_pVBoxFuncs->pfnComUnallocString(machineNameUtf16); 599 870 printf("\tName: %s\n", machineName); 600 871 g_pVBoxFuncs->pfnUtf8Free(machineName); … … 606 877 607 878 { 608 PRUnichar *uuidUtf16;879 BSTR uuidUtf16; 609 880 char *uuidUtf8; 610 881 611 machine->vtbl->GetId(machine, &uuidUtf16);882 IMachine_get_Id(machine, &uuidUtf16); 612 883 g_pVBoxFuncs->pfnUtf16ToUtf8(uuidUtf16, &uuidUtf8); 613 g_pVBoxFuncs->pfnComUnalloc Mem(uuidUtf16);884 g_pVBoxFuncs->pfnComUnallocString(uuidUtf16); 614 885 printf("\tUUID: %s\n", uuidUtf8); 615 886 g_pVBoxFuncs->pfnUtf8Free(uuidUtf8); … … 619 890 { 620 891 { 621 PRUnichar *configFileUtf16;892 BSTR configFileUtf16; 622 893 char *configFileUtf8; 623 894 624 machine->vtbl->GetSettingsFilePath(machine, &configFileUtf16);895 IMachine_get_SettingsFilePath(machine, &configFileUtf16); 625 896 g_pVBoxFuncs->pfnUtf16ToUtf8(configFileUtf16, &configFileUtf8); 626 g_pVBoxFuncs->pfnComUnalloc Mem(configFileUtf16);897 g_pVBoxFuncs->pfnComUnallocString(configFileUtf16); 627 898 printf("\tConfig file: %s\n", configFileUtf8); 628 899 g_pVBoxFuncs->pfnUtf8Free(configFileUtf8); … … 630 901 631 902 { 632 PRUint32memorySize;633 634 machine->vtbl->GetMemorySize(machine, &memorySize);903 ULONG memorySize; 904 905 IMachine_get_MemorySize(machine, &memorySize); 635 906 printf("\tMemory size: %uMB\n", memorySize); 636 907 } 637 908 638 909 { 639 PRUnichar *typeId;640 PRUnichar *osNameUtf16;910 BSTR typeId; 911 BSTR osNameUtf16; 641 912 char *osName; 642 913 IGuestOSType *osType = NULL; 643 914 644 machine->vtbl->GetOSTypeId(machine, &typeId);645 virtualBox->vtbl->GetGuestOSType(virtualBox, typeId, &osType);646 g_pVBoxFuncs->pfnComUnalloc Mem(typeId);647 osType->vtbl->GetDescription(osType, &osNameUtf16);915 IMachine_get_OSTypeId(machine, &typeId); 916 IVirtualBox_GetGuestOSType(virtualBox, typeId, &osType); 917 g_pVBoxFuncs->pfnComUnallocString(typeId); 918 IGuestOSType_get_Description(osType, &osNameUtf16); 648 919 g_pVBoxFuncs->pfnUtf16ToUtf8(osNameUtf16,&osName); 649 g_pVBoxFuncs->pfnComUnalloc Mem(osNameUtf16);920 g_pVBoxFuncs->pfnComUnallocString(osNameUtf16); 650 921 printf("\tGuest OS: %s\n\n", osName); 651 922 g_pVBoxFuncs->pfnUtf8Free(osName); 652 923 653 osType->vtbl->nsisupports.Release((nsISupports *)osType);924 IGuestOSType_Release(osType); 654 925 } 655 926 } … … 670 941 if (machine) 671 942 { 672 PRUnichar *uuidUtf16 = NULL;673 674 machine->vtbl->GetId(machine, &uuidUtf16);675 startVM(argv0, virtualBox, session, uuidUtf16 , queue);676 g_pVBoxFuncs->pfnComUnalloc Mem(uuidUtf16);943 BSTR uuidUtf16 = NULL; 944 945 IMachine_get_Id(machine, &uuidUtf16); 946 startVM(argv0, virtualBox, session, uuidUtf16); 947 g_pVBoxFuncs->pfnComUnallocString(uuidUtf16); 677 948 } 678 949 } … … 688 959 if (machine) 689 960 { 690 machine->vtbl->nsisupports.Release((nsISupports *)machine);961 IMachine_Release(machine); 691 962 } 692 963 } 693 964 if (machines) 694 g_pVBoxFuncs->pfnComUnallocMem(machines);965 free(machines); 695 966 } 696 967 … … 702 973 IVirtualBox *vbox = NULL; 703 974 ISession *session = NULL; 704 nsIEventQueue *queue = NULL; 705 PRUint32 revision = 0; 706 PRUnichar *versionUtf16 = NULL; 707 PRUnichar *homefolderUtf16 = NULL; 708 nsresult rc; /* Result code of various function (method) calls. */ 975 ULONG revision = 0; 976 BSTR versionUtf16 = NULL; 977 BSTR homefolderUtf16 = NULL; 978 HRESULT rc; /* Result code of various function (method) calls. */ 709 979 710 980 printf("Starting main()\n"); … … 724 994 } 725 995 726 g_pVBoxFuncs->pfnClientInitialize( IVIRTUALBOXCLIENT_IID_STR, &vboxclient);727 if ( vboxclient == NULL)996 g_pVBoxFuncs->pfnClientInitialize(NULL, &vboxclient); 997 if (!vboxclient) 728 998 { 729 999 fprintf(stderr, "%s: FATAL: could not get VirtualBoxClient reference\n", argv[0]); … … 733 1003 printf("----------------------------------------------------\n"); 734 1004 735 rc = vboxclient->vtbl->GetVirtualBox(vboxclient, &vbox);736 if ( NS_FAILED(rc) || !vbox)1005 rc = IVirtualBoxClient_get_VirtualBox(vboxclient, &vbox); 1006 if (FAILED(rc) || !vbox) 737 1007 { 738 1008 PrintErrorInfo(argv[0], "FATAL: could not get VirtualBox reference", rc); 739 1009 return EXIT_FAILURE; 740 1010 } 741 rc = vboxclient->vtbl->GetSession(vboxclient, &session);742 if ( NS_FAILED(rc) || !session)1011 rc = IVirtualBoxClient_get_Session(vboxclient, &session); 1012 if (FAILED(rc) || !session) 743 1013 { 744 1014 PrintErrorInfo(argv[0], "FATAL: could not get Session reference", rc); … … 746 1016 } 747 1017 748 g_pVBoxFuncs->pfnGetEventQueue(&queue); 1018 #ifdef USE_ACTIVE_EVENT_LISTENER 1019 # ifdef WIN32 1020 rc = LoadTypeInfo(&IID_IEventListener, &g_pTInfoIEventListener); 1021 if (FAILED(rc) || !g_pTInfoIEventListener) 1022 { 1023 PrintErrorInfo(argv[0], "FATAL: could not get type information for IEventListener", rc); 1024 return EXIT_FAILURE; 1025 } 1026 # endif /* WIN32 */ 1027 #endif /* USE_ACTIVE_EVENT_LISTENER */ 749 1028 750 1029 /* … … 756 1035 /* 1. Revision */ 757 1036 758 rc = vbox->vtbl->GetRevision(vbox, &revision);759 if ( NS_SUCCEEDED(rc))1037 rc = IVirtualBox_get_Revision(vbox, &revision); 1038 if (SUCCEEDED(rc)) 760 1039 printf("\tRevision: %u\n", revision); 761 1040 else … … 764 1043 /* 2. Version */ 765 1044 766 rc = vbox->vtbl->GetVersion(vbox, &versionUtf16);767 if ( NS_SUCCEEDED(rc))1045 rc = IVirtualBox_get_Version(vbox, &versionUtf16); 1046 if (SUCCEEDED(rc)) 768 1047 { 769 1048 char *version = NULL; … … 771 1050 printf("\tVersion: %s\n", version); 772 1051 g_pVBoxFuncs->pfnUtf8Free(version); 773 g_pVBoxFuncs->pfnComUnalloc Mem(versionUtf16);1052 g_pVBoxFuncs->pfnComUnallocString(versionUtf16); 774 1053 } 775 1054 else … … 778 1057 /* 3. Home Folder */ 779 1058 780 rc = vbox->vtbl->GetHomeFolder(vbox, &homefolderUtf16);781 if ( NS_SUCCEEDED(rc))1059 rc = IVirtualBox_get_HomeFolder(vbox, &homefolderUtf16); 1060 if (SUCCEEDED(rc)) 782 1061 { 783 1062 char *homefolder = NULL; … … 785 1064 printf("\tHomeFolder: %s\n", homefolder); 786 1065 g_pVBoxFuncs->pfnUtf8Free(homefolder); 787 g_pVBoxFuncs->pfnComUnalloc Mem(homefolderUtf16);1066 g_pVBoxFuncs->pfnComUnallocString(homefolderUtf16); 788 1067 } 789 1068 else 790 1069 PrintErrorInfo(argv[0], "GetHomeFolder() failed", rc); 791 1070 792 listVMs(argv[0], vbox, session , queue);793 session->vtbl->UnlockMachine(session);1071 listVMs(argv[0], vbox, session); 1072 ISession_UnlockMachine(session); 794 1073 795 1074 printf("----------------------------------------------------\n"); … … 799 1078 */ 800 1079 1080 #ifdef USE_ACTIVE_EVENT_LISTENER 1081 # ifdef WIN32 1082 if (g_pTInfoIEventListener) 1083 { 1084 ITypeInfo_Release(g_pTInfoIEventListener); 1085 g_pTInfoIEventListener = NULL; 1086 } 1087 # endif /* WIN32 */ 1088 #endif /* USE_ACTIVE_EVENT_LISTENER */ 1089 801 1090 if (session) 802 1091 { 803 session->vtbl->nsisupports.Release((nsISupports *)session);1092 ISession_Release(session); 804 1093 session = NULL; 805 1094 } 806 1095 if (vbox) 807 1096 { 808 vbox->vtbl->nsisupports.Release((nsISupports *)vbox);1097 IVirtualBox_Release(vbox); 809 1098 vbox = NULL; 810 1099 } 811 1100 if (vboxclient) 812 1101 { 813 vboxclient->vtbl->nsisupports.Release((nsISupports *)vboxclient);1102 IVirtualBoxClient_Release(vboxclient); 814 1103 vboxclient = NULL; 815 1104 } 1105 816 1106 g_pVBoxFuncs->pfnClientUninitialize(); 817 1107 VBoxCGlueTerm(); -
trunk/src/VBox/Main/glue/glue-java.xsl
r48005 r50183 11 11 VirtualBox.xidl. 12 12 13 Copyright (C) 2010-201 3Oracle Corporation13 Copyright (C) 2010-2014 Oracle Corporation 14 14 15 15 This file is part of VirtualBox Open Source Edition (OSE), as … … 47 47 <xsl:param name="name" /> 48 48 <xsl:text>/* 49 * Copyright (C) 2010-201 3Oracle Corporation49 * Copyright (C) 2010-2014 Oracle Corporation 50 50 * 51 51 * This file is part of the VirtualBox SDK, as available from … … 2487 2487 <xsl:variable name="extends" select="//interface[@name=$ifname]/@extends" /> 2488 2488 <xsl:choose> 2489 <xsl:when test="($extends = '$unknown') or ($extends = '$ dispatched') or ($extends = '$errorinfo')">2489 <xsl:when test="($extends = '$unknown') or ($extends = '$errorinfo')"> 2490 2490 <xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown ')" /> 2491 2491 <xsl:text>{ </xsl:text> -
trunk/src/VBox/Main/idl/apiwrap-server.xsl
r49994 r50183 6 6 VirtualBox.xidl. 7 7 8 Copyright (C) 2010-201 3Oracle Corporation8 Copyright (C) 2010-2014 Oracle Corporation 9 9 10 10 This file is part of VirtualBox Open Source Edition (OSE), as … … 78 78 79 79 /** 80 * Copyright (C) 201 1-2013Oracle Corporation80 * Copyright (C) 2010-2014 Oracle Corporation 81 81 * 82 82 * This file is part of VirtualBox Open Source Edition (OSE), as … … 98 98 <!-- now recurse to emit all base interfaces --> 99 99 <xsl:variable name="extends" select="$iface/@extends"/> 100 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$ dispatched') and not($extends='$errorinfo')">100 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')"> 101 101 <xsl:call-template name="emitCOMInterfaces"> 102 102 <xsl:with-param name="iface" select="//interface[@name=$extends]"/> … … 165 165 166 166 <xsl:choose> 167 <xsl:when test="$extends and not($extends='$unknown') and not($extends='$ dispatched') and not($extends='$errorinfo')">167 <xsl:when test="$extends and not($extends='$unknown') and not($extends='$errorinfo')"> 168 168 <xsl:variable name="newextends" select="//interface[@name=$extends]/@extends"/> 169 169 <xsl:variable name="newiflist" select="concat($interfacelist, ', ', $extends)"/> … … 876 876 <!-- first recurse to emit all base interfaces --> 877 877 <xsl:variable name="extends" select="$iface/@extends"/> 878 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$ dispatched') and not($extends='$errorinfo')">878 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')"> 879 879 <xsl:call-template name="emitAttributes"> 880 880 <xsl:with-param name="iface" select="//interface[@name=$extends]"/> … … 1131 1131 <!-- first recurse to emit all base interfaces --> 1132 1132 <xsl:variable name="extends" select="$iface/@extends"/> 1133 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$ dispatched') and not($extends='$errorinfo')">1133 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')"> 1134 1134 <xsl:call-template name="emitMethods"> 1135 1135 <xsl:with-param name="iface" select="//interface[@name=$extends]"/> -
trunk/src/VBox/Main/idl/midl.xsl
r49908 r50183 6 6 * from the generic interface definition expressed in XML. 7 7 8 Copyright (C) 2006-201 2Oracle Corporation8 Copyright (C) 2006-2014 Oracle Corporation 9 9 10 10 This file is part of VirtualBox Open Source Edition (OSE), as … … 243 243 <xsl:choose> 244 244 <xsl:when test="@extends='$unknown'">IDispatch</xsl:when> 245 <xsl:when test="@extends='$dispatched'">IDispatch</xsl:when>246 245 <xsl:when test="@extends='$errorinfo'">IErrorInfo</xsl:when> 247 246 <xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise> -
trunk/src/VBox/Main/idl/xpidl.xsl
r50121 r50183 244 244 <xsl:choose> 245 245 <xsl:when test="@extends='$unknown'">nsISupports</xsl:when> 246 <xsl:when test="@extends='$dispatched'">nsISupports</xsl:when>247 246 <xsl:when test="@extends='$errorinfo'">nsIException</xsl:when> 248 247 <xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise> -
trunk/src/VBox/Main/webservice/websrv-php.xsl
r45483 r50183 12 12 Contributed by James Lucas (mjlucas at eng.uts.edu.au). 13 13 14 Copyright (C) 2008-201 3Oracle Corporation14 Copyright (C) 2008-2014 Oracle Corporation 15 15 16 16 This file is part of VirtualBox Open Source Edition (OSE), as … … 169 169 </xsl:text> 170 170 <xsl:choose> 171 <xsl:when test="($extends = '$unknown') or ($extends = '$ dispatched') or ($extends = '$errorinfo')">171 <xsl:when test="($extends = '$unknown') or ($extends = '$errorinfo')"> 172 172 <xsl:value-of select="concat('class ', $ifname, ' extends VBox_ManagedObject { ')" /> 173 173 </xsl:when> … … 361 361 362 362 /* 363 * Copyright (C) 2008-201 3Oracle Corporation363 * Copyright (C) 2008-2014 Oracle Corporation 364 364 * 365 365 * This file is part of a free software library; you can redistribute -
trunk/src/VBox/Main/webservice/websrv-python.xsl
r45483 r50183 10 10 web service API. Depends on WSDL file for actual SOAP bindings. 11 11 12 Copyright (C) 2008-201 3Oracle Corporation12 Copyright (C) 2008-2014 Oracle Corporation 13 13 14 14 This file is part of VirtualBox Open Source Edition (OSE), as … … 52 52 <xsl:when test="$type='octet'">Octet</xsl:when> 53 53 <xsl:when test="$type='$unknown'">IUnknown</xsl:when> 54 <xsl:when test="$type='$dispatched'">IUnknown</xsl:when>55 54 <xsl:otherwise><xsl:value-of select="$type" /></xsl:otherwise> 56 55 </xsl:choose> … … 149 148 150 149 <xsl:choose> 151 <xsl:when test="($base = '$unknown') or ($base = '$dispatched')">150 <xsl:when test="($base = '$unknown')"> 152 151 <xsl:value-of select="'IUnknown'"/> 153 152 </xsl:when> … … 469 468 470 469 <xsl:template match="/"> 471 <xsl:text># Copyright (C) 2008-201 1Oracle Corporation470 <xsl:text># Copyright (C) 2008-2014 Oracle Corporation 472 471 # 473 472 # This file is part of a free software library; you can redistribute
Note:
See TracChangeset
for help on using the changeset viewer.