Esempio n. 1
0
void UmlActivityParameter::write(FileOut & out) {
  // write parameter def

  out.indent();
  out << "<ownedParameter name=\"";
  out.quote(name());
  out << '"';
  out.id(this);
  write_dir(out);
  write_effect(out);
  write_flags(out);
  out << ">\n";
  
  out.indent(+1);
  
  write_description_properties(out);
  write_multiplicity(out, multiplicity(), this);
  write_default_value(out, defaultValue(), this);
  UmlItem::write_type(out, type());
  
  out.indent(-1);

  out.indent();
  out << "</ownedParameter>\n";

  //write parameter node
  out.indent();
  out << "<node xmi:type=\"uml:ActivityParameterNode\" name =\"";
  out.quote(name());
  out << '"';
  out.id_prefix(this, "PARAMETER_NODE_");
  if (isControlType())
    out << " isControlType=\"true\"";
  write_ordering(out);
  write_selection(out);
  write_in_state(out);
  out << ">\n";
  out.indent(+1);

  UmlItem::write_type(out, type());

  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  
  for (unsigned i = 0; i != n; i += 1)
    ch[i]->write(out);

  out.indent(-1);
  out.indent();
  out << "</node>\n";

  unload();
}
Esempio n. 2
0
void UmlActivityObject::write(FileOut & out)
{
    const char * k = (parent()->kind() == anActivity)
                     ? "node" : "containedNode";

    out.indent();
    out << '<' << k << " xmi:type=\"uml:";

    WrapperStr st = stereotype();

    if (st == "datastore")
        out << "DataStoreNode";
    else if (st == "centralBuffer")
        out << "CentralBufferNode";
    else
        out << "ObjectNode";

    out << "\" name=\"";
    out.quote(name());
    out << '"';
    out.id(this);

    if (isControlType())
        out << " isControlType=\"true\"";

    write_ordering(out);
    write_selection(out);
    write_in_state(out);
    out << ">\n";

    out.indent(+1);

    write_description_properties(out);
    write_multiplicity(out, multiplicity(), this);
    UmlItem::write_type(out, type());

    const QVector<UmlItem*> ch = children();
    unsigned n = ch.size();

    for (unsigned i = 0; i != n; i += 1)
        ch[i]->write(out);

    write_incoming_flows(out);

    out.indent(-1);

    out.indent();
    out << "</" << k << ">\n";

    unload();
}
Esempio n. 3
0
int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
{
  uv_stdio_container_t proc_stdio[3];
  uv_process_options_t proc_opts;
  uv_process_t proc;
  uv_pipe_t proc_stdin, proc_stdout;
  uv_write_t write_req;
  int expected_exits = 1;
  ProcessData pdata = {
    .reading = false,
    .exited = 0,
    .old_mode = cur_tmode,
    .old_state = State,
    .shell_stdin = (uv_stream_t *)&proc_stdin,
    .wbuffer = NULL,
  };

  out_flush();
  if (opts & kShellOptCooked) {
    // set to normal mode
    settmode(TMODE_COOK);
  }

  // While the child is running, ignore terminating signals
  signal_reject_deadly();

  // Create argv for `uv_spawn`
  // TODO(tarruda): we can use a static buffer for small argument vectors. 1024
  // bytes should be enough for most of the commands and if more is necessary
  // we can allocate a another buffer
  proc_opts.args = shell_build_argv(cmd, extra_shell_arg);
  proc_opts.file = proc_opts.args[0];
  proc_opts.exit_cb = exit_cb;
  // Initialize libuv structures
  proc_opts.stdio = proc_stdio;
  proc_opts.stdio_count = 3;
  // Hide window on Windows :)
  proc_opts.flags = UV_PROCESS_WINDOWS_HIDE;
  proc_opts.cwd = NULL;
  proc_opts.env = NULL;

  // The default is to inherit all standard file descriptors(this will change
  // when the UI is moved to an external process)
  proc_stdio[0].flags = UV_INHERIT_FD;
  proc_stdio[0].data.fd = 0;
  proc_stdio[1].flags = UV_INHERIT_FD;
  proc_stdio[1].data.fd = 1;
  proc_stdio[2].flags = UV_INHERIT_FD;
  proc_stdio[2].data.fd = 2;

  if (opts & (kShellOptHideMess | kShellOptExpand)) {
    // Ignore the shell stdio(redirects to /dev/null on unixes)
    proc_stdio[0].flags = UV_IGNORE;
    proc_stdio[1].flags = UV_IGNORE;
    proc_stdio[2].flags = UV_IGNORE;
  } else {
    State = EXTERNCMD;

    if (opts & kShellOptWrite) {
      // Write from the current buffer into the process stdin
      uv_pipe_init(uv_default_loop(), &proc_stdin, 0);
      write_req.data = &pdata;
      proc_stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
      proc_stdio[0].data.stream = (uv_stream_t *)&proc_stdin;
    }

    if (opts & kShellOptRead) {
      // Read from the process stdout into the current buffer
      uv_pipe_init(uv_default_loop(), &proc_stdout, 0);
      proc_stdout.data = &pdata;
      proc_stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
      proc_stdio[1].data.stream = (uv_stream_t *)&proc_stdout;
      ga_init(&pdata.ga, 1, BUFFER_LENGTH);
    }
  }

  if (uv_spawn(uv_default_loop(), &proc, &proc_opts)) {
    // Failed, probably due to `sh` not being executable
    if (!emsg_silent) {
      MSG_PUTS(_("\nCannot execute shell "));
      msg_outtrans(p_sh);
      msg_putchar('\n');
    }

    return proc_cleanup_exit(&pdata, &proc_opts, opts);
  }

  // Assign the flag address after `proc` is initialized by `uv_spawn`
  proc.data = &pdata;

  if (opts & kShellOptWrite) {
    // Queue everything for writing to the shell stdin
    write_selection(&write_req);
    expected_exits++;
  }

  if (opts & kShellOptRead) {
    // Start the read stream for the shell stdout
    uv_read_start((uv_stream_t *)&proc_stdout, alloc_cb, read_cb);
    expected_exits++;
  }

  // Keep running the loop until all three handles are completely closed
  while (pdata.exited < expected_exits) {
    uv_run(uv_default_loop(), UV_RUN_ONCE);

    if (got_int) {
      // Forward SIGINT to the shell
      // TODO(tarruda): for now this is only needed if the terminal is in raw
      // mode, but when the UI is externalized we'll also need it, so leave it
      // here
      uv_process_kill(&proc, SIGINT);
      got_int = false;
    }
  }

  if (opts & kShellOptRead) {
    if (pdata.ga.ga_len > 0) {
      // If there's an unfinished line in the growable array, append it now.
      append_ga_line(&pdata.ga);
      // remember that the NL was missing
      curbuf->b_no_eol_lnum = curwin->w_cursor.lnum;
    } else {
      curbuf->b_no_eol_lnum = 0;
    }
    ga_clear(&pdata.ga);
  }

  if (opts & kShellOptWrite) {
    free(pdata.wbuffer);
  }

  return proc_cleanup_exit(&pdata, &proc_opts, opts);
}

static int tokenize(char_u *str, char **argv)
{
  int argc = 0, len;
  char_u *p = str;

  while (*p != NUL) {
    len = word_length(p);

    if (argv != NULL) {
      // Fill the slot
      argv[argc] = xmalloc(len + 1);
      memcpy(argv[argc], p, len);
      argv[argc][len] = NUL;
    }

    argc++;
    p += len;
    p = skipwhite(p);
  }

  return argc;
}
Esempio n. 4
0
int
main(int argc, char **argv)
{
	int nocol_short, nocol_long, nocol_float, nocol_double;
	int status;
	char **argval, **arglabel;
	int i, nbrow = NBROW, nbcol=NBCOL, sel[NBROW];
	short sval, s_colbuf[NBROW], s_key;
	long lval, l_colbuf[NBROW];
	float fval, f_colbuf[NBROW];
	double dval, d_colbuf[NBROW];
	char ident[20];
	char selection[30];
	TABLE table;

						/*  init_session() checking */	


	printf("IOLIB environment routines :\n\n");
	fflush(stdout);
	init_session(argv,argc,&arglabel,&argval);
/* 	set_control_level(WARNING); */

	printf("Table creation ...");
	fflush(stdout);
	strcpy(ident,"Dummy table");
	create_table(&table,"chk_tbl_io",nbrow,nbcol,'W',ident);
	printf("Ok\n");
	fflush(stdout);
/*
	printf("Column creation ...(format Characters) ");
	fflush(stdout);
	nocol_char = create_col(&table,":TEXT",CHAR,'N',"A20",NULL);
	if (nocol_char < 0) {
		printf("Problem creating column TEXT, status returned = %d\n", nocol_char);
		exit (-1);
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Writing into created column ...");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		sprintf(text,"String no %2d",i);
		WR_tbl(&table,i,nocol_char,text);
	}
	printf("Ok\n");
	fflush(stdout);
*/
	printf("Column creation ...(format Short) ");
	fflush(stdout);
	nocol_short = create_col(&table,":SHORT",SHORT,'N',"I2",NULL);
	if (nocol_short < 0) {
		printf("Problem creating column SHORT, status returned = %d\n", nocol_short);
		exit (-1);
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Writing into created column ...");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		sval = (short)i;
		WR_tbl(&table,i,nocol_short,&sval);
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Column creation ...(format Long) ");
	fflush(stdout);
	nocol_long = create_col(&table,":LONG",LONG,'N',"I4",NULL);
	if (nocol_long < 0) {
		printf("Problem creating column LONG, status returned = %d\n", nocol_long);
		exit (-1);
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Writing into created column ...");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		lval = (long)i;
		WR_tbl(&table,i,nocol_long,&lval);
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Column creation ...(format Float) ");
	fflush(stdout);
	nocol_float = create_col(&table,":FLOAT",FLOAT,'N',"F9.6",NULL);
	if (nocol_float < 0) {
		printf("Problem creating column FLOAT, status returned = %d\n", nocol_float);
		exit (-1);
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Writing into created column ...");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		fval = (float)i;
		WR_tbl(&table,i,nocol_float,&fval);
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Column creation ...(format Double) ");
	fflush(stdout);
	nocol_double = create_col(&table,":DOUBLE",DOUBLE,'N',"E15.5",NULL);
	if (nocol_double < 0) {
		printf("Problem creating column DOUBLE, status returned = %d\n", nocol_double);
		exit (-1);
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Writing into created column ...");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		dval = (double)i;
		WR_tbl(&table,i,nocol_double,&dval);
	}
	printf("Ok\n\n");
	fflush(stdout);

	for (i=0; i<nbrow; i++) {
		if (i%2 == 0)
			sel[i] = 0;
		else
			sel[i] = 1;
	}
	write_selection(&table,sel,"check_selection");

	printf("Saving created table ...");
	fflush(stdout);
	close_table(&table);
	printf("Ok\n");
	fflush(stdout);

	printf("Opening previous table ...");
	fflush(stdout);
	open_table(&table,"chk_tbl_io","I");
	printf("Ok\n");
	fflush(stdout);

	printf("Handling selection ...");
	fflush(stdout);
	handle_select_flag(&table,'W',selection);
	printf("Ok\n");
	fflush(stdout);

	printf("Reading columns info ...");
	fflush(stdout);
/*	nocol_char = get_col_ref(&table,":TEXT"); */
	nocol_short = get_col_ref(&table,":SHORT");
	nocol_long = get_col_ref(&table,":LONG");
	nocol_float = get_col_ref(&table,":FLOAT");
	nocol_double = get_col_ref(&table,":DOUBLE");
	printf("Ok\n");
	nbrow = table.row;
/*
	printf("Reading previous column ...(format Characters) ");
	fflush(stdout);
	RD_col(&table,nocol_char,c_colbuf);
	for (i=0; i<nbrow; i++) {
		sprintf(text,"String no %2d",i);
		if (strcmp(text,(c_colbuf+i*21)) != 0) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			return(-1);
		}
	}
	printf("Ok\n");

	printf("Reading previous column item by item  ...(format Characters) ");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		RD_tbl(&table,i,nocol_char,Rtext);
		sprintf(text,"String no %2d",i);
		if (strcmp(text,Rtext) != 0) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			printf("*%s* is not *%s*\n", Rtext, text);
	 	return(-1); 
		}
	}
	printf("Ok\n");
*/
	printf("Reading previous column ...(format Short) ");
	fflush(stdout);
	s_colbuf[0] = 0;
	RD_col(&table,nocol_short,s_colbuf);
	printf("Ok\n");

	printf("Searching for no 501 ... ");
	fflush(stdout);
	
	s_key = 501;
	status = search_in_col(&table,nocol_short,&s_key);
	if (status >= 0)
		printf("Found in line %d\n",status);
	else {
		printf("Unable to find it\n");
		return(-1);
	}
	
	printf("Searching for no 500 ... ");
	fflush(stdout);
	
	s_key = 500;
	status = search_in_col(&table,nocol_short,&s_key);
	if (status >= 0)
		printf("Found in line %d\n",status);
	else {
		printf("Unable to find it (not selected)\n");
	}

	for (i=0; i<nbrow; i++) {
		if (s_colbuf[i] != (short)(2*i+1)) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			printf("Read %d, Expected %d\n",s_colbuf[i],2*i+1);
			return(-1);
		}
	}
	printf("Ok\n");
	printf("Reading previous column item by item ...(format Short) ");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		RD_tbl(&table,i,nocol_short,&sval);
		if (sval != (short)(2*i+1)) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			return(-1);
		}
	}
	printf("Ok\n");

	printf("Reading previous column ..(format Long) ");
	fflush(stdout);
	RD_col(&table,nocol_long,l_colbuf);
	for (i=0; i<nbrow; i++) {
		if (l_colbuf[i] != (long)(2*i+1)) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			return(-1);
		}
	}
	printf("Ok\n");
	printf("Reading previous column item by item ...(format Long) ");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		RD_tbl(&table,i,nocol_long,&lval);
		if (lval != (long)(2*i+1)) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			return(-1);
		}
	}
	printf("Ok\n");

	printf("Reading previous column ...(format Float) ");
	fflush(stdout);
	RD_col(&table,nocol_float,f_colbuf);
	for (i=0; i<nbrow; i++) {
		if (f_colbuf[i] != (float)(2*i+1)) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			return(-1);
		}
	}
	printf("Ok\n");
	printf("Reading previous column item by item ...(format Float) ");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		RD_tbl(&table,i,nocol_float,&fval);
		if (fval != (float)(2*i+1)) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			return(-1);
		}
	}
	printf("Ok\n");

	printf("Reading previous column ..(format Double) ");
	fflush(stdout);
	RD_col(&table,nocol_double,d_colbuf);
	for (i=0; i<nbrow; i++) {
		if (ABS(d_colbuf[i] - (double)(2*i+1)) > 1e-8) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			return(-1);
		}
	}
	printf("Ok\n");
	printf("Reading previous column item by item ...(format Double) ");
	fflush(stdout);
	for (i=0; i<nbrow; i++) {
		RD_tbl(&table,i,nocol_double,&dval);
		if (ABS(dval - (double)(2*i+1)) > 1e-8) {
			printf("FATAL : Unexpected values in table, line %d\n",i);
			return(-1);
		}
	}
	printf("Ok\n");
	fflush(stdout);

	printf("Deleting previous table ...");
	fflush(stdout);
	delete_table(&table);
	printf("Ok\n");
	fflush(stdout);

	exit_session(0);
	return(0);
}