VirtualBox

vbox的更動 22357 路徑 trunk/src/libs/xpcom18a4/python


忽略:
時間撮記:
2009-8-19 下午09:32:54 (15 年 以前)
作者:
vboxsync
訊息:

COM, Python: wrappers cleanup, some generic improvments

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • 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')...
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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