diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index 60bf2d5753..811fb37f02 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -450,58 +450,60 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { _functions.push_back(func); // Now get all the valid FunctionRemaps for the function. - InterrogateFunction::Instances::const_iterator ii; - for (ii = ifunc._instances.begin(); - ii != ifunc._instances.end(); - ++ii) { - CPPInstance *cppfunc = (*ii).second; - CPPFunctionType *ftype = cppfunc->_type->as_function_type(); - int max_default_parameters = 0; - - if (separate_overloading()) { - // Count up the number of default parameters this function might - // take. - CPPParameterList *parameters = ftype->_parameters; - CPPParameterList::Parameters::reverse_iterator pi; - for (pi = parameters->_parameters.rbegin(); - pi != parameters->_parameters.rend(); - ++pi) { - CPPInstance *param = (*pi); - if (param->_initializer != (CPPExpression *)NULL) { - // This parameter has a default value. - max_default_parameters++; - } else { - // The first parameter without a default value ends the search. - break; + if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + InterrogateFunction::Instances::const_iterator ii; + for (ii = ifunc._instances->begin(); + ii != ifunc._instances->end(); + ++ii) { + CPPInstance *cppfunc = (*ii).second; + CPPFunctionType *ftype = cppfunc->_type->as_function_type(); + int max_default_parameters = 0; + + if (separate_overloading()) { + // Count up the number of default parameters this function might + // take. + CPPParameterList *parameters = ftype->_parameters; + CPPParameterList::Parameters::reverse_iterator pi; + for (pi = parameters->_parameters.rbegin(); + pi != parameters->_parameters.rend(); + ++pi) { + CPPInstance *param = (*pi); + if (param->_initializer != (CPPExpression *)NULL) { + // This parameter has a default value. + max_default_parameters++; + } else { + // The first parameter without a default value ends the search. + break; + } } } - } - - // Now make a different wrapper for each combination of default - // parameters. This will happen only if separate_overloading(), - // tested above, returned true; otherwise, max_default_parameters - // will be 0 and the loop will only be traversed once. - for (int num_default_parameters = 0; - num_default_parameters <= max_default_parameters; - num_default_parameters++) { - FunctionRemap *remap = - make_function_remap(itype, ifunc, cppfunc, num_default_parameters); - if (remap != (FunctionRemap *)NULL) { - func->_remaps.push_back(remap); - - // If *any* of the variants of this function has a "this" - // pointer, the entire set of functions is deemed to have a - // "this" pointer. - if (remap->_has_this) { - func->_has_this = true; - } - - // Make a wrapper for the function. - FunctionWrapperIndex wrapper_index = - remap->make_wrapper_entry(func_index); - if (wrapper_index != 0) { - InterrogateFunction &mod_ifunc = idb->update_function(func_index); - record_function_wrapper(mod_ifunc, wrapper_index); + + // Now make a different wrapper for each combination of default + // parameters. This will happen only if separate_overloading(), + // tested above, returned true; otherwise, max_default_parameters + // will be 0 and the loop will only be traversed once. + for (int num_default_parameters = 0; + num_default_parameters <= max_default_parameters; + num_default_parameters++) { + FunctionRemap *remap = + make_function_remap(itype, ifunc, cppfunc, num_default_parameters); + if (remap != (FunctionRemap *)NULL) { + func->_remaps.push_back(remap); + + // If *any* of the variants of this function has a "this" + // pointer, the entire set of functions is deemed to have a + // "this" pointer. + if (remap->_has_this) { + func->_has_this = true; + } + + // Make a wrapper for the function. + FunctionWrapperIndex wrapper_index = + remap->make_wrapper_entry(func_index); + if (wrapper_index != 0) { + InterrogateFunction &mod_ifunc = idb->update_function(func_index); + record_function_wrapper(mod_ifunc, wrapper_index); + } } } } diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index e7d6a2c6e2..eda54a18b1 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -1559,7 +1559,7 @@ get_function(CPPInstance *function, string description, } // Also, make sure this particular signature is defined. - ifunction._instances.insert(InterrogateFunction::Instances::value_type(function_signature, function)); + ifunction._instances->insert(InterrogateFunction::Instances::value_type(function_signature, function)); return index; } @@ -1572,6 +1572,7 @@ get_function(CPPInstance *function, string description, InterrogateFunction *ifunction = new InterrogateFunction; ifunction->_name = function->get_local_name(scope); ifunction->_scoped_name = descope(function->get_local_name(&parser)); + ifunction->_instances = new InterrogateFunction::Instances; if (function->_leading_comment != (CPPCommentBlock *)NULL) { ifunction->_comment = trim_blanks(function->_leading_comment->_comment); @@ -1589,7 +1590,7 @@ get_function(CPPInstance *function, string description, } ifunction->_flags |= flags; - ifunction->_instances.insert(InterrogateFunction::Instances::value_type(function_signature, function)); + ifunction->_instances->insert(InterrogateFunction::Instances::value_type(function_signature, function)); ifunction->_expression = expression; InterrogateDatabase::get_ptr()->add_function(index, ifunction); diff --git a/dtool/src/interrogatedb/interrogateFunction.I b/dtool/src/interrogatedb/interrogateFunction.I index 0d9b4bfafc..5bd0174628 100644 --- a/dtool/src/interrogatedb/interrogateFunction.I +++ b/dtool/src/interrogatedb/interrogateFunction.I @@ -28,6 +28,7 @@ InterrogateFunction(InterrogateModuleDef *def) : { _flags = 0; _class = 0; + _instances = (Instances *)NULL; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/interrogatedb/interrogateFunction.h b/dtool/src/interrogatedb/interrogateFunction.h index 4e131d18d0..0587d5bde2 100644 --- a/dtool/src/interrogatedb/interrogateFunction.h +++ b/dtool/src/interrogatedb/interrogateFunction.h @@ -91,8 +91,11 @@ public: // session of interrogate that generates the database, and will not // be filled in when the database is reloaded from disk. + // This must be a pointer, rather than a concrete map, so we don't + // risk trying to create a map in one DLL and access it in another. + // Silly Windows. typedef map Instances; - Instances _instances; + Instances *_instances; string _expression; friend class InterrogateBuilder;