@@ -26,6 +26,8 @@ const c = @cImport({
2626 @cInclude ("events/event.h" );
2727 @cInclude ("events/mouse_event.h" );
2828 @cInclude ("utils/validate.h" );
29+ @cInclude ("html/html_element.h" );
30+ @cInclude ("html/html_document.h" );
2931});
3032
3133const mimalloc = @import ("mimalloc.zig" );
@@ -550,7 +552,7 @@ pub fn mutationEventRelatedNode(evt: *MutationEvent) !?*Node {
550552 const err = c ._dom_mutation_event_get_related_node (evt , & n );
551553 try DOMErr (err );
552554 if (n == null ) return null ;
553- return @as (* Node , @ptrCast (n ));
555+ return @as (* Node , @alignCast ( @ ptrCast (n ) ));
554556}
555557
556558// EventListener
@@ -565,7 +567,7 @@ fn eventListenerGetData(lst: *EventListener) ?*anyopaque {
565567pub const EventTarget = c .dom_event_target ;
566568
567569pub fn eventTargetToNode (et : * EventTarget ) * Node {
568- return @as (* Node , @ptrCast (et ));
570+ return @as (* Node , @alignCast ( @ ptrCast (et ) ));
569571}
570572
571573fn eventTargetVtable (et : * EventTarget ) c.dom_event_target_vtable {
@@ -894,7 +896,7 @@ pub fn nodeListItem(nodeList: *NodeList, index: u32) !?*Node {
894896 const err = c ._dom_nodelist_item (nodeList , index , & n );
895897 try DOMErr (err );
896898 if (n == null ) return null ;
897- return @as (* Node , @ptrCast (n ));
899+ return @as (* Node , @alignCast ( @ ptrCast (n ) ));
898900}
899901
900902// NodeExternal is the libdom public representation of a Node.
@@ -1323,7 +1325,7 @@ fn characterDataVtable(data: *CharacterData) c.dom_characterdata_vtable {
13231325}
13241326
13251327pub inline fn characterDataToNode (cdata : * CharacterData ) * Node {
1326- return @as (* Node , @ptrCast (cdata ));
1328+ return @as (* Node , @alignCast ( @ ptrCast (cdata ) ));
13271329}
13281330
13291331pub fn characterDataData (cdata : * CharacterData ) ! []const u8 {
@@ -1408,7 +1410,7 @@ pub const ProcessingInstruction = c.dom_processing_instruction;
14081410
14091411// processingInstructionToNode is an helper to convert an ProcessingInstruction to a node.
14101412pub inline fn processingInstructionToNode (pi : * ProcessingInstruction ) * Node {
1411- return @as (* Node , @ptrCast (pi ));
1413+ return @as (* Node , @alignCast ( @ ptrCast (pi ) ));
14121414}
14131415
14141416pub fn processInstructionCopy (pi : * ProcessingInstruction ) ! * ProcessingInstruction {
@@ -1463,7 +1465,7 @@ pub fn attributeGetOwnerElement(a: *Attribute) !?*Element {
14631465
14641466// attributeToNode is an helper to convert an attribute to a node.
14651467pub inline fn attributeToNode (a : * Attribute ) * Node {
1466- return @as (* Node , @ptrCast (a ));
1468+ return @as (* Node , @alignCast ( @ ptrCast (a ) ));
14671469}
14681470
14691471// Element
@@ -1601,7 +1603,7 @@ pub fn elementHasClass(elem: *Element, class: []const u8) !bool {
16011603
16021604// elementToNode is an helper to convert an element to a node.
16031605pub inline fn elementToNode (e : * Element ) * Node {
1604- return @as (* Node , @ptrCast (e ));
1606+ return @as (* Node , @alignCast ( @ ptrCast (e ) ));
16051607}
16061608
16071609// TokenList
@@ -1685,14 +1687,14 @@ pub fn elementHTMLGetTagType(elem_html: *ElementHTML) !Tag {
16851687
16861688// scriptToElt is an helper to convert an script to an element.
16871689pub inline fn scriptToElt (s : * Script ) * Element {
1688- return @as (* Element , @ptrCast (s ));
1690+ return @as (* Element , @alignCast ( @ ptrCast (s ) ));
16891691}
16901692
16911693// HTMLAnchorElement
16921694
16931695// anchorToNode is an helper to convert an anchor to a node.
16941696pub inline fn anchorToNode (a : * Anchor ) * Node {
1695- return @as (* Node , @ptrCast (a ));
1697+ return @as (* Node , @alignCast ( @ ptrCast (a ) ));
16961698}
16971699
16981700pub fn anchorGetTarget (a : * Anchor ) ! []const u8 {
@@ -1837,7 +1839,7 @@ pub const OptionCollection = c.dom_html_options_collection;
18371839pub const DocumentFragment = c .dom_document_fragment ;
18381840
18391841pub inline fn documentFragmentToNode (doc : * DocumentFragment ) * Node {
1840- return @as (* Node , @ptrCast (doc ));
1842+ return @as (* Node , @alignCast ( @ ptrCast (doc ) ));
18411843}
18421844
18431845pub fn documentFragmentBodyChildren (doc : * DocumentFragment ) ! ? * NodeList {
@@ -1947,7 +1949,7 @@ pub inline fn domImplementationCreateHTMLDocument(title: ?[]const u8) !*Document
19471949 if (title ) | t | {
19481950 const htitle = try documentCreateElement (doc , "title" );
19491951 const txt = try documentCreateTextNode (doc , t );
1950- _ = try nodeAppendChild (elementToNode (htitle ), @as (* Node , @ptrCast (txt )));
1952+ _ = try nodeAppendChild (elementToNode (htitle ), @as (* Node , @alignCast ( @ ptrCast (txt ) )));
19511953 _ = try nodeAppendChild (elementToNode (head ), elementToNode (htitle ));
19521954 }
19531955
@@ -1965,7 +1967,7 @@ fn documentVtable(doc: *Document) c.dom_document_vtable {
19651967}
19661968
19671969pub inline fn documentToNode (doc : * Document ) * Node {
1968- return @as (* Node , @ptrCast (doc ));
1970+ return @as (* Node , @alignCast ( @ ptrCast (doc ) ));
19691971}
19701972
19711973pub inline fn documentGetElementById (doc : * Document , id : []const u8 ) ! ? * Element {
@@ -2103,15 +2105,15 @@ pub inline fn documentImportNode(doc: *Document, node: *Node, deep: bool) !*Node
21032105 const nodeext = toNodeExternal (Node , node );
21042106 const err = documentVtable (doc ).dom_document_import_node .? (doc , nodeext , deep , & res );
21052107 try DOMErr (err );
2106- return @as (* Node , @ptrCast (res ));
2108+ return @as (* Node , @alignCast ( @ ptrCast (res ) ));
21072109}
21082110
21092111pub inline fn documentAdoptNode (doc : * Document , node : * Node ) ! * Node {
21102112 var res : NodeExternal = undefined ;
21112113 const nodeext = toNodeExternal (Node , node );
21122114 const err = documentVtable (doc ).dom_document_adopt_node .? (doc , nodeext , & res );
21132115 try DOMErr (err );
2114- return @as (* Node , @ptrCast (res ));
2116+ return @as (* Node , @alignCast ( @ ptrCast (res ) ));
21152117}
21162118
21172119pub inline fn documentCreateAttribute (doc : * Document , name : []const u8 ) ! * Attribute {
@@ -2146,7 +2148,7 @@ pub const DocumentHTML = c.dom_html_document;
21462148
21472149// documentHTMLToNode is an helper to convert a documentHTML to an node.
21482150pub inline fn documentHTMLToNode (doc : * DocumentHTML ) * Node {
2149- return @as (* Node , @ptrCast (doc ));
2151+ return @as (* Node , @alignCast ( @ ptrCast (doc ) ));
21502152}
21512153
21522154fn documentHTMLVtable (doc_html : * DocumentHTML ) c.dom_html_document_vtable {
@@ -2291,7 +2293,7 @@ pub inline fn documentHTMLBody(doc_html: *DocumentHTML) !?*Body {
22912293}
22922294
22932295pub inline fn bodyToElement (body : * Body ) * Element {
2294- return @as (* Element , @ptrCast (body ));
2296+ return @as (* Element , @alignCast ( @ ptrCast (body ) ));
22952297}
22962298
22972299pub inline fn documentHTMLSetBody (doc_html : * DocumentHTML , elt : ? * ElementHTML ) ! void {
@@ -2330,7 +2332,7 @@ pub inline fn documentHTMLSetTitle(doc: *DocumentHTML, v: []const u8) !void {
23302332
23312333pub fn documentHTMLSetCurrentScript (doc : * DocumentHTML , script : ? * Script ) ! void {
23322334 var s : ? * ElementHTML = null ;
2333- if (script != null ) s = @ptrCast (script .? );
2335+ if (script != null ) s = @alignCast ( @ ptrCast (script .? ) );
23342336 const err = documentHTMLVtable (doc ).set_current_script .? (doc , s );
23352337 try DOMErr (err );
23362338}
@@ -2759,7 +2761,7 @@ pub fn inputSetType(input: *Input, type_: []const u8) !void {
27592761 }
27602762 }
27612763 const new_type = if (found ) type_ else "text" ;
2762- try elementSetAttribute (@ptrCast (input ), "type" , new_type );
2764+ try elementSetAttribute (@alignCast ( @ ptrCast (input ) ), "type" , new_type );
27632765}
27642766
27652767pub fn inputGetValue (input : * Input ) ! []const u8 {
0 commit comments