Mercurial > ecos
comparison host/libcdl/dialog.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 |
|---|---|
| 146 { | 146 { |
| 147 CYG_REPORT_FUNCNAMETYPE("CdlDialog::parse_dialog", "result %d"); | 147 CYG_REPORT_FUNCNAMETYPE("CdlDialog::parse_dialog", "result %d"); |
| 148 CYG_REPORT_FUNCARG1("argc %d", argc); | 148 CYG_REPORT_FUNCARG1("argc %d", argc); |
| 149 CYG_PRECONDITION_CLASSC(interp); | 149 CYG_PRECONDITION_CLASSC(interp); |
| 150 | 150 |
| 151 const char* diag_argv0 = CdlParse::get_tcl_cmd_name(argv[0]); | 151 std::string diag_argv0 = CdlParse::get_tcl_cmd_name(argv[0]); |
| 152 | 152 |
| 153 CdlLoadable loadable = interp->get_loadable(); | 153 CdlLoadable loadable = interp->get_loadable(); |
| 154 CdlContainer parent = interp->get_container(); | 154 CdlContainer parent = interp->get_container(); |
| 155 CdlToplevel toplevel = interp->get_toplevel(); | 155 CdlToplevel toplevel = interp->get_toplevel(); |
| 156 std::string filename = interp->get_filename(); | |
| 157 CYG_ASSERT_CLASSC(loadable); // There should always be a loadable during parsing | 156 CYG_ASSERT_CLASSC(loadable); // There should always be a loadable during parsing |
| 158 CYG_ASSERT_CLASSC(parent); | 157 CYG_ASSERT_CLASSC(parent); |
| 159 CYG_ASSERT_CLASSC(toplevel); | 158 CYG_ASSERT_CLASSC(toplevel); |
| 160 CYG_ASSERTC("" != filename); | |
| 161 | 159 |
| 162 // The new dialog should be created and added to the loadable | 160 // The new dialog should be created and added to the loadable |
| 163 // early on. If there is a parsing error it will get cleaned up | 161 // early on. If there is a parsing error it will get cleaned up |
| 164 // automatically as a consequence of the loadable destructor. | 162 // automatically as a consequence of the loadable destructor. |
| 165 // However it is necessary to validate the name first. Errors | 163 // However it is necessary to validate the name first. Errors |
| 170 std::vector<CdlInterpreterCommandEntry>* old_commands = 0; | 168 std::vector<CdlInterpreterCommandEntry>* old_commands = 0; |
| 171 int result = TCL_OK; | 169 int result = TCL_OK; |
| 172 | 170 |
| 173 // Currently there are no command-line options. This may change in future. | 171 // Currently there are no command-line options. This may change in future. |
| 174 if (3 != argc) { | 172 if (3 != argc) { |
| 175 CdlParse::report_error(interp, std::string("Incorrect number of arguments to ") + diag_argv0 + | 173 CdlParse::report_error(interp, "", std::string("Incorrect number of arguments to `") + diag_argv0 + |
| 176 "\n Expecting name and properties list."); | 174 "'\nExpecting name and properties list."); |
| 177 } else if (!Tcl_CommandComplete(argv[2])) { | 175 } else if (!Tcl_CommandComplete(argv[2])) { |
| 178 CdlParse::report_error(interp, std::string("Invalid property list for cdl_dialog ") + argv[1]); | 176 CdlParse::report_error(interp, "", std::string("Invalid property list for cdl_dialog `") + argv[1] + "'."); |
| 179 } else if (0 != toplevel->lookup(argv[1])) { | 177 } else if (0 != toplevel->lookup(argv[1])) { |
| 180 CdlParse::report_error(interp, std::string("Dialog ") + argv[1] + " cannot be loaded.\n" + | 178 CdlParse::report_error(interp, "", std::string("Dialog `") + argv[1] + "' cannot be loaded.\n" + |
| 181 " The name is already in use."); | 179 "The name is already in use."); |
| 182 } else { | 180 } else { |
| 183 | 181 |
| 184 try { | 182 try { |
| 185 new_dialog = new CdlDialogBody(argv[1]); | 183 new_dialog = new CdlDialogBody(argv[1]); |
| 186 toplevel->add_node(loadable, parent, new_dialog); | 184 toplevel->add_node(loadable, parent, new_dialog); |
| 229 | 227 |
| 230 // The init_proc and update_proc properties are optional. | 228 // The init_proc and update_proc properties are optional. |
| 231 // The display_proc, confirm_proc and cancel_proc properties | 229 // The display_proc, confirm_proc and cancel_proc properties |
| 232 // are compulsory. | 230 // are compulsory. |
| 233 if (new_dialog->count_properties(CdlPropertyId_InitProc) > 1) { | 231 if (new_dialog->count_properties(CdlPropertyId_InitProc) > 1) { |
| 234 CdlParse::report_error(interp, "A dialog should have only one `init_proc' property."); | 232 CdlParse::report_error(interp, "", "A dialog should have only one `init_proc' property."); |
| 235 } | 233 } |
| 236 if (new_dialog->count_properties(CdlPropertyId_UpdateProc) > 1) { | 234 if (new_dialog->count_properties(CdlPropertyId_UpdateProc) > 1) { |
| 237 CdlParse::report_error(interp, "A dialog should have only one `update_proc' property."); | 235 CdlParse::report_error(interp, "", "A dialog should have only one `update_proc' property."); |
| 238 } | 236 } |
| 239 if (new_dialog->count_properties(CdlPropertyId_DisplayProc) != 1) { | 237 if (new_dialog->count_properties(CdlPropertyId_DisplayProc) != 1) { |
| 240 CdlParse::report_error(interp, "A dialog should have one `display_proc' property."); | 238 CdlParse::report_error(interp, "", "A dialog should have one `display_proc' property."); |
| 241 } | 239 } |
| 242 if (new_dialog->count_properties(CdlPropertyId_ConfirmProc) != 1) { | 240 if (new_dialog->count_properties(CdlPropertyId_ConfirmProc) != 1) { |
| 243 CdlParse::report_error(interp, "A dialog should have one `confirm_proc' property."); | 241 CdlParse::report_error(interp, "", "A dialog should have one `confirm_proc' property."); |
| 244 } | 242 } |
| 245 if (new_dialog->count_properties(CdlPropertyId_CancelProc) != 1) { | 243 if (new_dialog->count_properties(CdlPropertyId_CancelProc) != 1) { |
| 246 CdlParse::report_error(interp, "A dialog should have one `cancel_proc' property."); | 244 CdlParse::report_error(interp, "", "A dialog should have one `cancel_proc' property."); |
| 247 } | 245 } |
| 248 } | 246 } |
| 249 | 247 |
| 250 } catch(...) { | 248 } catch(...) { |
| 251 if (0 != new_dialog) { | 249 if (0 != new_dialog) { |
