Esempio n. 1
0
static void write_function_type(const function_type_t *type)
{
	fprintf(out, "(func(");

	function_parameter_t *parameter = type->parameters;
	int                   first     = 1;
	while(parameter != NULL) {
		if(!first) {
			fprintf(out, ", ");
		} else {
			first = 0;
		}

#if 0
		if(parameter->symbol != NULL) {
			fprintf(out, "%s : ", parameter->symbol->string);
		} else {
			/* TODO make up some unused names (or allow _ in fluffy?) */
			fprintf(out, "_ : ");
		}
#endif
		fputs("_ : ", out);
		write_type(parameter->type);

		parameter = parameter->next;
	}

	fprintf(out, ") : ");
	write_type(type->return_type);
	fprintf(out, ")");
}
Esempio n. 2
0
void test() {
  /* Matrix:
   * 0 1 0
   * 0 | 0
   * 1 & 1
   * 0 1 0 */

  printf("Test: Sblock Matrix\n");

  write_lut(LUT_SELF, 0);
  write_lut(LUT_AND4, 1);
  write_lut(LUT_OR,   2);

  write_type(0,1,1, 2);
  write_type(0,2,1, 1);

  write_state(0,0,1, 1);
  write_state(0,2,0, 1);
  write_state(0,2,2, 1);
  write_state(0,3,1, 1);

  swap_cell_storage();
  config();

  step(1);
  readback();

  swap_cell_storage();
  read_state(0,0,1);
  read_state(0,1,1);
  read_state(0,2,1);
  read_state(0,3,1);

  step(1);
  readback();

  swap_cell_storage();
  read_state(0,0,1);
  read_state(0,1,1);
  read_state(0,2,1);
  read_state(0,3,1);

  assert_uint32(1, get_state());
  assert_uint32(1, get_state());
  assert_uint32(0, get_state());
  assert_uint32(1, get_state());

  assert_uint32(1, get_state());
  assert_uint32(1, get_state());
  assert_uint32(1, get_state());
  assert_uint32(1, get_state());
}
static gboolean
do_typedef(TreeState *state)
{
    IDL_tree type = IDL_TYPE_DCL(state->tree).type_spec;
    IDL_tree dcls = IDL_TYPE_DCL(state->tree).dcls;
    IDL_tree complex;
    GSList *doc_comments;

    if (IDL_NODE_TYPE(type) == IDLN_TYPE_SEQUENCE) {
        XPIDL_WARNING((state->tree, IDL_WARNING1,
                       "sequences not supported, ignored"));
    } else {
        if (IDL_NODE_TYPE(complex = IDL_LIST(dcls).data) == IDLN_TYPE_ARRAY) {
            IDL_tree dim = IDL_TYPE_ARRAY(complex).size_list;
            doc_comments = IDL_IDENT(IDL_TYPE_ARRAY(complex).ident).comments;

            if (doc_comments != NULL)
                printlist(state->file, doc_comments);

            fputs("typedef ", state->file);
            if (!write_type(type, FALSE, state->file))
                return FALSE;
            fputs(" ", state->file);

            fprintf(state->file, "%s",
                    IDL_IDENT(IDL_TYPE_ARRAY(complex).ident).str);
            do {
                fputc('[', state->file);
                if (IDL_LIST(dim).data) {
                    fprintf(state->file, "%ld",
                            (long)IDL_INTEGER(IDL_LIST(dim).data).value);
                }
                fputc(']', state->file);
            } while ((dim = IDL_LIST(dim).next) != NULL);
        } else {
            doc_comments = IDL_IDENT(IDL_LIST(dcls).data).comments;

            if (doc_comments != NULL)
                printlist(state->file, doc_comments);

            fputs("typedef ", state->file);
            if (!write_type(type, FALSE, state->file))
                return FALSE;
            fputs(" ", state->file);
            fputs(IDL_IDENT(IDL_LIST(dcls).data).str, state->file);
        }
        fputs(";\n\n", state->file);
    }
    return TRUE;
}
Esempio n. 4
0
/* <typeOfReference></typeOfReference> */
static int
get_type_issuance( fields *f, param *p )
{
	int type = TYPE_UNKNOWN;
	int i, monographic = 0, monographic_level = 0;
//	int text = 0;
	for ( i=0; i<f->n; ++i ) {
		if ( !strcasecmp( f->tag[i].data, "issuance" ) &&
		     !strcasecmp( f->data[i].data, "MONOGRAPHIC" ) ){
			monographic = 1;
			monographic_level = f->level[i];
		}
//		if ( !strcasecmp( f->tag[i].data, "typeOfResource" ) &&
//		     !strcasecmp( f->data[i].data,"text") ) {
//			text = 1;
//		}
	}
//	if ( monographic && text ) {
	if ( monographic ) {
		if ( monographic_level==0 ) type=TYPE_BOOK;
		else if ( monographic_level>0 ) type=TYPE_INBOOK;
	}

	if ( p->verbose ) {
		if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
		fprintf( stderr, "Type from issuance/typeOfReference elements: " );
		write_type( stderr, type );
		fprintf( stderr, "\n" );
	}

	return type;
}
Esempio n. 5
0
void UmlOperation::write_cpp_returntype(FileOut & out, QCString decl) {
  // doesn't manage function pointer
  // manage keywords
  int index;
  
  if ((index = decl.find("${static}")) != -1)
    decl.remove(index, 9);
  
  if ((index = decl.find("${friend}")) != -1)
    decl.remove(index, 9);
  
  if ((index = decl.find("${virtual}")) != -1)
    decl.remove(index, 10);
  
  if ((index = decl.find("${inline}")) != -1)
    decl.remove(index, 9);
  
  if ((index = decl.find("${(}")) == -1)
    decl = "${type} ${name}";
  else
    decl.truncate(index);
  
  UmlTypeSpec t = returnType();
  
  if ((t.type != 0) ||
      !(t.explicit_type = CppSettings::type(t.explicit_type)).isEmpty())
    write_type(out, t, decl, "${name}", "${type}");
}
Esempio n. 6
0
void UmlOperation::write_java_returntype(FileOut & out, QCString decl) {
// manage keywords
int index;

if ((index = decl.find("${visibility}")) != -1)
  decl.remove(index, 13);

if ((index = decl.find("${final}")) != -1)
  decl.remove(index, 8);

if ((index = decl.find("${static}")) != -1)
  decl.remove(index, 9);

if ((index = decl.find("${abstract}")) != -1)
  decl.remove(index, 11);

if ((index = decl.find("${synchronized}")) != -1)
  decl.remove(index, 15);

if ((index = decl.find("${@}")) != -1)
  decl.remove(index, 4);

if ((index = decl.find("${(}")) == -1)
  decl = "${type} ${name}";
else
  decl.truncate(index);

UmlTypeSpec t = returnType();

if ((t.type != 0) ||
    !(t.explicit_type = JavaSettings::type(t.explicit_type)).isEmpty())
  write_type(out, t, decl, "${name}", "${type}");
}
Esempio n. 7
0
void UmlAttribute::write_cpp_type(FileOut & out)
{
    // note : doesn't manage function/operation pointer
    Q3CString s = cppDecl();
    int index;

    remove_comments(s);

    // remove keywords not linked to the type
    if ((index = s.find("${static}")) != -1)
        s.replace(index, 9, " ");

    if ((index = s.find("${mutable}")) != -1)
        s.replace(index, 10, (isCppMutable()) ? "mutable " : "");

    if ((index = s.find("${volatile}")) != -1)
        s.replace(index, 11, (isVolatile()) ? "volatile " : "");

    if ((index = s.find("${value}")) != -1)
        s.replace(index, 8, " ");

    if ((index = s.find("${h_value}")) != -1)
        s.replace(index, 10, " ");

    // replace keywords linked to the type
    if ((index = s.find("${const}")) != -1)
        s.replace(index, 8, isReadOnly() ? "const" : "");

    UmlTypeSpec t = type();

    if (t.type == 0)
        t.explicit_type = CppSettings::type(t.explicit_type);

    write_type(out, t, s, "${name}", "${type}");
}
Esempio n. 8
0
void UmlOperation::write_cpp_java_params(FileOut & out, QCString decl) {
  int index1 = decl.find("${(}");
    
  if (index1 == -1)
    return;
    
  int index2 = decl.find("${)}", index1 + 4);
    
  if (index2 == -1)
    return;
    
  decl = decl.mid(index1 + 4, index2 - index1 - 4);
    
  index1 = 0;
    
  const QValueList<UmlParameter> p = params();
  QCString sparam;
  QCString kname;
  QCString ktype;
  int rank;
    
  if ((name() == "unload") && (parent()->name() == "UmlBasePackage"))
    rank = 123;
    
  while (get_param(decl, index1, sparam, kname, ktype, rank)) {
    if (rank < (int) p.count()) {
      const UmlParameter & pa = p[rank];
      
      out.indent();
      out << "<UML:Parameter name=\"" << pa.name
	<< "\" xmi.id=\"BOUML_op_param_"
	  << ++param_id << "\" kind =\"";
      switch (pa.dir) {
      case InputOutputDirection: out << "inout\">\n"; break;
      case OutputDirection: out << "out\">\n"; break;
      default: out << "in\">\n";
      }
      
      UmlTypeSpec t = pa.type;
      
      if ((t.type != 0) ||
	  !(t.explicit_type = (_lang == Cpp)
	    ? CppSettings::type(t.explicit_type)
	    : JavaSettings::type(t.explicit_type)).isEmpty()) {
	out.indent();
	out << "\t<UML:Parameter.type>\n";
	out.indent();
	out << "\t\t<UML:DataType";
	write_type(out, t, sparam, kname, ktype);
	out << "/>\n";
	out.indent();
	out << "\t</UML:Parameter.type>\n";
      }
      
      out.indent();
      out << "</UML:Parameter>\n";
    }
  }
}
Esempio n. 9
0
static void write_function(const entity_t *entity)
{
	if (entity->function.statement != NULL) {
		fprintf(stderr, "Warning: can't convert function bodies (at %s)\n",
		        entity->base.symbol->string);
	}

	fprintf(out, "func extern %s(", entity->base.symbol->string);

	const function_type_t *function_type
		= (const function_type_t*) entity->declaration.type;

	entity_t *parameter = entity->function.parameters.entities;
	int       first     = 1;
	for( ; parameter != NULL; parameter = parameter->base.next) {
		assert(parameter->kind == ENTITY_PARAMETER);
		if(!first) {
			fprintf(out, ", ");
		} else {
			first = 0;
		}
		if(parameter->base.symbol != NULL) {
			fprintf(out, "%s : ", parameter->base.symbol->string);
		} else {
			fputs("_ : ", out);
		}
		write_type(parameter->declaration.type);
	}
	if(function_type->variadic) {
		if(!first) {
			fprintf(out, ", ");
		} else {
			first = 0;
		}
		fputs("...", out);
	}
	fprintf(out, ")");

	const type_t *return_type = skip_typeref(function_type->return_type);
	if(!is_type_atomic(return_type, ATOMIC_TYPE_VOID)) {
		fprintf(out, " : ");
		write_type(return_type);
	}
	fputc('\n', out);
}
Esempio n. 10
0
	Stream Stream::create( const char* path, utf_t type )
	{
		FILE* file = fopen( path, "wt" );
		if( file == 0 ) throw File_Open_Failed( path );

		write_type( file, type );

		return Stream( file, type, true );
	}
Esempio n. 11
0
/* If notype is true, just write the param name. */
static gboolean
write_param(IDL_tree param_tree, FILE *outfile)
{
    IDL_tree param_type_spec = IDL_PARAM_DCL(param_tree).param_type_spec;
    gboolean is_in = IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_IN;
    /* in string, wstring, nsid, domstring, utf8string, cstring and 
     * astring any explicitly marked [const] are const 
     */

    if (is_in &&
        (IDL_NODE_TYPE(param_type_spec) == IDLN_TYPE_STRING ||
         IDL_NODE_TYPE(param_type_spec) == IDLN_TYPE_WIDE_STRING ||
         IDL_tree_property_get(IDL_PARAM_DCL(param_tree).simple_declarator,
                               "const") ||
         IDL_tree_property_get(param_type_spec, "nsid") ||
         IDL_tree_property_get(param_type_spec, "domstring")  ||
         IDL_tree_property_get(param_type_spec, "utf8string") ||
         IDL_tree_property_get(param_type_spec, "cstring")    ||
         IDL_tree_property_get(param_type_spec, "astring"))) {
        fputs("const ", outfile);
    }
    else if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_OUT &&
             IDL_tree_property_get(IDL_PARAM_DCL(param_tree).simple_declarator, 
                                   "shared")) {
        fputs("const ", outfile);
    }

    if (!write_type(param_type_spec, !is_in, outfile))
        return FALSE;

    /* unless the type ended in a *, add a space */
    if (!STARRED_TYPE(param_type_spec))
        fputc(' ', outfile);

    /* out and inout params get a bonus '*' (unless this is type that has a 
     * 'dipper' class that is passed in to receive 'out' data) 
     */
    if (IDL_PARAM_DCL(param_tree).attr != IDL_PARAM_IN &&
        !DIPPER_TYPE(param_type_spec)) {
        fputc('*', outfile);
    }
    /* arrays get a bonus * too */
    /* XXX Should this be a leading '*' or a trailing "[]" ?*/
    if (IDL_tree_property_get(IDL_PARAM_DCL(param_tree).simple_declarator,
                              "array"))
        fputc('*', outfile);

    fputs(IDL_IDENT(IDL_PARAM_DCL(param_tree).simple_declarator).str, outfile);

    if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_OUT) {
        fputs(" NS_OUTPARAM", outfile);
    } else if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_INOUT) {
        fputs(" NS_INOUTPARAM", outfile);
    }

    return TRUE;
}
Esempio n. 12
0
/*
 *  AS_DECL writes 'NS_IMETHOD foo(string bar, long sil)'
 *  AS_IMPL writes 'NS_IMETHODIMP className::foo(string bar, long sil)'
 *  AS_CALL writes 'foo(bar, sil)'
 */
static gboolean
write_attr_accessor(IDL_tree attr_tree, FILE * outfile,
                    gboolean getter, int mode, const char *className)
{
    char *attrname = ATTR_IDENT(attr_tree).str;
    const char *binaryname;
    IDL_tree ident = IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data;

    if (mode == AS_DECL) {
        if (IDL_tree_property_get(ident, "deprecated"))
            fputs("NS_DEPRECATED ", outfile);
        if (is_method_scriptable(attr_tree, ident))
            fputs("NS_SCRIPTABLE ", outfile);

        fputs("NS_IMETHOD ", outfile);
    } else if (mode == AS_IMPL) {
        fprintf(outfile, "NS_IMETHODIMP %s::", className);
    }
    fprintf(outfile, "%cet",
            getter ? 'G' : 'S');
    binaryname = IDL_tree_property_get(ATTR_DECLS(attr_tree), "binaryname");
    if (binaryname) {
        fprintf(outfile, "%s(",
                binaryname);
    } else {
        fprintf(outfile, "%c%s(",
                toupper(*attrname),
                attrname + 1);
    }
    if (mode == AS_DECL || mode == AS_IMPL) {
        /* Setters for string, wstring, nsid, domstring, utf8string, 
         * cstring and astring get const. 
         */
        if (!getter &&
            (IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_STRING ||
             IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_WIDE_STRING ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "nsid") ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "domstring")  ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "utf8string") ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "cstring")    ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "astring")))
        {
            fputs("const ", outfile);
        }

        if (!write_type(ATTR_TYPE_DECL(attr_tree), getter, outfile))
            return FALSE;
        fprintf(outfile, "%s%s",
                (STARRED_TYPE(attr_tree) ? "" : " "),
                (getter && !DIPPER_TYPE(ATTR_TYPE_DECL(attr_tree)))? "*" : "");
    }
    fprintf(outfile, "a%c%s)", toupper(attrname[0]), attrname + 1);
    return TRUE;
}
Esempio n. 13
0
File: lct.c Progetto: jbailhache/log
write_type (type t, struct put_fnct *put)
{
	switch (t->k)
	{
		case TYPE_ORD:
			sput ("O", put);
			break;
		case TYPE_FNC:
			if (t->fnc.arg->k == TYPE_FNC)
				sput ("(", put);
			write_type (t->fnc.arg, put);
			if (t->fnc.arg->k == TYPE_FNC)
				sput (")", put);
			sput ("->", put);
			write_type (t->fnc.res, put);
			break;
		default:
			sput ("?", put);
	}
}
Esempio n. 14
0
/* Try to determine type of reference from
 * <TypeOfResource></TypeOfResource>
 */
static int
get_type_resource( fields *f, param *p )
{
	match_type match_res[] = {
		{ "software, multimedia",      TYPE_PROGRAM },
		{ "cartographic",              TYPE_MAP     },
	};
	int nmatch_res = sizeof( match_res ) / sizeof( match_res[0] );
	int type, i, j;
	char *value;
	vplist a;

	type = TYPE_UNKNOWN;

	vplist_init( &a );
	fields_findv_each( f, LEVEL_ANY, FIELDS_CHRP, &a, "RESOURCE" );

	for ( i=0; i<a.n; ++i ) {
		value = ( char * ) vplist_get( &a, i );
		for ( j=0; j<nmatch_res; ++j ) {
			if ( !strcasecmp( value, match_res[j].name ) )
				type = match_res[j].type;
		}
		if ( p->verbose ) {
			if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
			fprintf( stderr, "Type from tag 'RESOURCE' data '%s': ", value );
			write_type( stderr, type );
			fprintf( stderr, "\n" );
		}
	}

	if ( p->verbose ) {
		if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
		fprintf( stderr, "Type from resource element: " );
		write_type( stderr, type );
		fprintf( stderr, "\n" );
	}

	vplist_free( &a );
	return type;
}
Esempio n. 15
0
File: lct.c Progetto: jbailhache/log
term ap (term fnc, term arg)
{
type tf, ta;
	tf = type_term (fnc);
	if (tf->k != TYPE_FNC)
		sput ("ap: invalid function\n", err);
	ta = type_term (arg);
	if (!equal_type (ta, tf->fnc.arg))
	{
		sput ("ap: bad type\n\tfunction ", err);
		write_term (fnc, err);
		sput (" has type ", err);
		write_type (tf, err);
		sput ("\n\targument ", err);
		write_term (arg, err);
		sput (" has type ", err);
		write_type (ta, err);
		sput ("\n", err);
	}
	return ap1 (fnc, arg);
}
Esempio n. 16
0
static void write_function(const entity_t *entity)
{
	if (entity->function.body != NULL) {
		fprintf(stderr, "Warning: can't convert function bodies (at %s)\n",
		        entity->base.symbol->string);
		return;
	}


	const function_type_t *function_type
		= (const function_type_t*) entity->declaration.type;

	fputc('\n', out);
	fprintf(out, "\tpublic static native ");
	type_t *return_type = skip_typeref(function_type->return_type);
	write_type(return_type);
	fprintf(out, " %s(", entity->base.symbol->string);

	entity_t   *parameter = entity->function.parameters.entities;
	separator_t sep       = { "", ", " };
	int         n         = 0;
	for ( ; parameter != NULL; parameter = parameter->base.next) {
		assert(parameter->kind == ENTITY_PARAMETER);
		fputs(sep_next(&sep), out);
		write_type(parameter->declaration.type);
		if (parameter->base.symbol != NULL) {
			fprintf(out, " %s", fix_builtin_names(parameter->base.symbol->string));
		} else {
			fprintf(out, " _%d", n++);
		}
	}
	if (function_type->variadic) {
		fputs(sep_next(&sep), out);
		fputs("Object ... args", out);
	}
	fprintf(out, ");\n");
}
Esempio n. 17
0
static int write_entries(scconf_context * config, scconf_block * block, scconf_entry * entry, int depth)
{
	int r, idx;
	scconf_entry *e;

	if (config->debug) {
		fprintf(stderr, "write_entries called, depth %d\n", depth);
	}
	for (idx = 0; entry[idx].name; idx++) {
		e = &entry[idx];
		r = write_type(config, block, e, depth);
		if (r) {
			return r;
		}
	}
	return 0;
}
Esempio n. 18
0
File: lct.c Progetto: jbailhache/log
type type_term (term x)
{
type t;
#ifdef TRACE
	sput ("Type of ", err);
	write_term (x, err);
	sput ("...\n", err);
#endif
	t = type_term_1 (x);
#ifdef TRACE
	sput ("type of ", err);
	write_term (x, err);
	sput ("is ", err);
	write_type (t, err);
	sput (".\n", err);
#endif
	return t;
}
/*
 *  AS_DECL writes 'NS_IMETHOD foo(string bar, long sil)'
 *  AS_IMPL writes 'NS_IMETHODIMP className::foo(string bar, long sil)'
 *  AS_CALL writes 'foo(bar, sil)'
 */
static gboolean
write_attr_accessor(IDL_tree attr_tree, FILE * outfile,
                    gboolean getter, int mode, const char *className)
{
    char *attrname = ATTR_IDENT(attr_tree).str;

    if (mode == AS_DECL) {
        fputs("NS_IMETHOD ", outfile);
    } else if (mode == AS_IMPL) {
        fprintf(outfile, "NS_IMETHODIMP %s::", className);
    }
    fprintf(outfile, "%cet%c%s(",
            getter ? 'G' : 'S',
            toupper(*attrname), attrname + 1);
    if (mode == AS_DECL || mode == AS_IMPL) {
        /* Setters for string, wstring, nsid, domstring, utf8string, 
         * cstring and astring get const. 
         */
        if (!getter &&
            (IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_STRING ||
             IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_WIDE_STRING ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "nsid") ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "domstring")  ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "utf8string") ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "cstring")    ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "astring")))
        {
            fputs("const ", outfile);
        }

        if (!write_type(ATTR_TYPE_DECL(attr_tree), getter, outfile))
            return FALSE;
        fprintf(outfile, "%s%s",
                (STARRED_TYPE(attr_tree) ? "" : " "),
                (getter && !DIPPER_TYPE(ATTR_TYPE_DECL(attr_tree)))? "*" : "");
    }
    fprintf(outfile, "a%c%s)", toupper(attrname[0]), attrname + 1);
    return TRUE;
}
Esempio n. 20
0
static int
get_type( fields *f, param *p )
{
	int type;
	type = get_type_genre( f, p );
	if ( type==TYPE_UNKNOWN ) type = get_type_resource( f, p );
	if ( type==TYPE_UNKNOWN ) type = get_type_issuance( f, p );
	if ( type==TYPE_UNKNOWN ) {
		if ( fields_maxlevel( f ) > 0 ) type = TYPE_INBOOK;
		else type = TYPE_STD;
	}

	if ( p->verbose ) {
		if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
		fprintf( stderr, "Final type: " );
		write_type( stderr, type );
		fprintf( stderr, "\n" );
	}


	return type;
}
Esempio n. 21
0
void UmlAttribute::write_java_type(FileOut & out)
{
    Q3CString s = javaDecl();
    int index;

    remove_comments(s);

    // remove keywords not linked to the type
    if ((index = s.find("${visibility}")) != -1)
        s.replace(index, 13, " ");

    if ((index = s.find("${static}")) != -1)
        s.replace(index, 9, " ");

    if ((index = s.find("${final}")) != -1)
        s.replace(index, 8, " ");

    if ((index = s.find("${transient}")) != -1)
        s.replace(index, 12, " ");

    if ((index = s.find("${volatile}")) != -1)
        s.replace(index, 11, " ");

    if ((index = s.find("${value}")) != -1)
        s.replace(index, 8, " ");

    if ((index = s.find("${@}")) != -1)
        s.replace(index, 4, " ");

    UmlTypeSpec t = type();

    if (t.type == 0)
        t.explicit_type = JavaSettings::type(t.explicit_type);

    write_type(out, t, s, "${name}", "${type}");
}
Esempio n. 22
0
/* Try to determine type of reference from
 * <genre></genre>
 */
static int
get_type_genre( fields *f, param *p )
{
	match_type match_genres[] = {
		{ "academic journal",          TYPE_ARTICLE },
		{ "article",                   TYPE_ARTICLE },
		{ "journal article",           TYPE_ARTICLE },
		{ "magazine",                  TYPE_MAGARTICLE },
		{ "conference publication",    TYPE_CONF },
		{ "newspaper",                 TYPE_NEWS },
		{ "legislation",               TYPE_STATUTE },
		{ "communication",             TYPE_PCOMM },
		{ "hearing",                   TYPE_HEAR },
		{ "electronic",                TYPE_ELEC },
		{ "legal case and case notes", TYPE_CASE },
		{ "book chapter",              TYPE_INBOOK },
		{ "Ph.D. thesis",              TYPE_PHDTHESIS },
		{ "Masters thesis",            TYPE_MASTERSTHESIS },
		{ "Diploma thesis",            TYPE_DIPLOMATHESIS },
		{ "Doctoral thesis",           TYPE_DOCTORALTHESIS },
		{ "Habilitation thesis",       TYPE_HABILITATIONTHESIS },
		{ "report",                    TYPE_REPORT },
		{ "abstract or summary",       TYPE_ABSTRACT },
		{ "patent",                    TYPE_PATENT },
		{ "unpublished",               TYPE_UNPUBLISHED },
		{ "map",                       TYPE_MAP },
	};
	int nmatch_genres = sizeof( match_genres ) / sizeof( match_genres[0] );
	int type, i, j;
	char *tag, *value;

	type = TYPE_UNKNOWN;

	for ( i=0; i<fields_num( f ); ++i ) {
		if ( !fields_match_tag( f, i, "GENRE" ) &&
		     !fields_match_tag( f, i, "NGENRE" ) )
			continue;
		value = ( char * ) fields_value( f, i, FIELDS_CHRP );
		for ( j=0; j<nmatch_genres; ++j )
			if ( !strcasecmp( match_genres[j].name, value ) )
				type = match_genres[j].type;
		if ( p->verbose ) {
			tag = ( char * ) fields_tag( f, i, FIELDS_CHRP );
			if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
			fprintf( stderr, "Type from tag '%s' data '%s': ", tag, value );
			write_type( stderr, type );
			fprintf( stderr, "\n" );
		}
		if ( type==TYPE_UNKNOWN ) {
			if ( !strcasecmp( value, "periodical" ) )
				type = TYPE_ARTICLE;
			else if ( !strcasecmp( value, "thesis" ) )
				type = TYPE_THESIS;
			else if ( !strcasecmp( value, "book" ) ) {
				if ( fields_level( f, i )==0 ) type=TYPE_BOOK;
				else type=TYPE_INBOOK;
			}
			else if ( !strcasecmp( value, "collection" ) ) {
				if ( fields_level( f, i )==0 ) type=TYPE_BOOK;
				else type=TYPE_INBOOK;
			}
		}

	}

	if ( p->verbose ) {
		if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
		fprintf( stderr, "Type from genre element: " );
		write_type( stderr, type );
		fprintf( stderr, "\n" );
	}

	return type;
}
/*
 * Shared between the interface class declaration and the NS_DECL_IFOO macro
 * provided to aid declaration of implementation classes.  
 * mode...
 *  AS_DECL writes 'NS_IMETHOD foo(string bar, long sil)'
 *  AS_IMPL writes 'NS_IMETHODIMP className::foo(string bar, long sil)'
 *  AS_CALL writes 'foo(bar, sil)'
 */
static gboolean
write_method_signature(IDL_tree method_tree, FILE *outfile, int mode,
                       const char *className)
{
    struct _IDL_OP_DCL *op = &IDL_OP_DCL(method_tree);
    gboolean no_generated_args = TRUE;
    gboolean op_notxpcom =
        (IDL_tree_property_get(op->ident, "notxpcom") != NULL);
    const char *name;
    IDL_tree iter;

    if (mode == AS_DECL) {
        if (op_notxpcom) {
            fputs("NS_IMETHOD_(", outfile);
            if (!write_type(op->op_type_spec, FALSE, outfile))
                return FALSE;
            fputc(')', outfile);
        } else {
            fputs("NS_IMETHOD", outfile);
        }
        fputc(' ', outfile);
    }
    else if (mode == AS_IMPL) {
        if (op_notxpcom) {
            fputs("NS_IMETHODIMP_(", outfile);
            if (!write_type(op->op_type_spec, FALSE, outfile))
                return FALSE;
            fputc(')', outfile);
        } else {
            fputs("NS_IMETHODIMP", outfile);
        }
        fputc(' ', outfile);
    }
    name = IDL_IDENT(op->ident).str;
    if (mode == AS_IMPL) {
        fprintf(outfile, "%s::%c%s(", className, toupper(*name), name + 1);
    } else {
        fprintf(outfile, "%c%s(", toupper(*name), name + 1);
    }
    for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) {
        if (mode == AS_DECL || mode == AS_IMPL) {
            if (!write_param(IDL_LIST(iter).data, outfile))
                return FALSE;
        } else {
            fputs(IDL_IDENT(IDL_PARAM_DCL(IDL_LIST(iter).data)
                            .simple_declarator).str,
                  outfile);
        }
        if ((IDL_LIST(iter).next ||
             (!op_notxpcom && op->op_type_spec) || op->f_varargs))
            fputs(", ", outfile);
        no_generated_args = FALSE;
    }

    /* make IDL return value into trailing out argument */
    if (op->op_type_spec && !op_notxpcom) {
        IDL_tree fake_param = IDL_param_dcl_new(IDL_PARAM_OUT,
                                                op->op_type_spec,
                                                IDL_ident_new("_retval"));
        if (!fake_param)
            return FALSE;
        if (mode == AS_DECL || mode == AS_IMPL) {
            if (!write_param(fake_param, outfile))
                return FALSE;
        } else {
            fputs("_retval", outfile);
        }
        if (op->f_varargs)
            fputs(", ", outfile);
        no_generated_args = FALSE;
    }

    /* varargs go last */
    if (op->f_varargs) {
        if (mode == AS_DECL || mode == AS_IMPL) {
            fputs("nsVarArgs *", outfile);
        }
        fputs("_varargs", outfile);
        no_generated_args = FALSE;
    }

    /*
     * If generated method has no arguments, output 'void' to avoid C legacy
     * behavior of disabling type checking.
     */
    if (no_generated_args && mode == AS_DECL) {
        fputs("void", outfile);
    }

    fputc(')', outfile);

    return TRUE;
}
Esempio n. 24
0
static void write_variable(const entity_t *entity)
{
	fprintf(out, "var %s : ", entity->base.symbol->string);
	write_type(entity->declaration.type);
	fprintf(out, "\n");
}
/**
 * Determines the transaction code based on the enumeration value received
 *
 * @return buffer after transaction text line is composed and concatenated for file write
 **/
char* Transaction::write(char* dest){
	//prepare the code

	switch (this->code){
		case Transaction::Test:{
			//write code
			if( debug_transaction) printf("writing code\n");
			char* curr = write_code( dest, this->code);
			if( error) break;
			if( debug_transaction) printf("writing token\n");
			curr = write_token( curr);
			//write username
			if( debug_transaction) printf("writing username\n");
			curr = write_username( curr, this->username);
			if( error) break;
			if( debug_transaction) printf("writing token\n");
			curr = write_token( curr);
			//write buyer username
			if( debug_transaction) printf("writing buyer username\n");
			curr = write_username( curr, this->buyer);
			if( error) break;
			if( debug_transaction) printf("writing token\n");
			curr = write_token( curr);
			//write seller username
			if( debug_transaction) printf("writing seller username\n");
			curr = write_username( curr, this->seller);
			if( error) break;
			if( debug_transaction) printf("writing token\n");
			curr = write_token( curr);
			//write event name
			if( debug_transaction) printf("writing event name\n");
			curr = write_eventName( curr, this->eventName);
			if( error) break;
			if( debug_transaction) printf("writing token\n");
			curr = write_token( curr);
			//write type
			if( debug_transaction) printf("writing type\n");
			curr = write_type( curr, this->type);
			if( error) break;
			if( debug_transaction) printf("writing token\n");
			curr = write_token( curr);
			//write ticket amount
			if( debug_transaction) printf("writing ticket amount\n");
			curr = write_ticketAmount( curr, this->ticketAmount);
			if( error) break;
			if( debug_transaction) printf("writing token\n");
			curr = write_token( curr);
			//write ticket price
			if( debug_transaction) printf("writing ticket price\n");
			curr = write_ticketPrice( curr, this->ticketPrice);
			if( error) break;
			curr = write_token( curr);
			//write credit
			if( debug_transaction) printf("writing credit\n");
			curr = write_credit( curr, this->totalCredits);
			if( error) break;
			if( debug_transaction) printf("writing token\n");
			//good
			if( debug_transaction) printf("done\n");
			return dest;}

		//01-create, 02-delete, 06-addcredit, 00-end of session
		//(X field 2, U field 15, T field 2, C field 9, total 28 + 3 = 31)
		//XX_UUUUUUUUUUUUUUU_TT_CCCCCCCCC
		case Transaction::Create:
		case Transaction::Delete:
		case Transaction::AddCredit:{
			//write code
			char* curr = write_code( dest, this->code);
			if( error) break;
			curr = write_token( curr);

			//write username
			curr = write_username( curr, this->username);
			if( error) break;
			curr = write_token( curr);

			//write type
			curr = write_type( curr, this->type);
			if( error) break;
			curr = write_token( curr);

			//write credit
			curr = write_credit( curr, this->totalCredits);
			if( error) break;

			//done
			return dest;}

		//05-refund
		//(X field 2, U field 15, S field 15, C field 9, total 44)
		//XX_UUUUUUUUUUUUUUU_SSSSSSSSSSSSSSS_CCCCCCCCC
		case Transaction::Refund:{
			//write code
			char* curr = write_code( dest, this->code);
			if( error) break;
			curr = write_token( curr);

			//write buyer username
			curr = write_username( curr, this->buyer);
			if( error) break;
			curr = write_token( curr);

			//write seller username
			curr = write_username( curr, this->seller);
			if( error) break;
			curr = write_token( curr);

			//write credit
			curr = write_credit( curr, this->totalCredits);
			if( error) break;

			//done
			return dest;}

		//03-sell, 04-buy
		//(X field 2, E field 19, S field 15, T field 3, P field 6, total 45+4 = 49)
		//XX_EEEEEEEEEEEEEEEEEEE_SSSSSSSSSSSSSSS_TTT_PPPPPP
		case Transaction::Buy:
		case Transaction::Sell:{
			//write code
			char* curr = write_code( dest, this->code);
			if( error) break;
			curr = write_token( curr);

			//write seller username
			curr = write_username( curr, this->seller);
			if( error) break;
			curr = write_token( curr);

			//write ticket amount
			curr = write_ticketAmount( curr, this->ticketAmount);
			if( error) break;
			curr = write_token( curr);

			//write ticket price
			curr = write_ticketPrice( curr, this->ticketPrice);
			if( error) break;

			//done
			return dest;}

		//manage the error case
		default:{
			printf("%s\n", Error::TransactionInvalidCode);
			break;}}
	//handle the error case
	printf("%s\n", error_string);
	dest[0] = '\0';
	printf("transaction: {%s}\n", dest);
	return buffer;
}
Esempio n. 26
0
File: lct.c Progetto: jbailhache/log
main ()
{
term x, n;
type t;
term plus_omega, omega_2, plus_omega_2, plus_omega_n, omega_n, omega_omega,
	plus_omega_omega;
term f, p;

	param_out.fd = stdout;
	param_err.fd = stderr;
	init ();
	/* Exemple : construction de l'ordinal omega * 2 */
	x = ap (LIM, ap (ap (S(ORD,ORD,ORD),
		ap (ap (S(ORD,fnc(ORD,ORD),fnc(ORD,ORD)),rep(ORD)),
			ap(K(fnc(ORD,ORD),ORD),SUC))),
		ap(K(ORD,ORD),ap(LIM,I(ORD)))));
	sput ("x = ", out);
	write_term (x, out);
	t = type_term (x);
	sput ("\nt = ", out);
	write_type (t, out);
	sput ("\n", out);

	n = var ("n", ORD);
	/*
	x = ap (LIM, lambda (n,
		ap (ap (ap (rep(ORD), n), SUC), ap (LIM, I(ORD)))
			));
		*/
	x = ap (ap (ap (rep(ORD), n), SUC), ap (LIM, I(ORD)));
	/*   x = ap (rep(ORD), n); */

	sput ("x = ", out);
	write_term (x, out);
	t = type_term (x);
	sput ("\nt = ", out);
	write_type (t, out);
	sput ("\n", out);

	x = lambda (n, x);
	sput ("x = ", out);
	write_term (x, out);
	t = type_term (x);
	sput ("\nt = ", out);
	write_type (t, out);
	sput ("\n", out);

	x = ap (LIM, x);
	sput ("x = ", out);
	write_term (x, out);
	t = type_term (x);
	sput ("\nt = ", out);
	write_type (t, out);
	sput ("\n", out);

	x = var ("x", ORD);
	plus_omega = lambda (x, lim (lambda (n,
		rpt (ORD, n, SUC, x)
			)));
	omega_2 = lim (lambda (n, rpt (ORD, n, plus_omega, ZERO)));
	t = type_term (omega_2);
	sput ("Type of omega_2 = ", out);
	write_type (t, out);
	sput ("\n", out);

	plus_omega_2 = lambda (x, lim (lambda (n,
		rpt (ORD, n, plus_omega, x))));
	t = type_term (plus_omega_2);
	sput ("Type of plus_omega_2 is ", out);
	write_type (t, out);

	f = var ("f", fnc(ORD,ORD));
	p = var ("p", ORD);

	plus_omega_n = lambda (n, rpt (fnc(ORD,ORD), n, lambda (f,
		lambda (x, lim (lambda (p, rpt (ORD, p, f, x)))) ),
		SUC));
	/*
	next_power = lambda (f,
		lambda (x, lim (lambda (p, rpt (ORD, p, f, x)))));
	plus_omega_n = lambda (n, rpt (fnc(ORD,ORD), n,
	*/
	t = type_term (plus_omega_n);
	sput ("\nType of plus_omega_n is ", out);
	write_type (t, out);

	omega_n = lambda (n, ap (ap (plus_omega_n, n), ZERO));
	t = type_term (omega_n);
	sput ("\nType of omega_n is ", out);
	write_type (t, out);

	omega_omega = lim (omega_n);
	t = type_term (omega_omega);
	sput ("\nType of omega_omega is ", out);
	write_type (t, out);

	plus_omega_omega = lambda (x, lim (lambda (n,
					    ap (ap (plus_omega_n, n), x) )));
	t = type_term (plus_omega_omega);
	sput ("\nType of plus_omega_omega is ", out);
	write_type (t, out);

	sput ("\n", out);

}
Esempio n. 27
0
File: lct.c Progetto: jbailhache/log
write_term (term x, struct put_fnct *put)
{
	switch (x->k)
	{
		case TERM_I:
			sput (" I [", put);
			write_type (x->I.a, put);
			sput ("] ", put);
			break;
		case TERM_K:
			sput (" K [", put);
			write_type (x->K.a, put);
			sput (", ", put);
			write_type (x->K.b, put);
			sput ("] ", put);
			break;
		case TERM_S:
			sput (" S [", put);
			write_type (x->S.a, put);
			sput (", ", put);
			write_type (x->S.b, put);
			sput (", ", put);
			write_type (x->S.c, put);
			sput ("] ", put);
			break;
		case TERM_Y:
			sput (" Y [", put);
			write_type (x->Y.a, put);
			sput ("] ", put);
			break;
		case TERM_ZERO:
			sput (" 0 ", put);
			break;
		case TERM_SUC:
			sput (" suc ", put);
			break;
		case TERM_LIM:
			sput (" lim ", put);
			break;
		case TERM_REP:
			sput (" rep [", put);
			write_type (x->rep.a, put);
			sput ("] ", put);
			break;
		case TERM_AP:
			sput ("-", put);
			write_term (x->ap.fnc, put);
			write_term (x->ap.arg, put);
			break;
		case TERM_VAR:
			sput (" <", put);
			sput (x->var.name, put);
			sput (":", put);
			write_type (x->var.typ, put);
			sput ("> ", put);
			break;
		case TERM_UNDEF:
			sput (" U ", put);
			break;
		default:
			sput ("?", put);

	}
}
Esempio n. 28
0
static void write_compound_entry(const entity_t *entity)
{
	fprintf(out, "\t%s : ", entity->base.symbol->string);
	write_type(entity->declaration.type);
	fprintf(out, "\n");
}
Esempio n. 29
0
void io::write(std::ostream& os, const std::string& key, const tag& t)
{
    write_type(os, t.get_type());
    write_str(os, key);
    t.write_payload(os);
}
Esempio n. 30
0
static void write_pointer_type(const pointer_type_t *type)
{
	write_type(type->points_to);
	fputc('*', out);
}