Attached is some notes on the gEDA attribute API I made when looking to
see if some things could be cut down. There is a fair bit of
code-duplication still, and I didn't finish the job in making the
simplifications.
Some brief notes on what a new API might have are below:
"""
Attribute API..
Query by name, for a particular attrib in a list of attributes (glist of
ATTRIB, or just plain "OBJECT"s which store the name=value stuff)
Helper to execute the above - for an object which might have attributes
- for a list of objects which might have attributes
<-- THIS IS GOING ANYWAY IN FAVOUR OF glists
- for a glist of objects which might have attributes
When we want to find the 'n'th copy of a given attribute, is that per
object, or for the entire list?
What use-cases are there using API for getting the 'n'th attribute with
a given name - could we return a list?
"""
--
Peter Clifton
Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA
Tel: +44 (0)7729 980173 - (No signal in the lab!)
/* g_smob.c: 9 Functions */
SCM g_make_attrib_smob (TOPLEVEL *curr_w, ATTRIB *curr_attr);
SCM g_get_attrib_name_value (SCM attrib_smob);
SCM g_set_attrib_value_internal (SCM attrib_smob, SCM scm_value, TOPLEVEL **world, OBJECT **o_attrib, char *new_string[]);
SCM g_calcule_new_attrib_bounds (SCM attrib_smob, SCM scm_alignment, SCM scm_angle, SCM scm_x, SCM scm_y);
void g_init_attrib_smob (void);
SCM g_get_attrib_bounds(SCM attrib_smob);
SCM g_get_attrib_angle(SCM attrib_smob);
SCM g_get_object_attributes(SCM object_smob);
SCM g_get_attrib_value_by_attrib_name(SCM object_smob, SCM scm_attrib_name);
/* o_attrib.c: 33 functions */
OBJECT *o_read_attribs(TOPLEVEL *toplevel, OBJECT *object_to_get_attribs, TextBuffer *tb, unsigned int release_ver, unsigned int fileformat_ver);
void o_save_attribs(FILE *fp, GList *attribs);
/* Given an attribute list, find an ATTRIB with the same SID as the object passed in */
/* Used: o_attrib_attach(); so should be static - or removed? */
ATTRIB *o_attrib_search(GList *list, OBJECT *item);
/* Perhaps rename o_attrib_search_object ? */
/* Populates a new ATTRIB structure for the passed item, and attaches to object's attribs list */
/* Used: o_attrib_attach(), o_update_component(); The later one is probably not good usage */
void o_attrib_add(TOPLEVEL *toplevel, OBJECT *object, OBJECT *item);
/* Recolours object, free's ATTRIB structure associated with it. Does not update any attrib lists */
/* Used: o_attrib_free_all(); so should be static? */
void o_attrib_free(TOPLEVEL *toplevel, ATTRIB *current);
/* Frees an entire list of ATTRIBs. */
/* Used: s_delete_object(), i_callback_attributes_detach() */
void o_attrib_free_all(TOPLEVEL *toplevel, GList *list);
/* Removes a given attribute object from a given list of attributes. Free's corresponding ATTRIB struct */
/* Used: s_delete_object() */
void o_attrib_remove(GList **list, OBJECT *remove);
/* Searches for an object with SID == that of passed text_object in the parent_list, then (if found)
* adds that object to the passed "object", and colours the attribute appropriately. */
/* Used: o_read_attribs(), lots of other places in libgeda, gschem and one in gattrib */
void o_attrib_attach(TOPLEVEL *toplevel, OBJECT *parent_list, OBJECT *text_object, OBJECT *object);
/* Debug printing for the a list of ATTRIBs */
/* Used: print_struct_forw(), print_struct() */
void o_attrib_print(GList *attributes);
/* Sets the objects associated with the passed list of ATTRIB structures to the the attribute color */
/* Unused -- Remove me, or use me to avoid duplication elsewhere!!! */
void o_attrib_set_color(TOPLEVEL *toplevel, GList *attributes);
int o_attrib_get_name_value(char *string, char **name, char **value);
OBJECT *o_attrib_search_string_list(OBJECT *list, char *string);
OBJECT *o_attrib_search_string_single(OBJECT *object, char *search_for);
OBJECT *o_attrib_search_attrib_value(GList *list, char *value, char *name, int counter);
/* Given list of objects (generally a pin with attached attribs), and a pinnumber
* search for and return pinseq= attrib (object) */
/* Used: o_attrib_slot_copy(), o_attrib_slot_update() - make static? */
OBJECT *o_attrib_search_pinseq(OBJECT *list, int pin_number);
/* Used: o_attrib_slot_update(), o_attrib_slot_copy() - make static? */
char *o_attrib_search_slotdef(OBJECT *object, int slotnumber);
/* Search for slotdef attribute in the object list */
/* Used: o_attrib_search_slotdef() - remove or make static? */
char *o_attrib_search_string_partial(OBJECT *object, char *search_for, int counter);
char *o_attrib_search_name(OBJECT *list, char *name, int counter);
/* How is this different from o_attrib_search_name - just the list type? */
char *o_attrib_search_attrib_name(GList *list, char *name, int counter);
/* How is this different from o_attrib_search_name? */
char *o_attrib_search_toplevel(OBJECT *list, char *name, int counter);
/* How is this different from o_attrib_search_name? */
char *o_attrib_search_name_single(OBJECT *object, char *name, OBJECT **return_found);
/* How is this different from o_attrib_search_name? */
char *o_attrib_search_name_single_count(OBJECT *object, char *name, int counter);
/* Why special case this.. remove? */
char *o_attrib_search_slot(OBJECT *object, OBJECT **return_found);
/* Why special case this.. remove? */
char *o_attrib_search_numslots(OBJECT *object, OBJECT **return_found);
/* Why special case this.. remove? */
char *o_attrib_search_default_slot(OBJECT *object);
/* Why special case this.. remove? */
char *o_attrib_search_toplevel_all(GedaPageList *page_list, char *name);
/* Why special case this.. remove? */
char *o_attrib_search_component(OBJECT *object, char *name);
void o_attrib_slot_update(TOPLEVEL *toplevel, OBJECT *object);
void o_attrib_slot_copy(TOPLEVEL *toplevel, OBJECT *original, OBJECT *target);
OBJECT **o_attrib_return_attribs(OBJECT *object_list, OBJECT *sel_object);
void o_attrib_free_returned(OBJECT **found_objects);
/* o_complex_basic.c: 1 function */
SHOULD BE STATIC int o_complex_is_eligible_attribute(TOPLEVEL *toplevel, OBJECT *object, int promote_invisible);
/* s_attrib.c: 6 functions */
int s_attrib_add_entry(char *new_attrib);
void s_attrib_print(void);
int s_attrib_uniq(char *name);
void s_attrib_free(void);
void s_attrib_init(void);
char *s_attrib_get(int counter);
AND SPECIFIC TO GSCHEM:
/* g_funcs.c */
SCM get_selected_component_attributes(GSCHEM_TOPLEVEL *w_current);
/* g_hook.c */
SCM g_make_attrib_smob_list(GSCHEM_TOPLEVEL *w_current, OBJECT *curr_object);
SCM g_set_attrib_value_x(SCM attrib_smob, SCM scm_value);
SCM g_add_attrib(SCM object, SCM attrib_name, SCM attrib_value, SCM scm_vis, SCM scm_show);
SCM g_set_attrib_text_properties(SCM attrib_smob, SCM scm_colorname, SCM scm_size,
SCM scm_alignment, SCM scm_rotation, SCM scm_x,
SCM scm_y);
/* g_keys.c */
SCM g_get_selected_component_attributes(void);
/* o_attrib.c */
void o_attrib_add_selected(GSCHEM_TOPLEVEL *w_current, SELECTION *selection, OBJECT *selected);
void o_attrib_toggle_visibility(GSCHEM_TOPLEVEL *w_current, GList *list);
void o_attrib_toggle_show_name_value(GSCHEM_TOPLEVEL *w_current, GList *list, int new_show_name_value);
OBJECT *o_attrib_add_attrib(GSCHEM_TOPLEVEL *w_current, char *text_string, int visibility, int show_name_value, OBJECT *object);
AND SPECIFIC TO GATTRIB:
/* s_attrib.c: 2 functions */
int s_attrib_name_in_list(STRING_LIST *name_value_list, char *name);
char *s_attrib_get_refdes(OBJECT *object);
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev