VirtualBox

Ignore:
Timestamp:
Aug 19, 2009 9:32:54 PM (15 years ago)
Author:
vboxsync
Message:

COM, Python: wrappers cleanup, some generic improvments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp

    r21300 r22357  
    493493
    494494#ifdef VBOX
     495
    495496static nsIEventQueue* g_mainEventQ = nsnull;
    496497
     
    575576PyXPCOMMethod_DeinitCOM(PyObject *self, PyObject *args)
    576577{
    577   Py_BEGIN_ALLOW_THREADS;
    578   deinitVBoxPython();
    579   Py_END_ALLOW_THREADS;
    580   return PyInt_FromLong(0);
     578    Py_BEGIN_ALLOW_THREADS;
     579    deinitVBoxPython();
     580    Py_END_ALLOW_THREADS;
     581    return PyInt_FromLong(0);
     582}
     583
     584static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
     585
     586static PyObject*
     587PyXPCOMMethod_AttachThread(PyObject *self, PyObject *args)
     588{
     589    nsresult rv;
     590    PRInt32  result = 0;
     591    nsCOMPtr<nsIEventQueueService> eqs;
     592
     593    // Create the Event Queue for this thread...
     594    Py_BEGIN_ALLOW_THREADS;
     595    eqs =
     596      do_GetService(kEventQueueServiceCID, &rv);
     597    Py_END_ALLOW_THREADS;
     598    if (NS_FAILED(rv))
     599    {
     600      result = 1;
     601      goto done;
     602    }
     603
     604    Py_BEGIN_ALLOW_THREADS;
     605    rv = eqs->CreateThreadEventQueue();
     606    Py_END_ALLOW_THREADS;
     607    if (NS_FAILED(rv))
     608    {
     609      result = 2;
     610      goto done;
     611    }
     612
     613 done:
     614    /** @todo: better throw an exception on error */
     615    return PyInt_FromLong(result);
     616}
     617
     618static PyObject*
     619PyXPCOMMethod_DetachThread(PyObject *self, PyObject *args)
     620{
     621    nsresult rv;
     622    PRInt32  result = 0;
     623    nsCOMPtr<nsIEventQueueService> eqs;
     624
     625    // Destroy the Event Queue for this thread...
     626    Py_BEGIN_ALLOW_THREADS;
     627    eqs =
     628      do_GetService(kEventQueueServiceCID, &rv);
     629    Py_END_ALLOW_THREADS;
     630    if (NS_FAILED(rv))
     631    {
     632      result = 1;
     633      goto done;
     634    }
     635
     636    Py_BEGIN_ALLOW_THREADS;
     637    rv = eqs->DestroyThreadEventQueue();
     638    Py_END_ALLOW_THREADS;
     639    if (NS_FAILED(rv))
     640    {
     641      result = 2;
     642      goto done;
     643    }
     644
     645 done:
     646    /** @todo: better throw an exception on error */
     647    return PyInt_FromLong(result);
    581648}
    582649#endif
     
    609676#ifdef VBOX
    610677        {"WaitForEvents", PyXPCOMMethod_WaitForEvents, 1},
    611         {"DeinitCOM", PyXPCOMMethod_DeinitCOM, 1},
     678        {"DeinitCOM",     PyXPCOMMethod_DeinitCOM, 1},
     679        {"AttachThread",  PyXPCOMMethod_AttachThread, 1},
     680        {"DetachThread",  PyXPCOMMethod_DetachThread, 1},
    612681#endif
    613682        // These should no longer be used - just use the logging.getLogger('pyxpcom')...
Note: See TracChangeset for help on using the changeset viewer.

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