| ... | ... | @@ -5977,6 +5977,16 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf |
| 5977 | 5977 | return; |
| 5978 | 5978 | } |
| 5979 | 5979 | case TypeTableEntryIdArray: |
| 5980 | { |
| 5981 | TypeTableEntryArray *array_data = &type_entry->data.array; |
| 5982 | |
| 5983 | Buf *child_buf = buf_alloc(); |
| 5984 | get_c_type(g, gen_h, array_data->child_type, child_buf); |
| 5985 | |
| 5986 | buf_resize(out_buf, 0); |
| 5987 | buf_appendf(out_buf, "%s", buf_ptr(child_buf)); |
| 5988 | return; |
| 5989 | } |
| 5980 | 5990 | case TypeTableEntryIdErrorUnion: |
| 5981 | 5991 | case TypeTableEntryIdPureError: |
| 5982 | 5992 | case TypeTableEntryIdFn: |
| ... | ... | @@ -6081,8 +6091,15 @@ static void gen_h_file(CodeGen *g) { |
| 6081 | 6091 | const char *comma_str = (param_i == 0) ? "" : ", "; |
| 6082 | 6092 | const char *restrict_str = param_info->is_noalias ? "restrict" : ""; |
| 6083 | 6093 | get_c_type(g, gen_h, param_info->type, &param_type_c); |
| 6084 | | buf_appendf(&h_buf, "%s%s%s %s", comma_str, buf_ptr(&param_type_c), |
| 6085 | | restrict_str, buf_ptr(param_name)); |
| 6094 | |
| 6095 | if (param_info->type->id == TypeTableEntryIdArray) { |
| 6096 | // Arrays decay to pointers |
| 6097 | buf_appendf(&h_buf, "%s%s%s %s[]", comma_str, buf_ptr(&param_type_c), |
| 6098 | restrict_str, buf_ptr(param_name)); |
| 6099 | } else { |
| 6100 | buf_appendf(&h_buf, "%s%s%s %s", comma_str, buf_ptr(&param_type_c), |
| 6101 | restrict_str, buf_ptr(param_name)); |
| 6102 | } |
| 6086 | 6103 | } |
| 6087 | 6104 | buf_appendf(&h_buf, ")"); |
| 6088 | 6105 | } else { |
| ... | ... | @@ -6169,7 +6186,15 @@ static void gen_h_file(CodeGen *g) { |
| 6169 | 6186 | |
| 6170 | 6187 | Buf *type_name_buf = buf_alloc(); |
| 6171 | 6188 | get_c_type(g, gen_h, struct_field->type_entry, type_name_buf); |
| 6172 | | fprintf(out_h, " %s %s;\n", buf_ptr(type_name_buf), buf_ptr(struct_field->name)); |
| 6189 | |
| 6190 | if (struct_field->type_entry->id == TypeTableEntryIdArray) { |
| 6191 | fprintf(out_h, " %s %s[%d];\n", buf_ptr(type_name_buf), |
| 6192 | buf_ptr(struct_field->name), |
| 6193 | struct_field->type_entry->data.array.len); |
| 6194 | } else { |
| 6195 | fprintf(out_h, " %s %s;\n", buf_ptr(type_name_buf), buf_ptr(struct_field->name)); |
| 6196 | } |
| 6197 | |
| 6173 | 6198 | } |
| 6174 | 6199 | fprintf(out_h, "};\n\n"); |
| 6175 | 6200 | break; |