Applies changes from jsruntime Self and mem_guaranteed

Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
Francis Bouvier
2023-06-02 16:54:57 +02:00
parent 8f2d59172b
commit e0eee45156
9 changed files with 318 additions and 538 deletions

View File

@@ -6,30 +6,20 @@ const Node = @import("node.zig").Node;
const Element = @import("element.zig").Element; const Element = @import("element.zig").Element;
pub const Document = struct { pub const Document = struct {
proto: Node, pub const Self = parser.Document;
base: ?*parser.Document,
pub const prototype = *Node; pub const prototype = *Node;
pub const mem_guarantied = true;
pub fn init(base: ?*parser.Document) Document { // pub fn constructor() *parser.Document {
return .{ // // TODO
.proto = Node.init(null), // return .{};
.base = base, // }
};
}
pub fn constructor() Document { pub fn getElementById(self: *parser.Document, elem: *parser.Element, id: []const u8) ?*parser.Element {
return Document.init(null); const collection = parser.collectionInit(self, 1);
}
pub fn getElementById(self: Document, elem_dom: *parser.Element, id: []const u8) ?Element {
if (self.base == null) {
return null;
}
const collection = parser.collectionInit(self.base.?, 1);
defer parser.collectionDeinit(collection); defer parser.collectionDeinit(collection);
const case_sensitve = true; const case_sensitve = true;
parser.elementsByAttr(elem_dom, collection, "id", id, case_sensitve) catch |err| { parser.elementsByAttr(elem, collection, "id", id, case_sensitve) catch |err| {
std.debug.print("getElementById error: {s}\n", .{@errorName(err)}); std.debug.print("getElementById error: {s}\n", .{@errorName(err)});
return null; return null;
}; };
@@ -37,19 +27,18 @@ pub const Document = struct {
// no results // no results
return null; return null;
} }
const element_base = parser.collectionElement(collection, 0); return parser.collectionElement(collection, 0);
return Element.init(element_base);
} }
// JS funcs // JS funcs
// -------- // --------
pub fn get_body(_: Document) ?void { pub fn get_body(_: *parser.Document) ?*parser.Body {
// TODO // TODO
return null; return null;
} }
pub fn _getElementById(_: Document, _: []u8) ?Element { pub fn _getElementById(_: *parser.Document, _: []u8) ?*parser.Element {
// TODO // TODO
return null; return null;
} }

View File

@@ -5,22 +5,14 @@ const parser = @import("../parser.zig");
const Node = @import("node.zig").Node; const Node = @import("node.zig").Node;
pub const Element = struct { pub const Element = struct {
proto: Node, pub const Self = parser.Element;
base: *parser.Element,
pub const prototype = *Node; pub const prototype = *Node;
pub const mem_guarantied = true;
pub fn init(base: *parser.Element) Element {
return .{
.proto = Node.init(null),
.base = base,
};
}
// JS funcs // JS funcs
// -------- // --------
pub fn get_localName(self: Element) []const u8 { pub fn get_localName(self: *parser.Element) []const u8 {
return parser.elementLocalName(self.base); return parser.elementLocalName(self);
} }
}; };

View File

@@ -1,13 +1,6 @@
const parser = @import("../parser.zig"); const parser = @import("../parser.zig");
pub const EventTarget = struct { pub const EventTarget = struct {
base: ?*parser.EventTarget = null, pub const Self = parser.EventTarget;
pub const mem_guarantied = true;
pub fn init(base: ?*parser.EventTarget) EventTarget {
return .{ .base = base };
}
pub fn constructor() EventTarget {
return .{};
}
}; };

View File

@@ -18,19 +18,11 @@ pub fn create_tree(node: ?*parser.Node, _: ?*anyopaque) callconv(.C) parser.Acti
} }
pub const Node = struct { pub const Node = struct {
proto: EventTarget, pub const Self = parser.Node;
base: ?*parser.Node = null,
pub const prototype = *EventTarget; pub const prototype = *EventTarget;
pub const mem_guarantied = true;
pub fn init(base: ?*parser.Node) Node { pub fn make_tree(self: *parser.Node) !void {
return .{ .proto = EventTarget.init(null), .base = base }; try parser.nodeWalk(self, create_tree);
}
pub fn make_tree(self: Node) !void {
if (self.base) |node| {
try parser.nodeWalk(node, create_tree);
}
return error.NodeParserNull;
} }
}; };

View File

@@ -54,7 +54,7 @@ pub const Union = struct {
} else if (members_nb < 16) { } else if (members_nb < 16) {
tag_type = u4; tag_type = u4;
} else if (members_nb < 32) { } else if (members_nb < 32) {
tag_type = u4; tag_type = u5;
} else if (members_nb < 64) { } else if (members_nb < 64) {
tag_type = u6; tag_type = u6;
} else if (members_nb < 128) { } else if (members_nb < 128) {
@@ -109,19 +109,31 @@ pub const Union = struct {
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;
if (@hasDecl(field.field_type, "Self")) {
T = @field(field.field_type, "Self");
T = *T;
} else {
T = field.field_type;
}
union_fields[done] = .{ union_fields[done] = .{
.name = fmtName(field.field_type), .name = fmtName(field.field_type),
.field_type = field.field_type, .field_type = T,
.alignment = field.alignment, .alignment = @alignOf(T),
}; };
done += 1; done += 1;
} }
} else if (member_info == .Struct) { } else if (member_info == .Struct) {
const alignment = tuple_info.Struct.fields[i].alignment; const member_name = try itoa(i);
var T = @field(tuple, member_name);
if (@hasDecl(T, "Self")) {
T = @field(T, "Self");
T = *T;
}
union_fields[done] = .{ union_fields[done] = .{
.name = fmtName(member_T), .name = fmtName(member_T),
.field_type = member_T, .field_type = T,
.alignment = alignment, .alignment = @alignOf(T),
}; };
done += 1; done += 1;
} }

View File

@@ -11,45 +11,28 @@ const Document = @import("../dom/document.zig").Document;
const E = @import("elements.zig"); const E = @import("elements.zig");
pub const HTMLDocument = struct { pub const HTMLDocument = struct {
proto: Document, pub const Self = parser.DocumentHTML;
base: *parser.DocumentHTML,
pub const prototype = *Document; pub const prototype = *Document;
pub const mem_guarantied = true;
pub fn init() HTMLDocument {
return .{
.proto = Document.init(null),
.base = parser.documentHTMLInit(),
};
}
pub fn deinit(self: HTMLDocument) void {
parser.documentHTMLDeinit(self.base);
}
pub fn parse(self: *HTMLDocument, html: []const u8) !void {
try parser.documentHTMLParse(self.base, html);
self.proto.base = parser.documentHTMLToDocument(self.base);
}
// JS funcs // JS funcs
// -------- // --------
pub fn get_body(self: HTMLDocument) ?E.HTMLBodyElement { pub fn get_body(self: *parser.DocumentHTML) ?*parser.Body {
const body_dom = parser.documentHTMLBody(self.base); return parser.documentHTMLBody(self);
return E.HTMLBodyElement.init(body_dom);
} }
pub fn _getElementById(self: HTMLDocument, id: []u8) ?E.HTMLElement { pub fn _getElementById(self: *parser.DocumentHTML, id: []u8) ?*parser.HTMLElement {
const body_dom = parser.documentHTMLBody(self.base); const body_html = parser.documentHTMLBody(self);
if (self.proto.getElementById(body_dom, id)) |elem| { const body_dom = @ptrCast(*parser.Element, body_html);
return E.HTMLElement.init(elem.base); const doc_dom = @ptrCast(*parser.Document, self);
} const elem_dom = Document.getElementById(doc_dom, body_dom, id);
return null; return @ptrCast(*parser.HTMLElement, elem_dom);
} }
pub fn _createElement(self: HTMLDocument, tag_name: []const u8) E.HTMLElements { pub fn _createElement(self: *parser.DocumentHTML, tag_name: []const u8) E.HTMLElements {
const base = parser.documentCreateElement(self.proto.base.?, tag_name); const doc_dom = parser.documentHTMLToDocument(self);
const base = parser.documentCreateElement(doc_dom, tag_name);
return E.ElementToHTMLElementInterface(base); return E.ElementToHTMLElementInterface(base);
} }
}; };

View File

@@ -7,13 +7,9 @@ const Element = @import("../dom/element.zig").Element;
// -------------- // --------------
pub const HTMLElement = struct { pub const HTMLElement = struct {
proto: Element, pub const Self = parser.HTMLElement;
pub const prototype = *Element; pub const prototype = *Element;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLElement {
return .{ .proto = Element.init(elem_base) };
}
}; };
pub const HTMLElementsTypes = .{ pub const HTMLElementsTypes = .{
@@ -27,8 +23,8 @@ pub const HTMLElementsTypes = .{
HTMLButtonElement, HTMLButtonElement,
HTMLCanvasElement, HTMLCanvasElement,
HTMLDListElement, HTMLDListElement,
HTMLDialogElement,
HTMLDataElement, HTMLDataElement,
HTMLDialogElement,
HTMLDivElement, HTMLDivElement,
HTMLEmbedElement, HTMLEmbedElement,
HTMLFieldSetElement, HTMLFieldSetElement,
@@ -90,680 +86,436 @@ pub const HTMLElementsTags = HTMLElementsGenerated._enum;
// -------------------- // --------------------
pub const HTMLMediaElement = struct { pub const HTMLMediaElement = struct {
proto: HTMLElement, pub const Self = parser.MediaElement;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLMediaElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
// HTML elements // HTML elements
// ------------- // -------------
pub const HTMLUnknownElement = struct { pub const HTMLUnknownElement = struct {
proto: HTMLElement, pub const Self = parser.Unknown;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLUnknownElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLAnchorElement = struct { pub const HTMLAnchorElement = struct {
proto: HTMLElement, pub const Self = parser.Anchor;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLAnchorElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLAreaElement = struct { pub const HTMLAreaElement = struct {
proto: HTMLElement, pub const Self = parser.Area;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLAreaElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLAudioElement = struct { pub const HTMLAudioElement = struct {
proto: HTMLMediaElement, pub const Self = parser.Audio;
pub const prototype = *HTMLMediaElement; pub const prototype = *HTMLMediaElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLAudioElement {
return .{ .proto = HTMLMediaElement.init(elem_base) };
}
}; };
pub const HTMLBRElement = struct { pub const HTMLBRElement = struct {
proto: HTMLElement, pub const Self = parser.BR;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLBRElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLBaseElement = struct { pub const HTMLBaseElement = struct {
proto: HTMLElement, pub const Self = parser.Base;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLBaseElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLBodyElement = struct { pub const HTMLBodyElement = struct {
proto: HTMLElement, pub const Self = parser.Body;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLBodyElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLButtonElement = struct { pub const HTMLButtonElement = struct {
proto: HTMLElement, pub const Self = parser.Button;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLButtonElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLCanvasElement = struct { pub const HTMLCanvasElement = struct {
proto: HTMLElement, pub const Self = parser.Canvas;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLCanvasElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLDListElement = struct { pub const HTMLDListElement = struct {
proto: HTMLElement, pub const Self = parser.DList;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLDListElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
};
pub const HTMLDialogElement = struct {
proto: HTMLElement,
pub const prototype = *HTMLElement;
pub fn init(elem_base: *parser.Element) HTMLDialogElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLDataElement = struct { pub const HTMLDataElement = struct {
proto: HTMLElement, pub const Self = parser.Data;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
};
pub fn init(elem_base: *parser.Element) HTMLDataElement { pub const HTMLDialogElement = struct {
return .{ .proto = HTMLElement.init(elem_base) }; pub const Self = parser.Dialog;
} pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
}; };
pub const HTMLDivElement = struct { pub const HTMLDivElement = struct {
proto: HTMLElement, pub const Self = parser.Div;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLDivElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLEmbedElement = struct { pub const HTMLEmbedElement = struct {
proto: HTMLElement, pub const Self = parser.Embed;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLEmbedElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLFieldSetElement = struct { pub const HTMLFieldSetElement = struct {
proto: HTMLElement, pub const Self = parser.FieldSet;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLFieldSetElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLFormElement = struct { pub const HTMLFormElement = struct {
proto: HTMLElement, pub const Self = parser.Form;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLFormElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLFrameSetElement = struct { pub const HTMLFrameSetElement = struct {
proto: HTMLElement, pub const Self = parser.FrameSet;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLFrameSetElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLHRElement = struct { pub const HTMLHRElement = struct {
proto: HTMLElement, pub const Self = parser.HR;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLHRElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLHeadElement = struct { pub const HTMLHeadElement = struct {
proto: HTMLElement, pub const Self = parser.Head;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLHeadElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLHeadingElement = struct { pub const HTMLHeadingElement = struct {
proto: HTMLElement, pub const Self = parser.Heading;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLHeadingElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLHtmlElement = struct { pub const HTMLHtmlElement = struct {
proto: HTMLElement, pub const Self = parser.Html;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLHtmlElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLIFrameElement = struct { pub const HTMLIFrameElement = struct {
proto: HTMLElement, pub const Self = parser.IFrame;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLIFrameElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLImageElement = struct { pub const HTMLImageElement = struct {
proto: HTMLElement, pub const Self = parser.Image;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLImageElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLInputElement = struct { pub const HTMLInputElement = struct {
proto: HTMLElement, pub const Self = parser.Input;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLInputElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLLIElement = struct { pub const HTMLLIElement = struct {
proto: HTMLElement, pub const Self = parser.LI;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLLIElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLLabelElement = struct { pub const HTMLLabelElement = struct {
proto: HTMLElement, pub const Self = parser.Label;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLLabelElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLLegendElement = struct { pub const HTMLLegendElement = struct {
proto: HTMLElement, pub const Self = parser.Legend;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLLegendElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLLinkElement = struct { pub const HTMLLinkElement = struct {
proto: HTMLElement, pub const Self = parser.Link;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLLinkElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLMapElement = struct { pub const HTMLMapElement = struct {
proto: HTMLElement, pub const Self = parser.Map;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLMapElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLMetaElement = struct { pub const HTMLMetaElement = struct {
proto: HTMLElement, pub const Self = parser.Meta;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLMetaElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLMeterElement = struct { pub const HTMLMeterElement = struct {
proto: HTMLElement, pub const Self = parser.Meter;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLMeterElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLModElement = struct { pub const HTMLModElement = struct {
proto: HTMLElement, pub const Self = parser.Mod;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLModElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLOListElement = struct { pub const HTMLOListElement = struct {
proto: HTMLElement, pub const Self = parser.OList;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLOListElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLObjectElement = struct { pub const HTMLObjectElement = struct {
proto: HTMLElement, pub const Self = parser.Object;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLObjectElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLOptGroupElement = struct { pub const HTMLOptGroupElement = struct {
proto: HTMLElement, pub const Self = parser.OptGroup;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLOptGroupElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLOptionElement = struct { pub const HTMLOptionElement = struct {
proto: HTMLElement, pub const Self = parser.Option;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLOptionElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLOutputElement = struct { pub const HTMLOutputElement = struct {
proto: HTMLElement, pub const Self = parser.Output;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLOutputElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLParagraphElement = struct { pub const HTMLParagraphElement = struct {
proto: HTMLElement, pub const Self = parser.Paragraph;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLParagraphElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLPictureElement = struct { pub const HTMLPictureElement = struct {
proto: HTMLElement, pub const Self = parser.Picture;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLPictureElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLPreElement = struct { pub const HTMLPreElement = struct {
proto: HTMLElement, pub const Self = parser.Pre;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLPreElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLProgressElement = struct { pub const HTMLProgressElement = struct {
proto: HTMLElement, pub const Self = parser.Progress;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLProgressElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLQuoteElement = struct { pub const HTMLQuoteElement = struct {
proto: HTMLElement, pub const Self = parser.Quote;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLQuoteElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLScriptElement = struct { pub const HTMLScriptElement = struct {
proto: HTMLElement, pub const Self = parser.Script;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLScriptElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLSelectElement = struct { pub const HTMLSelectElement = struct {
proto: HTMLElement, pub const Self = parser.Select;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLSelectElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLSourceElement = struct { pub const HTMLSourceElement = struct {
proto: HTMLElement, pub const Self = parser.Source;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLSourceElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLSpanElement = struct { pub const HTMLSpanElement = struct {
proto: HTMLElement, pub const Self = parser.Span;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLSpanElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLStyleElement = struct { pub const HTMLStyleElement = struct {
proto: HTMLElement, pub const Self = parser.Style;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLStyleElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTableElement = struct { pub const HTMLTableElement = struct {
proto: HTMLElement, pub const Self = parser.Table;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTableElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTableCaptionElement = struct { pub const HTMLTableCaptionElement = struct {
proto: HTMLElement, pub const Self = parser.TableCaption;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTableCaptionElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTableCellElement = struct { pub const HTMLTableCellElement = struct {
proto: HTMLElement, pub const Self = parser.TableCell;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTableCellElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTableColElement = struct { pub const HTMLTableColElement = struct {
proto: HTMLElement, pub const Self = parser.TableCol;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTableColElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTableRowElement = struct { pub const HTMLTableRowElement = struct {
proto: HTMLElement, pub const Self = parser.TableRow;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTableRowElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTableSectionElement = struct { pub const HTMLTableSectionElement = struct {
proto: HTMLElement, pub const Self = parser.TableSection;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTableSectionElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTemplateElement = struct { pub const HTMLTemplateElement = struct {
proto: HTMLElement, pub const Self = parser.Template;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTemplateElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTextAreaElement = struct { pub const HTMLTextAreaElement = struct {
proto: HTMLElement, pub const Self = parser.TextArea;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTextAreaElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTimeElement = struct { pub const HTMLTimeElement = struct {
proto: HTMLElement, pub const Self = parser.Time;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTimeElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTitleElement = struct { pub const HTMLTitleElement = struct {
proto: HTMLElement, pub const Self = parser.Title;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTitleElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLTrackElement = struct { pub const HTMLTrackElement = struct {
proto: HTMLElement, pub const Self = parser.Track;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLTrackElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLUListElement = struct { pub const HTMLUListElement = struct {
proto: HTMLElement, pub const Self = parser.UList;
pub const prototype = *HTMLElement; pub const prototype = *HTMLElement;
pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLUListElement {
return .{ .proto = HTMLElement.init(elem_base) };
}
}; };
pub const HTMLVideoElement = struct { pub const HTMLVideoElement = struct {
proto: HTMLMediaElement, pub const Self = parser.Video;
pub const prototype = *HTMLElement;
pub const prototype = *HTMLMediaElement; pub const mem_guarantied = true;
pub fn init(elem_base: *parser.Element) HTMLVideoElement {
return .{ .proto = HTMLMediaElement.init(elem_base) };
}
}; };
pub fn ElementToHTMLElementInterface(base: *parser.Element) HTMLElements { pub fn ElementToHTMLElementInterface(elem: *parser.Element) HTMLElements {
const tag = parser.nodeTag(parser.elementNode(base)); const tag = parser.nodeTag(parser.elementNode(elem));
return switch (tag) { return switch (tag) {
.a => .{ .HTMLAnchorElement = HTMLAnchorElement.init(base) }, .a => .{ .HTMLAnchorElement = @ptrCast(*parser.Anchor, elem) },
.area => .{ .HTMLAreaElement = HTMLAreaElement.init(base) }, .area => .{ .HTMLAreaElement = @ptrCast(*parser.Area, elem) },
.audio => .{ .HTMLAudioElement = HTMLAudioElement.init(base) }, .audio => .{ .HTMLAudioElement = @ptrCast(*parser.Audio, elem) },
.br => .{ .HTMLBRElement = HTMLBRElement.init(base) }, .br => .{ .HTMLBRElement = @ptrCast(*parser.BR, elem) },
.base => .{ .HTMLBaseElement = HTMLBaseElement.init(base) }, .base => .{ .HTMLBaseElement = @ptrCast(*parser.Base, elem) },
.body => .{ .HTMLBodyElement = HTMLBodyElement.init(base) }, .body => .{ .HTMLBodyElement = @ptrCast(*parser.Body, elem) },
.button => .{ .HTMLButtonElement = HTMLButtonElement.init(base) }, .button => .{ .HTMLButtonElement = @ptrCast(*parser.Button, elem) },
.canvas => .{ .HTMLCanvasElement = HTMLCanvasElement.init(base) }, .canvas => .{ .HTMLCanvasElement = @ptrCast(*parser.Canvas, elem) },
.dl => .{ .HTMLDListElement = HTMLDListElement.init(base) }, .dl => .{ .HTMLDListElement = @ptrCast(*parser.DList, elem) },
.dialog => .{ .HTMLDialogElement = HTMLDialogElement.init(base) }, .data => .{ .HTMLDataElement = @ptrCast(*parser.Data, elem) },
.data => .{ .HTMLDataElement = HTMLDataElement.init(base) }, .dialog => .{ .HTMLDialogElement = @ptrCast(*parser.Dialog, elem) },
.div => .{ .HTMLDivElement = HTMLDivElement.init(base) }, .div => .{ .HTMLDivElement = @ptrCast(*parser.Div, elem) },
.embed => .{ .HTMLEmbedElement = HTMLEmbedElement.init(base) }, .embed => .{ .HTMLEmbedElement = @ptrCast(*parser.Embed, elem) },
.fieldset => .{ .HTMLFieldSetElement = HTMLFieldSetElement.init(base) }, .fieldset => .{ .HTMLFieldSetElement = @ptrCast(*parser.FieldSet, elem) },
.form => .{ .HTMLFormElement = HTMLFormElement.init(base) }, .form => .{ .HTMLFormElement = @ptrCast(*parser.Form, elem) },
.frameset => .{ .HTMLFrameSetElement = HTMLFrameSetElement.init(base) }, .frameset => .{ .HTMLFrameSetElement = @ptrCast(*parser.FrameSet, elem) },
.hr => .{ .HTMLHRElement = HTMLHRElement.init(base) }, .hr => .{ .HTMLHRElement = @ptrCast(*parser.HR, elem) },
.head => .{ .HTMLHeadElement = HTMLHeadElement.init(base) }, .head => .{ .HTMLHeadElement = @ptrCast(*parser.Head, elem) },
.h1, .h2, .h3, .h4, .h5, .h6 => .{ .HTMLHeadingElement = HTMLHeadingElement.init(base) }, .h1, .h2, .h3, .h4, .h5, .h6 => .{ .HTMLHeadingElement = @ptrCast(*parser.Heading, elem) },
.html => .{ .HTMLHtmlElement = HTMLHtmlElement.init(base) }, .html => .{ .HTMLHtmlElement = @ptrCast(*parser.Html, elem) },
.iframe => .{ .HTMLIFrameElement = HTMLIFrameElement.init(base) }, .iframe => .{ .HTMLIFrameElement = @ptrCast(*parser.IFrame, elem) },
.img => .{ .HTMLImageElement = HTMLImageElement.init(base) }, .img => .{ .HTMLImageElement = @ptrCast(*parser.Image, elem) },
.input => .{ .HTMLInputElement = HTMLInputElement.init(base) }, .input => .{ .HTMLInputElement = @ptrCast(*parser.Input, elem) },
.li => .{ .HTMLLIElement = HTMLLIElement.init(base) }, .li => .{ .HTMLLIElement = @ptrCast(*parser.LI, elem) },
.label => .{ .HTMLLabelElement = HTMLLabelElement.init(base) }, .label => .{ .HTMLLabelElement = @ptrCast(*parser.Label, elem) },
.legend => .{ .HTMLLegendElement = HTMLLegendElement.init(base) }, .legend => .{ .HTMLLegendElement = @ptrCast(*parser.Legend, elem) },
.link => .{ .HTMLLinkElement = HTMLLinkElement.init(base) }, .link => .{ .HTMLLinkElement = @ptrCast(*parser.Link, elem) },
.map => .{ .HTMLMapElement = HTMLMapElement.init(base) }, .map => .{ .HTMLMapElement = @ptrCast(*parser.Map, elem) },
.meta => .{ .HTMLMetaElement = HTMLMetaElement.init(base) }, .meta => .{ .HTMLMetaElement = @ptrCast(*parser.Meta, elem) },
.meter => .{ .HTMLMeterElement = HTMLMeterElement.init(base) }, .meter => .{ .HTMLMeterElement = @ptrCast(*parser.Meter, elem) },
.ins, .del => .{ .HTMLModElement = HTMLModElement.init(base) }, .ins, .del => .{ .HTMLModElement = @ptrCast(*parser.Mod, elem) },
.ol => .{ .HTMLOListElement = HTMLOListElement.init(base) }, .ol => .{ .HTMLOListElement = @ptrCast(*parser.OList, elem) },
.object => .{ .HTMLObjectElement = HTMLObjectElement.init(base) }, .object => .{ .HTMLObjectElement = @ptrCast(*parser.Object, elem) },
.optgroup => .{ .HTMLOptGroupElement = HTMLOptGroupElement.init(base) }, .optgroup => .{ .HTMLOptGroupElement = @ptrCast(*parser.OptGroup, elem) },
.option => .{ .HTMLOptionElement = HTMLOptionElement.init(base) }, .option => .{ .HTMLOptionElement = @ptrCast(*parser.Option, elem) },
.output => .{ .HTMLOutputElement = HTMLOutputElement.init(base) }, .output => .{ .HTMLOutputElement = @ptrCast(*parser.Output, elem) },
.p => .{ .HTMLParagraphElement = HTMLParagraphElement.init(base) }, .p => .{ .HTMLParagraphElement = @ptrCast(*parser.Paragraph, elem) },
.picture => .{ .HTMLPictureElement = HTMLPictureElement.init(base) }, .picture => .{ .HTMLPictureElement = @ptrCast(*parser.Picture, elem) },
.pre => .{ .HTMLPreElement = HTMLPreElement.init(base) }, .pre => .{ .HTMLPreElement = @ptrCast(*parser.Pre, elem) },
.progress => .{ .HTMLProgressElement = HTMLProgressElement.init(base) }, .progress => .{ .HTMLProgressElement = @ptrCast(*parser.Progress, elem) },
.blockquote, .q => .{ .HTMLQuoteElement = HTMLQuoteElement.init(base) }, .blockquote, .q => .{ .HTMLQuoteElement = @ptrCast(*parser.Quote, elem) },
.script => .{ .HTMLScriptElement = HTMLScriptElement.init(base) }, .script => .{ .HTMLScriptElement = @ptrCast(*parser.Script, elem) },
.select => .{ .HTMLSelectElement = HTMLSelectElement.init(base) }, .select => .{ .HTMLSelectElement = @ptrCast(*parser.Select, elem) },
.source => .{ .HTMLSourceElement = HTMLSourceElement.init(base) }, .source => .{ .HTMLSourceElement = @ptrCast(*parser.Source, elem) },
.span => .{ .HTMLSpanElement = HTMLSpanElement.init(base) }, .span => .{ .HTMLSpanElement = @ptrCast(*parser.Span, elem) },
.style => .{ .HTMLStyleElement = HTMLStyleElement.init(base) }, .style => .{ .HTMLStyleElement = @ptrCast(*parser.Style, elem) },
.table => .{ .HTMLTableElement = HTMLTableElement.init(base) }, .table => .{ .HTMLTableElement = @ptrCast(*parser.Table, elem) },
.caption => .{ .HTMLTableCaptionElement = HTMLTableCaptionElement.init(base) }, .caption => .{ .HTMLTableCaptionElement = @ptrCast(*parser.TableCaption, elem) },
.th, .td => .{ .HTMLTableCellElement = HTMLTableCellElement.init(base) }, .th, .td => .{ .HTMLTableCellElement = @ptrCast(*parser.TableCell, elem) },
.col => .{ .HTMLTableColElement = HTMLTableColElement.init(base) }, .col => .{ .HTMLTableColElement = @ptrCast(*parser.TableCol, elem) },
.tr => .{ .HTMLTableRowElement = HTMLTableRowElement.init(base) }, .tr => .{ .HTMLTableRowElement = @ptrCast(*parser.TableRow, elem) },
.thead, .tbody, .tfoot => .{ .HTMLTableSectionElement = HTMLTableSectionElement.init(base) }, .thead, .tbody, .tfoot => .{ .HTMLTableSectionElement = @ptrCast(*parser.TableSection, elem) },
.template => .{ .HTMLTemplateElement = HTMLTemplateElement.init(base) }, .template => .{ .HTMLTemplateElement = @ptrCast(*parser.Template, elem) },
.textarea => .{ .HTMLTextAreaElement = HTMLTextAreaElement.init(base) }, .textarea => .{ .HTMLTextAreaElement = @ptrCast(*parser.TextArea, elem) },
.time => .{ .HTMLTimeElement = HTMLTimeElement.init(base) }, .time => .{ .HTMLTimeElement = @ptrCast(*parser.Time, elem) },
.title => .{ .HTMLTitleElement = HTMLTitleElement.init(base) }, .title => .{ .HTMLTitleElement = @ptrCast(*parser.Title, elem) },
.track => .{ .HTMLTrackElement = HTMLTrackElement.init(base) }, .track => .{ .HTMLTrackElement = @ptrCast(*parser.Track, elem) },
.ul => .{ .HTMLUListElement = HTMLUListElement.init(base) }, .ul => .{ .HTMLUListElement = @ptrCast(*parser.UList, elem) },
.video => .{ .HTMLVideoElement = HTMLVideoElement.init(base) }, .video => .{ .HTMLVideoElement = @ptrCast(*parser.Video, elem) },
.undef => .{ .HTMLUnknownElement = HTMLUnknownElement.init(base) }, .undef => .{ .HTMLUnknownElement = @ptrCast(*parser.Unknown, elem) },
}; };
} }

View File

@@ -125,7 +125,6 @@ pub const Tag = enum(u8) {
fn elementName(comptime tag: Tag) []const u8 { fn elementName(comptime tag: Tag) []const u8 {
return switch (tag) { return switch (tag) {
.area, .audio, .base, .body, .button, .br, .canvas, .dialog, .data, .div, .embed, .form, .head, .html, .hr, .input, .label, .li, .legend, .link, .map, .meta, .meter, .object, .option, .output, .picture, .pre, .progress, .script, .select, .source, .span, .style, .table, .template, .time, .title, .track, .video => upperName(@tagName(tag)),
.a => "Anchor", .a => "Anchor",
.dl => "DList", .dl => "DList",
.fieldset => "FieldSet", .fieldset => "FieldSet",
@@ -146,6 +145,7 @@ pub const Tag = enum(u8) {
.textarea => "TextArea", .textarea => "TextArea",
.ul => "UList", .ul => "UList",
.undef => "Unknown", .undef => "Unknown",
else => upperName(@tagName(tag)),
}; };
} }
}; };
@@ -260,8 +260,8 @@ pub inline fn documentHTMLToDocument(document_html: *DocumentHTML) *Document {
return &document_html.dom_document; return &document_html.dom_document;
} }
pub inline fn documentHTMLBody(document_html: *DocumentHTML) *Element { pub inline fn documentHTMLBody(document_html: *DocumentHTML) *Body {
return c.lxb_dom_interface_element(document_html.body); return document_html.body;
} }
// Document // Document
@@ -288,6 +288,72 @@ pub inline fn collectionElement(collection: *Collection, index: usize) *Element
return c.lxb_dom_collection_element(collection, index); return c.lxb_dom_collection_element(collection, index);
} }
// HTML Elements
pub const HTMLElement = c.lxb_html_element_t;
pub const MediaElement = c.lxb_html_media_element_t;
pub const Unknown = c.lxb_html_unknown_element_t;
pub const Anchor = c.lxb_html_anchor_element_t;
pub const Area = c.lxb_html_area_element_t;
pub const Audio = c.lxb_html_audio_element_t;
pub const BR = c.lxb_html_br_element_t;
pub const Base = c.lxb_html_base_element_t;
pub const Body = c.lxb_html_body_element_t;
pub const Button = c.lxb_html_button_element_t;
pub const Canvas = c.lxb_html_canvas_element_t;
pub const DList = c.lxb_html_d_list_element_t;
pub const Data = c.lxb_html_data_element_t;
pub const Dialog = c.lxb_html_dialog_element_t;
pub const Div = c.lxb_html_div_element_t;
pub const Embed = c.lxb_html_embed_element_t;
pub const FieldSet = c.lxb_html_field_set_element_t;
pub const Form = c.lxb_html_form_element_t;
pub const FrameSet = c.lxb_html_frame_set_element_t;
pub const HR = c.lxb_html_hr_element_t;
pub const Head = c.lxb_html_head_element_t;
pub const Heading = c.lxb_html_heading_element_t;
pub const Html = c.lxb_html_html_element_t;
pub const IFrame = c.lxb_html_iframe_element_t;
pub const Image = c.lxb_html_image_element_t;
pub const Input = c.lxb_html_input_element_t;
pub const LI = c.lxb_html_li_element_t;
pub const Label = c.lxb_html_label_element_t;
pub const Legend = c.lxb_html_legend_element_t;
pub const Link = c.lxb_html_link_element_t;
pub const Map = c.lxb_html_map_element_t;
pub const Meta = c.lxb_html_meta_element_t;
pub const Meter = c.lxb_html_meter_element_t;
pub const Mod = c.lxb_html_mod_element_t;
pub const OList = c.lxb_html_o_list_element_t;
pub const Object = c.lxb_html_object_element_t;
pub const OptGroup = c.lxb_html_opt_group_element_t;
pub const Option = c.lxb_html_option_element_t;
pub const Output = c.lxb_html_output_element_t;
pub const Paragraph = c.lxb_html_paragraph_element_t;
pub const Picture = c.lxb_html_picture_element_t;
pub const Pre = c.lxb_html_pre_element_t;
pub const Progress = c.lxb_html_progress_element_t;
pub const Quote = c.lxb_html_quote_element_t;
pub const Script = c.lxb_html_script_element_t;
pub const Select = c.lxb_html_select_element_t;
pub const Source = c.lxb_html_source_element_t;
pub const Span = c.lxb_html_span_element_t;
pub const Style = c.lxb_html_style_element_t;
pub const Table = c.lxb_html_table_element_t;
pub const TableCaption = c.lxb_html_table_caption_element_t;
pub const TableCell = c.lxb_html_table_cell_element_t;
pub const TableCol = c.lxb_html_table_col_element_t;
pub const TableRow = c.lxb_html_table_row_element_t;
pub const TableSection = c.lxb_html_table_section_element_t;
pub const Template = c.lxb_html_template_element_t;
pub const TextArea = c.lxb_html_text_area_element_t;
pub const Time = c.lxb_html_time_element_t;
pub const Title = c.lxb_html_title_element_t;
pub const Track = c.lxb_html_track_element_t;
pub const UList = c.lxb_html_u_list_element_t;
pub const Video = c.lxb_html_video_element_t;
// Base // Base
pub const Action = c.lexbor_action_t; pub const Action = c.lexbor_action_t;

View File

@@ -3,12 +3,13 @@ const std = @import("std");
const jsruntime = @import("jsruntime"); const jsruntime = @import("jsruntime");
const generate = @import("generate.zig"); const generate = @import("generate.zig");
const parser = @import("parser.zig");
const DOM = @import("dom.zig"); const DOM = @import("dom.zig");
const testExecFn = @import("html/document.zig").testExecFn; const testExecFn = @import("html/document.zig").testExecFn;
const html_test = @import("html_test.zig").html; const html_test = @import("html_test.zig").html;
var doc: DOM.HTMLDocument = undefined; var doc: *parser.DocumentHTML = undefined;
fn testsExecFn( fn testsExecFn(
alloc: std.mem.Allocator, alloc: std.mem.Allocator,
@@ -37,9 +38,9 @@ test {
const apis = jsruntime.compile(DOM.Interfaces); const apis = jsruntime.compile(DOM.Interfaces);
// document // document
doc = DOM.HTMLDocument.init(); doc = parser.documentHTMLInit();
defer doc.deinit(); defer parser.documentHTMLDeinit(doc);
try doc.parse(html_test); try parser.documentHTMLParse(doc, html_test);
// create JS vm // create JS vm
const vm = jsruntime.VM.init(); const vm = jsruntime.VM.init();