void s_traverse_start(TOPLEVEL * pr_current) { GList *iter; PAGE *p_current; for ( iter = geda_list_get_glist( pr_current->pages ); iter != NULL; iter = g_list_next( iter ) ) { p_current = (PAGE *)iter->data; /* only traverse pages which are toplevel, ie not underneath */ if (p_current->page_control == 0) { pr_current->page_current = p_current; s_traverse_sheet (pr_current, s_page_objects (p_current), NULL); } } /* now that all the sheets have been read, go through and do the */ /* post processing work */ s_netlist_post_process(pr_current, netlist_head); /* Now match the graphical netlist with the net names already assigned */ s_netlist_name_named_nets(pr_current, netlist_head, graphical_netlist_head); if (verbose_mode) { printf("\nInternal netlist representation:\n\n"); s_netlist_print(netlist_head); } }
void s_hierarchy_traverse(TOPLEVEL * pr_current, OBJECT * o_current, NETLIST * netlist) { char *attrib; int page_control=-1; PAGE *p_current; PAGE *child_page; int count = 0; int pcount = 0; int looking_inside = FALSE; int loaded_flag = FALSE; char *current_filename; int graphical=FALSE; attrib = o_attrib_search_attached_attribs_by_name (o_current, "source", 0); /* if above is null, then look inside symbol */ if (attrib == NULL) { attrib = o_attrib_search_inherited_attribs_by_name (o_current, "source", count); looking_inside = TRUE; #if DEBUG printf("going to look inside now\n"); #endif } graphical = s_hierarchy_graphical_search(o_current, count); if (graphical) { /* Do not bother traversing the hierarchy if the symbol has an */ /* graphical attribute attached to it. */ if (attrib) { g_free(attrib); attrib = NULL; } } while (attrib) { /* look for source=filename,filename, ... */ pcount = 0; current_filename = u_basic_breakup_string(attrib, ',', pcount); /* loop over all filenames */ while (current_filename != NULL) { s_log_message(_("Going to traverse source [%1$s]"), current_filename); /* guts here */ /* guts for a single filename */ p_current = pr_current->page_current; #if DEBUG printf("Going down %s\n", current_filename); #endif GError *err = NULL; child_page = s_hierarchy_down_schematic_single(pr_current, current_filename, pr_current->page_current, page_control, HIERARCHY_FORCE_LOAD, &err); if (child_page == NULL) { g_warning (_("Failed to load subcircuit '%1$s': %2$s\n"), current_filename, err->message); fprintf(stderr, _("ERROR: Failed to load subcircuit '%1$s': %2$s\n"), current_filename, err->message); g_error_free (err); exit (2); } else { page_control = child_page->page_control; s_page_goto (pr_current, child_page); loaded_flag = TRUE; verbose_print("v\n"); verbose_reset_index(); netlist->composite_component = TRUE; /* can't do the following, don't know why... HACK TODO */ /*netlist->hierarchy_tag = u_basic_strdup (netlist->component_uref);*/ s_traverse_sheet (pr_current, s_page_objects (pr_current->page_current), netlist->component_uref); verbose_print("^"); } pr_current->page_current = p_current; g_free(current_filename); pcount++; current_filename = u_basic_breakup_string(attrib, ',', pcount); } g_free(attrib); g_free(current_filename); count++; /* continue looking outside first */ if (!looking_inside) { attrib = o_attrib_search_attached_attribs_by_name (o_current, "source", count); } /* okay we were looking outside and didn't */ /* find anything, so now we need to look */ /* inside the symbol */ if (!looking_inside && attrib == NULL && !loaded_flag) { looking_inside = TRUE; #if DEBUG printf("switching to go to look inside\n"); #endif } if (looking_inside) { #if DEBUG printf("looking inside\n"); #endif attrib = o_attrib_search_inherited_attribs_by_name (o_current, "source", count); } graphical = s_hierarchy_graphical_search(o_current, count); if (graphical) { /* Do not bother looking further in the hierarchy if the symbol */ /* has an graphical attribute attached to it. */ if (attrib) { g_free(attrib); attrib = NULL; } } } }