示例#1
0
/*
	save the instance resource into the stream
*/
static __bool _save_inst_res_proc(ITreeNode * nd, __bool firstVisit, f8_uint _s)
{
	IBlk * blk;
	ICBlk * cblk;
	struct cblk_link_t * lk;
	struct blk_pin_t  * p;
	struct cblk_pin_t * cp;
	IF8Stream * s;

	s = (IF8Stream*)_s;

	blk = __dcast__(ITreeNode, IBlk, nd);
	
	save_res_stream(&blk->uuid, s);

	if(blk->h.magic == CBLK_MAGIC){
		cblk = __dcast__(IBlk, ICBlk, (blk));
		
		lk = ICBlk_first_link(cblk);
		while(lk){
			save_res_stream(&lk->uuid, s);
			lk = ICBlk_next_link(lk);
		}

		p = __vcall__(blk, first_pin, (blk));
		while(p){
			cp = CONTAINING_RECORD(p, struct cblk_pin_t, p);
			save_res_stream(&cp->uuid, s);
			p = __vcall__(blk, next_pin, (p));
		}
	}
示例#2
0
static void dumpCblk(IBlk * b, __bool firstVisit, FILE * of)
{
	const char * name;
	char path[F8_MAX_PATH];
	char buf[1024];
	char idName[128];
	struct blk_ent_t be;

	if(firstVisit){
		name = IBlk_name(b);
		IBlk_path_by_blk(parent_blk(b), path, sizeof(path));
		if(parent_blk(b) && !(parent_blk(b)->h.flags & BLK_F_READONLY)){
			if(b->h.flags & BLK_F_READONLY){
				if(blklib_query(&b->h.uuid, &be)){
					sprintf(buf, "mount  path=\"%s\" type=\"%s.%s\" name=\"%s\"", path, be.dir, be.name, name);
				}else{
					f8_uuid_to_string(&b->h.uuid, idName, sizeof(idName));
					sprintf(buf, "mount  path=\"%s\" id=%s name=\"%s\"", path, idName, name);
				}
				if(of==stdout)
					utils_trace("%s\n",buf);
				else
					fprintf(of, "%s\n", buf);
				return;
			}else{
				sprintf(buf, "mount path=\"%s\" file=blank.blk name=\"%s\" rw", path, name);
			}
			if (of==stdout)
				utils_trace("%s\n",buf);
			else
				fprintf(of, "%s\n", buf);
			IBlk_path_by_blk(b, path, sizeof(path));
			sprintf(buf, "place block \"%s\" (%d,%d)", path, get_res_int(&b->uuid, "x", 0), get_res_int(&b->uuid, "y", 0));
			if(of==stdout)
				utils_trace("%s\n",buf);
			else
				fprintf(of, "%s\n", buf);
		}

		enum_variables(b, defineVariable, (__uint)of);
	}else{
		/*
			dump links positions/export pins
		*/
		if(b->h.flags & BLK_F_READONLY){
			return;
		}
		ICBlk * cb = __dcast__(IBlk, ICBlk, b);
		struct cblk_link_t * l;
		for(l=ICBlk_first_link(cb); l; l=ICBlk_next_link(l)){
			char p1[F8_MAX_PATH];
			char p2[F8_MAX_PATH];
			IBlk_path_by_pin(l->s.pin, p1, sizeof(p1));
			IBlk_path_by_pin(l->t.pin, p2, sizeof(p2));
			sprintf(buf, "link \"%s\" \"%s\"", p1, p2);
			if(of==stdout)
				utils_trace("%s\n",buf);
			else
				fprintf(of, "%s\n", buf);

			TLinkMetrics *m;
			m = (TLinkMetrics *)get_res_buf(&l->uuid, 0, "metrics");
			if(m){
				char *p;
				p = buf;
				p += sprintf(p, "place link \"%s\" %d ", p2, m->count);
				int i;
				for(i=0; i<m->count; i++){
					p += sprintf(p, "(%d,%d) ", m->coord[i].x, m->coord[i].y);
				}
				if(of==stdout)
					utils_trace("%s\n",buf);
				else
					fprintf(of, "%s\n", buf);
			}
		}
	}
}