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 diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index da19170534..d719d3b549 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2594,6 +2594,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) { @@ -2614,8 +2616,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 >=") { @@ -2640,6 +2644,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"; @@ -6082,8 +6123,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())) { @@ -6438,9 +6484,14 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, TypeManager::is_vector_unsigned_char(type)) { // Most types are now handled by the many overloads of Dtool_WrapValue, // defined in py_panda.h. - indent(out, indent_level) - << "return Dtool_WrapValue(" << return_expr << ");\n"; - + 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"; + } } else if (TypeManager::is_pointer(type)) { bool is_const = TypeManager::is_const_pointer_to_anything(type); bool owns_memory = remap->_return_value_needs_management; 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 { diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 588d400b1e..b792b0cf1e 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1434,7 +1434,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"]) ######################################################################## ## diff --git a/panda/src/egldisplay/eglGraphicsBuffer.cxx b/panda/src/egldisplay/eglGraphicsBuffer.cxx index ba1048b23a..2cfbff83b4 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; 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