diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 22:55:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 22:55:45 +0000 |
commit | 04aecf1372d30eb709d8de65152535ab66dcb74a (patch) | |
tree | d1e4d8c453a76465e8b63119314a28d39b474479 /src/libs/xpcom18a4/python | |
parent | Adding upstream version 7.0.14-dfsg. (diff) | |
download | virtualbox-upstream/7.0.16-dfsg.tar.xz virtualbox-upstream/7.0.16-dfsg.zip |
Adding upstream version 7.0.16-dfsg.upstream/7.0.16-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/libs/xpcom18a4/python/Makefile.kmk | 32 | ||||
-rw-r--r-- | src/libs/xpcom18a4/python/src/PyIID.cpp | 27 | ||||
-rw-r--r-- | src/libs/xpcom18a4/python/src/PyXPCOM.h | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | src/libs/xpcom18a4/python/test/regrtest.py | 0 |
4 files changed, 51 insertions, 9 deletions
diff --git a/src/libs/xpcom18a4/python/Makefile.kmk b/src/libs/xpcom18a4/python/Makefile.kmk index 49653847..6495299e 100644 --- a/src/libs/xpcom18a4/python/Makefile.kmk +++ b/src/libs/xpcom18a4/python/Makefile.kmk @@ -75,7 +75,24 @@ ifeq ($(KBUILD_TARGET),darwin) # Relatively predictable, don't script. VBOX_PYTHON27_LIB = endif endif - # No Python 3.x yet as part of OSX versions including El Capitan, 10.11. + # + # Apple introduced python3 as part of the developer command tools starting with at least 10.15 (didn't go back further as it is not of interest to us). + # However the headers and libraries are now residing under /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions with 3.8 and 3.9 + # being present on Monterey. + # For now we will only provide the module for 3.8 and the version agnostic variant using the limited API. + # + if exists "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9" + VBOX_PYTHON39_INC = /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers + VBOX_PYTHON39_LIB = /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/libpython3.9.dylib + endif + if exists "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8" + VBOX_PYTHON38_INC = /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/Headers + VBOX_PYTHON38_LIB = /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/libpython3.8.dylib + endif + if exists "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7" + VBOX_PYTHON37_INC = /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/Headers + VBOX_PYTHON37_LIB = /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/libpython3.8.dylib + endif else # Use the script. @@ -686,18 +703,21 @@ ifndef VBOX_ONLY_SDK # TODO: ASSUMING that we don't need a different headers for pymalloc # ('m' builds < 3.8) and CRT malloc. # - VBOX_PYTHON_LIMITED_API_VER := $(firstword $(foreach ver, 35 36 38 39 310 311 312 34 33 \ + VBOX_PYTHON_LIMITED_API_VER := $(firstword $(foreach ver, 35 36 37 38 39 310 311 312 34 33 \ ,$(if-expr defined(VBOX_PYTHON$(ver)_INC),$(ver),)$(if-expr defined(VBOX_PYTHON$(ver)M_INC),$(ver)M,))) ifneq ($(VBOX_PYTHON_LIMITED_API_VER),) DLLS += VBoxPython3 VBoxPython3_EXTENDS = VBoxPythonBase VBoxPython3_DEFS = $(filter-out VBOX_PYXPCOM_VERSIONED,$(VBoxPythonBase_DEFS)) Py_LIMITED_API=0x03030000 VBoxPython3_INCS = $(VBoxPythonBase_INCS) $(VBOX_PYTHON$(VBOX_PYTHON_LIMITED_API_VER)_INC) + VBoxPython3_LDFLAGS.darwin = -undefined dynamic_lookup - DLLS += VBoxPython3m - VBoxPython3m_EXTENDS = VBoxPythonBase_m - VBoxPython3m_DEFS = $(filter-out VBOX_PYXPCOM_VERSIONED,$(VBoxPythonBase_m_DEFS)) Py_LIMITED_API=0x03030000 - VBoxPython3m_INCS = $(VBoxPythonBase_m_INCS) $(VBOX_PYTHON$(VBOX_PYTHON_LIMITED_API_VER)_INC) + ifneq ($(KBUILD_TARGET),darwin) + DLLS += VBoxPython3m + VBoxPython3m_EXTENDS = VBoxPythonBase_m + VBoxPython3m_DEFS = $(filter-out VBOX_PYXPCOM_VERSIONED,$(VBoxPythonBase_m_DEFS)) Py_LIMITED_API=0x03030000 + VBoxPython3m_INCS = $(VBoxPythonBase_m_INCS) $(VBOX_PYTHON$(VBOX_PYTHON_LIMITED_API_VER)_INC) + endif endif endif # VBOX_WITH_PYTHON_LIMITED_API diff --git a/src/libs/xpcom18a4/python/src/PyIID.cpp b/src/libs/xpcom18a4/python/src/PyIID.cpp index f24ae20e..9825db88 100644 --- a/src/libs/xpcom18a4/python/src/PyIID.cpp +++ b/src/libs/xpcom18a4/python/src/PyIID.cpp @@ -236,13 +236,14 @@ PyTypeObject *Py_nsIID::GetTypeObject(void) { Py_tp_hash, (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_hash }, { Py_tp_str, (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_str }, { Py_tp_richcompare, (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_richcompare }, + { Py_tp_is_gc, (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_is_gc }, { 0, NULL } /* terminator */ }; PyType_Spec TypeSpec = { /* .name: */ "IID", /* .basicsize: */ sizeof(Py_nsIID), /* .itemsize: */ 0, - /* .flags: */ 0, + /* .flags: */ Py_TPFLAGS_DEFAULT, /* .slots: */ aTypeSlots, }; @@ -319,10 +320,22 @@ Py_nsIID::PyTypeMethod_compare(PyObject *self, PyObject *other) /* static */ PyObject * Py_nsIID::PyTypeMethod_richcompare(PyObject *self, PyObject *other, int op) { + nsIID iid; + if (!Py_nsIID::IIDFromPyObject(other, &iid)) + { + /* Can't do comparison besides equality/inequality if the other object does not contain an IID. */ + if (op == Py_EQ) + Py_RETURN_FALSE; + else if (op == Py_NE) + Py_RETURN_TRUE; + + PyErr_SetString(PyExc_TypeError, "Comparison between different object types is not defined"); + return NULL; + } + PyObject *result = NULL; Py_nsIID *s_iid = (Py_nsIID *)self; - Py_nsIID *o_iid = (Py_nsIID *)other; - int rc = memcmp(&s_iid->m_iid, &o_iid->m_iid, sizeof(s_iid->m_iid)); + int rc = memcmp(&s_iid->m_iid, &iid, sizeof(s_iid->m_iid)); switch (op) { case Py_LT: @@ -408,3 +421,11 @@ Py_nsIID::PyTypeMethod_dealloc(PyObject *ob) { delete (Py_nsIID *)ob; } + +#ifdef Py_LIMITED_API +/* static */ int +Py_nsIID::PyTypeMethod_is_gc(PyObject *self) +{ + return 0; +} +#endif diff --git a/src/libs/xpcom18a4/python/src/PyXPCOM.h b/src/libs/xpcom18a4/python/src/PyXPCOM.h index 91bc8d12..c6b42b4f 100644 --- a/src/libs/xpcom18a4/python/src/PyXPCOM.h +++ b/src/libs/xpcom18a4/python/src/PyXPCOM.h @@ -586,6 +586,7 @@ public: #else static NS_EXPORT_STATIC_MEMBER_(PyTypeObject *) s_pType; static PyTypeObject *GetTypeObject(void); + static int PyTypeMethod_is_gc(PyObject *self); #endif static NS_EXPORT_STATIC_MEMBER_(PyMethodDef) methods[]; }; diff --git a/src/libs/xpcom18a4/python/test/regrtest.py b/src/libs/xpcom18a4/python/test/regrtest.py index 90d07948..90d07948 100644..100755 --- a/src/libs/xpcom18a4/python/test/regrtest.py +++ b/src/libs/xpcom18a4/python/test/regrtest.py |