/*! \brief Get name and value from an attribute OBJECT * \par Function Description * See o_attrib_string_get_name_value() for more details * * \param [in] attrib The attribute OBJECT whos name/value to return. * \param [out] name_ptr The return location for the name, or NULL. * \param [out] value_ptr The return location for the value, or NULL. * \return TRUE on success, FALSE otherwise. */ gboolean o_attrib_get_name_value (OBJECT *attrib, gchar **name_ptr, gchar **value_ptr) { g_return_val_if_fail (attrib->type == OBJ_TEXT, FALSE); return o_attrib_string_get_name_value (attrib->text->string, name_ptr, value_ptr); }
/* given a net name, an attribute, and a wanted attribute, return all the given attribute of all the graphical objects connected to that net name */ SCM g_graphical_objs_in_net_with_attrib_get_attrib (SCM scm_netname, SCM scm_has_attribute, SCM scm_wanted_attribute) { SCM list = SCM_EOL; NETLIST *nl_current; CPINLIST *pl_current; char *wanted_net_name; char *wanted_attrib; char *has_attrib; char *net_name; char *attrib_value=NULL; char *has_attrib_value = NULL; char *has_attrib_name = NULL; SCM_ASSERT(scm_is_string (scm_netname), scm_netname, SCM_ARG1, "gnetlist:graphical-objs-in-net-with-attrib-get-attrib"); SCM_ASSERT(scm_is_string (scm_wanted_attribute), scm_wanted_attribute, SCM_ARG3, "gnetlist:graphical-objs-in-net-with-attrib-get-attrib"); SCM_ASSERT(scm_is_string (scm_has_attribute), scm_has_attribute, SCM_ARG2, "gnetlist:graphical-objs-in-net-with-attrib-get-attrib"); scm_dynwind_begin (0); wanted_net_name = scm_to_utf8_string (scm_netname); if (wanted_net_name == NULL) { return list; } scm_dynwind_free (wanted_net_name); wanted_attrib = scm_to_utf8_string (scm_wanted_attribute); scm_dynwind_free (wanted_attrib); has_attrib = scm_to_utf8_string (scm_has_attribute); scm_dynwind_free (has_attrib); nl_current = graphical_netlist_head; /* walk through the list of components, and through the list * of individual pins on each, adding net names to the list * being careful to ignore duplicates, and unconnected pins */ while (nl_current != NULL) { pl_current = nl_current->cpins; while (pl_current != NULL) { if (pl_current->net_name) { net_name = pl_current->net_name; if (strcmp(net_name, wanted_net_name) == 0) { if (o_attrib_string_get_name_value (has_attrib, &has_attrib_name, &has_attrib_value) != 0) { attrib_value = o_attrib_search_object_attribs_by_name (nl_current->object_ptr, has_attrib_name, 0); if ( ((has_attrib_value == NULL) && (attrib_value == NULL)) || ((has_attrib_value != NULL) && (attrib_value != NULL) && (strcmp(attrib_value, has_attrib_value) == 0)) ) { g_free (attrib_value); attrib_value = o_attrib_search_object_attribs_by_name (nl_current->object_ptr, wanted_attrib, 0); if (attrib_value) { list = scm_cons (scm_from_utf8_string (attrib_value), list); } g_free (attrib_value); } g_free (has_attrib_name); g_free (has_attrib_value); } } } pl_current = pl_current->next; } nl_current = nl_current->next; } scm_dynwind_end (); return list; }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_slot_end(GSCHEM_TOPLEVEL *w_current, OBJECT *object, const char *string) { TOPLEVEL *toplevel = w_current->toplevel; OBJECT *new_obj; char *slot_value; char *numslots_value; OBJECT *o_slot; char *value = NULL; int numslots; int new_slot_number; int status; g_return_if_fail (object != NULL); status = o_attrib_string_get_name_value (string, NULL, &value); if (!status) { s_log_message (_("Slot attribute malformed\n")); return; } numslots_value = o_attrib_search_object_attribs_by_name (object, "numslots", 0); if (!numslots_value) { s_log_message (_("numslots attribute missing\n")); s_log_message (_("Slotting not allowed for this component\n")); g_free (value); return; } numslots = atoi (numslots_value); g_free (numslots_value); new_slot_number = atoi (value); #if DEBUG printf ("numslots = %d\n", numslots); #endif if (new_slot_number > numslots || new_slot_number <=0 ) { s_log_message (_("New slot number out of range\n")); g_free (value); return; } /* first see if slot attribute already exists outside * complex */ slot_value = s_slot_search_slot (object, &o_slot); g_free (slot_value); if (o_slot != NULL && !o_attrib_is_inherited (o_slot)) { o_text_set_string (toplevel, o_slot, string); } else { /* here you need to do the add the slot attribute since it doesn't exist */ new_obj = o_text_new (toplevel, OBJ_TEXT, ATTRIBUTE_COLOR, object->complex->x, object->complex->y, LOWER_LEFT, 0, /* zero is angle */ string, 10, INVISIBLE, SHOW_NAME_VALUE); s_page_append (toplevel, toplevel->page_current, new_obj); /* manually attach attribute */ o_attrib_attach (toplevel, new_obj, object, FALSE); } s_slot_update_object (toplevel, object); toplevel->page_current->CHANGED = 1; g_free (value); }