update to zig 0.14.0
This commit is contained in:
parent
12e24b01ad
commit
4f16553410
14 changed files with 97 additions and 68 deletions
2
.envrc
2
.envrc
|
@ -5,4 +5,4 @@ if ! has zvm_direnv_version || ! zvm_direnv_version 1.0.0; then
|
|||
source_url "https://git.lerch.org/lobo/zvm-direnv/raw/tag/1.0.0/direnvrc" "sha256-Gtddvcr6aJsrjKd53uChxA1reQmJgEBpmPUWmMdtDIQ="
|
||||
fi
|
||||
|
||||
use zig 2024.11.0-mach
|
||||
use zig 0.14.0
|
||||
|
|
9
.github/workflows/build.yaml
vendored
9
.github/workflows/build.yaml
vendored
|
@ -1,11 +1,10 @@
|
|||
name: AWS-Zig Build
|
||||
name: Current zig version build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '!zig-develop*'
|
||||
- 'master'
|
||||
jobs:
|
||||
build-zig-0-12-0-amd64:
|
||||
build-amd64:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.env.GITEA_ACTIONS != 'true' }}
|
||||
steps:
|
||||
|
@ -14,7 +13,7 @@ jobs:
|
|||
- name: Setup Zig
|
||||
uses: mlugg/setup-zig@v1.2.1
|
||||
with:
|
||||
version: 0.13.0
|
||||
version: 0.14.0
|
||||
- name: Run tests
|
||||
run: zig build test -Dbroken-windows --verbose # Github runners try to run the windows tests despite disabling foreign checks
|
||||
- name: Build example
|
||||
|
|
4
.github/workflows/zig-mach.yaml
vendored
4
.github/workflows/zig-mach.yaml
vendored
|
@ -1,8 +1,8 @@
|
|||
name: aws-zig mach nominated build
|
||||
name: Latest mach nominated zig version build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'zig-develop*'
|
||||
- 'zig-mach*'
|
||||
jobs:
|
||||
build-zig-mach-latest:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
2
.github/workflows/zig-nightly.yaml
vendored
2
.github/workflows/zig-nightly.yaml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: aws-zig nightly build
|
||||
name: Nightly zig version Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
|
20
.github/workflows/zig-previous.yaml
vendored
Normal file
20
.github/workflows/zig-previous.yaml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
name: Previous zig version Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'zig-0.13'
|
||||
jobs:
|
||||
build-amd64:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.env.GITEA_ACTIONS != 'true' }}
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Zig
|
||||
uses: mlugg/setup-zig@v1.2.1
|
||||
with:
|
||||
version: 0.13.0
|
||||
- name: Run tests
|
||||
run: zig build test -Dbroken-windows --verbose # Github runners try to run the windows tests despite disabling foreign checks
|
||||
- name: Build example
|
||||
run: ( cd example && zig build ) # Make sure example builds
|
|
@ -1,6 +1,7 @@
|
|||
.{
|
||||
.name = "aws",
|
||||
.name = .aws,
|
||||
.version = "0.0.1",
|
||||
.fingerprint = 0x1f26b7b27005bb49,
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
|
@ -11,8 +12,8 @@
|
|||
|
||||
.dependencies = .{
|
||||
.smithy = .{
|
||||
.url = "https://git.lerch.org/lobo/smithy/archive/3ed98751bc414e005af6ad185feb213d4366c0db.tar.gz",
|
||||
.hash = "12204a784751a4ad5ed6c8955ba91fcbc4a3cad6c5a7da38f39abf074ef801d13172",
|
||||
.url = "https://git.lerch.org/lobo/smithy/archive/a4c6ec6dfe552c57bab601c7d99e8de02bbab1fe.tar.gz",
|
||||
.hash = "smithy-1.0.0-uAyBgS_MAgC4qgc9QaEy5Y5Nf7kv32buQZBYugqNQsAn",
|
||||
},
|
||||
.models = .{
|
||||
.url = "https://github.com/aws/aws-sdk-go-v2/archive/58cf6509525a12d64fd826da883bfdbacbd2f00e.tar.gz",
|
||||
|
|
|
@ -435,7 +435,7 @@ fn generateServices(allocator: std.mem.Allocator, comptime _: []const u8, file:
|
|||
|
||||
fn generateAdditionalTypes(allocator: std.mem.Allocator, file_state: FileGenerationState, writer: anytype) !void {
|
||||
// More types may be added during processing
|
||||
while (file_state.additional_types_to_generate.popOrNull()) |t| {
|
||||
while (file_state.additional_types_to_generate.pop()) |t| {
|
||||
if (file_state.additional_types_generated.getEntry(t.name) != null) continue;
|
||||
// std.log.info("\t\t{s}", .{t.name});
|
||||
var type_stack = std.ArrayList(*const smithy.ShapeInfo).init(allocator);
|
||||
|
|
60
src/aws.zig
60
src/aws.zig
|
@ -263,9 +263,9 @@ pub fn Request(comptime request_action: anytype) type {
|
|||
fn callJson(request: ActionRequest, options: Options) !FullResponseType {
|
||||
const target =
|
||||
try std.fmt.allocPrint(options.client.allocator, "{s}.{s}", .{
|
||||
Self.service_meta.name,
|
||||
action.action_name,
|
||||
});
|
||||
Self.service_meta.name,
|
||||
action.action_name,
|
||||
});
|
||||
defer options.client.allocator.free(target);
|
||||
|
||||
var buffer = std.ArrayList(u8).init(options.client.allocator);
|
||||
|
@ -326,11 +326,11 @@ pub fn Request(comptime request_action: anytype) type {
|
|||
// originally?
|
||||
const body =
|
||||
try std.fmt.allocPrint(options.client.allocator, "Action={s}&Version={s}{s}{s}", .{
|
||||
action.action_name,
|
||||
Self.service_meta.version,
|
||||
continuation,
|
||||
buffer.items,
|
||||
});
|
||||
action.action_name,
|
||||
Self.service_meta.version,
|
||||
continuation,
|
||||
buffer.items,
|
||||
});
|
||||
defer options.client.allocator.free(body);
|
||||
return try Self.callAws(.{
|
||||
.query = query,
|
||||
|
@ -739,20 +739,20 @@ pub fn Request(comptime request_action: anytype) type {
|
|||
errdefer options.client.allocator.destroy(ptr);
|
||||
@field(ptr.*, std.meta.fields(action.Response)[0].name) =
|
||||
json.parse(response_types.RawResponse, &stream, parser_options) catch |e| {
|
||||
log.err(
|
||||
\\Call successful, but unexpected response from service.
|
||||
\\This could be the result of a bug or a stale set of code generated
|
||||
\\service models.
|
||||
\\
|
||||
\\Model Type: {}
|
||||
\\
|
||||
\\Response from server:
|
||||
\\
|
||||
\\{s}
|
||||
\\
|
||||
, .{ action.Response, data });
|
||||
return e;
|
||||
};
|
||||
log.err(
|
||||
\\Call successful, but unexpected response from service.
|
||||
\\This could be the result of a bug or a stale set of code generated
|
||||
\\service models.
|
||||
\\
|
||||
\\Model Type: {}
|
||||
\\
|
||||
\\Response from server:
|
||||
\\
|
||||
\\{s}
|
||||
\\
|
||||
, .{ action.Response, data });
|
||||
return e;
|
||||
};
|
||||
break :blk ptr;
|
||||
};
|
||||
return ParsedJsonData(response_types.NormalResponse){
|
||||
|
@ -777,8 +777,12 @@ fn coerceFromString(comptime T: type, val: []const u8) anyerror!T {
|
|||
// TODO: This is terrible...fix it
|
||||
switch (T) {
|
||||
bool => return std.ascii.eqlIgnoreCase(val, "true"),
|
||||
i64 => return parseInt(T, val) catch |e| {
|
||||
log.err("Invalid string representing i64: {s}", .{val});
|
||||
i64, i128 => return parseInt(T, val) catch |e| {
|
||||
log.err("Invalid string representing {s}: {s}", .{ @typeName(T), val });
|
||||
return e;
|
||||
},
|
||||
f64, f128 => return std.fmt.parseFloat(T, val) catch |e| {
|
||||
log.err("Invalid string representing {s}: {s}", .{ @typeName(T), val });
|
||||
return e;
|
||||
},
|
||||
else => return val,
|
||||
|
@ -932,14 +936,14 @@ fn ServerResponse(comptime action: anytype) type {
|
|||
.{
|
||||
.name = action.action_name ++ "Result",
|
||||
.type = T,
|
||||
.default_value = null,
|
||||
.default_value_ptr = null,
|
||||
.is_comptime = false,
|
||||
.alignment = 0,
|
||||
},
|
||||
.{
|
||||
.name = "ResponseMetadata",
|
||||
.type = ResponseMetadata,
|
||||
.default_value = null,
|
||||
.default_value_ptr = null,
|
||||
.is_comptime = false,
|
||||
.alignment = 0,
|
||||
},
|
||||
|
@ -955,7 +959,7 @@ fn ServerResponse(comptime action: anytype) type {
|
|||
.{
|
||||
.name = action.action_name ++ "Response",
|
||||
.type = Result,
|
||||
.default_value = null,
|
||||
.default_value_ptr = null,
|
||||
.is_comptime = false,
|
||||
.alignment = 0,
|
||||
},
|
||||
|
@ -1143,7 +1147,7 @@ fn addQueryArg(comptime ValueType: type, prefix: []const u8, key: []const u8, va
|
|||
},
|
||||
// if this is a pointer, we want to make sure it is more than just a string
|
||||
.pointer => |ptr| {
|
||||
if (ptr.child == u8 or ptr.size != .Slice) {
|
||||
if (ptr.child == u8 or ptr.size != .slice) {
|
||||
// This is just a string
|
||||
return try addBasicQueryArg(prefix, key, value, writer);
|
||||
}
|
||||
|
|
|
@ -662,12 +662,12 @@ fn canonicalUri(allocator: std.mem.Allocator, path: []const u8, double_encode: b
|
|||
}
|
||||
defer allocator.free(encoded_once);
|
||||
var encoded_twice = try encodeUri(allocator, encoded_once);
|
||||
defer allocator.free(encoded_twice);
|
||||
log.debug("encoded path (2): {s}", .{encoded_twice});
|
||||
if (std.mem.lastIndexOf(u8, encoded_twice, "?")) |i| {
|
||||
_ = allocator.resize(encoded_twice, i);
|
||||
return encoded_twice[0..i];
|
||||
return try allocator.dupe(u8, encoded_twice[0..i]);
|
||||
}
|
||||
return encoded_twice;
|
||||
return try allocator.dupe(u8, encoded_twice);
|
||||
}
|
||||
|
||||
fn encodeParamPart(allocator: std.mem.Allocator, path: []const u8) ![]const u8 {
|
||||
|
@ -936,6 +936,7 @@ fn canonicalHeaderValue(allocator: std.mem.Allocator, value: []const u8) ![]cons
|
|||
const in_quote = false;
|
||||
var start: usize = 0;
|
||||
const rc = try allocator.alloc(u8, value.len);
|
||||
defer allocator.free(rc);
|
||||
var rc_inx: usize = 0;
|
||||
for (value, 0..) |c, i| {
|
||||
if (!started and !std.ascii.isWhitespace(c)) {
|
||||
|
@ -953,8 +954,7 @@ fn canonicalHeaderValue(allocator: std.mem.Allocator, value: []const u8) ![]cons
|
|||
// Trim end
|
||||
while (std.ascii.isWhitespace(rc[rc_inx - 1]))
|
||||
rc_inx -= 1;
|
||||
_ = allocator.resize(rc, rc_inx);
|
||||
return rc[0..rc_inx];
|
||||
return try allocator.dupe(u8, rc[0..rc_inx]);
|
||||
}
|
||||
fn lessThan(context: void, lhs: std.http.Header, rhs: std.http.Header) bool {
|
||||
_ = context;
|
||||
|
@ -986,6 +986,7 @@ test "canonical uri" {
|
|||
const path = "/documents and settings/?foo=bar";
|
||||
const expected = "/documents%2520and%2520settings/";
|
||||
const actual = try canonicalUri(allocator, path, true);
|
||||
|
||||
defer allocator.free(actual);
|
||||
try std.testing.expectEqualStrings(expected, actual);
|
||||
|
||||
|
|
24
src/json.zig
24
src/json.zig
|
@ -1723,7 +1723,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
|
|||
}
|
||||
inline for (structInfo.fields, 0..) |field, i| {
|
||||
if (!fields_seen[i]) {
|
||||
if (field.default_value) |default_value_ptr| {
|
||||
if (field.default_value_ptr) |default_value_ptr| {
|
||||
if (!field.is_comptime) {
|
||||
const default_value = @as(*align(1) const field.type, @ptrCast(default_value_ptr)).*;
|
||||
@field(r, field.name) = default_value;
|
||||
|
@ -1773,18 +1773,18 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
|
|||
.pointer => |ptrInfo| {
|
||||
const allocator = options.allocator orelse return error.AllocatorRequired;
|
||||
switch (ptrInfo.size) {
|
||||
.One => {
|
||||
.one => {
|
||||
const r: T = try allocator.create(ptrInfo.child);
|
||||
errdefer allocator.destroy(r);
|
||||
r.* = try parseInternal(ptrInfo.child, token, tokens, options);
|
||||
return r;
|
||||
},
|
||||
.Slice => {
|
||||
.slice => {
|
||||
switch (token) {
|
||||
.ArrayBegin => {
|
||||
var arraylist = std.ArrayList(ptrInfo.child).init(allocator);
|
||||
errdefer {
|
||||
while (arraylist.popOrNull()) |v| {
|
||||
while (arraylist.pop()) |v| {
|
||||
parseFree(ptrInfo.child, v, options);
|
||||
}
|
||||
arraylist.deinit();
|
||||
|
@ -1829,7 +1829,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
|
|||
if (value_type == null) return error.UnexpectedToken;
|
||||
var arraylist = std.ArrayList(ptrInfo.child).init(allocator);
|
||||
errdefer {
|
||||
while (arraylist.popOrNull()) |v| {
|
||||
while (arraylist.pop()) |v| {
|
||||
parseFree(ptrInfo.child, v, options);
|
||||
}
|
||||
arraylist.deinit();
|
||||
|
@ -1879,7 +1879,7 @@ fn isMapPattern(comptime T: type) bool {
|
|||
// Let's just double check before proceeding
|
||||
const ti = @typeInfo(T);
|
||||
if (ti != .pointer) return false;
|
||||
if (ti.pointer.size != .Slice) return false;
|
||||
if (ti.pointer.size != .slice) return false;
|
||||
const ti_child = @typeInfo(ti.pointer.child);
|
||||
if (ti_child != .@"struct") return false;
|
||||
if (ti_child.@"struct".fields.len != 2) return false;
|
||||
|
@ -1935,11 +1935,11 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void {
|
|||
.pointer => |ptrInfo| {
|
||||
const allocator = options.allocator orelse unreachable;
|
||||
switch (ptrInfo.size) {
|
||||
.One => {
|
||||
.one => {
|
||||
parseFree(ptrInfo.child, value.*, options);
|
||||
allocator.destroy(value);
|
||||
},
|
||||
.Slice => {
|
||||
.slice => {
|
||||
for (value) |v| {
|
||||
parseFree(ptrInfo.child, v, options);
|
||||
}
|
||||
|
@ -2284,7 +2284,7 @@ pub const Parser = struct {
|
|||
return;
|
||||
}
|
||||
|
||||
var value = p.stack.pop();
|
||||
var value = p.stack.pop().?;
|
||||
try p.pushToParent(&value);
|
||||
},
|
||||
.String => |s| {
|
||||
|
@ -2350,7 +2350,7 @@ pub const Parser = struct {
|
|||
return;
|
||||
}
|
||||
|
||||
var value = p.stack.pop();
|
||||
var value = p.stack.pop().?;
|
||||
try p.pushToParent(&value);
|
||||
},
|
||||
.ObjectBegin => {
|
||||
|
@ -2922,7 +2922,7 @@ pub fn stringify(
|
|||
},
|
||||
.error_set => return stringify(@as([]const u8, @errorName(value)), options, out_stream),
|
||||
.pointer => |ptr_info| switch (ptr_info.size) {
|
||||
.One => switch (@typeInfo(ptr_info.child)) {
|
||||
.one => switch (@typeInfo(ptr_info.child)) {
|
||||
.array => {
|
||||
const Slice = []const std.meta.Elem(ptr_info.child);
|
||||
return stringify(@as(Slice, value), options, out_stream);
|
||||
|
@ -2933,7 +2933,7 @@ pub fn stringify(
|
|||
},
|
||||
},
|
||||
// TODO: .Many when there is a sentinel (waiting for https://github.com/ziglang/zig/pull/3972)
|
||||
.Slice => {
|
||||
.slice => {
|
||||
if (ptr_info.child == u8 and options.string == .String and std.unicode.utf8ValidateSlice(value)) {
|
||||
try out_stream.writeByte('\"');
|
||||
var i: usize = 0;
|
||||
|
|
|
@ -12,7 +12,7 @@ pub fn Services(comptime service_imports: anytype) type {
|
|||
item.* = .{
|
||||
.name = @tagName(service_imports[i]),
|
||||
.type = @TypeOf(import_field),
|
||||
.default_value = &import_field,
|
||||
.default_value_ptr = &import_field,
|
||||
.is_comptime = false,
|
||||
.alignment = 0,
|
||||
};
|
||||
|
|
|
@ -24,10 +24,11 @@ fn encodeStruct(
|
|||
comptime options: EncodingOptions,
|
||||
) !bool {
|
||||
var rc = first;
|
||||
var arena = std.heap.ArenaAllocator.init(allocator);
|
||||
defer arena.deinit();
|
||||
const arena_alloc = arena.allocator();
|
||||
inline for (@typeInfo(@TypeOf(obj)).@"struct".fields) |field| {
|
||||
const field_name = try options.field_name_transformer(allocator, field.name);
|
||||
defer if (options.field_name_transformer.* != defaultTransformer)
|
||||
allocator.free(field_name);
|
||||
const field_name = try options.field_name_transformer(arena_alloc, field.name);
|
||||
// @compileLog(@typeInfo(field.field_type).Pointer);
|
||||
rc = try encodeInternal(allocator, parent, field_name, rc, @field(obj, field.name), writer, options);
|
||||
}
|
||||
|
@ -50,7 +51,7 @@ pub fn encodeInternal(
|
|||
.optional => if (obj) |o| {
|
||||
rc = try encodeInternal(allocator, parent, field_name, first, o, writer, options);
|
||||
},
|
||||
.pointer => |ti| if (ti.size == .One) {
|
||||
.pointer => |ti| if (ti.size == .one) {
|
||||
rc = try encodeInternal(allocator, parent, field_name, first, obj.*, writer, options);
|
||||
} else {
|
||||
if (!first) _ = try writer.write("&");
|
||||
|
|
|
@ -653,7 +653,10 @@ fn dupeAndUnescape(alloc: Allocator, text: []const u8) ![]const u8 {
|
|||
|
||||
// This error is not strictly true, but we need to match one of the items
|
||||
// from the error set provided by the other stdlib calls at the calling site
|
||||
if (!alloc.resize(str, j)) return error.OutOfMemory;
|
||||
if (!alloc.resize(str, j)) {
|
||||
defer alloc.free(str);
|
||||
return alloc.dupe(u8, str[0..j]) catch return error.OutOfMemory;
|
||||
}
|
||||
return str[0..j];
|
||||
}
|
||||
|
||||
|
|
|
@ -313,13 +313,13 @@ fn parseInternal(comptime T: type, element: *xml.Element, options: ParseOptions)
|
|||
.pointer => |ptr_info| {
|
||||
const allocator = options.allocator orelse return error.AllocatorRequired;
|
||||
switch (ptr_info.size) {
|
||||
.One => {
|
||||
.one => {
|
||||
const r: T = try allocator.create(ptr_info.child);
|
||||
errdefer allocator.free(r);
|
||||
r.* = try parseInternal(ptr_info.child, element, options);
|
||||
return r;
|
||||
},
|
||||
.Slice => {
|
||||
.slice => {
|
||||
// TODO: Detect and deal with arrays. This will require two
|
||||
// passes through the element children - one to
|
||||
// determine if it is an array, one to parse the elements
|
||||
|
@ -348,10 +348,10 @@ fn parseInternal(comptime T: type, element: *xml.Element, options: ParseOptions)
|
|||
}
|
||||
return try allocator.dupe(u8, element.children.items[0].CharData);
|
||||
},
|
||||
.Many => {
|
||||
.many => {
|
||||
return error.ManyPointerSizeNotImplemented;
|
||||
},
|
||||
.C => {
|
||||
.c => {
|
||||
return error.CPointerSizeNotImplemented;
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue