Changeset 19728 in vbox
- Timestamp:
- May 15, 2009 11:52:49 AM (16 years ago)
- Location:
- trunk/src/VBox/Main/cbinding
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/cbinding/Makefile.kmk
r18998 r19728 101 101 $(VBoxXPCOMCGlue_1_TARGET) 102 102 103 ifeq (disabled,1) 104 # 105 # The callback testcase. 106 # 107 PROGRAMS += tstXPCOMCCall 108 tstXPCOMCCall_TEMPLATE = VBOXR3EXE 109 tstXPCOMCCall_INCS = \ 110 $(VBOX_PATH_SDK)/bindings/xpcom/include 111 tstXPCOMCCall_INTERMEDIATES = \ 112 $(VBOX_PATH_SDK)/bindings/xpcom/include/VBoxCAPI_v2_5.h 113 tstXPCOMCCall_SOURCES = \ 114 tstXPCOMCCall.c 115 tstXPCOMCCall_LIBS = \ 116 $(VBoxXPCOMCGlue_1_TARGET) 117 endif 103 118 endif 104 119 -
trunk/src/VBox/Main/cbinding/tstXPCOMCCall.c
r19375 r19728 30 30 #include <stdlib.h> 31 31 #include <unistd.h> 32 32 #include <signal.h> 33 #include <sys/poll.h> 34 35 /******************************************************************************* 36 * Internal Functions * 37 *******************************************************************************/ 33 38 static void listVMs(IVirtualBox *virtualBox, ISession *session, nsIEventQueue *queue); 34 39 static void registerCallBack(IVirtualBox *virtualBox, ISession *session, PRUnichar *machineId, nsIEventQueue *queue); 35 40 static void startVM(IVirtualBox *virtualBox, ISession *session, PRUnichar *id, nsIEventQueue *queue); 41 42 /******************************************************************************* 43 * Global Variables * 44 *******************************************************************************/ 45 /** Set by signal handler. */ 46 static volatile int g_fStop = 0; 36 47 37 48 int volatile g_refcount = 0; … … 212 223 nsresult c; 213 224 214 printf("AddRef\n");215 c = g_refcount++;225 c = ++g_refcount; 226 printf("AddRef: %d\n", c); 216 227 return c; 217 228 } … … 220 231 { 221 232 nsresult c; 222 printf("Release\n"); 223 224 c = g_refcount--;233 234 c = --g_refcount; 235 printf("Release: %d\n", c); 225 236 if (c == 0) 226 237 { … … 236 247 IConsoleCallback *that = (IConsoleCallback *)pThis; 237 248 238 printf("QueryInterface\n");239 249 /* match iid */ 240 g_refcount++; 250 ++g_refcount; 251 printf("QueryInterface: %d\n", g_refcount); 241 252 *resultp = that; 242 return 0; 253 return NS_OK; 254 } 255 256 /** 257 * Signal callback. 258 * 259 * @param iSig The signal number (ignored). 260 */ 261 static void sigIntHandler(int iSig) 262 { 263 printf("sigIntHandler\n"); 264 (void)iSig; 265 g_fStop = 1; 243 266 } 244 267 … … 295 318 * great ideas anyone? 296 319 */ 297 int run = 10000000; 298 while (run-- > 0) { 299 queue->vtbl->ProcessPendingEvents(queue); 320 PRInt32 fd; 321 322 printf("Entering event loop, press Ctrl-C to terminate\n"); 323 fflush(stdout); 324 signal(SIGINT, sigIntHandler); 325 326 fd = queue->vtbl->GetEventQueueSelectFD(queue); 327 if (fd >= 0) { 328 while (!g_fStop) { 329 struct pollfd pfd; 330 pfd.fd = fd; 331 pfd.events = POLLIN | POLLERR | POLLHUP; 332 pfd.revents = 0; 333 poll(&pfd, 1, 250); 334 rc = queue->vtbl->ProcessPendingEvents(queue); 335 } 336 } else { 337 while (!g_fStop) { 338 PLEvent *pEvent = NULL; 339 rc = queue->vtbl->WaitForEvent(queue, &pEvent); 340 /*printf("event: %p rc=%x\n", (void *)pEvent, rc);*/ 341 if (NS_SUCCEEDED(rc)) 342 queue->vtbl->HandleEvent(queue, pEvent); 343 } 300 344 } 345 signal(SIGINT, SIG_DFL); 301 346 } 302 347 console->vtbl->UnregisterCallback(console, consoleCallback); 303 }304 consoleCallback->vtbl->nsisupports.Release((nsISupports *)consoleCallback);348 consoleCallback->vtbl->nsisupports.Release((nsISupports *)consoleCallback); 349 } 305 350 } 306 351 session->vtbl->Close((void *)session); … … 593 638 } 594 639 g_pVBoxFuncs->pfnGetEventQueue(&queue); 595 printf("Got the event queue: %p\n", queue);640 printf("Got the event queue: %p\n", (void *)queue); 596 641 597 642 /*
Note:
See TracChangeset
for help on using the changeset viewer.