zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 6b8ae6fffb71128169de447851244869aebb882b (tree)
parent 0a563902305369ca298f5b2d360be55f4d5a95e8
Author: Tadeo Kondrak <me@tadeo.ca>
Date:   Sat, 26 Sep 2020 09:05:11 -0600

langref: update for opaque {} syntax

Diffstat:
Mdoc/docgen.zig | 1+
Mdoc/langref.html.in | 15++++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/doc/docgen.zig b/doc/docgen.zig @@ -808,6 +808,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: anytype, source_token: .Keyword_noalias, .Keyword_noinline, .Keyword_nosuspend, + .Keyword_opaque, .Keyword_or, .Keyword_orelse, .Keyword_packed, diff --git a/doc/langref.html.in b/doc/langref.html.in @@ -1988,7 +1988,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|opaque type|Opaque Types#}.</li> + {#syntax#}c_void{#endsyntax#} or any other {#link|opaque type|opaque#}.</li> </ul> </li> </ul> @@ -5545,7 +5545,7 @@ test "turn HashMap into a set with void" { </p> <p> {#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this: - {#syntax#}pub const c_void = @Type(.Opaque);{#endsyntax#}. + {#syntax#}pub const c_void = 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> @@ -8471,7 +8471,7 @@ test "integer truncation" { <li>{#link|Error Set Type#}</li> <li>{#link|Error Union Type#}</li> <li>{#link|Vectors#}</li> - <li>{#link|Opaque Types#}</li> + <li>{#link|opaque#}</li> <li>{#link|@Frame#}</li> <li>{#syntax#}anyframe{#endsyntax#}</li> <li>{#link|struct#}</li> @@ -8547,17 +8547,18 @@ fn foo(comptime T: type, ptr: *T) T { {#header_close#} {#header_close#} - {#header_open|Opaque Types#} + {#header_open|opaque#} <p> - {#syntax#}@Type(.Opaque){#endsyntax#} creates a new type with an unknown (but non-zero) size and alignment. + {#syntax#}opaque {}{#endsyntax#} declares a new type with an unknown (but non-zero) size and alignment. + It can have declarations like structs, unions, or enums. </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); +const Derp = opaque {}; +const Wat = opaque {}; extern fn bar(d: *Derp) void; fn foo(w: *Wat) callconv(.C) void {