events: add EventTargetBase

EventTargetBase implements event target vtable for pure zig struct
This commit is contained in:
Pierre Tachoire
2024-01-17 18:17:40 +01:00
parent 85a8decffc
commit 9050f2586b
3 changed files with 45 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
const std = @import("std");
const parser = @import("../netsurf.zig");
const c = @cImport({
@cInclude("events/event_target.h");
});
const EventTarget = @import("../dom/event_target.zig").EventTarget;
@@ -10,6 +13,9 @@ pub const Window = struct {
pub const prototype = *EventTarget;
pub const mem_guarantied = true;
// Extend libdom event target for pure zig struct.
base: parser.EventTargetTBase = parser.EventTargetTBase{},
document: ?*parser.Document = null,
target: []const u8,
@@ -42,6 +48,4 @@ pub const Window = struct {
pub fn get_name(self: *Window) []const u8 {
return self.target;
}
// TODO we need to re-implement EventTarget interface.
};