Exemplo n.º 1
0
/*
 * Emit the C-routine for the given definition 
 */
void
emit(definition * def)
{
    if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
	return;
    }
    print_header(def);
    switch (def->def_kind) {
    case DEF_UNION:
	emit_union(def);
	break;
    case DEF_ENUM:
	emit_enum(def);
	break;
    case DEF_STRUCT:
	emit_struct(def);
	break;
    case DEF_TYPEDEF:
	emit_typedef(def);
	break;
    default:
	break;
    }
    print_trailer();
}
Exemplo n.º 2
0
/*
 * Emit the C-routine for the given definition 
 */
void
emit(definition *def)
{
	if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
		return;
	}
	print_header(def);
	switch (def->def_kind) {
	case DEF_UNION:
		fprintf(stderr, "*** Error: Union not supported\n");
        	exit(1);

		emit_union(def);
		break;
	case DEF_ENUM:
		emit_enum(def);
		break;
	case DEF_STRUCT:
		emit_struct(def);
		break;
	case DEF_TYPEDEF:
		emit_typedef(def);
		break;
        default:
		printf("emit default\n");
		break;
          
	}
	print_trailer();
}
Exemplo n.º 3
0
/*
 * Emit the C-routine for the given definition
 */
void
emit(definition *def)
{
	if (def->def_kind == DEF_CONST) {
		return;
	}
	if (def->def_kind == DEF_PROGRAM) {
		emit_program(def);
		return;
	}
	if (def->def_kind == DEF_TYPEDEF) {
		/*
		 * now we need to handle declarations like
		 * struct typedef foo foo;
		 * since we dont want this to be expanded into 2 calls to xdr_foo
		 */

		if (strcmp(def->def.ty.old_type, def->def_name) == 0)
			return;
	}
	print_header(def);
	switch (def->def_kind) {
	case DEF_UNION:
		emit_union(def);
		break;
	case DEF_ENUM:
		emit_enum(def);
		break;
	case DEF_STRUCT:
		emit_struct(def);
		break;
	case DEF_TYPEDEF:
		emit_typedef(def);
		break;
		/* DEF_CONST and DEF_PROGRAM have already been handled */
	default:
		break;
	}
	print_trailer();
}
Exemplo n.º 4
0
Arquivo: emit_c.c Projeto: tbeu/lcm
int emit_c(lcmgen_t *lcmgen)
{
    ////////////////////////////////////////////////////////////
    // ENUMS
    for (unsigned int i = 0; i < g_ptr_array_size(lcmgen->enums); i++) {

        lcm_enum_t *le = (lcm_enum_t *) g_ptr_array_index(lcmgen->enums, i);
        if (emit_enum(lcmgen, le))
            return -1;
    }

    ////////////////////////////////////////////////////////////
    // STRUCTS
    for (unsigned int i = 0; i < g_ptr_array_size(lcmgen->structs); i++) {
        lcm_struct_t *lr = (lcm_struct_t *) g_ptr_array_index(lcmgen->structs, i);

        if (emit_struct(lcmgen, lr))
            return -1;
    }

    return 0;
}