diff options
| author | Tadeo Kondrak <me@tadeo.ca> | 2020-04-27 23:23:13 -0600 |
|---|---|---|
| committer | Tadeo Kondrak <me@tadeo.ca> | 2020-04-28 00:02:14 -0600 |
| commit | 2ef0795bfb440671bffd3c6b93603c012d27c24d (patch) | |
| tree | 32f25393c954a3c0f0a792da9517ba12cbcb8ea9 /doc | |
| parent | 17e41f6cd36f9b086036b445c0f6cd4bfc576b9d (diff) | |
| download | zig-2ef0795bfb440671bffd3c6b93603c012d27c24d.tar.gz zig-2ef0795bfb440671bffd3c6b93603c012d27c24d.zip | |
Update language reference for recent @Type changes
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/langref.html.in | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in index 3e335c8d64..fa649ebf25 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -1885,7 +1885,7 @@ test "null terminated array" { <li>Supports slice syntax: {#syntax#}ptr[start..end]{#endsyntax#}</li> <li>Supports pointer arithmetic: {#syntax#}ptr + x{#endsyntax#}, {#syntax#}ptr - x{#endsyntax#}</li> <li>{#syntax#}T{#endsyntax#} must have a known size, which means that it cannot be - {#syntax#}c_void{#endsyntax#} or any other {#link|@OpaqueType#}.</li> + {#syntax#}c_void{#endsyntax#} or any other {#link|opaque type|Opaque Types#}.</li> </ul> </li> </ul> @@ -5392,7 +5392,7 @@ fn eql_i32(a: i32, b: i32) bool { </p> <p> {#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this: - {#syntax#}pub const c_void = @OpaqueType();{#endsyntax#}. + {#syntax#}pub const c_void = @Type(.Opaque);{#endsyntax#}. {#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size. </p> <p> @@ -7666,30 +7666,6 @@ mem.set(u8, dest, c);{#endsyntax#}</pre> </p> {#header_close#} - {#header_open|@OpaqueType#} - <pre>{#syntax#}@OpaqueType() type{#endsyntax#}</pre> - <p> - Creates a new type with an unknown (but non-zero) size and alignment. - </p> - <p> - This is typically used for type safety when interacting with C code that does not expose struct details. - Example: - </p> - {#code_begin|test_err|expected type '*Derp', found '*Wat'#} -const Derp = @OpaqueType(); -const Wat = @OpaqueType(); - -extern fn bar(d: *Derp) void; -fn foo(w: *Wat) callconv(.C) void { - bar(w); -} - -test "call foo" { - foo(undefined); -} - {#code_end#} - {#header_close#} - {#header_open|@panic#} <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre> <p> @@ -8274,21 +8250,21 @@ test "integer truncation" { <li>{#syntax#}comptime_float{#endsyntax#}</li> <li>{#syntax#}@TypeOf(undefined){#endsyntax#}</li> <li>{#syntax#}@TypeOf(null){#endsyntax#}</li> + <li>{#link|Arrays#}</li> + <li>{#link|Optionals#}</li> + <li>{#link|Error Union Type#}</li> + <li>{#link|Vectors#}</li> + <li>{#link|Opaque Types#}</li> + <li>AnyFrame</li> </ul> <p> For these types it is a <a href="https://github.com/ziglang/zig/issues/2907">TODO in the compiler to implement</a>: </p> <ul> - <li>Array</li> - <li>Optional</li> - <li>ErrorUnion</li> <li>ErrorSet</li> <li>Enum</li> - <li>Opaque</li> <li>FnFrame</li> - <li>AnyFrame</li> - <li>Vector</li> <li>EnumLiteral</li> </ul> <p> @@ -8373,6 +8349,28 @@ fn foo(comptime T: type, ptr: *T) T { {#header_close#} {#header_close#} + {#header_open|Opaque Types#} + {#syntax#}@Type(.Opaque){#endsyntax#} creates a new type with an unknown (but non-zero) size and alignment. + </p> + <p> + This is typically used for type safety when interacting with C code that does not expose struct details. + Example: + </p> + {#code_begin|test_err|expected type '*Derp', found '*Wat'#} +const Derp = @Type(.Opaque); +const Wat = @Type(.Opaque); + +extern fn bar(d: *Derp) void; +fn foo(w: *Wat) callconv(.C) void { + bar(w); +} + +test "call foo" { + foo(undefined); +} + {#code_end#} + {#header_close#} + {#header_open|Build Mode#} <p> Zig has four build modes: |
