Mercurial > flash_v2
comparison host/libcdl/config.cxx @ 82:6736c52df507 ecos-sw-2000-04-14
Merge from eCos master repository on 2000-04-14-13:35:46-BST
| author | jlarmour |
|---|---|
| date | Tue, 18 Apr 2000 21:51:55 +0000 |
| parents | 435cced73e2f |
| children | b15c60e34c84 |
comparison
equal
deleted
inserted
replaced
| 81:89fef2181d7d | 82:6736c52df507 |
|---|---|
| 748 const std::vector<std::string>& versions = database->get_package_versions(name); | 748 const std::vector<std::string>& versions = database->get_package_versions(name); |
| 749 if ("" == version) { | 749 if ("" == version) { |
| 750 version = *(versions.begin()); | 750 version = *(versions.begin()); |
| 751 } else { | 751 } else { |
| 752 if (std::find(versions.begin(), versions.end(), version) == versions.end()) { | 752 if (std::find(versions.begin(), versions.end(), version) == versions.end()) { |
| 753 throw CdlInputOutputException("Package " + name + " does not have an installed version " + version); | 753 throw CdlInputOutputException("Package " + name + " does not have an installed version `" + version + "'."); |
| 754 } | 754 } |
| 755 } | 755 } |
| 756 std::string directory = database->get_package_directory(name); | 756 std::string directory = database->get_package_directory(name); |
| 757 std::string script = database->get_package_script(name); | 757 std::string script = database->get_package_script(name); |
| 758 CYG_ASSERTC(("" != directory) && ("" != script)); | 758 CYG_ASSERTC(("" != directory) && ("" != script)); |
| 763 CYG_ASSERT_CLASSC(interp); | 763 CYG_ASSERT_CLASSC(interp); |
| 764 | 764 |
| 765 std::string tcl_cmd = "regsub -all -- {\\\\} [file join " + directory + " " + version + "] / result; return $result"; | 765 std::string tcl_cmd = "regsub -all -- {\\\\} [file join " + directory + " " + version + "] / result; return $result"; |
| 766 std::string tcl_result; | 766 std::string tcl_result; |
| 767 if (TCL_OK != interp->eval(tcl_cmd, tcl_result)) { | 767 if (TCL_OK != interp->eval(tcl_cmd, tcl_result)) { |
| 768 throw CdlInputOutputException("Cannot load package " + name + ", internal error constructing pathname"); | 768 throw CdlInputOutputException("Cannot load package `" + name + "', internal error constructing pathname."); |
| 769 } | 769 } |
| 770 directory = tcl_result; | 770 directory = tcl_result; |
| 771 | 771 |
| 772 tcl_cmd = "file isdirectory [file join \"" + database->get_component_repository() + "\" " + directory + "]"; | 772 tcl_cmd = "file isdirectory [file join \"" + database->get_component_repository() + "\" " + directory + "]"; |
| 773 if ((TCL_OK != interp->eval(tcl_cmd, tcl_result)) || ("1" != tcl_result)) { | 773 if ((TCL_OK != interp->eval(tcl_cmd, tcl_result)) || ("1" != tcl_result)) { |
| 774 throw CdlInputOutputException("Cannot load package " + name + ", there is no directory " + directory); | 774 throw CdlInputOutputException("Cannot load package `" + name + "', there is no directory `" + directory + "'."); |
| 775 } | 775 } |
| 776 | 776 |
| 777 // Make sure that there is no name conflict. No resources have been allocated | 777 // Make sure that there is no name conflict. No resources have been allocated |
| 778 // yet, so this is a good time. | 778 // yet, so this is a good time. |
| 779 CdlNode node = lookup(name); | 779 CdlNode node = lookup(name); |
| 780 if (0 != node) { | 780 if (0 != node) { |
| 781 if (0 != dynamic_cast<CdlPackage>(node)) { | 781 if (0 != dynamic_cast<CdlPackage>(node)) { |
| 782 throw CdlInputOutputException("Package " + name + " is already loaded"); | 782 throw CdlInputOutputException("Package `" + name + "' is already loaded."); |
| 783 } else { | 783 } else { |
| 784 | 784 |
| 785 std::string msg = "Name clash for package " + name + ",there is a " + | 785 std::string msg = "Name clash for package `" + name + "',there is a `" + |
| 786 node->get_class_name() + " " + name + " already loaded"; | 786 node->get_class_name() + " " + name + "' already loaded"; |
| 787 CdlLoadable owner_pkg = node->get_owner(); | 787 CdlLoadable owner_pkg = node->get_owner(); |
| 788 if (0 != owner_pkg) { | 788 if (0 != owner_pkg) { |
| 789 msg += " in package " + owner_pkg->get_name(); | 789 msg += " in package " + owner_pkg->get_name(); |
| 790 } | 790 } |
| 791 throw CdlInputOutputException(msg); | 791 throw CdlInputOutputException(msg); |
| 792 } | 792 } |
| 793 } | 793 } |
| 794 | 794 |
| 795 // Now create the package object itself. | 795 // Now create the package object itself. |
| 796 CdlPackage package = 0; | 796 CdlPackage package = 0; |
| 797 bool bound = false; | 797 bool bound = false; |
| 798 CdlConfiguration_CommitCancelLoad* load_op = 0; | 798 CdlConfiguration_CommitCancelLoad* load_op = 0; |
| 799 | 799 |
| 823 if ((TCL_OK != interp->eval(tcl_cmd, tcl_result)) || ("1" != tcl_result)) { | 823 if ((TCL_OK != interp->eval(tcl_cmd, tcl_result)) || ("1" != tcl_result)) { |
| 824 throw CdlInputOutputException("Package " + name + ", " + actual_script + " is not a CDL script"); | 824 throw CdlInputOutputException("Package " + name + ", " + actual_script + " is not a CDL script"); |
| 825 } | 825 } |
| 826 | 826 |
| 827 // The script is valid. Set up the interpreter appropriately. | 827 // The script is valid. Set up the interpreter appropriately. |
| 828 CdlContainer old_container = interp->push_container(package); | |
| 829 std::string old_filename = interp->push_filename(actual_script); | |
| 830 CdlDiagnosticFnPtr old_error_fn = interp->push_error_fn_ptr(error_fn); | |
| 831 CdlDiagnosticFnPtr old_warn_fn = interp->push_warning_fn_ptr(warn_fn); | |
| 832 CdlParse::clear_error_count(interp); | 828 CdlParse::clear_error_count(interp); |
| 833 | |
| 834 static CdlInterpreterCommandEntry commands[] = | 829 static CdlInterpreterCommandEntry commands[] = |
| 835 { | 830 { |
| 836 CdlInterpreterCommandEntry("cdl_package", &CdlPackageBody::parse_package ), | 831 CdlInterpreterCommandEntry("cdl_package", &CdlPackageBody::parse_package ), |
| 837 CdlInterpreterCommandEntry("cdl_component", &CdlComponentBody::parse_component ), | 832 CdlInterpreterCommandEntry("cdl_component", &CdlComponentBody::parse_component ), |
| 838 CdlInterpreterCommandEntry("cdl_option", &CdlOptionBody::parse_option ), | 833 CdlInterpreterCommandEntry("cdl_option", &CdlOptionBody::parse_option ), |
| 839 CdlInterpreterCommandEntry("cdl_interface", &CdlInterfaceBody::parse_interface ), | 834 CdlInterpreterCommandEntry("cdl_interface", &CdlInterfaceBody::parse_interface ), |
| 840 CdlInterpreterCommandEntry("cdl_dialog", &CdlDialogBody::parse_dialog ), | 835 CdlInterpreterCommandEntry("cdl_dialog", &CdlDialogBody::parse_dialog ), |
| 841 CdlInterpreterCommandEntry("cdl_wizard", &CdlWizardBody::parse_wizard ), | 836 CdlInterpreterCommandEntry("cdl_wizard", &CdlWizardBody::parse_wizard ), |
| 842 CdlInterpreterCommandEntry("", 0 ) | 837 CdlInterpreterCommandEntry("", 0 ) |
| 843 }; | 838 }; |
| 844 std::vector<CdlInterpreterCommandEntry> new_commands; | 839 CdlInterpreterBody::CommandSupport interp_cmds(interp, commands); |
| 845 for (int i = 0; 0 != commands[i].command; i++) { | 840 CdlInterpreterBody::ContainerSupport interp_container(interp, package); |
| 846 new_commands.push_back(commands[i]); | 841 CdlInterpreterBody::ContextSupport interp_context(interp, actual_script); |
| 847 } | |
| 848 std::vector<CdlInterpreterCommandEntry>* old_commands = interp->push_commands(new_commands); | |
| 849 | 842 |
| 850 // The interpreter is now ready. | 843 // The interpreter is now ready. |
| 851 if (TCL_OK != interp->eval_file(actual_script, tcl_result)) { | 844 (void) interp->eval_file(actual_script); |
| 852 throw CdlInputOutputException("Package " + name + ", error executing CDL script.\n" + tcl_result); | |
| 853 } | |
| 854 | 845 |
| 855 // Clean out the commands etc. This interpreter may get used again | 846 // Clean out the commands etc. This interpreter may get used again |
| 856 // in future, and it should not be possible to define new options | 847 // in future, and it should not be possible to define new options |
| 857 // etc. in that invocation. | 848 // etc. in that invocation. |
| 858 interp->remove_command("unknown"); | 849 interp->remove_command("unknown"); |
| 859 interp->pop_commands(old_commands); | |
| 860 interp->pop_container(old_container); | |
| 861 interp->pop_filename(old_filename); | |
| 862 interp->pop_error_fn_ptr(old_error_fn); | |
| 863 interp->pop_warning_fn_ptr(old_warn_fn); | |
| 864 | 850 |
| 865 // All the data has been read in without generating an | 851 // All the data has been read in without generating an |
| 866 // exception. However there may have been errors reported via | 852 // exception. However there may have been errors reported via |
| 867 // the parse_error_fn, and any errors at all should result | 853 // the parse_error_fn, and any errors at all should result |
| 868 // in an exception. | 854 // in an exception. |
| 1057 CYG_REPORT_FUNCNAME("CdlConfiguration::set_hardware"); | 1043 CYG_REPORT_FUNCNAME("CdlConfiguration::set_hardware"); |
| 1058 CYG_REPORT_FUNCARG2XV(this, transaction); | 1044 CYG_REPORT_FUNCARG2XV(this, transaction); |
| 1059 CYG_PRECONDITION_THISC(); | 1045 CYG_PRECONDITION_THISC(); |
| 1060 CYG_PRECONDITION_CLASSC(transaction); | 1046 CYG_PRECONDITION_CLASSC(transaction); |
| 1061 | 1047 |
| 1062 // Minimal consistency check before | 1048 // Minimal consistency check before attempting anything complicated. |
| 1063 if (!database->is_known_target(target_name)) { | 1049 if (!database->is_known_target(target_name)) { |
| 1064 throw CdlInputOutputException("Unknown target " + target_name); | 1050 throw CdlInputOutputException("Unknown target " + target_name); |
| 1065 } | 1051 } |
| 1066 | 1052 |
| 1067 int i; | 1053 CdlInterpreter interp = this->get_interpreter(); |
| 1054 CdlInterpreterBody::DiagSupport diag_support(interp, error_fn, warn_fn); | |
| 1055 CdlInterpreterBody::ContextSupport context_support(interp, "Hardware selection"); | |
| 1056 | |
| 1068 CdlConfiguration_CommitCancelHardwareName* rename_op = new CdlConfiguration_CommitCancelHardwareName(current_hardware); | 1057 CdlConfiguration_CommitCancelHardwareName* rename_op = new CdlConfiguration_CommitCancelHardwareName(current_hardware); |
| 1069 try { | 1058 try { |
| 1070 transaction->add_commit_cancel_op(rename_op); | 1059 transaction->add_commit_cancel_op(rename_op); |
| 1071 const std::vector<CdlLoadable>& loadables = this->get_loadables(); | 1060 const std::vector<CdlLoadable>& loadables = this->get_loadables(); |
| 1061 int i; | |
| 1072 for (i = (int) loadables.size() - 1; i >= 0; i--) { | 1062 for (i = (int) loadables.size() - 1; i >= 0; i--) { |
| 1073 CdlPackage package = dynamic_cast<CdlPackage>(loadables[i]); | 1063 CdlPackage package = dynamic_cast<CdlPackage>(loadables[i]); |
| 1074 if ((0 != package) && package->belongs_to_hardware()) { | 1064 if ((0 != package) && package->belongs_to_hardware()) { |
| 1075 this->unload_package(transaction, package, limbo); | 1065 this->unload_package(transaction, package, limbo); |
| 1076 } | 1066 } |
| 1080 if ("" != target_name) { | 1070 if ("" != target_name) { |
| 1081 | 1071 |
| 1082 const std::vector<std::string>& packages = database->get_target_packages(target_name); | 1072 const std::vector<std::string>& packages = database->get_target_packages(target_name); |
| 1083 std::vector<std::string>::const_iterator name_i; | 1073 std::vector<std::string>::const_iterator name_i; |
| 1084 for (name_i = packages.begin(); name_i != packages.end(); name_i++) { | 1074 for (name_i = packages.begin(); name_i != packages.end(); name_i++) { |
| 1085 // It is possible for a hardware package to have been | 1075 // Target specifications may refer to packages that are not |
| 1086 // loaded separately, in which case there is no point in | 1076 // installed. This is useful in e.g. an anoncvs environment. |
| 1087 // loading it again. | 1077 if (database->is_known_package(*name_i)) { |
| 1088 CYG_ASSERTC(database->is_known_package(*name_i)); | 1078 // It is possible for a hardware package to have been |
| 1089 if (0 == this->lookup(*name_i)) { | 1079 // loaded separately, in which case there is no point in |
| 1090 this->load_package(transaction, *name_i, "", error_fn, warn_fn, limbo); | 1080 // loading it again. |
| 1091 CdlPackage package = dynamic_cast<CdlPackage>(this->lookup(*name_i)); | 1081 if (0 == this->lookup(*name_i)) { |
| 1092 CYG_LOOP_INVARIANT_CLASSC(package); | 1082 this->load_package(transaction, *name_i, "", |
| 1093 package->loaded_for_hardware = true; | 1083 error_fn, warn_fn, limbo); |
| 1084 CdlPackage package = dynamic_cast<CdlPackage>(this->lookup(*name_i)); | |
| 1085 CYG_LOOP_INVARIANT_CLASSC(package); | |
| 1086 package->loaded_for_hardware = true; | |
| 1087 } | |
| 1088 } else { | |
| 1089 CdlParse::report_warning(interp, "", | |
| 1090 std::string("The target specification lists a package `") + *name_i + | |
| 1091 "' which is not present in the component repository."); | |
| 1094 } | 1092 } |
| 1095 } | 1093 } |
| 1096 } | 1094 } |
| 1097 current_hardware = target_name; | 1095 current_hardware = target_name; |
| 1098 | 1096 |
| 1120 CdlNode node; | 1118 CdlNode node; |
| 1121 CdlValuable valuable; | 1119 CdlValuable valuable; |
| 1122 CdlValueFlavor flavor; | 1120 CdlValueFlavor flavor; |
| 1123 | 1121 |
| 1124 for (opt_i = enables.begin(); opt_i != enables.end(); opt_i++) { | 1122 for (opt_i = enables.begin(); opt_i != enables.end(); opt_i++) { |
| 1123 valuable = 0; | |
| 1124 node = this->lookup(*opt_i); | |
| 1125 if (0 != node) { | |
| 1126 valuable = dynamic_cast<CdlValuable>(node); | |
| 1127 if (0 != valuable) { | |
| 1128 } | |
| 1129 } | |
| 1130 if (0 != valuable) { | |
| 1131 flavor = valuable->get_flavor(); | |
| 1132 if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) { | |
| 1133 valuable->enable(transaction, CdlValueSource_User); | |
| 1134 } else { | |
| 1135 CdlParse::report_warning(interp, std::string("target `") + target_name + "'", | |
| 1136 std::string("The option `") + *opt_i + | |
| 1137 "' is supposed to be enabled for this target.\n" + | |
| 1138 "However the option does not have a bool or booldata flavors."); | |
| 1139 } | |
| 1140 } else { | |
| 1141 CdlParse::report_warning(interp, std::string("target `") + target_name + "'", | |
| 1142 std::string("The option `") + *opt_i + | |
| 1143 "' is supposed to be enabled for this target.\n" + | |
| 1144 "However this option is not in the current configuration."); | |
| 1145 } | |
| 1146 } | |
| 1147 for (opt_i = disables.begin(); opt_i != disables.end(); opt_i++) { | |
| 1148 valuable = 0; | |
| 1125 node = this->lookup(*opt_i); | 1149 node = this->lookup(*opt_i); |
| 1126 if (0 != node) { | 1150 if (0 != node) { |
| 1127 valuable = dynamic_cast<CdlValuable>(node); | 1151 valuable = dynamic_cast<CdlValuable>(node); |
| 1128 if (0 != valuable) { | 1152 } |
| 1129 flavor = valuable->get_flavor(); | 1153 if (0 != valuable) { |
| 1130 if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) { | 1154 flavor = valuable->get_flavor(); |
| 1131 valuable->enable(transaction, CdlValueSource_User); | 1155 if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) { |
| 1132 } | 1156 valuable->disable(transaction, CdlValueSource_User); |
| 1157 } else { | |
| 1158 CdlParse::report_warning(interp, std::string("target `") + target_name + "'", | |
| 1159 std::string("The option `") + *opt_i + | |
| 1160 "' is supposed to be disabled for this target.\n" + | |
| 1161 "However the option does not have a bool or booldata flavors."); | |
| 1133 } | 1162 } |
| 1134 } | 1163 } else { |
| 1135 } | 1164 CdlParse::report_warning(interp, std::string("target `") + target_name + "'", |
| 1136 for (opt_i = disables.begin(); opt_i != disables.end(); opt_i++) { | 1165 std::string("The option `") + *opt_i + |
| 1137 node = this->lookup(*opt_i); | 1166 "' is supposed to be disabled for this target.\n" + |
| 1138 if (0 != node) { | 1167 "However this option is not in the current configuration."); |
| 1139 valuable = dynamic_cast<CdlValuable>(node); | |
| 1140 if (0 != valuable) { | |
| 1141 flavor = valuable->get_flavor(); | |
| 1142 if ((CdlValueFlavor_Bool == flavor) || (CdlValueFlavor_BoolData == flavor)) { | |
| 1143 valuable->disable(transaction, CdlValueSource_User); | |
| 1144 } | |
| 1145 } | |
| 1146 } | 1168 } |
| 1147 } | 1169 } |
| 1148 std::vector<std::pair<std::string,std::string> >::const_iterator value_i; | 1170 std::vector<std::pair<std::string,std::string> >::const_iterator value_i; |
| 1149 for (value_i = set_values.begin(); value_i != set_values.end(); value_i++) { | 1171 for (value_i = set_values.begin(); value_i != set_values.end(); value_i++) { |
| 1172 valuable = 0; | |
| 1150 node = this->lookup(value_i->first); | 1173 node = this->lookup(value_i->first); |
| 1151 if (0 != node) { | 1174 if (0 != node) { |
| 1152 valuable = dynamic_cast<CdlValuable>(node); | 1175 valuable = dynamic_cast<CdlValuable>(node); |
| 1153 if (0 != valuable) { | 1176 } |
| 1154 flavor = valuable->get_flavor(); | 1177 if (0 != valuable) { |
| 1155 if ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor)) { | 1178 flavor = valuable->get_flavor(); |
| 1156 valuable->set_value(transaction, value_i->second, CdlValueSource_User); | 1179 if ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor)) { |
| 1157 } | 1180 valuable->set_value(transaction, value_i->second, CdlValueSource_User); |
| 1181 } else { | |
| 1182 CdlParse::report_warning(interp, std::string("target `") + target_name + "'", | |
| 1183 std::string("The option `") + *opt_i + | |
| 1184 "' is supposed to be given the value `" + value_i->second + | |
| 1185 "' for this target.\n" + | |
| 1186 "However the option does not have a data or booldata flavor."); | |
| 1158 } | 1187 } |
| 1188 } else { | |
| 1189 CdlParse::report_warning(interp, std::string("target `") + target_name + "'", | |
| 1190 std::string("The option `") + *opt_i + | |
| 1191 "' is supposed to be given the value `" + value_i->second + | |
| 1192 "' for this target.\n" + | |
| 1193 "However this option is not in the current configuration."); | |
| 1159 } | 1194 } |
| 1160 } | 1195 } |
| 1161 } | 1196 } |
| 1162 } | 1197 } |
| 1163 | 1198 |
| 1571 CYG_PRECONDITION_CLASSC(interp); | 1606 CYG_PRECONDITION_CLASSC(interp); |
| 1572 CYG_ASSERTC(0 == interp->get_loadable()); | 1607 CYG_ASSERTC(0 == interp->get_loadable()); |
| 1573 CYG_ASSERTC(0 == interp->get_container()); | 1608 CYG_ASSERTC(0 == interp->get_container()); |
| 1574 CYG_ASSERTC(0 == interp->get_node()); | 1609 CYG_ASSERTC(0 == interp->get_node()); |
| 1575 CYG_ASSERTC(0 == interp->get_transaction()); | 1610 CYG_ASSERTC(0 == interp->get_transaction()); |
| 1576 | 1611 |
| 1577 // Keep track of enough information to undo all the changes. | 1612 // Keep track of enough information to undo all the changes. |
| 1578 std::string old_filename = interp->get_filename(); | 1613 CdlParse::clear_error_count(interp); |
| 1579 CdlDiagnosticFnPtr old_error_fn = interp->get_error_fn_ptr(); | 1614 CdlInterpreterBody::DiagSupport diag_support(interp, error_fn, warn_fn); |
| 1580 CdlDiagnosticFnPtr old_warn_fn = interp->get_warning_fn_ptr(); | 1615 CdlInterpreterBody::ContextSupport context_support(interp, filename); |
| 1581 std::vector<CdlInterpreterCommandEntry>* old_commands = 0; | |
| 1582 std::vector<CdlInterpreterCommandEntry> commands; | |
| 1583 | 1616 |
| 1584 try { | 1617 try { |
| 1585 | |
| 1586 // Associate the right information with the interpreter | |
| 1587 old_filename = interp->push_filename(filename); | |
| 1588 old_error_fn = interp->push_error_fn_ptr(error_fn); | |
| 1589 old_warn_fn = interp->push_warning_fn_ptr(warn_fn); | |
| 1590 CdlParse::clear_error_count(interp); | |
| 1591 | |
| 1592 interp->set_transaction(transaction); | 1618 interp->set_transaction(transaction); |
| 1593 | 1619 |
| 1620 std::vector<CdlInterpreterCommandEntry> commands; | |
| 1594 this->get_savefile_commands(commands); | 1621 this->get_savefile_commands(commands); |
| 1595 old_commands = interp->push_commands(commands); | 1622 CdlInterpreterBody::CommandSupport interp_cmds(interp, commands); |
| 1596 | 1623 |
| 1597 std::string tcl_result = ""; | 1624 interp->eval_file(filename); |
| 1598 if (TCL_OK != interp->eval_file(filename, tcl_result)) { | 1625 |
| 1599 throw CdlInputOutputException("Invalid savefile \"" + filename + "\".\n" + tcl_result); | |
| 1600 } | |
| 1601 // All the data has been read in without generating an | 1626 // All the data has been read in without generating an |
| 1602 // exception. However there may have been errors reported via | 1627 // exception. However there may have been errors reported via |
| 1603 // the error_fn handling, and any errors at all should result | 1628 // the error_fn handling, and any errors at all should result |
| 1604 // in an exception. | 1629 // in an exception. |
| 1605 int error_count = CdlParse::get_error_count(interp); | 1630 int error_count = CdlParse::get_error_count(interp); |
| 1610 tmp + " error" + ((error_count > 1) ? "s" : "") + | 1635 tmp + " error" + ((error_count > 1) ? "s" : "") + |
| 1611 " occurred while reading in the savefile data."); | 1636 " occurred while reading in the savefile data."); |
| 1612 } | 1637 } |
| 1613 | 1638 |
| 1614 } catch(...) { | 1639 } catch(...) { |
| 1615 | |
| 1616 if (0 != old_commands) { | |
| 1617 interp->pop_commands(old_commands); | |
| 1618 } | |
| 1619 interp->pop_filename(old_filename); | |
| 1620 interp->pop_error_fn_ptr(old_error_fn); | |
| 1621 interp->pop_warning_fn_ptr(old_warn_fn); | |
| 1622 interp->set_transaction(0); | 1640 interp->set_transaction(0); |
| 1623 throw; | 1641 throw; |
| 1624 } | 1642 } |
| 1625 | 1643 |
| 1626 interp->pop_filename(old_filename); | |
| 1627 interp->pop_error_fn_ptr(old_error_fn); | |
| 1628 interp->pop_warning_fn_ptr(old_warn_fn); | |
| 1629 interp->pop_commands(old_commands); | |
| 1630 interp->set_transaction(0); | 1644 interp->set_transaction(0); |
| 1631 | 1645 |
| 1632 CYG_REPORT_RETURN(); | 1646 CYG_REPORT_RETURN(); |
| 1633 } | 1647 } |
| 1634 | 1648 |
| 1662 int data_index = CdlParse::parse_options(interp, "cdl_configuration command", 0, argc, argv, 1, options); | 1676 int data_index = CdlParse::parse_options(interp, "cdl_configuration command", 0, argc, argv, 1, options); |
| 1663 | 1677 |
| 1664 // A broken cdl_configuration command is pretty fatal, chances are | 1678 // A broken cdl_configuration command is pretty fatal, chances are |
| 1665 // that the entire load is going to fail. | 1679 // that the entire load is going to fail. |
| 1666 if (data_index != (argc - 2)) { | 1680 if (data_index != (argc - 2)) { |
| 1667 CdlParse::report_error(interp, "Invalid cdl_configuration command in savefile, expecting two arguments."); | 1681 CdlParse::report_error(interp, "", "Invalid cdl_configuration command in savefile, expecting two arguments."); |
| 1668 } else { | 1682 } else { |
| 1669 config->set_name(argv[1]); | 1683 config->set_name(argv[1]); |
| 1670 config->get_savefile_subcommands("cdl_configuration", subcommands); | 1684 config->get_savefile_subcommands("cdl_configuration", subcommands); |
| 1671 toplevel_commands = interp->push_commands(subcommands); | 1685 toplevel_commands = interp->push_commands(subcommands); |
| 1672 | 1686 |
| 1702 | 1716 |
| 1703 std::vector<std::pair<std::string,std::string> > options; | 1717 std::vector<std::pair<std::string,std::string> > options; |
| 1704 int data_index = CdlParse::parse_options(interp, "cdl_configuration/description command", 0, argc, argv, 1, options); | 1718 int data_index = CdlParse::parse_options(interp, "cdl_configuration/description command", 0, argc, argv, 1, options); |
| 1705 | 1719 |
| 1706 if (data_index != (argc - 1)) { | 1720 if (data_index != (argc - 1)) { |
| 1707 CdlParse::report_warning(interp, | 1721 CdlParse::report_warning(interp, "", |
| 1708 "Ignoring invalid configuration description command, expecting a single argument."); | 1722 "Ignoring invalid configuration description command, expecting a single argument."); |
| 1709 } else { | 1723 } else { |
| 1710 config->description = argv[1]; | 1724 config->description = argv[1]; |
| 1711 } | 1725 } |
| 1712 return TCL_OK; | 1726 return TCL_OK; |
| 1726 | 1740 |
| 1727 std::vector<std::pair<std::string,std::string> > options; | 1741 std::vector<std::pair<std::string,std::string> > options; |
| 1728 int data_index = CdlParse::parse_options(interp, "cdl_configuration/hardware command", 0, argc, argv, 1, options); | 1742 int data_index = CdlParse::parse_options(interp, "cdl_configuration/hardware command", 0, argc, argv, 1, options); |
| 1729 | 1743 |
| 1730 if (data_index != (argc - 1)) { | 1744 if (data_index != (argc - 1)) { |
| 1731 CdlParse::report_warning(interp, "Ignoring invalid configuration hardware command, expecting a single argument."); | 1745 CdlParse::report_warning(interp, "", "Ignoring invalid configuration hardware command, expecting a single argument."); |
| 1732 } else { | 1746 } else { |
| 1733 config->current_hardware = argv[1]; | 1747 config->current_hardware = argv[1]; |
| 1734 } | 1748 } |
| 1735 | 1749 |
| 1736 return TCL_OK; | 1750 return TCL_OK; |
| 1750 | 1764 |
| 1751 std::vector<std::pair<std::string,std::string> > options; | 1765 std::vector<std::pair<std::string,std::string> > options; |
| 1752 int data_index = CdlParse::parse_options(interp, "cdl_configuration/template command", 0, argc, argv, 1, options); | 1766 int data_index = CdlParse::parse_options(interp, "cdl_configuration/template command", 0, argc, argv, 1, options); |
| 1753 | 1767 |
| 1754 if (data_index != (argc - 1)) { | 1768 if (data_index != (argc - 1)) { |
| 1755 CdlParse::report_warning(interp, "Ignoring invalid configuration template command, expecting a single argument."); | 1769 CdlParse::report_warning(interp, "", "Ignoring invalid configuration template command, expecting a single argument."); |
| 1756 } else { | 1770 } else { |
| 1757 config->current_template = argv[1]; | 1771 config->current_template = argv[1]; |
| 1758 } | 1772 } |
| 1759 | 1773 |
| 1760 return TCL_OK; | 1774 return TCL_OK; |
| 1785 0 | 1799 0 |
| 1786 }; | 1800 }; |
| 1787 int data_index = CdlParse::parse_options(interp, "cdl_configuration/package command", optlist, argc, argv, 1, options); | 1801 int data_index = CdlParse::parse_options(interp, "cdl_configuration/package command", optlist, argc, argv, 1, options); |
| 1788 | 1802 |
| 1789 if (data_index == (argc - 1)) { | 1803 if (data_index == (argc - 1)) { |
| 1790 CdlParse::report_warning(interp, std::string("Missing version information for package ") + argv[argc - 1]); | 1804 CdlParse::report_warning(interp, "", std::string("Missing version information for package `") |
| 1805 + argv[argc - 1] + "'."); | |
| 1791 pkgname = argv[argc - 1]; | 1806 pkgname = argv[argc - 1]; |
| 1792 pkgversion = ""; | 1807 pkgversion = ""; |
| 1793 } else if (data_index == (argc - 2)) { | 1808 } else if (data_index == (argc - 2)) { |
| 1794 pkgname = argv[argc - 2]; | 1809 pkgname = argv[argc - 2]; |
| 1795 pkgversion = argv[argc - 1]; | 1810 pkgversion = argv[argc - 1]; |
| 1796 } else { | 1811 } else { |
| 1797 // If we cannot load all the packages then much of the | 1812 // If we cannot load all the packages then much of the |
| 1798 // savefile is likely to be problematical. | 1813 // savefile is likely to be problematical. |
| 1799 CdlParse::report_error(interp, "Invalid cdl_configuration/package command, expecting name and version"); | 1814 CdlParse::report_error(interp, "", "Invalid cdl_configuration/package command, expecting name and version"); |
| 1800 CYG_REPORT_RETURN(); | 1815 CYG_REPORT_RETURN(); |
| 1801 return TCL_OK; | 1816 return TCL_OK; |
| 1802 } | 1817 } |
| 1803 | 1818 |
| 1804 if (0 != config->lookup(pkgname)) { | 1819 if (0 != config->lookup(pkgname)) { |
| 1808 CdlNode node = config->lookup(pkgname); | 1823 CdlNode node = config->lookup(pkgname); |
| 1809 CYG_ASSERT_CLASSC(node); | 1824 CYG_ASSERT_CLASSC(node); |
| 1810 pkg = dynamic_cast<CdlPackage>(node); | 1825 pkg = dynamic_cast<CdlPackage>(node); |
| 1811 if (0 == pkg) { | 1826 if (0 == pkg) { |
| 1812 // The name is in use, but it is not a package | 1827 // The name is in use, but it is not a package |
| 1813 CdlParse::report_error(interp, std::string("Unable to load package ") + pkgname + ", the name is already in use."); | 1828 CdlParse::report_error(interp, "", |
| 1829 std::string("Unable to load package `") + pkgname + "', the name is already in use."); | |
| 1814 } else if (pkgversion != pkg->get_value()) { | 1830 } else if (pkgversion != pkg->get_value()) { |
| 1815 CdlParse::report_warning(interp, std::string("Cannot load version ") + pkgversion + " of package " + | 1831 CdlParse::report_warning(interp, "", |
| 1816 pkgname + ", version " + pkg->get_value() + " already loaded."); | 1832 std::string("Cannot load version `") + pkgversion + "' of package `" + |
| 1833 pkgname + "', version `" + pkg->get_value() + "' is already loaded."); | |
| 1817 } | 1834 } |
| 1818 } else if (!db->is_known_package(pkgname)) { | 1835 } else if (!db->is_known_package(pkgname)) { |
| 1819 CdlParse::report_error(interp, std::string("Attempt to load an unknown package ") + pkgname); | 1836 CdlParse::report_error(interp, "", |
| 1837 std::string("Attempt to load an unknown package `") + pkgname + "'."); | |
| 1820 } else { | 1838 } else { |
| 1821 if ("" != pkgversion) { | 1839 if ("" != pkgversion) { |
| 1822 const std::vector<std::string>& versions = db->get_package_versions(pkgname); | 1840 const std::vector<std::string>& versions = db->get_package_versions(pkgname); |
| 1823 if (versions.end() == std::find(versions.begin(), versions.end(), pkgversion)) { | 1841 if (versions.end() == std::find(versions.begin(), versions.end(), pkgversion)) { |
| 1824 CdlParse::report_warning(interp, std::string("The savefile specifies version `") + pkgversion + | 1842 CdlParse::report_warning(interp, "", |
| 1843 std::string("The savefile specifies version `") + pkgversion + | |
| 1825 "' for package `" + pkgname + "'\nThis version is not available.\n" + | 1844 "' for package `" + pkgname + "'\nThis version is not available.\n" + |
| 1826 "Using the most recent version instead."); | 1845 "Using the most recent version instead."); |
| 1827 pkgversion = ""; | 1846 pkgversion = ""; |
| 1828 } | 1847 } |
| 1829 } | 1848 } |
