Hi folks,
Patrick is correct that code which uses libgeda shouldn't know -- or
need to know -- that selection lists are implemented using GList.
The attached series of patches are preparatory to reintroducing the
SELECTION struct. They refactor the API for dealing with selections
in order to make it more consistent. In particular, all functions now
accept a pointer to the list of the same type.
Interestingly, gschem used the o_selection_select() and
o_selection_unselect() functions despite them clearly being marked,
"This function should not be called by anybody outside of this file.".
This patch series marks the functions as deprecated by comments in the
header file, and makes sure only libgeda is using them. I recommend
that they are removed from the public header file at some point.
The following snippets from libgeda's prototype.h summarize the changes:
Before:
GList *o_selection_add(GList *head, OBJECT *o_selected);
void o_selection_print_all( GList *head );
void o_selection_select(OBJECT *object, int color);
void o_selection_unselect(OBJECT *object);
void o_selection_remove(GList **head, OBJECT *o_selected);
void o_selection_unselect_list(TOPLEVEL *w_current, GList **head);
After:
void o_selection_add(GList **head, OBJECT *o_selected);
void o_selection_print_all(const GList **head);
void o_selection_select(OBJECT *object, int color); // DEPRECATED
void o_selection_unselect(OBJECT *object); // DEPRECATED
void o_selection_remove(GList **head, OBJECT *o_selected);
void o_selection_unselect_list(TOPLEVEL *w_current, GList **head);
The next step after this are to:
* introduce a new SELECTION struct which encapsulates a GList (which
IMHO would have been the right way to do this in the first place);
* add an iterator system so that code which needs to iterate
over a SELECTION can do so without needing to know how libgeda
implements it;
* add a system for registering callbacks to be executed when items
are added or removed from the selection list.
However, such a change can wait for a convenient time to be
implemented. I know there's a big queue of changes, and I think it's
probably a good idea to let Ales catch up. ;)
These patches are from my 'ptbb-selection' branch:
http://www2.eng.cam.ac.uk/~ptbb/geda/ptbb.git/#ptbb-selection
Cheers,
Peter
P.S. I apologise if the patch mails come through slightly mangled: I'm
trying out a tool called 'Stacked Git' (stgit) which generates them
automatically.
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev