| ... | ... | @@ -61,12 +61,17 @@ start_over: |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | static Buf *to_zig_type(CXType raw_type) { |
| 64 | | CXType canonical = clang_getCanonicalType(raw_type); |
| 65 | | switch (canonical.kind) { |
| 64 | if (raw_type.kind == CXType_Unexposed) { |
| 65 | CXType canonical = clang_getCanonicalType(raw_type); |
| 66 | if (canonical.kind != CXType_Unexposed) |
| 67 | return to_zig_type(canonical); |
| 68 | else |
| 69 | zig_panic("clang C api insufficient"); |
| 70 | } |
| 71 | switch (raw_type.kind) { |
| 66 | 72 | case CXType_Invalid: |
| 67 | | zig_unreachable(); |
| 68 | 73 | case CXType_Unexposed: |
| 69 | | zig_panic("clang C api insufficient"); |
| 74 | zig_unreachable(); |
| 70 | 75 | case CXType_Void: |
| 71 | 76 | return buf_create_from_str("void"); |
| 72 | 77 | case CXType_Bool: |
| ... | ... | @@ -125,7 +130,7 @@ static Buf *to_zig_type(CXType raw_type) { |
| 125 | 130 | zig_panic("TODO"); |
| 126 | 131 | case CXType_Pointer: |
| 127 | 132 | { |
| 128 | | CXType pointee_type = clang_getPointeeType(canonical); |
| 133 | CXType pointee_type = clang_getPointeeType(raw_type); |
| 129 | 134 | Buf *pointee_buf = to_zig_type(pointee_type); |
| 130 | 135 | if (clang_isConstQualifiedType(pointee_type)) { |
| 131 | 136 | return buf_sprintf("*const %s", buf_ptr(pointee_buf)); |
| ... | ... | @@ -141,16 +146,39 @@ static Buf *to_zig_type(CXType raw_type) { |
| 141 | 146 | zig_panic("TODO"); |
| 142 | 147 | case CXType_Record: |
| 143 | 148 | { |
| 144 | | const char *name = prefixes_stripped(canonical); |
| 149 | const char *name = prefixes_stripped(raw_type); |
| 145 | 150 | return buf_sprintf("%s", name); |
| 146 | 151 | } |
| 147 | 152 | case CXType_Enum: |
| 148 | 153 | { |
| 149 | | const char *name = prefixes_stripped(canonical); |
| 154 | const char *name = prefixes_stripped(raw_type); |
| 150 | 155 | return buf_sprintf("%s", name); |
| 151 | 156 | } |
| 152 | 157 | case CXType_Typedef: |
| 153 | | zig_panic("TODO"); |
| 158 | { |
| 159 | const char *name = prefixes_stripped(raw_type); |
| 160 | if (strcmp(name, "int8_t") == 0) { |
| 161 | return buf_create_from_str("i8"); |
| 162 | } else if (strcmp(name, "uint8_t") == 0) { |
| 163 | return buf_create_from_str("u8"); |
| 164 | } else if (strcmp(name, "uint16_t") == 0) { |
| 165 | return buf_create_from_str("u16"); |
| 166 | } else if (strcmp(name, "uint32_t") == 0) { |
| 167 | return buf_create_from_str("u32"); |
| 168 | } else if (strcmp(name, "uint64_t") == 0) { |
| 169 | return buf_create_from_str("u64"); |
| 170 | } else if (strcmp(name, "int16_t") == 0) { |
| 171 | return buf_create_from_str("i16"); |
| 172 | } else if (strcmp(name, "int32_t") == 0) { |
| 173 | return buf_create_from_str("i32"); |
| 174 | } else if (strcmp(name, "int64_t") == 0) { |
| 175 | return buf_create_from_str("i64"); |
| 176 | } else { |
| 177 | CXCursor typedef_cursor = clang_getTypeDeclaration(raw_type); |
| 178 | CXType underlying_type = clang_getTypedefDeclUnderlyingType(typedef_cursor); |
| 179 | return to_zig_type(underlying_type); |
| 180 | } |
| 181 | } |
| 154 | 182 | case CXType_ObjCInterface: |
| 155 | 183 | zig_panic("TODO"); |
| 156 | 184 | case CXType_ObjCObjectPointer: |