summaryrefslogtreecommitdiff
path: root/src/libs/xpcom18a4/python
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/xpcom18a4/python')
-rw-r--r--src/libs/xpcom18a4/python/Makefile.kmk77
-rwxr-xr-xsrc/libs/xpcom18a4/python/gen_python_deps.py23
-rw-r--r--src/libs/xpcom18a4/python/server/loader.py14
-rw-r--r--src/libs/xpcom18a4/python/src/PyGBase.cpp3
-rw-r--r--src/libs/xpcom18a4/python/src/PyIID.cpp2
-rw-r--r--src/libs/xpcom18a4/python/src/PyISupports.cpp4
-rw-r--r--src/libs/xpcom18a4/python/src/VariantUtils.cpp2
-rw-r--r--src/libs/xpcom18a4/python/src/module/_xpcom.cpp66
-rwxr-xr-xsrc/libs/xpcom18a4/python/vboxxpcom.py61
9 files changed, 163 insertions, 89 deletions
diff --git a/src/libs/xpcom18a4/python/Makefile.kmk b/src/libs/xpcom18a4/python/Makefile.kmk
index ea62ae26..50cc5e2d 100644
--- a/src/libs/xpcom18a4/python/Makefile.kmk
+++ b/src/libs/xpcom18a4/python/Makefile.kmk
@@ -26,24 +26,27 @@ endif
#
# List of supported Python versions, defining a number of
-# VBOX_PYTHON[25|26|27|28|DEF]_[INC|LIB] variables which get picked up below.
+# VBOX_PYTHON[25|26|27|DEF]_[INC|LIB] variables which get picked up below.
#
ifeq ($(KBUILD_TARGET),darwin) # Relatively predictable, don't script.
ifeq ($(KBUILD_TARGET_ARCH),x86)
VBOX_PYTHON25_INC = $(VBOX_PATH_MACOSX_SDK)/usr/include/python2.5
VBOX_PYTHON25_LIB = $(VBOX_PATH_MACOSX_SDK)/usr/lib/libpython2.5.dylib
+ VBOX_PYTHON25_LIB_X86 = $(VBOX_PYTHON25_LIB)
endif
if !defined(VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_6) \
&& ( !defined(VBOX_OSE) \
|| "$(wildcard $(VBOX_PATH_MACOSX_SDK_10_6)/usr/lib/libpython2.6.dylib)" != "")
VBOX_PYTHON26_INC = $(VBOX_PATH_MACOSX_SDK_10_6)/usr/include/python2.6
VBOX_PYTHON26_LIB = $(VBOX_PATH_MACOSX_SDK_10_6)/usr/lib/libpython2.6.dylib
+ VBOX_PYTHON26_LIB_X86 = $(VBOX_PYTHON26_LIB)
endif
if !defined(VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_7) \
&& ( defined(VBOX_NOT_OSE_LATER_SOMETIME) \
|| "$(wildcard $(VBOX_PATH_MACOSX_SDK_10_7)/usr/lib/libpython2.7.dylib)" != "")
VBOX_PYTHON27_INC = $(VBOX_PATH_MACOSX_SDK_10_7)/usr/include/python2.7
VBOX_PYTHON27_LIB = $(VBOX_PATH_MACOSX_SDK_10_7)/usr/lib/libpython2.7.dylib
+ VBOX_PYTHON27_LIB_X86 = $(VBOX_PYTHON27_LIB)
endif
else
@@ -102,6 +105,14 @@ VBoxPythonBase_LIBS = \
$(PATH_STAGE_LIB)/VBoxCOM$(VBOX_SUFF_LIB) \
$(PATH_STAGE_BIN)/VBoxXPCOM$(VBOX_SUFF_DLL)
+# 32-bit base.
+VBoxPythonBase_x86_TEMPLATE = XPCOM-x86
+VBoxPythonBase_x86_EXTENDS = VBoxPythonBase
+VBoxPythonBase_x86_DEFS = MODULE_NAME_SUFFIX=_x86 $(VBoxPythonBase_DEFS)
+VBoxPythonBase_x86_LIBS = \
+ $(PATH_STAGE_LIB)/VBoxCOM-x86$(VBOX_SUFF_LIB) \
+ $(PATH_STAGE_BIN)/VBoxXPCOM-x86$(VBOX_SUFF_DLL)
+
ifdef VBOX_PYTHON23_INC
#
@@ -113,6 +124,15 @@ VBoxPython2_3_EXTENDS_BY = appending
VBoxPython2_3_TEMPLATE = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX104,)
VBoxPython2_3_INCS = $(VBOX_PYTHON23_INC)
VBoxPython2_3_LIBS = $(VBOX_PYTHON23_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_3_x86
+VBoxPython2_3_x86_EXTENDS = VBoxPythonBase_x86
+VBoxPython2_3_x86_EXTENDS_BY = appending
+VBoxPython2_3_x86_TEMPLATE = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX104,-x86)
+VBoxPython2_3_x86_INCS = $(VBOX_PYTHON23_INC)
+VBoxPython2_3_x86_LIBS = $(VBOX_PYTHON23_LIB_X86)
+ endif
endif
ifdef VBOX_PYTHON24_INC
@@ -124,6 +144,14 @@ VBoxPython2_4_EXTENDS = VBoxPythonBase
VBoxPython2_4_EXTENDS_BY = appending
VBoxPython2_4_INCS = $(VBOX_PYTHON24_INC)
VBoxPython2_4_LIBS = $(VBOX_PYTHON24_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_4_x86
+VBoxPython2_4_x86_EXTENDS = VBoxPythonBase_x86
+VBoxPython2_4_x86_EXTENDS_BY = appending
+VBoxPython2_4_x86_INCS = $(VBOX_PYTHON24_INC)
+VBoxPython2_4_x86_LIBS = $(VBOX_PYTHON24_LIB_X86)
+ endif
endif
ifdef VBOX_PYTHON25_INC
@@ -133,9 +161,16 @@ ifdef VBOX_PYTHON25_INC
DLLS += VBoxPython2_5
VBoxPython2_5_EXTENDS = VBoxPythonBase
VBoxPython2_5_EXTENDS_BY = appending
-VBoxPython2_5_TEMPLATE = XPCOM
VBoxPython2_5_INCS = $(VBOX_PYTHON25_INC)
VBoxPython2_5_LIBS = $(VBOX_PYTHON25_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_5_x86
+VBoxPython2_5_x86_EXTENDS = VBoxPythonBase_x86
+VBoxPython2_5_x86_EXTENDS_BY = appending
+VBoxPython2_5_x86_INCS = $(VBOX_PYTHON25_INC)
+VBoxPython2_5_x86_LIBS = $(VBOX_PYTHON25_LIB_X86)
+ endif
endif
ifdef VBOX_PYTHON26_INC
@@ -148,6 +183,15 @@ VBoxPython2_6_EXTENDS_BY = appending
VBoxPython2_6_TEMPLATE = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX106,)
VBoxPython2_6_INCS = $(VBOX_PYTHON26_INC)
VBoxPython2_6_LIBS = $(VBOX_PYTHON26_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_6_x86
+VBoxPython2_6_x86_EXTENDS = VBoxPythonBase_x86
+VBoxPython2_6_x86_EXTENDS_BY = appending
+VBoxPython2_6_x86_TEMPLATE = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX106,-x86)
+VBoxPython2_6_x86_INCS = $(VBOX_PYTHON26_INC)
+VBoxPython2_6_x86_LIBS = $(VBOX_PYTHON26_LIB_X86)
+ endif
endif
ifdef VBOX_PYTHON27_INC
@@ -160,17 +204,15 @@ VBoxPython2_7_EXTENDS_BY = appending
VBoxPython2_7_TEMPLATE = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX107,)
VBoxPython2_7_INCS = $(VBOX_PYTHON27_INC)
VBoxPython2_7_LIBS = $(VBOX_PYTHON27_LIB)
-endif
-ifdef VBOX_PYTHON28_INC
-#
-# Python 2.8 version
-#
-DLLS += VBoxPython2_8
-VBoxPython2_8_EXTENDS = VBoxPythonBase
-VBoxPython2_8_EXTENDS_BY = appending
-VBoxPython2_8_INCS = $(VBOX_PYTHON28_INC)
-VBoxPython2_8_LIBS = $(VBOX_PYTHON28_LIB)
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_7_x86
+VBoxPython2_7_x86_EXTENDS = VBoxPythonBase_x86
+VBoxPython2_7_x86_EXTENDS_BY = appending
+VBoxPython2_7_x86_TEMPLATE = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX107,-x86)
+VBoxPython2_7_x86_INCS = $(VBOX_PYTHON27_INC)
+VBoxPython2_7_x86_LIBS = $(VBOX_PYTHON27_LIB_X86)
+ endif
endif
ifdef VBOX_PYTHONDEF_INC
@@ -186,6 +228,17 @@ if "$(KBUILD_TARGET)" == "linux"
else
VBoxPython_LIBS = $(VBoxPythonBase_LIBS) $(VBOX_PYTHONDEF_LIB)
endif
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+VBoxPython_x86_EXTENDS = VBoxPythonBase_x86
+VBoxPython_x86_DEFS = $(filter-out VBOX_PYXPCOM_VERSIONED,$(VBoxPythonBase_x86_DEFS))
+VBoxPython_x86_INCS = $(VBoxPythonBase_x86_INCS) $(VBOX_PYTHONDEF_INC)
+if "$(KBUILD_TARGET)" == "linux"
+ VBoxPython_x86_LIBS = $(VBoxPythonBase_x86_LIBS)
+else
+ VBoxPython_x86_LIBS = $(VBoxPythonBase_x86_LIBS) $(VBOX_PYTHONDEF_LIB_X86)
+endif
+ endif
endif
endif # VBOX_ONLY_SDK
diff --git a/src/libs/xpcom18a4/python/gen_python_deps.py b/src/libs/xpcom18a4/python/gen_python_deps.py
index bcca1da0..1cf39b3b 100755
--- a/src/libs/xpcom18a4/python/gen_python_deps.py
+++ b/src/libs/xpcom18a4/python/gen_python_deps.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-Copyright (C) 2009-2012 Oracle Corporation
+Copyright (C) 2009-2013 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
@@ -14,7 +14,7 @@ hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
import os,sys
-versions = ["2.3", "2.4", "2.5", "2.6", "2.7", "2.8"]
+versions = ["2.3", "2.4", "2.5", "2.6", "2.7",]
prefixes = ["/usr", "/usr/local", "/opt", "/opt/local"]
known = {}
@@ -23,26 +23,29 @@ def checkPair(p, v,dllpre,dllsuff, bitness_magic):
if not os.path.isfile(file):
return None
- lib = os.path.join(p, "lib", dllpre+"python"+v+dllsuff)
+ lib = os.path.join(p, "lib/i386-linux-gnu", dllpre+"python"+v+dllsuff)
+ if not os.path.isfile(lib):
+ lib = os.path.join(p, "lib", dllpre+"python"+v+dllsuff)
if bitness_magic == 1:
lib64 = os.path.join(p, "lib", "64", dllpre+"python"+v+dllsuff)
elif bitness_magic == 2:
- lib64 = os.path.join(p, "lib64", dllpre+"python"+v+dllsuff)
+ lib64 = os.path.join(p, "lib/x86_64-linux-gnu", dllpre+"python"+v+dllsuff)
if not os.path.isfile(lib64):
- lib64 = lib
+ lib64 = os.path.join(p, "lib64", dllpre+"python"+v+dllsuff)
+ if not os.path.isfile(lib64):
+ lib64 = lib
else:
lib64 = None
- return [os.path.join(p, "include", "python"+v),
- lib,
- lib64]
+ return [os.path.join(p, "include", "python"+v), lib, lib64]
def print_vars(vers, known, sep, bitness_magic):
print "VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep)
if bitness_magic > 0:
- print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)
+ print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)
+ print "VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep)
else:
- print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
+ print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
def main(argv):
diff --git a/src/libs/xpcom18a4/python/server/loader.py b/src/libs/xpcom18a4/python/server/loader.py
index b5875546..e59155a5 100644
--- a/src/libs/xpcom18a4/python/server/loader.py
+++ b/src/libs/xpcom18a4/python/server/loader.py
@@ -57,11 +57,15 @@ def FindCOMComponents(py_module):
# For now, just run over all classes looking for likely candidates.
comps = []
for name, object in py_module.__dict__.items():
- if type(object)==types.ClassType and \
- _has_good_attr(object, "_com_interfaces_") and \
- _has_good_attr(object, "_reg_clsid_") and \
- _has_good_attr(object, "_reg_contractid_"):
- comps.append(object)
+ try:
+ if (type(object) == types.ClassType or issubclass(object, object)) and \
+ _has_good_attr(object, "_com_interfaces_") and \
+ _has_good_attr(object, "_reg_clsid_") and \
+ _has_good_attr(object, "_reg_contractid_"):
+ comps.append(object)
+ except TypeError:
+ # The issubclass call raises TypeError when the obj is not a class.
+ pass;
return comps
def register_self(klass, compMgr, location, registryLocation, componentType):
diff --git a/src/libs/xpcom18a4/python/src/PyGBase.cpp b/src/libs/xpcom18a4/python/src/PyGBase.cpp
index 93fe03f9..0a935017 100644
--- a/src/libs/xpcom18a4/python/src/PyGBase.cpp
+++ b/src/libs/xpcom18a4/python/src/PyGBase.cpp
@@ -195,7 +195,8 @@ void *PyG_Base::ThisAsIID( const nsIID &iid )
PyG_Base::AutoWrapPythonInstance(PyObject *ob, const nsIID &iid, nsISupports **ppret)
{
NS_PRECONDITION(ppret!=NULL, "null pointer when wrapping a Python instance!");
- NS_PRECONDITION(ob && PyInstance_Check(ob), "AutoWrapPythonInstance is expecting an non-NULL instance!");
+ NS_PRECONDITION(ob && PyObject_HasAttrString(ob, "__class__"),
+ "AutoWrapPythonInstance is expecting an non-NULL instance!");
PRBool ok = PR_FALSE;
// XXX - todo - this static object leaks! (but Python on Windows leaks 2000+ objects as it is ;-)
static PyObject *func = NULL; // fetch this once and remember!
diff --git a/src/libs/xpcom18a4/python/src/PyIID.cpp b/src/libs/xpcom18a4/python/src/PyIID.cpp
index 2cdcf5c0..783c9c61 100644
--- a/src/libs/xpcom18a4/python/src/PyIID.cpp
+++ b/src/libs/xpcom18a4/python/src/PyIID.cpp
@@ -114,7 +114,7 @@ Py_nsIID::IIDFromPyObject(PyObject *ob, nsIID *pRet) {
}
} else if (ob->ob_type == &type) {
iid = ((Py_nsIID *)ob)->m_iid;
- } else if (PyInstance_Check(ob)) {
+ } else if (PyObject_HasAttrString(ob, "__class__")) {
// Get the _iidobj_ attribute
PyObject *use_ob = PyObject_GetAttrString(ob, "_iidobj_");
if (use_ob==NULL) {
diff --git a/src/libs/xpcom18a4/python/src/PyISupports.cpp b/src/libs/xpcom18a4/python/src/PyISupports.cpp
index 508eeeae..0802eeed 100644
--- a/src/libs/xpcom18a4/python/src/PyISupports.cpp
+++ b/src/libs/xpcom18a4/python/src/PyISupports.cpp
@@ -321,7 +321,7 @@ Py_nsISupports::InterfaceFromPyObject(PyObject *ob,
// support nsIVariant
if (iid.Equals(NS_GET_IID(nsIVariant)) || iid.Equals(NS_GET_IID(nsIWritableVariant))) {
// Check it is not already nsIVariant
- if (PyInstance_Check(ob)) {
+ if (PyObject_HasAttrString(ob, "__class__")) {
PyObject *sub_ob = PyObject_GetAttrString(ob, "_comobj_");
if (sub_ob==NULL) {
PyErr_Clear();
@@ -344,7 +344,7 @@ Py_nsISupports::InterfaceFromPyObject(PyObject *ob,
}
// end of variant support.
- if (PyInstance_Check(ob)) {
+ if (PyObject_HasAttrString(ob, "__class__")) {
// Get the _comobj_ attribute
PyObject *use_ob = PyObject_GetAttrString(ob, "_comobj_");
if (use_ob==NULL) {
diff --git a/src/libs/xpcom18a4/python/src/VariantUtils.cpp b/src/libs/xpcom18a4/python/src/VariantUtils.cpp
index 0c864ec4..cc050b5f 100644
--- a/src/libs/xpcom18a4/python/src/VariantUtils.cpp
+++ b/src/libs/xpcom18a4/python/src/VariantUtils.cpp
@@ -1116,7 +1116,7 @@ PRBool PyXPCOM_InterfaceVariantHelper::Init(PyObject *obParams)
if (PySequence_Length(m_pyparams) != total_params_needed) {
#ifdef VBOX
PyErr_Format(PyExc_ValueError, "The type descriptions indicate %d args are needed, but %ld were provided",
- total_params_needed, PySequence_Length(m_pyparams));
+ total_params_needed, (long)PySequence_Length(m_pyparams));
#else
PyErr_Format(PyExc_ValueError, "The type descriptions indicate %d args are needed, but %d were provided",
total_params_needed, PySequence_Length(m_pyparams));
diff --git a/src/libs/xpcom18a4/python/src/module/_xpcom.cpp b/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
index f5465131..be6b1888 100644
--- a/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
+++ b/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
@@ -74,24 +74,44 @@ extern PYXPCOM_EXPORT void PyXPCOM_InterpreterState_Ensure();
#endif
#ifdef VBOX_PYXPCOM
+# include <iprt/cdefs.h>
+# ifndef MODULE_NAME_SUFFIX
+# define MANGLE_MODULE_NAME(a_szName) a_szName
+# define MANGLE_MODULE_INIT(a_Name) a_Name
+# else
+# define MANGLE_MODULE_NAME(a_szName) a_szName RT_XSTR(MODULE_NAME_SUFFIX)
+# define MANGLE_MODULE_INIT(a_Name) RT_CONCAT(a_Name, MODULE_NAME_SUFFIX)
+# endif
# ifdef VBOX_PYXPCOM_VERSIONED
# if PY_VERSION_HEX >= 0x02080000
-# define MODULE_NAME "VBoxPython2_8"
+# define MODULE_NAME MANGLE_MODULE_NAME("VBoxPython2_8")
+# define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_8)
+
# elif PY_VERSION_HEX >= 0x02070000
-# define MODULE_NAME "VBoxPython2_7"
+# define MODULE_NAME MANGLE_MODULE_NAME("VBoxPython2_7")
+# define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_7)
+
# elif PY_VERSION_HEX >= 0x02060000
-# define MODULE_NAME "VBoxPython2_6"
+# define MODULE_NAME MANGLE_MODULE_NAME("VBoxPython2_6")
+# define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_6)
+
# elif PY_VERSION_HEX >= 0x02050000
-# define MODULE_NAME "VBoxPython2_5"
+# define MODULE_NAME MANGLE_MODULE_NAME("VBoxPython2_5")
+# define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_5)
+
# elif PY_VERSION_HEX >= 0x02040000
-# define MODULE_NAME "VBoxPython2_4"
+# define MODULE_NAME MANGLE_MODULE_NAME("VBoxPython2_4")
+# define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_4)
+
# elif PY_VERSION_HEX >= 0x02030000
-# define MODULE_NAME "VBoxPython2_3"
+# define MODULE_NAME MANGLE_MODULE_NAME("VBoxPython2_3")
+# define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_3)
# else
# error "Fix module versioning."
# endif
# else
-# define MODULE_NAME "VBoxPython"
+# define MODULE_NAME MANGLE_MODULE_NAME("VBoxPython")
+# define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython)
# endif
#else
#define MODULE_NAME "_xpcom"
@@ -510,7 +530,7 @@ PyObject *LogConsoleMessage(PyObject *self, PyObject *args)
#ifdef VBOX
-# include <VBox/com/EventQueue.h>
+# include <VBox/com/NativeEventQueue.h>
# include <iprt/err.h>
static PyObject *
@@ -521,7 +541,7 @@ PyXPCOMMethod_WaitForEvents(PyObject *self, PyObject *args)
return NULL;
int rc;
- com::EventQueue* aEventQ = com::EventQueue::getMainEventQueue();
+ com::NativeEventQueue* aEventQ = com::NativeEventQueue::getMainEventQueue();
NS_WARN_IF_FALSE(aEventQ != nsnull, "Null main event queue");
if (!aEventQ)
{
@@ -556,7 +576,7 @@ PyXPCOMMethod_WaitForEvents(PyObject *self, PyObject *args)
static PyObject*
PyXPCOMMethod_InterruptWait(PyObject *self, PyObject *args)
{
- com::EventQueue* aEventQ = com::EventQueue::getMainEventQueue();
+ com::NativeEventQueue* aEventQ = com::NativeEventQueue::getMainEventQueue();
NS_WARN_IF_FALSE(aEventQ != nsnull, "Null main event queue");
if (!aEventQ)
return NULL;
@@ -776,31 +796,13 @@ using namespace com;
extern "C" NS_EXPORT
void
-# ifdef VBOX_PYXPCOM_VERSIONED
-# if PY_VERSION_HEX >= 0x02080000
-initVBoxPython2_8() {
-# elif PY_VERSION_HEX >= 0x02070000
-initVBoxPython2_7() {
-# elif PY_VERSION_HEX >= 0x02060000
-initVBoxPython2_6() {
-# elif PY_VERSION_HEX >= 0x02050000
-initVBoxPython2_5() {
-# elif PY_VERSION_HEX >= 0x02040000
-initVBoxPython2_4() {
-# elif PY_VERSION_HEX >= 0x02030000
-initVBoxPython2_3() {
-# else
-# error "Fix module versioning."
-# endif
-# else
-initVBoxPython() {
-# endif
+initVBoxPython() { /* NOTE! This name is redefined at the top of the file! */
static bool s_vboxInited = false;
if (!s_vboxInited) {
int rc = 0;
#if defined(VBOX_PATH_APP_PRIVATE_ARCH) && defined(VBOX_PATH_SHARED_LIBS)
- rc = RTR3InitDll(0);
+ rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
#else
const char *home = getenv("VBOX_PROGRAM_PATH");
if (home) {
@@ -808,9 +810,9 @@ initVBoxPython() {
char *exepath = (char *)alloca(len + 32);
memcpy(exepath, home, len);
memcpy(exepath + len, "/pythonfake", sizeof("/pythonfake"));
- rc = RTR3InitEx(RTR3INIT_VER_CUR, RTR3INIT_FLAGS_DLL, 0, NULL, exepath);
+ rc = RTR3InitEx(RTR3INIT_VER_CUR, RTR3INIT_FLAGS_DLL | RTR3INIT_FLAGS_UNOBTRUSIVE, 0, NULL, exepath);
} else {
- rc = RTR3InitDll(0);
+ rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
}
#endif
diff --git a/src/libs/xpcom18a4/python/vboxxpcom.py b/src/libs/xpcom18a4/python/vboxxpcom.py
index 47b11d0f..fa1f597a 100755
--- a/src/libs/xpcom18a4/python/vboxxpcom.py
+++ b/src/libs/xpcom18a4/python/vboxxpcom.py
@@ -1,5 +1,5 @@
"""
-Copyright (C) 2008 Oracle Corporation
+Copyright (C) 2008-2012 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
@@ -14,38 +14,49 @@ import xpcom
import sys
import platform
-# this code overcomes somewhat unlucky feature of Python, where it searches
+#
+# This code overcomes somewhat unlucky feature of Python, where it searches
# for binaries in the same place as platfom independent modules, while
# rest of Python bindings expect _xpcom to be inside xpcom module
-
-candidates = ['VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]),
- 'VBoxPython' + str(sys.version_info[0]),
- 'VBoxPython']
+#
+
+_asVBoxPythons = [
+ 'VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]),
+ 'VBoxPython' + str(sys.version_info[0]),
+ 'VBoxPython'
+];
+
+# On platforms where we ship both 32-bit and 64-bit API bindings, we have to
+# look for the right set if we're a 32-bit process.
+if platform.system() in [ 'SunOS', ] and sys.maxsize <= 2**32:
+ _asNew = [ sCandidate + '_x86' for sCandidate in _asVBoxPythons ];
+ _asNew.extend(_asVBoxPythons);
+ _asVBoxPythons = _asNew;
+ del _asNew;
+
+# On Darwin (aka Mac OS X) we know exactly where things are in a normal
+# VirtualBox installation.
+## @todo Edit this at build time to the actual VBox location set in the make files.
+## @todo We know the location for most hardened builds, not just darwin!
if platform.system() == 'Darwin':
- # On Darwin (aka Mac OS X) we know exactly where things are in a normal
- # VirtualBox installation. Also, there are two versions of python there
- # (2.3.x and 2.5.x) depending on whether the os is striped or spotty, so
- # we have to choose the right module to load.
- #
- # XXX: This needs to be adjusted for OSE builds. A more general solution would
- # be to to sed the file during install and inject the VBOX_PATH_APP_PRIVATE_ARCH
- # and VBOX_PATH_SHARED_LIBS when these are set.
sys.path.append('/Applications/VirtualBox.app/Contents/MacOS')
-cglue = None
-for m in candidates:
- try:
- cglue = __import__(m)
- break
- except:
- pass
+_oVBoxPythonMod = None
+for m in _asVBoxPythons:
+ try:
+ _oVBoxPythonMod = __import__(m)
+ break
+ except Exception, x:
+ print 'm=%s x=%s' % (m, x);
+ #except:
+ # pass
if platform.system() == 'Darwin':
sys.path.remove('/Applications/VirtualBox.app/Contents/MacOS')
-if cglue == None:
- raise Exception, "Cannot find VBoxPython module"
+if _oVBoxPythonMod == None:
+ raise Exception('Cannot find VBoxPython module (tried: %s)' % (', '.join(_asVBoxPythons),));
-sys.modules['xpcom._xpcom'] = cglue
-xpcom._xpcom = cglue
+sys.modules['xpcom._xpcom'] = _oVBoxPythonMod;
+xpcom._xpcom = _oVBoxPythonMod;