diff --git a/dtool/src/prc/configVariableBase.I b/dtool/src/prc/configVariableBase.I index aea916b51d..92018bd791 100644 --- a/dtool/src/prc/configVariableBase.I +++ b/dtool/src/prc/configVariableBase.I @@ -28,7 +28,9 @@ ConfigVariableBase(const string &name, ConfigVariableBase::ValueType value_type) : _core(ConfigVariableManager::get_global_ptr()->make_variable(name)) { - _core->set_value_type(value_type); + if (value_type != VT_undefined) { + _core->set_value_type(value_type); + } } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableBase.cxx b/dtool/src/prc/configVariableBase.cxx index 3acc1d0f76..372d82953b 100644 --- a/dtool/src/prc/configVariableBase.cxx +++ b/dtool/src/prc/configVariableBase.cxx @@ -30,7 +30,9 @@ ConfigVariableBase(const string &name, const string &description, int flags) : _core(ConfigVariableManager::get_global_ptr()->make_variable(name)) { - _core->set_value_type(value_type); + if (value_type != VT_undefined) { + _core->set_value_type(value_type); + } if (flags != 0) { _core->set_flags(flags); } diff --git a/dtool/src/prc/configVariableCore.cxx b/dtool/src/prc/configVariableCore.cxx index df76154fc8..4d473cddba 100644 --- a/dtool/src/prc/configVariableCore.cxx +++ b/dtool/src/prc/configVariableCore.cxx @@ -340,6 +340,10 @@ write(ostream &out) const { out << " " << *(*di) << " (from " << (*di)->get_page()->get_name() << ", untrusted)\n"; } + + if (!_description.empty()) { + out << "\n" << _description << "\n"; + } } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableManager.cxx b/dtool/src/prc/configVariableManager.cxx index 6a180bf85a..dd6d8a6edc 100644 --- a/dtool/src/prc/configVariableManager.cxx +++ b/dtool/src/prc/configVariableManager.cxx @@ -117,20 +117,14 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// void ConfigVariableManager:: write(ostream &out) const { - out << "ConfigVariableManager, " << _variables.size() << " variables:\n"; VariablesByName::const_iterator ni; for (ni = _variables_by_name.begin(); ni != _variables_by_name.end(); ++ni) { ConfigVariableCore *variable = (*ni).second; - if (!variable->is_dynamic()) { - out << " " << variable->get_name(); - if (!variable->is_used()) { - out << " (not used)"; - } else { - out << " " << variable->get_declaration(0)->get_string_value(); - } - out << "\n"; + if (variable->get_num_trusted_references() != 0 || + variable->has_local_value()) { + list_variable(variable, false); } } } @@ -175,7 +169,7 @@ list_variables() const { ++ni) { const ConfigVariableCore *variable = (*ni).second; if (variable->is_used() && !variable->is_dynamic()) { - list_variable(variable); + list_variable(variable, true); } } } @@ -197,7 +191,7 @@ list_dynamic_variables() const { ++ni) { const ConfigVariableCore *variable = (*ni).second; if (variable->is_used() && variable->is_dynamic()) { - list_variable(variable); + list_variable(variable, false); } } } @@ -221,44 +215,64 @@ get_global_ptr() { // Description: Lists a single variable and its value. //////////////////////////////////////////////////////////////////// void ConfigVariableManager:: -list_variable(const ConfigVariableCore *variable) const { - nout << variable->get_name() << " " - << variable->get_value_type() << "\n"; - - const ConfigDeclaration *decl; - - if (variable->get_value_type() == ConfigVariableCore::VT_list) { - // We treat a "list" variable as a special case: list all of - // its values. - nout << " current value =\n"; - int num_references = variable->get_num_trusted_references(); - for (int i = 0; i < num_references; i++) { - decl = variable->get_trusted_reference(i); - nout << " " << decl->get_string_value() - << " (from " << decl->get_page()->get_name() << ")\n"; +list_variable(const ConfigVariableCore *variable, + bool include_descriptions) const { + if (!variable->is_used()) { + // If the variable is unused, just show its name. + nout << variable->get_name() << " not used"; + if (variable->get_num_references() > 0) { + nout << " (referenced in " + << variable->get_reference(0)->get_page()->get_name() + << ")"; } - + nout << "\n"; + } else { - // An ordinary, non-list variable gets one line for its - // current value (if it has one) and another line for its - // default value. - decl = variable->get_declaration(0); - if (decl != variable->get_default_value()) { - nout << " current value = " << decl->get_string_value(); - if (!decl->get_page()->is_special()) { - nout << " (from " << decl->get_page()->get_name() << ")\n"; - } else { - nout << " (defined locally)\n"; + // If the variable is used--it's been defined somewhere--show its + // name, its type, its current and default values, and if + // available, its description. + + nout << variable->get_name() << " " + << variable->get_value_type() << "\n"; + + const ConfigDeclaration *decl; + + if (variable->get_value_type() == ConfigVariableCore::VT_list || + variable->get_value_type() == ConfigVariableCore::VT_search_path) { + // We treat a "list" variable as a special case: list all of + // its values. + nout << " current value =\n"; + int num_references = variable->get_num_trusted_references(); + for (int i = 0; i < num_references; i++) { + decl = variable->get_trusted_reference(i); + nout << " " << decl->get_string_value() + << " (from " << decl->get_page()->get_name() << ")\n"; + } + + } else { + // An ordinary, non-list variable gets one line for its + // current value (if it has one) and another line for its + // default value. + decl = variable->get_declaration(0); + if (decl != variable->get_default_value()) { + nout << " current value = " << decl->get_string_value(); + if (!decl->get_page()->is_special()) { + nout << " (from " << decl->get_page()->get_name() << ")\n"; + } else { + nout << " (defined locally)\n"; + } + } + + decl = variable->get_default_value(); + if (decl != (ConfigDeclaration *)NULL) { + nout << " default value = " << decl->get_string_value() << "\n"; } } - decl = variable->get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { - nout << " default value = " << decl->get_string_value() << "\n"; + if (!variable->get_description().empty() && include_descriptions) { + nout << " " << variable->get_description() << "\n"; } } - - if (!variable->get_description().empty()) { - nout << " " << variable->get_description() << "\n"; - } + + nout << "\n"; } diff --git a/dtool/src/prc/configVariableManager.h b/dtool/src/prc/configVariableManager.h index ac03b6bb8f..c05727ec9e 100644 --- a/dtool/src/prc/configVariableManager.h +++ b/dtool/src/prc/configVariableManager.h @@ -55,7 +55,8 @@ PUBLISHED: static ConfigVariableManager *get_global_ptr(); private: - void list_variable(const ConfigVariableCore *variable) const; + void list_variable(const ConfigVariableCore *variable, + bool include_descriptions) const; typedef pvector Variables; Variables _variables;