Redesigned option handling, start of libtool introduction
[fw/sdcc] / sim / ucsim / cmd.src / get.cc
index 34c995859f85ac6ae2966aa9a3d7cb65d479361f..f070f02f07c78db1924822f28f7896af58cd7fb9 100644 (file)
@@ -28,6 +28,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "ddconfig.h"
 
 #include <ctype.h>
+#include "i_string.h"
+
+// prj
+#include "utils.h"
 
 // sim
 #include "simcl.h"
@@ -44,26 +48,27 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  *----------------------------------------------------------------------------
  */
 
-int
-cl_get_sfr_cmd::do_work(class cl_sim *sim,
-                       class cl_cmdline *cmdline, class cl_console *con)
+//int
+//cl_get_sfr_cmd::do_work(class cl_sim *sim,
+//                     class cl_cmdline *cmdline, class cl_console *con)
+COMMAND_DO_WORK_UC(cl_get_sfr_cmd)
 {
-  class cl_mem *mem= sim->uc->mem(MEM_SFR);
+  class cl_mem *mem= uc->mem(MEM_SFR);
   class cl_cmd_arg *parm;
   int i;
 
   if (!mem)
     {
-      con->printf("Error: No SFR\n");
+      con->dd_printf("Error: No SFR\n");
       return(DD_FALSE);
     }
   for (i= 0, parm= cmdline->param(i);
        parm;
        i++, parm= cmdline->param(i))
     {
-      if (!parm->as_address())
-       con->printf("Warning: Invalid address %s\n",
-                   (char*)cmdline->tokens->at(i+1));
+      if (!parm->as_address(uc))
+       con->dd_printf("Warning: Invalid address %s\n",
+                      (char*)cmdline->tokens->at(i+1));
       else
        mem->dump(parm->value.address, parm->value.address, 1, con);
     }
@@ -77,31 +82,34 @@ cl_get_sfr_cmd::do_work(class cl_sim *sim,
  *----------------------------------------------------------------------------
  */
 
-int
-cl_get_option_cmd::do_work(class cl_sim *sim,
-                          class cl_cmdline *cmdline, class cl_console *con)
+//int
+//cl_get_option_cmd::do_work(class cl_sim *sim,
+//                        class cl_cmdline *cmdline, class cl_console *con)
+COMMAND_DO_WORK_APP(cl_get_option_cmd)
 {
   class cl_cmd_arg *parm= cmdline->param(0);
   char *s= 0;
 
   if (!parm)
     ;
-  else if (cmdline->syntax_match(sim, STRING)) {
+  else if (cmdline->syntax_match(0/*app->get_uc()*/, STRING)) {
     s= parm->value.string.string;
   }
   else
-    con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
+    con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
 
   int i;
-  for (i= 0; i < sim->uc->options->count; i++)
+  for (i= 0; i < app->options->count; i++)
     {
-      class cl_option *o= (class cl_option *)(sim->uc->options->at(i));
-      if (!s ||
-         !strcmp(s, o->id))
+      class cl_option *o= (class cl_option *)(/*uc*/app->options->at(i));
+      if ((!s ||
+          !strcmp(s, o->get_name())) &&
+         !o->hidden)
        {
-         con->printf("%s ", o->id);
+         con->dd_printf("%2d. %s(by %s): ", i, object_name(o),
+                        object_name(o->get_creator()));
          o->print(con);
-         con->printf(" %s\n", o->help);
+         con->dd_printf(" - %s\n", o->help);
        }
     }