Merge branch 'release/1.10.x'

This commit is contained in:
rdb 2020-10-02 12:20:58 +02:00
commit c788912070
6 changed files with 88 additions and 8 deletions

View File

@ -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

View File

@ -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<FunctionRemap*> 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<FunctionRemap*> 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;

View File

@ -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 {

View File

@ -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"])
########################################################################
##

View File

@ -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;

View File

@ -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