view ueda/uschem-netlist/netobj.c @ 139:bf188727e606

donl-rename-parts reader: no tEDAx-style escapes
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 07 Sep 2020 04:25:11 +0000
parents cd92449fdb51
children
line wrap: on
line source

#include <sys/types.h>
#include <stdio.h>
#include "netlist.h"
#include "../libuschem/schemstruct.h"

extern struct net *alloc_nethead();
extern struct net *get_nethead_for_netname();

extern struct schem *curschem;
extern int global_errflag;

static struct net *curnet;
static struct schemobj *cur_grouphead;

process_netobj(obj)
	register struct schemobj *obj;
{
	register struct netpoint *netpt;

	if (!obj->netobj_grouphead || obj->netobj_grouphead != cur_grouphead) {
		curnet = NULL;
		cur_grouphead = obj->netobj_grouphead;
	}
	if (!curnet && obj->netobj_netname)
		curnet = get_nethead_for_netname(obj->netobj_netname);
	for (netpt = obj->netobj_points; netpt; netpt = netpt->netpt_next)
		if (netpt->netpt_type == NETPT_TYPE_PIN)
			process_netpoint(obj, netpt);
}

process_netpoint(netobj, netpt)
	struct schemobj *netobj;
	register struct netpoint *netpt;
{
	struct schemobj *comp;
	char *soughtpin;
	int bynum;

	if (!netpt->netpt_pin_nameref) {
		fprintf(stderr,
"%s: line %d: Pin connection specified by coordinates only not netlistable\n",
			curschem->orig_filename, netobj->obj_lineno);
		fprintf(stderr, "Run uschem-rewrite -g %s to fix\n",
			curschem->orig_filename);
		global_errflag++;
		return;
	}
	if (parse_pin_nameref(curschem, netobj->obj_lineno,
				netpt->netpt_pin_nameref, &comp, &soughtpin,
				&bynum) < 0) {
		/* error msg already printed */
		global_errflag++;
		return;
	}
	/* handle unnamed nets -- point of no return */
	if (!curnet) {
		curnet = alloc_nethead();
		add_unnamed_net(curnet);
	}
	do_connect(curnet, comp, soughtpin, bynum, netobj->obj_lineno);
}