From f477db0b196decd59764e48fdec4d553ef77b5eb Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 20 Jan 2009 19:51:31 +0000 Subject: [PATCH] might as well expose int and float typecasts, too --- .../interfaceMakerPythonNative.cxx | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index ca0c5bbb8e..23c125b31a 100755 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -561,12 +561,27 @@ get_slotted_function_def(Object *obj, Function *func, SlottedFunctionDef &def) { } if (func->_ifunc.is_operator_typecast()) { - // A typecast operator. If it's a bool type, then we wrap it with - // the __nonzero__ slot method. - if (!func->_remaps.empty() && TypeManager::is_bool(func->_remaps[0]->_return_type->get_orig_type())) { - def._answer_location = "tp_as_number->nb_nonzero"; - def._wrapper_type = WT_inquiry; - return true; + // A typecast operator. Check for a supported low-level typecast type. + if (!func->_remaps.empty()) { + if (TypeManager::is_bool(func->_remaps[0]->_return_type->get_orig_type())) { + // If it's a bool type, then we wrap it with the __nonzero__ + // slot method. + def._answer_location = "tp_as_number->nb_nonzero"; + def._wrapper_type = WT_inquiry; + return true; + + } else if (TypeManager::is_integer(func->_remaps[0]->_return_type->get_orig_type())) { + // An integer type. + def._answer_location = "tp_as_number->nb_int"; + def._wrapper_type = WT_no_params; + return true; + + } else if (TypeManager::is_float(func->_remaps[0]->_return_type->get_orig_type())) { + // A floating-point (or double) type. + def._answer_location = "tp_as_number->nb_float"; + def._wrapper_type = WT_no_params; + return true; + } } }