From 426fdf08424414464176c26c712a0afcbcf596a9 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 31 Mar 2015 22:34:28 +0200 Subject: [PATCH] Fix issue where overloads with invalid default arg types weren't exported at all --- .../interfaceMakerPythonNative.cxx | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 0835387141..a35f8c0fb4 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -4475,15 +4475,23 @@ write_function_instance(ostream &out, FunctionRemap *remap, // Now convert (the rest of the) actual arguments, one by one. for (; pn < num_params; ++pn) { - if (pn > 0) { - expected_params += ", "; + ParameterRemap *param = remap->_parameters[pn]._remap; + CPPType *orig_type = param->get_orig_type(); + CPPType *type = param->get_new_type(); + CPPExpression *default_value = param->get_default_value(); + string param_name = remap->get_parameter_name(pn); + + if (!is_cpp_type_legal(orig_type)) { + // We can't wrap this. We sometimes get here for default arguments. + // Just skip this parameter. + continue; } - bool is_optional = false; // Has this remap been selected to consider optional arguments for // this parameter? We can do that by adding a vertical bar to the // PyArg_ParseTuple format string, coupled with some extra logic // in the argument handling, below. + bool is_optional = false; if (remap->_has_this && !is_constructor) { if (pn > min_num_args) { is_optional = true; @@ -4500,11 +4508,9 @@ write_function_instance(ostream &out, FunctionRemap *remap, } } - ParameterRemap *param = remap->_parameters[pn]._remap; - CPPType *orig_type = param->get_orig_type(); - CPPType *type = param->get_new_type(); - CPPExpression *default_value = param->get_default_value(); - string param_name = remap->get_parameter_name(pn); + if (pn > 0) { + expected_params += ", "; + } // This is the string to convert our local variable to the // appropriate C++ type. Normally this is just a cast. @@ -6432,10 +6438,11 @@ is_remap_legal(FunctionRemap *remap) { return false; } - // all params must be legal + // all non-optional params must be legal for (int pn = 0; pn < (int)remap->_parameters.size(); pn++) { - CPPType *orig_type = remap->_parameters[pn]._remap->get_orig_type(); - if (!is_cpp_type_legal(orig_type)) { + ParameterRemap *param = remap->_parameters[pn]._remap; + CPPType *orig_type = param->get_orig_type(); + if (param->get_default_value() == NULL && !is_cpp_type_legal(orig_type)) { return false; } }