Uniformize calling name conventions

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
Francis Bouvier
2024-06-19 15:56:44 +02:00
parent 0f8b47b598
commit aca64eedca
9 changed files with 38 additions and 39 deletions

View File

@@ -6,7 +6,7 @@ const cdp = @import("cdp.zig");
const result = cdp.result;
const getMsg = cdp.getMsg;
const BrowserMethods = enum {
const Methods = enum {
getVersion,
setDownloadBehavior,
getWindowForTarget,
@@ -20,11 +20,11 @@ pub fn browser(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(BrowserMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.getVersion => browserGetVersion(alloc, id, scanner, ctx),
.setDownloadBehavior => browserSetDownloadBehavior(alloc, id, scanner, ctx),
.getVersion => getVersion(alloc, id, scanner, ctx),
.setDownloadBehavior => setDownloadBehavior(alloc, id, scanner, ctx),
.getWindowForTarget => getWindowForTarget(alloc, id, scanner, ctx),
.setWindowBounds => setWindowBounds(alloc, id, scanner, ctx),
};
@@ -36,7 +36,7 @@ const Revision = "@9e6ded5ac1ff5e38d930ae52bd9aec09bd1a68e4";
const UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
const JsVersion = "12.4.254.8";
fn browserGetVersion(
fn getVersion(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,
@@ -62,7 +62,7 @@ fn browserGetVersion(
return result(alloc, id orelse msg.id.?, Res, res, null);
}
fn browserSetDownloadBehavior(
fn setDownloadBehavior(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,

View File

@@ -7,7 +7,7 @@ const result = cdp.result;
const getMsg = cdp.getMsg;
const stringify = cdp.stringify;
const EmulationMethods = enum {
const Methods = enum {
setEmulatedMedia,
setFocusEmulationEnabled,
setDeviceMetricsOverride,
@@ -21,7 +21,7 @@ pub fn emulation(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(EmulationMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.setEmulatedMedia => setEmulatedMedia(alloc, id, scanner, ctx),

View File

@@ -6,7 +6,7 @@ const cdp = @import("cdp.zig");
const result = cdp.result;
const getMsg = cdp.getMsg;
const FetchMethods = enum {
const Methods = enum {
disable,
};
@@ -17,15 +17,15 @@ pub fn fetch(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(FetchMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.disable => fetchDisable(alloc, id, scanner, ctx),
.disable => disable(alloc, id, scanner, ctx),
};
}
fn fetchDisable(
fn disable(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,

View File

@@ -7,7 +7,7 @@ const result = cdp.result;
const getMsg = cdp.getMsg;
const stringify = cdp.stringify;
const LogMethods = enum {
const Methods = enum {
enable,
};
@@ -18,15 +18,15 @@ pub fn log(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(LogMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.enable => logEnable(alloc, id, scanner, ctx),
.enable => enable(alloc, id, scanner, ctx),
};
}
fn logEnable(
fn enable(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,

View File

@@ -5,9 +5,8 @@ const Ctx = server.Cmd;
const cdp = @import("cdp.zig");
const result = cdp.result;
const getMsg = cdp.getMsg;
const stringify = cdp.stringify;
const NetworkMethods = enum {
const Methods = enum {
enable,
setCacheDisabled,
};
@@ -19,16 +18,16 @@ pub fn network(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(NetworkMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.enable => networkEnable(alloc, id, scanner, ctx),
.setCacheDisabled => networkSetCacheDisabled(alloc, id, scanner, ctx),
.enable => enable(alloc, id, scanner, ctx),
.setCacheDisabled => setCacheDisabled(alloc, id, scanner, ctx),
};
}
fn networkEnable(
fn enable(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,
@@ -39,7 +38,7 @@ fn networkEnable(
return result(alloc, id orelse msg.id.?, null, null, msg.sessionID);
}
fn networkSetCacheDisabled(
fn setCacheDisabled(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,

View File

@@ -10,7 +10,7 @@ const sendEvent = cdp.sendEvent;
const Runtime = @import("runtime.zig");
const PageMethods = enum {
const Methods = enum {
enable,
getFrameTree,
setLifecycleEventsEnabled,
@@ -26,7 +26,7 @@ pub fn page(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(PageMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.enable => enable(alloc, id, scanner, ctx),

View File

@@ -6,7 +6,7 @@ const cdp = @import("cdp.zig");
const result = cdp.result;
const getMsg = cdp.getMsg;
const PerformanceMethods = enum {
const Methods = enum {
enable,
};
@@ -17,15 +17,15 @@ pub fn performance(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(PerformanceMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.enable => performanceEnable(alloc, id, scanner, ctx),
.enable => enable(alloc, id, scanner, ctx),
};
}
fn performanceEnable(
fn enable(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,

View File

@@ -9,7 +9,7 @@ const result = cdp.result;
const getMsg = cdp.getMsg;
const stringify = cdp.stringify;
const RuntimeMethods = enum {
const Methods = enum {
enable,
runIfWaitingForDebugger,
evaluate,
@@ -24,7 +24,7 @@ pub fn runtime(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(RuntimeMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.enable => enable(alloc, id, scanner, ctx),

View File

@@ -7,7 +7,7 @@ const result = cdp.result;
const getMsg = cdp.getMsg;
const stringify = cdp.stringify;
const TargetMethods = enum {
const Methods = enum {
setDiscoverTargets,
setAutoAttach,
getTargetInfo,
@@ -23,12 +23,12 @@ pub fn target(
scanner: *std.json.Scanner,
ctx: *Ctx,
) ![]const u8 {
const method = std.meta.stringToEnum(TargetMethods, action) orelse
const method = std.meta.stringToEnum(Methods, action) orelse
return error.UnknownMethod;
return switch (method) {
.setDiscoverTargets => targetSetDiscoverTargets(alloc, id, scanner, ctx),
.setAutoAttach => tagetSetAutoAttach(alloc, id, scanner, ctx),
.getTargetInfo => tagetGetTargetInfo(alloc, id, scanner, ctx),
.setDiscoverTargets => setDiscoverTargets(alloc, id, scanner, ctx),
.setAutoAttach => setAutoAttach(alloc, id, scanner, ctx),
.getTargetInfo => getTargetInfo(alloc, id, scanner, ctx),
.getBrowserContexts => getBrowserContexts(alloc, id, scanner, ctx),
.createBrowserContext => createBrowserContext(alloc, id, scanner, ctx),
.createTarget => createTarget(alloc, id, scanner, ctx),
@@ -39,7 +39,7 @@ const PageTargetID = "CFCD6EC01573CF29BB638E9DC0F52DDC";
const BrowserTargetID = "2d2bdef9-1c95-416f-8c0e-83f3ab73a30c";
const BrowserContextID = "65618675CB7D3585A95049E9DFE95EA9";
fn targetSetDiscoverTargets(
fn setDiscoverTargets(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,
@@ -69,7 +69,7 @@ const TargetFilter = struct {
exclude: ?bool = null,
};
fn tagetSetAutoAttach(
fn setAutoAttach(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,
@@ -100,7 +100,7 @@ fn tagetSetAutoAttach(
return result(alloc, id orelse msg.id.?, null, null, msg.sessionID);
}
fn tagetGetTargetInfo(
fn getTargetInfo(
alloc: std.mem.Allocator,
id: ?u16,
scanner: *std.json.Scanner,