Ejemplo n.º 1
0
int main( void )
{
   appl_init();
   graf_mouse(ARROW, 0);
   rsrc_obfix(rs_object,0);        /* chg coord from char to pixel */
   rsrc_obfix(rs_object,1);        /* chg coord from char to pixel */
   if( is_ttf_gdos() ) {      /* is ttf-gdos loaded? */
      save_inf();
      dump_gem_fonts( Getrez()+2 );	/* screen workstation */
      dump_gem_fonts( 21 );		/* printer */
      call_fontwid();
      tidy_up();
   }
   else form_alert(1, "[3][this program needs TTF-GDOS][OK]");
   appl_exit();
   exit(0);
} /* main() */
Ejemplo n.º 2
0
// Add provided methods to the given entity
static bool trait_entity(ast_t* entity, pass_opt_t* options)
{
  assert(entity != NULL);

  int state = ast_checkflag(entity,
    AST_FLAG_RECURSE_1 | AST_FLAG_DONE_1 | AST_FLAG_ERROR_1);

  // Check for recursive definitions
  switch(state)
  {
    case 0:
      ast_setflag(entity, AST_FLAG_RECURSE_1);
      break;

    case AST_FLAG_RECURSE_1:
      ast_error(entity, "traits and interfaces can't be recursive");
      ast_clearflag(entity, AST_FLAG_RECURSE_1);
      ast_setflag(entity, AST_FLAG_ERROR_1);
      return false;

    case AST_FLAG_DONE_1:
      return true;

    case AST_FLAG_ERROR_1:
      return false;

    default:
      assert(0);
      return false;
  }

  setup_local_methods(entity);

  bool r =
    provides_list(entity, options) && // Stage 1
    provided_methods(options, entity) && // Stage 2
    field_delegations(entity) && // Stage 3
    resolve_methods(entity, options); // Stage 4

  tidy_up(entity);
  ast_clearflag(entity, AST_FLAG_RECURSE_1);
  ast_setflag(entity, AST_FLAG_DONE_1);

  return r;
}
Ejemplo n.º 3
0
// Add provided and delegated methods to the given entity.
static bool trait_entity(ast_t* entity, pass_opt_t* opt)
{
  assert(entity != NULL);

  int state = ast_checkflag(entity,
    AST_FLAG_RECURSE_1 | AST_FLAG_DONE_1 | AST_FLAG_ERROR_1);

  // Check for recursive definitions
  switch(state)
  {
    case 0:
      ast_setflag(entity, AST_FLAG_RECURSE_1);
      break;

    case AST_FLAG_RECURSE_1:
      ast_error(opt->check.errors, entity,
        "traits and interfaces can't be recursive");
      ast_clearflag(entity, AST_FLAG_RECURSE_1);
      ast_setflag(entity, AST_FLAG_ERROR_1);
      return false;

    case AST_FLAG_DONE_1:
      return true;

    case AST_FLAG_ERROR_1:
      return false;

    default:
      assert(0);
      return false;
  }

  setup_local_methods(entity);

  bool r =
    delegated_methods(entity, opt) &&
    provided_methods(entity, opt) &&
    check_concrete_bodies(entity, opt);

  tidy_up(entity);
  ast_clearflag(entity, AST_FLAG_RECURSE_1);
  ast_setflag(entity, AST_FLAG_DONE_1);

  return r;
}
Ejemplo n.º 4
0
// Add provided methods to the given entity
static bool trait_entity(ast_t* entity, pass_opt_t* options)
{
  assert(entity != NULL);

  ast_state_t state = (ast_state_t)(uint64_t)ast_data(entity);

  // Check for recursive definitions
  switch(state)
  {
    case AST_STATE_INITIAL:
      ast_setdata(entity, (void*)AST_STATE_INPROGRESS);
      break;

    case AST_STATE_INPROGRESS:
      ast_error(entity, "traits and interfaces can't be recursive");
      ast_setdata(entity, (void*)AST_STATE_ERROR);
      return false;

    case AST_STATE_DONE:
      return true;

    case AST_STATE_ERROR:
      return false;

    default:
      assert(0);
      return false;
  }

  setup_local_methods(entity);

  bool r =
    provides_list(entity, options) && // Stage 1
    provided_methods(entity) &&       // Stage 2
    field_delegations(entity) &&      // Stage 3
    resolve_methods(entity, options); // Stage 4

  tidy_up(entity);
  ast_setdata(entity, r ? (void*)AST_STATE_DONE : (void*)AST_STATE_ERROR);

  return r;
}
Ejemplo n.º 5
0
void apply_boxes(BLOCK_LIST *block_list    //real blocks
                ) {
  INT16 boxfile_lineno = 0;
  INT16 boxfile_charno = 0;
  BOX box;                       //boxfile box
  char ch[2];                    //correct ch from boxfile
  ROW *row;
  ROW *prev_row = NULL;
  INT16 prev_box_right = MAX_INT16;
  INT16 block_id;
  INT16 row_id;
  INT16 box_count = 0;
  INT16 box_failures = 0;
  INT16 labels_ok;
  INT16 rows_ok;
  INT16 bad_blobs;
  INT16 tgt_char_counts[128];    //No. of box samples
  //      INT16                                   labelled_char_counts[128];      //No. of unique labelled samples
  INT16 i;
  INT16 rebalance_count = 0;
  char min_char;
  INT16 min_samples;
  INT16 final_labelled_blob_count;

  for (i = 0; i < 128; i++)
    tgt_char_counts[i] = 0;

  FILE* box_file;
  STRING filename = imagefile;
  filename += ".box";
  if (!(box_file = fopen (filename.string(), "r"))) {
    CANTOPENFILE.error ("read_next_box", EXIT,
      "Cant open box file %s %d",
      filename.string(), errno);
  }

  ch[1] = '\0';
  clear_any_old_text(block_list);
  while (read_next_box (box_file, &box, &ch[0])) {
    box_count++;
    tgt_char_counts[ch[0]]++;
    row = find_row_of_box (block_list, box, block_id, row_id);
    if (box.left () < prev_box_right) {
      boxfile_lineno++;
      boxfile_charno = 1;
    }
    else
      boxfile_charno++;

    if (row == NULL) {
      box_failures++;
      report_failed_box (boxfile_lineno, boxfile_charno, box, ch,
        "FAILURE! box overlaps no blobs or blobs in multiple rows");
    }
    else {
      if ((box.left () >= prev_box_right) && (row != prev_row))
        report_failed_box (boxfile_lineno, boxfile_charno, box, ch,
          "WARNING! false row break");
      box_failures += resegment_box (row, box, ch, block_id, row_id,
        boxfile_lineno, boxfile_charno);
      prev_row = row;
    }
    prev_box_right = box.right ();
  }
  tidy_up(block_list,
          labels_ok,
          rows_ok,
          bad_blobs,
          tgt_char_counts,
          rebalance_count,
          min_char,
          min_samples,
          final_labelled_blob_count);
  tprintf ("APPLY_BOXES:\n");
  tprintf ("   Boxes read from boxfile:  %6d\n", box_count);
  tprintf ("   Initially labelled blobs: %6d in %d rows\n",
    labels_ok, rows_ok);
  tprintf ("   Box failures detected:		%6d\n", box_failures);
  tprintf ("   Duped blobs for rebalance:%6d\n", rebalance_count);
  tprintf ("   \"%c\" has fewest samples:%6d\n", min_char, min_samples);
  tprintf ("				Total unlabelled words:   %6d\n",
    bad_blobs);
  tprintf ("				Final labelled words:     %6d\n",
    final_labelled_blob_count);
}
Ejemplo n.º 6
0
int main(int argc,char *argv[])
{
	unsigned int start = hz1000();
	char filename[200];
	double starttime, endtime;
	int sonogram;

	if(argc==2 && (strcmp(argv[1],"--version") == 0)) {
		fprintf(stdout,"%s\n",cdp_version);
		fflush(stdout);
		return 0;
	}
	/* initialise SFSYS	*/
	if( sflinit("paview") < 0 ) {
		fprintf(stdout,"ERROR: Cannot initialise soundfile system.\n");
		fflush(stdout);
		return tidy_up(3,start);
	}
	if(argc!=7)  {
		fprintf(stdout,"ERROR: Wrong number of arguments.\n");
		fflush(stdout);
		return tidy_up(2,start);
	}
	if(sscanf(argv[2],"%lf",&starttime)!=1) {
		fprintf(stdout,"ERROR: cannot read start time.\n");
		fflush(stdout);
		return tidy_up(2,start);
	}
	if(sscanf(argv[3],"%lf",&endtime)!=1) {
		fprintf(stdout,"ERROR: cannot read end time.\n");
		fflush(stdout);
		return tidy_up(2,start);
	}
	if(sscanf(argv[4],"%d",&sonogram)!=1) {
		fprintf(stdout,"ERROR: cannot read sonogram flag.\n");
		fflush(stdout);
		return tidy_up(2,start);
	}
	if(sscanf(argv[5],"%d",&startchan)!=1) {
		fprintf(stdout,"ERROR: cannot read sonogram flag.\n");
		fflush(stdout);
		return tidy_up(2,start);
	}
	if(sscanf(argv[6],"%d",&endchan)!=1) {
		fprintf(stdout,"ERROR: cannot read sonogram flag.\n");
		fflush(stdout);
		return tidy_up(2,start);
	}
	/* open input file */
	if(open_in(argv[1]) < 0)
		return tidy_up(2,start);

	startwin = (int)floor(starttime/frametime);
	endwin   = (int)ceil(endtime/frametime);

	strcpy(filename,argv[1]);

	/* get biggest buffer */
	if(get_big_buf() == 0)
		return tidy_up(1,start);
		
	/* max soundfiles */
	if(make_textfile(sonogram,filename)<0)
		return tidy_up(1,start);

	/* tidy up */
	return tidy_up(0,start);
}
Ejemplo n.º 7
0
/*
 * Produce a consensus trace from a specific region of this contig.
 */
Read *cons_trace(EdStruct *xx, int start, int end, int strand,
		 int match, int exception) {
    int *seqList, i, j, count, next;
    Read *r;
    int max_points = 10000;
    char *con = NULL;
    diff_cons_seq *rlist = NULL;
    char fileName[256];
    char t_type[5];
    int form;
    int offset = 0, w;

    /* Get the consensus sequence */
    if (NULL == (con = (char *)xmalloc(end - start + 2)))
	goto error;
    DBcalcConsensus(xx, start, end - start + 1, con, NULL, BOTH_STRANDS);

    /* Allocate a list of read pointers and positions */
    if (NULL == (rlist = (diff_cons_seq *)xcalloc(DBI_gelCount(xx),
						  sizeof(*rlist))))
	goto error;

    /* Allocate a read structure */
    if (NULL == (r = read_allocate(max_points, end - start + 1)))
	goto error;

    /* Derive the initial list of sequences covering the start point */
    count = 0;
    seqList = DBI_list(xx);
    for (i = 1;
	 i <= DBI_gelCount(xx) && DB_RelPos(xx, DBI_order(xx)[i]) <= start;
	 i++) {
	int seq = DBI_order(xx)[i];
	DBgetSeq(DBI(xx), seq);
	if (DB_RelPos(xx, seq) + DB_Length(xx, seq) > start &&
	    strand_matches(xx, seq, strand) &&
	    seq != exception) {
	    if (get_trace_path(xx, seq, fileName, t_type) == 0) {
		form = trace_type_str2int(t_type);
		rlist[count].r = read_reading(fileName, form);
		if (rlist[count].r) {
		    rlist[count].seq = DBgetSeq(DBI(xx), seq);
		    rlist[count].opos =
			get_trace_pos(rlist[count].r, xx, seq, 0,
				      DB_Start(xx, seq),
				      DB_Start(xx, seq) + DB_Length(xx, seq),
				      DB_Seq(xx, seq), 0);

		    seqList[count++] = seq;
		}
	    }
	}
    }
    if (i <= DBI_gelCount(xx))
	next = i;
    else
	next = 0;

    /*
     * Loop along the sequence updating seqList as we go.
     * At each point we know how many sequences there are so we can
     * produce the consensus from these sequences.
     */
    for (i = start; i <= end; i++) {
	w = do_cons_base(xx, con, i, start, count, seqList, rlist, r, offset,
			 match, &max_points);
	if (w == -1)
	    goto error;
	offset += w;

	/* Update seqList for the next position */
	if (i < end) {
	    /* Remove sequences */
	    for (j = 0; j < count; j++) {
		int seq = seqList[j];
		if (DB_RelPos(xx, seq) + DB_Length(xx, seq) - 1 <= i) {
		    read_deallocate(rlist[j].r);
		    xfree(rlist[j].opos);
		    memmove(&seqList[j], &seqList[j+1],
			    (count-1-j) * sizeof(*seqList));
		    memmove(&rlist[j], &rlist[j+1],
			    (count-1-j) * sizeof(*rlist));
		    count--;
		    j--;
		}
	    }

	    /* Add sequences */
	    while (next && DB_RelPos(xx, next) <= i+1) {
		/* printf("next=%d %d %d\n",
		       next, DB_RelPos(xx, next), i+1); */
		DBgetSeq(DBI(xx), next);
		if (strand_matches(xx, next, strand) &&
		    get_trace_path(xx, next, fileName, t_type) == 0) {
		    form = trace_type_str2int(t_type);
		    rlist[count].r = read_reading(fileName, form);
		    if (rlist[count].r) {
			rlist[count].seq = DBgetSeq(DBI(xx), next);
			rlist[count].opos =
			    get_trace_pos(rlist[count].r, xx, next, 0,
					  DB_Start(xx, next),
					  DB_Start(xx,next)+DB_Length(xx,next),
					  DB_Seq(xx, next), 0);

			seqList[count++] = next;
		    }
		}
		if (++next > DBI_gelCount(xx))
		    next = 0;
	    }
	}
    }

    for (i = 0; i < count; i++) {
	read_deallocate(rlist[i].r);
	xfree(rlist[i].opos);
    }

    tidy_up(r, end-start + 1, offset);

    xfree(con);
    xfree(rlist);
    return r;

 error:
    if (con) xfree(con);
    if (rlist) xfree(rlist);
    return NULL;
}