comparison host/libcdl/interface.cxx @ 103:95f3e12a6327 ecos-sw-2000-06-23

Merge from eCos master repository on 2000-06-23-16:41:10-BST
author jlarmour
date Fri, 23 Jun 2000 17:06:31 +0000
parents 6736c52df507
children 6ed91473a1cd
comparison
equal deleted inserted replaced
102:6409b6d94dd7 103:95f3e12a6327
229 new_interface->CdlValuableBody::check_properties(interp); 229 new_interface->CdlValuableBody::check_properties(interp);
230 new_interface->CdlParentableBody::check_properties(interp); 230 new_interface->CdlParentableBody::check_properties(interp);
231 new_interface->CdlBuildableBody::check_properties(interp); 231 new_interface->CdlBuildableBody::check_properties(interp);
232 new_interface->CdlDefinableBody::check_properties(interp); 232 new_interface->CdlDefinableBody::check_properties(interp);
233 233
234 // A few properties do not make sense for interfaces. 234 // The flavor "none" makes no sense for interfaces.
235 // Start with the value-related ones. Interfaces always 235 // The flavor "bool" makes very little sense, but may be useful
236 // have the flavor Data. 236 // in weird cases. Both booldata and data make sense.
237 // The default flavor is "data", because interfaces are
238 // essentially just counters.
237 if (new_interface->has_property(CdlPropertyId_Flavor)) { 239 if (new_interface->has_property(CdlPropertyId_Flavor)) {
238 CdlParse::report_error(interp, "", "An interface should not have a `flavor' property."); 240 if (CdlValueFlavor_None == new_interface->get_flavor()) {
239 } 241 CdlParse::report_error(interp, "", "An interface should not have the `none' flavor.");
242 }
243 }
244
240 // Interfaces cannot be modified directly by the user, so 245 // Interfaces cannot be modified directly by the user, so
241 // there is no point in entry_proc, check_proc, dialog or 246 // there is no point in entry_proc, check_proc, dialog or
242 // wizard 247 // wizard
243 if (new_interface->has_property(CdlPropertyId_EntryProc)) { 248 if (new_interface->has_property(CdlPropertyId_EntryProc)) {
244 CdlParse::report_error(interp, "", "An interface should not have an `entry_proc' property."); 249 CdlParse::report_error(interp, "", "An interface should not have an `entry_proc' property.");
340 345
341 // Start with details of everything that implements this interface. 346 // Start with details of everything that implements this interface.
342 if (!minimal) { 347 if (!minimal) {
343 const std::vector<CdlReferrer>& referrers = this->get_referrers(); 348 const std::vector<CdlReferrer>& referrers = this->get_referrers();
344 std::vector<CdlReferrer>::const_iterator ref_i; 349 std::vector<CdlReferrer>::const_iterator ref_i;
350 int real_referrers = 0;
345 for (ref_i = referrers.begin(); ref_i != referrers.end(); ref_i++) { 351 for (ref_i = referrers.begin(); ref_i != referrers.end(); ref_i++) {
346 CdlNode node = ref_i->get_source(); 352 CdlNode node = ref_i->get_source();
347 CdlProperty prop = ref_i->get_source_property(); 353 CdlProperty prop = ref_i->get_source_property();
348 354
349 CdlValuable valuable = dynamic_cast<CdlValuable>(node); 355 CdlValuable valuable = dynamic_cast<CdlValuable>(node);
350 if ((0 != valuable) && (CdlPropertyId_Implements == prop->get_property_name())) { 356 if ((0 != valuable) && (CdlPropertyId_Implements == prop->get_property_name())) {
357 real_referrers++;
351 data += std::string(indentation, ' ') + " # Implemented by " + valuable->get_name() + ", " + 358 data += std::string(indentation, ' ') + " # Implemented by " + valuable->get_name() + ", " +
352 (valuable->is_active() ? "active" : "inactive") + ", " + 359 (valuable->is_active() ? "active" : "inactive") + ", " +
353 (valuable->is_enabled() ? "enabled" : "disabled") + '\n'; 360 (valuable->is_enabled() ? "enabled" : "disabled") + '\n';
354 } 361 }
362 }
363 if (0 == real_referrers) {
364 data += std::string(indentation, ' ') + " # No options implement this inferface\n";
355 } 365 }
356 } 366 }
357 interp->write_data(chan, data); 367 interp->write_data(chan, data);
358 368
359 // Deal with the value 369 // Deal with the value
467 if (implementer_value.is_enabled()) { 477 if (implementer_value.is_enabled()) {
468 count++; 478 count++;
469 } 479 }
470 } 480 }
471 } 481 }
472 if (count != old_value.get_integer_value()) { 482
473 CdlValue new_value = old_value; 483 // What to do with the count depends on the flavor.
474 new_value.set_integer_value(count, CdlValueSource_Default); 484 switch(this->get_flavor()) {
475 transaction->set_whole_value(this, old_value, new_value); 485 case CdlValueFlavor_Bool :
486 {
487 bool new_bool = (count > 0);
488 if (new_bool != old_value.is_enabled()) {
489 CdlValue new_value = old_value;
490 new_value.set_enabled(new_bool, CdlValueSource_Default);
491 transaction->set_whole_value(this, old_value, new_value);
492 }
493 break;
494 }
495 case CdlValueFlavor_BoolData:
496 {
497 // The only thing that actually needs checking is the count value.
498 // Iff that has changed then the boolean part may need changing as well.
499 if (count != old_value.get_integer_value()) {
500 CdlValue new_value = old_value;
501 new_value.set_enabled_and_value(count > 0, count, CdlValueSource_Default);
502 transaction->set_whole_value(this, old_value, new_value);
503 }
504
505 break;
506 }
507 case CdlValueFlavor_Data:
508 {
509 if (count != old_value.get_integer_value()) {
510 CdlValue new_value = old_value;
511 new_value.set_integer_value(count, CdlValueSource_Default);
512 transaction->set_whole_value(this, old_value, new_value);
513 }
514 break;
515 }
516
517 default:
518 break;
476 } 519 }
477 520
478 CYG_REPORT_RETURN(); 521 CYG_REPORT_RETURN();
479 } 522 }
480 523