X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=sim%2Fucsim%2Foption.cc;h=83bccf754d008bb1d6d78f295c7a9c851a91dd38;hb=eae1bd2f705a2c61e143c539f8c4d1e9c2b4efe6;hp=45e62cf1c38867def034ef500ef23228390d0822;hpb=f27da39dbcab5678aca6d8462f1cc37a643f37e9;p=fw%2Fsdcc diff --git a/sim/ucsim/option.cc b/sim/ucsim/option.cc index 45e62cf1..83bccf75 100644 --- a/sim/ucsim/option.cc +++ b/sim/ucsim/option.cc @@ -45,12 +45,12 @@ /*struct id_element option_type_names[]= { - { non_opt , "non" }, - { integer_opt , "integer" }, - { float_opt , "float" }, - { bool_opt , "boolean" }, - { string_opt , "string" }, - { pointer_opt , "pointer" }, + { non_opt , "non" }, + { integer_opt , "integer" }, + { float_opt , "float" }, + { bool_opt , "boolean" }, + { string_opt , "string" }, + { pointer_opt , "pointer" }, { 0, 0 } };*/ @@ -60,7 +60,7 @@ * */ -cl_option::cl_option(class cl_base *the_creator, char *aname, char *Ihelp): +cl_option::cl_option(class cl_base *the_creator, const char *aname, const char *Ihelp): cl_base() { creator= the_creator; @@ -218,24 +218,16 @@ cl_option::set_value(double opt) * List of options */ -void * +const void * cl_options::key_of(void *item) { return(((class cl_base *)item)->get_name()); } int -cl_options::compare(void *key1, void *key2) +cl_options::compare(const void *key1, const void *key2) { - //class cl_option *k1, *k2; - int i; - char *k1, *k2; - - k1= /*(class cl_option *)*/(char *)key1; - k2= /*(class cl_option *)*/(char *)key2; - if ((i= strcmp(k1, k2)) != 0) - return(i); - return(i); + return(strcmp(static_cast(key1), static_cast(key2))); } void @@ -253,7 +245,7 @@ cl_options::del_option(class cl_option *opt) } class cl_option * -cl_options::get_option(char *the_name) +cl_options::get_option(const char *the_name) { t_index idx; @@ -263,7 +255,7 @@ cl_options::get_option(char *the_name) } class cl_option * -cl_options::get_option(char *the_name, class cl_base *creator) +cl_options::get_option(const char *the_name, class cl_base *creator) { t_index idx; class cl_option *o; @@ -275,24 +267,24 @@ cl_options::get_option(char *the_name, class cl_base *creator) idx--; o= (class cl_option *)(at(idx)); while (compare(the_name, key_of(o)) == 0 && - idx > 0) - { - idx--; - o= (class cl_option *)(at(idx)); - } + idx > 0) + { + idx--; + o= (class cl_option *)(at(idx)); + } if (compare(the_name, key_of(o)) != 0) - idx++; + idx++; } o= (class cl_option *)(at(idx)); while (compare(the_name, key_of(o)) == 0 && - o->get_creator() != creator && - idx < count) + o->get_creator() != creator && + idx < count) { idx++; o= (class cl_option *)(at(idx)); if (compare(the_name, key_of(o)) == 0 && - o->get_creator() == creator) - return(o); + o->get_creator() == creator) + return(o); } if (compare(the_name, key_of(o)) == 0 && o->get_creator() == creator) @@ -301,7 +293,7 @@ cl_options::get_option(char *the_name, class cl_base *creator) } class cl_option * -cl_options::get_option(char *the_name, char *creator) +cl_options::get_option(const char *the_name, char *creator) { t_index idx; class cl_option *o; @@ -313,24 +305,24 @@ cl_options::get_option(char *the_name, char *creator) idx--; o= (class cl_option *)(at(idx)); while (compare(the_name, key_of(o)) == 0 && - idx > 0) - { - idx--; - o= (class cl_option *)(at(idx)); - } + idx > 0) + { + idx--; + o= (class cl_option *)(at(idx)); + } if (compare(the_name, key_of(o)) != 0) - idx++; + idx++; } o= (class cl_option *)(at(idx)); while (compare(the_name, key_of(o)) == 0 && - strcmp(object_name(o->get_creator()), creator) != 0 && - idx < count) + strcmp(object_name(o->get_creator()), creator) != 0 && + idx < count) { idx++; o= (class cl_option *)(at(idx)); if (compare(the_name, key_of(o)) == 0 && - strcmp(object_name(o->get_creator()), creator) == 0) - return(o); + strcmp(object_name(o->get_creator()), creator) == 0) + return(o); } if (compare(the_name, key_of(o)) == 0 && strcmp(object_name(o->get_creator()), creator) == 0) @@ -355,7 +347,7 @@ cl_options::nuof_options(char *the_name) { class cl_option *o= (class cl_option *)(at(i)); if (strcmp(the_name, o->get_name()) == 0) - n++; + n++; } return(n); } @@ -369,14 +361,14 @@ cl_options::nuof_options(char *the_name, char *creator) { class cl_option *o= (class cl_option *)(at(i)); if (strcmp(the_name, o->get_name()) == 0 && - strcmp(creator, object_name(o->get_creator())) == 0) - n++; + strcmp(creator, object_name(o->get_creator())) == 0) + n++; } return(n); } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, bool value) +cl_options::set_value(const char *the_name, cl_base *creator, bool value) { class cl_option *o= get_option(the_name, creator); @@ -386,7 +378,7 @@ cl_options::set_value(char *the_name, cl_base *creator, bool value) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, char *value) +cl_options::set_value(const char *the_name, cl_base *creator, char *value) { class cl_option *o= get_option(the_name, creator); @@ -396,7 +388,7 @@ cl_options::set_value(char *the_name, cl_base *creator, char *value) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, void *value) +cl_options::set_value(const char *the_name, cl_base *creator, void *value) { class cl_option *o= get_option(the_name, creator); @@ -406,7 +398,7 @@ cl_options::set_value(char *the_name, cl_base *creator, void *value) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, long value) +cl_options::set_value(const char *the_name, cl_base *creator, long value) { class cl_option *o= get_option(the_name, creator); @@ -416,7 +408,7 @@ cl_options::set_value(char *the_name, cl_base *creator, long value) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, double value) +cl_options::set_value(const char *the_name, cl_base *creator, double value) { class cl_option *o= get_option(the_name, creator); @@ -454,14 +446,14 @@ cl_optref::~cl_optref(void) { option->del_reference(this); if (option->get_creator() == owner) - application->options->del_option(option); + application->options->del_option(option); } } class cl_option * cl_optref::create(class cl_base *creator, - enum option_type type, - char *the_name, char *help) + enum option_type type, + const char *the_name, const char *help) { if (option) option->del_reference(this); @@ -500,7 +492,7 @@ cl_optref::create(class cl_base *creator, } void -cl_optref::default_option(char *the_name) +cl_optref::default_option(const char *the_name) { class cl_option *o= application->options->get_option(the_name, application); @@ -527,7 +519,7 @@ cl_optref::use(void) } class cl_option * -cl_optref::use(char *the_name) +cl_optref::use(const char *the_name) { if (option) option->del_reference(this); @@ -552,7 +544,7 @@ cl_optref::get_value(bool) if (!option) { fprintf(stderr, "Warning: \"%s\" is sdereferencing a non-existent " - "bool option: %s\n", object_name(owner), get_name()); + "bool option: %s\n", object_name(owner), get_name()); return(DD_FALSE); } else @@ -564,12 +556,12 @@ cl_optref::get_value(bool) } char * -cl_optref::get_value(char *) +cl_optref::get_value(const char *) { if (!option) { fprintf(stderr, "Warning: \"%s\" is sdereferencing a non-existent " - "string option: %s\n", object_name(owner), get_name()); + "string option: %s\n", object_name(owner), get_name()); return(0); } else @@ -586,7 +578,7 @@ cl_optref::get_value(void *) if (!option) { fprintf(stderr, "Warning: \"%s\" is sdereferencing a non-existent " - "pointer option: %s\n", object_name(owner), get_name()); + "pointer option: %s\n", object_name(owner), get_name()); return(NIL); } else @@ -603,7 +595,7 @@ cl_optref::get_value(long) if (!option) { fprintf(stderr, "Warning: \"%s\" is sdereferencing a non-existent " - "number option: %s\n", object_name(owner), get_name()); + "number option: %s\n", object_name(owner), get_name()); return(0); } else @@ -620,7 +612,7 @@ cl_optref::get_value(double) if (!option) { fprintf(stderr, "Warning: \"%s\" is sdereferencing a non-existent " - "float option: %s\n", object_name(owner), get_name()); + "float option: %s\n", object_name(owner), get_name()); return(0); } else @@ -639,12 +631,12 @@ cl_optref::get_value(double) */ cl_bool_option::cl_bool_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} void -cl_bool_option::print(class cl_console *con) +cl_bool_option::print(class cl_console_base *con) { if (/**(bool *)option*/value.bval) con->dd_printf("TRUE"); @@ -661,11 +653,11 @@ cl_bool_option::set_value(char *s) { c= toupper(*s); if (c == '1' || - c == 'T' || - c == 'Y') - /**(bool *)option=*/ value.bval= DD_TRUE; + c == 'T' || + c == 'Y') + /**(bool *)option=*/ value.bval= DD_TRUE; else - /**(bool *)option=*/ value.bval= DD_FALSE; + /**(bool *)option=*/ value.bval= DD_FALSE; } inform_users(); } @@ -678,7 +670,7 @@ cl_bool_option::set_value(char *s) */ cl_string_option::cl_string_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} @@ -692,7 +684,7 @@ cl_string_option::operator=(class cl_option &o) } void -cl_string_option::print(class cl_console *con) +cl_string_option::print(class cl_console_base *con) { if (/**(bool *)option*/value.sval) con->dd_printf("\"%s\"", value.sval); @@ -708,7 +700,7 @@ cl_string_option::print(class cl_console *con) */ cl_pointer_option::cl_pointer_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} @@ -720,7 +712,7 @@ cl_pointer_option::operator=(class cl_option &o) } void -cl_pointer_option::print(class cl_console *con) +cl_pointer_option::print(class cl_console_base *con) { if (value.pval) con->dd_printf("\"%p\"", value.pval); @@ -734,15 +726,15 @@ cl_pointer_option::print(class cl_console *con) */ /* cl_cons_debug_opt::cl_cons_debug_opt(class cl_app *the_app, - char *Iid, - char *Ihelp): + char *Iid, + char *Ihelp): cl_option(0, Iid, Ihelp) { app= the_app; } void -cl_cons_debug_opt::print(class cl_console *con) +cl_cons_debug_opt::print(class cl_console_base *con) { if (con->flags & CONS_DEBUG) con->dd_printf("TRUE"); @@ -764,9 +756,9 @@ cl_cons_debug_opt::set_value(bool opt) if (app->get_commander()->actual_console) { if (opt) - app->get_commander()->actual_console->flags|= CONS_DEBUG; + app->get_commander()->actual_console->flags|= CONS_DEBUG; else - app->get_commander()->actual_console->flags&= ~CONS_DEBUG; + app->get_commander()->actual_console->flags&= ~CONS_DEBUG; } inform_users(); } @@ -781,11 +773,11 @@ cl_cons_debug_opt::set_value(char *s) { c= toupper(*s); if (c == '1' || - c == 'T' || - c == 'Y') - set_value(1); + c == 'T' || + c == 'Y') + set_value(1); else - set_value(0); + set_value(0); } } */ @@ -797,12 +789,12 @@ cl_cons_debug_opt::set_value(char *s) */ cl_number_option::cl_number_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} void -cl_number_option::print(class cl_console *con) +cl_number_option::print(class cl_console_base *con) { con->dd_printf("%ld", value.ival); } @@ -823,12 +815,12 @@ cl_number_option::set_value(char *s) */ cl_float_option::cl_float_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} void -cl_float_option::print(class cl_console *con) +cl_float_option::print(class cl_console_base *con) { con->dd_printf("%.3f", value.fval); }