update data files

This commit is contained in:
Techatrix 2023-04-17 21:59:34 +02:00 committed by Lee Cannon
parent 3ae56929fc
commit c77e3cebeb
2 changed files with 62 additions and 35 deletions

View File

@ -848,17 +848,16 @@ fn generateVersionDataFile(allocator: std.mem.Allocator, version: []const u8, pa
defer allocator.free(url); defer allocator.free(url);
const response = try httpGET(allocator, try std.Uri.parse(url)); const response = try httpGET(allocator, try std.Uri.parse(url));
switch (response) { const response_bytes = switch (response) {
.ok => {}, .success => |response_bytes| response_bytes,
.other => |status| { .other => |status| {
const error_name = status.phrase() orelse @tagName(status.class()); const error_name = status.phrase() orelse @tagName(status.class());
std.log.err("failed to download {s}: {s}", .{ url, error_name }); std.log.err("failed to download {s}: {s}", .{ url, error_name });
return error.DownloadFailed; return error.DownloadFailed;
}, },
} };
defer allocator.free(response.ok); defer allocator.free(response_bytes);
const response_bytes = response.ok;
// const response_bytes: []const u8 = @embedFile("langref.html.in"); // const response_bytes: []const u8 = @embedFile("langref.html.in");
var builtins = try collectBuiltinData(allocator, version, response_bytes); var builtins = try collectBuiltinData(allocator, version, response_bytes);
@ -956,7 +955,7 @@ fn generateVersionDataFile(allocator: std.mem.Allocator, version: []const u8, pa
} }
const Response = union(enum) { const Response = union(enum) {
ok: []const u8, success: []const u8,
other: std.http.Status, other: std.http.Status,
}; };
@ -965,26 +964,21 @@ fn httpGET(allocator: std.mem.Allocator, uri: std.Uri) !Response {
defer client.deinit(); defer client.deinit();
try client.ca_bundle.rescan(allocator); try client.ca_bundle.rescan(allocator);
var request = try client.request(uri, .{}, .{}); var request = try client.request(uri, .{ .connection = .close }, .{});
defer request.deinit(); defer request.deinit();
var output = std.ArrayListUnmanaged(u8){}; try request.do();
defer output.deinit(allocator); // try request.finish();
var buffer: [1024]u8 = undefined; if (request.response.headers.status.class() != .success) {
while (true) {
const size = try request.read(&buffer);
if (size == 0) break;
try output.appendSlice(allocator, buffer[0..size]);
}
if (request.response.headers.status != .ok) {
return .{ return .{
.other = request.response.headers.status, .other = request.response.headers.status,
}; };
} }
return .{ .ok = try output.toOwnedSlice(allocator) }; return .{
.success = try request.reader().readAllAlloc(allocator, std.math.maxInt(usize)),
};
} }
pub fn main() !void { pub fn main() !void {

View File

@ -205,7 +205,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@breakpoint", .name = "@breakpoint",
.signature = "@breakpoint()", .signature = "@breakpoint() void",
.snippet = "@breakpoint()", .snippet = "@breakpoint()",
.documentation = .documentation =
\\This function inserts a platform-specific debug trap instruction which causes debuggers to break there. Unlike for `@trap()`, execution may continue after this point if the program is resumed. \\This function inserts a platform-specific debug trap instruction which causes debuggers to break there. Unlike for `@trap()`, execution may continue after this point if the program is resumed.
@ -329,7 +329,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@cDefine", .name = "@cDefine",
.signature = "@cDefine(comptime name: []u8, value)", .signature = "@cDefine(comptime name: []u8, value) void",
.snippet = "@cDefine(${1:comptime name: []u8}, ${2:value})", .snippet = "@cDefine(${1:comptime name: []u8}, ${2:value})",
.documentation = .documentation =
\\This function can only occur inside `@cImport`. \\This function can only occur inside `@cImport`.
@ -370,7 +370,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@cInclude", .name = "@cInclude",
.signature = "@cInclude(comptime path: []u8)", .signature = "@cInclude(comptime path: []u8) void",
.snippet = "@cInclude(${1:comptime path: []u8})", .snippet = "@cInclude(${1:comptime path: []u8})",
.documentation = .documentation =
\\This function can only occur inside `@cImport`. \\This function can only occur inside `@cImport`.
@ -384,7 +384,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@clz", .name = "@clz",
.signature = "@clz(operand: anytype)", .signature = "@clz(operand: anytype) anytype",
.snippet = "@clz(${1:operand: anytype})", .snippet = "@clz(${1:operand: anytype})",
.documentation = .documentation =
\\`@TypeOf(operand)` must be an integer type or an integer vector type. \\`@TypeOf(operand)` must be an integer type or an integer vector type.
@ -469,7 +469,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@compileError", .name = "@compileError",
.signature = "@compileError(comptime msg: []u8)", .signature = "@compileError(comptime msg: []u8) noreturn",
.snippet = "@compileError(${1:comptime msg: []u8})", .snippet = "@compileError(${1:comptime msg: []u8})",
.documentation = .documentation =
\\This function, when semantically analyzed, causes a compile error with the message `msg`. \\This function, when semantically analyzed, causes a compile error with the message `msg`.
@ -482,7 +482,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@compileLog", .name = "@compileLog",
.signature = "@compileLog(args: ...)", .signature = "@compileLog(args: ...) void",
.snippet = "@compileLog(${1:args: ...})", .snippet = "@compileLog(${1:args: ...})",
.documentation = .documentation =
\\This function prints the arguments passed to it at compile-time. \\This function prints the arguments passed to it at compile-time.
@ -535,7 +535,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@ctz", .name = "@ctz",
.signature = "@ctz(operand: anytype)", .signature = "@ctz(operand: anytype) anytype",
.snippet = "@ctz(${1:operand: anytype})", .snippet = "@ctz(${1:operand: anytype})",
.documentation = .documentation =
\\`@TypeOf(operand)` must be an integer type or an integer vector type. \\`@TypeOf(operand)` must be an integer type or an integer vector type.
@ -554,7 +554,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@cUndef", .name = "@cUndef",
.signature = "@cUndef(comptime name: []u8)", .signature = "@cUndef(comptime name: []u8) void",
.snippet = "@cUndef(${1:comptime name: []u8})", .snippet = "@cUndef(${1:comptime name: []u8})",
.documentation = .documentation =
\\This function can only occur inside `@cImport`. \\This function can only occur inside `@cImport`.
@ -784,7 +784,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@fence", .name = "@fence",
.signature = "@fence(order: AtomicOrder)", .signature = "@fence(order: AtomicOrder) void",
.snippet = "@fence(${1:order: AtomicOrder})", .snippet = "@fence(${1:order: AtomicOrder})",
.documentation = .documentation =
\\The `fence` function is used to introduce happens-before edges between operations. \\The `fence` function is used to introduce happens-before edges between operations.
@ -1049,7 +1049,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@memcpy", .name = "@memcpy",
.signature = "@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize)", .signature = "@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize) void",
.snippet = "@memcpy(${1:noalias dest: [*]u8}, ${2:noalias source: [*]const u8}, ${3:byte_count: usize})", .snippet = "@memcpy(${1:noalias dest: [*]u8}, ${2:noalias source: [*]const u8}, ${3:byte_count: usize})",
.documentation = .documentation =
\\This function copies bytes from one region of memory to another. `dest` and `source` are both pointers and must not overlap. \\This function copies bytes from one region of memory to another. `dest` and `source` are both pointers and must not overlap.
@ -1074,7 +1074,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@memset", .name = "@memset",
.signature = "@memset(dest: [*]u8, c: u8, byte_count: usize)", .signature = "@memset(dest: [*]u8, c: u8, byte_count: usize) void",
.snippet = "@memset(${1:dest: [*]u8}, ${2:c: u8}, ${3:byte_count: usize})", .snippet = "@memset(${1:dest: [*]u8}, ${2:c: u8}, ${3:byte_count: usize})",
.documentation = .documentation =
\\This function sets a region of memory to `c`. `dest` is a pointer. \\This function sets a region of memory to `c`. `dest` is a pointer.
@ -1196,7 +1196,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@popCount", .name = "@popCount",
.signature = "@popCount(operand: anytype)", .signature = "@popCount(operand: anytype) anytype",
.snippet = "@popCount(${1:operand: anytype})", .snippet = "@popCount(${1:operand: anytype})",
.documentation = .documentation =
\\`@TypeOf(operand)` must be an integer type. \\`@TypeOf(operand)` must be an integer type.
@ -1213,7 +1213,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@prefetch", .name = "@prefetch",
.signature = "@prefetch(ptr: anytype, comptime options: std.builtin.PrefetchOptions)", .signature = "@prefetch(ptr: anytype, comptime options: std.builtin.PrefetchOptions) void",
.snippet = "@prefetch(${1:ptr: anytype}, ${2:comptime options: std.builtin.PrefetchOptions})", .snippet = "@prefetch(${1:ptr: anytype}, ${2:comptime options: std.builtin.PrefetchOptions})",
.documentation = .documentation =
\\This builtin tells the compiler to emit a prefetch instruction if supported by the target CPU. If the target CPU does not support the requested prefetch instruction, this builtin is a no-op. This function has no effect on the behavior of the program, only on the performance characteristics. \\This builtin tells the compiler to emit a prefetch instruction if supported by the target CPU. If the target CPU does not support the requested prefetch instruction, this builtin is a no-op. This function has no effect on the behavior of the program, only on the performance characteristics.
@ -1332,7 +1332,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@setAlignStack", .name = "@setAlignStack",
.signature = "@setAlignStack(comptime alignment: u29)", .signature = "@setAlignStack(comptime alignment: u29) void",
.snippet = "@setAlignStack(${1:comptime alignment: u29})", .snippet = "@setAlignStack(${1:comptime alignment: u29})",
.documentation = .documentation =
\\Ensures that a function will have a stack alignment of at least `alignment` bytes. \\Ensures that a function will have a stack alignment of at least `alignment` bytes.
@ -1343,7 +1343,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@setCold", .name = "@setCold",
.signature = "@setCold(comptime is_cold: bool)", .signature = "@setCold(comptime is_cold: bool) void",
.snippet = "@setCold(${1:comptime is_cold: bool})", .snippet = "@setCold(${1:comptime is_cold: bool})",
.documentation = .documentation =
\\Tells the optimizer that a function is rarely called. \\Tells the optimizer that a function is rarely called.
@ -1354,7 +1354,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@setEvalBranchQuota", .name = "@setEvalBranchQuota",
.signature = "@setEvalBranchQuota(comptime new_quota: u32)", .signature = "@setEvalBranchQuota(comptime new_quota: u32) void",
.snippet = "@setEvalBranchQuota(${1:comptime new_quota: u32})", .snippet = "@setEvalBranchQuota(${1:comptime new_quota: u32})",
.documentation = .documentation =
\\Changes the maximum number of backwards branches that compile-time code execution can use before giving up and making a compile error. \\Changes the maximum number of backwards branches that compile-time code execution can use before giving up and making a compile error.
@ -1380,7 +1380,7 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@setFloatMode", .name = "@setFloatMode",
.signature = "@setFloatMode(comptime mode: @import(\"std\").builtin.FloatMode)", .signature = "@setFloatMode(comptime mode: @import(\"std\").builtin.FloatMode) void",
.snippet = "@setFloatMode(${1:comptime mode: @import(\"std\").builtin.FloatMode})", .snippet = "@setFloatMode(${1:comptime mode: @import(\"std\").builtin.FloatMode})",
.documentation = .documentation =
\\Sets the floating point mode of the current scope. Possible values are: \\Sets the floating point mode of the current scope. Possible values are:
@ -2029,6 +2029,39 @@ pub const builtins = [_]Builtin{
"value: anytype", "value: anytype",
}, },
}, },
.{
.name = "@workGroupId",
.signature = "@workGroupId(comptime dimension: u32) u32",
.snippet = "@workGroupId(${1:comptime dimension: u32})",
.documentation =
\\Returns the index of the work group in the current kernel invocation in dimension `dimension`.
,
.arguments = &.{
"comptime dimension: u32",
},
},
.{
.name = "@workGroupSize",
.signature = "@workGroupSize(comptime dimension: u32) u32",
.snippet = "@workGroupSize(${1:comptime dimension: u32})",
.documentation =
\\Returns the number of work items that a work group has in dimension `dimension`.
,
.arguments = &.{
"comptime dimension: u32",
},
},
.{
.name = "@workItemId",
.signature = "@workItemId(comptime dimension: u32) u32",
.snippet = "@workItemId(${1:comptime dimension: u32})",
.documentation =
\\Returns the index of the work item in the work group in dimension `dimension`. This function returns values between `0` (inclusive) and `@workGroupSize(dimension)` (exclusive).
,
.arguments = &.{
"comptime dimension: u32",
},
},
}; };
// DO NOT EDIT // DO NOT EDIT