Brad Watson wrote:
> I'm considering splitting the wrapped c function calls
across two subclasses of CObject: NCWindow and NCScreen. c
functions that return a WINDOW pointer, or take a WINDOW
pointer argument will be wrapped
> by an instance method in the NCWindow class. c
functions that return a SCREEN pointer, or take a SCREEN
pointer argument will be wrapped by an instance method in
the NCSreen class. The remaining c functions will by
wrapped by class methods in the class that they have the
closest affinity. Does this scheme sound reasonable, and
consisent with the goal of "objectification"
NCurses ?
>
SCREEN functions are a bit of a pain to wrap, because
NCurses uses a
FILE * while Smalltalk only knows file descriptors (and
rightly so).
Therefore, since they are just three (newterm, set_term,
delscreen) and
rarely used, I'd just do without them completely. For the
record,
though, newterm (and possibly
initscr/endwin/isendwin/slk_init and other
listed in the curs_initscr(3X) man page) could be an
NCScreen class method.
I think that NCurses functions without a WINDOW * are
divided in three:
those that are merely wrappers (e.g. refresh () for wrefresh
(stdscr)),
those that return a WINDOW *, and those that do something
else.
The first need not be wrapped at all, IMO. Object-oriented
people are
used to singleton and will happily write NCWindow stdscr
wprintw:
'foo'. There may be some exception (e.g. I can't see a
difference
between getch and wgetch), but it is not worthwhile
introducing
exception IMO
The second should undoubtedly be NCWindow class methods.
You can make
them return an NCWindow instance using "returning:
NCWindow type" in the
C call-out.
The third category includes initscr, endwin, and so on. As
I said,
these could be placed in a separate NCScreen class, where
they would be
class methods (or instance methods if the class implemented
the
Singleton pattern). But if you want, it's also possible to
put them in
NCWindow as class methods, as you prefer.
Paolo
_______________________________________________
help-smalltalk mailing list
help-smalltalk gnu.org
http://lists.gnu.org/mailman/listinfo/help-smalltalk
|