Mercurial > flash_v2
comparison host/libcdl/wizard.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 | 6ed91473a1cd |
comparison
equal
deleted
inserted
replaced
| 81:89fef2181d7d | 82:6736c52df507 |
|---|---|
| 114 CYG_REPORT_FUNCNAMETYPE("CdlWizard::parse_wizard", "result %d"); | 114 CYG_REPORT_FUNCNAMETYPE("CdlWizard::parse_wizard", "result %d"); |
| 115 CYG_REPORT_FUNCARG1("argc %d", argc); | 115 CYG_REPORT_FUNCARG1("argc %d", argc); |
| 116 CYG_PRECONDITION_CLASSC(interp); | 116 CYG_PRECONDITION_CLASSC(interp); |
| 117 | 117 |
| 118 int result = TCL_OK; | 118 int result = TCL_OK; |
| 119 const char* diag_argv0 = CdlParse::get_tcl_cmd_name(argv[0]); | 119 std::string diag_argv0 = CdlParse::get_tcl_cmd_name(argv[0]); |
| 120 | 120 |
| 121 CdlLoadable loadable = interp->get_loadable(); | 121 CdlLoadable loadable = interp->get_loadable(); |
| 122 CdlContainer parent = interp->get_container(); | 122 CdlContainer parent = interp->get_container(); |
| 123 CdlToplevel toplevel = interp->get_toplevel(); | 123 CdlToplevel toplevel = interp->get_toplevel(); |
| 124 std::string filename = interp->get_filename(); | |
| 125 CYG_ASSERT_CLASSC(loadable); // There should always be a loadable during parsing | 124 CYG_ASSERT_CLASSC(loadable); // There should always be a loadable during parsing |
| 126 CYG_ASSERT_CLASSC(parent); | 125 CYG_ASSERT_CLASSC(parent); |
| 127 CYG_ASSERT_CLASSC(toplevel); | 126 CYG_ASSERT_CLASSC(toplevel); |
| 128 CYG_ASSERTC("" != filename); | |
| 129 | 127 |
| 130 // The new wizard should be created and added to the loadable | 128 // The new wizard should be created and added to the loadable |
| 131 // early on. If there is a parsing error it will get cleaned up | 129 // early on. If there is a parsing error it will get cleaned up |
| 132 // automatically as a consequence of the loadable destructor. | 130 // automatically as a consequence of the loadable destructor. |
| 133 // However it is necessary to validate the name first. Errors | 131 // However it is necessary to validate the name first. Errors |
| 136 CdlWizard new_wizard = 0; | 134 CdlWizard new_wizard = 0; |
| 137 try { | 135 try { |
| 138 | 136 |
| 139 // Currently there are no command-line options. This may change in future. | 137 // Currently there are no command-line options. This may change in future. |
| 140 if (3 != argc) { | 138 if (3 != argc) { |
| 141 CdlParse::report_error(interp, std::string("Incorrect number of arguments to ") + diag_argv0 + | 139 CdlParse::report_error(interp, "", std::string("Incorrect number of arguments to `") + diag_argv0 + |
| 142 "\n Expecting name and properties list."); | 140 "'\nExpecting name and properties list."); |
| 143 } else if (!Tcl_CommandComplete(argv[2])) { | 141 } else if (!Tcl_CommandComplete(argv[2])) { |
| 144 CdlParse::report_error(interp, std::string("Invalid property list for cdl_wizard ") + argv[1]); | 142 CdlParse::report_error(interp, "", std::string("Invalid property list for cdl_wizard `") + argv[1]+ "'."); |
| 145 } else if (0 != toplevel->lookup(argv[1])) { | 143 } else if (0 != toplevel->lookup(argv[1])) { |
| 146 CdlParse::report_error(interp, std::string("Wizard ") + argv[1] + " cannot be loaded.\n" + | 144 CdlParse::report_error(interp, "", std::string("Wizard `") + argv[1] + |
| 147 " The name is already in use."); | 145 "' cannot be loaded.\nThe name is already in use."); |
| 148 } else { | 146 } else { |
| 149 new_wizard = new CdlWizardBody(argv[1]); | 147 new_wizard = new CdlWizardBody(argv[1]); |
| 150 toplevel->add_node(loadable, parent, new_wizard); | 148 toplevel->add_node(loadable, parent, new_wizard); |
| 151 | 149 |
| 152 // At this stage new_wizard has been created and added to the hierarchy. | 150 // At this stage new_wizard has been created and added to the hierarchy. |
| 197 // The init_proc and decoration_proc properties are | 195 // The init_proc and decoration_proc properties are |
| 198 // optional. The confirm_proc and cancel_proc properties | 196 // optional. The confirm_proc and cancel_proc properties |
| 199 // are compulsory, and there should be at least one screen | 197 // are compulsory, and there should be at least one screen |
| 200 // definition. | 198 // definition. |
| 201 if (new_wizard->count_properties(CdlPropertyId_InitProc) > 1) { | 199 if (new_wizard->count_properties(CdlPropertyId_InitProc) > 1) { |
| 202 CdlParse::report_error(interp, "A wizard should have only one `init_proc' property."); | 200 CdlParse::report_error(interp, "", "A wizard should have only one `init_proc' property."); |
| 203 } | 201 } |
| 204 if (new_wizard->count_properties(CdlPropertyId_DecorationProc) > 1) { | 202 if (new_wizard->count_properties(CdlPropertyId_DecorationProc) > 1) { |
| 205 CdlParse::report_error(interp, "A wizard should have only one `decoration_proc' property."); | 203 CdlParse::report_error(interp, "", "A wizard should have only one `decoration_proc' property."); |
| 206 } | 204 } |
| 207 if (new_wizard->count_properties(CdlPropertyId_ConfirmProc) != 1) { | 205 if (new_wizard->count_properties(CdlPropertyId_ConfirmProc) != 1) { |
| 208 CdlParse::report_error(interp, "A wizard should have one `confirm_proc' property."); | 206 CdlParse::report_error(interp, "", "A wizard should have one `confirm_proc' property."); |
| 209 } | 207 } |
| 210 if (new_wizard->count_properties(CdlPropertyId_CancelProc) != 1) { | 208 if (new_wizard->count_properties(CdlPropertyId_CancelProc) != 1) { |
| 211 CdlParse::report_error(interp, "A wizard should have one `cancel_proc' property."); | 209 CdlParse::report_error(interp, "", "A wizard should have one `cancel_proc' property."); |
| 212 } | 210 } |
| 213 if (new_wizard->count_properties(CdlPropertyId_Screen) < 1) { | 211 if (new_wizard->count_properties(CdlPropertyId_Screen) < 1) { |
| 214 CdlParse::report_error(interp, "A wizard should have at least one `screen' property."); | 212 CdlParse::report_error(interp, "", "A wizard should have at least one `screen' property."); |
| 215 } | 213 } |
| 216 | 214 |
| 217 // It is necessary to check that all the screen properties have unique numbers | 215 // It is necessary to check that all the screen properties have unique numbers |
| 218 const std::vector<CdlProperty>& properties = new_wizard->get_properties(); | 216 const std::vector<CdlProperty>& properties = new_wizard->get_properties(); |
| 219 std::vector<CdlProperty>::const_iterator prop_i, prop_j; | 217 std::vector<CdlProperty>::const_iterator prop_i, prop_j; |
| 234 cdl_int num2 = tclprop2->get_number(); | 232 cdl_int num2 = tclprop2->get_number(); |
| 235 | 233 |
| 236 if (num1 == num2) { | 234 if (num1 == num2) { |
| 237 std::string tmp = ""; | 235 std::string tmp = ""; |
| 238 Cdl::integer_to_string(num1, tmp); | 236 Cdl::integer_to_string(num1, tmp); |
| 239 CdlParse::report_error(interp, "Duplicate definition of screen " + tmp); | 237 CdlParse::report_error(interp, "", "Duplicate definition of screen `" + tmp + "'."); |
| 240 break; | 238 break; |
| 241 } | 239 } |
| 242 } | 240 } |
| 243 } | 241 } |
| 244 | 242 |
