respect __nonzero__

This commit is contained in:
David Rose 2009-08-05 21:51:28 +00:00
parent 9f9316ff81
commit 0e773c8684

View File

@ -67,14 +67,14 @@ RenameSet methodRenameDictionary[] = {
{ "operator =" , "assign", 0 },
{ "operator ()" , "__call__", 0 },
{ "operator []" , "__getitem__", 0 },
{ "operator ++unary" , "increment", 0 },
{ "operator ++unary", "increment", 0 },
{ "operator ++" , "increment", 0 },
{ "operator --unary" , "decrement", 0 },
{ "operator --unary", "decrement", 0 },
{ "operator --" , "decrement", 0 },
{ "operator ^" , "__xor__", 0 },
{ "operator %" , "__mod__", 0 },
{ "operator !" , "logicalNot", 0 },
{ "operator ~unary" , "__invert__", 0 },
{ "operator ~unary", "__invert__", 0 },
{ "operator &" , "__and__", 0 },
{ "operator &&" , "logicalAnd", 0 },
{ "operator |" , "__or__", 0 },
@ -96,9 +96,10 @@ RenameSet methodRenameDictionary[] = {
{ "operator ->" , "dereference", 0 },
{ "operator <<=" , "__ilshift__", 1 },
{ "operator >>=" , "__irshift__", 1 },
{ "operator typecast bool" , "__nonzero__", 0 },
{ "operator typecast bool", "__nonzero__", 0 },
{ "__nonzero__" , "__nonzero__", 0 },
{ "print" , "Cprint", 0 },
{ "CInterval.set_t" , "_priv__cSetT", 0 },
{ "CInterval.set_t", "_priv__cSetT", 0 },
{ NULL, NULL, -1 }
};
@ -558,6 +559,12 @@ get_slotted_function_def(Object *obj, Function *func, SlottedFunctionDef &def) {
return true;
}
if (method_name == "__nonzero__") {
def._answer_location = "tp_as_number->nb_nonzero";
def._wrapper_type = WT_inquiry;
return true;
}
if (func->_ifunc.is_operator_typecast()) {
// A typecast operator. Check for a supported low-level typecast type.
if (!func->_remaps.empty()) {