| ... | ... | @@ -7508,51 +7508,60 @@ static void gen_h_file(CodeGen *g) { |
| 7508 | 7508 | case TypeTableEntryIdPromise: |
| 7509 | 7509 | zig_unreachable(); |
| 7510 | 7510 | case TypeTableEntryIdEnum: |
| 7511 | | assert(type_entry->data.enumeration.layout == ContainerLayoutExtern); |
| 7512 | | fprintf(out_h, "enum %s {\n", buf_ptr(&type_entry->name)); |
| 7513 | | for (uint32_t field_i = 0; field_i < type_entry->data.enumeration.src_field_count; field_i += 1) { |
| 7514 | | TypeEnumField *enum_field = &type_entry->data.enumeration.fields[field_i]; |
| 7515 | | Buf *value_buf = buf_alloc(); |
| 7516 | | bigint_append_buf(value_buf, &enum_field->value, 10); |
| 7517 | | fprintf(out_h, " %s = %s", buf_ptr(enum_field->name), buf_ptr(value_buf)); |
| 7518 | | if (field_i != type_entry->data.enumeration.src_field_count - 1) { |
| 7519 | | fprintf(out_h, ","); |
| 7511 | if (type_entry->data.enumeration.layout == ContainerLayoutExtern) { |
| 7512 | fprintf(out_h, "enum %s {\n", buf_ptr(&type_entry->name)); |
| 7513 | for (uint32_t field_i = 0; field_i < type_entry->data.enumeration.src_field_count; field_i += 1) { |
| 7514 | TypeEnumField *enum_field = &type_entry->data.enumeration.fields[field_i]; |
| 7515 | Buf *value_buf = buf_alloc(); |
| 7516 | bigint_append_buf(value_buf, &enum_field->value, 10); |
| 7517 | fprintf(out_h, " %s = %s", buf_ptr(enum_field->name), buf_ptr(value_buf)); |
| 7518 | if (field_i != type_entry->data.enumeration.src_field_count - 1) { |
| 7519 | fprintf(out_h, ","); |
| 7520 | } |
| 7521 | fprintf(out_h, "\n"); |
| 7520 | 7522 | } |
| 7521 | | fprintf(out_h, "\n"); |
| 7523 | fprintf(out_h, "};\n\n"); |
| 7524 | } else { |
| 7525 | fprintf(out_h, "enum %s;\n", buf_ptr(&type_entry->name)); |
| 7522 | 7526 | } |
| 7523 | | fprintf(out_h, "};\n\n"); |
| 7524 | 7527 | break; |
| 7525 | 7528 | case TypeTableEntryIdStruct: |
| 7526 | | assert(type_entry->data.structure.layout == ContainerLayoutExtern); |
| 7527 | | fprintf(out_h, "struct %s {\n", buf_ptr(&type_entry->name)); |
| 7528 | | for (uint32_t field_i = 0; field_i < type_entry->data.structure.src_field_count; field_i += 1) { |
| 7529 | | TypeStructField *struct_field = &type_entry->data.structure.fields[field_i]; |
| 7530 | | |
| 7531 | | Buf *type_name_buf = buf_alloc(); |
| 7532 | | get_c_type(g, gen_h, struct_field->type_entry, type_name_buf); |
| 7533 | | |
| 7534 | | if (struct_field->type_entry->id == TypeTableEntryIdArray) { |
| 7535 | | fprintf(out_h, " %s %s[%" ZIG_PRI_u64 "];\n", buf_ptr(type_name_buf), |
| 7536 | | buf_ptr(struct_field->name), |
| 7537 | | struct_field->type_entry->data.array.len); |
| 7538 | | } else { |
| 7539 | | fprintf(out_h, " %s %s;\n", buf_ptr(type_name_buf), buf_ptr(struct_field->name)); |
| 7540 | | } |
| 7529 | if (type_entry->data.structure.layout == ContainerLayoutExtern) { |
| 7530 | fprintf(out_h, "struct %s {\n", buf_ptr(&type_entry->name)); |
| 7531 | for (uint32_t field_i = 0; field_i < type_entry->data.structure.src_field_count; field_i += 1) { |
| 7532 | TypeStructField *struct_field = &type_entry->data.structure.fields[field_i]; |
| 7533 | |
| 7534 | Buf *type_name_buf = buf_alloc(); |
| 7535 | get_c_type(g, gen_h, struct_field->type_entry, type_name_buf); |
| 7536 | |
| 7537 | if (struct_field->type_entry->id == TypeTableEntryIdArray) { |
| 7538 | fprintf(out_h, " %s %s[%" ZIG_PRI_u64 "];\n", buf_ptr(type_name_buf), |
| 7539 | buf_ptr(struct_field->name), |
| 7540 | struct_field->type_entry->data.array.len); |
| 7541 | } else { |
| 7542 | fprintf(out_h, " %s %s;\n", buf_ptr(type_name_buf), buf_ptr(struct_field->name)); |
| 7543 | } |
| 7541 | 7544 | |
| 7545 | } |
| 7546 | fprintf(out_h, "};\n\n"); |
| 7547 | } else { |
| 7548 | fprintf(out_h, "struct %s;\n", buf_ptr(&type_entry->name)); |
| 7542 | 7549 | } |
| 7543 | | fprintf(out_h, "};\n\n"); |
| 7544 | 7550 | break; |
| 7545 | 7551 | case TypeTableEntryIdUnion: |
| 7546 | | assert(type_entry->data.unionation.layout == ContainerLayoutExtern); |
| 7547 | | fprintf(out_h, "union %s {\n", buf_ptr(&type_entry->name)); |
| 7548 | | for (uint32_t field_i = 0; field_i < type_entry->data.unionation.src_field_count; field_i += 1) { |
| 7549 | | TypeUnionField *union_field = &type_entry->data.unionation.fields[field_i]; |
| 7550 | | |
| 7551 | | Buf *type_name_buf = buf_alloc(); |
| 7552 | | get_c_type(g, gen_h, union_field->type_entry, type_name_buf); |
| 7553 | | fprintf(out_h, " %s %s;\n", buf_ptr(type_name_buf), buf_ptr(union_field->name)); |
| 7552 | if (type_entry->data.unionation.layout == ContainerLayoutExtern) { |
| 7553 | fprintf(out_h, "union %s {\n", buf_ptr(&type_entry->name)); |
| 7554 | for (uint32_t field_i = 0; field_i < type_entry->data.unionation.src_field_count; field_i += 1) { |
| 7555 | TypeUnionField *union_field = &type_entry->data.unionation.fields[field_i]; |
| 7556 | |
| 7557 | Buf *type_name_buf = buf_alloc(); |
| 7558 | get_c_type(g, gen_h, union_field->type_entry, type_name_buf); |
| 7559 | fprintf(out_h, " %s %s;\n", buf_ptr(type_name_buf), buf_ptr(union_field->name)); |
| 7560 | } |
| 7561 | fprintf(out_h, "};\n\n"); |
| 7562 | } else { |
| 7563 | fprintf(out_h, "union %s;\n", buf_ptr(&type_entry->name)); |
| 7554 | 7564 | } |
| 7555 | | fprintf(out_h, "};\n\n"); |
| 7556 | 7565 | break; |
| 7557 | 7566 | case TypeTableEntryIdOpaque: |
| 7558 | 7567 | fprintf(out_h, "struct %s;\n\n", buf_ptr(&type_entry->name)); |