Re: [U-Boot] [PATCH v2 4/6] Add generic, reusable menu code

2011-06-24 Thread Jason Hobbs
On Thu, Jun 23, 2011 at 10:03:12PM +0200, Wolfgang Denk wrote:
 Dear Jason Hobbs,
 Is this all new code, or was it copied from some other project?  If
 so, reference would be needed.

All new code.

 Then, we need documentation how this is going to be used. Please add a
 README with documentation of the interfaces and usage examples.

Ok - I'll add this.

 Also, I would like to know why you didn't adapt for example the menu
 code from barebox - which specific advantages do you see in the code
 you have chosen?

I looked over barebox's menu code after you pointed it out, and
it does have more functionality and a fancier interface than this
implementation. Unfortunately, it appears that there aren't any menus
defined to use it in the barebox codebase to provide a real example for
it.

The primary advantage of the implementation I've provided over the
barebox implementation is simplicity.

From a user interface perspective, there are no ANSI terminal codes
used, and selection of a choice is just typing out the name of the
desired choice. It should work on any terminal, and would be easy to
use with expect type automation tools. This simple prompt is also the
default behavior for pxelinux, so should be familiar to end users.

From an implementation perspective, the code does exactly what's needed
for pxecfg without adding extra features that would require some
invention of functionality to prevent introduction of untested and dead
code. It could work equally well for other jobs that just require a
user to make a choice between some options presented on the screen, and
if anything else is needed in the future, it should be extensible to
accommodate. The simplicity makes the code size small - ~1k when built
for my platform, vs ~2.5k for barebox's menu code.

An example complexity from barebox's menu code we don't use here is each
menu entry having its own display, destroy, and call when selected
action method. Instead, we implement display the same way for all
menus, destroy the same way for all entries in a menu, and the selected
entry is merely returned to the caller for it to handle.

The implementation also hides the details of the menu's internal
structure from consumers of the interface - the menu and menu_item
struct's are not externally defined, forcing all interaction to go
through the function interfaces. Interface consumers provide a name and
an opaque pointer to a data structure of the user's choice for each
item, and the rest is shielded from the consumer's view. This should
help prevent coding errors and make maintenance of the internals easier
by preventing consumers from relying the implementation rather than the
interface.

Thanks,
Jason
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 4/6] Add generic, reusable menu code

2011-06-24 Thread Wolfgang Denk
Dear Jason Hobbs,

In message 20110624202511.GA18667@jhobbs-laptop you wrote:
 On Thu, Jun 23, 2011 at 10:03:12PM +0200, Wolfgang Denk wrote:
  Dear Jason Hobbs,
  Is this all new code, or was it copied from some other project?  If
  so, reference would be needed.
 
 All new code.
 
  Then, we need documentation how this is going to be used. Please add a
  README with documentation of the interfaces and usage examples.
 
 Ok - I'll add this.
 
  Also, I would like to know why you didn't adapt for example the menu
  code from barebox - which specific advantages do you see in the code
  you have chosen?
 
 I looked over barebox's menu code after you pointed it out, and
 it does have more functionality and a fancier interface than this
 implementation. Unfortunately, it appears that there aren't any menus
 defined to use it in the barebox codebase to provide a real example for
 it.
 
 The primary advantage of the implementation I've provided over the
 barebox implementation is simplicity.
...

Thanks for the detailed explanation.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
You can't evaluate a man by logic alone.
-- McCoy, I, Mudd, stardate 4513.3
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 4/6] Add generic, reusable menu code

2011-06-23 Thread Wolfgang Denk
Dear Jason Hobbs,

In message 1308853655-12407-5-git-send-email-jason.ho...@calxeda.com you 
wrote:
 This will be used first by the pxecfg code, but is intended to be
 generic and reusable for other jobs in U-boot.
 
 Signed-off-by: Jason Hobbs jason.ho...@calxeda.com
 ---
 changes in v2:
 - new in v2
 
  common/Makefile |1 +
  common/menu.c   |  338 
 +++
  include/menu.h  |   40 +++
  3 files changed, 379 insertions(+), 0 deletions(-)
  create mode 100644 common/menu.c
  create mode 100644 include/menu.h

Is this all new code, or was it copied from some other project?  If so,
reference would be needed.

Then, we need documentation how this is going to be used. Please add a
README with documentation of the interfaces and usage examples.

Also, I would like to know why you didn't adapt for example the menu
code from barebox - which specific advantages do you see in the code
you have chosen?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
I think it's a new feature. Don't tell anyone it was an accident. :-)
  -- Larry Wall on s/foo/bar/eieio in 10...@jpl-devvax.jpl.nasa.gov
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot