Re: Consensus on getter conventions?
- From: Oskar Liljeblad <osk hem passagen se>
- To: Karl Nelson <kenelson ece ucdavis edu>
- Cc: gnome-hackers gnome org, gtk-devel-list gnome org
- Subject: Re: Consensus on getter conventions?
- Date: Fri, 25 Aug 2000 09:42:16 +0200
On Thursday, August 24, 2000 at 17:11, Karl Nelson wrote:
> >
> > First, I don't really see this as a huge problem. Putting results
> > into variables (instead of using nested function calls) makes for more
> > readable code. But you do have a point...
> >
> > Second, apparantly Karl's method causes problems for other
> > languages (at least, it does for Java).
>
> I didn't read the java message that way. He said he need the number
> of in/out arguments capped at one. C++ needs the same for most
> functions. More than one means ugly C++ interface.
You interpreted my message correctly. :)
> Note, that gtk+ constantly has more than 1 in/out parameter in
> many functions that cause bindings problems.
Yes. Fortunately, most of those functions are rather simple - they
check each out-parameter for NULL first, and if that's the case they
don't do anything with them. So I make multiple methods for these
functions - e.g. gtk_ctree_get_node_info becomes (something like)
String getNodeText(CTreeNode node)
int getNodeSpacing(CTreeNode node, int column)
GdkPixmap getNodePixmapClosed(CTreeNode node)
GdkPixmap getNodeMaskClosed(CTreeNode node)
GdkPixmap getNodePixmapOpened(CTreeNode node)
GdkPixmap getNodeMaskOpened(CTreeNode node)
boolean isNodeExpanded(CTreeNode node)
boolean isNodeLeaf(CTreeNode node)
Unfortunately the success/failure int return value of
gtk_ctree_get_node_info has to be ignored (at least not delivered to
the user).
Another problem with these multiple-return functions is that the
corresponding set-method (in this case gtk_ctree_set_node_info)
cannot be used to set only one value, so in Java I get:
void setNodeInfo(CTreeNode, String text, int spacing,
GdkPixmap pixmapClosed, GdkBitmap maskClosed,
GdkPixmap pixmapOpened, GdkBitmap maskOpened,
boolean leaf, boolean expanded)
instead of (nicer) setNodeText, setNodeSpacing, ...
Oskar Liljeblad (osk@hem.passagen.se)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]