예제 #1
0
static void
puniondef(definition * def)
{
    case_list *l;
    char *name = def->def_name;
    declaration *decl;

    f_print(fout, "struct %s {\n", name);
    decl = &def->def.un.enum_decl;
    if (streq(decl->type, "bool")) {
	f_print(fout, "\tbool_t %s;\n", decl->name);
    } else {
	f_print(fout, "\t%s %s;\n", decl->type, decl->name);
    }
    f_print(fout, "\tunion {\n");
    for (l = def->def.un.cases; l != NULL; l = l->next) {
	pdeclaration(name, &l->case_decl, 2);
    }
    decl = def->def.un.default_decl;
    if (decl && !streq(decl->type, "void")) {
	pdeclaration(name, decl, 2);
    }
    if (brief_flag) {
	f_print(fout, "\t} u;\n");
    } else {
	f_print(fout, "\t} %s_u;\n", name);
    }
    f_print(fout, "};\n");
    f_print(fout, "typedef struct %s %s;\n", name, name);
    STOREVAL(&uniondef_defined, def);
}
예제 #2
0
static void
ptypedef(definition * def)
{
    char *name = def->def_name;
    char *old = def->def.ty.old_type;
    char prefix[8];		/* enough to contain "struct ", including NUL */
    relation rel = def->def.ty.rel;


    if (!streq(name, old)) {
	if (streq(old, "string")) {
	    old = "char";
	    rel = REL_POINTER;
	} else if (!brief_flag && streq(old, "opaque")) {
	    old = "char";
	} else if (streq(old, "bool")) {
	    old = "bool_t";
	}
	if (undefined2(old, name) && def->def.ty.old_prefix) {
	    s_print(prefix, "%s ", def->def.ty.old_prefix);
	} else {
	    prefix[0] = 0;
	}
	f_print(fout, "typedef ");
	switch (rel) {
	case REL_ARRAY:
	    if (brief_flag) {
	        if (streq(old, "opaque")) {
		    f_print(fout, "struct rx_opaque %s", name);
		} else {
		    f_print(fout, "struct {\n");
		    f_print(fout, "\tu_int len;\n");
		    f_print(fout, "\t%s%s *val;\n", prefix, old);
		    f_print(fout, "} %s", name);
		}
	    } else {
	        f_print(fout, "struct %s {\n", name);
		f_print(fout, "\tu_int %s_len;\n", name);
		f_print(fout, "\t%s%s *%s_val;\n", prefix, old, name);
	        f_print(fout, "} %s", name);
	    }
	    break;
	case REL_POINTER:
	    f_print(fout, "%s%s *%s", prefix, old, name);
	    break;
	case REL_VECTOR:
	    f_print(fout, "%s%s %s[%s]", prefix, old, name,
		    def->def.ty.array_max);
	    break;
	case REL_ALIAS:
	    f_print(fout, "%s%s %s", prefix, old, name);
	    break;
	}
	def->pc.rel = rel;
	STOREVAL(&typedef_defined, def);
	f_print(fout, ";\n");
    }
}
예제 #3
0
static void
isdefined (definition * defp)
{
  STOREVAL (&defined, defp);
}