authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-27 14:41:44-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-28 14:51:55-05:00
log662b5f7c6045ba857d0d9abd72350a82f0b7ddf3
tree028405b54b4d73a6fee4b8692f2dd6e94941f67c
parentf89a1844bfc97f2023fc9961cdf12900ccb77cf8
signaturelock-open Commit is signed but in an unrecognized format.

update docs to latest Target API


2 files changed, 18 insertions(+), 18 deletions(-)

doc/docgen.zig+3-3
...@@ -1146,10 +1146,10 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1146,10 +1146,10 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1146 return parseError(tokenizer, code.source_token, "example failed to compile", .{});1146 return parseError(tokenizer, code.source_token, "example failed to compile", .{});
11471147
1148 if (code.target_str) |triple| {1148 if (code.target_str) |triple| {
1149 if ((mem.startsWith(u8, triple, "wasm32") or1149 if (mem.startsWith(u8, triple, "wasm32") or
1150 mem.startsWith(u8, triple, "riscv64-linux") or1150 mem.startsWith(u8, triple, "riscv64-linux") or
1151 mem.startsWith(u8, triple, "x86_64-linux")) and1151 (mem.startsWith(u8, triple, "x86_64-linux") and
1152 (std.Target.current.os.tag != .linux or std.Target.current.cpu.arch != .x86_64))1152 std.Target.current.os.tag != .linux or std.Target.current.cpu.arch != .x86_64))
1153 {1153 {
1154 // skip execution1154 // skip execution
1155 try out.print("</code></pre>\n", .{});1155 try out.print("</code></pre>\n", .{});
doc/langref.html.in+15-15
...@@ -965,7 +965,8 @@ const nan = std.math.nan(f128);...@@ -965,7 +965,8 @@ const nan = std.math.nan(f128);
965 but you can switch to {#syntax#}Optimized{#endsyntax#} mode on a per-block basis:</p>965 but you can switch to {#syntax#}Optimized{#endsyntax#} mode on a per-block basis:</p>
966 {#code_begin|obj|foo#}966 {#code_begin|obj|foo#}
967 {#code_release_fast#}967 {#code_release_fast#}
968const builtin = @import("builtin");968const std = @import("std");
969const builtin = std.builtin;
969const big = @as(f64, 1 << 40);970const big = @as(f64, 1 << 40);
970971
971export fn foo_strict(x: f64) f64 {972export fn foo_strict(x: f64) f64 {
...@@ -2063,15 +2064,15 @@ test "pointer child type" {...@@ -2063,15 +2064,15 @@ test "pointer child type" {
2063 alignment of the underlying type, it can be omitted from the type:2064 alignment of the underlying type, it can be omitted from the type:
2064 </p>2065 </p>
2065 {#code_begin|test#}2066 {#code_begin|test#}
2066const assert = @import("std").debug.assert;2067const std = @import("std");
2067const builtin = @import("builtin");2068const assert = std.debug.assert;
20682069
2069test "variable alignment" {2070test "variable alignment" {
2070 var x: i32 = 1234;2071 var x: i32 = 1234;
2071 const align_of_i32 = @alignOf(@TypeOf(x));2072 const align_of_i32 = @alignOf(@TypeOf(x));
2072 assert(@TypeOf(&x) == *i32);2073 assert(@TypeOf(&x) == *i32);
2073 assert(*i32 == *align(align_of_i32) i32);2074 assert(*i32 == *align(align_of_i32) i32);
2074 if (builtin.arch == builtin.Arch.x86_64) {2075 if (std.Target.current.cpu.arch == .x86_64) {
2075 assert((*i32).alignment == 4);2076 assert((*i32).alignment == 4);
2076 }2077 }
2077}2078}
...@@ -2474,7 +2475,7 @@ test "default struct initialization fields" {...@@ -2474,7 +2475,7 @@ test "default struct initialization fields" {
2474 </p>2475 </p>
2475 {#code_begin|test#}2476 {#code_begin|test#}
2476const std = @import("std");2477const std = @import("std");
2477const builtin = @import("builtin");2478const builtin = std.builtin;
2478const assert = std.debug.assert;2479const assert = std.debug.assert;
24792480
2480const Full = packed struct {2481const Full = packed struct {
...@@ -3204,8 +3205,8 @@ test "separate scopes" {...@@ -3204,8 +3205,8 @@ test "separate scopes" {
32043205
3205 {#header_open|switch#}3206 {#header_open|switch#}
3206 {#code_begin|test|switch#}3207 {#code_begin|test|switch#}
3207const assert = @import("std").debug.assert;3208const std = @import("std");
3208const builtin = @import("builtin");3209const assert = std.debug.assert;
32093210
3210test "switch simple" {3211test "switch simple" {
3211 const a: u64 = 10;3212 const a: u64 = 10;
...@@ -3249,16 +3250,16 @@ test "switch simple" {...@@ -3249,16 +3250,16 @@ test "switch simple" {
3249}3250}
32503251
3251// Switch expressions can be used outside a function:3252// Switch expressions can be used outside a function:
3252const os_msg = switch (builtin.os) {3253const os_msg = switch (std.Target.current.os.tag) {
3253 builtin.Os.linux => "we found a linux user",3254 .linux => "we found a linux user",
3254 else => "not a linux user",3255 else => "not a linux user",
3255};3256};
32563257
3257// Inside a function, switch statements implicitly are compile-time3258// Inside a function, switch statements implicitly are compile-time
3258// evaluated if the target expression is compile-time known.3259// evaluated if the target expression is compile-time known.
3259test "switch inside function" {3260test "switch inside function" {
3260 switch (builtin.os) {3261 switch (std.Target.current.os.tag) {
3261 builtin.Os.fuchsia => {3262 .fuchsia => {
3262 // On an OS other than fuchsia, block is not even analyzed,3263 // On an OS other than fuchsia, block is not even analyzed,
3263 // so this compile error is not triggered.3264 // so this compile error is not triggered.
3264 // On fuchsia this compile error would be triggered.3265 // On fuchsia this compile error would be triggered.
...@@ -7364,8 +7365,6 @@ test "main" {...@@ -7364,8 +7365,6 @@ test "main" {
7364 the {#syntax#}export{#endsyntax#} keyword used on a function:7365 the {#syntax#}export{#endsyntax#} keyword used on a function:
7365 </p>7366 </p>
7366 {#code_begin|obj#}7367 {#code_begin|obj#}
7367const builtin = @import("builtin");
7368
7369comptime {7368comptime {
7370 @export(internalName, .{ .name = "foo", .linkage = .Strong });7369 @export(internalName, .{ .name = "foo", .linkage = .Strong });
7371}7370}
...@@ -9397,7 +9396,7 @@ const separator = if (builtin.os == builtin.Os.windows) '\\' else '/';...@@ -9397,7 +9396,7 @@ const separator = if (builtin.os == builtin.Os.windows) '\\' else '/';
9397 </p>9396 </p>
9398 {#code_begin|test|detect_test#}9397 {#code_begin|test|detect_test#}
9399const std = @import("std");9398const std = @import("std");
9400const builtin = @import("builtin");9399const builtin = std.builtin;
9401const assert = std.debug.assert;9400const assert = std.debug.assert;
94029401
9403test "builtin.is_test" {9402test "builtin.is_test" {
...@@ -9715,7 +9714,8 @@ WebAssembly.instantiate(typedArray, {...@@ -9715,7 +9714,8 @@ WebAssembly.instantiate(typedArray, {
9715 <pre><code>$ node test.js9714 <pre><code>$ node test.js
9716The result is 3</code></pre>9715The result is 3</code></pre>
9717 {#header_open|WASI#}9716 {#header_open|WASI#}
9718 <p>Zig's support for WebAssembly System Interface (WASI) is under active development. Example of using the standard library and reading command line arguments:</p>9717 <p>Zig's support for WebAssembly System Interface (WASI) is under active development.
9718 Example of using the standard library and reading command line arguments:</p>
9719 {#code_begin|exe|wasi#}9719 {#code_begin|exe|wasi#}
9720 {#target_wasi#}9720 {#target_wasi#}
9721const std = @import("std");9721const std = @import("std");