| author | |
| committer | |
| log | 03dd1fca94526f78400c662b6b1e712c05aee849 |
| tree | 8655669fbdba9243a2a6ef1a3105f565d69ff76b |
| parent | db25c78413ac4472c6d50122d96c85a42dc032bc |
| parent | 2ef0795bfb440671bffd3c6b93603c012d27c24d |
| signature | Signed by PGP key 4AEE18F83AFDEB23 |
@OpaqueType -> `@Type(.Opaque)12 files changed, 158 insertions(+), 159 deletions(-)
doc/langref.html.in+30-32| ... | ... | @@ -1885,7 +1885,7 @@ test "null terminated array" { |
| 1885 | 1885 | <li>Supports slice syntax: {#syntax#}ptr[start..end]{#endsyntax#}</li> |
| 1886 | 1886 | <li>Supports pointer arithmetic: {#syntax#}ptr + x{#endsyntax#}, {#syntax#}ptr - x{#endsyntax#}</li> |
| 1887 | 1887 | <li>{#syntax#}T{#endsyntax#} must have a known size, which means that it cannot be |
| 1888 | {#syntax#}c_void{#endsyntax#} or any other {#link|@OpaqueType#}.</li> | |
| 1888 | {#syntax#}c_void{#endsyntax#} or any other {#link|opaque type|Opaque Types#}.</li> | |
| 1889 | 1889 | </ul> |
| 1890 | 1890 | </li> |
| 1891 | 1891 | </ul> |
| ... | ... | @@ -5392,7 +5392,7 @@ fn eql_i32(a: i32, b: i32) bool { |
| 5392 | 5392 | </p> |
| 5393 | 5393 | <p> |
| 5394 | 5394 | {#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this: |
| 5395 | {#syntax#}pub const c_void = @OpaqueType();{#endsyntax#}. | |
| 5395 | {#syntax#}pub const c_void = @Type(.Opaque);{#endsyntax#}. | |
| 5396 | 5396 | {#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size. |
| 5397 | 5397 | </p> |
| 5398 | 5398 | <p> |
| ... | ... | @@ -7666,30 +7666,6 @@ mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 7666 | 7666 | </p> |
| 7667 | 7667 | {#header_close#} |
| 7668 | 7668 | |
| 7669 | {#header_open|@OpaqueType#} | |
| 7670 | <pre>{#syntax#}@OpaqueType() type{#endsyntax#}</pre> | |
| 7671 | <p> | |
| 7672 | Creates a new type with an unknown (but non-zero) size and alignment. | |
| 7673 | </p> | |
| 7674 | <p> | |
| 7675 | This is typically used for type safety when interacting with C code that does not expose struct details. | |
| 7676 | Example: | |
| 7677 | </p> | |
| 7678 | {#code_begin|test_err|expected type '*Derp', found '*Wat'#} | |
| 7679 | const Derp = @OpaqueType(); | |
| 7680 | const Wat = @OpaqueType(); | |
| 7681 | ||
| 7682 | extern fn bar(d: *Derp) void; | |
| 7683 | fn foo(w: *Wat) callconv(.C) void { | |
| 7684 | bar(w); | |
| 7685 | } | |
| 7686 | ||
| 7687 | test "call foo" { | |
| 7688 | foo(undefined); | |
| 7689 | } | |
| 7690 | {#code_end#} | |
| 7691 | {#header_close#} | |
| 7692 | ||
| 7693 | 7669 | {#header_open|@panic#} |
| 7694 | 7670 | <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre> |
| 7695 | 7671 | <p> |
| ... | ... | @@ -8274,21 +8250,21 @@ test "integer truncation" { |
| 8274 | 8250 | <li>{#syntax#}comptime_float{#endsyntax#}</li> |
| 8275 | 8251 | <li>{#syntax#}@TypeOf(undefined){#endsyntax#}</li> |
| 8276 | 8252 | <li>{#syntax#}@TypeOf(null){#endsyntax#}</li> |
| 8253 | <li>{#link|Arrays#}</li> | |
| 8254 | <li>{#link|Optionals#}</li> | |
| 8255 | <li>{#link|Error Union Type#}</li> | |
| 8256 | <li>{#link|Vectors#}</li> | |
| 8257 | <li>{#link|Opaque Types#}</li> | |
| 8258 | <li>AnyFrame</li> | |
| 8277 | 8259 | </ul> |
| 8278 | 8260 | <p> |
| 8279 | 8261 | For these types it is a |
| 8280 | 8262 | <a href="https://github.com/ziglang/zig/issues/2907">TODO in the compiler to implement</a>: |
| 8281 | 8263 | </p> |
| 8282 | 8264 | <ul> |
| 8283 | <li>Array</li> | |
| 8284 | <li>Optional</li> | |
| 8285 | <li>ErrorUnion</li> | |
| 8286 | 8265 | <li>ErrorSet</li> |
| 8287 | 8266 | <li>Enum</li> |
| 8288 | <li>Opaque</li> | |
| 8289 | 8267 | <li>FnFrame</li> |
| 8290 | <li>AnyFrame</li> | |
| 8291 | <li>Vector</li> | |
| 8292 | 8268 | <li>EnumLiteral</li> |
| 8293 | 8269 | </ul> |
| 8294 | 8270 | <p> |
| ... | ... | @@ -8373,6 +8349,28 @@ fn foo(comptime T: type, ptr: *T) T { |
| 8373 | 8349 | {#header_close#} |
| 8374 | 8350 | {#header_close#} |
| 8375 | 8351 | |
| 8352 | {#header_open|Opaque Types#} | |
| 8353 | {#syntax#}@Type(.Opaque){#endsyntax#} creates a new type with an unknown (but non-zero) size and alignment. | |
| 8354 | </p> | |
| 8355 | <p> | |
| 8356 | This is typically used for type safety when interacting with C code that does not expose struct details. | |
| 8357 | Example: | |
| 8358 | </p> | |
| 8359 | {#code_begin|test_err|expected type '*Derp', found '*Wat'#} | |
| 8360 | const Derp = @Type(.Opaque); | |
| 8361 | const Wat = @Type(.Opaque); | |
| 8362 | ||
| 8363 | extern fn bar(d: *Derp) void; | |
| 8364 | fn foo(w: *Wat) callconv(.C) void { | |
| 8365 | bar(w); | |
| 8366 | } | |
| 8367 | ||
| 8368 | test "call foo" { | |
| 8369 | foo(undefined); | |
| 8370 | } | |
| 8371 | {#code_end#} | |
| 8372 | {#header_close#} | |
| 8373 | ||
| 8376 | 8374 | {#header_open|Build Mode#} |
| 8377 | 8375 | <p> |
| 8378 | 8376 | Zig has four build modes: |
lib/std/c.zig+2-2| ... | ... | @@ -277,8 +277,8 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) c_int; |
| 277 | 277 | pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) c_int; |
| 278 | 278 | pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) c_int; |
| 279 | 279 | |
| 280 | pub const pthread_t = *@OpaqueType(); | |
| 281 | pub const FILE = @OpaqueType(); | |
| 280 | pub const pthread_t = *@Type(.Opaque); | |
| 281 | pub const FILE = @Type(.Opaque); | |
| 282 | 282 | |
| 283 | 283 | pub extern "c" fn dlopen(path: [*:0]const u8, mode: c_int) ?*c_void; |
| 284 | 284 | pub extern "c" fn dlclose(handle: *c_void) c_int; |
lib/std/os/uefi.zig+3-3| ... | ... | @@ -12,7 +12,7 @@ pub var handle: Handle = undefined; |
| 12 | 12 | pub var system_table: *tables.SystemTable = undefined; |
| 13 | 13 | |
| 14 | 14 | /// A handle to an event structure. |
| 15 | pub const Event = *@OpaqueType(); | |
| 15 | pub const Event = *@Type(.Opaque); | |
| 16 | 16 | |
| 17 | 17 | /// GUIDs must be align(8) |
| 18 | 18 | pub const Guid = extern struct { |
| ... | ... | @@ -46,7 +46,7 @@ pub const Guid = extern struct { |
| 46 | 46 | }; |
| 47 | 47 | |
| 48 | 48 | /// An EFI Handle represents a collection of related interfaces. |
| 49 | pub const Handle = *@OpaqueType(); | |
| 49 | pub const Handle = *@Type(.Opaque); | |
| 50 | 50 | |
| 51 | 51 | /// This structure represents time information. |
| 52 | 52 | pub const Time = extern struct { |
| ... | ... | @@ -103,4 +103,4 @@ pub const TimeCapabilities = extern struct { |
| 103 | 103 | }; |
| 104 | 104 | |
| 105 | 105 | /// File Handle as specified in the EFI Shell Spec |
| 106 | pub const FileHandle = *@OpaqueType(); | |
| 106 | pub const FileHandle = *@Type(.Opaque); |
lib/std/os/uefi/protocols/hii.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const uefi = @import("std").os.uefi; |
| 2 | 2 | const Guid = uefi.Guid; |
| 3 | 3 | |
| 4 | pub const HIIHandle = *@OpaqueType(); | |
| 4 | pub const HIIHandle = *@Type(.Opaque); | |
| 5 | 5 | |
| 6 | 6 | /// The header found at the start of each package. |
| 7 | 7 | pub const HIIPackageHeader = packed struct { |
lib/std/os/windows/bits.zig+15-15| ... | ... | @@ -27,16 +27,16 @@ pub const UCHAR = u8; |
| 27 | 27 | pub const FLOAT = f32; |
| 28 | 28 | pub const HANDLE = *c_void; |
| 29 | 29 | pub const HCRYPTPROV = ULONG_PTR; |
| 30 | pub const HBRUSH = *@OpaqueType(); | |
| 31 | pub const HCURSOR = *@OpaqueType(); | |
| 32 | pub const HICON = *@OpaqueType(); | |
| 33 | pub const HINSTANCE = *@OpaqueType(); | |
| 34 | pub const HMENU = *@OpaqueType(); | |
| 35 | pub const HMODULE = *@OpaqueType(); | |
| 36 | pub const HWND = *@OpaqueType(); | |
| 37 | pub const HDC = *@OpaqueType(); | |
| 38 | pub const HGLRC = *@OpaqueType(); | |
| 39 | pub const FARPROC = *@OpaqueType(); | |
| 30 | pub const HBRUSH = *@Type(.Opaque); | |
| 31 | pub const HCURSOR = *@Type(.Opaque); | |
| 32 | pub const HICON = *@Type(.Opaque); | |
| 33 | pub const HINSTANCE = *@Type(.Opaque); | |
| 34 | pub const HMENU = *@Type(.Opaque); | |
| 35 | pub const HMODULE = *@Type(.Opaque); | |
| 36 | pub const HWND = *@Type(.Opaque); | |
| 37 | pub const HDC = *@Type(.Opaque); | |
| 38 | pub const HGLRC = *@Type(.Opaque); | |
| 39 | pub const FARPROC = *@Type(.Opaque); | |
| 40 | 40 | pub const INT = c_int; |
| 41 | 41 | pub const LPBYTE = *BYTE; |
| 42 | 42 | pub const LPCH = *CHAR; |
| ... | ... | @@ -76,7 +76,7 @@ pub const WPARAM = usize; |
| 76 | 76 | pub const LPARAM = ?*c_void; |
| 77 | 77 | pub const LRESULT = ?*c_void; |
| 78 | 78 | |
| 79 | pub const va_list = *@OpaqueType(); | |
| 79 | pub const va_list = *@Type(.Opaque); | |
| 80 | 80 | |
| 81 | 81 | pub const TRUE = 1; |
| 82 | 82 | pub const FALSE = 0; |
| ... | ... | @@ -1169,10 +1169,10 @@ pub const UNICODE_STRING = extern struct { |
| 1169 | 1169 | Buffer: [*]WCHAR, |
| 1170 | 1170 | }; |
| 1171 | 1171 | |
| 1172 | const ACTIVATION_CONTEXT_DATA = @OpaqueType(); | |
| 1173 | const ASSEMBLY_STORAGE_MAP = @OpaqueType(); | |
| 1174 | const FLS_CALLBACK_INFO = @OpaqueType(); | |
| 1175 | const RTL_BITMAP = @OpaqueType(); | |
| 1172 | const ACTIVATION_CONTEXT_DATA = @Type(.Opaque); | |
| 1173 | const ASSEMBLY_STORAGE_MAP = @Type(.Opaque); | |
| 1174 | const FLS_CALLBACK_INFO = @Type(.Opaque); | |
| 1175 | const RTL_BITMAP = @Type(.Opaque); | |
| 1176 | 1176 | pub const PRTL_BITMAP = *RTL_BITMAP; |
| 1177 | 1177 | const KAFFINITY = usize; |
| 1178 | 1178 |
lib/std/os/windows/ws2_32.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | usingnamespace @import("bits.zig"); |
| 2 | 2 | |
| 3 | pub const SOCKET = *@OpaqueType(); | |
| 3 | pub const SOCKET = *@Type(.Opaque); | |
| 4 | 4 | pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0)); |
| 5 | 5 | pub const SOCKET_ERROR = -1; |
| 6 | 6 |
src-self-hosted/clang.zig+84-84| ... | ... | @@ -1,89 +1,89 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | |
| 3 | pub const struct_ZigClangConditionalOperator = @OpaqueType(); | |
| 4 | pub const struct_ZigClangBinaryConditionalOperator = @OpaqueType(); | |
| 5 | pub const struct_ZigClangAbstractConditionalOperator = @OpaqueType(); | |
| 6 | pub const struct_ZigClangAPInt = @OpaqueType(); | |
| 7 | pub const struct_ZigClangAPSInt = @OpaqueType(); | |
| 8 | pub const struct_ZigClangAPFloat = @OpaqueType(); | |
| 9 | pub const struct_ZigClangASTContext = @OpaqueType(); | |
| 10 | pub const struct_ZigClangASTUnit = @OpaqueType(); | |
| 11 | pub const struct_ZigClangArraySubscriptExpr = @OpaqueType(); | |
| 12 | pub const struct_ZigClangArrayType = @OpaqueType(); | |
| 13 | pub const struct_ZigClangAttributedType = @OpaqueType(); | |
| 14 | pub const struct_ZigClangBinaryOperator = @OpaqueType(); | |
| 15 | pub const struct_ZigClangBreakStmt = @OpaqueType(); | |
| 16 | pub const struct_ZigClangBuiltinType = @OpaqueType(); | |
| 17 | pub const struct_ZigClangCStyleCastExpr = @OpaqueType(); | |
| 18 | pub const struct_ZigClangCallExpr = @OpaqueType(); | |
| 19 | pub const struct_ZigClangCaseStmt = @OpaqueType(); | |
| 20 | pub const struct_ZigClangCompoundAssignOperator = @OpaqueType(); | |
| 21 | pub const struct_ZigClangCompoundStmt = @OpaqueType(); | |
| 22 | pub const struct_ZigClangConstantArrayType = @OpaqueType(); | |
| 23 | pub const struct_ZigClangContinueStmt = @OpaqueType(); | |
| 24 | pub const struct_ZigClangDecayedType = @OpaqueType(); | |
| 25 | pub const struct_ZigClangDecl = @OpaqueType(); | |
| 26 | pub const struct_ZigClangDeclRefExpr = @OpaqueType(); | |
| 27 | pub const struct_ZigClangDeclStmt = @OpaqueType(); | |
| 28 | pub const struct_ZigClangDefaultStmt = @OpaqueType(); | |
| 29 | pub const struct_ZigClangDiagnosticOptions = @OpaqueType(); | |
| 30 | pub const struct_ZigClangDiagnosticsEngine = @OpaqueType(); | |
| 31 | pub const struct_ZigClangDoStmt = @OpaqueType(); | |
| 32 | pub const struct_ZigClangElaboratedType = @OpaqueType(); | |
| 33 | pub const struct_ZigClangEnumConstantDecl = @OpaqueType(); | |
| 34 | pub const struct_ZigClangEnumDecl = @OpaqueType(); | |
| 35 | pub const struct_ZigClangEnumType = @OpaqueType(); | |
| 36 | pub const struct_ZigClangExpr = @OpaqueType(); | |
| 37 | pub const struct_ZigClangFieldDecl = @OpaqueType(); | |
| 38 | pub const struct_ZigClangFileID = @OpaqueType(); | |
| 39 | pub const struct_ZigClangForStmt = @OpaqueType(); | |
| 40 | pub const struct_ZigClangFullSourceLoc = @OpaqueType(); | |
| 41 | pub const struct_ZigClangFunctionDecl = @OpaqueType(); | |
| 42 | pub const struct_ZigClangFunctionProtoType = @OpaqueType(); | |
| 43 | pub const struct_ZigClangIfStmt = @OpaqueType(); | |
| 44 | pub const struct_ZigClangImplicitCastExpr = @OpaqueType(); | |
| 45 | pub const struct_ZigClangIncompleteArrayType = @OpaqueType(); | |
| 46 | pub const struct_ZigClangIntegerLiteral = @OpaqueType(); | |
| 47 | pub const struct_ZigClangMacroDefinitionRecord = @OpaqueType(); | |
| 48 | pub const struct_ZigClangMacroExpansion = @OpaqueType(); | |
| 49 | pub const struct_ZigClangMacroQualifiedType = @OpaqueType(); | |
| 50 | pub const struct_ZigClangMemberExpr = @OpaqueType(); | |
| 51 | pub const struct_ZigClangNamedDecl = @OpaqueType(); | |
| 52 | pub const struct_ZigClangNone = @OpaqueType(); | |
| 53 | pub const struct_ZigClangOpaqueValueExpr = @OpaqueType(); | |
| 54 | pub const struct_ZigClangPCHContainerOperations = @OpaqueType(); | |
| 55 | pub const struct_ZigClangParenExpr = @OpaqueType(); | |
| 56 | pub const struct_ZigClangParenType = @OpaqueType(); | |
| 57 | pub const struct_ZigClangParmVarDecl = @OpaqueType(); | |
| 58 | pub const struct_ZigClangPointerType = @OpaqueType(); | |
| 59 | pub const struct_ZigClangPreprocessedEntity = @OpaqueType(); | |
| 60 | pub const struct_ZigClangRecordDecl = @OpaqueType(); | |
| 61 | pub const struct_ZigClangRecordType = @OpaqueType(); | |
| 62 | pub const struct_ZigClangReturnStmt = @OpaqueType(); | |
| 63 | pub const struct_ZigClangSkipFunctionBodiesScope = @OpaqueType(); | |
| 64 | pub const struct_ZigClangSourceManager = @OpaqueType(); | |
| 65 | pub const struct_ZigClangSourceRange = @OpaqueType(); | |
| 66 | pub const struct_ZigClangStmt = @OpaqueType(); | |
| 67 | pub const struct_ZigClangStringLiteral = @OpaqueType(); | |
| 68 | pub const struct_ZigClangStringRef = @OpaqueType(); | |
| 69 | pub const struct_ZigClangSwitchStmt = @OpaqueType(); | |
| 70 | pub const struct_ZigClangTagDecl = @OpaqueType(); | |
| 71 | pub const struct_ZigClangType = @OpaqueType(); | |
| 72 | pub const struct_ZigClangTypedefNameDecl = @OpaqueType(); | |
| 73 | pub const struct_ZigClangTypedefType = @OpaqueType(); | |
| 74 | pub const struct_ZigClangUnaryExprOrTypeTraitExpr = @OpaqueType(); | |
| 75 | pub const struct_ZigClangUnaryOperator = @OpaqueType(); | |
| 76 | pub const struct_ZigClangValueDecl = @OpaqueType(); | |
| 77 | pub const struct_ZigClangVarDecl = @OpaqueType(); | |
| 78 | pub const struct_ZigClangWhileStmt = @OpaqueType(); | |
| 79 | pub const struct_ZigClangFunctionType = @OpaqueType(); | |
| 80 | pub const struct_ZigClangPredefinedExpr = @OpaqueType(); | |
| 81 | pub const struct_ZigClangInitListExpr = @OpaqueType(); | |
| 82 | pub const ZigClangPreprocessingRecord = @OpaqueType(); | |
| 83 | pub const ZigClangFloatingLiteral = @OpaqueType(); | |
| 84 | pub const ZigClangConstantExpr = @OpaqueType(); | |
| 85 | pub const ZigClangCharacterLiteral = @OpaqueType(); | |
| 86 | pub const ZigClangStmtExpr = @OpaqueType(); | |
| 3 | pub const struct_ZigClangConditionalOperator = @Type(.Opaque); | |
| 4 | pub const struct_ZigClangBinaryConditionalOperator = @Type(.Opaque); | |
| 5 | pub const struct_ZigClangAbstractConditionalOperator = @Type(.Opaque); | |
| 6 | pub const struct_ZigClangAPInt = @Type(.Opaque); | |
| 7 | pub const struct_ZigClangAPSInt = @Type(.Opaque); | |
| 8 | pub const struct_ZigClangAPFloat = @Type(.Opaque); | |
| 9 | pub const struct_ZigClangASTContext = @Type(.Opaque); | |
| 10 | pub const struct_ZigClangASTUnit = @Type(.Opaque); | |
| 11 | pub const struct_ZigClangArraySubscriptExpr = @Type(.Opaque); | |
| 12 | pub const struct_ZigClangArrayType = @Type(.Opaque); | |
| 13 | pub const struct_ZigClangAttributedType = @Type(.Opaque); | |
| 14 | pub const struct_ZigClangBinaryOperator = @Type(.Opaque); | |
| 15 | pub const struct_ZigClangBreakStmt = @Type(.Opaque); | |
| 16 | pub const struct_ZigClangBuiltinType = @Type(.Opaque); | |
| 17 | pub const struct_ZigClangCStyleCastExpr = @Type(.Opaque); | |
| 18 | pub const struct_ZigClangCallExpr = @Type(.Opaque); | |
| 19 | pub const struct_ZigClangCaseStmt = @Type(.Opaque); | |
| 20 | pub const struct_ZigClangCompoundAssignOperator = @Type(.Opaque); | |
| 21 | pub const struct_ZigClangCompoundStmt = @Type(.Opaque); | |
| 22 | pub const struct_ZigClangConstantArrayType = @Type(.Opaque); | |
| 23 | pub const struct_ZigClangContinueStmt = @Type(.Opaque); | |
| 24 | pub const struct_ZigClangDecayedType = @Type(.Opaque); | |
| 25 | pub const struct_ZigClangDecl = @Type(.Opaque); | |
| 26 | pub const struct_ZigClangDeclRefExpr = @Type(.Opaque); | |
| 27 | pub const struct_ZigClangDeclStmt = @Type(.Opaque); | |
| 28 | pub const struct_ZigClangDefaultStmt = @Type(.Opaque); | |
| 29 | pub const struct_ZigClangDiagnosticOptions = @Type(.Opaque); | |
| 30 | pub const struct_ZigClangDiagnosticsEngine = @Type(.Opaque); | |
| 31 | pub const struct_ZigClangDoStmt = @Type(.Opaque); | |
| 32 | pub const struct_ZigClangElaboratedType = @Type(.Opaque); | |
| 33 | pub const struct_ZigClangEnumConstantDecl = @Type(.Opaque); | |
| 34 | pub const struct_ZigClangEnumDecl = @Type(.Opaque); | |
| 35 | pub const struct_ZigClangEnumType = @Type(.Opaque); | |
| 36 | pub const struct_ZigClangExpr = @Type(.Opaque); | |
| 37 | pub const struct_ZigClangFieldDecl = @Type(.Opaque); | |
| 38 | pub const struct_ZigClangFileID = @Type(.Opaque); | |
| 39 | pub const struct_ZigClangForStmt = @Type(.Opaque); | |
| 40 | pub const struct_ZigClangFullSourceLoc = @Type(.Opaque); | |
| 41 | pub const struct_ZigClangFunctionDecl = @Type(.Opaque); | |
| 42 | pub const struct_ZigClangFunctionProtoType = @Type(.Opaque); | |
| 43 | pub const struct_ZigClangIfStmt = @Type(.Opaque); | |
| 44 | pub const struct_ZigClangImplicitCastExpr = @Type(.Opaque); | |
| 45 | pub const struct_ZigClangIncompleteArrayType = @Type(.Opaque); | |
| 46 | pub const struct_ZigClangIntegerLiteral = @Type(.Opaque); | |
| 47 | pub const struct_ZigClangMacroDefinitionRecord = @Type(.Opaque); | |
| 48 | pub const struct_ZigClangMacroExpansion = @Type(.Opaque); | |
| 49 | pub const struct_ZigClangMacroQualifiedType = @Type(.Opaque); | |
| 50 | pub const struct_ZigClangMemberExpr = @Type(.Opaque); | |
| 51 | pub const struct_ZigClangNamedDecl = @Type(.Opaque); | |
| 52 | pub const struct_ZigClangNone = @Type(.Opaque); | |
| 53 | pub const struct_ZigClangOpaqueValueExpr = @Type(.Opaque); | |
| 54 | pub const struct_ZigClangPCHContainerOperations = @Type(.Opaque); | |
| 55 | pub const struct_ZigClangParenExpr = @Type(.Opaque); | |
| 56 | pub const struct_ZigClangParenType = @Type(.Opaque); | |
| 57 | pub const struct_ZigClangParmVarDecl = @Type(.Opaque); | |
| 58 | pub const struct_ZigClangPointerType = @Type(.Opaque); | |
| 59 | pub const struct_ZigClangPreprocessedEntity = @Type(.Opaque); | |
| 60 | pub const struct_ZigClangRecordDecl = @Type(.Opaque); | |
| 61 | pub const struct_ZigClangRecordType = @Type(.Opaque); | |
| 62 | pub const struct_ZigClangReturnStmt = @Type(.Opaque); | |
| 63 | pub const struct_ZigClangSkipFunctionBodiesScope = @Type(.Opaque); | |
| 64 | pub const struct_ZigClangSourceManager = @Type(.Opaque); | |
| 65 | pub const struct_ZigClangSourceRange = @Type(.Opaque); | |
| 66 | pub const struct_ZigClangStmt = @Type(.Opaque); | |
| 67 | pub const struct_ZigClangStringLiteral = @Type(.Opaque); | |
| 68 | pub const struct_ZigClangStringRef = @Type(.Opaque); | |
| 69 | pub const struct_ZigClangSwitchStmt = @Type(.Opaque); | |
| 70 | pub const struct_ZigClangTagDecl = @Type(.Opaque); | |
| 71 | pub const struct_ZigClangType = @Type(.Opaque); | |
| 72 | pub const struct_ZigClangTypedefNameDecl = @Type(.Opaque); | |
| 73 | pub const struct_ZigClangTypedefType = @Type(.Opaque); | |
| 74 | pub const struct_ZigClangUnaryExprOrTypeTraitExpr = @Type(.Opaque); | |
| 75 | pub const struct_ZigClangUnaryOperator = @Type(.Opaque); | |
| 76 | pub const struct_ZigClangValueDecl = @Type(.Opaque); | |
| 77 | pub const struct_ZigClangVarDecl = @Type(.Opaque); | |
| 78 | pub const struct_ZigClangWhileStmt = @Type(.Opaque); | |
| 79 | pub const struct_ZigClangFunctionType = @Type(.Opaque); | |
| 80 | pub const struct_ZigClangPredefinedExpr = @Type(.Opaque); | |
| 81 | pub const struct_ZigClangInitListExpr = @Type(.Opaque); | |
| 82 | pub const ZigClangPreprocessingRecord = @Type(.Opaque); | |
| 83 | pub const ZigClangFloatingLiteral = @Type(.Opaque); | |
| 84 | pub const ZigClangConstantExpr = @Type(.Opaque); | |
| 85 | pub const ZigClangCharacterLiteral = @Type(.Opaque); | |
| 86 | pub const ZigClangStmtExpr = @Type(.Opaque); | |
| 87 | 87 | |
| 88 | 88 | pub const ZigClangBO = extern enum { |
| 89 | 89 | PtrMemD, |
src-self-hosted/translate_c.zig+2-1| ... | ... | @@ -4025,7 +4025,8 @@ fn transCreateNodeFloat(c: *Context, int: var) !*ast.Node { |
| 4025 | 4025 | } |
| 4026 | 4026 | |
| 4027 | 4027 | fn transCreateNodeOpaqueType(c: *Context) !*ast.Node { |
| 4028 | const call_node = try transCreateNodeBuiltinFnCall(c, "@OpaqueType"); | |
| 4028 | const call_node = try transCreateNodeBuiltinFnCall(c, "@Type"); | |
| 4029 | try call_node.params.push(try transCreateNodeEnumLiteral(c, "Opaque")); | |
| 4029 | 4030 | call_node.rparen_token = try appendToken(c, .RParen, ")"); |
| 4030 | 4031 | return &call_node.base; |
| 4031 | 4032 | } |
test/compile_errors.zig+9-9| ... | ... | @@ -1992,7 +1992,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1992 | 1992 | }); |
| 1993 | 1993 | |
| 1994 | 1994 | cases.add("directly embedding opaque type in struct and union", |
| 1995 | \\const O = @OpaqueType(); | |
| 1995 | \\const O = @Type(.Opaque); | |
| 1996 | 1996 | \\const Foo = struct { |
| 1997 | 1997 | \\ o: O, |
| 1998 | 1998 | \\}; |
| ... | ... | @@ -2007,7 +2007,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2007 | 2007 | \\ var bar: Bar = undefined; |
| 2008 | 2008 | \\} |
| 2009 | 2009 | \\export fn c() void { |
| 2010 | \\ var baz: *@OpaqueType() = undefined; | |
| 2010 | \\ var baz: *@Type(.Opaque) = undefined; | |
| 2011 | 2011 | \\ const qux = .{baz.*}; |
| 2012 | 2012 | \\} |
| 2013 | 2013 | , &[_][]const u8{ |
| ... | ... | @@ -2971,7 +2971,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2971 | 2971 | }); |
| 2972 | 2972 | |
| 2973 | 2973 | cases.add("unknown length pointer to opaque", |
| 2974 | \\export const T = [*]@OpaqueType(); | |
| 2974 | \\export const T = [*]@Type(.Opaque); | |
| 2975 | 2975 | , &[_][]const u8{ |
| 2976 | 2976 | "tmp.zig:1:21: error: unknown-length pointer to opaque", |
| 2977 | 2977 | }); |
| ... | ... | @@ -6127,8 +6127,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6127 | 6127 | "tmp.zig:2:31: error: index 2 outside array of size 2", |
| 6128 | 6128 | }); |
| 6129 | 6129 | |
| 6130 | cases.add("wrong pointer coerced to pointer to @OpaqueType()", | |
| 6131 | \\const Derp = @OpaqueType(); | |
| 6130 | cases.add("wrong pointer coerced to pointer to @Type(.Opaque)", | |
| 6131 | \\const Derp = @Type(.Opaque); | |
| 6132 | 6132 | \\extern fn bar(d: *Derp) void; |
| 6133 | 6133 | \\export fn foo() void { |
| 6134 | 6134 | \\ var x = @as(u8, 1); |
| ... | ... | @@ -6166,7 +6166,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6166 | 6166 | \\export fn entry9() void { |
| 6167 | 6167 | \\ var z: noreturn = return; |
| 6168 | 6168 | \\} |
| 6169 | \\const Opaque = @OpaqueType(); | |
| 6169 | \\const Opaque = @Type(.Opaque); | |
| 6170 | 6170 | \\const Foo = struct { |
| 6171 | 6171 | \\ fn bar(self: *const Foo) void {} |
| 6172 | 6172 | \\}; |
| ... | ... | @@ -6320,7 +6320,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6320 | 6320 | }); |
| 6321 | 6321 | |
| 6322 | 6322 | cases.add("field access of opaque type", |
| 6323 | \\const MyType = @OpaqueType(); | |
| 6323 | \\const MyType = @Type(.Opaque); | |
| 6324 | 6324 | \\ |
| 6325 | 6325 | \\export fn entry() bool { |
| 6326 | 6326 | \\ var x: i32 = 1; |
| ... | ... | @@ -6936,7 +6936,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6936 | 6936 | }); |
| 6937 | 6937 | |
| 6938 | 6938 | cases.add("function returning opaque type", |
| 6939 | \\const FooType = @OpaqueType(); | |
| 6939 | \\const FooType = @Type(.Opaque); | |
| 6940 | 6940 | \\export fn bar() !FooType { |
| 6941 | 6941 | \\ return error.InvalidValue; |
| 6942 | 6942 | \\} |
| ... | ... | @@ -6954,7 +6954,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6954 | 6954 | }); |
| 6955 | 6955 | |
| 6956 | 6956 | cases.add("generic function returning opaque type", |
| 6957 | \\const FooType = @OpaqueType(); | |
| 6957 | \\const FooType = @Type(.Opaque); | |
| 6958 | 6958 | \\fn generic(comptime T: type) !T { |
| 6959 | 6959 | \\ return undefined; |
| 6960 | 6960 | \\} |
test/gen_h.zig+1-1| ... | ... | @@ -74,7 +74,7 @@ pub fn addCases(cases: *tests.GenHContext) void { |
| 74 | 74 | }); |
| 75 | 75 | |
| 76 | 76 | cases.add("declare opaque type", |
| 77 | \\const Foo = @OpaqueType(); | |
| 77 | \\const Foo = @Type(.Opaque); | |
| 78 | 78 | \\ |
| 79 | 79 | \\export fn entry(foo: ?*Foo) void { } |
| 80 | 80 | , &[_][]const u8{ |
test/stage1/behavior/misc.zig+3-3| ... | ... | @@ -444,9 +444,9 @@ export fn writeToVRam() void { |
| 444 | 444 | vram[0] = 'X'; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | const OpaqueA = @OpaqueType(); | |
| 448 | const OpaqueB = @OpaqueType(); | |
| 449 | test "@OpaqueType" { | |
| 447 | const OpaqueA = @Type(.Opaque); | |
| 448 | const OpaqueB = @Type(.Opaque); | |
| 449 | test "opaque types" { | |
| 450 | 450 | expect(*OpaqueA != *OpaqueB); |
| 451 | 451 | expect(mem.eql(u8, @typeName(OpaqueA), "OpaqueA")); |
| 452 | 452 | expect(mem.eql(u8, @typeName(OpaqueB), "OpaqueB")); |
test/translate_c.zig+7-7| ... | ... | @@ -36,9 +36,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 36 | 36 | \\struct foo { int x; int y[]; }; |
| 37 | 37 | \\struct bar { int x; int y[0]; }; |
| 38 | 38 | , &[_][]const u8{ |
| 39 | \\pub const struct_foo = @OpaqueType(); | |
| 39 | \\pub const struct_foo = @Type(.Opaque); | |
| 40 | 40 | , |
| 41 | \\pub const struct_bar = @OpaqueType(); | |
| 41 | \\pub const struct_bar = @Type(.Opaque); | |
| 42 | 42 | }); |
| 43 | 43 | |
| 44 | 44 | cases.add("nested loops without blocks", |
| ... | ... | @@ -106,7 +106,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 106 | 106 | \\pub const struct_arcan_shmif_page = // |
| 107 | 107 | , |
| 108 | 108 | \\warning: unsupported type: 'Atomic' |
| 109 | \\ @OpaqueType(); // | |
| 109 | \\ @Type(.Opaque); // | |
| 110 | 110 | , |
| 111 | 111 | \\ warning: struct demoted to opaque type - unable to translate type of field abufused |
| 112 | 112 | , // TODO should be `addr: *struct_arcan_shmif_page` |
| ... | ... | @@ -285,8 +285,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 285 | 285 | \\ struct opaque_2 *cast = (struct opaque_2 *)opaque; |
| 286 | 286 | \\} |
| 287 | 287 | , &[_][]const u8{ |
| 288 | \\pub const struct_opaque = @OpaqueType(); | |
| 289 | \\pub const struct_opaque_2 = @OpaqueType(); | |
| 288 | \\pub const struct_opaque = @Type(.Opaque); | |
| 289 | \\pub const struct_opaque_2 = @Type(.Opaque); | |
| 290 | 290 | \\pub export fn function(arg_opaque_1: ?*struct_opaque) void { |
| 291 | 291 | \\ var opaque_1 = arg_opaque_1; |
| 292 | 292 | \\ var cast: ?*struct_opaque_2 = @ptrCast(?*struct_opaque_2, opaque_1); |
| ... | ... | @@ -524,7 +524,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 524 | 524 | \\ struct Foo *foo; |
| 525 | 525 | \\}; |
| 526 | 526 | , &[_][]const u8{ |
| 527 | \\pub const struct_Foo = @OpaqueType(); | |
| 527 | \\pub const struct_Foo = @Type(.Opaque); | |
| 528 | 528 | , |
| 529 | 529 | \\pub const struct_Bar = extern struct { |
| 530 | 530 | \\ foo: ?*struct_Foo, |
| ... | ... | @@ -601,7 +601,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 601 | 601 | \\struct Foo; |
| 602 | 602 | \\struct Foo *some_func(struct Foo *foo, int x); |
| 603 | 603 | , &[_][]const u8{ |
| 604 | \\pub const struct_Foo = @OpaqueType(); | |
| 604 | \\pub const struct_Foo = @Type(.Opaque); | |
| 605 | 605 | , |
| 606 | 606 | \\pub extern fn some_func(foo: ?*struct_Foo, x: c_int) ?*struct_Foo; |
| 607 | 607 | , |