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