From 5655e97ec14d029338080bae0772a7fba8c1c88c Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 16 Sep 2020 23:17:26 +0200 Subject: [PATCH 1/6] interrogate: fix misbehaving == and != operator if only < is defined Fixes comparison of two empty RenderEffects objects --- .../interfaceMakerPythonNative.cxx | 57 ++++++++++++++++++- .../interrogate/interfaceMakerPythonNative.h | 3 + 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index bf0ff5d333..2856c95fba 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2570,6 +2570,8 @@ write_module_class(ostream &out, Object *obj) { out << " return nullptr;\n"; out << " }\n\n"; + bool have_eq = false; + bool have_ne = false; for (Function *func : obj->_methods) { std::set remaps; if (!func) { @@ -2590,8 +2592,10 @@ write_module_class(ostream &out, Object *obj) { op_type = "Py_LE"; } else if (fname == "operator ==") { op_type = "Py_EQ"; + have_eq = true; } else if (fname == "operator !=") { op_type = "Py_NE"; + have_ne = true; } else if (fname == "operator >") { op_type = "Py_GT"; } else if (fname == "operator >=") { @@ -2616,6 +2620,43 @@ write_module_class(ostream &out, Object *obj) { } if (has_local_richcompare) { + if (have_eq && !have_ne) { + // Generate a not-equal function from the equal function. + for (Function *func : obj->_methods) { + std::set remaps; + if (!func) { + continue; + } + const string &fname = func->_ifunc.get_name(); + if (fname != "operator ==") { + continue; + } + for (FunctionRemap *remap : func->_remaps) { + if (is_remap_legal(remap) && remap->_has_this && (remap->_args_type == AT_single_arg)) { + remaps.insert(remap); + } + } + out << " case Py_NE: // from Py_EQ\n"; + out << " {\n"; + + string expected_params; + write_function_forset(out, remaps, 1, 1, expected_params, 6, true, false, + AT_single_arg, RF_pyobject | RF_invert_bool | RF_err_null, false); + + out << " break;\n"; + out << " }\n"; + } + } + else if (!have_eq && !slots.count("tp_compare")) { + // Generate an equals function. + out << " case Py_EQ:\n"; + out << " return PyBool_FromLong(DtoolInstance_Check(arg) && DtoolInstance_VOID_PTR(self) == DtoolInstance_VOID_PTR(arg));\n"; + if (!have_ne) { + out << " case Py_NE:\n"; + out << " return PyBool_FromLong(!DtoolInstance_Check(arg) || DtoolInstance_VOID_PTR(self) != DtoolInstance_VOID_PTR(arg));\n"; + } + } + // End of switch block out << " }\n\n"; out << " if (_PyErr_OCCURRED()) {\n"; @@ -6048,8 +6089,13 @@ write_function_instance(ostream &out, FunctionRemap *remap, return_flags &= ~RF_pyobject; } else if (return_null && TypeManager::is_bool(remap->_return_type->get_new_type())) { - indent(out, indent_level) - << "return Dtool_Return_Bool(" << return_expr << ");\n"; + if (return_flags & RF_invert_bool) { + indent(out, indent_level) + << "return Dtool_Return_Bool(!(" << return_expr << "));\n"; + } else { + indent(out, indent_level) + << "return Dtool_Return_Bool(" << return_expr << ");\n"; + } return_flags &= ~RF_pyobject; } else if (return_null && TypeManager::is_pointer_to_PyObject(remap->_return_type->get_new_type())) { @@ -6415,7 +6461,12 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, indent(out, indent_level) << "return PyString_FromStringAndSize((char *)return_value.data(), (Py_ssize_t)return_value.size());\n"; out << "#endif\n"; - } else { + } + else if (return_flags & RF_invert_bool) { + indent(out, indent_level) + << "return Dtool_WrapValue(!(" << return_expr << "));\n"; + } + else { indent(out, indent_level) << "return Dtool_WrapValue(" << return_expr << ");\n"; } diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.h b/dtool/src/interrogate/interfaceMakerPythonNative.h index c667ab22fa..b387cf0001 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.h +++ b/dtool/src/interrogate/interfaceMakerPythonNative.h @@ -115,6 +115,9 @@ private: // This raises a KeyError on falsey (or -1) return value. RF_raise_keyerror = 0x4000, + + // Invert boolean return value. + RF_invert_bool = 0x8000, }; class SlottedFunctionDef { From 5d0044a48125a9f4f29d23fcd6125706e7101990 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 16 Sep 2020 23:38:56 +0200 Subject: [PATCH 2/6] tests: Add unit test for RenderEffects comparison --- tests/pgraph/test_rendereffects.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/pgraph/test_rendereffects.py diff --git a/tests/pgraph/test_rendereffects.py b/tests/pgraph/test_rendereffects.py new file mode 100644 index 0000000000..91751fed68 --- /dev/null +++ b/tests/pgraph/test_rendereffects.py @@ -0,0 +1,26 @@ +from panda3d import core + + +def test_rendereffects_compare(): + re1 = core.RenderEffects.make_empty() + re2 = core.RenderEffects.make_empty() + + assert re1 == re1 + assert not (re1 != re1) + assert not (re1 < re1) + assert not (re1 > re1) + + assert re1 == re2 + assert not (re1 != re2) + assert not (re1 < re2) + assert not (re1 > re2) + + assert re1 != 123 + + rd = core.RenderEffects.make(core.DecalEffect.make()) + assert not (re1 == rd) + assert not (rd == re1) + assert re1 != rd + assert rd != re1 + assert re1 < rd or rd < re1 + assert re1 > rd or rd > re1 From 4b7e32e9b0bb5a89ba2a0057f10b3e9314e69826 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 16 Sep 2020 23:39:13 +0200 Subject: [PATCH 3/6] egldisplay: Fix bad use of X11 None symbol instead of nullptr --- panda/src/egldisplay/eglGraphicsBuffer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/egldisplay/eglGraphicsBuffer.cxx b/panda/src/egldisplay/eglGraphicsBuffer.cxx index a0cf71f1fa..7319f25430 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.cxx +++ b/panda/src/egldisplay/eglGraphicsBuffer.cxx @@ -172,7 +172,7 @@ open_buffer() { } } - if (eglgsg->_fbconfig == None) { + if (eglgsg->_fbconfig == nullptr) { // If we didn't use an fbconfig to create the GSG, we can't create a // PBuffer. return false; From 5443f6206834cb9a95ba974756314f69ceea5d87 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 2 Oct 2020 01:25:45 +0300 Subject: [PATCH 4/6] makepanda: Add missing YY_NO_UNISTD_H to built Flex sources Closes #1028 --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index c00a6203b1..bcdca0bea0 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1643,7 +1643,7 @@ def CompileFlex(wobj,wsrc,opts): oscmd(flex + " -P" + pre + " -o"+wdst+" "+wsrc) # Finally, compile the generated source file. - CompileCxx(wobj,wdst,opts) + CompileCxx(wobj, wdst, opts + ["FLEX"]) ######################################################################## ## From 0e70fcf1ef367c11c6983fbe5afc54e2f31065f9 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 2 Oct 2020 12:13:19 +0200 Subject: [PATCH 5/6] Bump version number on release/1.10.x branch to 1.10.8 --- dtool/PandaVersion.pp | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dtool/PandaVersion.pp b/dtool/PandaVersion.pp index c8fd21da65..d783d0496a 100644 --- a/dtool/PandaVersion.pp +++ b/dtool/PandaVersion.pp @@ -7,7 +7,7 @@ // place to put this. // Use spaces to separate the major, minor, and sequence numbers here. -#define PANDA_VERSION 1 10 7 +#define PANDA_VERSION 1 10 8 // This variable will be defined to false in the CVS repository, but // scripts that generate source tarballs and/or binary releases for diff --git a/setup.cfg b/setup.cfg index 6fc504b43a..3addb096a0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = Panda3D -version = 1.10.7 +version = 1.10.8 url = https://www.panda3d.org/ description = Panda3D is a framework for 3D rendering and game development for Python and C++ programs. license = Modified BSD License From b507c88cd9fd5d3a432aae42fdc9165422a527b4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 2 Oct 2020 01:53:33 +0300 Subject: [PATCH 6/6] directtools: Fix empty scaling node of object handle Closes #1029 --- direct/src/directtools/DirectManipulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/direct/src/directtools/DirectManipulation.py b/direct/src/directtools/DirectManipulation.py index d7aeb1ee3b..8a07b14702 100644 --- a/direct/src/directtools/DirectManipulation.py +++ b/direct/src/directtools/DirectManipulation.py @@ -1066,7 +1066,7 @@ class ObjectHandles(NodePath, DirectObject): # Load up object handles model and assign it to self self.assign(loader.loadModel('models/misc/objectHandles')) self.setName(name) - self.scalingNode = NodePath(self) + self.scalingNode = self.getChild(0) self.scalingNode.setName('ohScalingNode') self.ohScalingFactor = 1.0 self.directScalingFactor = 1.0