mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
15
Makefile
15
Makefile
@@ -1,3 +1,8 @@
|
|||||||
|
# Variables
|
||||||
|
# ---------
|
||||||
|
|
||||||
|
ZIG := zig
|
||||||
|
|
||||||
# Infos
|
# Infos
|
||||||
# -----
|
# -----
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
@@ -15,19 +20,19 @@ help:
|
|||||||
-e 'p;}' Makefile | awk '{printf "\033[33m%-35s\033[0m%s\n", $$1, substr($$0,length($$1)+1)}'
|
-e 'p;}' Makefile | awk '{printf "\033[33m%-35s\033[0m%s\n", $$1, substr($$0,length($$1)+1)}'
|
||||||
|
|
||||||
|
|
||||||
# Zig commands
|
# $(ZIG) commands
|
||||||
# ------------
|
# ------------
|
||||||
.PHONY: build build-release run run-release shell test bench
|
.PHONY: build build-release run run-release shell test bench
|
||||||
|
|
||||||
## Build in debug mode
|
## Build in debug mode
|
||||||
build:
|
build:
|
||||||
@printf "\e[36mBuilding (debug)...\e[0m\n"
|
@printf "\e[36mBuilding (debug)...\e[0m\n"
|
||||||
@zig build -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
@$(ZIG) build -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||||
@printf "\e[33mBuild OK\e[0m\n"
|
@printf "\e[33mBuild OK\e[0m\n"
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
@printf "\e[36mBuilding (release safe)...\e[0m\n"
|
@printf "\e[36mBuilding (release safe)...\e[0m\n"
|
||||||
@zig build -Drelease-safe -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
@$(ZIG) build -Doptimize=ReleaseSafe -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||||
@printf "\e[33mBuild OK\e[0m\n"
|
@printf "\e[33mBuild OK\e[0m\n"
|
||||||
|
|
||||||
## Run the server
|
## Run the server
|
||||||
@@ -38,12 +43,12 @@ run: build
|
|||||||
## Run a JS shell in release-safe mode
|
## Run a JS shell in release-safe mode
|
||||||
shell:
|
shell:
|
||||||
@printf "\e[36mBuilding shell...\e[0m\n"
|
@printf "\e[36mBuilding shell...\e[0m\n"
|
||||||
@zig build shell -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
@$(ZIG) build shell -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||||
|
|
||||||
## Test
|
## Test
|
||||||
test:
|
test:
|
||||||
@printf "\e[36mTesting...\e[0m\n"
|
@printf "\e[36mTesting...\e[0m\n"
|
||||||
@zig build test -Dengine=v8 || (printf "\e[33mTest ERROR\e[0m\n"; exit 1;)
|
@$(ZIG) build test -Dengine=v8 || (printf "\e[33mTest ERROR\e[0m\n"; exit 1;)
|
||||||
@printf "\e[33mTest OK\e[0m\n"
|
@printf "\e[33mTest OK\e[0m\n"
|
||||||
|
|
||||||
# Install and build required dependencies commands
|
# Install and build required dependencies commands
|
||||||
|
|||||||
46
build.zig
46
build.zig
@@ -6,7 +6,7 @@ const jsruntime_pkgs = jsruntime.packages(jsruntime_path);
|
|||||||
|
|
||||||
pub fn build(b: *std.build.Builder) !void {
|
pub fn build(b: *std.build.Builder) !void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const mode = b.standardReleaseOptions();
|
const mode = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const options = try jsruntime.buildOptions(b);
|
const options = try jsruntime.buildOptions(b);
|
||||||
|
|
||||||
@@ -14,12 +14,17 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
// -------
|
// -------
|
||||||
|
|
||||||
// compile and install
|
// compile and install
|
||||||
const exe = b.addExecutable("browsercore", "src/main.zig");
|
const exe = b.addExecutable(.{
|
||||||
try common(exe, mode, target, options);
|
.name = "browsercore",
|
||||||
exe.install();
|
.root_source_file = .{ .path = "src/main.zig" },
|
||||||
|
.target = target,
|
||||||
|
.optimize = mode,
|
||||||
|
});
|
||||||
|
try common(exe, options);
|
||||||
|
b.installArtifact(exe);
|
||||||
|
|
||||||
// run
|
// run
|
||||||
const run_cmd = exe.run();
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
run_cmd.step.dependOn(b.getInstallStep());
|
run_cmd.step.dependOn(b.getInstallStep());
|
||||||
if (b.args) |args| {
|
if (b.args) |args| {
|
||||||
run_cmd.addArgs(args);
|
run_cmd.addArgs(args);
|
||||||
@@ -33,14 +38,19 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
// -----
|
// -----
|
||||||
|
|
||||||
// compile and install
|
// compile and install
|
||||||
const shell = b.addExecutable("browsercore-shell", "src/main_shell.zig");
|
const shell = b.addExecutable(.{
|
||||||
try common(shell, mode, target, options);
|
.name = "browsercore-shell",
|
||||||
try jsruntime_pkgs.add_shell(shell, mode);
|
.root_source_file = .{ .path = "src/main_shell.zig" },
|
||||||
|
.target = target,
|
||||||
|
.optimize = mode,
|
||||||
|
});
|
||||||
|
try common(shell, options);
|
||||||
|
try jsruntime_pkgs.add_shell(shell);
|
||||||
// do not install shell binary
|
// do not install shell binary
|
||||||
shell.install();
|
b.installArtifact(shell);
|
||||||
|
|
||||||
// run
|
// run
|
||||||
const shell_cmd = shell.run();
|
const shell_cmd = b.addRunArtifact(shell);
|
||||||
shell_cmd.step.dependOn(b.getInstallStep());
|
shell_cmd.step.dependOn(b.getInstallStep());
|
||||||
if (b.args) |args| {
|
if (b.args) |args| {
|
||||||
shell_cmd.addArgs(args);
|
shell_cmd.addArgs(args);
|
||||||
@@ -54,8 +64,8 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
// ----
|
// ----
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
const exe_tests = b.addTest("src/run_tests.zig");
|
const exe_tests = b.addTest(.{ .root_source_file = .{ .path = "src/run_tests.zig" } });
|
||||||
try common(exe_tests, mode, target, options);
|
try common(exe_tests, options);
|
||||||
|
|
||||||
// step
|
// step
|
||||||
const test_step = b.step("test", "Run unit tests");
|
const test_step = b.step("test", "Run unit tests");
|
||||||
@@ -63,20 +73,16 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn common(
|
fn common(
|
||||||
step: *std.build.LibExeObjStep,
|
step: *std.Build.CompileStep,
|
||||||
mode: std.builtin.Mode,
|
|
||||||
target: std.zig.CrossTarget,
|
|
||||||
options: jsruntime.Options,
|
options: jsruntime.Options,
|
||||||
) !void {
|
) !void {
|
||||||
step.setTarget(target);
|
try jsruntime_pkgs.add(step, options);
|
||||||
step.setBuildMode(mode);
|
|
||||||
try jsruntime_pkgs.add(step, mode, options);
|
|
||||||
linkLexbor(step);
|
linkLexbor(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn linkLexbor(step: *std.build.LibExeObjStep) void {
|
fn linkLexbor(step: *std.build.LibExeObjStep) void {
|
||||||
// cmake . -DLEXBOR_BUILD_SHARED=OFF
|
// cmake . -DLEXBOR_BUILD_SHARED=OFF
|
||||||
const lib_path = "vendor/lexbor/liblexbor_static.a";
|
const lib_path = "vendor/lexbor/liblexbor_static.a";
|
||||||
step.addObjectFile(lib_path);
|
step.addObjectFile(.{ .path = lib_path });
|
||||||
step.addIncludePath("vendor/lexbor-src/source");
|
step.addIncludePath(.{ .path = "vendor/lexbor-src/source" });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ pub const Union = struct {
|
|||||||
const member_union = member_info.Union;
|
const member_union = member_info.Union;
|
||||||
for (member_union.fields) |field| {
|
for (member_union.fields) |field| {
|
||||||
enum_fields[done] = .{
|
enum_fields[done] = .{
|
||||||
.name = fmtName(field.field_type),
|
.name = fmtName(field.type),
|
||||||
.value = done,
|
.value = done,
|
||||||
};
|
};
|
||||||
done += 1;
|
done += 1;
|
||||||
@@ -92,7 +92,6 @@ pub const Union = struct {
|
|||||||
}
|
}
|
||||||
const decls: [0]std.builtin.Type.Declaration = undefined;
|
const decls: [0]std.builtin.Type.Declaration = undefined;
|
||||||
const enum_info = std.builtin.Type.Enum{
|
const enum_info = std.builtin.Type.Enum{
|
||||||
.layout = .Auto,
|
|
||||||
.tag_type = tag_type,
|
.tag_type = tag_type,
|
||||||
.fields = &enum_fields,
|
.fields = &enum_fields,
|
||||||
.decls = &decls,
|
.decls = &decls,
|
||||||
@@ -103,22 +102,22 @@ pub const Union = struct {
|
|||||||
// third iteration to generate union type
|
// third iteration to generate union type
|
||||||
var union_fields: [members_nb]std.builtin.Type.UnionField = undefined;
|
var union_fields: [members_nb]std.builtin.Type.UnionField = undefined;
|
||||||
done = 0;
|
done = 0;
|
||||||
for (tuple_members) |member, i| {
|
for (tuple_members, 0..) |member, i| {
|
||||||
const member_T = @field(tuple, member.name);
|
const member_T = @field(tuple, member.name);
|
||||||
const member_info = @typeInfo(member_T);
|
const member_info = @typeInfo(member_T);
|
||||||
if (member_info == .Union) {
|
if (member_info == .Union) {
|
||||||
const member_union = member_info.Union;
|
const member_union = member_info.Union;
|
||||||
for (member_union.fields) |field| {
|
for (member_union.fields) |field| {
|
||||||
var T: type = undefined;
|
var T: type = undefined;
|
||||||
if (@hasDecl(field.field_type, "Self")) {
|
if (@hasDecl(field.type, "Self")) {
|
||||||
T = @field(field.field_type, "Self");
|
T = @field(field.type, "Self");
|
||||||
T = *T;
|
T = *T;
|
||||||
} else {
|
} else {
|
||||||
T = field.field_type;
|
T = field.type;
|
||||||
}
|
}
|
||||||
union_fields[done] = .{
|
union_fields[done] = .{
|
||||||
.name = fmtName(field.field_type),
|
.name = fmtName(field.type),
|
||||||
.field_type = T,
|
.type = T,
|
||||||
.alignment = @alignOf(T),
|
.alignment = @alignOf(T),
|
||||||
};
|
};
|
||||||
done += 1;
|
done += 1;
|
||||||
@@ -132,7 +131,7 @@ pub const Union = struct {
|
|||||||
}
|
}
|
||||||
union_fields[done] = .{
|
union_fields[done] = .{
|
||||||
.name = fmtName(member_T),
|
.name = fmtName(member_T),
|
||||||
.field_type = T,
|
.type = T,
|
||||||
.alignment = @alignOf(T),
|
.alignment = @alignOf(T),
|
||||||
};
|
};
|
||||||
done += 1;
|
done += 1;
|
||||||
@@ -205,7 +204,7 @@ pub fn TupleT(comptime tuple: anytype) type {
|
|||||||
while (done < members_nb) {
|
while (done < members_nb) {
|
||||||
fields[done] = .{
|
fields[done] = .{
|
||||||
.name = try itoa(done),
|
.name = try itoa(done),
|
||||||
.field_type = type,
|
.type = type,
|
||||||
.default_value = null,
|
.default_value = null,
|
||||||
.is_comptime = false,
|
.is_comptime = false,
|
||||||
.alignment = @alignOf(type),
|
.alignment = @alignOf(type),
|
||||||
@@ -299,7 +298,7 @@ pub fn tests() !void {
|
|||||||
try std.testing.expect(from_structs_union == .Union);
|
try std.testing.expect(from_structs_union == .Union);
|
||||||
try std.testing.expect(from_structs_union.Union.tag_type == FromStructs._enum);
|
try std.testing.expect(from_structs_union.Union.tag_type == FromStructs._enum);
|
||||||
try std.testing.expect(from_structs_union.Union.fields.len == 3);
|
try std.testing.expect(from_structs_union.Union.fields.len == 3);
|
||||||
try std.testing.expect(from_structs_union.Union.fields[0].field_type == Astruct);
|
try std.testing.expect(from_structs_union.Union.fields[0].type == Astruct);
|
||||||
try std.testing.expectEqualStrings(from_structs_union.Union.fields[0].name, "Astruct");
|
try std.testing.expectEqualStrings(from_structs_union.Union.fields[0].name, "Astruct");
|
||||||
|
|
||||||
// Union from union and structs
|
// Union from union and structs
|
||||||
@@ -316,7 +315,7 @@ pub fn tests() !void {
|
|||||||
try std.testing.expect(from_mix_union == .Union);
|
try std.testing.expect(from_mix_union == .Union);
|
||||||
try std.testing.expect(from_mix_union.Union.tag_type == FromMix._enum);
|
try std.testing.expect(from_mix_union.Union.tag_type == FromMix._enum);
|
||||||
try std.testing.expect(from_mix_union.Union.fields.len == 4);
|
try std.testing.expect(from_mix_union.Union.fields.len == 4);
|
||||||
try std.testing.expect(from_mix_union.Union.fields[3].field_type == Dstruct);
|
try std.testing.expect(from_mix_union.Union.fields[3].type == Dstruct);
|
||||||
try std.testing.expectEqualStrings(from_mix_union.Union.fields[3].name, "Dstruct");
|
try std.testing.expectEqualStrings(from_mix_union.Union.fields[3].name, "Dstruct");
|
||||||
|
|
||||||
std.debug.print("Generate Union: OK\n", .{});
|
std.debug.print("Generate Union: OK\n", .{});
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ pub const HTMLDocument = struct {
|
|||||||
|
|
||||||
pub fn _getElementById(self: *parser.DocumentHTML, id: []u8) ?*parser.HTMLElement {
|
pub fn _getElementById(self: *parser.DocumentHTML, id: []u8) ?*parser.HTMLElement {
|
||||||
const body_html = parser.documentHTMLBody(self);
|
const body_html = parser.documentHTMLBody(self);
|
||||||
const body_dom = @ptrCast(*parser.Element, body_html);
|
const body_dom = @as(*parser.Element, @ptrCast(body_html));
|
||||||
const doc_dom = @ptrCast(*parser.Document, self);
|
const doc_dom = @as(*parser.Document, @ptrCast(self));
|
||||||
const elem_dom = Document.getElementById(doc_dom, body_dom, id);
|
const elem_dom = Document.getElementById(doc_dom, body_dom, id);
|
||||||
return @ptrCast(*parser.HTMLElement, elem_dom);
|
return @as(*parser.HTMLElement, @ptrCast(elem_dom));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _createElement(self: *parser.DocumentHTML, tag_name: []const u8) E.HTMLElements {
|
pub fn _createElement(self: *parser.DocumentHTML, tag_name: []const u8) E.HTMLElements {
|
||||||
@@ -63,7 +63,7 @@ pub fn testExecFn(
|
|||||||
const tags = comptime parser.Tag.all();
|
const tags = comptime parser.Tag.all();
|
||||||
const elements = comptime parser.Tag.allElements();
|
const elements = comptime parser.Tag.allElements();
|
||||||
var createElements: [(tags.len - 1) * 3]Case = undefined;
|
var createElements: [(tags.len - 1) * 3]Case = undefined;
|
||||||
inline for (tags) |tag, i| {
|
inline for (tags, 0..) |tag, i| {
|
||||||
if (tag == .undef) {
|
if (tag == .undef) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,65 +457,65 @@ pub const HTMLVideoElement = struct {
|
|||||||
pub fn ElementToHTMLElementInterface(elem: *parser.Element) HTMLElements {
|
pub fn ElementToHTMLElementInterface(elem: *parser.Element) HTMLElements {
|
||||||
const tag = parser.nodeTag(parser.elementNode(elem));
|
const tag = parser.nodeTag(parser.elementNode(elem));
|
||||||
return switch (tag) {
|
return switch (tag) {
|
||||||
.a => .{ .HTMLAnchorElement = @ptrCast(*parser.Anchor, elem) },
|
.a => .{ .HTMLAnchorElement = @as(*parser.Anchor, @ptrCast(elem)) },
|
||||||
.area => .{ .HTMLAreaElement = @ptrCast(*parser.Area, elem) },
|
.area => .{ .HTMLAreaElement = @as(*parser.Area, @ptrCast(elem)) },
|
||||||
.audio => .{ .HTMLAudioElement = @ptrCast(*parser.Audio, elem) },
|
.audio => .{ .HTMLAudioElement = @as(*parser.Audio, @ptrCast(elem)) },
|
||||||
.br => .{ .HTMLBRElement = @ptrCast(*parser.BR, elem) },
|
.br => .{ .HTMLBRElement = @as(*parser.BR, @ptrCast(elem)) },
|
||||||
.base => .{ .HTMLBaseElement = @ptrCast(*parser.Base, elem) },
|
.base => .{ .HTMLBaseElement = @as(*parser.Base, @ptrCast(elem)) },
|
||||||
.body => .{ .HTMLBodyElement = @ptrCast(*parser.Body, elem) },
|
.body => .{ .HTMLBodyElement = @as(*parser.Body, @ptrCast(elem)) },
|
||||||
.button => .{ .HTMLButtonElement = @ptrCast(*parser.Button, elem) },
|
.button => .{ .HTMLButtonElement = @as(*parser.Button, @ptrCast(elem)) },
|
||||||
.canvas => .{ .HTMLCanvasElement = @ptrCast(*parser.Canvas, elem) },
|
.canvas => .{ .HTMLCanvasElement = @as(*parser.Canvas, @ptrCast(elem)) },
|
||||||
.dl => .{ .HTMLDListElement = @ptrCast(*parser.DList, elem) },
|
.dl => .{ .HTMLDListElement = @as(*parser.DList, @ptrCast(elem)) },
|
||||||
.data => .{ .HTMLDataElement = @ptrCast(*parser.Data, elem) },
|
.data => .{ .HTMLDataElement = @as(*parser.Data, @ptrCast(elem)) },
|
||||||
.dialog => .{ .HTMLDialogElement = @ptrCast(*parser.Dialog, elem) },
|
.dialog => .{ .HTMLDialogElement = @as(*parser.Dialog, @ptrCast(elem)) },
|
||||||
.div => .{ .HTMLDivElement = @ptrCast(*parser.Div, elem) },
|
.div => .{ .HTMLDivElement = @as(*parser.Div, @ptrCast(elem)) },
|
||||||
.embed => .{ .HTMLEmbedElement = @ptrCast(*parser.Embed, elem) },
|
.embed => .{ .HTMLEmbedElement = @as(*parser.Embed, @ptrCast(elem)) },
|
||||||
.fieldset => .{ .HTMLFieldSetElement = @ptrCast(*parser.FieldSet, elem) },
|
.fieldset => .{ .HTMLFieldSetElement = @as(*parser.FieldSet, @ptrCast(elem)) },
|
||||||
.form => .{ .HTMLFormElement = @ptrCast(*parser.Form, elem) },
|
.form => .{ .HTMLFormElement = @as(*parser.Form, @ptrCast(elem)) },
|
||||||
.frameset => .{ .HTMLFrameSetElement = @ptrCast(*parser.FrameSet, elem) },
|
.frameset => .{ .HTMLFrameSetElement = @as(*parser.FrameSet, @ptrCast(elem)) },
|
||||||
.hr => .{ .HTMLHRElement = @ptrCast(*parser.HR, elem) },
|
.hr => .{ .HTMLHRElement = @as(*parser.HR, @ptrCast(elem)) },
|
||||||
.head => .{ .HTMLHeadElement = @ptrCast(*parser.Head, elem) },
|
.head => .{ .HTMLHeadElement = @as(*parser.Head, @ptrCast(elem)) },
|
||||||
.h1, .h2, .h3, .h4, .h5, .h6 => .{ .HTMLHeadingElement = @ptrCast(*parser.Heading, elem) },
|
.h1, .h2, .h3, .h4, .h5, .h6 => .{ .HTMLHeadingElement = @as(*parser.Heading, @ptrCast(elem)) },
|
||||||
.html => .{ .HTMLHtmlElement = @ptrCast(*parser.Html, elem) },
|
.html => .{ .HTMLHtmlElement = @as(*parser.Html, @ptrCast(elem)) },
|
||||||
.iframe => .{ .HTMLIFrameElement = @ptrCast(*parser.IFrame, elem) },
|
.iframe => .{ .HTMLIFrameElement = @as(*parser.IFrame, @ptrCast(elem)) },
|
||||||
.img => .{ .HTMLImageElement = @ptrCast(*parser.Image, elem) },
|
.img => .{ .HTMLImageElement = @as(*parser.Image, @ptrCast(elem)) },
|
||||||
.input => .{ .HTMLInputElement = @ptrCast(*parser.Input, elem) },
|
.input => .{ .HTMLInputElement = @as(*parser.Input, @ptrCast(elem)) },
|
||||||
.li => .{ .HTMLLIElement = @ptrCast(*parser.LI, elem) },
|
.li => .{ .HTMLLIElement = @as(*parser.LI, @ptrCast(elem)) },
|
||||||
.label => .{ .HTMLLabelElement = @ptrCast(*parser.Label, elem) },
|
.label => .{ .HTMLLabelElement = @as(*parser.Label, @ptrCast(elem)) },
|
||||||
.legend => .{ .HTMLLegendElement = @ptrCast(*parser.Legend, elem) },
|
.legend => .{ .HTMLLegendElement = @as(*parser.Legend, @ptrCast(elem)) },
|
||||||
.link => .{ .HTMLLinkElement = @ptrCast(*parser.Link, elem) },
|
.link => .{ .HTMLLinkElement = @as(*parser.Link, @ptrCast(elem)) },
|
||||||
.map => .{ .HTMLMapElement = @ptrCast(*parser.Map, elem) },
|
.map => .{ .HTMLMapElement = @as(*parser.Map, @ptrCast(elem)) },
|
||||||
.meta => .{ .HTMLMetaElement = @ptrCast(*parser.Meta, elem) },
|
.meta => .{ .HTMLMetaElement = @as(*parser.Meta, @ptrCast(elem)) },
|
||||||
.meter => .{ .HTMLMeterElement = @ptrCast(*parser.Meter, elem) },
|
.meter => .{ .HTMLMeterElement = @as(*parser.Meter, @ptrCast(elem)) },
|
||||||
.ins, .del => .{ .HTMLModElement = @ptrCast(*parser.Mod, elem) },
|
.ins, .del => .{ .HTMLModElement = @as(*parser.Mod, @ptrCast(elem)) },
|
||||||
.ol => .{ .HTMLOListElement = @ptrCast(*parser.OList, elem) },
|
.ol => .{ .HTMLOListElement = @as(*parser.OList, @ptrCast(elem)) },
|
||||||
.object => .{ .HTMLObjectElement = @ptrCast(*parser.Object, elem) },
|
.object => .{ .HTMLObjectElement = @as(*parser.Object, @ptrCast(elem)) },
|
||||||
.optgroup => .{ .HTMLOptGroupElement = @ptrCast(*parser.OptGroup, elem) },
|
.optgroup => .{ .HTMLOptGroupElement = @as(*parser.OptGroup, @ptrCast(elem)) },
|
||||||
.option => .{ .HTMLOptionElement = @ptrCast(*parser.Option, elem) },
|
.option => .{ .HTMLOptionElement = @as(*parser.Option, @ptrCast(elem)) },
|
||||||
.output => .{ .HTMLOutputElement = @ptrCast(*parser.Output, elem) },
|
.output => .{ .HTMLOutputElement = @as(*parser.Output, @ptrCast(elem)) },
|
||||||
.p => .{ .HTMLParagraphElement = @ptrCast(*parser.Paragraph, elem) },
|
.p => .{ .HTMLParagraphElement = @as(*parser.Paragraph, @ptrCast(elem)) },
|
||||||
.picture => .{ .HTMLPictureElement = @ptrCast(*parser.Picture, elem) },
|
.picture => .{ .HTMLPictureElement = @as(*parser.Picture, @ptrCast(elem)) },
|
||||||
.pre => .{ .HTMLPreElement = @ptrCast(*parser.Pre, elem) },
|
.pre => .{ .HTMLPreElement = @as(*parser.Pre, @ptrCast(elem)) },
|
||||||
.progress => .{ .HTMLProgressElement = @ptrCast(*parser.Progress, elem) },
|
.progress => .{ .HTMLProgressElement = @as(*parser.Progress, @ptrCast(elem)) },
|
||||||
.blockquote, .q => .{ .HTMLQuoteElement = @ptrCast(*parser.Quote, elem) },
|
.blockquote, .q => .{ .HTMLQuoteElement = @as(*parser.Quote, @ptrCast(elem)) },
|
||||||
.script => .{ .HTMLScriptElement = @ptrCast(*parser.Script, elem) },
|
.script => .{ .HTMLScriptElement = @as(*parser.Script, @ptrCast(elem)) },
|
||||||
.select => .{ .HTMLSelectElement = @ptrCast(*parser.Select, elem) },
|
.select => .{ .HTMLSelectElement = @as(*parser.Select, @ptrCast(elem)) },
|
||||||
.source => .{ .HTMLSourceElement = @ptrCast(*parser.Source, elem) },
|
.source => .{ .HTMLSourceElement = @as(*parser.Source, @ptrCast(elem)) },
|
||||||
.span => .{ .HTMLSpanElement = @ptrCast(*parser.Span, elem) },
|
.span => .{ .HTMLSpanElement = @as(*parser.Span, @ptrCast(elem)) },
|
||||||
.style => .{ .HTMLStyleElement = @ptrCast(*parser.Style, elem) },
|
.style => .{ .HTMLStyleElement = @as(*parser.Style, @ptrCast(elem)) },
|
||||||
.table => .{ .HTMLTableElement = @ptrCast(*parser.Table, elem) },
|
.table => .{ .HTMLTableElement = @as(*parser.Table, @ptrCast(elem)) },
|
||||||
.caption => .{ .HTMLTableCaptionElement = @ptrCast(*parser.TableCaption, elem) },
|
.caption => .{ .HTMLTableCaptionElement = @as(*parser.TableCaption, @ptrCast(elem)) },
|
||||||
.th, .td => .{ .HTMLTableCellElement = @ptrCast(*parser.TableCell, elem) },
|
.th, .td => .{ .HTMLTableCellElement = @as(*parser.TableCell, @ptrCast(elem)) },
|
||||||
.col => .{ .HTMLTableColElement = @ptrCast(*parser.TableCol, elem) },
|
.col => .{ .HTMLTableColElement = @as(*parser.TableCol, @ptrCast(elem)) },
|
||||||
.tr => .{ .HTMLTableRowElement = @ptrCast(*parser.TableRow, elem) },
|
.tr => .{ .HTMLTableRowElement = @as(*parser.TableRow, @ptrCast(elem)) },
|
||||||
.thead, .tbody, .tfoot => .{ .HTMLTableSectionElement = @ptrCast(*parser.TableSection, elem) },
|
.thead, .tbody, .tfoot => .{ .HTMLTableSectionElement = @as(*parser.TableSection, @ptrCast(elem)) },
|
||||||
.template => .{ .HTMLTemplateElement = @ptrCast(*parser.Template, elem) },
|
.template => .{ .HTMLTemplateElement = @as(*parser.Template, @ptrCast(elem)) },
|
||||||
.textarea => .{ .HTMLTextAreaElement = @ptrCast(*parser.TextArea, elem) },
|
.textarea => .{ .HTMLTextAreaElement = @as(*parser.TextArea, @ptrCast(elem)) },
|
||||||
.time => .{ .HTMLTimeElement = @ptrCast(*parser.Time, elem) },
|
.time => .{ .HTMLTimeElement = @as(*parser.Time, @ptrCast(elem)) },
|
||||||
.title => .{ .HTMLTitleElement = @ptrCast(*parser.Title, elem) },
|
.title => .{ .HTMLTitleElement = @as(*parser.Title, @ptrCast(elem)) },
|
||||||
.track => .{ .HTMLTrackElement = @ptrCast(*parser.Track, elem) },
|
.track => .{ .HTMLTrackElement = @as(*parser.Track, @ptrCast(elem)) },
|
||||||
.ul => .{ .HTMLUListElement = @ptrCast(*parser.UList, elem) },
|
.ul => .{ .HTMLUListElement = @as(*parser.UList, @ptrCast(elem)) },
|
||||||
.video => .{ .HTMLVideoElement = @ptrCast(*parser.Video, elem) },
|
.video => .{ .HTMLVideoElement = @as(*parser.Video, @ptrCast(elem)) },
|
||||||
.undef => .{ .HTMLUnknownElement = @ptrCast(*parser.Unknown, elem) },
|
.undef => .{ .HTMLUnknownElement = @as(*parser.Unknown, @ptrCast(elem)) },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ pub const Tag = enum(u8) {
|
|||||||
comptime {
|
comptime {
|
||||||
const info = @typeInfo(Tag).Enum;
|
const info = @typeInfo(Tag).Enum;
|
||||||
comptime var l: [info.fields.len]Tag = undefined;
|
comptime var l: [info.fields.len]Tag = undefined;
|
||||||
inline for (info.fields) |field, i| {
|
inline for (info.fields, 0..) |field, i| {
|
||||||
l[i] = @intToEnum(Tag, field.value);
|
l[i] = @as(Tag, @enumFromInt(field.value));
|
||||||
}
|
}
|
||||||
return &l;
|
return &l;
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ pub const Tag = enum(u8) {
|
|||||||
comptime {
|
comptime {
|
||||||
const tags = all();
|
const tags = all();
|
||||||
var names: [tags.len][]const u8 = undefined;
|
var names: [tags.len][]const u8 = undefined;
|
||||||
inline for (tags) |tag, i| {
|
inline for (tags, 0..) |tag, i| {
|
||||||
names[i] = tag.elementName();
|
names[i] = tag.elementName();
|
||||||
}
|
}
|
||||||
return &names;
|
return &names;
|
||||||
@@ -106,7 +106,7 @@ pub const Tag = enum(u8) {
|
|||||||
fn upperName(comptime name: []const u8) []const u8 {
|
fn upperName(comptime name: []const u8) []const u8 {
|
||||||
comptime {
|
comptime {
|
||||||
var upper_name: [name.len]u8 = undefined;
|
var upper_name: [name.len]u8 = undefined;
|
||||||
for (name) |char, i| {
|
for (name, 0..) |char, i| {
|
||||||
var to_upper = false;
|
var to_upper = false;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
to_upper = true;
|
to_upper = true;
|
||||||
@@ -188,7 +188,7 @@ pub inline fn nodeTag(node: *Node) Tag {
|
|||||||
if (val > 256) {
|
if (val > 256) {
|
||||||
val = 0;
|
val = 0;
|
||||||
}
|
}
|
||||||
return @intToEnum(Tag, val);
|
return @as(Tag, @enumFromInt(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const nodeWalker = (fn (node: ?*Node, _: ?*anyopaque) callconv(.C) Action);
|
pub const nodeWalker = (fn (node: ?*Node, _: ?*anyopaque) callconv(.C) Action);
|
||||||
@@ -199,7 +199,7 @@ pub inline fn nodeName(node: *Node) [*c]const u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn nodeType(node: *Node) NodeType {
|
pub inline fn nodeType(node: *Node) NodeType {
|
||||||
return @intToEnum(NodeType, node.*.type);
|
return @as(NodeType, @enumFromInt(node.*.type));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn nodeWalk(node: *Node, comptime walker: nodeWalker) !void {
|
pub inline fn nodeWalk(node: *Node, comptime walker: nodeWalker) !void {
|
||||||
|
|||||||
2
vendor/jsruntime-lib
vendored
2
vendor/jsruntime-lib
vendored
Submodule vendor/jsruntime-lib updated: fba2064c18...978b166c65
Reference in New Issue
Block a user