mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 05:56:07 +00:00
Merge pull request #189 from jetzig-framework/zig-alignment-changes
Use Alignment arg instead of integer
This commit is contained in:
commit
6d9fa8bff4
@ -447,7 +447,7 @@ fn generateMarkdownFragments(b: *std.Build) ![]const u8 {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const stat = try file.stat();
|
const stat = try file.stat();
|
||||||
const source = try file.readToEndAllocOptions(b.allocator, @intCast(stat.size), null, @alignOf(u8), 0);
|
const source = try file.readToEndAllocOptions(b.allocator, @intCast(stat.size), null, .of(u8), 0);
|
||||||
if (try getMarkdownFragmentsSource(b.allocator, source)) |markdown_fragments_source| {
|
if (try getMarkdownFragmentsSource(b.allocator, source)) |markdown_fragments_source| {
|
||||||
return try std.fmt.allocPrint(b.allocator,
|
return try std.fmt.allocPrint(b.allocator,
|
||||||
\\const std = @import("std");
|
\\const std = @import("std");
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.name = .jetzig,
|
.name = .jetzig,
|
||||||
.version = "0.0.0",
|
.version = "0.0.0",
|
||||||
.fingerprint = 0x93ad8bfa2d209022,
|
.fingerprint = 0x93ad8bfa2d209022,
|
||||||
.minimum_zig_version = "0.15.0-dev.345+ec2888858",
|
.minimum_zig_version = "0.15.0-dev.355+206bd1ced",
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.jetcommon = .{
|
.jetcommon = .{
|
||||||
.url = "https://github.com/jetzig-framework/jetcommon/archive/fb4edc13759d87bfcd9b1f5fcefdf93f8c9c62dd.tar.gz",
|
.url = "https://github.com/jetzig-framework/jetcommon/archive/fb4edc13759d87bfcd9b1f5fcefdf93f8c9c62dd.tar.gz",
|
||||||
|
@ -376,7 +376,7 @@ fn generateRoutesForView(self: *Routes, dir: std.fs.Dir, path: []const u8) !Rout
|
|||||||
path,
|
path,
|
||||||
@intCast(stat.size),
|
@intCast(stat.size),
|
||||||
null,
|
null,
|
||||||
@alignOf(u8),
|
.of(u8),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
defer self.allocator.free(source);
|
defer self.allocator.free(source);
|
||||||
|
@ -33,7 +33,7 @@ pub fn main() !void {
|
|||||||
const Repo = jetzig.jetquery.Repo(jetzig.database.adapter, Schema);
|
const Repo = jetzig.jetquery.Repo(jetzig.database.adapter, Schema);
|
||||||
var repo = try Repo.loadConfig(
|
var repo = try Repo.loadConfig(
|
||||||
allocator,
|
allocator,
|
||||||
std.enums.nameCast(jetzig.jetquery.Environment, jetzig.environment),
|
@field(jetzig.jetquery.Environment, @tagName(jetzig.environment)),
|
||||||
.{ .env = try jetzig.database.repoEnv(env), .context = .cli },
|
.{ .env = try jetzig.database.repoEnv(env), .context = .cli },
|
||||||
);
|
);
|
||||||
defer repo.deinit();
|
defer repo.deinit();
|
||||||
@ -60,7 +60,7 @@ pub fn main() !void {
|
|||||||
|
|
||||||
const email = args[2];
|
const email = args[2];
|
||||||
|
|
||||||
try repo.insert(std.enums.nameCast(std.meta.DeclEnum(Schema), model), .{
|
try repo.insert(@field(std.meta.DeclEnum(Schema), model), .{
|
||||||
.email = email,
|
.email = email,
|
||||||
.password_hash = try hashPassword(allocator, password),
|
.password_hash = try hashPassword(allocator, password),
|
||||||
});
|
});
|
||||||
|
@ -133,7 +133,7 @@ const MigrationsRepo = jetquery.Repo(config.adapter, MigrateSchema);
|
|||||||
fn migrationsRepo(action: Action, allocator: std.mem.Allocator, repo_env: anytype) !MigrationsRepo {
|
fn migrationsRepo(action: Action, allocator: std.mem.Allocator, repo_env: anytype) !MigrationsRepo {
|
||||||
return try MigrationsRepo.loadConfig(
|
return try MigrationsRepo.loadConfig(
|
||||||
allocator,
|
allocator,
|
||||||
std.enums.nameCast(jetquery.Environment, environment),
|
@field(jetquery.Environment, @tagName(environment)),
|
||||||
.{
|
.{
|
||||||
.admin = switch (action) {
|
.admin = switch (action) {
|
||||||
.migrate, .rollback, .update => false,
|
.migrate, .rollback, .update => false,
|
||||||
@ -154,7 +154,7 @@ fn reflectSchema(allocator: std.mem.Allocator, repo_env: anytype) !void {
|
|||||||
const Repo = jetquery.Repo(config.adapter, Schema);
|
const Repo = jetquery.Repo(config.adapter, Schema);
|
||||||
var repo = try Repo.loadConfig(
|
var repo = try Repo.loadConfig(
|
||||||
allocator,
|
allocator,
|
||||||
std.enums.nameCast(jetquery.Environment, environment),
|
@field(jetquery.Environment, @tagName(environment)),
|
||||||
.{ .context = .migration, .env = repo_env },
|
.{ .context = .migration, .env = repo_env },
|
||||||
);
|
);
|
||||||
const reflect = @import("jetquery_reflect").Reflect(config.adapter, Schema).init(
|
const reflect = @import("jetquery_reflect").Reflect(config.adapter, Schema).init(
|
||||||
|
@ -33,7 +33,10 @@ pub const Date = jetcommon.types.Date;
|
|||||||
pub const authenticity_token_name = config.get([]const u8, "authenticity_token_name");
|
pub const authenticity_token_name = config.get([]const u8, "authenticity_token_name");
|
||||||
|
|
||||||
pub const build_options = @import("build_options");
|
pub const build_options = @import("build_options");
|
||||||
pub const environment = std.enums.nameCast(Environment.EnvironmentName, build_options.environment);
|
pub const environment = @field(
|
||||||
|
Environment.EnvironmentName,
|
||||||
|
@tagName(build_options.environment),
|
||||||
|
);
|
||||||
|
|
||||||
/// The primary interface for a Jetzig application. Create an `App` in your application's
|
/// The primary interface for a Jetzig application. Create an `App` in your application's
|
||||||
/// `src/main.zig` and call `start` to launch the application.
|
/// `src/main.zig` and call `start` to launch the application.
|
||||||
|
@ -14,7 +14,7 @@ pub fn getUserId(comptime id_type: IdType, request: *jetzig.Request) !?switch (i
|
|||||||
} {
|
} {
|
||||||
const session = try request.session();
|
const session = try request.session();
|
||||||
|
|
||||||
return session.getT(std.enums.nameCast(jetzig.data.ValueType, id_type), "_jetzig_user_id");
|
return session.getT(@field(jetzig.data.ValueType, id_type), "_jetzig_user_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signIn(request: *jetzig.Request, user_id: anytype) !void {
|
pub fn signIn(request: *jetzig.Request, user_id: anytype) !void {
|
||||||
|
@ -18,7 +18,10 @@ pub const mail = @import("mail.zig");
|
|||||||
pub const kv = @import("kv.zig");
|
pub const kv = @import("kv.zig");
|
||||||
pub const db = @import("database.zig");
|
pub const db = @import("database.zig");
|
||||||
pub const Environment = @import("Environment.zig");
|
pub const Environment = @import("Environment.zig");
|
||||||
pub const environment = std.enums.nameCast(Environment.EnvironmentName, build_options.environment);
|
pub const environment = @field(
|
||||||
|
Environment.EnvironmentName,
|
||||||
|
@tagName(build_options.environment),
|
||||||
|
);
|
||||||
pub const build_options = @import("build_options");
|
pub const build_options = @import("build_options");
|
||||||
|
|
||||||
const root = @import("root");
|
const root = @import("root");
|
||||||
|
@ -2,9 +2,9 @@ const std = @import("std");
|
|||||||
|
|
||||||
const jetzig = @import("../jetzig.zig");
|
const jetzig = @import("../jetzig.zig");
|
||||||
|
|
||||||
pub const adapter = std.enums.nameCast(
|
pub const adapter = @field(
|
||||||
jetzig.jetquery.adapters.Name,
|
jetzig.jetquery.adapters.Name,
|
||||||
@field(jetzig.jetquery.config.database, @tagName(jetzig.environment)).adapter,
|
@tagName(@field(jetzig.jetquery.config.database, @tagName(jetzig.environment)).adapter),
|
||||||
);
|
);
|
||||||
|
|
||||||
pub const Schema = jetzig.config.get(type, "Schema");
|
pub const Schema = jetzig.config.get(type, "Schema");
|
||||||
@ -25,7 +25,7 @@ pub fn repo(allocator: std.mem.Allocator, app: anytype) !Repo {
|
|||||||
|
|
||||||
return try Repo.loadConfig(
|
return try Repo.loadConfig(
|
||||||
allocator,
|
allocator,
|
||||||
std.enums.nameCast(jetzig.jetquery.Environment, jetzig.environment),
|
@field(jetzig.jetquery.Environment, @tagName(jetzig.environment)),
|
||||||
.{
|
.{
|
||||||
.eventCallback = Callback.callbackFn,
|
.eventCallback = Callback.callbackFn,
|
||||||
.lazy_connect = switch (jetzig.environment) {
|
.lazy_connect = switch (jetzig.environment) {
|
||||||
|
@ -41,9 +41,9 @@ fn jetKVOptions(options: KVOptions) jetzig.jetkv.Options {
|
|||||||
.port = options.valkey_options.port,
|
.port = options.valkey_options.port,
|
||||||
.connect_timeout = options.valkey_options.connect_timeout * std.time.ms_per_s,
|
.connect_timeout = options.valkey_options.connect_timeout * std.time.ms_per_s,
|
||||||
.read_timeout = options.valkey_options.read_timeout * std.time.ms_per_s,
|
.read_timeout = options.valkey_options.read_timeout * std.time.ms_per_s,
|
||||||
.connect = std.enums.nameCast(
|
.connect = @field(
|
||||||
jetzig.jetkv.ValkeyBackendOptions.ConnectMode,
|
jetzig.jetkv.ValkeyBackendOptions.ConnectMode,
|
||||||
options.valkey_options.connect,
|
@tagName(options.valkey_options.connect),
|
||||||
),
|
),
|
||||||
.buffer_size = options.valkey_options.buffer_size,
|
.buffer_size = options.valkey_options.buffer_size,
|
||||||
.pool_size = options.valkey_options.pool_size,
|
.pool_size = options.valkey_options.pool_size,
|
||||||
|
@ -50,7 +50,7 @@ fn detectEncoding(request: *const jetzig.http.Request) ?Encoding {
|
|||||||
while (it.next()) |param| {
|
while (it.next()) |param| {
|
||||||
inline for (@typeInfo(Encoding).@"enum".fields) |field| {
|
inline for (@typeInfo(Encoding).@"enum".fields) |field| {
|
||||||
if (std.mem.eql(u8, field.name, jetzig.util.strip(param))) {
|
if (std.mem.eql(u8, field.name, jetzig.util.strip(param))) {
|
||||||
return std.enums.nameCast(Encoding, field.name);
|
return @field(Encoding, field.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ fn stubbedRequest(
|
|||||||
.route_data = null,
|
.route_data = null,
|
||||||
.middlewares = undefined,
|
.middlewares = undefined,
|
||||||
.address = undefined,
|
.address = undefined,
|
||||||
.method = std.enums.nameCast(httpz.Method, @tagName(method)),
|
.method = @field(httpz.Method, @tagName(method)),
|
||||||
.protocol = .HTTP11,
|
.protocol = .HTTP11,
|
||||||
.params = undefined,
|
.params = undefined,
|
||||||
.conn = undefined,
|
.conn = undefined,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user